Files | |
file | text.c |
Implementaion of on-screen text handling and constant strings. | |
file | text.h |
Interface to code handling on-screen text. | |
Defines | |
#define | _(text) ((wchar_t*)gettext((char*)(text))) |
A macro to make using gettext() shorter by giving it a shorter name and performing the needed type casts to avoid compiler warnings. | |
#define | prnfile fwprintf |
Writes a formatted string to a file using fwprintf(), fprintf(), or a similar function. | |
#define | prnout wprintf |
Writes a formatted string to stdout using wprintf(), printf(), or a similar function. | |
#define | prnstr swprintf |
Writes a formatted string to another string using snwprintf(), snprintf(), or a similar function. | |
#define | RenderTTF TTF_RenderUNICODE_Blended |
The function to render text. | |
#define | rtsa_strchr wcschr |
Finds the next instance of a specific character in a string using either wstrchr() for I18N support, or strchr. | |
#define | rtsa_strcmp wcscmp |
A string compare function, either wcscmp() for I18N support, or strcmp(). | |
#define | rtsa_strcpy wcscpy |
A string copy function, either wcscpy() for I18N support, or strcpy(). | |
#define | rtsa_strlen wcslen |
A string length function, either wcslen() for I18N support, or strlen(). | |
#define | rtsa_strncpy wcsncpy |
A string copy function, either wcsncpy() for I18N support, or strncpy(). | |
#define | SizeTTF TTF_SizeUNICODE |
The function to report the height and width of text. | |
#define | vprnstr vswprintf |
Writes a formatted string to another string using vsnwprintf(), vsnprintf(), or a similar function. | |
#define | witechar putwc |
Writes a single character to a file using putwc(), or putc(). | |
Typedefs | |
typedef wchar_t | rtsa_char |
The character type used to store and manipulate strings for later output. | |
typedef Uint16 | rtsa_outchar |
The character type used in the strings given to the SDL_ttf functions. | |
Enumerations | |
enum | { TEXTITEM_TITLE, TEXTITEM_TRANS, TEXTITEM_AUTH, TEXTITEM_COPYRIGHT, TEXTITEM_GPL, TEXTITEM_ERROR = 1, TEXTITEM_ERRCONT, TEXTITEM_CHOSETEAM = 1, TEXTITEM_FIREOPT, TEXTITEM_NETSTAT, TEXTITEM_NETOPTS, TEXTITEM_REDMEM, TEXTITEM_BLUEMEM, TEXTITEM_REDTEAM = 0, TEXTITEM_BLUETEAM, TEXTITEM_REDSCORE, TEXTITEM_BLUESCORE, TEXTITEM_RESPAWN, TEXTITEM_MISC, TEXTITEM_MAX } |
Indices into an array of RenderItems used to render text. More... | |
enum | { STRING_REDTEAM, STRING_BLUETEAM, STRING_REDFLAGHELD, STRING_REDFLAGCAP, STRING_BLUEFLAGHELD, STRING_BLUEFLAGCAP, STRING_TEAMKILL, STRING_LOCALTEAMKILLER, STRING_LOCALTEAMKILLED, STRING_KILL, STRING_LOCALKILL, STRING_REDWIN, STRING_BLUEWIN, STRING_RESPAWN, STRING_TITLE, STRING_AUTH, STRING_TRANS, STRING_COPYRIGHT, STRING_GPL, STRING_CHOSETEAM, STRING_FIREOPT, STRING_FIRECONT, STRING_NETLOOKING, STRING_NETCONTACT, STRING_NETRCVCFG, STRING_NETCLIENT, STRING_NETCLIDISCONN, STRING_NETSERVER, STRING_NETSRVDISCONN, STRING_NETDENY, STRING_NETDISCONN, STRING_NETSEARCHERR, STRING_NETSRVERR, STRING_NETCONERR, STRING_NETADDR, STRING_NETSYNC, STRING_NETLAT, STRING_DEFAULTNAME, STRING_TIMEFORM, STRING_TIMELEFT, STRING_BF_STAT, STRING_CMPLOPT, STRING_ERR_READ, STRING_ERR_PROC, STRING_ERR_MEM, STRING_ERR_FOPEN, STRING_ERR_EOFINC, STRING_ERR_EOFNAME, STRING_ERR_NAMELONG, STRING_ERR_FLDSMALL, STRING_ERR_FLDLARGE, STRING_ERR_NOSIZE, STRING_ERR_INVLDKEY, STRING_ERR_NOREDSPN, STRING_ERR_NOBLSPN, STRING_ERR_NOREDGOAL, STRING_ERR_NOBLGOAL, STRING_ERR_BACKSLASH, STRING_ERR_IO, STRING_ERR_EOL, STRING_ERR_PARAM, STRING_ERR_XYRANGE, STRING_ERR_WHRANGE, STRING_ERR_BADOWN, STRING_ERR_NONE, STRING_ERR_WOULDBLOCK, STRING_ERR_BADF, STRING_ERR_FAULT, STRING_ERR_INTR, STRING_ERR_INVAL, STRING_ERR_NOTSOCK, STRING_ERR_ADDRINUSE, STRING_ERR_NETDOWN, STRING_ERR_NETUNREACH, STRING_ERR_CONNRESET, STRING_ERR_CONNREFUSED, STRING_ERR_HOSTUNREACH, STRING_ERR_HOSTLOOK, STRING_ERR_SDL, STRING_ERR_VIDQ, STRING_ERR_VIDMODE, STRING_ERR_TTFINIT, STRING_ERR_RENDER, STRING_ERR_FNTOPEN, STRING_ERR_FNTINIT, STRING_ERR_OPENAUDIO, STRING_ERR_LOADSND, STRING_ERR_NOSNDS, STRING_ERR_DEFAULT, STRING_STAT_SINGLEBUFF, STRING_STAT_DOUBLEBUFF, STRING_STAT_NOHWACCEL, STRING_STAT_HWACCEL, STRING_STAT_OUTSYSMEM, STRING_STAT_OUTGRPMEM, STRING_STAT_VIDDRNAME, STRING_STAT_JOYSTICK, STRING_STAT_NOAUDIO, STRING_STAT_ENTERSTATE, STRING_STAT_EXITSTATE, STRING_MAX } |
Indices into an array of constant strings used for messages presented to the user. More... | |
enum | FONTS { FONT_MESSAGE, FONT_SCORE, FONT_PLAYER, FONT_MAX } |
The available fonts. More... | |
Functions | |
Bool | FontInit () |
Initalizes fonts and other graphical parts of the text system. | |
Bool | TextInit () |
Initalizes the text system's string table and support for translation through GNU gettext (if compiled to support gettext). | |
int | TextNativeToUTF16 (Uint16 *dest, size_t destlen, rtsa_char *src, size_t srclen) |
Converts a string from the internal format to big endian UTF-16. | |
Bool | TextRenderString (RenderItem *text, int font, int maxwidth, SDL_Color color, const rtsa_char *format,...) |
Renders a string to an SDL_Surface stored at text->data, sets the size to match, and sets the render function to GenericSurfaceRenderer(). | |
Bool | TextRenderStringV (RenderItem *text, int font, int maxwidth, SDL_Color color, const rtsa_char *format, va_list args) |
Renders a string to an SDL_Surface stored at text->data, sets the size to match, and sets the render function to GenericSurfaceRenderer(). | |
static Bool | TextSetup (int startStr, int startInd, int endInd, int font, SDL_Color color) |
Renders several of the constant strings and puts them in a ready to use RenderItem in textItems. | |
Bool | TextSetupStateMenu () |
Configures the text system for use with STATE_CODES::STATE_MENUROOT and other menu states. | |
Bool | TextSetupStatePlay () |
Configures the text system for use with STATE_CODES::STATE_PLAY. | |
Bool | TextSetupStateSplash () |
Configures the text system for use with STATE_CODES::STATE_SPLASH. | |
void | TextSetWindowTitle () |
Sets the title used on the program's window. | |
void | TextUninit () |
Uninitalizes the text system and loaded fonts. | |
void | TextUnsetState () |
Removes rendered text items in preperation for a new set to be rendered. | |
int | TextUTF16toNative (rtsa_char *dest, size_t destlen, Uint16 *src, size_t srclen) |
Converts a string from big endian UTF-16 to the internal format. | |
Variables | |
static int | fontHeight [FONT_MAX] |
The height of each font. | |
static TTF_Font * | fonts [FONT_MAX] |
Pointers to the loaded and ready-to-use fonts. | |
static int | spaceWidth [FONT_MAX] |
The width of a space in each font. | |
static iconv_t | strconvdescr |
A descriptor used to convert text from the internal wide format (wchar_t) to native byte order UTF-16 for use with the SDL_ttf functions. | |
static iconv_t | strconvntou |
A descriptor used to convert text from the internal wide format (wchar_t) to big endian UTF-16 for use with network communications. | |
static iconv_t | strconvuton |
A descriptor used to convert text from big endian UTF-16 to the internal wide format (wchar_t) for network communications. | |
rtsa_char * | strings [STRING_MAX] |
An array of strings with message text. | |
RenderItem | textItems [TEXTITEM_MAX] |
The array of text items that can be displayed. |
Includes text constants that can, hopefully, be easily changed to support other languages.
To use the text system, first call TextInit(). Then, call one of the TextSetupState* functions to prepare a set of constant strings for the state. Before calling another TextSetupState* function, call TextUnsetState() to remove all text items. Use TextRenderString() to create new strings with variable content. Once finished with the system, call TextUninit() to free memory used by the fonts.
Copyright (C) 2007 Jeff Jackowski
This program 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.
This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Or visit their website at: http://www.gnu.org/
#define _ | ( | text | ) | ((wchar_t*)gettext((char*)(text))) |
A macro to make using gettext() shorter by giving it a shorter name and performing the needed type casts to avoid compiler warnings.
Definition at line 157 of file text.h.
Referenced by TextInit().
#define prnfile fwprintf |
Writes a formatted string to a file using fwprintf(), fprintf(), or a similar function.
Definition at line 148 of file text.h.
Referenced by ErrorOut(), FontInit(), LookupResult(), main(), and TextInit().
#define prnout wprintf |
Writes a formatted string to stdout using wprintf(), printf(), or a similar function.
Definition at line 143 of file text.h.
Referenced by main(), MakeBuffers(), and TextInit().
#define prnstr swprintf |
Writes a formatted string to another string using snwprintf(), snprintf(), or a similar function.
Definition at line 133 of file text.h.
Referenced by ErrorOut().
#define RenderTTF TTF_RenderUNICODE_Blended |
The function to render text.
Uses TTF_RenderUNICODE_Blended() when built with I18N support, or TTF_RenderText_Blended().
Definition at line 162 of file text.h.
Referenced by TextRenderStringV().
#define rtsa_strchr wcschr |
#define rtsa_strcmp wcscmp |
#define rtsa_strcpy wcscpy |
A string copy function, either wcscpy() for I18N support, or strcpy().
Definition at line 111 of file text.h.
Referenced by AddPlayer(), and GetLocalPlayerName().
#define rtsa_strlen wcslen |
A string length function, either wcslen() for I18N support, or strlen().
Definition at line 123 of file text.h.
Referenced by AppendPlayerData(), and TextSetWindowTitle().
#define rtsa_strncpy wcsncpy |
A string copy function, either wcsncpy() for I18N support, or strncpy().
Definition at line 115 of file text.h.
Referenced by SetLocalPlayerName(), and SetUsername().
#define SizeTTF TTF_SizeUNICODE |
The function to report the height and width of text.
Uses TTF_SizeUNICODE() when built with I18N support, or TTF_SizeText().
Definition at line 167 of file text.h.
Referenced by TextRenderStringV().
#define vprnstr vswprintf |
Writes a formatted string to another string using vsnwprintf(), vsnprintf(), or a similar function.
Definition at line 138 of file text.h.
Referenced by ErrorOut().
#define witechar putwc |
Writes a single character to a file using putwc(), or putc().
Definition at line 152 of file text.h.
Referenced by ErrorOut().
typedef wchar_t rtsa_char |
typedef Uint16 rtsa_outchar |
anonymous enum |
Indices into an array of RenderItems used to render text.
Serveral of the items have the same value because they are used during different operating states and will never be used together.
TEXTITEM_TITLE | The title of the game in a large font. |
TEXTITEM_TRANS | The author of the game. |
TEXTITEM_AUTH | The translator for the language the game is currently using. |
TEXTITEM_COPYRIGHT | Copyright year. |
TEXTITEM_GPL | The multi-line GPL notice. |
TEXTITEM_ERROR | The error message. |
TEXTITEM_ERRCONT | Prompt to press fire to continue. |
TEXTITEM_CHOSETEAM | Prompt to chose a team to join. |
TEXTITEM_FIREOPT | Prompt to see more options by pressing fire. |
TEXTITEM_NETSTAT |
The network status message, one of:
|
TEXTITEM_NETOPTS | The networked game options. |
TEXTITEM_REDMEM | The number of red team members. |
TEXTITEM_BLUEMEM | The number of blue team members. |
TEXTITEM_REDTEAM | Red team's label for the score display. |
TEXTITEM_BLUETEAM | Blue team's label for the score display. |
TEXTITEM_REDSCORE |
Red team's score.
This value will vary during the game. |
TEXTITEM_BLUESCORE |
Blue team's score.
This value will vary during the game. |
TEXTITEM_RESPAWN | A prompt for the user to press fire to make their tank respawn. |
TEXTITEM_MISC | |
TEXTITEM_MAX |
anonymous enum |
Indices into an array of constant strings used for messages presented to the user.
STRING_REDTEAM | Label for the red team. |
STRING_BLUETEAM | Label for the blue team. |
STRING_REDFLAGHELD | Notice that the blue team holds the red flag. |
STRING_REDFLAGCAP | Notice that the red team's flag was successfully captured. |
STRING_BLUEFLAGHELD | Notice that the red team holds the blue flag. |
STRING_BLUEFLAGCAP | Notice that the blue team's flag was successfully captured. |
STRING_TEAMKILL | Notice that someone killed one of their teammates. |
STRING_LOCALTEAMKILLER | Notice that the local player killed one of his/her teammates. |
STRING_LOCALTEAMKILLED | Notice that the local player was killed by one of his/her teammates. |
STRING_KILL | Notice that someone killed one of their opponents. |
STRING_LOCALKILL | Notice that the local player killed one of his/her opponents. |
STRING_REDWIN | Notice that the red team has won the game. |
STRING_BLUEWIN | Notice that the blue team has won the game. |
STRING_RESPAWN | Message informing the player that pressing fire will respawn their tank. |
STRING_TITLE | The program's name. |
STRING_AUTH | The author's name and email address. |
STRING_TRANS |
The translator's credit.
Set to "translator" for English (no translator). |
STRING_COPYRIGHT | Copyright notice. |
STRING_GPL | GPL notice. |
STRING_CHOSETEAM | Request that the user select a team to join. |
STRING_FIREOPT | Notice to the player that pressing fire will show an options menu. |
STRING_FIRECONT | A prompt for the user to press the fire button to continue on to the next screen. |
STRING_NETLOOKING | Notice that the program is attempting to find a server on the LAN. |
STRING_NETCONTACT |
Notice that the program is attempting to contact a specific server, such as one specified by the player.
The string should include a "%s" that will be expanded to the hostname being contacted. |
STRING_NETRCVCFG | A message telling the user that the game has contacted a server (hostname is s) and is waiting on game option/config data before the user can join the game in progress. |
STRING_NETCLIENT |
Notice that a connection has been made to a server and this process is functioning as a server.
The string should include a "%s" that will be expanded to the hostname of the server. |
STRING_NETCLIDISCONN | A message informing the user that the game client is disconnecting from the server. |
STRING_NETSERVER |
Notice that this process is functioning as a game server.
The string should include a "%s" that will be expanded to the hostname of the local system. |
STRING_NETSRVDISCONN | A message informing the user that the server is disconnecting all game clients. |
STRING_NETDENY | A message telling the user that the server (hostname s) will not allow the game client to connect. |
STRING_NETDISCONN | A status message indicating the game has disconnected from the server or all clients. |
STRING_NETSEARCHERR |
An error message informing the user that the process of finding a server on the LAN could not be performed.
This does not mean that a server could not be found, but that the finding could not be done. The error string is ls and its translations are in net.c. |
STRING_NETSRVERR |
An error message indicating that the game could not run as a server.
The error string is ls and its translations are in net.c. |
STRING_NETCONERR |
An error message telling the user that the game acting as a client could not connect to a server.
The error is ls. |
STRING_NETADDR | A status message showing this computer's network address (s). |
STRING_NETSYNC | A message informing the user that time synchronization with the server is in progress. |
STRING_NETLAT |
A message with the latency result of time synchronization.
The latency value is given as a double (I recommed using 0.1lf for one digit after the decimal point). The units are milliseconds. |
STRING_DEFAULTNAME | The player name used when a name cannot be determined from the enviornment variables. |
STRING_TIMEFORM |
The time format.
Only minutes and seconds are provided. |
STRING_TIMELEFT | The time that remains for the round of combat. |
STRING_BF_STAT |
A format for status output showing a summary of information read from the battlefield file(s).
This output is only shown on the console to assist people in creating their own battlefields. |
STRING_CMPLOPT | A success/debugging message sent to the console that indicates the battlefield data is ready for network transmission. |
STRING_ERR_READ | The format to present any errors encountered while reading the battlefield file(s). |
STRING_ERR_PROC | The format to present any errors encountered while processing the battlefield data that isn't attributed to any particular file. |
STRING_ERR_MEM | Too little memory to handle the battlefield file. |
STRING_ERR_FOPEN | The battlefield file could not be opened. |
STRING_ERR_EOFINC | The battlefield file ends inside an include statement. |
STRING_ERR_EOFNAME |
The name of a battlefield file to include continues to the end of the file.
It should be terminated by either a semicolon (';') or the end of a line. |
STRING_ERR_NAMELONG | The name of a battlefield file to include is too long. |
STRING_ERR_FLDSMALL | The size of the battlefield is too small. |
STRING_ERR_FLDLARGE | The size of the battlefield is too large. |
STRING_ERR_NOSIZE | The battlefield size is not specified. |
STRING_ERR_INVLDKEY | An invalid keyword is in the battlefield file. |
STRING_ERR_NOREDSPN | No spawn area for the red team. |
STRING_ERR_NOBLSPN | No spawn area for the blue team. |
STRING_ERR_NOREDGOAL | No goal area specified for the red team. |
STRING_ERR_NOBLGOAL | No goal area specified for the blue team. |
STRING_ERR_BACKSLASH | Illegal use of a backslash in the path to a file. |
STRING_ERR_IO | I/O error while reading from a battlefield file. |
STRING_ERR_EOL | Line break before the end of a token. |
STRING_ERR_PARAM | Too few parameters were given to a statement in a battlefield file. |
STRING_ERR_XYRANGE | A specified coordinate is out of the allowable range. |
STRING_ERR_WHRANGE | A specified height or width is out of the allowable range. |
STRING_ERR_BADOWN | An invalid team was specified as the owning team of either a goal or spawn area. |
STRING_ERR_NONE | An error string for no error just in case. |
STRING_ERR_WOULDBLOCK | Network non-error for an operation that would have blocked if the socket wasn't non-blocking. |
STRING_ERR_BADF | Bad file descriptor. |
STRING_ERR_FAULT | Bad pointer given; dereferencing it will case a segmentation fault. |
STRING_ERR_INTR | The operation was interrupted. |
STRING_ERR_INVAL | A general error indicating that something is invalid. |
STRING_ERR_NOTSOCK | The given file descriptor is not a socket but was used as a socket. |
STRING_ERR_ADDRINUSE | The requested socket address is already in use. |
STRING_ERR_NETDOWN | The network is down. |
STRING_ERR_NETUNREACH | The network is unreachable. |
STRING_ERR_CONNRESET | The connection was reset. |
STRING_ERR_CONNREFUSED | The connection was refused. |
STRING_ERR_HOSTUNREACH | The host is unreachable. |
STRING_ERR_HOSTLOOK | A header for a specific error on a host lookup. |
STRING_ERR_SDL | SDL was not initialized. |
STRING_ERR_VIDQ | A query for video output information (SDL_GetVideoInfo()) failed. |
STRING_ERR_VIDMODE | An attempt to set the video output mode (SDL_SetVideoMode()) failed. |
STRING_ERR_TTFINIT | The SDL_ttf library failed to initialize. |
STRING_ERR_RENDER | The rendering system failed to initialize. |
STRING_ERR_FNTOPEN | A font file could not be opened. |
STRING_ERR_FNTINIT | The font(s) failed to load. |
STRING_ERR_OPENAUDIO | Failed to open an audio output device. |
STRING_ERR_LOADSND | Failed to load sound from a specific file. |
STRING_ERR_NOSNDS | No sounds were loaded. |
STRING_ERR_DEFAULT | The most generic error -- something is wrong and there is no other error string for it. |
STRING_STAT_SINGLEBUFF | Using single buffered output. |
STRING_STAT_DOUBLEBUFF | Using double buffered output. |
STRING_STAT_NOHWACCEL | No hardware acceleration on video output. |
STRING_STAT_HWACCEL | Using hardware acceleration on video output. |
STRING_STAT_OUTSYSMEM | The video output buffer is stored in system/main memory. |
STRING_STAT_OUTGRPMEM | The video output buffer is stored in the graphics hardware's memory. |
STRING_STAT_VIDDRNAME | Formatting string to show the video driver in use. |
STRING_STAT_JOYSTICK | Formatting string for some joystick or other controller information. |
STRING_STAT_NOAUDIO | Notification that audio output could not be initialized. |
STRING_STAT_ENTERSTATE | Notification that the program has entered the main state loop. |
STRING_STAT_EXITSTATE | Notification that the program has left the main state loop. |
STRING_MAX |
enum FONTS |
The available fonts.
The freely distributable Bitstream Vera font availble from http://www.gnome.org/fonts/ is used for now. To support more languages, especially non-european ones, a different font will be required.
FONT_MESSAGE |
A large font used to display these messages:
|
FONT_SCORE | A medium sized font used to display score lists. |
FONT_PLAYER | A small font used for player name labels. |
FONT_MAX |
Bool FontInit | ( | ) |
Initalizes fonts and other graphical parts of the text system.
Definition at line 675 of file text.c.
References binPath, FALSE, FONT_MAX, FONT_MESSAGE, FONT_PLAYER, FONT_SCORE, fontHeight, fonts, prnfile, spaceWidth, STRING_ERR_FNTOPEN, strings, textItems, and TRUE.
Referenced by main().
Bool TextInit | ( | ) |
Initalizes the text system's string table and support for translation through GNU gettext (if compiled to support gettext).
Does not initialize fonts or any graphics releated data -- FontInit() handles that.
Definition at line 105 of file text.c.
References _, FALSE, prnfile, prnout, strconvdescr, strconvntou, strconvuton, STRING_AUTH, STRING_BF_STAT, STRING_BLUEFLAGCAP, STRING_BLUEFLAGHELD, STRING_BLUETEAM, STRING_BLUEWIN, STRING_CHOSETEAM, STRING_CMPLOPT, STRING_COPYRIGHT, STRING_DEFAULTNAME, STRING_ERR_ADDRINUSE, STRING_ERR_BACKSLASH, STRING_ERR_BADF, STRING_ERR_BADOWN, STRING_ERR_CONNREFUSED, STRING_ERR_CONNRESET, STRING_ERR_DEFAULT, STRING_ERR_EOFINC, STRING_ERR_EOFNAME, STRING_ERR_EOL, STRING_ERR_FAULT, STRING_ERR_FLDLARGE, STRING_ERR_FLDSMALL, STRING_ERR_FNTINIT, STRING_ERR_FNTOPEN, STRING_ERR_FOPEN, STRING_ERR_HOSTLOOK, STRING_ERR_HOSTUNREACH, STRING_ERR_INTR, STRING_ERR_INVAL, STRING_ERR_INVLDKEY, STRING_ERR_IO, STRING_ERR_LOADSND, STRING_ERR_MEM, STRING_ERR_NAMELONG, STRING_ERR_NETDOWN, STRING_ERR_NETUNREACH, STRING_ERR_NOBLGOAL, STRING_ERR_NOBLSPN, STRING_ERR_NONE, STRING_ERR_NOREDGOAL, STRING_ERR_NOREDSPN, STRING_ERR_NOSIZE, STRING_ERR_NOSNDS, STRING_ERR_NOTSOCK, STRING_ERR_OPENAUDIO, STRING_ERR_PARAM, STRING_ERR_PROC, STRING_ERR_READ, STRING_ERR_RENDER, STRING_ERR_SDL, STRING_ERR_TTFINIT, STRING_ERR_VIDMODE, STRING_ERR_VIDQ, STRING_ERR_WHRANGE, STRING_ERR_WOULDBLOCK, STRING_ERR_XYRANGE, STRING_FIRECONT, STRING_FIREOPT, STRING_GPL, STRING_KILL, STRING_LOCALKILL, STRING_LOCALTEAMKILLED, STRING_LOCALTEAMKILLER, STRING_MAX, STRING_NETADDR, STRING_NETCLIDISCONN, STRING_NETCLIENT, STRING_NETCONERR, STRING_NETCONTACT, STRING_NETDENY, STRING_NETDISCONN, STRING_NETLAT, STRING_NETLOOKING, STRING_NETRCVCFG, STRING_NETSEARCHERR, STRING_NETSERVER, STRING_NETSRVDISCONN, STRING_NETSRVERR, STRING_NETSYNC, STRING_REDFLAGCAP, STRING_REDFLAGHELD, STRING_REDTEAM, STRING_REDWIN, STRING_RESPAWN, STRING_STAT_DOUBLEBUFF, STRING_STAT_ENTERSTATE, STRING_STAT_EXITSTATE, STRING_STAT_HWACCEL, STRING_STAT_JOYSTICK, STRING_STAT_NOAUDIO, STRING_STAT_NOHWACCEL, STRING_STAT_OUTGRPMEM, STRING_STAT_OUTSYSMEM, STRING_STAT_SINGLEBUFF, STRING_STAT_VIDDRNAME, STRING_TEAMKILL, STRING_TIMEFORM, STRING_TIMELEFT, STRING_TITLE, STRING_TRANS, strings, and TRUE.
Referenced by main().
int TextNativeToUTF16 | ( | Uint16 * | dest, | |
size_t | destlen, | |||
rtsa_char * | src, | |||
size_t | srclen | |||
) |
Converts a string from the internal format to big endian UTF-16.
dest | The destination string buffer. | |
destlen | The length of the destination buffer in characters (2 bytes each). | |
src | The source string in the native format. | |
srclen | The length of the source string in characters. |
Definition at line 886 of file text.c.
References strconvntou.
Referenced by AppendPlayerData().
Bool TextRenderString | ( | RenderItem * | text, | |
int | font, | |||
int | maxwidth, | |||
SDL_Color | color, | |||
const rtsa_char * | format, | |||
... | ||||
) |
Renders a string to an SDL_Surface stored at text->data, sets the size to match, and sets the render function to GenericSurfaceRenderer().
If a surface already exists in the render item, it will be destroyed before being replaced with the newly rendered text.
text | The item that will represent the rendered text. The surface pointed to by RenderItem::data should either be a valid surface, which will be freed, or NULL. | |
font | The index of the font to use. See FONTS. | |
maxwidth | The maximum width of the text in pixels. If zero or less, no maximum width will be enforced. | |
color | A display format independent color to use for the text. | |
format | The formatting string, printf() style, used to control the output. | |
... | Additional variables used to fill in fields of the formatting string. |
Definition at line 1025 of file text.c.
References TextRenderStringV().
Referenced by AddPlayer(), BfldErrInit(), BfldErrResize(), NetStatUpdate(), RenderLatency(), RenderLocalAddr(), RenderScore(), RenderTSync(), and TextSetupStateSplash().
Here is the call graph for this function:
Bool TextRenderStringV | ( | RenderItem * | text, | |
int | font, | |||
int | maxwidth, | |||
SDL_Color | color, | |||
const rtsa_char * | format, | |||
va_list | args | |||
) |
Renders a string to an SDL_Surface stored at text->data, sets the size to match, and sets the render function to GenericSurfaceRenderer().
If a surface already exists in the render item, it will be destroyed before being replaced with the newly rendered text.
text | The item that will represent the rendered text. The surface pointed to by RenderItem::data should either be a valid surface, which will be freed, or NULL. | |
font | The index of the font to use. See FONTS. | |
maxwidth | The maximum width of the text in pixels. If zero or less, no maximum width will be enforced. | |
color | A display format independent color to use for the text. | |
format | The formatting string, printf() style, used to control the output. | |
args | A variable argument list used to fill in fields of the formatting string. |
Definition at line 1038 of file text.c.
References RenderItem_t::data, FALSE, FONT_MAX, fontHeight, fonts, GenericSurfaceRenderer(), inbuff, RenderItem_t::loc, RenderItem_t::renderer, RenderTTF, SizeTTF, strconvdescr, TEXT_MAX_LINES, and TRUE.
Referenced by AddNotice(), and TextRenderString().
Here is the call graph for this function:
static Bool TextSetup | ( | int | startStr, | |
int | startInd, | |||
int | endInd, | |||
int | font, | |||
SDL_Color | color | |||
) | [static] |
Renders several of the constant strings and puts them in a ready to use RenderItem in textItems.
For internal use only.
startStr | The index of the first string in the strings array to render. | |
startInd | The index of the first textItem to contain the first rendered string. | |
endInd | The index past the last textItem to render to. A loop counter starts at startInd and the loop terminates when the counter equals endInd. | |
font | The index of the font to use. | |
color | The color of the rendered text. |
Definition at line 729 of file text.c.
References AddRenderItem(), FALSE, fonts, GenericSurfaceRenderer(), LAYER_TEXT, RenderItem_t::loc, RenderItem_t::renderer, strconvdescr, strings, textItems, and TRUE.
Referenced by TextSetupStateMenu(), TextSetupStatePlay(), and TextSetupStateSplash().
Here is the call graph for this function:
Bool TextSetupStateMenu | ( | ) |
Configures the text system for use with STATE_CODES::STATE_MENUROOT and other menu states.
Definition at line 812 of file text.c.
References COLOR_TEXT, colorFmtInd, FALSE, FONT_MESSAGE, FONT_SCORE, STRING_CHOSETEAM, STRING_TITLE, TEXTITEM_CHOSETEAM, TEXTITEM_FIREOPT, TEXTITEM_TITLE, TextSetup(), and TRUE.
Referenced by MenuRootInit().
Here is the call graph for this function:
Bool TextSetupStatePlay | ( | ) |
Configures the text system for use with STATE_CODES::STATE_PLAY.
Definition at line 825 of file text.c.
References COLOR_TEXT, colorFmtInd, FALSE, FONT_MESSAGE, FONT_SCORE, STRING_REDTEAM, STRING_RESPAWN, TEXTITEM_BLUETEAM, TEXTITEM_REDTEAM, TEXTITEM_RESPAWN, TextSetup(), and TRUE.
Referenced by GraphicReset().
Here is the call graph for this function:
Bool TextSetupStateSplash | ( | ) |
Configures the text system for use with STATE_CODES::STATE_SPLASH.
Definition at line 774 of file text.c.
References AddRenderItem(), COLOR_TEXT, colorFmtInd, FALSE, FONT_MESSAGE, FONT_PLAYER, FONT_SCORE, LAYER_TEXT, STRING_AUTH, STRING_COPYRIGHT, STRING_GPL, STRING_TITLE, STRING_TRANS, strings, TEXTITEM_AUTH, TEXTITEM_COPYRIGHT, TEXTITEM_GPL, TEXTITEM_TITLE, TEXTITEM_TRANS, textItems, TextRenderString(), TextSetup(), and TRUE.
Referenced by SplashInit().
Here is the call graph for this function:
void TextSetWindowTitle | ( | ) |
Sets the title used on the program's window.
The title used is taken from strings[STRING_TITLE] if UTF-8 support is available in SDL, otherwise an English title is used.
Definition at line 982 of file text.c.
References rtsa_strlen, STRING_TITLE, and strings.
Referenced by main().
void TextUninit | ( | ) |
Uninitalizes the text system and loaded fonts.
Does the opposite of both TextInit() and FontInit().
Definition at line 857 of file text.c.
References FONT_MAX, fonts, strconvdescr, strconvntou, strconvuton, STRING_MAX, strings, and TextUnsetState().
Referenced by main().
Here is the call graph for this function:
void TextUnsetState | ( | ) |
Removes rendered text items in preperation for a new set to be rendered.
Definition at line 838 of file text.c.
References RemoveRenderItem(), TEXTITEM_MAX, and textItems.
Referenced by BfldErrUninit(), GameInit(), GameUninit(), MenuRootUninit(), SplashUninit(), and TextUninit().
Here is the call graph for this function:
int TextUTF16toNative | ( | rtsa_char * | dest, | |
size_t | destlen, | |||
Uint16 * | src, | |||
size_t | srclen | |||
) |
Converts a string from big endian UTF-16 to the internal format.
dest | The destination string buffer. | |
destlen | The length of the destination buffer in characters. | |
src | The source string in the native format. | |
srclen | The length of the source string in characters (2 bytes each). |
Definition at line 930 of file text.c.
References strconvuton.
Referenced by ReadPlayer().
int fontHeight[FONT_MAX] [static] |
The height of each font.
For internal use only.
Definition at line 103 of file text.c.
Referenced by FontInit(), and TextRenderStringV().
TTF_Font* fonts[FONT_MAX] [static] |
Pointers to the loaded and ready-to-use fonts.
For internal use only.
Definition at line 88 of file text.c.
Referenced by FontInit(), TextRenderStringV(), TextSetup(), and TextUninit().
int spaceWidth[FONT_MAX] [static] |
The width of a space in each font.
Used to assist in calculating how many lines of text will be required.
For internal use only.
Definition at line 96 of file text.c.
Referenced by FontInit().
iconv_t strconvdescr [static] |
A descriptor used to convert text from the internal wide format (wchar_t) to native byte order UTF-16 for use with the SDL_ttf functions.
For internal use only.
Definition at line 48 of file text.c.
Referenced by TextInit(), TextRenderStringV(), TextSetup(), and TextUninit().
iconv_t strconvntou [static] |
A descriptor used to convert text from the internal wide format (wchar_t) to big endian UTF-16 for use with network communications.
For internal use only.
Definition at line 55 of file text.c.
Referenced by TextInit(), TextNativeToUTF16(), and TextUninit().
iconv_t strconvuton [static] |
A descriptor used to convert text from big endian UTF-16 to the internal wide format (wchar_t) for network communications.
For internal use only.
Definition at line 62 of file text.c.
Referenced by TextInit(), TextUninit(), and TextUTF16toNative().
An array of strings with message text.
Limits the code changes to support additional languages.
Definition at line 79 of file text.c.
Referenced by AddPlayer(), AddScoreNotice(), BfldErrInit(), CopyAreaData(), ErrorOut(), FontInit(), GetNetErrorString(), LookupResult(), main(), MakeBuffers(), NetStatUpdate(), OpenFile(), ReadAreaParams(), ReadInts(), ReadToken(), RenderLatency(), RenderLocalAddr(), RenderTSync(), SetUsername(), StartLoadConfig(), TextInit(), TextSetup(), TextSetupStateSplash(), TextSetWindowTitle(), and TextUninit().
RenderItem textItems[TEXTITEM_MAX] |
The array of text items that can be displayed.
If their data pointer (RenderItem::data) is NULL, then the item is not presently in use, is not a memeber of a Layer, and a surface containing the text does not exist.
Definition at line 81 of file text.c.
Referenced by BfldErrInit(), BfldErrResize(), FontInit(), GameInit(), NetStatFocus(), NetStatInit(), NetStatUpdate(), RenderLatency(), RenderLocalAddr(), RenderScore(), RenderTSync(), SetupMenu(), SplashResize(), TeamSelUpdate(), TextSetup(), TextSetupStateSplash(), and TextUnsetState().