mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Added "Scrape Ratings" option to settings menu.
Finally changed the stupid "SAVE" label hack to an actual ButtonComponent.
This commit is contained in:
parent
56b04aec4c
commit
bff7920f14
|
@ -7,13 +7,14 @@
|
||||||
#include "../scrapers/GamesDBScraper.h"
|
#include "../scrapers/GamesDBScraper.h"
|
||||||
|
|
||||||
GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
||||||
mList(window, Eigen::Vector2i(2, 5)),
|
mList(window, Eigen::Vector2i(2, 6)),
|
||||||
mBox(mWindow, ":/frame.png", 0x444444FF),
|
mBox(mWindow, ":/frame.png", 0x444444FF),
|
||||||
mDrawFramerateSwitch(window),
|
mDrawFramerateSwitch(window),
|
||||||
mVolumeSlider(window, 0, 100, 1),
|
mVolumeSlider(window, 0, 100, 1),
|
||||||
mDisableSoundsSwitch(window, false),
|
mDisableSoundsSwitch(window, false),
|
||||||
mSaveLabel(window),
|
mScraperOptList(window),
|
||||||
mScraperOptList(window)
|
mScrapeRatingsSwitch(window),
|
||||||
|
mSaveButton(window)
|
||||||
{
|
{
|
||||||
loadStates();
|
loadStates();
|
||||||
|
|
||||||
|
@ -70,10 +71,19 @@ GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
||||||
|
|
||||||
mList.setEntry(Vector2i(1, 3), Vector2i(1, 1), &mScraperOptList, true, ComponentListComponent::AlignCenter);
|
mList.setEntry(Vector2i(1, 3), Vector2i(1, 1), &mScraperOptList, true, ComponentListComponent::AlignCenter);
|
||||||
|
|
||||||
//save label
|
//scrape ratings label
|
||||||
mSaveLabel.setText("SAVE");
|
label = new TextComponent(mWindow);
|
||||||
mSaveLabel.setColor(0x000000FF);
|
label->setText("Scrape ratings? ");
|
||||||
mList.setEntry(Vector2i(0, 4), Vector2i(2, 1), &mSaveLabel, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(false, true));
|
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<bool, 1, 2>(false, true));
|
||||||
|
|
||||||
//center list
|
//center list
|
||||||
mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, Renderer::getScreenHeight() / 2 - mList.getSize().y() / 2);
|
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))
|
if(GuiComponent::input(config, input))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//cancel if b is pressed
|
||||||
if(config->isMappedTo("b", input) && input.value)
|
if(config->isMappedTo("b", input) && input.value)
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->isMappedTo("a", input) && mList.getSelectedComponent() == &mSaveLabel && input.value)
|
|
||||||
{
|
|
||||||
applyStates();
|
|
||||||
delete this;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +124,8 @@ void GuiSettingsMenu::loadStates()
|
||||||
mVolumeSlider.setValue((float)VolumeControl::getInstance()->getVolume());
|
mVolumeSlider.setValue((float)VolumeControl::getInstance()->getVolume());
|
||||||
|
|
||||||
mDisableSoundsSwitch.setState(s->getBool("DISABLESOUNDS"));
|
mDisableSoundsSwitch.setState(s->getBool("DISABLESOUNDS"));
|
||||||
|
|
||||||
|
mScrapeRatingsSwitch.setState(s->getBool("ScrapeRatings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiSettingsMenu::applyStates()
|
void GuiSettingsMenu::applyStates()
|
||||||
|
@ -134,5 +140,7 @@ void GuiSettingsMenu::applyStates()
|
||||||
if(mScraperOptList.getSelected().size() > 0)
|
if(mScraperOptList.getSelected().size() > 0)
|
||||||
s->setScraper(mScraperOptList.getSelected()[0]->object);
|
s->setScraper(mScraperOptList.getSelected()[0]->object);
|
||||||
|
|
||||||
|
s->setBool("ScrapeRatings", mScrapeRatingsSwitch.getState());
|
||||||
|
|
||||||
s->saveFile();
|
s->saveFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "TextComponent.h"
|
#include "TextComponent.h"
|
||||||
#include "NinePatchComponent.h"
|
#include "NinePatchComponent.h"
|
||||||
#include "OptionListComponent.h"
|
#include "OptionListComponent.h"
|
||||||
|
#include "ButtonComponent.h"
|
||||||
#include "../scrapers/Scraper.h"
|
#include "../scrapers/Scraper.h"
|
||||||
|
|
||||||
class GuiSettingsMenu : public GuiComponent
|
class GuiSettingsMenu : public GuiComponent
|
||||||
|
@ -31,8 +32,9 @@ private:
|
||||||
SliderComponent mVolumeSlider;
|
SliderComponent mVolumeSlider;
|
||||||
SwitchComponent mDisableSoundsSwitch;
|
SwitchComponent mDisableSoundsSwitch;
|
||||||
OptionListComponent< std::shared_ptr<Scraper> > mScraperOptList;
|
OptionListComponent< std::shared_ptr<Scraper> > mScraperOptList;
|
||||||
TextComponent mSaveLabel;
|
SwitchComponent mScrapeRatingsSwitch;
|
||||||
|
ButtonComponent mSaveButton;
|
||||||
|
|
||||||
std::vector<GuiComponent*> mLabels;
|
std::vector<GuiComponent*> mLabels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue