From b283f48de26bef00b3b12466c15257416af892fb Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Fri, 19 Jan 2024 04:21:05 +0100 Subject: [PATCH] Added color for text files --- src/menu/components/file_list.c | 18 +++++++++++------- src/menu/fonts.c | 9 +++++---- src/menu/fonts.h | 9 +++++---- src/menu/menu_state.h | 2 +- src/menu/views/browser.c | 12 ++++++------ 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/menu/components/file_list.c b/src/menu/components/file_list.c index 15a438fc..1de3cd19 100644 --- a/src/menu/components/file_list.c +++ b/src/menu/components/file_list.c @@ -37,7 +37,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { component_main_text_draw( ALIGN_LEFT, VALIGN_TOP, "^%02X** empty directory **", - STL_UNKNOWN + STL_GRAY ); } else { rdpq_paragraph_t *file_list_layout; @@ -80,12 +80,16 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { menu_font_style_t style; switch (entry->type) { - case ENTRY_TYPE_DIR: style = STL_DIRECTORY; break; - case ENTRY_TYPE_SAVE: style = STL_SAVE; break; - case ENTRY_TYPE_OTHER: style = STL_UNKNOWN; break; - case ENTRY_TYPE_IMAGE: style = STL_MEDIA; break; - case ENTRY_TYPE_MUSIC: style = STL_MEDIA; break; - default: style = STL_DEFAULT; break; + case ENTRY_TYPE_DIR: style = STL_YELLOW; break; + case ENTRY_TYPE_ROM: style = STL_DEFAULT; break; + case ENTRY_TYPE_DISK: style = STL_DEFAULT; break; + case ENTRY_TYPE_EMULATOR: style = STL_DEFAULT; break; + case ENTRY_TYPE_SAVE: style = STL_GREEN; break; + case ENTRY_TYPE_IMAGE: style = STL_BLUE; break; + case ENTRY_TYPE_MUSIC: style = STL_BLUE; break; + case ENTRY_TYPE_TEXT: style = STL_ORANGE; break; + case ENTRY_TYPE_OTHER: style = STL_GRAY; break; + default: style = STL_GRAY; break; } rdpq_paragraph_builder_style(style); diff --git a/src/menu/fonts.c b/src/menu/fonts.c index 27eccd09..e8eccc95 100644 --- a/src/menu/fonts.c +++ b/src/menu/fonts.c @@ -7,10 +7,11 @@ static void load_default_font (void) { rdpq_font_t *default_font = rdpq_font_load("rom:/FiraMonoBold.font64"); rdpq_font_style(default_font, STL_DEFAULT, &((rdpq_fontstyle_t) { .color = RGBA32(0xFF, 0xFF, 0xFF, 0xFF) })); - rdpq_font_style(default_font, STL_DIRECTORY, &((rdpq_fontstyle_t) { .color = RGBA32(0xFF, 0xFF, 0x70, 0xFF) })); - rdpq_font_style(default_font, STL_SAVE, &((rdpq_fontstyle_t) { .color = RGBA32(0x70, 0xFF, 0x70, 0xFF) })); - rdpq_font_style(default_font, STL_MEDIA, &((rdpq_fontstyle_t) { .color = RGBA32(0x70, 0xBC, 0xFF, 0xFF) })); - rdpq_font_style(default_font, STL_UNKNOWN, &((rdpq_fontstyle_t) { .color = RGBA32(0xA0, 0xA0, 0xA0, 0xFF) })); + rdpq_font_style(default_font, STL_GREEN, &((rdpq_fontstyle_t) { .color = RGBA32(0x70, 0xFF, 0x70, 0xFF) })); + rdpq_font_style(default_font, STL_BLUE, &((rdpq_fontstyle_t) { .color = RGBA32(0x70, 0xBC, 0xFF, 0xFF) })); + rdpq_font_style(default_font, STL_YELLOW, &((rdpq_fontstyle_t) { .color = RGBA32(0xFF, 0xFF, 0x70, 0xFF) })); + rdpq_font_style(default_font, STL_ORANGE, &((rdpq_fontstyle_t) { .color = RGBA32(0xFF, 0x99, 0x00, 0xFF) })); + rdpq_font_style(default_font, STL_GRAY, &((rdpq_fontstyle_t) { .color = RGBA32(0xA0, 0xA0, 0xA0, 0xFF) })); rdpq_text_register_font(FNT_DEFAULT, default_font); } diff --git a/src/menu/fonts.h b/src/menu/fonts.h index 2e006efc..2ddade59 100644 --- a/src/menu/fonts.h +++ b/src/menu/fonts.h @@ -15,10 +15,11 @@ typedef enum { /** @brief Font style enumeration. */ typedef enum { STL_DEFAULT = 0, - STL_DIRECTORY, - STL_SAVE, - STL_MEDIA, - STL_UNKNOWN, + STL_GREEN, + STL_BLUE, + STL_YELLOW, + STL_ORANGE, + STL_GRAY, } menu_font_style_t; diff --git a/src/menu/menu_state.h b/src/menu/menu_state.h index f0d93492..265443fe 100644 --- a/src/menu/menu_state.h +++ b/src/menu/menu_state.h @@ -51,8 +51,8 @@ typedef enum { ENTRY_TYPE_EMULATOR, ENTRY_TYPE_SAVE, ENTRY_TYPE_IMAGE, - ENTRY_TYPE_TEXT, ENTRY_TYPE_MUSIC, + ENTRY_TYPE_TEXT, ENTRY_TYPE_OTHER, } entry_type_t; diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index 01cdb41b..00061d67 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -47,14 +47,14 @@ static int compare_entry (const void *pa, const void *pb) { return -1; } else if (b->type == ENTRY_TYPE_IMAGE) { return 1; - } else if (a->type == ENTRY_TYPE_TEXT) { - return -1; - } else if (b->type == ENTRY_TYPE_TEXT) { - return 1; } else if (a->type == ENTRY_TYPE_MUSIC) { return -1; } else if (b->type == ENTRY_TYPE_MUSIC) { return 1; + } else if (a->type == ENTRY_TYPE_TEXT) { + return -1; + } else if (b->type == ENTRY_TYPE_TEXT) { + return 1; } } @@ -355,14 +355,14 @@ static void draw (menu_t *menu, surface_t *d) { "%s\n" "^%02XB: Back^00", menu->browser.entries == 0 ? "" : action, - path_is_root(menu->browser.directory) ? STL_UNKNOWN : STL_DEFAULT + path_is_root(menu->browser.directory) ? STL_GRAY : STL_DEFAULT ); component_actions_bar_text_draw( ALIGN_RIGHT, VALIGN_TOP, "Start: Settings\n" "^%02XR: Options^00", - menu->browser.entries == 0 ? STL_UNKNOWN : STL_DEFAULT + menu->browser.entries == 0 ? STL_GRAY : STL_DEFAULT ); if (menu->current_time >= 0) {