Taseditor: fixed filename logic when user creates project from an fm2 or a corrupted fm3

This commit is contained in:
ansstuff 2012-04-26 18:11:24 +00:00
parent 32a7970a99
commit 2dc196a0bd
3 changed files with 11 additions and 8 deletions

View File

@ -415,12 +415,12 @@ bool SaveProjectAs()
ofn.lpstrDefExt = "fm3";
ofn.nMaxFile = 2048;
ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); // initial directory
ofn.lpstrInitialDir = initdir.c_str();
if(GetSaveFileName(&ofn)) //If it is a valid filename
if(GetSaveFileName(&ofn)) // if it is a valid filename
{
project.RenameProject(nameo);
project.RenameProject(nameo, true);
project.save();
taseditor_window.UpdateRecentProjectsArray(nameo);
} else return false;
@ -544,10 +544,10 @@ void SaveCompact()
ofn.lpstrDefExt = "fm3";
ofn.nMaxFile = 2048;
ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); // initial directory
ofn.lpstrInitialDir = initdir.c_str();
if(GetSaveFileName(&ofn)) //If it is a valid filename
if(GetSaveFileName(&ofn)) // if it is a valid filename
project.save(nameo, taseditor_config.savecompact_binary, taseditor_config.savecompact_markers, taseditor_config.savecompact_bookmarks, taseditor_config.savecompact_greenzone, taseditor_config.savecompact_history, taseditor_config.savecompact_piano_roll, taseditor_config.savecompact_selection);
}
}

View File

@ -270,13 +270,13 @@ bool TASEDITOR_PROJECT::load(char* fullname)
splicer.reset();
popup_display.reset();
reset();
RenameProject(fullname);
RenameProject(fullname, load_all);
// restore mouse cursor shape
taseditor_window.must_update_mouse_cursor = true;
return true;
}
void TASEDITOR_PROJECT::RenameProject(char* new_fullname)
void TASEDITOR_PROJECT::RenameProject(char* new_fullname, bool filename_is_correct)
{
projectFile = new_fullname;
char drv[512], dir[512], name[512], ext[512]; // For getting the filename
@ -285,6 +285,9 @@ void TASEDITOR_PROJECT::RenameProject(char* new_fullname)
std::string thisfm2name = name;
thisfm2name.append(".fm2");
fm2FileName = thisfm2name;
// if filename is not correct (for example, user opened a corrupted FM3) clear the filename, so on Ctrl+S user will be forwarded to SaveAs
if (!filename_is_correct)
projectFile.clear();
}
// -----------------------------------------------------------------
std::string TASEDITOR_PROJECT::GetProjectFile()

View File

@ -42,7 +42,7 @@ public:
bool save(const char* different_name = 0, bool save_binary = true, bool save_markers = true, bool save_bookmarks = true, bool save_greenzone = true, bool save_history = true, bool save_piano_roll = true, bool save_selection = true);
bool load(char* fullname);
void RenameProject(char* new_fullname);
void RenameProject(char* new_fullname, bool filename_is_correct);
std::string GetProjectFile();
std::string GetProjectName();