refactored dialogs to use only one pointer for other dialogs

This commit is contained in:
thrust26 2021-01-12 11:24:24 +01:00
parent b2acd8b266
commit 29685703d4
5 changed files with 55 additions and 129 deletions

View File

@ -38,7 +38,7 @@ CommandMenu::~CommandMenu()
Dialog* CommandMenu::baseDialog()
{
if (myBaseDialog == nullptr) {
if (myOSystem.settings().getBool("minimal_ui"))
if(myOSystem.settings().getBool("minimal_ui"))
myBaseDialog = new MinUICommandDialog(myOSystem, *this);
else
myBaseDialog = new CommandDialog(myOSystem, *this);

View File

@ -320,25 +320,23 @@ void MinUICommandDialog::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(),
1280, 720, Menu::AppMode::launcher);
myStellaSettingsDialog->open();
myDialog = make_unique<StellaSettingsDialog>(instance(), parent(),
1280, 720, Menu::AppMode::launcher);
myDialog->open();
}
else
{
if (myOptionsDialog == nullptr)
myOptionsDialog = make_unique<OptionsDialog>(instance(), parent(), this,
FBMinimum::Width, FBMinimum::Height, Menu::AppMode::launcher);
myOptionsDialog->open();
myDialog = make_unique<OptionsDialog>(instance(), parent(), this,
FBMinimum::Width, FBMinimum::Height,
Menu::AppMode::launcher);
myDialog->open();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MinUICommandDialog::openHighscores()
{
if(myHighScoresDialog == nullptr)
myHighScoresDialog = make_unique<HighScoresDialog>(instance(), parent(),
1280, 720, Menu::AppMode::emulator);
myHighScoresDialog->open();
myDialog = make_unique<HighScoresDialog>(instance(), parent(),
1280, 720, Menu::AppMode::emulator);
myDialog->open();
}

View File

@ -22,9 +22,6 @@ class Properties;
class CommandSender;
class DialogContainer;
class OSystem;
class StellaSettingsDialog;
class OptionsDialog;
class HighScoresDialog;
#include "Dialog.hxx"
@ -61,9 +58,7 @@ class MinUICommandDialog : public Dialog
ButtonWidget* myStretchButton{nullptr};
ButtonWidget* myPhosphorButton{nullptr};
unique_ptr<StellaSettingsDialog> myStellaSettingsDialog;
unique_ptr<OptionsDialog> myOptionsDialog;
unique_ptr<HighScoresDialog> myHighScoresDialog;
unique_ptr<Dialog> myDialog;
enum
{

View File

@ -135,21 +135,6 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
wid.push_back(b);
addCancelWidget(b);
// Now create all the dialogs attached to each menu button
myVideoDialog = make_unique<VideoAudioDialog>(osystem, parent, _font, max_w, max_h);
myEmulationDialog= make_unique<EmulationDialog>(osystem, parent, _font, max_w, max_h);
myInputDialog = make_unique<InputDialog>(osystem, parent, _font, max_w, max_h);
myUIDialog = make_unique<UIDialog>(osystem, parent, _font, boss, max_w, max_h);
mySnapshotDialog = make_unique<SnapshotDialog>(osystem, parent, _font, max_w, max_h);
myDeveloperDialog = make_unique<DeveloperDialog>(osystem, parent, _font, max_w, max_h);
myGameInfoDialog = make_unique<GameInfoDialog>(osystem, parent, _font, this, max_w, max_h);
#ifdef CHEATCODE_SUPPORT
myCheatCodeDialog = make_unique<CheatCodeDialog>(osystem, parent, _font);
#endif
myRomAuditDialog = make_unique<RomAuditDialog>(osystem, parent, _font, max_w, max_h);
myHelpDialog = make_unique<HelpDialog>(osystem, parent, _font);
myAboutDialog = make_unique<AboutDialog>(osystem, parent, _font);
addToFocusList(wid);
// Certain buttons are disabled depending on mode
@ -205,133 +190,108 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().leaveMenuMode();
break;
case kEmuCmd:
myEmulationDialog->open();
break;
case kVidCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if(myVideoDialog == nullptr || myVideoDialog->shouldResize(w, h))
{
myVideoDialog = make_unique<VideoAudioDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h);
}
myVideoDialog->open();
getDynamicBounds(w, h);
myDialog = make_unique<VideoAudioDialog>(instance(), parent(), _font, w, h);
myDialog->open();
break;
}
case kEmuCmd:
{
uInt32 w = 0, h = 0;
getDynamicBounds(w, h);
myDialog = make_unique<EmulationDialog>(instance(), parent(), _font, w, h);
myDialog->open();
break;
}
case kInptCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if(myInputDialog == nullptr || myInputDialog->shouldResize(w, h))
{
myInputDialog = make_unique<InputDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h);
}
myInputDialog->open();
getDynamicBounds(w, h);
myDialog = make_unique<InputDialog>(instance(), parent(), _font, w, h);
myDialog->open();
break;
}
case kUsrIfaceCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if(myUIDialog == nullptr || myUIDialog->shouldResize(w, h))
{
myUIDialog = make_unique<UIDialog>(instance(), parent(),
instance().frameBuffer().font(), myBoss, w, h);
}
myUIDialog->open();
getDynamicBounds(w, h);
myDialog = make_unique<UIDialog>(instance(), parent(), _font, myBoss, w, h);
myDialog->open();
break;
}
case kSnapCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if(mySnapshotDialog == nullptr || mySnapshotDialog->shouldResize(w, h))
{
mySnapshotDialog = make_unique<SnapshotDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h);
}
mySnapshotDialog->open();
getDynamicBounds(w, h);
myDialog = make_unique<SnapshotDialog>(instance(), parent(), _font, w, h);
myDialog->open();
break;
}
case kDevelopCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if(myDeveloperDialog == nullptr || myDeveloperDialog->shouldResize(w, h))
{
myDeveloperDialog = make_unique<DeveloperDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h);
}
myDeveloperDialog->open();
getDynamicBounds(w, h);
myDialog = make_unique<DeveloperDialog>(instance(), parent(), _font, w, h);
myDialog->open();
break;
}
case kInfoCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if(myGameInfoDialog == nullptr || myGameInfoDialog->shouldResize(w, h))
{
myGameInfoDialog = make_unique<GameInfoDialog>(instance(), parent(),
instance().frameBuffer().font(), this, w, h);
}
myGameInfoDialog->open();
getDynamicBounds(w, h);
myDialog = make_unique<GameInfoDialog>(instance(), parent(), _font, this, w, h);
myDialog->open();
break;
}
#ifdef CHEATCODE_SUPPORT
case kCheatCmd:
myCheatCodeDialog->open();
myDialog = make_unique<CheatCodeDialog>(instance(), parent(), _font);
myDialog->open();
break;
#endif
case kAuditCmd:
myRomAuditDialog->open();
break;
{
uInt32 w = 0, h = 0;
getDynamicBounds(w, h);
myDialog = make_unique<RomAuditDialog>(instance(), parent(), _font, w, h);
myDialog->open();
break;
}
case kLoggerCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
bool uselargefont = getDynamicBounds(w, h);
if(myLoggerDialog == nullptr || myLoggerDialog->shouldResize(w, h))
{
myLoggerDialog = make_unique<LoggerDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h, uselargefont);
}
myLoggerDialog->open();
myDialog = make_unique<LoggerDialog>(instance(), parent(), _font, w, h, uselargefont);
myDialog->open();
break;
}
case kHelpCmd:
myHelpDialog->open();
myDialog = make_unique<HelpDialog>(instance(), parent(), _font);
myDialog->open();
break;
case kAboutCmd:
myAboutDialog->open();
myDialog = make_unique<AboutDialog>(instance(), parent(), _font);
myDialog->open();
break;
case kExitCmd:

