added functions to create/modify settings config for hbmenu theme

This commit is contained in:
NightlyFox 2018-09-26 02:08:56 -05:00
parent 19ea89c4de
commit 1d9ef3b9de
6 changed files with 21 additions and 22 deletions

View File

@ -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] =
),
},*/
};

View File

@ -43,7 +43,7 @@ typedef enum
StrId_NetLoaderActive,
StrId_NetLoaderTransferring,
StrId_Actions_Theme_Menu,
StrId_ThemeMenu,
StrId_Max,
} StrId;

View File

@ -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));
}

View File

@ -54,10 +54,11 @@ void themeStartup(ThemePreset preset) {
.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);

View File

@ -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;