diff options
author | tron <tron@openttd.org> | 2006-08-29 19:26:13 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-08-29 19:26:13 +0000 |
commit | b83a3f8726e3980820fa2c4b508f70a56826228b (patch) | |
tree | bfebe9391624be5031618ddb87d904e064fe4034 | |
parent | 21db9de388330156680de6fd745d770563de0270 (diff) | |
download | openttd-b83a3f8726e3980820fa2c4b508f70a56826228b.tar.xz |
(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
-rw-r--r-- | gfx.h | 33 | ||||
-rw-r--r-- | graph_gui.c | 16 | ||||
-rw-r--r-- | main_gui.c | 2 | ||||
-rw-r--r-- | players.c | 2 | ||||
-rw-r--r-- | settings_gui.c | 4 | ||||
-rw-r--r-- | viewport.c | 2 | ||||
-rw-r--r-- | widget.c | 38 |
7 files changed, 57 insertions, 40 deletions
@@ -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 @@ static inline byte GetCharacterHeight(FontSize size) 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; diff --git a/graph_gui.c b/graph_gui.c index 011bbc1cd..58f4ac638 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -65,7 +65,7 @@ static void DrawGraph(const GraphDrawer *gw) * 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 @@ static void OperatingProfitWndProc(Window *w, WindowEvent *e) 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 @@ static void IncomeGraphWndProc(Window *w, WindowEvent *e) 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 @@ static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e) 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 @@ static void PerformanceHistoryWndProc(Window *w, WindowEvent *e) 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 @@ static void CompanyValueGraphWndProc(Window *w, WindowEvent *e) 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 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) } // 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++) { diff --git a/main_gui.c b/main_gui.c index 65dcce396..de3c9ec85 100644 --- a/main_gui.c +++ b/main_gui.c @@ -2349,7 +2349,7 @@ void SetupColorsAndInitialWindow(void) 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; @@ -34,7 +34,7 @@ uint16 GetDrawStringPlayerColor(PlayerID player) * 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; } diff --git a/settings_gui.c b/settings_gui.c index 33a14de37..a6b1a4647 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -413,7 +413,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e) 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 ShowNewgrf(void) */ 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); diff --git a/viewport.c b/viewport.c index 4af32ead9..7200c2156 100644 --- a/viewport.c +++ b/viewport.c @@ -1166,7 +1166,7 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss * 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( @@ -152,10 +152,10 @@ int GetWidgetFromPos(const Window *w, int x, int y) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ void DrawWindowWidgets(const Window *w) 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 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e) 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); |