win32: save custom rom dialog position and column sizes

This commit is contained in:
OV2 2018-07-03 22:39:20 +02:00
parent 170f90aa21
commit cb5b6651f4
3 changed files with 122 additions and 80 deletions

View File

@ -806,6 +806,9 @@ void WinPreSave(ConfigFile& conf)
if(GUI.window_size.bottom < 10) GUI.window_size.bottom = 10; if(GUI.window_size.bottom < 10) GUI.window_size.bottom = 10;
if(GUI.window_size.right < 10) GUI.window_size.right = 10; if(GUI.window_size.right < 10) GUI.window_size.right = 10;
GUI.customRomDlgSettings.window_size.right -= GUI.customRomDlgSettings.window_size.left;
GUI.customRomDlgSettings.window_size.bottom -= GUI.customRomDlgSettings.window_size.top;
conf.DeleteKey("Sound::Mono"); conf.DeleteKey("Sound::Mono");
if(configSort == 2) if(configSort == 2)
conf.ClearLines(); conf.ClearLines();
@ -825,6 +828,9 @@ void WinPostSave(ConfigFile& conf)
GUI.window_size.bottom += GUI.window_size.top; GUI.window_size.bottom += GUI.window_size.top;
GUI.window_size.right += extra_width; GUI.window_size.right += extra_width;
GUI.window_size.bottom += extra_height; GUI.window_size.bottom += extra_height;
GUI.customRomDlgSettings.window_size.right += GUI.customRomDlgSettings.window_size.left;
GUI.customRomDlgSettings.window_size.bottom += GUI.customRomDlgSettings.window_size.top;
} }
void WinPostLoad(ConfigFile& conf) void WinPostLoad(ConfigFile& conf)
{ {
@ -913,6 +919,15 @@ void WinRegisterConfigItems()
AddIntC("Window:Left", GUI.window_size.left, 0, "in pixels from left edge of screen"); AddIntC("Window:Left", GUI.window_size.left, 0, "in pixels from left edge of screen");
AddIntC("Window:Top", GUI.window_size.top, 0, "in pixels from top edge of screen"); AddIntC("Window:Top", GUI.window_size.top, 0, "in pixels from top edge of screen");
AddBool("Window:Maximized", GUI.window_maximized, false); AddBool("Window:Maximized", GUI.window_maximized, false);
AddIntC("CustomRomDialog:Width", GUI.customRomDlgSettings.window_size.right, 660, "");
AddIntC("CustomRomDialog:Height", GUI.customRomDlgSettings.window_size.bottom, 400, "");
AddIntC("CustomRomDialog:Left", GUI.customRomDlgSettings.window_size.left, 50, "in pixels from left edge of screen");
AddIntC("CustomRomDialog:Top", GUI.customRomDlgSettings.window_size.top, 50, "in pixels from top edge of screen");
AddBool("CustomRomDialog:Maximized", GUI.customRomDlgSettings.window_maximized, false);
AddIntC("CustomRomDialog:FolderPaneWidth", GUI.customRomDlgSettings.folderPaneWidth, 230, "");
AddIntC("CustomRomDialog:DescColumnWidth", GUI.customRomDlgSettings.columnDescription, 112, "");
AddIntC("CustomRomDialog:FilenameColumnWidth", GUI.customRomDlgSettings.columnFilename, 196, "");
AddIntC("CustomRomDialog:SizeColumnWidth", GUI.customRomDlgSettings.columnSize, 67, "");
AddBoolC("Stretch:Enabled", GUI.Stretch, true, "true to stretch the game image to fill the window or screen"); AddBoolC("Stretch:Enabled", GUI.Stretch, true, "true to stretch the game image to fill the window or screen");
AddBoolC("Stretch:MaintainAspectRatio", GUI.AspectRatio, true, "prevents stretching from changing the aspect ratio"); AddBoolC("Stretch:MaintainAspectRatio", GUI.AspectRatio, true, "prevents stretching from changing the aspect ratio");
AddBoolC("Stretch:IntegerScaling", GUI.IntegerScaling, false, "scales image height to exact integer multiples"); AddBoolC("Stretch:IntegerScaling", GUI.IntegerScaling, false, "scales image height to exact integer multiples");

View File

@ -6019,6 +6019,74 @@ void MoveOpenRomWindows(HWND hDlg, unsigned int newWidth, int newHeight)
SetWindowPos(cancelButton, 0, buttonCancelLeft, buttonTop, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOZORDER); SetWindowPos(cancelButton, 0, buttonCancelLeft, buttonTop, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOZORDER);
} }
void MoveSplitterRelativeDirList(HWND hDlg, int offset_x)
{
HWND hTree, hList, hSplitter;
RECT treeRect;
RECT listRect;
hTree = GetDlgItem(hDlg, IDC_ROM_DIR);
hList = GetDlgItem(hDlg, IDC_ROMLIST);
hSplitter = GetDlgItem(hDlg, IDC_ROM_SPLITTER);
GetWindowRect(hTree, &treeRect);
POINT p;
p.x = offset_x + treeRect.right;
p.y = treeRect.top;
GetWindowRect(hList, &listRect);
if (p.x > (listRect.right - 50))
{
offset_x -= (short)(p.x - (listRect.right - 50));
p.x = listRect.right - 50;
}
ScreenToClient(hDlg, &p);
if (p.x < 50)
{
offset_x += (short)(50 - p.x);
p.x = 50;
}
MoveWindow(hSplitter, p.x, p.y, listRect.left - treeRect.right, listRect.bottom - listRect.top, FALSE);
MoveWindow(hList, p.x + (listRect.left - treeRect.right), p.y, listRect.right - listRect.left - offset_x, listRect.bottom - listRect.top, TRUE);
p.x = treeRect.left;
p.y = treeRect.top;
ScreenToClient(hDlg, &p);
MoveWindow(hTree, p.x, p.y, treeRect.right - treeRect.left + offset_x, treeRect.bottom - treeRect.top, true);
InvalidateRect(hSplitter, NULL, true);
}
void SaveCustomDialogSettings(HWND hDlg)
{
WINDOWPLACEMENT wndPlacement = { 0 };
wndPlacement.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hDlg, &wndPlacement);
GUI.customRomDlgSettings.window_maximized = wndPlacement.showCmd == SW_SHOWMAXIMIZED;
GUI.customRomDlgSettings.window_size = wndPlacement.rcNormalPosition;
HWND dirList = GetDlgItem(hDlg, IDC_ROM_DIR);
HWND romList = GetDlgItem(hDlg, IDC_ROMLIST);
RECT dirRect;
GetWindowRect(dirList, &dirRect);
GUI.customRomDlgSettings.folderPaneWidth = dirRect.right - dirRect.left;
LVCOLUMN col;
memset(&col, 0, sizeof(LVCOLUMN));
col.mask = LVCF_WIDTH;
ListView_GetColumn(romList, 0, &col);
GUI.customRomDlgSettings.columnFilename = col.cx;
ListView_GetColumn(romList, 1, &col);
GUI.customRomDlgSettings.columnDescription = col.cx;
ListView_GetColumn(romList, 2, &col);
GUI.customRomDlgSettings.columnSize = col.cx;
}
INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
int rv=0; int rv=0;
@ -6079,7 +6147,7 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH; col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH;
col.fmt=LVCFMT_LEFT; col.fmt=LVCFMT_LEFT;
col.iOrder=0; col.iOrder=0;
col.cx=196; col.cx= GUI.customRomDlgSettings.columnFilename;
col.cchTextMax=5; col.cchTextMax=5;
col.pszText=temp1; col.pszText=temp1;
@ -6090,7 +6158,7 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM; col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
col.fmt=LVCFMT_LEFT; col.fmt=LVCFMT_LEFT;
col.iOrder=1; col.iOrder=1;
col.cx=112; col.cx= GUI.customRomDlgSettings.columnDescription;
col.cchTextMax=32; col.cchTextMax=32;
col.pszText=temp2; col.pszText=temp2;
col.iSubItem=1; col.iSubItem=1;
@ -6103,7 +6171,7 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM; col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
col.fmt=LVCFMT_LEFT; col.fmt=LVCFMT_LEFT;
col.iOrder=2; col.iOrder=2;
col.cx=67; col.cx= GUI.customRomDlgSettings.columnSize;
col.cchTextMax=32; col.cchTextMax=32;
col.pszText=temp3; col.pszText=temp3;
col.iSubItem=2; col.iSubItem=2;
@ -6358,9 +6426,16 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
nextInvalidatedROMCounter = 0; nextInvalidatedROMCounter = 0;
SetTimer(hDlg,42,600,NULL); SetTimer(hDlg,42,600,NULL);
WINDOWPLACEMENT wndPlacement = { 0 };
wndPlacement.length = sizeof(WINDOWPLACEMENT);
wndPlacement.showCmd = GUI.customRomDlgSettings.window_maximized ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
wndPlacement.rcNormalPosition = GUI.customRomDlgSettings.window_size;
SetWindowPlacement(hDlg, &wndPlacement);
RECT clientRect; RECT clientRect;
GetClientRect(hDlg, &clientRect); GetClientRect(hDlg, &clientRect);
PostMessage(hDlg, WM_SIZE, SIZE_RESTORED, MAKELPARAM(clientRect.right, clientRect.bottom)); MoveOpenRomWindows(hDlg, clientRect.right, clientRect.bottom);
MoveSplitterRelativeDirList(hDlg, GUI.customRomDlgSettings.folderPaneWidth - (treeRect.right - treeRect.left));
return true; //true sets the keyboard focus, in case we need this elsewhere return true; //true sets the keyboard focus, in case we need this elsewhere
} }
@ -6554,6 +6629,7 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
} }
} }
case IDCANCEL: case IDCANCEL:
SaveCustomDialogSettings(hDlg);
EndDialog(hDlg, rv); EndDialog(hDlg, rv);
ClearCacheList(rdl); ClearCacheList(rdl);
rdl=NULL; rdl=NULL;
@ -6809,6 +6885,7 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
} }
return false; return false;
} }
LRESULT CALLBACK DlgChildSplitProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK DlgChildSplitProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
static bool PaintSpecial; static bool PaintSpecial;
@ -6835,87 +6912,26 @@ LRESULT CALLBACK DlgChildSplitProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
SetCapture(hWnd); SetCapture(hWnd);
return 0; return 0;
case WM_LBUTTONUP: case WM_LBUTTONUP:
PaintSpecial=false; {
temp_x=(GET_X_LPARAM(lParam)-drag_x); PaintSpecial = false;
HWND hDlg,hTree,hList; temp_x = (GET_X_LPARAM(lParam) - drag_x);
RECT treeRect; HWND hDlg = GetParent(hWnd);
RECT listRect; MoveSplitterRelativeDirList(hDlg, temp_x);
hDlg=GetParent(hWnd);
hTree=GetDlgItem(hDlg, IDC_ROM_DIR);
hList=GetDlgItem(hDlg, IDC_ROMLIST);
GetWindowRect(hTree, &treeRect);
POINT p;
p.x=temp_x+treeRect.right;
p.y=treeRect.top;
GetWindowRect(hList, &listRect);
if(p.x>(listRect.right-50))
{
temp_x-=(short)(p.x-(listRect.right-50));
p.x=listRect.right-50;
}
ScreenToClient(hDlg, &p);
if(p.x<50)
{
temp_x+=(short)(50-p.x);
p.x=50;
}
MoveWindow( hWnd, p.x, p.y, listRect.left-treeRect.right, listRect.bottom-listRect.top, FALSE);
MoveWindow(hList, p.x+(listRect.left-treeRect.right), p.y,listRect.right-listRect.left-temp_x, listRect.bottom-listRect.top, TRUE);
p.x=treeRect.left;
p.y=treeRect.top;
ScreenToClient(hDlg, &p);
MoveWindow(hTree, p.x, p.y,treeRect.right-treeRect.left+temp_x,treeRect.bottom-treeRect.top, true);
InvalidateRect(hWnd,NULL, true);
ReleaseCapture(); ReleaseCapture();
return 0; return 0;
}
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (wParam & MK_LBUTTON) {
if (wParam & MK_LBUTTON)
{ {
//move paint location //move paint location
PaintSpecial=true; PaintSpecial = true;
temp_x=(GET_X_LPARAM(lParam)-drag_x); temp_x = (GET_X_LPARAM(lParam) - drag_x);
hDlg=GetParent(hWnd); HWND hDlg = GetParent(hWnd);
hTree=GetDlgItem(hDlg, IDC_ROM_DIR); MoveSplitterRelativeDirList(hDlg, temp_x);
hList=GetDlgItem(hDlg, IDC_ROMLIST);
GetWindowRect(hTree, &treeRect);
p.x=temp_x+treeRect.right;
p.y=treeRect.top;
GetWindowRect(hList, &listRect);
if(p.x>(listRect.right-50))
{
temp_x-=(short)(p.x-(listRect.right-50));
p.x=listRect.right-50;
}
ScreenToClient(hDlg, &p);
if(p.x<50)
{
temp_x+=(short)(50-p.x);
p.x=50;
}
MoveWindow(hWnd, p.x, p.y, listRect.left-treeRect.right, listRect.bottom-listRect.top, FALSE);
MoveWindow(hList, p.x+(listRect.left-treeRect.right), p.y,listRect.right-listRect.left-temp_x, listRect.bottom-listRect.top, TRUE);
p.x=treeRect.left;
p.y=treeRect.top;
ScreenToClient(hDlg, &p);
MoveWindow(hTree, p.x, p.y,treeRect.right-treeRect.left+temp_x,treeRect.bottom-treeRect.top, true);
InvalidateRect(hWnd,NULL, true);
} }
return 0; return 0;
}
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
PaintSpecial=false; PaintSpecial=false;
ReleaseCapture(); ReleaseCapture();

View File

@ -302,6 +302,15 @@ struct dMode
long rate; long rate;
}; };
struct sCustomRomDlgSettings {
int columnFilename;
int columnDescription;
int columnSize;
int folderPaneWidth;
RECT window_size;
bool window_maximized;
};
struct sGUI { struct sGUI {
HWND hWnd; HWND hWnd;
HMENU hMenu; HMENU hMenu;
@ -345,6 +354,8 @@ struct sGUI {
bool IgnoreNextMouseMove; bool IgnoreNextMouseMove;
RECT window_size; RECT window_size;
bool window_maximized; bool window_maximized;
sCustomRomDlgSettings customRomDlgSettings;
int MouseX; int MouseX;
int MouseY; int MouseY;
unsigned int MouseButtons; unsigned int MouseButtons;