repair recent filenames
support recent filenames with 7z archives
This commit is contained in:
parent
6f9831ec68
commit
f334b0dce8
|
@ -327,7 +327,7 @@ static BOOL CALLBACK ArchiveFileSelectorCallback(HWND hwndDlg, UINT uMsg, WPARAM
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void do7zip(HWND hParent, std::string fname)
|
||||
void do7zip(HWND hParent, std::string fname, std::string* innerFilename)
|
||||
{
|
||||
LibRef libref("7zxa.dll");
|
||||
if(!libref.hmod) {
|
||||
|
@ -389,7 +389,21 @@ void do7zip(HWND hParent, std::string fname)
|
|||
fileSelectorContext.items.push_back(item);
|
||||
}
|
||||
|
||||
int ret = DialogBoxParam(fceu_hInstance, "7ZIPARCHIVEDIALOG", hParent, ArchiveFileSelectorCallback, (LPARAM)0);
|
||||
//try to load the file directly if we're in autopilot
|
||||
int ret = LB_ERR;
|
||||
if(innerFilename)
|
||||
{
|
||||
for(uint32 i=0;i<fileSelectorContext.items.size();i++)
|
||||
if(fileSelectorContext.items[i].name == *innerFilename)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
//or use the UI if we're not
|
||||
ret = DialogBoxParam(fceu_hInstance, "7ZIPARCHIVEDIALOG", hParent, ArchiveFileSelectorCallback, (LPARAM)0);
|
||||
|
||||
if(ret != LB_ERR)
|
||||
{
|
||||
FileSelectorContext::Item& item = fileSelectorContext.items[ret];
|
||||
|
@ -402,8 +416,8 @@ void do7zip(HWND hParent, std::string fname)
|
|||
FILE* outf = fopen(tempname,"wb");
|
||||
fwrite(&data[0],1,item.size,outf);
|
||||
fclose(outf);
|
||||
void ALoad(char *nameo,char* actualfile);
|
||||
ALoad((char*)item.name.c_str(),tempname);
|
||||
void ALoad(char *nameo,char* actualfile,char* archiveFile);
|
||||
ALoad((char*)item.name.c_str(),tempname,(char*)fname.c_str());
|
||||
|
||||
} //if we extracted the file correctly
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
//if you want to autopilot this, pass in an innerfilename to try and automatically load
|
||||
void do7zip(HWND hParent, std::string fname, std::string* innerFilename=0);
|
|
@ -47,6 +47,7 @@
|
|||
#include "tasedit.h"
|
||||
#include "oldmovie.h"
|
||||
#include "movie.h"
|
||||
#include "7zip.h"
|
||||
|
||||
#include "guiconfig.h"
|
||||
#include "timing.h"
|
||||
|
@ -113,6 +114,14 @@ static int vchanged = 0;
|
|||
|
||||
// Internal functions
|
||||
|
||||
void SplitRecentArchiveFilename(std::string src, std::string& archive, std::string& file)
|
||||
{
|
||||
src = src.substr(1);
|
||||
size_t pipe = src.find_first_of('|');
|
||||
archive = src.substr(0,pipe);
|
||||
file = src.substr(pipe+1);
|
||||
}
|
||||
|
||||
static void ConvertFCM(HWND hwndOwner)
|
||||
{
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
|
@ -349,32 +358,40 @@ void UpdateRMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int basei
|
|||
// Recreate the menus
|
||||
for(x = MAX_NUMBER_OF_RECENT_FILES - 1; x >= 0; x--)
|
||||
{
|
||||
char tmp[128 + 5];
|
||||
|
||||
// Skip empty strings
|
||||
if(!strs[x])
|
||||
{
|
||||
continue;
|
||||
|
||||
std::string tmp = strs[x];
|
||||
if(tmp[0] == '|')
|
||||
{
|
||||
std::string archiveName, fileName;
|
||||
SplitRecentArchiveFilename(tmp,archiveName,fileName);
|
||||
tmp = archiveName + " <" + fileName + ">";
|
||||
}
|
||||
|
||||
//clamp this string to 128 chars
|
||||
if(tmp.size()>128)
|
||||
tmp = tmp.substr(0,128);
|
||||
|
||||
moo.cbSize = sizeof(moo);
|
||||
moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
|
||||
|
||||
// Fill in the menu text.
|
||||
if(strlen(strs[x]) < 128)
|
||||
{
|
||||
sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x] + strlen( strs[x] ) - 127);
|
||||
}
|
||||
//// Fill in the menu text.
|
||||
//if(strlen(strs[x]) < 128)
|
||||
//{
|
||||
// sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x]);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x] + strlen( strs[x] ) - 127);
|
||||
//}
|
||||
|
||||
// Insert the menu item
|
||||
moo.cch = strlen(tmp);
|
||||
moo.cch = tmp.size();
|
||||
moo.fType = 0;
|
||||
moo.wID = baseid + x;
|
||||
moo.dwTypeData = tmp;
|
||||
moo.dwTypeData = (LPSTR)tmp.c_str();
|
||||
InsertMenuItem(menu, 0, 1, &moo);
|
||||
}
|
||||
|
||||
|
@ -512,10 +529,10 @@ void FCEUD_HideMenuToggle(void)
|
|||
ToggleHideMenu();
|
||||
}
|
||||
|
||||
void ALoad(char *nameo,char* actualfile)
|
||||
void ALoad(char *nameo,char* actualfile,char* archiveFile)
|
||||
{
|
||||
bool isvirtual = (actualfile==0);
|
||||
if(isvirtual) actualfile = nameo;
|
||||
bool isvirtual = (actualfile!=0);
|
||||
if(!isvirtual) actualfile = nameo;
|
||||
if(FCEUI_LoadGameVirtual(actualfile, nameo, 1))
|
||||
{
|
||||
pal_emulation = FCEUI_GetCurrentVidSystem(0, 0);
|
||||
|
@ -525,8 +542,13 @@ void ALoad(char *nameo,char* actualfile)
|
|||
SetMainWindowStuff();
|
||||
|
||||
//todo-add recent files from archives somehow
|
||||
if(!isvirtual)
|
||||
AddRecentFile(nameo);
|
||||
std::string recentFileName = nameo;
|
||||
if(archiveFile)
|
||||
recentFileName = (std::string)"|" + archiveFile + "|" + nameo;
|
||||
else
|
||||
recentFileName = nameo;
|
||||
|
||||
AddRecentFile(recentFileName.c_str());
|
||||
|
||||
RefreshThrottleFPS();
|
||||
|
||||
|
@ -576,7 +598,6 @@ void LoadNewGamey(HWND hParent, const char *initialdir)
|
|||
//if the user selected a 7zip file, then we have some work to do..
|
||||
//todo - scan file instead of checking extension
|
||||
std::string fname = nameo;
|
||||
extern void do7zip(HWND hwnd, std::string fname);
|
||||
if(fname.substr(fname.size()-3,3) == ".7z")
|
||||
{
|
||||
do7zip(hParent, fname);
|
||||
|
@ -731,8 +752,18 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
// A menu item from the recent files menu was clicked.
|
||||
if(wParam >= MENU_FIRST_RECENT_FILE && wParam <= MENU_FIRST_RECENT_FILE + MAX_NUMBER_OF_RECENT_FILES - 1)
|
||||
{
|
||||
if(recent_files[wParam - MENU_FIRST_RECENT_FILE])
|
||||
ALoad(recent_files[wParam - MENU_FIRST_RECENT_FILE],0);
|
||||
char*& fname = recent_files[wParam - MENU_FIRST_RECENT_FILE];
|
||||
if(fname)
|
||||
{
|
||||
if(fname[0] == '|')
|
||||
{
|
||||
std::string fnamestr = fname, archiveName, fileName;
|
||||
SplitRecentArchiveFilename(fnamestr,archiveName,fileName);
|
||||
do7zip(hWnd,archiveName,&fileName);
|
||||
}
|
||||
else
|
||||
ALoad(fname,0);
|
||||
}
|
||||
}
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ void ByebyeWindow();
|
|||
void DoTimingConfigFix();
|
||||
int CreateMainWindow();
|
||||
void UpdateCheckedMenuItems();
|
||||
void ALoad(char *nameo,char* actualfile=0);
|
||||
void ALoad(char *nameo,char* actualfile=0, char* archiveFile=0);
|
||||
void LoadNewGamey(HWND hParent, const char *initialdir);
|
||||
int BrowseForFolder(HWND hParent, const char *htext, char *buf);
|
||||
void UpdateCheckedMenuItems();
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="xcopy /d $(ProjectDir)\..\src\drivers\win\7zxa.dll $(OutDir)"
|
||||
CommandLine="xcopy /y /d $(ProjectDir)\..\src\drivers\win\7zxa.dll $(OutDir)"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
|
@ -181,6 +181,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="xcopy /d $(ProjectDir)\..\src\drivers\win\7zxa.dll $(OutDir)"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
|
@ -707,6 +708,10 @@
|
|||
RelativePath="..\src\drivers\win\7zip.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\drivers\win\7zip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\drivers\win\args.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue