Changed the TASEdit project structure to a more OOP approach

This commit is contained in:
chris220 2009-06-16 14:30:34 +00:00
parent e4243982d0
commit da638104be
3 changed files with 75 additions and 61 deletions

View File

@ -4,6 +4,7 @@
#include "common.h"
#include "tasedit.h"
#include "taseditlib/taseditproj.h"
#include "fceu.h"
#include "debugger.h"
#include "replay.h"
@ -38,66 +39,8 @@ static TSelectionFrames selectionFrames;
//add a new fceud_ function?? blehhh maybe
extern EMOVIEMODE movieMode;
//The project file struct
struct TASEDIT_PROJECT
{
//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;
std::string GetProjectName();
void SetProjectName(std::string e);
std::string GetFM2Name();
void SetFM2Name(std::string e);
std::string GetProjectFile();
void SetProjectFile(std::string e);
};
TASEDIT_PROJECT project; //Create an instance of the project
//All the get/set functions...
std::string TASEDIT_PROJECT::GetProjectName()
{
return project.projectName;
}
void TASEDIT_PROJECT::SetProjectName(std::string e)
{
project.projectName = e;
}
std::string TASEDIT_PROJECT::GetFM2Name()
{
return project.fm2FileName;
}
void TASEDIT_PROJECT::SetFM2Name(std::string e)
{
project.fm2FileName = e;
}
std::string TASEDIT_PROJECT::GetProjectFile()
{
return project.projectFile;
}
void TASEDIT_PROJECT::SetProjectFile(std::string e)
{
project.projectFile = e;
}
void SaveProjectToDisk()
{
std::string PFN = project.GetProjectFile();
const char* filename = PFN.c_str();
ofstream ofs;
ofs.open(filename);
ofs << project.GetProjectName() << endl;
ofs << project.GetFM2Name() << endl;
ofs.close();
}
static void GetDispInfo(NMLVDISPINFO* nmlvDispInfo)
{
LVITEM& item = nmlvDispInfo->item;
@ -629,7 +572,7 @@ static void NewProject()
std::string thisfm2name = project.GetProjectName();
thisfm2name.append(".fm2"); //Setup the fm2 name
project.SetFM2Name(thisfm2name); //Set the project's fm2 name
SaveProjectToDisk();
project.SaveProject();
}
//TODO: Reinitialise project
}

View File

@ -2,5 +2,47 @@
//Written by Chris220
//Contains all the TASEDit project and all files/settings associated with it
//Also contains all methods for manipulting the project files/settings, and saving them to disk
//Also contains all methods for manipulating the project files/settings, and saving them to disk
#include <string>
#include <iostream>
#include <fstream>
#include "taseditproj.h"
//All the get/set functions...
std::string TASEDIT_PROJECT::GetProjectName()
{
return projectName;
}
void TASEDIT_PROJECT::SetProjectName(std::string e)
{
projectName = e;
}
std::string TASEDIT_PROJECT::GetFM2Name()
{
return fm2FileName;
}
void TASEDIT_PROJECT::SetFM2Name(std::string e)
{
fm2FileName = e;
}
std::string TASEDIT_PROJECT::GetProjectFile()
{
return projectFile;
}
void TASEDIT_PROJECT::SetProjectFile(std::string e)
{
projectFile = e;
}
void TASEDIT_PROJECT::SaveProject()
{
std::string PFN = GetProjectFile();
const char* filename = PFN.c_str();
std::ofstream ofs;
ofs.open(filename);
ofs << GetProjectName() << endl;
ofs << GetFM2Name() << endl;
ofs.close();
}

View File

@ -2,4 +2,33 @@
//Written by Chris220
//Contains all the TASEDit project and all files/settings associated with it
//Also contains all methods for manipulting the project files/settings, and saving them to disk
//Also contains all methods for manipulating the project files/settings, and saving them to disk
//The project file struct
#include <string>
using namespace std;
class TASEDIT_PROJECT
{
public:
//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;
std::string GetProjectName();
void SetProjectName(std::string e);
std::string GetFM2Name();
void SetFM2Name(std::string e);
std::string GetProjectFile();
void SetProjectFile(std::string e);
//Guess what this function is for...
void SaveProject();
};