-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Theming #57
Conversation
Now requires libconfig "separator" was spelled "seperator"
:D |
README.md
Outdated
#### Usage | ||
See [Homebrew_Applications](http://switchbrew.org/index.php?title=Homebrew_Applications) for SD layout and applications, etc. See [Switchbrew](http://switchbrew.org/index.php?title=Homebrew_Menu) for hbmenu docs. | ||
|
||
#### Download | ||
The latest release is available from the [releases](https://github.com/switchbrew/nx-hbmenu/releases/latest) page. | ||
The latest release is available from the [releases](https://github.com/friedkeenan/nx-hbmenu/releases/latest) page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert
Use same spacing style as elsewhere, not tabs. |
Settings not specified in the config should be loaded from the default theme config. |
README.md
Outdated
@@ -1,8 +1,11 @@ | |||
#### Theming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this too, can be moved to wiki later.
common/theme.c
Outdated
if(rgba==NULL) | ||
return MakeColor(128,0,128,255); | ||
return MakeColor(config_setting_get_int_elem(rgba, 0), config_setting_get_int_elem(rgba, 1), config_setting_get_int_elem(rgba, 2), config_setting_get_int_elem(rgba, 3)); | ||
} | ||
void themeStartup(ThemePreset preset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert newline
common/theme.c
Outdated
//.buttonBImage = button_b_light_bin, | ||
.hbmenuLogoImage = hbmenu_logo_light_bin | ||
}; | ||
} | ||
break; | ||
|
||
case THEME_PRESET_DARK: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate code, same code should be used for light/dark.
I tried to remove as much duplicate code as I think I can Also missing settings in the hbtheme.cfg file will now be supplemented by the default values
I'm sorry, I'm not sure what you mean. I get the colors and stuff from the default themes with the "{themename}." prefix, and I get the children from "theme" using the config functions because it's loaded from the config file. Do you want a default config file included? EDIT: Wait no, I get what you mean. use config_setting_lookup so I don't have to hardcode lightTheme and darkTheme |
README.md
Outdated
@@ -11,3 +11,4 @@ Build with ```make nx``` or just run ```make```. | |||
|
|||
* This uses code based on 3DS [new-hbmenu](https://github.com/fincs/new-hbmenu). | |||
* [nanojpeg](https://svn.emphy.de/nanojpeg/trunk/nanojpeg/nanojpeg.c) is used for handling JPEG icons. This library doesn't support lossless JPEG. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert
Looks better now. :) |
common/theme.c
Outdated
//.buttonBImage = button_b_light_bin, | ||
.hbmenuLogoImage = hbmenu_logo_light_bin | ||
}; | ||
theme_t themeDark = (theme_t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert newline
common/theme.c
Outdated
//.buttonBImage = button_b_dark_bin, | ||
.hbmenuLogoImage = hbmenu_logo_dark_bin | ||
}; | ||
theme_t *themeDefault; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert newline
common/theme.c
Outdated
color_t text, frontWave, middleWave, backWave, background, highlight, separator; | ||
int waveBlending; | ||
const char *AText, *BText; | ||
bool good_cfg=config_read_file(cfg, "/hbtheme.cfg"); | ||
switch (preset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert newline
common/theme.c
Outdated
//.buttonBImage = button_b_light_bin, | ||
.hbmenuLogoImage = hbmenu_logo_light_bin | ||
}; | ||
themeDefault = &themeLight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert: "default:"
common/theme.c
Outdated
theme = config_lookup(cfg, "darkTheme"); | ||
break; | ||
} | ||
if (good_cfg){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
") {"
The default case acts like the system theme is the dark one, because who really use the light theme?
Dang, didn't even know that was a thing |
common/theme.c
Outdated
}; | ||
|
||
theme_t *themeDefault; | ||
config_t *cfg = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store on stack. "config_t cfg = {0};"
Cleanup once finished using it via config_destory is also missing.
common/theme.c
Outdated
color_t text, frontWave, middleWave, backWave, background, highlight, separator; | ||
int waveBlending; | ||
const char *AText, *BText; | ||
bool good_cfg=config_read_file(&cfg, "/hbtheme.cfg"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spaces around =.
//.buttonBImage = button_b_dark_bin, | ||
.hbmenuLogoImage = hbmenu_logo_dark_bin | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add:
char tmp_path[PATH_MAX] = {0};
#ifdef __SWITCH__
tmp_path[0] = '/';
#endif
strncat(tmp_path, "config/nx-hbmenu/themes/theme.cfg", sizeof(tmp_path)-2);
Then use that string for config_read_file.
EDIT: code updated
Can you comment with a link to a gist which contains a sample cfg file, which can be moved to switchbrew later? |
https://gist.github.com/friedkeenan/14dec59d01410a7fcf40a324be70efcf I can add comments to give more information if you want |
ping @ code change |
It will load from "config/nx-hbmenu/themes/theme.cfg" if you're using the PC version
Yeah, I was just testing it and making sure I knew what the code was actually doing |
It looks good, except that if you comment out the enableWaveBlending line, it'll use the default, which is disabled, so you have to do |
fixed |
Looks fine now, thank you :) |
This fixes issue #6.
You can check out the binary and an example of a theme here.
Like the readme says, you just put the hbtheme.cfg file on the root of the SD card to use a theme. If there are any problems with that file or if it doesn't exist at all, it will just use the default themes.
My C knowledge is super shallow, and I'm not sure if my coding style matches up with yours all the time (I tried my best), so the code probably isn't that good, but it's something. You probably also want to move the theming info in the readme to http://switchbrew.org/index.php/Homebrew_Menu