mirror of
https://github.com/hax4dazy/TinWoo.git
synced 2025-02-09 19:25:05 +01:00
add theme stuff to usb & hdd install pages
This commit is contained in:
parent
04bce9ace4
commit
5d3a90c6e8
@ -126,6 +126,11 @@ namespace inst::ui {
|
|||||||
fsdevUnmountDevice("user");
|
fsdevUnmountDevice("user");
|
||||||
|
|
||||||
std::string Info = ("usage.system_size"_lang + sdsize2 + "usage.gb"_lang + "usage.freespace"_lang + freespace2 + "usage.gb"_lang + "usage.percent_used"_lang + percent2 + "usage.percent"_lang + "usage.sd_size"_lang + sdsize + "usage.gb"_lang + "usage.sd_space"_lang + freespace + "usage.gb"_lang + "usage.sd_used"_lang + percent + "usage.percent_symbol"_lang);
|
std::string Info = ("usage.system_size"_lang + sdsize2 + "usage.gb"_lang + "usage.freespace"_lang + freespace2 + "usage.gb"_lang + "usage.percent_used"_lang + percent2 + "usage.percent"_lang + "usage.sd_size"_lang + sdsize + "usage.gb"_lang + "usage.sd_space"_lang + freespace + "usage.gb"_lang + "usage.sd_used"_lang + percent + "usage.percent_symbol"_lang);
|
||||||
|
|
||||||
|
std::string drive = "romfs:/images/icons/drive.png";
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.drive"_theme)){
|
||||||
|
drive = inst::config::appDir + "icons_others.drive"_theme;
|
||||||
|
}
|
||||||
inst::ui::mainApp->CreateShowDialog("usage.space_info"_lang, Info, { "common.ok"_lang }, true, "romfs:/images/icons/drive.png");
|
inst::ui::mainApp->CreateShowDialog("usage.space_info"_lang, Info, { "common.ok"_lang }, true, "romfs:/images/icons/drive.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +140,11 @@ namespace inst::ui {
|
|||||||
tin::data::NUM_BUFFER_SEGMENTS = 2;
|
tin::data::NUM_BUFFER_SEGMENTS = 2;
|
||||||
if (menuLoaded) {
|
if (menuLoaded) {
|
||||||
inst::ui::appletFinished = true;
|
inst::ui::appletFinished = true;
|
||||||
mainApp->CreateShowDialog("main.applet.title"_lang, "main.applet.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png");
|
std::string information = "romfs:/images/icons/information.png";
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.information"_theme)){
|
||||||
|
information = inst::config::appDir + "icons_others.information"_theme;
|
||||||
|
}
|
||||||
|
mainApp->CreateShowDialog("main.applet.title"_lang, "main.applet.desc"_lang, { "common.ok"_lang }, true, information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!appletFinished) {
|
else if (!appletFinished) {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "util/curl.hpp"
|
#include "util/curl.hpp"
|
||||||
#include "util/lang.hpp"
|
#include "util/lang.hpp"
|
||||||
#include "netInstall.hpp"
|
#include "netInstall.hpp"
|
||||||
|
#include "util/theme.hpp"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
@ -21,26 +22,62 @@ namespace inst::ui {
|
|||||||
std::string sourceString = "";
|
std::string sourceString = "";
|
||||||
|
|
||||||
netInstPage::netInstPage() : Layout::Layout() {
|
netInstPage::netInstPage() : Layout::Layout() {
|
||||||
this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
|
std::string infoRect_colour = "colour.inforect"_theme;
|
||||||
this->SetBackgroundColor(COLOR("#000000FF"));
|
std::string bg_colour = "colour.background"_theme;
|
||||||
this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
|
std::string tbar_colour = "colour.topbar"_theme;
|
||||||
this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
|
std::string bbar_colour = "colour.bottombar"_theme;
|
||||||
|
std::string net_top = inst::config::appDir + "bg_images.net_top"_theme;
|
||||||
|
std::string default_background = inst::config::appDir + "bg_images.default_background"_theme;
|
||||||
|
std::string pageinfo_colour = "colour.pageinfo_text"_theme;
|
||||||
|
std::string bottombar_text = "colour.bottombar_text"_theme;
|
||||||
|
std::string background_overlay1 = "colour.background_overlay1"_theme;
|
||||||
|
std::string background_overlay2 = "colour.background_overlay2"_theme;
|
||||||
|
std::string focus = "colour.focus"_theme;
|
||||||
|
std::string scrollbar = "colour.scrollbar"_theme;
|
||||||
|
std::string waiting = inst::config::appDir + "icons_others.waiting_lan"_theme;
|
||||||
|
|
||||||
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Net.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/theme/images/Net.png"));
|
|
||||||
else this->titleImage = Image::New(0, 0, "romfs:/images/Net.png");
|
|
||||||
|
|
||||||
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/theme/images/Background.png");
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR(infoRect_colour));
|
||||||
|
else this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->SetBackgroundColor(COLOR(bg_colour));
|
||||||
|
else this->SetBackgroundColor(COLOR("#000000FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR(tbar_colour));
|
||||||
|
else this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR(bbar_colour));
|
||||||
|
else this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(net_top)) this->titleImage = Image::New(0, 0, (net_top));
|
||||||
|
else this->titleImage = Image::New(0, 0, "romfs:/images/net.png");
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(default_background)) this->SetBackgroundImage(default_background);
|
||||||
else this->SetBackgroundImage("romfs:/images/Background.png");
|
else this->SetBackgroundImage("romfs:/images/Background.png");
|
||||||
|
|
||||||
this->pageInfoText = TextBlock::New(10, 109, "");
|
this->pageInfoText = TextBlock::New(10, 109, "inst.hd.top_info"_lang);
|
||||||
this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30));
|
this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30));
|
||||||
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
|
||||||
this->butText = TextBlock::New(10, 678, "");
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->pageInfoText->SetColor(COLOR(pageinfo_colour));
|
||||||
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
else this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
||||||
this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84));
|
|
||||||
this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
|
this->butText = TextBlock::New(10, 678, "inst.hd.buttons"_lang);
|
||||||
this->menu->SetScrollbarColor(COLOR("#1A1919FF"));
|
|
||||||
this->infoImage = Image::New(453, 292, "romfs:/images/icons/lan-connection-waiting.png");
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->butText->SetColor(COLOR(bottombar_text));
|
||||||
|
else this->butText->SetColor(COLOR("#FFFFFFFF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR(background_overlay1), COLOR(background_overlay2), 84, (506 / 84));
|
||||||
|
else this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu->SetItemsFocusColor(COLOR(focus));
|
||||||
|
else this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu->SetScrollbarColor(COLOR(scrollbar));
|
||||||
|
else this->menu->SetScrollbarColor(COLOR("#1A1919FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(waiting)) this->infoImage = Image::New(453, 292, waiting);
|
||||||
|
else this->infoImage = Image::New(453, 292, "romfs:/images/icons/lan-connection-waiting.png");
|
||||||
|
|
||||||
this->Add(this->topRect);
|
this->Add(this->topRect);
|
||||||
this->Add(this->infoRect);
|
this->Add(this->infoRect);
|
||||||
this->Add(this->botRect);
|
this->Add(this->botRect);
|
||||||
@ -56,12 +93,16 @@ namespace inst::ui {
|
|||||||
if (clearItems) this->selectedUrls = {};
|
if (clearItems) this->selectedUrls = {};
|
||||||
if (clearItems) this->alternativeNames = {};
|
if (clearItems) this->alternativeNames = {};
|
||||||
std::string itm;
|
std::string itm;
|
||||||
|
std::string text_colour = "colour.main_text"_theme;
|
||||||
|
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
for (auto& urls : this->ourUrls) {
|
for (auto& urls : this->ourUrls) {
|
||||||
itm = inst::util::shortenString(inst::util::formatUrlString(urls), 56, true);
|
itm = inst::util::shortenString(inst::util::formatUrlString(urls), 56, true);
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
|
||||||
|
else ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
|
|
||||||
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
||||||
long unsigned int i;
|
long unsigned int i;
|
||||||
for (i = 0; i < this->selectedUrls.size(); i++) {
|
for (i = 0; i < this->selectedUrls.size(); i++) {
|
||||||
@ -79,6 +120,7 @@ namespace inst::ui {
|
|||||||
if (clearItems) this->selectedUrls = {};
|
if (clearItems) this->selectedUrls = {};
|
||||||
if (clearItems) this->alternativeNames = {};
|
if (clearItems) this->alternativeNames = {};
|
||||||
std::string itm;
|
std::string itm;
|
||||||
|
std::string text_colour = "colour.main_text"_theme;
|
||||||
|
|
||||||
//Degug code to print out and sort a list of the files on the http server.
|
//Degug code to print out and sort a list of the files on the http server.
|
||||||
/*
|
/*
|
||||||
@ -109,7 +151,10 @@ namespace inst::ui {
|
|||||||
itm = inst::util::shortenString(inst::util::formatUrlString(file_without_extension), 56, true);
|
itm = inst::util::shortenString(inst::util::formatUrlString(file_without_extension), 56, true);
|
||||||
//itm = inst::util::shortenString(inst::util::formatUrlString(urls), 56, true);
|
//itm = inst::util::shortenString(inst::util::formatUrlString(urls), 56, true);
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
|
||||||
|
else ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
|
|
||||||
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
||||||
long unsigned int i;
|
long unsigned int i;
|
||||||
for (i = 0; i < this->selectedUrls.size(); i++) {
|
for (i = 0; i < this->selectedUrls.size(); i++) {
|
||||||
@ -135,7 +180,6 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void netInstPage::startNetwork() {
|
void netInstPage::startNetwork() {
|
||||||
this->butText->SetText("inst.net.buttons"_lang);
|
this->butText->SetText("inst.net.buttons"_lang);
|
||||||
//this->butText->SetText("inst.net.buttons"_lang + " \ue0f0 Install From HTTP Directory");
|
|
||||||
this->menu->SetVisible(false);
|
this->menu->SetVisible(false);
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
this->infoImage->SetVisible(true);
|
this->infoImage->SetVisible(true);
|
||||||
@ -149,7 +193,11 @@ namespace inst::ui {
|
|||||||
|
|
||||||
else if (this->ourUrls[0] == "supplyUrl") {
|
else if (this->ourUrls[0] == "supplyUrl") {
|
||||||
std::string keyboardResult;
|
std::string keyboardResult;
|
||||||
switch (mainApp->CreateShowDialog("inst.net.src.title"_lang, "common.cancel_desc"_lang, { "inst.net.src.opt0"_lang, "inst.net.src.opt1"_lang }, false, "romfs:/images/icons/update.png")) {
|
std::string update = "romfs:/images/icons/update.png";
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.update"_theme)){
|
||||||
|
update = inst::config::appDir + "icons_others.update"_theme;
|
||||||
|
}
|
||||||
|
switch (mainApp->CreateShowDialog("inst.net.src.title"_lang, "common.cancel_desc"_lang, { "inst.net.src.opt0"_lang, "inst.net.src.opt1"_lang }, false, update)) {
|
||||||
case 0:
|
case 0:
|
||||||
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httplastUrl, 500);
|
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httplastUrl, 500);
|
||||||
if (keyboardResult.size() > 0) {
|
if (keyboardResult.size() > 0) {
|
||||||
@ -164,7 +212,11 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inst::util::formatUrlString(keyboardResult) == "" || keyboardResult == "https://" || keyboardResult == "http://") {
|
if (inst::util::formatUrlString(keyboardResult) == "" || keyboardResult == "https://" || keyboardResult == "http://") {
|
||||||
mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png");
|
std::string fail = "romfs:/images/icons/fail.png";
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)){
|
||||||
|
fail = inst::config::appDir + "icons_others.fail"_theme;
|
||||||
|
}
|
||||||
|
mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false, fail);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sourceString = "inst.net.url.source_string"_lang;
|
sourceString = "inst.net.url.source_string"_lang;
|
||||||
@ -207,13 +259,21 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void netInstPage::startInstall(bool urlMode) {
|
void netInstPage::startInstall(bool urlMode) {
|
||||||
int dialogResult = -1;
|
int dialogResult = -1;
|
||||||
|
std::string install = "romfs:/images/icons/install.png";
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.install"_theme)){
|
||||||
|
install = inst::config::appDir + "icons_others.install"_theme;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->selectedUrls.size() == 1) {
|
if (this->selectedUrls.size() == 1) {
|
||||||
std::string ourUrlString;
|
std::string ourUrlString;
|
||||||
if (this->alternativeNames.size() > 0) ourUrlString = inst::util::shortenString(this->alternativeNames[0], 32, true);
|
if (this->alternativeNames.size() > 0) ourUrlString = inst::util::shortenString(this->alternativeNames[0], 32, true);
|
||||||
else ourUrlString = inst::util::shortenString(inst::util::formatUrlString(this->selectedUrls[0]), 32, true);
|
else {
|
||||||
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + ":\n\n" + ourUrlString + "\n\n" + "inst.target.desc1"_lang, "\n\n\n\n\n\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, "romfs:/images/icons/install.png");
|
ourUrlString = inst::util::shortenString(inst::util::formatUrlString(this->selectedUrls[0]), 32, true);
|
||||||
}
|
}
|
||||||
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedUrls.size()) + "inst.target.desc01"_lang, "\n\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, "romfs:/images/icons/install.png");
|
|
||||||
|
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + ":\n\n" + ourUrlString + "\n\n" + "inst.target.desc1"_lang, "\n\n\n\n\n\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, install);
|
||||||
|
}
|
||||||
|
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedUrls.size()) + "inst.target.desc01"_lang, "\n\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, install);
|
||||||
if (dialogResult == -1 && !urlMode) return;
|
if (dialogResult == -1 && !urlMode) return;
|
||||||
else if (dialogResult == -1 && urlMode) {
|
else if (dialogResult == -1 && urlMode) {
|
||||||
this->startNetwork();
|
this->startNetwork();
|
||||||
@ -241,10 +301,7 @@ namespace inst::ui {
|
|||||||
if (xxx != 1) {
|
if (xxx != 1) {
|
||||||
int var = this->menu->GetItems().size();
|
int var = this->menu->GetItems().size();
|
||||||
auto s = std::to_string(var);
|
auto s = std::to_string(var);
|
||||||
if (s == "0") {
|
if (s != "0") {
|
||||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->selectTitle(this->menu->GetSelectedIndex());
|
this->selectTitle(this->menu->GetSelectedIndex());
|
||||||
if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) {
|
if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) {
|
||||||
this->startInstall(false);
|
this->startInstall(false);
|
||||||
@ -261,13 +318,7 @@ namespace inst::ui {
|
|||||||
if (xxx != 1) {
|
if (xxx != 1) {
|
||||||
int var = this->menu->GetItems().size();
|
int var = this->menu->GetItems().size();
|
||||||
auto s = std::to_string(var);
|
auto s = std::to_string(var);
|
||||||
//std::string s = ourUrlString; //debug stuff
|
if (s != "0") {
|
||||||
//this->appVersionText->SetText(s); //debug stuff
|
|
||||||
|
|
||||||
if (s == "0") {
|
|
||||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->selectTitle(this->menu->GetSelectedIndex());
|
this->selectTitle(this->menu->GetSelectedIndex());
|
||||||
if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) {
|
if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) {
|
||||||
this->startInstall(false);
|
this->startInstall(false);
|
||||||
@ -293,11 +344,7 @@ namespace inst::ui {
|
|||||||
int var = this->menu->GetItems().size();
|
int var = this->menu->GetItems().size();
|
||||||
auto s = std::to_string(var);
|
auto s = std::to_string(var);
|
||||||
|
|
||||||
if (s == "0") {
|
if (s != "0") {
|
||||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
if (this->selectedUrls.size() == 0) {
|
if (this->selectedUrls.size() == 0) {
|
||||||
this->selectTitle(this->menu->GetSelectedIndex());
|
this->selectTitle(this->menu->GetSelectedIndex());
|
||||||
this->startInstall(false);
|
this->startInstall(false);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "util/config.hpp"
|
#include "util/config.hpp"
|
||||||
#include "util/lang.hpp"
|
#include "util/lang.hpp"
|
||||||
#include "usbInstall.hpp"
|
#include "usbInstall.hpp"
|
||||||
|
#include "util/theme.hpp"
|
||||||
|
|
||||||
|
|
||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
@ -13,26 +14,62 @@ namespace inst::ui {
|
|||||||
s32 www = 0; //touchscreen variable
|
s32 www = 0; //touchscreen variable
|
||||||
|
|
||||||
usbInstPage::usbInstPage() : Layout::Layout() {
|
usbInstPage::usbInstPage() : Layout::Layout() {
|
||||||
this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
|
std::string infoRect_colour = "colour.inforect"_theme;
|
||||||
this->SetBackgroundColor(COLOR("#000000FF"));
|
std::string bg_colour = "colour.background"_theme;
|
||||||
this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
|
std::string tbar_colour = "colour.topbar"_theme;
|
||||||
this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
|
std::string bbar_colour = "colour.bottombar"_theme;
|
||||||
|
std::string usb_top = inst::config::appDir + "bg_images.usb_top"_theme;
|
||||||
|
std::string default_background = inst::config::appDir + "bg_images.default_background"_theme;
|
||||||
|
std::string pageinfo_colour = "colour.pageinfo_text"_theme;
|
||||||
|
std::string bottombar_text = "colour.bottombar_text"_theme;
|
||||||
|
std::string background_overlay1 = "colour.background_overlay1"_theme;
|
||||||
|
std::string background_overlay2 = "colour.background_overlay2"_theme;
|
||||||
|
std::string focus = "colour.focus"_theme;
|
||||||
|
std::string scrollbar = "colour.scrollbar"_theme;
|
||||||
|
std::string waiting = inst::config::appDir + "icons_others.waiting_usb"_theme;
|
||||||
|
|
||||||
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Usb.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/theme/images/Usb.png"));
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR(infoRect_colour));
|
||||||
|
else this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->SetBackgroundColor(COLOR(bg_colour));
|
||||||
|
else this->SetBackgroundColor(COLOR("#000000FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR(tbar_colour));
|
||||||
|
else this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR(bbar_colour));
|
||||||
|
else this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(usb_top)) this->titleImage = Image::New(0, 0, (usb_top));
|
||||||
else this->titleImage = Image::New(0, 0, "romfs:/images/Usb.png");
|
else this->titleImage = Image::New(0, 0, "romfs:/images/Usb.png");
|
||||||
|
|
||||||
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/theme/images/Background.png");
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(default_background)) this->SetBackgroundImage(default_background);
|
||||||
else this->SetBackgroundImage("romfs:/images/Background.png");
|
else this->SetBackgroundImage("romfs:/images/Background.png");
|
||||||
|
|
||||||
this->pageInfoText = TextBlock::New(10, 109, "");
|
this->pageInfoText = TextBlock::New(10, 109, "inst.hd.top_info"_lang);
|
||||||
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
|
||||||
this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30));
|
this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30));
|
||||||
this->butText = TextBlock::New(10, 678, "");
|
|
||||||
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->pageInfoText->SetColor(COLOR(pageinfo_colour));
|
||||||
this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84));
|
else this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
||||||
this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
|
|
||||||
this->menu->SetScrollbarColor(COLOR("#1A1919FF"));
|
this->butText = TextBlock::New(10, 678, "inst.hd.buttons"_lang);
|
||||||
this->infoImage = Image::New(460, 332, "romfs:/images/icons/usb-connection-waiting.png");
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->butText->SetColor(COLOR(bottombar_text));
|
||||||
|
else this->butText->SetColor(COLOR("#FFFFFFFF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR(background_overlay1), COLOR(background_overlay2), 84, (506 / 84));
|
||||||
|
else this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu->SetItemsFocusColor(COLOR(focus));
|
||||||
|
else this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu->SetScrollbarColor(COLOR(scrollbar));
|
||||||
|
else this->menu->SetScrollbarColor(COLOR("#1A1919FF"));
|
||||||
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(waiting)) this->infoImage = Image::New(453, 292, waiting);
|
||||||
|
else this->infoImage = Image::New(453, 292, "romfs:/images/icons/usb-connection-waiting.png");
|
||||||
|
|
||||||
this->Add(this->topRect);
|
this->Add(this->topRect);
|
||||||
this->Add(this->infoRect);
|
this->Add(this->infoRect);
|
||||||
this->Add(this->botRect);
|
this->Add(this->botRect);
|
||||||
@ -46,11 +83,15 @@ namespace inst::ui {
|
|||||||
void usbInstPage::drawMenuItems_withext(bool clearItems) {
|
void usbInstPage::drawMenuItems_withext(bool clearItems) {
|
||||||
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
||||||
if (clearItems) this->selectedTitles = {};
|
if (clearItems) this->selectedTitles = {};
|
||||||
|
std::string text_colour = "colour.main_text"_theme;
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
for (auto& url : this->ourTitles) {
|
for (auto& url : this->ourTitles) {
|
||||||
std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
|
||||||
|
else ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
|
|
||||||
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
||||||
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
||||||
if (this->selectedTitles[i] == url) {
|
if (this->selectedTitles[i] == url) {
|
||||||
@ -65,6 +106,7 @@ namespace inst::ui {
|
|||||||
void usbInstPage::drawMenuItems(bool clearItems) {
|
void usbInstPage::drawMenuItems(bool clearItems) {
|
||||||
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
||||||
if (clearItems) this->selectedTitles = {};
|
if (clearItems) this->selectedTitles = {};
|
||||||
|
std::string text_colour = "colour.main_text"_theme;
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
for (auto& url : this->ourTitles) {
|
for (auto& url : this->ourTitles) {
|
||||||
|
|
||||||
@ -75,8 +117,11 @@ namespace inst::ui {
|
|||||||
|
|
||||||
//std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
//std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
|
||||||
|
else ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
|
||||||
|
|
||||||
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
||||||
if (this->selectedTitles[i] == url) {
|
if (this->selectedTitles[i] == url) {
|
||||||
ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png");
|
ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png");
|
||||||
@ -125,11 +170,17 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void usbInstPage::startInstall() {
|
void usbInstPage::startInstall() {
|
||||||
int dialogResult = -1;
|
int dialogResult = -1;
|
||||||
|
|
||||||
|
std::string install = "romfs:/images/icons/install.png";
|
||||||
|
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.install"_theme)){
|
||||||
|
install = inst::config::appDir + "icons_others.install"_theme;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->selectedTitles.size() == 1) {
|
if (this->selectedTitles.size() == 1) {
|
||||||
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + ":\n\n" + inst::util::shortenString(std::filesystem::path(this->selectedTitles[0]).filename().string(), 32, true) + "\n\n" + "inst.target.desc1"_lang, "\n\n\n\n\n\n\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, "romfs:/images/icons/install.png");
|
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + ":\n\n" + inst::util::shortenString(std::filesystem::path(this->selectedTitles[0]).filename().string(), 32, true) + "\n\n" + "inst.target.desc1"_lang, "\n\n\n\n\n\n\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, install);
|
||||||
}
|
}
|
||||||
//else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
//else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, "romfs:/images/icons/install.png");
|
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "\n" + "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false, install);
|
||||||
if (dialogResult == -1) return;
|
if (dialogResult == -1) return;
|
||||||
usbInstStuff::installTitleUsb(this->selectedTitles, dialogResult);
|
usbInstStuff::installTitleUsb(this->selectedTitles, dialogResult);
|
||||||
return;
|
return;
|
||||||
|
@ -18,6 +18,7 @@ static size_t writeDataFile(void* ptr, size_t size, size_t nmemb, void* stream)
|
|||||||
|
|
||||||
size_t writeDataBuffer(char* ptr, size_t size, size_t nmemb, void* userdata) {
|
size_t writeDataBuffer(char* ptr, size_t size, size_t nmemb, void* userdata) {
|
||||||
std::ostringstream* stream = (std::ostringstream*)userdata;
|
std::ostringstream* stream = (std::ostringstream*)userdata;
|
||||||
|
//std::ofstream* stream = (std::ofstream*)userdata;
|
||||||
size_t count = size * nmemb;
|
size_t count = size * nmemb;
|
||||||
stream->write(ptr, count);
|
stream->write(ptr, count);
|
||||||
return count;
|
return count;
|
||||||
@ -92,6 +93,7 @@ namespace inst::curl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string downloadToBuffer(const std::string ourUrl, int firstRange, int secondRange, long timeout) {
|
std::string downloadToBuffer(const std::string ourUrl, int firstRange, int secondRange, long timeout) {
|
||||||
|
//https://www.php.net/manual/en/function.curl-setopt.php
|
||||||
CURL* curl_handle;
|
CURL* curl_handle;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@ -100,6 +102,13 @@ namespace inst::curl {
|
|||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
curl_handle = curl_easy_init();
|
curl_handle = curl_easy_init();
|
||||||
|
|
||||||
|
curl_easy_setopt(curl_handle, CURLOPT_BUFFERSIZE, 240000L);
|
||||||
|
curl_easy_setopt(curl_handle, CURLOPT_ENCODING, "" );
|
||||||
|
curl_easy_setopt(curl_handle, CURLOPT_TCP_FASTOPEN, 1L);
|
||||||
|
curl_easy_setopt(curl_handle, CURLOPT_STREAM_WEIGHT, 256L);
|
||||||
|
curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPALIVE, 1L);
|
||||||
|
curl_easy_setopt(curl_handle, CURLOPT_MAX_RECV_SPEED_LARGE, 1L);
|
||||||
|
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
|
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_REFERER, url);
|
curl_easy_setopt(curl_handle, CURLOPT_REFERER, url);
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
|
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
@ -111,6 +120,7 @@ namespace inst::curl {
|
|||||||
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT_MS, timeout);
|
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT_MS, timeout);
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT_MS, timeout);
|
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT_MS, timeout);
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeDataBuffer);
|
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeDataBuffer);
|
||||||
|
//curl_easy_setopt(curl_handle, CURLOPT_STDERR, fopen("sdmc://curl.txt", "a+"));
|
||||||
if (firstRange && secondRange) {
|
if (firstRange && secondRange) {
|
||||||
const char* ourRange = (std::to_string(firstRange) + "-" + std::to_string(secondRange)).c_str();
|
const char* ourRange = (std::to_string(firstRange) + "-" + std::to_string(secondRange)).c_str();
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_RANGE, ourRange);
|
curl_easy_setopt(curl_handle, CURLOPT_RANGE, ourRange);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user