From a16e39bb629a5115168b3c18ae93efdcac4f0125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Sun, 14 Nov 2021 19:50:05 +0100 Subject: [PATCH 01/10] Initial commit for changeable icon set --- src/include/86box/win.h | 7 +- src/win/CMakeLists.txt | 2 +- src/win/Makefile.mingw | 2 +- src/win/win_icon.c | 149 ++++++++++++++++++++++++++++++++++++++++ src/win/win_settings.c | 8 +-- src/win/win_stbar.c | 42 +---------- src/win/win_ui.c | 13 +--- 7 files changed, 160 insertions(+), 63 deletions(-) create mode 100644 src/win/win_icon.c diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 33e55f1d4..f4d592756 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -107,6 +107,7 @@ extern HWND hwndMain, hwndRender; extern HANDLE ghMutex; extern HICON hIcon[256]; +extern int dpi; extern RECT oldclip; extern int sbar_height, user_resize; extern int acp_utf8; @@ -122,8 +123,6 @@ extern uint8_t filterindex; extern void ResizeWindowByClientArea(HWND hwnd, int width, int height); extern void InitCrashDump(void); -extern HICON LoadIconEx(PCTSTR pszIconName); - /* Emulator start/stop support functions. */ extern void do_start(void); extern void do_stop(void); @@ -150,6 +149,10 @@ extern int win_get_system_metrics(int i, int dpi); extern LPARAM win_get_string(int id); +extern void win_clear_icon_set(); +extern void win_system_icon_set(HINSTANCE hInst); +extern void win_load_icon_set(HINSTANCE hInst); + extern intptr_t fdd_type_to_icon(int type); #ifdef EMU_DEVICE_H diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index 727644f7b..d94485929 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -18,7 +18,7 @@ enable_language(RC) add_library(plat OBJECT win.c win_dynld.c win_cdrom.c win_thread.c win_keyboard.c win_crashdump.c win_midi.c win_mouse.c) -add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c +add_library(ui OBJECT win_ui.c win_icon.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 win_lang.c 86Box.rc) diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 8414f538f..ceb31a75a 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -423,7 +423,7 @@ ifeq ($(WX), y) LIBS += $(WX_LIBS) UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o else - UIOBJ := win_ui.o win_stbar.o \ + UIOBJ := win_ui.o win_icon.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_lang.o \ diff --git a/src/win/win_icon.c b/src/win/win_icon.c new file mode 100644 index 000000000..14ac454e6 --- /dev/null +++ b/src/win/win_icon.c @@ -0,0 +1,149 @@ +/* + * 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. + * + * Implement the application's icon changing system. + * + * + * Authors: Laci bá' + * + * Copyright 2021 Laci bá'. + */ + +#include +#include +#include +#include +#include +#include +#include +#include <86box/86box.h> +#include <86box/config.h> +#include <86box/plat.h> +#include <86box/ui.h> +#include <86box/win.h> + +HICON hIcon[256]; /* icon data loaded from resources */ +char icon_set[256] = "winbox"; /* name of the iconset to be used */ + +void win_clear_icon_set() +{ + int i; + + for (i = 0; i < 256; i++) + if (hIcon[i] != 0) + { + DestroyIcon(hIcon[i]); + hIcon[i] = 0; + } +} + +void win_system_icon_set(HINSTANCE hInst) +{ + int i, x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi); + + for (i = 0; i < 256; i++) + hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, y, LR_DEFAULTCOLOR); +} + +typedef struct +{ + int id; + char* filename; +} _ICON_DATA; + +const _ICON_DATA icon_files[] = + { + {16, "floppy_525.ico"}, + {17, "floppy_525_active.ico"}, + {24, "floppy_35.ico"}, + {25, "floppy_35_active.ico"}, + {32, "cdrom.ico"}, + {33, "cdrom_active.ico"}, + {48, "zip.ico"}, + {49, "zip_active.ico"}, + {56, "mo.ico"}, + {57, "mo_active.ico"}, + {64, "cassette.ico"}, + {65, "cassette_active.ico"}, + {80, "hard_disk.ico"}, + {81, "hard_disk_active.ico"}, + {96, "network.ico"}, + {97, "network_active.ico"}, + {104, "cartridge.ico"}, + {144, "floppy_525_empty.ico"}, + {145, "floppy_525_empty_active.ico"}, + {152, "floppy_35_empty.ico"}, + {153, "floppy_35_empty_active.ico"}, + {160, "cdrom_empty.ico"}, + {161, "cdrom_empty_active.ico"}, + {176, "zip_empty.ico"}, + {177, "zip_empty_active.ico"}, + {184, "mo_empty.ico"}, + {185, "mo_empty_active.ico"}, + {192, "cassette_empty.ico"}, + {193, "cassette_empty_active.ico"}, + {232, "cartridge_empty.ico"}, + {240, "machine.ico"}, + {241, "display.ico"}, + {242, "input_devices.ico"}, + {243, "sound.ico"}, + {244, "ports.ico"}, + {245, "other_peripherals.ico"}, + {246, "floppy_and_cdrom_drives.ico"}, + {247, "other_removable_devices.ico"}, + {248, "floppy_disabled.ico"}, + {249, "cdrom_disabled.ico"}, + {250, "zip_disabled.ico"}, + {251, "mo_disabled.ico"}, + {252, "storage_controllers.ico"} + }; + +void win_load_icon_set(HINSTANCE hInst) +{ + win_clear_icon_set(); + win_system_icon_set(hInst); + + if (strlen(icon_set) == 0) + return; + + char path_root[2048] = {0}, temp[2048] = {0}; + wchar_t wtemp[2048] = {0}; + + char roms_root[1024] = {0}; + if (rom_path[0]) + strcpy(roms_root, rom_path); + else + plat_append_filename(roms_root, exe_path, "roms"); + + plat_append_filename(path_root, roms_root, "icons"); + plat_path_slash(path_root); + strcat(path_root, icon_set); + plat_path_slash(path_root); + + int i, count = sizeof(icon_files) / sizeof(_ICON_DATA), + x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi); + for (i = 0; i < count; i++) + { + plat_append_filename(temp, path_root, icon_files[i].filename); + mbstowcs(wtemp, temp, strlen(temp) + 1); + + HICON ictemp; + ictemp = LoadImageW(NULL, (LPWSTR)wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR); + if (ictemp) + { + HICON* helper = &hIcon[icon_files[i].id]; + if (*helper) + DestroyIcon(*helper); + *helper = ictemp; + } + } + + uint32_t curr_lang = lang_id; + lang_id = 0; + set_language(curr_lang); +} \ No newline at end of file diff --git a/src/win/win_settings.c b/src/win/win_settings.c index d7fdb3816..4d253d8f7 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -76,7 +76,6 @@ static int first_cat = 0; -static int dpi = 96; /* Machine category */ static int temp_machine_type, temp_machine, temp_cpu, temp_wait_states, temp_fpu, temp_sync; @@ -265,13 +264,8 @@ image_list_init(HWND hdlg, int id, const uint8_t *icon_ids) if (icon_ids[i] == 0) break; -#if defined(__amd64__) || defined(__aarch64__) - hiconItem = LoadIcon(hinstance, (LPCWSTR) ((uint64_t) icon_ids[i])); -#else - hiconItem = LoadIcon(hinstance, (LPCWSTR) ((uint32_t) icon_ids[i])); -#endif + hiconItem = hIcon[icon_ids[i]]; ImageList_AddIcon(hSmall, hiconItem); - DestroyIcon(hiconItem); i++; } diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index b89bcafed..df82d15e5 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -71,7 +71,6 @@ static uint8_t *sb_part_icons; static int sb_parts = 0; static int sb_ready = 0; static uint8_t sb_map[256]; -static int dpi = 96; static int icon_width = 24; static wchar_t sb_text[512] = L"\0"; static wchar_t sb_bugtext[512] = L"\0"; @@ -878,46 +877,7 @@ StatusBarPopupMenu(HWND hwnd, POINT pt, int id) /* API: Load status bar icons */ void StatusBarLoadIcon(HINSTANCE hInst) { - int i; - int x = win_get_system_metrics(SM_CXSMICON, dpi); - - for (i=0; i<256; i++) { - if (hIcon[i] != 0) - DestroyIcon(hIcon[i]); - } - - for (i = 16; i < 18; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 24; i < 26; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 32; i < 34; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 48; i < 50; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 56; i < 58; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 64; i < 66; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 80; i < 82; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 96; i < 98; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - hIcon[104] = LoadImage(hInst, MAKEINTRESOURCE(104), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 144; i < 146; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 152; i < 154; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 160; i < 162; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 176; i < 178; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 184; i < 186; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 192; i < 194; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - hIcon[232] = LoadImage(hInst, MAKEINTRESOURCE(232), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); - for (i = 243; i < 244; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR); + win_load_icon_set(hInst); } /* Handle messages for the Status Bar window. */ diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 57ef417a2..ca089eabd 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -59,7 +59,6 @@ HWND hwndMain, /* application main window */ hwndRender; /* machine render window */ HMENU menuMain; /* application main menu */ -HICON hIcon[256]; /* icon data loaded from resources */ RECT oldclip; /* mouse rect */ int sbar_height = 23; /* statusbar height */ int minimized = 0; @@ -78,7 +77,7 @@ extern WCHAR wopenfilestring[512]; static wchar_t wTitle[512]; static int manager_wm = 0; static int save_window_pos = 0, pause_state = 0; -static int dpi = 96; +int dpi = 96; static int padded_frame = 0; static int vis = -1; @@ -153,15 +152,6 @@ show_cursor(int val) vis = val; } - -HICON -LoadIconEx(PCTSTR pszIconName) -{ - return((HICON)LoadImage(hinstance, pszIconName, IMAGE_ICON, - 16, 16, LR_SHARED)); -} - - static void video_toggle_option(HMENU h, int *val, int id) { @@ -1074,6 +1064,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: + win_clear_icon_set(); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); break; From 0aa6e9c8a64e8b65f546ed89673f538b4d303386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Tue, 16 Nov 2021 19:38:31 +0100 Subject: [PATCH 02/10] Finish the changeable iconset --- src/86box.c | 3 + src/config.c | 11 +++ src/include/86box/86box.h | 1 + src/include/86box/plat.h | 5 ++ src/include/86box/resource.h | 2 + src/include/86box/win.h | 4 -- src/unix/unix.c | 25 +++++++ src/win/languages/cs-CZ.rc | 1 + src/win/languages/de-DE.rc | 1 + src/win/languages/dialogs.rc | 14 ++-- src/win/languages/en-US.rc | 1 + src/win/languages/hr-HR.rc | 1 + src/win/languages/hu-HU.rc | 1 + src/win/languages/it-IT.rc | 1 + src/win/languages/pt-BR.rc | 1 + src/win/languages/pt-PT.rc | 1 + src/win/win_icon.c | 33 +++++---- src/win/win_lang.c | 125 +++++++++++++++++++++++++++++++++++ src/win/win_stbar.c | 2 +- src/win/win_ui.c | 2 +- 20 files changed, 210 insertions(+), 25 deletions(-) diff --git a/src/86box.c b/src/86box.c index 8f9338920..964e885bc 100644 --- a/src/86box.c +++ b/src/86box.c @@ -715,6 +715,9 @@ usage: if (lang_init) set_language(lang_init); + /* Load the desired iconset */ + plat_load_icon_set(); + /* All good! */ return(1); } diff --git a/src/config.c b/src/config.c index 57bdf5508..e302b0b48 100644 --- a/src/config.c +++ b/src/config.c @@ -573,6 +573,12 @@ load_general(void) lang_id = plat_language_code(p); } + p = config_get_string(cat, "iconset", NULL); + if (p != NULL) + strcpy(icon_set, p); + else + strcpy(icon_set, ""); + #if USE_DISCORD enable_discord = !!config_get_int(cat, "enable_discord", 0); #endif @@ -2230,6 +2236,11 @@ save_general(void) plat_language_code_r(lang_id, buffer, 511); config_set_string(cat, "language", buffer); } + + if (!strcmp(icon_set, "")) + config_delete_var(cat, "iconset"); + else + config_set_string(cat, "iconset", icon_set); #if USE_DISCORD if (enable_discord) diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index c27f1d93e..f56757f38 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -97,6 +97,7 @@ extern int window_w, window_h, /* (C) window size and */ invert_display, /* (C) invert the display */ suppress_overscan; /* (C) suppress overscans */ extern uint32_t lang_id; /* (C) language code identifier */ +extern char icon_set[256]; /* (C) iconset identifier */ extern int scale; /* (C) screen scale factor */ extern int dpi_scale; /* (C) DPI scaling of the emulated screen */ extern int vid_api; /* (C) video renderer */ diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index ca116a684..8d0d4c4ef 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -125,6 +125,11 @@ extern void plat_vid_reload_options(void); extern uint32_t plat_language_code(char* langcode); extern void plat_language_code_r(uint32_t lcid, char* outbuf, int len); +extern void plat_clear_icon_set(); +extern void plat_system_icon_set(); +extern void plat_load_icon_set(); +extern void plat_get_icons_path(char* path_root); + /* Resource management. */ extern void set_language(uint32_t id); extern wchar_t *plat_get_string(int id); diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 2a13b01f1..d05409e0d 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -265,8 +265,10 @@ #define IDC_COMBO_RPM_MODE 1202 #define IDC_COMBO_LANG 1009 /* change language dialog */ +#define IDC_COMBO_ICON 1010 #define IDC_CHECKBOX_GLOBAL 1300 #define IDC_BUTTON_DEFAULT 1302 +#define IDC_BUTTON_DEFICON 1304 /* For the DeviceConfig code, re-do later. */ #define IDC_CONFIG_BASE 1300 diff --git a/src/include/86box/win.h b/src/include/86box/win.h index f4d592756..3a287a11b 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -149,10 +149,6 @@ extern int win_get_system_metrics(int i, int dpi); extern LPARAM win_get_string(int id); -extern void win_clear_icon_set(); -extern void win_system_icon_set(HINSTANCE hInst); -extern void win_load_icon_set(HINSTANCE hInst); - extern intptr_t fdd_type_to_icon(int type); #ifdef EMU_DEVICE_H diff --git a/src/unix/unix.c b/src/unix/unix.c index ae786f8ad..0c4696d56 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -51,6 +51,7 @@ SDL_threadID eventthread; static int exit_event = 0; static int fullscreen_pending = 0; uint32_t lang_id = 0x0409, lang_sys = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US +char icon_set[256] = ""; /* name of the iconset to be used */ static const uint16_t sdl_to_xt[0x200] = { @@ -1244,6 +1245,30 @@ plat_language_code_r(uint32_t lcid, char* outbuf, int len) return; } +void +plat_clear_icon_set() +{ + return; +} + +void +plat_system_icon_set() +{ + return; +} + +void +plat_load_icon_set() +{ + return; +} + +void +plat_get_icons_path(char* path_root) +{ + return; +} + void joystick_init(void) {} void joystick_close(void) {} diff --git a/src/win/languages/cs-CZ.rc b/src/win/languages/cs-CZ.rc index 24f41ba6a..60a234827 100644 --- a/src/win/languages/cs-CZ.rc +++ b/src/win/languages/cs-CZ.rc @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Uložit toto nastavení jako &globální výchozí stav" #define STR_DEFAULT "&Výchozí" #define STR_LANGUAGE "Jazyk:" +#define STR_ICONSET "Sada ikon:" #define STR_GAIN "Zesílení" diff --git a/src/win/languages/de-DE.rc b/src/win/languages/de-DE.rc index ef737c2e3..3e50191a6 100644 --- a/src/win/languages/de-DE.rc +++ b/src/win/languages/de-DE.rc @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Einstellungen als &globalen Standard speichern" #define STR_DEFAULT "&Standard" #define STR_LANGUAGE "Sprache:" +#define STR_ICONSET "Ikonensatz:" #define STR_GAIN "Verstärkung" diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index 6645c462d..9862a5080 100644 --- a/src/win/languages/dialogs.rc +++ b/src/win/languages/dialogs.rc @@ -1,14 +1,17 @@ -DLG_PROG_SETT DIALOG DISCARDABLE 0, 0, 240, 86 +DLG_PROG_SETT DIALOG DISCARDABLE 0, 0, 240, 118 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION STR_PROG_SETT FONT 9, "Segoe UI" BEGIN - DEFPUSHBUTTON STR_OK, IDOK, 123, 65, 50, 14 - PUSHBUTTON STR_CANCEL, IDCANCEL, 179, 65, 50, 14 + DEFPUSHBUTTON STR_OK, IDOK, 123, 97, 50, 14 + PUSHBUTTON STR_CANCEL, IDCANCEL, 179, 97, 50, 14 COMBOBOX IDC_COMBO_LANG, 13, 18, 213, 22, CBS_DROPDOWNLIST | CBS_HASSTRINGS - AUTOCHECKBOX STR_GLOBAL, IDC_CHECKBOX_GLOBAL, 13, 50, 217, 8 , WS_DISABLED PUSHBUTTON STR_DEFAULT, IDC_BUTTON_DEFAULT, 162, 32, 60, 14 - LTEXT STR_LANGUAGE, 0, 13, 8, 34, 8 + COMBOBOX IDC_COMBO_ICON, 13, 50, 213, 22, CBS_DROPDOWNLIST | CBS_HASSTRINGS + PUSHBUTTON STR_DEFAULT, IDC_BUTTON_DEFICON, 162, 64, 60, 14 + AUTOCHECKBOX STR_GLOBAL, IDC_CHECKBOX_GLOBAL, 13, 82, 217, 8 , WS_DISABLED + LTEXT STR_LANGUAGE, 0, 13, 8, 100, 8 + LTEXT STR_ICONSET, 0, 13, 40, 100, 8 END DLG_SND_GAIN DIALOG DISCARDABLE 0, 0, 113, 136 @@ -468,6 +471,7 @@ END #undef STR_GLOBAL #undef STR_DEFAULT #undef STR_LANGUAGE +#undef STR_ICONSET #undef STR_GAIN diff --git a/src/win/languages/en-US.rc b/src/win/languages/en-US.rc index 443d0debc..2b3ad1e94 100644 --- a/src/win/languages/en-US.rc +++ b/src/win/languages/en-US.rc @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Save these settings as &global defaults" #define STR_DEFAULT "&Default" #define STR_LANGUAGE "Language:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Gain" diff --git a/src/win/languages/hr-HR.rc b/src/win/languages/hr-HR.rc index e71a3b10b..699c353e8 100644 --- a/src/win/languages/hr-HR.rc +++ b/src/win/languages/hr-HR.rc @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Spremite ove postavke kao &globalne zadane postavke" #define STR_DEFAULT "&Standard" #define STR_LANGUAGE "Jezik:" +#define STR_ICONSET "Skup ikona:" #define STR_GAIN "Pojačavanje" diff --git a/src/win/languages/hu-HU.rc b/src/win/languages/hu-HU.rc index fdda601a6..569f3b616 100644 --- a/src/win/languages/hu-HU.rc +++ b/src/win/languages/hu-HU.rc @@ -287,6 +287,7 @@ END #define STR_GLOBAL "Beállítások mentése &globális alapértékként" #define STR_DEFAULT "&Alapértelmezett" #define STR_LANGUAGE "Nyelv:" +#define STR_ICONSET "Ikonkészlet:" #define STR_GAIN "Hangerő" diff --git a/src/win/languages/it-IT.rc b/src/win/languages/it-IT.rc index b988a40c5..8feaeccf7 100644 --- a/src/win/languages/it-IT.rc +++ b/src/win/languages/it-IT.rc @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Salva queste impostazioni come &predefinite globali" #define STR_DEFAULT "&Predefinito" #define STR_LANGUAGE "Lingua:" +#define STR_ICONSET "Set di Icone:" #define STR_GAIN "Guadagno" diff --git a/src/win/languages/pt-BR.rc b/src/win/languages/pt-BR.rc index 4e6b97981..a9024321b 100644 --- a/src/win/languages/pt-BR.rc +++ b/src/win/languages/pt-BR.rc @@ -285,6 +285,7 @@ END #define STR_GLOBAL "Usar estas configurações como &padrões globais" #define STR_DEFAULT "&Padrão" #define STR_LANGUAGE "Idioma:" +#define STR_ICONSET "Conjunto de ícones:" #define STR_GAIN "Ganho" diff --git a/src/win/languages/pt-PT.rc b/src/win/languages/pt-PT.rc index 8efc1aa29..aaeed8dc5 100644 --- a/src/win/languages/pt-PT.rc +++ b/src/win/languages/pt-PT.rc @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Guardar estas definições como padrões &globais" #define STR_DEFAULT "&Padrão" #define STR_LANGUAGE "Idioma:" +#define STR_ICONSET "Conjunto de ícones:" #define STR_GAIN "Ganho" diff --git a/src/win/win_icon.c b/src/win/win_icon.c index 14ac454e6..345d028af 100644 --- a/src/win/win_icon.c +++ b/src/win/win_icon.c @@ -28,9 +28,9 @@ #include <86box/win.h> HICON hIcon[256]; /* icon data loaded from resources */ -char icon_set[256] = "winbox"; /* name of the iconset to be used */ +char icon_set[256] = ""; /* name of the iconset to be used */ -void win_clear_icon_set() +void plat_clear_icon_set() { int i; @@ -42,12 +42,12 @@ void win_clear_icon_set() } } -void win_system_icon_set(HINSTANCE hInst) +void plat_system_icon_set() { int i, x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi); for (i = 0; i < 256; i++) - hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, y, LR_DEFAULTCOLOR); + hIcon[i] = LoadImage(hinstance, MAKEINTRESOURCE(i), IMAGE_ICON, x, y, LR_DEFAULTCOLOR); } typedef struct @@ -103,17 +103,8 @@ const _ICON_DATA icon_files[] = {252, "storage_controllers.ico"} }; -void win_load_icon_set(HINSTANCE hInst) +void plat_get_icons_path(char* path_root) { - win_clear_icon_set(); - win_system_icon_set(hInst); - - if (strlen(icon_set) == 0) - return; - - char path_root[2048] = {0}, temp[2048] = {0}; - wchar_t wtemp[2048] = {0}; - char roms_root[1024] = {0}; if (rom_path[0]) strcpy(roms_root, rom_path); @@ -122,6 +113,20 @@ void win_load_icon_set(HINSTANCE hInst) plat_append_filename(path_root, roms_root, "icons"); plat_path_slash(path_root); +} + +void plat_load_icon_set() +{ + plat_clear_icon_set(); + plat_system_icon_set(); + + if (strlen(icon_set) == 0) + return; + + char path_root[2048] = {0}, temp[2048] = {0}; + wchar_t wtemp[2048] = {0}; + + plat_get_icons_path(path_root); strcat(path_root, icon_set); plat_path_slash(path_root); diff --git a/src/win/win_lang.c b/src/win/win_lang.c index 5f79e8c61..f67c6144f 100644 --- a/src/win/win_lang.c +++ b/src/win/win_lang.c @@ -36,6 +36,8 @@ /* Language */ static LCID temp_language; +static char temp_icon_set[256] = {0}; + int enum_helper, c; HWND hwndProgSett; @@ -76,6 +78,86 @@ progsett_fill_languages(HWND hdlg) SendMessage(lang_combo, CB_SETCURSEL, enum_helper, 0); } +/* Load available iconsets */ +static void +progsett_fill_iconsets(HWND hdlg) +{ + HWND icon_combo = GetDlgItem(hdlg, IDC_COMBO_ICON); + + /* Add the default one */ + wchar_t buffer[512] = L"("; + wcscat(buffer, plat_get_string(IDS_2090)); + wcscat(buffer, L")"); + + SendMessage(icon_combo, CB_RESETCONTENT, 0, 0); + SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM)buffer); + SendMessage(icon_combo, CB_SETITEMDATA, 0, (LPARAM)strdup("")); + + int combo_index = -1; + + /* Find for extra ones */ + HANDLE hFind; + WIN32_FIND_DATA data; + + char icon_path_root[512]; + plat_get_icons_path(icon_path_root); + + wchar_t search[512]; + pclog("icon_path_root: %s\n", icon_path_root); + mbstowcs(search, icon_path_root, strlen(icon_path_root) + 1); + wcscat(search, L"*.*"); + pclog("search: %ls\n", search); + + hFind = FindFirstFile((LPCWSTR)search, &data); + + if (hFind != INVALID_HANDLE_VALUE) { + do { + if (wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..") && + (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + wchar_t temp[512] = {0}, dispname[512] = {0}; + mbstowcs(temp, icon_path_root, strlen(icon_path_root) + 1); + wcscat(temp, data.cFileName); + wcscat(temp, L"\\iconinfo.txt"); + + pclog("temp: %ls\n", temp); + + wcscpy(dispname, data.cFileName); + FILE *fp = _wfopen(temp, L"r"); + if (fp) + { + char line[512]; + if (fgets(line, 511, fp)) + { + pclog("found! %s\n", line); + mbstowcs(dispname, line, strlen(line) + 1); + } + + fclose(fp); + } + + char filename[512]; + wcstombs(filename, data.cFileName, 511); + + int index = SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM)dispname); + SendMessage(icon_combo, CB_SETITEMDATA, index, (LPARAM)(strdup(filename))); + + if (!strcmp(filename, icon_set)) + combo_index = index; + } + } while (FindNextFile(hFind, &data)); + FindClose(hFind); + } + + if (combo_index == -1) + { + combo_index = 0; + strcpy(temp_icon_set, ""); + } + + SendMessage(icon_combo, CB_SETCURSEL, combo_index, 0); +} + /* This returns 1 if any variable has changed, 0 if not. */ static int progsett_settings_changed(void) @@ -84,6 +166,7 @@ progsett_settings_changed(void) /* Language */ i = i || has_language_changed(temp_language); + i = i || strcmp(temp_icon_set, icon_set); return i; } @@ -107,6 +190,10 @@ progsett_settings_save(void) /* Language */ set_language(temp_language); + /* Iconset */ + strcpy(icon_set, temp_icon_set); + plat_load_icon_set(hinstance); + /* Update title bar */ update_mouse_msg(); @@ -131,7 +218,10 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) hwndProgSett = hdlg; /* Language */ temp_language = lang_id; + strcpy(temp_icon_set, icon_set); + pclog("temp_icon_set: %s\n", temp_icon_set); progsett_fill_languages(hdlg); + progsett_fill_iconsets(hdlg); break; case WM_COMMAND: @@ -154,6 +244,16 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } break; + case IDC_COMBO_ICON: + if (HIWORD(wParam) == CBN_SELCHANGE) { + pclog("dosth\n"); + HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON); + int index = SendMessage(combo, CB_GETCURSEL, 0, 0); + strcpy(temp_icon_set, (char*)SendMessage(combo, CB_GETITEMDATA, index, 0)); + pclog("temp_icon_set: %s\n", temp_icon_set); + } + break; + case IDC_BUTTON_DEFAULT: { HWND combo = GetDlgItem(hdlg, IDC_COMBO_LANG); int index = progsett_indexof(combo, DEFAULT_LANGUAGE); @@ -161,10 +261,35 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) temp_language = DEFAULT_LANGUAGE; break; } + + case IDC_BUTTON_DEFICON: { + pclog("dosth\n"); + SendMessage(GetDlgItem(hdlg, IDC_COMBO_ICON), CB_SETCURSEL, 0, 0); + strcpy(temp_icon_set, ""); + pclog("temp_icon_set: %s\n", temp_icon_set); + break; + } default: break; } break; + + case WM_DESTROY: { + int i; + LRESULT temp; + HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON); + for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) + { + temp = SendMessage(combo, CB_GETITEMDATA, i, 0); + if (temp) + { + free((void*)temp); + SendMessage(combo, CB_SETITEMDATA, i, 0); + } + } + } + break; + } return(FALSE); diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index df82d15e5..d8e079e14 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -877,7 +877,7 @@ StatusBarPopupMenu(HWND hwnd, POINT pt, int id) /* API: Load status bar icons */ void StatusBarLoadIcon(HINSTANCE hInst) { - win_load_icon_set(hInst); + plat_load_icon_set(hInst); } /* Handle messages for the Status Bar window. */ diff --git a/src/win/win_ui.c b/src/win/win_ui.c index ca089eabd..84bde8e64 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -1064,7 +1064,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: - win_clear_icon_set(); + plat_clear_icon_set(); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); break; From 05f4596f49d5030693090a0a8310a5238b87e94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Tue, 16 Nov 2021 19:39:48 +0100 Subject: [PATCH 03/10] Final cleanup --- src/win/win_lang.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/win/win_lang.c b/src/win/win_lang.c index f67c6144f..fb2bc46b5 100644 --- a/src/win/win_lang.c +++ b/src/win/win_lang.c @@ -103,10 +103,8 @@ progsett_fill_iconsets(HWND hdlg) plat_get_icons_path(icon_path_root); wchar_t search[512]; - pclog("icon_path_root: %s\n", icon_path_root); mbstowcs(search, icon_path_root, strlen(icon_path_root) + 1); wcscat(search, L"*.*"); - pclog("search: %ls\n", search); hFind = FindFirstFile((LPCWSTR)search, &data); @@ -119,9 +117,7 @@ progsett_fill_iconsets(HWND hdlg) mbstowcs(temp, icon_path_root, strlen(icon_path_root) + 1); wcscat(temp, data.cFileName); wcscat(temp, L"\\iconinfo.txt"); - - pclog("temp: %ls\n", temp); - + wcscpy(dispname, data.cFileName); FILE *fp = _wfopen(temp, L"r"); if (fp) @@ -129,7 +125,6 @@ progsett_fill_iconsets(HWND hdlg) char line[512]; if (fgets(line, 511, fp)) { - pclog("found! %s\n", line); mbstowcs(dispname, line, strlen(line) + 1); } @@ -219,7 +214,6 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) /* Language */ temp_language = lang_id; strcpy(temp_icon_set, icon_set); - pclog("temp_icon_set: %s\n", temp_icon_set); progsett_fill_languages(hdlg); progsett_fill_iconsets(hdlg); break; @@ -246,11 +240,9 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_COMBO_ICON: if (HIWORD(wParam) == CBN_SELCHANGE) { - pclog("dosth\n"); HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON); int index = SendMessage(combo, CB_GETCURSEL, 0, 0); strcpy(temp_icon_set, (char*)SendMessage(combo, CB_GETITEMDATA, index, 0)); - pclog("temp_icon_set: %s\n", temp_icon_set); } break; @@ -263,10 +255,8 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } case IDC_BUTTON_DEFICON: { - pclog("dosth\n"); SendMessage(GetDlgItem(hdlg, IDC_COMBO_ICON), CB_SETCURSEL, 0, 0); strcpy(temp_icon_set, ""); - pclog("temp_icon_set: %s\n", temp_icon_set); break; } default: From 7853f9f9225b10e67362f83f86d7c5f2a487c40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Tue, 16 Nov 2021 22:02:17 +0100 Subject: [PATCH 04/10] Small safety fix --- src/win/win_lang.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/win_lang.c b/src/win/win_lang.c index fb2bc46b5..229c81cb2 100644 --- a/src/win/win_lang.c +++ b/src/win/win_lang.c @@ -122,7 +122,7 @@ progsett_fill_iconsets(HWND hdlg) FILE *fp = _wfopen(temp, L"r"); if (fp) { - char line[512]; + char line[512] = {0}; if (fgets(line, 511, fp)) { mbstowcs(dispname, line, strlen(line) + 1); From 03a72476300ef46604b726d9567f84eecb21694f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Wed, 17 Nov 2021 19:02:19 +0100 Subject: [PATCH 05/10] Apply requested changes - Remove icon functions from plat.h. - Fix some indentation problems. - Remove unused parameter from win_stbar.c - Rename win_lang.c to win_progsett.c - Remove stub functions from unix.c - Move win_load_icon_set() to ui_init() - Replace the translated texts to English, and let the translators translate them - Fix the control IDs in dialogs.rc. - Use the requested solution in win_icon.c for setting the array variables. --- src/86box.c | 3 --- src/include/86box/plat.h | 5 ----- src/include/86box/win.h | 7 ++++++- src/unix/unix.c | 25 ------------------------- src/win/CMakeLists.txt | 2 +- src/win/Makefile.mingw | 2 +- src/win/languages/cs-CZ.rc | 6 +++--- src/win/languages/de-DE.rc | 6 +++--- src/win/languages/dialogs.rc | 4 ++-- src/win/languages/en-US.rc | 6 +++--- src/win/languages/hr-HR.rc | 6 +++--- src/win/languages/hu-HU.rc | 6 +++--- src/win/languages/it-IT.rc | 6 +++--- src/win/languages/pt-BR.rc | 6 +++--- src/win/languages/pt-PT.rc | 6 +++--- src/win/win_icon.c | 21 ++++++++++----------- src/win/{win_lang.c => win_progsett.c} | 7 +++---- src/win/win_stbar.c | 2 +- src/win/win_ui.c | 7 +++++-- 19 files changed, 53 insertions(+), 80 deletions(-) rename src/win/{win_lang.c => win_progsett.c} (97%) diff --git a/src/86box.c b/src/86box.c index 964e885bc..8f9338920 100644 --- a/src/86box.c +++ b/src/86box.c @@ -715,9 +715,6 @@ usage: if (lang_init) set_language(lang_init); - /* Load the desired iconset */ - plat_load_icon_set(); - /* All good! */ return(1); } diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 8d0d4c4ef..ca116a684 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -125,11 +125,6 @@ extern void plat_vid_reload_options(void); extern uint32_t plat_language_code(char* langcode); extern void plat_language_code_r(uint32_t lcid, char* outbuf, int len); -extern void plat_clear_icon_set(); -extern void plat_system_icon_set(); -extern void plat_load_icon_set(); -extern void plat_get_icons_path(char* path_root); - /* Resource management. */ extern void set_language(uint32_t id); extern wchar_t *plat_get_string(int id); diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 3a287a11b..9eef0067d 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -107,7 +107,7 @@ extern HWND hwndMain, hwndRender; extern HANDLE ghMutex; extern HICON hIcon[256]; -extern int dpi; +extern int dpi; extern RECT oldclip; extern int sbar_height, user_resize; extern int acp_utf8; @@ -149,6 +149,11 @@ extern int win_get_system_metrics(int i, int dpi); extern LPARAM win_get_string(int id); +extern void win_clear_icon_set(); +extern void win_system_icon_set(); +extern void win_load_icon_set(); +extern void win_get_icons_path(char* path_root); + extern intptr_t fdd_type_to_icon(int type); #ifdef EMU_DEVICE_H diff --git a/src/unix/unix.c b/src/unix/unix.c index 0c4696d56..684fad935 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -1245,31 +1245,6 @@ plat_language_code_r(uint32_t lcid, char* outbuf, int len) return; } -void -plat_clear_icon_set() -{ - return; -} - -void -plat_system_icon_set() -{ - return; -} - -void -plat_load_icon_set() -{ - return; -} - -void -plat_get_icons_path(char* path_root) -{ - return; -} - - void joystick_init(void) {} void joystick_close(void) {} void joystick_process(void) {} diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index d94485929..5b44eeb45 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_icon.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 win_lang.c 86Box.rc) + win_jsconf.c win_media_menu.c win_progsett.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 c80cf694e..d678e2699 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -408,7 +408,7 @@ else UIOBJ := win_ui.o win_icon.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_lang.o \ + win_settings.o win_devconf.o win_snd_gain.o win_specify_dim.o win_progsett.o \ win_new_floppy.o win_jsconf.o win_media_menu.o endif diff --git a/src/win/languages/cs-CZ.rc b/src/win/languages/cs-CZ.rc index 60a234827..8aa608389 100644 --- a/src/win/languages/cs-CZ.rc +++ b/src/win/languages/cs-CZ.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Nastavení...", IDM_CONFIG MENUITEM "&Aktualizovat ikony stavového řádku", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "&Změnit jazyk zobrazení...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Povolit integraci s &Discordem", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Změnit jazyk zobrazení" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Zesílení zvuku" #define STR_NEW_FLOPPY "Nový obraz" #define STR_CONFIG "Nastavení emulátoru 86Box" @@ -284,7 +284,7 @@ END #define STR_GLOBAL "Uložit toto nastavení jako &globální výchozí stav" #define STR_DEFAULT "&Výchozí" #define STR_LANGUAGE "Jazyk:" -#define STR_ICONSET "Sada ikon:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Zesílení" diff --git a/src/win/languages/de-DE.rc b/src/win/languages/de-DE.rc index 3e50191a6..8df5bd68a 100644 --- a/src/win/languages/de-DE.rc +++ b/src/win/languages/de-DE.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Einstellungen...", IDM_CONFIG MENUITEM "&Statusleistenicons aktualisieren", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "&Anzeigesprache ändern...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "&Discord-Integration aktivieren", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Anzeigesprache ändern" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Klangverstärkung" #define STR_NEW_FLOPPY "Neues Image" #define STR_CONFIG "86Box-Einstellungen" @@ -284,7 +284,7 @@ END #define STR_GLOBAL "Einstellungen als &globalen Standard speichern" #define STR_DEFAULT "&Standard" #define STR_LANGUAGE "Sprache:" -#define STR_ICONSET "Ikonensatz:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Verstärkung" diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index 9862a5080..ce3a04b99 100644 --- a/src/win/languages/dialogs.rc +++ b/src/win/languages/dialogs.rc @@ -10,8 +10,8 @@ BEGIN COMBOBOX IDC_COMBO_ICON, 13, 50, 213, 22, CBS_DROPDOWNLIST | CBS_HASSTRINGS PUSHBUTTON STR_DEFAULT, IDC_BUTTON_DEFICON, 162, 64, 60, 14 AUTOCHECKBOX STR_GLOBAL, IDC_CHECKBOX_GLOBAL, 13, 82, 217, 8 , WS_DISABLED - LTEXT STR_LANGUAGE, 0, 13, 8, 100, 8 - LTEXT STR_ICONSET, 0, 13, 40, 100, 8 + LTEXT STR_LANGUAGE, 1001, 13, 8, 100, 8 + LTEXT STR_ICONSET, 1002, 13, 40, 100, 8 END DLG_SND_GAIN DIALOG DISCARDABLE 0, 0, 113, 136 diff --git a/src/win/languages/en-US.rc b/src/win/languages/en-US.rc index 2b3ad1e94..c3baf5f0e 100644 --- a/src/win/languages/en-US.rc +++ b/src/win/languages/en-US.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Settings...", IDM_CONFIG MENUITEM "&Update status bar icons", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "Change dis&play language...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Enable &Discord integration", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Change Display Language" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Sound Gain" #define STR_NEW_FLOPPY "New Image" #define STR_CONFIG "86Box Settings" @@ -284,7 +284,7 @@ END #define STR_GLOBAL "Save these settings as &global defaults" #define STR_DEFAULT "&Default" #define STR_LANGUAGE "Language:" -#define STR_ICONSET "Iconset:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Gain" diff --git a/src/win/languages/hr-HR.rc b/src/win/languages/hr-HR.rc index 699c353e8..87a38b29b 100644 --- a/src/win/languages/hr-HR.rc +++ b/src/win/languages/hr-HR.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Postavke...", IDM_CONFIG MENUITEM "&Ažuriranje ikone statusne trake", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "&Promijeni jezik prikaza...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Omogući integraciju &Discord-a", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Promjena jezika prikaza" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Pojačavanje zvuka" #define STR_NEW_FLOPPY "Nova image daoteka" #define STR_CONFIG "86Box postavke" @@ -284,7 +284,7 @@ END #define STR_GLOBAL "Spremite ove postavke kao &globalne zadane postavke" #define STR_DEFAULT "&Standard" #define STR_LANGUAGE "Jezik:" -#define STR_ICONSET "Skup ikona:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Pojačavanje" diff --git a/src/win/languages/hu-HU.rc b/src/win/languages/hu-HU.rc index 569f3b616..0841c4dac 100644 --- a/src/win/languages/hu-HU.rc +++ b/src/win/languages/hu-HU.rc @@ -104,7 +104,7 @@ BEGIN MENUITEM "&Beállítások...", IDM_CONFIG MENUITEM "Állapotsori ikonok &frissítése", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "A &program nyelvének módosítása...", IDM_VID_PROG_SETT + MENUITEM "Program&beállítások...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "&Discord integráció engedélyezése", IDM_DISCORD @@ -276,7 +276,7 @@ END // Dialog // -#define STR_PROG_SETT "Nyelvi beállítások" +#define STR_PROG_SETT "Programbeállítások" #define STR_SND_GAIN "Hangerőszabályzó" #define STR_NEW_FLOPPY "Új képfájl létrehozása" #define STR_CONFIG "86Box beállítások" @@ -287,7 +287,7 @@ END #define STR_GLOBAL "Beállítások mentése &globális alapértékként" #define STR_DEFAULT "&Alapértelmezett" #define STR_LANGUAGE "Nyelv:" -#define STR_ICONSET "Ikonkészlet:" +#define STR_ICONSET "Ikonkészlet:" #define STR_GAIN "Hangerő" diff --git a/src/win/languages/it-IT.rc b/src/win/languages/it-IT.rc index 8feaeccf7..7e067dd9c 100644 --- a/src/win/languages/it-IT.rc +++ b/src/win/languages/it-IT.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Impostazioni...", IDM_CONFIG MENUITEM "&Aggiorna icone della barra di stato", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "Cambia li&ngua...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Abilita &integrazione Discord", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Cambia lingua dell'interfaccia" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Guadagno del suono" #define STR_NEW_FLOPPY "Nuova immagine" #define STR_CONFIG "Impostazioni di 86Box" @@ -284,7 +284,7 @@ END #define STR_GLOBAL "Salva queste impostazioni come &predefinite globali" #define STR_DEFAULT "&Predefinito" #define STR_LANGUAGE "Lingua:" -#define STR_ICONSET "Set di Icone:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Guadagno" diff --git a/src/win/languages/pt-BR.rc b/src/win/languages/pt-BR.rc index a9024321b..6066f093d 100644 --- a/src/win/languages/pt-BR.rc +++ b/src/win/languages/pt-BR.rc @@ -102,7 +102,7 @@ BEGIN MENUITEM "&Configurações...", IDM_CONFIG MENUITEM "&Atualizar ícones da barra de status", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "Alterar o &idioma de exibição...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Ativar integração com o &Discord", IDM_DISCORD @@ -274,7 +274,7 @@ END // Dialog // -#define STR_PROG_SETT "Alterar idioma de exibição" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Ganho de som" #define STR_NEW_FLOPPY "Nova imagem de disquete" #define STR_CONFIG "Configurações do 86Box" @@ -285,7 +285,7 @@ END #define STR_GLOBAL "Usar estas configurações como &padrões globais" #define STR_DEFAULT "&Padrão" #define STR_LANGUAGE "Idioma:" -#define STR_ICONSET "Conjunto de ícones:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Ganho" diff --git a/src/win/languages/pt-PT.rc b/src/win/languages/pt-PT.rc index aaeed8dc5..97afaa543 100644 --- a/src/win/languages/pt-PT.rc +++ b/src/win/languages/pt-PT.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Definições...", IDM_CONFIG MENUITEM "&Atualizar ícones da barra de estado", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "Mudar idioma de a&presentação...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Ativar integração com &Discord", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Mudar idioma de apresentação" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Ganho de som" #define STR_NEW_FLOPPY "Nova imagem" #define STR_CONFIG "Definições do 86Box" @@ -284,7 +284,7 @@ END #define STR_GLOBAL "Guardar estas definições como padrões &globais" #define STR_DEFAULT "&Padrão" #define STR_LANGUAGE "Idioma:" -#define STR_ICONSET "Conjunto de ícones:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Ganho" diff --git a/src/win/win_icon.c b/src/win/win_icon.c index 345d028af..e5e4cdc67 100644 --- a/src/win/win_icon.c +++ b/src/win/win_icon.c @@ -30,7 +30,7 @@ HICON hIcon[256]; /* icon data loaded from resources */ char icon_set[256] = ""; /* name of the iconset to be used */ -void plat_clear_icon_set() +void win_clear_icon_set() { int i; @@ -42,7 +42,7 @@ void plat_clear_icon_set() } } -void plat_system_icon_set() +void win_system_icon_set() { int i, x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi); @@ -103,7 +103,7 @@ const _ICON_DATA icon_files[] = {252, "storage_controllers.ico"} }; -void plat_get_icons_path(char* path_root) +void win_get_icons_path(char* path_root) { char roms_root[1024] = {0}; if (rom_path[0]) @@ -115,10 +115,10 @@ void plat_get_icons_path(char* path_root) plat_path_slash(path_root); } -void plat_load_icon_set() +void win_load_icon_set() { - plat_clear_icon_set(); - plat_system_icon_set(); + win_clear_icon_set(); + win_system_icon_set(); if (strlen(icon_set) == 0) return; @@ -126,7 +126,7 @@ void plat_load_icon_set() char path_root[2048] = {0}, temp[2048] = {0}; wchar_t wtemp[2048] = {0}; - plat_get_icons_path(path_root); + win_get_icons_path(path_root); strcat(path_root, icon_set); plat_path_slash(path_root); @@ -141,10 +141,9 @@ void plat_load_icon_set() ictemp = LoadImageW(NULL, (LPWSTR)wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR); if (ictemp) { - HICON* helper = &hIcon[icon_files[i].id]; - if (*helper) - DestroyIcon(*helper); - *helper = ictemp; + if (hIcon[icon_files[i].id]) + DestroyIcon(hIcon[icon_files[i].id]); + hIcon[icon_files[i].id] = ictemp; } } diff --git a/src/win/win_lang.c b/src/win/win_progsett.c similarity index 97% rename from src/win/win_lang.c rename to src/win/win_progsett.c index 229c81cb2..46594ef45 100644 --- a/src/win/win_lang.c +++ b/src/win/win_progsett.c @@ -6,8 +6,7 @@ * * This file is part of the 86Box distribution. * - * Handle the dialog for changing the program's language. - * + * Handle the dialog for changing the program's language and other global settings. * * * Authors: Laci bá' @@ -100,7 +99,7 @@ progsett_fill_iconsets(HWND hdlg) WIN32_FIND_DATA data; char icon_path_root[512]; - plat_get_icons_path(icon_path_root); + win_get_icons_path(icon_path_root); wchar_t search[512]; mbstowcs(search, icon_path_root, strlen(icon_path_root) + 1); @@ -187,7 +186,7 @@ progsett_settings_save(void) /* Iconset */ strcpy(icon_set, temp_icon_set); - plat_load_icon_set(hinstance); + win_load_icon_set(hinstance); /* Update title bar */ update_mouse_msg(); diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index d8e079e14..c980253e0 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -877,7 +877,7 @@ StatusBarPopupMenu(HWND hwnd, POINT pt, int id) /* API: Load status bar icons */ void StatusBarLoadIcon(HINSTANCE hInst) { - plat_load_icon_set(hInst); + win_load_icon_set(); } /* Handle messages for the Status Bar window. */ diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 84bde8e64..321871da2 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -68,6 +68,7 @@ int user_resize = 0; int fixed_size_x = 0, fixed_size_y = 0; int kbd_req_capture = 0; int hide_status_bar = 0; +int dpi = 96; extern char openfilestring[512]; extern WCHAR wopenfilestring[512]; @@ -77,7 +78,6 @@ extern WCHAR wopenfilestring[512]; static wchar_t wTitle[512]; static int manager_wm = 0; static int save_window_pos = 0, pause_state = 0; -int dpi = 96; static int padded_frame = 0; static int vis = -1; @@ -1064,7 +1064,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: - plat_clear_icon_set(); + win_clear_icon_set(); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); break; @@ -1395,6 +1395,9 @@ ui_init(int nCmdShow) /* Reset all menus to their defaults. */ ResetAllMenus(); media_menu_init(); + + /* Load the desired iconset */ + win_load_icon_set(); /* Make the window visible on the screen. */ ShowWindow(hwnd, nCmdShow); From cc59925be647d74c7591e0b85959ee1b3663828c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Wed, 17 Nov 2021 19:04:37 +0100 Subject: [PATCH 06/10] Make this branch up-to-date --- src/win/languages/zh-CN.rc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/win/languages/zh-CN.rc b/src/win/languages/zh-CN.rc index e625f53bc..1f0f97378 100644 --- a/src/win/languages/zh-CN.rc +++ b/src/win/languages/zh-CN.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "设置(&S)...", IDM_CONFIG MENUITEM "更新状态栏图标(&U)", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "更改显示语言(&p)...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "启用 Discord 集成(&D)", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "更改显示语言" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "音量增益" #define STR_NEW_FLOPPY "新建镜像" #define STR_CONFIG "86Box 设置" @@ -284,6 +284,7 @@ END #define STR_GLOBAL "将以上设定存储为全局默认值(&g)" #define STR_DEFAULT "默认(&D)" #define STR_LANGUAGE "语言:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "增益" From d9e6fc0db05a6790c45ca80e217c011767f30497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Wed, 17 Nov 2021 19:16:38 +0100 Subject: [PATCH 07/10] Update dialogs.rc --- src/win/languages/dialogs.rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index c9cb99921..9ef64b316 100644 --- a/src/win/languages/dialogs.rc +++ b/src/win/languages/dialogs.rc @@ -10,8 +10,8 @@ BEGIN COMBOBOX IDC_COMBO_ICON, 13, 50, 213, 22, CBS_DROPDOWNLIST | CBS_HASSTRINGS PUSHBUTTON STR_DEFAULT, IDC_BUTTON_DEFICON, 162, 64, 60, 14 AUTOCHECKBOX STR_GLOBAL, IDC_CHECKBOX_GLOBAL, 13, 82, 217, 8 , WS_DISABLED - LTEXT STR_LANGUAGE, 1001, 13, 8, 100, 8 - LTEXT STR_ICONSET, 1002, 13, 40, 100, 8 + LTEXT STR_LANGUAGE, 0, 13, 8, 100, 8 + LTEXT STR_ICONSET, 1, 13, 40, 100, 8 END DLG_SND_GAIN DIALOG DISCARDABLE 0, 0, 113, 136 From 988a22ebf47a2cc05eaca355986f4d8fdefe03d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Wed, 17 Nov 2021 19:23:55 +0100 Subject: [PATCH 08/10] Add missing texts to fi-FI translation too --- src/win/languages/dialogs.rc | 4 ++-- src/win/languages/fi-FI.rc | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index 9ef64b316..78ab8885b 100644 --- a/src/win/languages/dialogs.rc +++ b/src/win/languages/dialogs.rc @@ -10,8 +10,8 @@ BEGIN COMBOBOX IDC_COMBO_ICON, 13, 50, 213, 22, CBS_DROPDOWNLIST | CBS_HASSTRINGS PUSHBUTTON STR_DEFAULT, IDC_BUTTON_DEFICON, 162, 64, 60, 14 AUTOCHECKBOX STR_GLOBAL, IDC_CHECKBOX_GLOBAL, 13, 82, 217, 8 , WS_DISABLED - LTEXT STR_LANGUAGE, 0, 13, 8, 100, 8 - LTEXT STR_ICONSET, 1, 13, 40, 100, 8 + LTEXT STR_LANGUAGE, 0, 13, 8, 100, 8 + LTEXT STR_ICONSET, 1, 13, 40, 100, 8 END DLG_SND_GAIN DIALOG DISCARDABLE 0, 0, 113, 136 diff --git a/src/win/languages/fi-FI.rc b/src/win/languages/fi-FI.rc index 92e1187d5..28b34bb86 100644 --- a/src/win/languages/fi-FI.rc +++ b/src/win/languages/fi-FI.rc @@ -101,7 +101,7 @@ BEGIN MENUITEM "&Asetukset...", IDM_CONFIG MENUITEM "&Päivitä tilapalkin kuvakkeita", IDM_UPDATE_ICONS MENUITEM SEPARATOR - MENUITEM "&Vaihda näyttökieltä...", IDM_VID_PROG_SETT + MENUITEM "Change program &settings...", IDM_VID_PROG_SETT # ifdef USE_DISCORD MENUITEM SEPARATOR MENUITEM "Käytä &Discord integraatiota", IDM_DISCORD @@ -273,7 +273,7 @@ END // Dialog // -#define STR_PROG_SETT "Vaihda näyttökieltä" +#define STR_PROG_SETT "Program Settings" #define STR_SND_GAIN "Äänen tulotaso" #define STR_NEW_FLOPPY "Uusi levykuva" #define STR_CONFIG "86Box Asetukset" @@ -284,6 +284,7 @@ END #define STR_GLOBAL "Tallenna nämä asetukset &globaaleiksi oletuksiksi" #define STR_DEFAULT "&Oletus" #define STR_LANGUAGE "Kieli:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Taso" From 2f464edd651f26e126271cda8403db1805e494f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Wed, 17 Nov 2021 19:35:29 +0100 Subject: [PATCH 09/10] Another try to fix the VS2019 builds --- src/win/languages/dialogs.rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index 78ab8885b..b2813faa0 100644 --- a/src/win/languages/dialogs.rc +++ b/src/win/languages/dialogs.rc @@ -10,8 +10,8 @@ BEGIN COMBOBOX IDC_COMBO_ICON, 13, 50, 213, 22, CBS_DROPDOWNLIST | CBS_HASSTRINGS PUSHBUTTON STR_DEFAULT, IDC_BUTTON_DEFICON, 162, 64, 60, 14 AUTOCHECKBOX STR_GLOBAL, IDC_CHECKBOX_GLOBAL, 13, 82, 217, 8 , WS_DISABLED - LTEXT STR_LANGUAGE, 0, 13, 8, 100, 8 - LTEXT STR_ICONSET, 1, 13, 40, 100, 8 + LTEXT STR_LANGUAGE, 2000, 13, 8, 100, 8 + LTEXT STR_ICONSET, 2001, 13, 40, 100, 8 END DLG_SND_GAIN DIALOG DISCARDABLE 0, 0, 113, 136 From 9125169e5bb659680bdc990f82fde6cdb5b3f537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Wed, 17 Nov 2021 21:53:26 +0100 Subject: [PATCH 10/10] Apply requested changes, along with more indentation fixes --- src/win/win_progsett.c | 36 ++++++++++++++++++------------------ src/win/win_ui.c | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/win/win_progsett.c b/src/win/win_progsett.c index 46594ef45..46ede599b 100644 --- a/src/win/win_progsett.c +++ b/src/win/win_progsett.c @@ -156,25 +156,25 @@ progsett_fill_iconsets(HWND hdlg) static int progsett_settings_changed(void) { - int i = 0; + int i = 0; /* Language */ i = i || has_language_changed(temp_language); - i = i || strcmp(temp_icon_set, icon_set); + i = i || strcmp(temp_icon_set, icon_set); - return i; + return i; } /* IndexOf by ItemData */ static int progsett_indexof(HWND combo, LPARAM itemdata) { - int i; - for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) - if (SendMessage(combo, CB_GETITEMDATA, i, 0) == itemdata) - return i; + int i; + for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) + if (SendMessage(combo, CB_GETITEMDATA, i, 0) == itemdata) + return i; - return -1; + return -1; } /* This saves the settings back to the global variables. */ @@ -184,20 +184,20 @@ progsett_settings_save(void) /* Language */ set_language(temp_language); - /* Iconset */ - strcpy(icon_set, temp_icon_set); - win_load_icon_set(hinstance); + /* Iconset */ + strcpy(icon_set, temp_icon_set); + win_load_icon_set(); /* Update title bar */ - update_mouse_msg(); + update_mouse_msg(); - /* Update status bar */ - config_changed = 1; - ui_sb_set_ready(0); - ui_sb_update_panes(); + /* Update status bar */ + config_changed = 1; + ui_sb_set_ready(0); + ui_sb_update_panes(); - /* Save the language changes */ - config_save(); + /* Save the language changes */ + config_save(); } #if defined(__amd64__) || defined(__aarch64__) diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 321871da2..7c4bdff1f 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -1396,8 +1396,8 @@ ui_init(int nCmdShow) ResetAllMenus(); media_menu_init(); - /* Load the desired iconset */ - win_load_icon_set(); + /* Load the desired iconset */ + win_load_icon_set(); /* Make the window visible on the screen. */ ShowWindow(hwnd, nCmdShow);