mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
The scraper filter setting is now retained throughout the program session.
This commit is contained in:
parent
98d99ef8bb
commit
0c7e02e6f4
|
@ -31,18 +31,12 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
|
|||
for (auto it = scrapers.cbegin(); it != scrapers.cend(); it++)
|
||||
mScraper->add(*it, *it, *it == Settings::getInstance()->getString("Scraper"));
|
||||
mMenu.addWithLabel("SCRAPE FROM", mScraper);
|
||||
mMenu.addSaveFunc([this] {
|
||||
if (mScraper->getSelected() != Settings::getInstance()->getString("Scraper")) {
|
||||
Settings::getInstance()->setString("Scraper", mScraper->getSelected());
|
||||
mMenu.setNeedsSaving();
|
||||
}
|
||||
});
|
||||
|
||||
// Search filters, getSearches() will generate a queue of games to scrape
|
||||
// based on the outcome of the checks below.
|
||||
mFilters = std::make_shared< OptionListComponent<GameFilterFunc>>
|
||||
(mWindow, getHelpStyle(), "SCRAPE THESE GAMES", false);
|
||||
mFilters->add("ALL GAMES", [](SystemData*, FileData*) -> bool { return true; }, true);
|
||||
mFilters->add("ALL GAMES", [](SystemData*, FileData*) -> bool { return true; }, false);
|
||||
mFilters->add("FAVORITE GAMES", [](SystemData*, FileData* g) -> bool {
|
||||
return g->getFavorite(); }, false);
|
||||
mFilters->add("NO METADATA", [](SystemData*, FileData* g) -> bool {
|
||||
|
@ -56,8 +50,21 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
|
|||
mFilters->add("FOLDERS ONLY",
|
||||
[](SystemData*, FileData* g) -> bool {
|
||||
return g->getType() == FOLDER; }, false);
|
||||
|
||||
mFilters->selectEntry(Settings::getInstance()->getInt("ScraperFilter"));
|
||||
mMenu.addWithLabel("Filter", mFilters);
|
||||
|
||||
mMenu.addSaveFunc([this] {
|
||||
if (mScraper->getSelected() != Settings::getInstance()->getString("Scraper")) {
|
||||
Settings::getInstance()->setString("Scraper", mScraper->getSelected());
|
||||
mMenu.setNeedsSaving();
|
||||
}
|
||||
// The filter setting is only retained during the program session i.e. it's not saved
|
||||
// to es_settings.cfg.
|
||||
if (mFilters->getSelectedId() != Settings::getInstance()->getInt("ScraperFilter"))
|
||||
Settings::getInstance()->setInt("ScraperFilter", mFilters->getSelectedId());
|
||||
});
|
||||
|
||||
// Add systems (all systems with an existing platform ID are listed).
|
||||
mSystems = std::make_shared< OptionListComponent<SystemData*>>
|
||||
(mWindow, getHelpStyle(), "SCRAPE THESE SYSTEMS", true);
|
||||
|
@ -535,8 +542,8 @@ void GuiScraperMenu::pressedStart()
|
|||
|
||||
void GuiScraperMenu::start()
|
||||
{
|
||||
std::queue<ScraperSearchParams> searches = getSearches(mSystems->getSelectedObjects(),
|
||||
mFilters->getSelected());
|
||||
std::queue<ScraperSearchParams> searches =
|
||||
getSearches(mSystems->getSelectedObjects(), mFilters->getSelected());
|
||||
|
||||
if (searches.empty()) {
|
||||
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
||||
|
|
|
@ -52,7 +52,8 @@ std::vector<std::string> settings_dont_save {
|
|||
"DebugGrid",
|
||||
"DebugText",
|
||||
"DebugImage",
|
||||
"SplashScreenProgress"
|
||||
"SplashScreenProgress",
|
||||
"ScraperFilter"
|
||||
};
|
||||
|
||||
Settings::Settings()
|
||||
|
@ -275,6 +276,7 @@ void Settings::setDefaults()
|
|||
mBoolMap["DebugText"] = { false, false };
|
||||
mBoolMap["DebugImage"] = { false, false };
|
||||
mBoolMap["SplashScreenProgress"] = { true, true };
|
||||
mIntMap["ScraperFilter"] = { 0, 0 };
|
||||
mStringMap["UIMode_passkey"] = { "uuddlrlrba", "uuddlrlrba" };
|
||||
}
|
||||
|
||||
|
|
|
@ -208,17 +208,6 @@ public:
|
|||
[](OptionListData a, OptionListData b) { return a.name < b.name; });
|
||||
}
|
||||
|
||||
HelpStyle getHelpStyle() override { return mHelpStyle; };
|
||||
|
||||
private:
|
||||
struct OptionListData {
|
||||
std::string name;
|
||||
T object;
|
||||
bool selected;
|
||||
};
|
||||
|
||||
HelpStyle mHelpStyle;
|
||||
|
||||
unsigned int getSelectedId()
|
||||
{
|
||||
assert(mMultiSelect == false);
|
||||
|
@ -232,6 +221,17 @@ private:
|
|||
return 0;
|
||||
}
|
||||
|
||||
HelpStyle getHelpStyle() override { return mHelpStyle; };
|
||||
|
||||
private:
|
||||
struct OptionListData {
|
||||
std::string name;
|
||||
T object;
|
||||
bool selected;
|
||||
};
|
||||
|
||||
HelpStyle mHelpStyle;
|
||||
|
||||
void open()
|
||||
{
|
||||
mWindow->pushGui(new OptionListPopup(mWindow, getHelpStyle(), this, mName));
|
||||
|
|
Loading…
Reference in a new issue