diff --git a/common/language.c b/common/language.c index 2d61e0e..7df10e3 100644 --- a/common/language.c +++ b/common/language.c @@ -320,7 +320,7 @@ const char* const g_strings[StrId_Max][16] = }, - [StrId_Actions_Theme_Menu] = + [StrId_ThemeMenu] = { STR_EN("Theme Menu"), STR_ES("Menú temático"), @@ -887,4 +887,3 @@ const char* const g_strings[StrId_Max][16] = ), },*/ }; - diff --git a/common/language.h b/common/language.h index 331dcf6..68ff13d 100644 --- a/common/language.h +++ b/common/language.h @@ -43,7 +43,7 @@ typedef enum StrId_NetLoaderActive, StrId_NetLoaderTransferring, - StrId_Actions_Theme_Menu, + StrId_ThemeMenu, StrId_Max, } StrId; diff --git a/common/menu.c b/common/menu.c index 82e975e..b8dd635 100644 --- a/common/menu.c +++ b/common/menu.c @@ -56,7 +56,7 @@ void launchMenuBackTask() { void launchApplyThemeTask(menuEntry_s* arg) { const char* themePath = removeDriveFromPath(arg->path); - //SetThemePathToConfig(themePath); + SetThemePathToConfig(themePath); themeStartup(themeGlobalPreset); computeFrontGradient(themeCurrent.frontWaveColor, 280); } @@ -479,8 +479,8 @@ void menuLoop() { if(active_entry != NULL) { if (active_entry->type == ENTRY_TYPE_THEME) { - int getX = GetTextXCoordinate(interuiregular18, 1180, textGetString(StrId_Actions_Theme_Menu), 'r'); - DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_Actions_Theme_Menu)); + int getX = GetTextXCoordinate(interuiregular18, 1180, textGetString(StrId_ThemeMenu), 'r'); + DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_ThemeMenu)); DrawText(fontscale7, 1280 - 126 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, themeCurrent.buttonAText); DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Apply)); } diff --git a/common/theme.c b/common/theme.c index b687063..40b1efd 100644 --- a/common/theme.c +++ b/common/theme.c @@ -53,11 +53,12 @@ void themeStartup(ThemePreset preset) { //.buttonBImage = button_b_dark_bin, .hbmenuLogoImage = hbmenu_logo_dark_bin }; - - + const char* themePath = ""; - GetThemePathFromConfig(themePath); - + config_t themeCfg = {0}; + config_setting_t *setting; + config_init(&themeCfg); + GetThemePathFromConfig(themeCfg, setting, &themePath); theme_t *themeDefault; config_t cfg = {0}; @@ -67,6 +68,7 @@ void themeStartup(ThemePreset preset) { int waveBlending; const char *AText, *BText; bool good_cfg = config_read_file(&cfg, themePath); + config_destroy(&themeCfg); switch (preset) { case THEME_PRESET_LIGHT: @@ -135,25 +137,22 @@ void themeStartup(ThemePreset preset) { config_destroy(&cfg); } -void GetThemePathFromConfig(const char* themePath) { - config_t cfg = {0}; - config_setting_t *setting; - config_init(&cfg); - +void GetThemePathFromConfig(config_t cfg, config_setting_t *setting, const char** themePath) { char tmp_path[PATH_MAX] = {0}; #ifdef __SWITCH__ tmp_path[0] = '/'; #endif - strncat(tmp_path, "config/nx-hbmenu/setting.cfg", sizeof(tmp_path)-2); + strncat(tmp_path, "config/nx-hbmenu/settings.cfg", sizeof(tmp_path)-2); bool good_cfg = config_read_file(&cfg, tmp_path); if(good_cfg) { - setting = config_lookup(&cfg, "themePath"); - config_setting_lookup_string(setting, "themePath", &themePath); + setting = config_lookup(&cfg, "hbmenuConfig"); + if(setting != NULL){ + config_setting_lookup_string(setting, "themePath", themePath); + } } - config_destroy(&cfg); } void SetThemePathToConfig(const char* themePath) { @@ -167,7 +166,8 @@ void SetThemePathToConfig(const char* themePath) { settingPath[0] = '/'; #endif - strncat(settingPath, "config/nx-hbmenu/setting.cfg", sizeof(settingPath)-2); + strncat(settingPath, "config/nx-hbmenu/settings.cfg", sizeof(settingPath)-2); + root = config_root_setting(&cfg); group = config_setting_add(root, "hbmenuConfig", CONFIG_TYPE_GROUP); setting = config_setting_add(group, "themePath", CONFIG_TYPE_STRING); diff --git a/common/theme.h b/common/theme.h index a316863..956f6e2 100644 --- a/common/theme.h +++ b/common/theme.h @@ -30,7 +30,7 @@ typedef enum bool colorFromSetting(config_setting_t *rgba, color_t *col); void themeStartup(ThemePreset preset); -void GetThemePathFromConfig(const char* themePath); +void GetThemePathFromConfig(config_t cfg, config_setting_t *setting, const char** themePath); void SetThemePathToConfig(const char* themePath); extern theme_t themeCurrent; diff --git a/nx_main/main.c b/nx_main/main.c index 40a9600..a5da851 100644 --- a/nx_main/main.c +++ b/nx_main/main.c @@ -40,7 +40,7 @@ int main(int argc, char **argv) rc = plInitialize(); if (R_FAILED(rc)) fatalSimple(-6); - + themeStartup((ThemePreset)theme); textInit(); menuStartup();