From 3e2044fe966f372aecd91eedf0d2a9aff0fbb005 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 9 Jan 2021 20:59:59 +0100 Subject: [PATCH] added high scores button to R77 command dialog --- src/gui/MinUICommandDialog.cxx | 41 ++++++++++++++++++++++++++-------- src/gui/MinUICommandDialog.hxx | 39 ++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/gui/MinUICommandDialog.cxx b/src/gui/MinUICommandDialog.cxx index e9fc70471..0987b1acc 100644 --- a/src/gui/MinUICommandDialog.cxx +++ b/src/gui/MinUICommandDialog.cxx @@ -23,6 +23,8 @@ #include "EventHandler.hxx" #include "StateManager.hxx" #include "RewindManager.hxx" +#include "HighScoresManager.hxx" +#include "HighScoresDialog.hxx" #include "OSystem.hxx" #include "Widget.hxx" #include "StellaSettingsDialog.hxx" @@ -39,6 +41,7 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent const int VBORDER = 10; const int HGAP = 8; const int VGAP = 5; + const int buttonWidth = _font.getStringWidth(" Load State 0") + 20, buttonHeight = _font.getLineHeight() + 8, rowHeight = buttonHeight + VGAP; @@ -69,6 +72,8 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent wid.push_back(myLeftDiffButton); myRightDiffButton = ADD_CD_BUTTON("", kRightDiffCmd); wid.push_back(myRightDiffButton); + myHighScoresButton = ADD_CD_BUTTON("Highscores" + ELLIPSIS, kHighScoresCmd); + wid.push_back(myHighScoresButton); // Column 2 xoffset += buttonWidth + HGAP; @@ -84,6 +89,8 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent wid.push_back(myRewindButton); myUnwindButton = ADD_CD_BUTTON("Unwind", kUnwindCmd); wid.push_back(myUnwindButton); + bw = ADD_CD_BUTTON("Exit Game", kExitGameCmd); + wid.push_back(bw); // Column 3 xoffset += buttonWidth + HGAP; @@ -99,16 +106,18 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent wid.push_back(bw); bw = ADD_CD_BUTTON("Settings" + ELLIPSIS, kSettings); wid.push_back(bw); - - // Bottom row - xoffset = HBORDER + (buttonWidth + HGAP) / 2; - bw = ADD_CD_BUTTON("Exit Game", kExitGameCmd); - wid.push_back(bw); - xoffset += buttonWidth + HGAP; - yoffset -= buttonHeight + VGAP; bw = ADD_CD_BUTTON("Close", GuiObject::kCloseCmd); wid.push_back(bw); + //// Bottom row + //xoffset = HBORDER + (buttonWidth + HGAP) / 2; + //bw = ADD_CD_BUTTON("Exit Game", kExitGameCmd); + //wid.push_back(bw); + //xoffset += buttonWidth + HGAP; + //yoffset -= buttonHeight + VGAP; + //bw = ADD_CD_BUTTON("Close", GuiObject::kCloseCmd); + //wid.push_back(bw); + addToFocusList(wid); // We don't have a close/cancel button, but we still want the cancel @@ -123,6 +132,8 @@ void MinUICommandDialog::loadConfig() myColorButton->setLabel(instance().console().switches().tvColor() ? "Color Mode" : "B/W Mode"); myLeftDiffButton->setLabel(GUI::LEFT_DIFF + (instance().console().switches().leftDifficultyA() ? " A" : " B")); myRightDiffButton->setLabel(GUI::RIGHT_DIFF + (instance().console().switches().rightDifficultyA() ? " A" : " B")); + myHighScoresButton->setEnabled(instance().highScores().enabled()); + // Column 2 updateSlot(instance().state().currentSlot()); updateWinds(); @@ -183,6 +194,10 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd, consoleCmd = true; break; + case kHighScoresCmd: + openHighscores(); + break; + // Column 2 case kSaveStateCmd: event = Event::SaveState; @@ -207,11 +222,11 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd, // rewind 5s instance().state().rewindStates(5); updateWinds(); - break; + break; case kUnwindCmd: // unwind 5s - instance().state().unwindStates(5); + instance().state().unwindStates(5); updateWinds(); break; @@ -319,3 +334,11 @@ void MinUICommandDialog::openSettings() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void MinUICommandDialog::openHighscores() +{ + if(myHighScoresDialog == nullptr) + myHighScoresDialog = make_unique(instance(), parent(), + 1280, 720, Menu::AppMode::emulator); + myHighScoresDialog->open(); +} diff --git a/src/gui/MinUICommandDialog.hxx b/src/gui/MinUICommandDialog.hxx index 4930ad18c..81eb48e72 100644 --- a/src/gui/MinUICommandDialog.hxx +++ b/src/gui/MinUICommandDialog.hxx @@ -24,6 +24,7 @@ class DialogContainer; class OSystem; class StellaSettingsDialog; class OptionsDialog; +class HighScoresDialog; #include "Dialog.hxx" @@ -41,12 +42,14 @@ class MinUICommandDialog : public Dialog void updateWinds(); void updateTVFormat(); void openSettings(); + void openHighscores(); void processCancel() override; // column 0 ButtonWidget* myColorButton{nullptr}; ButtonWidget* myLeftDiffButton{nullptr}; ButtonWidget* myRightDiffButton{nullptr}; + ButtonWidget* myHighScoresButton{nullptr}; // column 1 ButtonWidget* mySaveStateButton{nullptr}; ButtonWidget* myStateSlotButton{nullptr}; @@ -60,26 +63,28 @@ class MinUICommandDialog : public Dialog unique_ptr myStellaSettingsDialog; unique_ptr myOptionsDialog; + unique_ptr myHighScoresDialog; enum { - kSelectCmd = 'Csel', - kResetCmd = 'Cres', - kColorCmd = 'Ccol', - kLeftDiffCmd = 'Cldf', - kRightDiffCmd = 'Crdf', - kSaveStateCmd = 'Csst', - kStateSlotCmd = 'Ccst', - kLoadStateCmd = 'Clst', - kSnapshotCmd = 'Csnp', - kRewindCmd = 'Crew', - kUnwindCmd = 'Cunw', - kFormatCmd = 'Cfmt', - kStretchCmd = 'Cstr', - kPhosphorCmd = 'Cpho', - kSettings = 'Cscn', - kFry = 'Cfry', - kExitGameCmd = 'Cext', + kSelectCmd = 'Csel', + kResetCmd = 'Cres', + kColorCmd = 'Ccol', + kLeftDiffCmd = 'Cldf', + kRightDiffCmd = 'Crdf', + kHighScoresCmd = 'Chsc', + kSaveStateCmd = 'Csst', + kStateSlotCmd = 'Ccst', + kLoadStateCmd = 'Clst', + kSnapshotCmd = 'Csnp', + kRewindCmd = 'Crew', + kUnwindCmd = 'Cunw', + kFormatCmd = 'Cfmt', + kStretchCmd = 'Cstr', + kPhosphorCmd = 'Cpho', + kSettings = 'Cscn', + kFry = 'Cfry', + kExitGameCmd = 'Cext' }; private: