diff options
-rw-r--r-- | screenshot.c | 4 | ||||
-rw-r--r-- | screenshot.h | 4 | ||||
-rw-r--r-- | settings.c | 1 | ||||
-rw-r--r-- | strings.c | 25 | ||||
-rw-r--r-- | variables.h | 3 |
5 files changed, 32 insertions, 5 deletions
diff --git a/screenshot.c b/screenshot.c index afcfff086..c9deaca7e 100644 --- a/screenshot.c +++ b/screenshot.c @@ -9,6 +9,10 @@ #include "gui.h" #include "screenshot.h" +char _screenshot_format_name[8]; +uint _num_screenshot_formats; +uint _cur_screenshot_format; + // called by the ScreenShot proc to generate screenshot lines. typedef void ScreenshotCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n); typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette); diff --git a/screenshot.h b/screenshot.h index 900c1e702..1ad20bcd4 100644 --- a/screenshot.h +++ b/screenshot.h @@ -9,4 +9,8 @@ void SetScreenshotFormat(int i); bool MakeScreenshot(void); bool MakeWorldScreenshot(int left, int top, int width, int height, int zoom); +extern char _screenshot_format_name[8]; +extern uint _num_screenshot_formats; +extern uint _cur_screenshot_format; + #endif diff --git a/settings.c b/settings.c index a06bb9770..c6707dc62 100644 --- a/settings.c +++ b/settings.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "openttd.h" +#include "screenshot.h" #include "sound.h" #include "string.h" #include "table/currency.h" @@ -1078,13 +1078,32 @@ void InitializeLanguagePacks(void) int n; int m; int def; + int fallback; LanguagePack hdr; FILE *in; char *files[32]; + uint j; + + char lang[] = "en"; + static const char* env[] = { + "LANGUAGE", + "LC_ALL", + "LC_MESSAGES", + "LANG" + }; + + for (j = 0; j < lengthof(env); j++) { + const char* envlang = getenv(env[j]); + if (envlang != NULL) { + snprintf(lang, lengthof(lang), "%.2s", envlang); + break; + } + } n = GetLanguageList(files, lengthof(files)); - def = 0; // default language file + def = -1; + fallback = 0; // go through the language files and make sure that they are valid. for (i = m = 0; i != n; i++) { @@ -1104,10 +1123,12 @@ void InitializeLanguagePacks(void) dl->ent[m].file = files[i]; dl->ent[m].name = strdup(hdr.name); - if (strcmp(hdr.name, "English") == 0) def = m; + if (strcmp(hdr.name, "English") == 0) fallback = m; + if (strcmp(hdr.isocode, lang) == 0) def = m; m++; } + if (def == -1) def = fallback; if (m == 0) error(n == 0 ? "No available language packs" : "Invalid version of language packs"); diff --git a/variables.h b/variables.h index f026a7601..c37cb4070 100644 --- a/variables.h +++ b/variables.h @@ -366,9 +366,6 @@ VARDEF int _num_resolutions; VARDEF uint16 _resolutions[32][2]; VARDEF uint16 _cur_resolution[2]; -VARDEF char _screenshot_format_name[8]; -VARDEF int _num_screenshot_formats, _cur_screenshot_format; - VARDEF char _savegame_format[8]; VARDEF char *_config_file; |