View File

@ -22,20 +22,6 @@ class CommandSender;
class DialogContainer;
class GuiObject;
class OSystem;
class EmulationDialog;
class VideoAudioDialog;
class InputDialog;
class UIDialog;
class SnapshotDialog;
class GameInfoDialog;
class RomAuditDialog;
#ifdef CHEATCODE_SUPPORT
class CheatCodeDialog;
#endif
class HelpDialog;
class AboutDialog;
class LoggerDialog;
class DeveloperDialog;
#include "Menu.hxx"
#include "Dialog.hxx"
@ -52,20 +38,7 @@ class OptionsDialog : public Dialog
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
private:
unique_ptr<VideoAudioDialog> myVideoDialog;
unique_ptr<EmulationDialog> myEmulationDialog;
unique_ptr<InputDialog> myInputDialog;
unique_ptr<UIDialog> myUIDialog;
unique_ptr<SnapshotDialog> mySnapshotDialog;
unique_ptr<DeveloperDialog> myDeveloperDialog;
unique_ptr<GameInfoDialog> myGameInfoDialog;
#ifdef CHEATCODE_SUPPORT
unique_ptr<CheatCodeDialog> myCheatCodeDialog;
#endif
unique_ptr<RomAuditDialog> myRomAuditDialog;
unique_ptr<LoggerDialog> myLoggerDialog;
unique_ptr<HelpDialog> myHelpDialog;
unique_ptr<AboutDialog> myAboutDialog;
unique_ptr<Dialog> myDialog;
ButtonWidget* myRomAuditButton{nullptr};
ButtonWidget* myGameInfoButton{nullptr};