2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-14 14:56:36 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/ivis_common/ivisdef.h"
|
|
|
|
#include "lib/ivis_common/piestate.h"
|
|
|
|
#include "lib/ivis_common/rendmode.h"
|
|
|
|
#include "lib/ivis_common/pieclip.h"
|
|
|
|
#include "lib/ivis_common/pieblitfunc.h"
|
|
|
|
#include "lib/ivis_common/piepalette.h"
|
|
|
|
#include "lib/ivis_common/ivispatch.h"
|
|
|
|
#include "lib/ivis_common/textdraw.h"
|
|
|
|
#include "lib/ivis_common/bitimage.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-03 04:57:16 -07:00
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Local Definitions
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
#define MAX_IVIS_FONTS 8
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
IMAGEFILE *FontFile; // The image data that contains the font.
|
|
|
|
// UWORD FontStartID; // The image ID of character ASCII 33.
|
|
|
|
// UWORD FontEndID; // The image ID of last character in the font.
|
|
|
|
int FontAbove; // Max pixels above the base line.
|
|
|
|
int FontBelow; // Max pixels below the base line.
|
|
|
|
int FontLineSize; // Pixel spacing used for new lines.
|
|
|
|
int FontSpaceSize; // Pixel spacing used for spaces.
|
|
|
|
SWORD FontColourIndex; // The colour index to use.
|
|
|
|
// BOOL bGameFont;
|
|
|
|
UWORD *AsciiTable;
|
|
|
|
} IVIS_FONT;
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Local Variables
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
static SWORD TextColourIndex;
|
|
|
|
static int NumFonts;
|
|
|
|
static int ActiveFontID;
|
|
|
|
static IVIS_FONT iVFonts[MAX_IVIS_FONTS];
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Local ProtoTypes
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
2007-08-01 11:59:51 -07:00
|
|
|
static void pie_BeginTextRender(SWORD ColourIndex);
|
|
|
|
static void pie_TextRender(IMAGEFILE *ImageFile, UWORD ID, int x, int y);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Source
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
void iV_ClearFonts(void)
|
|
|
|
{
|
|
|
|
NumFonts = 0;
|
|
|
|
ActiveFontID = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a font using an ascii lookup table.
|
|
|
|
//
|
|
|
|
// IMAGEFILE *ImageFile Image file containing the font graphics.
|
|
|
|
// UWORD *AsciiTable Array of 256 Ascii to ImageID lookups.
|
|
|
|
// int SpaceSize Pixel size of a space.
|
|
|
|
// BOOL bInGame Specifies that the font is used in game (WHY?)
|
|
|
|
//
|
|
|
|
int iV_CreateFontIndirect(IMAGEFILE *ImageFile, UWORD *AsciiTable, int SpaceSize)
|
|
|
|
{
|
2007-08-01 11:26:56 -07:00
|
|
|
int Above, Below;
|
2007-06-28 10:47:08 -07:00
|
|
|
int Height;
|
2007-08-01 11:26:56 -07:00
|
|
|
UWORD Index, c;
|
2007-06-28 10:47:08 -07:00
|
|
|
IVIS_FONT *Font;
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
assert(NumFonts < MAX_IVIS_FONTS - 1);
|
2006-06-02 12:34:58 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
Font = &iVFonts[NumFonts];
|
|
|
|
|
|
|
|
Font->FontFile = ImageFile;
|
|
|
|
Font->AsciiTable = AsciiTable;
|
|
|
|
Font->FontSpaceSize = SpaceSize;
|
|
|
|
Font->FontLineSize = 0;
|
|
|
|
Font->FontAbove = 0;
|
|
|
|
Font->FontBelow = 0;
|
|
|
|
|
|
|
|
// Initialise the font metrics.
|
2007-08-01 11:26:56 -07:00
|
|
|
for (c = 0; c < 256; c++)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
Index = (UWORD)AsciiTable[c];
|
2007-08-01 11:26:56 -07:00
|
|
|
Above = iV_GetImageYOffset(Font->FontFile, Index);
|
|
|
|
Below = Above + iV_GetImageHeight(Font->FontFile, Index);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
Height = abs(Above) + abs(Below);
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
if (Above < Font->FontAbove)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
Font->FontAbove = Above;
|
|
|
|
}
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
if (Below > Font->FontBelow)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
Font->FontBelow = Below;
|
|
|
|
}
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
if (Height > Font->FontLineSize)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
Font->FontLineSize = Height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ActiveFontID = NumFonts;
|
|
|
|
|
|
|
|
NumFonts++;
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
return NumFonts - 1;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void iV_SetFont(int FontID)
|
|
|
|
{
|
|
|
|
assert(FontID < NumFonts);
|
|
|
|
ActiveFontID = FontID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int iV_GetTextLineSize(void)
|
|
|
|
{
|
|
|
|
IVIS_FONT *Font = &iVFonts[ActiveFontID];
|
|
|
|
return abs(Font->FontAbove) + abs(Font->FontBelow);
|
|
|
|
}
|
|
|
|
|
|
|
|
int iV_GetTextAboveBase(void)
|
|
|
|
{
|
|
|
|
IVIS_FONT *Font = &iVFonts[ActiveFontID];
|
|
|
|
return Font->FontAbove;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iV_GetTextBelowBase(void)
|
|
|
|
{
|
|
|
|
IVIS_FONT *Font = &iVFonts[ActiveFontID];
|
|
|
|
return Font->FontBelow;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-30 09:44:56 -07:00
|
|
|
unsigned int iV_GetTextWidth(const char *String)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-30 09:42:37 -07:00
|
|
|
unsigned int width = 0;
|
|
|
|
while (*String != 0)
|
|
|
|
{
|
|
|
|
width += iV_GetCharWidth(*(String++));
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-07-30 09:42:37 -07:00
|
|
|
return width;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-03 04:37:06 -07:00
|
|
|
unsigned int iV_GetCharWidth(char Char)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
UWORD ImageID;
|
2007-07-30 09:46:37 -07:00
|
|
|
IVIS_FONT* Font = &iVFonts[ActiveFontID];
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-07-30 09:42:37 -07:00
|
|
|
if (Char == ASCII_COLOURMODE)
|
|
|
|
return 0;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-07-30 09:42:37 -07:00
|
|
|
if (Char == ASCII_SPACE)
|
|
|
|
return Font->FontSpaceSize;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-07-30 09:46:37 -07:00
|
|
|
ImageID = Font->AsciiTable[(unsigned char)Char];
|
2007-07-30 09:42:37 -07:00
|
|
|
return iV_GetImageWidth(Font->FontFile, ImageID) + 1;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void iV_SetTextColour(SWORD Index)
|
|
|
|
{
|
|
|
|
IVIS_FONT *Font = &iVFonts[ActiveFontID];
|
|
|
|
Font->FontColourIndex = Index;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EXTENTS_NONE,
|
|
|
|
EXTENTS_START,
|
|
|
|
EXTENTS_END
|
|
|
|
};
|
|
|
|
|
2006-11-03 13:35:50 -08:00
|
|
|
static char FString[256]; // Must do something about these wastefull static arrays.
|
|
|
|
static char FWord[256];
|
2007-06-28 10:47:08 -07:00
|
|
|
static int LastX; // Cursor position after last draw.
|
|
|
|
static int LastY;
|
|
|
|
static int LastTWidth; // Pixel width of the last string draw.
|
|
|
|
static int RecordExtents = EXTENTS_NONE;
|
|
|
|
static int ExtentsStartX;
|
|
|
|
static int ExtentsStartY;
|
|
|
|
static int ExtentsEndX;
|
|
|
|
static int ExtentsEndY;
|
|
|
|
|
|
|
|
// Draws formatted text with word wrap, long word splitting, embedded
|
|
|
|
// newlines ( uses @ rather than \n ) and colour mode toggle ( # ) which enables
|
|
|
|
// or disables font colouring.
|
|
|
|
//
|
|
|
|
// UBYTE *String The string to display.
|
|
|
|
// UDWORD x x coord of top left of formatted text window.
|
|
|
|
// UDWORD y y coord of top left of formatted text window.
|
|
|
|
// UDWORD Width Width of formatted text window.
|
|
|
|
// UDWORD Justify Justify mode, one of the following:
|
|
|
|
// FTEXT_LEFTJUSTIFY
|
|
|
|
// FTEXT_CENTRE
|
|
|
|
// FTEXT_RIGHTJUSTIFY
|
|
|
|
// BOOL DrawBack If TRUE then draws transparent box behind text.
|
|
|
|
//
|
|
|
|
// Returns y coord of next text line.
|
|
|
|
//
|
2007-08-03 06:14:34 -07:00
|
|
|
UDWORD iV_DrawFormattedText(const char* String, UDWORD x, UDWORD y, UDWORD Width, UDWORD Justify)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-30 10:03:02 -07:00
|
|
|
int i;
|
2007-06-28 10:47:08 -07:00
|
|
|
int jx = x; // Default to left justify.
|
|
|
|
int jy = y;
|
2007-01-04 10:41:24 -08:00
|
|
|
UDWORD WWidth;
|
2007-06-28 10:47:08 -07:00
|
|
|
int TWidth;
|
|
|
|
|
2007-07-30 10:03:02 -07:00
|
|
|
const char* curChar = String;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// DBPRINTF(("[%s] @(%d,%d) extentsmode=%d just=%d\n",String,x,y,ExtentsMode,Justify));
|
2006-06-02 12:34:58 -07:00
|
|
|
|
2007-07-30 10:03:02 -07:00
|
|
|
curChar = String;
|
|
|
|
while (*curChar != 0)
|
|
|
|
{
|
2007-08-06 04:22:31 -07:00
|
|
|
char* curSpaceChar;
|
|
|
|
|
2007-08-01 13:50:27 -07:00
|
|
|
bool GotSpace = false;
|
|
|
|
bool NewLine = false;
|
|
|
|
|
2007-08-01 13:17:23 -07:00
|
|
|
// Reset text draw buffer
|
2007-06-28 10:47:08 -07:00
|
|
|
FString[0] = 0;
|
|
|
|
|
2007-08-01 09:57:41 -07:00
|
|
|
WWidth = 0;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// Parse through the string, adding words until width is achieved.
|
2007-08-01 13:50:27 -07:00
|
|
|
while (*curChar != 0 && WWidth < Width && !NewLine)
|
2007-07-30 10:03:02 -07:00
|
|
|
{
|
2007-08-01 13:50:27 -07:00
|
|
|
const char* startOfWord = curChar;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// Get the next word.
|
2007-08-01 11:26:56 -07:00
|
|
|
i = 0;
|
2007-08-01 13:50:27 -07:00
|
|
|
for (; *curChar != 0
|
|
|
|
&& *curChar != ASCII_SPACE
|
|
|
|
&& *curChar != ASCII_NEWLINE;
|
|
|
|
++i, ++curChar)
|
2007-07-30 10:03:02 -07:00
|
|
|
{
|
2007-08-01 11:26:56 -07:00
|
|
|
if (*curChar == ASCII_COLOURMODE) // If it's a colour mode toggle char then just add it to the word.
|
2007-07-30 10:03:02 -07:00
|
|
|
{
|
|
|
|
FWord[i] = *curChar;
|
2007-08-01 13:17:23 -07:00
|
|
|
|
|
|
|
// this character won't be drawn so don't deal with its width
|
|
|
|
continue;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2007-08-01 13:17:23 -07:00
|
|
|
|
|
|
|
// Update this lines pixel width.
|
|
|
|
WWidth += iV_GetCharWidth(*curChar);
|
|
|
|
|
|
|
|
// If this word doesn't fit on the current line then break out
|
|
|
|
if (WWidth > Width)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// If width ok then add this character to the current word.
|
|
|
|
FWord[i] = *curChar;
|
2007-08-01 11:26:56 -07:00
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
// Don't forget the space.
|
2007-08-01 13:50:27 -07:00
|
|
|
if (*curChar == ASCII_SPACE)
|
2007-07-30 10:03:02 -07:00
|
|
|
{
|
2007-08-01 11:26:56 -07:00
|
|
|
WWidth += iV_GetCharWidth(' ');
|
|
|
|
if (WWidth <= Width)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
FWord[i] = ' ';
|
2007-07-30 10:03:02 -07:00
|
|
|
++i;
|
|
|
|
++curChar;
|
2007-08-01 13:50:27 -07:00
|
|
|
GotSpace = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
2007-08-01 13:50:27 -07:00
|
|
|
// Check for new line character.
|
|
|
|
else if (*curChar == ASCII_NEWLINE)
|
|
|
|
{
|
|
|
|
NewLine = true;
|
|
|
|
++curChar;
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-01 13:50:27 -07:00
|
|
|
// If we've passed a space on this line and the word goes past the
|
|
|
|
// maximum width and this isn't caused by the appended space then
|
|
|
|
// rewind to the start of this word and finish this line.
|
2007-08-01 13:17:23 -07:00
|
|
|
if (GotSpace
|
2007-08-01 13:50:27 -07:00
|
|
|
&& WWidth > Width
|
|
|
|
&& FWord[i - 1] != ' ')
|
2007-08-01 11:26:56 -07:00
|
|
|
{
|
2007-08-01 13:50:27 -07:00
|
|
|
// Skip back to the beginning of this
|
|
|
|
// word and draw it on the next line
|
|
|
|
curChar = startOfWord;
|
|
|
|
break;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Terminate the word.
|
|
|
|
FWord[i] = 0;
|
|
|
|
|
|
|
|
// And add it to the output string.
|
|
|
|
strcat(FString, FWord);
|
2007-08-01 11:26:56 -07:00
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
|
2007-08-01 09:57:41 -07:00
|
|
|
// Remove trailing spaces, useful when doing center alignment.
|
2007-08-06 04:22:31 -07:00
|
|
|
curSpaceChar = &FString[strlen(FString) - 1];
|
|
|
|
while (curSpaceChar != &FString[-1] && *curSpaceChar == ASCII_SPACE)
|
2007-08-01 09:57:41 -07:00
|
|
|
{
|
2007-08-06 04:22:31 -07:00
|
|
|
*(curSpaceChar--) = 0;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TWidth = iV_GetTextWidth(FString);
|
|
|
|
|
|
|
|
|
|
|
|
// DBPRINTF(("string[%s] is %d of %d pixels wide (according to DrawFormattedText)\n",FString,TWidth,Width));
|
|
|
|
|
|
|
|
// Do justify.
|
2007-08-01 11:26:56 -07:00
|
|
|
switch (Justify)
|
2007-08-01 09:57:41 -07:00
|
|
|
{
|
|
|
|
case FTEXT_CENTRE:
|
2007-08-01 11:26:56 -07:00
|
|
|
jx = x + (Width - TWidth) / 2;
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
|
2007-08-01 09:57:41 -07:00
|
|
|
case FTEXT_RIGHTJUSTIFY:
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
jx = x + Width - TWidth;
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
|
2007-08-01 09:57:41 -07:00
|
|
|
case FTEXT_LEFTJUSTIFY:
|
2007-06-28 10:47:08 -07:00
|
|
|
jx = x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw the text.
|
2007-08-03 06:14:34 -07:00
|
|
|
iV_DrawText(FString, jx, jy);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
//DBPRINTF(("[%s] @ %d,%d\n",FString,jx,jy));
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
/* callback type for resload display callback*/
|
2007-06-28 10:47:08 -07:00
|
|
|
// remember where we were..
|
|
|
|
LastX = jx + TWidth;
|
|
|
|
LastY = jy;
|
|
|
|
LastTWidth = TWidth;
|
|
|
|
|
|
|
|
// and move down a line.
|
|
|
|
jy += iV_GetTextLineSize();
|
|
|
|
}
|
|
|
|
|
2007-08-01 11:26:56 -07:00
|
|
|
if (RecordExtents == EXTENTS_START)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
RecordExtents = EXTENTS_END;
|
|
|
|
|
|
|
|
ExtentsStartY = y + iV_GetTextAboveBase();
|
2007-08-01 11:26:56 -07:00
|
|
|
ExtentsEndY = jy - iV_GetTextLineSize() + iV_GetTextBelowBase();
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-06 04:22:31 -07:00
|
|
|
ExtentsStartX = x; // Was jx, but this broke the console centre justified text background.
|
|
|
|
// ExtentsEndX = jx + TWidth;
|
|
|
|
ExtentsEndX = x + Width;
|
2007-08-01 11:26:56 -07:00
|
|
|
}
|
|
|
|
else if (RecordExtents == EXTENTS_END)
|
|
|
|
{
|
|
|
|
ExtentsEndY = jy - iV_GetTextLineSize() + iV_GetTextBelowBase();
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-06 04:22:31 -07:00
|
|
|
ExtentsEndX = x + Width;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return jy;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-09-25 13:40:56 -07:00
|
|
|
void iV_DrawTextRotated(const char* string, float x, float y, float rotation)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-09-27 05:23:23 -07:00
|
|
|
unsigned int curX;
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
IVIS_FONT *Font = &iVFonts[ActiveFontID];
|
|
|
|
|
2007-09-25 13:40:56 -07:00
|
|
|
// Move to the correct position and rotation for text rendering
|
|
|
|
glTranslatef(x, y, 0.f);
|
|
|
|
glRotatef(rotation, 0.f, 0.f, 1.f);
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* Colour selection */
|
|
|
|
pie_BeginTextRender(Font->FontColourIndex);
|
|
|
|
|
2007-09-27 05:23:23 -07:00
|
|
|
for (curX = 0; *string != 0; ++string)
|
2007-08-01 09:57:41 -07:00
|
|
|
{
|
|
|
|
unsigned int Index = (unsigned char)*string;
|
2007-08-01 11:59:51 -07:00
|
|
|
UWORD ImageID;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// Toggle colour mode?
|
2007-08-01 11:26:56 -07:00
|
|
|
if (Index == ASCII_COLOURMODE)
|
2007-08-01 09:57:41 -07:00
|
|
|
{
|
2007-08-01 11:59:51 -07:00
|
|
|
static SWORD OldTextColourIndex = -1;
|
|
|
|
|
2007-08-01 09:57:41 -07:00
|
|
|
if (TextColourIndex >= 0)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
OldTextColourIndex = TextColourIndex;
|
|
|
|
TextColourIndex = -1;
|
2007-08-01 09:57:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-01 11:26:56 -07:00
|
|
|
if (OldTextColourIndex >= 0)
|
2007-08-01 09:57:41 -07:00
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
TextColourIndex = OldTextColourIndex;
|
|
|
|
}
|
|
|
|
}
|
2007-08-01 11:59:51 -07:00
|
|
|
|
|
|
|
// Don't draw this character
|
|
|
|
continue;
|
2007-08-01 09:57:41 -07:00
|
|
|
}
|
2007-08-01 11:26:56 -07:00
|
|
|
else if (Index == ASCII_SPACE)
|
2007-08-01 09:57:41 -07:00
|
|
|
{
|
2007-09-25 13:40:56 -07:00
|
|
|
curX += Font->FontSpaceSize;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-08-01 11:59:51 -07:00
|
|
|
// Don't draw this character
|
|
|
|
continue;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2007-08-01 09:57:41 -07:00
|
|
|
|
2007-08-01 11:59:51 -07:00
|
|
|
// Draw the character
|
|
|
|
ImageID = Font->AsciiTable[Index];
|
2007-09-25 13:40:56 -07:00
|
|
|
pie_TextRender(Font->FontFile, ImageID, curX, 0);
|
2007-08-01 11:59:51 -07:00
|
|
|
|
|
|
|
// Advance the drawing position
|
2007-09-25 13:40:56 -07:00
|
|
|
curX += iV_GetImageWidth(Font->FontFile, ImageID) + 1;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-08-03 04:57:16 -07:00
|
|
|
// Reset the tranlation matrix
|
|
|
|
glLoadIdentity();
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void pie_BeginTextRender(SWORD ColourIndex)
|
|
|
|
{
|
|
|
|
TextColourIndex = ColourIndex;
|
|
|
|
pie_SetRendMode(REND_TEXT);
|
2006-06-02 12:34:58 -07:00
|
|
|
pie_SetBilinear(FALSE);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-08-06 04:22:31 -07:00
|
|
|
#define PIE_TEXT_WHITE_COLOUR (0xffffffff)
|
|
|
|
#define PIE_TEXT_LIGHTBLUE_COLOUR (0xffa0a0ff)
|
|
|
|
#define PIE_TEXT_DARKBLUE_COLOUR (0xff6060c0)
|
|
|
|
|
2007-08-01 11:59:51 -07:00
|
|
|
static void pie_TextRender(IMAGEFILE *ImageFile, UWORD ID, int x, int y)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
UDWORD Red;
|
|
|
|
UDWORD Green;
|
|
|
|
UDWORD Blue;
|
|
|
|
UDWORD Alpha = MAX_UB_LIGHT;
|
|
|
|
iColour* psPalette;
|
|
|
|
|
|
|
|
|
2007-08-01 09:57:41 -07:00
|
|
|
if (TextColourIndex == PIE_TEXT_WHITE
|
|
|
|
|| TextColourIndex == 255)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_SetColour(MAX_LIGHT);
|
2007-08-01 09:57:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (TextColourIndex == PIE_TEXT_WHITE)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_SetColour(PIE_TEXT_WHITE_COLOUR);
|
2007-08-01 09:57:41 -07:00
|
|
|
}
|
|
|
|
else if (TextColourIndex == PIE_TEXT_LIGHTBLUE)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_SetColour(PIE_TEXT_LIGHTBLUE_COLOUR);
|
2007-08-01 09:57:41 -07:00
|
|
|
}
|
|
|
|
else if (TextColourIndex == PIE_TEXT_DARKBLUE)
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_SetColour(PIE_TEXT_DARKBLUE_COLOUR);
|
2007-08-01 09:57:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
psPalette = pie_GetGamePal();
|
|
|
|
Red = psPalette[TextColourIndex].r;
|
2007-08-01 11:26:56 -07:00
|
|
|
Green = psPalette[TextColourIndex].g;
|
2007-06-28 10:47:08 -07:00
|
|
|
Blue = psPalette[TextColourIndex].b;
|
2007-08-01 11:26:56 -07:00
|
|
|
pie_SetColour(((Alpha << 24) | (Red << 16) | (Green << 8) | Blue));
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pie_SetColourKeyedBlack(TRUE);
|
2007-08-01 11:26:56 -07:00
|
|
|
pie_DrawImageFileID(ImageFile, ID, x, y);
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_SetColourKeyedBlack(FALSE);
|
|
|
|
}
|