Added something to automatically add an extension to the filename in the dialog window. I think I'm going to make CaH4e3 mad at me too.

This commit is contained in:
ugetab 2010-05-08 08:30:16 +00:00
parent 111cc48167
commit c136fcfa1e
12 changed files with 39 additions and 19 deletions

View File

@ -245,9 +245,10 @@ void SaveCDLogFileAs(){
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save Code Data Log File As...";
ofn.lpstrFilter=filter;
ofn.lpstrDefExt = "cdl";
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".cdl");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt = "cdl";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hCDLogger;
@ -330,14 +331,16 @@ void SaveStrippedRom(){ //this is based off of iNesSave()
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save Stripped File As...";
strcpy(sromfilename,GetRomName());
if (GameInfo->type==GIT_NSF) {
ofn.lpstrFilter=NSFfilter;
ofn.lpstrDefExt = "nsf";
//ofn.lpstrDefExt = "nsf";
AddExtensionIfMissing(sromfilename, sizeof(sromfilename), ".nsf");
} else {
ofn.lpstrFilter=NESfilter;
ofn.lpstrDefExt = "nes";
//ofn.lpstrDefExt = "nes";
AddExtensionIfMissing(sromfilename, sizeof(sromfilename), ".nes");
}
strcpy(sromfilename,GetRomName());
ofn.lpstrFile=sromfilename;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;

View File

@ -1564,8 +1564,10 @@ static void PresetExport(int preset)
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Export Input Preset To...";
ofn.lpstrFilter=filter;
nameo[0]=0;
nameo[0]=0; //No default filename
//AddExtensionIfMissing(nameo, sizeof(nameo), ".pre");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="pre";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
std::string initdir = FCEU_GetPath(FCEUMKF_INPUT).c_str();

View File

@ -298,9 +298,10 @@ void SaveRomAs()
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save Nes ROM as...";
ofn.lpstrFilter=filter;
ofn.lpstrDefExt="nes";
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".nes");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="nes";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hMemView;
@ -646,9 +647,10 @@ void dumpToFile(const char* buffer, unsigned int size)
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save to file ...";
ofn.lpstrFilter="Binary File (*.BIN)\0*.bin\0All Files (*.*)\0*.*\0\0";
ofn.lpstrDefExt="bin";
strcpy(name,GetRomName());
AddExtensionIfMissing(name, sizeof(name), ".bin");
ofn.lpstrFile=name;
//ofn.lpstrDefExt="bin";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY;

View File

@ -406,13 +406,15 @@ static void SaveMemWatch()
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save Memory Watch As...";
ofn.lpstrFilter=filter;
ofn.lpstrDefExt="txt";
//ofn.lpstrDefExt="txt";
char nameo[2048];
if (!memwLastFilename[0])
strcpy(nameo,GetRomName());
else
strcpy(nameo,memwLastFilename);
AddExtensionIfMissing(nameo, sizeof(nameo), ".txt");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="txt";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
string initdir = FCEU_GetPath(FCEUMKF_MEMW);

View File

@ -482,6 +482,9 @@ int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, H
OPENFILENAME ofn;
char *TempExt = 0;
TempExt=(char*)malloc(sizeof(Ext)+2);
strcpy(TempExt, ".");
strcat(TempExt, Ext);
SetCurrentDirectory(applicationPath);
@ -496,20 +499,17 @@ int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, H
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.hInstance = hInst;
AddExtensionIfMissing(Dest, 1024, TempExt); //1024 checked manually
ofn.lpstrFile = Dest;
ofn.nMaxFile = 2047;
ofn.lpstrFilter = Filter;
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir = Dir;
ofn.lpstrTitle = Titre;
ofn.lpstrDefExt = Ext;
//ofn.lpstrDefExt = Ext;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
if (GetSaveFileName(&ofn)) {
TempExt=(char*)malloc(sizeof(Ext)+2);
strcpy(TempExt, ".");
strcat(TempExt, Ext);
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(Dest, 1024, TempExt); //1024 checked manually

View File

@ -921,8 +921,9 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFilter = "FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0";
AddExtensionIfMissing(szChoice, sizeof(szChoice), ".fm2");
ofn.lpstrFile = szChoice;
ofn.lpstrDefExt = "fm2";
//ofn.lpstrDefExt = "fm2";
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn)) {

View File

@ -24,9 +24,10 @@ void FCEUD_SaveStateAs()
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Save State As...";
ofn.lpstrFilter = filter;
ofn.lpstrDefExt = "fcs";
strcpy(nameo,FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str());
AddExtensionIfMissing(nameo, sizeof(nameo), ".fcs");
ofn.lpstrFile = nameo;
//ofn.lpstrDefExt = "fcs";
std::string initdir = FCEU_GetPath(FCEUMKF_STATE);
ofn.lpstrInitialDir = initdir.c_str();
ofn.nMaxFile = 256;

View File

@ -892,7 +892,9 @@ static void SaveProjectAs()
char nameo[2048]; //File name
strcpy(nameo, GetRomName()); //For now, just use ROM name
AddExtensionIfMissing(nameo, sizeof(nameo), ".tas");
ofn.lpstrFile=nameo; //More parameters
//ofn.lpstrDefExt="tas";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory
@ -946,7 +948,9 @@ static void Export()
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Export TAS as...";
ofn.lpstrFilter=filter;
AddExtensionIfMissing(fname, sizeof(fname), ".fm2");
ofn.lpstrFile=fname;
//ofn.lpstrDefExt="fm2";
ofn.nMaxFile=256;
std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
ofn.lpstrInitialDir=initdir.c_str();

View File

@ -692,8 +692,9 @@ int TextHookerSaveTableFile(){
ofn.lpstrTitle="Load Table File...";
ofn.lpstrFilter=filter;
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".tht");
ofn.lpstrFile=nameo;
ofn.lpstrDefExt="tht";
//ofn.lpstrDefExt="tht";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_EXTENSIONDIFFERENT;
ofn.hwndOwner = hCDLogger;

View File

@ -591,9 +591,9 @@ void ShowLogDirDialog(void){
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Log Trace As...";
ofn.lpstrFilter=filter;
//ofn.lpstrDefExt="log";
strcpy(nameo,GetRomName());
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="log";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hTracer;

View File

@ -44,9 +44,10 @@ bool CreateSoundSave()
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Log Sound As...";
ofn.lpstrFilter=filter;
ofn.lpstrDefExt="wav";
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".wav");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="wav";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;

View File

@ -2421,8 +2421,9 @@ void FCEUD_AviRecordTo(void)
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hAppWnd;
ofn.lpstrFilter = "AVI Files (*.avi)\0*.avi\0All Files (*.*)\0*.*\0\0";
AddExtensionIfMissing(szChoice, sizeof(szChoice), ".avi");
ofn.lpstrFile = szChoice;
ofn.lpstrDefExt = "avi";
//ofn.lpstrDefExt = "avi";
ofn.lpstrTitle = "Save AVI as";
ofn.nMaxFile = MAX_PATH;
@ -2706,7 +2707,9 @@ void SaveMovieAs()
ofn.lpstrTitle="Save Movie as...";
ofn.lpstrFilter=filter;
strcpy(nameo,curMovieFilename);
AddExtensionIfMissing(tempName, ".fm2");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="fm2";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hMemView;