(svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
--- a/screenshot.c Tue Jul 19 06:31:39 2005 +0000
+++ b/screenshot.c Tue Jul 19 06:47:07 2005 +0000
@@ -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);
--- a/screenshot.h Tue Jul 19 06:31:39 2005 +0000
+++ b/screenshot.h Tue Jul 19 06:47:07 2005 +0000
@@ -9,4 +9,8 @@
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
--- a/settings.c Tue Jul 19 06:31:39 2005 +0000
+++ b/settings.c Tue Jul 19 06:47:07 2005 +0000
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "openttd.h"
+#include "screenshot.h"
#include "sound.h"
#include "string.h"
#include "table/currency.h"
--- a/strings.c Tue Jul 19 06:31:39 2005 +0000
+++ b/strings.c Tue Jul 19 06:47:07 2005 +0000
@@ -1078,13 +1078,32 @@
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 @@
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");
--- a/variables.h Tue Jul 19 06:31:39 2005 +0000
+++ b/variables.h Tue Jul 19 06:47:07 2005 +0000
@@ -366,9 +366,6 @@
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;