add option to switch settings mode in minimal UI

This commit is contained in:
thrust26 2019-04-27 21:07:18 +02:00
parent a7cf51995e
commit 75650f1930
14 changed files with 179 additions and 48 deletions

View File

@ -67,7 +67,7 @@ DebuggerDialog::DebuggerDialog(OSystem& osystem, DialogContainer& parent,
myTiaOutput->setZoomWidget(myTiaZoom);
myOptions = make_unique<OptionsDialog>(osystem, parent, this, w, h,
OptionsDialog::AppMode::debugger);
Menu::AppMode::debugger);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -118,6 +118,7 @@ Settings::Settings()
setPermanent("uipalette", "standard");
setPermanent("listdelay", "300");
setPermanent("mwheel", "4");
setPermanent("basic_settings", false);
// Misc options
setPermanent("autoslot", "false");

View File

@ -157,7 +157,7 @@ void DialogContainer::reStack()
while(!myDialogStack.empty())
myDialogStack.top()->close();
myBaseDialog->open();
getBaseDialog()->open();
// Reset all continuous events
reset();

View File

@ -141,6 +141,11 @@ class DialogContainer
*/
const Dialog* baseDialog() const { return myBaseDialog; }
/**
Return the bottom-most dialog of this container. Can be overwritten.
*/
virtual Dialog* getBaseDialog() { return myBaseDialog; }
/**
Inform the container that it should resize according to the current
screen dimensions. We make this virtual, since the container may or

View File

@ -55,7 +55,9 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
myPattern(nullptr),
myAllFiles(nullptr),
myRomInfoWidget(nullptr),
mySelectedItem(0)
mySelectedItem(0),
myStellaSettingsDialog(nullptr),
myOptionsDialog(nullptr)
{
myUseMinimalUI = instance().settings().getBool("minimal_ui");
@ -206,10 +208,6 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
}
mySelectedItem = 0; // Highlight 'Rom Listing'
// Create an options dialog, similar to the in-game one
myOptions = make_unique<OptionsDialog>(osystem, parent, this, w, h,
OptionsDialog::AppMode::launcher);
// Create a game list, which contains all the information about a ROM that
// the launcher needs
myGameList = make_unique<GameList>();
@ -226,9 +224,6 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// ROM properties
myGlobalProps = make_unique<GlobalPropsDialog>(this,
myUseMinimalUI ? osystem.frameBuffer().launcherFont() : osystem.frameBuffer().font());
if (myUseMinimalUI)
myStellaSettingsDialog =
make_unique<StellaSettingsDialog>(osystem, parent, osystem.frameBuffer().launcherFont(), w, h);
// Do we show only ROMs or all files?
bool onlyROMs = instance().settings().getBool("launcherroms");
@ -468,7 +463,7 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod)
switch(key)
{
case KBDK_F8:
myStellaSettingsDialog->open();
openSettings();
break;
case KBDK_F4:
@ -553,7 +548,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
}
case kOptionsCmd:
myOptions->open();
openSettings();
break;
case kPrevDirCmd:
@ -640,3 +635,22 @@ void LauncherDialog::startGame()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::openSettings()
{
// Create an options dialog, similar to the in-game one
if (instance().settings().getBool("basic_settings"))
{
if (myStellaSettingsDialog == nullptr)
myStellaSettingsDialog = make_unique<StellaSettingsDialog>(instance(), parent(),
instance().frameBuffer().launcherFont(), _w, _h, Menu::AppMode::launcher);
myStellaSettingsDialog->open();
}
else
{
if (myOptionsDialog == nullptr)
myOptionsDialog = make_unique<OptionsDialog>(instance(), parent(), this, _w, _h,
Menu::AppMode::launcher);
myOptionsDialog->open();
}
}

View File

@ -99,13 +99,14 @@ class LauncherDialog : public Dialog
void showOnlyROMs(bool state);
bool matchPattern(const string& s, const string& pattern) const;
void startGame();
void openSettings();
private:
unique_ptr<OptionsDialog> myOptions;
unique_ptr<OptionsDialog> myOptionsDialog;
unique_ptr<StellaSettingsDialog> myStellaSettingsDialog;
unique_ptr<GameList> myGameList;
unique_ptr<ContextMenu> myMenu;
unique_ptr<GlobalPropsDialog> myGlobalProps;
unique_ptr<StellaSettingsDialog> myStellaSettingsDialog;
unique_ptr<BrowserDialog> myRomDir;
ButtonWidget* myStartButton;

View File

@ -18,13 +18,33 @@
#include "Dialog.hxx"
#include "FrameBufferConstants.hxx"
#include "OptionsDialog.hxx"
#include "StellaSettingsDialog.hxx"
#include "FrameBuffer.hxx"
#include "bspf.hxx"
#include "Menu.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Menu::Menu(OSystem& osystem)
: DialogContainer(osystem)
: DialogContainer(osystem),
stellaSettingDialog(nullptr),
optionsDialog(nullptr)
{}
Dialog* Menu::getBaseDialog()
{
myBaseDialog = new OptionsDialog(myOSystem, *this, nullptr,
FBMinimum::Width, FBMinimum::Height, OptionsDialog::AppMode::emulator);
if (myOSystem.settings().getBool("basic_settings"))
{
if (stellaSettingDialog == nullptr)
stellaSettingDialog = new StellaSettingsDialog(myOSystem, *this, myOSystem.frameBuffer().font(),
FBMinimum::Width, FBMinimum::Height, AppMode::emulator);
return stellaSettingDialog;
}
else
{
if (optionsDialog == nullptr)
optionsDialog = new OptionsDialog(myOSystem, *this, nullptr,
FBMinimum::Width, FBMinimum::Height, AppMode::emulator);
return optionsDialog;
}
}

View File

@ -19,6 +19,8 @@
#define MENU_HXX
class OSystem;
class StellaSettingsDialog;
class OptionsDialog;
#include "DialogContainer.hxx"
@ -30,12 +32,20 @@ class OSystem;
class Menu : public DialogContainer
{
public:
// Current Stella mode
enum class AppMode { launcher, emulator, debugger };
/**
Create a new menu stack
*/
explicit Menu(OSystem& osystem);
virtual ~Menu() = default;
StellaSettingsDialog* stellaSettingDialog;
OptionsDialog* optionsDialog;
Dialog* getBaseDialog() override;
private:
// Following constructors and assignment operators not supported
Menu() = delete;

