From 0200c8ce634e175f8506a01dda40390c711e5f02 Mon Sep 17 00:00:00 2001 From: avolkov Date: Thu, 1 Oct 2009 22:34:36 +0000 Subject: [PATCH] Make border and box math dependent on symbolic constants instead of literals (easier to change) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3184 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/border.c | 18 +++++++++--------- sc2/src/sc2code/gameopt.c | 3 ++- sc2/src/sc2code/sis.c | 17 +++++++---------- sc2/src/sc2code/sis.h | 16 ++++++++++------ 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/sc2/src/sc2code/border.c b/sc2/src/sc2code/border.c index 69f5bd87a..193d19a42 100644 --- a/sc2/src/sc2code/border.c +++ b/sc2/src/sc2code/border.c @@ -88,14 +88,14 @@ DrawSISFrame (void) r.extent.height = SIS_ORG_Y; r.corner.x = SIS_ORG_X; - r.extent.width = SIS_SCREEN_WIDTH - 69; + r.extent.width = SIS_MESSAGE_BOX_WIDTH; DrawStarConBox (&r, 1, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0E), 0x54), BUILD_COLOR (MAKE_RGB15 (0x00, 0x01, 0x1C), 0x4E), TRUE, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); - r.extent.width = 57; - r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH - 57; + r.extent.width = SIS_TITLE_BOX_WIDTH; + r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH; DrawStarConBox (&r, 1, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0E), 0x54), BUILD_COLOR (MAKE_RGB15 (0x00, 0x01, 0x1C), 0x4E), @@ -117,10 +117,10 @@ DrawSISFrame (void) BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.y = 1; r.extent.width = 1; - r.extent.height = SAFE_Y + 8; + r.extent.height = SAFE_Y + SIS_TITLE_HEIGHT; r.corner.x = SIS_ORG_X - 1; DrawFilledRectangle (&r); - r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH - 57 - 1; + r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH - 1; DrawFilledRectangle (&r); r.corner.x = 0; @@ -153,8 +153,8 @@ DrawSISFrame (void) BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.y = 1; r.extent.width = 1; - r.extent.height = SAFE_Y + 8; - r.corner.x = SIS_ORG_X + (SIS_SCREEN_WIDTH - 69); + r.extent.height = SAFE_Y + SIS_MESSAGE_HEIGHT; + r.corner.x = SIS_ORG_X + SIS_MESSAGE_BOX_WIDTH; DrawFilledRectangle (&r); r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH; ++r.extent.height; @@ -166,8 +166,8 @@ DrawSISFrame (void) r.corner.x = 0; r.extent.width = SIS_ORG_X - r.corner.x; DrawFilledRectangle (&r); - r.corner.x = SIS_ORG_X + (SIS_SCREEN_WIDTH - 69); - r.extent.width = (SIS_ORG_X + SIS_SCREEN_WIDTH - 57) - r.corner.x; + r.corner.x = SIS_ORG_X + SIS_MESSAGE_BOX_WIDTH; + r.extent.width = SIS_SPACER_BOX_WIDTH; DrawFilledRectangle (&r); r.corner.x = 0; diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 22301bb39..44ac6cdfe 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -804,7 +804,8 @@ ShowSummary (SUMMARY_DESC *pSD) t.CharCount = (COUNT)~0; font_DrawText (&t); t.align = ALIGN_CENTER; - t.baseline.x = SIS_SCREEN_WIDTH - 57 - 3 + (SIS_TITLE_WIDTH >> 1); + t.baseline.x = SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH - 3 + + (SIS_TITLE_WIDTH >> 1); if (pSD->Activity == IN_STARBASE) utf8StringCopy (buf, sizeof (buf), GAME_STRING (STARBASE_STRING_BASE)); diff --git a/sc2/src/sc2code/sis.c b/sc2/src/sc2code/sis.c index 5aaffbad3..f83140b75 100644 --- a/sc2/src/sc2code/sis.c +++ b/sc2/src/sc2code/sis.c @@ -112,6 +112,7 @@ DrawSISTitle (UNICODE *pStr) { TEXT t; CONTEXT OldContext; + RECT r; t.baseline.x = SIS_TITLE_WIDTH >> 1; t.baseline.y = SIS_TITLE_HEIGHT - 2; @@ -120,16 +121,12 @@ DrawSISTitle (UNICODE *pStr) t.CharCount = (COUNT)~0; OldContext = SetContext (OffScreenContext); -{ -RECT r; - -r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH - 57 + 1; -r.corner.y = SIS_ORG_Y - SIS_TITLE_HEIGHT; -r.extent.width = SIS_TITLE_WIDTH; -r.extent.height = SIS_TITLE_HEIGHT - 1; -SetContextFGFrame (Screen); -SetContextClipRect (&r); -} + r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH + 1; + r.corner.y = SIS_ORG_Y - SIS_TITLE_HEIGHT; + r.extent.width = SIS_TITLE_WIDTH; + r.extent.height = SIS_TITLE_HEIGHT - 1; + SetContextFGFrame (Screen); + SetContextClipRect (&r); SetContextFont (TinyFont); BatchGraphics (); diff --git a/sc2/src/sc2code/sis.h b/sc2/src/sc2code/sis.h index b7c39cea2..16bc1be2e 100644 --- a/sc2/src/sc2code/sis.h +++ b/sc2/src/sc2code/sis.h @@ -189,12 +189,16 @@ enum {3 + 0, 30 + (5 * 16)}, \ {3 + 42, 30 + (5 * 16)}, -#define SIS_MESSAGE_WIDTH (SIS_SCREEN_WIDTH - 69 - 2) -#define SIS_MESSAGE_HEIGHT 8 -#define SIS_TITLE_WIDTH 55 -#define SIS_TITLE_HEIGHT 8 -#define STATUS_MESSAGE_WIDTH 60 -#define STATUS_MESSAGE_HEIGHT 7 +#define SIS_TITLE_BOX_WIDTH 57 +#define SIS_TITLE_WIDTH (SIS_TITLE_BOX_WIDTH - 2) +#define SIS_TITLE_HEIGHT 8 +#define SIS_SPACER_BOX_WIDTH 12 +#define SIS_MESSAGE_BOX_WIDTH (SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH \ + - SIS_SPACER_BOX_WIDTH) +#define SIS_MESSAGE_WIDTH (SIS_MESSAGE_BOX_WIDTH - 2) +#define SIS_MESSAGE_HEIGHT SIS_TITLE_HEIGHT +#define STATUS_MESSAGE_WIDTH (STATUS_WIDTH - 4) +#define STATUS_MESSAGE_HEIGHT 7 #define SIS_NAME_SIZE 16