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
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2018,2019 David Hrdlička.
|
||||
* Copyright 2021 Laci bá'
|
||||
*/
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
@@ -78,7 +79,7 @@ static int first_cat = 0;
|
||||
static int dpi = 96;
|
||||
|
||||
/* Language */
|
||||
static int temp_language;
|
||||
static LCID temp_language;
|
||||
|
||||
/* Machine category */
|
||||
static int temp_machine_type, temp_machine, temp_cpu, temp_wait_states, temp_fpu, temp_sync;
|
||||
@@ -318,7 +319,7 @@ settings_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn
|
||||
return(i);
|
||||
}
|
||||
|
||||
int enum_helper = -1, c = 0;
|
||||
int enum_helper, c;
|
||||
|
||||
BOOL CALLBACK
|
||||
EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam)
|
||||
@@ -326,11 +327,13 @@ EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLan
|
||||
wchar_t temp[LOCALE_NAME_MAX_LENGTH + 1];
|
||||
LCIDToLocaleName(wIDLanguage, temp, LOCALE_NAME_MAX_LENGTH, 0);
|
||||
SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)temp);
|
||||
SendMessage((HWND)lParam, CB_SETITEMDATA, c, (LPARAM)wIDLanguage);
|
||||
|
||||
if (wIDLanguage == temp_language)
|
||||
pclog("widl: %u, langid: %u, c: %u\n", wIDLanguage, lang_id, c);
|
||||
if (wIDLanguage == lang_id)
|
||||
enum_helper = c;
|
||||
|
||||
c++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -342,9 +345,13 @@ win_fill_languages(HWND hdlg)
|
||||
HWND lang_combo = GetDlgItem(hdlg, IDC_COMBO_LANG);
|
||||
|
||||
SendMessage(lang_combo, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
enum_helper = -1; c = 0;
|
||||
EnumResourceLanguages(hinstance, RT_MENU, L"MainMenu", &EnumResLangProc, (LPARAM)lang_combo);
|
||||
pclog("enum_helper is %d\n", enum_helper);
|
||||
|
||||
SendMessage(lang_combo, CB_SETCURSEL, enum_helper, 0);
|
||||
pclog("win_fill_languages\n");
|
||||
}
|
||||
|
||||
/* This does the initial read of global variables into the temporary ones. */
|
||||
@@ -354,6 +361,8 @@ win_settings_init(void)
|
||||
int i = 0;
|
||||
|
||||
/* Language */
|
||||
temp_language = lang_id;
|
||||
pclog("temp_language is %u\n", lang_id);
|
||||
win_fill_languages(hwndParentDialog);
|
||||
|
||||
/* Machine category */
|
||||
@@ -482,7 +491,7 @@ win_settings_changed(void)
|
||||
int i = 0, j = 0;
|
||||
|
||||
/* Language */
|
||||
// i = i || has_language_changed(temp_language);
|
||||
i = i || has_language_changed(temp_language);
|
||||
|
||||
/* Machine category */
|
||||
i = i || (machine != temp_machine);
|
||||
@@ -575,7 +584,7 @@ win_settings_save(void)
|
||||
pc_reset_hard_close();
|
||||
|
||||
/* Language */
|
||||
// set_language(temp_language);
|
||||
set_language(temp_language);
|
||||
|
||||
/* Machine category */
|
||||
machine = temp_machine;
|
||||
@@ -5229,6 +5238,13 @@ win_settings_main_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
EndDialog(hdlg, 0);
|
||||
win_notify_dlg_closed();
|
||||
return TRUE;
|
||||
case IDC_COMBO_LANG:
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
||||
HWND combo = GetDlgItem(hwndParentDialog, IDC_COMBO_LANG);
|
||||
int index = SendMessage(combo, CB_GETCURSEL, 0, 0);
|
||||
temp_language = SendMessage(combo, CB_GETITEMDATA, index, 0);
|
||||
pclog("combobox changed -> temp_language = %u", temp_language);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user