Added a setting for controlling language.
It doesn't seem to work and I don't understand why. It's as if gettext is ignoring the setting.
This commit is contained in:
parent
facc34b7ba
commit
0201eddbe5
|
@ -78,10 +78,6 @@ int main(int argc, char **argv)
|
|||
printf("Warning: failed to change directory to \"%s\"\n", DATADIR);
|
||||
#endif
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain("pr-starfighter", "./locale/");
|
||||
textdomain("pr-starfighter");
|
||||
|
||||
engine_init(); // Must do this first!
|
||||
|
||||
cheatAttempt = 0;
|
||||
|
@ -129,9 +125,18 @@ int main(int argc, char **argv)
|
|||
atexit(engine_cleanup);
|
||||
|
||||
gfx_init();
|
||||
engine_setMode();
|
||||
engine_setMode(); // Settings get loaded here
|
||||
gfx_loadFont();
|
||||
|
||||
if ((strcmp(engine.lang, "default") == 0)
|
||||
|| (strcmp(engine.lang, "") == 0))
|
||||
setlocale(LC_ALL, "");
|
||||
else
|
||||
setlocale(LC_ALL, engine.lang);
|
||||
|
||||
bindtextdomain("pr-starfighter", "./locale/");
|
||||
textdomain("pr-starfighter");
|
||||
|
||||
if (cheatAttempt && !engine.cheat)
|
||||
{
|
||||
screen_clear(black);
|
||||
|
|
27
src/engine.c
27
src/engine.c
|
@ -258,6 +258,15 @@ This sets up the video and sound system, and creates Starfighter's window.
|
|||
*/
|
||||
void engine_setMode()
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
int fullScreen = 0;
|
||||
int useSound = 1;
|
||||
int useMusic = 1;
|
||||
int autoPause = 0;
|
||||
int radioLife = DEFAULT_RADIO_LIFE;
|
||||
char lang[STRMAX_SHORT];
|
||||
strcpy(lang, "default");
|
||||
|
||||
strcpy(engine.configDirectory, "");
|
||||
|
||||
engine_setupConfigDirectory();
|
||||
|
@ -269,20 +278,15 @@ void engine_setMode()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
char filename[PATH_MAX];
|
||||
int fullScreen = 0;
|
||||
int useSound = 1;
|
||||
int useMusic = 1;
|
||||
int autoPause = 0;
|
||||
int radioLife = DEFAULT_RADIO_LIFE;
|
||||
|
||||
FILE *fp;
|
||||
snprintf(filename, PATH_MAX, "%sconf", engine.configDirectory);
|
||||
fp = fopen(filename, "r");
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (fscanf(fp, "%d %d %d %d %d", &fullScreen, &useSound, &useMusic, &autoPause, &radioLife) < 5)
|
||||
if (fscanf(fp, "%d %d %d %d %d%*c%[^\n]",
|
||||
&fullScreen, &useSound, &useMusic, &autoPause,
|
||||
&radioLife, lang) < 6)
|
||||
printf("Warning: Config file \"%s\" is not correctly formatted\n", filename);
|
||||
fclose(fp);
|
||||
}
|
||||
|
@ -292,6 +296,7 @@ void engine_setMode()
|
|||
engine.useMusic = useMusic;
|
||||
engine.autoPause = autoPause;
|
||||
engine.radioLife = radioLife;
|
||||
strcpy(engine.lang, lang);
|
||||
|
||||
screen_adjustDimensions(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
|
||||
|
||||
|
@ -451,9 +456,11 @@ void engine_cleanup()
|
|||
fp = fopen(filename, "w");
|
||||
if (fp != NULL)
|
||||
{
|
||||
fprintf(fp, "%d %d %d %d %d\n",
|
||||
fprintf(fp,
|
||||
"%d %d %d %d %d\n"
|
||||
"%s\n",
|
||||
engine.fullScreen, engine.useSound, engine.useMusic,
|
||||
engine.autoPause, engine.radioLife);
|
||||
engine.autoPause, engine.radioLife, engine.lang);
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -90,6 +90,7 @@ typedef struct Engine_ {
|
|||
int fullScreen;
|
||||
int autoPause;
|
||||
int radioLife;
|
||||
char lang[STRMAX_SHORT];
|
||||
|
||||
char configDirectory[PATH_MAX];
|
||||
|
||||
|
|
Loading…
Reference in New Issue