Expanded the random system or game button from an on/off entry to a selection of games only, games and systems or disabled.

This commit is contained in:
Leon Styhre 2023-03-06 19:27:59 +01:00
parent ee9d3cacc8
commit 03a44249af
5 changed files with 32 additions and 16 deletions

View file

@ -691,6 +691,29 @@ void GuiMenu::openUIOptions()
}
});
// Random entry button.
auto randomEntryButton = std::make_shared<OptionListComponent<std::string>>(
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<SwitchComponent>();
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<SwitchComponent>();
gamelistFilters->setState(Settings::getInstance()->getBool("GamelistFilters"));

View file

@ -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) {

View file

@ -455,7 +455,9 @@ std::vector<HelpPrompt> 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" &&

View file

@ -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<HelpPrompt> 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"))

View file

@ -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};