Win32 - TASEdit - more cleanup and commenting about what needs to be done.

This commit is contained in:
adelikat 2010-05-25 18:04:33 +00:00
parent 042feb025f
commit 50928c86fa
3 changed files with 57 additions and 56 deletions

View File

@ -14,7 +14,7 @@
#include "keyboard.h" #include "keyboard.h"
#include "joystick.h" #include "joystick.h"
#include "help.h" #include "help.h"
#include "main.h" //So we can use the GetRomName() function! #include "main.h" //For the GetRomName() function
using namespace std; using namespace std;
@ -39,7 +39,7 @@ static TSelectionFrames selectionFrames;
//add a new fceud_ function?? blehhh maybe //add a new fceud_ function?? blehhh maybe
extern EMOVIEMODE movieMode; extern EMOVIEMODE movieMode;
TASEDIT_PROJECT project; //Create an instance of the project TASEDIT_PROJECT project;
static void GetDispInfo(NMLVDISPINFO* nmlvDispInfo) static void GetDispInfo(NMLVDISPINFO* nmlvDispInfo)
{ {
@ -411,7 +411,7 @@ static void DeleteFrames()
if(frames == currMovieData.records.size()) if(frames == currMovieData.records.size())
{ {
MessageBox(hwndTasEdit,"Please don't delete all of the frames in the movie. This violates an internal invariant we need to keep.","Error deleting",0); MessageBox(hwndTasEdit,"Please don't delete all of the frames in the movie. This violates an internal invariant we need to keep.","Error deleting",0);
return; return; ///adelikat: why not just add an empty frame in the event of deleting all frames?
} }
//this is going to be _really_ slow. //this is going to be _really_ slow.
@ -820,22 +820,25 @@ static void NewProject()
if (!CheckSaveChanges()) if (!CheckSaveChanges())
return; return;
//TODO: Reinitialise project //TODO: close current project instance, create a new one with a non-parameterized constructor
} }
//Opens a new Project file //Opens a new Project file
static void OpenProject() static void OpenProject()
{ {
//determine if current project changed //TODO
//if so, ask to save changes //determine if current project changed
//close current project //if so, ask to save changes
//open dialog for new project file //close current project
//If OPENFILENAME dialog successful, open up a completely new project instance and scrap the old one
//Run the project Load() function to pull all info from the .tas file into this new project instance
const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0"; //Filetype filter const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0";
OPENFILENAME ofn; //New instance of OPENFILENAME OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn)); //Set aside some memory memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn); //Various parameters ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance; ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Open TASEdit Project..."; ofn.lpstrTitle="Open TASEdit Project...";
ofn.lpstrFilter=TPfilter; ofn.lpstrFilter=TPfilter;
@ -843,32 +846,32 @@ static void OpenProject()
char nameo[2048]; //File name char nameo[2048]; //File name
strcpy(nameo, GetRomName()); //For now, just use ROM name strcpy(nameo, GetRomName()); //For now, just use ROM name
ofn.lpstrFile=nameo; //More parameters ofn.lpstrFile=nameo;
ofn.nMaxFile=256; ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST;
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
ofn.lpstrInitialDir=initdir.c_str(); ofn.lpstrInitialDir=initdir.c_str();
if(GetOpenFileName(&ofn)){ //If it is a valid filename if(GetOpenFileName(&ofn)){ //If it is a valid filename
std::string tempstr = nameo; //Make a temporary string for filename std::string tempstr = nameo; //Make a temporary string for filename
char drv[512], dir[512], name[512], ext[512]; //For getting the 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 if(tempstr.rfind(".tas") == std::string::npos) //If they haven't put ".tas" after it
{ {
tempstr.append(".tas"); //Stick it on ourselves tempstr.append(".tas"); //Stick it on ourselves
splitpath(tempstr.c_str(), drv, dir, name, ext); //Split the path... splitpath(tempstr.c_str(), drv, dir, name, ext); //Split the path...
std::string filename = name; //Get the filename std::string filename = name; //Get the filename
filename.append(ext); //Shove the extension back onto it... filename.append(ext); //Shove the extension back onto it...
project.SetProjectFile(filename); //And update the project's filename. project.SetProjectFile(filename); //And update the project's filename.
} else { //If they've been nice and done it for us... } else { //If they've been nice and done it for us...
splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up... splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up...
std::string filename = name; //Grab the name... std::string filename = name; //Grab the name...
filename.append(ext); //Stick extension back on... filename.append(ext); //Stick extension back on...
project.SetProjectFile(filename); //And update the project's filename. project.SetProjectFile(filename); //And update the project's filename.
} }
project.SetProjectName(GetRomName()); //Set the project's name to the ROM name project.SetProjectName(GetRomName()); //Set the project's name to the ROM name
std::string thisfm2name = project.GetProjectName(); std::string thisfm2name = project.GetProjectName();
thisfm2name.append(".fm2"); //Setup the fm2 name thisfm2name.append(".fm2"); //Setup the fm2 name
project.SetFM2Name(thisfm2name); //Set the project's fm2 name project.SetFM2Name(thisfm2name); //Set the project's fm2 name
project.LoadProject(project.GetProjectFile()); project.LoadProject(project.GetProjectFile());
} }
@ -880,40 +883,39 @@ static void SaveProjectAs()
//Save project as new user selected filename //Save project as new user selected filename
//flag project as not changed //flag project as not changed
//Creation of a save window
const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0"; //Filetype filter const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0"; //Filetype filter
OPENFILENAME ofn; //New instance of OPENFILENAME OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn)); //Set aside some memory memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn); //Various parameters ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance; ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save TASEdit Project As..."; ofn.lpstrTitle="Save TASEdit Project As...";
ofn.lpstrFilter=TPfilter; ofn.lpstrFilter=TPfilter;
char nameo[2048]; //File name char nameo[2048]; //File name
strcpy(nameo, GetRomName()); //For now, just use ROM name strcpy(nameo, GetRomName()); //For now, just use ROM name
ofn.lpstrFile=nameo; //More parameters ofn.lpstrFile=nameo; //More parameters
ofn.lpstrDefExt="tas"; ofn.lpstrDefExt="tas";
ofn.nMaxFile=256; ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; 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(); ofn.lpstrInitialDir=initdir.c_str();
if(GetSaveFileName(&ofn)) //If it is a valid filename if(GetSaveFileName(&ofn)) //If it is a valid filename
{ {
std::string tempstr = nameo; //Make a temporary string for filename std::string tempstr = nameo; //Make a temporary string for filename
char drv[512], dir[512], name[512], ext[512]; //For getting the filename! char drv[512], dir[512], name[512], ext[512]; //For getting the filename!
splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up... splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up...
std::string filename = name; //Grab the name... std::string filename = name; //Grab the name...
filename.append(ext); //Stick extension back on... filename.append(ext); //Stick extension back on...
project.SetProjectFile(filename); //And update the project's filename. project.SetProjectFile(filename); //And update the project's filename.
project.SetProjectName(GetRomName()); //Set the project's name to the ROM name project.SetProjectName(GetRomName()); //Set the project's name to the ROM name
std::string thisfm2name = project.GetProjectName(); std::string thisfm2name = project.GetProjectName();
thisfm2name.append(".fm2"); //Setup the fm2 name thisfm2name.append(".fm2"); //Setup the fm2 name
project.SetFM2Name(thisfm2name); //Set the project's fm2 name project.SetFM2Name(thisfm2name); //Set the project's fm2 name
project.SaveProject(); project.SaveProject();
} }
@ -926,17 +928,21 @@ static void SaveProject()
//Save work, flag project as not changed //Save work, flag project as not changed
if (!project.SaveProject()) if (!project.SaveProject())
SaveProjectAs(); SaveProjectAs();
} }
//Takes a selected .fm2 file and adds it to the Project inputlog //Takes a selected .fm2 file and adds it to the Project inputlog
static void Import() static void Import()
{ {
//Pull the fm2 header, comments, subtitle information out and put it into the project info
//Pull the input out and add it to the main branch input log file
} }
//Takes current inputlog and saves it as a .fm2 file //Takes current inputlog and saves it as a .fm2 file
static void Export() static void Export()
{ {
//TODO: redesign this
//Dump project header info into file, then comments & subtitles, then input log
//This will require special prunctions, ::DumpHeader ::DumpComments etc
const char filter[]="FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0"; const char filter[]="FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0";
char fname[2048] = {0}; char fname[2048] = {0};
OPENFILENAME ofn; OPENFILENAME ofn;
@ -1074,7 +1080,6 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case ACCEL_CTRL_O: case ACCEL_CTRL_O:
case ID_FILE_OPENPROJECT: case ID_FILE_OPENPROJECT:
//Replay_LoadMovie(true); //TODO: change function name to LoadProject(true)?
OpenProject(); OpenProject();
break; break;

View File

@ -1,18 +1,8 @@
//Implementation file of TASEdit Project file object //Implementation file of TASEdit Project file object
//Written by Chris220
//Contains all the TASEDit project and all files/settings associated with it //Contains all the TASEDit project and all files/settings associated with it
//Also contains all methods for manipulating the project files/settings, and saving them to disk //Also contains all methods for manipulating the project files/settings, and saving them to disk
/*
//Private members
//The TASEdit Project's name
std::string projectName;
//The FM2's file name
std::string fm2FileName;
//The TASEdit Project's filename (For saving purposes)
std::string projectFile;
*/
#include <string> #include <string>
#include <iostream> #include <iostream>
@ -21,6 +11,11 @@
#include "taseditproj.h" #include "taseditproj.h"
#include "movie.h" #include "movie.h"
TASEDIT_PROJECT::TASEDIT_PROJECT() //Non parameterized constructor, loads project with default values
{
}
void TASEDIT_PROJECT::init() //TODO: rip this out! This should be the class constructor instead void TASEDIT_PROJECT::init() //TODO: rip this out! This should be the class constructor instead
{ {
projectName=""; projectName="";

View File

@ -47,6 +47,7 @@ struct TASEHeader
class TASEDIT_PROJECT class TASEDIT_PROJECT
{ {
public: public:
TASEDIT_PROJECT();
void init(); void init();
std::string GetProjectName(); std::string GetProjectName();