refactored AppMode definition

This commit is contained in:
Thomas Jentzsch 2021-10-27 10:23:41 +02:00
parent ac8acce229
commit 93ef03f4d8
13 changed files with 30 additions and 30 deletions

View File

@ -285,7 +285,7 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd,
getDynamicBounds(w, h); getDynamicBounds(w, h);
myOptions = make_unique<OptionsDialog>(instance(), parent(), this, w, h, myOptions = make_unique<OptionsDialog>(instance(), parent(), this, w, h,
OptionsMenu::AppMode::debugger); AppMode::debugger);
} }
myOptions->open(); myOptions->open();

View File

@ -44,6 +44,9 @@ class Dialog : public GuiObject
friend class DialogContainer; friend class DialogContainer;
public: public:
// Current Stella mode
enum class AppMode { launcher, emulator, debugger };
using RenderCallback = std::function<void()>; using RenderCallback = std::function<void()>;
Dialog(OSystem& instance, DialogContainer& parent, Dialog(OSystem& instance, DialogContainer& parent,

View File

@ -98,7 +98,7 @@ static constexpr std::array<uInt32, BUTTON_GFX_H_LARGE> NEXT_GFX_LARGE = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent, HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h, int max_w, int max_h,
OptionsMenu::AppMode mode) AppMode mode)
: Dialog(osystem, parent, osystem.frameBuffer().font(), "High Scores"), : Dialog(osystem, parent, osystem.frameBuffer().font(), "High Scores"),
_max_w{max_w}, _max_w{max_w},
_max_h{max_h}, _max_h{max_h},
@ -219,7 +219,7 @@ HighScoresDialog::~HighScoresDialog()
void HighScoresDialog::loadConfig() void HighScoresDialog::loadConfig()
{ {
// Enable blending (only once is necessary) // Enable blending (only once is necessary)
if (myMode == OptionsMenu::AppMode::emulator && !surface().attributes().blending) if (myMode == AppMode::emulator && !surface().attributes().blending)
{ {
surface().attributes().blending = true; surface().attributes().blending = true;
surface().attributes().blendalpha = 90; surface().attributes().blendalpha = 90;
@ -314,7 +314,7 @@ void HighScoresDialog::handleCommand(CommandSender* sender, int cmd, int data, i
saveConfig(); saveConfig();
[[fallthrough]]; [[fallthrough]];
case kCloseCmd: case kCloseCmd:
if(myMode != OptionsMenu::AppMode::emulator) if(myMode != AppMode::emulator)
close(); close();
else else
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();

View File

@ -47,7 +47,7 @@ class HighScoresDialog : public Dialog
static constexpr uInt32 NUM_RANKS = 10; static constexpr uInt32 NUM_RANKS = 10;
HighScoresDialog(OSystem& osystem, DialogContainer& parent, HighScoresDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h, OptionsMenu::AppMode mode); int max_w, int max_h, AppMode mode);
~HighScoresDialog() override; ~HighScoresDialog() override;
protected: protected:
@ -110,7 +110,7 @@ class HighScoresDialog : public Dialog
StaticTextWidget* myMD5Widget{nullptr}; StaticTextWidget* myMD5Widget{nullptr};
StaticTextWidget* myCheckSumWidget{nullptr}; StaticTextWidget* myCheckSumWidget{nullptr};
OptionsMenu::AppMode myMode{OptionsMenu::AppMode::emulator}; AppMode myMode{AppMode::emulator};
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -38,7 +38,7 @@ Dialog* HighScoresMenu::baseDialog()
if (myHighScoresDialog == nullptr) if (myHighScoresDialog == nullptr)
myHighScoresDialog = new HighScoresDialog(myOSystem, *this, myHighScoresDialog = new HighScoresDialog(myOSystem, *this,
FBMinimum::Width, FBMinimum::Height, FBMinimum::Width, FBMinimum::Height,
OptionsMenu::AppMode::emulator); Dialog::AppMode::emulator);
return myHighScoresDialog; return myHighScoresDialog;
} }

View File

@ -926,10 +926,10 @@ void LauncherDialog::openSettings()
// Create an options dialog, similar to the in-game one // Create an options dialog, similar to the in-game one
if (instance().settings().getBool("basic_settings")) if (instance().settings().getBool("basic_settings"))
myDialog = make_unique<StellaSettingsDialog>(instance(), parent(), myDialog = make_unique<StellaSettingsDialog>(instance(), parent(),
_w, _h, OptionsMenu::AppMode::launcher); _w, _h, AppMode::launcher);
else else
myDialog = make_unique<OptionsDialog>(instance(), parent(), this, _w, _h, myDialog = make_unique<OptionsDialog>(instance(), parent(), this, _w, _h,
OptionsMenu::AppMode::launcher); AppMode::launcher);
myDialog->open(); myDialog->open();
} }
@ -938,7 +938,7 @@ void LauncherDialog::openHighScores()
{ {
// Create an high scores dialog, similar to the in-game one // Create an high scores dialog, similar to the in-game one
myDialog = make_unique<HighScoresDialog>(instance(), parent(), _w, _h, myDialog = make_unique<HighScoresDialog>(instance(), parent(), _w, _h,
OptionsMenu::AppMode::launcher); AppMode::launcher);
myDialog->open(); myDialog->open();
} }

