added functions to create/modify settings config for hbmenu theme
This commit is contained in:
parent
19ea89c4de
commit
1d9ef3b9de
@ -320,7 +320,7 @@ const char* const g_strings[StrId_Max][16] =
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
[StrId_Actions_Theme_Menu] =
|
[StrId_ThemeMenu] =
|
||||||
{
|
{
|
||||||
STR_EN("Theme Menu"),
|
STR_EN("Theme Menu"),
|
||||||
STR_ES("Menú temático"),
|
STR_ES("Menú temático"),
|
||||||
@ -887,4 +887,3 @@ const char* const g_strings[StrId_Max][16] =
|
|||||||
),
|
),
|
||||||
},*/
|
},*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ typedef enum
|
|||||||
StrId_NetLoaderActive,
|
StrId_NetLoaderActive,
|
||||||
StrId_NetLoaderTransferring,
|
StrId_NetLoaderTransferring,
|
||||||
|
|
||||||
StrId_Actions_Theme_Menu,
|
StrId_ThemeMenu,
|
||||||
|
|
||||||
StrId_Max,
|
StrId_Max,
|
||||||
} StrId;
|
} StrId;
|
||||||
|
@ -56,7 +56,7 @@ void launchMenuBackTask() {
|
|||||||
|
|
||||||
void launchApplyThemeTask(menuEntry_s* arg) {
|
void launchApplyThemeTask(menuEntry_s* arg) {
|
||||||
const char* themePath = removeDriveFromPath(arg->path);
|
const char* themePath = removeDriveFromPath(arg->path);
|
||||||
//SetThemePathToConfig(themePath);
|
SetThemePathToConfig(themePath);
|
||||||
themeStartup(themeGlobalPreset);
|
themeStartup(themeGlobalPreset);
|
||||||
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
||||||
}
|
}
|
||||||
@ -479,8 +479,8 @@ void menuLoop() {
|
|||||||
|
|
||||||
if(active_entry != NULL) {
|
if(active_entry != NULL) {
|
||||||
if (active_entry->type == ENTRY_TYPE_THEME) {
|
if (active_entry->type == ENTRY_TYPE_THEME) {
|
||||||
int getX = GetTextXCoordinate(interuiregular18, 1180, textGetString(StrId_Actions_Theme_Menu), 'r');
|
int getX = GetTextXCoordinate(interuiregular18, 1180, textGetString(StrId_ThemeMenu), 'r');
|
||||||
DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_Actions_Theme_Menu));
|
DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_ThemeMenu));
|
||||||
DrawText(fontscale7, 1280 - 126 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, themeCurrent.buttonAText);
|
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));
|
DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Apply));
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,12 @@ void themeStartup(ThemePreset preset) {
|
|||||||
//.buttonBImage = button_b_dark_bin,
|
//.buttonBImage = button_b_dark_bin,
|
||||||
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const char* themePath = "";
|
const char* themePath = "";
|
||||||
GetThemePathFromConfig(themePath);
|
config_t themeCfg = {0};
|
||||||
|
config_setting_t *setting;
|
||||||
|
config_init(&themeCfg);
|
||||||
|
GetThemePathFromConfig(themeCfg, setting, &themePath);
|
||||||
|
|
||||||
theme_t *themeDefault;
|
theme_t *themeDefault;
|
||||||
config_t cfg = {0};
|
config_t cfg = {0};
|
||||||
@ -67,6 +68,7 @@ void themeStartup(ThemePreset preset) {
|
|||||||
int waveBlending;
|
int waveBlending;
|
||||||
const char *AText, *BText;
|
const char *AText, *BText;
|
||||||
bool good_cfg = config_read_file(&cfg, themePath);
|
bool good_cfg = config_read_file(&cfg, themePath);
|
||||||
|
config_destroy(&themeCfg);
|
||||||
|
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case THEME_PRESET_LIGHT:
|
case THEME_PRESET_LIGHT:
|
||||||
@ -135,25 +137,22 @@ void themeStartup(ThemePreset preset) {
|
|||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetThemePathFromConfig(const char* themePath) {
|
void GetThemePathFromConfig(config_t cfg, config_setting_t *setting, const char** themePath) {
|
||||||
config_t cfg = {0};
|
|
||||||
config_setting_t *setting;
|
|
||||||
config_init(&cfg);
|
|
||||||
|
|
||||||
char tmp_path[PATH_MAX] = {0};
|
char tmp_path[PATH_MAX] = {0};
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
tmp_path[0] = '/';
|
tmp_path[0] = '/';
|
||||||
#endif
|
#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);
|
bool good_cfg = config_read_file(&cfg, tmp_path);
|
||||||
|
|
||||||
if(good_cfg) {
|
if(good_cfg) {
|
||||||
setting = config_lookup(&cfg, "themePath");
|
setting = config_lookup(&cfg, "hbmenuConfig");
|
||||||
config_setting_lookup_string(setting, "themePath", &themePath);
|
if(setting != NULL){
|
||||||
|
config_setting_lookup_string(setting, "themePath", themePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
config_destroy(&cfg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetThemePathToConfig(const char* themePath) {
|
void SetThemePathToConfig(const char* themePath) {
|
||||||
@ -167,7 +166,8 @@ void SetThemePathToConfig(const char* themePath) {
|
|||||||
settingPath[0] = '/';
|
settingPath[0] = '/';
|
||||||
#endif
|
#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);
|
root = config_root_setting(&cfg);
|
||||||
group = config_setting_add(root, "hbmenuConfig", CONFIG_TYPE_GROUP);
|
group = config_setting_add(root, "hbmenuConfig", CONFIG_TYPE_GROUP);
|
||||||
setting = config_setting_add(group, "themePath", CONFIG_TYPE_STRING);
|
setting = config_setting_add(group, "themePath", CONFIG_TYPE_STRING);
|
||||||
|
@ -30,7 +30,7 @@ typedef enum
|
|||||||
|
|
||||||
bool colorFromSetting(config_setting_t *rgba, color_t *col);
|
bool colorFromSetting(config_setting_t *rgba, color_t *col);
|
||||||
void themeStartup(ThemePreset preset);
|
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);
|
void SetThemePathToConfig(const char* themePath);
|
||||||
|
|
||||||
extern theme_t themeCurrent;
|
extern theme_t themeCurrent;
|
||||||
|
@ -40,7 +40,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
rc = plInitialize();
|
rc = plInitialize();
|
||||||
if (R_FAILED(rc)) fatalSimple(-6);
|
if (R_FAILED(rc)) fatalSimple(-6);
|
||||||
|
|
||||||
themeStartup((ThemePreset)theme);
|
themeStartup((ThemePreset)theme);
|
||||||
textInit();
|
textInit();
|
||||||
menuStartup();
|
menuStartup();
|
||||||
|
Loading…
Reference in New Issue
Block a user