From 268637343ca13d0a80b0ca8e7751a2ef0986b667 Mon Sep 17 00:00:00 2001 From: Julie Marchant Date: Fri, 7 Jun 2019 00:18:24 -0400 Subject: [PATCH] Everything is translatable! (I think) --- src/defs.c | 2 - src/defs.h | 53 ++++++----- src/game.c | 30 ++++++ src/game.h | 4 +- src/gfx.c | 64 +++++++++---- src/intermission.c | 230 +++++++++++++++++++++++++-------------------- src/mission.c | 6 +- src/save.c | 39 +++----- src/shop.c | 171 ++++++++++++++++----------------- src/title.c | 79 ++++++++-------- 10 files changed, 369 insertions(+), 309 deletions(-) diff --git a/src/defs.c b/src/defs.c index 859129b..d54e686 100644 --- a/src/defs.c +++ b/src/defs.c @@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -const char * const systemNames[] = {"Spirit", "Eyananth", "Mordor", "Sol"}; - const char * const systemBackground[] = { "gfx/spirit.jpg", "gfx/eyananth.jpg", "gfx/mordor.jpg", "gfx/sol.jpg" }; diff --git a/src/defs.h b/src/defs.h index 1a55c6b..8baf069 100644 --- a/src/defs.h +++ b/src/defs.h @@ -67,6 +67,7 @@ along with this program. If not, see . #endif #define STRMAX 2000 +#define STRMAX_SHORT 200 #define FULLSCREEN SDL_WINDOW_FULLSCREEN_DESKTOP @@ -90,33 +91,33 @@ along with this program. If not, see . #define PIXFONT_H 14 #define MENU_Y (screen->h / 3 + 50) +#define MENU_W 400 #define MENU_SPACING 20 // Object Flags -#define FL_WEAPCO 1 -#define FL_FRIEND 2 -#define FL_IMMORTAL 4 -#define FL_NOMOVE 8 -#define FL_NOFIRE 16 -#define FL_FIRERAY 32 -#define FL_DAMAGEOWNER 64 -#define FL_LEAVESECTOR 128 -#define FL_ESCAPED 256 -#define FL_DROPMINES 512 -#define FL_AIMS 1024 -#define FL_DISABLED 2048 -#define FL_CANNOTDIE 4096 // No longer used -#define FL_RUNSAWAY 8192 -#define FL_ALWAYSFACE 16384 // Kline doesn't turn his back on you! ;) -#define FL_CIRCLES 32768L // Kline can circle around -#define FL_CONTINUOUS_FIRE 65536L // Go absolutely nutts(!) -#define FL_DEPLOYDRONES 131072L // Deploys small drone - Used by Boss 2 -#define FL_CANCLOAK 262144L -#define FL_ISCLOAKED 524288L -#define FL_ACTIVATE 1048576L -#define FL_HASMINIMUMSPEED 2097152L -#define FL_FIRELASER 4194304L -#define FL_NOBANTER 8388608L +#define FL_WEAPCO (1L << 0) +#define FL_FRIEND (1L << 1) +#define FL_IMMORTAL (1L << 2) +#define FL_NOMOVE (1L << 3) +#define FL_NOFIRE (1L << 4) +#define FL_FIRERAY (1L << 5) +#define FL_DAMAGEOWNER (1L << 6) +#define FL_LEAVESECTOR (1L << 7) +#define FL_ESCAPED (1L << 8) +#define FL_DROPMINES (1L << 9) +#define FL_AIMS (1L << 10) +#define FL_DISABLED (1L << 11) +#define FL_RUNSAWAY (1L << 12) +#define FL_ALWAYSFACE (1L << 13) // Kline doesn't turn his back on you! ;) +#define FL_CIRCLES (1L << 14) // Kline can circle around +#define FL_CONTINUOUS_FIRE (1L << 15) // Go absolutely nutts(!) +#define FL_DEPLOYDRONES (1L << 16) // Deploys small drone - Used by Boss 2 +#define FL_CANCLOAK (1L << 17) +#define FL_ISCLOAKED (1L << 18) +#define FL_ACTIVATE (1L << 19) +#define FL_HASMINIMUMSPEED (1L << 20) +#define FL_FIRELASER (1L << 21) +#define FL_NOBANTER (1L << 22) // Weapon flags #define WF_SPREAD 4 @@ -702,7 +703,8 @@ enum { SYSTEM_SPIRIT, SYSTEM_EYANANTH, SYSTEM_MORDOR, - SYSTEM_SOL + SYSTEM_SOL, + SYSTEM_MAX }; // Planets (Spirit) @@ -791,7 +793,6 @@ enum { DIFFICULTY_MAX }; -extern const char * const systemNames[]; extern const char * const systemBackground[]; extern const int rate2reload[6]; diff --git a/src/game.c b/src/game.c index f13c4f1..a8ab66a 100644 --- a/src/game.c +++ b/src/game.c @@ -59,6 +59,7 @@ typedef struct Star_ { } Star; Game game; +char game_systemNames[SYSTEM_MAX][STRMAX_SHORT]; static Star stars[STARS_NUM]; static Uint32 frameLimit = 0; @@ -67,6 +68,11 @@ static int thirds = 0; void game_init() { + strcpy(game_systemNames[SYSTEM_SPIRIT], _("Spirit")); + strcpy(game_systemNames[SYSTEM_EYANANTH], _("Eyananth")); + strcpy(game_systemNames[SYSTEM_MORDOR], _("Mordor")); + strcpy(game_systemNames[SYSTEM_SOL], _("Sol")); + game.system = SYSTEM_SPIRIT; game.area = MISN_START; game.sfxVolume = 0; @@ -2283,6 +2289,30 @@ static void game_showGameOver() screen_flushBuffer(); } +void game_getDifficultyText(char *dest, int difficulty) +{ + switch (difficulty) + { + case DIFFICULTY_EASY: + strcpy(dest, "Easy"); + break; + case DIFFICULTY_NORMAL: + strcpy(dest, "Normal"); + break; + case DIFFICULTY_HARD: + strcpy(dest, "Hard"); + break; + case DIFFICULTY_NIGHTMARE: + strcpy(dest, "Nightmare!"); + break; + case DIFFICULTY_ORIGINAL: + strcpy(dest, "Classic"); + break; + default: + strcpy(dest, "???"); + } +} + int game_mainLoop() { engine_resetLists(); diff --git a/src/game.h b/src/game.h index dafc586..feff72b 100644 --- a/src/game.h +++ b/src/game.h @@ -40,7 +40,7 @@ typedef struct Game_ { int cash; int cashEarned; - + int shots; int hits; int accuracy; @@ -99,12 +99,14 @@ typedef struct Game_ { } Game; extern Game game; +extern char game_systemNames[SYSTEM_MAX][STRMAX_SHORT]; void game_init(); void game_doStars(); void game_doExplosions(); void game_delayFrame(); int game_collision(float x0, float y0, int w0, int h0, float x2, float y2, int w1, int h1); +void game_getDifficultyText(char *dest, int difficulty); int game_mainLoop(); #endif diff --git a/src/gfx.c b/src/gfx.c index 30de3f0..9f69bb8 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -252,7 +252,7 @@ int gfx_renderUnicode(const char *in, int x, int y, int fontColor, int wrap, SDL return gfx_renderString(in, x, y, fontColor, wrap, dest); } #else -int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, SDL_Surface *dest, int blended) +int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, SDL_Surface *dest) { SDL_Surface *textSurf; SDL_Color color; @@ -268,6 +268,9 @@ int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, int i; SDL_Rect area; + if (strcmp(in, "") == 0) + return y; + avail_w = dest->w - x; switch (fontColor) @@ -343,10 +346,13 @@ int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, } if (w <= avail_w) { - if (blended) - textSurf = TTF_RenderUTF8_Blended(gfx_unicodeFont, testStr, color); - else - textSurf = TTF_RenderUTF8_Solid(gfx_unicodeFont, testStr, color); + textSurf = TTF_RenderUTF8_Blended(gfx_unicodeFont, testStr, color); + if (textSurf == NULL) + { + printf("While rendering testStr \"%s\" as unicode...\n", testStr); + engine_error("Attempted to render UTF8, got null surface!"); + } + area.x = x; area.y = y; area.w = textSurf->w; @@ -372,10 +378,13 @@ int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, engine_error(TTF_GetError()); } } - if (blended) - textSurf = TTF_RenderUTF8_Blended(gfx_unicodeFont, remainingStr, color); - else - textSurf = TTF_RenderUTF8_Solid(gfx_unicodeFont, remainingStr, color); + textSurf = TTF_RenderUTF8_Blended(gfx_unicodeFont, remainingStr, color); + if (textSurf == NULL) + { + printf("While rendering remainingStr \"%s\" as unicode...\n", remainingStr); + engine_error("Attempted to render UTF8, got null surface!"); + } + area.x = x; area.y = y; area.w = textSurf->w; @@ -385,6 +394,8 @@ int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, printf("BlitSurface error: %s\n", SDL_GetError()); engine_showError(2, ""); } + SDL_FreeSurface(textSurf); + textSurf = NULL; y += TTF_FontHeight(gfx_unicodeFont) + 1; } else @@ -405,13 +416,13 @@ int gfx_renderUnicode(const char *in, int x, int y, int fontColor, int wrap, SDL x = (dest->w - MIN(w, dest->w)) / 2; } - gfx_renderUnicodeBase(in, x, y - 1, FONT_OUTLINE, wrap, dest, 1); - gfx_renderUnicodeBase(in, x, y + 1, FONT_OUTLINE, wrap, dest, 1); - gfx_renderUnicodeBase(in, x, y + 2, FONT_OUTLINE, wrap, dest, 1); - gfx_renderUnicodeBase(in, x - 1, y, FONT_OUTLINE, wrap, dest, 1); - gfx_renderUnicodeBase(in, x - 2, y, FONT_OUTLINE, wrap, dest, 1); - gfx_renderUnicodeBase(in, x + 1, y, FONT_OUTLINE, wrap, dest, 1); - return gfx_renderUnicodeBase(in, x, y, fontColor, wrap, dest, 1); + gfx_renderUnicodeBase(in, x, y - 1, FONT_OUTLINE, wrap, dest); + gfx_renderUnicodeBase(in, x, y + 1, FONT_OUTLINE, wrap, dest); + gfx_renderUnicodeBase(in, x, y + 2, FONT_OUTLINE, wrap, dest); + gfx_renderUnicodeBase(in, x - 1, y, FONT_OUTLINE, wrap, dest); + gfx_renderUnicodeBase(in, x - 2, y, FONT_OUTLINE, wrap, dest); + gfx_renderUnicodeBase(in, x + 1, y, FONT_OUTLINE, wrap, dest); + return gfx_renderUnicodeBase(in, x, y, fontColor, wrap, dest); } #endif @@ -559,10 +570,25 @@ SDL_Surface *gfx_createSurface(int width, int height) SDL_Surface *gfx_createTextSurface(const char *inString, int color) { - // XXX: Magic numbers - SDL_Surface *surface = gfx_createSurface(strlen(inString) * (PIXFONT_W + 1), PIXFONT_LINE_HEIGHT); + int w, h, th; - gfx_renderString(inString, 1, 1, color, 0, surface); +#ifndef NOFONT + if (TTF_SizeUTF8(gfx_unicodeFont, inString, &w, &th) < 0) + { + engine_error(TTF_GetError()); + } + w += 2; + th += 2; + h = MAX(th, PIXFONT_LINE_HEIGHT); +#else + w = strlen(inString) * (PIXFONT_W + 1) + 1; + th = PIXFONT_H; + h = MAX(PIXFONT_LINE_HEIGHT, PIXFONT_H + 2); +#endif + + SDL_Surface *surface = gfx_createSurface(w, h); + + gfx_renderUnicode(inString, 1, (h - th) / 2, color, 0, surface); return gfx_setTransparent(surface); } diff --git a/src/intermission.c b/src/intermission.c index 618bfd2..e072c6d 100644 --- a/src/intermission.c +++ b/src/intermission.c @@ -209,7 +209,7 @@ void intermission_updateSystemStatus() intermission_planets[game.stationedPlanet].missionCompleted = 1; } - strcpy(game.destinationName, "None"); + strcpy(game.destinationName, _("None")); game.destinationPlanet = game.stationedPlanet; } @@ -232,80 +232,78 @@ These are set only once. */ static void intermission_setStatusLines() { - char string[50]; - char difficulty[50]; - int timeTaken = game.timeTaken; + char string[STRMAX_SHORT]; + char difficulty[STRMAX_SHORT]; + long timeTaken = game.timeTaken; - switch (game.difficulty) - { - case DIFFICULTY_EASY: - strcpy(difficulty, "Easy"); - break; - case DIFFICULTY_NORMAL: - strcpy(difficulty, "Normal"); - break; - case DIFFICULTY_HARD: - strcpy(difficulty, "Hard"); - break; - case DIFFICULTY_NIGHTMARE: - strcpy(difficulty, "Nightmare!"); - break; - case DIFFICULTY_ORIGINAL: - strcpy(difficulty, "Classic"); - break; - default: - strcpy(difficulty, "???"); - } + game_getDifficultyText(difficulty, game.difficulty); - sprintf(string, "Difficulty : %s", difficulty); + /// Retain "%s" as-is. It is replaced with the current difficulty. + sprintf(string, _("Difficulty : %s"), difficulty); gfx_createTextObject(TS_STATUS_DIFFICULTY, string, 0, 0, FONT_WHITE); - sprintf(string, "Shots Fired : %d", game.shots); + /// Retain "%d" as-is. It is replaced with the number of shots fired. + sprintf(string, _("Shots Fired : %d"), game.shots); gfx_createTextObject(TS_SHOTS_FIRED, string, 0, 0, FONT_WHITE); - sprintf(string, "Hits Scored : %d", game.hits); + /// Retain "%d" as-is. It is replaced with the number of hits scored. + sprintf(string, _("Hits Scored : %d"), game.hits); gfx_createTextObject(TS_HITS_SCORED, string, 0, 0, FONT_WHITE); - sprintf(string, "Accuracy : %d%%", game.accuracy); + /// Retain "%d" as-is. It is replaced with the firing accuracy as a percentage. + /// Note: To use the "%" symbol, you must enter "%%", as you can see in + /// the English version. + sprintf(string, _("Accuracy : %d%%"), game.accuracy); gfx_createTextObject(TS_ACCURACY, string, 0, 0, FONT_WHITE); - sprintf(string, "Enemies Killed by Others : %d", game.totalOtherKills); + /// Retain "%d" as-is. It is replaced with the number of kills. + sprintf(string, _("Enemies Killed by Others : %d"), game.totalOtherKills); gfx_createTextObject(TS_OTHER_KILLS, string, 0, 0, FONT_WHITE); - sprintf(string, "Total Cash Earned : %d", game.cashEarned); + /// Retain "%d" as-is. It is replaced with the amount of cash earned. + sprintf(string, _("Total Cash Earned : %d"), game.cashEarned); gfx_createTextObject(TS_CASH_EARNED, string, 0, 0, FONT_WHITE); - gfx_createTextObject(TS_CHRIS_HEADER, "*** Chris ***", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_CHRIS_HEADER, _("*** Chris ***"), 0, 0, FONT_WHITE); - sprintf(string, "Enemies Killed : %d", game.totalKills); + /// Retain "%d" as-is. It is replaced with the number of kills. + sprintf(string, _("Enemies Killed : %d"), game.totalKills); gfx_createTextObject(TS_CHRIS_KILLS, string, 0, 0, FONT_WHITE); - sprintf(string, "Shield Restores Picked Up : %d", game.shieldPickups); + /// Retain "%d" as-is. It is replaced with the number of shield restores picked up. + sprintf(string, _("Shield Restores Picked Up : %d"), game.shieldPickups); gfx_createTextObject(TS_CHRIS_SHIELD_PICKUPS, string, 0, 0, FONT_WHITE); - sprintf(string, "Plasma Cells Picked Up : %d", game.cellPickups); + /// Retain "%d" as-is. It is replaced with the number of plasma cells picked up. + sprintf(string, _("Plasma Cells Picked Up : %d"), game.cellPickups); gfx_createTextObject(TS_CHRIS_PLASMA_PICKUPS, string, 0, 0, FONT_WHITE); - sprintf(string, "Rockets Picked Up : %d", game.rocketPickups); + /// Retain "%d" as-is. It is replaced with the number of rockets picked up. + sprintf(string, _("Rockets Picked Up : %d"), game.rocketPickups); gfx_createTextObject(TS_CHRIS_ROCKET_PICKUPS, string, 0, 0, FONT_WHITE); - sprintf(string, "Powerups Picked Up : %d", game.powerups); + /// Retain "%d" as-is. It is replaced with the number of powerups picked up. + sprintf(string, _("Powerups Picked Up : %d"), game.powerups); gfx_createTextObject(TS_CHRIS_POWERUP_PICKUPS, string, 0, 0, FONT_WHITE); - sprintf(string, "Mines Destroyed : %d", game.minesKilled); + /// Retain "%d" as-is. It is replaced with the number of mines destroyed. + sprintf(string, _("Mines Destroyed : %d"), game.minesKilled); gfx_createTextObject(TS_CHRIS_MINES_KILLED, string, 0, 0, FONT_WHITE); - sprintf(string, "Slaves Rescued : %d", game.slavesRescued); + /// Retain "%d" as-is. It is replaced with the number of slaves rescued. + sprintf(string, _("Slaves Rescued : %d"), game.slavesRescued); gfx_createTextObject(TS_CHRIS_SLAVES_RESCUED, string, 0, 0, FONT_WHITE); if (game.hasWingMate1) { - gfx_createTextObject(TS_PHOEBE_HEADER, "*** Phoebe ***", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_PHOEBE_HEADER, _("*** Phoebe ***"), 0, 0, FONT_WHITE); - sprintf(string, "Enemies Killed : %d", game.wingMate1Kills); + /// Retain "%d" as-is. It is replaced with the number of kills. + sprintf(string, _("Enemies Killed : %d"), game.wingMate1Kills); gfx_createTextObject(TS_PHOEBE_KILLS, string, 0, 0, FONT_WHITE); - sprintf(string, "Ejections : %d", game.wingMate1Ejects); + /// Retain "%d" as-is. It is replaced with the number of ejections. + sprintf(string, _("Ejections : %d"), game.wingMate1Ejects); gfx_createTextObject(TS_PHOEBE_DEATHS, string, 0, 0, FONT_WHITE); } else @@ -317,12 +315,14 @@ static void intermission_setStatusLines() if (game.hasWingMate2) { - gfx_createTextObject(TS_URSULA_HEADER, "*** Ursula ***", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_URSULA_HEADER, _("*** Ursula ***"), 0, 0, FONT_WHITE); - sprintf(string, "Enemies Killed : %d", game.wingMate2Kills); + /// Retain "%d" as-is. It is replaced with the number of kills. + sprintf(string, _("Enemies Killed : %d"), game.wingMate2Kills); gfx_createTextObject(TS_URSULA_KILLS, string, 0, 0, FONT_WHITE); - sprintf(string, "Ejections : %d", game.wingMate2Ejects); + /// Retain "%d" as-is. It is replaced with the number of ejections. + sprintf(string, _("Ejections : %d"), game.wingMate2Ejects); gfx_createTextObject(TS_URSULA_DEATHS, string, 0, 0, FONT_WHITE); } else @@ -332,9 +332,22 @@ static void intermission_setStatusLines() gfx_createTextObject(TS_URSULA_DEATHS, "", 0, 0, FONT_WHITE); } - gfx_createTextObject(TS_STATUS_HEADER, "Current Status", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_STATUS_HEADER, _("Current Status"), 0, 0, FONT_WHITE); - snprintf(string, sizeof string, "Total Time : %2d:%02d:%02d", timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60); + /// "%ld" (which represents hours) and "%02ld" sequences (which + /// represent minutes and seconds, respectively) must remain and + /// stay in the same order relative to each other. The ":"s + /// between them can be changed to other characters if desired, + /// e.g. this would be acceptable: + /// + /// "Total Time : %ld hours, %02ld minutes, %02ld seconds" + /// + /// If you are familiar with printf formatting, you may also change + /// the formatting of any of these as long as the "ld" type remains. + /// For example, the "%02ld" sequences may be changed to "%ld" if + /// you wish to not force two digits to be filled in (e.g. to render + /// the number 3 as "3" instead of "03"). + snprintf(string, sizeof string, _("Total Time : %ld:%02ld:%02ld"), timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60); gfx_createTextObject(TS_STATUS_FOOTER, string, 0, 0, FONT_WHITE); } @@ -358,23 +371,23 @@ static void intermission_setPlanets() { case SYSTEM_SPIRIT: intermission_planets[PLANET_HAIL].dist = 3; - strcpy(intermission_planets[PLANET_HAIL].name, "Hail"); + strcpy(intermission_planets[PLANET_HAIL].name, _("Hail")); intermission_planets[PLANET_HAIL].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_CERADSE].dist = 6; - strcpy(intermission_planets[PLANET_CERADSE].name, "Ceradse"); + strcpy(intermission_planets[PLANET_CERADSE].name, _("Ceradse")); intermission_planets[PLANET_CERADSE].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_HINSTAG].dist = 6; - strcpy(intermission_planets[PLANET_HINSTAG].name, "Hinstag"); + strcpy(intermission_planets[PLANET_HINSTAG].name, _("Hinstag")); intermission_planets[PLANET_HINSTAG].image = gfx_sprites[SP_PLANET_RED]; intermission_planets[PLANET_JOLDAR].dist = 4; - strcpy(intermission_planets[PLANET_JOLDAR].name, "Joldar"); + strcpy(intermission_planets[PLANET_JOLDAR].name, _("Joldar")); intermission_planets[PLANET_JOLDAR].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_MOEBO].dist = 8; - strcpy(intermission_planets[PLANET_MOEBO].name, "Moebo"); + strcpy(intermission_planets[PLANET_MOEBO].name, _("Moebo")); intermission_planets[PLANET_MOEBO].image = gfx_sprites[SP_PLANET_ORANGE]; intermission_planets[PLANET_HAIL].messageMission = MISN_HAIL; @@ -410,26 +423,26 @@ static void intermission_setPlanets() break; case SYSTEM_EYANANTH: - strcpy(intermission_planets[PLANET_RESCUESLAVES].name, "WEAPCO interceptions"); + strcpy(intermission_planets[PLANET_RESCUESLAVES].name, _("WEAPCO interceptions")); intermission_planets[PLANET_NEROD].dist = 3; - strcpy(intermission_planets[PLANET_NEROD].name, "Nerod"); + strcpy(intermission_planets[PLANET_NEROD].name, _("Nerod")); intermission_planets[PLANET_NEROD].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_ALLEZ].dist = 6; - strcpy(intermission_planets[PLANET_ALLEZ].name, "Allez"); + strcpy(intermission_planets[PLANET_ALLEZ].name, _("Allez")); intermission_planets[PLANET_ALLEZ].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_URUSOR].dist = 6; - strcpy(intermission_planets[PLANET_URUSOR].name, "Urusor"); + strcpy(intermission_planets[PLANET_URUSOR].name, _("Urusor")); intermission_planets[PLANET_URUSOR].image = gfx_sprites[SP_PLANET_RED]; intermission_planets[PLANET_DORIM].dist = 4; - strcpy(intermission_planets[PLANET_DORIM].name, "Dorim"); + strcpy(intermission_planets[PLANET_DORIM].name, _("Dorim")); intermission_planets[PLANET_DORIM].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_ELAMALE].dist = 8; - strcpy(intermission_planets[PLANET_ELAMALE].name, "Elamale"); + strcpy(intermission_planets[PLANET_ELAMALE].name, _("Elamale")); intermission_planets[PLANET_ELAMALE].image = gfx_sprites[SP_PLANET_ORANGE]; intermission_planets[PLANET_RESCUESLAVES].messageMission = MISN_RESCUESLAVES; @@ -471,30 +484,30 @@ static void intermission_setPlanets() break; case SYSTEM_MORDOR: - strcpy(intermission_planets[PLANET_CLOAKFIGHTER].name, "WEAPCO interceptions"); + strcpy(intermission_planets[PLANET_CLOAKFIGHTER].name, _("WEAPCO interceptions")); intermission_planets[PLANET_ODEON].dist = 3; - strcpy(intermission_planets[PLANET_ODEON].name, "Odeon"); + strcpy(intermission_planets[PLANET_ODEON].name, _("Odeon")); intermission_planets[PLANET_ODEON].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_FELLON].dist = 6; - strcpy(intermission_planets[PLANET_FELLON].name, "Fellon"); + strcpy(intermission_planets[PLANET_FELLON].name, _("Fellon")); intermission_planets[PLANET_FELLON].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_SIVEDI].dist = 6; - strcpy(intermission_planets[PLANET_SIVEDI].name, "Sivedi"); + strcpy(intermission_planets[PLANET_SIVEDI].name, _("Sivedi")); intermission_planets[PLANET_SIVEDI].image = gfx_sprites[SP_PLANET_RED]; intermission_planets[PLANET_ALMARTHA].dist = 4; - strcpy(intermission_planets[PLANET_ALMARTHA].name, "Almartha"); + strcpy(intermission_planets[PLANET_ALMARTHA].name, _("Almartha")); intermission_planets[PLANET_ALMARTHA].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_POSWIC].dist = 4; - strcpy(intermission_planets[PLANET_POSWIC].name, "Poswic"); + strcpy(intermission_planets[PLANET_POSWIC].name, _("Poswic")); intermission_planets[PLANET_POSWIC].image = gfx_sprites[SP_PLANET_ORANGE]; intermission_planets[PLANET_ELLESH].dist = 8; - strcpy(intermission_planets[PLANET_ELLESH].name, "Ellesh"); + strcpy(intermission_planets[PLANET_ELLESH].name, _("Ellesh")); intermission_planets[PLANET_ELLESH].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_CLOAKFIGHTER].messageMission = MISN_CLOAKFIGHTER; @@ -543,39 +556,39 @@ static void intermission_setPlanets() case SYSTEM_SOL: intermission_planets[PLANET_MERCURY].dist = 3; - strcpy(intermission_planets[PLANET_MERCURY].name, "Mercury"); + strcpy(intermission_planets[PLANET_MERCURY].name, _("Mercury")); intermission_planets[PLANET_MERCURY].image = gfx_sprites[SP_PLANET_RED]; intermission_planets[PLANET_VENUS].dist = 4; - strcpy(intermission_planets[PLANET_VENUS].name, "Venus"); + strcpy(intermission_planets[PLANET_VENUS].name, _("Venus")); intermission_planets[PLANET_VENUS].image = gfx_sprites[SP_PLANET_ORANGE]; intermission_planets[PLANET_EARTH].dist = 4; - strcpy(intermission_planets[PLANET_EARTH].name, "Earth"); + strcpy(intermission_planets[PLANET_EARTH].name, _("Earth")); intermission_planets[PLANET_EARTH].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_MARS].dist = 4; - strcpy(intermission_planets[PLANET_MARS].name, "Mars"); + strcpy(intermission_planets[PLANET_MARS].name, _("Mars")); intermission_planets[PLANET_MARS].image = gfx_sprites[SP_PLANET_RED]; intermission_planets[PLANET_JUPITER].dist = 6; - strcpy(intermission_planets[PLANET_JUPITER].name, "Jupiter"); + strcpy(intermission_planets[PLANET_JUPITER].name, _("Jupiter")); intermission_planets[PLANET_JUPITER].image = gfx_sprites[SP_PLANET_ORANGE]; intermission_planets[PLANET_SATURN].dist = 4; - strcpy(intermission_planets[PLANET_SATURN].name, "Saturn"); + strcpy(intermission_planets[PLANET_SATURN].name, _("Saturn")); intermission_planets[PLANET_SATURN].image = gfx_sprites[SP_PLANET_GREEN]; intermission_planets[PLANET_URANUS].dist = 4; - strcpy(intermission_planets[PLANET_URANUS].name, "Uranus"); + strcpy(intermission_planets[PLANET_URANUS].name, _("Uranus")); intermission_planets[PLANET_URANUS].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_NEPTUNE].dist = 4; - strcpy(intermission_planets[PLANET_NEPTUNE].name, "Neptune"); + strcpy(intermission_planets[PLANET_NEPTUNE].name, _("Neptune")); intermission_planets[PLANET_NEPTUNE].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_PLUTO].dist = 4; - strcpy(intermission_planets[PLANET_PLUTO].name, "Pluto"); + strcpy(intermission_planets[PLANET_PLUTO].name, _("Pluto")); intermission_planets[PLANET_PLUTO].image = gfx_sprites[SP_PLANET_BLUE]; intermission_planets[PLANET_PLUTO].messageMission = MISN_PLUTO; @@ -669,7 +682,7 @@ static int intermission_showSystem(float pos, int selectable) { if (!printedName) { - screen_renderString(intermission_planets[planet].name, -1, screen->h - 25, FONT_WHITE); + screen_renderUnicode(intermission_planets[planet].name, -1, screen->h - 25, FONT_WHITE); printedName = 1; } if ((engine.keyState[KEY_FIRE])) @@ -748,9 +761,7 @@ static void intermission_createCommsSurface(SDL_Surface *comms) gfx_drawRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25); - gfx_renderString("+++ CURRENT MISSIONS +++", -1, 15, FONT_GREEN, 0, comms); - - /// Please keep this short; it is always rendered as a single line. + gfx_renderUnicode(_("+++ CURRENT MISSIONS +++"), -1, 15, FONT_GREEN, 0, comms); gfx_renderUnicode(_("click for info"), -1, 35, FONT_WHITE, 0, comms); yStart = 60; @@ -772,7 +783,7 @@ static int intermission_renderDialog(SDL_Surface *comms, int y, int face, const { int newY; gfx_blit(gfx_faceSprites[face], 10, y, comms); - newY = gfx_renderUnicode(string, 80, y, FONT_WHITE, 1, comms) + 20; + newY = gfx_renderUnicode(string, 80, y, FONT_WHITE, 1, comms) + MENU_SPACING; if (newY < y + 60) newY += (60 - (newY - y)); return newY; @@ -1235,7 +1246,7 @@ static void intermission_createOptions(SDL_Surface *optionsSurface) gfx_drawRect(optionsSurface, 0, 0, optionsSurface->w - 2, optionsSurface->h - 2, 0x00, 0x00, 0x44); - gfx_renderString("++ OPTIONS ++", 105, 8, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("++ OPTIONS ++"), 105, 8, FONT_WHITE, 0, optionsSurface); gfx_drawRect(optionsSurface, 190, 45, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 45, 50, 22, 0x00, 0x00, 0x00); @@ -1244,9 +1255,9 @@ static void intermission_createOptions(SDL_Surface *optionsSurface) gfx_drawRect(optionsSurface, 190, 45, 50, 22, 0xff, 0x00, 0x00); else gfx_drawRect(optionsSurface, 250, 45, 50, 22, 0xff, 0x00, 0x00); - gfx_renderString("ON", 207, 50, FONT_WHITE, 0, optionsSurface); - gfx_renderString("OFF", 263, 50, FONT_WHITE, 0, optionsSurface); - gfx_renderString("SOUND", 30, 50, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("ON"), 207, 50, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("OFF"), 263, 50, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("SOUND"), 30, 50, FONT_WHITE, 0, optionsSurface); gfx_drawRect(optionsSurface, 190, 95, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 95, 50, 22, 0x00, 0x00, 0x00); @@ -1255,9 +1266,9 @@ static void intermission_createOptions(SDL_Surface *optionsSurface) gfx_drawRect(optionsSurface, 190, 95, 50, 22, 0xff, 0x00, 0x00); else gfx_drawRect(optionsSurface, 250, 95, 50, 22, 0xff, 0x00, 0x00); - gfx_renderString("ON", 207, 100, FONT_WHITE, 0, optionsSurface); - gfx_renderString("OFF", 263, 100, FONT_WHITE, 0, optionsSurface); - gfx_renderString("MUSIC", 30, 100, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("ON"), 207, 100, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("OFF"), 263, 100, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("MUSIC"), 30, 100, FONT_WHITE, 0, optionsSurface); gfx_drawRect(optionsSurface, 190, 145, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 145, 50, 22, 0x00, 0x00, 0x00); @@ -1266,9 +1277,9 @@ static void intermission_createOptions(SDL_Surface *optionsSurface) gfx_drawRect(optionsSurface, 190, 145, 50, 22, 0xff, 0x00, 0x00); else gfx_drawRect(optionsSurface, 250, 145, 50, 22, 0xff, 0x00, 0x00); - gfx_renderString("ON", 207, 150, FONT_WHITE, 0, optionsSurface); - gfx_renderString("OFF", 263, 150, FONT_WHITE, 0, optionsSurface); - gfx_renderString("FULLSCREEN", 30, 150, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("ON"), 207, 150, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("OFF"), 263, 150, FONT_WHITE, 0, optionsSurface); + gfx_renderUnicode(_("FULLSCREEN"), 30, 150, FONT_WHITE, 0, optionsSurface); } static void intermission_doOptions(SDL_Surface *optionsSurface, int x, int y) @@ -1321,7 +1332,7 @@ selected an icon. */ int intermission() { - char string[25]; + char string[STRMAX_SHORT]; SDL_Rect r; SDL_Rect destRect; @@ -1468,26 +1479,35 @@ int intermission() if ((engine.useAudio) && (engine.useMusic)) audio_playMusic("music/through_space.ogg", -1); - sprintf(string, "System : %s", systemNames[game.system]); + /// Retain "%s" as-is. It is replaced with the current system name. + sprintf(string, _("System : %s"), game_systemNames[game.system]); gfx_createTextObject(TS_CURRENT_SYSTEM, string, 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_START_MISSION, "Start Next Mission", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_GOTO, "Go to Destination Planet", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_MAP, "View System Map", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_STATUS, "Current Status", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_SAVE_GAME, "Save Game", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_SHOP, "Upgrade FIREFLY", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_COMMS, "Missions", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_OPTIONS, "Options", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_INFO_EXIT, "Exit to Title Screen", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_START_MISSION, _("Start Next Mission"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_GOTO, _("Go to Destination Planet"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_MAP, _("View System Map"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_STATUS, _("Current Status"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_SAVE_GAME, _("Save Game"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_SHOP, _("Upgrade FIREFLY"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_COMMS, _("Missions"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_OPTIONS, _("Options"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_INFO_EXIT, _("Exit to Title Screen"), 0, 0, FONT_WHITE); - sprintf(string, "Stationed At: %s", intermission_planets[game.stationedPlanet].name); + /// Retain "%s" as-is. It is replaced with the name of the planet + /// the player is currently stationed on. + sprintf(string, _("Stationed At: %s"), intermission_planets[game.stationedPlanet].name); gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 0, FONT_WHITE); if (game.destinationPlanet > -1) - sprintf(string, "Destination: %s", intermission_planets[game.destinationPlanet].name); + { + /// Retain "%s" as-is. It is replaced with the name of the planet + /// the player's destination is currently set to. + sprintf(string, _("Destination: %s"), intermission_planets[game.destinationPlanet].name); + } else - strcpy(string, "Destination: None"); + { + strcpy(string, _("Destination: None")); + } gfx_createTextObject(TS_DEST_PLANET, string, 0, 0, FONT_WHITE); if (game.distanceCovered > 0) @@ -1595,6 +1615,8 @@ int intermission() if (intermission_showSystem(orbit_pos, 1)) { + /// Retain "%s" as-is. It is replaced with the name of the planet + /// the player's destination is currently set to. sprintf(string, "Destination: %s", intermission_planets[game.destinationPlanet].name); gfx_createTextObject(TS_DEST_PLANET, string, 0, 0, FONT_WHITE); } @@ -1655,7 +1677,9 @@ int intermission() game.stationedPlanet = game.destinationPlanet; game.distanceCovered = 0; player.shield = player.maxShield; - sprintf(string, "Stationed At: %s", + /// Retain "%s" as-is. It is replaced with the name of the planet + /// the player's destination is currently set to. + sprintf(string, _("Stationed At: %s"), intermission_planets[game.stationedPlanet].name); gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 0, FONT_WHITE); section = 1; diff --git a/src/mission.c b/src/mission.c index 9381a17..e005229 100644 --- a/src/mission.c +++ b/src/mission.c @@ -1028,7 +1028,7 @@ static void mission_drawScreen() screen_drawRect(screen->w / 2 - 260, screen->h / 2 - 235, 500, 20, 0x00, 0x77, 0x00); screen_drawRect(screen->w / 2 - 260, screen->h / 2 - 215, 500, 130, 0x00, 0x33, 0x00); - screen_renderUnicode(_("Primary Objectives"), screen->w / 2 - 250, screen->h / 2 - 231, FONT_WHITE); + screen_renderUnicode(_("Primary Objectives"), screen->w / 2 - 250, screen->h / 2 - 232, FONT_WHITE); for (int i = 0 ; i < 3 ; i++) { @@ -1042,7 +1042,7 @@ static void mission_drawScreen() { screen_drawRect(screen->w / 2 - 260, screen->h / 2 - 75, 500, 20, 0x00, 0x77, 0x77); screen_drawRect(screen->w / 2 - 260, screen->h / 2 - 55, 500, 130, 0x00, 0x33, 0x33); - screen_renderUnicode(_("Secondary Objectives"), screen->w / 2 - 250, screen->h / 2 - 71, FONT_WHITE); + screen_renderUnicode(_("Secondary Objectives"), screen->w / 2 - 250, screen->h / 2 - 72, FONT_WHITE); for (int i = 0 ; i < 3 ; i++) { @@ -1056,7 +1056,7 @@ static void mission_drawScreen() screen_drawRect(screen->w / 2 - 260, screen->h / 2 + 85, 500, 20, 0x77, 0x77, 0x00); screen_drawRect(screen->w / 2 - 260, screen->h / 2 + 105, 500, 130, 0x33, 0x33, 0x00); - screen_renderUnicode(_("Additional Information"), screen->w / 2 - 250, screen->h / 2 + 89, FONT_WHITE); + screen_renderUnicode(_("Additional Information"), screen->w / 2 - 250, screen->h / 2 + 88, FONT_WHITE); } /* diff --git a/src/save.c b/src/save.c index d00aa36..2160e7a 100644 --- a/src/save.c +++ b/src/save.c @@ -73,7 +73,7 @@ int save_initSlots() { if (i == 0) { - sprintf(saveSlot[i], "AUTOSAVE"); + sprintf(saveSlot[i], _("AUTOSAVE")); continueSaveIndex = 0; } else @@ -81,11 +81,11 @@ int save_initSlots() if (fscanf(fp, "%*[^\n]%*c%*[^\n]%*c%d %*d %*d%*c%[^\n]%*c", &system, stationedName) < 2) { - sprintf(saveSlot[i], "Corrupt Game Data"); + sprintf(saveSlot[i], _("Corrupt Game Data")); } else { - sprintf(saveSlot[i], "%s, %s", systemNames[system], + sprintf(saveSlot[i], "%s, %s", game_systemNames[system], stationedName); } } @@ -109,7 +109,7 @@ int save_initSlots() fp = fopen(fileName, "r"); if (fp == NULL) { - sprintf(saveSlot[i], (i == 0 ? "AUTOSAVE (Empty)" : "Empty")); + sprintf(saveSlot[i], (i == 0 ? _("AUTOSAVE (Empty)") : _("Empty"))); if (engine.gameSection == SECTION_TITLE) gfx_createTextObject(TS_SAVESLOT_0 + i, saveSlot[i], 0, imagePos, FONT_WHITE); @@ -118,18 +118,18 @@ int save_initSlots() { if (i == 0) { - sprintf(saveSlot[i], "AUTOSAVE"); + sprintf(saveSlot[i], _("AUTOSAVE")); continueSaveIndex = 0; } else { if (fread(&tempGame, sizeof(Game), 1, fp) != 1) { - sprintf(saveSlot[i], "Corrupt Game Data"); + sprintf(saveSlot[i], _("Corrupt Game Data")); } else { - sprintf(saveSlot[i], "%s, %s", systemNames[tempGame.system], + sprintf(saveSlot[i], "%s, %s", game_systemNames[tempGame.system], tempGame.stationedName); } } @@ -375,11 +375,11 @@ void save_createSurface(SDL_Surface *savesSurface, int clickedSlot) gfx_drawRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00); else gfx_drawRect(savesSurface, 5, y, 338, 25, 0x00, 0x00, 0x99); - gfx_renderString(saveSlot[i], 70, y + 5, FONT_WHITE, 0, savesSurface); + gfx_renderUnicode(saveSlot[i], 70, y + 5, FONT_WHITE, 0, savesSurface); y += 30; } - gfx_renderString("*** HELP ***", 120, 170, FONT_WHITE, 0, savesSurface); + gfx_renderUnicode(_("*** HELP ***"), 120, 170, FONT_WHITE, 0, savesSurface); switch (clickedSlot) { @@ -391,35 +391,20 @@ void save_createSurface(SDL_Surface *savesSurface, int clickedSlot) gfx_drawRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00); gfx_drawRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00); gfx_drawRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00); - gfx_renderString("SAVE", 40, 270, FONT_WHITE, 0, savesSurface); - gfx_renderString("CANCEL", 150, 270, FONT_WHITE, 0, savesSurface); - gfx_renderString("DELETE", 270, 270, FONT_WHITE, 0, savesSurface); - - /// Explanation of what the SAVE button does (note: "SAVE" is untranslated). - /// This must be short enough to fit on a single line. + gfx_renderUnicode(_("SAVE"), 40, 270, FONT_WHITE, 0, savesSurface); + gfx_renderUnicode(_("CANCEL"), 150, 270, FONT_WHITE, 0, savesSurface); + gfx_renderUnicode(_("DELETE"), 270, 270, FONT_WHITE, 0, savesSurface); gfx_renderUnicode(_("SAVE will save the game"), 17, 200, FONT_WHITE, 0, savesSurface); - - /// Explanation of what the CANCEL button does (note: "CANCEL" is untranslated) - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("CANCEL will unselect that slot"), 17, 220, FONT_WHITE, 0, savesSurface); - - /// Explanation of what the DELETE button does (note: "DELETE" is untranslated) - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("DELETE will remove the save"), 17, 240, FONT_WHITE, 0, savesSurface); break; case -1: - /// For when the player attempts to click "SAVE" or "DELETE" without selecting a slot. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("First click a Save game slot to use"), 17, 200, FONT_WHITE, 0, savesSurface); break; case -10: - /// For when the game is successfully saved. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Game Saved"), 130, 200, FONT_WHITE, 0, savesSurface); break; case -11: - /// For when the save slot is successfully deleted. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Save Deleted"), 130, 200, FONT_WHITE, 0, savesSurface); break; } diff --git a/src/shop.c b/src/shop.c index a55d056..7833dcc 100644 --- a/src/shop.c +++ b/src/shop.c @@ -54,45 +54,46 @@ static void drawSecondaryWeaponSurface() { char description[50] = ""; - gfx_renderString("Secondary Weapon", 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); + gfx_renderUnicode(_("Secondary Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); switch (player.weaponType[1]) { case W_NONE: - strcpy(description, "None"); + strcpy(description, _("None")); break; case W_ROCKETS: - strcpy(description, "Rockets"); + strcpy(description, _("Rockets")); break; case W_DOUBLE_ROCKETS: - strcpy(description, "Dbl Rockets"); + strcpy(description, _("Dbl Rockets")); break; case W_MICRO_ROCKETS: - strcpy(description, "Micro Rockets"); + strcpy(description, _("Micro Rockets")); break; case W_LASER: - strcpy(description, "Laser"); + strcpy(description, _("Laser")); break; case W_CHARGER: - strcpy(description, "Charger"); + strcpy(description, _("Charger")); break; case W_HOMING_MISSILE: - strcpy(description, "Homing Missile"); + strcpy(description, _("Homing Missile")); break; case W_DOUBLE_HOMING_MISSILES: - strcpy(description, "Dbl Homing Missiles"); + strcpy(description, _("Dbl Homing Missiles")); break; case W_MICRO_HOMING_MISSILES: - strcpy(description, "Mcr Homing Missiles"); + strcpy(description, _("Mcr Homing Missiles")); break; } - gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); + gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); if ((player.weaponType[1] != W_LASER) && (player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_NONE)) { - sprintf(description, "Capacity : %d", game.maxRocketAmmo); - gfx_renderString(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); + /// Retain "%d" as-is. It is replaced with the rocket capacity of the Firefly. + sprintf(description, _("Capacity : %d"), game.maxRocketAmmo); + gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); } } @@ -272,28 +273,35 @@ static void drawShop() strcpy(description, ""); - gfx_renderString("Primary Weapon", 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - sprintf(description, "Cannons : %d", game.minPlasmaOutput); - gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - sprintf(description, "Power : Stage %d", + gfx_renderUnicode(_("Primary Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); + /// Retain "%d" as-is. It is replaced with the min plasma output. + sprintf(description, _("Cannons : %d"), game.minPlasmaOutput); + gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); + /// Retain "%d" as-is. It is replaced with the min plasma damage. + sprintf(description, _("Power : Stage %d"), game.minPlasmaDamage); - gfx_renderString(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - sprintf(description, "Cooling : Stage %d", + gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); + /// Retain "%d" as-is. It is replaced with the min plasma cooling. + sprintf(description, _("Cooling : Stage %d"), game.minPlasmaRate); - gfx_renderString(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); + gfx_renderUnicode(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - gfx_renderString("Powerup Weapon", 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Splitter : Stage %d", + gfx_renderUnicode(_("Powerup Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); + /// Retain "%d" as-is. It is replaced with the max plasma output. + sprintf(description, _("Splitter : Stage %d"), game.maxPlasmaOutput); - gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Condensor : Stage %d", + gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); + /// Retain "%d" as-is. It is replaced with the max plasma damage. + sprintf(description, _("Condensor : Stage %d"), game.maxPlasmaDamage); - gfx_renderString(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "L.Nitrogen: Stage %d", + gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); + /// Retain "%d" as-is. It is replaced with the max plasma cooling. + sprintf(description, _("L.Nitrogen: Stage %d"), game.maxPlasmaRate); - gfx_renderString(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Capacity : %d", game.maxPlasmaAmmo); - gfx_renderString(description, 10, 67, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); + gfx_renderUnicode(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); + /// Retain "%d" as-is. It is replaced with the Firefly's plasma ammo capacity. + sprintf(description, _("Capacity : %d"), game.maxPlasmaAmmo); + gfx_renderUnicode(description, 10, 67, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); drawSecondaryWeaponSurface(); @@ -301,12 +309,12 @@ static void drawShop() gfx_drawRect(gfx_shopSprites[SHOP_S_CATALOG], 0, 0, 600, 120, 0x00, 0x00, 0x22); - gfx_renderString("Temporary Weapons", 10, 2, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); - gfx_renderString("Ammo and Storage", 260, 2, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); + gfx_renderUnicode(_("Temporary Weapons"), 10, 2, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); + gfx_renderUnicode(_("Ammo and Storage"), 260, 2, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); - gfx_renderString("Primary Weapons", 10, 62, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); + gfx_renderUnicode(_("Primary Weapons"), 10, 62, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); - gfx_renderString("Secondary Weapons", 260, 62, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); + gfx_renderUnicode(_("Secondary Weapons"), 260, 62, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_CATALOG]); if (game.system == 0) icons = SHOP_DOUBLE_ROCKETS + 1; @@ -321,19 +329,27 @@ static void drawShop() shopItems[i].y - SHOP_Y - 48, gfx_shopSprites[SHOP_S_CATALOG]); } - sprintf(description, "Shield : %d", player.maxShield); - gfx_renderString(description, 10, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); - sprintf(description, " Cash : $%d", game.cash); - gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); - sprintf(description, "Plasma Cells : %.3d", player.ammo[0]); - gfx_renderString(description, 430, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); - sprintf(description, "Rockets : %.2d", player.ammo[1]); - gfx_renderString(description, 475, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); + /// Retain "%d" as-is. It is replaced with the Firefly's max shield. + sprintf(description, _("Shield : %d"), player.maxShield); + gfx_renderUnicode(description, 10, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); + /// Retain "%d" as-is. It is replaced with the player's current cash. + sprintf(description, _(" Cash : $%d"), game.cash); + gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); + /// Retain "%.3d". It is replaced with the ship's current number of plasma cells. + /// "%.3d" can be changed to "%d" if you wish to not fill in space with zeroes, + /// e.g. render the number 5 as "5" rather than "005". + sprintf(description, _("Plasma Cells : %.3d"), player.ammo[0]); + gfx_renderUnicode(description, 430, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); + /// Retain "%.2d". It is replaced with the ship's current number of rockets. + /// "%.2d" can be changed to "%d" if you wish to not fill in space with zeroes, + /// e.g. render the number 3 as "3" rather than "03". + sprintf(description, _("Rockets : %.2d"), player.ammo[1]); + gfx_renderUnicode(description, 475, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); gfx_shopSprites[SHOP_S_ITEM_INFO] = gfx_createSurface(601, 56); gfx_drawRect(gfx_shopSprites[SHOP_S_ITEM_INFO], 0, 0, 600, 35, 0x00, 0x99, 0x00); gfx_drawRect(gfx_shopSprites[SHOP_S_ITEM_INFO], 0, 20, 600, 35, 0x00, 0x33, 0x00); - gfx_renderString("Information", 5, 4, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); + gfx_renderUnicode(_("Information"), 5, 4, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); switch (shopSelectedItem) { @@ -341,60 +357,56 @@ static void drawShop() break; case SHOP_ERROR_INSUFFICIENT_FUNDS: /// For when the player attempts to buy something they can't afford. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("You don't have enough money"), 20, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_CANNOT_UPGRADE: /// For when the player attempts an upgrade beyond the maximum (line 1 of 2). - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Cannot upgrade ship"), 5, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); /// For when the player attempts an upgrade beyond the maximum (line 2 of 2). - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Hardware capacity has been reached"), 20, 38, FONT_CYAN, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_AMMO_LIMIT: /// For when the player attempts to buy more ammo than the ship can hold. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Ammunition limit reached"), 20, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_CANNOT_SELL: /// For when the player attempts to sell an item they aren't allowed to sell. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("You cannot sell that item"), 20, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_NOTHING_TO_SELL: /// For when the player attempts to sell an item they don't have any of. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Nothing to sell"), 20, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_IS_NOT_ROCKETS: /// For when the player attempts to buy rockets or rocket capacity /// while secondary weapon is either laser or charge cannon. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("Rockets cannot be bought for Laser or Charger Cannon"), 5, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_ALREADY_OWNED: /// For when the player attempts to buy a weapon they already have. - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("You already have that weapon"), 20, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; case SHOP_ERROR_WEAPON_CAPACITY: /// For when the player attempts to increase rocket capacity beyond /// what is allowed for the weapon (used for homing missiles). - /// This must be short enough to fit on a single line. gfx_renderUnicode(_("This weapon's ammo limit has been reached"), 20, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); break; default: if (shopItems[shopSelectedItem].price != 0) { - sprintf(description, "%s ($%d)", + /// Used to put a shop item's name next to its price. + /// "%s" is replaced with the item name, and "%d" is replaced + /// with the item price. + sprintf(description, _("%s ($%d)"), shopItems[shopSelectedItem].description, shopItems[shopSelectedItem].price); } else { - sprintf(description, "%s (N/A)", + /// Used for shop items that cannot be bought. + /// "%s" is replaced with the item name. + sprintf(description, _("%s (N/A)"), shopItems[shopSelectedItem].description); } gfx_renderUnicode(shopItems[shopSelectedItem].name, 5, 22, @@ -409,23 +421,20 @@ void shop_init() /* ----------- Temporary Items ----------- */ shopItems[SHOP_PLASMA_MAX_OUTPUT].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MAX_OUTPUT].name, "Plasma Channel Splitter"); + strcpy(shopItems[SHOP_PLASMA_MAX_OUTPUT].name, _("Plasma Channel Splitter")); /// Shop item description: Plasma Channel Splitter (PLASMA_MAX_OUTPUT) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MAX_OUTPUT].description, _("Improves poweredup plasma output")); shopItems[SHOP_PLASMA_MAX_OUTPUT].image = SP_PLASMA_MAX_OUTPUT; shopItems[SHOP_PLASMA_MAX_DAMAGE].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MAX_DAMAGE].name, "Plasma Capacity Condensor"); + strcpy(shopItems[SHOP_PLASMA_MAX_DAMAGE].name, _("Plasma Capacity Condensor")); /// Shop item description: Plasma Capacity Condensor (PLASMA_MAX_DAMAGE) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MAX_DAMAGE].description, _("Increases poweredup plasma damage")); shopItems[SHOP_PLASMA_MAX_DAMAGE].image = SP_PLASMA_MAX_POWER; shopItems[SHOP_PLASMA_MAX_RATE].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MAX_RATE].name, "Liquid Nitrogen Capsules"); + strcpy(shopItems[SHOP_PLASMA_MAX_RATE].name, _("Liquid Nitrogen Capsules")); /// Shop item description: Liquid Nitrogen Capsules (PLASMA_MAX_RATE) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MAX_RATE].description, _("Increases plasma firing rate")); shopItems[SHOP_PLASMA_MAX_RATE].image = SP_PLASMA_MAX_RATE; @@ -434,9 +443,8 @@ void shop_init() else shopItems[SHOP_PLASMA_AMMO].price = 1; - strcpy(shopItems[SHOP_PLASMA_AMMO].name, "Plasma Cells"); + strcpy(shopItems[SHOP_PLASMA_AMMO].name, _("Plasma Cells")); /// Shop item description: Plasma Cells - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_AMMO].description, _("Plasma ammunition (10 cells each)")); shopItems[SHOP_PLASMA_AMMO].image = SP_PLASMA_AMMO; @@ -445,103 +453,90 @@ void shop_init() else shopItems[SHOP_ROCKET_AMMO].price = 1; - strcpy(shopItems[SHOP_ROCKET_AMMO].name, "Rocket Ammo"); + strcpy(shopItems[SHOP_ROCKET_AMMO].name, _("Rocket Ammo")); /// Shop item description: Rocket Ammo - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_ROCKET_AMMO].description, _("High velocity dumb fire rocket")); shopItems[SHOP_ROCKET_AMMO].image = SP_ROCKET_AMMO; /* ----------- Permanent Items ----------- */ shopItems[SHOP_PLASMA_MIN_OUTPUT].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MIN_OUTPUT].name, "Additional Plasma Cannon"); + strcpy(shopItems[SHOP_PLASMA_MIN_OUTPUT].name, _("Additional Plasma Cannon")); /// Shop item description: Additional Plasma Cannon (PLASMA_MIN_OUTPUT) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MIN_OUTPUT].description, _("Adds an extra plasma cannon to the Firefly")); shopItems[SHOP_PLASMA_MIN_OUTPUT].image = SP_PLASMA_MIN_OUTPUT; shopItems[SHOP_PLASMA_MIN_DAMAGE].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MIN_DAMAGE].name, "Plasma Power Booster"); + strcpy(shopItems[SHOP_PLASMA_MIN_DAMAGE].name, _("Plasma Power Booster")); /// Shop item description: Plasma Power Booster (PLASMA_MIN_DAMAGE) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MIN_DAMAGE].description, _("Increases power of plasma shots")); shopItems[SHOP_PLASMA_MIN_DAMAGE].image = SP_PLASMA_MIN_POWER; shopItems[SHOP_PLASMA_MIN_RATE].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MIN_RATE].name, "Plasma Cooling Booster"); + strcpy(shopItems[SHOP_PLASMA_MIN_RATE].name, _("Plasma Cooling Booster")); /// Shop item description: Plasma Cooling Booster (PLASMA_MIN_RATE) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MIN_RATE].description, _("Permanently increases firing rate")); shopItems[SHOP_PLASMA_MIN_RATE].image = SP_PLASMA_MIN_RATE; /* ----------- Ammo Items -------------- */ shopItems[SHOP_PLASMA_MAX_AMMO].price = 0; // Overwritten later - strcpy(shopItems[SHOP_PLASMA_MAX_AMMO].name, "Plasma Compressor"); + strcpy(shopItems[SHOP_PLASMA_MAX_AMMO].name, _("Plasma Compressor")); /// Shop item description: Plasma Compressor (PLASMA_MAX_AMMO) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_PLASMA_MAX_AMMO].description, _("Increases plasma ammo capacity")); shopItems[SHOP_PLASMA_MAX_AMMO].image = SP_PLASMA_MAX_AMMO; shopItems[SHOP_ROCKET_MAX_AMMO].price = 0; // Overwritten later - strcpy(shopItems[SHOP_ROCKET_MAX_AMMO].name, "Rocket Pod"); + strcpy(shopItems[SHOP_ROCKET_MAX_AMMO].name, _("Rocket Pod")); /// Shop item description: Rocket Pod (ROCKET_MAX_AMMO) - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_ROCKET_MAX_AMMO].description, _("Allows for an additional 5 rockets to be carried")); shopItems[SHOP_ROCKET_MAX_AMMO].image = SP_ROCKET_MAX_AMMO; /* ---------- Weaponary --------------- */ shopItems[SHOP_DOUBLE_ROCKETS].price = 2000; - strcpy(shopItems[SHOP_DOUBLE_ROCKETS].name, "Dual Rocket Launcher"); + strcpy(shopItems[SHOP_DOUBLE_ROCKETS].name, _("Dual Rocket Launcher")); /// Shop item description: Dual Rocket Launcher - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_DOUBLE_ROCKETS].description, _("Launches two rockets at once")); shopItems[SHOP_DOUBLE_ROCKETS].image = SP_DOUBLE_ROCKETS; shopItems[SHOP_MICRO_ROCKETS].price = 2500; - strcpy(shopItems[SHOP_MICRO_ROCKETS].name, "Micro Rocket Launcher"); + strcpy(shopItems[SHOP_MICRO_ROCKETS].name, _("Micro Rocket Launcher")); /// Shop item description: Micro Rocket Launcher - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_MICRO_ROCKETS].description, _("Launches several less powerful rockets at once")); shopItems[SHOP_MICRO_ROCKETS].image = SP_MICRO_ROCKETS; shopItems[SHOP_LASER].price = 5000; - strcpy(shopItems[SHOP_LASER].name, "Laser Cannon"); + strcpy(shopItems[SHOP_LASER].name, _("Laser Cannon")); /// Shop item description: Laser Cannon - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_LASER].description, _("Fires a continuous stream of energy particles")); shopItems[SHOP_LASER].image = SP_LASER; shopItems[SHOP_HOMING_MISSILE].price = 7500; - strcpy(shopItems[SHOP_HOMING_MISSILE].name, "Homing Missile Launcher"); + strcpy(shopItems[SHOP_HOMING_MISSILE].name, _("Homing Missile Launcher")); /// Shop item description: Homing Missile Launcher - /// This must be short enough to fit on a single line. /// %i must be retained. It is replaced by the maximum missile /// capacity of the weapon. - sprintf(shopItems[SHOP_HOMING_MISSILE].description, "Fires homing missile (max %i missiles)", MAX_HOMING); + sprintf(shopItems[SHOP_HOMING_MISSILE].description, _("Fires homing missile (max %i missiles)"), MAX_HOMING); shopItems[SHOP_HOMING_MISSILE].image = SP_HOMING_MISSILE; shopItems[SHOP_CHARGER].price = 10000; - strcpy(shopItems[SHOP_CHARGER].name, "Charge Cannon"); + strcpy(shopItems[SHOP_CHARGER].name, _("Charge Cannon")); /// Shop item description: Charge Cannon - /// This must be short enough to fit on a single line. strcpy(shopItems[SHOP_CHARGER].description, _("Compacts plasma into clusters for greater damage")); shopItems[SHOP_CHARGER].image = SP_CHARGER; shopItems[SHOP_DOUBLE_HOMING_MISSILES].price = 10000; - strcpy(shopItems[SHOP_DOUBLE_HOMING_MISSILES].name, "Dual Homing Missile Launcher"); + strcpy(shopItems[SHOP_DOUBLE_HOMING_MISSILES].name, _("Dual Homing Missile Launcher")); /// Shop item description: Dual Homing Missile Launcher - /// This must be short enough to fit on a single line. /// %i must be retained. It is replaced by the maximum missile /// capacity of the weapon. sprintf(shopItems[SHOP_DOUBLE_HOMING_MISSILES].description, _("Fires two homing missiles (max %i missiles)"), MAX_DOUBLE_HOMING); shopItems[SHOP_DOUBLE_HOMING_MISSILES].image = SP_DOUBLE_HOMING_MISSILES; shopItems[SHOP_MICRO_HOMING_MISSILES].price = 15000; - strcpy(shopItems[SHOP_MICRO_HOMING_MISSILES].name, "Micro Homing Missile Launcher"); + strcpy(shopItems[SHOP_MICRO_HOMING_MISSILES].name, _("Micro Homing Missile Launcher")); /// Shop item description: Micro Homing Missile Launcher - /// This must be short enough to fit on a single line. /// %i must be retained. It is replaced by the maximum missile /// capacity of the weapon. sprintf(shopItems[SHOP_MICRO_HOMING_MISSILES].description, _("Fires several small homing missiles (max %i missiles)"), MAX_MICRO_HOMING); diff --git a/src/title.c b/src/title.c index 405aa71..27e2689 100644 --- a/src/title.c +++ b/src/title.c @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include #include #include @@ -86,18 +87,17 @@ static int showLoadMenu() static void createDifficultyMenu() { - gfx_createTextObject(TS_START_GAME, "START GAME", 0, 0, FONT_WHITE); + char difficulty[STRMAX_SHORT]; + char menutext[STRMAX_SHORT]; - if (game.difficulty == DIFFICULTY_EASY) - gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - EASY", 0, 0, FONT_WHITE); - else if (game.difficulty == DIFFICULTY_HARD) - gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - HARD", 0, 0, FONT_WHITE); - else if (game.difficulty == DIFFICULTY_NIGHTMARE) - gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - NIGHTMARE!", 0, 0, FONT_WHITE); - else if (game.difficulty == DIFFICULTY_ORIGINAL) - gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - CLASSIC", 0, 0, FONT_WHITE); - else - gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - NORMAL", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_START_GAME, _("START GAME"), 0, 0, FONT_WHITE); + + game_getDifficultyText(difficulty, game.difficulty); + + /// Difficulty menu option. + /// Retain "%s" as-is. It is replaced with the difficulty chosen. + snprintf(menutext, STRMAX_SHORT, _("DIFFICULTY - %s"), difficulty); + gfx_createTextObject(TS_DIFFICULTY, menutext, 0, 0, FONT_WHITE); } static int showDifficultyMenu() @@ -113,24 +113,24 @@ static int showDifficultyMenu() static void createOptionsMenu() { if (engine.useSound) - gfx_createTextObject(TS_SOUND, "SOUND - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_SOUND, _("SOUND - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_SOUND, "SOUND - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_SOUND, _("SOUND - OFF"), 0, 0, FONT_WHITE); if (engine.useMusic) - gfx_createTextObject(TS_MUSIC, "MUSIC - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_MUSIC, _("MUSIC - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_MUSIC, "MUSIC - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_MUSIC, _("MUSIC - OFF"), 0, 0, FONT_WHITE); if (engine.fullScreen) - gfx_createTextObject(TS_FULLSCREEN, "FULLSCREEN - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_FULLSCREEN, _("FULLSCREEN - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_FULLSCREEN, "FULLSCREEN - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_FULLSCREEN, _("FULLSCREEN - OFF"), 0, 0, FONT_WHITE); if (engine.autoPause) - gfx_createTextObject(TS_AUTOPAUSE, "AUTOPAUSE - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_AUTOPAUSE, _("AUTOPAUSE - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_AUTOPAUSE, "AUTOPAUSE - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_AUTOPAUSE, _("AUTOPAUSE - OFF"), 0, 0, FONT_WHITE); } static int showOptionsMenu() @@ -148,24 +148,24 @@ static int showOptionsMenu() static void createCheatMenu() { if (engine.cheatShield) - gfx_createTextObject(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_SHIELD, _("UNLIMITED SHIELD - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_SHIELD, _("UNLIMITED SHIELD - OFF"), 0, 0, FONT_WHITE); if (engine.cheatAmmo) - gfx_createTextObject(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_AMMO, _("UNLIMITED AMMO - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_AMMO, _("UNLIMITED AMMO - OFF"), 0, 0, FONT_WHITE); if (engine.cheatCash) - gfx_createTextObject(TS_UNLIMITED_CASH, "UNLIMITED CASH - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_CASH, _("UNLIMITED CASH - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_UNLIMITED_CASH, "UNLIMITED CASH - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_CASH, _("UNLIMITED CASH - OFF"), 0, 0, FONT_WHITE); if (engine.cheatTime) - gfx_createTextObject(TS_UNLIMITED_TIME, "UNLIMITED TIME - ON", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_TIME, _("UNLIMITED TIME - ON"), 0, 0, FONT_WHITE); else - gfx_createTextObject(TS_UNLIMITED_TIME, "UNLIMITED TIME - OFF", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_UNLIMITED_TIME, _("UNLIMITED TIME - OFF"), 0, 0, FONT_WHITE); } static int showCheatMenu() @@ -233,17 +233,17 @@ int title_show() gfx_createTextObject(TS_PRESENTS, "PRESENTS", 0, 0, FONT_WHITE); gfx_createTextObject(TS_AN_SDL_GAME, "AN SDL GAME", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_START_NEW_GAME, "START NEW GAME", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_LOAD_GAME, "LOAD GAME", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_CONTINUE_CURRENT_GAME, "CONTINUE CURRENT GAME", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_OPTIONS, "OPTIONS", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_CREDITS, "CREDITS", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_CHEAT_OPTIONS, "CHEAT OPTIONS", 0, 0, FONT_WHITE); - gfx_createTextObject(TS_QUIT, "QUIT", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_START_NEW_GAME, _("START NEW GAME"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_LOAD_GAME, _("LOAD GAME"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_CONTINUE_CURRENT_GAME, _("CONTINUE CURRENT GAME"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_OPTIONS, _("OPTIONS"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_CREDITS, _("CREDITS"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_CHEAT_OPTIONS, _("CHEAT OPTIONS"), 0, 0, FONT_WHITE); + gfx_createTextObject(TS_QUIT, _("QUIT"), 0, 0, FONT_WHITE); createOptionsMenu(); createDifficultyMenu(); - gfx_createTextObject(TS_BACK_TO_MAIN_MENU, "BACK TO MAIN MENU", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_BACK_TO_MAIN_MENU, _("BACK TO MAIN MENU"), 0, 0, FONT_WHITE); createCheatMenu(); @@ -282,10 +282,10 @@ int title_show() SDL_Rect optionRec; - optionRec.x = screen->w / 2 - 110; + optionRec.x = screen->w / 2 - MENU_W / 2; optionRec.y = MENU_Y - 5; optionRec.h = MENU_SPACING + 2; - optionRec.w = 215; + optionRec.w = MENU_W; if (continueSaveSlot != -1) { @@ -342,7 +342,7 @@ int title_show() if ((now - then >= 27500) || (skip)) { - optionRec.x = screen->w / 2 - 110; + optionRec.x = screen->w / 2 - optionRec.w / 2; optionRec.y = (MENU_Y - 4 - MENU_SPACING) + MENU_SPACING * selectedOption; if (menuType > MENU_MAIN) if (selectedOption == listLength) @@ -496,8 +496,7 @@ int title_show() if (engine.useMusic) { - audio_playMusic( - "music/walking_among_androids.ogg", 1); + audio_playMusic("music/walking_among_androids.ogg", 1); } else {