Skip to content

Commit

Permalink
Fix bad behavior between system/menu settings
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Jul 2, 2024
1 parent 7117ae6 commit 2706ba0
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ In order to only build a certain subproject, you can run `make` plus the subproj

- Several scene developers for their help with small issues or features.

- `uMenu` translations: [DDinghoya]() for Korean translations
- `uMenu` translations: [DDinghoya](https://github.com/DDinghoya) for Korean translations

- Everyone from my Discord and other places whose suggestions made this project a little bit better! Specially all the testers for being essential in reporting bugs and helping a lot with the project's development <3
2 changes: 1 addition & 1 deletion libs/uCommon/include/ul/smi/smi_Protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace ul::smi {
OpenWebPage,
OpenAlbum,
RestartMenu,
SetHomebrewTakeoverApplication,
ReloadConfig,
UpdateMenuPaths,
UpdateMenuIndex,
OpenUserPage,
Expand Down
5 changes: 2 additions & 3 deletions projects/uMenu/include/ul/menu/smi/smi_Commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ namespace ul::menu::smi {
);
}

inline Result SetHomebrewTakeoverApplication(const u64 app_id) {
return SendCommand(SystemMessage::SetHomebrewTakeoverApplication,
inline Result ReloadConfig() {
return SendCommand(SystemMessage::ReloadConfig,
[&](ScopedStorageWriter &writer) {
writer.Push(app_id);
return ResultSuccess;
},
[](ScopedStorageReader &reader) {
Expand Down
2 changes: 2 additions & 0 deletions projects/uMenu/include/ul/menu/ui/ui_Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace ul::menu::ui {
void LoadSelectedUserIconTexture();
pu::sdl2::TextureHandle::Ref GetSelectedUserIconTexture();

void SaveConfig();

void RebootSystem();
void ShutdownSystem();
void SleepSystem();
Expand Down
2 changes: 1 addition & 1 deletion projects/uMenu/romfs/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"theme_info_text": "Temas disponibles",
"theme_no_active": "No tiene actualmente un tema activo.",
"theme_reset": "Restablecer tema (tema por defecto)",
"theme_reset_conf": "Would you like to return to uLaunch's default theme?",
"theme_reset_conf": "¿Le gustaría restablecer el tema por defecto de uLaunch?",
"theme_changed": "El tema de uLaunch ha sido restablecido.",
"theme_active_this": "Este es el actual tema activo.",
"theme_set_conf": "¿Le gustaría establecer este tema?",
Expand Down
5 changes: 5 additions & 0 deletions projects/uMenu/source/ul/menu/ui/ui_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ namespace ul::menu::ui {
return g_UserIconTexture;
}

void SaveConfig() {
cfg::SaveConfig(g_Config);
UL_RC_ASSERT(smi::ReloadConfig());
}

void RebootSystem() {
PushPowerSystemAppletMessage(system::GeneralChannelMessage::Unk_Reboot);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/uMenu/source/ul/menu/ui/ui_EntryMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace ul::menu::ui {

void SetEntryHeightCount(const u32 count) {
UL_ASSERT_TRUE(g_Config.SetEntry(cfg::ConfigEntryId::MenuEntryHeightCount, static_cast<u64>(count)));
cfg::SaveConfig(g_Config);
SaveConfig();

g_EntryHeightCount = count;
}
Expand Down
2 changes: 1 addition & 1 deletion projects/uMenu/source/ul/menu/ui/ui_MenuApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace ul::menu::ui {

// No need to save config, uSystem deals with that
UL_ASSERT_TRUE(g_Config.SetEntry(cfg::ConfigEntryId::HomebrewApplicationTakeoverApplicationId, this->takeover_app_id));
UL_RC_ASSERT(smi::SetHomebrewTakeoverApplication(this->takeover_app_id));
SaveConfig();
}

void MenuApplication::ShowNotification(const std::string &text, const u64 timeout) {
Expand Down
2 changes: 1 addition & 1 deletion projects/uMenu/source/ul/menu/ui/ui_SettingsMenuLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ namespace ul::menu::ui {

if(reload_need) {
pu::audio::PlaySfx(this->setting_save_sfx);
cfg::SaveConfig(g_Config);
SaveConfig();
this->Reload(false);
}
}
Expand Down
4 changes: 2 additions & 2 deletions projects/uMenu/source/ul/menu/ui/ui_ThemesMenuLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace ul::menu::ui {
if(option == 0) {
g_ActiveTheme = selected_theme;
UL_ASSERT_TRUE(g_Config.SetEntry(cfg::ConfigEntryId::ActiveThemeName, g_ActiveTheme.name));
cfg::SaveConfig(g_Config);
SaveConfig();
g_MenuApplication->ShowNotification(GetLanguageString("theme_cache"));
cfg::CacheActiveTheme(g_Config);

Expand All @@ -123,7 +123,7 @@ namespace ul::menu::ui {
if(option == 0) {
g_ActiveTheme = {};
UL_ASSERT_TRUE(g_Config.SetEntry(cfg::ConfigEntryId::ActiveThemeName, g_ActiveTheme.name));
cfg::SaveConfig(g_Config);
SaveConfig();
g_MenuApplication->ShowNotification(GetLanguageString("theme_cache"));
cfg::CacheActiveTheme(g_Config);

Expand Down
25 changes: 13 additions & 12 deletions projects/uSystem/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace {
bool g_LoaderOpenedAsApplication = false;
bool g_AppletActive = false;
AppletOperationMode g_OperationMode;
ul::cfg::Config g_Config = {};
ul::cfg::Config g_Config;

char g_CurrentMenuFsPath[FS_MAX_PATH] = {};
char g_CurrentMenuPath[FS_MAX_PATH] = {};
Expand Down Expand Up @@ -127,6 +127,14 @@ namespace {

namespace {

void LoadConfig() {
g_Config = ul::cfg::LoadConfig();

u64 menu_program_id;
UL_ASSERT_TRUE(g_Config.GetEntry(ul::cfg::ConfigEntryId::MenuTakeoverProgramId, menu_program_id));
la::SetMenuProgramId(menu_program_id);
}

inline void PushMenuMessageContext(const ul::smi::MenuMessageContext msg_ctx) {
ul::ScopedLock lk(g_MenuMessageQueueLock);
g_MenuMessageQueue->push(msg_ctx);
Expand Down Expand Up @@ -446,12 +454,8 @@ namespace {
g_MenuRestartFlag = true;
break;
}
case ul::smi::SystemMessage::SetHomebrewTakeoverApplication: {
u64 takeover_app_id;
UL_RC_TRY(reader.Pop(takeover_app_id));

UL_ASSERT_TRUE(g_Config.SetEntry(ul::cfg::ConfigEntryId::HomebrewApplicationTakeoverApplicationId, takeover_app_id));
ul::cfg::SaveConfig(g_Config);
case ul::smi::SystemMessage::ReloadConfig: {
LoadConfig();
break;
}
case ul::smi::SystemMessage::UpdateMenuPaths: {
Expand Down Expand Up @@ -530,7 +534,7 @@ namespace {
// ...
break;
}
case ul::smi::SystemMessage::SetHomebrewTakeoverApplication: {
case ul::smi::SystemMessage::ReloadConfig: {
// ...
break;
}
Expand Down Expand Up @@ -891,10 +895,7 @@ namespace {
ul::menu::CacheApplications(g_CurrentRecords);
ul::menu::CacheHomebrew();

g_Config = ul::cfg::LoadConfig();
u64 menu_program_id;
UL_ASSERT_TRUE(g_Config.GetEntry(ul::cfg::ConfigEntryId::MenuTakeoverProgramId, menu_program_id));
la::SetMenuProgramId(menu_program_id);
LoadConfig();

UL_RC_ASSERT(sf::Initialize());

Expand Down

0 comments on commit 2706ba0

Please sign in to comment.