From bff7920f1422a37e03020853832ea4cfd326df3e Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 16 Oct 2013 17:14:50 -0500 Subject: [PATCH] Added "Scrape Ratings" option to settings menu. Finally changed the stupid "SAVE" label hack to an actual ButtonComponent. --- src/components/GuiSettingsMenu.cpp | 36 ++++++++++++++++++------------ src/components/GuiSettingsMenu.h | 6 +++-- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/GuiSettingsMenu.cpp b/src/components/GuiSettingsMenu.cpp index af4106653..0b2ea8feb 100644 --- a/src/components/GuiSettingsMenu.cpp +++ b/src/components/GuiSettingsMenu.cpp @@ -7,13 +7,14 @@ #include "../scrapers/GamesDBScraper.h" GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window), - mList(window, Eigen::Vector2i(2, 5)), + mList(window, Eigen::Vector2i(2, 6)), mBox(mWindow, ":/frame.png", 0x444444FF), mDrawFramerateSwitch(window), mVolumeSlider(window, 0, 100, 1), mDisableSoundsSwitch(window, false), - mSaveLabel(window), - mScraperOptList(window) + mScraperOptList(window), + mScrapeRatingsSwitch(window), + mSaveButton(window) { loadStates(); @@ -70,10 +71,19 @@ GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window), mList.setEntry(Vector2i(1, 3), Vector2i(1, 1), &mScraperOptList, true, ComponentListComponent::AlignCenter); - //save label - mSaveLabel.setText("SAVE"); - mSaveLabel.setColor(0x000000FF); - mList.setEntry(Vector2i(0, 4), Vector2i(2, 1), &mSaveLabel, true, ComponentListComponent::AlignCenter, Matrix(false, true)); + //scrape ratings label + label = new TextComponent(mWindow); + label->setText("Scrape ratings? "); + label->setColor(0x0000FFFF); + mLabels.push_back(label); + mList.setEntry(Vector2i(0, 4), Vector2i(1, 1), label, false, ComponentListComponent::AlignRight); + + mList.setEntry(Vector2i(1, 4), Vector2i(1, 1), &mScrapeRatingsSwitch, true, ComponentListComponent::AlignCenter); + + //save button + mSaveButton.setText("SAVE", 0x00FF00FF); + mSaveButton.setPressedFunc([this] () { applyStates(); delete this; }); + mList.setEntry(Vector2i(0, 5), Vector2i(2, 1), &mSaveButton, true, ComponentListComponent::AlignCenter, Matrix(false, true)); //center list mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, Renderer::getScreenHeight() / 2 - mList.getSize().y() / 2); @@ -96,19 +106,13 @@ bool GuiSettingsMenu::input(InputConfig* config, Input input) if(GuiComponent::input(config, input)) return true; + //cancel if b is pressed if(config->isMappedTo("b", input) && input.value) { delete this; return true; } - if(config->isMappedTo("a", input) && mList.getSelectedComponent() == &mSaveLabel && input.value) - { - applyStates(); - delete this; - return true; - } - return false; } @@ -120,6 +124,8 @@ void GuiSettingsMenu::loadStates() mVolumeSlider.setValue((float)VolumeControl::getInstance()->getVolume()); mDisableSoundsSwitch.setState(s->getBool("DISABLESOUNDS")); + + mScrapeRatingsSwitch.setState(s->getBool("ScrapeRatings")); } void GuiSettingsMenu::applyStates() @@ -134,5 +140,7 @@ void GuiSettingsMenu::applyStates() if(mScraperOptList.getSelected().size() > 0) s->setScraper(mScraperOptList.getSelected()[0]->object); + s->setBool("ScrapeRatings", mScrapeRatingsSwitch.getState()); + s->saveFile(); } diff --git a/src/components/GuiSettingsMenu.h b/src/components/GuiSettingsMenu.h index 2f85bb34f..a55258f90 100644 --- a/src/components/GuiSettingsMenu.h +++ b/src/components/GuiSettingsMenu.h @@ -9,6 +9,7 @@ #include "TextComponent.h" #include "NinePatchComponent.h" #include "OptionListComponent.h" +#include "ButtonComponent.h" #include "../scrapers/Scraper.h" class GuiSettingsMenu : public GuiComponent @@ -31,8 +32,9 @@ private: SliderComponent mVolumeSlider; SwitchComponent mDisableSoundsSwitch; OptionListComponent< std::shared_ptr > mScraperOptList; - TextComponent mSaveLabel; - + SwitchComponent mScrapeRatingsSwitch; + ButtonComponent mSaveButton; + std::vector mLabels; };