Moved around movie options variables and make movie backup functions

This commit is contained in:
adelikat 2008-12-23 00:10:15 +00:00
parent 0e7abb6dd8
commit 6fb09465ca
6 changed files with 101 additions and 92 deletions

View File

@ -49,6 +49,8 @@ extern bool frameAdvanceLagSkip;
extern int ClipSidesOffset;
extern bool movieSubtitles;
extern bool subtitlesOnAVI;
extern bool autoMovieBackup;
extern bool bindSavestate;
extern int PPUViewRefresh;
extern int NTViewRefresh;
extern uint8 gNoBGFillColor;

View File

@ -23,13 +23,14 @@
//internal variables
int pauseAfterPlayback = 0; //Flag for pausing emulator when movie is finished
bool bindSavestate = true; //Toggle that determines if a savestate filename will include the movie filename
bool autoMovieBackup = false; //Toggle that determines if movies should be backed up automatically before altering them
//external
extern int status_icon; //In main.cpp - For displaying movie status icons (play,record,pause)
extern bool movieSubtitles; //In fceu.cpp - Toggle for displaying movie subtitles
extern bool subtitlesOnAVI; //In movie.cpp - Toggle for putting movie subtitles in an AVI
extern bool autoMovieBackup;//In fceu.cpp - Toggle that determines if movies should be backed up automatically before altering them
extern bool bindSavestate ; //Toggle that determines if a savestate filename will include the movie filename
void UpdateCheckBoxes(HWND hwndDlg)
{

View File

@ -1,5 +1,3 @@
void OpenMovieOptions();
extern int pauseAfterPlayback;
extern bool bindSavestate;
extern bool autoMovieBackup;
extern int pauseAfterPlayback;

View File

@ -94,9 +94,8 @@ void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add
void MapInput(void);
extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog
// Function declarations
void MakeBackupMovie(bool dispMessage); //Makes a backup of current movie file
bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
extern void MakeBackupMovie(bool dispMessage); //Makes a backup of current movie file
extern bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
//AutoFire-----------------------------------------------
void SetAutoFirePattern(int onframes, int offframes);
@ -2042,87 +2041,4 @@ void UpdateMenuHotkeys()
combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENCDLOGGER]);
combined = "Code/Data Logger...\t" + combo;
ChangeMenuItemText(MENU_CDLOGGER, combined);
}
void MakeBackupMovie(bool dispMessage)
{
//This function generates backup movie files
string currentFn; //Current movie fillename
string backupFn; //Target backup filename
string tempFn; //temp used in back filename creation
stringstream stream;
int x; //Temp variable for string manip
bool exist = false; //Used to test if filename exists
bool overflow = false; //Used for special situation when backup numbering exceeds limit
currentFn = curMovieFilename; //Get current moviefilename
backupFn = curMovieFilename; //Make backup filename the same as current moviefilename
x = backupFn.find_last_of("."); //Find file extension
backupFn = backupFn.substr(0,x); //Remove extension
tempFn = backupFn; //Store the filename at this point
for (unsigned int backNum=0;backNum<999;backNum++) //999 = arbituary limit to backup files
{
stream.str(""); //Clear stream
if (backNum > 99)
stream << "-" << backNum; //assign backNum to stream
else if (backNum <=99 && backNum >= 10)
stream << "-0"; //Make it 010, etc if two digits
else
stream << "-00" << backNum; //Make it 001, etc if single digit
backupFn.append(stream.str()); //add number to bak filename
backupFn.append(".bak"); //add extension
exist = CheckFileExists(backupFn.c_str()); //Check if file exists
if (!exist)
break; //Yeah yeah, I should use a do loop or something
else
{
backupFn = tempFn; //Before we loop again, reset the filename
if (backNum == 999) //If 999 exists, we have overflowed, let's handle that
{
backupFn.append("-001.bak"); //We are going to simply overwrite 001.bak
overflow = true; //Flag that we have exceeded limit
break; //Just in case
}
}
}
MovieData md = currMovieData; //Get current movie data
std::fstream* outf = FCEUD_UTF8_fstream(backupFn, "wb"); //open/create file
md.dump(outf,false); //dump movie data
delete outf; //clean up, delete file object
//TODO, decide if fstream successfully opened the file and print error message if it doesn't
if (dispMessage) //If we should inform the user
{
if (overflow)
FCEUI_DispMessage("Overwriting %s",backupFn.c_str()); //Inform user of overflow
else
FCEUI_DispMessage("%s created",backupFn.c_str()); //Inform user of backup filename
}
}
bool CheckFileExists(const char* filename)
{
//This function simply checks to see if the given filename exists
string checkFilename;
checkFilename = filename;
//Check if this filename exists
fstream test;
test.open(checkFilename.c_str(),fstream::in);
if (test.fail())
{
test.close();
return false;
}
else
{
test.close();
return true;
}
}

