More cleanup, fix more broken things

This commit is contained in:
XorTroll 2020-06-13 23:09:40 +02:00
parent ae77e3225e
commit 042a5f96cf
14 changed files with 450 additions and 438 deletions

View file

@ -356,7 +356,7 @@ namespace {
}
void PrepareUsbViewer() {
g_UsbViewerBuffer = new (std::align_val_t(0x1000), std::nothrow) u8[UsbPacketSize]();
g_UsbViewerBuffer = new (std::align_val_t(0x1000)) u8[UsbPacketSize]();
g_UsbViewerReadBuffer = g_UsbViewerBuffer + sizeof(u32);
u64 tmp_size;
if(R_SUCCEEDED(capsscCaptureJpegScreenShot(&tmp_size, g_UsbViewerReadBuffer, RawRGBAScreenBufferSize, ViLayerStack_Default, UINT64_MAX))) {
@ -522,7 +522,7 @@ namespace {
if(g_UsbViewerMode == UsbMode::JPEG) {
capsscExit();
}
operator delete[](g_UsbViewerBuffer, std::align_val_t(0x1000), std::nothrow);
operator delete[](g_UsbViewerBuffer, std::align_val_t(0x1000));
}
nsExit();

View file

@ -49,7 +49,7 @@ namespace dmi {
};
static constexpr u32 Magic = 0x434D4151;
static constexpr size_t BlockSize = 0x4000;
static constexpr size_t BlockSize = 0x800;
namespace impl {
@ -73,7 +73,7 @@ namespace dmi {
bool write_done;
public:
CommandWriter(V value) : request({ Magic, static_cast<u32>(value) }), data_block(new (std::nothrow) u8[BlockSize]()), data_pos(0), inner_rc(ResultSuccess), write_done(false) {
CommandWriter(V value) : request({ Magic, static_cast<u32>(value) }), data_block(new u8[BlockSize]()), data_pos(0), inner_rc(ResultSuccess), write_done(false) {
this->inner_rc = WriteFn(&this->request, sizeof(this->request), Wait);
}
@ -120,7 +120,7 @@ namespace dmi {
bool read_done;
public:
CommandReader() : response(), data_block(new (std::nothrow) u8[BlockSize]()), data_pos(0), inner_rc(ResultSuccess), read_done(false) {
CommandReader() : response(), data_block(new u8[BlockSize]()), data_pos(0), inner_rc(ResultSuccess), read_done(false) {
this->inner_rc = ReadFn(&this->response, sizeof(this->response), Wait);
if(R_SUCCEEDED(this->inner_rc)) {
this->inner_rc = ReadFn(this->data_block, BlockSize, Wait);

View file

@ -47,8 +47,7 @@ namespace dmi {
_UL_DMI_IMPL_RC(
AppletStorage st;
rc = appletCreateStorage(&st, size);
if(R_SUCCEEDED(rc))
{
if(R_SUCCEEDED(rc)) {
rc = appletStorageWrite(&st, 0, data, size);
if(R_SUCCEEDED(rc)) {
rc = appletPushOutData(&st);
@ -64,8 +63,8 @@ namespace dmi {
rc = appletPopInData(&st);
if(R_SUCCEEDED(rc)) {
rc = appletStorageRead(&st, 0, data, size);
appletStorageClose(&st);
}
appletStorageClose(&st);
);
}

View file

@ -20,20 +20,18 @@ extern "C" {
u32 __nx_applet_type = AppletType_LibraryApplet; // Explicitly declare we're a library applet (need to do so for non-hbloader homebrew)
TimeServiceType __nx_time_service_type = TimeServiceType_System;
size_t __nx_heap_size = 0x10000000; // 0xD000000; // 208MB heap
size_t __nx_heap_size = 0xD000000; // 208MB heap
}
#define MENU_ROMFS_BIN UL_BASE_SD_DIR "/bin/uMenu/romfs.bin"
#define UL_MENU_ROMFS_BIN UL_BASE_SD_DIR "/bin/uMenu/romfs.bin"
// Some global vars
ui::MenuApplication::Ref g_menu_app_instance;
cfg::TitleList g_entry_list;
std::vector<cfg::TitleRecord> g_homebrew_records;
cfg::Config g_ul_config;
cfg::Theme g_ul_theme;
u8 *g_app_capture_buffer;
ui::MenuApplication::Ref g_MenuApplication;
cfg::TitleList g_EntryList;
std::vector<cfg::TitleRecord> g_HomebrewRecordList;
cfg::Config g_Config;
cfg::Theme g_Theme;
u8 *g_ScreenCaptureBuffer;
namespace impl {
@ -54,8 +52,8 @@ namespace impl {
UL_ASSERT(am::InitializeDaemonMessageHandler());
// Load menu config and theme
g_ul_config = cfg::EnsureConfig();
g_ul_theme = cfg::LoadTheme(g_ul_config.theme_name);
g_Config = cfg::EnsureConfig();
g_Theme = cfg::LoadTheme(g_Config.theme_name);
}
void Exit() {
@ -82,54 +80,54 @@ int main() {
if(smode != dmi::MenuStartMode::Invalid) {
// Check if our RomFs data exists...
if(!fs::ExistsFile(MENU_ROMFS_BIN)) {
if(!fs::ExistsFile(UL_MENU_ROMFS_BIN)) {
UL_ASSERT(RES_VALUE(Menu, RomfsBinNotFound));
}
// Try to mount it
UL_ASSERT(romfsMountFromFsdev(MENU_ROMFS_BIN, 0, "romfs"));
UL_ASSERT(romfsMountFromFsdev(UL_MENU_ROMFS_BIN, 0, "romfs"));
// After initializing RomFs, start initializing the rest of stuff here
g_app_capture_buffer = new (std::nothrow) u8[RawRGBAScreenBufferSize]();
g_ScreenCaptureBuffer = new u8[RawRGBAScreenBufferSize]();
impl::Initialize();
g_entry_list = cfg::LoadTitleList();
g_EntryList = cfg::LoadTitleList();
// Get system language and load translations (default one if not present)
u64 lcode = 0;
setGetLanguageCode(&lcode);
std::string syslang = reinterpret_cast<char*>(&lcode);
auto lpath = cfg::GetLanguageJSONPath(syslang);
UL_ASSERT(util::LoadJSONFromFile(g_ul_config.default_lang, CFG_LANG_DEFAULT));
g_ul_config.main_lang = g_ul_config.default_lang;
UL_ASSERT(util::LoadJSONFromFile(g_Config.default_lang, CFG_LANG_DEFAULT));
g_Config.main_lang = g_Config.default_lang;
if(fs::ExistsFile(lpath)) {
auto ljson = JSON::object();
UL_ASSERT(util::LoadJSONFromFile(ljson, lpath));
g_ul_config.main_lang = ljson;
g_Config.main_lang = ljson;
}
// Get the text sizes to initialize default fonts
auto uijson = JSON::object();
UL_ASSERT(util::LoadJSONFromFile(uijson, cfg::GetAssetByTheme(g_ul_theme, "ui/UI.json")));
UL_ASSERT(util::LoadJSONFromFile(uijson, cfg::GetAssetByTheme(g_Theme, "ui/UI.json")));
auto menu_folder_txt_sz = uijson.value<u32>("menu_folder_text_size", 25);
auto renderer = pu::ui::render::Renderer::New(pu::ui::render::RendererInitOptions(SDL_INIT_EVERYTHING, pu::ui::render::RendererHardwareFlags).WithIMG(pu::ui::render::IMGAllFlags).WithMixer(pu::ui::render::MixerAllFlags).WithTTF().WithDefaultFontSize(menu_folder_txt_sz));
g_menu_app_instance = ui::MenuApplication::New(renderer);
g_MenuApplication = ui::MenuApplication::New(renderer);
g_menu_app_instance->SetInformation(smode, status, uijson);
g_menu_app_instance->Prepare();
g_MenuApplication->SetInformation(smode, status, uijson);
g_MenuApplication->Prepare();
if(smode == dmi::MenuStartMode::MenuApplicationSuspended) {
g_menu_app_instance->Show();
g_MenuApplication->Show();
}
else {
g_menu_app_instance->ShowWithFadeIn();
g_MenuApplication->ShowWithFadeIn();
}
// Exit RomFs manually, since we also initialized it manually
romfsExit();
operator delete[](g_app_capture_buffer, std::nothrow);
delete[] g_ScreenCaptureBuffer;
impl::Exit();
}
}

View file

@ -1,68 +1,79 @@
#include <am/am_DaemonMessages.hpp>
#include <map>
namespace am {
static Mutex g_receiver_lock = EmptyMutex;
static Service g_daemon_srv;
static bool g_init = false;
static bool g_thr_should_stop = false;
static Thread g_receiver_thr;
static std::vector<std::pair<MessageDetectCallback, dmi::MenuMessage>> g_callback_table;
namespace {
static void DaemonMessageReceiveThread(void *arg) {
while(true) {
mutexLock(&g_receiver_lock);
auto should_stop = g_thr_should_stop;
mutexUnlock(&g_receiver_lock);
if(should_stop) {
break;
}
auto tmp_msg = dmi::MenuMessage::Invalid;
u64 pid_placeholder = 0;
UL_ASSERT(serviceDispatchInOut(&g_daemon_srv, 0, pid_placeholder, tmp_msg,
.in_send_pid = true,
));
mutexLock(&g_receiver_lock);
for(auto &[cb, msg] : g_callback_table) {
if(msg == tmp_msg) {
cb();
Mutex g_ReceiverLock = EmptyMutex;
Service g_DaemonPrivateService;
bool g_Initialized = false;
bool g_ReceiveThreadShouldStop = false;
Thread g_ReceiverThread;
std::vector<std::pair<MessageDetectCallback, dmi::MenuMessage>> g_ReceiverCallbackTable;
void DaemonMessageReceiverThread(void*) {
while(true) {
mutexLock(&g_ReceiverLock);
auto should_stop = g_ReceiveThreadShouldStop;
mutexUnlock(&g_ReceiverLock);
if(should_stop) {
break;
}
auto tmp_msg = dmi::MenuMessage::Invalid;
u64 pid_placeholder = 0;
UL_ASSERT(serviceDispatchInOut(&g_DaemonPrivateService, 0, pid_placeholder, tmp_msg,
.in_send_pid = true,
));
mutexLock(&g_ReceiverLock);
for(auto &[cb, msg] : g_ReceiverCallbackTable) {
if(msg == tmp_msg) {
cb();
}
}
mutexUnlock(&g_ReceiverLock);
svcSleepThread(10'000'000ul);
}
mutexUnlock(&g_receiver_lock);
svcSleepThread(10'000'000ul);
}
}
Result InitializeDaemonMessageHandler() {
if(g_init) {
if(g_Initialized) {
return ResultSuccess;
}
R_TRY(smGetService(&g_daemon_srv, AM_DAEMON_PRIVATE_SERVICE_NAME));
g_thr_should_stop = false;
R_TRY(threadCreate(&g_receiver_thr, &DaemonMessageReceiveThread, nullptr, nullptr, 0x1000, 0x2b, -2));
R_TRY(threadStart(&g_receiver_thr));
g_init = true;
R_TRY(smGetService(&g_DaemonPrivateService, AM_DAEMON_PRIVATE_SERVICE_NAME));
g_ReceiveThreadShouldStop = false;
R_TRY(threadCreate(&g_ReceiverThread, &DaemonMessageReceiverThread, nullptr, nullptr, 0x1000, 0x2b, -2));
R_TRY(threadStart(&g_ReceiverThread));
g_Initialized = true;
return ResultSuccess;
}
void ExitDaemonMessageHandler() {
if(!g_init) {
if(!g_Initialized) {
return;
}
mutexLock(&g_receiver_lock);
g_thr_should_stop = true;
mutexUnlock(&g_receiver_lock);
threadWaitForExit(&g_receiver_thr);
threadClose(&g_receiver_thr);
serviceClose(&g_daemon_srv);
g_init = false;
mutexLock(&g_ReceiverLock);
g_ReceiveThreadShouldStop = true;
mutexUnlock(&g_ReceiverLock);
threadWaitForExit(&g_ReceiverThread);
threadClose(&g_ReceiverThread);
serviceClose(&g_DaemonPrivateService);
g_Initialized = false;
}
void RegisterOnMessageDetect(MessageDetectCallback callback, dmi::MenuMessage desired_msg) {
mutexLock(&g_receiver_lock);
g_callback_table.push_back(std::make_pair(callback, desired_msg));
mutexUnlock(&g_receiver_lock);
mutexLock(&g_ReceiverLock);
g_ReceiverCallbackTable.push_back(std::make_pair(callback, desired_msg));
mutexUnlock(&g_ReceiverLock);
}
}

View file

@ -2,18 +2,22 @@
#include <am/am_LibAppletWrap.hpp>
#include <am/am_DaemonMessages.hpp>
static Mutex g_amwrap_detection_lock = EmptyMutex;
static bool g_is_applet_running = false;
static bool g_detection_home_pressed = false;
namespace {
Mutex g_LibAppletWrapLock = EmptyMutex;
bool g_IsAppletRunning = false;
bool g_DetectionHomePressed = false;
}
namespace am {
void OnHomeButtonDetection() {
mutexLock(&g_amwrap_detection_lock);
if(g_is_applet_running) {
g_detection_home_pressed = true;
mutexLock(&g_LibAppletWrapLock);
if(g_IsAppletRunning) {
g_DetectionHomePressed = true;
}
mutexUnlock(&g_amwrap_detection_lock);
mutexUnlock(&g_LibAppletWrapLock);
}
void RegisterLibAppletHomeButtonDetection() {
@ -25,12 +29,13 @@ namespace am {
extern "C" {
// Wrap libappletStart and libappletLaunch to use our custom waiting system
Result __wrap_libappletStart(AppletHolder *h) {
R_TRY(appletHolderStart(h));
mutexLock(&g_amwrap_detection_lock);
g_is_applet_running = true;
mutexUnlock(&g_amwrap_detection_lock);
mutexLock(&g_LibAppletWrapLock);
g_IsAppletRunning = true;
mutexUnlock(&g_LibAppletWrapLock);
while(true) {
if(appletHolderCheckFinished(h)) {
@ -40,10 +45,10 @@ extern "C" {
break;
}
mutexLock(&g_amwrap_detection_lock);
auto home_pressed = g_detection_home_pressed;
g_detection_home_pressed = false;
mutexUnlock(&g_amwrap_detection_lock);
mutexLock(&g_LibAppletWrapLock);
auto home_pressed = g_DetectionHomePressed;
g_DetectionHomePressed = false;
mutexUnlock(&g_LibAppletWrapLock);
if(home_pressed) {
appletHolderRequestExitOrTerminate(h, 15'000'000'000ul);
@ -61,9 +66,9 @@ extern "C" {
rc = MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit);
}
mutexLock(&g_amwrap_detection_lock);
g_is_applet_running = false;
mutexUnlock(&g_amwrap_detection_lock);
mutexLock(&g_LibAppletWrapLock);
g_IsAppletRunning = false;
mutexUnlock(&g_LibAppletWrapLock);
return rc;
}

View file

@ -12,39 +12,39 @@
#include <fs/fs_Stdio.hpp>
#include <net/net_Service.hpp>
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::Config g_ul_config;
extern ui::MenuApplication::Ref g_MenuApplication;
extern cfg::Config g_Config;
namespace ui::actions {
void ShowAboutDialog() {
g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "ulaunch_about"), "uLaunch v" + std::string(UL_VERSION) + "\n\n" + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "ulaunch_desc") + ":\nhttps://github.com/XorTroll/uLaunch", { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "ok") }, true, "romfs:/LogoLarge.png");
g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "ulaunch_about"), "uLaunch v" + std::string(UL_VERSION) + "\n\n" + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "ulaunch_desc") + ":\nhttps://github.com/XorTroll/uLaunch", { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "ok") }, true, "romfs:/LogoLarge.png");
}
void ShowSettingsMenu() {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadSettingsMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadSettingsMenu();
g_MenuApplication->FadeIn();
}
void ShowThemesMenu() {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadThemeMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadThemeMenu();
g_MenuApplication->FadeIn();
}
void ShowUserMenu() {
auto uid = g_menu_app_instance->GetSelectedUser();
auto uid = g_MenuApplication->GetSelectedUser();
std::string name;
os::GetAccountName(name, uid);
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "user_settings"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "user_selected") + ": " + name + "\n" + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "user_option"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "user_view_page"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "user_logoff"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true, os::GetIconCacheImagePath(uid));
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "user_settings"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "user_selected") + ": " + name + "\n" + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "user_option"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "user_view_page"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "user_logoff"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true, os::GetIconCacheImagePath(uid));
if(sopt == 0) {
friendsLaShowMyProfileForHomeMenu(uid);
}
else if(sopt == 1) {
u32 logoff = 0;
if(g_menu_app_instance->IsSuspended()) {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "suspended_app"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "user_logoff_app_suspended"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
if(g_MenuApplication->IsSuspended()) {
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "suspended_app"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "user_logoff_app_suspended"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
logoff = 2;
}
@ -53,14 +53,14 @@ namespace ui::actions {
logoff = 1;
}
if(logoff > 0) {
auto &menu_lyt = g_menu_app_instance->GetMenuLayout();
auto &menu_lyt = g_MenuApplication->GetMenuLayout();
if(logoff == 2) {
menu_lyt->DoTerminateApplication();
}
g_menu_app_instance->FadeOut();
g_MenuApplication->FadeOut();
menu_lyt->MoveFolder("", false);
g_menu_app_instance->LoadStartupMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->LoadStartupMenu();
g_MenuApplication->FadeIn();
}
}
}
@ -81,7 +81,7 @@ namespace ui::actions {
UL_ON_SCOPE_EXIT({
swkbdClose(&swkbd);
});
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "swkbd_webpage_guide").c_str());
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "swkbd_webpage_guide").c_str());
char url[500] = {0};
swkbdShow(&swkbd, url, 500);
@ -94,35 +94,35 @@ namespace ui::actions {
writer.Write<WebCommonConfig>(web);
writer.FinishWrite();
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
}
void ShowHelpDialog() {
std::string msg;
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_launch") + "\n";
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_close") + "\n";
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_quick") + "\n";
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_multiselect") + "\n";
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_back") + "\n";
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_minus") + "\n";
msg += " - " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_plus") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_launch") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_close") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_quick") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_multiselect") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_back") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_minus") + "\n";
msg += " - " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_plus") + "\n";
g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "help_title"), msg, { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "ok") }, true);
g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "help_title"), msg, { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "ok") }, true);
}
void ShowAlbumApplet() {
dmi::MenuMessageWriter writer(dmi::DaemonMessage::OpenAlbum);
writer.FinishWrite();
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
}
void ShowPowerDialog() {
auto msg = os::GeneralChannelMessage::Invalid;
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "power_dialog"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "power_dialog_info"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "power_sleep"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "power_power_off"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "power_reboot"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "power_dialog"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "power_dialog_info"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "power_sleep"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "power_power_off"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "power_reboot"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
msg = os::GeneralChannelMessage::Sleep;
}
@ -135,14 +135,14 @@ namespace ui::actions {
if(msg != os::GeneralChannelMessage::Invalid) {
// Fade out on all cases
g_menu_app_instance->FadeOut();
g_MenuApplication->FadeOut();
auto smsg = os::SystemAppletMessage::Create(msg);
os::PushSystemAppletMessage(smsg);
svcSleepThread(1'500'000'000L);
// When we get back after sleep we will do a cool fade in, whereas wuth the other options the console will be already off/rebooted
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeIn();
}
}

View file

@ -8,50 +8,50 @@
#include <net/net_Service.hpp>
#include <am/am_LibraryApplet.hpp>
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::Theme g_ul_theme;
extern cfg::Config g_ul_config;
extern ui::MenuApplication::Ref g_MenuApplication;
extern cfg::Theme g_Theme;
extern cfg::Config g_Config;
namespace ui {
LanguagesMenuLayout::LanguagesMenuLayout() {
this->SetBackgroundImage(cfg::GetAssetByTheme(g_ul_theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(g_Theme, "ui/Background.png"));
pu::ui::Color textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
pu::ui::Color menubgclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
pu::ui::Color textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
pu::ui::Color menubgclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
this->infoText = pu::ui::elm::TextBlock::New(0, 100, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_info_text"));
this->infoText = pu::ui::elm::TextBlock::New(0, 100, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_info_text"));
this->infoText->SetColor(textclr);
this->infoText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center);
g_menu_app_instance->ApplyConfigForElement("languages_menu", "info_text", this->infoText);
g_MenuApplication->ApplyConfigForElement("languages_menu", "info_text", this->infoText);
this->Add(this->infoText);
this->langsMenu = pu::ui::elm::Menu::New(200, 160, 880, menubgclr, 100, 4);
this->langsMenu->SetOnFocusColor(menufocusclr);
g_menu_app_instance->ApplyConfigForElement("languages_menu", "languages_menu_item", this->langsMenu);
g_MenuApplication->ApplyConfigForElement("languages_menu", "languages_menu_item", this->langsMenu);
this->Add(this->langsMenu);
}
void LanguagesMenuLayout::OnMenuInput(u64 down, u64 up, u64 held, pu::ui::Touch touch_pos) {
if(down & KEY_B) {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadSettingsMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadSettingsMenu();
g_MenuApplication->FadeIn();
}
}
void LanguagesMenuLayout::OnHomeButtonPress() {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadMenu();
g_MenuApplication->FadeIn();
}
void LanguagesMenuLayout::Reload() {
this->langsMenu->ClearItems();
this->langsMenu->SetSelectedIndex(0);
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
u64 lcode = 0;
auto ilang = SetLanguage_ENUS;
setGetLanguageCode(&lcode);
@ -61,7 +61,7 @@ namespace ui {
for(auto &lang: os::GetLanguageNameList()) {
auto name = lang;
if(static_cast<u32>(ilang) == idx) {
name += " " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_selected");
name += " " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_selected");
}
auto litm = pu::ui::elm::MenuItem::New(name);
litm->SetColor(textclr);
@ -78,10 +78,10 @@ namespace ui {
setMakeLanguage(lcode, &ilang);
if(static_cast<u32>(ilang) == idx) {
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_active_this"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_active_this"));
}
else {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_set"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_set_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_set"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_set_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no") }, true);
if(sopt == 0) {
u64 codes[16] = {0};
s32 tmp;
@ -89,9 +89,9 @@ namespace ui {
auto code = codes[this->langsMenu->GetSelectedIndex()];
auto rc = setsysSetLanguageCode(code);
g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_set"), R_SUCCEEDED(rc) ? cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_set_ok") : cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "lang_set_error") + ": " + util::FormatResult(rc), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "ok") }, true);
g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_set"), R_SUCCEEDED(rc) ? cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_set_ok") : cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "lang_set_error") + ": " + util::FormatResult(rc), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "ok") }, true);
if(R_SUCCEEDED(rc)) {
g_menu_app_instance->FadeOut();
g_MenuApplication->FadeOut();
auto smsg = os::SystemAppletMessage::Create(os::GeneralChannelMessage::Reboot);
os::PushSystemAppletMessage(smsg);

View file

@ -1,32 +1,32 @@
#include <ui/ui_MenuApplication.hpp>
#include <util/util_Misc.hpp>
extern u8 *g_app_capture_buffer;
extern cfg::Theme g_ul_theme;
extern ui::MenuApplication::Ref g_menu_app_instance;
extern u8 *g_ScreenCaptureBuffer;
extern cfg::Theme g_Theme;
extern ui::MenuApplication::Ref g_MenuApplication;
namespace ui {
void UiOnHomeButtonDetection() {
switch(g_menu_app_instance->GetCurrentLoadedMenu()) {
switch(g_MenuApplication->GetCurrentLoadedMenu()) {
case MenuType::Startup: {
g_menu_app_instance->GetStartupLayout()->DoOnHomeButtonPress();
g_MenuApplication->GetStartupLayout()->DoOnHomeButtonPress();
break;
}
case MenuType::Main: {
g_menu_app_instance->GetMenuLayout()->DoOnHomeButtonPress();
g_MenuApplication->GetMenuLayout()->DoOnHomeButtonPress();
break;
}
case MenuType::Settings: {
g_menu_app_instance->GetSettingsMenuLayout()->DoOnHomeButtonPress();
g_MenuApplication->GetSettingsMenuLayout()->DoOnHomeButtonPress();
break;
}
case MenuType::Theme: {
g_menu_app_instance->GetThemeMenuLayout()->DoOnHomeButtonPress();
g_MenuApplication->GetThemeMenuLayout()->DoOnHomeButtonPress();
break;
}
case MenuType::Languages: {
g_menu_app_instance->GetLanguagesMenuLayout()->DoOnHomeButtonPress();
g_MenuApplication->GetLanguagesMenuLayout()->DoOnHomeButtonPress();
break;
}
}
@ -35,11 +35,11 @@ namespace ui {
void MenuApplication::OnLoad() {
if(this->IsSuspended()) {
bool flag;
appletGetLastApplicationCaptureImageEx(g_app_capture_buffer, RawRGBAScreenBufferSize, &flag);
appletGetLastApplicationCaptureImageEx(g_ScreenCaptureBuffer, RawRGBAScreenBufferSize, &flag);
}
auto jbgm = JSON::object();
util::LoadJSONFromFile(jbgm, cfg::GetAssetByTheme(g_ul_theme, "sound/BGM.json"));
util::LoadJSONFromFile(jbgm, cfg::GetAssetByTheme(g_Theme, "sound/BGM.json"));
this->bgmjson = jbgm;
this->bgm_loop = this->bgmjson.value("loop", true);
this->bgm_fade_in_ms = this->bgmjson.value("fade_in_ms", 1500);
@ -49,10 +49,10 @@ namespace ui {
auto toastbaseclr = pu::ui::Color::FromHex(GetUIConfigValue<std::string>("toast_base_color", "#282828ff"));
this->notifToast = pu::ui::extras::Toast::New("...", "DefaultFont@20", toasttextclr, toastbaseclr);
this->bgm = pu::audio::Open(cfg::GetAssetByTheme(g_ul_theme, "sound/BGM.mp3"));
this->bgm = pu::audio::Open(cfg::GetAssetByTheme(g_Theme, "sound/BGM.mp3"));
this->startupLayout = StartupLayout::New();
this->menuLayout = MenuLayout::New(g_app_capture_buffer, this->uijson.value("suspended_final_alpha", 80));
this->menuLayout = MenuLayout::New(g_ScreenCaptureBuffer, this->uijson.value("suspended_final_alpha", 80));
this->themeMenuLayout = ThemeMenuLayout::New();
this->settingsMenuLayout = SettingsMenuLayout::New();
this->languagesMenuLayout = LanguagesMenuLayout::New();

View file

@ -10,32 +10,32 @@
#include <fs/fs_Stdio.hpp>
#include <net/net_Service.hpp>
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::TitleList g_entry_list;
extern std::vector<cfg::TitleRecord> g_homebrew_records;
extern cfg::Config g_ul_config;
extern cfg::Theme g_ul_theme;
extern ui::MenuApplication::Ref g_MenuApplication;
extern cfg::TitleList g_EntryList;
extern std::vector<cfg::TitleRecord> g_HomebrewRecordList;
extern cfg::Config g_Config;
extern cfg::Theme g_Theme;
#define MENU_HBMENU_NRO "sdmc:/hbmenu.nro"
namespace ui {
MenuLayout::MenuLayout(void *raw, u8 min_alpha) : susptr(raw), last_hasconn(false), last_batterylvl(0), last_charge(false), warnshown(false), homebrew_mode(false), select_on(false), select_dir(false), minalpha(min_alpha), mode(0), rawalpha(0xFF) {
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menutextx = g_menu_app_instance->GetUIConfigValue<u32>("menu_folder_text_x", 30);
auto menutexty = g_menu_app_instance->GetUIConfigValue<u32>("menu_folder_text_y", 200);
auto menutextsz = g_menu_app_instance->GetUIConfigValue<u32>("menu_folder_text_size", 25);
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menutextx = g_MenuApplication->GetUIConfigValue<u32>("menu_folder_text_x", 30);
auto menutexty = g_MenuApplication->GetUIConfigValue<u32>("menu_folder_text_y", 200);
auto menutextsz = g_MenuApplication->GetUIConfigValue<u32>("menu_folder_text_size", 25);
this->bgSuspendedRaw = RawData::New(0, 0, raw, 1280, 720, 4);
this->Add(this->bgSuspendedRaw);
// Load banners first
this->topMenuImage = pu::ui::elm::Image::New(40, 35, cfg::GetAssetByTheme(g_ul_theme, "ui/TopMenu.png"));
g_menu_app_instance->ApplyConfigForElement("main_menu", "top_menu_bg", this->topMenuImage);
this->topMenuImage = pu::ui::elm::Image::New(40, 35, cfg::GetAssetByTheme(g_Theme, "ui/TopMenu.png"));
g_MenuApplication->ApplyConfigForElement("main_menu", "top_menu_bg", this->topMenuImage);
this->Add(this->topMenuImage);
this->bannerImage = pu::ui::elm::Image::New(0, 585, cfg::GetAssetByTheme(g_ul_theme, "ui/BannerInstalled.png"));
g_menu_app_instance->ApplyConfigForElement("main_menu", "banner_image", this->bannerImage);
this->bannerImage = pu::ui::elm::Image::New(0, 585, cfg::GetAssetByTheme(g_Theme, "ui/BannerInstalled.png"));
g_MenuApplication->ApplyConfigForElement("main_menu", "banner_image", this->bannerImage);
this->Add(this->bannerImage);
// Then load buttons and other UI elements
@ -43,87 +43,87 @@ namespace ui {
this->logo->SetWidth(60);
this->logo->SetHeight(60);
this->logo->SetOnClick(&actions::ShowAboutDialog);
g_menu_app_instance->ApplyConfigForElement("main_menu", "logo_icon", this->logo, false); // Sorry theme makers... logo must be visible, but can be moved
g_MenuApplication->ApplyConfigForElement("main_menu", "logo_icon", this->logo, false); // Sorry theme makers... logo must be visible, but can be moved
this->Add(this->logo);
this->connIcon = pu::ui::elm::Image::New(80, 53, cfg::GetAssetByTheme(g_ul_theme, "ui/NoConnectionIcon.png"));
g_menu_app_instance->ApplyConfigForElement("main_menu", "connection_icon", this->connIcon);
this->connIcon = pu::ui::elm::Image::New(80, 53, cfg::GetAssetByTheme(g_Theme, "ui/NoConnectionIcon.png"));
g_MenuApplication->ApplyConfigForElement("main_menu", "connection_icon", this->connIcon);
this->Add(this->connIcon);
this->users = ClickableImage::New(270, 53, ""); // On layout creation, no user is still selected...
this->users->SetOnClick(&actions::ShowUserMenu);
g_menu_app_instance->ApplyConfigForElement("main_menu", "user_icon", this->users);
g_MenuApplication->ApplyConfigForElement("main_menu", "user_icon", this->users);
this->Add(this->users);
this->controller = ClickableImage::New(340, 53, cfg::GetAssetByTheme(g_ul_theme, "ui/ControllerIcon.png"));
this->controller = ClickableImage::New(340, 53, cfg::GetAssetByTheme(g_Theme, "ui/ControllerIcon.png"));
this->controller->SetOnClick(&actions::ShowControllerSupport);
g_menu_app_instance->ApplyConfigForElement("main_menu", "controller_icon", this->controller);
g_MenuApplication->ApplyConfigForElement("main_menu", "controller_icon", this->controller);
this->Add(this->controller);
auto curtime = os::GetCurrentTime();
this->timeText = pu::ui::elm::TextBlock::New(515, 68, curtime);
this->timeText->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("main_menu", "time_text", this->timeText);
g_MenuApplication->ApplyConfigForElement("main_menu", "time_text", this->timeText);
this->Add(this->timeText);
auto lvl = os::GetBatteryLevel();
auto lvlstr = std::to_string(lvl) + "%";
this->batteryText = pu::ui::elm::TextBlock::New(700, 55, lvlstr);
this->batteryText->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("main_menu", "battery_text", this->batteryText);
g_MenuApplication->ApplyConfigForElement("main_menu", "battery_text", this->batteryText);
this->Add(this->batteryText);
this->batteryIcon = pu::ui::elm::Image::New(700, 80, cfg::GetAssetByTheme(g_ul_theme, "ui/BatteryNormalIcon.png"));
g_menu_app_instance->ApplyConfigForElement("main_menu", "battery_icon", this->batteryIcon);
this->batteryIcon = pu::ui::elm::Image::New(700, 80, cfg::GetAssetByTheme(g_Theme, "ui/BatteryNormalIcon.png"));
g_MenuApplication->ApplyConfigForElement("main_menu", "battery_icon", this->batteryIcon);
this->Add(this->batteryIcon);
this->settings = ClickableImage::New(880, 53, cfg::GetAssetByTheme(g_ul_theme, "ui/SettingsIcon.png"));
this->settings = ClickableImage::New(880, 53, cfg::GetAssetByTheme(g_Theme, "ui/SettingsIcon.png"));
this->settings->SetOnClick(&actions::ShowSettingsMenu);
g_menu_app_instance->ApplyConfigForElement("main_menu", "settings_icon", this->settings);
g_MenuApplication->ApplyConfigForElement("main_menu", "settings_icon", this->settings);
this->Add(this->settings);
this->themes = ClickableImage::New(950, 53, cfg::GetAssetByTheme(g_ul_theme, "ui/ThemesIcon.png"));
this->themes = ClickableImage::New(950, 53, cfg::GetAssetByTheme(g_Theme, "ui/ThemesIcon.png"));
this->themes->SetOnClick(&actions::ShowThemesMenu);
g_menu_app_instance->ApplyConfigForElement("main_menu", "themes_icon", this->themes);
g_MenuApplication->ApplyConfigForElement("main_menu", "themes_icon", this->themes);
this->Add(this->themes);
this->fwText = pu::ui::elm::TextBlock::New(1140, 68, os::GetFirmwareVersion());
this->fwText->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("main_menu", "firmware_text", this->fwText);
g_MenuApplication->ApplyConfigForElement("main_menu", "firmware_text", this->fwText);
this->Add(this->fwText);
this->menuToggle = ClickableImage::New(520, 200, cfg::GetAssetByTheme(g_ul_theme, "ui/ToggleClick.png"));
this->menuToggle = ClickableImage::New(520, 200, cfg::GetAssetByTheme(g_Theme, "ui/ToggleClick.png"));
this->menuToggle->SetOnClick(std::bind(&MenuLayout::menuToggle_Click, this));
g_menu_app_instance->ApplyConfigForElement("main_menu", "menu_toggle_button", this->menuToggle);
g_MenuApplication->ApplyConfigForElement("main_menu", "menu_toggle_button", this->menuToggle);
this->Add(this->menuToggle);
this->itemName = pu::ui::elm::TextBlock::New(40, 610, "A");
this->itemName->SetFont("DefaultFont@30");
this->itemName->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("main_menu", "banner_name_text", this->itemName);
g_MenuApplication->ApplyConfigForElement("main_menu", "banner_name_text", this->itemName);
this->Add(this->itemName);
this->itemAuthor = pu::ui::elm::TextBlock::New(45, 650, "A");
this->itemAuthor->SetFont("DefaultFont@20");
this->itemAuthor->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("main_menu", "banner_author_text", this->itemAuthor);
g_MenuApplication->ApplyConfigForElement("main_menu", "banner_author_text", this->itemAuthor);
this->Add(this->itemAuthor);
this->itemVersion = pu::ui::elm::TextBlock::New(45, 675, "A");
this->itemVersion->SetFont("DefaultFont@20");
this->itemVersion->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("main_menu", "banner_version_text", this->itemVersion);
g_MenuApplication->ApplyConfigForElement("main_menu", "banner_version_text", this->itemVersion);
this->Add(this->itemVersion);
std::string font_name = "DefaultFont@" + std::to_string(menutextsz);
this->itemsMenu = SideMenu::New(pu::ui::Color(0, 255, 120, 0xFF), cfg::GetAssetByTheme(g_ul_theme, "ui/Cursor.png"), cfg::GetAssetByTheme(g_ul_theme, "ui/Suspended.png"), cfg::GetAssetByTheme(g_ul_theme, "ui/Multiselect.png"), menutextx, menutexty, font_name, textclr, 294);
this->itemsMenu = SideMenu::New(pu::ui::Color(0, 255, 120, 0xFF), cfg::GetAssetByTheme(g_Theme, "ui/Cursor.png"), cfg::GetAssetByTheme(g_Theme, "ui/Suspended.png"), cfg::GetAssetByTheme(g_Theme, "ui/Multiselect.png"), menutextx, menutexty, font_name, textclr, 294);
this->MoveFolder("", false);
this->itemsMenu->SetOnItemSelected(std::bind(&MenuLayout::menu_Click, this, std::placeholders::_1, std::placeholders::_2));
this->itemsMenu->SetOnSelectionChanged(std::bind(&MenuLayout::menu_OnSelected, this, std::placeholders::_1));
g_menu_app_instance->ApplyConfigForElement("main_menu", "items_menu", this->itemsMenu, false); // Main menu must be visible, and only Y is customizable here
g_MenuApplication->ApplyConfigForElement("main_menu", "items_menu", this->itemsMenu, false); // Main menu must be visible, and only Y is customizable here
this->Add(this->itemsMenu);
this->quickMenu = QuickMenu::New(cfg::GetAssetByTheme(g_ul_theme, "ui/QuickMenuMain.png"));
this->quickMenu = QuickMenu::New(cfg::GetAssetByTheme(g_Theme, "ui/QuickMenuMain.png"));
this->Add(this->quickMenu);
this->tp = std::chrono::steady_clock::now();
this->sfxTitleLaunch = pu::audio::Load(cfg::GetAssetByTheme(g_ul_theme, "sound/TitleLaunch.wav"));
this->sfxMenuToggle = pu::audio::Load(cfg::GetAssetByTheme(g_ul_theme, "sound/MenuToggle.wav"));
this->sfxTitleLaunch = pu::audio::Load(cfg::GetAssetByTheme(g_Theme, "sound/TitleLaunch.wav"));
this->sfxMenuToggle = pu::audio::Load(cfg::GetAssetByTheme(g_Theme, "sound/MenuToggle.wav"));
this->SetBackgroundImage(cfg::GetAssetByTheme(g_ul_theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(g_Theme, "ui/Background.png"));
}
MenuLayout::~MenuLayout() {
@ -145,7 +145,7 @@ namespace ui {
if(hasconn) {
connection_img = "ui/ConnectionIcon.png";
}
this->connIcon->SetImage(cfg::GetAssetByTheme(g_ul_theme, connection_img));
this->connIcon->SetImage(cfg::GetAssetByTheme(g_Theme, connection_img));
}
auto curtime = os::GetCurrentTime();
@ -165,13 +165,13 @@ namespace ui {
if(ch) {
battery_img = "ui/BatteryChargingIcon.png";
}
this->batteryIcon->SetImage(cfg::GetAssetByTheme(g_ul_theme, battery_img));
this->batteryIcon->SetImage(cfg::GetAssetByTheme(g_Theme, battery_img));
}
auto ctp = std::chrono::steady_clock::now();
if(std::chrono::duration_cast<std::chrono::milliseconds>(ctp - this->tp).count() >= 500) {
if(g_menu_app_instance->LaunchFailed() && !this->warnshown) {
g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "app_launch"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "app_unexpected_error"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "ok") }, true);
if(g_MenuApplication->LaunchFailed() && !this->warnshown) {
g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "app_launch"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "app_unexpected_error"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "ok") }, true);
this->warnshown = true;
}
}
@ -230,7 +230,7 @@ namespace ui {
void MenuLayout::OnHomeButtonPress()
{
if(g_menu_app_instance->IsSuspended()) {
if(g_MenuApplication->IsSuspended()) {
if(this->mode == 1) {
this->mode = 2;
}
@ -253,9 +253,9 @@ namespace ui {
if(select_dir) {
if((down & KEY_A) || (down & KEY_Y)) {
if((!this->homebrew_mode) && this->curfolder.empty()) {
if(index < g_entry_list.folders.size()) {
auto &folder = g_entry_list.folders[index];
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_existing_folder_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
if(index < g_EntryList.folders.size()) {
auto &folder = g_EntryList.folders[index];
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_existing_folder_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
this->HandleMultiselectMoveToFolder(folder.name);
}
@ -267,12 +267,12 @@ namespace ui {
}
else if(down & KEY_B) {
this->select_dir = false;
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_select_folder_cancel"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_select_folder_cancel"));
}
}
else {
if(down & KEY_B) {
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_multiselect_cancel"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_multiselect_cancel"));
this->StopMultiselect();
}
else if(down & KEY_Y) {
@ -282,7 +282,7 @@ namespace ui {
}
else {
if(this->curfolder.empty()) {
selectable = index >= g_entry_list.folders.size();
selectable = index >= g_EntryList.folders.size();
}
else {
selectable = true;
@ -294,11 +294,11 @@ namespace ui {
}
else if(down & KEY_A) {
if(this->homebrew_mode) {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hb_mode_entries_add"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hb_mode_entries_add"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
// Get the idx of the last g_homebrew_records element.
// Get the idx of the last g_HomebrewRecordList element.
s32 hbidx = 0;
for(auto &entry: g_entry_list.root.titles) {
for(auto &entry: g_EntryList.root.titles) {
if(static_cast<cfg::TitleType>(entry.title_type) == cfg::TitleType::Installed) {
break;
}
@ -308,20 +308,20 @@ namespace ui {
hbidx = 0;
}
auto any = false;
for(u32 i = 0; i < g_homebrew_records.size(); i++) {
auto &hb = g_homebrew_records[i];
for(u32 i = 0; i < g_HomebrewRecordList.size(); i++) {
auto &hb = g_HomebrewRecordList[i];
auto idx = i + 1;
if(this->itemsMenu->IsItemMultiselected(idx)) {
if(!cfg::ExistsRecord(g_entry_list, hb)) {
if(!cfg::ExistsRecord(g_EntryList, hb)) {
cfg::SaveRecord(hb);
g_entry_list.root.titles.insert(g_entry_list.root.titles.begin() + hbidx, hb);
g_EntryList.root.titles.insert(g_EntryList.root.titles.begin() + hbidx, hb);
any = true;
hbidx++;
}
}
}
if(any) {
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hb_mode_entries_added"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hb_mode_entries_added"));
}
this->StopMultiselect();
}
@ -330,11 +330,11 @@ namespace ui {
}
}
else if(this->curfolder.empty()) {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_to_folder"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_new_folder"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_existing_folder"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_to_folder"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_new_folder"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_existing_folder"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
SwkbdConfig swkbd;
swkbdCreate(&swkbd, 0);
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "swkbd_new_folder_guide").c_str());
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "swkbd_new_folder_guide").c_str());
char dir[500] = {0};
auto rc = swkbdShow(&swkbd, dir, 500);
swkbdClose(&swkbd);
@ -344,22 +344,22 @@ namespace ui {
}
else if(sopt == 1) {
this->select_dir = true;
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_select_folder"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_select_folder"));
}
else if(sopt == 2) {
this->StopMultiselect();
}
}
else {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_move_from_folder"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_multiselect"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_move_from_folder"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
u32 rmvd = 0;
auto &folder = cfg::FindFolderByName(g_entry_list, this->curfolder);
auto &folder = cfg::FindFolderByName(g_EntryList, this->curfolder);
auto basesz = folder.titles.size();
for(u32 i = 0; i < basesz; i++) {
auto &title = folder.titles[i - rmvd];
if(this->itemsMenu->IsItemMultiselected(i)) {
if(cfg::MoveRecordTo(g_entry_list, title, "")) {
if(cfg::MoveRecordTo(g_EntryList, title, "")) {
rmvd++;
}
}
@ -387,8 +387,8 @@ namespace ui {
writer.Write<hb::HbTargetParams>(ipt);
writer.FinishWrite();
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
return;
}
}
@ -396,11 +396,11 @@ namespace ui {
s32 realidx = index;
if(this->homebrew_mode) {
realidx--;
auto hb = g_homebrew_records[realidx];
auto hb = g_HomebrewRecordList[realidx];
if(down & KEY_A) {
auto hblaunch = true;
if(g_menu_app_instance->IsHomebrewSuspended()) {
if(g_menu_app_instance->EqualsSuspendedHomebrewPath(hb.nro_target.nro_path)) {
if(g_MenuApplication->IsHomebrewSuspended()) {
if(g_MenuApplication->EqualsSuspendedHomebrewPath(hb.nro_target.nro_path)) {
if(this->mode == 1) {
this->mode = 2;
}
@ -409,7 +409,7 @@ namespace ui {
else {
hblaunch = false;
this->HandleCloseSuspended();
hblaunch = !g_menu_app_instance->IsHomebrewSuspended();
hblaunch = !g_MenuApplication->IsHomebrewSuspended();
}
}
if(hblaunch) {
@ -417,8 +417,8 @@ namespace ui {
}
}
else if(down & KEY_X) {
if(g_menu_app_instance->IsSuspended()) {
if(g_menu_app_instance->EqualsSuspendedHomebrewPath(hb.nro_target.nro_path)) {
if(g_MenuApplication->IsSuspended()) {
if(g_MenuApplication->EqualsSuspendedHomebrewPath(hb.nro_target.nro_path)) {
this->HandleCloseSuspended();
}
}
@ -429,28 +429,28 @@ namespace ui {
}
}
else {
auto &folder = cfg::FindFolderByName(g_entry_list, this->curfolder);
auto &folder = cfg::FindFolderByName(g_EntryList, this->curfolder);
s32 titleidx = realidx;
if(this->curfolder.empty()) {
if(static_cast<u32>(realidx) >= g_entry_list.folders.size()) {
titleidx -= g_entry_list.folders.size();
if(static_cast<u32>(realidx) >= g_EntryList.folders.size()) {
titleidx -= g_EntryList.folders.size();
}
else {
auto &foldr = g_entry_list.folders[realidx];
auto &foldr = g_EntryList.folders[realidx];
if(down & KEY_A) {
this->MoveFolder(foldr.name, true);
}
else if(down & KEY_Y) {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_rename_folder"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_rename_folder_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_rename_folder"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_rename_folder_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no") }, true);
if(sopt == 0) {
SwkbdConfig swkbd;
swkbdCreate(&swkbd, 0);
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "swkbd_rename_folder_guide").c_str());
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "swkbd_rename_folder_guide").c_str());
char dir[500] = {0};
auto rc = swkbdShow(&swkbd, dir, 500);
swkbdClose(&swkbd);
if(R_SUCCEEDED(rc)) {
cfg::RenameFolder(g_entry_list, foldr.name, dir);
cfg::RenameFolder(g_EntryList, foldr.name, dir);
this->MoveFolder(this->curfolder, true);
}
}
@ -464,9 +464,9 @@ namespace ui {
if(down & KEY_A) {
bool titlelaunch = true;
if(g_menu_app_instance->IsSuspended()) {
if(g_MenuApplication->IsSuspended()) {
if(type == cfg::TitleType::Homebrew) {
if(g_menu_app_instance->EqualsSuspendedHomebrewPath(title.nro_target.nro_path)) {
if(g_MenuApplication->EqualsSuspendedHomebrewPath(title.nro_target.nro_path)) {
if(this->mode == 1) {
this->mode = 2;
}
@ -474,7 +474,7 @@ namespace ui {
}
}
else if(type == cfg::TitleType::Installed) {
if(title.app_id == g_menu_app_instance->GetSuspendedApplicationId()) {
if(title.app_id == g_MenuApplication->GetSuspendedApplicationId()) {
if(this->mode == 1) {
this->mode = 2;
}
@ -486,7 +486,7 @@ namespace ui {
if(type == cfg::TitleType::Installed) {
titlelaunch = false;
this->HandleCloseSuspended();
titlelaunch = !g_menu_app_instance->IsSuspended();
titlelaunch = !g_MenuApplication->IsSuspended();
}
}
}
@ -502,28 +502,27 @@ namespace ui {
writer.FinishWrite();
dmi::MenuResultReader reader;
reader.FinishRead();
if(reader && R_SUCCEEDED(reader.GetValue())) {
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
return;
}
else {
auto rc = reader.GetValue();
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "app_launch_error") + ": " + util::FormatResult(rc));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "app_launch_error") + ": " + util::FormatResult(rc));
}
}
}
}
else if(down & KEY_X) {
if(g_menu_app_instance->IsSuspended()) {
if(g_MenuApplication->IsSuspended()) {
if(type == cfg::TitleType::Homebrew) {
if(g_menu_app_instance->EqualsSuspendedHomebrewPath(title.nro_target.nro_path)) {
if(g_MenuApplication->EqualsSuspendedHomebrewPath(title.nro_target.nro_path)) {
this->HandleCloseSuspended();
}
}
else {
if(title.app_id == g_menu_app_instance->GetSuspendedApplicationId()) {
if(title.app_id == g_MenuApplication->GetSuspendedApplicationId()) {
this->HandleCloseSuspended();
}
}
@ -531,7 +530,7 @@ namespace ui {
}
else if(down & KEY_Y) {
if(type == cfg::TitleType::Homebrew) {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_options"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_action"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_move"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_remove"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_options"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_action"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_move"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_remove"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
if(!this->select_on) {
this->select_on = true;
@ -539,11 +538,11 @@ namespace ui {
this->itemsMenu->SetItemMultiselected(this->itemsMenu->GetSelectedItem(), true);
}
else if(sopt == 1) {
auto sopt2 = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_remove"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_remove_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no") }, true);
auto sopt2 = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_remove"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_remove_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no") }, true);
if(sopt2 == 0) {
cfg::RemoveRecord(title);
folder.titles.erase(folder.titles.begin() + titleidx);
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "entry_remove_ok"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "entry_remove_ok"));
this->MoveFolder(this->curfolder, true);
}
}
@ -556,11 +555,11 @@ namespace ui {
else if(down & KEY_UP) {
if(type == cfg::TitleType::Installed) {
// TODO: strings
auto sopt = g_menu_app_instance->CreateShowDialog("Homebrew title take-over", "Would you like to select this title for homebrew launching?\nIf selected, homebrew will be launched as an application over this title.", { "Yes", "Cancel" }, true);
auto sopt = g_MenuApplication->CreateShowDialog("Homebrew title take-over", "Would you like to select this title for homebrew launching?\nIf selected, homebrew will be launched as an application over this title.", { "Yes", "Cancel" }, true);
if(sopt == 0) {
g_ul_config.homebrew_title_application_id = title.app_id;
cfg::SaveConfig(g_ul_config);
g_menu_app_instance->ShowNotification("Done");
g_Config.homebrew_title_application_id = title.app_id;
cfg::SaveConfig(g_Config);
g_MenuApplication->ShowNotification("Done");
}
}
}
@ -578,23 +577,23 @@ namespace ui {
if(index == 0) {
this->itemAuthor->SetVisible(false);
this->itemVersion->SetVisible(false);
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_ul_theme, "ui/BannerHomebrew.png"));
this->itemName->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hbmenu_launch"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_Theme, "ui/BannerHomebrew.png"));
this->itemName->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hbmenu_launch"));
}
else {
realidx--;
auto hb = g_homebrew_records[realidx];
auto hb = g_HomebrewRecordList[realidx];
auto info = cfg::GetRecordInformation(hb);
if(info.strings.name.empty()) {
this->itemName->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "unknown"));
this->itemName->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "unknown"));
}
else {
this->itemName->SetText(info.strings.name);
}
if(info.strings.author.empty()) {
this->itemAuthor->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "unknown"));
this->itemAuthor->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "unknown"));
}
else {
this->itemAuthor->SetText(info.strings.author);
@ -607,21 +606,21 @@ namespace ui {
this->itemVersion->SetText(info.strings.version);
}
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_ul_theme, "ui/BannerHomebrew.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_Theme, "ui/BannerHomebrew.png"));
}
}
else {
auto &folder = cfg::FindFolderByName(g_entry_list, this->curfolder);
auto &folder = cfg::FindFolderByName(g_EntryList, this->curfolder);
s32 titleidx = realidx;
if(this->curfolder.empty()) {
if(realidx >= g_entry_list.folders.size()) {
titleidx -= g_entry_list.folders.size();
if(realidx >= g_EntryList.folders.size()) {
titleidx -= g_EntryList.folders.size();
}
else {
auto foldr = g_entry_list.folders[realidx];
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_ul_theme, "ui/BannerFolder.png"));
auto foldr = g_EntryList.folders[realidx];
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_Theme, "ui/BannerFolder.png"));
auto sz = foldr.titles.size();
this->itemAuthor->SetText(std::to_string(sz) + " " + ((sz == 1) ? cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "folder_entry_single") : cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "folder_entry_mult")));
this->itemAuthor->SetText(std::to_string(sz) + " " + ((sz == 1) ? cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "folder_entry_single") : cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "folder_entry_mult")));
this->itemVersion->SetVisible(false);
this->itemName->SetText(foldr.name);
titleidx = -1;
@ -632,14 +631,14 @@ namespace ui {
auto info = cfg::GetRecordInformation(title);
if(info.strings.name.empty()) {
this->itemName->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "unknown"));
this->itemName->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "unknown"));
}
else {
this->itemName->SetText(info.strings.name);
}
if(info.strings.author.empty()) {
this->itemAuthor->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "unknown"));
this->itemAuthor->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "unknown"));
}
else {
this->itemAuthor->SetText(info.strings.author);
@ -653,46 +652,46 @@ namespace ui {
}
if(static_cast<cfg::TitleType>(title.title_type) == cfg::TitleType::Homebrew) {
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_ul_theme, "ui/BannerHomebrew.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_Theme, "ui/BannerHomebrew.png"));
}
else {
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_ul_theme, "ui/BannerInstalled.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_Theme, "ui/BannerInstalled.png"));
}
}
if(!this->curfolder.empty()) {
// This way we know we're inside a folder
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_ul_theme, "ui/BannerFolder.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(g_Theme, "ui/BannerFolder.png"));
}
}
}
void MenuLayout::MoveFolder(const std::string &name, bool fade) {
if(fade) {
g_menu_app_instance->FadeOut();
g_MenuApplication->FadeOut();
}
if(this->homebrew_mode) {
if(g_homebrew_records.empty()) {
g_homebrew_records = cfg::QueryAllHomebrew();
if(g_HomebrewRecordList.empty()) {
g_HomebrewRecordList = cfg::QueryAllHomebrew();
}
}
auto itm_list = g_homebrew_records;
auto itm_list = g_HomebrewRecordList;
if(!this->homebrew_mode) {
auto &folder = cfg::FindFolderByName(g_entry_list, name);
auto &folder = cfg::FindFolderByName(g_EntryList, name);
itm_list = folder.titles;
}
this->itemsMenu->ClearItems();
if(this->homebrew_mode) {
this->itemsMenu->AddItem(cfg::GetAssetByTheme(g_ul_theme, "ui/Hbmenu.png"));
this->itemsMenu->AddItem(cfg::GetAssetByTheme(g_Theme, "ui/Hbmenu.png"));
}
else {
if(name.empty()) {
// Remove empty folders
STL_REMOVE_IF(g_entry_list.folders, fldr, (fldr.titles.empty()))
for(auto folder: g_entry_list.folders) {
this->itemsMenu->AddItem(cfg::GetAssetByTheme(g_ul_theme, "ui/Folder.png"), folder.name);
STL_REMOVE_IF(g_EntryList.folders, fldr, (fldr.titles.empty()))
for(auto folder: g_EntryList.folders) {
this->itemsMenu->AddItem(cfg::GetAssetByTheme(g_Theme, "ui/Folder.png"), folder.name);
}
}
}
@ -701,15 +700,15 @@ namespace ui {
for(auto &itm: itm_list) {
bool set_susp = false;
if(static_cast<cfg::TitleType>(itm.title_type) == cfg::TitleType::Installed) {
if(g_menu_app_instance->IsTitleSuspended()) {
if(g_menu_app_instance->GetSuspendedApplicationId() == itm.app_id) {
if(g_MenuApplication->IsTitleSuspended()) {
if(g_MenuApplication->GetSuspendedApplicationId() == itm.app_id) {
set_susp = true;
}
}
}
else {
if(g_menu_app_instance->IsHomebrewSuspended()) {
if(g_menu_app_instance->EqualsSuspendedHomebrewPath(itm.nro_target.nro_path)) {
if(g_MenuApplication->IsHomebrewSuspended()) {
if(g_MenuApplication->EqualsSuspendedHomebrewPath(itm.nro_target.nro_path)) {
set_susp = true;
}
}
@ -723,7 +722,7 @@ namespace ui {
}
// Ignore front folders from main menu
else if(name.empty()) {
suspidx += g_entry_list.folders.size();
suspidx += g_EntryList.folders.size();
}
this->itemsMenu->SetSuspendedItem(suspidx);
}
@ -736,7 +735,7 @@ namespace ui {
}
if(fade) {
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeIn();
}
}
@ -751,14 +750,14 @@ namespace ui {
pu::audio::Play(this->sfxMenuToggle);
this->homebrew_mode = !this->homebrew_mode;
if(this->select_on) {
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_multiselect_cancel"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_multiselect_cancel"));
this->StopMultiselect();
}
this->MoveFolder("", true);
}
void MenuLayout::HandleCloseSuspended() {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "suspended_app"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "suspended_close"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "no") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "suspended_app"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "suspended_close"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "no") }, true);
if(sopt == 0) {
this->DoTerminateApplication();
}
@ -766,8 +765,8 @@ namespace ui {
void MenuLayout::HandleHomebrewLaunch(cfg::TitleRecord &rec) {
u32 launchmode = 0;
if(g_ul_config.system_title_override_enabled) {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hb_launch"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hb_launch_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hb_applet"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "hb_app"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
if(g_Config.system_title_override_enabled) {
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hb_launch"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hb_launch_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hb_applet"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "hb_app"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
launchmode = 1;
}
@ -791,18 +790,18 @@ namespace ui {
writer.Write<hb::HbTargetParams>(ipt);
writer.FinishWrite();
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
return;
}
else if(launchmode == 2) {
if(g_ul_config.homebrew_title_application_id != 0)
if(g_Config.homebrew_title_application_id != 0)
{
bool launch = true;
if(g_menu_app_instance->IsSuspended()) {
if(g_MenuApplication->IsSuspended()) {
launch = false;
this->HandleCloseSuspended();
if(!g_menu_app_instance->IsSuspended()) {
if(!g_MenuApplication->IsSuspended()) {
launch = true;
}
}
@ -816,25 +815,25 @@ namespace ui {
}
dmi::MenuMessageWriter writer(dmi::DaemonMessage::LaunchHomebrewApplication);
writer.Write<u64>(g_ul_config.homebrew_title_application_id);
writer.Write<u64>(g_Config.homebrew_title_application_id);
writer.Write<hb::HbTargetParams>(ipt);
writer.FinishWrite();
dmi::MenuResultReader reader;
reader.FinishRead();
if(reader && R_SUCCEEDED(reader.GetValue())) {
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
return;
}
else {
auto rc = reader.GetValue();
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "app_launch_error") + ": " + util::FormatResult(rc));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "app_launch_error") + ": " + util::FormatResult(rc));
}
}
}
else {
g_menu_app_instance->CreateShowDialog("Launch", "There is no title specified for homebrew to take over it.\nSelect one by pressing up over it.", { "Ok" }, true);
g_MenuApplication->CreateShowDialog("Launch", "There is no title specified for homebrew to take over it.\nSelect one by pressing up over it.", { "Ok" }, true);
}
}
}
@ -842,12 +841,12 @@ namespace ui {
void MenuLayout::HandleMultiselectMoveToFolder(const std::string &folder) {
if(this->select_on) {
u32 rmvd = 0;
auto basesz = g_entry_list.root.titles.size();
auto basefsz = g_entry_list.folders.size();
auto basesz = g_EntryList.root.titles.size();
auto basefsz = g_EntryList.folders.size();
for(u32 i = 0; i < basesz; i++) {
auto &title = g_entry_list.root.titles[i - rmvd];
auto &title = g_EntryList.root.titles[i - rmvd];
if(this->itemsMenu->IsItemMultiselected(basefsz + i)) {
if(cfg::MoveRecordTo(g_entry_list, title, folder)) {
if(cfg::MoveRecordTo(g_EntryList, title, folder)) {
rmvd++;
}
}
@ -865,7 +864,7 @@ namespace ui {
void MenuLayout::DoTerminateApplication() {
this->itemsMenu->UnsetSuspendedItem();
g_menu_app_instance->NotifyEndSuspended();
g_MenuApplication->NotifyEndSuspended();
this->bgSuspendedRaw->SetAlphaFactor(0);
dmi::MenuMessageWriter writer(dmi::DaemonMessage::TerminateApplication);

View file

@ -3,8 +3,8 @@
#include <cfg/cfg_Config.hpp>
#include <am/am_DaemonMessages.hpp>
extern cfg::Theme g_ul_theme;
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::Theme g_Theme;
extern ui::MenuApplication::Ref g_MenuApplication;
namespace ui {
@ -15,58 +15,58 @@ namespace ui {
this->on = false;
this->bgalpha = 0;
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menufocusclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
auto menubgclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menufocusclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
auto menubgclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
this->options_menu = pu::ui::elm::Menu::New(200, 115, 880, menubgclr, 60, 8);
this->options_menu->SetOnFocusColor(menufocusclr);
g_menu_app_instance->ApplyConfigForElement("quick_menu", "quick_menu_item", this->options_menu);
g_MenuApplication->ApplyConfigForElement("quick_menu", "quick_menu_item", this->options_menu);
auto opt_item = pu::ui::elm::MenuItem::New("Help & information");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/HelpIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/HelpIcon.png"));
opt_item->AddOnClick(&actions::ShowHelpDialog);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("Power options");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/PowerIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/PowerIcon.png"));
opt_item->AddOnClick(&actions::ShowPowerDialog);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("Controller options");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/ControllerIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/ControllerIcon.png"));
opt_item->AddOnClick(&actions::ShowControllerSupport);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("Open album");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/AlbumIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/AlbumIcon.png"));
opt_item->AddOnClick(&actions::ShowAlbumApplet);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("Open web-page");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/WebIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/WebIcon.png"));
opt_item->AddOnClick(&actions::ShowWebPage);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("User menu");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/UserIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/UserIcon.png"));
opt_item->AddOnClick(&actions::ShowUserMenu);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("Themes menu");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/ThemesIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/ThemesIcon.png"));
opt_item->AddOnClick(&actions::ShowThemesMenu);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);
opt_item = pu::ui::elm::MenuItem::New("Settings menu");
opt_item->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/SettingsIcon.png"));
opt_item->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/SettingsIcon.png"));
opt_item->AddOnClick(&actions::ShowSettingsMenu);
opt_item->SetColor(textclr);
this->options_menu->AddItem(opt_item);

View file

@ -7,15 +7,15 @@
#include <net/net_Service.hpp>
#include <am/am_LibraryApplet.hpp>
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::Theme g_ul_theme;
extern cfg::Config g_ul_config;
extern ui::MenuApplication::Ref g_MenuApplication;
extern cfg::Theme g_Theme;
extern cfg::Config g_Config;
namespace ui {
template<typename T>
inline std::string EncodeForSettings(T t) {
return cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_unknown_value");
return cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_unknown_value");
}
template<>
@ -30,40 +30,40 @@ namespace ui {
template<>
inline std::string EncodeForSettings<bool>(bool t) {
return t ? cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_true_value") : cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_false_value");
return t ? cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_true_value") : cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_false_value");
}
SettingsMenuLayout::SettingsMenuLayout() {
this->SetBackgroundImage(cfg::GetAssetByTheme(g_ul_theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(g_Theme, "ui/Background.png"));
pu::ui::Color textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
pu::ui::Color menubgclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
pu::ui::Color textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
pu::ui::Color menubgclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
this->infoText = pu::ui::elm::TextBlock::New(0, 100, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_info_text"));
this->infoText = pu::ui::elm::TextBlock::New(0, 100, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_info_text"));
this->infoText->SetColor(textclr);
this->infoText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center);
g_menu_app_instance->ApplyConfigForElement("settings_menu", "info_text", this->infoText);
g_MenuApplication->ApplyConfigForElement("settings_menu", "info_text", this->infoText);
this->Add(this->infoText);
this->settingsMenu = pu::ui::elm::Menu::New(50, 160, 1180, menubgclr, 100, 4);
this->settingsMenu->SetOnFocusColor(menufocusclr);
g_menu_app_instance->ApplyConfigForElement("settings_menu", "settings_menu_item", this->settingsMenu);
g_MenuApplication->ApplyConfigForElement("settings_menu", "settings_menu_item", this->settingsMenu);
this->Add(this->settingsMenu);
}
void SettingsMenuLayout::OnMenuInput(u64 down, u64 up, u64 held, pu::ui::Touch pos) {
if(down & KEY_B) {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadMenu();
g_MenuApplication->FadeIn();
}
}
void SettingsMenuLayout::OnHomeButtonPress() {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadMenu();
g_MenuApplication->FadeIn();
}
void SettingsMenuLayout::Reload() {
@ -72,63 +72,63 @@ namespace ui {
char consolename[SET_MAX_NICKNAME_SIZE] = {};
setsysGetDeviceNickname(consolename);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_console_nickname"), EncodeForSettings<std::string>(consolename), 0);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_console_nickname"), EncodeForSettings<std::string>(consolename), 0);
TimeLocationName loc = {};
timeGetDeviceLocationName(&loc);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_console_timezone"), EncodeForSettings<std::string>(loc.name), -1);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_viewer_enabled"), EncodeForSettings(g_ul_config.viewer_usb_enabled), 1);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_flog_enabled"), EncodeForSettings(g_ul_config.system_title_override_enabled), 2);
auto connectednet = cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_wifi_none");
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_console_timezone"), EncodeForSettings<std::string>(loc.name), -1);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_viewer_enabled"), EncodeForSettings(g_Config.viewer_usb_enabled), 1);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_flog_enabled"), EncodeForSettings(g_Config.system_title_override_enabled), 2);
auto connectednet = cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_wifi_none");
if(net::HasConnection()) {
net::NetworkProfileData data = {};
net::GetCurrentNetworkProfile(&data);
connectednet = data.wifi_name;
}
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_wifi_name"), EncodeForSettings(connectednet), 3);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_wifi_name"), EncodeForSettings(connectednet), 3);
u64 lcode = 0;
auto ilang = SetLanguage_ENUS;
setGetLanguageCode(&lcode);
setMakeLanguage(lcode, &ilang);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_console_lang"), EncodeForSettings(os::GetLanguageName(ilang)), 4);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_console_lang"), EncodeForSettings(os::GetLanguageName(ilang)), 4);
bool console_info_upload = false;
setsysGetConsoleInformationUploadFlag(&console_info_upload);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_console_info_upload"), EncodeForSettings(console_info_upload), 5);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_console_info_upload"), EncodeForSettings(console_info_upload), 5);
bool auto_titles_dl = false;
setsysGetAutomaticApplicationDownloadFlag(&auto_titles_dl);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_auto_titles_dl"), EncodeForSettings(auto_titles_dl), 6);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_auto_titles_dl"), EncodeForSettings(auto_titles_dl), 6);
bool auto_update = false;
setsysGetAutoUpdateEnableFlag(&auto_update);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_auto_update"), EncodeForSettings(auto_update), 7);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_auto_update"), EncodeForSettings(auto_update), 7);
bool wireless_lan = false;
setsysGetWirelessLanEnableFlag(&wireless_lan);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_wireless_lan"), EncodeForSettings(wireless_lan), 8);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_wireless_lan"), EncodeForSettings(wireless_lan), 8);
bool bluetooth = false;
setsysGetBluetoothEnableFlag(&bluetooth);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_bluetooth"), EncodeForSettings(bluetooth), 9);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_bluetooth"), EncodeForSettings(bluetooth), 9);
bool usb_30 = false;
setsysGetUsb30EnableFlag(&usb_30);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_usb_30"), EncodeForSettings(usb_30), 10);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_usb_30"), EncodeForSettings(usb_30), 10);
bool nfc = false;
setsysGetNfcEnableFlag(&nfc);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_nfc"), EncodeForSettings(nfc), 11);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_nfc"), EncodeForSettings(nfc), 11);
SetSysSerialNumber serial = {};
setsysGetSerialNumber(&serial);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_serial_no"), EncodeForSettings<std::string>(serial.number), -1);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_serial_no"), EncodeForSettings<std::string>(serial.number), -1);
u64 mac = 0;
net::GetMACAddress(&mac);
auto strmac = net::FormatMACAddress(mac);
this->PushSettingItem(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_mac_addr"), EncodeForSettings(strmac), -1);
this->PushSettingItem(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_mac_addr"), EncodeForSettings(strmac), -1);
auto ipstr = net::GetConsoleIPAddress();
// TODO: strings
this->PushSettingItem("Console IP address", EncodeForSettings(ipstr), -1);
}
void SettingsMenuLayout::PushSettingItem(const std::string &name, const std::string &value_display, int id) {
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto itm = pu::ui::elm::MenuItem::New(name + ": " + value_display);
itm->AddOnClick(std::bind(&SettingsMenuLayout::setting_Click, this, id));
itm->SetIcon(cfg::GetAssetByTheme(g_ul_theme, "ui/Setting" + std::string((id < 0) ? "No" : "") + "Editable.png"));
itm->SetIcon(cfg::GetAssetByTheme(g_Theme, "ui/Setting" + std::string((id < 0) ? "No" : "") + "Editable.png"));
itm->SetColor(textclr);
this->settingsMenu->AddItem(itm);
}
@ -139,7 +139,7 @@ namespace ui {
case 0: {
SwkbdConfig swkbd;
swkbdCreate(&swkbd, 0);
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "swkbd_console_nick_guide").c_str());
swkbdConfigSetGuideText(&swkbd, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "swkbd_console_nick_guide").c_str());
char consolename[SET_MAX_NICKNAME_SIZE] = {};
setsysGetDeviceNickname(consolename);
swkbdConfigSetInitialText(&swkbd, consolename);
@ -154,18 +154,18 @@ namespace ui {
break;
}
case 1: {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_viewer_enabled"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_viewer_info") + "\n" + (g_ul_config.viewer_usb_enabled ? cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_disable_conf") : cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_enable_conf")), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_viewer_enabled"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_viewer_info") + "\n" + (g_Config.viewer_usb_enabled ? cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_disable_conf") : cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_enable_conf")), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
g_ul_config.viewer_usb_enabled = !g_ul_config.viewer_usb_enabled;
g_Config.viewer_usb_enabled = !g_Config.viewer_usb_enabled;
reload_need = true;
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_changed_reboot"));
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_changed_reboot"));
}
break;
}
case 2: {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_flog_enabled"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_flog_info") + "\n" + (g_ul_config.viewer_usb_enabled ? cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_disable_conf") : cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "set_enable_conf")), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_flog_enabled"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_flog_info") + "\n" + (g_Config.viewer_usb_enabled ? cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_disable_conf") : cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "set_enable_conf")), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
g_ul_config.system_title_override_enabled = !g_ul_config.system_title_override_enabled;
g_Config.system_title_override_enabled = !g_Config.system_title_override_enabled;
reload_need = true;
}
break;
@ -189,9 +189,9 @@ namespace ui {
break;
}
case 4: {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadSettingsLanguagesMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadSettingsLanguagesMenu();
g_MenuApplication->FadeIn();
break;
}
@ -253,7 +253,7 @@ namespace ui {
}
}
if(reload_need) {
cfg::SaveConfig(g_ul_config);
cfg::SaveConfig(g_Config);
this->Reload();
}
}

