Added patch to implement vertical text alignment (for subtitles) - from Nic

- adds alignment to Commander, Druuge, illwrath, yehat, and Utwig


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@557 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
ghaushe
2003-01-16 04:30:25 +00:00
parent 97f0989378
commit 568ce92ec3
10 changed files with 86 additions and 5 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.2:
- Added vertical alignment for subtitles (text runs off screen fix)-from Nic
- Updated infinity text/symbol for RUs - from fOSSiL, Nic
- Split away DCQ-specific code into its own header file
- Added correct lander font - from fOSSiL
+65
View File
@@ -101,6 +101,61 @@ enum
};
static int subtitle_state = DONE_SUBTITLE;
/* _count_lines - mostly stolen from add_text, just sees how many lines
a given input string would take to display given the
line wrapping information */
static int _count_lines (PTEXT pText)
{
COUNT maxchars = (COUNT)~0;
UNICODE ch, *pStr;
SIZE text_width;
int num = 0;
text_width = CommData.AlienTextWidth;
SetContextFont (CommData.AlienFont);
pStr = pText->pStr;
do
{
++num;
pText->pStr = pStr;
pText->CharCount = 1;
{
BOOLEAN eot;
RECT r, old_r;
COUNT OldCount;
GetContextClipRect (&r);
eot = FALSE;
do
{
old_r = r;
OldCount = pText->CharCount;
while (!(eot = (BOOLEAN)(
(ch = *++pStr) == '\0'
|| ch == '\n'
|| ch == '\r'
|| (COUNT)(pStr - pText->pStr) >= maxchars
)) && ch != ' ')
;
pText->CharCount = pStr - pText->pStr;
TextRect (pText, &r, NULL_PTR);
} while (!eot && r.extent.width < text_width);
if (r.extent.width >= text_width)
{
pText->CharCount = OldCount;
r = old_r;
}
}
pStr = pText->pStr + pText->CharCount;
} while ((ch = *pStr++) != '\0' && ch != '\n' && ch != '\r' && maxchars);
pText->pStr = pStr;
return (num);
}
static COORD
add_text (int status, PTEXT pTextIn)
@@ -111,6 +166,7 @@ add_text (int status, PTEXT pTextIn)
SIZE leading;
UNICODE ch, *pStr;
SIZE text_width;
int num_lines = 0;
BatchGraphics ();
@@ -162,6 +218,15 @@ add_text (int status, PTEXT pTextIn)
numchars = 0;
pStr = pText->pStr;
if (status > 0 && (CommData.AlienTextTemplate.valign & (VALIGN_MIDDLE|VALIGN_BOTTOM))) {
num_lines = _count_lines(pText);
if (CommData.AlienTextTemplate.valign == VALIGN_BOTTOM)
pText->baseline.y -= (leading * num_lines);
else if (CommData.AlienTextTemplate.valign == VALIGN_MIDDLE)
pText->baseline.y -= ((leading * num_lines) / 2);
if (pText->baseline.y < 0) pText->baseline.y = 0;
}
do
{
pText->pStr = pStr;
+1
View File
@@ -663,6 +663,7 @@ init_commander_comm ()
commander_desc.AlienTextTemplate.baseline.x = 164;
commander_desc.AlienTextTemplate.baseline.y = 20;
commander_desc.AlienTextTemplate.align = ALIGN_CENTER;
commander_desc.AlienTextTemplate.valign = VALIGN_MIDDLE;
SET_GAME_STATE (BATTLE_SEGUE, 0);
retval = &commander_desc;
+2 -1
View File
@@ -883,8 +883,9 @@ init_druuge_comm (void)
druuge_desc.AlienTextTemplate.baseline.x =
TEXT_X_OFFS + (SIS_TEXT_WIDTH >> 1);
druuge_desc.AlienTextTemplate.baseline.y = 64;
druuge_desc.AlienTextTemplate.baseline.y = 70;
druuge_desc.AlienTextTemplate.align = ALIGN_CENTER;
druuge_desc.AlienTextTemplate.valign = VALIGN_MIDDLE;
druuge_desc.AlienTextWidth = SIS_TEXT_WIDTH - 16;
if ((GET_GAME_STATE (DRUUGE_MANNER) == 0
+2 -1
View File
@@ -603,8 +603,9 @@ init_ilwrath_comm (void)
ilwrath_desc.AlienTextTemplate.baseline.x =
TEXT_X_OFFS + (SIS_TEXT_WIDTH >> 1);
ilwrath_desc.AlienTextTemplate.baseline.y = 64;
ilwrath_desc.AlienTextTemplate.baseline.y = 70;
ilwrath_desc.AlienTextTemplate.align = ALIGN_CENTER;
ilwrath_desc.AlienTextTemplate.valign = VALIGN_MIDDLE;
ilwrath_desc.AlienTextWidth = SIS_TEXT_WIDTH - 16;
if (GET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER)
+2 -1
View File
@@ -414,8 +414,9 @@ init_rebel_yehat_comm (void)
yehat_desc.uninit_encounter_func = uninit_yehat;
yehat_desc.AlienTextTemplate.baseline.x = SIS_SCREEN_WIDTH * 2 / 3;
yehat_desc.AlienTextTemplate.baseline.y = 107 * 2 / 3;
yehat_desc.AlienTextTemplate.baseline.y = 100;
yehat_desc.AlienTextTemplate.align = ALIGN_CENTER;
yehat_desc.AlienTextTemplate.valign = VALIGN_BOTTOM;
yehat_desc.AlienTextWidth = (SIS_TEXT_WIDTH - 16) * 2 / 3;
SET_GAME_STATE (BATTLE_SEGUE, 0);
+1
View File
@@ -1929,6 +1929,7 @@ init_starbase_comm ()
commander_desc.AlienTextTemplate.baseline.x = 164;
commander_desc.AlienTextTemplate.baseline.y = 20;
commander_desc.AlienTextTemplate.align = ALIGN_CENTER;
commander_desc.AlienTextTemplate.valign = VALIGN_MIDDLE;
CurBulletinMask = 0;
SET_GAME_STATE (BATTLE_SEGUE, 0);
+2 -1
View File
@@ -929,8 +929,9 @@ init_utwig_comm (void)
utwig_desc.AlienTextTemplate.baseline.x =
TEXT_X_OFFS + (SIS_TEXT_WIDTH >> 1);
utwig_desc.AlienTextTemplate.baseline.y = 64;
utwig_desc.AlienTextTemplate.baseline.y = 70;
utwig_desc.AlienTextTemplate.align = ALIGN_CENTER;
utwig_desc.AlienTextTemplate.valign = VALIGN_MIDDLE;
utwig_desc.AlienTextWidth = SIS_TEXT_WIDTH - 16;
if (GET_GAME_STATE (UTWIG_HAVE_ULTRON)
+2 -1
View File
@@ -647,8 +647,9 @@ init_yehat_comm (void)
yehat_desc.uninit_encounter_func = uninit_yehat;
yehat_desc.AlienTextTemplate.baseline.x = SIS_SCREEN_WIDTH * 2 / 3;
yehat_desc.AlienTextTemplate.baseline.y = 107 * 2 / 3;
yehat_desc.AlienTextTemplate.baseline.y = 100;
yehat_desc.AlienTextTemplate.align = ALIGN_CENTER;
yehat_desc.AlienTextTemplate.valign = VALIGN_BOTTOM;
yehat_desc.AlienTextWidth = (SIS_TEXT_WIDTH - 16) * 2 / 3;
if (LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
+8
View File
@@ -115,11 +115,19 @@ typedef enum
ALIGN_RIGHT
} TEXT_ALIGN;
typedef enum
{
VALIGN_TOP,
VALIGN_MIDDLE,
VALIGN_BOTTOM
} TEXT_VALIGN;
typedef struct text
{
POINT baseline;
UNICODE *pStr;
TEXT_ALIGN align;
TEXT_VALIGN valign;
COUNT CharCount;
} TEXT;
typedef TEXT *PTEXT;