A lot of changes
- Fix the broken itemindex of ComboBox in the Settings dialog - Change from LCID to uint32_t - Rewrite the headers of the lang related functions (can handle the whole LCID as input) - Add dummy functions to unix.c - Add proper combobox handling in win_settings.c - Added a lot of debug calls temporarily - Reactivate every disabled option related to language changes - Move lang_id to 86box.h from win.h - Implement on-fly resource switch as discussed with OBattler - Reimplement everything language related in the initialization section of the program - Implemented the ladder of three points 1, what is the --lang? 2, what are definied in the config? (to be implemented) 3, what is the system language
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2017-2019 Fred N. van Kempen.
|
||||
* Copyright 2021 Laci bá'
|
||||
*/
|
||||
#define UNICODE
|
||||
#define NTDDI_VERSION 0x06010000
|
||||
@@ -66,7 +67,7 @@ typedef struct {
|
||||
/* Platform Public data, specific. */
|
||||
HINSTANCE hinstance; /* application instance */
|
||||
HANDLE ghMutex;
|
||||
LCID lang_id; /* current language ID used */
|
||||
uint32_t lang_id; /* current language ID used */
|
||||
DWORD dwSubLangID;
|
||||
int acp_utf8; /* Windows supports UTF-8 codepage */
|
||||
volatile int cpu_thread_run = 1;
|
||||
@@ -138,7 +139,7 @@ win_log(const char *fmt, ...)
|
||||
#define win_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
free_string(rc_str_t **str)
|
||||
{
|
||||
if (*str != NULL) {
|
||||
@@ -242,29 +243,28 @@ size_t c16stombs(char dst[], const uint16_t src[], int len)
|
||||
|
||||
|
||||
int
|
||||
has_language_changed(int id)
|
||||
has_language_changed(uint32_t id)
|
||||
{
|
||||
LCID lcidNew = MAKELCID(id, dwSubLangID);
|
||||
|
||||
return (lang_id != lcidNew);
|
||||
pclog("has_language_changed? lang_id:%u == id:%u?\n", lang_id, id);
|
||||
return (lang_id != id);
|
||||
}
|
||||
|
||||
|
||||
/* Set (or re-set) the language for the application. */
|
||||
void
|
||||
set_language(int id)
|
||||
set_language(uint32_t id)
|
||||
{
|
||||
LCID lcidNew = MAKELCID(id, dwSubLangID);
|
||||
pclog("set_language %u, lang_id %u\n", id, lang_id);
|
||||
if (lang_id != id) {
|
||||
/* Set our new language ID. */
|
||||
lang_id = id;
|
||||
SetThreadUILanguage(lang_id);
|
||||
|
||||
SetMenu(hwndMain, LoadMenu(hinstance, L"MainMenu"));
|
||||
|
||||
if (lang_id != lcidNew) {
|
||||
/* Set our new language ID. */
|
||||
lang_id = lcidNew;
|
||||
|
||||
SetThreadLocale(lang_id);
|
||||
|
||||
/* Load the strings table for this ID. */
|
||||
LoadCommonStrings();
|
||||
}
|
||||
/* Load the strings table for this ID. */
|
||||
LoadCommonStrings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -464,9 +464,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
|
||||
|
||||
/* Set the application version ID string. */
|
||||
sprintf(emu_version, "%s v%s", EMU_NAME, EMU_VERSION);
|
||||
|
||||
/* First, set our (default) language. */
|
||||
set_language(0x0409);
|
||||
|
||||
/* First, set our (default) language. */
|
||||
set_language(GetThreadUILanguage());
|
||||
|
||||
/* Process the command line for options. */
|
||||
argc = ProcessCommandLine(&argv);
|
||||
@@ -1193,8 +1193,8 @@ plat_vid_reload_options(void)
|
||||
}
|
||||
|
||||
/* Sets up the program language before initialization. */
|
||||
int
|
||||
plat_set_language(char* langcode)
|
||||
uint32_t
|
||||
plat_language_code(char* langcode)
|
||||
{
|
||||
int len = mbstoc16s(NULL, langcode, 0) + 1;
|
||||
wchar_t *temp = malloc(len * sizeof(wchar_t));
|
||||
@@ -1203,11 +1203,7 @@ plat_set_language(char* langcode)
|
||||
LCID lcid = LocaleNameToLCID((LPWSTR)temp, 0);
|
||||
|
||||
free(temp);
|
||||
|
||||
if (lcid)
|
||||
return (SetThreadUILanguage(lcid) == lcid);
|
||||
else
|
||||
return 0;
|
||||
return lcid;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user