diff options
author | Nebuleon Fumika | 2013-05-20 00:46:43 -0400 |
---|---|---|
committer | Nebuleon Fumika | 2013-05-20 00:46:43 -0400 |
commit | 41c50b372e7819f447d98ed2737aefc72d5b864d (patch) | |
tree | fc48b6665c8fad469c96b61154ae0bfd536505e3 | |
parent | 22aa56d2ed0bb3640e3808577d63c082c6ae162c (diff) | |
download | snes9x2005-41c50b372e7819f447d98ed2737aefc72d5b864d.tar.gz snes9x2005-41c50b372e7819f447d98ed2737aefc72d5b864d.tar.bz2 snes9x2005-41c50b372e7819f447d98ed2737aefc72d5b864d.zip |
CATSFC/system/gui/uicolors.txt: Theme support for active and inactive item text colors.
-rw-r--r-- | CATSFC/system/gui/uicolors.txt | 2 | ||||
-rw-r--r-- | source/nds/draw.c | 51 | ||||
-rw-r--r-- | source/nds/draw.h | 6 | ||||
-rw-r--r-- | source/nds/gui.c | 8 |
4 files changed, 65 insertions, 2 deletions
diff --git a/CATSFC/system/gui/uicolors.txt b/CATSFC/system/gui/uicolors.txt new file mode 100644 index 0000000..0bbb405 --- /dev/null +++ b/CATSFC/system/gui/uicolors.txt @@ -0,0 +1,2 @@ +InactiveItem: #461F99 +ActiveItem: #FFFFFF diff --git a/source/nds/draw.c b/source/nds/draw.c index 479d5e6..793b6ca 100644 --- a/source/nds/draw.c +++ b/source/nds/draw.c @@ -106,6 +106,9 @@ struct gui_iconlist gui_icon_list[]= { /* 34 */ {"sbutto", 76, 16, NULL} }; +u16 COLOR_INACTIVE_ITEM = COLOR16( 0, 0, 0); +u16 COLOR_ACTIVE_ITEM = COLOR16(31, 31, 31); + /* * Drawing string aroud center @@ -1098,6 +1101,54 @@ int icon_init(u32 language_id) return ret; } +int color_init() +{ + char path[MAX_PATH]; + char current_line[256]; + sprintf(path, "%s/%s/%s", main_path, GUI_SOURCE_PATH, "uicolors.txt"); + FILE* fp = fopen(path, "r"); + if (fp != NULL) + { + while(fgets(current_line, 256, fp)) + { + char* colon = strchr(current_line, ':'); + if (colon) + { + *colon = '\0'; + u16* color = NULL; + if (strcasecmp(current_line, "ActiveItem") == 0) + color = &COLOR_ACTIVE_ITEM; + else if (strcasecmp(current_line, "InactiveItem") == 0) + color = &COLOR_INACTIVE_ITEM; + + if (color != NULL) + { + char* end = strchr(colon + 1, '\0') - 1; + while (*end && (*end == '\r' || *end == '\n')) + *end-- = '\0'; + char* ptr = colon + 1; + while (*ptr && *ptr == ' ') + ptr++; + u32 color32; + u8 r, g, b; + if (strlen(ptr) == 7 && *ptr == '#') + { + color32 = strtol(ptr + 1, NULL, 16); + r = (color32 >> 16) & 0xFF; + g = (color32 >> 8) & 0xFF; + b = color32 & 0xFF; + *color = COLOR16(r >> 3, g >> 3, b >> 3); + } + } + } + } + fclose(fp); + return 0; + } + else + return 1; +} + /*************************************************************/ void show_icon(void* screen, struct gui_iconlist* icon, u32 x, u32 y) { diff --git a/source/nds/draw.h b/source/nds/draw.h index b81328a..904798a 100644 --- a/source/nds/draw.h +++ b/source/nds/draw.h @@ -68,8 +68,6 @@ #define COLOR_BG COLOR16(2, 4, 10) #define COLOR_BG32 COLOR32(2*8, 4*8, 10*8) #define COLOR_ROM_INFO COLOR16(22, 18, 26) -#define COLOR_ACTIVE_ITEM COLOR16(31, 31, 31) -#define COLOR_INACTIVE_ITEM COLOR16(11, 7, 19) #define COLOR_HELP_TEXT COLOR16(16, 20, 24) #define COLOR_DIALOG COLOR16(31, 31, 31) #define COLOR_DIALOG_SHADOW COLOR16( 0, 2, 8) @@ -89,6 +87,9 @@ extern "C" { #endif +extern u16 COLOR_INACTIVE_ITEM; +extern u16 COLOR_ACTIVE_ITEM; + struct background{ char bgname[128]; char bgbuffer[256*192*2]; @@ -180,6 +181,7 @@ extern void msg_screen_clear(void); extern void msg_set_text_color(u32 color); extern int icon_init(u32 language_id); +extern int color_init(void); extern int gui_change_icon(u32 language_id); extern int show_background(void *screen, char *bgname); extern void show_icon(void* screen, struct gui_iconlist *icon, u32 x, u32 y); diff --git a/source/nds/gui.c b/source/nds/gui.c index 7c9fb92..ca5a016 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -4904,6 +4904,14 @@ void gui_init(u32 lang_id) goto gui_init_err; } + flag = color_init(); + if(0 != flag) + { + char message[512]; + sprintf(message, "SYSTEM/GUI/uicolors.txt\nis missing\nPress any key to return to\nthe menu\n\nSYSTEM/GUI/uicolors.txt\nest manquant\nAppuyer sur une touche pour\nretourner au menu"); + err_msg(DOWN_SCREEN, message); + goto gui_init_err; + } flag = load_font(); if(0 != flag) |