View file

@ -4,39 +4,39 @@
#include <ui/ui_MenuApplication.hpp>
#include <fs/fs_Stdio.hpp>
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::Theme g_ul_theme;
extern cfg::Config g_ul_config;
extern ui::MenuApplication::Ref g_MenuApplication;
extern cfg::Theme g_Theme;
extern cfg::Config g_Config;
namespace ui {
StartupLayout::StartupLayout() {
this->SetBackgroundImage(cfg::GetAssetByTheme(g_ul_theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(g_Theme, "ui/Background.png"));
this->loadmenu = false;
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menufocusclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
auto menubgclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menufocusclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
auto menubgclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
this->infoText = pu::ui::elm::TextBlock::New(35, 635, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "startup_welcome_info") + "\n" + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "startup_control_info"));
this->infoText = pu::ui::elm::TextBlock::New(35, 635, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "startup_welcome_info") + "\n" + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "startup_control_info"));
this->infoText->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("startup_menu", "info_text", this->infoText);
g_MenuApplication->ApplyConfigForElement("startup_menu", "info_text", this->infoText);
this->Add(this->infoText);
this->usersMenu = pu::ui::elm::Menu::New(200, 60, 880, menubgclr, 100, 5);
this->usersMenu->SetOnFocusColor(menufocusclr);
g_menu_app_instance->ApplyConfigForElement("startup_menu", "users_menu_item", this->usersMenu);
g_MenuApplication->ApplyConfigForElement("startup_menu", "users_menu_item", this->usersMenu);
this->Add(this->usersMenu);
}
void StartupLayout::OnMenuInput(u64 down, u64 up, u64 held, pu::ui::Touch touch_pos) {
if(this->loadmenu) {
this->loadmenu = false;
g_menu_app_instance->StartPlayBGM();
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadMenu();
g_menu_app_instance->FadeIn();
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "menu_quick_info"), 3000); // Show for 3s
g_MenuApplication->StartPlayBGM();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadMenu();
g_MenuApplication->FadeIn();
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "menu_quick_info"), 3000); // Show for 3s
}
}
@ -46,15 +46,15 @@ namespace ui {
void StartupLayout::user_Click(AccountUid uid) {
this->loadmenu = true;
g_menu_app_instance->SetSelectedUser(uid);
g_MenuApplication->SetSelectedUser(uid);
}
void StartupLayout::create_Click() {
auto rc = pselShowUserCreator();
if(R_SUCCEEDED(rc)) {
g_menu_app_instance->FadeOut();
g_MenuApplication->FadeOut();
this->ReloadMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeIn();
}
}
@ -62,7 +62,7 @@ namespace ui {
this->usersMenu->ClearItems();
this->usersMenu->SetSelectedIndex(0);
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
std::vector<AccountUid> users;
auto rc = os::QuerySystemAccounts(users, true);
if(R_SUCCEEDED(rc)) {
@ -81,7 +81,7 @@ namespace ui {
}
}
auto citm = pu::ui::elm::MenuItem::New(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "startup_new_user"));
auto citm = pu::ui::elm::MenuItem::New(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "startup_new_user"));
citm->SetColor(textclr);
citm->AddOnClick(std::bind(&StartupLayout::create_Click, this));
this->usersMenu->AddItem(citm);

