Expanded the quick system select menu option from a simple on/off entry to a selection of different button combinations.

Also did some minor code cleanup in GuiMenu.
This commit is contained in:
Leon Styhre 2022-12-07 18:09:05 +01:00
parent 9e0a6df760
commit 2799974938
5 changed files with 129 additions and 39 deletions

View file

@ -119,7 +119,7 @@ void GuiMenu::openUIOptions()
for (auto it = themeSets.cbegin(); it != themeSets.cend(); ++it) {
// If required, abbreviate the theme set name so it doesn't overlap the setting name.
float maxNameLength = mSize.x * 0.62f;
const float maxNameLength = mSize.x * 0.62f;
themeSet->add(it->first, it->first, it == selectedSet, maxNameLength);
}
s->addWithLabel("THEME SET", themeSet);
@ -176,7 +176,7 @@ void GuiMenu::openUIOptions()
if (variant.selectable) {
// If required, abbreviate the variant name so it doesn't overlap the
// setting name.
float maxNameLength {mSize.x * 0.62f};
const float maxNameLength {mSize.x * 0.62f};
themeVariant->add(variant.label, variant.name, variant.name == selectedVariant,
maxNameLength);
}
@ -226,7 +226,7 @@ void GuiMenu::openUIOptions()
for (auto& colorScheme : currentSet->second.capabilities.colorSchemes) {
// If required, abbreviate the color scheme name so it doesn't overlap the
// setting name.
float maxNameLength {mSize.x * 0.52f};
const float maxNameLength {mSize.x * 0.52f};
themeColorScheme->add(colorScheme.label, colorScheme.name,
colorScheme.name == selectedColorScheme, maxNameLength);
}
@ -298,12 +298,12 @@ void GuiMenu::openUIOptions()
auto gamelistViewStyle = std::make_shared<OptionListComponent<std::string>>(
getHelpStyle(), "LEGACY GAMELIST VIEW STYLE", false);
std::string selectedViewStyle {Settings::getInstance()->getString("GamelistViewStyle")};
gamelistViewStyle->add("automatic", "automatic", selectedViewStyle == "automatic");
gamelistViewStyle->add("basic", "basic", selectedViewStyle == "basic");
gamelistViewStyle->add("detailed", "detailed", selectedViewStyle == "detailed");
gamelistViewStyle->add("video", "video", selectedViewStyle == "video");
gamelistViewStyle->add("AUTOMATIC", "automatic", selectedViewStyle == "automatic");
gamelistViewStyle->add("BASIC", "basic", selectedViewStyle == "basic");
gamelistViewStyle->add("DETAILED", "detailed", selectedViewStyle == "detailed");
gamelistViewStyle->add("VIDEO", "video", selectedViewStyle == "video");
// If there are no objects returned, then there must be a manually modified entry in the
// configuration file. Simply set the view style to Automatic in this case.
// configuration file. Simply set the view style to "automatic" in this case.
if (gamelistViewStyle->getSelectedObjects().size() == 0)
gamelistViewStyle->selectEntry(0);
s->addWithLabel("LEGACY GAMELIST VIEW STYLE", gamelistViewStyle);
@ -337,20 +337,43 @@ void GuiMenu::openUIOptions()
}
});
// Quick system select (navigate between systems in the gamelist view).
auto quickSystemSelect = std::make_shared<OptionListComponent<std::string>>(
getHelpStyle(), "QUICK SYSTEM SELECT", false);
std::string selectedQuickSelect {Settings::getInstance()->getString("QuickSystemSelect")};
quickSystemSelect->add("LEFT/RIGHT OR SHOULDERS", "leftrightshoulders",
selectedQuickSelect == "leftrightshoulders");
quickSystemSelect->add("LEFT/RIGHT OR TRIGGERS", "leftrighttriggers",
selectedQuickSelect == "leftrighttriggers");
quickSystemSelect->add("SHOULDERS", "shoulders", selectedQuickSelect == "shoulders");
quickSystemSelect->add("TRIGGERS", "triggers", selectedQuickSelect == "triggers");
quickSystemSelect->add("LEFT/RIGHT", "leftright", selectedQuickSelect == "leftright");
quickSystemSelect->add("DISABLED", "disabled", selectedQuickSelect == "disabled");
// If there are no objects returned, then there must be a manually modified entry in the
// configuration file. Simply set the quick system select to "leftrightshoulders" in this case.
if (quickSystemSelect->getSelectedObjects().size() == 0)
quickSystemSelect->selectEntry(0);
s->addWithLabel("QUICK SYSTEM SELECT", quickSystemSelect);
s->addSaveFunc([quickSystemSelect, s] {
if (quickSystemSelect->getSelected() !=
Settings::getInstance()->getString("QuickSystemSelect")) {
Settings::getInstance()->setString("QuickSystemSelect",
quickSystemSelect->getSelected());
s->setNeedsSaving();
}
});
// Optionally start in selected system/gamelist.
auto startupSystem = std::make_shared<OptionListComponent<std::string>>(
getHelpStyle(), "GAMELIST ON STARTUP", false);
startupSystem->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == "");
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
it != SystemData::sSystemVector.cend(); ++it) {
if ((*it)->getName() != "retropie") {
// If required, abbreviate the system name so it doesn't overlap the setting name.
float maxNameLength {mSize.x * 0.51f};
startupSystem->add((*it)->getFullName(), (*it)->getName(),
Settings::getInstance()->getString("StartupSystem") ==
(*it)->getName(),
maxNameLength);
}
// If required, abbreviate the system name so it doesn't overlap the setting name.
float maxNameLength {mSize.x * 0.51f};
startupSystem->add((*it)->getFullName(), (*it)->getName(),
Settings::getInstance()->getString("StartupSystem") == (*it)->getName(),
maxNameLength);
}
// This can probably not happen but as an extra precaution select the "NONE" entry if no
// entry is selected.
@ -686,18 +709,6 @@ void GuiMenu::openUIOptions()
}
});
// Quick system select (navigate left/right in gamelist view).
auto quickSystemSelect = std::make_shared<SwitchComponent>();
quickSystemSelect->setState(Settings::getInstance()->getBool("QuickSystemSelect"));
s->addWithLabel("ENABLE QUICK SYSTEM SELECT", quickSystemSelect);
s->addSaveFunc([quickSystemSelect, s] {
if (Settings::getInstance()->getBool("QuickSystemSelect") !=
quickSystemSelect->getState()) {
Settings::getInstance()->setBool("QuickSystemSelect", quickSystemSelect->getState());
s->setNeedsSaving();
}
});
// On-screen help prompts.
auto showHelpPrompts = std::make_shared<SwitchComponent>();
showHelpPrompts->setState(Settings::getInstance()->getBool("ShowHelpPrompts"));

View file

@ -196,8 +196,7 @@ bool GamelistBase::input(InputConfig* config, Input input)
}
}
else if (config->isMappedLike(getQuickSystemSelectRightButton(), input)) {
if (mLeftRightAvailable && Settings::getInstance()->getBool("QuickSystemSelect") &&
SystemData::sSystemVector.size() > 1) {
if (SystemData::sSystemVector.size() > 1) {
muteViewVideos();
onFocusLost();
stopListScrolling();
@ -207,8 +206,7 @@ bool GamelistBase::input(InputConfig* config, Input input)
}
}
else if (config->isMappedLike(getQuickSystemSelectLeftButton(), input)) {
if (mLeftRightAvailable && Settings::getInstance()->getBool("QuickSystemSelect") &&
SystemData::sSystemVector.size() > 1) {
if (SystemData::sSystemVector.size() > 1) {
muteViewVideos();
onFocusLost();
stopListScrolling();
@ -999,3 +997,79 @@ void GamelistBase::removeMedia(FileData* game)
removeEmptyDirFunc(systemMediaDir, mediaType, path);
}
}
std::string GamelistBase::getQuickSystemSelectLeftButton()
{
if (Settings::getInstance()->getString("QuickSystemSelect") == "leftrightshoulders") {
if (mLeftRightAvailable)
return "left";
else
return "leftshoulder";
}
if (Settings::getInstance()->getString("QuickSystemSelect") == "leftrighttriggers") {
if (mLeftRightAvailable)
return "left";
else
return "lefttrigger";
}
if (Settings::getInstance()->getString("QuickSystemSelect") == "shoulders")
return "leftshoulder";
if (Settings::getInstance()->getString("QuickSystemSelect") == "triggers")
return "lefttrigger";
if (Settings::getInstance()->getString("QuickSystemSelect") == "leftright") {
if (mLeftRightAvailable)
return "left";
else
return "";
}
if (Settings::getInstance()->getString("QuickSystemSelect") == "disabled")
return "";
// This should only happen if there is an invalid value in es_settings.xml.
if (mLeftRightAvailable)
return "left";
else
return "leftshoulder";
}
std::string GamelistBase::getQuickSystemSelectRightButton()
{
if (Settings::getInstance()->getString("QuickSystemSelect") == "leftrightshoulders") {
if (mLeftRightAvailable)
return "right";
else
return "rightshoulder";
}
if (Settings::getInstance()->getString("QuickSystemSelect") == "leftrighttriggers") {
if (mLeftRightAvailable)
return "right";
else
return "righttrigger";
}
if (Settings::getInstance()->getString("QuickSystemSelect") == "shoulders")
return "rightshoulder";
if (Settings::getInstance()->getString("QuickSystemSelect") == "triggers")
return "righttrigger";
if (Settings::getInstance()->getString("QuickSystemSelect") == "leftright") {
if (mLeftRightAvailable)
return "right";
else
return "";
}
if (Settings::getInstance()->getString("QuickSystemSelect") == "disabled")
return "";
if (mLeftRightAvailable)
return "right";
else
return "rightshoulder";
}

View file

@ -86,8 +86,8 @@ protected:
bool isListScrolling() override { return mPrimary->isScrolling(); }
std::string getQuickSystemSelectRightButton() { return "right"; }
std::string getQuickSystemSelectLeftButton() { return "left"; }
std::string getQuickSystemSelectLeftButton();
std::string getQuickSystemSelectRightButton();
FileData* mRoot;
std::unique_ptr<CarouselComponent<FileData*>> mCarousel;

View file

@ -368,7 +368,7 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
populateList(mRoot->getChildrenListToDisplay(), mRoot);
// Disable quick system select if the primary component uses the left and right buttons.
// Check whether the primary component uses the left and right buttons for its navigation.
if (mCarousel != nullptr) {
if (mCarousel->getType() == CarouselComponent<FileData*>::CarouselType::HORIZONTAL ||
mCarousel->getType() == CarouselComponent<FileData*>::CarouselType::HORIZONTAL_WHEEL)
@ -432,9 +432,14 @@ std::vector<HelpPrompt> GamelistView::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;
if (Settings::getInstance()->getBool("QuickSystemSelect") &&
SystemData::sSystemVector.size() > 1 && mLeftRightAvailable)
prompts.push_back(HelpPrompt("left/right", "system"));
if (Settings::getInstance()->getString("QuickSystemSelect") != "disabled") {
if (getQuickSystemSelectLeftButton() == "leftshoulder")
prompts.push_back(HelpPrompt("lr", "system"));
else if (getQuickSystemSelectLeftButton() == "lefttrigger")
prompts.push_back(HelpPrompt("ltrt", "system"));
else if (getQuickSystemSelectLeftButton() == "left")
prompts.push_back(HelpPrompt("left/right", "system"));
}
if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && mCursorStack.empty() &&
ViewController::getInstance()->getState().viewing == ViewController::GAMELIST)

View file

@ -136,6 +136,7 @@ void Settings::setDefaults()
mStringMap["ThemeAspectRatio"] = {"", ""};
mStringMap["GamelistViewStyle"] = {"automatic", "automatic"};
mStringMap["TransitionStyle"] = {"slide", "slide"};
mStringMap["QuickSystemSelect"] = {"leftrightshoulders", "leftrightshoulders"};
mStringMap["StartupSystem"] = {"", ""};
mStringMap["DefaultSortOrder"] = {"filename, ascending", "filename, ascending"};
mStringMap["MenuOpeningEffect"] = {"scale-up", "scale-up"};
@ -190,7 +191,6 @@ void Settings::setDefaults()
mBoolMap["FavoritesAddButton"] = {true, true};
mBoolMap["RandomAddButton"] = {false, false};
mBoolMap["GamelistFilters"] = {true, true};
mBoolMap["QuickSystemSelect"] = {true, true};
mBoolMap["ShowHelpPrompts"] = {true, true};
// Sound settings.