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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do7zip(HWND hParent, std::string fname)
|
void do7zip(HWND hParent, std::string fname, std::string* innerFilename)
|
||||||
{
|
{
|
||||||
LibRef libref("7zxa.dll");
|
LibRef libref("7zxa.dll");
|
||||||
if(!libref.hmod) {
|
if(!libref.hmod) {
|
||||||
|
@ -389,7 +389,21 @@ void do7zip(HWND hParent, std::string fname)
|
||||||
fileSelectorContext.items.push_back(item);
|
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)
|
if(ret != LB_ERR)
|
||||||
{
|
{
|
||||||
FileSelectorContext::Item& item = fileSelectorContext.items[ret];
|
FileSelectorContext::Item& item = fileSelectorContext.items[ret];
|
||||||
|
@ -402,8 +416,8 @@ void do7zip(HWND hParent, std::string fname)
|
||||||
FILE* outf = fopen(tempname,"wb");
|
FILE* outf = fopen(tempname,"wb");
|
||||||
fwrite(&data[0],1,item.size,outf);
|
fwrite(&data[0],1,item.size,outf);
|
||||||
fclose(outf);
|
fclose(outf);
|
||||||
void ALoad(char *nameo,char* actualfile);
|
void ALoad(char *nameo,char* actualfile,char* archiveFile);
|
||||||
ALoad((char*)item.name.c_str(),tempname);
|
ALoad((char*)item.name.c_str(),tempname,(char*)fname.c_str());
|
||||||
|
|
||||||
} //if we extracted the file correctly
|
} //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 "tasedit.h"
|
||||||
#include "oldmovie.h"
|
#include "oldmovie.h"
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
|
#include "7zip.h"
|
||||||
|
|
||||||
#include "guiconfig.h"
|
#include "guiconfig.h"
|
||||||
#include "timing.h"
|
#include "timing.h"
|
||||||
|
@ -113,6 +114,14 @@ static int vchanged = 0;
|
||||||
|
|
||||||
// Internal functions
|
// 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)
|
static void ConvertFCM(HWND hwndOwner)
|
||||||
{
|
{
|
||||||
std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
|
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
|
// Recreate the menus
|
||||||
for(x = MAX_NUMBER_OF_RECENT_FILES - 1; x >= 0; x--)
|
for(x = MAX_NUMBER_OF_RECENT_FILES - 1; x >= 0; x--)
|
||||||
{
|
{
|
||||||
char tmp[128 + 5];
|
|
||||||
|
|
||||||
// Skip empty strings
|
// Skip empty strings
|
||||||
if(!strs[x])
|
if(!strs[x])
|
||||||
{
|
|
||||||
continue;
|
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.cbSize = sizeof(moo);
|
||||||
moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
|
moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
|
||||||
|
|
||||||
// Fill in the menu text.
|
//// Fill in the menu text.
|
||||||
if(strlen(strs[x]) < 128)
|
//if(strlen(strs[x]) < 128)
|
||||||
{
|
//{
|
||||||
sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x]);
|
// sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x]);
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x] + strlen( strs[x] ) - 127);
|
// sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x] + strlen( strs[x] ) - 127);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Insert the menu item
|
// Insert the menu item
|
||||||
moo.cch = strlen(tmp);
|
moo.cch = tmp.size();
|
||||||
moo.fType = 0;
|
moo.fType = 0;
|
||||||
moo.wID = baseid + x;
|
moo.wID = baseid + x;
|
||||||
moo.dwTypeData = tmp;
|
moo.dwTypeData = (LPSTR)tmp.c_str();
|
||||||
InsertMenuItem(menu, 0, 1, &moo);
|
InsertMenuItem(menu, 0, 1, &moo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,10 +529,10 @@ void FCEUD_HideMenuToggle(void)
|
||||||
ToggleHideMenu();
|
ToggleHideMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALoad(char *nameo,char* actualfile)
|
void ALoad(char *nameo,char* actualfile,char* archiveFile)
|
||||||
{
|
{
|
||||||
bool isvirtual = (actualfile==0);
|
bool isvirtual = (actualfile!=0);
|
||||||
if(isvirtual) actualfile = nameo;
|
if(!isvirtual) actualfile = nameo;
|
||||||
if(FCEUI_LoadGameVirtual(actualfile, nameo, 1))
|
if(FCEUI_LoadGameVirtual(actualfile, nameo, 1))
|
||||||
{
|
{
|
||||||
pal_emulation = FCEUI_GetCurrentVidSystem(0, 0);
|
pal_emulation = FCEUI_GetCurrentVidSystem(0, 0);
|
||||||
|
@ -525,8 +542,13 @@ void ALoad(char *nameo,char* actualfile)
|
||||||
SetMainWindowStuff();
|
SetMainWindowStuff();
|
||||||
|
|
||||||
//todo-add recent files from archives somehow
|
//todo-add recent files from archives somehow
|
||||||
if(!isvirtual)
|
std::string recentFileName = nameo;
|
||||||
AddRecentFile(nameo);
|
if(archiveFile)
|
||||||
|
recentFileName = (std::string)"|" + archiveFile + "|" + nameo;
|
||||||
|
else
|
||||||
|
recentFileName = nameo;
|
||||||
|
|
||||||
|
AddRecentFile(recentFileName.c_str());
|
||||||
|
|
||||||
RefreshThrottleFPS();
|
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..
|
//if the user selected a 7zip file, then we have some work to do..
|
||||||
//todo - scan file instead of checking extension
|
//todo - scan file instead of checking extension
|
||||||
std::string fname = nameo;
|
std::string fname = nameo;
|
||||||
extern void do7zip(HWND hwnd, std::string fname);
|
|
||||||
if(fname.substr(fname.size()-3,3) == ".7z")
|
if(fname.substr(fname.size()-3,3) == ".7z")
|
||||||
{
|
{
|
||||||
do7zip(hParent, fname);
|
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.
|
// 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(wParam >= MENU_FIRST_RECENT_FILE && wParam <= MENU_FIRST_RECENT_FILE + MAX_NUMBER_OF_RECENT_FILES - 1)
|
||||||
{
|
{
|
||||||
if(recent_files[wParam - MENU_FIRST_RECENT_FILE])
|
char*& fname = recent_files[wParam - MENU_FIRST_RECENT_FILE];
|
||||||
ALoad(recent_files[wParam - MENU_FIRST_RECENT_FILE],0);
|
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))
|
switch(LOWORD(wParam))
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ void ByebyeWindow();
|
||||||
void DoTimingConfigFix();
|
void DoTimingConfigFix();
|
||||||
int CreateMainWindow();
|
int CreateMainWindow();
|
||||||
void UpdateCheckedMenuItems();
|
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);
|
void LoadNewGamey(HWND hParent, const char *initialdir);
|
||||||
int BrowseForFolder(HWND hParent, const char *htext, char *buf);
|
int BrowseForFolder(HWND hParent, const char *htext, char *buf);
|
||||||
void UpdateCheckedMenuItems();
|
void UpdateCheckedMenuItems();
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
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>
|
||||||
<Configuration
|
<Configuration
|
||||||
|
@ -181,6 +181,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
|
CommandLine="xcopy /d $(ProjectDir)\..\src\drivers\win\7zxa.dll $(OutDir)"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
|
@ -707,6 +708,10 @@
|
||||||
RelativePath="..\src\drivers\win\7zip.cpp"
|
RelativePath="..\src\drivers\win\7zip.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\src\drivers\win\7zip.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\src\drivers\win\args.cpp"
|
RelativePath="..\src\drivers\win\args.cpp"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue