More col -> color renaming

This commit is contained in:
UnknownShadow200 2021-09-16 20:07:38 +10:00
parent 477b37fc80
commit c65143e6d0
11 changed files with 96 additions and 100 deletions

View File

@ -105,7 +105,7 @@ void SetWorkingDir(cc_string* title) {
## API ## API
I'm lazy so I will just link to [String.h](src/String.h) I'm lazy so I will just link to [String.h](/src/String.h)
If you'd rather I provided a more detailed reference here, please let me know. If you'd rather I provided a more detailed reference here, please let me know.
@ -189,13 +189,9 @@ string::insert -> String_InsertAt
string::erase -> String_DeleteAt string::erase -> String_DeleteAt
string::substr -> String_UNSAFE_Substring/String_UNSAFE_SubstringAt string::substr -> String_UNSAFE_Substring/String_UNSAFE_SubstringAt
string.Split -> String_UNSAFE_Split/String_UNSAFE_SplitBy
string.TrimStart -> String_UNSAFE_TrimStart
string.TrimEnd -> String_UNSAFE_TrimEnd
a.Length -> str.length string::length -> str.length
a == b -> String_Equals a == b -> String_Equals
string.Equals -> String_CaslessEquals (StringComparison.OrdinalIgnoreCase)
string::find -> String_IndexOf/String_IndexOfConst string::find -> String_IndexOf/String_IndexOfConst
string::rfind -> String_LastIndexOf string::rfind -> String_LastIndexOf
string::compare -> String_Compare string::compare -> String_Compare

View File

@ -71,9 +71,9 @@ void Bitmap_Scale(struct Bitmap* dst, struct Bitmap* src,
#define PNG_PALETTE 256 #define PNG_PALETTE 256
#define PNG_FourCC(a, b, c, d) (((cc_uint32)a << 24) | ((cc_uint32)b << 16) | ((cc_uint32)c << 8) | (cc_uint32)d) #define PNG_FourCC(a, b, c, d) (((cc_uint32)a << 24) | ((cc_uint32)b << 16) | ((cc_uint32)c << 8) | (cc_uint32)d)
enum PngCol { enum PngColor {
PNG_COL_GRAYSCALE = 0, PNG_COL_RGB = 2, PNG_COL_INDEXED = 3, PNG_COLOR_GRAYSCALE = 0, PNG_COLOR_RGB = 2, PNG_COLOR_INDEXED = 3,
PNG_COL_GRAYSCALE_A = 4, PNG_COL_RGB_A = 6 PNG_COLOR_GRAYSCALE_A = 4, PNG_COLOR_RGB_A = 6
}; };
enum PngFilter { enum PngFilter {
@ -271,7 +271,7 @@ static void Png_Expand_RGB_A_16(int width, BitmapCol* palette, cc_uint8* src, Bi
static Png_RowExpander Png_GetExpander(cc_uint8 col, cc_uint8 bitsPerSample) { static Png_RowExpander Png_GetExpander(cc_uint8 col, cc_uint8 bitsPerSample) {
switch (col) { switch (col) {
case PNG_COL_GRAYSCALE: case PNG_COLOR_GRAYSCALE:
switch (bitsPerSample) { switch (bitsPerSample) {
case 1: return Png_Expand_GRAYSCALE_1; case 1: return Png_Expand_GRAYSCALE_1;
case 2: return Png_Expand_GRAYSCALE_2; case 2: return Png_Expand_GRAYSCALE_2;
@ -281,14 +281,14 @@ static Png_RowExpander Png_GetExpander(cc_uint8 col, cc_uint8 bitsPerSample) {
} }
return NULL; return NULL;
case PNG_COL_RGB: case PNG_COLOR_RGB:
switch (bitsPerSample) { switch (bitsPerSample) {
case 8: return Png_Expand_RGB_8; case 8: return Png_Expand_RGB_8;
case 16: return Png_Expand_RGB_16; case 16: return Png_Expand_RGB_16;
} }
return NULL; return NULL;
case PNG_COL_INDEXED: case PNG_COLOR_INDEXED:
switch (bitsPerSample) { switch (bitsPerSample) {
case 1: return Png_Expand_INDEXED_1; case 1: return Png_Expand_INDEXED_1;
case 2: return Png_Expand_INDEXED_2; case 2: return Png_Expand_INDEXED_2;
@ -297,14 +297,14 @@ static Png_RowExpander Png_GetExpander(cc_uint8 col, cc_uint8 bitsPerSample) {
} }
return NULL; return NULL;
case PNG_COL_GRAYSCALE_A: case PNG_COLOR_GRAYSCALE_A:
switch (bitsPerSample) { switch (bitsPerSample) {
case 8: return Png_Expand_GRAYSCALE_A_8; case 8: return Png_Expand_GRAYSCALE_A_8;
case 16: return Png_Expand_GRAYSCALE_A_16; case 16: return Png_Expand_GRAYSCALE_A_16;
} }
return NULL; return NULL;
case PNG_COL_RGB_A: case PNG_COLOR_RGB_A:
switch (bitsPerSample) { switch (bitsPerSample) {
case 8: return Png_Expand_RGB_A_8; case 8: return Png_Expand_RGB_A_8;
case 16: return Png_Expand_RGB_A_16; case 16: return Png_Expand_RGB_A_16;
@ -426,14 +426,14 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
} break; } break;
case PNG_FourCC('t','R','N','S'): { case PNG_FourCC('t','R','N','S'): {
if (col == PNG_COL_GRAYSCALE) { if (col == PNG_COLOR_GRAYSCALE) {
if (dataSize != 2) return PNG_ERR_TRANS_COUNT; if (dataSize != 2) return PNG_ERR_TRANS_COUNT;
res = Stream_Read(stream, tmp, dataSize); res = Stream_Read(stream, tmp, dataSize);
if (res) return res; if (res) return res;
/* RGB is 16 bits big endian, ignore least significant 8 bits */ /* RGB is 16 bits big endian, ignore least significant 8 bits */
trnsCol = BitmapCol_Make(tmp[0], tmp[0], tmp[0], 0); trnsCol = BitmapCol_Make(tmp[0], tmp[0], tmp[0], 0);
} else if (col == PNG_COL_INDEXED) { } else if (col == PNG_COLOR_INDEXED) {
if (dataSize > PNG_PALETTE) return PNG_ERR_TRANS_COUNT; if (dataSize > PNG_PALETTE) return PNG_ERR_TRANS_COUNT;
res = Stream_Read(stream, tmp, dataSize); res = Stream_Read(stream, tmp, dataSize);
if (res) return res; if (res) return res;
@ -443,7 +443,7 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
palette[i] &= BITMAPCOL_RGB_MASK; /* set A to 0 */ palette[i] &= BITMAPCOL_RGB_MASK; /* set A to 0 */
palette[i] |= tmp[i] << BITMAPCOL_A_SHIFT; palette[i] |= tmp[i] << BITMAPCOL_A_SHIFT;
} }
} else if (col == PNG_COL_RGB) { } else if (col == PNG_COLOR_RGB) {
if (dataSize != 6) return PNG_ERR_TRANS_COUNT; if (dataSize != 6) return PNG_ERR_TRANS_COUNT;
res = Stream_Read(stream, tmp, dataSize); res = Stream_Read(stream, tmp, dataSize);
if (res) return res; if (res) return res;
@ -653,7 +653,7 @@ cc_result Png_Encode(struct Bitmap* bmp, struct Stream* stream,
Stream_SetU32_BE(&tmp[8], bmp->width); Stream_SetU32_BE(&tmp[8], bmp->width);
Stream_SetU32_BE(&tmp[12], bmp->height); Stream_SetU32_BE(&tmp[12], bmp->height);
tmp[16] = 8; /* bits per sample */ tmp[16] = 8; /* bits per sample */
tmp[17] = alpha ? PNG_COL_RGB_A : PNG_COL_RGB; tmp[17] = alpha ? PNG_COLOR_RGB_A : PNG_COLOR_RGB;
tmp[18] = 0; /* DEFLATE compression method */ tmp[18] = 0; /* DEFLATE compression method */
tmp[19] = 0; /* ADAPTIVE filter method */ tmp[19] = 0; /* ADAPTIVE filter method */
tmp[20] = 0; /* Not using interlacing */ tmp[20] = 0; /* Not using interlacing */

View File

@ -189,7 +189,7 @@ void Gradient_Noise(struct Bitmap* bmp, BitmapCol col, int variation,
void Gradient_Vertical(struct Bitmap* bmp, BitmapCol a, BitmapCol b, void Gradient_Vertical(struct Bitmap* bmp, BitmapCol a, BitmapCol b,
int x, int y, int width, int height) { int x, int y, int width, int height) {
BitmapCol* row, col; BitmapCol* row, color;
int xx, yy; int xx, yy;
float t; float t;
if (!Drawer2D_Clamp(bmp, &x, &y, &width, &height)) return; if (!Drawer2D_Clamp(bmp, &x, &y, &width, &height)) return;
@ -198,13 +198,13 @@ void Gradient_Vertical(struct Bitmap* bmp, BitmapCol a, BitmapCol b,
row = Bitmap_GetRow(bmp, y + yy) + x; row = Bitmap_GetRow(bmp, y + yy) + x;
t = (float)yy / (height - 1); /* so last row has colour of b */ t = (float)yy / (height - 1); /* so last row has colour of b */
col = BitmapCol_Make( color = BitmapCol_Make(
Math_Lerp(BitmapCol_R(a), BitmapCol_R(b), t), Math_Lerp(BitmapCol_R(a), BitmapCol_R(b), t),
Math_Lerp(BitmapCol_G(a), BitmapCol_G(b), t), Math_Lerp(BitmapCol_G(a), BitmapCol_G(b), t),
Math_Lerp(BitmapCol_B(a), BitmapCol_B(b), t), Math_Lerp(BitmapCol_B(a), BitmapCol_B(b), t),
255); 255);
for (xx = 0; xx < width; xx++) { row[xx] = col; } for (xx = 0; xx < width; xx++) { row[xx] = color; }
} }
} }
@ -239,7 +239,7 @@ void Gradient_Blend(struct Bitmap* bmp, BitmapCol col, int blend,
void Gradient_Tint(struct Bitmap* bmp, cc_uint8 tintA, cc_uint8 tintB, void Gradient_Tint(struct Bitmap* bmp, cc_uint8 tintA, cc_uint8 tintB,
int x, int y, int width, int height) { int x, int y, int width, int height) {
BitmapCol* row, col; BitmapCol* row, color;
cc_uint8 tint; cc_uint8 tint;
int xx, yy; int xx, yy;
if (!Drawer2D_Clamp(bmp, &x, &y, &width, &height)) return; if (!Drawer2D_Clamp(bmp, &x, &y, &width, &height)) return;
@ -250,13 +250,13 @@ void Gradient_Tint(struct Bitmap* bmp, cc_uint8 tintA, cc_uint8 tintB,
for (xx = 0; xx < width; xx++) { for (xx = 0; xx < width; xx++) {
/* TODO: Not shift when multiplying */ /* TODO: Not shift when multiplying */
col = BitmapCol_Make( color = BitmapCol_Make(
BitmapCol_R(row[xx]) * tint / 255, BitmapCol_R(row[xx]) * tint / 255,
BitmapCol_G(row[xx]) * tint / 255, BitmapCol_G(row[xx]) * tint / 255,
BitmapCol_B(row[xx]) * tint / 255, BitmapCol_B(row[xx]) * tint / 255,
0); 0);
row[xx] = col | (row[xx] & BITMAPCOL_A_MASK); row[xx] = color | (row[xx] & BITMAPCOL_A_MASK);
} }
} }
} }

View File

@ -226,8 +226,8 @@ cc_bool Entity_TouchesAnyWater(struct Entity* e) {
static void MakeNameTexture(struct Entity* e) { static void MakeNameTexture(struct Entity* e) {
cc_string colorlessName; char colorlessBuffer[STRING_SIZE]; cc_string colorlessName; char colorlessBuffer[STRING_SIZE];
BitmapCol shadowCol = BitmapCol_Make(80, 80, 80, 255); BitmapCol shadowColor = BitmapCol_Make(80, 80, 80, 255);
BitmapCol origWhiteCol; BitmapCol origWhiteColor;
struct DrawTextArgs args; struct DrawTextArgs args;
struct FontDesc font; struct FontDesc font;
@ -254,14 +254,14 @@ static void MakeNameTexture(struct Entity* e) {
Bitmap_AllocateClearedPow2(&bmp, width, height); Bitmap_AllocateClearedPow2(&bmp, width, height);
{ {
origWhiteCol = Drawer2D.Colors['f']; origWhiteColor = Drawer2D.Colors['f'];
Drawer2D.Colors['f'] = shadowCol; Drawer2D.Colors['f'] = shadowColor;
Drawer2D_WithoutColors(&colorlessName, &name); Drawer2D_WithoutColors(&colorlessName, &name);
args.text = colorlessName; args.text = colorlessName;
Drawer2D_DrawText(&bmp, &args, NAME_OFFSET, NAME_OFFSET); Drawer2D_DrawText(&bmp, &args, NAME_OFFSET, NAME_OFFSET);
Drawer2D.Colors['f'] = origWhiteCol; Drawer2D.Colors['f'] = origWhiteColor;
args.text = name; args.text = name;
Drawer2D_DrawText(&bmp, &args, 0, 0); Drawer2D_DrawText(&bmp, &args, 0, 0);
} }

View File

@ -217,13 +217,13 @@ cc_bool Gfx_TryRestoreContext(void);
void Gfx_UpdateDynamicVb_IndexedTris(GfxResourceID vb, void* vertices, int vCount); void Gfx_UpdateDynamicVb_IndexedTris(GfxResourceID vb, void* vertices, int vCount);
/* Renders a 2D flat coloured rectangle. */ /* Renders a 2D flat coloured rectangle. */
void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol col); void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol color);
/* Renders a 2D flat vertical gradient rectangle. */ /* Renders a 2D flat vertical gradient rectangle. */
void Gfx_Draw2DGradient(int x, int y, int width, int height, PackedCol top, PackedCol bottom); void Gfx_Draw2DGradient(int x, int y, int width, int height, PackedCol top, PackedCol bottom);
/* Renders a 2D coloured texture. */ /* Renders a 2D coloured texture. */
void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol col); void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol color);
/* Fills out the vertices for rendering a 2D coloured texture. */ /* Fills out the vertices for rendering a 2D coloured texture. */
void Gfx_Make2DQuad(const struct Texture* tex, PackedCol col, struct VertexTextured** vertices); void Gfx_Make2DQuad(const struct Texture* tex, PackedCol color, struct VertexTextured** vertices);
/* Switches state to be suitable for drawing 2D graphics. */ /* Switches state to be suitable for drawing 2D graphics. */
/* NOTE: This means turning off fog/depth test, changing matrices, etc.*/ /* NOTE: This means turning off fog/depth test, changing matrices, etc.*/

View File

@ -150,20 +150,20 @@ static void LButton_DrawBorder(struct LButton* w) {
} }
static void LButton_DrawHighlight(struct LButton* w) { static void LButton_DrawHighlight(struct LButton* w) {
BitmapCol activeCol = BitmapCol_Make(189, 198, 255, 255); BitmapCol activeColor = BitmapCol_Make(189, 198, 255, 255);
BitmapCol col = Launcher_Theme.ButtonHighlightColor; BitmapCol color = Launcher_Theme.ButtonHighlightColor;
if (Launcher_Theme.ClassicBackground) { if (Launcher_Theme.ClassicBackground) {
if (w->hovered) col = activeCol; if (w->hovered) color = activeColor;
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + xBorder2, w->y + yBorder, w->x + xBorder2, w->y + yBorder,
w->width - xBorder4, yBorder); w->width - xBorder4, yBorder);
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + xBorder, w->y + yBorder2, w->x + xBorder, w->y + yBorder2,
xBorder, w->height - yBorder4); xBorder, w->height - yBorder4);
} else if (!w->hovered) { } else if (!w->hovered) {
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + xBorder2, w->y + yBorder, w->x + xBorder2, w->y + yBorder,
w->width - xBorder4, yBorder); w->width - xBorder4, yBorder);
} }
@ -269,10 +269,10 @@ void LBackend_DrawCheckbox(struct LCheckbox* w) {
*------------------------------------------------------InputWidget--------------------------------------------------------* *------------------------------------------------------InputWidget--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static void LInput_DrawOuterBorder(struct LInput* w) { static void LInput_DrawOuterBorder(struct LInput* w) {
BitmapCol col = BitmapCol_Make(97, 81, 110, 255); BitmapCol color = BitmapCol_Make(97, 81, 110, 255);
if (w->selected) { if (w->selected) {
DrawBoxBounds(col, w->x, w->y, w->width, w->height); DrawBoxBounds(color, w->x, w->y, w->width, w->height);
} else { } else {
Launcher_ResetArea(w->x, w->y, Launcher_ResetArea(w->x, w->y,
w->width, yBorder); w->width, yBorder);
@ -286,32 +286,32 @@ static void LInput_DrawOuterBorder(struct LInput* w) {
} }
static void LInput_DrawInnerBorder(struct LInput* w) { static void LInput_DrawInnerBorder(struct LInput* w) {
BitmapCol col = BitmapCol_Make(165, 142, 168, 255); BitmapCol color = BitmapCol_Make(165, 142, 168, 255);
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + xBorder, w->y + yBorder, w->x + xBorder, w->y + yBorder,
w->width - xBorder2, yBorder); w->width - xBorder2, yBorder);
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + xBorder, w->y + w->height - yBorder2, w->x + xBorder, w->y + w->height - yBorder2,
w->width - xBorder2, yBorder); w->width - xBorder2, yBorder);
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + xBorder, w->y + yBorder, w->x + xBorder, w->y + yBorder,
xBorder, w->height - yBorder2); xBorder, w->height - yBorder2);
Drawer2D_Clear(&Launcher_Framebuffer, col, Drawer2D_Clear(&Launcher_Framebuffer, color,
w->x + w->width - xBorder2, w->y + yBorder, w->x + w->width - xBorder2, w->y + yBorder,
xBorder, w->height - yBorder2); xBorder, w->height - yBorder2);
} }
static void LInput_BlendBoxTop(struct LInput* w) { static void LInput_BlendBoxTop(struct LInput* w) {
BitmapCol col = BitmapCol_Make(0, 0, 0, 255); BitmapCol color = BitmapCol_Make(0, 0, 0, 255);
Gradient_Blend(&Launcher_Framebuffer, col, 75, Gradient_Blend(&Launcher_Framebuffer, color, 75,
w->x + xBorder, w->y + yBorder, w->x + xBorder, w->y + yBorder,
w->width - xBorder2, yBorder); w->width - xBorder2, yBorder);
Gradient_Blend(&Launcher_Framebuffer, col, 50, Gradient_Blend(&Launcher_Framebuffer, color, 50,
w->x + xBorder, w->y + yBorder2, w->x + xBorder, w->y + yBorder2,
w->width - xBorder2, yBorder); w->width - xBorder2, yBorder);
Gradient_Blend(&Launcher_Framebuffer, col, 25, Gradient_Blend(&Launcher_Framebuffer, color, 25,
w->x + xBorder, w->y + yBorder3, w->x + xBorder, w->y + yBorder3,
w->width - xBorder2, yBorder); w->width - xBorder2, yBorder);
} }

View File

@ -1062,8 +1062,8 @@ static void CheckResourcesScreen_Layout(struct LScreen* s_) {
} }
CC_NOINLINE static void CheckResourcesScreen_ResetArea(int x, int y, int width, int height) { CC_NOINLINE static void CheckResourcesScreen_ResetArea(int x, int y, int width, int height) {
BitmapCol boxCol = BitmapCol_Make(120, 85, 151, 255); BitmapCol boxColor = BitmapCol_Make(120, 85, 151, 255);
Gradient_Noise(&Launcher_Framebuffer, boxCol, 4, x, y, width, height); Gradient_Noise(&Launcher_Framebuffer, boxColor, 4, x, y, width, height);
Launcher_MarkDirty(x, y, width, height); Launcher_MarkDirty(x, y, width, height);
} }

View File

@ -640,10 +640,10 @@ static void LTable_SetSelectedTo(struct LTable* w, int index) {
/* Draws background behind column headers */ /* Draws background behind column headers */
static void LTable_DrawHeaderBackground(struct LTable* w) { static void LTable_DrawHeaderBackground(struct LTable* w) {
BitmapCol gridCol = BitmapCol_Make(20, 20, 10, 255); BitmapCol gridColor = BitmapCol_Make(20, 20, 10, 255);
if (!Launcher_Theme.ClassicBackground) { if (!Launcher_Theme.ClassicBackground) {
Drawer2D_Clear(&Launcher_Framebuffer, gridCol, Drawer2D_Clear(&Launcher_Framebuffer, gridColor,
w->x, w->y, w->width, w->hdrHeight); w->x, w->y, w->width, w->hdrHeight);
} else { } else {
Launcher_ResetArea(w->x, w->y, w->width, w->hdrHeight); Launcher_ResetArea(w->x, w->y, w->width, w->hdrHeight);
@ -652,9 +652,9 @@ static void LTable_DrawHeaderBackground(struct LTable* w) {
/* Works out the background colour of the given row */ /* Works out the background colour of the given row */
static BitmapCol LTable_RowColor(struct LTable* w, int row) { static BitmapCol LTable_RowColor(struct LTable* w, int row) {
BitmapCol featSelCol = BitmapCol_Make( 50, 53, 0, 255); BitmapCol featSelColor = BitmapCol_Make( 50, 53, 0, 255);
BitmapCol featuredCol = BitmapCol_Make(101, 107, 0, 255); BitmapCol featuredColor = BitmapCol_Make(101, 107, 0, 255);
BitmapCol selectedCol = BitmapCol_Make( 40, 40, 40, 255); BitmapCol selectedColor = BitmapCol_Make( 40, 40, 40, 255);
struct ServerInfo* entry; struct ServerInfo* entry;
cc_bool selected; cc_bool selected;
entry = row < w->rowsCount ? LTable_Get(row) : NULL; entry = row < w->rowsCount ? LTable_Get(row) : NULL;
@ -662,9 +662,9 @@ static BitmapCol LTable_RowColor(struct LTable* w, int row) {
if (entry) { if (entry) {
selected = String_Equals(&entry->hash, w->selectedHash); selected = String_Equals(&entry->hash, w->selectedHash);
if (entry->featured) { if (entry->featured) {
return selected ? featSelCol : featuredCol; return selected ? featSelColor : featuredColor;
} else if (selected) { } else if (selected) {
return selectedCol; return selectedColor;
} }
} }

View File

@ -2450,14 +2450,14 @@ static void MenuOptionsScreen_Init(void* screen) {
static void MenuOptionsScreen_Render(void* screen, double delta) { static void MenuOptionsScreen_Render(void* screen, double delta) {
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen; struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
struct TextGroupWidget* w; struct TextGroupWidget* w;
PackedCol tableCol = PackedCol_Make(20, 20, 20, 200); PackedCol tableColor = PackedCol_Make(20, 20, 20, 200);
MenuScreen_Render2(s, delta); MenuScreen_Render2(s, delta);
if (!s->extHelp.lines) return; if (!s->extHelp.lines) return;
w = &s->extHelp; w = &s->extHelp;
Gfx_Draw2DFlat(w->x - EXTHELP_PAD, w->y - EXTHELP_PAD, Gfx_Draw2DFlat(w->x - EXTHELP_PAD, w->y - EXTHELP_PAD,
w->width + EXTHELP_PAD * 2, w->height + EXTHELP_PAD * 2, tableCol); w->width + EXTHELP_PAD * 2, w->height + EXTHELP_PAD * 2, tableColor);
Gfx_SetTexturing(true); Gfx_SetTexturing(true);
Elem_Render(&s->extHelp, delta); Elem_Render(&s->extHelp, delta);

View File

@ -120,10 +120,10 @@ static void ButtonWidget_Reposition(void* widget) {
} }
static void ButtonWidget_Render(void* widget, double delta) { static void ButtonWidget_Render(void* widget, double delta) {
PackedCol normCol = PackedCol_Make(224, 224, 224, 255); PackedCol normColor = PackedCol_Make(224, 224, 224, 255);
PackedCol activeCol = PackedCol_Make(255, 255, 160, 255); PackedCol activeColor = PackedCol_Make(255, 255, 160, 255);
PackedCol disabledCol = PackedCol_Make(160, 160, 160, 255); PackedCol disabledColor = PackedCol_Make(160, 160, 160, 255);
PackedCol col; PackedCol color;
struct ButtonWidget* w = (struct ButtonWidget*)widget; struct ButtonWidget* w = (struct ButtonWidget*)widget;
struct Texture back; struct Texture back;
@ -155,15 +155,15 @@ static void ButtonWidget_Render(void* widget, double delta) {
} }
if (!w->tex.ID) return; if (!w->tex.ID) return;
col = w->disabled ? disabledCol : (w->active ? activeCol : normCol); color = w->disabled ? disabledColor : (w->active ? activeColor : normColor);
Texture_RenderShaded(&w->tex, col); Texture_RenderShaded(&w->tex, color);
} }
static void ButtonWidget_BuildMesh(void* widget, struct VertexTextured** vertices) { static void ButtonWidget_BuildMesh(void* widget, struct VertexTextured** vertices) {
PackedCol normCol = PackedCol_Make(224, 224, 224, 255); PackedCol normColor = PackedCol_Make(224, 224, 224, 255);
PackedCol activeCol = PackedCol_Make(255, 255, 160, 255); PackedCol activeColor = PackedCol_Make(255, 255, 160, 255);
PackedCol disabledCol = PackedCol_Make(160, 160, 160, 255); PackedCol disabledColor = PackedCol_Make(160, 160, 160, 255);
PackedCol col; PackedCol color;
struct ButtonWidget* w = (struct ButtonWidget*)widget; struct ButtonWidget* w = (struct ButtonWidget*)widget;
struct Texture back; struct Texture back;
@ -192,8 +192,8 @@ static void ButtonWidget_BuildMesh(void* widget, struct VertexTextured** vertice
Gfx_Make2DQuad(&back, w->col, vertices); Gfx_Make2DQuad(&back, w->col, vertices);
} }
col = w->disabled ? disabledCol : (w->active ? activeCol : normCol); color = w->disabled ? disabledColor : (w->active ? activeColor : normColor);
Gfx_Make2DQuad(&w->tex, col, vertices); Gfx_Make2DQuad(&w->tex, color, vertices);
} }
static int ButtonWidget_Render2(void* widget, int offset) { static int ButtonWidget_Render2(void* widget, int offset) {
@ -749,13 +749,13 @@ static void TableWidget_Render(void* widget, double delta) {
/* These were sourced by taking a screenshot of vanilla */ /* These were sourced by taking a screenshot of vanilla */
/* Then using paint to extract the colour components */ /* Then using paint to extract the colour components */
/* Then using wolfram alpha to solve the glblendfunc equation */ /* Then using wolfram alpha to solve the glblendfunc equation */
PackedCol topBackCol = PackedCol_Make( 34, 34, 34, 168); PackedCol topBackColor = PackedCol_Make( 34, 34, 34, 168);
PackedCol bottomBackCol = PackedCol_Make( 57, 57, 104, 202); PackedCol bottomBackColor = PackedCol_Make( 57, 57, 104, 202);
PackedCol topSelCol = PackedCol_Make(255, 255, 255, 142); PackedCol topSelColor = PackedCol_Make(255, 255, 255, 142);
PackedCol bottomSelCol = PackedCol_Make(255, 255, 255, 192); PackedCol bottomSelColor = PackedCol_Make(255, 255, 255, 192);
Gfx_Draw2DGradient(Table_X(w), Table_Y(w), Gfx_Draw2DGradient(Table_X(w), Table_Y(w),
Table_Width(w), Table_Height(w), topBackCol, bottomBackCol); Table_Width(w), Table_Height(w), topBackColor, bottomBackColor);
if (w->rowsVisible < w->rowsTotal) { if (w->rowsVisible < w->rowsTotal) {
Elem_Render(&w->scroll, delta); Elem_Render(&w->scroll, delta);
@ -770,7 +770,7 @@ static void TableWidget_Render(void* widget, double delta) {
off = cellSizeX * 0.1f; off = cellSizeX * 0.1f;
size = (int)(cellSizeX + off * 2); size = (int)(cellSizeX + off * 2);
Gfx_Draw2DGradient((int)(x - off), (int)(y - off), Gfx_Draw2DGradient((int)(x - off), (int)(y - off),
size, size, topSelCol, bottomSelCol); size, size, topSelColor, bottomSelColor);
} }
Gfx_SetTexturing(true); Gfx_SetTexturing(true);
Gfx_SetVertexFormat(VERTEX_FORMAT_TEXTURED); Gfx_SetVertexFormat(VERTEX_FORMAT_TEXTURED);
@ -1540,7 +1540,7 @@ static int TextInputWidget_Render2(void* widget, int offset) {
static void TextInputWidget_RemakeTexture(void* widget) { static void TextInputWidget_RemakeTexture(void* widget) {
cc_string range; char rangeBuffer[STRING_SIZE]; cc_string range; char rangeBuffer[STRING_SIZE];
struct TextInputWidget* w = (struct TextInputWidget*)widget; struct TextInputWidget* w = (struct TextInputWidget*)widget;
PackedCol backCol = PackedCol_Make(30, 30, 30, 200); PackedCol backColor = PackedCol_Make(30, 30, 30, 200);
struct MenuInputDesc* desc; struct MenuInputDesc* desc;
struct DrawTextArgs args; struct DrawTextArgs args;
struct Texture* tex; struct Texture* tex;
@ -1567,7 +1567,7 @@ static void TextInputWidget_RemakeTexture(void* widget) {
if (lineHeight < height) { y = height / 2 - lineHeight / 2; } if (lineHeight < height) { y = height / 2 - lineHeight / 2; }
w->base.caretOffset = 2 + y; w->base.caretOffset = 2 + y;
Drawer2D_Clear(&bmp, backCol, 0, 0, width, height); Drawer2D_Clear(&bmp, backColor, 0, 0, width, height);
Drawer2D_DrawText(&bmp, &args, w->base.padding, y); Drawer2D_DrawText(&bmp, &args, w->base.padding, y);
args.text = range; args.text = range;
@ -1700,7 +1700,7 @@ static void ChatInputWidget_RemakeTexture(void* widget) {
static void ChatInputWidget_Render(void* widget, double delta) { static void ChatInputWidget_Render(void* widget, double delta) {
struct InputWidget* w = (struct InputWidget*)widget; struct InputWidget* w = (struct InputWidget*)widget;
PackedCol backCol = PackedCol_Make(0, 0, 0, 127); PackedCol backColor = PackedCol_Make(0, 0, 0, 127);
int x = w->x, y = w->y; int x = w->x, y = w->y;
cc_bool caretAtEnd; cc_bool caretAtEnd;
int i, width; int i, width;
@ -1714,7 +1714,7 @@ static void ChatInputWidget_Render(void* widget, double delta) {
/* Cover whole window width to match original classic behaviour */ /* Cover whole window width to match original classic behaviour */
if (Gui.ClassicChat) { width = max(width, WindowInfo.Width - x * 4); } if (Gui.ClassicChat) { width = max(width, WindowInfo.Width - x * 4); }
Gfx_Draw2DFlat(x, y, width + w->padding * 2, w->lineHeight, backCol); Gfx_Draw2DFlat(x, y, width + w->padding * 2, w->lineHeight, backColor);
y += w->lineHeight; y += w->lineHeight;
} }
@ -2394,19 +2394,19 @@ static int SpecialInputWidget_MeasureTitles(struct SpecialInputWidget* w) {
} }
static void SpecialInputWidget_DrawTitles(struct SpecialInputWidget* w, struct Bitmap* bmp) { static void SpecialInputWidget_DrawTitles(struct SpecialInputWidget* w, struct Bitmap* bmp) {
BitmapCol col_selected = BitmapCol_Make(30, 30, 30, 200); BitmapCol color_selected = BitmapCol_Make(30, 30, 30, 200);
BitmapCol col_inactive = BitmapCol_Make( 0, 0, 0, 127); BitmapCol color_inactive = BitmapCol_Make( 0, 0, 0, 127);
BitmapCol col; BitmapCol color;
struct DrawTextArgs args; struct DrawTextArgs args;
int i, width, x = 0; int i, width, x = 0;
DrawTextArgs_MakeEmpty(&args, w->font, false); DrawTextArgs_MakeEmpty(&args, w->font, false);
for (i = 0; i < Array_Elems(w->tabs); i++) { for (i = 0; i < Array_Elems(w->tabs); i++) {
args.text = w->tabs[i].title; args.text = w->tabs[i].title;
col = i == w->selectedIndex ? col_selected : col_inactive; color = i == w->selectedIndex ? color_selected : color_inactive;
width = w->tabs[i].titleWidth; width = w->tabs[i].titleWidth;
Drawer2D_Clear(bmp, col, x, 0, width, w->titleHeight); Drawer2D_Clear(bmp, color, x, 0, width, w->titleHeight);
Drawer2D_DrawText(bmp, &args, x + SPECIAL_TITLE_SPACING / 2, 0); Drawer2D_DrawText(bmp, &args, x + SPECIAL_TITLE_SPACING / 2, 0);
x += width; x += width;
} }

View File

@ -113,14 +113,14 @@ void Gfx_UpdateDynamicVb_IndexedTris(GfxResourceID vb, void* vertices, int vCoun
Gfx_DrawVb_IndexedTris(vCount); Gfx_DrawVb_IndexedTris(vCount);
} }
void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol col) { void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol color) {
struct VertexColoured verts[4]; struct VertexColoured verts[4];
struct VertexColoured* v = verts; struct VertexColoured* v = verts;
v->X = (float)x; v->Y = (float)y; v->Z = 0; v->Col = col; v++; v->X = (float)x; v->Y = (float)y; v->Z = 0; v->Col = color; v++;
v->X = (float)(x + width); v->Y = (float)y; v->Z = 0; v->Col = col; v++; v->X = (float)(x + width); v->Y = (float)y; v->Z = 0; v->Col = color; v++;
v->X = (float)(x + width); v->Y = (float)(y + height); v->Z = 0; v->Col = col; v++; v->X = (float)(x + width); v->Y = (float)(y + height); v->Z = 0; v->Col = color; v++;
v->X = (float)x; v->Y = (float)(y + height); v->Z = 0; v->Col = col; v++; v->X = (float)x; v->Y = (float)(y + height); v->Z = 0; v->Col = color; v++;
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED); Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
Gfx_UpdateDynamicVb_IndexedTris(Gfx_quadVb, verts, 4); Gfx_UpdateDynamicVb_IndexedTris(Gfx_quadVb, verts, 4);
@ -139,15 +139,15 @@ void Gfx_Draw2DGradient(int x, int y, int width, int height, PackedCol top, Pack
Gfx_UpdateDynamicVb_IndexedTris(Gfx_quadVb, verts, 4); Gfx_UpdateDynamicVb_IndexedTris(Gfx_quadVb, verts, 4);
} }
void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol col) { void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol color) {
struct VertexTextured texVerts[4]; struct VertexTextured texVerts[4];
struct VertexTextured* ptr = texVerts; struct VertexTextured* ptr = texVerts;
Gfx_Make2DQuad(tex, col, &ptr); Gfx_Make2DQuad(tex, color, &ptr);
Gfx_SetVertexFormat(VERTEX_FORMAT_TEXTURED); Gfx_SetVertexFormat(VERTEX_FORMAT_TEXTURED);
Gfx_UpdateDynamicVb_IndexedTris(Gfx_texVb, texVerts, 4); Gfx_UpdateDynamicVb_IndexedTris(Gfx_texVb, texVerts, 4);
} }
void Gfx_Make2DQuad(const struct Texture* tex, PackedCol col, struct VertexTextured** vertices) { void Gfx_Make2DQuad(const struct Texture* tex, PackedCol color, struct VertexTextured** vertices) {
float x1 = (float)tex->X, x2 = (float)(tex->X + tex->Width); float x1 = (float)tex->X, x2 = (float)(tex->X + tex->Width);
float y1 = (float)tex->Y, y2 = (float)(tex->Y + tex->Height); float y1 = (float)tex->Y, y2 = (float)(tex->Y + tex->Height);
struct VertexTextured* v = *vertices; struct VertexTextured* v = *vertices;
@ -159,10 +159,10 @@ void Gfx_Make2DQuad(const struct Texture* tex, PackedCol col, struct VertexTextu
y1 -= 0.5f; y2 -= 0.5f; y1 -= 0.5f; y2 -= 0.5f;
#endif #endif
v->X = x1; v->Y = y1; v->Z = 0; v->Col = col; v->U = tex->uv.U1; v->V = tex->uv.V1; v++; v->X = x1; v->Y = y1; v->Z = 0; v->Col = color; v->U = tex->uv.U1; v->V = tex->uv.V1; v++;
v->X = x2; v->Y = y1; v->Z = 0; v->Col = col; v->U = tex->uv.U2; v->V = tex->uv.V1; v++; v->X = x2; v->Y = y1; v->Z = 0; v->Col = color; v->U = tex->uv.U2; v->V = tex->uv.V1; v++;
v->X = x2; v->Y = y2; v->Z = 0; v->Col = col; v->U = tex->uv.U2; v->V = tex->uv.V2; v++; v->X = x2; v->Y = y2; v->Z = 0; v->Col = color; v->U = tex->uv.U2; v->V = tex->uv.V2; v++;
v->X = x1; v->Y = y2; v->Z = 0; v->Col = col; v->U = tex->uv.U1; v->V = tex->uv.V2; v++; v->X = x1; v->Y = y2; v->Z = 0; v->Col = color; v->U = tex->uv.U1; v->V = tex->uv.V2; v++;
*vertices = v; *vertices = v;
} }