mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-11 09:25:34 +02:00
Implement MKXP.user_language, return more LANGIDs
This commit is contained in:
parent
6b007ed8d9
commit
9b70f18c8c
3 changed files with 46 additions and 5 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "debugwriter.h"
|
||||
#include "graphics.h"
|
||||
#include "audio.h"
|
||||
#include "lang-fun.h"
|
||||
#include "boost-hash.h"
|
||||
|
||||
#include <ruby.h>
|
||||
|
@ -95,6 +96,7 @@ RB_METHOD(mkxpPuts);
|
|||
RB_METHOD(mkxpRawKeyStates);
|
||||
RB_METHOD(mkxpMouseInWindow);
|
||||
RB_METHOD(mkxpPlatform);
|
||||
RB_METHOD(mkxpUserLanguage);
|
||||
|
||||
RB_METHOD(mriRgssMain);
|
||||
RB_METHOD(mriRgssStop);
|
||||
|
@ -165,6 +167,7 @@ static void mriBindingInit()
|
|||
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
|
||||
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
|
||||
_rb_define_module_function(mod, "platform", mkxpPlatform);
|
||||
_rb_define_module_function(mod, "user_language", mkxpUserLanguage);
|
||||
|
||||
/* Load global constants */
|
||||
rb_gv_set("MKXP", Qtrue);
|
||||
|
@ -270,6 +273,13 @@ RB_METHOD(mkxpPlatform)
|
|||
return rb_str_new_cstr(SDL_GetPlatform());
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpUserLanguage)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_str_new_cstr(getUserLanguage());
|
||||
}
|
||||
|
||||
static VALUE rgssMainCb(VALUE block)
|
||||
{
|
||||
rb_funcall2(block, rb_intern("call"), 0, 0);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "eventthread.h"
|
||||
#include "filesystem.h"
|
||||
#include "input.h"
|
||||
#include "lang-fun.h"
|
||||
#include "fake-api.h"
|
||||
|
||||
|
||||
|
@ -594,11 +595,38 @@ MKXP_GetPrivateProfileString(LPCTSTR lpAppName,
|
|||
}
|
||||
|
||||
|
||||
// Only supports English, other languages are too
|
||||
// much work to keep in hacky code like this
|
||||
// Does not handle sublanguages, only returns a few
|
||||
// common languages
|
||||
|
||||
// Use MKXP.user_language instead
|
||||
|
||||
PREFABI short // I know it's a LANGID but I don't care
|
||||
MKXP_GetUserDefaultLangID(void)
|
||||
NOP_VAL(0xC09);
|
||||
{
|
||||
char buf[50];
|
||||
strncpy(buf, getUserLanguage(), sizeof(buf));
|
||||
|
||||
for (int i = 0; i < strlen(buf); i++)
|
||||
{
|
||||
if (buf[i] == '_')
|
||||
{
|
||||
buf[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define MATCH(l, c) if (!strcmp(l, buf)) return (c & 0x3ff);
|
||||
MATCH("ja", 0x11);
|
||||
MATCH("en", 0x09);
|
||||
MATCH("fr", 0x0c);
|
||||
MATCH("it", 0x10);
|
||||
MATCH("de", 0x07);
|
||||
MATCH("es", 0x0a);
|
||||
MATCH("ko", 0x12);
|
||||
MATCH("pt", 0x16);
|
||||
MATCH("zh", 0x04);
|
||||
#undef MATCH
|
||||
return 0x09;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,7 @@ zlib = dependency('zlib')
|
|||
main_dependencies = [sigcxx, openal, opengl, boost, zlib, pixman, physfs, vorbisfile, sdl2, sdl2_ttf, sdl2_image, sdl_sound]
|
||||
if host_system == 'darwin'
|
||||
main_dependencies += compiler.find_library('iconv')
|
||||
main_dependencies += dependency('CoreFoundation')
|
||||
|
||||
if openal.type_name() != 'pkgconfig'
|
||||
add_project_arguments('-DUSE_MAC_OPENAL', language: 'cpp')
|
||||
|
@ -96,7 +97,8 @@ main_headers = files(
|
|||
'tileatlasvx.h',
|
||||
'sharedmidistate.h',
|
||||
'fluid-fun.h',
|
||||
'sdl-util.h'
|
||||
'sdl-util.h',
|
||||
'lang-fun.h'
|
||||
)
|
||||
|
||||
main_source = files(
|
||||
|
@ -142,7 +144,8 @@ main_source = files(
|
|||
'tileatlasvx.cpp',
|
||||
'autotilesvx.cpp',
|
||||
'midisource.cpp',
|
||||
'fluid-fun.cpp'
|
||||
'fluid-fun.cpp',
|
||||
'lang-fun.cpp'
|
||||
)
|
||||
|
||||
main = [main_source, main_headers]
|
||||
|
|
Loading…
Add table
Reference in a new issue