* Taseditor: Greenzone: always keep Greenzone.lagLog in touch with history.currentSnapshot.laglog (fixes workflow with "Auto-adjust" disabled)

This commit is contained in:
ansstuff 2013-07-03 16:46:12 +00:00
parent 440550a02d
commit 9046b369ce
6 changed files with 38 additions and 27 deletions

View File

@ -627,6 +627,8 @@ void importInputData()
{ {
greenzone.invalidateAndUpdatePlayback(result); greenzone.invalidateAndUpdatePlayback(result);
greenzone.lagLog.invalidateFromFrame(result); greenzone.lagLog.invalidateFromFrame(result);
// keep current snapshot laglog in touch
history.getCurrentSnapshot().laglog.invalidateFromFrame(result);
} else } else
{ {
MessageBox(taseditorWindow.hwndTASEditor, "Imported movie has the same Input.\nNo changes were made.", "TAS Editor", MB_OK); MessageBox(taseditorWindow.hwndTASEditor, "Imported movie has the same Input.\nNo changes were made.", "TAS Editor", MB_OK);

View File

@ -66,7 +66,7 @@ bool BOOKMARK::isDifferentFromCurrentMovie()
void BOOKMARK::set() void BOOKMARK::set()
{ {
// copy Input and Hotchanges // copy Input and Hotchanges
snapshot.init(currMovieData, taseditorConfig.enableHotChanges); snapshot.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
snapshot.keyFrame = currFrameCounter; snapshot.keyFrame = currFrameCounter;
if (taseditorConfig.enableHotChanges) if (taseditorConfig.enableHotChanges)
snapshot.inputlog.copyHotChanges(&history.getCurrentSnapshot().inputlog); snapshot.inputlog.copyHotChanges(&history.getCurrentSnapshot().inputlog);

View File

@ -94,9 +94,16 @@ void GREENZONE::update()
} else } else
{ {
if (lagFlag && (old_lagFlag != LAGGED_YES)) if (lagFlag && (old_lagFlag != LAGGED_YES))
{
lagLog.setLagInfo(currFrameCounter - 1, true); lagLog.setLagInfo(currFrameCounter - 1, true);
else if (!lagFlag && old_lagFlag != LAGGED_NO) // keep current snapshot laglog in touch
history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, true);
} else if (!lagFlag && old_lagFlag != LAGGED_NO)
{
lagLog.setLagInfo(currFrameCounter - 1, false); lagLog.setLagInfo(currFrameCounter - 1, false);
// keep current snapshot laglog in touch
history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, false);
}
} }
} }
} }

View File

