2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-22 15:27:53 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-22 15:27:53 +00:00
|
|
|
// GuiCollectionSystemsOptions.cpp
|
|
|
|
//
|
|
|
|
// User interface for the game collection settings.
|
2020-06-28 16:39:18 +00:00
|
|
|
// Submenu to the GuiMenu main menu.
|
2020-06-22 15:27:53 +00:00
|
|
|
//
|
|
|
|
|
2017-06-12 16:38:59 +00:00
|
|
|
#include "guis/GuiCollectionSystemsOptions.h"
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#include "CollectionSystemsManager.h"
|
2017-06-12 16:38:59 +00:00
|
|
|
#include "components/OptionListComponent.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "components/SwitchComponent.h"
|
2020-11-09 16:50:02 +00:00
|
|
|
#include "guis/GuiMsgBox.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "guis/GuiSettings.h"
|
2021-09-17 20:23:41 +00:00
|
|
|
#include "guis/GuiTextEditKeyboardPopup.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "guis/GuiTextEditPopup.h"
|
2021-01-01 16:18:04 +00:00
|
|
|
#include "utils/StringUtil.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "views/ViewController.h"
|
2017-06-12 16:38:59 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::string title)
|
|
|
|
: GuiSettings(window, title)
|
|
|
|
, mAddedCustomCollection(false)
|
|
|
|
, mDeletedCustomCollection(false)
|
2017-06-12 16:38:59 +00:00
|
|
|
{
|
2020-11-06 19:27:41 +00:00
|
|
|
// Finish editing custom collection.
|
2020-12-23 17:06:30 +00:00
|
|
|
if (CollectionSystemsManager::get()->isEditing()) {
|
2020-11-06 19:27:41 +00:00
|
|
|
ComponentListRow row;
|
2021-07-07 18:03:42 +00:00
|
|
|
row.addElement(std::make_shared<TextComponent>(
|
|
|
|
mWindow,
|
|
|
|
"FINISH EDITING '" +
|
|
|
|
Utils::String::toUpper(
|
|
|
|
CollectionSystemsManager::get()->getEditingCollection()) +
|
|
|
|
"' COLLECTION",
|
|
|
|
Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
|
|
|
|
true);
|
2020-11-06 19:27:41 +00:00
|
|
|
row.makeAcceptInputHandler([this] {
|
2020-12-23 17:06:30 +00:00
|
|
|
CollectionSystemsManager::get()->exitEditMode();
|
2020-12-31 15:40:08 +00:00
|
|
|
mWindow->invalidateCachedBackground();
|
2020-11-06 19:27:41 +00:00
|
|
|
delete this;
|
|
|
|
});
|
|
|
|
addRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Automatic collections.
|
2021-07-07 18:03:42 +00:00
|
|
|
collection_systems_auto = std::make_shared<OptionListComponent<std::string>>(
|
|
|
|
mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
2020-11-06 19:27:41 +00:00
|
|
|
std::map<std::string, CollectionSystemData, stringComparator> autoSystems =
|
2021-07-07 18:03:42 +00:00
|
|
|
CollectionSystemsManager::get()->getAutoCollectionSystems();
|
2020-11-06 19:27:41 +00:00
|
|
|
// Add automatic systems.
|
2021-07-07 18:03:42 +00:00
|
|
|
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
|
|
|
autoSystems.cbegin();
|
|
|
|
it != autoSystems.cend(); it++)
|
2020-11-06 19:27:41 +00:00
|
|
|
collection_systems_auto->add(it->second.decl.longName, it->second.decl.name,
|
2021-07-07 18:03:42 +00:00
|
|
|
it->second.isEnabled);
|
2020-11-06 19:27:41 +00:00
|
|
|
addWithLabel("AUTOMATIC GAME COLLECTIONS", collection_systems_auto);
|
2021-01-01 16:18:04 +00:00
|
|
|
addSaveFunc([this, autoSystems] {
|
2021-02-06 08:30:05 +00:00
|
|
|
std::string autoSystemsSelected = Utils::String::vectorToDelimitedString(
|
2021-07-07 18:03:42 +00:00
|
|
|
collection_systems_auto->getSelectedObjects(), ",", true);
|
2020-11-06 19:27:41 +00:00
|
|
|
std::string autoSystemsConfig = Settings::getInstance()->getString("CollectionSystemsAuto");
|
|
|
|
if (autoSystemsSelected != autoSystemsConfig) {
|
2020-12-23 17:06:30 +00:00
|
|
|
if (CollectionSystemsManager::get()->isEditing())
|
|
|
|
CollectionSystemsManager::get()->exitEditMode();
|
2020-11-06 19:27:41 +00:00
|
|
|
Settings::getInstance()->setString("CollectionSystemsAuto", autoSystemsSelected);
|
2021-01-01 16:18:04 +00:00
|
|
|
// Check if any systems have been enabled, and if so repopulate them, which results in
|
|
|
|
// a complete initialization of their content. This is necessary as collections aren't
|
|
|
|
// updated while they are disabled.
|
|
|
|
std::vector<std::string> addedAutoSystems;
|
|
|
|
if (autoSystemsConfig == "") {
|
|
|
|
addedAutoSystems = Utils::String::delimitedStringToVector(autoSystemsSelected, ",");
|
|
|
|
}
|
|
|
|
else if (autoSystemsSelected != "") {
|
|
|
|
std::vector<std::string> selectedVector =
|
2021-07-07 18:03:42 +00:00
|
|
|
Utils::String::delimitedStringToVector(autoSystemsSelected, ",");
|
2021-01-01 16:18:04 +00:00
|
|
|
std::vector<std::string> configuredVector =
|
2021-07-07 18:03:42 +00:00
|
|
|
Utils::String::delimitedStringToVector(autoSystemsConfig, ",");
|
2021-01-01 16:18:04 +00:00
|
|
|
for (std::string system : selectedVector) {
|
|
|
|
if (std::find(configuredVector.begin(), configuredVector.end(), system) ==
|
2021-07-07 18:03:42 +00:00
|
|
|
configuredVector.end())
|
2021-01-01 16:18:04 +00:00
|
|
|
addedAutoSystems.push_back(system);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!addedAutoSystems.empty()) {
|
|
|
|
for (std::string system : addedAutoSystems)
|
2021-07-07 18:03:42 +00:00
|
|
|
CollectionSystemsManager::get()->repopulateCollection(
|
|
|
|
autoSystems.find(system)->second.system);
|
2021-01-01 16:18:04 +00:00
|
|
|
}
|
2020-11-06 19:27:41 +00:00
|
|
|
setNeedsSaving();
|
|
|
|
setNeedsReloading();
|
|
|
|
setNeedsCollectionsUpdate();
|
|
|
|
}
|
|
|
|
});
|
2020-06-22 15:27:53 +00:00
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// Custom collections.
|
2021-07-07 18:03:42 +00:00
|
|
|
collection_systems_custom = std::make_shared<OptionListComponent<std::string>>(
|
|
|
|
mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
2020-11-06 19:27:41 +00:00
|
|
|
std::map<std::string, CollectionSystemData, stringComparator> customSystems =
|
2021-07-07 18:03:42 +00:00
|
|
|
CollectionSystemsManager::get()->getCustomCollectionSystems();
|
2020-11-06 19:27:41 +00:00
|
|
|
// Add custom systems.
|
2021-07-07 18:03:42 +00:00
|
|
|
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
|
|
|
customSystems.cbegin();
|
|
|
|
it != customSystems.cend(); it++)
|
2020-11-06 19:27:41 +00:00
|
|
|
collection_systems_custom->add(it->second.decl.longName, it->second.decl.name,
|
2021-07-07 18:03:42 +00:00
|
|
|
it->second.isEnabled);
|
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
addWithLabel("CUSTOM GAME COLLECTIONS", collection_systems_custom);
|
2021-01-01 16:18:04 +00:00
|
|
|
addSaveFunc([this, customSystems] {
|
2020-11-09 16:50:02 +00:00
|
|
|
if (!mDeletedCustomCollection) {
|
2021-02-06 08:30:05 +00:00
|
|
|
std::string customSystemsSelected = Utils::String::vectorToDelimitedString(
|
2021-07-07 18:03:42 +00:00
|
|
|
collection_systems_custom->getSelectedObjects(), ",", true);
|
|
|
|
std::string customSystemsConfig =
|
|
|
|
Settings::getInstance()->getString("CollectionSystemsCustom");
|
2020-11-09 16:50:02 +00:00
|
|
|
if (customSystemsSelected != customSystemsConfig) {
|
2020-12-23 17:06:30 +00:00
|
|
|
if (CollectionSystemsManager::get()->isEditing())
|
|
|
|
CollectionSystemsManager::get()->exitEditMode();
|
2020-11-09 16:50:02 +00:00
|
|
|
Settings::getInstance()->setString("CollectionSystemsCustom",
|
2021-07-07 18:03:42 +00:00
|
|
|
customSystemsSelected);
|
2021-01-01 16:18:04 +00:00
|
|
|
// Check if any systems have been enabled, and if so repopulate them, which
|
|
|
|
// results in a complete initialization of their content. This is necessary as
|
|
|
|
// collections aren't updated while they are disabled.
|
|
|
|
std::vector<std::string> addedCustomSystems;
|
|
|
|
if (customSystemsConfig == "") {
|
|
|
|
addedCustomSystems =
|
2021-07-07 18:03:42 +00:00
|
|
|
Utils::String::delimitedStringToVector(customSystemsSelected, ",");
|
2021-01-01 16:18:04 +00:00
|
|
|
}
|
|
|
|
else if (customSystemsSelected != "") {
|
|
|
|
std::vector<std::string> selectedVector =
|
2021-07-07 18:03:42 +00:00
|
|
|
Utils::String::delimitedStringToVector(customSystemsSelected, ",");
|
2021-01-01 16:18:04 +00:00
|
|
|
std::vector<std::string> configuredVector =
|
2021-07-07 18:03:42 +00:00
|
|
|
Utils::String::delimitedStringToVector(customSystemsConfig, ",");
|
2021-01-01 16:18:04 +00:00
|
|
|
for (std::string system : selectedVector) {
|
|
|
|
if (std::find(configuredVector.begin(), configuredVector.end(), system) ==
|
2021-07-07 18:03:42 +00:00
|
|
|
configuredVector.end())
|
2021-01-01 16:18:04 +00:00
|
|
|
addedCustomSystems.push_back(system);
|
|
|
|
}
|
|
|
|
}
|
2021-01-02 11:33:27 +00:00
|
|
|
if (!mAddedCustomCollection && !addedCustomSystems.empty()) {
|
2021-01-01 16:18:04 +00:00
|
|
|
for (std::string system : addedCustomSystems)
|
2021-07-07 18:03:42 +00:00
|
|
|
CollectionSystemsManager::get()->repopulateCollection(
|
|
|
|
customSystems.find(system)->second.system);
|
2021-01-01 16:18:04 +00:00
|
|
|
}
|
2020-11-09 16:50:02 +00:00
|
|
|
setNeedsSaving();
|
|
|
|
setNeedsReloading();
|
|
|
|
setNeedsCollectionsUpdate();
|
2021-01-02 11:33:27 +00:00
|
|
|
setNeedsGoToGroupedCollections();
|
2020-11-09 16:50:02 +00:00
|
|
|
}
|
2020-11-06 19:27:41 +00:00
|
|
|
}
|
|
|
|
});
|
2020-06-22 15:27:53 +00:00
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// Create custom collection from theme.
|
2020-06-22 15:27:53 +00:00
|
|
|
std::vector<std::string> unusedFolders =
|
2021-07-07 18:03:42 +00:00
|
|
|
CollectionSystemsManager::get()->getUnusedSystemsFromTheme();
|
2020-06-22 15:27:53 +00:00
|
|
|
if (unusedFolders.size() > 0) {
|
2020-11-06 19:27:41 +00:00
|
|
|
ComponentListRow row;
|
2021-07-07 18:03:42 +00:00
|
|
|
auto themeCollection =
|
|
|
|
std::make_shared<TextComponent>(mWindow, "CREATE NEW CUSTOM COLLECTION FROM THEME",
|
|
|
|
Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
2020-11-06 19:27:41 +00:00
|
|
|
auto bracketThemeCollection = std::make_shared<ImageComponent>(mWindow);
|
|
|
|
bracketThemeCollection->setImage(":/graphics/arrow.svg");
|
2021-07-07 18:03:42 +00:00
|
|
|
bracketThemeCollection->setResize(
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
2020-11-06 19:27:41 +00:00
|
|
|
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 =
|
2021-07-07 18:03:42 +00:00
|
|
|
std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
|
|
|
|
"SELECT THEME FOLDER", true);
|
2020-06-22 15:27:53 +00:00
|
|
|
// Add custom systems.
|
2021-07-07 18:03:42 +00:00
|
|
|
for (auto it = unusedFolders.cbegin(); it != unusedFolders.cend(); it++) {
|
2020-06-22 15:27:53 +00:00
|
|
|
ComponentListRow row;
|
|
|
|
std::string name = *it;
|
2020-11-06 19:27:41 +00:00
|
|
|
std::function<void()> createCollectionCall = [this, name] {
|
|
|
|
createCustomCollection(name);
|
2020-06-22 15:27:53 +00:00
|
|
|
};
|
|
|
|
row.makeAcceptInputHandler(createCollectionCall);
|
2021-07-07 18:03:42 +00:00
|
|
|
auto themeFolder = std::make_shared<TextComponent>(
|
|
|
|
mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF);
|
2020-06-22 15:27:53 +00:00
|
|
|
row.addElement(themeFolder, true);
|
2020-11-09 16:50:02 +00:00
|
|
|
// This transparent bracket is only added to generate the correct help prompts.
|
|
|
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
|
|
|
bracket->setImage(":/graphics/arrow.svg");
|
|
|
|
bracket->setOpacity(0);
|
|
|
|
row.addElement(bracket, false);
|
2020-11-06 19:27:41 +00:00
|
|
|
ss->addRow(row);
|
2020-06-22 15:27:53 +00:00
|
|
|
}
|
2020-11-06 19:27:41 +00:00
|
|
|
mWindow->pushGui(ss);
|
2020-06-22 15:27:53 +00:00
|
|
|
});
|
2020-11-06 19:27:41 +00:00
|
|
|
addRow(row);
|
2020-06-22 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// Create new custom collection.
|
2020-06-22 15:27:53 +00:00
|
|
|
ComponentListRow row;
|
2021-07-07 18:03:42 +00:00
|
|
|
auto newCollection = std::make_shared<TextComponent>(mWindow, "CREATE NEW CUSTOM COLLECTION",
|
|
|
|
Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
2020-11-06 19:27:41 +00:00
|
|
|
auto bracketNewCollection = std::make_shared<ImageComponent>(mWindow);
|
|
|
|
bracketNewCollection->setImage(":/graphics/arrow.svg");
|
2021-08-16 16:25:01 +00:00
|
|
|
bracketNewCollection->setResize(
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
2020-11-06 19:27:41 +00:00
|
|
|
row.addElement(newCollection, true);
|
|
|
|
row.addElement(bracketNewCollection, false);
|
|
|
|
auto createCollectionCall = [this](const std::string& newVal) {
|
2020-06-22 15:27:53 +00:00
|
|
|
std::string name = newVal;
|
2020-11-06 19:27:41 +00:00
|
|
|
// We need to store the first GUI and remove it, as it'll be deleted
|
|
|
|
// by the actual GUI.
|
2020-06-22 15:27:53 +00:00
|
|
|
Window* window = mWindow;
|
|
|
|
GuiComponent* topGui = window->peekGui();
|
|
|
|
window->removeGui(topGui);
|
2020-11-06 19:27:41 +00:00
|
|
|
createCustomCollection(name);
|
2020-06-22 15:27:53 +00:00
|
|
|
};
|
2021-09-17 20:23:41 +00:00
|
|
|
|
|
|
|
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
|
|
|
row.makeAcceptInputHandler([this, createCollectionCall] {
|
|
|
|
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
|
|
|
mWindow, getHelpStyle(), "New Collection Name", "", createCollectionCall, false,
|
|
|
|
"CREATE", "CREATE COLLECTION?"));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
row.makeAcceptInputHandler([this, createCollectionCall] {
|
|
|
|
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "New Collection Name",
|
|
|
|
"", createCollectionCall, false, "CREATE",
|
|
|
|
"CREATE COLLECTION?"));
|
|
|
|
});
|
|
|
|
}
|
2020-11-06 19:27:41 +00:00
|
|
|
addRow(row);
|
|
|
|
|
2020-11-09 16:50:02 +00:00
|
|
|
// Delete custom collection.
|
|
|
|
row.elements.clear();
|
2021-07-07 18:03:42 +00:00
|
|
|
auto deleteCollection = std::make_shared<TextComponent>(
|
|
|
|
mWindow, "DELETE CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
2020-11-09 16:50:02 +00:00
|
|
|
auto bracketDeleteCollection = std::make_shared<ImageComponent>(mWindow);
|
|
|
|
bracketDeleteCollection->setImage(":/graphics/arrow.svg");
|
2021-08-16 16:25:01 +00:00
|
|
|
bracketDeleteCollection->setResize(
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
2020-11-09 16:50:02 +00:00
|
|
|
row.addElement(deleteCollection, true);
|
|
|
|
row.addElement(bracketDeleteCollection, false);
|
|
|
|
row.makeAcceptInputHandler([this, customSystems] {
|
|
|
|
auto ss = new GuiSettings(mWindow, "SELECT COLLECTION TO DELETE");
|
|
|
|
std::shared_ptr<OptionListComponent<std::string>> customCollections =
|
2021-07-07 18:03:42 +00:00
|
|
|
std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), "", true);
|
|
|
|
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
|
|
|
customSystems.cbegin();
|
|
|
|
it != customSystems.cend(); it++) {
|
2020-11-09 16:50:02 +00:00
|
|
|
ComponentListRow row;
|
|
|
|
std::string name = (*it).first;
|
|
|
|
std::function<void()> deleteCollectionCall = [this, name] {
|
2021-07-07 18:03:42 +00:00
|
|
|
mWindow->pushGui(new GuiMsgBox(
|
|
|
|
mWindow, getHelpStyle(),
|
|
|
|
"THIS WILL PERMANENTLY\nDELETE THE COLLECTION\n'" +
|
|
|
|
Utils::String::toUpper(name) +
|
|
|
|
"'\n"
|
2020-11-09 16:50:02 +00:00
|
|
|
"ARE YOU SURE?",
|
2021-07-07 18:03:42 +00:00
|
|
|
"YES",
|
|
|
|
[this, name] {
|
|
|
|
if (CollectionSystemsManager::get()->isEditing())
|
|
|
|
CollectionSystemsManager::get()->exitEditMode();
|
|
|
|
mDeletedCustomCollection = true;
|
|
|
|
std::vector<std::string> selectedCustomCollections =
|
|
|
|
collection_systems_custom->getSelectedObjects();
|
|
|
|
std::string collectionsConfigEntry;
|
|
|
|
// Create the configuration file entry. If the collection to be
|
|
|
|
// deleted was activated, then exclude it.
|
|
|
|
for (auto it = selectedCustomCollections.begin();
|
|
|
|
it != selectedCustomCollections.end(); it++) {
|
|
|
|
if ((*it) != name) {
|
|
|
|
if ((*it) != selectedCustomCollections.front() &&
|
|
|
|
collectionsConfigEntry != "")
|
|
|
|
collectionsConfigEntry += ",";
|
|
|
|
collectionsConfigEntry += (*it);
|
2020-11-09 16:50:02 +00:00
|
|
|
}
|
2021-07-07 18:03:42 +00:00
|
|
|
}
|
|
|
|
// If the system to be deleted was present in es_settings.xml, we
|
|
|
|
// need to re-write it.
|
|
|
|
if (collectionsConfigEntry !=
|
|
|
|
Settings::getInstance()->getString("CollectionSystemsCustom")) {
|
|
|
|
Settings::getInstance()->setString("CollectionSystemsCustom",
|
|
|
|
collectionsConfigEntry);
|
|
|
|
setNeedsSaving();
|
|
|
|
setNeedsGoToStart();
|
|
|
|
}
|
|
|
|
CollectionSystemsManager::get()->deleteCustomCollection(name);
|
|
|
|
return true;
|
|
|
|
},
|
2021-09-19 12:37:10 +00:00
|
|
|
"NO", [] { return false; }));
|
2020-11-09 16:50:02 +00:00
|
|
|
};
|
|
|
|
row.makeAcceptInputHandler(deleteCollectionCall);
|
2021-07-07 18:03:42 +00:00
|
|
|
auto customCollection = std::make_shared<TextComponent>(
|
|
|
|
mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF);
|
2020-11-09 16:50:02 +00:00
|
|
|
row.addElement(customCollection, true);
|
|
|
|
// This transparent bracket is only added generate the correct help prompts.
|
|
|
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
|
|
|
bracket->setImage(":/graphics/arrow.svg");
|
|
|
|
bracket->setOpacity(0);
|
|
|
|
row.addElement(bracket, false);
|
|
|
|
ss->addRow(row);
|
|
|
|
}
|
|
|
|
mWindow->pushGui(ss);
|
|
|
|
});
|
|
|
|
addRow(row);
|
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// 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();
|
2021-03-21 17:46:45 +00:00
|
|
|
setInvalidateCachedBackground();
|
2020-11-06 19:27:41 +00:00
|
|
|
}
|
2020-06-22 15:27:53 +00:00
|
|
|
});
|
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// 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();
|
2021-03-21 17:46:45 +00:00
|
|
|
setInvalidateCachedBackground();
|
2020-11-06 19:27:41 +00:00
|
|
|
}
|
|
|
|
});
|
2020-10-25 20:29:54 +00:00
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// Group unthemed custom collections.
|
|
|
|
auto use_custom_collections_system = std::make_shared<SwitchComponent>(mWindow);
|
2021-07-07 18:03:42 +00:00
|
|
|
use_custom_collections_system->setState(
|
|
|
|
Settings::getInstance()->getBool("UseCustomCollectionsSystem"));
|
2020-11-06 19:27:41 +00:00
|
|
|
addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", use_custom_collections_system);
|
|
|
|
addSaveFunc([this, use_custom_collections_system] {
|
|
|
|
if (use_custom_collections_system->getState() !=
|
2021-07-07 18:03:42 +00:00
|
|
|
Settings::getInstance()->getBool("UseCustomCollectionsSystem")) {
|
2020-11-06 19:27:41 +00:00
|
|
|
Settings::getInstance()->setBool("UseCustomCollectionsSystem",
|
2021-07-07 18:03:42 +00:00
|
|
|
use_custom_collections_system->getState());
|
2021-03-12 19:16:02 +00:00
|
|
|
if (CollectionSystemsManager::get()->isEditing())
|
|
|
|
CollectionSystemsManager::get()->exitEditMode();
|
2020-11-06 19:27:41 +00:00
|
|
|
setNeedsSaving();
|
|
|
|
setNeedsCollectionsUpdate();
|
|
|
|
setNeedsReloading();
|
2021-01-01 21:37:21 +00:00
|
|
|
setNeedsGoToSystem(SystemData::sSystemVector.front());
|
2021-03-21 17:46:45 +00:00
|
|
|
setInvalidateCachedBackground();
|
2020-11-06 19:27:41 +00:00
|
|
|
}
|
|
|
|
});
|
2020-06-22 15:27:53 +00:00
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
// Show system names in collections.
|
|
|
|
auto collection_show_system_info = std::make_shared<SwitchComponent>(mWindow);
|
2021-07-07 18:03:42 +00:00
|
|
|
collection_show_system_info->setState(
|
|
|
|
Settings::getInstance()->getBool("CollectionShowSystemInfo"));
|
2020-11-06 19:27:41 +00:00
|
|
|
addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", collection_show_system_info);
|
|
|
|
addSaveFunc([this, collection_show_system_info] {
|
|
|
|
if (collection_show_system_info->getState() !=
|
2021-07-07 18:03:42 +00:00
|
|
|
Settings::getInstance()->getBool("CollectionShowSystemInfo")) {
|
2020-11-06 19:27:41 +00:00
|
|
|
Settings::getInstance()->setBool("CollectionShowSystemInfo",
|
2021-07-07 18:03:42 +00:00
|
|
|
collection_show_system_info->getState());
|
2020-11-06 19:27:41 +00:00
|
|
|
setNeedsSaving();
|
|
|
|
setNeedsReloading();
|
2021-03-21 17:46:45 +00:00
|
|
|
setInvalidateCachedBackground();
|
2020-11-06 19:27:41 +00:00
|
|
|
}
|
|
|
|
});
|
2017-06-12 16:38:59 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
void GuiCollectionSystemsOptions::createCustomCollection(std::string inName)
|
2017-07-18 09:45:50 +00:00
|
|
|
{
|
2020-12-23 17:06:30 +00:00
|
|
|
if (CollectionSystemsManager::get()->isEditing())
|
|
|
|
CollectionSystemsManager::get()->exitEditMode();
|
2017-07-18 09:45:50 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
std::string collectionName = CollectionSystemsManager::get()->getValidNewCollectionName(inName);
|
|
|
|
SystemData* newCollection =
|
|
|
|
CollectionSystemsManager::get()->addNewCustomCollection(collectionName);
|
2017-07-18 09:45:50 +00:00
|
|
|
|
2020-12-23 17:06:30 +00:00
|
|
|
CollectionSystemsManager::get()->saveCustomCollection(newCollection);
|
2020-11-06 19:27:41 +00:00
|
|
|
collection_systems_custom->add(collectionName, collectionName, true);
|
2017-07-18 09:45:50 +00:00
|
|
|
|
2020-11-06 19:27:41 +00:00
|
|
|
mAddedCustomCollection = true;
|
2021-01-02 11:33:27 +00:00
|
|
|
setNeedsGoToStart();
|
|
|
|
|
|
|
|
if (Settings::getInstance()->getBool("UseCustomCollectionsSystem"))
|
|
|
|
setNeedsGoToGroupedCollections();
|
|
|
|
else
|
|
|
|
setNeedsGoToSystem(newCollection);
|
2020-06-22 15:27:53 +00:00
|
|
|
|
|
|
|
Window* window = mWindow;
|
2020-07-13 18:58:25 +00:00
|
|
|
while (window->peekGui() && window->peekGui() != ViewController::get())
|
2020-06-22 15:27:53 +00:00
|
|
|
delete window->peekGui();
|
2020-12-23 17:06:30 +00:00
|
|
|
CollectionSystemsManager::get()->setEditMode(collectionName);
|
2020-06-07 18:09:02 +00:00
|
|
|
}
|