From b4f5ff7ad156ef450aed1ad0293fe59e226dcd7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Fri, 12 Nov 2021 22:41:01 +0100 Subject: [PATCH] Separate language dialog, and minor language fixes --- src/include/86box/resource.h | 9 ++- src/include/86box/win.h | 3 + src/win/CMakeLists.txt | 2 +- src/win/Makefile.mingw | 2 +- src/win/languages/en-US.rc | 24 +++++- src/win/languages/hu-HU.rc | 67 ++++++++++------- src/win/win_lang.c | 142 +++++++++++++++++++++++++++++++++++ src/win/win_ui.c | 4 + 8 files changed, 221 insertions(+), 32 deletions(-) create mode 100644 src/win/win_lang.c diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index eaadaccd6..306a9c839 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -29,6 +29,7 @@ #define DLG_SND_GAIN 103 /* top-level dialog */ #define DLG_NEW_FLOPPY 104 /* top-level dialog */ #define DLG_SPECIFY_DIM 105 /* top-level dialog */ +#define DLG_PROG_SETT 106 /* top-level dialog */ #define DLG_CONFIG 110 /* top-level dialog */ #define DLG_CFG_MACHINE 111 /* sub-dialog of config */ #define DLG_CFG_VIDEO 112 /* sub-dialog of config */ @@ -122,7 +123,6 @@ #define IDC_RADIO_TS_DISABLED 1006 #define IDC_RADIO_TS_LOCAL 1007 #define IDC_RADIO_TS_UTC 1008 -#define IDC_COMBO_LANG 1009 #define IDC_COMBO_MACHINE_TYPE 1010 #define IDC_COMBO_MACHINE 1011 /* machine/cpu config */ @@ -264,6 +264,11 @@ #define IDC_COMBO_DISK_SIZE 1201 #define IDC_COMBO_RPM_MODE 1202 +#define IDC_COMBO_LANG 1009 /* change language dialog */ +#define IDC_CHECKBOX_GLOBAL 1300 +#define IDC_BUTTON_SYSTEM 1301 +#define IDC_BUTTON_DEFAULT 1302 + /* For the DeviceConfig code, re-do later. */ #define IDC_CONFIG_BASE 1300 #define IDC_CONFIGURE_VID 1300 @@ -351,6 +356,8 @@ #define IDM_DISCORD 40090 #endif +#define IDM_VID_PROG_SETT 40091 + #if defined(DEV_BRANCH) && defined(USE_OPENGL) #define IDM_VID_GL_FPS_BLITTER 40100 #define IDM_VID_GL_FPS_25 40101 diff --git a/src/include/86box/win.h b/src/include/86box/win.h index da4d9fb05..33e55f1d4 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -184,6 +184,9 @@ extern void NewFloppyDialogCreate(HWND hwnd, int id, int part); /* Functions in win_specify_dim.c: */ extern void SpecifyDimensionsDialogCreate(HWND hwnd); +/* Functions in win_lang.c: */ +extern void ProgSettDlgCreate(HWND hwnd); + /* Functions in win_settings.c: */ #define SETTINGS_PAGE_MACHINE 0 diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index e1b3fd942..727644f7b 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -20,7 +20,7 @@ add_library(plat OBJECT win.c win_dynld.c win_cdrom.c win_thread.c add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c win_settings.c win_devconf.c win_snd_gain.c win_specify_dim.c win_new_floppy.c - win_jsconf.c win_media_menu.c 86Box.rc) + win_jsconf.c win_media_menu.c win_lang.c 86Box.rc) if(MSVC) # MSVC complains when we include the manifest from 86Box.rc... diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 90ef6136a..ddafd98d0 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -444,7 +444,7 @@ else UIOBJ := win_ui.o win_stbar.o \ win_sdl.o \ win_dialog.o win_about.o \ - win_settings.o win_devconf.o win_snd_gain.o win_specify_dim.o \ + win_settings.o win_devconf.o win_snd_gain.o win_specify_dim.o win_lang.o \ win_new_floppy.o win_jsconf.o win_media_menu.o endif diff --git a/src/win/languages/en-US.rc b/src/win/languages/en-US.rc index e08aad513..4c7460213 100644 --- a/src/win/languages/en-US.rc +++ b/src/win/languages/en-US.rc @@ -18,14 +18,14 @@ BEGIN MENUITEM "&Keyboard requires capture", IDM_ACTION_KBD_REQ_CAPTURE MENUITEM "&Right CTRL is left ALT", IDM_ACTION_RCTRL_IS_LALT MENUITEM SEPARATOR - MENUITEM "&Hard Reset", IDM_ACTION_HRESET + MENUITEM "&Hard Reset...", IDM_ACTION_HRESET MENUITEM "&Ctrl+Alt+Del\tCtrl+F12", IDM_ACTION_RESET_CAD MENUITEM SEPARATOR MENUITEM "Ctrl+Alt+&Esc", IDM_ACTION_CTRL_ALT_ESC MENUITEM SEPARATOR MENUITEM "&Pause", IDM_ACTION_PAUSE MENUITEM SEPARATOR - MENUITEM "E&xit", IDM_ACTION_EXIT + MENUITEM "E&xit...", IDM_ACTION_EXIT END POPUP "&View" BEGIN @@ -47,7 +47,7 @@ BEGIN #endif END MENUITEM SEPARATOR - MENUITEM "Specify dimensions", IDM_VID_SPECIFY_DIM + MENUITEM "Specify dimensions...", IDM_VID_SPECIFY_DIM MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43 POPUP "&Window scale factor" BEGIN @@ -62,6 +62,7 @@ BEGIN MENUITEM "&Linear", IDM_VID_FILTER_LINEAR END MENUITEM "Hi&DPI scaling", IDM_VID_HIDPI + MENUITEM "Dis&play language...", IDM_VID_PROG_SETT MENUITEM SEPARATOR MENUITEM "&Fullscreen\tCtrl+Alt+PageUP", IDM_VID_FULLSCREEN POPUP "Fullscreen &stretch mode" @@ -268,6 +269,23 @@ END // // Dialog // + +DLG_PROG_SETT DIALOG DISCARDABLE 0, 0, 286, 86 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Change Display Language" +FONT 9, "Segoe UI" +BEGIN + DEFPUSHBUTTON "OK", IDOK, 166, 64, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 222, 64, 50, 14 + COMBOBOX IDC_COMBO_LANG, 10, 18, 266, 16, CBS_DROPDOWNLIST | CBS_HASSTRINGS +#if 0 + AUTOCHECKBOX "Use these settings as global &defaults", IDC_CHECKBOX_GLOBAL, 8, 67, 152, 8 +#endif + PUSHBUTTON "&System Language", IDC_BUTTON_SYSTEM, 120, 35, 82, 14 + PUSHBUTTON "&Default", IDC_BUTTON_DEFAULT, 206, 35, 60, 14 + LTEXT "Language:", 0, 9, 8, 34, 8 +END + DLG_STATUS DIALOG DISCARDABLE 0, 0, 186, 386 STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Status" diff --git a/src/win/languages/hu-HU.rc b/src/win/languages/hu-HU.rc index bd9e7425a..4604fcb91 100644 --- a/src/win/languages/hu-HU.rc +++ b/src/win/languages/hu-HU.rc @@ -21,14 +21,14 @@ BEGIN MENUITEM "A &billentyűzet elfogást igényel", IDM_ACTION_KBD_REQ_CAPTURE MENUITEM "A &jobb oldali CTRL a bal ALT", IDM_ACTION_RCTRL_IS_LALT MENUITEM SEPARATOR - MENUITEM "Hardveres &újraindítás", IDM_ACTION_HRESET + MENUITEM "Hardveres &újraindítás...", IDM_ACTION_HRESET MENUITEM "&Ctrl+Alt+Del\tCtrl+F12", IDM_ACTION_RESET_CAD MENUITEM SEPARATOR MENUITEM "Ctrl+Alt+&Esc", IDM_ACTION_CTRL_ALT_ESC MENUITEM SEPARATOR MENUITEM "&Szüneteltetés", IDM_ACTION_PAUSE MENUITEM SEPARATOR - MENUITEM "&Kilépés", IDM_ACTION_EXIT + MENUITEM "&Kilépés...", IDM_ACTION_EXIT END POPUP "&Nézet" BEGIN @@ -50,7 +50,7 @@ BEGIN #endif END MENUITEM SEPARATOR - MENUITEM "Méretek kézi megadása", IDM_VID_SPECIFY_DIM + MENUITEM "Méretek kézi megadása...", IDM_VID_SPECIFY_DIM MENUITEM "&Rögzített 4:3 képarány", IDM_VID_FORCE43 POPUP "&Ablak méretezési tényező" BEGIN @@ -65,6 +65,7 @@ BEGIN MENUITEM "&Lineáris", IDM_VID_FILTER_LINEAR END MENUITEM "Hi&DPI méretezés", IDM_VID_HIDPI + MENUITEM "&Nyelvi beállítások...", IDM_VID_PROG_SETT MENUITEM SEPARATOR MENUITEM "&Teljes képernyő\tCtrl+Alt+PageUP", IDM_VID_FULLSCREEN POPUP "Teljes képernyős &méretezés" @@ -271,6 +272,22 @@ END // // Dialog // +DLG_PROG_SETT DIALOG DISCARDABLE 0, 0, 286, 86 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Nyelvi beállítások" +FONT 9, "Segoe UI" +BEGIN + DEFPUSHBUTTON "OK", IDOK, 166, 64, 50, 14 + PUSHBUTTON "Mégse", IDCANCEL, 222, 64, 50, 14 + COMBOBOX IDC_COMBO_LANG, 10, 18, 266, 16, CBS_DROPDOWNLIST | CBS_HASSTRINGS +#if 0 + AUTOCHECKBOX "Ezen beállítások használata mint alapérték", IDC_CHECKBOX_GLOBAL, 8, 67, 152, 8 +#endif + PUSHBUTTON "A &rendszer nyelve", IDC_BUTTON_SYSTEM, 120, 35, 82, 14 + PUSHBUTTON "&Alapértelmezett", IDC_BUTTON_DEFAULT, 206, 35, 60, 14 + LTEXT "Nyelv:", 0, 9, 8, 34, 8 +END + DLG_STATUS DIALOG DISCARDABLE 0, 0, 186, 386 STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Status" @@ -328,25 +345,23 @@ BEGIN WS_TABSTOP END -DLG_SPECIFY_DIM DIALOG DISCARDABLE 0, 0, 175, 66 +DLG_SPECIFY_DIM DIALOG DISCARDABLE 0, 0, 203, 66 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Főablak méreteinek megadása" FONT 9, "Segoe UI" BEGIN - LTEXT "Szél.:",IDT_1709,7,9,24,12 - EDITTEXT IDC_EDIT_WIDTH,33,7,45,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Szélesség:",IDT_1709,7, 9, 34, 12 + EDITTEXT IDC_EDIT_WIDTH,44, 7, 45, 12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_WIDTHSPIN,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,76,6, - 12,12 - LTEXT "Mag.:",IDT_1710,97,9,24,12 - EDITTEXT IDC_EDIT_HEIGHT,123,7,45,12,ES_AUTOHSCROLL | ES_NUMBER + UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS, 87, 6, 10, 12 + LTEXT "Magasság:",IDT_1710,103, 8, 35, 12 + EDITTEXT IDC_EDIT_HEIGHT, 140, 7, 45, 12 ,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_HEIGHTSPIN,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,166,6, - 12,12 - CONTROL "Rögzítés erre a méretre",IDC_CHECK_LOCK_SIZE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,26,94,10 - DEFPUSHBUTTON "OK",IDOK,30,45,50,14 - PUSHBUTTON "Mégse",IDCANCEL,99,45,50,14 + UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,183, 6, 10, 12 + CONTROL "Rögzítés a megadott méretre",IDC_CHECK_LOCK_SIZE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7, 26, 123, 10 + DEFPUSHBUTTON "OK",IDOK,42, 45, 50, 14 + PUSHBUTTON "Mégse",IDCANCEL,112, 45, 50, 14 END DLG_CFG_MACHINE DIALOG DISCARDABLE 107, 0, 305, 200 @@ -371,20 +386,20 @@ BEGIN LTEXT "FPU-egység:",IDT_1707,7,66,59,10 COMBOBOX IDC_COMBO_WS,71,83,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Várakozási cikl.:",IDT_1703,7,85,60,10 + LTEXT "Várak. ciklusok:",IDT_1703,7,85,60,10 EDITTEXT IDC_MEMTEXT,70,102,45,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_MEMSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,113,101, 12,12 LTEXT "MB",IDT_1705,123,104,10,10 LTEXT "Memória:",IDT_1706,7,104,30,10 - GROUPBOX "Idő szinkronizáció",IDC_TIME_SYNC,7,135,100,56 + GROUPBOX "Idő szinkronizáció",IDC_TIME_SYNC,7,135,114,56 CONTROL "Letiltva",IDC_RADIO_TS_DISABLED,"Button", BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,147,84,10 - CONTROL "Engedély. (helyi idő)", IDC_RADIO_TS_LOCAL,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,14,161,84,10 - CONTROL "Engedély. (UTC)", IDC_RADIO_TS_UTC,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,14,175,84,10 + CONTROL "Engedélyezve (helyi idő)", IDC_RADIO_TS_LOCAL,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,14,161,102,10 + CONTROL "Engedélyezve (UTC)", IDC_RADIO_TS_UTC,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,14,175,102,10 #ifdef USE_DYNAREC CONTROL "Dinamikus újrafordítás",IDC_CHECK_DYNAREC,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,120,94,10 @@ -594,9 +609,9 @@ BEGIN EDITTEXT IDC_EDIT_HD_SIZE,42,52,28,12 COMBOBOX IDC_COMBO_HD_TYPE,113,52,98,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Szektorok:",IDT_1726,154,35,27,10 - LTEXT "Fejek:",IDT_1727,81,35,29,8 - LTEXT "Cilinderek:",IDT_1728,7,35,32,12 + LTEXT "Szektor:",IDT_1726,154,35,27,10 + LTEXT "Fej:",IDT_1727,81,35,29,8 + LTEXT "Cilinder:",IDT_1728,7,35,32,12 LTEXT "Méret (MB):",IDT_1729,7,54,33,8 LTEXT "Típus:",IDT_1730,86,54,24,8 LTEXT "Fájlnév:",IDT_1731,7,7,204,9 @@ -682,7 +697,7 @@ BEGIN LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,137,253,60 LTEXT "ZIP-meghajtók:",IDT_1759,7,127,253,8 - COMBOBOX IDC_COMBO_ZIP_BUS,33,205,90,12,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_ZIP_BUS,33, 205, 84, 14,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Busz:",IDT_1753,7,207,24,8 COMBOBOX IDC_COMBO_ZIP_ID,170,205,90,12,CBS_DROPDOWNLIST | diff --git a/src/win/win_lang.c b/src/win/win_lang.c new file mode 100644 index 000000000..8c69048ab --- /dev/null +++ b/src/win/win_lang.c @@ -0,0 +1,142 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Handle the dialog for specifying the dimensions of the main window. + * + * + * + * Authors: Laci bá' + * + * Copyright 2021 Laci bá' + */ +#define UNICODE +#define BITMAP WINDOWS_BITMAP +#include +#include +#undef BITMAP +#include +#include +#include +#include +#include +#include +#include <86box/86box.h> +#include <86box/config.h> +#include <86box/plat.h> +#include <86box/sound.h> +#include <86box/win.h> + +/* Language */ +static LCID temp_language; + +int enum_helper, c; + +BOOL CALLBACK +EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) +{ + wchar_t temp[LOCALE_NAME_MAX_LENGTH + 1]; + LCIDToLocaleName(wIDLanguage, temp, LOCALE_NAME_MAX_LENGTH, 0); + wchar_t dispname[MAX_PATH + 1]; + GetLocaleInfoEx(temp, LOCALE_SENGLISHDISPLAYNAME, dispname, MAX_PATH); + SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)dispname); + SendMessage((HWND)lParam, CB_SETITEMDATA, c, (LPARAM)wIDLanguage); + + pclog("widl: %u, langid: %u, c: %u\n", wIDLanguage, lang_id, c); + if (wIDLanguage == lang_id) + enum_helper = c; + c++; + + return 1; +} + +/* Load available languages */ +static void +progsett_fill_languages(HWND hdlg) +{ + temp_language = GetThreadUILanguage(); + 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 returns 1 if any variable has changed, 0 if not. */ +static int +progsett_settings_changed(void) +{ + int i = 0; + + /* Language */ + i = i || has_language_changed(temp_language); + + return i; +} + +/* This saves the settings back to the global variables. */ +static void +progsett_settings_save(void) +{ + /* Language */ + set_language(temp_language); +} + +#if defined(__amd64__) || defined(__aarch64__) +static LRESULT CALLBACK +#else +static BOOL CALLBACK +#endif +ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + /* Language */ + temp_language = lang_id; + pclog("temp_language is %u\n", lang_id); + progsett_fill_languages(hdlg); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + if (progsett_settings_changed()) + progsett_settings_save(); + EndDialog(hdlg, 0); + return TRUE; + + case IDCANCEL: + EndDialog(hdlg, 0); + return TRUE; + + case IDC_COMBO_LANG: + if (HIWORD(wParam) == CBN_SELCHANGE) { + HWND combo = GetDlgItem(hdlg, 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); + } + default: + break; + } + break; + } + + return(FALSE); +} + + +void +ProgSettDlgCreate(HWND hwnd) +{ + DialogBox(hinstance, (LPCTSTR)DLG_PROG_SETT, hwnd, ProgSettDlgProcedure); +} diff --git a/src/win/win_ui.c b/src/win/win_ui.c index a099489aa..57ef417a2 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -810,6 +810,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) doresize = 1; config_save(); break; + + case IDM_VID_PROG_SETT: + ProgSettDlgCreate(hwnd); + break; case IDM_VID_SPECIFY_DIM: SpecifyDimensionsDialogCreate(hwnd);