Win32 - TasEdit - Adding functionality to interface items.
This commit is contained in:
parent
f3d9832f96
commit
7774d786cb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -19,6 +19,16 @@
|
|||
#include <fstream>
|
||||
|
||||
#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();
|
||||
|
||||
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;
|
||||
}
|
|
@ -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;
|
||||
};
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _ZAPPER_H_
|
||||
#define _ZAPPER_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct ZAPPER
|
||||
{
|
||||
uint32 mzx,mzy,mzb;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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_
|
||||
|
|
Loading…
Reference in New Issue