Mercurial > hg > openttd
changeset 4444:b7bbcb0f7ed0 draft
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
All the struct holds is a simple colour gradient, so using a simple array with 8 entries is more clear
Also add the names of colour the gradients as enum
author | tron <tron@openttd.org> |
---|---|
date | Tue, 29 Aug 2006 19:26:13 +0000 |
parents | 917acff8e545 |
children | a65661ff31c2 |
files | gfx.h graph_gui.c main_gui.c players.c settings_gui.c viewport.c widget.c |
diffstat | 7 files changed, 57 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/gfx.h +++ b/gfx.h @@ -5,13 +5,6 @@ typedef byte Pixel; -typedef struct ColorList { - byte unk0, unk1, unk2; - byte window_color_1a, window_color_1b; - byte window_color_bga, window_color_bgb; - byte window_color_2; -} ColorList; - struct DrawPixelInfo { Pixel *dst_ptr; int left, top, width, height; @@ -122,9 +115,33 @@ VARDEF DrawPixelInfo _screen; VARDEF DrawPixelInfo *_cur_dpi; -VARDEF ColorList _color_list[16]; VARDEF CursorVars _cursor; +enum { + COLOUR_DARK_BLUE, + COLOUR_PALE_GREEN, + COLOUR_PINK, + COLOUR_YELLOW, + COLOUR_RED, + COLOUR_LIGHT_BLUE, + COLOUR_GREEN, + COLOUR_DARK_GREEN, + COLOUR_BLUE, + COLOUR_CREAM, + COLOUR_MAUVE, + COLOUR_PURPLE, + COLOUR_ORANGE, + COLOUR_BROWN, + COLOUR_GREY, + COLOUR_WHITE +}; + +/** + * All 16 colour gradients + * 8 colours per gradient from darkest (0) to lightest (7) + */ +VARDEF byte _colour_gradient[16][8]; + VARDEF int _pal_first_dirty; VARDEF int _pal_last_dirty;
--- a/graph_gui.c +++ b/graph_gui.c @@ -65,7 +65,7 @@ * both values for cargo and players. So if any are higher, quit */ assert(GRAPH_NUM >= NUM_CARGO && GRAPH_NUM >= MAX_PLAYERS); - color = _color_list[gw->bg_line_color].window_color_1b; + color = _colour_gradient[gw->bg_line_color][4]; /* draw the vertical lines */ i = gw->num_vert_lines; assert(i > 0); @@ -344,7 +344,7 @@ numd = 0; FOR_ALL_PLAYERS(p) { if (p->is_active) { - gd.colors[numd] = _color_list[p->player_color].window_color_bgb; + gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)(p->old_economy[j].income + p->old_economy[j].expenses); i++; @@ -417,7 +417,7 @@ numd = 0; FOR_ALL_PLAYERS(p) { if (p->is_active) { - gd.colors[numd] = _color_list[p->player_color].window_color_bgb; + gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].income; i++; @@ -490,7 +490,7 @@ numd = 0; FOR_ALL_PLAYERS(p) { if (p->is_active) { - gd.colors[numd] = _color_list[p->player_color].window_color_bgb; + gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].delivered_cargo; i++; @@ -563,7 +563,7 @@ numd = 0; FOR_ALL_PLAYERS(p) { if (p->is_active) { - gd.colors[numd] = _color_list[p->player_color].window_color_bgb; + gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].performance_history; i++; @@ -639,7 +639,7 @@ numd = 0; FOR_ALL_PLAYERS(p) { if (p->is_active) { - gd.colors[numd] = _color_list[p->player_color].window_color_bgb; + gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].company_value; i++; @@ -923,8 +923,8 @@ } // The colors used to show how the progress is going - color_done = _color_list[6].window_color_1b; - color_notdone = _color_list[4].window_color_1b; + color_done = _colour_gradient[COLOUR_GREEN][4]; + color_notdone = _colour_gradient[COLOUR_RED][4]; // Draw all the score parts for (i = 0; i < NUM_SCORE; i++) {
--- a/main_gui.c +++ b/main_gui.c @@ -2349,7 +2349,7 @@ const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i); assert(b); - _color_list[i] = *(const ColorList*)(b + 0xC6); + memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i])); } width = _screen.width;
--- a/players.c +++ b/players.c @@ -34,7 +34,7 @@ * player */ if (player == OWNER_SPECTATOR || player == OWNER_SPECTATOR - 1) return 1; - return (_color_list[_player_colors[player]].window_color_1b) | IS_PALETTE_COLOR; + return (_colour_gradient[_player_colors[player]][4]) | IS_PALETTE_COLOR; }
--- a/settings_gui.c +++ b/settings_gui.c @@ -413,7 +413,7 @@ DrawFrameRect( 5, y, 5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? FR_LOWERED : 0); DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? FR_LOWERED : 0); if (GetBitAndShift(&disabled) || (_networking && !_network_server)) { - int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2; + int color = PALETTE_MODIFIER_GREYOUT | _colour_gradient[COLOUR_YELLOW][2]; GfxFillRect( 6, y + 1, 6 + 8, y + 8, color); GfxFillRect(16, y + 1, 16 + 8, y + 8, color); } @@ -1061,7 +1061,7 @@ */ void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right) { - int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2; + int color = PALETTE_MODIFIER_GREYOUT | _colour_gradient[COLOUR_YELLOW][2]; DrawFrameRect(x, y + 1, x + 9, y + 9, ctab, (state == 1) ? FR_LOWERED : 0); DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : 0);
--- a/viewport.c +++ b/viewport.c @@ -1166,7 +1166,7 @@ * otherwise colors from _string_colormap are assumed. */ DrawString( ss->x >> zoom, (ss->y >> zoom) - (ss->width & 0x8000 ? 2 : 0), - ss->string, (_color_list[ss->color].window_color_bgb | IS_PALETTE_COLOR) + ss->string, _colour_gradient[ss->color][6] | IS_PALETTE_COLOR ); } else { DrawString(
--- a/widget.c +++ b/widget.c @@ -152,10 +152,10 @@ void DrawFrameRect(int left, int top, int right, int bottom, int ctab, FrameFlags flags) { - uint dark = _color_list[ctab].window_color_1a; - uint medium_dark = _color_list[ctab].window_color_bga; - uint medium_light = _color_list[ctab].window_color_bgb; - uint light = _color_list[ctab].window_color_2; + uint dark = _colour_gradient[ctab][3]; + uint medium_dark = _colour_gradient[ctab][5]; + uint medium_light = _colour_gradient[ctab][6]; + uint light = _colour_gradient[ctab][7]; if (flags & FR_TRANSPARENT) { GfxFillRect(left, top, right, bottom, 0x322 | USE_COLORTABLE); @@ -261,7 +261,7 @@ d = GB(wi->unkA, 8, 8); amt2 = (wi->bottom - wi->top + 1) / d; - color = _color_list[wi->color & 0xF].window_color_bgb; + color = _colour_gradient[wi->color & 0xF][6]; x = r.left; for (ctr = c; ctr > 1; ctr--) { @@ -275,7 +275,7 @@ GfxFillRect(r.left + 1, x, r.right - 1, x, color); } - color = _color_list[wi->color&0xF].window_color_1b; + color = _colour_gradient[wi->color&0xF][4]; x = r.left - 1; for (ctr = c; ctr > 1; ctr--) { @@ -308,8 +308,8 @@ DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); - c1 = _color_list[wi->color&0xF].window_color_1a; - c2 = _color_list[wi->color&0xF].window_color_2; + c1 = _colour_gradient[wi->color&0xF][3]; + c2 = _colour_gradient[wi->color&0xF][7]; // draw "shaded" background GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); @@ -340,8 +340,8 @@ DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); - c1 = _color_list[wi->color&0xF].window_color_1a; - c2 = _color_list[wi->color&0xF].window_color_2; + c1 = _colour_gradient[wi->color&0xF][3]; + c2 = _colour_gradient[wi->color&0xF][7]; // draw "shaded" background GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); @@ -373,8 +373,8 @@ DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked); - c1 = _color_list[wi->color&0xF].window_color_1a; - c2 = _color_list[wi->color&0xF].window_color_2; + c1 = _colour_gradient[wi->color&0xF][3]; + c2 = _colour_gradient[wi->color&0xF][7]; // draw "shaded" background GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2); @@ -399,8 +399,8 @@ if (wi->unkA != 0) x2 = DrawString(r.left + 6, r.top, wi->unkA, 0); - c1 = _color_list[wi->color].window_color_1a; - c2 = _color_list[wi->color].window_color_2; + c1 = _colour_gradient[wi->color][3]; + c2 = _colour_gradient[wi->color][7]; //Line from upper left corner to start of text GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1); @@ -456,13 +456,13 @@ DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY); if (w->caption_color != 0xFF) { - GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _color_list[_player_colors[w->caption_color]].window_color_1b); + GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _colour_gradient[_player_colors[w->caption_color]][4]); } DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84); draw_default:; if (cur_disabled & 1) { - GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | PALETTE_MODIFIER_GREYOUT); + GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _colour_gradient[wi->color&0xF][2] | PALETTE_MODIFIER_GREYOUT); } } } @@ -530,12 +530,12 @@ if (HASBIT(WP(w,dropdown_d).disabled_state, i)) { GfxFillRect(x, y, x + w->width - 3, y + 9, - PALETTE_MODIFIER_GREYOUT | _color_list[_dropdown_menu_widgets[0].color].window_color_bga + PALETTE_MODIFIER_GREYOUT | _colour_gradient[_dropdown_menu_widgets[0].color][5] ); } } else { - int c1 = _color_list[_dropdown_menu_widgets[0].color].window_color_1a; - int c2 = _color_list[_dropdown_menu_widgets[0].color].window_color_2; + int c1 = _colour_gradient[_dropdown_menu_widgets[0].color][3]; + int c2 = _colour_gradient[_dropdown_menu_widgets[0].color][7]; GfxFillRect(x + 1, y + 3, x + w->width - 5, y + 3, c1); GfxFillRect(x + 1, y + 4, x + w->width - 5, y + 4, c2);