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/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 2fdddb56e..333b6fbee 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,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 3d20b3adf..2b949ea5f 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,7 +1245,6 @@ plat_language_code_r(uint32_t lcid, char* outbuf, int len) 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 727644f7b..5b44eeb45 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -18,9 +18,9 @@ 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) + 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 1dc7426f0..d678e2699 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -405,10 +405,10 @@ 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 \ + 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 cd903b9ba..fd9b083b6 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,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 "Iconset:" #define STR_GAIN "Zesílení" diff --git a/src/win/languages/de-DE.rc b/src/win/languages/de-DE.rc index 67e46e318..bca50e627 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,6 +284,7 @@ END #define STR_GLOBAL "Einstellungen als &globalen Standard speichern" #define STR_DEFAULT "&Standard" #define STR_LANGUAGE "Sprache:" +#define STR_ICONSET "Iconset:" #define STR_GAIN "Verstärkung" diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index 7b3de5fc5..b2813faa0 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 FONT_SIZE, FONT_NAME 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, 2000, 13, 8, 100, 8 + LTEXT STR_ICONSET, 2001, 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 64c604aad..3bd489b08 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,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/fi-FI.rc b/src/win/languages/fi-FI.rc index a54368ae5..c6dc4ea35 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" diff --git a/src/win/languages/hr-HR.rc b/src/win/languages/hr-HR.rc index 89df536a5..fe48f0a81 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,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 "Iconset:" #define STR_GAIN "Pojačavanje" diff --git a/src/win/languages/hu-HU.rc b/src/win/languages/hu-HU.rc index a9d0f9e0d..569cf5570 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,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 48ee0aaed..807ae11a2 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,6 +284,7 @@ END #define STR_GLOBAL "Salva queste impostazioni come &predefinite globali" #define STR_DEFAULT "&Predefinito" #define STR_LANGUAGE "Lingua:" +#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 ae81ee59f..8759f3e61 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,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 "Iconset:" #define STR_GAIN "Ganho" diff --git a/src/win/languages/pt-PT.rc b/src/win/languages/pt-PT.rc index 361326349..89e044d66 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,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 "Iconset:" #define STR_GAIN "Ganho" diff --git a/src/win/languages/zh-CN.rc b/src/win/languages/zh-CN.rc index 75e98df39..3b7d35e05 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 "增益" diff --git a/src/win/win_icon.c b/src/win/win_icon.c new file mode 100644 index 000000000..e5e4cdc67 --- /dev/null +++ b/src/win/win_icon.c @@ -0,0 +1,153 @@ +/* + * 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] = ""; /* 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() +{ + 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(hinstance, 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_get_icons_path(char* path_root) +{ + 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); +} + +void win_load_icon_set() +{ + win_clear_icon_set(); + win_system_icon_set(); + + if (strlen(icon_set) == 0) + return; + + char path_root[2048] = {0}, temp[2048] = {0}; + wchar_t wtemp[2048] = {0}; + + win_get_icons_path(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) + { + if (hIcon[icon_files[i].id]) + DestroyIcon(hIcon[icon_files[i].id]); + hIcon[icon_files[i].id] = 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_lang.c b/src/win/win_progsett.c similarity index 53% rename from src/win/win_lang.c rename to src/win/win_progsett.c index 5f79e8c61..46ede599b 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á' @@ -36,6 +35,8 @@ /* Language */ static LCID temp_language; +static char temp_icon_set[256] = {0}; + int enum_helper, c; HWND hwndProgSett; @@ -76,28 +77,104 @@ 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]; + win_get_icons_path(icon_path_root); + + wchar_t search[512]; + mbstowcs(search, icon_path_root, strlen(icon_path_root) + 1); + wcscat(search, L"*.*"); + + 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"); + + wcscpy(dispname, data.cFileName); + FILE *fp = _wfopen(temp, L"r"); + if (fp) + { + char line[512] = {0}; + if (fgets(line, 511, fp)) + { + 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) { - int i = 0; + int i = 0; /* Language */ i = i || has_language_changed(temp_language); + 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. */ @@ -107,16 +184,20 @@ progsett_settings_save(void) /* Language */ set_language(temp_language); + /* 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__) @@ -131,7 +212,9 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) hwndProgSett = hdlg; /* Language */ temp_language = lang_id; + strcpy(temp_icon_set, icon_set); progsett_fill_languages(hdlg); + progsett_fill_iconsets(hdlg); break; case WM_COMMAND: @@ -154,6 +237,14 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } break; + case IDC_COMBO_ICON: + if (HIWORD(wParam) == CBN_SELCHANGE) { + 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)); + } + break; + case IDC_BUTTON_DEFAULT: { HWND combo = GetDlgItem(hdlg, IDC_COMBO_LANG); int index = progsett_indexof(combo, DEFAULT_LANGUAGE); @@ -161,10 +252,33 @@ ProgSettDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) temp_language = DEFAULT_LANGUAGE; break; } + + case IDC_BUTTON_DEFICON: { + SendMessage(GetDlgItem(hdlg, IDC_COMBO_ICON), CB_SETCURSEL, 0, 0); + strcpy(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_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..c980253e0 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(); } /* Handle messages for the Status Bar window. */ diff --git a/src/win/win_ui.c b/src/win/win_ui.c index b25ed5df1..e5ab4958c 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; @@ -69,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]; @@ -78,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; -static 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) { @@ -1077,6 +1067,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; @@ -1404,11 +1395,18 @@ ui_init(int nCmdShow) ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height); } - /* Load the desired language, and reset all menus to their defaults */ + /* Load the desired language, and reset all menus to their defaults */ uint32_t helper_lang = lang_id; lang_id = 0; set_language(helper_lang); + /* 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);