View File

@ -31,7 +31,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent)
: Dialog(osystem, parent, osystem.frameBuffer().font(), "Commands")
: Dialog(osystem, parent, osystem.frameBuffer().font(), "Commands"),
myStellaSettingsDialog(nullptr)
{
const int HBORDER = 10;
const int VBORDER = 10;
@ -101,9 +102,6 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent
wid.push_back(bw);
addToFocusList(wid);
myStellaSettingsDialog = make_unique<StellaSettingsDialog>(osystem, parent, _font,
FBMinimum::Width, FBMinimum::Height);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -219,7 +217,7 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd,
if(myStellaSettingsDialog == nullptr || myStellaSettingsDialog->shouldResize(w, h))
{
myStellaSettingsDialog = make_unique<StellaSettingsDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h);
instance().frameBuffer().font(), w, h, Menu::AppMode::emulator);
}
myStellaSettingsDialog->open();
break;

View File

@ -37,6 +37,7 @@
#include "OptionsDialog.hxx"
#include "Launcher.hxx"
#include "Settings.hxx"
#include "Menu.hxx"
#ifdef CHEATCODE_SUPPORT
#include "CheatCodeDialog.hxx"
@ -46,10 +47,12 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
GuiObject* boss, int max_w, int max_h, AppMode mode)
GuiObject* boss, int max_w, int max_h, Menu::AppMode mode)
: Dialog(osystem, parent, osystem.frameBuffer().font(), "Options"),
myMode(mode)
{
// do not show basic settings options in debugger
bool minSettings = osystem.settings().getBool("minimal_ui") && mode != Menu::AppMode::debugger;
const int buttonHeight = _font.getLineHeight() + 6,
rowHeight = _font.getLineHeight() + 10;
const int VBORDER = 10 + _th;
@ -62,6 +65,15 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
WidgetArray wid;
ButtonWidget* b = nullptr;
if (minSettings)
{
ButtonWidget* bw = new ButtonWidget(this, _font, xoffset, yoffset,
_w - 10 * 2, buttonHeight, "Switch to Basic Settings" + ELLIPSIS, kBasSetCmd);
wid.push_back(bw);
yoffset += rowHeight + 8;
_h += rowHeight + 8;
}
auto ADD_OD_BUTTON = [&](const string& label, int cmd)
{
ButtonWidget* bw = new ButtonWidget(this, _font, xoffset, yoffset,
@ -93,7 +105,7 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
wid.push_back(b);
// Move to second column
xoffset += buttonWidth + 10; yoffset = VBORDER;
xoffset += buttonWidth + 10; yoffset = minSettings ? VBORDER + rowHeight + 8 : VBORDER;
myGameInfoButton = ADD_OD_BUTTON("Game Properties" + ELLIPSIS, kInfoCmd);
wid.push_back(myGameInfoButton);
@ -140,7 +152,7 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
addToFocusList(wid);
// Certain buttons are disabled depending on mode
if(myMode == AppMode::launcher)
if(myMode == Menu::AppMode::launcher)
{
myCheatCodeButton->clearFlags(WIDGET_ENABLED);
}
@ -183,6 +195,15 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
{
switch(cmd)
{
case kBasSetCmd:
// enable basic settings
instance().settings().setValue("basic_settings", true);
if (myMode != Menu::AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();
break;
case kVidCmd:
{
// This dialog is resizable under certain conditions, so we need
@ -302,7 +323,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kExitCmd:
if(myMode != AppMode::emulator)
if(myMode != Menu::AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();

View File

@ -37,16 +37,14 @@ class AboutDialog;
class LoggerDialog;
class DeveloperDialog;
#include "Menu.hxx"
#include "Dialog.hxx"
class OptionsDialog : public Dialog
{
public:
// Current Stella mode
enum class AppMode { launcher, emulator, debugger };
OptionsDialog(OSystem& osystem, DialogContainer& parent, GuiObject* boss,
int max_w, int max_h, AppMode mode);
int max_w, int max_h, Menu::AppMode mode);
virtual ~OptionsDialog();
private:
@ -74,9 +72,10 @@ class OptionsDialog : public Dialog
ButtonWidget* myCheatCodeButton;
// Indicates if this dialog is used for global (vs. in-game) settings
AppMode myMode;
Menu::AppMode myMode;
enum {
kBasSetCmd = 'BAST',
kVidCmd = 'VIDO',
kAudCmd = 'AUDO',
kInptCmd = 'INPT',

View File

@ -22,18 +22,21 @@
#include "ControllerDetector.hxx"
#include "NTSCFilter.hxx"
#include "PopUpWidget.hxx"
#include "MessageBox.hxx"
#include "StellaSettingsDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent, font, "Stella settings")
const GUI::Font& font, int max_w, int max_h, Menu::AppMode mode)
: Dialog(osystem, parent, font, "Stella settings"),
myMode(mode)
{
const int VBORDER = 8;
const int HBORDER = 10;
const int INDENT = 20;
const int lineHeight = font.getLineHeight(),
const int buttonHeight = font.getLineHeight() + 6,
lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
const int VGAP = 5;
int xpos, ypos;
@ -42,15 +45,20 @@ StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& pa
VariantList items;
// Set real dimensions
setSize(33 * fontWidth + HBORDER * 2, 13 * (lineHeight + VGAP) + VGAP * 8 + 6 + _th, max_w, max_h);
setSize(33 * fontWidth + HBORDER * 2, 14 * (lineHeight + VGAP) + VGAP * 9 + 6 + _th, max_w, max_h);
xpos = HBORDER;
ypos = VBORDER + _th;
myAdvancedSettings = new ButtonWidget(this, font, xpos, ypos, _w - HBORDER * 2, buttonHeight,
"Switch to Advanced Settings" + ELLIPSIS, kAdvancedSettings);
ypos += lineHeight + VGAP*4;
new StaticTextWidget(this, font, xpos, ypos + 1, "Global settings:");
xpos += INDENT;
ypos += lineHeight + VGAP;
addUIOptions(wid, xpos, ypos, font);
ypos += VGAP * 4;
addVideoOptions(wid, xpos, ypos, font);
@ -284,15 +292,32 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
{
switch (cmd)
{
case GuiObject::kOKCmd:
saveConfig();
close();
break;
case GuiObject::kDefaultsCmd:
setDefaults();
break;
case GuiObject::kOKCmd:
saveConfig();
// falls through
case GuiObject::kCloseCmd:
if (myMode != Menu::AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();
break;
case kAdvancedSettings:
switchSettingsMode();
break;
case kConfirmSwitchCmd:
instance().settings().setValue("basic_settings", false);
if (myMode != Menu::AppMode::emulator)
close();
else
instance().eventHandler().leaveMenuMode();
break;
case kScanlinesChanged:
if(myTVScanIntense->getValue() == 0)
myTVScanIntense->setValueLabel("Off");
@ -309,6 +334,26 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::switchSettingsMode()
{
StringList msg;
msg.push_back("Warning!");
msg.push_back("");
msg.push_back("Advanced settings should be");
msg.push_back("handled with care! When in");
msg.push_back("doubt, read the manual.");
msg.push_back("");
msg.push_back("If you are sure you want to");
msg.push_back("proceed with the switch, click");
msg.push_back("'OK', otherwise click 'Cancel'.");
myConfirmMsg = make_unique<GUI::MessageBox>(this, instance().frameBuffer().font(), msg,
_w-16, _h, kConfirmSwitchCmd, "OK", "Cancel", "Switch settings mode", false);
myConfirmMsg->show();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::loadControllerProperties(const Properties& props)
{

View File

@ -21,17 +21,19 @@
class PopUpWidget;
#include "Props.hxx"
#include "Menu.hxx"
#include "Dialog.hxx"
namespace GUI {
class Font;
class MessageBox;
}
class StellaSettingsDialog : public Dialog
{
public:
StellaSettingsDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h);
const GUI::Font& font, int max_w, int max_h, Menu::AppMode mode);
virtual ~StellaSettingsDialog() = default;
private:
@ -45,6 +47,9 @@ class StellaSettingsDialog : public Dialog
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
// switch to advanced settings after user confirmation
void switchSettingsMode();
// load the properties for the controller settings
void loadControllerProperties(const Properties& props);
@ -53,6 +58,9 @@ class StellaSettingsDialog : public Dialog
int valueToLevel(int value);
private:
// advanced settings mode:
ButtonWidget* myAdvancedSettings;
// UI theme
PopUpWidget* myThemePopup;
@ -76,7 +84,14 @@ class StellaSettingsDialog : public Dialog
PopUpWidget* myRightPort;
StaticTextWidget* myRightPortDetected;
unique_ptr<GUI::MessageBox> myConfirmMsg;
// Indicates if this dialog is used for global (vs. in-game) settings
Menu::AppMode myMode;
enum {
kAdvancedSettings = 'SSad',
kConfirmSwitchCmd = 'SScf',
kScanlinesChanged = 'SSsc',
kPhosphorChanged = 'SSph'
};

View File

@ -55,6 +55,8 @@ SettingsR77::SettingsR77()
setPermanent("exitlauncher", "true");
setTemporary("minimal_ui", true);
setPermanent("basic_settings", true);
setPermanent("dev.settings", false);
// record states for 60 seconds
setPermanent("plr.timemachine", true);