From e4a1532e2d580a6014d1b98acc4025b977caf607 Mon Sep 17 00:00:00 2001 From: frysee Date: Sat, 11 Jul 2026 01:00:59 +0200 Subject: [PATCH] fix: update color parsing to include alpha channel in color presets where it was missed --- workspace/all/gametime/gametime.c | 16 +++------------- workspace/all/ledcontrol/ledcontrol.c | 3 ++- workspace/all/settings/colorpickermenu.cpp | 5 +++-- workspace/all/settings/colorpickermenu.hpp | 2 +- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/workspace/all/gametime/gametime.c b/workspace/all/gametime/gametime.c index 49f23c4ca..a30f67c5c 100644 --- a/workspace/all/gametime/gametime.c +++ b/workspace/all/gametime/gametime.c @@ -51,16 +51,6 @@ static SDL_Surface **romImages; static PlayActivities *play_activities; -static inline SDL_Color colorFromUint(uint32_t colour) -{ - SDL_Color tempcol; - tempcol.a = 255; - tempcol.r = (colour >> 16) & 0xFF; - tempcol.g = (colour >> 8) & 0xFF; - tempcol.b = colour & 0xFF; - return tempcol; -} - /////// int _renderText(const char *text, TTF_Font *font, SDL_Color color, SDL_Rect *rect, bool right_align) @@ -260,7 +250,7 @@ void renderList(int count, int start, int end, int selected) cleanName(rom_name, rom->name); SDL_Color textColor = COLOR_WHITE; if(isSelected) { - //textColor = colorFromUint(THEME_COLOR1); + //textColor = uintToColour(THEME_COLOR1); textColor = COLOR_BLACK; } renderText(rom_name, font.medium, textColor, &(SDL_Rect){ @@ -281,8 +271,8 @@ void renderList(int count, int start, int end, int selected) textHeight }; for (int i = 0; i < 6; i++) { - SDL_Color detailCol = i % 2 == 0 ? COLOR_DARK_TEXT : colorFromUint(THEME_COLOR2_255); - //SDL_Color detailCol = colorFromUint(i % 2 == 0 ? THEME_COLOR3_255 : THEME_COLOR2_255); + SDL_Color detailCol = i % 2 == 0 ? COLOR_DARK_TEXT : uintToColour(THEME_COLOR2_255); + //SDL_Color detailCol = uintToColour(i % 2 == 0 ? THEME_COLOR3_255 : THEME_COLOR2_255); //SDL_Color detailCol = i % 2 == 0 ? COLOR_DARK_TEXT : COLOR_LIGHT_TEXT; detailsRect.x += renderText(details[i], font.small, detailCol, &detailsRect); } diff --git a/workspace/all/ledcontrol/ledcontrol.c b/workspace/all/ledcontrol/ledcontrol.c index e22ecbe7f..c38167a3c 100644 --- a/workspace/all/ledcontrol/ledcontrol.c +++ b/workspace/all/ledcontrol/ledcontrol.c @@ -374,10 +374,11 @@ int main(int argc, char *argv[]) &(SDL_Rect){SCALE1(PADDING + BUTTON_PADDING), y + SCALE1(4)}); SDL_FreeSurface(text); + // color1 is stored as 0xRRGGBB; GFX_blitAssetColor expects 0xRRGGBBAA GFX_blitAssetColor(ASSET_BUTTON, NULL, screen, &(SDL_Rect){ SCALE1(PADDING) + text_width, y + SCALE1(BUTTON_MARGIN) - }, settings_values[j]); + }, ((uint32_t)settings_values[j] << 8) | 0xFF); } else { snprintf(setting_text, sizeof(setting_text), "%s: %d", settings_labels[j], settings_values[j]); SDL_Surface *text = TTF_RenderUTF8_Blended(font.medium, setting_text, current_color); diff --git a/workspace/all/settings/colorpickermenu.cpp b/workspace/all/settings/colorpickermenu.cpp index 33646a79f..eb605f6e0 100644 --- a/workspace/all/settings/colorpickermenu.cpp +++ b/workspace/all/settings/colorpickermenu.cpp @@ -357,13 +357,14 @@ void ColorPickerMenu::drawPreset(SDL_Surface *surface, const SDL_Rect &row, SDL_Rect sq_rect = {row.x + SCALE1(OPTION_PADDING), row.y + (row.h - sq) / 2, sq, sq}; SDL_FillRect(surface, &sq_rect, SDL_MapRGB(surface->format, 255, 255, 255)); SDL_Rect sq_inner = {sq_rect.x + 1, sq_rect.y + 1, sq_rect.w - 2, sq_rect.h - 2}; + SDL_Color preset_color = uintToColour(preset.color); SDL_FillRect(surface, &sq_inner, SDL_MapRGB(surface->format, - (preset.color >> 16) & 0xFF, (preset.color >> 8) & 0xFF, preset.color & 0xFF)); + preset_color.r, preset_color.g, preset_color.b)); SDL_Color text_color = is_selected ? uintToColour(THEME_COLOR5_255) : uintToColour(THEME_COLOR4_255); // Hex value "#RRGGBBAA" - char hex_str[9]; + char hex_str[10]; snprintf(hex_str, sizeof(hex_str), "#%08X", preset.color); SDL_Surface *hex_surf = TTF_RenderUTF8_Blended(font.tiny, hex_str, text_color); int hex_x = sq_rect.x + sq + SCALE1(OPTION_PADDING / 2 + 2); diff --git a/workspace/all/settings/colorpickermenu.hpp b/workspace/all/settings/colorpickermenu.hpp index 5e183cd11..2b5ab4496 100644 --- a/workspace/all/settings/colorpickermenu.hpp +++ b/workspace/all/settings/colorpickermenu.hpp @@ -3,7 +3,7 @@ #include "menu.hpp" struct ColorPreset { - uint32_t color; // 0xRRGGBB + uint32_t color; // 0xRRGGBBAA std::string label; };