Commit bfa5341d authored by Jean-Baptiste Demonte's avatar Jean-Baptiste Demonte

feat(favorites): add filtered options menu on favorite system

parent baede058
......@@ -68,23 +68,25 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
mMenu.addWithLabel(mListSort, _("SORT GAMES BY"), _(MenuMessages::GAMELISTOPTION_SORT_GAMES_MSG));
addSaveFunc([this, system] { RecalboxConf::getInstance()->setUInt(system->getName() + ".sort", (unsigned int) mListSort->getSelected()); });
// favorite only
auto favorite_only = std::make_shared<SwitchComponent>(mWindow);
favorite_only->setState(Settings::getInstance()->getBool("FavoritesOnly"));
mMenu.addWithLabel(favorite_only, _("FAVORITES ONLY"), _(MenuMessages::GAMELISTOPTION_FAVORITES_ONLY_MSG));
addSaveFunc([favorite_only] { Settings::getInstance()->setBool("FavoritesOnly", favorite_only->getState()); });
// show hidden
auto show_hidden = std::make_shared<SwitchComponent>(mWindow);
show_hidden->setState(Settings::getInstance()->getBool("ShowHidden"));
mMenu.addWithLabel(show_hidden, _("SHOW HIDDEN"), _(MenuMessages::GAMELISTOPTION_SHOW_HIDDEN_MSG));
addSaveFunc([show_hidden] { Settings::getInstance()->setBool("ShowHidden", show_hidden->getState()); });
// flat folders
auto flat_folders = std::make_shared<SwitchComponent>(mWindow);
flat_folders->setState(RecalboxConf::getInstance()->getBool(system->getName() + ".flatfolder"));
mMenu.addWithLabel(flat_folders, _("SHOW FOLDERS CONTENT"), _(MenuMessages::GAMELISTOPTION_SHOW_FOLDER_CONTENT_MSG));
addSaveFunc([flat_folders, system] { RecalboxConf::getInstance()->setBool(system->getName() + ".flatfolder", flat_folders->getState()); });
if (!system->isFavorite()) {
// favorite only
auto favorite_only = std::make_shared<SwitchComponent>(mWindow);
favorite_only->setState(Settings::getInstance()->getBool("FavoritesOnly"));
mMenu.addWithLabel(favorite_only, _("FAVORITES ONLY"), _(MenuMessages::GAMELISTOPTION_FAVORITES_ONLY_MSG));
addSaveFunc([favorite_only] { Settings::getInstance()->setBool("FavoritesOnly", favorite_only->getState()); });
// show hidden
auto show_hidden = std::make_shared<SwitchComponent>(mWindow);
show_hidden->setState(Settings::getInstance()->getBool("ShowHidden"));
mMenu.addWithLabel(show_hidden, _("SHOW HIDDEN"), _(MenuMessages::GAMELISTOPTION_SHOW_HIDDEN_MSG));
addSaveFunc([show_hidden] { Settings::getInstance()->setBool("ShowHidden", show_hidden->getState()); });
// flat folders
auto flat_folders = std::make_shared<SwitchComponent>(mWindow);
flat_folders->setState(RecalboxConf::getInstance()->getBool(system->getName() + ".flatfolder"));
mMenu.addWithLabel(flat_folders, _("SHOW FOLDERS CONTENT"), _(MenuMessages::GAMELISTOPTION_SHOW_FOLDER_CONTENT_MSG));
addSaveFunc([flat_folders, system] { RecalboxConf::getInstance()->setBool(system->getName() + ".flatfolder", flat_folders->getState()); });
}
// edit game metadata
row.elements.clear();
......@@ -96,34 +98,37 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
mMenu.addRowWithHelp(row, _("EDIT THIS GAME'S METADATA"), _(MenuMessages::GAMELISTOPTION_EDIT_METADATA_MSG));
}
// update game list
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, _("UPDATE GAMES LISTS"), menuTheme->menuText.font, menuTheme->menuText.color), true);
row.addElement(makeArrow(mWindow), false);
row.makeAcceptInputHandler([this, system, window] {
mReloading = true;
window->pushGui(new GuiMsgBox(window, _("REALLY UPDATE GAMES LISTS ?"),
_("YES"), [system, window] {
std::string systemName = system->getName();
ViewController::get()->goToStart();
window->renderShutdownScreen();
delete ViewController::get();
SystemData::deleteSystems();
SystemData::loadConfig();
window->deleteAllGui();
ViewController::init(window);
ViewController::get()->reloadAll();
window->pushGui(ViewController::get());
if (!ViewController::get()->goToGameList(systemName)) {
ViewController::get()->goToStart();
}
},
_("NO"), [this] {
mReloading = false;
}
));
});
mMenu.addRowWithHelp(row, _("UPDATE GAMES LISTS"), _(MenuMessages::UI_UPDATE_GAMELIST_HELP_MSG));
if (!system->isFavorite()) {
// update game list
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, _("UPDATE GAMES LISTS"), menuTheme->menuText.font,
menuTheme->menuText.color), true);
row.addElement(makeArrow(mWindow), false);
row.makeAcceptInputHandler([this, system, window] {
mReloading = true;
window->pushGui(new GuiMsgBox(window, _("REALLY UPDATE GAMES LISTS ?"),
_("YES"), [system, window] {
std::string systemName = system->getName();
ViewController::get()->goToStart();
window->renderShutdownScreen();
delete ViewController::get();
SystemData::deleteSystems();
SystemData::loadConfig();
window->deleteAllGui();
ViewController::init(window);
ViewController::get()->reloadAll();
window->pushGui(ViewController::get());
if (!ViewController::get()->goToGameList(systemName)) {
ViewController::get()->goToStart();
}
},
_("NO"), [this] {
mReloading = false;
}
));
});
mMenu.addRowWithHelp(row, _("UPDATE GAMES LISTS"), _(MenuMessages::UI_UPDATE_GAMELIST_HELP_MSG));
}
// center the menu
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
......
......@@ -308,7 +308,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) {
}
if(config->isMappedTo("start", input) && input.value && getRoot()->getSystem() != SystemData::getFavoriteSystem())
if(config->isMappedTo("start", input) && input.value)
{
mWindow->pushGui(new GuiGamelistOptions(mWindow, getRoot()->getSystem()));
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment