From a0536fc4605d252986d5b36d24a4928ef3194281 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 15 Oct 2022 19:02:50 +1100 Subject: [PATCH] Launcher: Colour background of 'missing resources' menu based on current theme background colour --- src/Bitmap.c | 7 +++++++ src/Bitmap.h | 1 + src/EntityComponents.c | 4 ++-- src/LScreens.c | 5 ++--- src/Widgets.c | 4 ++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Bitmap.c b/src/Bitmap.c index 613cc17d7..1c7883b34 100644 --- a/src/Bitmap.c +++ b/src/Bitmap.c @@ -15,6 +15,13 @@ BitmapCol BitmapColor_Offset(BitmapCol color, int rBy, int gBy, int bBy) { return BitmapColor_RGB(r, g, b); } +BitmapCol BitmapColor_Scale(BitmapCol a, float t) { + cc_uint8 R = (cc_uint8)(BitmapCol_R(a) * t); + cc_uint8 G = (cc_uint8)(BitmapCol_G(a) * t); + cc_uint8 B = (cc_uint8)(BitmapCol_B(a) * t); + return (a & BITMAPCOLOR_A_MASK) | BitmapColor_R_Bits(R) | BitmapColor_G_Bits(G) | BitmapColor_B_Bits(B); +} + void Bitmap_UNSAFE_CopyBlock(int srcX, int srcY, int dstX, int dstY, struct Bitmap* src, struct Bitmap* dst, int size) { int x, y; diff --git a/src/Bitmap.h b/src/Bitmap.h index 214949c5d..d072f43b1 100644 --- a/src/Bitmap.h +++ b/src/Bitmap.h @@ -43,6 +43,7 @@ typedef cc_uint32 BitmapCol; #define BITMAPCOLOR_WHITE BitmapColor_RGB(255, 255, 255) BitmapCol BitmapColor_Offset(BitmapCol color, int rBy, int gBy, int bBy); +BitmapCol BitmapColor_Scale(BitmapCol a, float t); /* A 2D array of BitmapCol pixels */ struct Bitmap { BitmapCol* scan0; int width, height; }; diff --git a/src/EntityComponents.c b/src/EntityComponents.c index e553bff92..1137b5ad1 100644 --- a/src/EntityComponents.c +++ b/src/EntityComponents.c @@ -590,7 +590,7 @@ static cc_bool ShadowComponent_GetBlocks(struct Entity* e, int x, int y, int z, #define sh_half (sh_size / 2) static void ShadowComponent_MakeTex(void) { BitmapCol pixels[sh_size * sh_size]; - BitmapCol col = BitmapCol_Make(0, 0, 0, 200); + BitmapCol color = BitmapCol_Make(0, 0, 0, 200); struct Bitmap bmp; cc_uint32 x, y; @@ -602,7 +602,7 @@ static void ShadowComponent_MakeTex(void) { double dist = (sh_half - (x + 0.5)) * (sh_half - (x + 0.5)) + (sh_half - (y + 0.5)) * (sh_half - (y + 0.5)); - row[x] = dist < sh_half * sh_half ? col : 0; + row[x] = dist < sh_half * sh_half ? color : 0; } } Gfx_RecreateTexture(&ShadowComponent_ShadowTex, &bmp, 0, false); diff --git a/src/LScreens.c b/src/LScreens.c index 8cf07e786..1b2e1cc31 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -1017,16 +1017,15 @@ static void CheckResourcesScreen_Show(struct LScreen* s_) { LLabel_SetText(&s->lblStatus, &str); } -#define RESOURCES_BACK_COLOR BitmapColor_RGB( 12, 12, 12) #define RESOURCES_FORE_COLOR BitmapColor_RGB(120, 85, 151) - static void CheckResourcesScreen_ResetArea(struct Context2D* ctx, int x, int y, int width, int height) { Gradient_Noise(ctx, RESOURCES_FORE_COLOR, 4, x, y, width, height); } static void CheckResourcesScreen_DrawBackground(struct LScreen* s, struct Context2D* ctx) { int x, y, width, height; - Context2D_Clear(ctx, RESOURCES_BACK_COLOR, 0, 0, ctx->width, ctx->height); + BitmapCol color = BitmapColor_Scale(Launcher_Theme.BackgroundColor, 0.2f); + Context2D_Clear(ctx, color, 0, 0, ctx->width, ctx->height); width = Display_ScaleX(380); height = Display_ScaleY(140); diff --git a/src/Widgets.c b/src/Widgets.c index c8847f3ce..6df4b73db 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -2477,7 +2477,7 @@ static void SpecialInputWidget_DrawContent(struct SpecialInputWidget* w, struct } static void SpecialInputWidget_Make(struct SpecialInputWidget* w, struct SpecialInputTab* tab) { - BitmapCol col = BitmapCol_Make(30, 30, 30, 200); + BitmapCol color = BitmapCol_Make(30, 30, 30, 200); int titlesWidth, titlesHeight; int contentWidth, contentHeight; struct Context2D ctx; @@ -2495,7 +2495,7 @@ static void SpecialInputWidget_Make(struct SpecialInputWidget* w, struct Special Context2D_Alloc(&ctx, width, height); { SpecialInputWidget_DrawTitles(w, &ctx); - Context2D_Clear(&ctx, col, 0, titlesHeight, width, contentHeight); + Context2D_Clear(&ctx, color, 0, titlesHeight, width, contentHeight); SpecialInputWidget_DrawContent(w, tab, &ctx, titlesHeight); } Context2D_MakeTexture(&w->tex, &ctx);