text.h

Go to the documentation of this file.
00001 
00027 #ifndef __text_h__
00028 #define __text_h__
00029 
00030 #if defined(_MSC_VER) && (_MSC_VER <= 1310)
00031 // For some reason it seems Microsoft's wchar.h in Visual Studio 2003 lacks
00032 // prototypes for several functions that are defined in the header for use
00033 // with C++, nevermind they are part of the C standard.
00034 #ifndef fwide
00035 #define fwide(file, num)  (num)
00036 #endif
00037 // When used with C, Microsoft's wchar.h defines an old, non-standard
00038 // swprintf() function. Work out getting the standard prototype.
00039 #define swprintf  _nonstd_swprintf
00040 #endif
00041 
00075 #ifndef _render_h_
00076 #include "bool.h"
00077 #else
00078 #include <stdarg.h>
00079 #endif
00080 #include <SDL_types.h>
00081 #if defined(USE_GETTEXT) || defined(DOXYGEN)
00082 #include <wchar.h>
00083 #include <libintl.h>
00089 typedef wchar_t  rtsa_char;
00095 typedef Uint16   rtsa_outchar;
00096 #ifdef WIN32
00097 
00101 #undef fprintf
00102 
00106 #undef fwprintf
00107 #endif
00108 
00111 #define rtsa_strcpy  wcscpy
00112 
00115 #define rtsa_strncpy wcsncpy
00116 
00119 #define rtsa_strcmp  wcscmp
00120 
00123 #define rtsa_strlen  wcslen
00124 
00128 #define rtsa_strchr  wcschr
00129 
00133 #define prnstr    swprintf
00134 
00138 #define vprnstr   vswprintf
00139 
00143 #define prnout    wprintf
00144 
00148 #define prnfile   fwprintf
00149 
00152 #define witechar  putwc
00153 
00157 #define _(text)  ((wchar_t*)gettext((char*)(text)))
00158 
00162 #define RenderTTF  TTF_RenderUNICODE_Blended
00163 
00167 #define SizeTTF    TTF_SizeUNICODE
00168 #else
00169 typedef char   rtsa_char;
00170 typedef char   rtsa_outchar;
00171 #define rtsa_strcpy    strcpy
00172 #define rtsa_strncpy   strncpy
00173 #define rtsa_strcmp    strcmp
00174 #define rtsa_strlen    strlen
00175 #define rtsa_strchr    strchr
00176 #undef  snwprintf
00177 #define snwprintf      snprintf
00178 #define prnstr         snprintf
00179 #define vprnstr        vsnprintf
00180 #define prnout         printf
00181 #define prnfile        fprintf
00182 #define wprintf        printf
00183 #define witechar       putc
00184 #define gettext(text)  (text)
00185 #define _(text)        (text)
00186 #define RenderTTF      TTF_RenderText_Blended
00187 #define SizeTTF        TTF_SizeText
00188 #endif
00189 
00190 // Several ISO C functions are not available on older MSVCs, but the gettext
00191 // library will supply them
00192 #ifndef USE_GETTEXT
00193 #if defined(_MSC_VER) && (_MSC_VER <= 1310)
00194 #undef snwprintf
00195 // Make all calls of swprintf() go to a function that uses the standard
00196 // prototype. This function does not guarentee a null-terminated result,
00197 // unlike the standard function, so problems could result. Use a newer version
00198 // of Visual Studio (like 2005) to avoid the trouble altogether.
00199 #define snwprintf  _snwprintf
00200 #define vsnprintf  _vsnprintf
00201 #define vswprintf  _vsnwprintf
00202 #endif
00203 #ifdef _MSC_VER
00204 #define snprintf   _snprintf
00205 #endif
00206 #endif
00207 
00213 enum {
00214     // ---------- STATE_SPLASH ----------
00218     TEXTITEM_TITLE,
00222     TEXTITEM_TRANS,
00226     TEXTITEM_AUTH,
00230     TEXTITEM_COPYRIGHT,
00234     TEXTITEM_GPL,
00235     // ---------- STATE_BFLDERR ----------
00236     // Also uses TEXTITEM_TITLE
00240     TEXTITEM_ERROR = 1,
00244     TEXTITEM_ERRCONT,
00245     // ---------- STATE_MENU ----------
00246     // Also uses TEXTITEM_TITLE
00250     TEXTITEM_CHOSETEAM = 1,
00254     TEXTITEM_FIREOPT,
00262     TEXTITEM_NETSTAT,
00266     TEXTITEM_NETOPTS,
00270     TEXTITEM_REDMEM,
00274     TEXTITEM_BLUEMEM,
00275     // ---------- STATE_PLAY ----------
00279     TEXTITEM_REDTEAM = 0,
00283     TEXTITEM_BLUETEAM,
00287     TEXTITEM_REDSCORE,
00291     TEXTITEM_BLUESCORE,
00295     TEXTITEM_RESPAWN,
00296     TEXTITEM_MISC,
00297     TEXTITEM_MAX
00298 };
00299 
00306 enum FONTS {
00322     FONT_MESSAGE,
00326     FONT_SCORE,
00330     FONT_PLAYER,
00331     FONT_MAX
00332 };
00333 
00334 #if defined(_render_h_) || defined(DOXYGEN)
00335 
00340 extern RenderItem textItems[TEXTITEM_MAX];
00341 #endif
00342 
00347 enum {
00351     STRING_REDTEAM,
00355     STRING_BLUETEAM,
00359     STRING_REDFLAGHELD,
00363     STRING_REDFLAGCAP,
00367     STRING_BLUEFLAGHELD,
00371     STRING_BLUEFLAGCAP,
00375     STRING_TEAMKILL,
00379     STRING_LOCALTEAMKILLER,
00383     STRING_LOCALTEAMKILLED,
00387     STRING_KILL,
00391     STRING_LOCALKILL,
00395     STRING_REDWIN,
00399     STRING_BLUEWIN,
00403     STRING_RESPAWN,
00407     STRING_TITLE,
00411     STRING_AUTH,
00415     STRING_TRANS,
00419     STRING_COPYRIGHT,
00423     STRING_GPL,
00427     STRING_CHOSETEAM,
00431     STRING_FIREOPT,
00436     STRING_FIRECONT,
00440     STRING_NETLOOKING,
00446     STRING_NETCONTACT,
00452     STRING_NETRCVCFG,
00458     STRING_NETCLIENT,
00463     STRING_NETCLIDISCONN,
00469     STRING_NETSERVER,
00474     STRING_NETSRVDISCONN,
00479     STRING_NETDENY,
00484     STRING_NETDISCONN,
00491     STRING_NETSEARCHERR,
00496     STRING_NETSRVERR,
00501     STRING_NETCONERR,
00505     STRING_NETADDR,
00510     STRING_NETSYNC,
00516     STRING_NETLAT,
00521     STRING_DEFAULTNAME,
00525     STRING_TIMEFORM,
00529     STRING_TIMELEFT,
00535     STRING_BF_STAT,
00540     STRING_CMPLOPT,
00545     STRING_ERR_READ,
00550     STRING_ERR_PROC,
00554     STRING_ERR_MEM,
00558     STRING_ERR_FOPEN,
00562     STRING_ERR_EOFINC,
00568     STRING_ERR_EOFNAME,
00572     STRING_ERR_NAMELONG,
00576     STRING_ERR_FLDSMALL,
00580     STRING_ERR_FLDLARGE,
00584     STRING_ERR_NOSIZE,
00588     STRING_ERR_INVLDKEY,
00592     STRING_ERR_NOREDSPN,
00596     STRING_ERR_NOBLSPN,
00600     STRING_ERR_NOREDGOAL,
00604     STRING_ERR_NOBLGOAL,
00608     STRING_ERR_BACKSLASH,
00612     STRING_ERR_IO,
00616     STRING_ERR_EOL,
00620     STRING_ERR_PARAM,
00624     STRING_ERR_XYRANGE,
00628     STRING_ERR_WHRANGE,
00633     STRING_ERR_BADOWN,
00637     STRING_ERR_NONE,
00642     STRING_ERR_WOULDBLOCK,
00646     STRING_ERR_BADF,
00650     STRING_ERR_FAULT,
00654     STRING_ERR_INTR,
00658     STRING_ERR_INVAL,
00662     STRING_ERR_NOTSOCK,
00666     STRING_ERR_ADDRINUSE,
00670     STRING_ERR_NETDOWN,
00674     STRING_ERR_NETUNREACH,
00678     STRING_ERR_CONNRESET,
00682     STRING_ERR_CONNREFUSED,
00686     STRING_ERR_HOSTUNREACH,
00690     STRING_ERR_HOSTLOOK,
00694     STRING_ERR_SDL,
00698     STRING_ERR_VIDQ,
00702     STRING_ERR_VIDMODE,
00706     STRING_ERR_TTFINIT,
00710     STRING_ERR_RENDER,
00714     STRING_ERR_FNTOPEN,
00718     STRING_ERR_FNTINIT,
00722     STRING_ERR_OPENAUDIO,
00726     STRING_ERR_LOADSND,
00730     STRING_ERR_NOSNDS,  
00735     STRING_ERR_DEFAULT,
00739     STRING_STAT_SINGLEBUFF,
00743     STRING_STAT_DOUBLEBUFF,
00747     STRING_STAT_NOHWACCEL,
00751     STRING_STAT_HWACCEL,
00755     STRING_STAT_OUTSYSMEM,
00759     STRING_STAT_OUTGRPMEM,
00763     STRING_STAT_VIDDRNAME,
00767     STRING_STAT_JOYSTICK,
00771     STRING_STAT_NOAUDIO,
00775     STRING_STAT_ENTERSTATE,
00779     STRING_STAT_EXITSTATE,
00780     STRING_MAX
00781 };
00782 
00787 extern rtsa_char * strings[STRING_MAX];
00788 
00796 Bool TextInit();
00797 
00803 Bool FontInit();
00804 
00810 Bool TextSetupStateSplash();
00811 
00818 Bool TextSetupStateMenu();
00819 
00825 Bool TextSetupStatePlay();
00826 
00831 void TextUnsetState();
00832 
00838 void TextUninit();
00839 
00851 int TextNativeToUTF16(Uint16 *dest, size_t destlen, rtsa_char *src,
00852 size_t srclen);
00853 
00860 void TextSetWindowTitle();
00861 
00872 int TextUTF16toNative(rtsa_char *dest, size_t destlen, Uint16 *src,
00873 size_t srclen);
00874 
00875 #if defined(_render_h_) || defined(DOXYGEN)
00876 
00895 Bool TextRenderString(RenderItem *text, int font, int maxwidth, SDL_Color color,
00896 const rtsa_char *format, ...);
00897 
00917 Bool TextRenderStringV(RenderItem *text, int font, int maxwidth, SDL_Color color,
00918 const rtsa_char *format, va_list args);
00919 
00920 #endif
00921 
00922 #endif
00923 

Generated on Mon May 28 04:41:39 2007 for Retro Tank Super Attack by  doxygen 1.5.2