Hopefully removed all the duplicate code
This commit is contained in:
parent
ca6a2ad810
commit
e42df316d7
124
common/theme.c
124
common/theme.c
@ -44,6 +44,7 @@ void themeStartup(ThemePreset preset) {
|
|||||||
//.buttonBImage = button_b_dark_bin,
|
//.buttonBImage = button_b_dark_bin,
|
||||||
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
||||||
};
|
};
|
||||||
|
theme_t *themeDefault;
|
||||||
config_t *cfg = NULL;
|
config_t *cfg = NULL;
|
||||||
cfg = (config_t *) malloc(sizeof(config_t));
|
cfg = (config_t *) malloc(sizeof(config_t));
|
||||||
config_init(cfg);
|
config_init(cfg);
|
||||||
@ -54,83 +55,58 @@ void themeStartup(ThemePreset preset) {
|
|||||||
bool good_cfg=config_read_file(cfg, "/hbtheme.cfg");
|
bool good_cfg=config_read_file(cfg, "/hbtheme.cfg");
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case THEME_PRESET_LIGHT:
|
case THEME_PRESET_LIGHT:
|
||||||
if (good_cfg) {
|
themeDefault = &themeLight;
|
||||||
theme=config_lookup(cfg, "lightTheme");
|
if (good_cfg)
|
||||||
if (theme != NULL) {
|
theme = config_lookup(cfg, "lightTheme");
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.textColor"), &text))
|
|
||||||
text = themeLight.textColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.frontWaveColor"), &frontWave))
|
|
||||||
frontWave = themeLight.frontWaveColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.middleWaveColor"), &middleWave))
|
|
||||||
middleWave = themeLight.middleWaveColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.backWaveColor"), &backWave))
|
|
||||||
backWave = themeLight.backWaveColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.backgroundColor"), &background))
|
|
||||||
background = themeLight.backgroundColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.highlightColor"), &highlight))
|
|
||||||
highlight = themeLight.highlightColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "lightTheme.separatorColor"), &separator))
|
|
||||||
separator = themeLight.separatorColor;
|
|
||||||
if (!config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending))
|
|
||||||
waveBlending = themeLight.enableWaveBlending;
|
|
||||||
if (!config_setting_lookup_string(theme, "buttonAText", &AText))
|
|
||||||
AText = themeLight.buttonAText;
|
|
||||||
if (!config_setting_lookup_string(theme, "buttonBText", &BText))
|
|
||||||
BText = themeLight.buttonBText;
|
|
||||||
} else {
|
|
||||||
themeCurrent=themeLight;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
themeCurrent=themeLight;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THEME_PRESET_DARK:
|
case THEME_PRESET_DARK:
|
||||||
if (good_cfg) {
|
themeDefault = &themeDark;
|
||||||
theme=config_lookup(cfg, "darkTheme");
|
if (good_cfg)
|
||||||
if (theme != NULL) {
|
theme = config_lookup(cfg, "darkTheme");
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.textColor"), &text))
|
|
||||||
text = themeDark.textColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.frontWaveColor"), &frontWave))
|
|
||||||
frontWave = themeDark.frontWaveColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.middleWaveColor"), &middleWave))
|
|
||||||
middleWave = themeDark.middleWaveColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.backWaveColor"), &backWave))
|
|
||||||
backWave = themeDark.backWaveColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.backgroundColor"), &background))
|
|
||||||
background = themeDark.backgroundColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.highlightColor"), &highlight))
|
|
||||||
highlight = themeDark.highlightColor;
|
|
||||||
if (!colorFromSetting(config_lookup(cfg, "darkTheme.separatorColor"), &separator))
|
|
||||||
separator = themeDark.separatorColor;
|
|
||||||
if (!config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending))
|
|
||||||
waveBlending = themeDark.enableWaveBlending;
|
|
||||||
if (!config_setting_lookup_string(theme, "buttonAText", &AText))
|
|
||||||
AText = themeDark.buttonAText;
|
|
||||||
if (!config_setting_lookup_string(theme, "buttonBText", &BText))
|
|
||||||
BText = themeDark.buttonBText;
|
|
||||||
} else {
|
|
||||||
themeCurrent=themeDark;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
themeCurrent=themeDark;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (good_cfg)
|
if (good_cfg){
|
||||||
themeCurrent = (theme_t) {
|
if (theme !=NULL){
|
||||||
.textColor = text,
|
if (!colorFromSetting(config_setting_lookup(theme, "textColor"), &text))
|
||||||
.frontWaveColor = frontWave,
|
text = themeDefault->textColor;
|
||||||
.middleWaveColor = middleWave,
|
if (!colorFromSetting(config_setting_lookup(theme, "frontWaveColor"), &frontWave))
|
||||||
.backWaveColor = backWave,
|
frontWave = themeDefault->frontWaveColor;
|
||||||
.backgroundColor = background,
|
if (!colorFromSetting(config_setting_lookup(theme, "middleWaveColor"), &middleWave))
|
||||||
.highlightColor = highlight,
|
middleWave = themeDefault->middleWaveColor;
|
||||||
.separatorColor = separator,
|
if (!colorFromSetting(config_setting_lookup(theme, "backWaveColor"), &backWave))
|
||||||
.enableWaveBlending = waveBlending,
|
backWave = themeDefault->backWaveColor;
|
||||||
.buttonAText = AText,
|
if (!colorFromSetting(config_setting_lookup(theme, "backgroundColor"), &background))
|
||||||
.buttonBText = BText,
|
background = themeDefault->backgroundColor;
|
||||||
//.buttonAImage = button_a_dark_bin,
|
if (!colorFromSetting(config_setting_lookup(theme, "highlightColor"), &highlight))
|
||||||
//.buttonBImage = button_b_dark_bin,
|
highlight = themeDefault->highlightColor;
|
||||||
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
if (!colorFromSetting(config_setting_lookup(theme, "separatorColor"), &separator))
|
||||||
};
|
separator = themeDefault->separatorColor;
|
||||||
|
if (!config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending))
|
||||||
|
waveBlending = themeDefault->enableWaveBlending;
|
||||||
|
if (!config_setting_lookup_string(theme, "buttonAText", &AText))
|
||||||
|
AText = themeDefault->buttonAText;
|
||||||
|
if (!config_setting_lookup_string(theme, "buttonBText", &BText))
|
||||||
|
BText = themeDefault->buttonBText;
|
||||||
|
themeCurrent = (theme_t) {
|
||||||
|
.textColor = text,
|
||||||
|
.frontWaveColor = frontWave,
|
||||||
|
.middleWaveColor = middleWave,
|
||||||
|
.backWaveColor = backWave,
|
||||||
|
.backgroundColor = background,
|
||||||
|
.highlightColor = highlight,
|
||||||
|
.separatorColor = separator,
|
||||||
|
.enableWaveBlending = waveBlending,
|
||||||
|
.buttonAText = AText,
|
||||||
|
.buttonBText = BText,
|
||||||
|
//.buttonAImage = button_a_dark_bin,
|
||||||
|
//.buttonBImage = button_b_dark_bin,
|
||||||
|
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
themeCurrent = *themeDefault;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
themeCurrent = *themeDefault;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user