Merge pull request #373 from ClusterM/archive-window
Resizable "open archive window" for Windows version
This commit is contained in:
commit
e1f67a0a86
|
@ -18,6 +18,11 @@
|
||||||
//it would be nonreadable because we wouldnt actually decompress the contents
|
//it would be nonreadable because we wouldnt actually decompress the contents
|
||||||
|
|
||||||
static FCEUARCHIVEFILEINFO *currFileSelectorContext;
|
static FCEUARCHIVEFILEINFO *currFileSelectorContext;
|
||||||
|
static RECT oldWindowRect;
|
||||||
|
static RECT newWindowRect;
|
||||||
|
// Minimum window size
|
||||||
|
static const int MIN_WIDTH = 250;
|
||||||
|
static const int MIN_HEIGHT = 150;
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_CFormat_07,0x23170F69,0x40C1,0x278A,0x10,0x00,0x00,0x01,0x10,0x07,0x00,0x00);
|
DEFINE_GUID(CLSID_CFormat_07,0x23170F69,0x40C1,0x278A,0x10,0x00,0x00,0x01,0x10,0x07,0x00,0x00);
|
||||||
|
|
||||||
|
@ -261,6 +266,37 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//used to move all child items in the dialog when you resize (except for the dock fill controls which are resized)
|
||||||
|
BOOL CALLBACK ArchiveEnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||||
|
{
|
||||||
|
RECT crect;
|
||||||
|
HWND parent = GetParent(hwnd);
|
||||||
|
GetWindowRect(hwnd, &crect); //Get rect of current child to be resized
|
||||||
|
ScreenToClient(parent, (LPPOINT)&crect); //Convert rect coordinates to client area coordinates
|
||||||
|
ScreenToClient(parent, ((LPPOINT)&crect) + 1);
|
||||||
|
|
||||||
|
int plusWidth = (newWindowRect.right - newWindowRect.left) - (oldWindowRect.right - oldWindowRect.left);
|
||||||
|
int plusHeight = (newWindowRect.bottom - newWindowRect.top) - (oldWindowRect.bottom - oldWindowRect.top);
|
||||||
|
|
||||||
|
switch (GetDlgCtrlID(hwnd))
|
||||||
|
{
|
||||||
|
case IDC_LIST1:
|
||||||
|
// horizontal and vertical stretch
|
||||||
|
SetWindowPos(hwnd, 0, crect.left, crect.top,
|
||||||
|
crect.right - crect.left + plusWidth, crect.bottom - crect.top + plusHeight,
|
||||||
|
SWP_NOZORDER);
|
||||||
|
break;
|
||||||
|
case IDOK:
|
||||||
|
case IDCANCEL:
|
||||||
|
// movement only
|
||||||
|
SetWindowPos(hwnd, 0, crect.left + plusWidth, crect.top + plusHeight,
|
||||||
|
crect.right - crect.left, crect.bottom - crect.top,
|
||||||
|
SWP_NOZORDER);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
class LibRef
|
class LibRef
|
||||||
{
|
{
|
||||||
|
@ -275,6 +311,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Callback for resizing child controls
|
||||||
static INT_PTR CALLBACK ArchiveFileSelectorCallback(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static INT_PTR CALLBACK ArchiveFileSelectorCallback(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
|
@ -287,6 +324,7 @@ static INT_PTR CALLBACK ArchiveFileSelectorCallback(HWND hwndDlg, UINT uMsg, WPA
|
||||||
std::string& name = (*currFileSelectorContext)[i].name;
|
std::string& name = (*currFileSelectorContext)[i].name;
|
||||||
SendMessage(hwndListbox, LB_ADDSTRING, 0, (LPARAM)name.c_str());
|
SendMessage(hwndListbox, LB_ADDSTRING, 0, (LPARAM)name.c_str());
|
||||||
}
|
}
|
||||||
|
GetWindowRect(hwndDlg, &oldWindowRect);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -309,6 +347,32 @@ static INT_PTR CALLBACK ArchiveFileSelectorCallback(HWND hwndDlg, UINT uMsg, WPA
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case WM_SIZE:
|
||||||
|
{
|
||||||
|
GetWindowRect(hwndDlg, &newWindowRect); // Get new size
|
||||||
|
// Limit window size
|
||||||
|
bool fixSize = false;
|
||||||
|
if (newWindowRect.right - newWindowRect.left < MIN_WIDTH)
|
||||||
|
{
|
||||||
|
newWindowRect.right = newWindowRect.left + MIN_WIDTH;
|
||||||
|
fixSize = true;
|
||||||
|
}
|
||||||
|
if (newWindowRect.bottom - newWindowRect.top < MIN_HEIGHT)
|
||||||
|
{
|
||||||
|
newWindowRect.bottom = newWindowRect.top + MIN_HEIGHT;
|
||||||
|
fixSize = true;
|
||||||
|
}
|
||||||
|
if (fixSize)
|
||||||
|
{
|
||||||
|
SetWindowPos(hwndDlg, 0, newWindowRect.left, newWindowRect.top,
|
||||||
|
newWindowRect.right - newWindowRect.left, newWindowRect.bottom - newWindowRect.top, 0);
|
||||||
|
}
|
||||||
|
// Initiate callback for resizing child controls
|
||||||
|
EnumChildWindows(hwndDlg, ArchiveEnumWindowsProc, 0);
|
||||||
|
InvalidateRect(hwndDlg, 0, TRUE);
|
||||||
|
UpdateWindow(hwndDlg);
|
||||||
|
oldWindowRect = newWindowRect; // Store for future calculations
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -326,10 +390,11 @@ TFormatRecords formatRecords;
|
||||||
static bool archiveSystemInitialized=false;
|
static bool archiveSystemInitialized=false;
|
||||||
|
|
||||||
#ifdef WIN64
|
#ifdef WIN64
|
||||||
static LibRef libref("7z_64.dll");
|
#define _7Z_DLL "7z_64.dll"
|
||||||
#else
|
#else
|
||||||
static LibRef libref("7z.dll");
|
#define _7Z_DLL "7z.dll"
|
||||||
#endif
|
#endif
|
||||||
|
static LibRef libref(_7Z_DLL);
|
||||||
|
|
||||||
void initArchiveSystem()
|
void initArchiveSystem()
|
||||||
{
|
{
|
||||||
|
@ -411,10 +476,17 @@ static std::string wstringFromPROPVARIANT(BSTR bstr, bool& success)
|
||||||
return strret;
|
return strret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool endsWith(const std::string& str, const std::string& suffix)
|
||||||
|
{
|
||||||
|
return (str.size() >= suffix.size()) && (str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
ArchiveScanRecord FCEUD_ScanArchive(std::string fname)
|
ArchiveScanRecord FCEUD_ScanArchive(std::string fname)
|
||||||
{
|
{
|
||||||
if(!archiveSystemInitialized)
|
if(!archiveSystemInitialized)
|
||||||
{
|
{
|
||||||
|
if (endsWith(fname, ".zip") || endsWith(fname, ".7z") || endsWith(fname, ".rar"))
|
||||||
|
MessageBox(hAppWnd, "Could not locate " _7Z_DLL, "Failure reading archive file", 0);
|
||||||
return ArchiveScanRecord();
|
return ArchiveScanRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +584,7 @@ static FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, s
|
||||||
FCEUFILE* fp = 0;
|
FCEUFILE* fp = 0;
|
||||||
|
|
||||||
if(!archiveSystemInitialized) {
|
if(!archiveSystemInitialized) {
|
||||||
MessageBox(hAppWnd,"Could not locate 7z.dll","Failure launching archive browser",0);
|
MessageBox(hAppWnd,"Could not locate " _7Z_DLL, "Failure launching archive browser", 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +592,7 @@ static FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, s
|
||||||
CreateObjectFunc CreateObject = (CreateObjectFunc)GetProcAddress(libref.hmod,"CreateObject");
|
CreateObjectFunc CreateObject = (CreateObjectFunc)GetProcAddress(libref.hmod,"CreateObject");
|
||||||
if(!CreateObject)
|
if(!CreateObject)
|
||||||
{
|
{
|
||||||
MessageBox(hAppWnd,"7z.dll was invalid","Failure launching archive browser",0);
|
MessageBox(hAppWnd, _7Z_DLL " was invalid","Failure launching archive browser",0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1355,7 +1355,7 @@ BEGIN
|
||||||
END
|
END
|
||||||
|
|
||||||
ARCHIVECHOOSERDIALOG DIALOGEX 0, 0, 265, 159
|
ARCHIVECHOOSERDIALOG DIALOGEX 0, 0, 265, 159
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||||
CAPTION "Choose File From Archive"
|
CAPTION "Choose File From Archive"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -2314,6 +2314,11 @@ BEGIN
|
||||||
0
|
0
|
||||||
END
|
END
|
||||||
|
|
||||||
|
ARCHIVECHOOSERDIALOG AFX_DIALOG_LAYOUT
|
||||||
|
BEGIN
|
||||||
|
0
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue