Add option to remember window size & position.
This commit is contained in:
parent
541c9f0030
commit
01ad1ed98c
5 changed files with 62 additions and 0 deletions
|
|
@ -504,3 +504,4 @@ void onesec();
|
|||
void resetpc_cad();
|
||||
|
||||
extern int start_in_fullscreen;
|
||||
extern int window_w, window_h, window_x, window_y, window_remember;
|
||||
|
|
|
|||
14
src/pc.c
14
src/pc.c
|
|
@ -38,6 +38,8 @@
|
|||
#include "vid_voodoo.h"
|
||||
#include "video.h"
|
||||
|
||||
int window_w, window_h, window_x, window_y, window_remember;
|
||||
|
||||
int start_in_fullscreen = 0;
|
||||
int frame = 0;
|
||||
|
||||
|
|
@ -647,6 +649,12 @@ void loadconfig(char *fn)
|
|||
|
||||
fdd_set_type(0, config_get_int(NULL, "drive_a_type", 7));
|
||||
fdd_set_type(1, config_get_int(NULL, "drive_b_type", 7));
|
||||
|
||||
window_w = config_get_int(NULL, "window_w", 0);
|
||||
window_h = config_get_int(NULL, "window_h", 0);
|
||||
window_x = config_get_int(NULL, "window_x", 0);
|
||||
window_y = config_get_int(NULL, "window_y", 0);
|
||||
window_remember = config_get_int(NULL, "window_remember", 0);
|
||||
}
|
||||
|
||||
void saveconfig()
|
||||
|
|
@ -700,6 +708,12 @@ void saveconfig()
|
|||
|
||||
config_set_int(NULL, "drive_a_type", fdd_get_type(0));
|
||||
config_set_int(NULL, "drive_b_type", fdd_get_type(1));
|
||||
|
||||
config_set_int(NULL, "window_w", window_w);
|
||||
config_set_int(NULL, "window_h", window_h);
|
||||
config_set_int(NULL, "window_x", window_x);
|
||||
config_set_int(NULL, "window_y", window_y);
|
||||
config_set_int(NULL, "window_remember", window_remember);
|
||||
|
||||
config_save(config_file_default);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ BEGIN
|
|||
POPUP "&Video"
|
||||
BEGIN
|
||||
MENUITEM "&Resizeable window",IDM_VID_RESIZE
|
||||
MENUITEM "Remember size && position",IDM_VID_REMEMBER
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&DirectDraw", IDM_VID_DDRAW
|
||||
MENUITEM "Direct&3D", IDM_VID_D3D
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#define IDM_CONFIG_SAVE 40022
|
||||
#define IDM_STATUS 40030
|
||||
#define IDM_VID_RESIZE 40050
|
||||
#define IDM_VID_REMEMBER 40051
|
||||
#define IDM_VID_DDRAW 40060
|
||||
#define IDM_VID_D3D 40061
|
||||
#define IDM_VID_FULLSCREEN 40070
|
||||
|
|
|
|||
45
src/win.c
45
src/win.c
|
|
@ -41,6 +41,7 @@
|
|||
#define MAPVK_VK_TO_VSC 0
|
||||
#endif
|
||||
|
||||
static int save_window_pos = 0;
|
||||
uint64_t timer_freq;
|
||||
|
||||
int rawinputkey[272];
|
||||
|
|
@ -564,6 +565,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
|||
if (vid_resize) CheckMenuItem(menu, IDM_VID_RESIZE, MF_CHECKED);
|
||||
CheckMenuItem(menu, IDM_VID_DDRAW + vid_api, MF_CHECKED);
|
||||
CheckMenuItem(menu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED);
|
||||
CheckMenuItem(menu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
|
||||
// set_display_switch_mode(SWITCH_BACKGROUND);
|
||||
|
||||
d=romset;
|
||||
|
|
@ -661,6 +663,13 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
|||
endblit();
|
||||
device_force_redraw();
|
||||
}
|
||||
if (window_remember)
|
||||
{
|
||||
MoveWindow(hwnd, window_x, window_y,
|
||||
window_w,
|
||||
window_h,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
/* Run the message loop. It will run until GetMessage() returns 0 */
|
||||
while (!quited)
|
||||
|
|
@ -707,6 +716,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
|||
TerminateThread(mainthreadh,0);
|
||||
// pclog("Quited? %i\n",quited);
|
||||
// pclog("Closepc\n");
|
||||
if (save_window_pos && window_remember)
|
||||
saveconfig();
|
||||
closepc();
|
||||
// pclog("dumpregs\n");
|
||||
|
||||
|
|
@ -926,6 +937,19 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
saveconfig();
|
||||
break;
|
||||
case IDM_VID_REMEMBER:
|
||||
window_remember = !window_remember;
|
||||
CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
|
||||
GetWindowRect(hwnd, &rect);
|
||||
if (window_remember)
|
||||
{
|
||||
window_x = rect.left;
|
||||
window_y = rect.top;
|
||||
window_w = rect.right - rect.left;
|
||||
window_h = rect.bottom - rect.top;
|
||||
}
|
||||
saveconfig();
|
||||
break;
|
||||
|
||||
case IDM_VID_DDRAW: case IDM_VID_D3D:
|
||||
startblit();
|
||||
|
|
@ -1259,8 +1283,29 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
pcclip.bottom -= GetSystemMetrics(SM_CXFIXEDFRAME) + 10;
|
||||
ClipCursor(&pcclip);
|
||||
}
|
||||
if (window_remember)
|
||||
{
|
||||
GetWindowRect(hwnd, &rect);
|
||||
window_x = rect.left;
|
||||
window_y = rect.top;
|
||||
window_w = rect.right - rect.left;
|
||||
window_h = rect.bottom - rect.top;
|
||||
save_window_pos = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
if (window_remember)
|
||||
{
|
||||
GetWindowRect(hwnd, &rect);
|
||||
window_x = rect.left;
|
||||
window_y = rect.top;
|
||||
window_w = rect.right - rect.left;
|
||||
window_h = rect.bottom - rect.top;
|
||||
save_window_pos = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
if (wParam == TIMER_1SEC)
|
||||
onesec();
|
||||
|
|
|
|||
Loading…
Reference in a new issue