mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Rewrote collection settings to the new settings logic.
This commit is contained in:
parent
d7ef06546c
commit
9f747e161d
|
@ -13,257 +13,219 @@
|
|||
#include "components/SwitchComponent.h"
|
||||
#include "guis/GuiSettings.h"
|
||||
#include "guis/GuiTextEditPopup.h"
|
||||
#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")
|
||||
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::string title)
|
||||
: GuiSettings(window, title), mAddedCustomCollection(false)
|
||||
{
|
||||
initializeMenu();
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::initializeMenu()
|
||||
{
|
||||
addChild(&mMenu);
|
||||
// Finish editing custom collection.
|
||||
if (CollectionSystemManager::get()->isEditing()) {
|
||||
ComponentListRow row;
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" +
|
||||
Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) +
|
||||
"' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||
row.makeAcceptInputHandler([this] {
|
||||
CollectionSystemManager::get()->exitEditMode();
|
||||
delete this;
|
||||
});
|
||||
addRow(row);
|
||||
}
|
||||
|
||||
// Get collections.
|
||||
addSystemsToMenu();
|
||||
// Automatic collections.
|
||||
collection_systems_auto = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||
std::map<std::string, CollectionSystemData, stringComparator> autoSystems =
|
||||
CollectionSystemManager::get()->getAutoCollectionSystems();
|
||||
// Add automatic systems.
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = autoSystems.cbegin(); it != autoSystems.cend() ; it++)
|
||||
collection_systems_auto->add(it->second.decl.longName, it->second.decl.name,
|
||||
it->second.isEnabled);
|
||||
addWithLabel("AUTOMATIC GAME COLLECTIONS", collection_systems_auto);
|
||||
addSaveFunc([this] {
|
||||
std::string autoSystemsSelected =
|
||||
Utils::String::vectorToCommaString(collection_systems_auto->getSelectedObjects(), true);
|
||||
std::string autoSystemsConfig = Settings::getInstance()->getString("CollectionSystemsAuto");
|
||||
if (autoSystemsSelected != autoSystemsConfig) {
|
||||
if (CollectionSystemManager::get()->isEditing())
|
||||
CollectionSystemManager::get()->exitEditMode();
|
||||
Settings::getInstance()->setString("CollectionSystemsAuto", autoSystemsSelected);
|
||||
setNeedsSaving();
|
||||
setNeedsReloading();
|
||||
setNeedsCollectionsUpdate();
|
||||
if (!mAddedCustomCollection)
|
||||
setNeedsGoToSystemView(SystemData::sSystemVector.front());
|
||||
}
|
||||
});
|
||||
|
||||
// Add "Create New Custom Collection from Theme".
|
||||
// Custom collections.
|
||||
collection_systems_custom = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||
std::map<std::string, CollectionSystemData, stringComparator> customSystems =
|
||||
CollectionSystemManager::get()->getCustomCollectionSystems();
|
||||
// Add custom systems.
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = customSystems.cbegin(); it != customSystems.cend() ; it++)
|
||||
collection_systems_custom->add(it->second.decl.longName, it->second.decl.name,
|
||||
it->second.isEnabled);
|
||||
addWithLabel("CUSTOM GAME COLLECTIONS", collection_systems_custom);
|
||||
addSaveFunc([this] {
|
||||
std::string customSystemsSelected = Utils::String::vectorToCommaString(
|
||||
collection_systems_custom->getSelectedObjects(), true);
|
||||
std::string customSystemsConfig = Settings::getInstance()->
|
||||
getString("CollectionSystemsCustom");
|
||||
if (customSystemsSelected != customSystemsConfig) {
|
||||
if (CollectionSystemManager::get()->isEditing())
|
||||
CollectionSystemManager::get()->exitEditMode();
|
||||
Settings::getInstance()->setString("CollectionSystemsCustom", customSystemsSelected);
|
||||
setNeedsSaving();
|
||||
setNeedsReloading();
|
||||
setNeedsCollectionsUpdate();
|
||||
if (!mAddedCustomCollection)
|
||||
setNeedsGoToSystemView(SystemData::sSystemVector.front());
|
||||
}
|
||||
});
|
||||
|
||||
// Create custom collection from theme.
|
||||
std::vector<std::string> unusedFolders =
|
||||
CollectionSystemManager::get()->getUnusedSystemsFromTheme();
|
||||
if (unusedFolders.size() > 0) {
|
||||
addEntry("CREATE NEW CUSTOM COLLECTION FROM THEME", 0x777777FF, true,
|
||||
[this, unusedFolders] {
|
||||
auto s = new GuiSettings(mWindow, "SELECT THEME FOLDER");
|
||||
std::shared_ptr< OptionListComponent<std::string>>
|
||||
folderThemes = std::make_shared< OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT THEME FOLDER", true);
|
||||
|
||||
ComponentListRow row;
|
||||
auto themeCollection = std::make_shared<TextComponent>(mWindow,
|
||||
"CREATE NEW CUSTOM COLLECTION FROM THEME", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||
auto bracketThemeCollection = std::make_shared<ImageComponent>(mWindow);
|
||||
bracketThemeCollection->setImage(":/graphics/arrow.svg");
|
||||
bracketThemeCollection->setResize(Vector2f(0,
|
||||
Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
|
||||
row.addElement(themeCollection, true);
|
||||
row.addElement(bracketThemeCollection, false);
|
||||
row.makeAcceptInputHandler([this, unusedFolders] {
|
||||
auto ss = new GuiSettings(mWindow, "SELECT THEME FOLDER");
|
||||
std::shared_ptr<OptionListComponent<std::string>> folderThemes =
|
||||
std::make_shared<OptionListComponent<std::string>>(mWindow,
|
||||
getHelpStyle(), "SELECT THEME FOLDER", true);
|
||||
// Add custom systems.
|
||||
for (auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) {
|
||||
ComponentListRow row;
|
||||
std::string name = *it;
|
||||
|
||||
std::function<void()> createCollectionCall = [name, this, s] {
|
||||
createCollection(name);
|
||||
std::function<void()> createCollectionCall = [this, name] {
|
||||
createCustomCollection(name);
|
||||
};
|
||||
row.makeAcceptInputHandler(createCollectionCall);
|
||||
|
||||
auto themeFolder = std::make_shared<TextComponent>(mWindow,
|
||||
Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF);
|
||||
row.addElement(themeFolder, true);
|
||||
s->addRow(row);
|
||||
ss->addRow(row);
|
||||
}
|
||||
mWindow->pushGui(s);
|
||||
mWindow->pushGui(ss);
|
||||
});
|
||||
addRow(row);
|
||||
}
|
||||
|
||||
// Create new custom collection.
|
||||
ComponentListRow row;
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow,
|
||||
"CREATE NEW CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||
bracket->setImage(":/graphics/arrow.svg");
|
||||
bracket->setResize(Vector2f(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
|
||||
row.addElement(bracket, false);
|
||||
auto createCustomCollection = [this](const std::string& newVal) {
|
||||
auto newCollection = std::make_shared<TextComponent>(mWindow,
|
||||
"CREATE NEW CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||
auto bracketNewCollection = std::make_shared<ImageComponent>(mWindow);
|
||||
bracketNewCollection->setImage(":/graphics/arrow.svg");
|
||||
bracketNewCollection->setResize(Vector2f(0,
|
||||
Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
|
||||
row.addElement(newCollection, true);
|
||||
row.addElement(bracketNewCollection, false);
|
||||
auto createCollectionCall = [this](const std::string& newVal) {
|
||||
std::string name = newVal;
|
||||
// We need to store the first GUI and remove it, as it'll
|
||||
// be deleted by the actual GUI.
|
||||
// We need to store the first GUI and remove it, as it'll be deleted
|
||||
// by the actual GUI.
|
||||
Window* window = mWindow;
|
||||
GuiComponent* topGui = window->peekGui();
|
||||
window->removeGui(topGui);
|
||||
createCollection(name);
|
||||
createCustomCollection(name);
|
||||
};
|
||||
row.makeAcceptInputHandler([this, createCustomCollection] {
|
||||
row.makeAcceptInputHandler([this, createCollectionCall] {
|
||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(),
|
||||
"New Collection Name", "", createCustomCollection, false, "SAVE"));
|
||||
"New Collection Name", "", createCollectionCall, false, "SAVE"));
|
||||
});
|
||||
addRow(row);
|
||||
|
||||
// Sort favorites on top for custom collections.
|
||||
auto fav_first_custom = std::make_shared<SwitchComponent>(mWindow);
|
||||
fav_first_custom->setState(Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", fav_first_custom);
|
||||
addSaveFunc([this, fav_first_custom] {
|
||||
if (fav_first_custom->getState() != Settings::getInstance()->getBool("FavFirstCustom")) {
|
||||
Settings::getInstance()->setBool("FavFirstCustom", fav_first_custom->getState());
|
||||
setNeedsSaving();
|
||||
setNeedsReloading();
|
||||
setNeedsSorting();
|
||||
setNeedsSortingCollections();
|
||||
}
|
||||
});
|
||||
|
||||
mMenu.addRow(row);
|
||||
// Display star markings for custom collections.
|
||||
auto fav_star_custom = std::make_shared<SwitchComponent>(mWindow);
|
||||
fav_star_custom->setState(Settings::getInstance()->getBool("FavStarCustom"));
|
||||
addWithLabel("DISPLAY STAR MARKINGS FOR CUSTOM COLLECTIONS", fav_star_custom);
|
||||
addSaveFunc([this, fav_star_custom] {
|
||||
if (fav_star_custom->getState() != Settings::getInstance()->getBool("FavStarCustom")) {
|
||||
Settings::getInstance()->setBool("FavStarCustom", fav_star_custom->getState());
|
||||
setNeedsSaving();
|
||||
setNeedsReloading();
|
||||
}
|
||||
});
|
||||
|
||||
sortFavFirstCustomSwitch = std::make_shared<SwitchComponent>(mWindow);
|
||||
sortFavFirstCustomSwitch->setState(Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
mMenu.addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", sortFavFirstCustomSwitch);
|
||||
|
||||
favoriteStarCustomSwitch = std::make_shared<SwitchComponent>(mWindow);
|
||||
favoriteStarCustomSwitch->setState(Settings::getInstance()->getBool("FavStarCustom"));
|
||||
mMenu.addWithLabel("DISPLAY STAR MARKINGS FOR CUSTOM COLLECTIONS", favoriteStarCustomSwitch);
|
||||
|
||||
bundleCustomCollections = std::make_shared<SwitchComponent>(mWindow);
|
||||
bundleCustomCollections->setState(Settings::getInstance()->
|
||||
// Group unthemed custom collections.
|
||||
auto use_custom_collections_system = std::make_shared<SwitchComponent>(mWindow);
|
||||
use_custom_collections_system->setState(Settings::getInstance()->
|
||||
getBool("UseCustomCollectionsSystem"));
|
||||
mMenu.addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", bundleCustomCollections);
|
||||
addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", use_custom_collections_system);
|
||||
addSaveFunc([this, use_custom_collections_system] {
|
||||
if (use_custom_collections_system->getState() !=
|
||||
Settings::getInstance()->getBool("UseCustomCollectionsSystem")) {
|
||||
Settings::getInstance()->setBool("UseCustomCollectionsSystem",
|
||||
use_custom_collections_system->getState());
|
||||
setNeedsSaving();
|
||||
setNeedsCollectionsUpdate();
|
||||
setNeedsReloading();
|
||||
setNeedsGoToSystemView(SystemData::sSystemVector.front());
|
||||
}
|
||||
});
|
||||
|
||||
toggleSystemNameInCollections = std::make_shared<SwitchComponent>(mWindow);
|
||||
toggleSystemNameInCollections->setState(Settings::getInstance()->
|
||||
// Show system names in collections.
|
||||
auto collection_show_system_info = std::make_shared<SwitchComponent>(mWindow);
|
||||
collection_show_system_info->setState(Settings::getInstance()->
|
||||
getBool("CollectionShowSystemInfo"));
|
||||
mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections);
|
||||
|
||||
if (CollectionSystemManager::get()->isEditing()) {
|
||||
row.elements.clear();
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" +
|
||||
Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) +
|
||||
"' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||
row.makeAcceptInputHandler(std::bind(&GuiCollectionSystemsOptions::exitEditMode, this));
|
||||
mMenu.addRow(row);
|
||||
addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", collection_show_system_info);
|
||||
addSaveFunc([this, collection_show_system_info] {
|
||||
if (collection_show_system_info->getState() !=
|
||||
Settings::getInstance()->getBool("CollectionShowSystemInfo")) {
|
||||
Settings::getInstance()->setBool("CollectionShowSystemInfo",
|
||||
collection_show_system_info->getState());
|
||||
setNeedsSaving();
|
||||
setNeedsReloading();
|
||||
}
|
||||
|
||||
mMenu.addButton("BACK", "back", std::bind(&GuiCollectionSystemsOptions::applySettings, this));
|
||||
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2,
|
||||
Renderer::getScreenHeight() * 0.15f);
|
||||
});
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::addEntry(const char* name, unsigned int color,
|
||||
bool add_arrow, const std::function<void()>& func)
|
||||
void GuiCollectionSystemsOptions::createCustomCollection(std::string inName)
|
||||
{
|
||||
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
||||
|
||||
// Populate the list.
|
||||
ComponentListRow row;
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true);
|
||||
|
||||
if (add_arrow) {
|
||||
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow);
|
||||
row.addElement(bracket, false);
|
||||
}
|
||||
|
||||
row.makeAcceptInputHandler(func);
|
||||
mMenu.addRow(row);
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::createCollection(std::string inName) {
|
||||
if (CollectionSystemManager::get()->isEditing())
|
||||
CollectionSystemManager::get()->exitEditMode();
|
||||
std::string name = CollectionSystemManager::get()->getValidNewCollectionName(inName);
|
||||
SystemData* newSys = CollectionSystemManager::get()->addNewCustomCollection(name);
|
||||
CollectionSystemManager::get()->saveCustomCollection(newSys);
|
||||
customOptionList->add(name, name, true);
|
||||
std::string outAuto = Utils::String::vectorToCommaString(
|
||||
autoOptionList->getSelectedObjects());
|
||||
std::vector<std::string> customSystems = customOptionList->getSelectedObjects();
|
||||
std::string outCustom = Utils::String::vectorToCommaString(customSystems, true);
|
||||
updateSettings(outAuto, outCustom);
|
||||
ViewController::get()->goToSystemView(newSys);
|
||||
|
||||
std::string collectionName = CollectionSystemManager::get()->
|
||||
getValidNewCollectionName(inName);
|
||||
SystemData* newCollection = CollectionSystemManager::get()->
|
||||
addNewCustomCollection(collectionName);
|
||||
|
||||
CollectionSystemManager::get()->saveCustomCollection(newCollection);
|
||||
collection_systems_custom->add(collectionName, collectionName, true);
|
||||
|
||||
mAddedCustomCollection = true;
|
||||
setNeedsGoToSystemView(newCollection);
|
||||
|
||||
Window* window = mWindow;
|
||||
CollectionSystemManager::get()->setEditMode(name);
|
||||
while (window->peekGui() && window->peekGui() != ViewController::get())
|
||||
delete window->peekGui();
|
||||
return;
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::exitEditMode()
|
||||
{
|
||||
CollectionSystemManager::get()->exitEditMode();
|
||||
applySettings();
|
||||
}
|
||||
|
||||
GuiCollectionSystemsOptions::~GuiCollectionSystemsOptions()
|
||||
{
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::addSystemsToMenu()
|
||||
{
|
||||
std::map<std::string, CollectionSystemData, stringComparator> autoSystems =
|
||||
CollectionSystemManager::get()->getAutoCollectionSystems();
|
||||
|
||||
autoOptionList = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||
|
||||
// Add automatic systems.
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = autoSystems.cbegin(); it != autoSystems.cend() ; it++)
|
||||
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
||||
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
|
||||
|
||||
std::map<std::string, CollectionSystemData, stringComparator> customSystems =
|
||||
CollectionSystemManager::get()->getCustomCollectionSystems();
|
||||
|
||||
customOptionList = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||
|
||||
// Add custom systems.
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = customSystems.cbegin(); it != customSystems.cend() ; it++)
|
||||
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
||||
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::applySettings()
|
||||
{
|
||||
std::string outAuto = Utils::String::vectorToCommaString(
|
||||
autoOptionList->getSelectedObjects());
|
||||
std::string prevAuto = Settings::getInstance()->getString("CollectionSystemsAuto");
|
||||
std::vector<std::string> customSystems = customOptionList->getSelectedObjects();
|
||||
std::string outCustom = Utils::String::vectorToCommaString(customSystems, true);
|
||||
std::string prevCustom = Settings::getInstance()->getString("CollectionSystemsCustom");
|
||||
bool outSort = sortFavFirstCustomSwitch->getState();
|
||||
bool prevSort = Settings::getInstance()->getBool("FavFirstCustom");
|
||||
bool outFavStar = favoriteStarCustomSwitch->getState();
|
||||
bool prevFavStar = Settings::getInstance()->getBool("FavStarCustom");
|
||||
bool outBundle = bundleCustomCollections->getState();
|
||||
bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem");
|
||||
bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo");
|
||||
bool outShow = toggleSystemNameInCollections->getState();
|
||||
bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort !=
|
||||
prevSort || outFavStar != prevFavStar || outBundle != prevBundle || prevShow != outShow;
|
||||
|
||||
if (needUpdateSettings)
|
||||
updateSettings(outAuto, outCustom);
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings,
|
||||
std::string newCustomSettings)
|
||||
{
|
||||
if (CollectionSystemManager::get()->isEditing())
|
||||
CollectionSystemManager::get()->exitEditMode();
|
||||
|
||||
Settings::getInstance()->setString("CollectionSystemsAuto", newAutoSettings);
|
||||
Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings);
|
||||
Settings::getInstance()->setBool("FavFirstCustom", sortFavFirstCustomSwitch->getState());
|
||||
Settings::getInstance()->setBool("FavStarCustom", favoriteStarCustomSwitch->getState());
|
||||
Settings::getInstance()->setBool("UseCustomCollectionsSystem",
|
||||
bundleCustomCollections->getState());
|
||||
Settings::getInstance()->setBool("CollectionShowSystemInfo",
|
||||
toggleSystemNameInCollections->getState());
|
||||
Settings::getInstance()->saveFile();
|
||||
CollectionSystemManager::get()->loadEnabledListFromSettings();
|
||||
CollectionSystemManager::get()->updateSystemsList();
|
||||
ViewController::get()->goToStart();
|
||||
ViewController::get()->reloadAll();
|
||||
mWindow->invalidateCachedBackground();
|
||||
}
|
||||
|
||||
bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
|
||||
{
|
||||
bool consumed = GuiComponent::input(config, input);
|
||||
|
||||
if (consumed)
|
||||
return true;
|
||||
|
||||
if (config->isMappedTo("b", input) && input.value != 0)
|
||||
applySettings();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> GuiCollectionSystemsOptions::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
||||
prompts.push_back(HelpPrompt("a", "select"));
|
||||
prompts.push_back(HelpPrompt("b", "back"));
|
||||
return prompts;
|
||||
}
|
||||
|
||||
HelpStyle GuiCollectionSystemsOptions::getHelpStyle()
|
||||
{
|
||||
HelpStyle style = HelpStyle();
|
||||
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
||||
return style;
|
||||
CollectionSystemManager::get()->setEditMode(collectionName);
|
||||
}
|
||||
|
|
|
@ -10,40 +10,23 @@
|
|||
#ifndef ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
||||
#define ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
||||
|
||||
#include "components/MenuComponent.h"
|
||||
#include "GuiSettings.h"
|
||||
|
||||
template<typename T>
|
||||
class OptionListComponent;
|
||||
class SwitchComponent;
|
||||
class SystemData;
|
||||
|
||||
class GuiCollectionSystemsOptions : public GuiComponent
|
||||
class GuiCollectionSystemsOptions : public GuiSettings
|
||||
{
|
||||
public:
|
||||
GuiCollectionSystemsOptions(Window* window);
|
||||
~GuiCollectionSystemsOptions();
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
|
||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
HelpStyle getHelpStyle() override;
|
||||
GuiCollectionSystemsOptions(Window* window, std::string title);
|
||||
|
||||
private:
|
||||
void initializeMenu();
|
||||
void applySettings();
|
||||
void addSystemsToMenu();
|
||||
void addEntry(const char* name, unsigned int color,
|
||||
bool add_arrow, const std::function<void()>& func);
|
||||
void updateSettings(std::string newAutoSettings, std::string newCustomSettings);
|
||||
void createCollection(std::string inName);
|
||||
void exitEditMode();
|
||||
std::shared_ptr<OptionListComponent<std::string>> autoOptionList;
|
||||
std::shared_ptr<OptionListComponent<std::string>> customOptionList;
|
||||
std::shared_ptr<SwitchComponent> bundleCustomCollections;
|
||||
std::shared_ptr<SwitchComponent> sortFavFirstCustomSwitch;
|
||||
std::shared_ptr<SwitchComponent> favoriteStarCustomSwitch;
|
||||
std::shared_ptr<SwitchComponent> toggleSystemNameInCollections;
|
||||
MenuComponent mMenu;
|
||||
SystemData* mSystem;
|
||||
void createCustomCollection(std::string inName);
|
||||
|
||||
std::shared_ptr<OptionListComponent<std::string>> collection_systems_auto;
|
||||
std::shared_ptr<OptionListComponent<std::string>> collection_systems_custom;
|
||||
|
||||
bool mAddedCustomCollection;
|
||||
};
|
||||
|
||||
#endif // ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
||||
|
|
|
@ -75,8 +75,7 @@ GuiMenu::~GuiMenu()
|
|||
|
||||
void GuiMenu::openScraperSettings()
|
||||
{
|
||||
// Open the scrape menu.
|
||||
mWindow->pushGui(new GuiScraperMenu(mWindow));
|
||||
mWindow->pushGui(new GuiScraperMenu(mWindow, "SCRAPER"));
|
||||
}
|
||||
|
||||
void GuiMenu::openUISettings()
|
||||
|
@ -163,7 +162,7 @@ void GuiMenu::openUISettings()
|
|||
CollectionSystemManager::get()->updateSystemsList();
|
||||
Settings::getInstance()->setString("ThemeSet", theme_set->getSelected());
|
||||
s->setNeedsSaving();
|
||||
s->setNeedsGoToStart();
|
||||
s->setNeedsGoToSystemView(SystemData::sSystemVector.front());
|
||||
s->setNeedsReloading();
|
||||
}
|
||||
});
|
||||
|
@ -894,12 +893,14 @@ void GuiMenu::addVersionInfo()
|
|||
addChild(&mVersion);
|
||||
}
|
||||
|
||||
void GuiMenu::openScreensaverOptions() {
|
||||
void GuiMenu::openScreensaverOptions()
|
||||
{
|
||||
mWindow->pushGui(new GuiScreensaverOptions(mWindow, "SCREENSAVER SETTINGS"));
|
||||
}
|
||||
|
||||
void GuiMenu::openCollectionSystemSettings() {
|
||||
mWindow->pushGui(new GuiCollectionSystemsOptions(mWindow));
|
||||
void GuiMenu::openCollectionSystemSettings()
|
||||
{
|
||||
mWindow->pushGui(new GuiCollectionSystemsOptions(mWindow, "GAME COLLECTION SETTINGS"));
|
||||
}
|
||||
|
||||
void GuiMenu::onSizeChanged()
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include "SystemData.h"
|
||||
#include "guis/GuiSettings.h"
|
||||
|
||||
GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window),
|
||||
mMenu(window, "SCRAPER")
|
||||
GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
|
||||
: GuiComponent(window), mMenu(window, title)
|
||||
{
|
||||
// Scraper service.
|
||||
mScraper = std::make_shared<OptionListComponent<std::string>>
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef std::function<bool(SystemData*, FileData*)> GameFilterFunc;
|
|||
class GuiScraperMenu : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiScraperMenu(Window* window);
|
||||
GuiScraperMenu(Window* window, std::string title);
|
||||
~GuiScraperMenu();
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
|
|
|
@ -13,20 +13,25 @@
|
|||
#include "guis/GuiTextEditPopup.h"
|
||||
#include "views/gamelist/IGameListView.h"
|
||||
#include "views/ViewController.h"
|
||||
#include "CollectionSystemManager.h"
|
||||
#include "Settings.h"
|
||||
#include "SystemData.h"
|
||||
#include "Window.h"
|
||||
|
||||
GuiSettings::GuiSettings(
|
||||
Window* window,
|
||||
const char* title)
|
||||
std::string title)
|
||||
: GuiComponent(window),
|
||||
mMenu(window, title),
|
||||
mNeedsSaving(false),
|
||||
mNeedsGoToStart(false),
|
||||
mNeedsCollectionsUpdate(false),
|
||||
mNeedsReloading(false),
|
||||
mNeedsSorting(false),
|
||||
mNeedsSortingCollections(false)
|
||||
mNeedsSortingCollections(false),
|
||||
mGoToSystem(nullptr),
|
||||
mNeedsGoToStart(false),
|
||||
mNeedsGoToSystemView(false),
|
||||
mNeedsDestroyAllWindows(false)
|
||||
{
|
||||
addChild(&mMenu);
|
||||
mMenu.addButton("BACK", "back", [this] { delete this; });
|
||||
|
@ -51,8 +56,10 @@ void GuiSettings::save()
|
|||
if (mNeedsSaving)
|
||||
Settings::getInstance()->saveFile();
|
||||
|
||||
if (mNeedsGoToStart)
|
||||
ViewController::get()->goToStart();
|
||||
if (mNeedsCollectionsUpdate) {
|
||||
CollectionSystemManager::get()->loadEnabledListFromSettings();
|
||||
CollectionSystemManager::get()->updateSystemsList();
|
||||
}
|
||||
|
||||
if (mNeedsReloading)
|
||||
ViewController::get()->reloadAll();
|
||||
|
@ -69,7 +76,19 @@ void GuiSettings::save()
|
|||
}
|
||||
}
|
||||
|
||||
if (mNeedsSaving || mNeedsGoToStart || mNeedsReloading || mNeedsSorting)
|
||||
if (mNeedsGoToStart)
|
||||
ViewController::get()->goToStart();
|
||||
|
||||
if (mNeedsGoToSystemView)
|
||||
ViewController::get()->goToSystemView(mGoToSystem);
|
||||
|
||||
if (mNeedsDestroyAllWindows) {
|
||||
while (mWindow->peekGui() && mWindow->peekGui() != ViewController::get())
|
||||
delete mWindow->peekGui();
|
||||
}
|
||||
|
||||
if (mNeedsSaving || mNeedsCollectionsUpdate || mNeedsReloading || mNeedsSorting ||
|
||||
mNeedsGoToStart || mNeedsGoToSystemView || mNeedsDestroyAllWindows)
|
||||
mWindow->invalidateCachedBackground();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
#define ES_APP_GUIS_GUI_SETTINGS_H
|
||||
|
||||
#include "components/MenuComponent.h"
|
||||
#include "SystemData.h"
|
||||
|
||||
// This is just a really simple template for a GUI that calls some save functions when closed.
|
||||
class GuiSettings : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiSettings(Window* window, const char* title);
|
||||
GuiSettings(Window* window, std::string title);
|
||||
virtual ~GuiSettings();
|
||||
|
||||
void save();
|
||||
|
@ -29,10 +30,14 @@ public:
|
|||
inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); };
|
||||
|
||||
void setNeedsSaving() { mNeedsSaving = true; };
|
||||
void setNeedsGoToStart() { mNeedsGoToStart = true; };
|
||||
void setNeedsCollectionsUpdate() { mNeedsCollectionsUpdate = true; };
|
||||
void setNeedsReloading() { mNeedsReloading = true; };
|
||||
void setNeedsSorting() { mNeedsSorting = true; };
|
||||
void setNeedsSortingCollections() { mNeedsSortingCollections = true; };
|
||||
void setNeedsGoToStart() { mNeedsGoToStart = true; };
|
||||
void setNeedsGoToSystemView(SystemData* goToSystem)
|
||||
{ mNeedsGoToSystemView = true; mGoToSystem = goToSystem; };
|
||||
void setNeedsDestroyAllWindows() { mNeedsDestroyAllWindows = true; };
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
|
@ -42,10 +47,15 @@ private:
|
|||
MenuComponent mMenu;
|
||||
std::vector<std::function<void()>> mSaveFuncs;
|
||||
bool mNeedsSaving;
|
||||
bool mNeedsGoToStart;
|
||||
bool mNeedsCollectionsUpdate;
|
||||
bool mNeedsReloading;
|
||||
bool mNeedsSorting;
|
||||
bool mNeedsSortingCollections;
|
||||
bool mNeedsGoToStart;
|
||||
bool mNeedsGoToSystemView;
|
||||
bool mNeedsDestroyAllWindows;
|
||||
|
||||
SystemData* mGoToSystem;
|
||||
};
|
||||
|
||||
#endif // ES_APP_GUIS_GUI_SETTINGS_H
|
||||
|
|
|
@ -154,6 +154,9 @@ void ViewController::goToSystemView(SystemData* system)
|
|||
mCurrentView->setRenderView(false);
|
||||
}
|
||||
|
||||
if (system->isGroupedCustomCollection())
|
||||
system = system->getRootFolder()->getParent()->getSystem();
|
||||
|
||||
mState.viewing = SYSTEM_SELECT;
|
||||
mState.system = system;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
MenuComponent::MenuComponent(
|
||||
Window* window,
|
||||
const char* title,
|
||||
std::string title,
|
||||
const std::shared_ptr<Font>& titleFont)
|
||||
: GuiComponent(window),
|
||||
mBackground(window),
|
||||
|
@ -66,7 +66,7 @@ void MenuComponent::save()
|
|||
}
|
||||
}
|
||||
|
||||
void MenuComponent::setTitle(const char* title, const std::shared_ptr<Font>& font)
|
||||
void MenuComponent::setTitle(std::string title, const std::shared_ptr<Font>& font)
|
||||
{
|
||||
mTitle->setText(Utils::String::toUpper(title));
|
||||
mTitle->setFont(font);
|
||||
|
|
|
@ -27,7 +27,7 @@ std::shared_ptr<ImageComponent> makeArrow(Window* window);
|
|||
class MenuComponent : public GuiComponent
|
||||
{
|
||||
public:
|
||||
MenuComponent(Window* window, const char* title,
|
||||
MenuComponent(Window* window, std::string title,
|
||||
const std::shared_ptr<Font>& titleFont = Font::get(FONT_SIZE_LARGE));
|
||||
virtual ~MenuComponent(); // just calls save();
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
void addButton(const std::string& label, const std::string& helpText,
|
||||
const std::function<void()>& callback);
|
||||
|
||||
void setTitle(const char* title, const std::shared_ptr<Font>& font);
|
||||
void setTitle(std::string title, const std::shared_ptr<Font>& font);
|
||||
|
||||
inline void setCursorToList() { mGrid.setCursorTo(mList); }
|
||||
inline void setCursorToButtons() { assert(mButtonGrid); mGrid.setCursorTo(mButtonGrid); }
|
||||
|
|
Loading…
Reference in a new issue