Finish the changeable iconset

This commit is contained in:
Laci bá
2021-11-16 19:38:31 +01:00
parent 98316e228f
commit 0aa6e9c8a6
20 changed files with 210 additions and 25 deletions

View File

@@ -715,6 +715,9 @@ usage:
if (lang_init)
set_language(lang_init);
/* Load the desired iconset */
plat_load_icon_set();
/* All good! */
return(1);
}

View File

@@ -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
@@ -2231,6 +2237,11 @@ save_general(void)
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)
config_set_int(cat, "enable_discord", enable_discord);

View File

@@ -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 */

View File

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

View File

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

View File

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

View File

@@ -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) {}

View File

@@ -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í"

View File

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

View File

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

View File

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

View File

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

View File

@@ -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ő"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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. */

View File

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