CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

DIALOG.CPP (43665B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/DIALOG.CPP 1     3/03/97 10:24a Joe_bostic $ */
     17 /***********************************************************************************************
     18  ***              C O N F I D E N T I A L  ---  W E S T W O O D  S T U D I O S               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : DIALOG.CPP                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : September 10, 1993                                           *
     28  *                                                                                             *
     29  *                  Last Update : July 31, 1996 [JLB]                                          *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   Clip_Text_Print -- Prints text with clipping and <TAB> support.                           *
     34  *   Dialog_Box -- draws a dialog background box                                               *
     35  *   Display_Place_Building -- Displays the "place building" dialog box.                       *
     36  *   Display_Select_Target -- Displays the "choose target" prompt.                             *
     37  *   Display_Status -- Display the player scenario status box.                                 *
     38  *   Draw_Box -- Displays a highlighted box.                                                   *
     39  *   Draw_Caption -- Draws a caption on a dialog box.                                          *
     40  *   Fancy_Text_Print -- Prints text with a drop shadow.                                       *
     41  *   Plain_Text_Print -- Prints text without using a color scheme                              *
     42  *   Redraw_Needed -- Determine if sidebar needs to be redrawn.                                *
     43  *   Render_Bar_Graph -- Renders a specified bargraph.                                         *
     44  *   Simple_Text_Print -- Prints text with a drop shadow.                                      *
     45  *   Window_Box -- Draws a fancy box over the specified window.                                *
     46  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     47 
     48 #include	"function.h"
     49 
     50 #include   "defines.h"   //VG 10/17/96
     51 
     52 unsigned char * Font_Palette(int color);
     53 
     54 
     55 /***********************************************************************************************
     56  * Dialog_Box -- draws a dialog background box                                                 *
     57  *                                                                                             *
     58  * INPUT:                                                                                      *
     59  *      x,y,w,h      the usual                                                                 *
     60  *                                                                                             *
     61  * OUTPUT:                                                                                     *
     62  *      none.                                                                                  *
     63  *                                                                                             *
     64  * WARNINGS:                                                                                   *
     65  *      none.                                                                                  *
     66  *                                                                                             *
     67  * HISTORY:                                                                                    *
     68  *   01/26/1995 BR : Created.                                                                  *
     69  *   07/31/1996 JLB : Uses shapes to draw the box.                                             *
     70  *=============================================================================================*/
     71 void Dialog_Box(int x, int y, int w, int h)
     72 {
     73 // Try to expand the box a little taller and a little wider to make room for
     74 // the dialog box graphics in the DOS version.
     75 #ifndef WIN32
     76 	x = max(0, x-4);
     77 	y = max(0, y-4);
     78 	w = min(w+8, 320-x);
     79 	h = min(h+8, 200-y);
     80 #endif
     81 
     82 	WindowList[WINDOW_PARTIAL][WINDOWX] = x;
     83 	WindowList[WINDOW_PARTIAL][WINDOWY] = y;
     84 	WindowList[WINDOW_PARTIAL][WINDOWWIDTH] = w;
     85 	WindowList[WINDOW_PARTIAL][WINDOWHEIGHT] = h;
     86 
     87 	/*
     88 	**	Always draw to the hidpage and then blit forward.
     89 	*/
     90 #ifdef WIN32
     91 	GraphicViewPortClass * oldpage = Set_Logic_Page(HidPage);
     92 #else
     93 	GraphicBufferClass * oldpage = Set_Logic_Page(HidPage);
     94 #endif
     95 
     96 	/*
     97 	**	Draw the background block.
     98 	*/
     99 	int cx = w/2;
    100 	int cy = h/2;
    101 	void const * shapedata = MFCD::Retrieve("DD-BKGND.SHP");
    102 #ifdef WIN32
    103 	CC_Draw_Shape(shapedata, 0, cx-312, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
    104 	CC_Draw_Shape(shapedata, 1, cx,     cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
    105 	CC_Draw_Shape(shapedata, 2, cx-312, cy,     WINDOW_PARTIAL, SHAPE_WIN_REL);
    106 	CC_Draw_Shape(shapedata, 3, cx,     cy,     WINDOW_PARTIAL, SHAPE_WIN_REL);
    107 #else
    108 	CC_Draw_Shape(shapedata, 0, cx-156, cy-96, WINDOW_PARTIAL, SHAPE_WIN_REL);
    109 #endif
    110 	/*
    111 	**	Draw the side strips.
    112 	*/
    113 	shapedata = MFCD::Retrieve("DD-EDGE.SHP");
    114 	for (int yy = 0; yy < h; yy += 6) {
    115 		CC_Draw_Shape(shapedata, 0, 7*RESFACTOR,         yy, WINDOW_PARTIAL, SHAPE_WIN_REL);
    116 		CC_Draw_Shape(shapedata, 1, w-((7+8)*RESFACTOR), yy, WINDOW_PARTIAL, SHAPE_WIN_REL);
    117 	}
    118 
    119 	/*
    120 	**	Draw the border bars.
    121 	*/
    122 	shapedata = MFCD::Retrieve("DD-LEFT.SHP");
    123 	CC_Draw_Shape(shapedata, 0, 0, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
    124 	CC_Draw_Shape(shapedata, 0, 0, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
    125 
    126 	shapedata = MFCD::Retrieve("DD-RIGHT.SHP");
    127 	int rightx = w - (7*RESFACTOR);
    128 #ifndef WIN32
    129 	rightx--;
    130 #endif
    131 	CC_Draw_Shape(shapedata, 0, rightx, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
    132 	CC_Draw_Shape(shapedata, 0, rightx, cy,					WINDOW_PARTIAL, SHAPE_WIN_REL);
    133 
    134 	shapedata = MFCD::Retrieve("DD-BOTM.SHP");
    135 	CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
    136 	CC_Draw_Shape(shapedata, 0, cx, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
    137 
    138 	shapedata = MFCD::Retrieve("DD-TOP.SHP");
    139 	CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
    140 	CC_Draw_Shape(shapedata, 0, cx, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
    141 
    142 	/*
    143 	**	Draw the corner caps.
    144 	*/
    145 	shapedata = MFCD::Retrieve("DD-CRNR.SHP");
    146 	CC_Draw_Shape(shapedata, 0, 0,                  0, 					WINDOW_PARTIAL, SHAPE_WIN_REL);
    147 	CC_Draw_Shape(shapedata, 1, w-(12*RESFACTOR-1), 0, 					WINDOW_PARTIAL, SHAPE_WIN_REL);
    148 	CC_Draw_Shape(shapedata, 2, 0,                  h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
    149 	CC_Draw_Shape(shapedata, 3, w-(12*RESFACTOR-1), h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
    150 
    151 #ifdef WIN32
    152 	WWMouse->Draw_Mouse(&HidPage);
    153 	HidPage.Blit(SeenBuff, x, y, x, y, w, h, false);
    154 	WWMouse->Erase_Mouse(&HidPage, FALSE);
    155 #else
    156 //	Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, Map.ShadowPage->Get_Buffer());
    157 	Hide_Mouse();
    158 	HidPage.Blit(SeenBuff);
    159 	Show_Mouse();
    160 //	Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, ((GraphicBufferClass*)Map.Shadow_Address())->Get_Buffer());
    161 #endif
    162 	Set_Logic_Page(oldpage);
    163 }
    164 
    165 
    166 /***********************************************************************************************
    167  * Draw_Box -- Displays a highlighted box.                                                     *
    168  *                                                                                             *
    169  *    This will draw a highlighted box to the logicpage. It can                                *
    170  *    optionally fill the box with a color as well. This is a low level                        *
    171  *    function and thus, it doesn't do any graphic mode color adjustments.                     *
    172  *                                                                                             *
    173  * INPUT:   x,y   -- Upper left corner of the box to be drawn (pixels).                        *
    174  *                                                                                             *
    175  *          w,h   -- Width and height of box (in pixels).                                      *
    176  *                                                                                             *
    177  *          up    -- Is the box rendered in the "up" stated?                                   *
    178  *                                                                                             *
    179  *          filled-- Is the box to be filled.                                                  *
    180  *                                                                                             *
    181  * OUTPUT:     none                                                                            *
    182  *                                                                                             *
    183  * WARNINGS:   none                                                                            *
    184  *                                                                                             *
    185  * HISTORY:                                                                                    *
    186  *   05/28/1991 JLB : Created.                                                                 *
    187  *   05/30/1992 JLB : Embedded color codes.                                                    *
    188  *   07/31/1992 JLB : Depressed option added.                                                  *
    189  *=============================================================================================*/
    190 void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled)
    191 {
    192 	RemapControlType * scheme = GadgetClass::Get_Color_Scheme();
    193 
    194 	// Filler, Shadow, Hilite, Corner colors
    195 
    196 	BoxStyleType const ButtonColors[BOXSTYLE_COUNT] = {
    197 		{ scheme->Background, scheme->Highlight, scheme->Shadow,  scheme->Corners},	// Down
    198 		{ scheme->Background, scheme->Shadow, scheme->Highlight,  scheme->Corners},	// Raised
    199 		{ DKGREY, WHITE,  BLACK,  DKGREY},				// Disabled down
    200 		{ DKGREY, BLACK,  LTGREY, DKGREY},				// Disabled up
    201 		{ BLACK,  scheme->Box, scheme->Box,  BLACK},	// List box
    202 		{ BLACK,  scheme->Box, scheme->Box,  BLACK},	// Dialog box
    203 	};
    204 
    205 	w--;
    206 	h--;
    207 	BoxStyleType const &style = ButtonColors[up];
    208 
    209 	if (filled) {
    210 		LogicPage->Fill_Rect( x, y, x+w, y+h, style.Filler);
    211 	}
    212 
    213 	switch (up) {
    214 		case (BOXSTYLE_BOX):
    215 			LogicPage->Draw_Rect(x, y, x+w, y+h, style.Highlight);
    216 			break;
    217 
    218 		case (BOXSTYLE_BORDER):
    219 			LogicPage->Draw_Rect(x+1, y+1, x+w-1, y+h-1, style.Highlight);
    220 			break;
    221 
    222 		default:
    223 			LogicPage->Draw_Line(x, y+h, x+w, y+h, style.Shadow);
    224 			LogicPage->Draw_Line(x+w, y, x+w, y+h, style.Shadow);
    225 
    226 			LogicPage->Draw_Line(x, y, x+w, y, style.Highlight);
    227 			LogicPage->Draw_Line(x, y, x, y+h, style.Highlight);
    228 
    229 			LogicPage->Put_Pixel(x, y+h, style.Corner);
    230 			LogicPage->Put_Pixel(x+w, y, style.Corner);
    231 			break;
    232 	}
    233 }
    234 
    235 
    236 /***********************************************************************************************
    237  * Format_Window_String -- Separates a String into Lines.                                      *
    238  *   This function will take a long string and break it up into lines                          *
    239  *   which are not longer then the window width. Any character < ' ' is                        *
    240  *   considered a new line marker and will be replaced by a NULL.                              *
    241  *                                                                                             *
    242  * INPUT:      char *String - string to be formated.                                           *
    243  *             int maxlinelen - Max length of any line in pixels.                              *
    244  *                                                                                             *
    245  * OUTPUT:     int - number of lines string is.                                                *
    246  *                                                                                             *
    247  * WARNINGS:    The string passed in will be modified - NULLs will be put                      *
    248  *                into each position that will be a new line.                                  *
    249  *                                                                                             *
    250  * HISTORY:                                                                                    *
    251  *   03/27/1992  SB : Created.                                                                 *
    252  *   05/18/1995 JLB : Greatly revised for new font system.                                     *
    253  *	  09/04/1996 BWG : Added '@' is treated as a carriage return for width calculations.		  *
    254  *=============================================================================================*/
    255 int Format_Window_String(char * string, int maxlinelen, int & width, int & height)
    256 {
    257 	int	linelen;
    258 	int	lines = 0;
    259 	width	= 0;
    260 	height = 0;
    261 
    262 	// In no string was passed in, then there are no lines.
    263 	if (!string) return(0);
    264 
    265 	// While there are more letters left divide the line up.
    266 	while (*string) {
    267 		linelen = 0;
    268 		height += FontHeight + FontYSpacing;
    269 		lines++;
    270 
    271 		/*
    272 		**	Look for special line break character and force a line break when it is
    273 		**	discovered.
    274 		*/
    275 		if (*string == '@') {
    276 			*string = '\r';
    277 		}
    278 
    279 		// While the current line is less then the max length...
    280 		while (linelen < maxlinelen && *string != '\r' && *string != '\0' && *string != '@') {
    281 			linelen += Char_Pixel_Width(*string++);
    282 		}
    283 
    284 		// if the line is to long...
    285 		if (linelen >= maxlinelen) {
    286 
    287 			/*
    288 			**	Back up to an appropriate location to break.
    289 			*/
    290 			while (*string != ' ' && *string != '\r' && *string != '\0' && *string != '@') {
    291 				linelen -= Char_Pixel_Width(*string--);
    292 			}
    293 
    294 		}
    295 
    296 		/*
    297 		**	Record the largest width of the worst case string.
    298 		*/
    299 		if (linelen > width) {
    300 			width = linelen;
    301 		}
    302 
    303 		/*
    304 		**	Force a break at the end of the line.
    305 		*/
    306 		if (*string) {
    307 		 	*string++ = '\r';
    308 		}
    309 	}
    310 	return(lines);
    311 }
    312 
    313 
    314 /***********************************************************************************************
    315  * Window_Box -- Draws a fancy box over the specified window.                                  *
    316  *                                                                                             *
    317  *    This routine will draw a fancy (shaded) box over the specified                           *
    318  *    window. This is the effect used to give the polished look to                             *
    319  *    screen rectangles without having to use art.                                             *
    320  *                                                                                             *
    321  * INPUT:   window   -- Specified window to fill and border.                                   *
    322  *                                                                                             *
    323  *          style    -- The style to render the window.                                        *
    324  *                                                                                             *
    325  * OUTPUT:  none                                                                               *
    326  *                                                                                             *
    327  * WARNINGS:   The rendering is done to the LogicPage.                                         *
    328  *                                                                                             *
    329  * HISTORY:                                                                                    *
    330  *   03/03/1992 JLB : Created.                                                                 *
    331  *   07/31/1992 JLB : Cool raised border effect.                                               *
    332  *   06/08/1994 JLB : Takes appropriate enumeration parameters.                                *
    333  *=============================================================================================*/
    334 void Window_Box(WindowNumberType window, BoxStyleEnum style)
    335 {
    336 	int x = WindowList[window][WINDOWX];
    337 	int y = WindowList[window][WINDOWY];
    338 	int w = WindowList[window][WINDOWWIDTH];
    339 	int h = WindowList[window][WINDOWHEIGHT];
    340 
    341 	/*
    342 	**	If it is to be rendered to the seenpage, then
    343 	**	hide the mouse.
    344 	*/
    345 	if (LogicPage == (&SeenBuff)) Conditional_Hide_Mouse(x ,y, x+w, y+h);
    346 
    347 	Draw_Box(x, y, w, h, style, true);
    348 
    349 	/*
    350 	**	Restore the mouse if it has been hidden and return.
    351 	*/
    352 	if (LogicPage == &SeenBuff) Conditional_Show_Mouse();
    353 }
    354 
    355 
    356 /***********************************************************************************************
    357  * Simple_Text_Print -- Prints text with a drop shadow.                                        *
    358  *                                                                                             *
    359  *    This routine functions like Text_Print, but will render a drop                           *
    360  *    shadow (in black).                                                                       *
    361  *                                                                                             *
    362  *    The C&C gradient font colors are as follows:															  *
    363  *			0		transparent (background)																		  *
    364  *			1		foreground color for mono-color fonts only												  *
    365  *			2		shadow under characters ("drop shadow")													  *
    366  *			3		shadow all around characters ("full shadow")												  *
    367  *			4-10	unused																								  *
    368  *			11		top row																								  *
    369  *			12		next row																								  *
    370  *			13		next row																								  *
    371  *			14		next row																								  *
    372  *			15		bottom row																							  *
    373  *                                                                                             *
    374  * INPUT:   text  -- Pointer to text to render.                                                *
    375  *                                                                                             *
    376  *          x,y   -- Pixel coordinate for to print text.                                       *
    377  *                                                                                             *
    378  *          fore  -- Foreground color.                                                         *
    379  *                                                                                             *
    380  *          back  -- Background color.                                                         *
    381  *                                                                                             *
    382  *          flag  -- Text print control flags.                                                 *
    383  *                                                                                             *
    384  * OUTPUT:  none                                                                               *
    385  *                                                                                             *
    386  * WARNINGS:   none                                                                            *
    387  *                                                                                             *
    388  * HISTORY:                                                                                    *
    389  *   12/24/1991 JLB : Created.                                                                 *
    390  *   10/26/94   JLB : Handles font X spacing in a more friendly manner.                        *
    391  *=============================================================================================*/
    392 void Simple_Text_Print(char const * text, unsigned x, unsigned y, RemapControlType * fore, unsigned back, TextPrintType flag)
    393 {
    394 	static int		yspace=0;			// Y spacing adjustment for font.
    395 	static int		xspace=0;			// Spacing adjustment for font.
    396 	void const *	font=0;		// Font to use.
    397 	int				shadow;				// Requested shadow value.
    398 	unsigned char	fontpalette[16];	// Working font palette array.
    399 	int forecolor;
    400 
    401 	if (fore == NULL) {
    402 		fore = &ColorRemaps[PCOLOR_RED];
    403 	}
    404 
    405 	/*
    406 	** Init the font palette to the given background color
    407 	*/
    408 	memset(&fontpalette[0], back, 16);
    409 
    410 	forecolor = fore->Color;
    411 
    412 	/*
    413 	**	A gradient font always requires special fixups for the palette
    414 	*/
    415 	int point = (flag & (TextPrintType)0x000F);
    416 	if (point == TPF_VCR || point == TPF_6PT_GRAD || point == TPF_METAL12 || point == TPF_EFNT || point == TPF_TYPE) {
    417 
    418 		/*
    419 		** If a gradient palette is specified, copy the remap table directly, otherwise
    420 		**	use the foreground color as the entire font remap color.
    421 		*/
    422 		if (flag & TPF_USE_GRAD_PAL) {
    423 			memcpy(fontpalette, fore->FontRemap, 16);
    424 			forecolor = fore->Color;
    425 			if (point == TPF_TYPE) {
    426 				forecolor = fontpalette[1];
    427 			}
    428 		} else {
    429 			memset(&fontpalette[4], fore->Color, 12);
    430 			forecolor = fore->Color;
    431 		}
    432 
    433 		/*
    434 		** Medium color: set all font colors to a medium value.  This flag
    435 		** overrides any gradient effects.
    436 		*/
    437 		if (flag & TPF_MEDIUM_COLOR) {
    438 			forecolor = fore->Color;
    439 			memset(&fontpalette[4], fore->Color, 12);
    440 		}
    441 
    442 		/*
    443 		** Bright color: set all font colors to a bright value.  This flag
    444 		** overrides any gradient effects.
    445 		*/
    446 		if (flag & TPF_BRIGHT_COLOR) {
    447 			forecolor = fore->Bright;
    448 			memset(&fontpalette[4], fore->BrightColor, 12);
    449 		}
    450 	}
    451 
    452 	/*
    453 	**	Change the current font if it differs from the font desired.
    454 	*/
    455 #ifdef WIN32
    456 	xspace = 1;
    457 #else
    458 	xspace = 0;
    459 #endif
    460 	yspace = 0;
    461 
    462 	switch (point) {
    463 		case TPF_SCORE:
    464 			font = ScoreFontPtr;
    465 			break;
    466 
    467 		case TPF_METAL12:
    468 			font = Metal12FontPtr;
    469 			//xspace += 1;
    470 			break;
    471 
    472 		case TPF_MAP:
    473 			font = MapFontPtr;
    474 			xspace -= 1;
    475 			break;
    476 
    477 		case TPF_VCR:
    478 			font = VCRFontPtr;
    479 			break;
    480 
    481 		case TPF_6PT_GRAD:
    482 			font = GradFont6Ptr;
    483 			xspace -= 1;
    484 			break;
    485 
    486 		case TPF_3POINT:
    487 			xspace += 1;
    488 			font = Font3Ptr;
    489 			flag = flag & ~(TPF_DROPSHADOW|TPF_FULLSHADOW|TPF_NOSHADOW);
    490 			break;
    491 
    492 		case TPF_6POINT:
    493 			font = Font6Ptr;
    494 			xspace -= 1;
    495 			break;
    496 
    497 		case TPF_EFNT:
    498 			font = EditorFont;
    499 #ifdef WIN32
    500 			yspace += 1;
    501 			xspace -= 1;
    502 #endif
    503 			xspace -= 1;
    504 			break;
    505 
    506 		case TPF_8POINT:
    507 			font = Font8Ptr;
    508 #ifdef WIN32
    509 			xspace -= 2;
    510 			yspace -= 4;
    511 #else
    512 			xspace -= 1;
    513 			yspace -= 2;
    514 #endif
    515 			break;
    516 
    517 		case TPF_LED:
    518 #ifdef WIN32
    519 			xspace -= 4;
    520 #else
    521 			xspace -= 2;
    522 #endif
    523 			font = FontLEDPtr;
    524 			break;
    525 
    526 		case TPF_TYPE:
    527 			font = TypeFontPtr;
    528 			xspace -= 1;
    529 
    530 #ifdef WOLAPI_INTEGRATION
    531 		   xspace -= 2;
    532 		   yspace += 2;
    533 #else	//	I am implicitly assuming that TPF_TYPE was no longer being used, before I came along, despite the following. ajw
    534 #ifdef GERMAN
    535 		   yspace += 4;   //VG 10/17/96
    536 #endif
    537 #endif
    538 
    539 			break;
    540 
    541 		default:
    542 			font = FontPtr;
    543 			break;
    544 	}
    545 
    546 	/*
    547 	**	Change the current font palette according to the dropshadow flags.
    548 	*/
    549 	shadow = (flag & (TPF_NOSHADOW|TPF_DROPSHADOW|TPF_FULLSHADOW|TPF_LIGHTSHADOW));
    550 	switch (shadow) {
    551 
    552 		/*
    553 		**	The text is rendered plain.
    554 		*/
    555 		case TPF_NOSHADOW:
    556 			fontpalette[2] = back;
    557 			fontpalette[3] = back;
    558 			xspace -= 1;
    559 #ifdef WIN32
    560 			yspace -= 2;
    561 #else
    562 			yspace -= 1;
    563 #endif
    564 			break;
    565 
    566 		/*
    567 		**	The text is rendered with a simple
    568 		**	drop shadow.
    569 		*/
    570 		case TPF_DROPSHADOW:
    571 			fontpalette[2] = BLACK;
    572 			fontpalette[3] = back;
    573 			xspace -= 1;
    574 			break;
    575 
    576 		/*
    577 		**	Special engraved text look for the options
    578 		**	dialog system.
    579 		*/
    580 		case TPF_LIGHTSHADOW:
    581 			fontpalette[2] = ((14 * 16) + 7)+1;
    582 			fontpalette[3] = back;
    583 			xspace -= 1;
    584 			break;
    585 
    586 		/*
    587 		**	Each letter is surrounded by black. This is used
    588 		**	when the text will be over a non-plain background.
    589 		*/
    590 		case TPF_FULLSHADOW:
    591 			fontpalette[2] = BLACK;
    592 			fontpalette[3] = BLACK;
    593 			xspace -= 1;
    594 			break;
    595 
    596 		default:
    597 			break;
    598 	}
    599 	if (point != TPF_TYPE) {
    600 		fontpalette[0] = back;
    601 		fontpalette[1] = fore->Color;
    602 	}
    603 
    604 	/*
    605 	**	Set the font and spacing according to the values they should be.
    606 	*/
    607 	FontXSpacing = xspace;
    608 	FontYSpacing = yspace;
    609 	Set_Font(font);
    610 	Set_Font_Palette(fontpalette);
    611 
    612 	/*
    613 	**	Display the (centered) message if there is one.
    614 	*/
    615 	if (text && *text) {
    616 		switch (flag & (TPF_CENTER|TPF_RIGHT)) {
    617 			case TPF_CENTER:
    618 				x -= String_Pixel_Width(text)>>1;
    619 				break;
    620 
    621 			case TPF_RIGHT:
    622 				x -= String_Pixel_Width(text);
    623 				break;
    624 
    625 			default:
    626 				break;
    627 		}
    628 
    629 		if (x < (unsigned)LogicPage->Get_Width() && y < (unsigned)LogicPage->Get_Height()) {
    630 			LogicPage->Print(text, x, y, forecolor, back);
    631 //			LogicPage->Print(text, x, y, fore->Color, back);
    632 		}
    633 	}
    634 }
    635 
    636 
    637 /***********************************************************************************************
    638  * Fancy_Text_Print -- Prints text with a drop shadow.                                         *
    639  *                                                                                             *
    640  *    This routine functions like Text_Print, but will render a drop                           *
    641  *    shadow (in black).                                                                       *
    642  *                                                                                             *
    643  * INPUT:   text  -- Text number to print.                                                     *
    644  *                                                                                             *
    645  *          x,y   -- Pixel coordinate for to print text.                                       *
    646  *                                                                                             *
    647  *          fore  -- Foreground color.                                                         *
    648  *                                                                                             *
    649  *          back  -- Background color.                                                         *
    650  *                                                                                             *
    651  *          flag  -- Text print control flags.                                                 *
    652  *                                                                                             *
    653  * OUTPUT:  none                                                                               *
    654  *                                                                                             *
    655  * WARNINGS:   This routine is much slower than normal text print and                          *
    656  *             if rendered to the SEENPAGE, the intermediate rendering                         *
    657  *             steps could be visible.                                                         *
    658  *                                                                                             *
    659  * HISTORY:                                                                                    *
    660  *   11/29/1994 JLB : Created                                                                  *
    661  *=============================================================================================*/
    662 void Fancy_Text_Print(int text, unsigned x, unsigned y, RemapControlType * fore, unsigned back, TextPrintType flag, ...)
    663 {
    664 	char		buffer[512];		// Working staging buffer.
    665 	va_list	arg;					// Argument list var.
    666 
    667 	/*
    668 	**	If the text number is valid, then process it.
    669 	*/
    670 	if (text != TXT_NONE) {
    671 		va_start(arg, flag);
    672 
    673 		/*
    674 		**	The text string must be locked since the vsprintf function doesn't know
    675 		**	how to handle EMS pointers.
    676 		*/
    677 		char const * tptr = Text_String(text);
    678 		vsprintf(buffer, tptr, arg);
    679 		va_end(arg);
    680 
    681 		Simple_Text_Print(buffer, x, y, fore, back, flag);
    682 	} else {
    683 
    684 		/*
    685 		**	Just the flags are to be changed, since the text number is TXT_NONE.
    686 		*/
    687 		Simple_Text_Print((char const *)0, x, y, fore, back, flag);
    688 	}
    689 }
    690 
    691 
    692 /***********************************************************************************************
    693  * Fancy_Text_Print -- Prints text with a drop shadow.                                         *
    694  *                                                                                             *
    695  *    This routine functions like Text_Print, but will render a drop                           *
    696  *    shadow (in black).                                                                       *
    697  *                                                                                             *
    698  * INPUT:   text  -- Pointer to text to render.                                                *
    699  *                                                                                             *
    700  *          x,y   -- Pixel coordinate for to print text.                                       *
    701  *                                                                                             *
    702  *          fore  -- Foreground color.                                                         *
    703  *                                                                                             *
    704  *          back  -- Background color.                                                         *
    705  *                                                                                             *
    706  *          flag  -- Text print control flags.                                                 *
    707  *                                                                                             *
    708  * OUTPUT:  none                                                                               *
    709  *                                                                                             *
    710  * WARNINGS:   This routine is much slower than normal text print and                          *
    711  *             if rendered to the SEENPAGE, the intermediate rendering                         *
    712  *             steps could be visible.                                                         *
    713  *                                                                                             *
    714  * HISTORY:                                                                                    *
    715  *   12/24/1991 JLB : Created.                                                                 *
    716  *   10/26/94   JLB : Handles font X spacing in a more friendly manner.                        *
    717  *   11/29/1994 JLB : Separated actual draw action.                                            *
    718  *=============================================================================================*/
    719 void Fancy_Text_Print(char const * text, unsigned x, unsigned y, RemapControlType * fore, unsigned back, TextPrintType flag, ...)
    720 {
    721 	char		buffer[512];		// Working staging buffer.
    722 	va_list	arg;					// Argument list var.
    723 
    724 	/*
    725 	**	If there is a valid text string pointer then build the final string into the
    726 	**	working buffer before sending it to the simple string printing routine.
    727 	*/
    728 	if (text) {
    729 
    730 		/*
    731 		**	Since vsprintf doesn't know about EMS pointers, be sure to surround this
    732 		**	call with locking code.
    733 		*/
    734 		va_start(arg, flag);
    735 		vsprintf(buffer, text, arg);
    736 		va_end(arg);
    737 
    738 		Simple_Text_Print(buffer, x, y, fore, back, flag);
    739 	} else {
    740 
    741 		/*
    742 		**	Just the flags are desired to be changed, so call the simple print routine with
    743 		**	a NULL text pointer.
    744 		*/
    745 		Simple_Text_Print((char const *)0, x, y, fore, back, flag);
    746 	}
    747 }
    748 
    749 
    750 /***********************************************************************************************
    751  * Clip_Text_Print -- Prints text with clipping and <TAB> support.                             *
    752  *                                                                                             *
    753  *    Use this routine to print text that that should be clipped at an arbitrary right margin  *
    754  *    as well as possibly recognizing <TAB> characters. Typical users of this routine would    *
    755  *    be list boxes.                                                                           *
    756  *                                                                                             *
    757  * INPUT:   text  -- Reference to the text to print.                                           *
    758  *                                                                                             *
    759  *          x,y   -- Pixel coordinate of the upper left corner of the text position.           *
    760  *                                                                                             *
    761  *          fore  -- The foreground color to use.                                              *
    762  *                                                                                             *
    763  *          back  -- The background color to use.                                              *
    764  *                                                                                             *
    765  *          flag  -- The text print flags to use.                                              *
    766  *                                                                                             *
    767  *          width -- The maximum pixel width to draw the text. Extra characters beyond this    *
    768  *                   point will not be printed.                                                *
    769  *                                                                                             *
    770  *          tabs  -- Optional pointer to a series of pixel tabstop positions.                  *
    771  *                                                                                             *
    772  * OUTPUT:  none                                                                               *
    773  *                                                                                             *
    774  * WARNINGS:   none                                                                            *
    775  *                                                                                             *
    776  * HISTORY:                                                                                    *
    777  *   01/21/1995 JLB : Created.                                                                 *
    778  *=============================================================================================*/
    779 void Conquer_Clip_Text_Print(char const * text, unsigned x, unsigned y, RemapControlType * fore, unsigned back, TextPrintType flag, int width, int const * tabs)
    780 {
    781 	char buffer[512];
    782 
    783 	if (text) {
    784 		strcpy(buffer, text);
    785 
    786 		/*
    787 		**	Set the font and spacing characteristics according to the flag
    788 		**	value passed in.
    789 		*/
    790 		//PG_TO_FIX
    791 		//Simple_Text_Print(TXT_NONE, 0, 0, TBLACK, TBLACK, flag);
    792 
    793 		char * source = &buffer[0];
    794 		unsigned offset = 0;
    795 		int processing = true;
    796 		while (processing && offset < (unsigned) width) {
    797 			char * ptr = strchr(source, '\t');
    798 
    799 			/*
    800 			**	Zap the tab character. It will be processed later.
    801 			*/
    802 			if (ptr) {
    803 				*ptr = '\0';
    804 			}
    805 
    806 			if (*source) {
    807 
    808 				/*
    809 				**	Scan forward until the end of the string is reached or the
    810 				**	maximum width, whichever comes first.
    811 				*/
    812 				int w = 0;
    813 				char * bptr = source;
    814 				do {
    815 					w += Char_Pixel_Width(*bptr++);
    816 				} while (*bptr && offset+w < (unsigned)width);
    817 
    818 				/*
    819 				**	If the maximum width has been exceeded, then remove the last
    820 				**	character and signal that further processing is not necessary.
    821 				*/
    822 				if (offset+w >= (unsigned)width) {
    823 					bptr--;
    824 					w -= Char_Pixel_Width(*bptr);
    825 					*bptr = '\0';
    826 					processing = 0;
    827 				}
    828 
    829 				/*
    830 				**	Print this text block and advance the offset accordingly.
    831 				*/
    832 				Simple_Text_Print(source, x+offset, y, fore, back, flag);
    833 				offset += w;
    834 			}
    835 
    836 			/*
    837 			**	If a <TAB> was the terminator for this text block, then advance
    838 			**	to the next tabstop.
    839 			*/
    840 			if (ptr) {
    841 				if (tabs) {
    842 					while ((int)offset > *tabs) {
    843 						tabs++;
    844 					}
    845 					offset = *tabs;
    846 				} else {
    847 					offset = ((offset+1 / 50) + 1) * 50;
    848 				}
    849 				source = ptr+1;
    850 			} else {
    851 				break;
    852 			}
    853 		}
    854 	}
    855 }
    856 
    857 /***************************************************************************
    858  * Plain_Text_Print -- Prints text without using a color scheme            *
    859  *                                                                         *
    860  * INPUT:                                                                  *
    861  *		text		text to print																*
    862  *		x,y		coords to print at														*
    863  *		fore		desired foreground color												*
    864  *		back		desired background color												*
    865  *		flag		text print control flags												*
    866  *                                                                         *
    867  * OUTPUT:                                                                 *
    868  *		none.																						*
    869  *                                                                         *
    870  * WARNINGS:                                                               *
    871  *		Do not use the gradient control flag with this routine!  For 			*
    872  *		a gradient appearance, use Fancy_Text_Print.									*
    873  *		Despite this routine's name, it is actually faster to call				*
    874  *		Fancy_Text_Print than this routine.												*
    875  *                                                                         *
    876  * HISTORY:                                                                *
    877  *   01/05/1996 BRR : Created.                                             *
    878  *=========================================================================*/
    879 void Plain_Text_Print(int text, unsigned x, unsigned y, unsigned fore, unsigned back, TextPrintType flag, ...)
    880 {
    881 	RemapControlType scheme;
    882 
    883 	memset(&scheme, 0, sizeof(RemapControlType));
    884 	memset(&(scheme.FontRemap[4]), fore, 12);
    885 
    886 	scheme.BrightColor = fore;
    887 	scheme.Color = fore;
    888 	scheme.Shadow = fore;
    889 	scheme.Background = fore;
    890 	scheme.Corners = fore;
    891 	scheme.Highlight = fore;
    892 	scheme.Box = fore;
    893 	scheme.Bright = fore;
    894 	scheme.Underline = fore;
    895 	scheme.Bar = fore;
    896 
    897 	Fancy_Text_Print(text, x, y, &scheme, back, flag);
    898 }
    899 
    900 
    901 /***************************************************************************
    902  * Plain_Text_Print -- Prints text without using a color scheme            *
    903  *                                                                         *
    904  * INPUT:                                                                  *
    905  *		text		text to print																*
    906  *		x,y		coords to print at														*
    907  *		fore		desired foreground color												*
    908  *		back		desired background color												*
    909  *		flag		text print control flags												*
    910  *                                                                         *
    911  * OUTPUT:                                                                 *
    912  *		none.																						*
    913  *                                                                         *
    914  * WARNINGS:                                                               *
    915  *		Do not use the gradient control flag with this routine!  For 			*
    916  *		a gradient appearance, use Fancy_Text_Print.									*
    917  *		Despite this routine's name, it is actually faster to call				*
    918  *		Fancy_Text_Print than this routine.												*
    919  *                                                                         *
    920  * HISTORY:                                                                *
    921  *   01/05/1996 BRR : Created.                                             *
    922  *=========================================================================*/
    923 void Plain_Text_Print(char const * text, unsigned x, unsigned y, unsigned fore, unsigned back, TextPrintType flag, ...)
    924 {
    925 	RemapControlType scheme;
    926 
    927 	memset(&scheme, 0, sizeof(RemapControlType));
    928 	memset(&(scheme.FontRemap[4]), fore, 12);
    929 
    930 	scheme.BrightColor = fore;
    931 	scheme.Color = fore;
    932 	scheme.Shadow = fore;
    933 	scheme.Background = fore;
    934 	scheme.Corners = fore;
    935 	scheme.Highlight = fore;
    936 	scheme.Box = fore;
    937 	scheme.Bright = fore;
    938 	scheme.Underline = fore;
    939 	scheme.Bar = fore;
    940 
    941 	Fancy_Text_Print(text, x, y, &scheme, back, flag);
    942 }
    943 
    944 
    945 
    946 unsigned char * Font_Palette(int color)
    947 {
    948 	static unsigned char _fpalette[16];
    949 
    950 	memset(_fpalette, '\0', sizeof(_fpalette));
    951 	memset(&_fpalette[11], color, 5);
    952 	return(_fpalette);
    953 }
    954 
    955 
    956 
    957 /***********************************************************************************************
    958  * Draw_Caption -- Draws a caption on a dialog box.                                            *
    959  *                                                                                             *
    960  *    This routine draws the caption text and any fancy filigree that the dialog may require.  *
    961  *                                                                                             *
    962  * INPUT:   text  -- The text of the caption. This is the text number.                         *
    963  *                                                                                             *
    964  *          x,y   -- The dialog box X and Y pixel coordinate of the upper left corner.         *
    965  *                                                                                             *
    966  *          w     -- The width of the dialog box (in pixels).                                  *
    967  *                                                                                             *
    968  * OUTPUT:  none                                                                               *
    969  *                                                                                             *
    970  * WARNINGS:   none                                                                            *
    971  *                                                                                             *
    972  * HISTORY:                                                                                    *
    973  *   06/23/1995 JLB : Created.                                                                 *
    974  *=============================================================================================*/
    975 void Draw_Caption(int text, int x, int y, int w)
    976 {
    977 	Draw_Caption(Text_String(text), x, y, w);
    978 }
    979 
    980 
    981 void Draw_Caption(char const * text, int x, int y, int w)
    982 {
    983 	/*
    984 	**	Draw the caption.
    985 	*/
    986 	if (text != NULL && *text != '\0') {
    987 		if (Debug_Map) {
    988 			Fancy_Text_Print(text, w/2 + x, (2 * RESFACTOR) + y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER|TPF_EFNT|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
    989 		} else {
    990 			Fancy_Text_Print(text, w/2 + x, (8 * RESFACTOR) + y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER|TPF_TEXT);
    991 			int length = String_Pixel_Width(text);
    992 			LogicPage->Draw_Line((x+(w/2))-(length/2), y+FontHeight+FontYSpacing + (8 * RESFACTOR), (x+(w/2))+(length/2),
    993 				y+FontHeight+FontYSpacing + (8 * RESFACTOR), GadgetClass::Get_Color_Scheme()->Box);
    994 		}
    995 	}
    996 }