@ -146,7 +146,7 @@ void HISTORY::reset()
historyCursorPos = -1; historyCursorPos = -1;
// create initial snapshot // create initial snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
snap.modificationType = MODTYPE_INIT; snap.modificationType = MODTYPE_INIT;
strcat(snap.description, modCaptions[snap.modificationType]); strcat(snap.description, modCaptions[snap.modificationType]);
snap.keyFrame = -1; snap.keyFrame = -1;
@ -404,6 +404,8 @@ int HISTORY::jumpInTime(int new_pos)
// truncate after the timeline starts to differ // truncate after the timeline starts to differ
first_lag_changes = first_changes; first_lag_changes = first_changes;
greenzone.lagLog.invalidateFromFrame(first_lag_changes); greenzone.lagLog.invalidateFromFrame(first_lag_changes);
// keep current snapshot laglog in touch
snapshots[real_pos].laglog = greenzone.lagLog;
} else } else
{ {
greenzone.lagLog = snapshots[real_pos].laglog; greenzone.lagLog = snapshots[real_pos].laglog;
@ -484,9 +486,9 @@ void HISTORY::addItemToHistoryLog(SNAPSHOT &snap, int cur_branch, BOOKMARK &book
// returns frame of first actual change // returns frame of first actual change
int HISTORY::registerChanges(int mod_type, int start, int end, int size, const char* comment, int consecutivenessTag, RowsSelection* frameset) int HISTORY::registerChanges(int mod_type, int start, int end, int size, const char* comment, int consecutivenessTag, RowsSelection* frameset)
{ {
// create new shanshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
// check if there are Input differences from latest snapshot // check if there are Input differences from latest snapshot
int real_pos = (historyStartPos + historyCursorPos) % historySize; int real_pos = (historyStartPos + historyCursorPos) % historySize;
int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog, start, end); int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog, start, end);
@ -641,9 +643,9 @@ int HISTORY::registerChanges(int mod_type, int start, int end, int size, const c
} }
int HISTORY::registerAdjustLag(int start, int size) int HISTORY::registerAdjustLag(int start, int size)
{ {
// create new shanshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
// check if there are Input differences from latest snapshot // check if there are Input differences from latest snapshot
int real_pos = (historyStartPos + historyCursorPos) % historySize; int real_pos = (historyStartPos + historyCursorPos) % historySize;
SNAPSHOT& current_snap = snapshots[real_pos]; SNAPSHOT& current_snap = snapshots[real_pos];
@ -681,9 +683,9 @@ int HISTORY::registerAdjustLag(int start, int size)
} }
void HISTORY::registerMarkersChange(int modificationType, int start, int end, const char* comment) void HISTORY::registerMarkersChange(int modificationType, int start, int end, const char* comment)
{ {
// create new shanshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
// fill description: // fill description:
snap.modificationType = modificationType; snap.modificationType = modificationType;
strcat(snap.description, modCaptions[modificationType]); strcat(snap.description, modCaptions[modificationType]);
@ -698,9 +700,9 @@ void HISTORY::registerMarkersChange(int modificationType, int start, int end, co
if (snap.endFrame > snap.startFrame || modificationType == MODTYPE_MARKER_DRAG || modificationType == MODTYPE_MARKER_SWAP) if (snap.endFrame > snap.startFrame || modificationType == MODTYPE_MARKER_DRAG || modificationType == MODTYPE_MARKER_SWAP)
{ {
if (modificationType == MODTYPE_MARKER_DRAG) if (modificationType == MODTYPE_MARKER_DRAG)
strcat(snap.description, "=>"); strcat(snap.description, "->");
else if (modificationType == MODTYPE_MARKER_SWAP) else if (modificationType == MODTYPE_MARKER_SWAP)
strcat(snap.description, "<=>"); strcat(snap.description, "<->");
else else
strcat(snap.description, "-"); strcat(snap.description, "-");
_itoa(snap.endFrame, framenum, 10); _itoa(snap.endFrame, framenum, 10);
@ -723,7 +725,7 @@ void HISTORY::registerBookmarkSet(int slot, BOOKMARK& backupCopy, int oldCurrent
{ {
// create new snapshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
// fill description: modification type + keyframe of the Bookmark // fill description: modification type + keyframe of the Bookmark
snap.modificationType = MODTYPE_BOOKMARK_0 + slot; snap.modificationType = MODTYPE_BOOKMARK_0 + slot;
strcat(snap.description, modCaptions[snap.modificationType]); strcat(snap.description, modCaptions[snap.modificationType]);
@ -741,7 +743,7 @@ int HISTORY::registerBranching(int slot, bool markers_changed)
{ {
// create new snapshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
// check if there are Input differences from latest snapshot // check if there are Input differences from latest snapshot
int real_pos = (historyStartPos + historyCursorPos) % historySize; int real_pos = (historyStartPos + historyCursorPos) % historySize;
int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog); int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog);
@ -786,10 +788,12 @@ int HISTORY::registerBranching(int slot, bool markers_changed)
// truncate after the timeline starts to differ // truncate after the timeline starts to differ
first_lag_changes = first_changes; first_lag_changes = first_changes;
greenzone.lagLog.invalidateFromFrame(first_lag_changes); greenzone.lagLog.invalidateFromFrame(first_lag_changes);
// keep current snapshot laglog in touch
snap.laglog.invalidateFromFrame(first_lag_changes); snap.laglog.invalidateFromFrame(first_lag_changes);
} else } else
{ {
greenzone.lagLog = bookmarks.bookmarksArray[slot].snapshot.laglog; greenzone.lagLog = bookmarks.bookmarksArray[slot].snapshot.laglog;
// keep current snapshot laglog in touch
snap.laglog = greenzone.lagLog; snap.laglog = greenzone.lagLog;
} }
// Greenzone should be invalidated after the frame of Lag changes if this frame is less than the frame of Input changes // Greenzone should be invalidated after the frame of Lag changes if this frame is less than the frame of Input changes
@ -808,7 +812,7 @@ void HISTORY::registerRecording(int frameOfChange, uint32 joypadDifferenceBits)
{ {
// reinit current snapshot and set hotchanges // reinit current snapshot and set hotchanges
SNAPSHOT* snap = &snapshots[real_pos]; SNAPSHOT* snap = &snapshots[real_pos];
snap->reinit(currMovieData, taseditorConfig.enableHotChanges, frameOfChange); snap->reinit(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges, frameOfChange);
// refill description // refill description
strcat(snap->description, modCaptions[MODTYPE_RECORD]); strcat(snap->description, modCaptions[MODTYPE_RECORD]);
char framenum[11]; char framenum[11];
@ -842,7 +846,7 @@ void HISTORY::registerRecording(int frameOfChange, uint32 joypadDifferenceBits)
{ {
// not consecutive - create new snapshot and add it to history // not consecutive - create new snapshot and add it to history
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
snap.recordedJoypadDifferenceBits = joypadDifferenceBits; snap.recordedJoypadDifferenceBits = joypadDifferenceBits;
// fill description: // fill description:
snap.modificationType = MODTYPE_RECORD; snap.modificationType = MODTYPE_RECORD;
@ -881,7 +885,7 @@ int HISTORY::registerImport(MovieData& md, char* filename)
{ {
// create new snapshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(md, taseditorConfig.enableHotChanges, getInputType(currMovieData)); snap.init(md, greenzone.lagLog, taseditorConfig.enableHotChanges, getInputType(currMovieData));
// check if there are Input differences from latest snapshot // check if there are Input differences from latest snapshot
int real_pos = (historyStartPos + historyCursorPos) % historySize; int real_pos = (historyStartPos + historyCursorPos) % historySize;
int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog); int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog);
@ -913,9 +917,9 @@ int HISTORY::registerImport(MovieData& md, char* filename)
} }
int HISTORY::registerLuaChanges(const char* name, int start, bool insertionOrDeletionWasDone) int HISTORY::registerLuaChanges(const char* name, int start, bool insertionOrDeletionWasDone)
{ {
// create new shanshot // create new snapshot
SNAPSHOT snap; SNAPSHOT snap;
snap.init(currMovieData, taseditorConfig.enableHotChanges); snap.init(currMovieData, greenzone.lagLog, taseditorConfig.enableHotChanges);
// check if there are Input differences from latest snapshot // check if there are Input differences from latest snapshot
int real_pos = (historyStartPos + historyCursorPos) % historySize; int real_pos = (historyStartPos + historyCursorPos) % historySize;
int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog, start); int first_changes = snap.inputlog.findFirstChange(snapshots[real_pos].inputlog, start);

View File

@ -29,12 +29,12 @@ SNAPSHOT::SNAPSHOT()
{ {
} }
void SNAPSHOT::init(MovieData& md, bool hotchanges, int enforceInputType) void SNAPSHOT::init(MovieData& md, LAGLOG& lagLog, bool hotchanges, int enforceInputType)
{ {
inputlog.init(md, hotchanges, enforceInputType); inputlog.init(md, hotchanges, enforceInputType);
// take a copy from greenzone.laglog // make a copy of the given laglog
laglog = greenzone.lagLog; laglog = lagLog;
laglog.resetCompressedStatus(); laglog.resetCompressedStatus();
// take a copy of markers_manager.markers // take a copy of markers_manager.markers
@ -49,13 +49,11 @@ void SNAPSHOT::init(MovieData& md, bool hotchanges, int enforceInputType)
strftime(description, 10, "%H:%M:%S", timeinfo); strftime(description, 10, "%H:%M:%S", timeinfo);
} }
void SNAPSHOT::reinit(MovieData& md, bool hotchanges, int frameOfChanges) void SNAPSHOT::reinit(MovieData& md, LAGLOG& lagLog, bool hotchanges, int frameOfChanges)
{ {
inputlog.reinit(md, hotchanges, frameOfChanges); inputlog.reinit(md, hotchanges, frameOfChanges);
// take a copy from greenzone.laglog // do not copy laglog, because it will be updated later, when Greenzone will sync its data with the current history snapshot
laglog = greenzone.lagLog;
laglog.resetCompressedStatus();
// Markers are supposed to be the same, because this is consecutive Recording // Markers are supposed to be the same, because this is consecutive Recording

View File

@ -8,8 +8,8 @@ class SNAPSHOT
{ {
public: public:
SNAPSHOT(); SNAPSHOT();
void init(MovieData& md, bool hotChanges, int enforceInputType = -1); void init(MovieData& md, LAGLOG& lagLog, bool hotChanges, int enforceInputType = -1);
void reinit(MovieData& md, bool hotChanges, int frameOfChanges); // used when combining consecutive Recordings void reinit(MovieData& md, LAGLOG& lagLog, bool hotChanges, int frameOfChanges); // used when combining consecutive Recordings
bool areMarkersDifferentFromCurrentMarkers(); bool areMarkersDifferentFromCurrentMarkers();
void copyToCurrentMarkers(); void copyToCurrentMarkers();