mirror of
https://github.com/Huntereb/Awoo-Installer
synced 2024-11-26 05:30:19 +00:00
Settings menu
This commit is contained in:
parent
2700f478ce
commit
3c551c4e98
6 changed files with 92 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "ui/netInstPage.hpp"
|
||||
#include "ui/nspInstPage.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
#include "ui/optionsPage.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
class MainApplication : public pu::ui::Application {
|
||||
|
@ -15,5 +16,6 @@ namespace inst::ui {
|
|||
netInstPage::Ref netinstPage;
|
||||
nspInstPage::Ref nspinstPage;
|
||||
instPage::Ref instpage;
|
||||
optionsPage::Ref optionspage;
|
||||
};
|
||||
}
|
19
include/ui/optionsPage.hpp
Executable file
19
include/ui/optionsPage.hpp
Executable file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include <pu/Plutonium>
|
||||
|
||||
using namespace pu::ui::elm;
|
||||
namespace inst::ui {
|
||||
class optionsPage : public pu::ui::Layout
|
||||
{
|
||||
public:
|
||||
optionsPage();
|
||||
PU_SMART_CTOR(optionsPage)
|
||||
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
|
||||
private:
|
||||
TextBlock::Ref topText;
|
||||
TextBlock::Ref pageInfoText;
|
||||
pu::ui::elm::Menu::Ref menu;
|
||||
void setMenuText();
|
||||
std::string getMenuOptionText(bool ourBool);
|
||||
};
|
||||
}
|
|
@ -10,10 +10,12 @@ namespace inst::ui {
|
|||
this->netinstPage = netInstPage::New();
|
||||
this->nspinstPage = nspInstPage::New();
|
||||
this->instpage = instPage::New();
|
||||
this->optionspage = optionsPage::New();
|
||||
this->mainPage->SetOnInput(std::bind(&MainPage::onInput, this->mainPage, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
this->netinstPage->SetOnInput(std::bind(&netInstPage::onInput, this->netinstPage, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
this->nspinstPage->SetOnInput(std::bind(&nspInstPage::onInput, this->nspinstPage, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
this->instpage->SetOnInput(std::bind(&instPage::onInput, this->instpage, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
this->optionspage->SetOnInput(std::bind(&optionsPage::onInput, this->optionspage, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
this->LoadLayout(this->mainPage);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
#include "ui/mainPage.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "sigInstall.hpp"
|
||||
#include "netInstall.hpp"
|
||||
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
|
@ -56,6 +55,7 @@ namespace inst::ui {
|
|||
}
|
||||
|
||||
void MainPage::settingsMenuItem_Click() {
|
||||
mainApp->LoadLayout(mainApp->optionspage);
|
||||
}
|
||||
|
||||
void MainPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
||||
|
|
67
source/ui/optionsPage.cpp
Executable file
67
source/ui/optionsPage.cpp
Executable file
|
@ -0,0 +1,67 @@
|
|||
#include <filesystem>
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "ui/mainPage.hpp"
|
||||
#include "ui/optionsPage.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "util/config.hpp"
|
||||
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
|
||||
std::vector<std::string> ourMenuEntries = {"Ignore Required Firmware Version - ", "Disable Anime - "};
|
||||
|
||||
optionsPage::optionsPage() : Layout::Layout() {
|
||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
|
||||
this->topText->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->pageInfoText = TextBlock::New(10, 45, "Settings Menu", 35);
|
||||
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->menu = pu::ui::elm::Menu::New(0, 160, 1280, COLOR("#FFFFFF00"), 80, (560 / 80));
|
||||
this->menu->SetOnFocusColor(COLOR("#00000033"));
|
||||
this->Add(this->topText);
|
||||
this->Add(this->pageInfoText);
|
||||
optionsPage::setMenuText();
|
||||
this->Add(this->menu);
|
||||
}
|
||||
|
||||
std::string optionsPage::getMenuOptionText(bool ourBool) {
|
||||
if(ourBool) return "Enabled";
|
||||
else return "Disabled";
|
||||
}
|
||||
|
||||
void optionsPage::setMenuText() {
|
||||
this->menu->ClearItems();
|
||||
auto ignoreFirmOption = pu::ui::elm::MenuItem::New(ourMenuEntries[0] + getMenuOptionText(inst::config::ignoreReqVers));
|
||||
ignoreFirmOption->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->menu->AddItem(ignoreFirmOption);
|
||||
auto gayModeOption = pu::ui::elm::MenuItem::New(ourMenuEntries[1] + getMenuOptionText(inst::config::gayMode));
|
||||
gayModeOption->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->menu->AddItem(gayModeOption);
|
||||
}
|
||||
|
||||
void optionsPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
||||
if (Down & KEY_B) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
if (Down & KEY_A) {
|
||||
switch (this->menu->GetSelectedIndex()) {
|
||||
case 0:
|
||||
if (inst::config::ignoreReqVers) inst::config::ignoreReqVers = false;
|
||||
else inst::config::ignoreReqVers = true;
|
||||
inst::config::setConfig();
|
||||
optionsPage::setMenuText();
|
||||
break;
|
||||
case 1:
|
||||
if (inst::config::gayMode) inst::config::gayMode = false;
|
||||
else inst::config::gayMode = true;
|
||||
inst::config::setConfig();
|
||||
optionsPage::setMenuText();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace inst::config {
|
|||
INIReader reader(inst::config::configPath);
|
||||
inst::config::ignoreReqVers = reader.GetBoolean("settings", "ignoreReqVers", true);
|
||||
inst::config::gayMode = reader.GetBoolean("settings", "gayMode", false);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
void setConfig() {
|
||||
|
|
Loading…
Reference in a new issue