From 99983c609a763da9ec2958dc5d8e380f4879a133 Mon Sep 17 00:00:00 2001 From: John Lioneil Dionisio Date: Tue, 2 Apr 2024 01:35:46 +0800 Subject: [PATCH 1/4] fix: add helpstyle to component --- es-core/src/components/OptionListComponent.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index bf922acdcb..95d9c8d64a 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -5,6 +5,8 @@ #include "GuiComponent.h" #include "Log.h" #include "Window.h" +#include "SystemData.h" +#include "views/ViewController.h" //Used to display a list of options. //Can select one or multiple options. @@ -125,6 +127,14 @@ class OptionListComponent : public GuiComponent return GuiComponent::input(config, input); } + HelpStyle getHelpStyle() override + { + HelpStyle style = HelpStyle(); + style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + + return style; + } + std::vector getHelpPrompts() override { auto prompts = mMenu.getHelpPrompts(); @@ -316,6 +326,14 @@ class OptionListComponent : public GuiComponent } } + HelpStyle getHelpStyle() override + { + HelpStyle style = HelpStyle(); + style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + + return style; + } + std::vector getHelpPrompts() override { std::vector prompts; From 478c254d231858807f5c4845be93627c4f1a769e Mon Sep 17 00:00:00 2001 From: John Lioneil Dionisio Date: Tue, 2 Apr 2024 01:36:12 +0800 Subject: [PATCH 2/4] fix: add helpstyle to scraper gui --- es-app/src/guis/GuiScraperStart.cpp | 7 +++++++ es-app/src/guis/GuiScraperStart.h | 1 + 2 files changed, 8 insertions(+) diff --git a/es-app/src/guis/GuiScraperStart.cpp b/es-app/src/guis/GuiScraperStart.cpp index 2242046901..52db5e6c27 100644 --- a/es-app/src/guis/GuiScraperStart.cpp +++ b/es-app/src/guis/GuiScraperStart.cpp @@ -119,6 +119,13 @@ bool GuiScraperStart::input(InputConfig* config, Input input) return false; } +HelpStyle GuiScraperStart::getHelpStyle() +{ + HelpStyle style = HelpStyle(); + style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + return style; +} + std::vector GuiScraperStart::getHelpPrompts() { std::vector prompts = mMenu.getHelpPrompts(); diff --git a/es-app/src/guis/GuiScraperStart.h b/es-app/src/guis/GuiScraperStart.h index 6c442b9fe0..7ef114870b 100644 --- a/es-app/src/guis/GuiScraperStart.h +++ b/es-app/src/guis/GuiScraperStart.h @@ -24,6 +24,7 @@ class GuiScraperStart : public GuiComponent bool input(InputConfig* config, Input input) override; virtual std::vector getHelpPrompts() override; + HelpStyle getHelpStyle() override; private: void pressedStart(); From f943cdf771336c4b87141e960c3cf0acb1ed7f96 Mon Sep 17 00:00:00 2001 From: John Lioneil Dionisio Date: Tue, 2 Apr 2024 21:19:37 +0800 Subject: [PATCH 3/4] feat: add helpStyle overrides in ScreensaveOptions and GuiTextEditPopup --- es-app/src/guis/GuiScreensaverOptions.cpp | 10 +++++++++- es-core/src/guis/GuiTextEditPopup.cpp | 17 ++++++++++++++--- es-core/src/guis/GuiTextEditPopup.h | 8 ++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/es-app/src/guis/GuiScreensaverOptions.cpp b/es-app/src/guis/GuiScreensaverOptions.cpp index 6537694e5f..8e248c6c5c 100644 --- a/es-app/src/guis/GuiScreensaverOptions.cpp +++ b/es-app/src/guis/GuiScreensaverOptions.cpp @@ -89,7 +89,15 @@ void GuiScreensaverOptions::addEditableTextComponent(ComponentListRow row, const auto updateVal = [ed](const std::string& newVal) { ed->setValue(newVal); }; // ok callback (apply new value to ed) row.makeAcceptInputHandler([this, label, ed, updateVal] { - mWindow->pushGui(new GuiTextEditPopup(mWindow, label, ed->getValue(), updateVal, false)); + mWindow->pushGui(new GuiTextEditPopup( + mWindow, + label, + ed->getValue(), + updateVal, + false, + "OK", + ViewController::get()->getState().getSystem()->getTheme() + )); }); assert(ed); addRow(row); diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index 4c14bddb47..56fcde9924 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -4,9 +4,9 @@ #include "components/MenuComponent.h" #include "components/TextEditComponent.h" -GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue, - const std::function& okCallback, bool multiLine, const char* acceptBtnText) - : GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 3)), mMultiLine(multiLine) +GuiTextEditPopup::GuiTextEditPopup(Window *window, const std::string &title, const std::string &initValue, + const std::function &okCallback, bool multiLine, const char *acceptBtnText, const std::shared_ptr &theme) + : GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 3)), mMultiLine(multiLine), mTheme(theme) { addChild(&mBackground); addChild(&mGrid); @@ -65,6 +65,17 @@ bool GuiTextEditPopup::input(InputConfig* config, Input input) return false; } +HelpStyle GuiTextEditPopup::getHelpStyle() +{ + if (mTheme) { + HelpStyle style = HelpStyle(); + style.applyTheme(mTheme, "system"); + return style; + } + + return GuiComponent::getHelpStyle(); +} + std::vector GuiTextEditPopup::getHelpPrompts() { std::vector prompts = mGrid.getHelpPrompts(); diff --git a/es-core/src/guis/GuiTextEditPopup.h b/es-core/src/guis/GuiTextEditPopup.h index 59a95b9516..7738e84c90 100644 --- a/es-core/src/guis/GuiTextEditPopup.h +++ b/es-core/src/guis/GuiTextEditPopup.h @@ -12,12 +12,15 @@ class TextEditComponent; class GuiTextEditPopup : public GuiComponent { public: - GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue, - const std::function& okCallback, bool multiLine, const char* acceptBtnText = "OK"); + GuiTextEditPopup(Window *window, const std::string &title, const std::string &initValue, + const std::function &okCallback, bool multiLine, + const char *acceptBtnText = "OK", const std::shared_ptr &theme = NULL); bool input(InputConfig* config, Input input) override; void onSizeChanged() override; + std::vector getHelpPrompts() override; + HelpStyle getHelpStyle() override; private: NinePatchComponent mBackground; @@ -26,6 +29,7 @@ class GuiTextEditPopup : public GuiComponent std::shared_ptr mTitle; std::shared_ptr mText; std::shared_ptr mButtonGrid; + std::shared_ptr mTheme; bool mMultiLine; }; From d035937e564bad2aedfecaa65aad653c562df1ae Mon Sep 17 00:00:00 2001 From: John Lioneil Dionisio Date: Wed, 3 Apr 2024 02:26:01 +0800 Subject: [PATCH 4/4] fix: add helpsystem to style help hints using current theme --- .../src/components/ScraperSearchComponent.cpp | 5 ++- .../src/guis/GuiCollectionSystemsOptions.cpp | 17 ++++++- es-app/src/guis/GuiCollectionSystemsOptions.h | 1 + es-app/src/guis/GuiMenu.cpp | 45 +++++++++++++++---- .../src/guis/GuiRandomCollectionOptions.cpp | 7 +++ es-app/src/guis/GuiRandomCollectionOptions.h | 1 + es-app/src/guis/GuiScraperMulti.cpp | 17 ++++++- es-app/src/guis/GuiScraperMulti.h | 1 + es-core/src/guis/GuiMsgBox.cpp | 26 ++++++++--- es-core/src/guis/GuiMsgBox.h | 9 ++-- 10 files changed, 109 insertions(+), 20 deletions(-) diff --git a/es-app/src/components/ScraperSearchComponent.cpp b/es-app/src/components/ScraperSearchComponent.cpp index 752c4a8e69..c3e4d28264 100644 --- a/es-app/src/components/ScraperSearchComponent.cpp +++ b/es-app/src/components/ScraperSearchComponent.cpp @@ -8,10 +8,12 @@ #include "components/TextComponent.h" #include "guis/GuiMsgBox.h" #include "guis/GuiTextEditPopup.h" +#include "views/ViewController.h" #include "resources/Font.h" #include "utils/StringUtil.h" #include "FileData.h" #include "Log.h" +#include "SystemData.h" #include "Window.h" ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window), @@ -456,7 +458,8 @@ void ScraperSearchComponent::openInputScreen(ScraperSearchParams& params) mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR", // initial value is last search if there was one, otherwise the clean path name params.nameOverride.empty() ? params.game->getCleanName() : params.nameOverride, - searchForFunc, false, "SEARCH")); + searchForFunc, false, "SEARCH", + ViewController::get()->getState().getSystem()->getTheme())); } std::vector ScraperSearchComponent::getHelpPrompts() diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index cd58229ff9..de6cd21b7b 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -8,6 +8,7 @@ #include "utils/StringUtil.h" #include "views/ViewController.h" #include "CollectionSystemManager.h" +#include "SystemData.h" #include "Window.h" GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window) : GuiComponent(window), mMenu(window, "GAME COLLECTION SETTINGS") @@ -64,7 +65,14 @@ void GuiCollectionSystemsOptions::initializeMenu() createCollection(name); }; row.makeAcceptInputHandler([this, createCustomCollection] { - mWindow->pushGui(new GuiTextEditPopup(mWindow, "New Collection Name", "", createCustomCollection, false)); + mWindow->pushGui(new GuiTextEditPopup( + mWindow, + "New Collection Name", + "", + createCustomCollection, + false, "OK", + ViewController::get()->getState().getSystem()->getTheme() + )); }); mMenu.addRow(row); @@ -276,6 +284,13 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input) return false; } +HelpStyle GuiCollectionSystemsOptions::getHelpStyle() +{ + HelpStyle style = HelpStyle(); + style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + return style; +} + std::vector GuiCollectionSystemsOptions::getHelpPrompts() { std::vector prompts = mMenu.getHelpPrompts(); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.h b/es-app/src/guis/GuiCollectionSystemsOptions.h index d8dae7b303..369dc9e57a 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.h +++ b/es-app/src/guis/GuiCollectionSystemsOptions.h @@ -17,6 +17,7 @@ class GuiCollectionSystemsOptions : public GuiComponent bool input(InputConfig* config, Input input) override; virtual std::vector getHelpPrompts() override; + HelpStyle getHelpStyle() override; private: void initializeMenu(); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 09f377e0d9..55c9fb6d29 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -220,7 +220,8 @@ void GuiMenu::openUISettings() LOG(LogDebug) << "Setting UI mode to " << selectedMode; Settings::getInstance()->setString("UIMode", selectedMode); Settings::getInstance()->saveFile(); - }, "NO",nullptr)); + }, "NO", nullptr, + "", nullptr, ViewController::get()->getState().getSystem()->getTheme())); } }); @@ -503,10 +504,14 @@ void GuiMenu::openOtherSettings() void GuiMenu::openConfigInput() { Window* window = mWindow; - window->pushGui(new GuiMsgBox(window, "ARE YOU SURE YOU WANT TO CONFIGURE INPUT?", "YES", + window->pushGui(new GuiMsgBox( + window, "ARE YOU SURE YOU WANT TO CONFIGURE INPUT?", "YES", [window] { - window->pushGui(new GuiDetectDevice(window, false, nullptr)); - }, "NO", nullptr) + window->pushGui(new GuiDetectDevice(window, false, nullptr)); + }, + "NO", nullptr, + "", nullptr, + ViewController::get()->getState().getSystem()->getTheme()) ); } @@ -532,7 +537,13 @@ void GuiMenu::openQuitMenu() if (confirm_quit) { row.makeAcceptInputHandler([window] { - window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", restart_es_fx, "NO", nullptr)); + window->pushGui(new GuiMsgBox( + window, "REALLY RESTART?", "YES", + restart_es_fx, + "NO", nullptr, + "", nullptr, + ViewController::get()->getState().getSystem()->getTheme() + )); }); } else { row.makeAcceptInputHandler(restart_es_fx); @@ -550,7 +561,13 @@ void GuiMenu::openQuitMenu() row.elements.clear(); if (confirm_quit) { row.makeAcceptInputHandler([window] { - window->pushGui(new GuiMsgBox(window, "REALLY QUIT?", "YES", quit_es_fx, "NO", nullptr)); + window->pushGui(new GuiMsgBox( + window, "REALLY QUIT?", "YES", + quit_es_fx, + "NO", nullptr, + "", nullptr, + ViewController::get()->getState().getSystem()->getTheme() + )); }); } else { row.makeAcceptInputHandler(quit_es_fx); @@ -571,7 +588,13 @@ void GuiMenu::openQuitMenu() row.elements.clear(); if (confirm_quit) { row.makeAcceptInputHandler([window] { - window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", {reboot_sys_fx}, "NO", nullptr)); + window->pushGui(new GuiMsgBox( + window, "REALLY RESTART?", "YES", + {reboot_sys_fx}, + "NO", nullptr, + "", nullptr, + ViewController::get()->getState().getSystem()->getTheme() + )); }); } else { row.makeAcceptInputHandler(reboot_sys_fx); @@ -590,7 +613,13 @@ void GuiMenu::openQuitMenu() row.elements.clear(); if (confirm_quit) { row.makeAcceptInputHandler([window] { - window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES", shutdown_sys_fx, "NO", nullptr)); + window->pushGui(new GuiMsgBox( + window, "REALLY SHUTDOWN?", "YES", + shutdown_sys_fx, + "NO", nullptr, + "", nullptr, + ViewController::get()->getState().getSystem()->getTheme() + )); }); } else { row.makeAcceptInputHandler(shutdown_sys_fx); diff --git a/es-app/src/guis/GuiRandomCollectionOptions.cpp b/es-app/src/guis/GuiRandomCollectionOptions.cpp index 9f520213a7..0a4aa229be 100644 --- a/es-app/src/guis/GuiRandomCollectionOptions.cpp +++ b/es-app/src/guis/GuiRandomCollectionOptions.cpp @@ -220,6 +220,13 @@ bool GuiRandomCollectionOptions::input(InputConfig* config, Input input) return false; } +HelpStyle GuiRandomCollectionOptions::getHelpStyle() +{ + HelpStyle style = HelpStyle(); + style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + return style; +} + std::vector GuiRandomCollectionOptions::getHelpPrompts() { std::vector prompts = mMenu.getHelpPrompts(); diff --git a/es-app/src/guis/GuiRandomCollectionOptions.h b/es-app/src/guis/GuiRandomCollectionOptions.h index 53bf50bd8b..79ee43e8ff 100644 --- a/es-app/src/guis/GuiRandomCollectionOptions.h +++ b/es-app/src/guis/GuiRandomCollectionOptions.h @@ -27,6 +27,7 @@ class GuiRandomCollectionOptions : public GuiComponent bool input(InputConfig* config, Input input) override; virtual std::vector getHelpPrompts() override; + HelpStyle getHelpStyle() override; private: void initializeMenu(); diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 28b87db40f..55d6f9bf9d 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -143,13 +143,26 @@ void GuiScraperMulti::finish() ss << "\n" << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED."; } - mWindow->pushGui(new GuiMsgBox(mWindow, ss.str(), - "OK", [&] { delete this; })); + mWindow->pushGui(new GuiMsgBox( + mWindow, ss.str(), + "OK", [&] + { delete this; }, + "", nullptr, + "", nullptr, + ViewController::get()->getState().getSystem()->getTheme() + )); mIsProcessing = false; PowerSaver::resume(); } +HelpStyle GuiScraperMulti::getHelpStyle() +{ + HelpStyle style = HelpStyle(); + style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + return style; +} + std::vector GuiScraperMulti::getHelpPrompts() { return mGrid.getHelpPrompts(); diff --git a/es-app/src/guis/GuiScraperMulti.h b/es-app/src/guis/GuiScraperMulti.h index 6622f0b8ca..8ded14d7cd 100644 --- a/es-app/src/guis/GuiScraperMulti.h +++ b/es-app/src/guis/GuiScraperMulti.h @@ -18,6 +18,7 @@ class GuiScraperMulti : public GuiComponent void onSizeChanged() override; std::vector getHelpPrompts() override; + HelpStyle getHelpStyle() override; private: void acceptResult(const ScraperSearchResult& result); diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 9db9ffff11..5588531915 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -5,11 +5,15 @@ #define HORIZONTAL_PADDING_PX 20 -GuiMsgBox::GuiMsgBox(Window* window, const std::string& text, - const std::string& name1, const std::function& func1, - const std::string& name2, const std::function& func2, - const std::string& name3, const std::function& func3) : GuiComponent(window), - mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 2)) +GuiMsgBox::GuiMsgBox(Window *window, const std::string &text, + const std::string &name1, const std::function &func1, + const std::string &name2, const std::function &func2, + const std::string &name3, const std::function &func3, + const std::shared_ptr &theme): + GuiComponent(window), + mBackground(window, ":/frame.png"), + mGrid(window, Vector2i(1, 2)), + mTheme(theme) { float width = Renderer::getScreenWidth() * 0.6f; // max width float minWidth = Renderer::getScreenWidth() * 0.3f; // minimum width @@ -104,6 +108,18 @@ void GuiMsgBox::deleteMeAndCall(const std::function& func) } +HelpStyle GuiMsgBox::getHelpStyle() +{ + if (mTheme) + { + HelpStyle style = HelpStyle(); + style.applyTheme(mTheme, "system"); + return style; + } + + return GuiComponent::getHelpStyle(); +} + std::vector GuiMsgBox::getHelpPrompts() { return mGrid.getHelpPrompts(); diff --git a/es-core/src/guis/GuiMsgBox.h b/es-core/src/guis/GuiMsgBox.h index cd9883244b..bc58ce2945 100644 --- a/es-core/src/guis/GuiMsgBox.h +++ b/es-core/src/guis/GuiMsgBox.h @@ -13,13 +13,15 @@ class GuiMsgBox : public GuiComponent { public: GuiMsgBox(Window* window, const std::string& text, - const std::string& name1 = "OK", const std::function& func1 = nullptr, - const std::string& name2 = "", const std::function& func2 = nullptr, - const std::string& name3 = "", const std::function& func3 = nullptr); + const std::string &name1 = "OK", const std::function &func1 = nullptr, + const std::string &name2 = "", const std::function &func2 = nullptr, + const std::string &name3 = "", const std::function &func3 = nullptr, + const std::shared_ptr &theme = NULL); bool input(InputConfig* config, Input input) override; void onSizeChanged() override; std::vector getHelpPrompts() override; + HelpStyle getHelpStyle() override; private: void deleteMeAndCall(const std::function& func); @@ -32,6 +34,7 @@ class GuiMsgBox : public GuiComponent std::vector< std::shared_ptr > mButtons; std::shared_ptr mButtonGrid; std::function mAcceleratorFunc; + std::shared_ptr mTheme; }; #endif // ES_CORE_GUIS_GUI_MSG_BOX_H