Added a progress dialog for saving Qt TAS projects to disk.
This commit is contained in:
parent
a28bbb3ce3
commit
72af0270a3
|
@ -393,11 +393,19 @@ void BOOKMARKS::save(EMUFILE *os, bool really_save)
|
||||||
{
|
{
|
||||||
if (really_save)
|
if (really_save)
|
||||||
{
|
{
|
||||||
|
setTasProjectProgressBarText("Saving Bookmarks...");
|
||||||
|
setTasProjectProgressBar( 0, TOTAL_BOOKMARKS );
|
||||||
|
|
||||||
// write "BOOKMARKS" string
|
// write "BOOKMARKS" string
|
||||||
os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN);
|
os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN);
|
||||||
// write all 10 bookmarks
|
// write all 10 bookmarks
|
||||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||||
|
{
|
||||||
|
setTasProjectProgressBar( i, TOTAL_BOOKMARKS );
|
||||||
bookmarksArray[i].save(os);
|
bookmarksArray[i].save(os);
|
||||||
|
}
|
||||||
|
setTasProjectProgressBar( TOTAL_BOOKMARKS, TOTAL_BOOKMARKS );
|
||||||
|
|
||||||
// write branches
|
// write branches
|
||||||
branches->save(os);
|
branches->save(os);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -440,6 +440,9 @@ void BRANCHES::update()
|
||||||
|
|
||||||
void BRANCHES::save(EMUFILE *os)
|
void BRANCHES::save(EMUFILE *os)
|
||||||
{
|
{
|
||||||
|
setTasProjectProgressBarText("Saving Branches...");
|
||||||
|
setTasProjectProgressBar( 0, TOTAL_BOOKMARKS );
|
||||||
|
|
||||||
// write cloud time
|
// write cloud time
|
||||||
os->fwrite(cloudTimestamp, TIMESTAMP_LENGTH);
|
os->fwrite(cloudTimestamp, TIMESTAMP_LENGTH);
|
||||||
// write current branch and flag of changes since it
|
// write current branch and flag of changes since it
|
||||||
|
@ -469,6 +472,7 @@ void BRANCHES::save(EMUFILE *os)
|
||||||
write32le(cachedFirstDifferences[i][t], os);
|
write32le(cachedFirstDifferences[i][t], os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setTasProjectProgressBar( TOTAL_BOOKMARKS, TOTAL_BOOKMARKS );
|
||||||
}
|
}
|
||||||
// returns true if couldn't load
|
// returns true if couldn't load
|
||||||
bool BRANCHES::load(EMUFILE *is)
|
bool BRANCHES::load(EMUFILE *is)
|
||||||
|
|
|
@ -236,6 +236,7 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
||||||
{
|
{
|
||||||
if (save_type != GREENZONE_SAVING_MODE_NO)
|
if (save_type != GREENZONE_SAVING_MODE_NO)
|
||||||
{
|
{
|
||||||
|
setTasProjectProgressBarText("Saving Greenzone...");
|
||||||
collectCurrentState(); // in case the project is being saved before the greenzone.update() was called within current frame
|
collectCurrentState(); // in case the project is being saved before the greenzone.update() was called within current frame
|
||||||
runGreenzoneCleaning();
|
runGreenzoneCleaning();
|
||||||
if (greenzoneSize > (int)savestates.size())
|
if (greenzoneSize > (int)savestates.size())
|
||||||
|
@ -248,9 +249,11 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
||||||
write32le(greenzoneSize, os);
|
write32le(greenzoneSize, os);
|
||||||
// write Playback cursor position
|
// write Playback cursor position
|
||||||
write32le(currFrameCounter, os);
|
write32le(currFrameCounter, os);
|
||||||
|
|
||||||
|
setTasProjectProgressBar( 0, greenzoneSize );
|
||||||
}
|
}
|
||||||
int frame, size;
|
int frame, size;
|
||||||
int last_tick = 0;
|
int last_tick = -1;
|
||||||
|
|
||||||
switch (save_type)
|
switch (save_type)
|
||||||
{
|
{
|
||||||
|
@ -262,7 +265,8 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
||||||
// update TASEditor progressbar from time to time
|
// update TASEditor progressbar from time to time
|
||||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||||
{
|
{
|
||||||
playback->setProgressbar(frame, greenzoneSize);
|
setTasProjectProgressBar( frame, greenzoneSize );
|
||||||
|
//playback->setProgressbar(frame, greenzoneSize);
|
||||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||||
}
|
}
|
||||||
if (!savestates[frame].size()) continue;
|
if (!savestates[frame].size()) continue;
|
||||||
|
@ -286,7 +290,8 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
||||||
// update TASEditor progressbar from time to time
|
// update TASEditor progressbar from time to time
|
||||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||||
{
|
{
|
||||||
playback->setProgressbar(frame, greenzoneSize);
|
setTasProjectProgressBar( frame, greenzoneSize );
|
||||||
|
//playback->setProgressbar(frame, greenzoneSize);
|
||||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||||
}
|
}
|
||||||
if (!savestates[frame].size()) continue;
|
if (!savestates[frame].size()) continue;
|
||||||
|
@ -311,7 +316,8 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
||||||
// update TASEditor progressbar from time to time
|
// update TASEditor progressbar from time to time
|
||||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||||
{
|
{
|
||||||
playback->setProgressbar(frame, greenzoneSize);
|
setTasProjectProgressBar( frame, greenzoneSize );
|
||||||
|
//playback->setProgressbar(frame, greenzoneSize);
|
||||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||||
}
|
}
|
||||||
if (!savestates[frame].size()) continue;
|
if (!savestates[frame].size()) continue;
|
||||||
|
@ -345,6 +351,10 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (save_type != GREENZONE_SAVING_MODE_NO)
|
||||||
|
{
|
||||||
|
setTasProjectProgressBar( greenzoneSize, greenzoneSize );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// returns true if couldn't load
|
// returns true if couldn't load
|
||||||
bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
||||||
|
@ -357,7 +367,8 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
||||||
if (offset)
|
if (offset)
|
||||||
{
|
{
|
||||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
playback->restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
playback->restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||||
|
|
|
@ -989,7 +989,11 @@ void HISTORY::save(EMUFILE *os, bool really_save)
|
||||||
{
|
{
|
||||||
if (really_save)
|
if (really_save)
|
||||||
{
|
{
|
||||||
int real_pos, last_tick = 0;
|
int real_pos, last_tick = -1;
|
||||||
|
|
||||||
|
setTasProjectProgressBarText("Saving History...");
|
||||||
|
setTasProjectProgressBar( 0, historyTotalItems );
|
||||||
|
|
||||||
// write "HISTORY" string
|
// write "HISTORY" string
|
||||||
os->fwrite(historySaveID, HISTORY_ID_LEN);
|
os->fwrite(historySaveID, HISTORY_ID_LEN);
|
||||||
// write vars
|
// write vars
|
||||||
|
@ -1004,11 +1008,14 @@ void HISTORY::save(EMUFILE *os, bool really_save)
|
||||||
os->fwrite(¤tBranchNumberBackups[real_pos], 1);
|
os->fwrite(¤tBranchNumberBackups[real_pos], 1);
|
||||||
if (i / SAVING_HISTORY_PROGRESSBAR_UPDATE_RATE > last_tick)
|
if (i / SAVING_HISTORY_PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||||
{
|
{
|
||||||
playback->setProgressbar(i, historyTotalItems);
|
setTasProjectProgressBar( i, historyTotalItems );
|
||||||
|
//playback->setProgressbar(i, historyTotalItems);
|
||||||
last_tick = i / PROGRESSBAR_UPDATE_RATE;
|
last_tick = i / PROGRESSBAR_UPDATE_RATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
setTasProjectProgressBar( historyTotalItems, historyTotalItems );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// write "HISTORX" string
|
// write "HISTORX" string
|
||||||
os->fwrite(historySkipSaveID, HISTORY_ID_LEN);
|
os->fwrite(historySkipSaveID, HISTORY_ID_LEN);
|
||||||
|
|
|
@ -64,11 +64,16 @@ void MARKERS_MANAGER::save(EMUFILE *os, bool really_save)
|
||||||
{
|
{
|
||||||
if (really_save)
|
if (really_save)
|
||||||
{
|
{
|
||||||
|
setTasProjectProgressBarText("Saving Markers...");
|
||||||
|
setTasProjectProgressBar( 0, 100 );
|
||||||
|
|
||||||
// write "MARKERS" string
|
// write "MARKERS" string
|
||||||
os->fwrite(markers_save_id, MARKERS_ID_LEN);
|
os->fwrite(markers_save_id, MARKERS_ID_LEN);
|
||||||
markers.resetCompressedStatus(); // must recompress data, because most likely it has changed since last compression
|
markers.resetCompressedStatus(); // must recompress data, because most likely it has changed since last compression
|
||||||
markers.save(os);
|
markers.save(os);
|
||||||
} else
|
setTasProjectProgressBar( 100, 100 );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// write "MARKERX" string, meaning that Markers are not saved
|
// write "MARKERX" string, meaning that Markers are not saved
|
||||||
os->fwrite(markers_skipsave_id, MARKERS_ID_LEN);
|
os->fwrite(markers_skipsave_id, MARKERS_ID_LEN);
|
||||||
|
|
|
@ -263,6 +263,11 @@ void SELECTION::save(EMUFILE *os, bool really_save)
|
||||||
{
|
{
|
||||||
if (really_save)
|
if (really_save)
|
||||||
{
|
{
|
||||||
|
int last_tick = -1;
|
||||||
|
|
||||||
|
setTasProjectProgressBarText("Saving Selection...");
|
||||||
|
setTasProjectProgressBar( 0, historyTotalItems );
|
||||||
|
|
||||||
// write "SELECTION" string
|
// write "SELECTION" string
|
||||||
os->fwrite(selection_save_id, SELECTION_ID_LEN);
|
os->fwrite(selection_save_id, SELECTION_ID_LEN);
|
||||||
// write vars
|
// write vars
|
||||||
|
@ -272,10 +277,20 @@ void SELECTION::save(EMUFILE *os, bool really_save)
|
||||||
for (int i = 0; i < historyTotalItems; ++i)
|
for (int i = 0; i < historyTotalItems; ++i)
|
||||||
{
|
{
|
||||||
saveSelection(rowsSelectionHistory[(historyStartPos + i) % historySize], os);
|
saveSelection(rowsSelectionHistory[(historyStartPos + i) % historySize], os);
|
||||||
|
|
||||||
|
if (i / SAVING_HISTORY_PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||||
|
{
|
||||||
|
setTasProjectProgressBar( i, historyTotalItems );
|
||||||
|
//playback->setProgressbar(i, historyTotalItems);
|
||||||
|
last_tick = i / PROGRESSBAR_UPDATE_RATE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// write clipboard_selection
|
// write clipboard_selection
|
||||||
saveSelection(splicer->getClipboardSelection(), os);
|
saveSelection(splicer->getClipboardSelection(), os);
|
||||||
} else
|
|
||||||
|
setTasProjectProgressBar( historyTotalItems, historyTotalItems );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// write "SELECTIOX" string
|
// write "SELECTIOX" string
|
||||||
os->fwrite(selection_skipsave_id, SELECTION_ID_LEN);
|
os->fwrite(selection_skipsave_id, SELECTION_ID_LEN);
|
||||||
|
|
|
@ -17,6 +17,7 @@ Project - Manager of working project
|
||||||
------------------------------------------------------------------------------------ */
|
------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
#include "fceu.h"
|
#include "fceu.h"
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
|
@ -32,6 +33,8 @@ extern void FCEU_PrintError(const char *format, ...);
|
||||||
extern bool saveProject(bool save_compact = false);
|
extern bool saveProject(bool save_compact = false);
|
||||||
extern bool saveProjectAs(bool save_compact = false);
|
extern bool saveProjectAs(bool save_compact = false);
|
||||||
|
|
||||||
|
static QProgressDialog *progressDialog = NULL;
|
||||||
|
|
||||||
TASEDITOR_PROJECT::TASEDITOR_PROJECT()
|
TASEDITOR_PROJECT::TASEDITOR_PROJECT()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -95,37 +98,51 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
|
||||||
if (count1 && count2)
|
if (count1 && count2)
|
||||||
{
|
{
|
||||||
// ask user if he wants to fix the checksum before saving
|
// ask user if he wants to fix the checksum before saving
|
||||||
char message[2048] = {0};
|
std::string message;
|
||||||
strcpy(message, "Movie ROM:\n");
|
message.assign("Movie ROM:\n");
|
||||||
strncat(message, currMovieData.romFilename.c_str(), 2047 - strlen(message));
|
message.append(currMovieData.romFilename.c_str());
|
||||||
strncat(message, "\nMD5: ", 2047 - strlen(message));
|
message.append("\nMD5: ");
|
||||||
strncat(message, md5OfMovie, 2047 - strlen(message));
|
message.append(md5OfMovie);
|
||||||
strncat(message, "\n\nCurrent ROM:\n", 2047 - strlen(message));
|
message.append("\n\nCurrent ROM:\n");
|
||||||
strncat(message, GameInfo->filename, 2047 - strlen(message));
|
message.append(GameInfo->filename);
|
||||||
strncat(message, "\nMD5: ", 2047 - strlen(message));
|
message.append("\nMD5: ");
|
||||||
strncat(message, md5OfRom, 2047 - strlen(message));
|
message.append(md5OfRom);
|
||||||
strncat(message, "\n\nFix the movie header before saving? ", 2047 - strlen(message));
|
message.append("\n\nFix the movie header before saving? ");
|
||||||
//int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNOCANCEL);
|
|
||||||
//if (answer == IDCANCEL)
|
int ans = QMessageBox::warning( tasWin, QObject::tr("ROM Checksum Mismatch"), QObject::tr(message.c_str()), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel );
|
||||||
//{
|
|
||||||
// // cancel saving
|
if ( QMessageBox::Cancel == ans )
|
||||||
// return false;
|
{ // cancel saving
|
||||||
//} else if (answer == IDYES)
|
return false;
|
||||||
//{
|
}
|
||||||
|
else if ( QMessageBox::Yes == ans )
|
||||||
|
{
|
||||||
// change ROM data in the movie to current ROM
|
// change ROM data in the movie to current ROM
|
||||||
currMovieData.romFilename = GameInfo->filename;
|
currMovieData.romFilename = GameInfo->filename;
|
||||||
currMovieData.romChecksum = GameInfo->MD5;
|
currMovieData.romChecksum = GameInfo->MD5;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// open file for write
|
// open file for write
|
||||||
EMUFILE_FILE* ofs = 0;
|
EMUFILE_FILE* ofs = 0;
|
||||||
if (differentName)
|
if (differentName)
|
||||||
|
{
|
||||||
ofs = FCEUD_UTF8_fstream(differentName, "wb");
|
ofs = FCEUD_UTF8_fstream(differentName, "wb");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ofs = FCEUD_UTF8_fstream(getProjectFile().c_str(), "wb");
|
ofs = FCEUD_UTF8_fstream(getProjectFile().c_str(), "wb");
|
||||||
|
}
|
||||||
if (ofs)
|
if (ofs)
|
||||||
{
|
{
|
||||||
|
progressDialog = new QProgressDialog( QObject::tr("Saving TAS Project"), QObject::tr("Cancel"), 0, 100, tasWin );
|
||||||
|
progressDialog->setWindowModality(Qt::WindowModal);
|
||||||
|
progressDialog->setWindowTitle( QObject::tr("Saving TAS Project") );
|
||||||
|
progressDialog->setAutoReset(false);
|
||||||
|
progressDialog->setAutoClose(false);
|
||||||
|
progressDialog->setMinimumDuration(500);
|
||||||
|
progressDialog->setValue(0);
|
||||||
|
|
||||||
// change cursor to hourglass
|
// change cursor to hourglass
|
||||||
//SetCursor(LoadCursor(0, IDC_WAIT));
|
//SetCursor(LoadCursor(0, IDC_WAIT));
|
||||||
// save fm2 data to the project file
|
// save fm2 data to the project file
|
||||||
|
@ -171,14 +188,20 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
|
||||||
write32le(selectionOffset, ofs);
|
write32le(selectionOffset, ofs);
|
||||||
// finish
|
// finish
|
||||||
delete ofs;
|
delete ofs;
|
||||||
playback->updateProgressbar();
|
//playback->updateProgressbar();
|
||||||
// also set project.changed to false, unless it was SaveCompact
|
// also set project.changed to false, unless it was SaveCompact
|
||||||
if (!differentName)
|
if (!differentName)
|
||||||
reset();
|
reset();
|
||||||
// restore cursor
|
// restore cursor
|
||||||
|
|
||||||
|
if ( progressDialog )
|
||||||
|
{
|
||||||
|
delete progressDialog; progressDialog = NULL;
|
||||||
|
}
|
||||||
//taseditorWindow.mustUpdateMouseCursor = true;
|
//taseditorWindow.mustUpdateMouseCursor = true;
|
||||||
return true;
|
return true;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -455,3 +478,25 @@ void setInputType(MovieData& md, int newInputType)
|
||||||
taseditorConfig->lastExportedInputType = newInputType;
|
taseditorConfig->lastExportedInputType = newInputType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTasProjectProgressBarText( const char *txt )
|
||||||
|
{
|
||||||
|
if ( progressDialog )
|
||||||
|
{
|
||||||
|
progressDialog->setLabelText( QObject::tr(txt) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTasProjectProgressBar( int cur, int max )
|
||||||
|
{
|
||||||
|
if ( progressDialog )
|
||||||
|
{
|
||||||
|
//printf("Set Progress %i / %i \n", cur, max );
|
||||||
|
|
||||||
|
if ( max != progressDialog->maximum() )
|
||||||
|
{
|
||||||
|
progressDialog->setMaximum(max);
|
||||||
|
}
|
||||||
|
progressDialog->setValue(cur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -79,3 +79,5 @@ private:
|
||||||
|
|
||||||
int getInputType(MovieData& md);
|
int getInputType(MovieData& md);
|
||||||
void setInputType(MovieData& md, int new_input_type);
|
void setInputType(MovieData& md, int new_input_type);
|
||||||
|
void setTasProjectProgressBar( int cur, int max );
|
||||||
|
void setTasProjectProgressBarText( const char *txt );
|
||||||
|
|
Loading…
Reference in New Issue