redundant code removed, let windows doing it on by own

This commit is contained in:
CaH4e3 2010-05-08 09:27:42 +00:00
parent c136fcfa1e
commit f0a3f8cf21
12 changed files with 30 additions and 97 deletions

View File

@ -237,7 +237,10 @@ void LoadCDLogFile(){
}
void SaveCDLogFileAs(){
//don't be stupid
const char filter[]="Code Data Log File (*.CDL)\0*.cdl\0All Files (*.*)\0*.*\0\0";
//this feature not for select desired file extension for saved filename
//this feature only for filter file list only for desired file extension.
char nameo[2048];
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
@ -246,16 +249,23 @@ void SaveCDLogFileAs(){
ofn.lpstrTitle="Save Code Data Log File As...";
ofn.lpstrFilter=filter;
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".cdl");
//don't be stupid,
ofn.lpstrDefExt = "cdl";
//do this automatically with system function, it is doing exactly what it written for
//why do you need to do this one more time? All we need here, filled extension in dialog window
//BEFORE saving it, there is no other options.
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt = "cdl";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hCDLogger;
//after that we will get complete file with ext added automatically from DefExt string
//change ext in Save Dialog and it will be saved
if(!GetSaveFileName(&ofn))return;
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".cdl");
//there is bad if something is written AFTER i selectdesired file extension in Save Dialog
//when I want NOT to have any extension, it will write me default one, that is stupid,
//in addition, this is silently forcing default extension to file, but user didn't know about it at all
//that's all what needed to work. I checked this and it works exactly what it should
strcpy(loadedcdfile,nameo);
SaveCDLogFile();
return;
@ -334,12 +344,10 @@ void SaveStrippedRom(){ //this is based off of iNesSave()
strcpy(sromfilename,GetRomName());
if (GameInfo->type==GIT_NSF) {
ofn.lpstrFilter=NSFfilter;
//ofn.lpstrDefExt = "nsf";
AddExtensionIfMissing(sromfilename, sizeof(sromfilename), ".nsf");
ofn.lpstrDefExt = "nsf";
} else {
ofn.lpstrFilter=NESfilter;
//ofn.lpstrDefExt = "nes";
AddExtensionIfMissing(sromfilename, sizeof(sromfilename), ".nes");
ofn.lpstrDefExt = "nes";
}
ofn.lpstrFile=sromfilename;
ofn.nMaxFile=256;
@ -347,14 +355,6 @@ void SaveStrippedRom(){ //this is based off of iNesSave()
ofn.hwndOwner = hCDLogger;
if(!GetSaveFileName(&ofn))return;
if (ofn.nFilterIndex == 1) {
if (GameInfo->type==GIT_NSF) {
AddExtensionIfMissing(sromfilename, sizeof(sromfilename), ".nsf");
} else {
AddExtensionIfMissing(sromfilename, sizeof(sromfilename), ".nes");
}
}
fp = fopen(sromfilename,"wb");
if(GameInfo->type==GIT_NSF)

View File

@ -1565,9 +1565,8 @@ static void PresetExport(int preset)
ofn.lpstrTitle="Export Input Preset To...";
ofn.lpstrFilter=filter;
nameo[0]=0; //No default filename
//AddExtensionIfMissing(nameo, sizeof(nameo), ".pre");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="pre";
ofn.lpstrDefExt="pre";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
std::string initdir = FCEU_GetPath(FCEUMKF_INPUT).c_str();
@ -1583,9 +1582,6 @@ static void PresetExport(int preset)
InputPresetDir[ofn.nFileOffset]=0;
}
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".pre");
FILE *fp=FCEUD_UTF8fopen(nameo,"w");
switch(preset)
{

View File

@ -299,19 +299,13 @@ void SaveRomAs()
ofn.lpstrTitle="Save Nes ROM as...";
ofn.lpstrFilter=filter;
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".nes");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="nes";
ofn.lpstrDefExt="nes";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hMemView;
if (GetSaveFileName(&ofn))
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".nes");
iNesSaveAs(nameo);
}
}
int LoadTable(const char* nameo)
@ -648,17 +642,13 @@ void dumpToFile(const char* buffer, unsigned int size)
ofn.lpstrTitle="Save to file ...";
ofn.lpstrFilter="Binary File (*.BIN)\0*.bin\0All Files (*.*)\0*.*\0\0";
strcpy(name,GetRomName());
AddExtensionIfMissing(name, sizeof(name), ".bin");
ofn.lpstrFile=name;
//ofn.lpstrDefExt="bin";
ofn.lpstrDefExt="bin";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY;
if (GetSaveFileName(&ofn))
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(name, sizeof(name), ".bin");
FILE* memfile = fopen(name, "wb");
if (!memfile || fwrite(buffer, 1, size, memfile) != size)

