mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-11 15:45:05 +02:00
Linux automatic language selector
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
set -e
|
||||
clang++ -std=c++11 -Os -s -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o../../../bin/OpenLara -lX11 -lGL -lm -lpthread -lpulse-simple -lpulse
|
||||
clang++ -std=c++11 -Os -s -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -Wno-invalid-source-encoding -DNDEBUG -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o../../../bin/OpenLara -lX11 -lGL -lm -lpthread -lpulse-simple -lpulse
|
||||
strip ../../../bin/OpenLara --strip-all --remove-section=.comment --remove-section=.note
|
||||
|
@@ -353,6 +353,27 @@ void WndProc(const XEvent &e,Display*dpy,Window wnd) {
|
||||
}
|
||||
}
|
||||
|
||||
int checkLanguage() {
|
||||
char *lang = getenv("LANG");
|
||||
if (!lang || strlen(lang) < 2) return 0;
|
||||
|
||||
uint16 id;
|
||||
memcpy(&id, lang, 2);
|
||||
|
||||
if (id == TWOCC("en")) return STR_LANG_EN - STR_LANG_EN;
|
||||
if (id == TWOCC("fr")) return STR_LANG_FR - STR_LANG_EN;
|
||||
if (id == TWOCC("de")) return STR_LANG_DE - STR_LANG_EN;
|
||||
if (id == TWOCC("es")) return STR_LANG_ES - STR_LANG_EN;
|
||||
if (id == TWOCC("it")) return STR_LANG_IT - STR_LANG_EN;
|
||||
if (id == TWOCC("pl")) return STR_LANG_PL - STR_LANG_EN;
|
||||
if (id == TWOCC("uk")) return STR_LANG_RU - STR_LANG_EN;
|
||||
if (id == TWOCC("be")) return STR_LANG_RU - STR_LANG_EN;
|
||||
if (id == TWOCC("ru")) return STR_LANG_RU - STR_LANG_EN;
|
||||
if (id == TWOCC("ja")) return STR_LANG_JA - STR_LANG_EN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
@@ -405,6 +426,8 @@ int main(int argc, char **argv) {
|
||||
gettimeofday(&t, NULL);
|
||||
startTime = t.tv_sec;
|
||||
|
||||
Core::defLang = checkLanguage();
|
||||
|
||||
joyInit();
|
||||
sndInit();
|
||||
Game::init(argc > 1 ? argv[1] : NULL);
|
||||
|
@@ -96,6 +96,7 @@ typedef unsigned int uint32;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
#define FOURCC(str) uint32( ((uint8*)(str))[0] | (((uint8*)(str))[1] << 8) | (((uint8*)(str))[2] << 16) | (((uint8*)(str))[3] << 24) )
|
||||
#define TWOCC(str) uint32( ((uint8*)(str))[0] | (((uint8*)(str))[1] << 8) )
|
||||
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
#define COUNT(arr) int(sizeof(arr) / sizeof(arr[0]))
|
||||
|
Reference in New Issue
Block a user