Commit 6a38a143 authored by Jean-Baptiste Demonte's avatar Jean-Baptiste Demonte

feat(demo): Add system selection for demo

parent c7c5e654
......@@ -765,6 +765,20 @@ void GuiMenu::menuUISettings(){
Settings::getInstance()->setString("ScreenSaverBehavior", screensaver_behavior->getSelected());
});
// add systems (all with a platformid specified selected)
auto systems = std::make_shared< OptionListComponent<std::string> >(mWindow, _("SYSTEMS TO SHOW IN DEMO"), true);
for (auto& it : SystemData::sSystemVector)
{
if (!it->hasPlatformId(PlatformIds::PLATFORM_IGNORE))
systems->add(it->getFullName(), it->getName(), RecalboxConf::getInstance()->isInList("global.demo.systemlist", it->getName()) && !it->getPlatformIds().empty());
}
s->addWithLabel(systems, _("SYSTEMS FOR DEMO"));
s->addSaveFunc([systems] {
std::vector<std::string> names = systems->getSelectedObjects();
RecalboxConf::getInstance()->setList("global.demo.systemlist", names);
});
// display clock
auto show_time = std::make_shared<SwitchComponent>(mWindow);
show_time->setState(Settings::getInstance()->getBool("ShowClock"));
......@@ -1096,6 +1110,10 @@ void GuiMenu::menuUISettings(){
}, _("NO"), nullptr));
}, _(MenuMessages::UI_UPDATE_GAMELIST_HELP_MSG));
s->addSaveFunc([] {
RecalboxConf::getInstance()->saveRecalboxConf();
});
mWindow->pushGui(s);
}
......
......@@ -146,6 +146,28 @@ void RecalboxConf::setUInt(const std::string &name, unsigned int value) {
confMap[name] = std::to_string(value).c_str();
}
/**
* Join a list using the , as delimiter, removing all empty values
*/
void RecalboxConf::setList(const std::string &name, const std::vector<std::string> &values) {
std::stringstream ss;
std::string delimiter = ",";
bool addDelimiter = false;
for (auto & value: values)
{
if (value.length())
{
if (addDelimiter)
ss << delimiter;
ss << value;
addDelimiter = true;
}
}
confMap[name] = ss.str();
}
bool RecalboxConf::isInList(const std::string &name, const std::string &value) {
bool result = false;
if (confMap.count(name)) {
......
......@@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include <map>
class RecalboxConf {
......@@ -28,6 +29,7 @@ public:
void set(const std::string &name, const std::string &value);
void setBool(const std::string &name, bool value);
void setUInt(const std::string &name, unsigned int value);
void setList(const std::string &name, const std::vector<std::string> &values);
bool isInList(const std::string &name, const std::string &value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment