From 53012324a8275f6f3446b3fbaaa228842428411c Mon Sep 17 00:00:00 2001 From: mcmartin Date: Sun, 12 Nov 2006 07:07:51 +0000 Subject: [PATCH] Graphics cleanups: locking, colors.h for shadowboxes git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2498 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/colors.h | 11 ++++++++++- sc2/src/sc2code/confirm.c | 7 ++----- sc2/src/sc2code/libs/graphics/widgets.c | 8 +++----- sc2/src/sc2code/melee.c | 12 ++++++------ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/sc2/src/sc2code/colors.h b/sc2/src/sc2code/colors.h index 57bded8de..92c58d3f6 100644 --- a/sc2/src/sc2code/colors.h +++ b/sc2/src/sc2code/colors.h @@ -140,7 +140,16 @@ // The text "MORE" when reviewing the conversation history. #define COMM_MORE_TEXT_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x17, 0x00), 0x00) - + +// Default colors for System Dialog Boxes (DrawShadowedBox) +#define SHADOWBOX_BACKGROUND_COLOR \ + MENU_BACKGROUND_COLOR + +#define SHADOWBOX_MEDIUM_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19) + +#define SHADOWBOX_DARK_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F) #endif /* _COLORS_H */ diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index bb290492c..535d8042f 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -38,21 +38,18 @@ static void DrawConfirmationWindow (BOOLEAN answer) { COLOR oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR); - COLOR dark, medium; FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; TEXT t; - dark = BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F); - medium = BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19); - BatchGraphics (); r.corner.x = (SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1; r.corner.y = (SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1; r.extent.width = CONFIRM_WIN_WIDTH; r.extent.height = CONFIRM_WIN_HEIGHT; - DrawShadowedBox (&r, MENU_BACKGROUND_COLOR, dark, medium); + DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR, + SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + 8; diff --git a/sc2/src/sc2code/libs/graphics/widgets.c b/sc2/src/sc2code/libs/graphics/widgets.c index 4fc835a70..a478228e3 100644 --- a/sc2/src/sc2code/libs/graphics/widgets.c +++ b/sc2/src/sc2code/libs/graphics/widgets.c @@ -1,5 +1,6 @@ #include "graphics/gfx_common.h" #include "graphics/widgets.h" +#include "colors.h" #include "strlib.h" #include "setup.h" #include "units.h" @@ -63,16 +64,12 @@ void DrawLabelAsWindow(WIDGET_LABEL *label) { COLOR oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); - COLOR dark, medium; FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; TEXT t; int i, win_w, win_h; - dark = BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F); - medium = BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19); - /* Compute the dimensions of the label */ win_h = label->height ((WIDGET *)label) + 16; win_w = 0; @@ -91,7 +88,8 @@ DrawLabelAsWindow(WIDGET_LABEL *label) r.corner.y = (SCREEN_HEIGHT - win_h) >> 1; r.extent.width = win_w; r.extent.height = win_h; - DrawShadowedBox (&r, WIDGET_DIALOG_COLOR, dark, medium); + DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR, + SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + 16; diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 9d083c3e3..12a8d7ed1 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -2208,9 +2208,8 @@ DoConnectingDialog (PMELEE_STATE pMS) if (!pMS->Initialized) { RECT r; - FONT oldfont = SetContextFont (StarConFont); - COLOR oldcolor = SetContextForeGroundColor (BLACK_COLOR); - COLOR dark, medium; + FONT oldfont; + COLOR oldcolor; TEXT t; if (pMS->flash_task) @@ -2229,14 +2228,15 @@ DoConnectingDialog (PMELEE_STATE pMS) /* Draw the dialog box here */ LockMutex (GraphicsLock); + oldfont = SetContextFont (StarConFont); + oldcolor = SetContextForeGroundColor (BLACK_COLOR); BatchGraphics (); r.extent.width = 200; r.extent.height = 30; r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; - dark = BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F); - medium = BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19); - DrawShadowedBox (&r, MENU_BACKGROUND_COLOR, dark, medium); + DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR, + SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); if (NetConnection_getPeerOptions (conn)->isServer) {