diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 2e6c080bb..d0f12547f 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -691,6 +691,29 @@ void GuiMenu::openUIOptions() } }); + // Random entry button. + auto randomEntryButton = std::make_shared>( + getHelpStyle(), "RANDOM ENTRY BUTTON", false); + const std::string selectedRandomEntryButton { + Settings::getInstance()->getString("RandomEntryButton")}; + randomEntryButton->add("GAMES ONLY", "games", selectedRandomEntryButton == "games"); + randomEntryButton->add("GAMES AND SYSTEMS", "gamessystems", + selectedRandomEntryButton == "gamessystems"); + randomEntryButton->add("DISABLED", "disabled", selectedRandomEntryButton == "disabled"); + // If there are no objects returned, then there must be a manually modified entry in the + // configuration file. Simply set the random entry button to "games" in this case. + if (randomEntryButton->getSelectedObjects().size() == 0) + randomEntryButton->selectEntry(0); + s->addWithLabel("RANDOM ENTRY BUTTON", randomEntryButton); + s->addSaveFunc([randomEntryButton, s] { + if (randomEntryButton->getSelected() != + Settings::getInstance()->getString("RandomEntryButton")) { + Settings::getInstance()->setString("RandomEntryButton", + randomEntryButton->getSelected()); + s->setNeedsSaving(); + } + }); + // Media viewer. ComponentListRow mediaViewerRow; mediaViewerRow.elements.clear(); @@ -854,17 +877,6 @@ void GuiMenu::openUIOptions() } }); - // Enable the thumbstick click buttons for jumping to a random system or game. - auto randomAddButton = std::make_shared(); - randomAddButton->setState(Settings::getInstance()->getBool("RandomAddButton")); - s->addWithLabel("ENABLE RANDOM SYSTEM OR GAME BUTTON", randomAddButton); - s->addSaveFunc([randomAddButton, s] { - if (Settings::getInstance()->getBool("RandomAddButton") != randomAddButton->getState()) { - Settings::getInstance()->setBool("RandomAddButton", randomAddButton->getState()); - s->setNeedsSaving(); - } - }); - // Gamelist filters. auto gamelistFilters = std::make_shared(); gamelistFilters->setState(Settings::getInstance()->getBool("GamelistFilters")); diff --git a/es-app/src/views/GamelistBase.cpp b/es-app/src/views/GamelistBase.cpp index 9faf69137..8596c12c6 100644 --- a/es-app/src/views/GamelistBase.cpp +++ b/es-app/src/views/GamelistBase.cpp @@ -216,7 +216,8 @@ bool GamelistBase::input(InputConfig* config, Input input) return true; } } - else if (Settings::getInstance()->getBool("RandomAddButton") && + else if ((Settings::getInstance()->getString("RandomEntryButton") == "games" || + Settings::getInstance()->getString("RandomEntryButton") == "gamessystems") && (config->isMappedTo("leftthumbstickclick", input) || config->isMappedTo("rightthumbstickclick", input))) { if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER) { diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 8ec739020..b69d4c40d 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -455,7 +455,9 @@ std::vector GamelistView::getHelpPrompts() if (!UIModeController::getInstance()->isUIModeKid()) prompts.push_back(HelpPrompt("back", "options")); - if (mRoot->getSystem()->isGameSystem() && Settings::getInstance()->getBool("RandomAddButton")) + if (mRoot->getSystem()->isGameSystem() && + (Settings::getInstance()->getString("RandomEntryButton") == "games" || + Settings::getInstance()->getString("RandomEntryButton") == "gamessystems")) prompts.push_back(HelpPrompt("thumbstickclick", "random")); if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index c909aef84..663f6b6c9 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -119,12 +119,13 @@ bool SystemView::input(InputConfig* config, Input input) NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); return true; } - if (Settings::getInstance()->getBool("RandomAddButton") && + if (Settings::getInstance()->getString("RandomEntryButton") == "gamessystems" && (config->isMappedTo("leftthumbstickclick", input) || config->isMappedTo("rightthumbstickclick", input))) { // Get a random system and jump to it. NavigationSounds::getInstance().playThemeNavigationSound(SYSTEMBROWSESOUND); mPrimary->stopScrolling(); + ViewController::getInstance()->cancelViewTransitions(); mPrimary->setCursor(SystemData::getRandomSystem(mPrimary->getSelected())); return true; } @@ -215,7 +216,7 @@ std::vector SystemView::getHelpPrompts() prompts.push_back(HelpPrompt("a", "select")); - if (Settings::getInstance()->getBool("RandomAddButton")) + if (Settings::getInstance()->getString("RandomEntryButton") == "gamessystems") prompts.push_back(HelpPrompt("thumbstickclick", "random")); if (Settings::getInstance()->getBool("ScreensaverControls")) diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 207e3c256..af77713e1 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -163,6 +163,7 @@ void Settings::setDefaults() mStringMap["MenuOpeningEffect"] = {"scale-up", "scale-up"}; mStringMap["LaunchScreenDuration"] = {"normal", "normal"}; mStringMap["UIMode"] = {"full", "full"}; + mStringMap["RandomEntryButton"] = {"games", "games"}; // UI settings -> media viewer settings. mBoolMap["MediaViewerKeepVideoRunning"] = {true, true}; @@ -211,7 +212,6 @@ void Settings::setDefaults() mBoolMap["ListScrollOverlay"] = {false, false}; mBoolMap["VirtualKeyboard"] = {true, true}; mBoolMap["FavoritesAddButton"] = {true, true}; - mBoolMap["RandomAddButton"] = {false, false}; mBoolMap["GamelistFilters"] = {true, true}; mBoolMap["ShowHelpPrompts"] = {true, true};