i18n updates. Not optimised. That will come later.
This commit is contained in:
parent
821e7ac872
commit
58e7b9b8ea
|
@ -242,7 +242,7 @@ void drawBullets(void)
|
|||
|
||||
if (incomingMissile && battle.stats[STAT_TIME] % FPS < 40)
|
||||
{
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 60, 18, TA_CENTER, colors.red, "WARNING: INCOMING MISSILE!");
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 60, 18, TA_CENTER, colors.red, _("WARNING: INCOMING MISSILE!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
|||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern void playSound(int id);
|
||||
extern char *getFileLocation(char *filename);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -302,15 +302,15 @@ static void drawWeaponInfo(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
drawText(30, 70, 14, TA_LEFT, colors.white, "(None)");
|
||||
drawText(30, 70, 14, TA_LEFT, colors.white, _("(None)"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
drawText(30, 70, 14, TA_LEFT, colors.white, "(Combined Guns)");
|
||||
drawText(30, 70, 14, TA_LEFT, colors.white, _("(Combined Guns)"));
|
||||
}
|
||||
|
||||
drawText(280, 70, 14, TA_RIGHT, colors.white, "Missiles (%d)", player->missiles);
|
||||
drawText(280, 70, 14, TA_RIGHT, colors.white, _("Missiles (%d)"), player->missiles);
|
||||
}
|
||||
|
||||
static void drawPlayerTargeter(void)
|
||||
|
@ -433,7 +433,7 @@ static void drawDistancesInfo(void)
|
|||
|
||||
distance = distanceToKM(player->x, player->y, player->target->x, player->target->y);
|
||||
|
||||
drawText(SCREEN_WIDTH - 15, y, 14, TA_RIGHT, colors.red, "Target: %.2fkm", distance);
|
||||
drawText(SCREEN_WIDTH - 15, y, 14, TA_RIGHT, colors.red, _("Target: %.2fkm"), distance);
|
||||
|
||||
y += 25;
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ static void drawDistancesInfo(void)
|
|||
{
|
||||
distance = distanceToKM(player->x, player->y, battle.missionTarget->x, battle.missionTarget->y);
|
||||
|
||||
drawText(SCREEN_WIDTH - 15, y, 14, TA_RIGHT, colors.green, "Objective: %.2fkm", distance);
|
||||
drawText(SCREEN_WIDTH - 15, y, 14, TA_RIGHT, colors.green, _("Objective: %.2fkm"), distance);
|
||||
|
||||
y += 25;
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ static void drawDistancesInfo(void)
|
|||
{
|
||||
distance = distanceToKM(player->x, player->y, battle.extractionPoint->x, battle.extractionPoint->y);
|
||||
|
||||
drawText(SCREEN_WIDTH - 15, y, 14, TA_RIGHT, colors.yellow, "Extraction Point: %.2fkm", distance);
|
||||
drawText(SCREEN_WIDTH - 15, y, 14, TA_RIGHT, colors.yellow, _("Extraction Point: %.2fkm"), distance);
|
||||
|
||||
y += 25;
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ static void drawPlayerSelect(void)
|
|||
|
||||
blit(targetCircle, player->x - battle.camera.x, player->y - battle.camera.y, 1);
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, 500, 28, TA_CENTER, colors.white, "SELECT NEW FIGHTER");
|
||||
drawText(SCREEN_WIDTH / 2, 500, 28, TA_CENTER, colors.white, _("SELECT NEW FIGHTER"));
|
||||
|
||||
if (player->health > 0)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ extern void drawRadar(void);
|
|||
extern void drawRadarRangeWarning(void);
|
||||
extern int getPercent(float current, float total);
|
||||
extern int playerHasGun(int type);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -87,7 +87,7 @@ static void drawMissionSummary(SDL_Texture *header)
|
|||
|
||||
if (!battle.isChallenge)
|
||||
{
|
||||
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.white, "OBJECTIVES");
|
||||
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.white, _("OBJECTIVES"));
|
||||
|
||||
y += 10;
|
||||
|
||||
|
@ -125,7 +125,7 @@ static void drawMissionSummary(SDL_Texture *header)
|
|||
{
|
||||
y += 50;
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, y, 22, TA_CENTER, colors.white, "(none)");
|
||||
drawText(SCREEN_WIDTH / 2, y, 22, TA_CENTER, colors.white, _("(none)"));
|
||||
}
|
||||
|
||||
y += 75;
|
||||
|
|
|
@ -25,6 +25,7 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char
|
|||
extern SDL_Texture *getTexture(char *filename);
|
||||
extern char *getChallengeDescription(Challenge *c);
|
||||
extern void drawWidgets(char *groupName);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -124,6 +124,6 @@ void drawRadarRangeWarning(void)
|
|||
|
||||
if (leaving && battle.stats[STAT_TIME] % FPS < 40)
|
||||
{
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 30, 14, TA_CENTER, colors.white, "Caution: Leaving battle area - turn around.");
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 30, 14, TA_CENTER, colors.white, _("Caution: Leaving battle area - turn around."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ extern void blit(SDL_Texture *texture, int x, int y, int center);
|
|||
extern SDL_Texture *getTexture(char *filename);
|
||||
extern void blitRotated(SDL_Texture *texture, int x, int y, float angle);
|
||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -136,7 +136,7 @@ static void updatePandoranAdvance(void)
|
|||
|
||||
if (fallenStarSystem)
|
||||
{
|
||||
showOKDialog(&fallenOK, "%s has fallen to the Pandorans", fallenStarSystem->name);
|
||||
showOKDialog(&fallenOK, _("%s has fallen to the Pandorans"), fallenStarSystem->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ static void logic(void)
|
|||
pulseTimer++;
|
||||
pulseTimer %= (FPS * 60);
|
||||
|
||||
arrowPulse += 0.01;
|
||||
arrowPulse += 0.1;
|
||||
|
||||
doWidgets();
|
||||
}
|
||||
|
@ -389,8 +389,6 @@ static void drawGalaxy(void)
|
|||
SDL_Color color;
|
||||
float ax, ay, aa;
|
||||
|
||||
arrowPulse += 0.1;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
{
|
||||
r.x = starSystem->x - camera.x;
|
||||
|
@ -490,7 +488,7 @@ static void drawInfoBars(void)
|
|||
SDL_RenderFillRect(app.renderer, &r);
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||
|
||||
drawText((SCREEN_WIDTH / 2), 5, 18, TA_CENTER, colors.white, "Missions: %d / %d", game.completedMissions, game.availableMissions);
|
||||
drawText((SCREEN_WIDTH / 2), 5, 18, TA_CENTER, colors.white, _("Missions: %d / %d"), game.completedMissions, game.availableMissions);
|
||||
}
|
||||
|
||||
static void selectStarSystem(void)
|
||||
|
@ -526,7 +524,7 @@ static void drawStarSystemDetail(void)
|
|||
|
||||
y = 70;
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.cyan, "%s", selectedStarSystem->name);
|
||||
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.cyan, selectedStarSystem->name);
|
||||
|
||||
SDL_RenderDrawLine(app.renderer, r.x, 120, r.x + r.w - 1, 120);
|
||||
|
||||
|
@ -560,9 +558,9 @@ static void drawStarSystemDetail(void)
|
|||
|
||||
if (game.currentMission->available)
|
||||
{
|
||||
drawText(525, 135, 18, TA_LEFT, colors.lightGrey, "Pilot: %s", game.currentMission->pilot);
|
||||
drawText(525, 160, 18, TA_LEFT, colors.lightGrey, "Craft: %s", game.currentMission->craft);
|
||||
drawText(525, 185, 18, TA_LEFT, colors.lightGrey, "Squadron: %s", game.currentMission->squadron);
|
||||
drawText(525, 135, 18, TA_LEFT, colors.lightGrey, _("Pilot: %s"), game.currentMission->pilot);
|
||||
drawText(525, 160, 18, TA_LEFT, colors.lightGrey, _("Craft: %s"), game.currentMission->craft);
|
||||
drawText(525, 185, 18, TA_LEFT, colors.lightGrey, _("Squadron: %s"), game.currentMission->squadron);
|
||||
|
||||
limitTextWidth(500);
|
||||
drawText(525, 230, 22, TA_LEFT, colors.white, game.currentMission->description);
|
||||
|
@ -571,11 +569,11 @@ static void drawStarSystemDetail(void)
|
|||
|
||||
if (game.currentMission->completed)
|
||||
{
|
||||
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.green, "This mission has been completed.");
|
||||
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.green, _("This mission has been completed."));
|
||||
}
|
||||
else if (game.currentMission->epic)
|
||||
{
|
||||
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, "Note: this is an Epic Mission.");
|
||||
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an Epic Mission."));
|
||||
}
|
||||
|
||||
startMissionButton->enabled = (!game.currentMission->completed || selectedStarSystem->isSol);
|
||||
|
|
|
@ -59,6 +59,7 @@ extern void updateStarSystemMissions(void);
|
|||
extern StarSystem *getStarSystem(char *name);
|
||||
extern void setMouse(int x, int y);
|
||||
extern void showOKDialog(void (*callback)(void), const char *format, ...);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -48,7 +48,7 @@ Mission *loadMissionMeta(char *filename)
|
|||
memset(mission, 0, sizeof(Mission));
|
||||
|
||||
STRNCPY(mission->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
|
||||
STRNCPY(mission->description, cJSON_GetObjectItem(root, "description")->valuestring, MAX_DESCRIPTION_LENGTH);
|
||||
STRNCPY(mission->description, _(cJSON_GetObjectItem(root, "description")->valuestring), MAX_DESCRIPTION_LENGTH);
|
||||
STRNCPY(mission->filename, filename, MAX_DESCRIPTION_LENGTH);
|
||||
|
||||
if (cJSON_GetObjectItem(root, "requires"))
|
||||
|
@ -236,7 +236,7 @@ static void loadObjectives(cJSON *node)
|
|||
battle.objectiveTail = o;
|
||||
|
||||
o->active = 1;
|
||||
STRNCPY(o->description, cJSON_GetObjectItem(node, "description")->valuestring, MAX_DESCRIPTION_LENGTH);
|
||||
STRNCPY(o->description, _(cJSON_GetObjectItem(node, "description")->valuestring), MAX_DESCRIPTION_LENGTH);
|
||||
STRNCPY(o->targetName, cJSON_GetObjectItem(node, "targetName")->valuestring, MAX_NAME_LENGTH);
|
||||
o->targetValue = cJSON_GetObjectItem(node, "targetValue")->valueint;
|
||||
o->targetType = lookup(cJSON_GetObjectItem(node, "targetType")->valuestring);
|
||||
|
|
|
@ -48,6 +48,7 @@ extern char *getFileLocation(char *filename);
|
|||
extern void updateCapitalShipComponentProperties(Entity *parent);
|
||||
extern void countNumEnemies(void);
|
||||
extern void initMissionInfo(void);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
|
|
|
@ -93,9 +93,9 @@ void drawStats(void)
|
|||
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
||||
SDL_RenderDrawRect(app.renderer, &r);
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, 70, 28, TA_CENTER, colors.white, "Stats");
|
||||
drawText(SCREEN_WIDTH / 2, 70, 28, TA_CENTER, colors.white, _("Stats"));
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, "Page %d / %d", page + 1, maxPages);
|
||||
drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, _("Page %d / %d"), page + 1, maxPages);
|
||||
|
||||
y = 170;
|
||||
|
||||
|
@ -118,7 +118,7 @@ void drawStats(void)
|
|||
seconds %= 60;
|
||||
|
||||
sprintf(timePlayed, "%dh:%02dm:%02ds", hours, minutes, seconds);
|
||||
drawText(r.x + 20, 565, 18, TA_LEFT, colors.white, "Time Played");
|
||||
drawText(r.x + 20, 565, 18, TA_LEFT, colors.white, _("Time Played"));
|
||||
drawText(r.x + r.w - 20, 565, 18, TA_RIGHT, colors.white, timePlayed);
|
||||
|
||||
drawWidgets("stats");
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
extern void drawWidgets(char *groupName);
|
||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern Widget *getWidget(const char *name, const char *group);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
17
src/main.c
17
src/main.c
|
@ -37,7 +37,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
srand(time(NULL));
|
||||
|
||||
setlocale(LC_NUMERIC, "");
|
||||
init18N(argc, argv);
|
||||
|
||||
initSDL();
|
||||
|
||||
|
@ -156,7 +156,6 @@ static void handleArguments(int argc, char *argv[])
|
|||
{
|
||||
int i;
|
||||
int testingMission = 0;
|
||||
int languageId = -1;
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
{
|
||||
|
@ -173,23 +172,9 @@ static void handleArguments(int argc, char *argv[])
|
|||
{
|
||||
dev.debug = 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "-language") == 0)
|
||||
{
|
||||
languageId = i + 1;
|
||||
|
||||
if (languageId >= argc)
|
||||
{
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "You must specify a language to use with -language. Using default.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLanguage("tbftss", languageId == -1 ? NULL : argv[languageId]);
|
||||
printf("Numeric is %s\n", setlocale(LC_NUMERIC, "C"));
|
||||
printf("atof(2.75) is %f\n", atof("2.75"));
|
||||
|
||||
if (!testingMission)
|
||||
{
|
||||
if (fileExists(getSaveFilePath("game.save")))
|
||||
|
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "SDL2/SDL.h"
|
||||
#include "time.h"
|
||||
#include "locale.h"
|
||||
|
||||
#include "defs.h"
|
||||
#include "structs.h"
|
||||
|
@ -44,7 +43,7 @@ extern void drawModalDialog(void);
|
|||
extern void loadGame(void);
|
||||
extern int fileExists(char *filename);
|
||||
extern char *getSaveFilePath(char *filename);
|
||||
extern void setLanguage(char *applicationName, char *languageCode);
|
||||
extern void init18N(int argc, char *argv[]);
|
||||
|
||||
App app;
|
||||
Colors colors;
|
||||
|
|
|
@ -25,6 +25,32 @@ void saveConfig(void);
|
|||
static void initColor(SDL_Color *c, int r, int g, int b);
|
||||
static void showLoadingStep(float step, float maxSteps);
|
||||
|
||||
void init18N(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int languageId = -1;
|
||||
|
||||
setlocale(LC_NUMERIC, "");
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-language") == 0)
|
||||
{
|
||||
languageId = i + 1;
|
||||
|
||||
if (languageId >= argc)
|
||||
{
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "You must specify a language to use with -language. Using default.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLanguage("tbftss", languageId == -1 ? NULL : argv[languageId]);
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Numeric is %s\n", setlocale(LC_NUMERIC, "C"));
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "atof(2.75) is %f\n", atof("2.75"));
|
||||
}
|
||||
|
||||
void initSDL(void)
|
||||
{
|
||||
int rendererFlags, windowFlags;
|
||||
|
|
|
@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../json/cJSON.h"
|
||||
|
||||
#include "locale.h"
|
||||
|
||||
#include "SDL2/SDL_image.h"
|
||||
#include "SDL2/SDL_mixer.h"
|
||||
#include "SDL2/SDL_ttf.h"
|
||||
|
@ -62,6 +64,7 @@ extern void initInput(void);
|
|||
extern void initModalDialog(void);
|
||||
extern void createSaveFolder(void);
|
||||
extern char *getFileLocation(char *filename);
|
||||
extern void setLanguage(char *applicationName, char *languageCode);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -77,7 +77,7 @@ void drawOptions(void)
|
|||
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
||||
SDL_RenderDrawRect(app.renderer, &r);
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, 70, 28, TA_CENTER, colors.white, "Options");
|
||||
drawText(SCREEN_WIDTH / 2, 70, 28, TA_CENTER, colors.white, _("Options"));
|
||||
|
||||
SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
|
||||
SDL_RenderDrawLine(app.renderer, r.x, 120, r.x + r.w, 120);
|
||||
|
@ -85,7 +85,7 @@ void drawOptions(void)
|
|||
drawWidgets("options");
|
||||
|
||||
limitTextWidth(r.w - 100);
|
||||
drawText(SCREEN_WIDTH / 2, r.y + r.h - 135, 16, TA_CENTER, colors.yellow, "Note: you must restart the game for window size and fullscreen options to take effect.");
|
||||
drawText(SCREEN_WIDTH / 2, r.y + r.h - 135, 16, TA_CENTER, colors.yellow, _("Note: you must restart the game for window size and fullscreen options to take effect."));
|
||||
limitTextWidth(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ extern void setWidgetOption(const char *name, const char *group, const char *val
|
|||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern void saveConfig(void);
|
||||
extern void limitTextWidth(int width);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -301,7 +301,7 @@ static void loadWidgetSet(char *filename)
|
|||
switch (w->type)
|
||||
{
|
||||
case WT_BUTTON:
|
||||
STRNCPY(w->text, _((cJSON_GetObjectItem(node, "text")->valuestring)), MAX_NAME_LENGTH);
|
||||
STRNCPY(w->text, _(cJSON_GetObjectItem(node, "text")->valuestring), MAX_NAME_LENGTH);
|
||||
w->rect.w = cJSON_GetObjectItem(node, "w")->valueint;
|
||||
w->rect.h = cJSON_GetObjectItem(node, "h")->valueint;
|
||||
w->rect.x -= w->rect.w / 2;
|
||||
|
|
Loading…
Reference in New Issue