From 977359aec9e75ab00a5699b76480340ced3eb76f Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 5 May 2019 11:18:49 +0200 Subject: [PATCH] add more and fix default buttons for R77 add rewind/unwind events improve R77HelpDialog --- src/common/PJoystickHandler.cxx | 8 ++- src/common/PKeyboardHandler.cxx | 1 - src/emucore/Event.hxx | 1 + src/emucore/EventHandler.cxx | 10 +++ src/emucore/EventHandler.hxx | 2 +- src/gui/R77HelpDialog.cxx | 106 +++++++++++++++++++++++++------ src/gui/R77HelpDialog.hxx | 5 +- src/gui/StellaSettingsDialog.cxx | 1 + 8 files changed, 109 insertions(+), 25 deletions(-) diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 75223f449..53bffebc4 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -325,6 +325,7 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick, setDefaultBtn(stick, 2, Event::CmdMenuMode); setDefaultBtn(stick, 3, Event::OptionsMenuMode); setDefaultBtn(stick, 4, Event::LauncherMode); + setDefaultBtn(stick, 5, Event::Rewind10); #endif break; default: @@ -340,9 +341,10 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick, // joystick (assume buttons zero..three) setDefaultBtn( stick, 0, Event::UISelect ); - setDefaultBtn( stick, 1, Event::UICancel ); - setDefaultBtn( stick, 2, Event::UITabPrev ); - setDefaultBtn( stick, 3, Event::UITabNext ); + setDefaultBtn( stick, 1, Event::UIOK ); + setDefaultBtn( stick, 2, Event::UITabNext); + setDefaultBtn( stick, 3, Event::UITabPrev ); + setDefaultBtn( stick, 5, Event::UICancel); setDefaultHat( stick, 0, JoyHat::LEFT, Event::UINavPrev ); setDefaultHat( stick, 0, JoyHat::RIGHT, Event::UINavNext ); diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 48169bc8c..6e10cfd79 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -379,7 +379,6 @@ bool PhysicalKeyboardHandler::handleAltEvent(StellaKey key, StellaMod mod, bool switch(key) { case KBDK_LEFT: // Alt-left(-shift) rewinds 1(10) states - //if (!myEvent.getKeys()[KBDK_SPACE]) myHandler.enterTimeMachineMenuMode((StellaModTest::isShift(mod) && pressed) ? 10 : 1, false); break; diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 54eb29594..ca4d513db 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -75,6 +75,7 @@ class Event ChangeState, LoadState, SaveState, TakeSnapshot, Quit, PauseMode, OptionsMenuMode, CmdMenuMode, TimeMachineMode, DebuggerMode, LauncherMode, Fry, VolumeDecrease, VolumeIncrease, SoundToggle, VidmodeDecrease, VidmodeIncrease, + Rewind, Unwind, UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown, UISelect, UINavPrev, UINavNext, UIOK, UICancel, UIPrevDir, diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 929ec248c..325378cee 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -414,6 +414,14 @@ void EventHandler::handleEvent(Event::Type event, bool pressed) if(pressed) myOSystem.state().loadState(); return; + case Event::Rewind: + if (pressed) myOSystem.state().rewindStates(); + return; + + case Event::Unwind: + if (pressed) myOSystem.state().unwindStates(); + return; + case Event::TakeSnapshot: if(pressed) myOSystem.frameBuffer().tiaSurface().saveSnapShot(); return; @@ -1327,6 +1335,8 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] = { Event::OptionsMenuMode, "Enter options menu UI", "", false }, { Event::CmdMenuMode, "Toggle command menu UI", "", false }, { Event::TimeMachineMode, "Toggle time machine UI", "", false }, + { Event::Rewind, "Rewind game", "", false }, + { Event::Unwind, "Unwind game", "", false }, { Event::DebuggerMode, "Toggle debugger mode", "", false }, { Event::LauncherMode, "Enter ROM launcher", "", false }, { Event::Quit, "Quit", "", false }, diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index b56164766..1e9c2d93c 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -363,7 +363,7 @@ class EventHandler static constexpr Int32 COMBO_SIZE = 16, EVENTS_PER_COMBO = 8, - EMUL_ACTIONLIST_SIZE = 83 + COMBO_SIZE, + EMUL_ACTIONLIST_SIZE = 85 + COMBO_SIZE, MENU_ACTIONLIST_SIZE = 16 ; diff --git a/src/gui/R77HelpDialog.cxx b/src/gui/R77HelpDialog.cxx index 3b8d54efe..0aa77a9c1 100644 --- a/src/gui/R77HelpDialog.cxx +++ b/src/gui/R77HelpDialog.cxx @@ -87,6 +87,13 @@ R77HelpDialog::R77HelpDialog(OSystem& osystem, DialogContainer& parent, addToFocusList(wid); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void R77HelpDialog::loadConfig() +{ + displayInfo(); + setFocus(getFocusList()[1]); // skip disabled 'Previous' button +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void R77HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title) { @@ -107,20 +114,22 @@ void R77HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title) switch (page) { case 1: - title = "Emulation commands"; + title = "\\C\\c5Emulation commands"; ADD_BIND("The joystic", "ks work nor", "mal and all console"); ADD_BIND("buttons as ", "labeled exc", "ept of the following:"); ADD_BIND(); ADD_BIND("Joystick", "Button", "Command"); ADD_LINE(); - ADD_BIND("Button 3", "4:3,16:9", "Open command dialog"); - ADD_BIND("Button 4", "-", "Open settings"); - ADD_BIND("Button 5", "FRY", "Return to launcher"); - + ADD_BIND("\\c2Button 3", "4:3,16:9", "Open command dialog"); + ADD_BIND("\\c2Button 4", "\\c2-", "Open settings"); + ADD_BIND("\\c2Button 5", "FRY", "Return to launcher"); + ADD_BIND("\\c2Button 6", "-", "Rewind game"); + ADD_BIND("\\c2Button 8", "MODE", "Select"); + ADD_BIND("\\c2Button 9", "RESET", "Reset"); break; case 2: - title = "Launcher commands"; + title = "\\C\\c5Launcher commands"; ADD_BIND("Joystick", "Button", "Command"); ADD_LINE(); ADD_BIND("Up", "SAVE", "Previous game"); @@ -128,26 +137,27 @@ void R77HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title) ADD_BIND("Left", "LOAD", "Page up"); ADD_BIND("Right", "MODE", "Page down"); ADD_BIND("Button 1", "SKILL P1", "Start selected game"); - ADD_BIND("Button 2", "SKILL P2", "Open power-on options"); - ADD_BIND("Button 4", "Color,B/W", "Open settings"); + ADD_BIND("\\c2Button 2", "SKILL P2", "Open power-on options"); + ADD_BIND("\\c2Button 4", "Color,B/W", "Open settings"); break; case 3: - title = "Dialog commands"; + title = "\\C\\c5Dialog commands"; ADD_BIND("Joystick", "Button", "Command"); ADD_LINE(); ADD_BIND("Up", "SAVE", "Increase current setting"); ADD_BIND("Down", "RESET", "Decrease current setting"); ADD_BIND("Left", "LOAD", "Previous dialog element"); ADD_BIND("Right", "MODE", "Next dialog element"); - ADD_BIND("Button 1", "SKILL P1", "Select"); - ADD_BIND("Button 2", "SKILL P2", "Cancel dialog"); - ADD_BIND("Button 3", "4:3,16:9", "Previous tab"); - ADD_BIND("Button 4", "FRY", "Next tab"); + ADD_BIND("Button 1", "SKILL P1", "Select element"); + ADD_BIND("\\c2Button 2", "SKILL P2", "OK"); + ADD_BIND("\\c2Button 3", "4:3,16:9", "Previous tab"); + ADD_BIND("\\c2Button 4", "FRY", "Next tab"); + ADD_BIND("\\c2Button 6", "\\c2-", "Cancel"); break; case 4: - title = "All commands"; + title = "\\C\\c5All commands"; ADD_BIND(); ADD_BIND("Remapped Ev", "ents", ""); ADD_BIND(); @@ -169,15 +179,75 @@ void R77HelpDialog::displayInfo() string titleStr; updateStrings(myPage, LINES_PER_PAGE, titleStr); - myTitle->setLabel(titleStr); + formatWidget(titleStr, myTitle); for (uInt8 i = 0; i < LINES_PER_PAGE; ++i) { - myJoy[i]->setLabel(myJoyStr[i]); - myBtn[i]->setLabel(myBtnStr[i]); - myDesc[i]->setLabel(myDescStr[i]); + formatWidget(myJoyStr[i], myJoy[i]); + formatWidget(myBtnStr[i], myBtn[i]); + formatWidget(myDescStr[i], myDesc[i]); } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void R77HelpDialog::formatWidget(const string& label, StaticTextWidget* widget) +{ + const char* str = label.c_str(); + TextAlign align = TextAlign::Left; + ColorId color = kTextColor; + + while (str[0] == '\\') + { + switch (str[1]) + { + case 'C': + align = TextAlign::Center; + break; + + case 'L': + align = TextAlign::Left; + break; + + case 'R': + align = TextAlign::Right; + break; + + case 'c': + switch (str[2]) + { + case '0': + color = kTextColor; + break; + case '1': + color = kTextColorHi; + break; + case '2': + color = kColor; + break; + case '3': + color = kShadowColor; + break; + case '4': + color = kBGColor; + break; + case '5': + color = kTextColorEm; + break; + default: + break; + } + str++; + break; + + default: + break; + } + str += 2; + } + widget->setAlign(align); + widget->setTextColor(color); + widget->setLabel(str); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void R77HelpDialog::handleCommand(CommandSender * sender, int cmd, int data, int id) diff --git a/src/gui/R77HelpDialog.hxx b/src/gui/R77HelpDialog.hxx index aabf8bf56..90c6656f2 100644 --- a/src/gui/R77HelpDialog.hxx +++ b/src/gui/R77HelpDialog.hxx @@ -37,10 +37,11 @@ class R77HelpDialog : public Dialog void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void updateStrings(uInt8 page, uInt8 lines, string& title); void displayInfo(); - void loadConfig() override { displayInfo(); } + void formatWidget(const string& label, StaticTextWidget* widget); + void loadConfig() override; private: - static constexpr uInt32 LINES_PER_PAGE = 10; + static constexpr uInt32 LINES_PER_PAGE = 11; ButtonWidget* myNextButton; ButtonWidget* myPrevButton; diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index 40186de31..3c87744a9 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -23,6 +23,7 @@ #include "NTSCFilter.hxx" #include "PopUpWidget.hxx" #include "MessageBox.hxx" + // FIXME - use the R77 define in the final release // use the '1' define for testing #if defined(RETRON77)