Taseditor: fixed bug in "Auto-adjust Input due to lag"

This commit is contained in:
ansstuff 2012-06-14 14:24:59 +00:00
parent 5a67cb3474
commit ea47e532ec
3 changed files with 64 additions and 84 deletions

View File

@ -212,64 +212,6 @@ void EDITOR::InputSetPattern(int start, int end, int joy, int button, int consec
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_PATTERN, start, end, autofire_patterns_names[current_pattern].c_str(), consecutive_tag));
}
void EDITOR::AdjustUp(int at)
{
if (at < 0)
return;
bool markers_changed = false;
// delete one frame
currMovieData.records.erase(currMovieData.records.begin() + at);
if (taseditor_config.bind_markers)
{
if (markers_manager.EraseMarker(at))
markers_changed = true;
}
// check if user deleted all frames
if (!currMovieData.getNumRecords())
playback.StartFromZero();
// reduce Piano Roll
piano_roll.UpdateItemCount();
// check and register changes
int result = history.RegisterChanges(MODTYPE_ADJUST_UP, at);
if (result >= 0)
{
greenzone.InvalidateAndCheck(result);
} else
{
// check for special case: user deleted a bunch of empty frames the end of the movie
greenzone.InvalidateAndCheck(currMovieData.getNumRecords() - 1);
if (markers_changed)
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, at);
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
}
void EDITOR::AdjustDown(int at)
{
if (at < 0)
return;
bool markers_changed = false;
// insert blank frame
currMovieData.insertEmpty(at, 1);
if (taseditor_config.bind_markers)
{
if (markers_manager.insertEmpty(at, 1))
markers_changed = true;
}
// check and register changes
int first_changes = history.RegisterChanges(MODTYPE_ADJUST_DOWN, at);
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
} else if (markers_changed)
{
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, at);
piano_roll.RedrawList();
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
}
// following functions use current Selection to determine range of frames
bool EDITOR::FrameColumnSet()
{
@ -485,6 +427,49 @@ void EDITOR::RemoveMarkers()
}
}
}
// these two functions don't restore Playback cursor, they only invalidate Greenzone
void EDITOR::AdjustUp(int at)
{
if (at < 0)
return;
bool markers_changed = false;
// delete one frame
currMovieData.records.erase(currMovieData.records.begin() + at);
if (taseditor_config.bind_markers)
{
if (markers_manager.EraseMarker(at))
markers_changed = true;
}
// check if user deleted all frames
if (!currMovieData.getNumRecords())
playback.StartFromZero();
// reduce Piano Roll
piano_roll.UpdateItemCount();
// check and register changes
history.RegisterChanges(MODTYPE_ADJUST_UP, at);
greenzone.Invalidate(at);
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
}
void EDITOR::AdjustDown(int at)
{
if (at < 0)
return;
bool markers_changed = false;
// insert blank frame
currMovieData.insertEmpty(at, 1);
if (taseditor_config.bind_markers)
{
if (markers_manager.insertEmpty(at, 1))
markers_changed = true;
}
// check and register changes
history.RegisterChanges(MODTYPE_ADJUST_DOWN, at);
greenzone.Invalidate(at);
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
}
// ----------------------------------------------------------------------------------------------

View File

@ -12,9 +12,6 @@ public:
void InputToggle(int start, int end, int joy, int button, int consecutive_tag = 0);
void InputSetPattern(int start, int end, int joy, int button, int consecutive_tag = 0);
void AdjustUp(int at);
void AdjustDown(int at);
bool FrameColumnSet();
bool FrameColumnSetPattern();
bool InputColumnSet(int joy, int button);
@ -22,6 +19,9 @@ public:
void SetMarkers();
void RemoveMarkers();
void AdjustUp(int at);
void AdjustDown(int at);
std::vector<std::string> autofire_patterns_names;
std::vector<std::vector<uint8>> autofire_patterns;

View File

@ -88,7 +88,6 @@ void GREENZONE::CollectCurrentState()
{
// lagFlag indicates that lag was in previous frame
int old_lagFlag = lag_history[currFrameCounter - 1];
int saved_currFrameCounter = currFrameCounter;
// Auto-adjust Input due to lag
if (taseditor_config.adjust_input_due_to_lag)
{
@ -97,14 +96,21 @@ void GREENZONE::CollectCurrentState()
// there's no more lag on previous frame - shift input up
lag_history.erase(lag_history.begin() + (currFrameCounter - 1));
editor.AdjustUp(currFrameCounter - 1);
// make sure the Playback cursor always rewinds too
if (currFrameCounter == saved_currFrameCounter)
InvalidateAndCheck(currFrameCounter - 1);
// since AdjustUp didn't restore Playback cursor, we must rewind here
int pause_frame = playback.pause_frame;
playback.jump(currFrameCounter - 1); // rewind
if (pause_frame)
playback.SeekingStart(pause_frame);
} else if (!old_lagFlag && lagFlag)
{
// there's new lag on previous frame - shift input down
lag_history.insert(lag_history.begin() + (currFrameCounter - 1), 1);
editor.AdjustDown(currFrameCounter - 1);
// since AdjustDown didn't restore Playback cursor, we must rewind here
int pause_frame = playback.pause_frame;
playback.jump(currFrameCounter - 1); // rewind
if (pause_frame)
playback.SeekingStart(pause_frame);
}
} else
{
@ -437,27 +443,16 @@ void GREENZONE::InvalidateAndCheck(int after)
// either set Playback cursor to the end of Greenzone or run seeking to restore playback position
if (currFrameCounter >= greenZoneCount)
{
// auto-restore position if needed
if (taseditor_config.restore_position)
if (playback.pause_frame && playback.pause_frame_must_be_fixed)
{
if (playback.pause_frame && playback.pause_frame_must_be_fixed)
{
playback.jump(playback.pause_frame - 1);
} else
{
playback.SetLostPosition(currFrameCounter);
playback.jump(currFrameCounter);
}
playback.jump(playback.pause_frame - 1);
} else
{
if (playback.pause_frame && playback.pause_frame_must_be_fixed)
{
playback.jump(playback.pause_frame - 1);
} else
{
playback.SetLostPosition(currFrameCounter);
playback.jump(greenZoneCount-1);
}
playback.SetLostPosition(currFrameCounter);
if (taseditor_config.restore_position)
playback.jump(currFrameCounter);
else
playback.jump(greenZoneCount - 1);
}
}
}
@ -466,7 +461,7 @@ void GREENZONE::InvalidateAndCheck(int after)
piano_roll.RedrawList();
bookmarks.RedrawBookmarksList();
}
// This version doesn't restore playback, may be used only by Branching and Recording functions!
// This version doesn't restore playback, may be used only by Branching, Recording and Adjusting functions!
void GREENZONE::Invalidate(int after)
{
if (after >= 0)