View File

@ -321,14 +321,14 @@ void MinUICommandDialog::openSettings()
if (instance().settings().getBool("basic_settings")) if (instance().settings().getBool("basic_settings"))
{ {
myDialog = make_unique<StellaSettingsDialog>(instance(), parent(), myDialog = make_unique<StellaSettingsDialog>(instance(), parent(),
1280, 720, OptionsMenu::AppMode::launcher); 1280, 720, AppMode::launcher);
myDialog->open(); myDialog->open();
} }
else else
{ {
myDialog = make_unique<OptionsDialog>(instance(), parent(), this, myDialog = make_unique<OptionsDialog>(instance(), parent(), this,
FBMinimum::Width, FBMinimum::Height, FBMinimum::Width, FBMinimum::Height,
OptionsMenu::AppMode::launcher); AppMode::launcher);
myDialog->open(); myDialog->open();
} }
} }
@ -337,6 +337,6 @@ void MinUICommandDialog::openSettings()
void MinUICommandDialog::openHighscores() void MinUICommandDialog::openHighscores()
{ {
myDialog = make_unique<HighScoresDialog>(instance(), parent(), myDialog = make_unique<HighScoresDialog>(instance(), parent(),
1280, 720, OptionsMenu::AppMode::emulator); 1280, 720, AppMode::emulator);
myDialog->open(); myDialog->open();
} }

View File

@ -47,13 +47,13 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
GuiObject* boss, int max_w, int max_h, OptionsMenu::AppMode mode) GuiObject* boss, int max_w, int max_h, AppMode mode)
: Dialog(osystem, parent, osystem.frameBuffer().font(), "Options"), : Dialog(osystem, parent, osystem.frameBuffer().font(), "Options"),
myBoss{boss}, myBoss{boss},
myMode{mode} myMode{mode}
{ {
// do not show basic settings options in debugger // do not show basic settings options in debugger
bool minSettings = osystem.settings().getBool("minimal_ui") && mode != OptionsMenu::AppMode::debugger; bool minSettings = osystem.settings().getBool("minimal_ui") && mode != AppMode::debugger;
const int buttonHeight = Dialog::buttonHeight(), const int buttonHeight = Dialog::buttonHeight(),
VBORDER = Dialog::vBorder(), VBORDER = Dialog::vBorder(),
HBORDER = Dialog::hBorder(), HBORDER = Dialog::hBorder(),
@ -138,7 +138,7 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
addToFocusList(wid); addToFocusList(wid);
// Certain buttons are disabled depending on mode // Certain buttons are disabled depending on mode
if(myMode == OptionsMenu::AppMode::launcher) if(myMode == AppMode::launcher)
{ {
myCheatCodeButton->clearFlags(Widget::FLAG_ENABLED); myCheatCodeButton->clearFlags(Widget::FLAG_ENABLED);
} }
@ -186,7 +186,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
case kBasSetCmd: case kBasSetCmd:
// enable basic settings // enable basic settings
instance().settings().setValue("basic_settings", true); instance().settings().setValue("basic_settings", true);
if (myMode != OptionsMenu::AppMode::emulator) if (myMode != AppMode::emulator)
close(); close();
else else
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
@ -297,7 +297,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kExitCmd: case kExitCmd:
if(myMode != OptionsMenu::AppMode::emulator) if(myMode != AppMode::emulator)
close(); close();
else else
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();

View File

@ -30,7 +30,7 @@ class OptionsDialog : public Dialog
{ {
public: public:
OptionsDialog(OSystem& osystem, DialogContainer& parent, GuiObject* boss, OptionsDialog(OSystem& osystem, DialogContainer& parent, GuiObject* boss,
int max_w, int max_h, OptionsMenu::AppMode mode); int max_w, int max_h, AppMode mode);
~OptionsDialog() override; ~OptionsDialog() override;
private: private:
@ -46,7 +46,7 @@ class OptionsDialog : public Dialog
GuiObject* myBoss{nullptr}; GuiObject* myBoss{nullptr};
// Indicates if this dialog is used for global (vs. in-game) settings // Indicates if this dialog is used for global (vs. in-game) settings
OptionsMenu::AppMode myMode{OptionsMenu::AppMode::emulator}; AppMode myMode{AppMode::emulator};
enum { enum {
kBasSetCmd = 'BAST', kBasSetCmd = 'BAST',

View File

@ -44,14 +44,14 @@ Dialog* OptionsMenu::baseDialog()
{ {
if (stellaSettingDialog == nullptr) if (stellaSettingDialog == nullptr)
stellaSettingDialog = new StellaSettingsDialog(myOSystem, *this, stellaSettingDialog = new StellaSettingsDialog(myOSystem, *this,
1280, 720, AppMode::emulator); 1280, 720, Dialog::AppMode::emulator);
return stellaSettingDialog; return stellaSettingDialog;
} }
else else
{ {
if (optionsDialog == nullptr) if (optionsDialog == nullptr)
optionsDialog = new OptionsDialog(myOSystem, *this, nullptr, optionsDialog = new OptionsDialog(myOSystem, *this, nullptr,
FBMinimum::Width, FBMinimum::Height, AppMode::emulator); FBMinimum::Width, FBMinimum::Height, Dialog::AppMode::emulator);
return optionsDialog; return optionsDialog;
} }
} }

View File

@ -32,9 +32,6 @@ class OptionsDialog;
class OptionsMenu : public DialogContainer class OptionsMenu : public DialogContainer
{ {
public: public:
// Current Stella mode
enum class AppMode { launcher, emulator, debugger };
/** /**
Create a new menu stack Create a new menu stack
*/ */

View File

@ -30,7 +30,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& parent, StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h, OptionsMenu::AppMode mode) int max_w, int max_h, AppMode mode)
: Dialog(osystem, parent, osystem.frameBuffer().font(), "Basic settings"), : Dialog(osystem, parent, osystem.frameBuffer().font(), "Basic settings"),
myMode{mode} myMode{mode}
{ {
@ -351,7 +351,7 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
saveConfig(); saveConfig();
[[fallthrough]]; [[fallthrough]];
case GuiObject::kCloseCmd: case GuiObject::kCloseCmd:
if (myMode != OptionsMenu::AppMode::emulator) if (myMode != AppMode::emulator)
close(); close();
else else
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
@ -363,7 +363,7 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
case kConfirmSwitchCmd: case kConfirmSwitchCmd:
instance().settings().setValue("basic_settings", false); instance().settings().setValue("basic_settings", false);
if (myMode != OptionsMenu::AppMode::emulator) if (myMode != AppMode::emulator)
close(); close();
else else
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();

View File

@ -39,7 +39,7 @@ class StellaSettingsDialog : public Dialog
{ {
public: public:
StellaSettingsDialog(OSystem& osystem, DialogContainer& parent, StellaSettingsDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h, OptionsMenu::AppMode mode); int max_w, int max_h, AppMode mode);
~StellaSettingsDialog() override; ~StellaSettingsDialog() override;
private: private:
@ -103,7 +103,7 @@ class StellaSettingsDialog : public Dialog
#endif #endif
// Indicates if this dialog is used for global (vs. in-game) settings // Indicates if this dialog is used for global (vs. in-game) settings
OptionsMenu::AppMode myMode{OptionsMenu::AppMode::emulator}; AppMode myMode{AppMode::emulator};
enum { enum {
kAdvancedSettings = 'SSad', kAdvancedSettings = 'SSad',