From 35a4736df067da92eccbb560beb55cdb2320b42b Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 12 Feb 2016 04:02:28 +0000 Subject: [PATCH] Pass color to gr_urect --- common/2d/rect.cpp | 3 +-- common/include/fwd-gr.h | 2 +- common/ui/icon.cpp | 3 ++- common/ui/keypad.cpp | 3 ++- common/ui/menubar.cpp | 11 +++++++---- common/ui/uidraw.cpp | 4 ++-- similar/main/kconfig.cpp | 19 ++++++++++++------- similar/main/newmenu.cpp | 14 ++++++++++---- 8 files changed, 37 insertions(+), 22 deletions(-) diff --git a/common/2d/rect.cpp b/common/2d/rect.cpp index bf4852972..9b3ed8278 100644 --- a/common/2d/rect.cpp +++ b/common/2d/rect.cpp @@ -33,9 +33,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. namespace dcx { -void gr_urect(int left,int top,int right,int bot) +void gr_urect(int left,int top,int right,int bot, const uint8_t color) { - const auto color = COLOR; #ifdef OGL if (TYPE == BM_OGL) { ogl_urect(left,top,right,bot, color); diff --git a/common/include/fwd-gr.h b/common/include/fwd-gr.h index 0a167531a..bd8828c94 100644 --- a/common/include/fwd-gr.h +++ b/common/include/fwd-gr.h @@ -219,7 +219,7 @@ void gr_ubitmapm(unsigned x, unsigned y, grs_bitmap &bm); // Draw a rectangle into the current canvas. void gr_rect(int left,int top,int right,int bot); -void gr_urect(int left,int top,int right,int bot); +void gr_urect(int left,int top,int right,int bot, uint8_t color); // Draw a filled circle int gr_disk(fix x,fix y,fix r); diff --git a/common/ui/icon.cpp b/common/ui/icon.cpp index 7f500b16e..8278467ac 100644 --- a/common/ui/icon.cpp +++ b/common/ui/icon.cpp @@ -37,8 +37,9 @@ namespace dcx { static void ui_draw_box_in1( short x1, short y1, short x2, short y2 ) { + const uint8_t color = CWHITE; gr_setcolor( CWHITE ); - gr_urect( x1+1, y1+1, x2-1, y2-1 ); + gr_urect(x1+1, y1+1, x2-1, y2-1, color); ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CGREY, CBRIGHT ); } diff --git a/common/ui/keypad.cpp b/common/ui/keypad.cpp index 1cee769b9..3e799c412 100644 --- a/common/ui/keypad.cpp +++ b/common/ui/keypad.cpp @@ -273,8 +273,9 @@ void ui_pad_draw(UI_DIALOG *dlg, int x, int y) ui_draw_box_in( x, y, x+(bw*4)+10 + 200, y+(bh*5)+45 ); gr_set_current_canvas( NULL ); + const uint8_t color = CWHITE; gr_setcolor( CWHITE ); - gr_urect( desc_x, desc_y, desc_x+ 56*4-1, desc_y+15 ); + gr_urect( desc_x, desc_y, desc_x+ 56*4-1, desc_y+15, color); gr_set_fontcolor( CBLACK, CWHITE ); gr_ustring(desc_x, desc_y, KeyPad[active_pad]->description.data()); } diff --git a/common/ui/menubar.cpp b/common/ui/menubar.cpp index f2d35ba0e..a0abd1375 100644 --- a/common/ui/menubar.cpp +++ b/common/ui/menubar.cpp @@ -85,8 +85,9 @@ static void item_show( MENU * menu, int n ) // If this is a seperator, then draw it. if ( item->Text[0] == '-' ) { + const uint8_t color = CBLACK; gr_setcolor( CBLACK ); - gr_urect( item->x, item->y+item->h/2, item->x+item->w-1, item->y+item->h/2 ); + gr_urect( item->x, item->y+item->h/2, item->x+item->w-1, item->y+item->h/2, color); return; } @@ -94,15 +95,17 @@ static void item_show( MENU * menu, int n ) { if ( menu != &Menu[0] ) { + const uint8_t color = CBLACK; gr_setcolor( CBLACK ); - gr_urect( item->x+1, item->y+1, item->x+menu->w-2, item->y+item->h-2 ); + gr_urect( item->x+1, item->y+1, item->x+menu->w-2, item->y+item->h-2, color); } gr_set_fontcolor( CWHITE, CBLACK ); }else { if ( menu != &Menu[0] ) { + const uint8_t color = CGREY; gr_setcolor( CGREY ); - gr_urect( item->x+1, item->y+1, item->x+menu->w-2, item->y+item->h-2 ); + gr_urect( item->x+1, item->y+1, item->x+menu->w-2, item->y+item->h-2, color); } gr_set_fontcolor( CBLACK, CGREY ); } @@ -129,7 +132,7 @@ static void menu_draw(MENU *menu) // Draw the menu background gr_setcolor( CGREY ); - gr_urect( menu->x, menu->y, menu->x + menu->w - 1, menu->y + menu->h - 1 ); + gr_urect( menu->x, menu->y, menu->x + menu->w - 1, menu->y + menu->h - 1, CGREY); if ( menu != &Menu[0] ) { gr_setcolor( CBLACK ); diff --git a/common/ui/uidraw.cpp b/common/ui/uidraw.cpp index efaf13711..80128b769 100644 --- a/common/ui/uidraw.cpp +++ b/common/ui/uidraw.cpp @@ -85,8 +85,9 @@ void ui_draw_frame( short x1, short y1, short x2, short y2 ) void ui_draw_box_out( short x1, short y1, short x2, short y2 ) { + const uint8_t color = CWHITE; gr_setcolor( CWHITE ); - gr_urect( x1+2, y1+2, x2-2, y2-2 ); + gr_urect( x1+2, y1+2, x2-2, y2-2, color); ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CBRIGHT, CGREY ); ui_draw_shad( x1+1, y1+1, x2-1, y2-1, CBRIGHT, CGREY ); @@ -97,7 +98,6 @@ void ui_draw_box_in( short x1, short y1, short x2, short y2 ) { gr_setcolor( CWHITE ); -// gr_urect( x1+2, y1+2, x2-2, y2-2 ); ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CGREY, CBRIGHT ); ui_draw_shad( x1+1, y1+1, x2-1, y2-1, CGREY, CBRIGHT ); diff --git a/similar/main/kconfig.cpp b/similar/main/kconfig.cpp index 4e2f84718..a0d8c0a09 100644 --- a/similar/main/kconfig.cpp +++ b/similar/main/kconfig.cpp @@ -1323,6 +1323,7 @@ static void kc_drawinput(const kc_item &item, kc_mitem& mitem, int is_current, c const char *btext; const auto &&fspacx = FSPACX(); const auto &&fspacy = FSPACY(); + unsigned r, g, b; if (label) { gr_set_fontcolor(is_current ? BM_XRGB(20, 20, 29) : BM_XRGB(15, 15, 24), -1 ); @@ -1333,11 +1334,16 @@ static void kc_drawinput(const kc_item &item, kc_mitem& mitem, int is_current, c if (!btext) return; { - gr_setcolor(is_current ? BM_XRGB(21, 0, 24) : BM_XRGB(16, 0, 19)); + if (is_current) + r = 21 * 2, g = 0, b = 24 * 2; + else + r = 16 * 2, g = 0, b = 19 * 2; + const uint8_t color = BM_XRGB(r, g, b); + gr_setcolor(color); int x, w, h; gr_get_string_size(btext, &w, &h, nullptr); - gr_urect(fspacx(item.xinput), fspacy(item.y - 1), fspacx(item.xinput + item.w2), fspacy(item.y) + h); + gr_urect(fspacx(item.xinput), fspacy(item.y - 1), fspacx(item.xinput + item.w2), fspacy(item.y) + h, color); gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); @@ -1353,12 +1359,11 @@ static void kc_drawquestion( kc_menu *menu, const kc_item *item ) int x; #if defined(DXX_BUILD_DESCENT_I) - int c = BM_XRGB(21,0,24); - - gr_setcolor( gr_fade_table[fades[menu->q_fade_i]][c] ); + const uint8_t color = gr_fade_table[fades[menu->q_fade_i]][BM_XRGB(21,0,24)]; #elif defined(DXX_BUILD_DESCENT_II) - gr_setcolor(BM_XRGB(21*fades[menu->q_fade_i]/31,0,24*fades[menu->q_fade_i]/31)); + const uint8_t color = BM_XRGB(21*fades[menu->q_fade_i]/31,0,24*fades[menu->q_fade_i]/31); #endif + gr_setcolor(color); menu->q_fade_i++; if (menu->q_fade_i>63) menu->q_fade_i=0; @@ -1367,7 +1372,7 @@ static void kc_drawquestion( kc_menu *menu, const kc_item *item ) int w, h; gr_get_string_size("?", &w, &h, nullptr); - gr_urect(fspacx(item->xinput), fspacy(item->y - 1), fspacx(item->xinput + item->w2), fspacy(item->y) + h); + gr_urect(fspacx(item->xinput), fspacy(item->y - 1), fspacx(item->xinput + item->w2), fspacy(item->y) + h, color); gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); diff --git a/similar/main/newmenu.cpp b/similar/main/newmenu.cpp index 65ac454ce..8a0e26b4e 100644 --- a/similar/main/newmenu.cpp +++ b/similar/main/newmenu.cpp @@ -194,12 +194,18 @@ void nm_draw_background(int x1, int y1, int x2, int y2 ) gr_set_current_canvas(old); gr_settransblend(14, GR_BLEND_NORMAL); - gr_setcolor( BM_XRGB(1,1,1) ); + { + const uint8_t color = BM_XRGB(1, 1, 1); + gr_setcolor(color); for (w=5*BGScaleX;w>0;w--) - gr_urect( x2-w, y1+w*(BGScaleY/BGScaleX), x2-w, y2-w*(BGScaleY/BGScaleX) );//right edge - gr_setcolor( BM_XRGB(0,0,0) ); + gr_urect( x2-w, y1+w*(BGScaleY/BGScaleX), x2-w, y2-w*(BGScaleY/BGScaleX), color);//right edge + } + { + const uint8_t color = BM_XRGB(0, 0, 0); + gr_setcolor(color); for (h=5*BGScaleY;h>0;h--) - gr_urect( x1+h*(BGScaleX/BGScaleY), y2-h, x2-h*(BGScaleX/BGScaleY), y2-h );//bottom edge + gr_urect( x1+h*(BGScaleX/BGScaleY), y2-h, x2-h*(BGScaleX/BGScaleY), y2-h, color);//bottom edge + } gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); }