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:
Laci bá
2021-11-09 22:33:54 +01:00
parent 11527d39b0
commit dafc429e93
7 changed files with 79 additions and 42 deletions

View File

@@ -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;