Launcher: Colour background of 'missing resources' menu based on current theme background colour

This commit is contained in:
UnknownShadow200 2022-10-15 19:02:50 +11:00
parent 46ccf99c67
commit a0536fc460
5 changed files with 14 additions and 7 deletions

View File

@ -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;

View File

@ -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; };

View File

@ -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);

View File

@ -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);

View File

@ -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);