Implement theming and fix spelling errors
Now requires libconfig "separator" was spelled "seperator"
This commit is contained in:
parent
4987cbddb1
commit
d9ba481844
@ -53,7 +53,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := `freetype-config --libs`
|
||||
LIBS := `freetype-config --libs` -lconfig
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
@ -26,7 +26,7 @@ test : pc_main/main.cpp pc_main/pc_launch.c \
|
||||
build_pc/invalid_icon.bin.o build_pc/folder_icon.bin.o \
|
||||
build_pc/hbmenu_logo_light.bin.o build_pc/hbmenu_logo_dark.bin.o \
|
||||
#build_pc/tahoma24.o build_pc/tahoma12.o build_pc/interuimedium20.o build_pc/interuimedium30.o build_pc/interuiregular14.o build_pc/interuiregular18.o
|
||||
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `pkg-config freetype2 --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ `pkg-config freetype2 --libs` -lm -lz $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@
|
||||
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `pkg-config freetype2 --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ `pkg-config freetype2 --libs` -lm -lz -lconfig $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@
|
||||
|
||||
build_pc/tahoma12.o : data/tahoma12.nxfnt
|
||||
mkdir -p $(dir $@)
|
||||
|
@ -58,7 +58,7 @@ void drawMsgBoxBgToBuff(color_t *buff, int width, int height) {
|
||||
color = base_color;
|
||||
|
||||
if (y == height - 80) {
|
||||
color = themeCurrent.seperatorColor;
|
||||
color = themeCurrent.separatorColor;
|
||||
}
|
||||
|
||||
off = (y * width + x);
|
||||
|
@ -6,9 +6,54 @@
|
||||
#include "hbmenu_logo_light_bin.h"
|
||||
#include "hbmenu_logo_dark_bin.h"
|
||||
|
||||
color_t colorFromSetting(config_setting_t *rgba) {
|
||||
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) {
|
||||
config_t *cfg = NULL;
|
||||
cfg = (config_t *) malloc(sizeof(config_t));
|
||||
config_init(cfg);
|
||||
config_setting_t *theme;
|
||||
color_t text, frontWave, middleWave, backWave, background, highlight, separator;
|
||||
int waveBlending;
|
||||
const char *AText, *BText;
|
||||
bool good_cfg=false;
|
||||
switch (preset) {
|
||||
case THEME_PRESET_LIGHT:
|
||||
if (config_read_file(cfg, "/hbtheme.cfg")) {
|
||||
theme=config_lookup(cfg, "lightTheme");
|
||||
if (theme != NULL) {
|
||||
text = colorFromSetting(config_lookup(cfg, "lightTheme.textColor"));
|
||||
frontWave = colorFromSetting(config_lookup(cfg, "lightTheme.frontWaveColor"));
|
||||
middleWave = colorFromSetting(config_lookup(cfg, "lightTheme.middleWaveColor"));
|
||||
backWave = colorFromSetting(config_lookup(cfg, "lightTheme.backWaveColor"));
|
||||
background = colorFromSetting(config_lookup(cfg, "lightTheme.backgroundColor"));
|
||||
highlight = colorFromSetting(config_lookup(cfg, "lightTheme.highlightColor"));
|
||||
separator = colorFromSetting(config_lookup(cfg, "lightTheme.separatorColor"));
|
||||
good_cfg = config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending);
|
||||
good_cfg = good_cfg && config_setting_lookup_string(theme, "buttonAText", &AText);
|
||||
good_cfg = good_cfg && config_setting_lookup_string(theme, "buttonBText", &BText);
|
||||
}
|
||||
}
|
||||
if (good_cfg) {
|
||||
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_light_bin,
|
||||
//.buttonBImage = button_b_light_bin,
|
||||
.hbmenuLogoImage = hbmenu_logo_light_bin
|
||||
};
|
||||
} else {
|
||||
themeCurrent = (theme_t) {
|
||||
.textColor = MakeColor(0, 0, 0, 255),
|
||||
.frontWaveColor = MakeColor(100, 212, 250, 255),
|
||||
@ -16,7 +61,7 @@ void themeStartup(ThemePreset preset) {
|
||||
.backWaveColor = MakeColor(154, 171, 255, 255),
|
||||
.backgroundColor = MakeColor(233, 236, 241, 255),
|
||||
.highlightColor = MakeColor(91, 237, 224, 255),
|
||||
.seperatorColor = MakeColor(219, 218, 219, 255),
|
||||
.separatorColor = MakeColor(219, 218, 219, 255),
|
||||
.enableWaveBlending = 0,
|
||||
.buttonAText = "\uE0E0",
|
||||
.buttonBText = "\uE0E1",
|
||||
@ -24,9 +69,42 @@ void themeStartup(ThemePreset preset) {
|
||||
//.buttonBImage = button_b_light_bin,
|
||||
.hbmenuLogoImage = hbmenu_logo_light_bin
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
||||
case THEME_PRESET_DARK:
|
||||
if (config_read_file(cfg, "/hbtheme.cfg")) {
|
||||
theme=config_lookup(cfg, "darkTheme");
|
||||
if (theme != NULL) {
|
||||
text = colorFromSetting(config_lookup(cfg, "darkTheme.textColor"));
|
||||
frontWave = colorFromSetting(config_lookup(cfg, "darkTheme.frontWaveColor"));
|
||||
middleWave = colorFromSetting(config_lookup(cfg, "darkTheme.middleWaveColor"));
|
||||
backWave = colorFromSetting(config_lookup(cfg, "darkTheme.backWaveColor"));
|
||||
background = colorFromSetting(config_lookup(cfg, "darkTheme.backgroundColor"));
|
||||
highlight = colorFromSetting(config_lookup(cfg, "darkTheme.highlightColor"));
|
||||
separator = colorFromSetting(config_lookup(cfg, "darkTheme.separatorColor"));
|
||||
good_cfg = config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending);
|
||||
good_cfg = good_cfg && config_setting_lookup_string(theme, "buttonAText", &AText);
|
||||
good_cfg = good_cfg && config_setting_lookup_string(theme, "buttonBText", &BText);
|
||||
}
|
||||
}
|
||||
if (good_cfg) {
|
||||
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 = (theme_t) {
|
||||
.textColor = MakeColor(255, 255, 255, 255),
|
||||
.frontWaveColor = MakeColor(96, 204, 204, 255),
|
||||
@ -34,7 +112,7 @@ void themeStartup(ThemePreset preset) {
|
||||
.backWaveColor = MakeColor(73, 103, 169, 255),
|
||||
.backgroundColor = MakeColor(45, 45, 50, 255),
|
||||
.highlightColor = MakeColor(91, 237, 224, 255),
|
||||
.seperatorColor = MakeColor(219, 218, 219, 255),
|
||||
.separatorColor = MakeColor(219, 218, 219, 255),
|
||||
.enableWaveBlending = 0,
|
||||
.buttonAText = "\uE0A0",
|
||||
.buttonBText = "\uE0A1",
|
||||
@ -42,6 +120,7 @@ void themeStartup(ThemePreset preset) {
|
||||
//.buttonBImage = button_b_dark_bin,
|
||||
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include <libconfig.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -10,7 +11,7 @@ typedef struct
|
||||
color_t backWaveColor;
|
||||
color_t backgroundColor;
|
||||
color_t highlightColor;
|
||||
color_t seperatorColor;
|
||||
color_t separatorColor;
|
||||
color_t activeColor;
|
||||
bool enableWaveBlending;
|
||||
const char *buttonAText;
|
||||
@ -26,6 +27,7 @@ typedef enum
|
||||
THEME_PRESET_DARK,
|
||||
} ThemePreset;
|
||||
|
||||
color_t colorFromSetting(config_setting_t *rgba);
|
||||
void themeStartup(ThemePreset preset);
|
||||
|
||||
theme_t themeCurrent;
|
||||
|
Loading…
Reference in New Issue
Block a user