View File

@ -50,6 +50,9 @@
#include "vsuni.h"
#include "ines.h"
#include <fstream>
#include <sstream>
#ifdef _S9XLUA_H
#include "fceulua.h"
#endif
@ -64,12 +67,18 @@
#include "drivers/sdl/sdl.h"
#endif
using namespace std;
int AFon = 1, AFoff = 1, AutoFireOffset = 0; //For keeping track of autofire settings
bool justLagged = false;
bool frameAdvanceLagSkip = false; //If this is true, frame advance will skip over lag frame (i.e. it will emulate 2 frames instead of 1)
bool movieSubtitles = true; //Toggle for displaying movie subtitles
bool autoMovieBackup = false; //Toggle that determines if movies should be backed up automatically before altering them
// Function declarations
void MakeBackupMovie(bool dispMessage); //Makes a backup of current movie file
bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
FCEUGI::FCEUGI()
: filename(0)
@ -1079,4 +1088,87 @@ uint8 FCEU_ReadRomByte(uint32 i) {
if(i < 16+PRGsize[0])return PRGptr[0][i-16];
if(i < 16+PRGsize[0]+CHRsize[0])return CHRptr[0][i-16-PRGsize[0]];
return 0;
}
void MakeBackupMovie(bool dispMessage)
{
//This function generates backup movie files
string currentFn; //Current movie fillename
string backupFn; //Target backup filename
string tempFn; //temp used in back filename creation
stringstream stream;
int x; //Temp variable for string manip
bool exist = false; //Used to test if filename exists
bool overflow = false; //Used for special situation when backup numbering exceeds limit
currentFn = curMovieFilename; //Get current moviefilename
backupFn = curMovieFilename; //Make backup filename the same as current moviefilename
x = backupFn.find_last_of("."); //Find file extension
backupFn = backupFn.substr(0,x); //Remove extension
tempFn = backupFn; //Store the filename at this point
for (unsigned int backNum=0;backNum<999;backNum++) //999 = arbituary limit to backup files
{
stream.str(""); //Clear stream
if (backNum > 99)
stream << "-" << backNum; //assign backNum to stream
else if (backNum <=99 && backNum >= 10)
stream << "-0"; //Make it 010, etc if two digits
else
stream << "-00" << backNum; //Make it 001, etc if single digit
backupFn.append(stream.str()); //add number to bak filename
backupFn.append(".bak"); //add extension
exist = CheckFileExists(backupFn.c_str()); //Check if file exists
if (!exist)
break; //Yeah yeah, I should use a do loop or something
else
{
backupFn = tempFn; //Before we loop again, reset the filename
if (backNum == 999) //If 999 exists, we have overflowed, let's handle that
{
backupFn.append("-001.bak"); //We are going to simply overwrite 001.bak
overflow = true; //Flag that we have exceeded limit
break; //Just in case
}
}
}
MovieData md = currMovieData; //Get current movie data
std::fstream* outf = FCEUD_UTF8_fstream(backupFn, "wb"); //open/create file
md.dump(outf,false); //dump movie data
delete outf; //clean up, delete file object
//TODO, decide if fstream successfully opened the file and print error message if it doesn't
if (dispMessage) //If we should inform the user
{
if (overflow)
FCEUI_DispMessage("Overwriting %s",backupFn.c_str()); //Inform user of overflow
else
FCEUI_DispMessage("%s created",backupFn.c_str()); //Inform user of backup filename
}
}
bool CheckFileExists(const char* filename)
{
//This function simply checks to see if the given filename exists
string checkFilename;
checkFilename = filename;
//Check if this filename exists
fstream test;
test.open(checkFilename.c_str(),fstream::in);
if (test.fail())
{
test.close();
return false;
}
else
{
test.close();
return true;
}
}

View File

@ -48,7 +48,7 @@
using namespace std;
bool bindSavestate = true; //Toggle that determines if a savestate filename will include the movie filename
static std::string BaseDirectory;
static char FileExt[2048]; //Includes the . character, as in ".nes"
char FileBase[2048];