mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 01:03:41 +01:00
UI: Allow overriding colors in the ini.
This commit is contained in:
1 parent
755429df81
commit
c9a5c00bf7
3 files changed
+132
-38
No files matched your search
+68
-7
@@ -63,65 +63,77 @@ struct ConfigSetting {
|
||||
TYPE_TERMINATOR,
|
||||
TYPE_BOOL,
|
||||
TYPE_INT,
|
||||
TYPE_UINT32,
|
||||
TYPE_FLOAT,
|
||||
TYPE_STRING,
|
||||
};
|
||||
union Value {
|
||||
bool b;
|
||||
int i;
|
||||
uint32_t u;
|
||||
float f;
|
||||
const char *s;
|
||||
};
|
||||
union SettingPtr {
|
||||
bool *b;
|
||||
int *i;
|
||||
uint32_t *u;
|
||||
float *f;
|
||||
std::string *s;
|
||||
};
|
||||
|
||||
typedef bool (*BoolDefaultCallback)();
|
||||
typedef int (*IntDefaultCallback)();
|
||||
typedef uint32_t (*Uint32DefaultCallback)();
|
||||
typedef float (*FloatDefaultCallback)();
|
||||
typedef const char *(*StringDefaultCallback)();
|
||||
|
||||
union Callback {
|
||||
BoolDefaultCallback b;
|
||||
IntDefaultCallback i;
|
||||
Uint32DefaultCallback u;
|
||||
FloatDefaultCallback f;
|
||||
StringDefaultCallback s;
|
||||
};
|
||||
|
||||
ConfigSetting(bool v)
|
||||
: ini_(""), type_(TYPE_TERMINATOR), report_(false), save_(false), perGame_(false) {
|
||||
ptr_.b = NULL;
|
||||
cb_.b = NULL;
|
||||
ptr_.b = nullptr;
|
||||
cb_.b = nullptr;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, bool *v, bool def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_BOOL), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_.b = v;
|
||||
cb_.b = NULL;
|
||||
cb_.b = nullptr;
|
||||
default_.b = def;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, int *v, int def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_.i = v;
|
||||
cb_.i = NULL;
|
||||
cb_.i = nullptr;
|
||||
default_.i = def;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, uint32_t *v, uint32_t def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_UINT32), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_.u = v;
|
||||
cb_.u = nullptr;
|
||||
default_.u = def;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, float *v, float def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_FLOAT), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_.f = v;
|
||||
cb_.f = NULL;
|
||||
cb_.f = nullptr;
|
||||
default_.f = def;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, std::string *v, const char *def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_STRING), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_.s = v;
|
||||
cb_.s = NULL;
|
||||
cb_.s = nullptr;
|
||||
default_.s = def;
|
||||
}
|
||||
|
||||
@@ -133,10 +145,16 @@ struct ConfigSetting {
|
||||
|
||||
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_ .i= v;
|
||||
ptr_ .i = v;
|
||||
cb_.i = def;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, uint32_t *v, Uint32DefaultCallback def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_UINT32), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_ .u = v;
|
||||
cb_.u = def;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, float *v, FloatDefaultCallback def, bool save = true, bool perGame = false)
|
||||
: ini_(ini), type_(TYPE_FLOAT), report_(false), save_(save), perGame_(perGame) {
|
||||
ptr_.f = v;
|
||||
@@ -165,6 +183,11 @@ struct ConfigSetting {
|
||||
default_.i = cb_.i();
|
||||
}
|
||||
return section->Get(ini_, ptr_.i, default_.i);
|
||||
case TYPE_UINT32:
|
||||
if (cb_.u) {
|
||||
default_.u = cb_.u();
|
||||
}
|
||||
return section->Get(ini_, ptr_.u, default_.u);
|
||||
case TYPE_FLOAT:
|
||||
if (cb_.f) {
|
||||
default_.f = cb_.f();
|
||||
@@ -190,6 +213,8 @@ struct ConfigSetting {
|
||||
return section->Set(ini_, *ptr_.b);
|
||||
case TYPE_INT:
|
||||
return section->Set(ini_, *ptr_.i);
|
||||
case TYPE_UINT32:
|
||||
return section->Set(ini_, *ptr_.u);
|
||||
case TYPE_FLOAT:
|
||||
return section->Set(ini_, *ptr_.f);
|
||||
case TYPE_STRING:
|
||||
@@ -209,6 +234,8 @@ struct ConfigSetting {
|
||||
return data.Add(prefix + ini_, *ptr_.b);
|
||||
case TYPE_INT:
|
||||
return data.Add(prefix + ini_, *ptr_.i);
|
||||
case TYPE_UINT32:
|
||||
return data.Add(prefix + ini_, *ptr_.u);
|
||||
case TYPE_FLOAT:
|
||||
return data.Add(prefix + ini_, *ptr_.f);
|
||||
case TYPE_STRING:
|
||||
@@ -770,6 +797,39 @@ static ConfigSetting upgradeSettings[] = {
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
||||
static ConfigSetting themeSettings[] = {
|
||||
ConfigSetting("ItemStyleFg", &g_Config.uItemStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ItemStyleBg", &g_Config.uItemStyleBg, 0x55000000, true, false),
|
||||
ConfigSetting("ItemFocusedStyleFg", &g_Config.uItemFocusedStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ItemFocusedStyleBg", &g_Config.uItemFocusedStyleBg, 0xFFEDC24C, true, false),
|
||||
ConfigSetting("ItemDownStyleFg", &g_Config.uItemDownStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ItemDownStyleBg", &g_Config.uItemDownStyleBg, 0xFFBD9939, true, false),
|
||||
ConfigSetting("ItemDisabledStyleFg", &g_Config.uItemDisabledStyleFg, 0x80EEEEEE, true, false),
|
||||
ConfigSetting("ItemDisabledStyleBg", &g_Config.uItemDisabledStyleBg, 0x55E0D4AF, true, false),
|
||||
ConfigSetting("ItemHighlightedStyleFg", &g_Config.uItemHighlightedStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ItemHighlightedStyleBg", &g_Config.uItemHighlightedStyleBg, 0x55BDBB39, true, false),
|
||||
|
||||
ConfigSetting("ButtonStyleFg", &g_Config.uButtonStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ButtonStyleBg", &g_Config.uButtonStyleBg, 0x55000000, true, false),
|
||||
ConfigSetting("ButtonFocusedStyleFg", &g_Config.uButtonFocusedStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ButtonFocusedStyleBg", &g_Config.uButtonFocusedStyleBg, 0xFFEDC24C, true, false),
|
||||
ConfigSetting("ButtonDownStyleFg", &g_Config.uButtonDownStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ButtonDownStyleBg", &g_Config.uButtonDownStyleBg, 0xFFBD9939, true, false),
|
||||
ConfigSetting("ButtonDisabledStyleFg", &g_Config.uButtonDisabledStyleFg, 0x80EEEEEE, true, false),
|
||||
ConfigSetting("ButtonDisabledStyleBg", &g_Config.uButtonDisabledStyleBg, 0x55E0D4AF, true, false),
|
||||
ConfigSetting("ButtonHighlightedStyleFg", &g_Config.uButtonHighlightedStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("ButtonHighlightedStyleBg", &g_Config.uButtonHighlightedStyleBg, 0x55BDBB39, true, false),
|
||||
|
||||
ConfigSetting("HeaderStyleFg", &g_Config.uHeaderStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("InfoStyleFg", &g_Config.uInfoStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("InfoStyleBg", &g_Config.uInfoStyleBg, 0x00000000U, true, false),
|
||||
ConfigSetting("PopupTitleStyleFg", &g_Config.uPopupTitleStyleFg, 0xFFE3BE59, true, false),
|
||||
ConfigSetting("PopupStyleFg", &g_Config.uPopupStyleFg, 0xFFFFFFFF, true, false),
|
||||
ConfigSetting("PopupStyleBg", &g_Config.uPopupStyleBg, 0xFF303030, true, false),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
||||
static ConfigSectionSettings sections[] = {
|
||||
{"General", generalSettings},
|
||||
{"CPU", cpuSettings},
|
||||
@@ -782,6 +842,7 @@ static ConfigSectionSettings sections[] = {
|
||||
{"SpeedHacks", speedHackSettings},
|
||||
{"JIT", jitSettings},
|
||||
{"Upgrade", upgradeSettings},
|
||||
{"Theme", themeSettings},
|
||||
};
|
||||
|
||||
static void IterateSettings(IniFile &iniFile, std::function<void(IniFile::Section *section, ConfigSetting *setting)> func) {
|
||||
|
||||
@@ -235,6 +235,36 @@ public:
|
||||
bool bShowDebuggerOnLoad;
|
||||
int iShowFPSCounter;
|
||||
|
||||
// TODO: Maybe move to a separate theme system.
|
||||
uint32_t uItemStyleFg;
|
||||
uint32_t uItemStyleBg;
|
||||
uint32_t uItemFocusedStyleFg;
|
||||
uint32_t uItemFocusedStyleBg;
|
||||
uint32_t uItemDownStyleFg;
|
||||
uint32_t uItemDownStyleBg;
|
||||
uint32_t uItemDisabledStyleFg;
|
||||
uint32_t uItemDisabledStyleBg;
|
||||
uint32_t uItemHighlightedStyleFg;
|
||||
uint32_t uItemHighlightedStyleBg;
|
||||
|
||||
uint32_t uButtonStyleFg;
|
||||
uint32_t uButtonStyleBg;
|
||||
uint32_t uButtonFocusedStyleFg;
|
||||
uint32_t uButtonFocusedStyleBg;
|
||||
uint32_t uButtonDownStyleFg;
|
||||
uint32_t uButtonDownStyleBg;
|
||||
uint32_t uButtonDisabledStyleFg;
|
||||
uint32_t uButtonDisabledStyleBg;
|
||||
uint32_t uButtonHighlightedStyleFg;
|
||||
uint32_t uButtonHighlightedStyleBg;
|
||||
|
||||
uint32_t uHeaderStyleFg;
|
||||
uint32_t uInfoStyleFg;
|
||||
uint32_t uInfoStyleBg;
|
||||
uint32_t uPopupTitleStyleFg;
|
||||
uint32_t uPopupStyleFg;
|
||||
uint32_t uPopupStyleBg;
|
||||
|
||||
bool bLogFrameDrops;
|
||||
bool bShowDebugStats;
|
||||
bool bShowAudioDebug;
|
||||
|
||||
+34
-31
@@ -534,18 +534,15 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
}
|
||||
}
|
||||
|
||||
void NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
ILOG("NativeInitGraphics");
|
||||
static UI::Style MakeStyle(uint32_t fg, uint32_t bg) {
|
||||
UI::Style s;
|
||||
s.background = UI::Drawable(bg);
|
||||
s.fgColor = fg;
|
||||
|
||||
using namespace Draw;
|
||||
Core_SetGraphicsContext(graphicsContext);
|
||||
g_draw = graphicsContext->GetDrawContext();
|
||||
return s;
|
||||
}
|
||||
|
||||
ui_draw2d.SetAtlas(&ui_atlas);
|
||||
ui_draw2d_front.SetAtlas(&ui_atlas);
|
||||
|
||||
// memset(&ui_theme, 0, sizeof(ui_theme));
|
||||
// New style theme
|
||||
static void UIThemeInit() {
|
||||
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
||||
ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22);
|
||||
ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15);
|
||||
@@ -562,30 +559,36 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
ui_theme.sliderKnob = I_CIRCLE;
|
||||
ui_theme.dropShadow4Grid = I_DROP_SHADOW;
|
||||
|
||||
ui_theme.itemStyle.background = UI::Drawable(0x55000000);
|
||||
ui_theme.itemStyle.fgColor = 0xFFFFFFFF;
|
||||
ui_theme.itemFocusedStyle.background = UI::Drawable(0xFFedc24c);
|
||||
ui_theme.itemFocusedStyle.fgColor = ui_theme.itemStyle.fgColor;
|
||||
ui_theme.itemDownStyle.background = UI::Drawable(0xFFbd9939);
|
||||
ui_theme.itemDownStyle.fgColor = 0xFFFFFFFF;
|
||||
ui_theme.itemDisabledStyle.background = UI::Drawable(0x55E0D4AF);
|
||||
ui_theme.itemDisabledStyle.fgColor = 0x80EEEEEE;
|
||||
ui_theme.itemHighlightedStyle.background = UI::Drawable(0x55bdBB39);
|
||||
ui_theme.itemHighlightedStyle.fgColor = 0xFFFFFFFF;
|
||||
ui_theme.itemStyle = MakeStyle(g_Config.uItemStyleFg, g_Config.uItemStyleBg);
|
||||
ui_theme.itemFocusedStyle = MakeStyle(g_Config.uItemFocusedStyleFg, g_Config.uItemFocusedStyleBg);
|
||||
ui_theme.itemDownStyle = MakeStyle(g_Config.uItemDownStyleFg, g_Config.uItemDownStyleBg);
|
||||
ui_theme.itemDisabledStyle = MakeStyle(g_Config.uItemDisabledStyleFg, g_Config.uItemDisabledStyleBg);
|
||||
ui_theme.itemHighlightedStyle = MakeStyle(g_Config.uItemHighlightedStyleFg, g_Config.uItemHighlightedStyleBg);
|
||||
|
||||
ui_theme.buttonStyle = ui_theme.itemStyle;
|
||||
ui_theme.buttonFocusedStyle = ui_theme.itemFocusedStyle;
|
||||
ui_theme.buttonDownStyle = ui_theme.itemDownStyle;
|
||||
ui_theme.buttonDisabledStyle = ui_theme.itemDisabledStyle;
|
||||
ui_theme.buttonHighlightedStyle = ui_theme.itemHighlightedStyle;
|
||||
ui_theme.buttonStyle = MakeStyle(g_Config.uButtonStyleFg, g_Config.uButtonStyleBg);
|
||||
ui_theme.buttonFocusedStyle = MakeStyle(g_Config.uButtonFocusedStyleFg, g_Config.uButtonFocusedStyleBg);
|
||||
ui_theme.buttonDownStyle = MakeStyle(g_Config.uButtonDownStyleFg, g_Config.uButtonDownStyleBg);
|
||||
ui_theme.buttonDisabledStyle = MakeStyle(g_Config.uButtonDisabledStyleFg, g_Config.uButtonDisabledStyleBg);
|
||||
ui_theme.buttonHighlightedStyle = MakeStyle(g_Config.uButtonHighlightedStyleFg, g_Config.uButtonHighlightedStyleBg);
|
||||
|
||||
ui_theme.headerStyle.fgColor = 0xFFFFFFFF;
|
||||
ui_theme.infoStyle.fgColor = 0xFFFFFFFF;
|
||||
ui_theme.infoStyle.background = UI::Drawable(0x00000000);
|
||||
ui_theme.headerStyle.fgColor = g_Config.uHeaderStyleFg;
|
||||
ui_theme.infoStyle = MakeStyle(g_Config.uInfoStyleFg, g_Config.uInfoStyleBg);
|
||||
|
||||
ui_theme.popupTitle.fgColor = 0xFFE3BE59;
|
||||
ui_theme.popupStyle.fgColor = 0xFFFFFFFF;
|
||||
ui_theme.popupStyle.background = UI::Drawable(0xFF303030);
|
||||
ui_theme.popupTitle.fgColor = g_Config.uPopupTitleStyleFg;
|
||||
ui_theme.popupStyle = MakeStyle(g_Config.uPopupStyleFg, g_Config.uPopupStyleBg);
|
||||
}
|
||||
|
||||
void NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
ILOG("NativeInitGraphics");
|
||||
|
||||
using namespace Draw;
|
||||
Core_SetGraphicsContext(graphicsContext);
|
||||
g_draw = graphicsContext->GetDrawContext();
|
||||
|
||||
ui_draw2d.SetAtlas(&ui_atlas);
|
||||
ui_draw2d_front.SetAtlas(&ui_atlas);
|
||||
|
||||
UIThemeInit();
|
||||
|
||||
uiTexture = CreateTextureFromFile(g_draw, "ui_atlas.zim", ImageFileType::ZIM);
|
||||
if (!uiTexture) {
|
||||
|
||||
Reference in new issue
Block a user