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