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);
myOptions = make_unique<OptionsDialog>(instance(), parent(), this, w, h,
OptionsMenu::AppMode::debugger);
AppMode::debugger);
}
myOptions->open();

View File

@ -44,6 +44,9 @@ class Dialog : public GuiObject
friend class DialogContainer;
public:
// Current Stella mode
enum class AppMode { launcher, emulator, debugger };
using RenderCallback = std::function<void()>;
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,
int max_w, int max_h,
OptionsMenu::AppMode mode)
AppMode mode)
: Dialog(osystem, parent, osystem.frameBuffer().font(), "High Scores"),
_max_w{max_w},
_max_h{max_h},
@ -219,7 +219,7 @@ HighScoresDialog::~HighScoresDialog()
void HighScoresDialog::loadConfig()
{
// 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().blendalpha = 90;
@ -314,7 +314,7 @@ void HighScoresDialog::handleCommand(CommandSender* sender, int cmd, int data, i
saveConfig();
[[fallthrough]];
case kCloseCmd:
if(myMode != OptionsMenu::AppMode::emulator)
if(myMode != AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();

View File

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

View File

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

View File

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

View File

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

View File

@ -47,13 +47,13 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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"),
myBoss{boss},
myMode{mode}
{
// 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(),
VBORDER = Dialog::vBorder(),
HBORDER = Dialog::hBorder(),
@ -138,7 +138,7 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
addToFocusList(wid);
// Certain buttons are disabled depending on mode
if(myMode == OptionsMenu::AppMode::launcher)
if(myMode == AppMode::launcher)
{
myCheatCodeButton->clearFlags(Widget::FLAG_ENABLED);
}
@ -186,7 +186,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
case kBasSetCmd:
// enable basic settings
instance().settings().setValue("basic_settings", true);
if (myMode != OptionsMenu::AppMode::emulator)
if (myMode != AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();
@ -297,7 +297,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kExitCmd:
if(myMode != OptionsMenu::AppMode::emulator)
if(myMode != AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();

View File

@ -30,7 +30,7 @@ class OptionsDialog : public Dialog
{
public:
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;
private:
@ -46,7 +46,7 @@ class OptionsDialog : public Dialog
GuiObject* myBoss{nullptr};
// Indicates if this dialog is used for global (vs. in-game) settings
OptionsMenu::AppMode myMode{OptionsMenu::AppMode::emulator};
AppMode myMode{AppMode::emulator};
enum {
kBasSetCmd = 'BAST',

View File

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

View File

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

View File

@ -30,7 +30,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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"),
myMode{mode}
{
@ -351,7 +351,7 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
saveConfig();
[[fallthrough]];
case GuiObject::kCloseCmd:
if (myMode != OptionsMenu::AppMode::emulator)
if (myMode != AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();
@ -363,7 +363,7 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
case kConfirmSwitchCmd:
instance().settings().setValue("basic_settings", false);
if (myMode != OptionsMenu::AppMode::emulator)
if (myMode != AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();

View File

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