2021-07-23 08:24:00 +01:00
|
|
|
/*
|
|
|
|
* options_tab.cpp
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
|
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
|
|
|
* nxdumptool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* nxdumptool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <nxdt_utils.h>
|
|
|
|
#include <options_tab.hpp>
|
|
|
|
#include <title.h>
|
|
|
|
|
|
|
|
using namespace brls::i18n::literals; /* For _i18n. */
|
|
|
|
|
|
|
|
namespace nxdt::views
|
|
|
|
{
|
|
|
|
OptionsTab::OptionsTab(void) : brls::List()
|
|
|
|
{
|
|
|
|
/* Set custom spacing. */
|
|
|
|
this->setSpacing(this->getSpacing() / 2);
|
|
|
|
this->setMarginBottom(20);
|
|
|
|
|
2021-07-25 06:37:13 +01:00
|
|
|
/* Information about actual dump options. */
|
|
|
|
brls::Label *dump_options_info = new brls::Label(brls::LabelStyle::DESCRIPTION, "options_tab/dump_options_info"_i18n, true);
|
|
|
|
dump_options_info->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->addView(dump_options_info);
|
|
|
|
|
2021-07-23 08:24:00 +01:00
|
|
|
/* Overclock. */
|
|
|
|
brls::ToggleListItem *overclock = new brls::ToggleListItem("options_tab/overclock/label"_i18n, configGetBoolean("overclock"), \
|
|
|
|
"options_tab/overclock/description"_i18n, "options_tab/overclock/value_enabled"_i18n, \
|
|
|
|
"options_tab/overclock/value_disabled"_i18n);
|
|
|
|
overclock->getClickEvent()->subscribe([](brls::View* view) {
|
|
|
|
brls::ToggleListItem *item = static_cast<brls::ToggleListItem*>(view);
|
2021-07-25 06:37:13 +01:00
|
|
|
|
|
|
|
/* Get current value. */
|
2021-07-23 08:24:00 +01:00
|
|
|
bool value = item->getToggleState();
|
2021-07-25 06:37:13 +01:00
|
|
|
|
|
|
|
/* Change hardware clocks based on the current value. */
|
2021-07-23 08:24:00 +01:00
|
|
|
utilsOverclockSystem(value);
|
2021-07-25 06:37:13 +01:00
|
|
|
|
|
|
|
/* Update configuration. */
|
2021-07-23 08:24:00 +01:00
|
|
|
configSetBoolean("overclock", value);
|
2021-07-25 06:37:13 +01:00
|
|
|
|
|
|
|
brls::Logger::debug("Overclock setting changed by user.");
|
2021-07-23 08:24:00 +01:00
|
|
|
});
|
|
|
|
this->addView(overclock);
|
|
|
|
|
|
|
|
/* Naming convention. */
|
|
|
|
brls::SelectListItem *naming_convention = new brls::SelectListItem("options_tab/naming_convention/label"_i18n, {
|
|
|
|
"options_tab/naming_convention/value_00"_i18n,
|
|
|
|
"options_tab/naming_convention/value_01"_i18n
|
|
|
|
}, static_cast<unsigned>(configGetInteger("naming_convention")),
|
|
|
|
"options_tab/naming_convention/description"_i18n);
|
|
|
|
naming_convention->getValueSelectedEvent()->subscribe([](int selected){
|
2021-07-25 06:37:13 +01:00
|
|
|
/* Make sure the current value isn't out of bounds. */
|
2021-07-23 08:24:00 +01:00
|
|
|
if (selected < 0 || selected > static_cast<int>(TitleNamingConvention_Count)) return;
|
2021-07-25 06:37:13 +01:00
|
|
|
|
|
|
|
/* Update configuration. */
|
2021-07-23 08:24:00 +01:00
|
|
|
configSetInteger("naming_convention", selected);
|
2021-07-25 06:37:13 +01:00
|
|
|
|
|
|
|
brls::Logger::debug("Naming convention setting changed by user.");
|
2021-07-23 08:24:00 +01:00
|
|
|
});
|
|
|
|
this->addView(naming_convention);
|
|
|
|
|
2021-07-25 23:23:44 +01:00
|
|
|
/* Update NSWDB XML. */
|
|
|
|
brls::ListItem *update_nswdb_xml = new brls::ListItem("options_tab/update_nswdb_xml/label"_i18n, "options_tab/update_nswdb_xml/description"_i18n);
|
|
|
|
update_nswdb_xml->getClickEvent()->subscribe([this](brls::View* view) {
|
2021-07-27 16:00:09 +01:00
|
|
|
brls::Dialog *dialog = new brls::Dialog("this is a test");
|
|
|
|
dialog->setCancelable(false);
|
|
|
|
dialog->addButton("cancel?", [dialog](brls::View *view) {
|
|
|
|
dialog->close();
|
|
|
|
});
|
|
|
|
dialog->open(false);
|
2021-07-25 23:23:44 +01:00
|
|
|
});
|
|
|
|
this->addView(update_nswdb_xml);
|
|
|
|
|
2021-07-23 08:24:00 +01:00
|
|
|
/* Update application. */
|
2021-07-25 06:37:13 +01:00
|
|
|
brls::ListItem *update_app = new brls::ListItem("options_tab/update_app/label"_i18n, "options_tab/update_app/description"_i18n);
|
|
|
|
update_app->getClickEvent()->subscribe([this](brls::View* view) {
|
|
|
|
if (envIsNso())
|
|
|
|
{
|
|
|
|
/* Display a notification if we're running as a NSO. */
|
|
|
|
this->DisplayNotification("options_tab/notifications/is_nso"_i18n);
|
|
|
|
return;
|
|
|
|
} else
|
|
|
|
if (false)
|
|
|
|
{
|
|
|
|
/* Display a notification if the application has already been updated. */
|
|
|
|
this->DisplayNotification("options_tab/notifications/already_updated"_i18n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*brls::StagedAppletFrame *staged_frame = new brls::StagedAppletFrame();
|
|
|
|
staged_frame->setTitle("options_tab/update_app/label"_i18n);
|
|
|
|
|
|
|
|
brls::Application::pushView(staged_frame);*/
|
|
|
|
});
|
|
|
|
this->addView(update_app);
|
|
|
|
}
|
|
|
|
|
|
|
|
OptionsTab::~OptionsTab(void)
|
|
|
|
{
|
|
|
|
brls::menu_timer_kill(&(this->notification_timer));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsTab::DisplayNotification(std::string str)
|
|
|
|
{
|
|
|
|
if (str == "" || !this->display_notification) return;
|
|
|
|
|
|
|
|
brls::Application::notify(str);
|
|
|
|
this->display_notification = false;
|
|
|
|
|
|
|
|
this->notification_timer_ctx.duration = brls::Application::getStyle()->AnimationDuration.notificationTimeout;
|
|
|
|
this->notification_timer_ctx.cb = [this](void *userdata) { this->display_notification = true; };
|
|
|
|
this->notification_timer_ctx.tick = [](void*){};
|
|
|
|
this->notification_timer_ctx.userdata = nullptr;
|
|
|
|
|
|
|
|
brls::menu_timer_start(&(this->notification_timer), &(this->notification_timer_ctx));
|
2021-07-23 08:24:00 +01:00
|
|
|
}
|
|
|
|
}
|