diff --git a/0.8-temp-changelog.md b/0.8-temp-changelog.md index a0b1bb70..39dbc253 100644 --- a/0.8-temp-changelog.md +++ b/0.8-temp-changelog.md @@ -20,6 +20,8 @@ - Now rebooting will reboot to RCM/payload, same way as if you rebooted from HOME menu's power menu. +- The web browser system was improved, adding now a custom menu, and the possibility to save a page as a bookmark after having browsed it. + ## Quark / USB - Quark's target version was changed to Java 9 or higher, since trying to support Java 8 too made it complicated to get it working. @@ -32,16 +34,12 @@ - Goldleaf also sets it's version as the serial number descriptor, so Quark can use it. Development builds have "-dev" after the version ("0.8.0-dev", for instance), which will make Quark warn about its possible unstability. +- Quark now displays the time anything was logged in the log box. That way, one can easily identify if USB connection is still working, for instance, with installs or long file copying. + ## (Planned features) - Integrated emuiibo 0.4.0 (next version) support -- Web browser bookmark system (skeleton code is already there) - -- More internal code improvements - -- Something else? (open to suggestions, will look into issues for ideas) - - Try to improve both filesystem and error system (the first one to use more the second one), since currently both are kinda poorly implemented - Write proper documentation and FAQ, specially about Quark/USB \ No newline at end of file diff --git a/Goldleaf/Include/Types.hpp b/Goldleaf/Include/Types.hpp index 3f51fe85..43719895 100644 --- a/Goldleaf/Include/Types.hpp +++ b/Goldleaf/Include/Types.hpp @@ -89,6 +89,7 @@ enum class Storage enum class Language { + Invalid, English, Spanish, German, @@ -97,6 +98,9 @@ enum class Language Dutch, }; +std::string LanguageToString(Language lang); +Language StringToLanguage(std::string str); + struct ColorScheme { pu::ui::Color Background; diff --git a/Goldleaf/Include/set/set_Settings.hpp b/Goldleaf/Include/set/set_Settings.hpp index eaf0898e..4dcd50c7 100644 --- a/Goldleaf/Include/set/set_Settings.hpp +++ b/Goldleaf/Include/set/set_Settings.hpp @@ -26,31 +26,32 @@ namespace set { struct WebBookmark { - std::string Name; - std::string URL; + std::string name; + std::string url; }; + #define SET_OPTIONAL_VALUE(type, name) \ + type name; \ + bool has_##name; + struct Settings { - Language CustomLanguage; - std::string KeysPath; - std::string ExternalRomFs; - ColorScheme CustomScheme; - u32 MenuItemSize; - bool HasScrollBar; - pu::ui::Color ScrollBarColor; - bool HasProgressBar; - pu::ui::Color ProgressBarColor; - bool IgnoreRequiredFirmwareVersion; - std::vector Bookmarks; + SET_OPTIONAL_VALUE(Language, custom_lang) + SET_OPTIONAL_VALUE(std::string, external_romfs) + SET_OPTIONAL_VALUE(pu::ui::Color, scrollbar_color) + SET_OPTIONAL_VALUE(pu::ui::Color, progressbar_color) + SET_OPTIONAL_VALUE(ColorScheme, custom_scheme) + SET_OPTIONAL_VALUE(u32, menu_item_size) + + bool ignore_required_fw_ver; + std::vector bookmarks; + void Save(); std::string PathForResource(std::string Path); void ApplyScrollBarColor(pu::ui::elm::Menu::Ref &Menu); void ApplyProgressBarColor(pu::ui::elm::ProgressBar::Ref &PBar); }; - static const std::string SettingsFile = "sdmc:/" + consts::Root + "/settings.json"; - Settings ProcessSettings(); bool Exists(); } \ No newline at end of file diff --git a/Goldleaf/Include/ui/ui_MainApplication.hpp b/Goldleaf/Include/ui/ui_MainApplication.hpp index ee3155a2..c48f6acc 100644 --- a/Goldleaf/Include/ui/ui_MainApplication.hpp +++ b/Goldleaf/Include/ui/ui_MainApplication.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -68,6 +69,7 @@ namespace ui void amiibo_Input(u64 down, u64 up, u64 held); void settings_Input(u64 down, u64 up, u64 held); void memory_Input(u64 down, u64 up, u64 held); + void webBrowser_Input(u64 down, u64 up, u64 held); void about_Input(u64 down, u64 up, u64 held); void userImage_OnClick(); void helpImage_OnClick(); @@ -90,7 +92,9 @@ namespace ui SettingsLayout::Ref &GetSettingsLayout(); MemoryLayout::Ref &GetMemoryLayout(); UpdateLayout::Ref &GetUpdateLayout(); + WebBrowserLayout::Ref &GetWebBrowserLayout(); AboutLayout::Ref &GetAboutLayout(); + private: u32 preblv; bool preisch; @@ -116,6 +120,7 @@ namespace ui SettingsLayout::Ref settings; MemoryLayout::Ref memory; UpdateLayout::Ref update; + WebBrowserLayout::Ref webBrowser; AboutLayout::Ref about; pu::ui::elm::Image::Ref baseImage; pu::ui::elm::TextBlock::Ref timeText; diff --git a/Goldleaf/Include/ui/ui_PartitionBrowserLayout.hpp b/Goldleaf/Include/ui/ui_PartitionBrowserLayout.hpp index 98275cd0..8fedb809 100644 --- a/Goldleaf/Include/ui/ui_PartitionBrowserLayout.hpp +++ b/Goldleaf/Include/ui/ui_PartitionBrowserLayout.hpp @@ -38,8 +38,8 @@ namespace ui void HandleFileDirectly(String Path); bool GoBack(); bool WarnNANDWriteAccess(); - void fsItems_Click(); - void fsItems_Click_Y(); + void fsItems_Click(String item); + void fsItems_Click_Y(String item); fs::Explorer *GetExplorer(); private: fs::Explorer *gexp; diff --git a/Goldleaf/Include/ui/ui_UnusedTicketsLayout.hpp b/Goldleaf/Include/ui/ui_UnusedTicketsLayout.hpp index 7003866a..1dadc186 100644 --- a/Goldleaf/Include/ui/ui_UnusedTicketsLayout.hpp +++ b/Goldleaf/Include/ui/ui_UnusedTicketsLayout.hpp @@ -32,7 +32,7 @@ namespace ui PU_SMART_CTOR(UnusedTicketsLayout) void UpdateElements(bool Cooldown); - void tickets_Click(); + void tickets_Click(hos::Ticket ticket); private: std::vector tickets; pu::ui::elm::TextBlock::Ref notTicketsText; diff --git a/Goldleaf/Include/ui/ui_WebBrowserLayout.hpp b/Goldleaf/Include/ui/ui_WebBrowserLayout.hpp new file mode 100644 index 00000000..866f6b5d --- /dev/null +++ b/Goldleaf/Include/ui/ui_WebBrowserLayout.hpp @@ -0,0 +1,40 @@ + +/* + + Goldleaf - Multipurpose homebrew tool for Nintendo Switch + Copyright (C) 2018-2019 XorTroll + + This program 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. + + This program 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 . + +*/ + +#pragma once +#include +#include + +namespace ui +{ + class WebBrowserLayout : public pu::ui::Layout + { + public: + WebBrowserLayout(); + PU_SMART_CTOR(WebBrowserLayout) + + void Refresh(); + void input_Click(); + void bookmark_Click(set::WebBookmark bmk); + private: + pu::ui::elm::Menu::Ref optionsMenu; + }; +} \ No newline at end of file diff --git a/Goldleaf/Source/Main.cpp b/Goldleaf/Source/Main.cpp index ffcddb7d..9cd05d96 100644 --- a/Goldleaf/Source/Main.cpp +++ b/Goldleaf/Source/Main.cpp @@ -21,8 +21,8 @@ #include -ui::MainApplication::Ref mainapp; -set::Settings gsets; +ui::MainApplication::Ref global_app; +set::Settings global_settings; bool gupdated = false; int main() @@ -31,10 +31,10 @@ int main() if(R_FAILED(rc)) fatalThrow(rc); auto renderer = pu::ui::render::Renderer::New(SDL_INIT_EVERYTHING, pu::ui::render::RendererInitOptions::RendererNoSound, pu::ui::render::RendererHardwareFlags); - mainapp = ui::MainApplication::New(renderer); + global_app = ui::MainApplication::New(renderer); - mainapp->Prepare(); - mainapp->ShowWithFadeIn(); + global_app->Prepare(); + global_app->ShowWithFadeIn(); Exit(); return 0; diff --git a/Goldleaf/Source/Types.cpp b/Goldleaf/Source/Types.cpp index 0181021a..ea742f55 100644 --- a/Goldleaf/Source/Types.cpp +++ b/Goldleaf/Source/Types.cpp @@ -34,6 +34,41 @@ namespace consts std::string TempUpdatePath = Root + "/UpdateTemp.nro"; } +std::string LanguageToString(Language lang) +{ + std::string langstr; + switch(lang) + { + case Language::English: + return "en"; + case Language::Spanish: + return "es"; + case Language::German: + return "de"; + case Language::French: + return "fr"; + case Language::Invalid: + return "it"; + case Language::Dutch: + return "nl"; + default: + break; + } + return langstr; +} + +Language StringToLanguage(std::string str) +{ + auto lang = Language::Invalid; + if(str == "en") lang = Language::English; + else if(str == "es") lang = Language::Spanish; + else if(str == "de") lang = Language::German; + else if(str == "fr") lang = Language::French; + else if(str == "it") lang = Language::Italian; + else if(str == "nl") lang = Language::Dutch; + return lang; +} + String Version::AsString() { String txt = std::to_string(this->Major) + "." + std::to_string(this->Minor); diff --git a/Goldleaf/Source/nsp/nsp_Installer.cpp b/Goldleaf/Source/nsp/nsp_Installer.cpp index 29b682ef..e8c70bc9 100644 --- a/Goldleaf/Source/nsp/nsp_Installer.cpp +++ b/Goldleaf/Source/nsp/nsp_Installer.cpp @@ -29,7 +29,7 @@ #include #include -extern set::Settings gsets; +extern set::Settings global_settings; namespace nsp { @@ -141,7 +141,7 @@ namespace nsp ncmContentStorageHas(&cst, &hascnmt, &record.ContentId); serviceClose(&cst.s); if(!hascnmt) ncas.push_back(record); - cnmt.GetInstallContentMeta(ccnmt, record, gsets.IgnoreRequiredFirmwareVersion); + cnmt.GetInstallContentMeta(ccnmt, record, global_settings.ignore_required_fw_ver); baseappid = hos::GetBaseApplicationId(mrec.id, static_cast(mrec.type)); auto recs = cnmt.GetContentRecords(); memset(&entrynacp, 0, sizeof(entrynacp)); diff --git a/Goldleaf/Source/set/set_Settings.cpp b/Goldleaf/Source/set/set_Settings.cpp index feba452c..2b110cd8 100644 --- a/Goldleaf/Source/set/set_Settings.cpp +++ b/Goldleaf/Source/set/set_Settings.cpp @@ -22,15 +22,50 @@ #include #include #include +#include namespace set { + static std::string ColorToHex(pu::ui::Color clr) + { + char str[0x20] = {0}; + sprintf(str, "#%02X%02X%02X%02X", clr.R, clr.G, clr.B, clr.A); + return str; + } + + void Settings::Save() + { + auto json = JSON::object(); + if(this->has_custom_lang) json["general"]["customLanguage"] = LanguageToString(this->custom_lang); + if(this->has_external_romfs) json["general"]["externalRomFs"] = this->external_romfs; + if(this->has_menu_item_size) json["ui"]["menuItemSize"] = this->menu_item_size; + if(this->has_custom_scheme) + { + json["ui"]["base"] = ColorToHex(this->custom_scheme.Base); + json["ui"]["baseFocus"] = ColorToHex(this->custom_scheme.BaseFocus); + json["ui"]["text"] = ColorToHex(this->custom_scheme.Text); + } + if(this->has_scrollbar_color) json["ui"]["scrollBar"] = ColorToHex(this->scrollbar_color); + if(this->has_progressbar_color) json["ui"]["progressBar"] = ColorToHex(this->progressbar_color); + json["installs"]["ignoreRequiredFwVersion"] = this->ignore_required_fw_ver; + for(u32 i = 0; i < this->bookmarks.size(); i++) + { + auto bmk = this->bookmarks[i]; + json["web"]["bookmarks"][i]["name"] = bmk.name; + json["web"]["bookmarks"][i]["url"] = bmk.url; + } + fs::DeleteFile("sdmc:/" + consts::Root + "/settings.json"); + std::ofstream ofs("sdmc:/" + consts::Root + "/settings.json"); + ofs << std::setw(4) << json; + ofs.close(); + } + std::string Settings::PathForResource(std::string Path) { std::string outres = "romfs:" + Path; - if(!this->ExternalRomFs.empty()) + if(this->has_external_romfs) { - std::string tmpres = this->ExternalRomFs + "/" + Path; + std::string tmpres = this->external_romfs + "/" + Path; if(fs::IsFile(tmpres)) outres = tmpres; } return outres; @@ -38,12 +73,12 @@ namespace set void Settings::ApplyScrollBarColor(pu::ui::elm::Menu::Ref &Menu) { - if(this->HasScrollBar) Menu->SetScrollbarColor(this->ScrollBarColor); + if(this->has_scrollbar_color) Menu->SetScrollbarColor(this->scrollbar_color); } void Settings::ApplyProgressBarColor(pu::ui::elm::ProgressBar::Ref &PBar) { - if(this->HasProgressBar) PBar->SetProgressColor(this->ProgressBarColor); + if(this->has_progressbar_color) PBar->SetProgressColor(this->progressbar_color); } Settings ProcessSettings() @@ -57,38 +92,45 @@ namespace set { case SetLanguage_ENUS: case SetLanguage_ENGB: - gset.CustomLanguage = Language::English; + gset.custom_lang = Language::English; break; case SetLanguage_FR: case SetLanguage_FRCA: - gset.CustomLanguage = Language::French; + gset.custom_lang = Language::French; break; case SetLanguage_DE: - gset.CustomLanguage = Language::German; + gset.custom_lang = Language::German; break; case SetLanguage_IT: - gset.CustomLanguage = Language::Italian; + gset.custom_lang = Language::Italian; break; case SetLanguage_ES: case SetLanguage_ES419: - gset.CustomLanguage = Language::Spanish; + gset.custom_lang = Language::Spanish; break; case SetLanguage_NL: - gset.CustomLanguage = Language::Dutch; + gset.custom_lang = Language::Dutch; break; default: - gset.CustomLanguage = Language::English; + gset.custom_lang = Language::English; break; } - gset.MenuItemSize = 80; - gset.HasScrollBar = false; - gset.HasProgressBar = false; - gset.IgnoreRequiredFirmwareVersion = true; + gset.has_custom_lang = false; + gset.has_external_romfs = false; + gset.has_scrollbar_color = false; + gset.has_progressbar_color = false; + gset.has_custom_scheme = false; + gset.has_menu_item_size = false; + + gset.menu_item_size = 80; + gset.ignore_required_fw_ver = true; + ColorSetId csid = ColorSetId_Light; setsysGetColorSetId(&csid); - if(csid == ColorSetId_Dark) gset.CustomScheme = ui::DefaultDark; - else gset.CustomScheme = ui::DefaultLight; - std::ifstream ifs(SettingsFile); + if(csid == ColorSetId_Dark) gset.custom_scheme = ui::DefaultDark; + else gset.custom_scheme = ui::DefaultLight; + + std::ifstream ifs("sdmc:/" + consts::Root + "/settings.json"); if(ifs.good()) { JSON settings = JSON::parse(ifs); @@ -97,74 +139,91 @@ namespace set std::string lang = settings["general"].value("customLanguage", ""); if(!lang.empty()) { - if(lang == "en") gset.CustomLanguage = Language::English; - else if(lang == "es") gset.CustomLanguage = Language::Spanish; - else if(lang == "de") gset.CustomLanguage = Language::German; - else if(lang == "fr") gset.CustomLanguage = Language::French; - else if(lang == "it") gset.CustomLanguage = Language::Italian; - else if(lang == "nl") gset.CustomLanguage = Language::Dutch; - } - std::string keys = settings["general"].value("keysPath", ""); - if(!keys.empty()) - { - gset.KeysPath = "sdmc:"; - if(keys[0] != '/') gset.KeysPath += "/"; - gset.KeysPath += keys; + auto clang = StringToLanguage(lang); + if(clang != Language::Invalid) + { + gset.has_custom_lang = true; + gset.custom_lang = clang; + } } std::string extrom = settings["general"].value("externalRomFs", ""); if(!extrom.empty()) { - gset.ExternalRomFs = "sdmc:"; - if(extrom[0] != '/') gset.ExternalRomFs += "/"; - gset.ExternalRomFs += extrom; + gset.has_external_romfs = true; + if(extrom.substr(0, 6) == "sdmc:/") gset.external_romfs = extrom; + else + { + gset.external_romfs = "sdmc:"; + if(extrom[0] != '/') gset.external_romfs += "/"; + gset.external_romfs += extrom; + } } } if(settings.count("ui")) { + auto itemsize = settings["ui"].value("menuItemSize", 0); + if(itemsize > 0) + { + gset.has_menu_item_size = true; + gset.menu_item_size = itemsize; + } std::string clr = settings["ui"].value("background", ""); - if(!clr.empty()) gset.CustomScheme.Background = pu::ui::Color::FromHex(clr); + if(!clr.empty()) + { + gset.has_custom_scheme = true; + gset.custom_scheme.Background = pu::ui::Color::FromHex(clr); + } clr = settings["ui"].value("base", ""); - if(!clr.empty()) gset.CustomScheme.Base = pu::ui::Color::FromHex(clr); + if(!clr.empty()) + { + gset.has_custom_scheme = true; + gset.custom_scheme.Base = pu::ui::Color::FromHex(clr); + } clr = settings["ui"].value("baseFocus", ""); - if(!clr.empty()) gset.CustomScheme.BaseFocus = pu::ui::Color::FromHex(clr); + if(!clr.empty()) + { + gset.has_custom_scheme = true; + gset.custom_scheme.BaseFocus = pu::ui::Color::FromHex(clr); + } clr = settings["ui"].value("text", ""); - if(!clr.empty()) gset.CustomScheme.Text = pu::ui::Color::FromHex(clr); + if(!clr.empty()) + { + gset.has_custom_scheme = true; + gset.custom_scheme.Text = pu::ui::Color::FromHex(clr); + } clr = settings["ui"].value("scrollBar", ""); if(!clr.empty()) { - gset.HasScrollBar = true; - gset.ScrollBarColor = pu::ui::Color::FromHex(clr); + gset.has_scrollbar_color = true; + gset.scrollbar_color = pu::ui::Color::FromHex(clr); } clr = settings["ui"].value("progressBar", ""); if(!clr.empty()) { - gset.HasProgressBar = true; - gset.ProgressBarColor = pu::ui::Color::FromHex(clr); + gset.has_progressbar_color = true; + gset.progressbar_color = pu::ui::Color::FromHex(clr); } } if(settings.count("installs")) { - gset.IgnoreRequiredFirmwareVersion = settings["installs"].value("ignoreRequiredFwVersion", true); - // More for 0.8! + gset.ignore_required_fw_ver = settings["installs"].value("ignoreRequiredFwVersion", true); } - /* 0.8 if(settings.count("web")) { if(settings["web"].count("bookmarks")) { for(u32 i = 0; i < settings["web"]["bookmarks"].size(); i++) { - WebBookmark bmk; - bmk.Name = settings["web"]["bookmarks"][i].value("name", ""); - bmk.URL = settings["web"]["bookmarks"][i].value("url", ""); - if(!bmk.URL.empty() && !bmk.Name.empty()) + WebBookmark bmk = {}; + bmk.name = settings["web"]["bookmarks"][i].value("name", ""); + bmk.url = settings["web"]["bookmarks"][i].value("url", ""); + if(!bmk.url.empty() && !bmk.name.empty()) { - gset.Bookmarks.push_back(bmk); + gset.bookmarks.push_back(bmk); } } } } - */ ifs.close(); } return gset; @@ -172,6 +231,6 @@ namespace set bool Exists() { - return fs::IsFile(SettingsFile); + return fs::IsFile("sdmc:/" + consts::Root + "/settings.json"); } } diff --git a/Goldleaf/Source/set/set_Strings.cpp b/Goldleaf/Source/set/set_Strings.cpp index d3394036..53ad365d 100644 --- a/Goldleaf/Source/set/set_Strings.cpp +++ b/Goldleaf/Source/set/set_Strings.cpp @@ -22,14 +22,14 @@ #include #include -extern set::Settings gsets; +extern set::Settings global_settings; namespace set { void Initialize() { std::string pdict = "en"; // By default - switch(gsets.CustomLanguage) + switch(global_settings.custom_lang) { case Language::English: pdict = "en"; @@ -51,15 +51,15 @@ namespace set break; } pdict += ".json"; - MainDictionary.DictLanguage = gsets.CustomLanguage; - std::ifstream ifs(gsets.PathForResource("/Language/Strings/" + pdict)); + MainDictionary.DictLanguage = global_settings.custom_lang; + std::ifstream ifs(global_settings.PathForResource("/Language/Strings/" + pdict)); if(ifs.good()) { try { MainDictionary.Strings = JSON::parse(ifs); } catch(std::exception&) {} ifs.close(); } - Errors.DictLanguage = gsets.CustomLanguage; - ifs.open(gsets.PathForResource("/Language/Errors/" + pdict)); + Errors.DictLanguage = global_settings.custom_lang; + ifs.open(global_settings.PathForResource("/Language/Errors/" + pdict)); if(ifs.good()) { try { Errors.Strings = JSON::parse(ifs); } catch(std::exception&) {} diff --git a/Goldleaf/Source/ui/ui_AboutLayout.cpp b/Goldleaf/Source/ui/ui_AboutLayout.cpp index b052a952..9f308b42 100644 --- a/Goldleaf/Source/ui/ui_AboutLayout.cpp +++ b/Goldleaf/Source/ui/ui_AboutLayout.cpp @@ -22,14 +22,14 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { AboutLayout::AboutLayout() { - this->logoImage = pu::ui::elm::Image::New(85, 150, gsets.PathForResource("/Logo.png")); + this->logoImage = pu::ui::elm::Image::New(85, 150, global_settings.PathForResource("/Logo.png")); this->Add(this->logoImage); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_AccountLayout.cpp b/Goldleaf/Source/ui/ui_AccountLayout.cpp index 5cbe2d05..49aa08d8 100644 --- a/Goldleaf/Source/ui/ui_AccountLayout.cpp +++ b/Goldleaf/Source/ui/ui_AccountLayout.cpp @@ -22,16 +22,16 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { AccountLayout::AccountLayout() : pu::ui::Layout() { - this->optsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->optsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->optsMenu); + this->optsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->optsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->optsMenu); this->ReloadItems(); this->Add(this->optsMenu); } @@ -40,21 +40,21 @@ namespace ui { this->optsMenu->ClearItems(); auto itm = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(208)); - itm->SetColor(gsets.CustomScheme.Text); + itm->SetColor(global_settings.custom_scheme.Text); itm->AddOnClick(std::bind(&AccountLayout::optsRename_Click, this)); this->optsMenu->AddItem(itm); auto itm2 = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(209)); - itm2->SetColor(gsets.CustomScheme.Text); + itm2->SetColor(global_settings.custom_scheme.Text); itm2->AddOnClick(std::bind(&AccountLayout::optsIcon_Click, this)); this->optsMenu->AddItem(itm2); auto itm3 = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(210)); - itm3->SetColor(gsets.CustomScheme.Text); + itm3->SetColor(global_settings.custom_scheme.Text); itm3->AddOnClick(std::bind(&AccountLayout::optsDelete_Click, this)); this->optsMenu->AddItem(itm3); if(acc::IsLinked()) { auto itm4 = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(336)); - itm4->SetColor(gsets.CustomScheme.Text); + itm4->SetColor(global_settings.custom_scheme.Text); itm4->AddOnClick(std::bind(&AccountLayout::optsServicesInfo_Click, this)); this->optsMenu->AddItem(itm4); } @@ -69,8 +69,8 @@ namespace ui if(rc != 0) { HandleResult(rc, set::GetDictionaryEntry(211)); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); return; } @@ -81,8 +81,8 @@ namespace ui if(rc != 0) { HandleResult(rc, set::GetDictionaryEntry(211)); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); return; } @@ -97,7 +97,7 @@ namespace ui usericon = "Accounts"; } - mainapp->LoadMenuData(set::GetDictionaryEntry(41), usericon, set::GetDictionaryEntry(212) + " " + String(pbase.nickname), deficon); + global_app->LoadMenuData(set::GetDictionaryEntry(41), usericon, set::GetDictionaryEntry(212) + " " + String(pbase.nickname), deficon); this->ReloadItems(); } @@ -112,8 +112,8 @@ namespace ui }); if(rc == 0) { - mainapp->LoadMenuHead(set::GetDictionaryEntry(212) + " " + name); - mainapp->ShowNotification(set::GetDictionaryEntry(214) + " \'" + name + "\'."); + global_app->LoadMenuHead(set::GetDictionaryEntry(212) + " " + name); + global_app->ShowNotification(set::GetDictionaryEntry(214) + " \'" + name + "\'."); } else HandleResult(rc, set::GetDictionaryEntry(215)); } @@ -122,27 +122,27 @@ namespace ui void AccountLayout::optsIcon_Click() { std::string iconpth = "/" + consts::Root + "/userdata/" + hos::FormatHex128(this->uid) + ".jpg"; - mainapp->CreateShowDialog(set::GetDictionaryEntry(216), set::GetDictionaryEntry(217) + "\n\'SdCard:" + iconpth + "\'", { set::GetDictionaryEntry(234) }, false, "sdmc:" + iconpth); + global_app->CreateShowDialog(set::GetDictionaryEntry(216), set::GetDictionaryEntry(217) + "\n\'SdCard:" + iconpth + "\'", { set::GetDictionaryEntry(234) }, false, "sdmc:" + iconpth); } void AccountLayout::optsDelete_Click() { - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(216), set::GetDictionaryEntry(218), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(216), set::GetDictionaryEntry(218), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt == 0) { s32 ucount = 0; accountGetUserCount(&ucount); if(ucount < 2) { - mainapp->CreateShowDialog(set::GetDictionaryEntry(216), set::GetDictionaryEntry(276), { set::GetDictionaryEntry(234) }, true); + global_app->CreateShowDialog(set::GetDictionaryEntry(216), set::GetDictionaryEntry(276), { set::GetDictionaryEntry(234) }, true); return; } auto rc = acc::DeleteUser(this->uid); if(rc == 0) { - mainapp->ShowNotification(set::GetDictionaryEntry(219)); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->ShowNotification(set::GetDictionaryEntry(219)); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); acc::ResetSelectedUser(); } @@ -155,13 +155,13 @@ namespace ui auto linkedinfo = acc::GetUserLinkedInfo(); String str = set::GetDictionaryEntry(328) + " " + hos::FormatHex(linkedinfo.AccountId); str += "\n" + set::GetDictionaryEntry(329) + " " + hos::FormatHex(linkedinfo.NintendoAccountId); - auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(330), str, { set::GetDictionaryEntry(331), set::GetDictionaryEntry(18) }, true); + auto sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(330), str, { set::GetDictionaryEntry(331), set::GetDictionaryEntry(18) }, true); if(sopt != 0) return; - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(332), set::GetDictionaryEntry(333), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(332), set::GetDictionaryEntry(333), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt == 0) { auto res = acc::UnlinkLocally(); - if(res == 0) mainapp->ShowNotification(set::GetDictionaryEntry(334)); + if(res == 0) global_app->ShowNotification(set::GetDictionaryEntry(334)); else HandleResult(res, set::GetDictionaryEntry(335)); } } diff --git a/Goldleaf/Source/ui/ui_AmiiboDumpLayout.cpp b/Goldleaf/Source/ui/ui_AmiiboDumpLayout.cpp index dda74f7b..5428b174 100644 --- a/Goldleaf/Source/ui/ui_AmiiboDumpLayout.cpp +++ b/Goldleaf/Source/ui/ui_AmiiboDumpLayout.cpp @@ -22,8 +22,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { @@ -31,7 +31,7 @@ namespace ui { this->infoText = pu::ui::elm::TextBlock::New(150, 320, "-"); this->infoText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); - this->infoText->SetColor(gsets.CustomScheme.Text); + this->infoText->SetColor(global_settings.custom_scheme.Text); this->Add(this->infoText); } @@ -44,7 +44,7 @@ namespace ui this->infoText->SetText(set::GetDictionaryEntry(295)); while(!nfp::IsReady()) { - mainapp->CallForRender(); + global_app->CallForRender(); } auto rc = nfp::Open(); if(rc == 0) @@ -55,12 +55,12 @@ namespace ui auto reg = nfp::GetRegisterInfo(); auto name = String(reg.amiibo_name); - auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(283), set::GetDictionaryEntry(317) + " '" + name + "'?", { set::GetDictionaryEntry(111), set::GetDictionaryEntry(112) }, true); + auto sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(283), set::GetDictionaryEntry(317) + " '" + name + "'?", { set::GetDictionaryEntry(111), set::GetDictionaryEntry(112) }, true); if(sopt == 0) { this->infoText->SetText(set::GetDictionaryEntry(296) + " '" + name + "' " + set::GetDictionaryEntry(297)); nfp::DumpToEmuiibo(tag, reg, common, model); - mainapp->ShowNotification("'" + name + "' " + set::GetDictionaryEntry(298)); + global_app->ShowNotification("'" + name + "' " + set::GetDictionaryEntry(298)); } nfp::Close(); } diff --git a/Goldleaf/Source/ui/ui_ContentInformationLayout.cpp b/Goldleaf/Source/ui/ui_ContentInformationLayout.cpp index c1f187b2..3fd61d82 100644 --- a/Goldleaf/Source/ui/ui_ContentInformationLayout.cpp +++ b/Goldleaf/Source/ui/ui_ContentInformationLayout.cpp @@ -22,16 +22,16 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { ContentInformationLayout::ContentInformationLayout() { - this->optionsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->optionsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->optionsMenu); + this->optionsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->optionsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->optionsMenu); this->Add(this->optionsMenu); } @@ -44,7 +44,7 @@ namespace ui if(this->tcontents[i].IsUpdate()) name = set::GetDictionaryEntry(262); if(this->tcontents[i].IsDLC()) name = set::GetDictionaryEntry(263) + " " + std::to_string(hos::GetIdFromDLCApplicationId(this->tcontents[i].ApplicationId)); auto subcnt = pu::ui::elm::MenuItem::New(name); - subcnt->SetColor(gsets.CustomScheme.Text); + subcnt->SetColor(global_settings.custom_scheme.Text); subcnt->AddOnClick(std::bind(&ContentInformationLayout::options_Click, this)); this->optionsMenu->AddItem(subcnt); } @@ -123,27 +123,27 @@ namespace ui if(cnt.Location == Storage::GameCart) { - mainapp->CreateShowDialog(set::GetDictionaryEntry(243), msg, { set::GetDictionaryEntry(234) }, true, icn); + global_app->CreateShowDialog(set::GetDictionaryEntry(243), msg, { set::GetDictionaryEntry(234) }, true, icn); return; } if(hastik) opts.push_back(set::GetDictionaryEntry(293)); if(cnt.Location != Storage::NANDSystem) opts.push_back(set::GetDictionaryEntry(319)); opts.push_back(set::GetDictionaryEntry(18)); - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(243), msg, opts, true, icn); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(243), msg, opts, true, icn); if(sopt < 0) return; if(sopt == 0) { if(cnt.Location == Storage::NANDSystem) { - mainapp->CreateShowDialog(set::GetDictionaryEntry(243), set::GetDictionaryEntry(185), { set::GetDictionaryEntry(234) }, true); + global_app->CreateShowDialog(set::GetDictionaryEntry(243), set::GetDictionaryEntry(185), { set::GetDictionaryEntry(234) }, true); return; } - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(243), set::GetDictionaryEntry(186), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(243), set::GetDictionaryEntry(186), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; bool remtik = false; if(hastik) { - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(243), set::GetDictionaryEntry(204), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(112), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(243), set::GetDictionaryEntry(204), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(112), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; remtik = (sopt == 0); } @@ -153,9 +153,9 @@ namespace ui if(remtik) rc = hos::RemoveTicket(stik); if(rc == 0) { - mainapp->ShowNotification(set::GetDictionaryEntry(246)); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->ShowNotification(set::GetDictionaryEntry(246)); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); } else HandleResult(rc, set::GetDictionaryEntry(247)); } @@ -163,24 +163,24 @@ namespace ui } else if(sopt == 1) { - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(182), set::GetDictionaryEntry(184), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(182), set::GetDictionaryEntry(184), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; if(sopt == 0) { - mainapp->LoadLayout(mainapp->GetTitleDumperLayout()); - mainapp->GetTitleDumperLayout()->StartDump(cnt, hastik); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->LoadLayout(global_app->GetTitleDumperLayout()); + global_app->GetTitleDumperLayout()->StartDump(cnt, hastik); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); } } else if(hastik && (sopt == 2)) { - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(200), set::GetDictionaryEntry(205), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(200), set::GetDictionaryEntry(205), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; Result rc = es::DeleteTicket(&stik.RId, sizeof(es::RightsId)); if(rc == 0) { - mainapp->ShowNotification(set::GetDictionaryEntry(206)); + global_app->ShowNotification(set::GetDictionaryEntry(206)); this->UpdateElements(); } else HandleResult(rc, set::GetDictionaryEntry(207)); @@ -190,7 +190,7 @@ namespace ui auto rc = ns::PushLaunchVersion(cnt.ApplicationId, 0); if(rc == 0) { - mainapp->ShowNotification(set::GetDictionaryEntry(322)); + global_app->ShowNotification(set::GetDictionaryEntry(322)); this->UpdateElements(); } else HandleResult(rc, set::GetDictionaryEntry(234)); @@ -221,7 +221,7 @@ namespace ui delete[] cicon; cicon = NULL; } - mainapp->LoadMenuData(set::GetDictionaryEntry(187), icon, tcnt, false); + global_app->LoadMenuData(set::GetDictionaryEntry(187), icon, tcnt, false); this->UpdateElements(); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_ContentManagerLayout.cpp b/Goldleaf/Source/ui/ui_ContentManagerLayout.cpp index 0efaf7a9..43b697f7 100644 --- a/Goldleaf/Source/ui/ui_ContentManagerLayout.cpp +++ b/Goldleaf/Source/ui/ui_ContentManagerLayout.cpp @@ -22,35 +22,35 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { ContentManagerLayout::ContentManagerLayout() : pu::ui::Layout() { - this->typesMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->typesMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->typesMenu); + this->typesMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->typesMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->typesMenu); this->sdCardMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(19)); - this->sdCardMenuItem->SetIcon(gsets.PathForResource("/Common/SdCard.png")); - this->sdCardMenuItem->SetColor(gsets.CustomScheme.Text); + this->sdCardMenuItem->SetIcon(global_settings.PathForResource("/Common/SdCard.png")); + this->sdCardMenuItem->SetColor(global_settings.custom_scheme.Text); this->sdCardMenuItem->AddOnClick(std::bind(&ContentManagerLayout::sdCardMenuItem_Click, this)); this->nandUserMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(28)); - this->nandUserMenuItem->SetIcon(gsets.PathForResource("/Common/NAND.png")); - this->nandUserMenuItem->SetColor(gsets.CustomScheme.Text); + this->nandUserMenuItem->SetIcon(global_settings.PathForResource("/Common/NAND.png")); + this->nandUserMenuItem->SetColor(global_settings.custom_scheme.Text); this->nandUserMenuItem->AddOnClick(std::bind(&ContentManagerLayout::nandUserMenuItem_Click, this)); this->nandSystemMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(29)); - this->nandSystemMenuItem->SetIcon(gsets.PathForResource("/Common/NAND.png")); - this->nandSystemMenuItem->SetColor(gsets.CustomScheme.Text); + this->nandSystemMenuItem->SetIcon(global_settings.PathForResource("/Common/NAND.png")); + this->nandSystemMenuItem->SetColor(global_settings.custom_scheme.Text); this->nandSystemMenuItem->AddOnClick(std::bind(&ContentManagerLayout::nandSystemMenuItem_Click, this)); this->gameCartMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(190)); - this->gameCartMenuItem->SetIcon(gsets.PathForResource("/Common/GameCart.png")); - this->gameCartMenuItem->SetColor(gsets.CustomScheme.Text); + this->gameCartMenuItem->SetIcon(global_settings.PathForResource("/Common/GameCart.png")); + this->gameCartMenuItem->SetColor(global_settings.custom_scheme.Text); this->gameCartMenuItem->AddOnClick(std::bind(&ContentManagerLayout::gameCartMenuItem_Click, this)); this->unusedTicketsMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(287)); - this->unusedTicketsMenuItem->SetIcon(gsets.PathForResource("/Common/Ticket.png")); - this->unusedTicketsMenuItem->SetColor(gsets.CustomScheme.Text); + this->unusedTicketsMenuItem->SetIcon(global_settings.PathForResource("/Common/Ticket.png")); + this->unusedTicketsMenuItem->SetColor(global_settings.custom_scheme.Text); this->unusedTicketsMenuItem->AddOnClick(std::bind(&ContentManagerLayout::unusedTicketsMenuItem_Click, this)); this->typesMenu->AddItem(this->sdCardMenuItem); this->typesMenu->AddItem(this->nandUserMenuItem); @@ -62,32 +62,32 @@ namespace ui void ContentManagerLayout::sdCardMenuItem_Click() { - mainapp->GetStorageContentsLayout()->LoadFromStorage(Storage::SdCard); - mainapp->LoadLayout(mainapp->GetStorageContentsLayout()); + global_app->GetStorageContentsLayout()->LoadFromStorage(Storage::SdCard); + global_app->LoadLayout(global_app->GetStorageContentsLayout()); } void ContentManagerLayout::nandUserMenuItem_Click() { - mainapp->GetStorageContentsLayout()->LoadFromStorage(Storage::NANDUser); - mainapp->LoadLayout(mainapp->GetStorageContentsLayout()); + global_app->GetStorageContentsLayout()->LoadFromStorage(Storage::NANDUser); + global_app->LoadLayout(global_app->GetStorageContentsLayout()); } void ContentManagerLayout::nandSystemMenuItem_Click() { - mainapp->GetStorageContentsLayout()->LoadFromStorage(Storage::NANDSystem); - mainapp->LoadLayout(mainapp->GetStorageContentsLayout()); + global_app->GetStorageContentsLayout()->LoadFromStorage(Storage::NANDSystem); + global_app->LoadLayout(global_app->GetStorageContentsLayout()); } void ContentManagerLayout::gameCartMenuItem_Click() { - mainapp->GetStorageContentsLayout()->LoadFromStorage(Storage::GameCart); - mainapp->LoadLayout(mainapp->GetStorageContentsLayout()); + global_app->GetStorageContentsLayout()->LoadFromStorage(Storage::GameCart); + global_app->LoadLayout(global_app->GetStorageContentsLayout()); } void ContentManagerLayout::unusedTicketsMenuItem_Click() { - mainapp->LoadMenuData(set::GetDictionaryEntry(34), "Ticket", set::GetDictionaryEntry(35)); - mainapp->GetUnusedTicketsLayout()->UpdateElements(true); - mainapp->LoadLayout(mainapp->GetUnusedTicketsLayout()); + global_app->LoadMenuData(set::GetDictionaryEntry(34), "Ticket", set::GetDictionaryEntry(35)); + global_app->GetUnusedTicketsLayout()->UpdateElements(true); + global_app->LoadLayout(global_app->GetUnusedTicketsLayout()); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_CopyLayout.cpp b/Goldleaf/Source/ui/ui_CopyLayout.cpp index ff13188c..d04c03f0 100644 --- a/Goldleaf/Source/ui/ui_CopyLayout.cpp +++ b/Goldleaf/Source/ui/ui_CopyLayout.cpp @@ -22,8 +22,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { @@ -31,9 +31,9 @@ namespace ui { this->infoText = pu::ui::elm::TextBlock::New(150, 320, set::GetDictionaryEntry(151)); this->infoText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); - this->infoText->SetColor(gsets.CustomScheme.Text); + this->infoText->SetColor(global_settings.custom_scheme.Text); this->copyBar = pu::ui::elm::ProgressBar::New(340, 360, 600, 30, 100.0f); - gsets.ApplyProgressBarColor(this->copyBar); + global_settings.ApplyProgressBarColor(this->copyBar); this->Add(this->infoText); this->Add(this->copyBar); } @@ -46,15 +46,15 @@ namespace ui { this->copyBar->SetMaxValue(total); this->copyBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); - mainapp->ShowNotification(set::GetDictionaryEntry(141)); + global_app->ShowNotification(set::GetDictionaryEntry(141)); } else { if(Exp->IsFile(NewPath)) { - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(153), set::GetDictionaryEntry(143), { set::GetDictionaryEntry(239), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(153), set::GetDictionaryEntry(143), { set::GetDictionaryEntry(239), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; } fs::DeleteFile(NewPath); @@ -62,9 +62,9 @@ namespace ui { this->copyBar->SetMaxValue(total); this->copyBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); - mainapp->ShowNotification(set::GetDictionaryEntry(240)); + global_app->ShowNotification(set::GetDictionaryEntry(240)); } } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_ExploreMenuLayout.cpp b/Goldleaf/Source/ui/ui_ExploreMenuLayout.cpp index 1d881687..fdceaca9 100644 --- a/Goldleaf/Source/ui/ui_ExploreMenuLayout.cpp +++ b/Goldleaf/Source/ui/ui_ExploreMenuLayout.cpp @@ -22,39 +22,39 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { ExploreMenuLayout::ExploreMenuLayout() : pu::ui::Layout() { - this->mountsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->mountsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->mountsMenu); + this->mountsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->mountsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->mountsMenu); this->sdCardMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(19)); - this->sdCardMenuItem->SetIcon(gsets.PathForResource("/Common/SdCard.png")); - this->sdCardMenuItem->SetColor(gsets.CustomScheme.Text); + this->sdCardMenuItem->SetIcon(global_settings.PathForResource("/Common/SdCard.png")); + this->sdCardMenuItem->SetColor(global_settings.custom_scheme.Text); this->sdCardMenuItem->AddOnClick(std::bind(&ExploreMenuLayout::sdCard_Click, this)); this->pcDriveMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(279)); - this->pcDriveMenuItem->SetIcon(gsets.PathForResource("/Common/Drive.png")); - this->pcDriveMenuItem->SetColor(gsets.CustomScheme.Text); + this->pcDriveMenuItem->SetIcon(global_settings.PathForResource("/Common/Drive.png")); + this->pcDriveMenuItem->SetColor(global_settings.custom_scheme.Text); this->pcDriveMenuItem->AddOnClick(std::bind(&ExploreMenuLayout::pcDrive_Click, this)); this->nandProfInfoFMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(20) + " (PRODINFOF)"); - this->nandProfInfoFMenuItem->SetIcon(gsets.PathForResource("/Common/NAND.png")); - this->nandProfInfoFMenuItem->SetColor(gsets.CustomScheme.Text); + this->nandProfInfoFMenuItem->SetIcon(global_settings.PathForResource("/Common/NAND.png")); + this->nandProfInfoFMenuItem->SetColor(global_settings.custom_scheme.Text); this->nandProfInfoFMenuItem->AddOnClick(std::bind(&ExploreMenuLayout::nandProdInfoF_Click, this)); this->nandSafeMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(20) + " (SAFE)"); - this->nandSafeMenuItem->SetIcon(gsets.PathForResource("/Common/NAND.png")); - this->nandSafeMenuItem->SetColor(gsets.CustomScheme.Text); + this->nandSafeMenuItem->SetIcon(global_settings.PathForResource("/Common/NAND.png")); + this->nandSafeMenuItem->SetColor(global_settings.custom_scheme.Text); this->nandSafeMenuItem->AddOnClick(std::bind(&ExploreMenuLayout::nandSafe_Click, this)); this->nandUserMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(20) + " (USER)"); - this->nandUserMenuItem->SetIcon(gsets.PathForResource("/Common/NAND.png")); - this->nandUserMenuItem->SetColor(gsets.CustomScheme.Text); + this->nandUserMenuItem->SetIcon(global_settings.PathForResource("/Common/NAND.png")); + this->nandUserMenuItem->SetColor(global_settings.custom_scheme.Text); this->nandUserMenuItem->AddOnClick(std::bind(&ExploreMenuLayout::nandUser_Click, this)); this->nandSystemMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(20) + " (SYSTEM)"); - this->nandSystemMenuItem->SetIcon(gsets.PathForResource("/Common/NAND.png")); - this->nandSystemMenuItem->SetColor(gsets.CustomScheme.Text); + this->nandSystemMenuItem->SetIcon(global_settings.PathForResource("/Common/NAND.png")); + this->nandSystemMenuItem->SetColor(global_settings.custom_scheme.Text); this->nandSystemMenuItem->AddOnClick(std::bind(&ExploreMenuLayout::nandSystem_Click, this)); this->mountsMenu->AddItem(this->sdCardMenuItem); this->mountsMenu->AddItem(this->pcDriveMenuItem); @@ -67,47 +67,47 @@ namespace ui void ExploreMenuLayout::sdCard_Click() { - mainapp->GetBrowserLayout()->ChangePartitionSdCard(); - mainapp->LoadMenuData(set::GetDictionaryEntry(19), "SdCard", mainapp->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->GetBrowserLayout()->ChangePartitionSdCard(); + global_app->LoadMenuData(set::GetDictionaryEntry(19), "SdCard", global_app->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); + global_app->LoadLayout(global_app->GetBrowserLayout()); } void ExploreMenuLayout::pcDrive_Click() { if(!usb::detail::IsStateOk()) { - mainapp->CreateShowDialog(set::GetDictionaryEntry(299), set::GetDictionaryEntry(300), { set::GetDictionaryEntry(234) }, true); + global_app->CreateShowDialog(set::GetDictionaryEntry(299), set::GetDictionaryEntry(300), { set::GetDictionaryEntry(234) }, true); return; } - mainapp->GetPCExploreLayout()->UpdatePaths(); - mainapp->LoadLayout(mainapp->GetPCExploreLayout()); + global_app->GetPCExploreLayout()->UpdatePaths(); + global_app->LoadLayout(global_app->GetPCExploreLayout()); } void ExploreMenuLayout::nandProdInfoF_Click() { - mainapp->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::PRODINFOF); - mainapp->LoadMenuData(set::GetDictionaryEntry(1), "NAND", mainapp->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::PRODINFOF); + global_app->LoadMenuData(set::GetDictionaryEntry(1), "NAND", global_app->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); + global_app->LoadLayout(global_app->GetBrowserLayout()); } void ExploreMenuLayout::nandSafe_Click() { - mainapp->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::NANDSafe); - mainapp->LoadMenuData(set::GetDictionaryEntry(1), "NAND", mainapp->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::NANDSafe); + global_app->LoadMenuData(set::GetDictionaryEntry(1), "NAND", global_app->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); + global_app->LoadLayout(global_app->GetBrowserLayout()); } void ExploreMenuLayout::nandUser_Click() { - mainapp->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::NANDUser); - mainapp->LoadMenuData(set::GetDictionaryEntry(1), "NAND", mainapp->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::NANDUser); + global_app->LoadMenuData(set::GetDictionaryEntry(1), "NAND", global_app->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); + global_app->LoadLayout(global_app->GetBrowserLayout()); } void ExploreMenuLayout::nandSystem_Click() { - mainapp->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::NANDSystem); - mainapp->LoadMenuData(set::GetDictionaryEntry(1), "NAND", mainapp->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->GetBrowserLayout()->ChangePartitionNAND(fs::Partition::NANDSystem); + global_app->LoadMenuData(set::GetDictionaryEntry(1), "NAND", global_app->GetBrowserLayout()->GetExplorer()->GetPresentableCwd()); + global_app->LoadLayout(global_app->GetBrowserLayout()); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_FileContentLayout.cpp b/Goldleaf/Source/ui/ui_FileContentLayout.cpp index 3ee66a79..c75bdaff 100644 --- a/Goldleaf/Source/ui/ui_FileContentLayout.cpp +++ b/Goldleaf/Source/ui/ui_FileContentLayout.cpp @@ -22,16 +22,16 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { FileContentLayout::FileContentLayout() { this->cntText = pu::ui::elm::TextBlock::New(40, 180, ""); - this->cntText->SetColor(gsets.CustomScheme.Text); - this->cntText->SetFont(pu::ui::render::LoadFont(gsets.PathForResource("/FileSystem/FileDataFont.ttf"), 25)); + this->cntText->SetColor(global_settings.custom_scheme.Text); + this->cntText->SetFont(pu::ui::render::LoadFont(global_settings.PathForResource("/FileSystem/FileDataFont.ttf"), 25)); this->Add(this->cntText); this->loffset = 0; } diff --git a/Goldleaf/Source/ui/ui_InstallLayout.cpp b/Goldleaf/Source/ui/ui_InstallLayout.cpp index 0be21b02..75c1d953 100644 --- a/Goldleaf/Source/ui/ui_InstallLayout.cpp +++ b/Goldleaf/Source/ui/ui_InstallLayout.cpp @@ -23,8 +23,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { @@ -32,9 +32,9 @@ namespace ui { this->installText = pu::ui::elm::TextBlock::New(150, 320, set::GetDictionaryEntry(151)); this->installText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); - this->installText->SetColor(gsets.CustomScheme.Text); + this->installText->SetColor(global_settings.custom_scheme.Text); this->installBar = pu::ui::elm::ProgressBar::New(340, 360, 600, 30, 100.0f); - gsets.ApplyProgressBarColor(this->installBar); + global_settings.ApplyProgressBarColor(this->installBar); this->Add(this->installText); this->Add(this->installBar); } @@ -48,7 +48,7 @@ namespace ui { if(rc == err::Make(err::ErrorDescription::TitleAlreadyInstalled)) { - auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(77), set::GetDictionaryEntry(272) + "\n" + set::GetDictionaryEntry(273) + "\n" + set::GetDictionaryEntry(274), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + auto sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(77), set::GetDictionaryEntry(272) + "\n" + set::GetDictionaryEntry(273) + "\n" + set::GetDictionaryEntry(274), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt == 0) { auto title = hos::Locate(inst.GetApplicationId()); @@ -233,7 +233,7 @@ namespace ui } } else info += "\n\n" + set::GetDictionaryEntry(97); - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(77), info, { set::GetDictionaryEntry(65), set::GetDictionaryEntry(18) }, true, inst.GetExportedIconPath()); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(77), info, { set::GetDictionaryEntry(65), set::GetDictionaryEntry(18) }, true, inst.GetExportedIconPath()); doinstall = (sopt == 0); } @@ -247,7 +247,7 @@ namespace ui return; } this->installText->SetText(set::GetDictionaryEntry(146)); - mainapp->CallForRender(); + global_app->CallForRender(); this->installBar->SetVisible(true); hos::LockAutoSleep(); rc = inst.WriteContents([&](ncm::ContentRecord Record, u32 Content, u32 ContentCount, double Done, double Total, u64 BytesSec) @@ -261,13 +261,13 @@ namespace ui name += ".nca\'... (" + fs::FormatSize(BytesSec) + "/s - " + hos::FormatTime(secstime) + ")"; this->installText->SetText(name); this->installBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); hos::UnlockAutoSleep(); } this->installBar->SetVisible(false); - mainapp->CallForRender(); + global_app->CallForRender(); if(rc != 0) HandleResult(rc, set::GetDictionaryEntry(251)); - else if(doinstall) mainapp->ShowNotification(set::GetDictionaryEntry(150)); + else if(doinstall) global_app->ShowNotification(set::GetDictionaryEntry(150)); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_MainApplication.cpp b/Goldleaf/Source/ui/ui_MainApplication.cpp index b8e7ceb0..9f212a66 100644 --- a/Goldleaf/Source/ui/ui_MainApplication.cpp +++ b/Goldleaf/Source/ui/ui_MainApplication.cpp @@ -21,59 +21,76 @@ #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { extern String clipboard; + #define MAINAPP_MENU_SET_BASE(layout) { \ + layout->SetBackgroundColor(global_settings.custom_scheme.Background); \ + layout->Add(this->baseImage); \ + layout->Add(this->timeText); \ + layout->Add(this->batteryText); \ + layout->Add(this->batteryImage); \ + layout->Add(this->batteryChargeImage); \ + layout->Add(this->menuImage); \ + layout->Add(this->usbImage); \ + layout->Add(this->connImage); \ + layout->Add(this->ipText); \ + layout->Add(this->menuNameText); \ + layout->Add(this->menuHeadText); \ + layout->Add(this->userImage); \ + layout->Add(this->helpImage); \ + } + void MainApplication::OnLoad() { - gsets = set::ProcessSettings(); + global_settings = set::ProcessSettings(); set::Initialize(); if(acc::SelectFromPreselectedUser()) acc::CacheSelectedUserIcon(); - pu::ui::render::SetDefaultFont(gsets.PathForResource("/Roboto-Medium.ttf")); + pu::ui::render::SetDefaultFont(global_settings.PathForResource("/Roboto-Medium.ttf")); this->preblv = 0; this->seluser = {}; this->preisch = false; this->pretime = ""; this->vfirst = true; this->connstate = 0; - this->baseImage = pu::ui::elm::Image::New(0, 0, gsets.PathForResource("/Base.png")); + this->baseImage = pu::ui::elm::Image::New(0, 0, global_settings.PathForResource("/Base.png")); this->timeText = pu::ui::elm::TextBlock::New(1124, 15, "00:00:00"); - this->timeText->SetColor(gsets.CustomScheme.Text); + this->timeText->SetColor(global_settings.custom_scheme.Text); this->batteryText = pu::ui::elm::TextBlock::New(1015, 20, "0%", 20); - this->batteryText->SetColor(gsets.CustomScheme.Text); - this->batteryImage = pu::ui::elm::Image::New(960, 8, gsets.PathForResource("/Battery/0.png")); - this->batteryChargeImage = pu::ui::elm::Image::New(960, 8, gsets.PathForResource("/Battery/Charge.png")); - this->menuBanner = pu::ui::elm::Image::New(10, 62, gsets.PathForResource("/MenuBanner.png")); - this->menuImage = pu::ui::elm::Image::New(15, 69, gsets.PathForResource("/Common/SdCard.png")); + this->batteryText->SetColor(global_settings.custom_scheme.Text); + this->batteryImage = pu::ui::elm::Image::New(960, 8, global_settings.PathForResource("/Battery/0.png")); + this->batteryChargeImage = pu::ui::elm::Image::New(960, 8, global_settings.PathForResource("/Battery/Charge.png")); + this->menuBanner = pu::ui::elm::Image::New(10, 62, global_settings.PathForResource("/MenuBanner.png")); + this->menuImage = pu::ui::elm::Image::New(15, 69, global_settings.PathForResource("/Common/SdCard.png")); this->menuImage->SetWidth(85); this->menuImage->SetHeight(85); - this->userImage = ClickableImage::New(1090, 75, gsets.PathForResource("/Common/User.png")); + this->userImage = ClickableImage::New(1090, 75, global_settings.PathForResource("/Common/User.png")); this->userImage->SetWidth(70); this->userImage->SetHeight(70); this->userImage->SetOnClick(std::bind(&MainApplication::userImage_OnClick, this)); - this->helpImage = ClickableImage::New(1180, 80, gsets.PathForResource("/Common/Help.png")); + this->helpImage = ClickableImage::New(1180, 80, global_settings.PathForResource("/Common/Help.png")); this->helpImage->SetWidth(60); this->helpImage->SetHeight(60); this->helpImage->SetOnClick(std::bind(&MainApplication::helpImage_OnClick, this)); - this->usbImage = pu::ui::elm::Image::New(695, 12, gsets.PathForResource("/Common/USB.png")); + this->usbImage = pu::ui::elm::Image::New(695, 12, global_settings.PathForResource("/Common/USB.png")); this->usbImage->SetWidth(40); this->usbImage->SetHeight(40); this->usbImage->SetVisible(false); - this->connImage = pu::ui::elm::Image::New(755, 12, gsets.PathForResource("/Connection/None.png")); + this->connImage = pu::ui::elm::Image::New(755, 12, global_settings.PathForResource("/Connection/None.png")); this->connImage->SetWidth(40); this->connImage->SetHeight(40); this->connImage->SetVisible(true); this->ipText = pu::ui::elm::TextBlock::New(800, 20, "", 20); - this->ipText->SetColor(gsets.CustomScheme.Text); + this->ipText->SetColor(global_settings.custom_scheme.Text); this->menuNameText = pu::ui::elm::TextBlock::New(120, 85, "-"); - this->menuNameText->SetColor(gsets.CustomScheme.Text); + this->menuNameText->SetColor(global_settings.custom_scheme.Text); this->menuHeadText = pu::ui::elm::TextBlock::New(120, 120, "-", 20); - this->menuHeadText->SetColor(gsets.CustomScheme.Text); + this->menuHeadText->SetColor(global_settings.custom_scheme.Text); this->UnloadMenuData(); this->toast = pu::ui::extras::Toast::New(":", 20, pu::ui::Color(225, 225, 225, 255), pu::ui::Color(40, 40, 40, 255)); this->UpdateValues(); @@ -106,261 +123,34 @@ namespace ui this->memory = MemoryLayout::New(); this->memory->SetOnInput(std::bind(&MainApplication::memory_Input, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); this->update = UpdateLayout::New(); + this->webBrowser = WebBrowserLayout::New(); + this->webBrowser->SetOnInput(std::bind(&MainApplication::webBrowser_Input, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); this->about = AboutLayout::New(); this->about->SetOnInput(std::bind(&MainApplication::about_Input, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - this->mainMenu->SetBackgroundColor(gsets.CustomScheme.Background); - this->browser->SetBackgroundColor(gsets.CustomScheme.Background); - this->exploreMenu->SetBackgroundColor(gsets.CustomScheme.Background); - this->pcExplore->SetBackgroundColor(gsets.CustomScheme.Background); - this->fileContent->SetBackgroundColor(gsets.CustomScheme.Background); - this->copy->SetBackgroundColor(gsets.CustomScheme.Background); - this->nspInstall->SetBackgroundColor(gsets.CustomScheme.Background); - this->contentInformation->SetBackgroundColor(gsets.CustomScheme.Background); - this->storageContents->SetBackgroundColor(gsets.CustomScheme.Background); - this->contentManager->SetBackgroundColor(gsets.CustomScheme.Background); - this->titleDump->SetBackgroundColor(gsets.CustomScheme.Background); - this->unusedTickets->SetBackgroundColor(gsets.CustomScheme.Background); - this->account->SetBackgroundColor(gsets.CustomScheme.Background); - this->amiibo->SetBackgroundColor(gsets.CustomScheme.Background); - this->settings->SetBackgroundColor(gsets.CustomScheme.Background); - this->memory->SetBackgroundColor(gsets.CustomScheme.Background); - this->update->SetBackgroundColor(gsets.CustomScheme.Background); - this->about->SetBackgroundColor(gsets.CustomScheme.Background); - this->mainMenu->Add(this->baseImage); - this->browser->Add(this->baseImage); - this->exploreMenu->Add(this->baseImage); - this->pcExplore->Add(this->baseImage); - this->fileContent->Add(this->baseImage); - this->copy->Add(this->baseImage); - this->nspInstall->Add(this->baseImage); - this->contentInformation->Add(this->baseImage); - this->storageContents->Add(this->baseImage); - this->contentManager->Add(this->baseImage); - this->titleDump->Add(this->baseImage); - this->unusedTickets->Add(this->baseImage); - this->account->Add(this->baseImage); - this->amiibo->Add(this->baseImage); - this->settings->Add(this->baseImage); - this->memory->Add(this->baseImage); - this->update->Add(this->baseImage); - this->about->Add(this->baseImage); - this->mainMenu->Add(this->timeText); - this->browser->Add(this->timeText); - this->exploreMenu->Add(this->timeText); - this->pcExplore->Add(this->timeText); - this->fileContent->Add(this->timeText); - this->copy->Add(this->timeText); - this->nspInstall->Add(this->timeText); - this->contentInformation->Add(this->timeText); - this->storageContents->Add(this->timeText); - this->contentManager->Add(this->timeText); - this->titleDump->Add(this->timeText); - this->unusedTickets->Add(this->timeText); - this->account->Add(this->timeText); - this->amiibo->Add(this->timeText); - this->settings->Add(this->timeText); - this->memory->Add(this->timeText); - this->update->Add(this->timeText); - this->about->Add(this->timeText); - this->mainMenu->Add(this->batteryText); - this->browser->Add(this->batteryText); - this->exploreMenu->Add(this->batteryText); - this->pcExplore->Add(this->batteryText); - this->fileContent->Add(this->batteryText); - this->copy->Add(this->batteryText); - this->nspInstall->Add(this->batteryText); - this->contentInformation->Add(this->batteryText); - this->storageContents->Add(this->batteryText); - this->contentManager->Add(this->batteryText); - this->titleDump->Add(this->batteryText); - this->unusedTickets->Add(this->batteryText); - this->account->Add(this->batteryText); - this->amiibo->Add(this->batteryText); - this->settings->Add(this->batteryText); - this->memory->Add(this->batteryText); - this->update->Add(this->batteryText); - this->about->Add(this->batteryText); - this->mainMenu->Add(this->batteryImage); - this->browser->Add(this->batteryImage); - this->exploreMenu->Add(this->batteryImage); - this->pcExplore->Add(this->batteryImage); - this->fileContent->Add(this->batteryImage); - this->copy->Add(this->batteryImage); - this->nspInstall->Add(this->batteryImage); - this->contentInformation->Add(this->batteryImage); - this->storageContents->Add(this->batteryImage); - this->contentManager->Add(this->batteryImage); - this->titleDump->Add(this->batteryImage); - this->unusedTickets->Add(this->batteryImage); - this->account->Add(this->batteryImage); - this->amiibo->Add(this->batteryImage); - this->settings->Add(this->batteryImage); - this->memory->Add(this->batteryImage); - this->update->Add(this->batteryImage); - this->about->Add(this->batteryImage); - this->mainMenu->Add(this->batteryChargeImage); - this->browser->Add(this->batteryChargeImage); - this->exploreMenu->Add(this->batteryChargeImage); - this->pcExplore->Add(this->batteryChargeImage); - this->fileContent->Add(this->batteryChargeImage); - this->copy->Add(this->batteryChargeImage); - this->nspInstall->Add(this->batteryChargeImage); - this->contentInformation->Add(this->batteryChargeImage); - this->storageContents->Add(this->batteryChargeImage); - this->contentManager->Add(this->batteryChargeImage); - this->titleDump->Add(this->batteryChargeImage); - this->unusedTickets->Add(this->batteryChargeImage); - this->account->Add(this->batteryChargeImage); - this->amiibo->Add(this->batteryChargeImage); - this->settings->Add(this->batteryChargeImage); - this->memory->Add(this->batteryChargeImage); - this->update->Add(this->batteryChargeImage); - this->about->Add(this->batteryChargeImage); - this->mainMenu->Add(this->menuImage); - this->browser->Add(this->menuImage); - this->exploreMenu->Add(this->menuImage); - this->pcExplore->Add(this->menuImage); - this->fileContent->Add(this->menuImage); - this->copy->Add(this->menuImage); - this->nspInstall->Add(this->menuImage); - this->contentInformation->Add(this->menuImage); - this->storageContents->Add(this->menuImage); - this->contentManager->Add(this->menuImage); - this->titleDump->Add(this->menuImage); - this->unusedTickets->Add(this->menuImage); - this->account->Add(this->menuImage); - this->amiibo->Add(this->menuImage); - this->settings->Add(this->menuImage); - this->memory->Add(this->menuImage); - this->update->Add(this->menuImage); - this->about->Add(this->menuImage); - this->mainMenu->Add(this->usbImage); - this->browser->Add(this->usbImage); - this->exploreMenu->Add(this->usbImage); - this->pcExplore->Add(this->usbImage); - this->fileContent->Add(this->usbImage); - this->copy->Add(this->usbImage); - this->nspInstall->Add(this->usbImage); - this->contentInformation->Add(this->usbImage); - this->storageContents->Add(this->usbImage); - this->contentManager->Add(this->usbImage); - this->titleDump->Add(this->usbImage); - this->unusedTickets->Add(this->usbImage); - this->account->Add(this->usbImage); - this->amiibo->Add(this->usbImage); - this->settings->Add(this->usbImage); - this->memory->Add(this->usbImage); - this->update->Add(this->usbImage); - this->about->Add(this->usbImage); - this->mainMenu->Add(this->connImage); - this->browser->Add(this->connImage); - this->exploreMenu->Add(this->connImage); - this->pcExplore->Add(this->connImage); - this->fileContent->Add(this->connImage); - this->copy->Add(this->connImage); - this->nspInstall->Add(this->connImage); - this->contentInformation->Add(this->connImage); - this->storageContents->Add(this->connImage); - this->contentManager->Add(this->connImage); - this->titleDump->Add(this->connImage); - this->unusedTickets->Add(this->connImage); - this->account->Add(this->connImage); - this->amiibo->Add(this->connImage); - this->settings->Add(this->connImage); - this->memory->Add(this->connImage); - this->update->Add(this->connImage); - this->about->Add(this->connImage); - this->mainMenu->Add(this->ipText); - this->browser->Add(this->ipText); - this->exploreMenu->Add(this->ipText); - this->pcExplore->Add(this->ipText); - this->fileContent->Add(this->ipText); - this->copy->Add(this->ipText); - this->nspInstall->Add(this->ipText); - this->contentInformation->Add(this->ipText); - this->storageContents->Add(this->ipText); - this->contentManager->Add(this->ipText); - this->titleDump->Add(this->ipText); - this->unusedTickets->Add(this->ipText); - this->account->Add(this->ipText); - this->amiibo->Add(this->ipText); - this->settings->Add(this->ipText); - this->memory->Add(this->ipText); - this->update->Add(this->ipText); - this->about->Add(this->ipText); + + MAINAPP_MENU_SET_BASE(this->mainMenu); + MAINAPP_MENU_SET_BASE(this->browser); + MAINAPP_MENU_SET_BASE(this->exploreMenu); + MAINAPP_MENU_SET_BASE(this->pcExplore); + MAINAPP_MENU_SET_BASE(this->fileContent); + MAINAPP_MENU_SET_BASE(this->copy); + MAINAPP_MENU_SET_BASE(this->nspInstall); + MAINAPP_MENU_SET_BASE(this->contentInformation); + MAINAPP_MENU_SET_BASE(this->storageContents); + MAINAPP_MENU_SET_BASE(this->contentManager); + MAINAPP_MENU_SET_BASE(this->titleDump); + MAINAPP_MENU_SET_BASE(this->unusedTickets); + MAINAPP_MENU_SET_BASE(this->account); + MAINAPP_MENU_SET_BASE(this->amiibo); + MAINAPP_MENU_SET_BASE(this->settings); + MAINAPP_MENU_SET_BASE(this->memory); + MAINAPP_MENU_SET_BASE(this->update); + MAINAPP_MENU_SET_BASE(this->webBrowser); + MAINAPP_MENU_SET_BASE(this->about); + + // Special extras this->mainMenu->Add(this->menuBanner); - this->mainMenu->Add(this->menuNameText); - this->browser->Add(this->menuNameText); - this->exploreMenu->Add(this->menuNameText); - this->pcExplore->Add(this->menuNameText); - this->fileContent->Add(this->menuNameText); - this->copy->Add(this->menuNameText); - this->nspInstall->Add(this->menuNameText); - this->contentInformation->Add(this->menuNameText); - this->storageContents->Add(this->menuNameText); - this->contentManager->Add(this->menuNameText); - this->titleDump->Add(this->menuNameText); - this->unusedTickets->Add(this->menuNameText); - this->account->Add(this->menuNameText); - this->amiibo->Add(this->menuNameText); - this->settings->Add(this->menuNameText); - this->memory->Add(this->menuNameText); - this->update->Add(this->menuNameText); - this->about->Add(this->menuNameText); - this->mainMenu->Add(this->menuHeadText); - this->browser->Add(this->menuHeadText); - this->exploreMenu->Add(this->menuHeadText); - this->pcExplore->Add(this->menuHeadText); - this->fileContent->Add(this->menuHeadText); - this->copy->Add(this->menuHeadText); - this->nspInstall->Add(this->menuHeadText); - this->contentInformation->Add(this->menuHeadText); - this->storageContents->Add(this->menuHeadText); - this->contentManager->Add(this->menuHeadText); - this->titleDump->Add(this->menuHeadText); - this->unusedTickets->Add(this->menuHeadText); - this->account->Add(this->menuHeadText); - this->amiibo->Add(this->menuHeadText); - this->settings->Add(this->menuHeadText); - this->memory->Add(this->menuHeadText); - this->update->Add(this->menuHeadText); - this->about->Add(this->menuHeadText); - this->mainMenu->Add(this->userImage); - this->browser->Add(this->userImage); - this->exploreMenu->Add(this->userImage); - this->pcExplore->Add(this->userImage); - this->fileContent->Add(this->userImage); - this->copy->Add(this->userImage); - this->nspInstall->Add(this->userImage); - this->contentInformation->Add(this->userImage); - this->storageContents->Add(this->userImage); - this->contentManager->Add(this->userImage); - this->titleDump->Add(this->userImage); - this->unusedTickets->Add(this->userImage); - this->account->Add(this->userImage); - this->amiibo->Add(this->userImage); - this->settings->Add(this->userImage); - this->memory->Add(this->userImage); - this->update->Add(this->userImage); - this->about->Add(this->userImage); - this->mainMenu->Add(this->helpImage); - this->browser->Add(this->helpImage); - this->exploreMenu->Add(this->helpImage); - this->pcExplore->Add(this->helpImage); - this->fileContent->Add(this->helpImage); - this->copy->Add(this->helpImage); - this->nspInstall->Add(this->helpImage); - this->contentInformation->Add(this->helpImage); - this->storageContents->Add(this->helpImage); - this->contentManager->Add(this->helpImage); - this->titleDump->Add(this->helpImage); - this->unusedTickets->Add(this->helpImage); - this->account->Add(this->helpImage); - this->amiibo->Add(this->helpImage); - this->settings->Add(this->helpImage); - this->memory->Add(this->helpImage); - this->update->Add(this->helpImage); - this->about->Add(this->helpImage); + this->AddThread(std::bind(&MainApplication::UpdateValues, this)); this->SetOnInput(std::bind(&MainApplication::OnInput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); this->LoadLayout(this->mainMenu); @@ -393,17 +183,17 @@ namespace ui bool isch = hos::IsCharging(); if((this->preblv != blv) || this->vfirst) { - if(blv <= 10) this->batteryImage->SetImage(gsets.PathForResource("/Battery/0.png")); - else if((blv > 10) && (blv <= 20)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/10.png")); - else if((blv > 20) && (blv <= 30)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/20.png")); - else if((blv > 30) && (blv <= 40)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/30.png")); - else if((blv > 40) && (blv <= 50)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/40.png")); - else if((blv > 50) && (blv <= 60)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/50.png")); - else if((blv > 60) && (blv <= 70)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/60.png")); - else if((blv > 70) && (blv <= 80)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/70.png")); - else if((blv > 80) && (blv <= 90)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/80.png")); - else if((blv > 90) && (blv < 100)) this->batteryImage->SetImage(gsets.PathForResource("/Battery/90.png")); - else if(blv == 100) this->batteryImage->SetImage(gsets.PathForResource("/Battery/100.png")); + if(blv <= 10) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/0.png")); + else if((blv > 10) && (blv <= 20)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/10.png")); + else if((blv > 20) && (blv <= 30)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/20.png")); + else if((blv > 30) && (blv <= 40)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/30.png")); + else if((blv > 40) && (blv <= 50)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/40.png")); + else if((blv > 50) && (blv <= 60)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/50.png")); + else if((blv > 60) && (blv <= 70)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/60.png")); + else if((blv > 70) && (blv <= 80)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/70.png")); + else if((blv > 80) && (blv <= 90)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/80.png")); + else if((blv > 90) && (blv < 100)) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/90.png")); + else if(blv == 100) this->batteryImage->SetImage(global_settings.PathForResource("/Battery/100.png")); this->batteryText->SetText(std::to_string(blv) + "%"); this->preblv = blv; } @@ -427,7 +217,7 @@ namespace ui if(rc == 0) if(connstr > 0) connimg = std::to_string(connstr); if(connstr != this->connstate) { - this->connImage->SetImage(gsets.PathForResource("/Connection/" + connimg + ".png")); + this->connImage->SetImage(global_settings.PathForResource("/Connection/" + connimg + ".png")); this->connImage->SetWidth(40); this->connImage->SetHeight(40); this->connstate = connstr; @@ -444,12 +234,12 @@ namespace ui if(!acc::UidCompare(&user, &this->seluser)) { this->seluser = user; - if(!accountUidIsValid(&this->seluser)) this->userImage->SetImage(gsets.PathForResource("/Common/User.png")); + if(!accountUidIsValid(&this->seluser)) this->userImage->SetImage(global_settings.PathForResource("/Common/User.png")); else { auto usericon = acc::GetCachedUserIcon(); if(fs::Exists(usericon)) this->userImage->SetImage(usericon); - else this->userImage->SetImage(gsets.PathForResource("/Common/User.png")); + else this->userImage->SetImage(global_settings.PathForResource("/Common/User.png")); } this->userImage->SetWidth(70); this->userImage->SetHeight(70); @@ -461,7 +251,7 @@ namespace ui if(this->menuImage != NULL) { this->menuImage->SetVisible(true); - if(CommonIcon) this->menuImage->SetImage(gsets.PathForResource("/Common/" + ImageName + ".png")); + if(CommonIcon) this->menuImage->SetImage(global_settings.PathForResource("/Common/" + ImageName + ".png")); else this->menuImage->SetImage(ImageName); this->menuImage->SetWidth(85); this->menuImage->SetHeight(85); @@ -508,17 +298,17 @@ namespace ui { bool cdir = this->browser->GetExplorer()->IsDirectory(clipboard); std::string fsicon; - if(cdir) fsicon = gsets.PathForResource("/FileSystem/Directory.png"); + if(cdir) fsicon = global_settings.PathForResource("/FileSystem/Directory.png"); else { String ext = fs::GetExtension(clipboard); - if(ext == "nsp") fsicon = gsets.PathForResource("/FileSystem/NSP.png"); - else if(ext == "nro") fsicon = gsets.PathForResource("/FileSystem/NRO.png"); - else if(ext == "tik") fsicon = gsets.PathForResource("/FileSystem/TIK.png"); - else if(ext == "cert") fsicon = gsets.PathForResource("/FileSystem/CERT.png"); - else if(ext == "nca") fsicon = gsets.PathForResource("/FileSystem/NCA.png"); - else if(ext == "nxtheme") fsicon = gsets.PathForResource("/FileSystem/NXTheme.png"); - else fsicon = gsets.PathForResource("/FileSystem/File.png"); + if(ext == "nsp") fsicon = global_settings.PathForResource("/FileSystem/NSP.png"); + else if(ext == "nro") fsicon = global_settings.PathForResource("/FileSystem/NRO.png"); + else if(ext == "tik") fsicon = global_settings.PathForResource("/FileSystem/TIK.png"); + else if(ext == "cert") fsicon = global_settings.PathForResource("/FileSystem/CERT.png"); + else if(ext == "nca") fsicon = global_settings.PathForResource("/FileSystem/NCA.png"); + else if(ext == "nxtheme") fsicon = global_settings.PathForResource("/FileSystem/NXTheme.png"); + else fsicon = global_settings.PathForResource("/FileSystem/File.png"); } int sopt = this->CreateShowDialog(set::GetDictionaryEntry(222), set::GetDictionaryEntry(223) + "\n(" + clipboard + ")", { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true, fsicon); if(sopt == 0) @@ -526,7 +316,7 @@ namespace ui String cname = fs::GetFileName(clipboard); this->LoadLayout(this->GetCopyLayout()); this->GetCopyLayout()->StartCopy(clipboard, this->browser->GetExplorer()->FullPathFor(cname), cdir, this->browser->GetExplorer()); - mainapp->LoadLayout(this->browser); + global_app->LoadLayout(this->browser); this->browser->UpdateElements(); clipboard = ""; } @@ -666,6 +456,15 @@ namespace ui } } + void MainApplication::webBrowser_Input(u64 down, u64 up, u64 held) + { + if(down & KEY_B) + { + this->UnloadMenuData(); + this->LoadLayout(this->mainMenu); + } + } + void MainApplication::about_Input(u64 down, u64 up, u64 held) { if(down & KEY_B) @@ -781,6 +580,11 @@ namespace ui return this->update; } + WebBrowserLayout::Ref &MainApplication::GetWebBrowserLayout() + { + return this->webBrowser; + } + AboutLayout::Ref &MainApplication::GetAboutLayout() { return this->about; @@ -789,9 +593,8 @@ namespace ui void UpdateClipboard(String Path) { SetClipboard(Path); - String copymsg; - if(mainapp->GetBrowserLayout()->GetExplorer()->IsFile(Path)) copymsg = set::GetDictionaryEntry(257); - else copymsg = set::GetDictionaryEntry(258); - mainapp->ShowNotification(copymsg); + String copymsg = set::GetDictionaryEntry(258); + if(global_app->GetBrowserLayout()->GetExplorer()->IsFile(Path)) copymsg = set::GetDictionaryEntry(257); + global_app->ShowNotification(copymsg); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_MainMenuLayout.cpp b/Goldleaf/Source/ui/ui_MainMenuLayout.cpp index c4ab49bc..a887e943 100644 --- a/Goldleaf/Source/ui/ui_MainMenuLayout.cpp +++ b/Goldleaf/Source/ui/ui_MainMenuLayout.cpp @@ -22,51 +22,51 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { MainMenuLayout::MainMenuLayout() : pu::ui::Layout() { - this->optionMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->optionMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->optionMenu); + this->optionMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->optionMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->optionMenu); this->exploreMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(277)); - this->exploreMenuItem->SetIcon(gsets.PathForResource("/Common/SdCard.png")); - this->exploreMenuItem->SetColor(gsets.CustomScheme.Text); + this->exploreMenuItem->SetIcon(global_settings.PathForResource("/Common/SdCard.png")); + this->exploreMenuItem->SetColor(global_settings.custom_scheme.Text); this->exploreMenuItem->AddOnClick(std::bind(&MainMenuLayout::exploreMenuItem_Click, this)); this->titleMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(3)); - this->titleMenuItem->SetIcon(gsets.PathForResource("/Common/Storage.png")); - this->titleMenuItem->SetColor(gsets.CustomScheme.Text); + this->titleMenuItem->SetIcon(global_settings.PathForResource("/Common/Storage.png")); + this->titleMenuItem->SetColor(global_settings.custom_scheme.Text); this->titleMenuItem->AddOnClick(std::bind(&MainMenuLayout::titleMenuItem_Click, this)); this->webMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(5)); - this->webMenuItem->SetIcon(gsets.PathForResource("/Common/Browser.png")); - this->webMenuItem->SetColor(gsets.CustomScheme.Text); + this->webMenuItem->SetIcon(global_settings.PathForResource("/Common/Browser.png")); + this->webMenuItem->SetColor(global_settings.custom_scheme.Text); this->webMenuItem->AddOnClick(std::bind(&MainMenuLayout::webMenuItem_Click, this)); this->accountMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(6)); - this->accountMenuItem->SetIcon(gsets.PathForResource("/Common/Accounts.png")); - this->accountMenuItem->SetColor(gsets.CustomScheme.Text); + this->accountMenuItem->SetIcon(global_settings.PathForResource("/Common/Accounts.png")); + this->accountMenuItem->SetColor(global_settings.custom_scheme.Text); this->accountMenuItem->AddOnClick(std::bind(&MainMenuLayout::accountMenuItem_Click, this)); this->amiiboMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(283)); - this->amiiboMenuItem->SetIcon(gsets.PathForResource("/Common/Amiibo.png")); - this->amiiboMenuItem->SetColor(gsets.CustomScheme.Text); + this->amiiboMenuItem->SetIcon(global_settings.PathForResource("/Common/Amiibo.png")); + this->amiiboMenuItem->SetColor(global_settings.custom_scheme.Text); this->amiiboMenuItem->AddOnClick(std::bind(&MainMenuLayout::amiiboMenuItem_Click, this)); this->emuiiboMenuItem = pu::ui::elm::MenuItem::New("emuiibo management"); - this->emuiiboMenuItem->SetIcon(gsets.PathForResource("/Common/Amiibo.png")); - this->emuiiboMenuItem->SetColor(gsets.CustomScheme.Text); + this->emuiiboMenuItem->SetIcon(global_settings.PathForResource("/Common/Amiibo.png")); + this->emuiiboMenuItem->SetColor(global_settings.custom_scheme.Text); this->emuiiboMenuItem->AddOnClick(std::bind(&MainMenuLayout::emuiiboMenuItem_Click, this)); this->settingsMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(375)); - this->settingsMenuItem->SetIcon(gsets.PathForResource("/Common/Settings.png")); - this->settingsMenuItem->SetColor(gsets.CustomScheme.Text); + this->settingsMenuItem->SetIcon(global_settings.PathForResource("/Common/Settings.png")); + this->settingsMenuItem->SetColor(global_settings.custom_scheme.Text); this->settingsMenuItem->AddOnClick(std::bind(&MainMenuLayout::settingsMenuItem_Click, this)); this->updateMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(284)); - this->updateMenuItem->SetIcon(gsets.PathForResource("/Common/Update.png")); - this->updateMenuItem->SetColor(gsets.CustomScheme.Text); + this->updateMenuItem->SetIcon(global_settings.PathForResource("/Common/Update.png")); + this->updateMenuItem->SetColor(global_settings.custom_scheme.Text); this->updateMenuItem->AddOnClick(std::bind(&MainMenuLayout::updateMenuItem_Click, this)); this->aboutMenuItem = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(8)); - this->aboutMenuItem->SetIcon(gsets.PathForResource("/Common/Info.png")); - this->aboutMenuItem->SetColor(gsets.CustomScheme.Text); + this->aboutMenuItem->SetIcon(global_settings.PathForResource("/Common/Info.png")); + this->aboutMenuItem->SetColor(global_settings.custom_scheme.Text); this->aboutMenuItem->AddOnClick(std::bind(&MainMenuLayout::aboutMenuItem_Click, this)); this->optionMenu->AddItem(this->exploreMenuItem); this->optionMenu->AddItem(this->titleMenuItem); @@ -82,62 +82,49 @@ namespace ui void MainMenuLayout::exploreMenuItem_Click() { - mainapp->LoadMenuData(set::GetDictionaryEntry(277), "Storage", set::GetDictionaryEntry(278)); - mainapp->LoadLayout(mainapp->GetExploreMenuLayout()); + global_app->LoadMenuData(set::GetDictionaryEntry(277), "Storage", set::GetDictionaryEntry(278)); + global_app->LoadLayout(global_app->GetExploreMenuLayout()); } void MainMenuLayout::titleMenuItem_Click() { - mainapp->LoadMenuData(set::GetDictionaryEntry(32), "Storage", set::GetDictionaryEntry(33)); + global_app->LoadMenuData(set::GetDictionaryEntry(32), "Storage", set::GetDictionaryEntry(33)); EnsureDirectories(); - mainapp->LoadLayout(mainapp->GetContentManagerLayout()); + global_app->LoadLayout(global_app->GetContentManagerLayout()); } void MainMenuLayout::webMenuItem_Click() { - String out = AskForText(set::GetDictionaryEntry(38), "https://"); - if(out.empty()) return; - else - { - bool nothttp = (out.AsUTF8().substr(0, 6) != "http:/"); - bool nothttps = (out.AsUTF8().substr(0, 7) != "https:/"); - if(nothttp && nothttps) - { - mainapp->CreateShowDialog(set::GetDictionaryEntry(36), set::GetDictionaryEntry(39), { set::GetDictionaryEntry(234) }, false); - return; - } - } - WebCommonConfig web; - webPageCreate(&web, out.AsUTF8().c_str()); - WebCommonReply wout; - webConfigShow(&web, &wout); + global_app->LoadMenuData("Web browser", "Browser", "Use the console's web browser library applet."); + global_app->GetWebBrowserLayout()->Refresh(); + global_app->LoadLayout(global_app->GetWebBrowserLayout()); } void MainMenuLayout::accountMenuItem_Click() { if(!acc::HasUser()) { - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(348), set::GetDictionaryEntry(349), {set::GetDictionaryEntry(111), set::GetDictionaryEntry(18)}, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(348), set::GetDictionaryEntry(349), {set::GetDictionaryEntry(111), set::GetDictionaryEntry(18)}, true); if(sopt != 0) return; - if(acc::SelectUser()) mainapp->ShowNotification(set::GetDictionaryEntry(324)); + if(acc::SelectUser()) global_app->ShowNotification(set::GetDictionaryEntry(324)); else { - mainapp->ShowNotification(set::GetDictionaryEntry(350)); + global_app->ShowNotification(set::GetDictionaryEntry(350)); return; } } - mainapp->LoadMenuData(set::GetDictionaryEntry(41), "Accounts", set::GetDictionaryEntry(42)); - mainapp->GetAccountLayout()->Load(); - mainapp->LoadLayout(mainapp->GetAccountLayout()); + global_app->LoadMenuData(set::GetDictionaryEntry(41), "Accounts", set::GetDictionaryEntry(42)); + global_app->GetAccountLayout()->Load(); + global_app->LoadLayout(global_app->GetAccountLayout()); } void MainMenuLayout::amiiboMenuItem_Click() { - mainapp->LoadMenuData(set::GetDictionaryEntry(283), "Amiibo", set::GetDictionaryEntry(301)); - mainapp->LoadLayout(mainapp->GetAmiiboDumpLayout()); - mainapp->GetAmiiboDumpLayout()->StartDump(); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->LoadMenuData(set::GetDictionaryEntry(283), "Amiibo", set::GetDictionaryEntry(301)); + global_app->LoadLayout(global_app->GetAmiiboDumpLayout()); + global_app->GetAmiiboDumpLayout()->StartDump(); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); } void MainMenuLayout::emuiiboMenuItem_Click() @@ -152,7 +139,7 @@ namespace ui if(R_SUCCEEDED(rc)) { Version otherv = Version::MakeVersion(v.major, v.minor, v.micro); - if(otherv.IsLower(Version::MakeVersion(0, 4, 0))) mainapp->ShowNotification("Only emuiibo 0.4.0 or newer is supported."); + if(otherv.IsLower(Version::MakeVersion(0, 4, 0))) global_app->ShowNotification("Only emuiibo 0.4.0 or newer is supported."); else { nfp::emu::EmulationStatus status; @@ -161,53 +148,53 @@ namespace ui { if(!nfp::emu::StatusIsOn(status)) { - auto sopt = mainapp->CreateShowDialog("emuiibo activation", "emuiibo is currently deactivated.\nWould you like to activate it?", { "Yes", "Cancel" }, true); + auto sopt = global_app->CreateShowDialog("emuiibo activation", "emuiibo is currently deactivated.\nWould you like to activate it?", { "Yes", "Cancel" }, true); if(sopt == 0) { rc = nfp::emu::SetEmulationOnForever(); - mainapp->ShowNotification("emuiibo was activated. Select this menu again."); + global_app->ShowNotification("emuiibo was activated. Select this menu again."); } } else { char amiibo[FS_MAX_PATH] = {0}; rc = nfp::emu::GetCurrentAmiibo(amiibo, FS_MAX_PATH); - mainapp->ShowNotification(String("Current amiibo: ") + amiibo); + global_app->ShowNotification(String("Current amiibo: ") + amiibo); auto id = nfp::emu::GetAmiiboIdFromPath(amiibo); - mainapp->ShowNotification(String("Amiibo ID: ") + id); + global_app->ShowNotification(String("Amiibo ID: ") + id); auto img = nfp::emu::SaveAmiiboImageById(id); - mainapp->ShowNotification(String("Amiibo ID image: ") + img); - mainapp->CreateShowDialog("Amiibo", String("Current selected amiibo: ") + amiibo, {"Ok"}, true, img.AsUTF8()); + global_app->ShowNotification(String("Amiibo ID image: ") + img); + global_app->CreateShowDialog("Amiibo", String("Current selected amiibo: ") + amiibo, {"Ok"}, true, img.AsUTF8()); } } } } nfp::emu::Exit(); } - if(R_FAILED(rc)) mainapp->ShowNotification("Result failed: " + hos::FormatHex(rc)); + if(R_FAILED(rc)) global_app->ShowNotification("Result failed: " + hos::FormatHex(rc)); } - else mainapp->ShowNotification("emuiibo isn't present or loaded."); + else global_app->ShowNotification("emuiibo isn't present or loaded."); return; - mainapp->LoadMenuData(set::GetDictionaryEntry(283), "Amiibo", set::GetDictionaryEntry(301)); - mainapp->LoadLayout(mainapp->GetAmiiboDumpLayout()); - mainapp->GetAmiiboDumpLayout()->StartDump(); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + global_app->LoadMenuData(set::GetDictionaryEntry(283), "Amiibo", set::GetDictionaryEntry(301)); + global_app->LoadLayout(global_app->GetAmiiboDumpLayout()); + global_app->GetAmiiboDumpLayout()->StartDump(); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); } void MainMenuLayout::settingsMenuItem_Click() { - mainapp->LoadMenuData(set::GetDictionaryEntry(375), "Settings", set::GetDictionaryEntry(376)); - mainapp->LoadLayout(mainapp->GetSettingsLayout()); + global_app->LoadMenuData(set::GetDictionaryEntry(375), "Settings", set::GetDictionaryEntry(376)); + global_app->LoadLayout(global_app->GetSettingsLayout()); } void MainMenuLayout::updateMenuItem_Click() { - mainapp->LoadMenuData(set::GetDictionaryEntry(284), "Update", set::GetDictionaryEntry(302)); - mainapp->LoadLayout(mainapp->GetUpdateLayout()); - mainapp->GetUpdateLayout()->StartUpdateSearch(); + global_app->LoadMenuData(set::GetDictionaryEntry(284), "Update", set::GetDictionaryEntry(302)); + global_app->LoadLayout(global_app->GetUpdateLayout()); + global_app->GetUpdateLayout()->StartUpdateSearch(); } void MainMenuLayout::aboutMenuItem_Click() @@ -219,7 +206,7 @@ namespace ui if(GetLaunchMode() == LaunchMode::Applet) lmode = set::GetDictionaryEntry(290); if(GetLaunchMode() == LaunchMode::Application) lmode = set::GetDictionaryEntry(291); - mainapp->LoadMenuData("Goldleaf v" + GetVersion(), "Info", exmode.AsUTF8() + ", " + lmode.AsUTF8()); - mainapp->LoadLayout(mainapp->GetAboutLayout()); + global_app->LoadMenuData("Goldleaf v" + GetVersion(), "Info", exmode.AsUTF8() + ", " + lmode.AsUTF8()); + global_app->LoadLayout(global_app->GetAboutLayout()); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_MemoryLayout.cpp b/Goldleaf/Source/ui/ui_MemoryLayout.cpp index fff0f430..33f38daf 100644 --- a/Goldleaf/Source/ui/ui_MemoryLayout.cpp +++ b/Goldleaf/Source/ui/ui_MemoryLayout.cpp @@ -22,37 +22,37 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { MemoryLayout::MemoryLayout() : pu::ui::Layout() { this->sdText = pu::ui::elm::TextBlock::New(125, 300, set::GetDictionaryEntry(19), 35); - this->sdText->SetColor(gsets.CustomScheme.Text); + this->sdText->SetColor(global_settings.custom_scheme.Text); this->sdBar = pu::ui::elm::ProgressBar::New(120, 345, 450, 30, 100.0f); - gsets.ApplyProgressBarColor(this->sdBar); + global_settings.ApplyProgressBarColor(this->sdBar); this->sdFreeText = pu::ui::elm::TextBlock::New(125, 385, "0 bytes " + set::GetDictionaryEntry(221)); - this->sdFreeText->SetColor(gsets.CustomScheme.Text); + this->sdFreeText->SetColor(global_settings.custom_scheme.Text); this->nandText = pu::ui::elm::TextBlock::New(615, 300, set::GetDictionaryEntry(79), 35); - this->nandText->SetColor(gsets.CustomScheme.Text); + this->nandText->SetColor(global_settings.custom_scheme.Text); this->nandBar = pu::ui::elm::ProgressBar::New(620, 345, 450, 30, 100.0f); - gsets.ApplyProgressBarColor(this->nandBar); + global_settings.ApplyProgressBarColor(this->nandBar); this->nandFreeText = pu::ui::elm::TextBlock::New(620, 385, "0 bytes " + set::GetDictionaryEntry(221)); - this->nandFreeText->SetColor(gsets.CustomScheme.Text); + this->nandFreeText->SetColor(global_settings.custom_scheme.Text); this->safeText = pu::ui::elm::TextBlock::New(105, 480, set::GetDictionaryEntry(27)); - this->safeText->SetColor(gsets.CustomScheme.Text); + this->safeText->SetColor(global_settings.custom_scheme.Text); this->safeBar = pu::ui::elm::ProgressBar::New(100, 515, 300, 30, 100.0f); - gsets.ApplyProgressBarColor(this->safeBar); + global_settings.ApplyProgressBarColor(this->safeBar); this->userText = pu::ui::elm::TextBlock::New(455, 480, set::GetDictionaryEntry(28)); - this->userText->SetColor(gsets.CustomScheme.Text); + this->userText->SetColor(global_settings.custom_scheme.Text); this->userBar = pu::ui::elm::ProgressBar::New(450, 515, 300, 30, 100.0f); - gsets.ApplyProgressBarColor(this->userBar); + global_settings.ApplyProgressBarColor(this->userBar); this->systemText = pu::ui::elm::TextBlock::New(805, 480, set::GetDictionaryEntry(29)); - this->systemText->SetColor(gsets.CustomScheme.Text); + this->systemText->SetColor(global_settings.custom_scheme.Text); this->systemBar = pu::ui::elm::ProgressBar::New(800, 515, 300, 30, 100.0f); - gsets.ApplyProgressBarColor(this->systemBar); + global_settings.ApplyProgressBarColor(this->systemBar); this->Add(this->sdText); this->Add(this->sdBar); this->Add(this->sdFreeText); diff --git a/Goldleaf/Source/ui/ui_PCExploreLayout.cpp b/Goldleaf/Source/ui/ui_PCExploreLayout.cpp index 777c118b..4780d541 100644 --- a/Goldleaf/Source/ui/ui_PCExploreLayout.cpp +++ b/Goldleaf/Source/ui/ui_PCExploreLayout.cpp @@ -22,16 +22,16 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { PCExploreLayout::PCExploreLayout() : pu::ui::Layout() { - this->pathsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->pathsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->pathsMenu); + this->pathsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->pathsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->pathsMenu); this->Add(this->pathsMenu); } @@ -76,15 +76,15 @@ namespace ui for(u32 i = 0; i < this->names.size(); i++) { auto itm = pu::ui::elm::MenuItem::New(this->names[i]); - itm->SetColor(gsets.CustomScheme.Text); - if(i < drivecount) itm->SetIcon(gsets.PathForResource("/Common/Drive.png")); - else itm->SetIcon(gsets.PathForResource("/FileSystem/Directory.png")); + itm->SetColor(global_settings.custom_scheme.Text); + if(i < drivecount) itm->SetIcon(global_settings.PathForResource("/Common/Drive.png")); + else itm->SetIcon(global_settings.PathForResource("/FileSystem/Directory.png")); itm->AddOnClick(std::bind(&PCExploreLayout::path_Click, this)); this->pathsMenu->AddItem(itm); } auto fselitm = pu::ui::elm::MenuItem::New("Select file from PC"); - fselitm->SetColor(gsets.CustomScheme.Text); - fselitm->SetIcon(gsets.PathForResource("/FileSystem/File.png")); + fselitm->SetColor(global_settings.custom_scheme.Text); + fselitm->SetIcon(global_settings.PathForResource("/FileSystem/File.png")); fselitm->AddOnClick(std::bind(&PCExploreLayout::fileSelect_Click, this)); this->pathsMenu->AddItem(fselitm); this->pathsMenu->SetSelectedIndex(0); @@ -93,14 +93,14 @@ namespace ui void PCExploreLayout::path_Click() { u32 idx = this->pathsMenu->GetSelectedIndex(); - mainapp->GetBrowserLayout()->ChangePartitionPCDrive(this->paths[idx]); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->GetBrowserLayout()->ChangePartitionPCDrive(this->paths[idx]); + global_app->LoadLayout(global_app->GetBrowserLayout()); } void PCExploreLayout::fileSelect_Click() { String selfile; auto rc = usb::ProcessCommand(usb::OutString(selfile)); - if(R_SUCCEEDED(rc)) mainapp->GetBrowserLayout()->HandleFileDirectly(selfile); + if(R_SUCCEEDED(rc)) global_app->GetBrowserLayout()->HandleFileDirectly(selfile); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_PartitionBrowserLayout.cpp b/Goldleaf/Source/ui/ui_PartitionBrowserLayout.cpp index eeaccc64..7e0bc471 100644 --- a/Goldleaf/Source/ui/ui_PartitionBrowserLayout.cpp +++ b/Goldleaf/Source/ui/ui_PartitionBrowserLayout.cpp @@ -22,8 +22,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { @@ -32,13 +32,13 @@ namespace ui PartitionBrowserLayout::PartitionBrowserLayout() : pu::ui::Layout() { this->gexp = fs::GetSdCardExplorer(); - this->browseMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->browseMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->browseMenu); + this->browseMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->browseMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->browseMenu); this->dirEmptyText = pu::ui::elm::TextBlock::New(30, 630, set::GetDictionaryEntry(49)); this->dirEmptyText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); this->dirEmptyText->SetVerticalAlign(pu::ui::elm::VerticalAlign::Center); - this->dirEmptyText->SetColor(gsets.CustomScheme.Text); + this->dirEmptyText->SetColor(global_settings.custom_scheme.Text); this->Add(this->browseMenu); this->Add(this->dirEmptyText); } @@ -82,7 +82,7 @@ namespace ui if(!this->elems.empty()) this->elems.clear(); this->elems = this->gexp->GetContents(); this->browseMenu->ClearItems(); - mainapp->LoadMenuHead(this->gexp->GetPresentableCwd()); + global_app->LoadMenuHead(this->gexp->GetPresentableCwd()); if(this->elems.empty()) { this->browseMenu->SetVisible(false); @@ -92,28 +92,27 @@ namespace ui { this->browseMenu->SetVisible(true); this->dirEmptyText->SetVisible(false); - for(u32 i = 0; i < this->elems.size(); i++) + for(auto &itm: this->elems) { - String itm = this->elems[i]; bool isdir = this->gexp->IsDirectory(itm); auto mitm = pu::ui::elm::MenuItem::New(itm); - mitm->SetColor(gsets.CustomScheme.Text); - if(isdir) mitm->SetIcon(gsets.PathForResource("/FileSystem/Directory.png")); + mitm->SetColor(global_settings.custom_scheme.Text); + if(isdir) mitm->SetIcon(global_settings.PathForResource("/FileSystem/Directory.png")); else { String ext = fs::GetExtension(itm); - if(ext == "nsp") mitm->SetIcon(gsets.PathForResource("/FileSystem/NSP.png")); - else if(ext == "nro") mitm->SetIcon(gsets.PathForResource("/FileSystem/NRO.png")); - else if(ext == "tik") mitm->SetIcon(gsets.PathForResource("/FileSystem/TIK.png")); - else if(ext == "cert") mitm->SetIcon(gsets.PathForResource("/FileSystem/CERT.png")); - else if(ext == "nxtheme") mitm->SetIcon(gsets.PathForResource("/FileSystem/NXTheme.png")); - else if(ext == "nca") mitm->SetIcon(gsets.PathForResource("/FileSystem/NCA.png")); - else if(ext == "nacp") mitm->SetIcon(gsets.PathForResource("/FileSystem/NACP.png")); - else if((ext == "jpg") || (ext == "jpeg")) mitm->SetIcon(gsets.PathForResource("/FileSystem/JPEG.png")); - else mitm->SetIcon(gsets.PathForResource("/FileSystem/File.png")); + if(ext == "nsp") mitm->SetIcon(global_settings.PathForResource("/FileSystem/NSP.png")); + else if(ext == "nro") mitm->SetIcon(global_settings.PathForResource("/FileSystem/NRO.png")); + else if(ext == "tik") mitm->SetIcon(global_settings.PathForResource("/FileSystem/TIK.png")); + else if(ext == "cert") mitm->SetIcon(global_settings.PathForResource("/FileSystem/CERT.png")); + else if(ext == "nxtheme") mitm->SetIcon(global_settings.PathForResource("/FileSystem/NXTheme.png")); + else if(ext == "nca") mitm->SetIcon(global_settings.PathForResource("/FileSystem/NCA.png")); + else if(ext == "nacp") mitm->SetIcon(global_settings.PathForResource("/FileSystem/NACP.png")); + else if((ext == "jpg") || (ext == "jpeg")) mitm->SetIcon(global_settings.PathForResource("/FileSystem/JPEG.png")); + else mitm->SetIcon(global_settings.PathForResource("/FileSystem/File.png")); } - mitm->AddOnClick(std::bind(&PartitionBrowserLayout::fsItems_Click, this)); - mitm->AddOnClick(std::bind(&PartitionBrowserLayout::fsItems_Click_Y, this), KEY_Y); + mitm->AddOnClick(std::bind(&PartitionBrowserLayout::fsItems_Click, this, itm)); + mitm->AddOnClick(std::bind(&PartitionBrowserLayout::fsItems_Click_Y, this, itm), KEY_Y); this->browseMenu->AddItem(mitm); } u32 tmpidx = 0; @@ -148,7 +147,7 @@ namespace ui u32 idx = std::distance(items.begin(), it); this->browseMenu->SetSelectedIndex(idx); - fsItems_Click(); + fsItems_Click(Path); } bool PartitionBrowserLayout::GoBack() @@ -159,16 +158,15 @@ namespace ui bool PartitionBrowserLayout::WarnNANDWriteAccess() { if(!this->gexp->ShouldWarnOnWriteAccess()) return true; - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(50), set::GetDictionaryEntry(51), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(50), set::GetDictionaryEntry(51), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); return (sopt == 0); } - void PartitionBrowserLayout::fsItems_Click() + void PartitionBrowserLayout::fsItems_Click(String item) { if(this->elems.empty()) return; - String itm = this->browseMenu->GetSelectedItem()->GetName(); - String fullitm = this->gexp->FullPathFor(itm); - String pfullitm = this->gexp->FullPresentablePathFor(itm); + String fullitm = this->gexp->FullPathFor(item); + String pfullitm = this->gexp->FullPresentablePathFor(item); if(this->gexp->NavigateForward(fullitm)) { expidxstack.push_back(this->browseMenu->GetSelectedIndex()); @@ -176,7 +174,7 @@ namespace ui } else { - String ext = fs::GetExtension(itm); + String ext = fs::GetExtension(item); String msg = set::GetDictionaryEntry(52) + " "; if(ext == "nsp") msg += set::GetDictionaryEntry(53); else if(ext == "nro") msg += set::GetDictionaryEntry(54); @@ -238,7 +236,7 @@ namespace ui vopts.push_back(set::GetDictionaryEntry(74)); vopts.push_back(set::GetDictionaryEntry(75)); vopts.push_back(set::GetDictionaryEntry(18)); - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(76), msg, vopts, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(76), msg, vopts, true); if(sopt < 0) return; int osopt = sopt; if(ext == "nsp") @@ -246,7 +244,7 @@ namespace ui switch(sopt) { case 0: - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(77), set::GetDictionaryEntry(78), { set::GetDictionaryEntry(19), set::GetDictionaryEntry(79), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(77), set::GetDictionaryEntry(78), { set::GetDictionaryEntry(19), set::GetDictionaryEntry(79), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; Storage dst = Storage::SdCard; if(sopt == 0) dst = Storage::SdCard; @@ -258,11 +256,11 @@ namespace ui HandleResult(err::Make(err::ErrorDescription::NotEnoughSize), set::GetDictionaryEntry(251)); return; } - mainapp->LoadMenuHead(set::GetDictionaryEntry(145) + " " + pfullitm); - mainapp->LoadLayout(mainapp->GetInstallLayout()); - mainapp->GetInstallLayout()->StartInstall(fullitm, this->gexp, dst); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); - mainapp->LoadMenuHead(this->gexp->GetPresentableCwd()); + global_app->LoadMenuHead(set::GetDictionaryEntry(145) + " " + pfullitm); + global_app->LoadLayout(global_app->GetInstallLayout()); + global_app->GetInstallLayout()->StartInstall(fullitm, this->gexp, dst); + global_app->LoadLayout(global_app->GetBrowserLayout()); + global_app->LoadMenuHead(this->gexp->GetPresentableCwd()); break; } } @@ -273,15 +271,15 @@ namespace ui case 0: if(GetExecutableMode() == ExecutableMode::NRO) { - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(98), set::GetDictionaryEntry(99), { set::GetDictionaryEntry(66), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(98), set::GetDictionaryEntry(99), { set::GetDictionaryEntry(66), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; envSetNextLoad(fullitm.AsUTF8().c_str(), fullitm.AsUTF8().c_str()); - mainapp->CloseWithFadeOut(); + global_app->CloseWithFadeOut(); return; } else { - mainapp->CreateShowDialog(set::GetDictionaryEntry(98), set::GetDictionaryEntry(100), { set::GetDictionaryEntry(234) }, false); + global_app->CreateShowDialog(set::GetDictionaryEntry(98), set::GetDictionaryEntry(100), { set::GetDictionaryEntry(234) }, false); return; } break; @@ -292,7 +290,7 @@ namespace ui switch(sopt) { case 0: - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(101), set::GetDictionaryEntry(102), { set::GetDictionaryEntry(234), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(101), set::GetDictionaryEntry(102), { set::GetDictionaryEntry(234), set::GetDictionaryEntry(18) }, true); if(sopt == 0) { auto btik = this->gexp->ReadFile(fullitm); @@ -310,7 +308,7 @@ namespace ui std::string ntnro = "sdmc:/switch/nxthemes_installer/nxthemesinstaller.nro"; if(!fs::IsFile(ntnro)) { - mainapp->CreateShowDialog(set::GetDictionaryEntry(104), set::GetDictionaryEntry(105), { set::GetDictionaryEntry(234) }, false); + global_app->CreateShowDialog(set::GetDictionaryEntry(104), set::GetDictionaryEntry(105), { set::GetDictionaryEntry(234) }, false); return; } std::string arg = ntnro + " installtheme=" + fullitm.AsUTF8(); @@ -322,7 +320,7 @@ namespace ui arg.replace(index, 1, "(_)"); } envSetNextLoad(ntnro.c_str(), arg.c_str()); - mainapp->CloseWithFadeOut(); + global_app->CloseWithFadeOut(); return; break; } @@ -336,7 +334,7 @@ namespace ui auto fsize = this->gexp->GetFileSize(fullitm); if(fsize < sizeof(NacpStruct)) { - mainapp->ShowNotification(set::GetDictionaryEntry(341)); + global_app->ShowNotification(set::GetDictionaryEntry(341)); return; } this->gexp->ReadFileBlock(fullitm, 0, sizeof(NacpStruct), (u8*)&nacp); @@ -378,7 +376,7 @@ namespace ui if(logom == 0) msg += set::GetDictionaryEntry(119); else if(logom == 2) msg += set::GetDictionaryEntry(120); else msg += set::GetDictionaryEntry(114); - mainapp->CreateShowDialog(set::GetDictionaryEntry(58), msg, { set::GetDictionaryEntry(234) }, false); + global_app->CreateShowDialog(set::GetDictionaryEntry(58), msg, { set::GetDictionaryEntry(234) }, false); break; } } @@ -388,7 +386,7 @@ namespace ui { case 0: if(!acc::HasUser()) return; - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(121), set::GetDictionaryEntry(122), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(121), set::GetDictionaryEntry(122), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; size_t fsize = this->gexp->GetFileSize(fullitm); @@ -396,7 +394,7 @@ namespace ui this->gexp->ReadFileBlock(fullitm, 0, fsize, iconbuf); auto rc = acc::EditUserIcon(iconbuf, fsize); - if(rc == 0) mainapp->ShowNotification(set::GetDictionaryEntry(123)); + if(rc == 0) global_app->ShowNotification(set::GetDictionaryEntry(123)); else HandleResult(rc, set::GetDictionaryEntry(124)); delete[] iconbuf; break; @@ -407,7 +405,7 @@ namespace ui if(IsAtmosphere()) switch(sopt) { case 0: - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(125), set::GetDictionaryEntry(126), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(125), set::GetDictionaryEntry(126), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; hos::PayloadProcess(fullitm); break; @@ -418,8 +416,8 @@ namespace ui switch(sopt) { case 0: - mainapp->LoadLayout(mainapp->GetFileContentLayout()); - mainapp->GetFileContentLayout()->LoadFile(pfullitm, fullitm, this->gexp, false); + global_app->LoadLayout(global_app->GetFileContentLayout()); + global_app->GetFileContentLayout()->LoadFile(pfullitm, fullitm, this->gexp, false); break; } } @@ -429,19 +427,19 @@ namespace ui int renopt = copt - 2; if((osopt == viewopt) && (this->gexp->GetFileSize(fullitm) > 0)) { - mainapp->LoadLayout(mainapp->GetFileContentLayout()); - mainapp->GetFileContentLayout()->LoadFile(pfullitm, fullitm, this->gexp, true); + global_app->LoadLayout(global_app->GetFileContentLayout()); + global_app->GetFileContentLayout()->LoadFile(pfullitm, fullitm, this->gexp, true); } else if(osopt == copyopt) UpdateClipboard(fullitm); else if(osopt == delopt) { if(this->WarnNANDWriteAccess()) { - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(127), set::GetDictionaryEntry(128), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(127), set::GetDictionaryEntry(128), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; Result rc = 0; this->gexp->DeleteFile(fullitm); - if(rc == 0) mainapp->ShowNotification(set::GetDictionaryEntry(129)); + if(rc == 0) global_app->ShowNotification(set::GetDictionaryEntry(129)); else HandleResult(rc, set::GetDictionaryEntry(253)); u32 tmpidx = this->browseMenu->GetSelectedIndex(); if(tmpidx > 0) tmpidx--; @@ -450,10 +448,10 @@ namespace ui } else if(osopt == renopt) { - String kbdt = AskForText(set::GetDictionaryEntry(130), itm); + String kbdt = AskForText(set::GetDictionaryEntry(130), item); if(kbdt != "") { - if(kbdt == itm) return; + if(kbdt == item) return; String newren = kbdt; if(this->gexp->IsFile(newren) || this->gexp->IsDirectory(newren)) HandleResult(err::Make(err::ErrorDescription::FileDirectoryAlreadyPresent), set::GetDictionaryEntry(254)); else if(this->WarnNANDWriteAccess()) @@ -463,7 +461,7 @@ namespace ui if(rc) HandleResult(err::MakeErrno(rc), set::GetDictionaryEntry(254)); else { - mainapp->ShowNotification(set::GetDictionaryEntry(133)); + global_app->ShowNotification(set::GetDictionaryEntry(133)); this->UpdateElements(this->browseMenu->GetSelectedIndex()); } } @@ -472,11 +470,10 @@ namespace ui } } - void PartitionBrowserLayout::fsItems_Click_Y() + void PartitionBrowserLayout::fsItems_Click_Y(String item) { - String itm = this->browseMenu->GetSelectedItem()->GetName().AsUTF8().c_str(); - String fullitm = this->gexp->FullPathFor(itm); - String pfullitm = this->gexp->FullPresentablePathFor(itm); + String fullitm = this->gexp->FullPathFor(item); + String pfullitm = this->gexp->FullPresentablePathFor(item); if(this->gexp->IsDirectory(fullitm)) { auto files = this->gexp->GetFiles(fullitm); @@ -491,7 +488,7 @@ namespace ui extraopts.push_back(set::GetDictionaryEntry(18)); String msg = set::GetDictionaryEntry(134); msg += "\n\n" + set::GetDictionaryEntry(237) + " " + fs::FormatSize(this->gexp->GetDirectorySize(fullitm)); - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(135), msg, { set::GetDictionaryEntry(73), set::GetDictionaryEntry(74), set::GetDictionaryEntry(75), set::GetDictionaryEntry(280), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(135), msg, { set::GetDictionaryEntry(73), set::GetDictionaryEntry(74), set::GetDictionaryEntry(75), set::GetDictionaryEntry(280), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; switch(sopt) { @@ -501,19 +498,19 @@ namespace ui case 1: if(this->WarnNANDWriteAccess()) { - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(325), set::GetDictionaryEntry(326), {set::GetDictionaryEntry(111), set::GetDictionaryEntry(18)}, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(325), set::GetDictionaryEntry(326), {set::GetDictionaryEntry(111), set::GetDictionaryEntry(18)}, true); if(sopt < 0) return; this->gexp->DeleteDirectory(fullitm); - mainapp->ShowNotification(set::GetDictionaryEntry(327)); + global_app->ShowNotification(set::GetDictionaryEntry(327)); this->UpdateElements(); } break; case 2: { - String kbdt = AskForText(set::GetDictionaryEntry(238), itm); + String kbdt = AskForText(set::GetDictionaryEntry(238), item); if(kbdt != "") { - if(kbdt == itm) return; + if(kbdt == item) return; String newren = this->gexp->FullPathFor(kbdt); if(this->gexp->IsFile(newren) || this->gexp->IsDirectory(newren)) HandleResult(err::Make(err::ErrorDescription::FileDirectoryAlreadyPresent), set::GetDictionaryEntry(254)); else if(this->WarnNANDWriteAccess()) @@ -521,23 +518,23 @@ namespace ui int rc = 0; this->gexp->RenameDirectory(fullitm, newren); if(rc) HandleResult(rc, set::GetDictionaryEntry(254)); - else mainapp->ShowNotification(set::GetDictionaryEntry(139)); + else global_app->ShowNotification(set::GetDictionaryEntry(139)); this->UpdateElements(); } } } break; case 3: - int sopt2 = mainapp->CreateShowDialog(set::GetDictionaryEntry(280), set::GetDictionaryEntry(134), extraopts, true); + int sopt2 = global_app->CreateShowDialog(set::GetDictionaryEntry(280), set::GetDictionaryEntry(134), extraopts, true); switch(sopt2) { case 0: this->gexp->SetArchiveBit(fullitm); this->UpdateElements(this->browseMenu->GetSelectedIndex()); - mainapp->ShowNotification(set::GetDictionaryEntry(303)); + global_app->ShowNotification(set::GetDictionaryEntry(303)); break; case 1: - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(77), set::GetDictionaryEntry(78), { set::GetDictionaryEntry(19), set::GetDictionaryEntry(79), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(77), set::GetDictionaryEntry(78), { set::GetDictionaryEntry(19), set::GetDictionaryEntry(79), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; Storage dst = Storage::SdCard; if(sopt == 0) dst = Storage::SdCard; @@ -554,12 +551,12 @@ namespace ui HandleResult(err::Make(err::ErrorDescription::NotEnoughSize), set::GetDictionaryEntry(251)); return; } - mainapp->LoadMenuHead(set::GetDictionaryEntry(145) + " " + pnsp); - mainapp->LoadLayout(mainapp->GetInstallLayout()); - mainapp->GetInstallLayout()->StartInstall(nsp, this->gexp, dst, true); - mainapp->LoadLayout(mainapp->GetBrowserLayout()); + global_app->LoadMenuHead(set::GetDictionaryEntry(145) + " " + pnsp); + global_app->LoadLayout(global_app->GetInstallLayout()); + global_app->GetInstallLayout()->StartInstall(nsp, this->gexp, dst, true); + global_app->LoadLayout(global_app->GetBrowserLayout()); } - mainapp->LoadMenuHead(this->gexp->GetPresentableCwd()); + global_app->LoadMenuHead(this->gexp->GetPresentableCwd()); break; } break; diff --git a/Goldleaf/Source/ui/ui_SettingsLayout.cpp b/Goldleaf/Source/ui/ui_SettingsLayout.cpp index c44d680c..2ebb90be 100644 --- a/Goldleaf/Source/ui/ui_SettingsLayout.cpp +++ b/Goldleaf/Source/ui/ui_SettingsLayout.cpp @@ -22,31 +22,31 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { SettingsLayout::SettingsLayout() : pu::ui::Layout() { - this->optsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->optsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->optsMenu); + this->optsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->optsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->optsMenu); auto itm = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(352)); - itm->SetColor(gsets.CustomScheme.Text); + itm->SetColor(global_settings.custom_scheme.Text); itm->AddOnClick(std::bind(&SettingsLayout::optsFirmware_Click, this)); this->optsMenu->AddItem(itm); auto itm2 = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(353)); - itm2->SetColor(gsets.CustomScheme.Text); + itm2->SetColor(global_settings.custom_scheme.Text); itm2->AddOnClick(std::bind(&SettingsLayout::optsMemory_Click, this)); this->optsMenu->AddItem(itm2); auto itm3 = pu::ui::elm::MenuItem::New(set::GetDictionaryEntry(354)); - itm3->SetColor(gsets.CustomScheme.Text); + itm3->SetColor(global_settings.custom_scheme.Text); itm3->AddOnClick(std::bind(&SettingsLayout::optsConfig_Click, this)); this->optsMenu->AddItem(itm3); this->progressInfo = pu::ui::elm::ProgressBar::New(340, 360, 600, 30, 100.0f); this->progressInfo->SetVisible(false); - gsets.ApplyProgressBarColor(this->progressInfo); + global_settings.ApplyProgressBarColor(this->progressInfo); this->Add(this->optsMenu); this->Add(this->progressInfo); } @@ -54,9 +54,9 @@ namespace ui void SettingsLayout::optsConfig_Click() { String msg = set::GetDictionaryEntry(354) + ":\n"; - msg += String("\n" + set::GetDictionaryEntry(355) + ": ") + (gsets.IgnoreRequiredFirmwareVersion ? set::GetDictionaryEntry(111) : set::GetDictionaryEntry(112)); - if(!gsets.ExternalRomFs.empty()) msg += "\n" + set::GetDictionaryEntry(356) + ": 'SdCard:/" + gsets.ExternalRomFs + "'"; - mainapp->CreateShowDialog(set::GetDictionaryEntry(357), msg, { set::GetDictionaryEntry(234) }, true); + msg += String("\n" + set::GetDictionaryEntry(355) + ": ") + (global_settings.ignore_required_fw_ver ? set::GetDictionaryEntry(111) : set::GetDictionaryEntry(112)); + if(!global_settings.external_romfs.empty()) msg += "\n" + set::GetDictionaryEntry(356) + ": 'SdCard:/" + global_settings.external_romfs + "'"; + global_app->CreateShowDialog(set::GetDictionaryEntry(357), msg, { set::GetDictionaryEntry(234) }, true); } void SettingsLayout::ExportUpdateToDirectory(String Input, SetSysFirmwareVersion Fw) @@ -65,19 +65,19 @@ namespace ui auto exp = fs::GetNANDSystemExplorer(); this->optsMenu->SetVisible(false); this->progressInfo->SetVisible(true); - mainapp->LoadMenuHead(set::GetDictionaryEntry(359) + " " + Fw.display_version + "..."); + global_app->LoadMenuHead(set::GetDictionaryEntry(359) + " " + Fw.display_version + "..."); auto outdir = sd->FullPathFor(consts::Root + "/dump/update/" + Fw.display_version); sd->DeleteDirectory(outdir); exp->CopyDirectoryProgress(Input, outdir, [&](double Done, double Total) { this->progressInfo->SetMaxValue(Total); this->progressInfo->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); - mainapp->LoadMenuData(set::GetDictionaryEntry(43), "Settings", set::GetDictionaryEntry(44)); + global_app->LoadMenuData(set::GetDictionaryEntry(43), "Settings", set::GetDictionaryEntry(44)); this->optsMenu->SetVisible(true); this->progressInfo->SetVisible(false); - mainapp->ShowNotification(set::GetDictionaryEntry(358) + " '" + outdir + "'."); + global_app->ShowNotification(set::GetDictionaryEntry(358) + " '" + outdir + "'."); } void SettingsLayout::ExportUpdateToNSP(String Input, SetSysFirmwareVersion Fw) @@ -86,24 +86,24 @@ namespace ui auto exp = fs::GetNANDSystemExplorer(); this->optsMenu->SetVisible(false); this->progressInfo->SetVisible(true); - mainapp->LoadMenuHead(set::GetDictionaryEntry(359) + " " + Fw.display_version + "..."); + global_app->LoadMenuHead(set::GetDictionaryEntry(359) + " " + Fw.display_version + "..."); auto outnsp = sd->FullPathFor(consts::Root + "/dump/update/" + Fw.display_version + ".nsp"); sd->DeleteFile(outnsp); nsp::GenerateFrom(exp->FullPathFor(Input), outnsp, [&](u64 Done, u64 Total) { this->progressInfo->SetMaxValue((double)Total); this->progressInfo->SetProgress((double)Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); - mainapp->LoadMenuData(set::GetDictionaryEntry(43), "Settings", set::GetDictionaryEntry(44)); + global_app->LoadMenuData(set::GetDictionaryEntry(43), "Settings", set::GetDictionaryEntry(44)); this->optsMenu->SetVisible(true); this->progressInfo->SetVisible(false); - mainapp->ShowNotification(set::GetDictionaryEntry(358) + " '" + outnsp + "'."); + global_app->ShowNotification(set::GetDictionaryEntry(358) + " '" + outnsp + "'."); } void SettingsLayout::HandleUpdate(String Base, SetSysFirmwareVersion Fw) { - auto sopt2 = mainapp->CreateShowDialog(set::GetDictionaryEntry(360), set::GetDictionaryEntry(361), { set::GetDictionaryEntry(377), set::GetDictionaryEntry(53), set::GetDictionaryEntry(18)}, true); + auto sopt2 = global_app->CreateShowDialog(set::GetDictionaryEntry(360), set::GetDictionaryEntry(361), { set::GetDictionaryEntry(377), set::GetDictionaryEntry(53), set::GetDictionaryEntry(18)}, true); if(sopt2 == 0) ExportUpdateToDirectory(Base, Fw); else if(sopt2 == 1) ExportUpdateToNSP(Base, Fw); } @@ -134,16 +134,16 @@ namespace ui opts.push_back(set::GetDictionaryEntry(370)); } - auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(360), msg, opts, false); + auto sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(360), msg, opts, false); if(sopt == 0) return; else if(sopt == 1) this->HandleUpdate("Contents/registered", fwver); else if(sopt == 2) { - auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(371), set::GetDictionaryEntry(372) + "\n" + set::GetDictionaryEntry(373), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + auto sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(371), set::GetDictionaryEntry(372) + "\n" + set::GetDictionaryEntry(373), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt == 0) { hos::CleanPendingUpdate(); - mainapp->ShowNotification(set::GetDictionaryEntry(374)); + global_app->ShowNotification(set::GetDictionaryEntry(374)); } } else if(sopt == 3) this->HandleUpdate("Contents/placehld", pendfwver); @@ -151,7 +151,7 @@ namespace ui void SettingsLayout::optsMemory_Click() { - mainapp->GetMemoryLayout()->UpdateElements(); - mainapp->LoadLayout(mainapp->GetMemoryLayout()); + global_app->GetMemoryLayout()->UpdateElements(); + global_app->LoadLayout(global_app->GetMemoryLayout()); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_StorageContentsLayout.cpp b/Goldleaf/Source/ui/ui_StorageContentsLayout.cpp index aaf240cf..ecadd578 100644 --- a/Goldleaf/Source/ui/ui_StorageContentsLayout.cpp +++ b/Goldleaf/Source/ui/ui_StorageContentsLayout.cpp @@ -22,20 +22,20 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { StorageContentsLayout::StorageContentsLayout() { - this->contentsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->contentsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->contentsMenu); + this->contentsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->contentsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->contentsMenu); this->noContentsText = pu::ui::elm::TextBlock::New(0, 0, set::GetDictionaryEntry(188)); this->noContentsText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); this->noContentsText->SetVerticalAlign(pu::ui::elm::VerticalAlign::Center); - this->noContentsText->SetColor(gsets.CustomScheme.Text); + this->noContentsText->SetColor(global_settings.custom_scheme.Text); this->noContentsText->SetVisible(false); this->Add(this->noContentsText); this->Add(this->contentsMenu); @@ -44,8 +44,8 @@ namespace ui void StorageContentsLayout::contents_Click() { hos::Title selcnt = this->contents[this->contentsMenu->GetSelectedIndex()]; - mainapp->GetContentInformationLayout()->LoadContent(selcnt); - mainapp->LoadLayout(mainapp->GetContentInformationLayout()); + global_app->GetContentInformationLayout()->LoadContent(selcnt); + global_app->LoadLayout(global_app->GetContentInformationLayout()); } void StorageContentsLayout::LoadFromStorage(Storage Location) @@ -96,7 +96,7 @@ namespace ui delete nacp; } auto itm = pu::ui::elm::MenuItem::New(name); - itm->SetColor(gsets.CustomScheme.Text); + itm->SetColor(global_settings.custom_scheme.Text); bool hicon = this->contents[i].DumpControlData(); if(hicon) itm->SetIcon(hos::GetExportedIconPath(this->contents[i].ApplicationId)); itm->AddOnClick(std::bind(&StorageContentsLayout::contents_Click, this)); @@ -104,7 +104,7 @@ namespace ui } this->contentsMenu->SetSelectedIndex(0); } - mainapp->LoadMenuHead(set::GetDictionaryEntry(189)); + global_app->LoadMenuHead(set::GetDictionaryEntry(189)); } std::vector StorageContentsLayout::GetContents() diff --git a/Goldleaf/Source/ui/ui_TitleDumperLayout.cpp b/Goldleaf/Source/ui/ui_TitleDumperLayout.cpp index bb7e316d..b46a21f0 100644 --- a/Goldleaf/Source/ui/ui_TitleDumperLayout.cpp +++ b/Goldleaf/Source/ui/ui_TitleDumperLayout.cpp @@ -22,8 +22,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { @@ -31,10 +31,10 @@ namespace ui { this->dumpText = pu::ui::elm::TextBlock::New(150, 320, set::GetDictionaryEntry(151)); this->dumpText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); - this->dumpText->SetColor(gsets.CustomScheme.Text); + this->dumpText->SetColor(global_settings.custom_scheme.Text); this->ncaBar = pu::ui::elm::ProgressBar::New(340, 360, 600, 30, 100.0f); this->ncaBar->SetVisible(false); - gsets.ApplyProgressBarColor(this->ncaBar); + global_settings.ApplyProgressBarColor(this->ncaBar); this->Add(this->dumpText); this->Add(this->ncaBar); } @@ -42,22 +42,22 @@ namespace ui void TitleDumperLayout::StartDump(hos::Title &Target, bool HasTicket) { EnsureDirectories(); - mainapp->CallForRender(); + global_app->CallForRender(); NcmStorageId stid = static_cast(Target.Location); String fappid = hos::FormatApplicationId(Target.ApplicationId); String outdir = "sdmc:/" + consts::Root + "/dump/title/" + fappid; fs::CreateDirectory(outdir); this->dumpText->SetText(set::GetDictionaryEntry(192)); - mainapp->CallForRender(); + global_app->CallForRender(); if(HasTicket) dump::GenerateTicketCert(Target.ApplicationId); this->dumpText->SetText(set::GetDictionaryEntry(193)); - mainapp->CallForRender(); + global_app->CallForRender(); NcmContentStorage cst; Result rc = ncmOpenContentStorage(&cst, stid); if(rc != 0) { HandleResult(err::Make(err::ErrorDescription::CouldNotLocateTitleContents), set::GetDictionaryEntry(198)); - mainapp->LoadLayout(mainapp->GetContentManagerLayout()); + global_app->LoadLayout(global_app->GetContentManagerLayout()); return; } NcmContentMetaDatabase cmdb; @@ -65,7 +65,7 @@ namespace ui if(rc != 0) { HandleResult(err::Make(err::ErrorDescription::CouldNotLocateTitleContents), set::GetDictionaryEntry(198)); - mainapp->LoadLayout(mainapp->GetContentManagerLayout()); + global_app->LoadLayout(global_app->GetContentManagerLayout()); serviceClose(&cst.s); return; } @@ -75,7 +75,7 @@ namespace ui if(!ok) { HandleResult(err::Make(err::ErrorDescription::CouldNotLocateTitleContents), set::GetDictionaryEntry(198)); - mainapp->LoadLayout(mainapp->GetContentManagerLayout()); + global_app->LoadLayout(global_app->GetContentManagerLayout()); serviceClose(&cst.s); serviceClose(&cmdb.s); return; @@ -126,7 +126,7 @@ namespace ui { this->ncaBar->SetMaxValue(Total); this->ncaBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); if(hasprogram) @@ -138,7 +138,7 @@ namespace ui { this->ncaBar->SetMaxValue(Total); this->ncaBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); } @@ -151,7 +151,7 @@ namespace ui { this->ncaBar->SetMaxValue(Total); this->ncaBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); } @@ -164,7 +164,7 @@ namespace ui { this->ncaBar->SetMaxValue(Total); this->ncaBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); } @@ -177,7 +177,7 @@ namespace ui { this->ncaBar->SetMaxValue(Total); this->ncaBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); } @@ -190,7 +190,7 @@ namespace ui { this->ncaBar->SetMaxValue(Total); this->ncaBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); } @@ -203,7 +203,7 @@ namespace ui else { HandleResult(err::Make(err::ErrorDescription::CouldNotLocateTitleContents), set::GetDictionaryEntry(198)); - mainapp->LoadLayout(mainapp->GetContentManagerLayout()); + global_app->LoadLayout(global_app->GetContentManagerLayout()); serviceClose(&cst.s); serviceClose(&cmdb.s); hos::UnlockAutoSleep(); @@ -218,7 +218,7 @@ namespace ui { this->ncaBar->SetMaxValue(total); this->ncaBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); xmeta = txmeta; @@ -232,7 +232,7 @@ namespace ui { this->ncaBar->SetMaxValue(total); this->ncaBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); xprogram = txprogram; @@ -247,7 +247,7 @@ namespace ui { this->ncaBar->SetMaxValue(total); this->ncaBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); xcontrol = txcontrol; @@ -262,7 +262,7 @@ namespace ui { this->ncaBar->SetMaxValue(total); this->ncaBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); xlinfo = txlinfo; @@ -277,7 +277,7 @@ namespace ui { this->ncaBar->SetMaxValue(total); this->ncaBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); xhoff = txhoff; @@ -292,7 +292,7 @@ namespace ui { this->ncaBar->SetMaxValue(total); this->ncaBar->SetProgress(done); - mainapp->CallForRender(); + global_app->CallForRender(); }); this->ncaBar->SetVisible(false); xdata = txdata; @@ -306,12 +306,12 @@ namespace ui { this->ncaBar->SetMaxValue((double)total); this->ncaBar->SetProgress((double)done); - mainapp->CallForRender(); + global_app->CallForRender(); }); hos::UnlockAutoSleep(); fs::DeleteDirectory("sdmc:/" + consts::Root + "/dump/temp"); fs::DeleteDirectory(outdir); - if(ok) mainapp->ShowNotification(set::GetDictionaryEntry(197) + " '" + fout + "'"); + if(ok) global_app->ShowNotification(set::GetDictionaryEntry(197) + " '" + fout + "'"); else { HandleResult(err::Make(err::ErrorDescription::CouldNotBuildNSP), set::GetDictionaryEntry(198)); diff --git a/Goldleaf/Source/ui/ui_UnusedTicketsLayout.cpp b/Goldleaf/Source/ui/ui_UnusedTicketsLayout.cpp index 977de573..6c7d117d 100644 --- a/Goldleaf/Source/ui/ui_UnusedTicketsLayout.cpp +++ b/Goldleaf/Source/ui/ui_UnusedTicketsLayout.cpp @@ -22,20 +22,20 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { UnusedTicketsLayout::UnusedTicketsLayout() : pu::ui::Layout() { - this->ticketsMenu = pu::ui::elm::Menu::New(0, 160, 1280, gsets.CustomScheme.Base, gsets.MenuItemSize, (560 / gsets.MenuItemSize)); - this->ticketsMenu->SetOnFocusColor(gsets.CustomScheme.BaseFocus); - gsets.ApplyScrollBarColor(this->ticketsMenu); + this->ticketsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->ticketsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->ticketsMenu); this->notTicketsText = pu::ui::elm::TextBlock::New(0, 0, set::GetDictionaryEntry(199)); this->notTicketsText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); this->notTicketsText->SetVerticalAlign(pu::ui::elm::VerticalAlign::Center); - this->notTicketsText->SetColor(gsets.CustomScheme.Text); + this->notTicketsText->SetColor(global_settings.custom_scheme.Text); this->Add(this->notTicketsText); this->Add(this->ticketsMenu); } @@ -44,15 +44,13 @@ namespace ui { if(!this->tickets.empty()) this->tickets.clear(); auto alltiks = hos::GetAllTickets(); - for(u32 i = 0; i < alltiks.size(); i++) + for(auto &ticket: alltiks) { - hos::Ticket ticket = alltiks[i]; u64 tappid = ticket.GetApplicationId(); - bool used = hos::ExistsTitle(ncm::ContentMetaType::Any, Storage::SdCard, tappid); - if(!used) used = hos::ExistsTitle(ncm::ContentMetaType::Any, Storage::NANDUser, tappid); - if(!used) this->tickets.push_back(alltiks[i]); + bool used = hos::ExistsTitle(ncm::ContentMetaType::Any, Storage::SdCard, tappid) || hos::ExistsTitle(ncm::ContentMetaType::Any, Storage::NANDUser, tappid); + if(!used) this->tickets.push_back(ticket); } - mainapp->LoadMenuHead(set::GetDictionaryEntry(248)); + global_app->LoadMenuHead(set::GetDictionaryEntry(248)); this->ticketsMenu->ClearItems(); if(Cooldown) this->ticketsMenu->SetCooldownEnabled(true); if(this->tickets.empty()) @@ -63,39 +61,36 @@ namespace ui else { this->notTicketsText->SetVisible(false); - std::vector usedidxs; - for(u32 i = 0; i < this->tickets.size(); i++) + for(auto &ticket: this->tickets) { - hos::Ticket ticket = this->tickets[i]; u64 tappid = ticket.GetApplicationId(); String tname = hos::FormatApplicationId(tappid); auto itm = pu::ui::elm::MenuItem::New(tname); - itm->SetColor(gsets.CustomScheme.Text); - itm->SetIcon(gsets.PathForResource("/Common/Ticket.png")); - itm->AddOnClick(std::bind(&UnusedTicketsLayout::tickets_Click, this)); + itm->SetColor(global_settings.custom_scheme.Text); + itm->SetIcon(global_settings.PathForResource("/Common/Ticket.png")); + itm->AddOnClick(std::bind(&UnusedTicketsLayout::tickets_Click, this, ticket)); this->ticketsMenu->AddItem(itm); } this->ticketsMenu->SetSelectedIndex(0); } } - void UnusedTicketsLayout::tickets_Click() + void UnusedTicketsLayout::tickets_Click(hos::Ticket ticket) { - hos::Ticket seltick = this->tickets[this->ticketsMenu->GetSelectedIndex()]; String info = set::GetDictionaryEntry(201) + "\n\n\n"; - u64 tappid = seltick.GetApplicationId(); + u64 tappid = ticket.GetApplicationId(); info += set::GetDictionaryEntry(90) + " " + hos::FormatApplicationId(tappid); - info += "\n" + set::GetDictionaryEntry(95) + " " + std::to_string(seltick.GetKeyGeneration() + 1); + info += "\n" + set::GetDictionaryEntry(95) + " " + std::to_string(ticket.GetKeyGeneration() + 1); info += "\n\n"; info += set::GetDictionaryEntry(203); - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(200), info, { set::GetDictionaryEntry(245), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(200), info, { set::GetDictionaryEntry(245), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; - sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(200), set::GetDictionaryEntry(204), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(200), set::GetDictionaryEntry(204), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; - Result rc = hos::RemoveTicket(seltick); - if(rc == 0) + auto rc = hos::RemoveTicket(ticket); + if(R_SUCCEEDED(rc)) { - mainapp->ShowNotification(set::GetDictionaryEntry(206)); + global_app->ShowNotification(set::GetDictionaryEntry(206)); this->UpdateElements(false); } else HandleResult(rc, set::GetDictionaryEntry(207)); diff --git a/Goldleaf/Source/ui/ui_UpdateLayout.cpp b/Goldleaf/Source/ui/ui_UpdateLayout.cpp index b423c7d1..c153c917 100644 --- a/Goldleaf/Source/ui/ui_UpdateLayout.cpp +++ b/Goldleaf/Source/ui/ui_UpdateLayout.cpp @@ -22,8 +22,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; extern bool gupdated; namespace ui @@ -32,9 +32,9 @@ namespace ui { this->infoText = pu::ui::elm::TextBlock::New(150, 320, "(...)"); this->infoText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center); - this->infoText->SetColor(gsets.CustomScheme.Text); + this->infoText->SetColor(global_settings.custom_scheme.Text); this->downloadBar = pu::ui::elm::ProgressBar::New(340, 360, 600, 30, 100.0f); - gsets.ApplyProgressBarColor(this->downloadBar); + global_settings.ApplyProgressBarColor(this->downloadBar); this->Add(this->infoText); this->Add(this->downloadBar); } @@ -44,40 +44,40 @@ namespace ui if(gupdated) return; this->downloadBar->SetVisible(false); this->infoText->SetText(set::GetDictionaryEntry(305)); - mainapp->CallForRender(); + global_app->CallForRender(); std::string js = net::RetrieveContent("https://api.github.com/repos/xortroll/goldleaf/releases", "application/json"); JSON j = JSON::parse(js); std::string latestid = j[0]["tag_name"].get(); this->infoText->SetText(set::GetDictionaryEntry(306)); - mainapp->CallForRender(); + global_app->CallForRender(); Version latestv = Version::FromString(latestid); Version currentv = Version::MakeVersion(GOLDLEAF_MAJOR, GOLDLEAF_MINOR, GOLDLEAF_MICRO); // Defined in Makefile - if(latestv.IsEqual(currentv)) mainapp->CreateShowDialog(set::GetDictionaryEntry(284), set::GetDictionaryEntry(307), { set::GetDictionaryEntry(234) }, true); + if(latestv.IsEqual(currentv)) global_app->CreateShowDialog(set::GetDictionaryEntry(284), set::GetDictionaryEntry(307), { set::GetDictionaryEntry(234) }, true); else if(latestv.IsLower(currentv)) { - int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(284), set::GetDictionaryEntry(308), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(set::GetDictionaryEntry(284), set::GetDictionaryEntry(308), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true); if(sopt == 0) { std::string newnro = "https://github.com/XorTroll/Goldleaf/releases/download/" + latestid + "/Goldleaf.nro"; fs::CreateDirectory("sdmc:/switch/Goldleaf"); fs::DeleteFile(consts::TempUpdatePath); this->infoText->SetText(set::GetDictionaryEntry(309)); - mainapp->CallForRender(); + global_app->CallForRender(); this->downloadBar->SetVisible(true); net::RetrieveToFile(newnro, consts::TempUpdatePath, [&](double Done, double Total) { this->downloadBar->SetMaxValue(Total); this->downloadBar->SetProgress(Done); - mainapp->CallForRender(); + global_app->CallForRender(); }); if(fs::IsFile(consts::TempUpdatePath)) gupdated = true; this->downloadBar->SetVisible(false); - mainapp->CallForRender(); - mainapp->ShowNotification(set::GetDictionaryEntry(314) + " " + set::GetDictionaryEntry(315)); + global_app->CallForRender(); + global_app->ShowNotification(set::GetDictionaryEntry(314) + " " + set::GetDictionaryEntry(315)); } } - else if(latestv.IsHigher(currentv)) mainapp->CreateShowDialog(set::GetDictionaryEntry(284), set::GetDictionaryEntry(316), { set::GetDictionaryEntry(234) }, true); - mainapp->UnloadMenuData(); - mainapp->LoadLayout(mainapp->GetMainMenuLayout()); + else if(latestv.IsHigher(currentv)) global_app->CreateShowDialog(set::GetDictionaryEntry(284), set::GetDictionaryEntry(316), { set::GetDictionaryEntry(234) }, true); + global_app->UnloadMenuData(); + global_app->LoadLayout(global_app->GetMainMenuLayout()); } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_Utils.cpp b/Goldleaf/Source/ui/ui_Utils.cpp index 64c4a11a..391589b8 100644 --- a/Goldleaf/Source/ui/ui_Utils.cpp +++ b/Goldleaf/Source/ui/ui_Utils.cpp @@ -22,8 +22,8 @@ #include #include -extern ui::MainApplication::Ref mainapp; -extern set::Settings gsets; +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; namespace ui { @@ -51,7 +51,7 @@ namespace ui void ShowPowerTasksDialog(String Title, String Message) { - int sopt = mainapp->CreateShowDialog(Title, Message, { set::GetDictionaryEntry(233), set::GetDictionaryEntry(232), set::GetDictionaryEntry(18) }, true); + int sopt = global_app->CreateShowDialog(Title, Message, { set::GetDictionaryEntry(233), set::GetDictionaryEntry(232), set::GetDictionaryEntry(18) }, true); if(sopt < 0) return; spsmInitialize(); spsmShutdown(sopt == 1); @@ -86,7 +86,7 @@ namespace ui sprintf(displayerr, "%04d-%04d", 2000 + R_MODULE(err.OSError), R_DESCRIPTION(err.OSError)); String emod = err.Module + " (" + std::to_string(R_MODULE(err.OSError)) + ")"; String edesc = err.Description + " (" + std::to_string(R_DESCRIPTION(err.OSError)) + ")"; - mainapp->CreateShowDialog(set::GetDictionaryEntry(266), Context + "\n\n" + set::GetDictionaryEntry(266) + ": " + std::string(displayerr) + " (" + hos::FormatHex(err.OSError) + ")\n" + set::GetDictionaryEntry(264) + ": " + emod + "\n" + set::GetDictionaryEntry(265) + ": " + edesc + "", { set::GetDictionaryEntry(234) }, false); + global_app->CreateShowDialog(set::GetDictionaryEntry(266), Context + "\n\n" + set::GetDictionaryEntry(266) + ": " + std::string(displayerr) + " (" + hos::FormatHex(err.OSError) + ")\n" + set::GetDictionaryEntry(264) + ": " + emod + "\n" + set::GetDictionaryEntry(265) + ": " + edesc + "", { set::GetDictionaryEntry(234) }, false); } } } \ No newline at end of file diff --git a/Goldleaf/Source/ui/ui_WebBrowserLayout.cpp b/Goldleaf/Source/ui/ui_WebBrowserLayout.cpp new file mode 100644 index 00000000..20d7f982 --- /dev/null +++ b/Goldleaf/Source/ui/ui_WebBrowserLayout.cpp @@ -0,0 +1,84 @@ + +/* + + Goldleaf - Multipurpose homebrew tool for Nintendo Switch + Copyright (C) 2018-2019 XorTroll + + This program 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. + + This program 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 . + +*/ + +#include +#include + +extern ui::MainApplication::Ref global_app; +extern set::Settings global_settings; + +namespace ui +{ + WebBrowserLayout::WebBrowserLayout() : pu::ui::Layout() + { + this->optionsMenu = pu::ui::elm::Menu::New(0, 160, 1280, global_settings.custom_scheme.Base, global_settings.menu_item_size, (560 / global_settings.menu_item_size)); + this->optionsMenu->SetOnFocusColor(global_settings.custom_scheme.BaseFocus); + global_settings.ApplyScrollBarColor(this->optionsMenu); + this->Add(this->optionsMenu); + } + + void WebBrowserLayout::Refresh() + { + this->optionsMenu->ClearItems(); + auto inputitm = pu::ui::elm::MenuItem::New("Enter web-page..."); + inputitm->SetColor(global_settings.custom_scheme.Text); + inputitm->AddOnClick(std::bind(&WebBrowserLayout::input_Click, this)); + this->optionsMenu->AddItem(inputitm); + for(auto &bmk: global_settings.bookmarks) + { + auto bmkitm = pu::ui::elm::MenuItem::New(bmk.name); + bmkitm->SetColor(global_settings.custom_scheme.Text); + bmkitm->SetIcon(global_settings.PathForResource("/Common/Browser.png")); + bmkitm->AddOnClick(std::bind(&WebBrowserLayout::bookmark_Click, this, bmk)); + this->optionsMenu->AddItem(bmkitm); + } + } + + static void LaunchWeb(std::string page) + { + WebCommonConfig web; + webPageCreate(&web, page.c_str()); + webConfigShow(&web, NULL); + } + + void WebBrowserLayout::input_Click() + { + String out = AskForText(set::GetDictionaryEntry(38), "https://"); + LaunchWeb(out.AsUTF8()); + + auto sopt = global_app->CreateShowDialog("Bookmark save", "Would you like to save this page as a bookmark?", { "Yes", "No" }, true); + if(sopt == 0) + { + auto name = AskForText("Bookmark name"); + set::WebBookmark bmk = {}; + bmk.name = name.AsUTF8(); + bmk.url = out.AsUTF8(); + global_settings.bookmarks.push_back(bmk); + global_settings.Save(); + global_app->ShowNotification("Settings were updated and saved."); + } + } + + void WebBrowserLayout::bookmark_Click(set::WebBookmark bmk) + { + LaunchWeb(bmk.url); + } +} \ No newline at end of file