mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Use hashtag for RGBA format
This commit is contained in:
@@ -63,7 +63,7 @@ bool ParseMacAddress(std::string str, uint8_t macAddr[6]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TryParse(const std::string &str, uint32_t *const output) {
|
||||
static bool ParseUnsigned32(const std::string &str, uint32_t *const output) {
|
||||
char *endptr = NULL;
|
||||
|
||||
// Holy crap this is ugly.
|
||||
@@ -93,6 +93,25 @@ bool TryParse(const std::string &str, uint32_t *const output) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TryParse(const std::string &str, uint32_t *const output) {
|
||||
if (str[0] != '#') {
|
||||
return ParseUnsigned32(str, output);
|
||||
} else {
|
||||
// Parse it as "#RGBA" and convert to a ABGR interger
|
||||
std::string s = ReplaceAll(str, "#", "0x");
|
||||
if (ParseUnsigned32(s, output)) {
|
||||
int a = (*output >> 24) & 0xff;
|
||||
int b = (*output >> 16) & 0xff;
|
||||
int g = (*output >> 8) & 0xff;
|
||||
int r = *output & 0xff;
|
||||
*output = (r << 24) | (g << 16) | (b << 8) | a;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TryParse(const std::string &str, uint64_t *const output) {
|
||||
char *endptr = NULL;
|
||||
|
||||
|
||||
+8
-37
@@ -37,21 +37,21 @@ struct ThemeInfo {
|
||||
std::string name;
|
||||
|
||||
uint32_t uItemStyleFg = 0xFFFFFFFF;
|
||||
uint32_t uItemStyleBg = 0x00000055;
|
||||
uint32_t uItemStyleBg = 0x55000000;
|
||||
uint32_t uItemFocusedStyleFg = 0xFFFFFFFF;
|
||||
uint32_t uItemFocusedStyleBg = 0x4CC2EDFF;
|
||||
uint32_t uItemFocusedStyleBg = 0xFFEDC24C;
|
||||
uint32_t uItemDownStyleFg = 0xFFFFFFFF;
|
||||
uint32_t uItemDownStyleBg = 0x3999BDFF;
|
||||
uint32_t uItemDisabledStyleFg = 0xEEEEEE80;
|
||||
uint32_t uItemDisabledStyleBg = 0x00000055;
|
||||
uint32_t uItemDownStyleBg = 0xFFBD9939;
|
||||
uint32_t uItemDisabledStyleFg = 0x80EEEEEE;
|
||||
uint32_t uItemDisabledStyleBg = 0x55000000;
|
||||
|
||||
uint32_t uHeaderStyleFg = 0xFFFFFFFF;
|
||||
uint32_t uInfoStyleFg = 0xFFFFFFFF;
|
||||
uint32_t uInfoStyleBg = 0x00000000;
|
||||
uint32_t uPopupTitleStyleFg = 0x59BEE3FF;
|
||||
uint32_t uPopupTitleStyleFg = 0xFFE3BE59;
|
||||
uint32_t uPopupStyleFg = 0xFFFFFFFF;
|
||||
uint32_t uPopupStyleBg = 0x303030FF;
|
||||
uint32_t uBackgroundColor = 0x244D75FF;
|
||||
uint32_t uPopupStyleBg = 0xFF303030;
|
||||
uint32_t uBackgroundColor = 0xFF754D24;
|
||||
|
||||
std::string sUIAtlas = "ui_atlas";
|
||||
|
||||
@@ -69,38 +69,10 @@ static std::vector<ThemeInfo> themeInfos;
|
||||
static Atlas ui_atlas;
|
||||
static Atlas font_atlas;
|
||||
|
||||
static void FlipColorEndianess(ThemeInfo &info) {
|
||||
auto convert = [](uint32_t abgr) {
|
||||
int a = (abgr >> 24) & 0xff;
|
||||
int b = (abgr >> 16) & 0xff;
|
||||
int g = (abgr >> 8) & 0xff;
|
||||
int r = abgr & 0xff;
|
||||
return (r << 24) | (g << 16) | (b << 8) | a;
|
||||
};
|
||||
|
||||
info.uItemStyleFg = convert(info.uItemStyleFg);
|
||||
info.uItemStyleBg = convert(info.uItemStyleBg);
|
||||
info.uItemFocusedStyleFg = convert(info.uItemFocusedStyleFg);
|
||||
info.uItemFocusedStyleBg = convert(info.uItemFocusedStyleBg);
|
||||
info.uItemDownStyleFg = convert(info.uItemDownStyleFg);
|
||||
info.uItemDownStyleBg = convert(info.uItemDownStyleBg);
|
||||
info.uItemDisabledStyleFg = convert(info.uItemDisabledStyleFg);
|
||||
info.uItemDisabledStyleBg = convert(info.uItemDisabledStyleBg);
|
||||
|
||||
info.uHeaderStyleFg = convert(info.uHeaderStyleFg);
|
||||
info.uInfoStyleFg = convert(info.uInfoStyleFg);
|
||||
info.uInfoStyleBg = convert(info.uInfoStyleBg);
|
||||
info.uPopupTitleStyleFg = convert(info.uPopupTitleStyleFg);
|
||||
info.uPopupStyleFg = convert(info.uPopupStyleFg);
|
||||
info.uPopupStyleBg = convert(info.uPopupStyleBg);
|
||||
info.uBackgroundColor = convert(info.uBackgroundColor);
|
||||
}
|
||||
|
||||
static void LoadThemeInfo(const std::vector<Path> &directories) {
|
||||
themeInfos.clear();
|
||||
ThemeInfo def{};
|
||||
def.name = "Default";
|
||||
FlipColorEndianess(def);
|
||||
themeInfos.push_back(def);
|
||||
|
||||
// This will update the theme if already present, as such default in assets/theme will get priority if exist
|
||||
@@ -176,7 +148,6 @@ static void LoadThemeInfo(const std::vector<Path> &directories) {
|
||||
}
|
||||
}
|
||||
|
||||
FlipColorEndianess(info);
|
||||
appendTheme(info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
[Default]
|
||||
Name = Default
|
||||
ItemStyleFg = 0xFFFFFFFF
|
||||
ItemStyleBg = 0x00000055
|
||||
ItemFocusedStyleFg = 0xFFFFFFFF
|
||||
ItemFocusedStyleBg = 0x4CC2EDFF
|
||||
ItemDownStyleFg = 0xFFFFFFFF
|
||||
ItemDownStyleBg = 0x3999BDFF
|
||||
ItemDisabledStyleFg = 0xEEEEEE80
|
||||
ItemDisabledStyleBg = 0x00000055
|
||||
HeaderStyleFg = 0xFFFFFFFF
|
||||
InfoStyleFg = 0xFFFFFFFF
|
||||
InfoStyleBg = 0x00000000
|
||||
PopupTitleStyleFg = 0x59BEE3FF
|
||||
PopupStyleFg = 0xFFFFFFFF
|
||||
PopupStyleBg = 0x303030FF
|
||||
BackgroundColor = 0x244D75FF
|
||||
ItemStyleFg = \#FFFFFFFF
|
||||
ItemStyleBg = \#00000055
|
||||
ItemFocusedStyleFg = \#FFFFFFFF
|
||||
ItemFocusedStyleBg = \#4CC2EDFF
|
||||
ItemDownStyleFg = \#FFFFFFFF
|
||||
ItemDownStyleBg = \#3999BDFF
|
||||
ItemDisabledStyleFg = \#EEEEEE80
|
||||
ItemDisabledStyleBg = \#00000055
|
||||
HeaderStyleFg = \#FFFFFFFF
|
||||
InfoStyleFg = \#FFFFFFFF
|
||||
InfoStyleBg = \#00000000
|
||||
PopupTitleStyleFg = \#59BEE3FF
|
||||
PopupStyleFg = \#FFFFFFFF
|
||||
PopupStyleBg = \#303030FF
|
||||
BackgroundColor = \#244D75FF
|
||||
UIAtlas = ../ui_atlas
|
||||
|
||||
# Colors are in HEX RGBA
|
||||
# Colors are either in the format \#RGB or 0xABGR (e.g. green is \#00FF00FF or 0xFF00FF00)
|
||||
# Atlas should be in the format path/to/filename where both filename.zim and filename.meta are
|
||||
# Unprovided entry will use the default value
|
||||
Reference in New Issue
Block a user