diff --git a/changelog.txt b/changelog.txt index b3290411..47102823 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +13-nov-2009 - mart0258 - Win32 - TASEdit - Added interface functionality (save/load, running TASEdit mid-movie, etc.) 13-nov-2009 - adelikat - made savestate compression togglable 13-nov-2009 - adelikat - made savestate backups togglable 08-nov-2009 - gocha - Win32 - Lua console - added a menu diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 7925ade7..e63561dd 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -226,7 +226,7 @@ BEGIN END POPUP "&Edit" BEGIN - MENUITEM "&Select All", ID_EDIT_SELECTALL, INACTIVE + MENUITEM "&Select All", ID_EDIT_SELECTALL MENUITEM SEPARATOR MENUITEM "Cu&t\tCtrl+X", ID_TASEDIT_CUT, INACTIVE MENUITEM "&Copy\tCtrl+C", ID_TASEDIT_COPY, INACTIVE diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 05de51a1..4f36d0c5 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -275,10 +275,7 @@ bool JumpToFrame(int index) } } - extern int disableBatteryLoading; - disableBatteryLoading = 1; - PowerNES(); - disableBatteryLoading = 0; + poweron(true); currFrameCounter=0; turbo = index>60; pauseframe=index+1; @@ -461,6 +458,9 @@ static void ColumnSet(int column) //Highlights all frames in current input log static void SelectAll() { + for(int i=0;i<=currMovieData.records.size();i++) + selectionFrames.insert(i); + } //cuts the current selection and copies to the clipboard @@ -607,10 +607,16 @@ static void InitDialog() UpdateTasEdit(); } +bool CheckSaveChanges() +{ + //TODO: determine if project has changed, and ask to save changes + return true; +} void KillTasEdit() { - //TODO: determine if project has changed, and ask to save changes + if (!CheckSaveChanges()) + return; DestroyWindow(hwndTasEdit); hwndTasEdit = 0; turbo=false; @@ -623,6 +629,70 @@ static void NewProject() //determine if current project changed //if so, ask to save changes //close current project + + if (!CheckSaveChanges()) + return; + + //TODO: Reinitialise project +} + +//Opens a new Project file +static void OpenProject() +{ +//determine if current project changed +//if so, ask to save changes +//close current project +//open dialog for new project file + + const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0"; //Filetype filter + + OPENFILENAME ofn; //New instance of OPENFILENAME + memset(&ofn,0,sizeof(ofn)); //Set aside some memory + ofn.lStructSize=sizeof(ofn); //Various parameters + ofn.hInstance=fceu_hInstance; + ofn.lpstrTitle="Save TASEdit Project As..."; + ofn.lpstrFilter=TPfilter; + + char nameo[2048]; //File name + strcpy(nameo, GetRomName()); //For now, just use ROM name + + ofn.lpstrFile=nameo; //More parameters + ofn.nMaxFile=256; + ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; + string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory + ofn.lpstrInitialDir=initdir.c_str(); + + if(GetOpenFileName(&ofn)){ //If it is a valid filename + std::string tempstr = nameo; //Make a temporary string for filename + char drv[512], dir[512], name[512], ext[512]; //For getting the filename! + if(tempstr.rfind(".tas") == std::string::npos) //If they haven't put ".tas" after it + { + tempstr.append(".tas"); //Stick it on ourselves + splitpath(tempstr.c_str(), drv, dir, name, ext); //Split the path... + std::string filename = name; //Get the filename + filename.append(ext); //Shove the extension back onto it... + project.SetProjectFile(filename); //And update the project's filename. + } else { //If they've been nice and done it for us... + splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up... + std::string filename = name; //Grab the name... + filename.append(ext); //Stick extension back on... + project.SetProjectFile(filename); //And update the project's filename. + } + project.SetProjectName(GetRomName()); //Set the project's name to the ROM name + std::string thisfm2name = project.GetProjectName(); + thisfm2name.append(".fm2"); //Setup the fm2 name + project.SetFM2Name(thisfm2name); //Set the project's fm2 name + project.LoadProject(project.GetProjectFile()); + } + +} + +// Saves current project +static void SaveProjectAs() +{ +//Save project as new user selected filename +//flag project as not changed + //Creation of a save window const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0"; //Filetype filter @@ -665,29 +735,17 @@ static void NewProject() project.SetFM2Name(thisfm2name); //Set the project's fm2 name project.SaveProject(); } - //TODO: Reinitialise project -} -//Opens a new Project file -static void OpenProject() -{ -//determine if current project changed -//if so, ask to save changes -//close current project -//open dialog for new project file } //Saves current project static void SaveProject() { -//determine if file exists, if not, do SaveProjectAs() +//TODO: determine if file exists, if not, do SaveProjectAs() //Save work, flag project as not changed -} + if (!project.SaveProject()) + SaveProjectAs(); -static void SaveProjectAs() -{ -//Save project as new user selected filename -//flag project as not changed } //Takes a selected .fm2 file and adds it to the Project inputlog @@ -828,7 +886,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case ACCEL_CTRL_O: case ID_FILE_OPENPROJECT: - Replay_LoadMovie(true); //TODO: change function name to LoadProject(true)? + //Replay_LoadMovie(true); //TODO: change function name to LoadProject(true)? + OpenProject(); break; case ACCEL_CTRL_S: diff --git a/src/drivers/win/taseditlib/taseditproj.cpp b/src/drivers/win/taseditlib/taseditproj.cpp index a76a0ed4..d1983b36 100644 --- a/src/drivers/win/taseditlib/taseditproj.cpp +++ b/src/drivers/win/taseditlib/taseditproj.cpp @@ -19,6 +19,16 @@ #include #include "taseditproj.h" +#include "movie.h" + +void TASEDIT_PROJECT::init() +{ + projectName=""; + fm2FileName=""; + projectFile=""; + + changed=false; +} //All the get/set functions... std::string TASEDIT_PROJECT::GetProjectName() @@ -46,13 +56,40 @@ void TASEDIT_PROJECT::SetProjectFile(std::string e) projectFile = e; } -void TASEDIT_PROJECT::SaveProject() +bool TASEDIT_PROJECT::SaveProject() { std::string PFN = GetProjectFile(); const char* filename = PFN.c_str(); std::ofstream ofs; + //ofs << GetProjectName() << std::endl; + //ofs << GetFM2Name() << std::endl; ofs.open(filename); - ofs << GetProjectName() << std::endl; - ofs << GetFM2Name() << std::endl; + + currMovieData.dump(&ofs, true); ofs.close(); -} \ No newline at end of file + + changed=false; + return true; +} + +extern bool LoadFM2(MovieData& movieData, std::istream* fp, int size, bool stopAfterHeader); + + +bool TASEDIT_PROJECT::LoadProject(std::string PFN) +{ + const char* filename = PFN.c_str(); + //char buf[4096]; + SetProjectName(PFN); + std::ifstream ifs; + ifs.open(filename); + //ifs.getline(ifs, 4090); + //ifs.getline(ifs, 4090); + LoadFM2(currMovieData, &ifs, INT_MAX, false); + LoadSubtitles(currMovieData); + poweron(true); + + ifs.close(); + + changed=false; + return true; +} diff --git a/src/drivers/win/taseditlib/taseditproj.h b/src/drivers/win/taseditlib/taseditproj.h index 3408cea9..c517bdfd 100644 --- a/src/drivers/win/taseditlib/taseditproj.h +++ b/src/drivers/win/taseditlib/taseditproj.h @@ -11,6 +11,8 @@ class TASEDIT_PROJECT { public: + void init(); + std::string GetProjectName(); void SetProjectName(std::string e); @@ -20,8 +22,9 @@ public: std::string GetProjectFile(); void SetProjectFile(std::string e); - //Guess what this function is for... - void SaveProject(); + //Guess what these functions are for... + bool SaveProject(); + bool LoadProject(std::string PFN); private: //The TASEdit Project's name @@ -30,4 +33,7 @@ private: std::string fm2FileName; //The TASEdit Project's filename (For saving purposes) std::string projectFile; + + // If there are unsaved changes. + bool changed; }; \ No newline at end of file diff --git a/src/input/zapper.h b/src/input/zapper.h index 9141ce1d..22876c4b 100644 --- a/src/input/zapper.h +++ b/src/input/zapper.h @@ -1,6 +1,8 @@ #ifndef _ZAPPER_H_ #define _ZAPPER_H_ +#include "types.h" + struct ZAPPER { uint32 mzx,mzy,mzb; diff --git a/src/movie.cpp b/src/movie.cpp index 0692b216..34dfc488 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -648,7 +648,7 @@ void FCEUI_StopMovie() if (bindSavestate) AutoSS = false; //If bind movies to savestates is true, then there is no longer a valid auto-save to load } -static void poweron(bool shouldDisableBatteryLoading) +void poweron(bool shouldDisableBatteryLoading) { //// make a for-movie-recording power-on clear the game's save data, too //extern char lastLoadedGameName [2048]; diff --git a/src/movie.h b/src/movie.h index 215bd6ba..b5cd28c7 100644 --- a/src/movie.h +++ b/src/movie.h @@ -9,6 +9,7 @@ #include "input/zapper.h" #include "utils/guid.h" +#include "utils/md5.h" struct FCEUFILE; @@ -267,4 +268,7 @@ void LoadSubtitles(MovieData); void ProcessSubtitles(void); void FCEU_DisplaySubtitles(char *format, ...); +void poweron(bool shouldDisableBatteryLoading); + + #endif //__MOVIE_H_