From 8607bbf06d0fd1781c6ea7cb551327bfde2a6b4b Mon Sep 17 00:00:00 2001 From: hackykid Date: Wed, 15 Jun 2005 17:27:14 +0000 Subject: (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_) --- aircraft_gui.c | 2 +- misc_gui.c | 10 +++++----- music_gui.c | 4 ++-- news_gui.c | 2 +- roadveh_gui.c | 2 +- settings_gui.c | 18 +++++++++--------- ship_gui.c | 2 +- train_gui.c | 2 +- viewport.c | 2 +- widget.c | 36 ++++++++++++++++++------------------ window.h | 8 ++++++++ 11 files changed, 48 insertions(+), 40 deletions(-) diff --git a/aircraft_gui.c b/aircraft_gui.c index 3515d0c24..ae475173a 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -67,7 +67,7 @@ static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selectio if (v->subtype == 0) DrawSprite(0xF3D, x+25, y+5); if (v->index == selection) { - DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, 0x10); + DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, FR_BORDERONLY); } } diff --git a/misc_gui.c b/misc_gui.c index c991d958a..daa8ed224 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -1725,19 +1725,19 @@ static void CheatsWndProc(Window *w, WindowEvent *e) DrawSprite((SPR_OPENTTD_BASE + ((*ce->been_used)?67:66)), x+5, y+2); if (ce->type == CE_BOOL) { - DrawFrameRect(x+20, y+1, x+30+9, y+9, (*(bool*)ce->variable)?6:4, (*(bool*)ce->variable)?0x20:0); + DrawFrameRect(x+20, y+1, x+30+9, y+9, (*(bool*)ce->variable) ? 6 : 4, (*(bool*)ce->variable) ? FR_LOWERED : 0); SetDParam(0, *(bool*)ce->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); } else if (ce->type == CE_CLICK) { - DrawFrameRect(x+20, y+1, x+30+9, y+9, 0, (WP(w,def_d).data_1==i*2+1)?0x20:0x00); - if(i==0) + DrawFrameRect(x+20, y+1, x+30+9, y+9, 0, (WP(w,def_d).data_1 == i*2+1) ? FR_LOWERED : 0); + if (i == 0) SetDParam64(0, (int64) 10000000); else SetDParam(0, false); } else { - DrawFrameRect(x+20, y+1, x+20+9, y+9, 3, clk == i*2+1 ? 0x20 : 0); - DrawFrameRect(x+30, y+1, x+30+9, y+9, 3, clk == i*2+2 ? 0x20 : 0); + DrawFrameRect(x+20, y+1, x+20+9, y+9, 3, clk == i*2+1 ? FR_LOWERED : 0); + DrawFrameRect(x+30, y+1, x+30+9, y+9, 3, clk == i*2+2 ? FR_LOWERED : 0); DrawStringCentered(x+25, y+1, STR_6819, 0); DrawStringCentered(x+35, y+1, STR_681A, 0); diff --git a/music_gui.c b/music_gui.c index c16efaa99..7f2e93cde 100644 --- a/music_gui.c +++ b/music_gui.c @@ -366,8 +366,8 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e) DrawStringCentered(247, 15, STR_01DC_EFFECTS_VOLUME, 0); DrawStringCentered(247, 29, STR_01DD_MIN_MAX, 0); - DrawFrameRect(108, 23, 174, 26, 14, 0x20); - DrawFrameRect(214, 23, 280, 26, 14, 0x20); + DrawFrameRect(108, 23, 174, 26, 14, FR_LOWERED); + DrawFrameRect(214, 23, 280, 26, 14, FR_LOWERED); DrawFrameRect(108 + (msf.music_vol>>1), 22, diff --git a/news_gui.c b/news_gui.c index 700f589e4..0baae7848 100644 --- a/news_gui.c +++ b/news_gui.c @@ -765,7 +765,7 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e) for (i = 0, y = 26; i != 10; i++, y += 12, click_state >>= 1, val >>= 2) { bool clicked = !!(click_state & 1); - DrawFrameRect(13, y, 89, 11 + y, 3, (clicked) ? 0x20 : 0); + DrawFrameRect(13, y, 89, 11 + y, 3, (clicked) ? FR_LOWERED : 0); DrawStringCentered(((13 + 89 + 1) >> 1) + clicked, ((y + 11 + y + 1) >> 1) - 5 + clicked, message_opt[val & 0x3], 0x10); DrawString(103, y + 1, i + STR_0206_ARRIVAL_OF_FIRST_VEHICLE, 0); } diff --git a/roadveh_gui.c b/roadveh_gui.c index 019c87d67..0092285cb 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -66,7 +66,7 @@ static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection DrawSprite(image | ormod, x+14, y+6); if (v->index == selection) { - DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10); + DrawFrameRect(x-1, y-1, x+28, y+12, 15, FR_BORDERONLY); } } diff --git a/settings_gui.c b/settings_gui.c index a0d716e6a..4583e6e06 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -842,13 +842,13 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) editable = false; if (pe->type == PE_BOOL) { if (editable) - DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable)?6:4, (*(bool*)pe->variable)?0x20:0); + DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable) ? 6 : 4, (*(bool*)pe->variable) ? FR_LOWERED : 0); else - DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable)?7:9, (*(bool*)pe->variable)?0x20:0); + DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable) ? 7 : 9, (*(bool*)pe->variable) ? FR_LOWERED : 0); SetDParam(0, *(bool*)pe->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); } else { - DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, clk == i*2+1 ? 0x20 : 0); - DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, clk == i*2+2 ? 0x20 : 0); + DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, clk == i*2+1 ? FR_LOWERED : 0); + DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, clk == i*2+2 ? FR_LOWERED : 0); if (!editable) { int color = 0x8000 | _color_list[3].unk2; GfxFillRect(x+6, y+2, x+6+8, y+9, color); @@ -1294,8 +1294,8 @@ void ShowNewgrf(void) /* state: 0 = none clicked, 0x01 = first clicked, 0x02 = second clicked */ void DrawArrowButtons(int x, int y, int state) { - DrawFrameRect(x, y+1, x+9, y+9, 3, (state&0x01) ? 0x20 : 0); - DrawFrameRect(x+10, y+1, x+19, y+9, 3, (state&0x02) ? 0x20 : 0); + DrawFrameRect(x, y+1, x+9, y+9, 3, (state & 0x01) ? FR_LOWERED : 0); + DrawFrameRect(x+10, y+1, x+19, y+9, 3, (state & 0x02) ? FR_LOWERED : 0); DrawStringCentered(x+5, y+1, STR_6819, 0); DrawStringCentered(x+15, y+1, STR_681A, 0); } @@ -1320,7 +1320,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) i++; // separator - DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03)?0x20:0x00); + DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03) ? FR_LOWERED : 0); x = DrawString(x, y + 1, STR_CURRENCY_SEPARATOR, 0); DoDrawString(_str_separator, x + 4, y + 1, 6); x = 35; @@ -1328,7 +1328,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) i++; // prefix - DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03)?0x20:0x00); + DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03) ? FR_LOWERED : 0); x = DrawString(x, y + 1, STR_CURRENCY_PREFIX, 0); DoDrawString(_currency_specs[23].prefix, x + 4, y + 1, 6); x = 35; @@ -1336,7 +1336,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) i++; // suffix - DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03)?0x20:0x00); + DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03) ? FR_LOWERED : 0); x = DrawString(x, y + 1, STR_CURRENCY_SUFFIX, 0); DoDrawString(_currency_specs[23].suffix, x + 4, y + 1, 6); x = 35; diff --git a/ship_gui.c b/ship_gui.c index 5100d3805..89eaefabf 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -64,7 +64,7 @@ static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) DrawSprite(image | ormod, x+32, y+10); if (v->index == selection) { - DrawFrameRect(x-5, y-1, x+67, y+21, 15, 0x10); + DrawFrameRect(x-5, y-1, x+67, y+21, 15, FR_BORDERONLY); } } diff --git a/train_gui.c b/train_gui.c index 63641a110..070b8e2d9 100644 --- a/train_gui.c +++ b/train_gui.c @@ -342,7 +342,7 @@ static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, ormod = PALETTE_CRASH; DrawSprite(image | ormod, x + 14, y + 6 + _traininfo_vehicle_pitch); if (v->index == selection) - DrawFrameRect(x - 1, y - 1, x + width + 4, y + 12, 15, 0x10); + DrawFrameRect(x - 1, y - 1, x + width + 4, y + 12, 15, FR_BORDERONLY); } x += width + 5; } diff --git a/viewport.c b/viewport.c index be0bbcf6e..e0e387542 100644 --- a/viewport.c +++ b/viewport.c @@ -1178,7 +1178,7 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, StringSpriteToDraw *ss) /* Draw the rectangle if 'tranparent station signs' is off, or if we are drawing a general text sign (STR_2806) */ if(!(_display_opt & DO_TRANS_SIGNS) || ss->string == STR_2806) - DrawFrameRect(x,y, x+w, bottom, ss->color, (_display_opt & DO_TRANS_BUILDINGS) ? 0x9 : 0); + DrawFrameRect(x,y, x+w, bottom, ss->color, (_display_opt & DO_TRANS_BUILDINGS) ? FR_TRANSPARENT | FR_NOBORDER : 0); } SetDParam(0, ss->params[0]); diff --git a/widget.c b/widget.c index 6cf5b03f6..1ef1701dd 100644 --- a/widget.c +++ b/widget.c @@ -189,7 +189,7 @@ void DrawWindowWidgets(Window *w) case WWT_PANEL_2: { int img; - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); if ((img = wi->unkA) != 0) { // has an image if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++; // show diff image when clicked @@ -201,7 +201,7 @@ void DrawWindowWidgets(Window *w) case WWT_CLOSEBOX: /* WWT_TEXTBTN */ case WWT_4: { - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); } /* fall through */ @@ -217,7 +217,7 @@ void DrawWindowWidgets(Window *w) case WWT_6: { StringID str; - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x60); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED); if ((str = wi->unkA) != 0) { DrawString(r.left+2, r.top+1, str, 0); @@ -231,7 +231,7 @@ void DrawWindowWidgets(Window *w) int x, amt1, amt2; int color; - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); c = (wi->unkA&0xFF); amt1 = (wi->right - wi->left + 1) / c; @@ -279,11 +279,11 @@ void DrawWindowWidgets(Window *w) // draw up/down buttons clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP); - DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); DoDrawString("\xA0", r.left + 2 + clicked, r.top + clicked, 0x10); clicked = !!(((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN)); - DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DoDrawString("\xAA", r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); c1 = _color_list[wi->color&0xF].window_color_1a; @@ -300,7 +300,7 @@ void DrawWindowWidgets(Window *w) GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); - DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? 0x20 : 0); + DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : 0); break; } case WWT_SCROLL2BAR: { @@ -311,11 +311,11 @@ void DrawWindowWidgets(Window *w) // draw up/down buttons clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2)); - DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); DoDrawString("\xA0", r.left + 2 + clicked, r.top + clicked, 0x10); clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2)); - DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DoDrawString("\xAA", r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); c1 = _color_list[wi->color&0xF].window_color_1a; @@ -332,7 +332,7 @@ void DrawWindowWidgets(Window *w) GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); - DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? 0x20 : 0); + DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : 0); break; } @@ -344,11 +344,11 @@ void DrawWindowWidgets(Window *w) assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere! clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL)); - DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked); clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL)); - DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + 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; @@ -366,7 +366,7 @@ void DrawWindowWidgets(Window *w) // draw actual scrollbar pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); - DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? 0x20 : 0); + DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : 0); break; } @@ -406,7 +406,7 @@ void DrawWindowWidgets(Window *w) case WWT_STICKYBOX: { assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked); break; } @@ -415,15 +415,15 @@ void DrawWindowWidgets(Window *w) assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! clicked = !!(w->flags4 & WF_SIZING); - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked); break; } case WWT_CAPTION: { assert(r.bottom - r.top == 13); // XXX - to ensure the same sizes are used everywhere! - DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10); - DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? 0x60 : 0x70); + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY); + 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); @@ -443,7 +443,7 @@ draw_default:; if (w->flags4 & WF_WHITE_BORDER_MASK) { //DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10); - DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, 0x10); + DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, FR_BORDERONLY); } } diff --git a/window.h b/window.h index b823a920c..96074d9f3 100644 --- a/window.h +++ b/window.h @@ -61,6 +61,14 @@ typedef struct Widget { uint16 tooltips; } Widget; +enum FrameFlags { + FR_TRANSPARENT = 0x01, ///< Makes the background transparent if set + FR_NOBORDER = 0x08, ///< Hide border (draws just a solid box) + FR_BORDERONLY = 0x10, ///< Draw border only, no background + FR_LOWERED = 0x20, ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed) + FR_DARKENED = 0x40, ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes) +}; + /* XXX - outside "byte event" so you can set event directly without going into * the union elements at first. Because of this every first element of the union * MUST BE 'byte event'. Whoever did this must get shot! Scheduled for immediate -- cgit v1.2.3-54-g00ecf