Bugfix: TasProjects without states loaded without a power on state.

Bugfix: There were several ways to edit movie in TAStudio without rewinding to edited frame.
Smarter state management.
This commit is contained in:
SuuperW 2015-03-12 18:31:28 +00:00
parent 10dbd9bafb
commit 1a0476892f
6 changed files with 41 additions and 14 deletions

View File

@ -46,8 +46,10 @@ namespace BizHawk.Client.Common
return; // Nothing to do return; // Nothing to do
} }
if (frame == LagLog.Count) if (frame >= LagLog.Count)
LagLog.Add(value.Value); {
do { LagLog.Add(value.Value); } while (frame >= LagLog.Count);
}
else else
LagLog[frame] = value.Value; LagLog[frame] = value.Value;

View File

@ -209,6 +209,11 @@ namespace BizHawk.Client.Common
StateManager.Load(br); StateManager.Load(br);
}); });
} }
else
{ // Movie should always have a state at frame 0.
if (!this.StartsFromSavestate)
StateManager.Capture();
}
bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr) bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr)
{ {

View File

@ -166,8 +166,9 @@ namespace BizHawk.Client.Common
int shouldRemove = -1; int shouldRemove = -1;
if (Used >= Settings.Cap) if (Used >= Settings.Cap)
shouldRemove = _movie.StartsFromSavestate ? 0 : 1; shouldRemove = _movie.StartsFromSavestate ? 0 : 1;
if (shouldRemove != -1) // Which one to remove? if (shouldRemove != -1)
{ { // Which one to remove?
// No need to have two savestates with only lag frames between them.
for (int i = shouldRemove; i < States.Count - 1; i++) for (int i = shouldRemove; i < States.Count - 1; i++)
{ {
if (AllLag(States.ElementAt(i).Key, States.ElementAt(i + 1).Key)) if (AllLag(States.ElementAt(i).Key, States.ElementAt(i + 1).Key))
@ -176,10 +177,16 @@ namespace BizHawk.Client.Common
break; break;
} }
} }
}
if (shouldRemove != -1) // Keep cap/2 (3?) marker saves
int maxMarkers = Settings.Cap / 2;
shouldRemove--;
do
{ {
shouldRemove++;
} while (_movie.Markers.IsMarker(States.ElementAt(shouldRemove).Key));
// Remove
Used -= States.ElementAt(shouldRemove).Value.Length; Used -= States.ElementAt(shouldRemove).Value.Length;
States.RemoveAt(shouldRemove); States.RemoveAt(shouldRemove);
} }

View File

@ -101,7 +101,7 @@ namespace BizHawk.Client.EmuHawk
private void SetZoneButton_Click(object sender, EventArgs e) private void SetZoneButton_Click(object sender, EventArgs e)
{ {
if (StartNum.Value >= CurrentTasMovie.InputLogLength || EndNum.Value > CurrentTasMovie.InputLogLength) if (StartNum.Value >= CurrentTasMovie.InputLogLength || EndNum.Value >= CurrentTasMovie.InputLogLength)
{ {
MessageBox.Show("Start and end frames must be inside the movie."); MessageBox.Show("Start and end frames must be inside the movie.");
return; return;

View File

@ -321,6 +321,8 @@ namespace BizHawk.Client.EmuHawk
{ {
_floatEditYPos = e.Y; _floatEditYPos = e.Y;
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName); _floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
return; return;
} }
} }
@ -358,6 +360,9 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog(); RefreshDialog();
} }
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName); _floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
if (e.Clicks != 2) if (e.Clicks != 2)
@ -405,6 +410,9 @@ namespace BizHawk.Client.EmuHawk
_rightClickFrame = frame; _rightClickFrame = frame;
} }
_rightClickLastFrame = -1; _rightClickLastFrame = -1;
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
// TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here. // TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here.
CurrentTasMovie.ChangeLog.BeginNewBatch("Right-Click Edit"); CurrentTasMovie.ChangeLog.BeginNewBatch("Right-Click Edit");
} }
@ -568,6 +576,8 @@ namespace BizHawk.Client.EmuHawk
{ {
for (int i = startVal; i <= endVal; i++) for (int i = startVal; i <= endVal; i++)
CurrentTasMovie.SetFrame(i, _rightClickInput[(_rightClickFrame - i) % _rightClickInput.Length]); CurrentTasMovie.SetFrame(i, _rightClickInput[(_rightClickFrame - i) % _rightClickInput.Length]);
if (startVal < _triggerAutoRestoreFromFrame)
_triggerAutoRestoreFromFrame = startVal;
} }
} }
else else
@ -608,6 +618,9 @@ namespace BizHawk.Client.EmuHawk
CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]); CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]);
_rightClickFrame = frame; _rightClickFrame = frame;
} }
if (frame < _triggerAutoRestoreFromFrame)
_triggerAutoRestoreFromFrame = frame;
} }
RefreshTasView(); RefreshTasView();
} }
@ -619,7 +632,7 @@ namespace BizHawk.Client.EmuHawk
for (var i = startVal; i <= endVal; i++) // SuuperW: <= so that it will edit the cell you are hovering over. (Inclusive) for (var i = startVal; i <= endVal; i++) // SuuperW: <= so that it will edit the cell you are hovering over. (Inclusive)
{ {
CurrentTasMovie.SetBoolState(i, _startBoolDrawColumn, _boolPaintState); // Notice it uses new row, old column, you can only paint across a single column CurrentTasMovie.SetBoolState(i, _startBoolDrawColumn, _boolPaintState); // Notice it uses new row, old column, you can only paint across a single column
_triggerAutoRestore = true; if (TasView.CurrentCell.RowIndex.Value < _triggerAutoRestoreFromFrame)
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value; _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
} }
@ -636,7 +649,7 @@ namespace BizHawk.Client.EmuHawk
if (i < CurrentTasMovie.InputLogLength) if (i < CurrentTasMovie.InputLogLength)
{ {
CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, _floatPaintState); // Notice it uses new row, old column, you can only paint across a single column CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, _floatPaintState); // Notice it uses new row, old column, you can only paint across a single column
_triggerAutoRestore = true; if (TasView.CurrentCell.RowIndex.Value < _triggerAutoRestoreFromFrame)
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value; _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
} }
} }

View File

@ -829,13 +829,13 @@ namespace BizHawk.Client.EmuHawk
Text = column.Text + " (" + column.Name + ")", Text = column.Text + " (" + column.Name + ")",
Checked = column.Visible, Checked = column.Visible,
CheckOnClick = true, CheckOnClick = true,
Tag = column Tag = column.Name
}; };
menuItem.CheckedChanged += (o, ev) => menuItem.CheckedChanged += (o, ev) =>
{ {
var sender = o as ToolStripMenuItem; var sender = o as ToolStripMenuItem;
(sender.Tag as InputRoll.RollColumn).Visible = sender.Checked; TasView.AllColumns.Find(c => c.Name == (string)sender.Tag).Visible = sender.Checked;
TasView.AllColumns.ColumnsChanged(); TasView.AllColumns.ColumnsChanged();
CurrentTasMovie.FlagChanges(); CurrentTasMovie.FlagChanges();
RefreshTasView(); RefreshTasView();