2014-06-25 16:29:58 +00:00
|
|
|
#include "guis/GuiSettings.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "views/ViewController.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Settings.h"
|
|
|
|
#include "SystemData.h"
|
|
|
|
#include "Window.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
GuiSettings::GuiSettings(Window* window, const char* title) : GuiComponent(window), mMenu(window, title)
|
|
|
|
{
|
|
|
|
addChild(&mMenu);
|
|
|
|
|
2020-06-09 18:03:31 +00:00
|
|
|
mMenu.addButton("BACK", "back", [this] { delete this; });
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
|
|
|
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
|
|
|
|
}
|
|
|
|
|
|
|
|
GuiSettings::~GuiSettings()
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiSettings::save()
|
|
|
|
{
|
|
|
|
if(!mSaveFuncs.size())
|
|
|
|
return;
|
|
|
|
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
|
2014-06-25 16:29:58 +00:00
|
|
|
(*it)();
|
|
|
|
|
|
|
|
Settings::getInstance()->saveFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiSettings::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
if(config->isMappedTo("b", input) && input.value != 0)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-09 18:03:31 +00:00
|
|
|
// Keep code for potential future use.
|
|
|
|
// if(config->isMappedTo("start", input) && input.value != 0)
|
|
|
|
// {
|
|
|
|
// // close everything
|
|
|
|
// Window* window = mWindow;
|
|
|
|
// while(window->peekGui() && window->peekGui() != ViewController::get())
|
|
|
|
// delete window->peekGui();
|
|
|
|
// return true;
|
|
|
|
// }
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
return GuiComponent::input(config, input);
|
|
|
|
}
|
|
|
|
|
2017-05-28 18:13:00 +00:00
|
|
|
HelpStyle GuiSettings::getHelpStyle()
|
|
|
|
{
|
|
|
|
HelpStyle style = HelpStyle();
|
|
|
|
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
std::vector<HelpPrompt> GuiSettings::getHelpPrompts()
|
|
|
|
{
|
|
|
|
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
|
|
|
prompts.push_back(HelpPrompt("b", "back"));
|
|
|
|
return prompts;
|
|
|
|
}
|