View File

@ -406,15 +406,14 @@ 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.lpstrDefExt="txt";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
string initdir = FCEU_GetPath(FCEUMKF_MEMW);
@ -432,9 +431,6 @@ static void SaveMemWatch()
MemWatchDir[ofn.nFileOffset]=0;
}
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".txt");
strcpy(memwLastFilename,nameo);
SaveStrings();

View File

@ -481,11 +481,6 @@ 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);
if (!strcmp(Dest, ""))
@ -499,20 +494,16 @@ 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)) {
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(Dest, 1024, TempExt); //1024 checked manually
return 1;
}
@ -525,7 +516,6 @@ bool Save_Watches()
strcpy(Str_Tmp,slash ? slash+1 : gamefilename);
char* dot = strrchr(Str_Tmp, '.');
if(dot) *dot = 0;
strcat(Str_Tmp,".wch");
if(Change_File_S(Str_Tmp, applicationPath, "Save Watches", "Watchlist (*.wch)\0*.wch\0All Files (*.*)\0*.*\0\0", "wch", RamWatchHWnd))
{
FILE *WatchFile = fopen(Str_Tmp,"r+b");

View File

@ -921,15 +921,11 @@ 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)) {
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(szChoice, sizeof(szChoice), ".fm2");
UpdateRecordDialogPath(hwndDlg,szChoice);
}
}

View File

@ -25,21 +25,15 @@ void FCEUD_SaveStateAs()
ofn.lpstrTitle = "Save State As...";
ofn.lpstrFilter = filter;
strcpy(nameo,FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str());
AddExtensionIfMissing(nameo, sizeof(nameo), ".fcs");
ofn.lpstrFile = nameo;
//ofn.lpstrDefExt = "fcs";
ofn.lpstrDefExt = "fcs";
std::string initdir = FCEU_GetPath(FCEUMKF_STATE);
ofn.lpstrInitialDir = initdir.c_str();
ofn.nMaxFile = 256;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(GetSaveFileName(&ofn))
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".fcs");
FCEUI_SaveState(nameo);
}
}
/**

View File

@ -892,9 +892,8 @@ 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.lpstrDefExt="tas";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory
@ -902,9 +901,6 @@ static void SaveProjectAs()
if(GetSaveFileName(&ofn)) //If it is a valid filename
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".tas");
std::string tempstr = nameo; //Make a temporary string for filename
char drv[512], dir[512], name[512], ext[512]; //For getting the filename!
@ -948,17 +944,13 @@ 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.lpstrDefExt="fm2";
ofn.nMaxFile=256;
std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
ofn.lpstrInitialDir=initdir.c_str();
if(GetSaveFileName(&ofn))
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(fname, sizeof(fname), ".fm2");
fstream* osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb");
currMovieData.dump(osRecordingMovie,false);
delete osRecordingMovie;

View File

@ -692,9 +692,8 @@ 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;
@ -702,9 +701,6 @@ int TextHookerSaveTableFile(){
//get the file name or quit
if(!GetSaveFileName(&ofn))return 0;
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".tht");
//open the file
FP = fopen(nameo,"wb");
line = 0; //init the line counter

View File

@ -593,7 +593,6 @@ void ShowLogDirDialog(void){
ofn.lpstrFilter=filter;
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

@ -45,19 +45,13 @@ bool CreateSoundSave()
ofn.lpstrTitle="Log Sound As...";
ofn.lpstrFilter=filter;
strcpy(nameo,GetRomName());
AddExtensionIfMissing(nameo, sizeof(nameo), ".wav");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="wav";
ofn.lpstrDefExt="wav";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
if(GetSaveFileName(&ofn))
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(nameo, sizeof(nameo), ".wav");
return FCEUI_BeginWaveRecord(nameo);
}
return false;
}

View File

@ -2421,21 +2421,15 @@ 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;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn))
{
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(szChoice, sizeof(szChoice), ".avi");
FCEUI_AviBegin(szChoice);
}
}
//Stop AVI recording
@ -2707,9 +2701,8 @@ void SaveMovieAs()
ofn.lpstrTitle="Save Movie as...";
ofn.lpstrFilter=filter;
strcpy(nameo,curMovieFilename);
AddExtensionIfMissing(tempName, ".fm2");
ofn.lpstrFile=nameo;
//ofn.lpstrDefExt="fm2";
ofn.lpstrDefExt="fm2";
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hMemView;
@ -2717,9 +2710,6 @@ void SaveMovieAs()
{
tempName = nameo;
if (ofn.nFilterIndex == 1)
AddExtensionIfMissing(tempName, ".fm2");
FCEUI_CreateMovieFile(tempName);
}
}