The scraper filter setting is now retained throughout the program session.

This commit is contained in:
Leon Styhre 2020-12-16 17:35:23 +01:00
parent 98d99ef8bb
commit 0c7e02e6f4
3 changed files with 30 additions and 21 deletions

View file

@ -31,18 +31,12 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
for (auto it = scrapers.cbegin(); it != scrapers.cend(); it++) for (auto it = scrapers.cbegin(); it != scrapers.cend(); it++)
mScraper->add(*it, *it, *it == Settings::getInstance()->getString("Scraper")); mScraper->add(*it, *it, *it == Settings::getInstance()->getString("Scraper"));
mMenu.addWithLabel("SCRAPE FROM", mScraper); 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 // Search filters, getSearches() will generate a queue of games to scrape
// based on the outcome of the checks below. // based on the outcome of the checks below.
mFilters = std::make_shared< OptionListComponent<GameFilterFunc>> mFilters = std::make_shared< OptionListComponent<GameFilterFunc>>
(mWindow, getHelpStyle(), "SCRAPE THESE GAMES", false); (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 { mFilters->add("FAVORITE GAMES", [](SystemData*, FileData* g) -> bool {
return g->getFavorite(); }, false); return g->getFavorite(); }, false);
mFilters->add("NO METADATA", [](SystemData*, FileData* g) -> bool { mFilters->add("NO METADATA", [](SystemData*, FileData* g) -> bool {
@ -56,8 +50,21 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
mFilters->add("FOLDERS ONLY", mFilters->add("FOLDERS ONLY",
[](SystemData*, FileData* g) -> bool { [](SystemData*, FileData* g) -> bool {
return g->getType() == FOLDER; }, false); return g->getType() == FOLDER; }, false);
mFilters->selectEntry(Settings::getInstance()->getInt("ScraperFilter"));
mMenu.addWithLabel("Filter", mFilters); 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). // Add systems (all systems with an existing platform ID are listed).
mSystems = std::make_shared< OptionListComponent<SystemData*>> mSystems = std::make_shared< OptionListComponent<SystemData*>>
(mWindow, getHelpStyle(), "SCRAPE THESE SYSTEMS", true); (mWindow, getHelpStyle(), "SCRAPE THESE SYSTEMS", true);
@ -535,8 +542,8 @@ void GuiScraperMenu::pressedStart()
void GuiScraperMenu::start() void GuiScraperMenu::start()
{ {
std::queue<ScraperSearchParams> searches = getSearches(mSystems->getSelectedObjects(), std::queue<ScraperSearchParams> searches =
mFilters->getSelected()); getSearches(mSystems->getSelectedObjects(), mFilters->getSelected());
if (searches.empty()) { if (searches.empty()) {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),

View file

@ -52,7 +52,8 @@ std::vector<std::string> settings_dont_save {
"DebugGrid", "DebugGrid",
"DebugText", "DebugText",
"DebugImage", "DebugImage",
"SplashScreenProgress" "SplashScreenProgress",
"ScraperFilter"
}; };
Settings::Settings() Settings::Settings()
@ -275,6 +276,7 @@ void Settings::setDefaults()
mBoolMap["DebugText"] = { false, false }; mBoolMap["DebugText"] = { false, false };
mBoolMap["DebugImage"] = { false, false }; mBoolMap["DebugImage"] = { false, false };
mBoolMap["SplashScreenProgress"] = { true, true }; mBoolMap["SplashScreenProgress"] = { true, true };
mIntMap["ScraperFilter"] = { 0, 0 };
mStringMap["UIMode_passkey"] = { "uuddlrlrba", "uuddlrlrba" }; mStringMap["UIMode_passkey"] = { "uuddlrlrba", "uuddlrlrba" };
} }

View file

@ -208,17 +208,6 @@ public:
[](OptionListData a, OptionListData b) { return a.name < b.name; }); [](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() unsigned int getSelectedId()
{ {
assert(mMultiSelect == false); assert(mMultiSelect == false);
@ -232,6 +221,17 @@ private:
return 0; return 0;
} }
HelpStyle getHelpStyle() override { return mHelpStyle; };
private:
struct OptionListData {
std::string name;
T object;
bool selected;
};
HelpStyle mHelpStyle;
void open() void open()
{ {
mWindow->pushGui(new OptionListPopup(mWindow, getHelpStyle(), this, mName)); mWindow->pushGui(new OptionListPopup(mWindow, getHelpStyle(), this, mName));