NOT STABLE: attempting to write functions that copy themePath to and from settings.cfg file, keeps crashing rn for some reason though
This commit is contained in:
parent
e60156c34f
commit
5621fb460b
@ -55,25 +55,7 @@ void launchMenuBackTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void launchApplyThemeTask(menuEntry_s* arg) {
|
void launchApplyThemeTask(menuEntry_s* arg) {
|
||||||
config_t cfg = {0};
|
//SetThemePathToConfig(arg->path);
|
||||||
config_init(&cfg);
|
|
||||||
|
|
||||||
if(!config_read_file(&cfg, arg->path)) {
|
|
||||||
menuCreateMsgBox(780, 300, "Something went wrong, and the theme could not be loaded!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char tmp_path[PATH_MAX] = {0};
|
|
||||||
#ifdef __SWITCH__
|
|
||||||
tmp_path[0] = '/';
|
|
||||||
#endif
|
|
||||||
|
|
||||||
strncat(tmp_path, "config/nx-hbmenu/theme.cfg", sizeof(tmp_path)-2);
|
|
||||||
if(!config_write_file(&cfg, tmp_path)) {
|
|
||||||
menuCreateMsgBox(780, 300, "Something went wrong, and the theme could not be applied!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
config_destroy(&cfg);
|
|
||||||
themeStartup(themeGlobalPreset);
|
themeStartup(themeGlobalPreset);
|
||||||
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
||||||
}
|
}
|
||||||
|
@ -54,16 +54,12 @@ void themeStartup(ThemePreset preset) {
|
|||||||
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
||||||
};
|
};
|
||||||
|
|
||||||
char tmp_path[PATH_MAX] = {0};
|
config_t themeCfg = {0};
|
||||||
|
config_setting_t *setting;
|
||||||
#ifdef __SWITCH__
|
config_init(&themeCfg);
|
||||||
tmp_path[0] = '/';
|
|
||||||
#endif
|
|
||||||
const char* themePath = "";
|
const char* themePath = "";
|
||||||
config_t thmPthCfg = {0};
|
//GetThemePathFromConfig(themeCfg, setting, themePath);
|
||||||
config_init(&thmPthCfg);
|
|
||||||
GetThemePathFromConfig(thmPthCfg, themePath);
|
|
||||||
strncat(tmp_path, "config/nx-hbmenu/theme.cfg", sizeof(tmp_path)-2);
|
|
||||||
|
|
||||||
theme_t *themeDefault;
|
theme_t *themeDefault;
|
||||||
config_t cfg = {0};
|
config_t cfg = {0};
|
||||||
@ -72,7 +68,8 @@ void themeStartup(ThemePreset preset) {
|
|||||||
color_t text, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor;
|
color_t text, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor;
|
||||||
int waveBlending;
|
int waveBlending;
|
||||||
const char *AText, *BText;
|
const char *AText, *BText;
|
||||||
bool good_cfg = config_read_file(&cfg, tmp_path);
|
bool good_cfg = config_read_file(&cfg, themePath);
|
||||||
|
config_destroy(&themeCfg);
|
||||||
|
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case THEME_PRESET_LIGHT:
|
case THEME_PRESET_LIGHT:
|
||||||
@ -141,18 +138,42 @@ void themeStartup(ThemePreset preset) {
|
|||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetThemePathFromConfig(config_t cfg, config_setting_t *setting, const char* themePath) {
|
||||||
void GetThemePathFromConfig(config_t cfg, const char* path){
|
|
||||||
char tmp_path[PATH_MAX] = {0};
|
char tmp_path[PATH_MAX] = {0};
|
||||||
config_setting_t *setting;
|
|
||||||
|
|
||||||
#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/setting.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) {
|
||||||
config_setting_lookup_string(theme, "themePath", &path);
|
setting = config_lookup(&cfg, "themePath");
|
||||||
|
config_setting_lookup_string(setting, "themePath", &themePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetThemePathToConfig(const char* themePath) {
|
||||||
|
config_t cfg = {0};
|
||||||
|
config_init(&cfg);
|
||||||
|
|
||||||
|
char tmp_path[PATH_MAX] = {0};
|
||||||
|
config_setting_t *root,*group, *setting;
|
||||||
|
|
||||||
|
#ifdef __SWITCH__
|
||||||
|
tmp_path[0] = '/';
|
||||||
|
#endif
|
||||||
|
|
||||||
|
strncat(tmp_path, "config/nx-hbmenu/setting.cfg", sizeof(tmp_path)-2);
|
||||||
|
root = config_root_setting(&cfg);
|
||||||
|
group = config_setting_add(root, "hbmenuConfig", CONFIG_TYPE_GROUP);
|
||||||
|
setting = config_setting_add(group, "themePath", CONFIG_TYPE_STRING);
|
||||||
|
config_setting_set_string(setting, themePath);
|
||||||
|
|
||||||
|
if(!config_write_file(&cfg, tmp_path)) {
|
||||||
|
menuCreateMsgBox(780, 300, "Something went wrong, and the theme could not be applied!");
|
||||||
|
}
|
||||||
|
|
||||||
|
config_destroy(&cfg);
|
||||||
|
}
|
@ -29,8 +29,9 @@ typedef enum
|
|||||||
} ThemePreset;
|
} ThemePreset;
|
||||||
|
|
||||||
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(config_t cfg, config_setting_t *setting, const char* themePath);
|
||||||
|
void SetThemePathToConfig(const char* themePath);
|
||||||
|
|
||||||
extern theme_t themeCurrent;
|
extern theme_t themeCurrent;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user