View file

@ -4,74 +4,74 @@
#include <ui/ui_MenuApplication.hpp>
#include <fs/fs_Stdio.hpp>
extern ui::MenuApplication::Ref g_menu_app_instance;
extern cfg::Theme g_ul_theme;
extern cfg::Config g_ul_config;
extern ui::MenuApplication::Ref g_MenuApplication;
extern cfg::Theme g_Theme;
extern cfg::Config g_Config;
namespace ui {
ThemeMenuLayout::ThemeMenuLayout() {
this->SetBackgroundImage(cfg::GetAssetByTheme(g_ul_theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(g_Theme, "ui/Background.png"));
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menufocusclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
auto menubgclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto menufocusclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
auto menubgclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
this->curThemeBanner = pu::ui::elm::Image::New(0, 585, cfg::GetAssetByTheme(g_ul_theme, "ui/BannerTheme.png"));
g_menu_app_instance->ApplyConfigForElement("themes_menu", "banner_image", this->curThemeBanner);
this->curThemeBanner = pu::ui::elm::Image::New(0, 585, cfg::GetAssetByTheme(g_Theme, "ui/BannerTheme.png"));
g_MenuApplication->ApplyConfigForElement("themes_menu", "banner_image", this->curThemeBanner);
this->Add(this->curThemeBanner);
this->themesMenu = pu::ui::elm::Menu::New(200, 60, 880, menubgclr, 100, 5);
this->themesMenu->SetOnFocusColor(menufocusclr);
g_menu_app_instance->ApplyConfigForElement("themes_menu", "themes_menu_item", this->themesMenu);
g_MenuApplication->ApplyConfigForElement("themes_menu", "themes_menu_item", this->themesMenu);
this->Add(this->themesMenu);
this->curThemeText = pu::ui::elm::TextBlock::New(20, 540, cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_current") + ":");
this->curThemeText = pu::ui::elm::TextBlock::New(20, 540, cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_current") + ":");
this->curThemeText->SetFont("DefaultFont@30");
this->curThemeText->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("themes_menu", "current_theme_text", this->curThemeText);
g_MenuApplication->ApplyConfigForElement("themes_menu", "current_theme_text", this->curThemeText);
this->Add(this->curThemeText);
this->curThemeName = pu::ui::elm::TextBlock::New(40, 610, "");
this->curThemeName->SetFont("DefaultFont@30");
this->curThemeName->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("themes_menu", "current_theme_name_text", this->curThemeName);
g_MenuApplication->ApplyConfigForElement("themes_menu", "current_theme_name_text", this->curThemeName);
this->Add(this->curThemeName);
this->curThemeAuthor = pu::ui::elm::TextBlock::New(45, 650, "");
this->curThemeAuthor->SetFont("DefaultFont@20");
this->curThemeAuthor->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("themes_menu", "current_theme_author_text", this->curThemeAuthor);
g_MenuApplication->ApplyConfigForElement("themes_menu", "current_theme_author_text", this->curThemeAuthor);
this->Add(this->curThemeAuthor);
this->curThemeVersion = pu::ui::elm::TextBlock::New(45, 675, "");
this->curThemeVersion->SetFont("DefaultFont@30");
this->curThemeVersion->SetColor(textclr);
g_menu_app_instance->ApplyConfigForElement("themes_menu", "current_theme_version_text", this->curThemeVersion);
g_MenuApplication->ApplyConfigForElement("themes_menu", "current_theme_version_text", this->curThemeVersion);
this->Add(this->curThemeVersion);
this->curThemeIcon = pu::ui::elm::Image::New(1000, 605, "");
this->curThemeIcon->SetWidth(100);
this->curThemeIcon->SetHeight(100);
g_menu_app_instance->ApplyConfigForElement("themes_menu", "current_theme_icon", this->curThemeIcon);
g_MenuApplication->ApplyConfigForElement("themes_menu", "current_theme_icon", this->curThemeIcon);
this->Add(this->curThemeIcon);
}
void ThemeMenuLayout::OnMenuInput(u64 down, u64 up, u64 held, pu::ui::Touch touch_pos) {
if(down & KEY_B) {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadMenu();
g_MenuApplication->FadeIn();
}
}
void ThemeMenuLayout::OnHomeButtonPress() {
g_menu_app_instance->FadeOut();
g_menu_app_instance->LoadMenu();
g_menu_app_instance->FadeIn();
g_MenuApplication->FadeOut();
g_MenuApplication->LoadMenu();
g_MenuApplication->FadeIn();
}
void ThemeMenuLayout::Reload() {
auto textclr = pu::ui::Color::FromHex(g_menu_app_instance->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
if(cfg::ThemeIsDefault(g_ul_theme)) {
this->curThemeText->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_no_custom"));
auto textclr = pu::ui::Color::FromHex(g_MenuApplication->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
if(cfg::ThemeIsDefault(g_Theme)) {
this->curThemeText->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_no_custom"));
this->curThemeName->SetVisible(false);
this->curThemeAuthor->SetVisible(false);
this->curThemeVersion->SetVisible(false);
@ -79,16 +79,16 @@ namespace ui {
this->curThemeIcon->SetVisible(false);
}
else {
this->curThemeText->SetText(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_current") + ":");
this->curThemeText->SetText(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_current") + ":");
this->curThemeName->SetVisible(true);
this->curThemeName->SetText(g_ul_theme.manifest.name);
this->curThemeName->SetText(g_Theme.manifest.name);
this->curThemeAuthor->SetVisible(true);
this->curThemeAuthor->SetText(g_ul_theme.manifest.author);
this->curThemeAuthor->SetText(g_Theme.manifest.author);
this->curThemeVersion->SetVisible(true);
this->curThemeVersion->SetText("v" + g_ul_theme.manifest.release);
this->curThemeVersion->SetText("v" + g_Theme.manifest.release);
this->curThemeBanner->SetVisible(true);
this->curThemeIcon->SetVisible(true);
this->curThemeIcon->SetImage(g_ul_theme.path + "/theme/Icon.png");
this->curThemeIcon->SetImage(g_Theme.path + "/theme/Icon.png");
this->curThemeIcon->SetWidth(100);
this->curThemeIcon->SetHeight(100);
}
@ -98,14 +98,14 @@ namespace ui {
this->loadedThemes.clear();
this->loadedThemes = cfg::LoadThemes();
auto ditm = pu::ui::elm::MenuItem::New(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_reset"));
auto ditm = pu::ui::elm::MenuItem::New(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_reset"));
ditm->AddOnClick(std::bind(&ThemeMenuLayout::theme_Click, this));
ditm->SetColor(textclr);
ditm->SetIcon("romfs:/Logo.png");
this->themesMenu->AddItem(ditm);
for(auto &ltheme: this->loadedThemes) {
auto itm = pu::ui::elm::MenuItem::New(ltheme.manifest.name + " (v" + ltheme.manifest.release + ", " + cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_by") + " " + ltheme.manifest.author + ")");
auto itm = pu::ui::elm::MenuItem::New(ltheme.manifest.name + " (v" + ltheme.manifest.release + ", " + cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_by") + " " + ltheme.manifest.author + ")");
itm->AddOnClick(std::bind(&ThemeMenuLayout::theme_Click, this));
itm->SetColor(textclr);
auto iconpath = ltheme.path + "/theme/Icon.png";
@ -117,18 +117,18 @@ namespace ui {
void ThemeMenuLayout::theme_Click() {
auto idx = this->themesMenu->GetSelectedIndex();
if(idx == 0) {
if(cfg::ThemeIsDefault(g_ul_theme)) {
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_no_custom"));
if(cfg::ThemeIsDefault(g_Theme)) {
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_no_custom"));
}
else {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_reset"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_reset_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_reset"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_reset_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true);
if(sopt == 0) {
g_ul_config.theme_name = "";
cfg::SaveConfig(g_ul_config);
g_Config.theme_name = "";
cfg::SaveConfig(g_Config);
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
// g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_changed"));
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
// g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_changed"));
dmi::MenuMessageWriter writer(dmi::DaemonMessage::RestartMenu);
writer.FinishWrite();
@ -139,18 +139,18 @@ namespace ui {
idx--;
auto seltheme = this->loadedThemes[idx];
auto iconpath = seltheme.path + "/theme/Icon.png";
if(seltheme.base_name == g_ul_theme.base_name) {
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_active_this"));
if(seltheme.base_name == g_Theme.base_name) {
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_active_this"));
}
else {
auto sopt = g_menu_app_instance->CreateShowDialog(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_set"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_set_conf"), { cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "yes"), cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "cancel") }, true, iconpath);
auto sopt = g_MenuApplication->CreateShowDialog(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_set"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_set_conf"), { cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "yes"), cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "cancel") }, true, iconpath);
if(sopt == 0) {
g_ul_config.theme_name = seltheme.base_name;
cfg::SaveConfig(g_ul_config);
g_Config.theme_name = seltheme.base_name;
cfg::SaveConfig(g_Config);
g_menu_app_instance->StopPlayBGM();
g_menu_app_instance->CloseWithFadeOut();
g_menu_app_instance->ShowNotification(cfg::GetLanguageString(g_ul_config.main_lang, g_ul_config.default_lang, "theme_changed"));
g_MenuApplication->StopPlayBGM();
g_MenuApplication->CloseWithFadeOut();
g_MenuApplication->ShowNotification(cfg::GetLanguageString(g_Config.main_lang, g_Config.default_lang, "theme_changed"));
dmi::MenuMessageWriter writer(dmi::DaemonMessage::RestartMenu);
writer.FinishWrite();