wxWidgets/SDL2 port now supports setting custom screen resolution. Patch from bit.
This commit is contained in:
parent
0c63c99b71
commit
807ee15f49
6 changed files with 9553 additions and 9228 deletions
5358
src/pc.xrc
5358
src/pc.xrc
File diff suppressed because it is too large
Load diff
13330
src/wx-resources.cpp
13330
src/wx-resources.cpp
File diff suppressed because it is too large
Load diff
|
|
@ -49,6 +49,9 @@ SDL_Rect remembered_rect;
|
||||||
int remembered_mouse_x = 0;
|
int remembered_mouse_x = 0;
|
||||||
int remembered_mouse_y = 0;
|
int remembered_mouse_y = 0;
|
||||||
|
|
||||||
|
int custom_resolution_width = 640;
|
||||||
|
int custom_resolution_height = 480;
|
||||||
|
|
||||||
int win_doresize = 0;
|
int win_doresize = 0;
|
||||||
int winsizex = 640, winsizey = 480;
|
int winsizex = 640, winsizey = 480;
|
||||||
|
|
||||||
|
|
@ -517,6 +520,12 @@ void window_setup()
|
||||||
rect.w = 640;
|
rect.w = 640;
|
||||||
rect.h = 480;
|
rect.h = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vid_resize == 2)
|
||||||
|
{
|
||||||
|
rect.w = custom_resolution_width;
|
||||||
|
rect.h = custom_resolution_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int window_create()
|
int window_create()
|
||||||
|
|
@ -692,8 +701,11 @@ int render()
|
||||||
{
|
{
|
||||||
window_dosetresize = 0;
|
window_dosetresize = 0;
|
||||||
SDL_GetWindowSize(window, &rect.w, &rect.h);
|
SDL_GetWindowSize(window, &rect.w, &rect.h);
|
||||||
SDL_SetWindowResizable(window, vid_resize);
|
SDL_SetWindowResizable(window, vid_resize == 1);
|
||||||
SDL_SetWindowSize(window, rect.w, rect.h);
|
SDL_SetWindowSize(window, rect.w, rect.h);
|
||||||
|
|
||||||
|
if (vid_resize == 2)
|
||||||
|
SDL_SetWindowSize(window, custom_resolution_width, custom_resolution_height);
|
||||||
}
|
}
|
||||||
if (renderer_doreset)
|
if (renderer_doreset)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ SDL_Rect remembered_rect;
|
||||||
int remembered_mouse_x = 0;
|
int remembered_mouse_x = 0;
|
||||||
int remembered_mouse_y = 0;
|
int remembered_mouse_y = 0;
|
||||||
|
|
||||||
|
int custom_resolution_width = 640;
|
||||||
|
int custom_resolution_height = 480;
|
||||||
|
|
||||||
int win_doresize = 0;
|
int win_doresize = 0;
|
||||||
int winsizex = 640, winsizey = 480;
|
int winsizex = 640, winsizey = 480;
|
||||||
|
|
||||||
|
|
@ -304,6 +307,12 @@ void window_setup()
|
||||||
rect.w = 640;
|
rect.w = 640;
|
||||||
rect.h = 480;
|
rect.h = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vid_resize == 2)
|
||||||
|
{
|
||||||
|
rect.w = custom_resolution_width;
|
||||||
|
rect.h = custom_resolution_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
|
|
@ -374,7 +383,7 @@ int window_create()
|
||||||
{
|
{
|
||||||
window = SDL_CreateWindow("PCem Display",
|
window = SDL_CreateWindow("PCem Display",
|
||||||
rect.x, rect.y, rect.w, rect.h,
|
rect.x, rect.y, rect.w, rect.h,
|
||||||
requested_render_driver.sdl_window_params | (vid_resize ? SDL_WINDOW_RESIZABLE : 0));
|
requested_render_driver.sdl_window_params | (vid_resize == 1 ? SDL_WINDOW_RESIZABLE : 0));
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
char message[200];
|
char message[200];
|
||||||
|
|
@ -427,11 +436,13 @@ int render()
|
||||||
window_dosetresize = 0;
|
window_dosetresize = 0;
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||||
SDL_GetWindowSize(window, &rect.w, &rect.h);
|
SDL_GetWindowSize(window, &rect.w, &rect.h);
|
||||||
SDL_SetWindowResizable(window, vid_resize);
|
SDL_SetWindowResizable(window, vid_resize == 1);
|
||||||
SDL_SetWindowSize(window, rect.w, rect.h);
|
SDL_SetWindowSize(window, rect.w, rect.h);
|
||||||
#else
|
#else
|
||||||
window_doreset = 1;
|
window_doreset = 1;
|
||||||
#endif
|
#endif
|
||||||
|
if (vid_resize == 2)
|
||||||
|
SDL_SetWindowSize(window, custom_resolution_width, custom_resolution_height);
|
||||||
}
|
}
|
||||||
if (window_doreset)
|
if (window_doreset)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,3 +64,6 @@ void color_flash(FLASH_FUNC func, int time_ms, char r, char g, char b, char a);
|
||||||
|
|
||||||
extern sdl_render_driver requested_render_driver;
|
extern sdl_render_driver requested_render_driver;
|
||||||
extern char current_render_driver_name[50];
|
extern char current_render_driver_name[50];
|
||||||
|
|
||||||
|
extern int custom_resolution_width;
|
||||||
|
extern int custom_resolution_height;
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,9 @@ void sdl_loadconfig()
|
||||||
strcpy(screenshot_format, config_get_string(CFG_MACHINE, "SDL2", "screenshot_format", IMAGE_PNG));
|
strcpy(screenshot_format, config_get_string(CFG_MACHINE, "SDL2", "screenshot_format", IMAGE_PNG));
|
||||||
screenshot_flash = config_get_int(CFG_MACHINE, "SDL2", "screenshot_flash", 1);
|
screenshot_flash = config_get_int(CFG_MACHINE, "SDL2", "screenshot_flash", 1);
|
||||||
|
|
||||||
|
custom_resolution_width = config_get_int(CFG_MACHINE, "SDL2", "custom_width", custom_resolution_width);
|
||||||
|
custom_resolution_height = config_get_int(CFG_MACHINE, "SDL2", "custom_height", custom_resolution_height);
|
||||||
|
|
||||||
video_fullscreen = config_get_int(CFG_MACHINE, "SDL2", "fullscreen", video_fullscreen);
|
video_fullscreen = config_get_int(CFG_MACHINE, "SDL2", "fullscreen", video_fullscreen);
|
||||||
video_fullscreen_mode = config_get_int(CFG_MACHINE, "SDL2", "fullscreen_mode", video_fullscreen_mode);
|
video_fullscreen_mode = config_get_int(CFG_MACHINE, "SDL2", "fullscreen_mode", video_fullscreen_mode);
|
||||||
video_scale = config_get_int(CFG_MACHINE, "SDL2", "scale", video_scale);
|
video_scale = config_get_int(CFG_MACHINE, "SDL2", "scale", video_scale);
|
||||||
|
|
@ -313,6 +316,9 @@ void sdl_saveconfig()
|
||||||
config_set_string(CFG_MACHINE, "SDL2", "screenshot_format", screenshot_format);
|
config_set_string(CFG_MACHINE, "SDL2", "screenshot_format", screenshot_format);
|
||||||
config_set_int(CFG_MACHINE, "SDL2", "screenshot_flash", screenshot_flash);
|
config_set_int(CFG_MACHINE, "SDL2", "screenshot_flash", screenshot_flash);
|
||||||
|
|
||||||
|
config_set_int(CFG_MACHINE, "SDL2", "custom_width", custom_resolution_width);
|
||||||
|
config_set_int(CFG_MACHINE, "SDL2", "custom_height", custom_resolution_height);
|
||||||
|
|
||||||
config_set_int(CFG_MACHINE, "SDL2", "fullscreen", video_fullscreen);
|
config_set_int(CFG_MACHINE, "SDL2", "fullscreen", video_fullscreen);
|
||||||
config_set_int(CFG_MACHINE, "SDL2", "fullscreen_mode", video_fullscreen_mode);
|
config_set_int(CFG_MACHINE, "SDL2", "fullscreen_mode", video_fullscreen_mode);
|
||||||
config_set_int(CFG_MACHINE, "SDL2", "scale", video_scale);
|
config_set_int(CFG_MACHINE, "SDL2", "scale", video_scale);
|
||||||
|
|
@ -383,8 +389,9 @@ int wx_setupmenu(void* data)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
update_cdrom_menu(menu);
|
update_cdrom_menu(menu);
|
||||||
if (vid_resize)
|
sprintf(menuitem, "IDM_VID_RESOLUTION[%d]", vid_resize);
|
||||||
wx_checkmenuitem(menu, WX_ID("IDM_VID_RESIZE"), WX_MB_CHECKED);
|
wx_checkmenuitem(menu, WX_ID(menuitem), WX_MB_CHECKED);
|
||||||
|
wx_enablemenuitem(menu, wx_xrcid("IDM_VID_SCALE_MENU"), !vid_resize);
|
||||||
sprintf(menuitem, "IDM_VID_FS[%d]", video_fullscreen_scale);
|
sprintf(menuitem, "IDM_VID_FS[%d]", video_fullscreen_scale);
|
||||||
wx_checkmenuitem(menu, WX_ID(menuitem), WX_MB_CHECKED);
|
wx_checkmenuitem(menu, WX_ID(menuitem), WX_MB_CHECKED);
|
||||||
wx_checkmenuitem(menu, WX_ID("IDM_VID_FULLSCREEN"), video_fullscreen);
|
wx_checkmenuitem(menu, WX_ID("IDM_VID_FULLSCREEN"), video_fullscreen);
|
||||||
|
|
@ -731,6 +738,36 @@ void atapi_close(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int custom_resolution_callback(void* window, int message, INT_PARAM wParam, LONG_PARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WX_INITDIALOG:
|
||||||
|
{
|
||||||
|
wx_sendmessage(wx_getdlgitem(window, wx_xrcid("IDC_WIDTH")), WX_UDM_SETPOS, 0, custom_resolution_width);
|
||||||
|
wx_sendmessage(wx_getdlgitem(window, wx_xrcid("IDC_HEIGHT")), WX_UDM_SETPOS, 0, custom_resolution_height);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
case WX_COMMAND:
|
||||||
|
{
|
||||||
|
if (wParam == wxID_OK)
|
||||||
|
{
|
||||||
|
custom_resolution_width = wx_sendmessage(wx_getdlgitem(window, wx_xrcid("IDC_WIDTH")), WX_UDM_GETPOS, 0, 0);
|
||||||
|
custom_resolution_height = wx_sendmessage(wx_getdlgitem(window, wx_xrcid("IDC_HEIGHT")), WX_UDM_GETPOS, 0, 0);
|
||||||
|
wx_enddialog(window, 1);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if (wParam == wxID_CANCEL)
|
||||||
|
{
|
||||||
|
wx_enddialog(window, 0);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int wx_handle_command(void* hwnd, int wParam, int checked)
|
int wx_handle_command(void* hwnd, int wParam, int checked)
|
||||||
{
|
{
|
||||||
void* hmenu;
|
void* hmenu;
|
||||||
|
|
@ -814,13 +851,27 @@ int wx_handle_command(void* hwnd, int wParam, int checked)
|
||||||
if (emulation_state != EMULATION_STOPPED)
|
if (emulation_state != EMULATION_STOPPED)
|
||||||
wx_togglewindow(hwnd);
|
wx_togglewindow(hwnd);
|
||||||
}
|
}
|
||||||
else if (ID_IS("IDM_VID_RESIZE"))
|
else if (ID_RANGE("IDM_VID_RESOLUTION[start]", "IDM_VID_RESOLUTION[end]"))
|
||||||
{
|
{
|
||||||
vid_resize = !vid_resize;
|
vid_resize = wParam - wx_xrcid("IDM_VID_RESOLUTION[start]");
|
||||||
wx_checkmenuitem(hmenu, wParam, vid_resize);
|
wx_checkmenuitem(hmenu, wParam, WX_MB_CHECKED);
|
||||||
window_dosetresize = 1;
|
window_dosetresize = 1;
|
||||||
|
wx_enablemenuitem(hmenu, wx_xrcid("IDM_VID_SCALE_MENU"), !vid_resize);
|
||||||
saveconfig(NULL);
|
saveconfig(NULL);
|
||||||
}
|
}
|
||||||
|
else if (ID_IS("IDM_VID_RESOLUTION_CUSTOM"))
|
||||||
|
{
|
||||||
|
if (wx_dialogbox(hwnd, "CustomResolutionDlg", custom_resolution_callback))
|
||||||
|
{
|
||||||
|
if (vid_resize != 2)
|
||||||
|
{
|
||||||
|
vid_resize = 2;
|
||||||
|
wx_checkmenuitem(hmenu, wx_xrcid("IDM_VID_RESOLUTION[2]"), WX_MB_CHECKED);
|
||||||
|
wx_enablemenuitem(hmenu, wx_xrcid("IDM_VID_SCALE_MENU"), !vid_resize);
|
||||||
|
}
|
||||||
|
window_dosetresize = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (ID_IS("IDM_SCREENSHOT"))
|
else if (ID_IS("IDM_SCREENSHOT"))
|
||||||
{
|
{
|
||||||
take_screenshot = 1;
|
take_screenshot = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue