1. Upgraded insert and delete functions in tastudio to support multiple selection.

2. Fixed issues with the light blue current frame pointer in tastudio
3. Removed a totally useless index that was being kept seperately in the movie log.
4. Moved the tastudio update after the check to see if the rest of the saved state list is valid.
5. Changed some function/variable names related to the movie log for clarity.
This commit is contained in:
phillip.grimsrud 2012-06-07 04:47:54 +00:00
parent 93b266838c
commit cb4c45eb70
10 changed files with 123 additions and 94 deletions

View File

@ -249,11 +249,11 @@ namespace BizHawk.MultiClient
{
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
{
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.Length().ToString() + " (Finished)";
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.LogLength().ToString() + " (Finished)";
}
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
{
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.Length().ToString();
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.LogLength().ToString();
}
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD)
return Global.Emulator.Frame.ToString();

View File

@ -1445,7 +1445,7 @@ namespace BizHawk.MultiClient
public int movie_length()
{
return Global.MovieSession.Movie.Length();
return Global.MovieSession.Movie.LogLength();
}
public string movie_filename()

View File

@ -1894,7 +1894,7 @@ namespace BizHawk.MultiClient
if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
{
if (Global.MovieSession.Movie.Length() == Global.Emulator.Frame+1 && true == StopOnEnd)
if (Global.MovieSession.Movie.LogLength() == Global.Emulator.Frame + 1 && true == StopOnEnd)
{
if (true == Global.MovieSession.Movie.TastudioOn)
{
@ -1905,7 +1905,7 @@ namespace BizHawk.MultiClient
}
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
{
if (Global.MovieSession.Movie.Length() > Global.Emulator.Frame+1)
if (Global.MovieSession.Movie.LogLength() > Global.Emulator.Frame + 1)
{
Global.MovieSession.Movie.StartPlayback();
//Global.MovieSession.MovieControllerAdapter.SetControllersAsMnemonic(Global.MovieSession.Movie.GetInputFrame(Global.Emulator.Frame));
@ -1998,8 +1998,8 @@ namespace BizHawk.MultiClient
{
//The other tool updates are earlier, TAStudio needs to be later so it can display the latest
//frame of execution in its list view.
TAStudio1.UpdateValues();
Global.MovieSession.Movie.CheckValidity();
TAStudio1.UpdateValues();
}
private unsafe Image MakeScreenshotImage()

View File

@ -88,7 +88,7 @@ namespace BizHawk.MultiClient
{
Movie m = new Movie(file.FullName, MOVIEMODE.INACTIVE);
m.LoadMovie(); //State files will have to load everything unfortunately
if (m.Length() == 0)
if (m.LogLength() == 0)
{
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return;
@ -119,7 +119,7 @@ namespace BizHawk.MultiClient
{
Movie m = new Movie(file.CanonicalFullPath, MOVIEMODE.INACTIVE);
m.LoadMovie(); //State files will have to load everything unfortunately
if (m.Length() > 0)
if (m.LogLength() > 0)
{
MovieList.Add(m);
sortReverse = false;

View File

@ -163,7 +163,7 @@ namespace BizHawk.MultiClient
{
for (int i = 0; i < frames; i++)
{
if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.Length()))
if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.LogLength()))
return;
if (LastState.Length < 0x10000)
Rewind64K();

View File

@ -72,15 +72,23 @@ namespace BizHawk.MultiClient
return Header.GetHeaderLine(MovieHeader.GAMENAME);
}
public int Length()
{
if (Loaded)
return Log.Length();
else
return Frames;
}
public int LogLength()
{
if (Loaded)
return Log.MovieLength();
else
return Frames;
}
public void UpdateFileName(string filename)
public int StateLength()
{
if (Loaded)
return Log.StateLength();
else
return Frames;
}
public void UpdateFileName(string filename)
{
this.Filename = filename;
}
@ -123,9 +131,9 @@ namespace BizHawk.MultiClient
Global.MainForm.TAStudio1.UpdateValues();
}
public int LastValidState()
public int ValidStateCount()
{
return Log.LastValidState();
return Log.ValidStateCount();
}
public void CheckValidity()
@ -146,7 +154,7 @@ namespace BizHawk.MultiClient
{
ClearSaveRAM();
Mode = MOVIEMODE.RECORD;
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Length() > 0)
if (Global.Config.EnableBackupMovies && MakeBackup && Log.MovieLength() > 0)
{
WriteBackup();
MakeBackup = false;
@ -205,7 +213,7 @@ namespace BizHawk.MultiClient
public string GetInputFrame(int frame)
{
lastLog = frame;
if (frame < Log.Length())
if (frame < Log.MovieLength())
return Log.GetFrame(frame);
else
return "";
@ -252,7 +260,7 @@ namespace BizHawk.MultiClient
private void WriteText(string file)
{
if (file.Length == 0) return; //Nothing to write
int length = Log.Length();
int length = Log.MovieLength();
using (StreamWriter sw = new StreamWriter(file))
{
@ -409,7 +417,7 @@ namespace BizHawk.MultiClient
writer.WriteLine("[Input]");
string s = MovieHeader.GUID + " " + Header.GetHeaderLine(MovieHeader.GUID);
writer.WriteLine(s);
for (int x = 0; x < Log.Length(); x++)
for (int x = 0; x < Log.MovieLength(); x++)
writer.WriteLine(Log.GetFrame(x));
writer.WriteLine("[/Input]");
}
@ -421,7 +429,7 @@ namespace BizHawk.MultiClient
//We are in record mode so replace the movie log with the one from the savestate
if (!Global.MovieSession.MultiTrack.IsActive)
{
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Length() > 0)
if (Global.Config.EnableBackupMovies && MakeBackup && Log.MovieLength() > 0)
{
WriteBackup();
MakeBackup = false;
@ -497,9 +505,9 @@ namespace BizHawk.MultiClient
}
}
}
if (stateFrame > 0 && stateFrame < Log.Length())
if (stateFrame > 0 && stateFrame < Log.MovieLength())
{
Log.Truncate(Global.Emulator.Frame);
Log.TruncateStates(Global.Emulator.Frame);
}
IncrementRerecords();
reader.Close();
@ -534,7 +542,7 @@ namespace BizHawk.MultiClient
if (preLoad)
seconds = GetSeconds(Frames);
else
seconds = GetSeconds(Log.Length());
seconds = GetSeconds(Log.MovieLength());
int hours = ((int)seconds) / 3600;
int minutes = (((int)seconds) / 60) % 60;
double sec = seconds % 60;
@ -697,7 +705,7 @@ namespace BizHawk.MultiClient
return true;
}
if (stateFrame > l.Length()) //stateFrame is greater than state input log, so movie finished mode
if (stateFrame > l.MovieLength()) //stateFrame is greater than state input log, so movie finished mode
{
if (Mode == MOVIEMODE.PLAY || Mode == MOVIEMODE.FINISHED)
{
@ -710,13 +718,13 @@ namespace BizHawk.MultiClient
if (stateFrame == 0)
{
stateFrame = l.Length(); //In case the frame count failed to parse, revert to using the entire state input log
stateFrame = l.MovieLength(); //In case the frame count failed to parse, revert to using the entire state input log
}
if (Log.Length() < stateFrame)
if (Log.MovieLength() < stateFrame)
{
//Future event error
MessageBox.Show("The savestate is from frame " + l.Length().ToString() + " which is greater than the current movie length of " +
Log.Length().ToString() + ".\nCan not load this savestate.", "Future event Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("The savestate is from frame " + l.MovieLength().ToString() + " which is greater than the current movie length of " +
Log.MovieLength().ToString() + ".\nCan not load this savestate.", "Future event Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
reader.Close();
return false;
}

View File

@ -212,7 +212,7 @@ namespace BizHawk.MultiClient
case '1':
break;
case '2':
if (m.Length() != 0)
if (m.LogLength() != 0)
warningMsg = "hard reset";
break;
case '4':

View File

@ -15,23 +15,26 @@ namespace BizHawk.MultiClient
List<string> MovieRecords = new List<string>();
private List<byte[]> StateList = new List<byte[]>();
private int StateLastValidIndex = -1;
private List<byte[]> StateRecords = new List<byte[]>();
public MovieLog()
{
//Should this class initialize with an empty string to MovieRecords so that first frame is index 1?
//MovieRecords.Add("");
}
public int Length()
public int MovieLength()
{
return MovieRecords.Count;
}
public int StateLength()
{
return StateRecords.Count;
}
public void Clear()
{
MovieRecords.Clear();
StateRecords.Clear();
}
public void AddFrame(string frame)
@ -41,10 +44,9 @@ namespace BizHawk.MultiClient
public void AddState(byte[] state)
{
if (Global.Emulator.Frame >= StateList.Count)
if (Global.Emulator.Frame >= StateRecords.Count)
{
StateList.Add(state);
StateLastValidIndex = Global.Emulator.Frame;
StateRecords.Add(state);
}
}
@ -59,63 +61,64 @@ namespace BizHawk.MultiClient
{
MovieRecords.Insert(frameNum, frame);
if (frameNum <= StateList.Count - 1)
if (frameNum <= StateRecords.Count - 1)
{
StateList.RemoveRange(frameNum, StateList.Count - frameNum);
}
if (StateLastValidIndex >= frameNum)
{
StateLastValidIndex = frameNum - 1;
StateRecords.RemoveRange(frameNum, StateRecords.Count - frameNum);
}
}
public void CheckValidity()
{
byte[] state = Global.Emulator.SaveStateBinary();
if (Global.Emulator.Frame < StateList.Count && (null == StateList[Global.Emulator.Frame] || !state.SequenceEqual((byte[])StateList[Global.Emulator.Frame])))
if (Global.Emulator.Frame < StateRecords.Count && !state.SequenceEqual((byte[])StateRecords[Global.Emulator.Frame]))
{
StateLastValidIndex = Global.Emulator.Frame;
TruncateStates(Global.Emulator.Frame);
}
}
public int CapturedStateCount()
{
return StateList.Count;
return StateRecords.Count;
}
public int LastValidState()
public int ValidStateCount()
{
return StateLastValidIndex;
return StateRecords.Count;
}
public byte[] GetState(int frame)
{
return StateList[frame];
return StateRecords[frame];
}
public void DeleteFrame(int frame)
{
MovieRecords.RemoveAt(frame);
if (frame < StateList.Count)
if (frame < StateRecords.Count)
{
StateList.RemoveAt(frame);
}
if (StateLastValidIndex > frame)
{
StateLastValidIndex = frame;
StateRecords.RemoveAt(frame);
}
}
public void ClearStates()
{
StateList.Clear();
StateLastValidIndex = -1;
StateRecords.Clear();
}
public void Truncate(int frame)
public void TruncateFrames(int frame)
{
if (frame >= 0 && frame < Length())
{ MovieRecords.RemoveRange(frame, Length() - frame); }
if (frame >= 0 && frame < MovieLength())
{
MovieRecords.RemoveRange(frame, MovieLength() - frame);
}
}
public void TruncateStates(int frame)
{
if (frame >= 0 && frame < StateLength())
{
StateRecords.RemoveRange(frame, StateLength() - frame);
}
}
public string GetFrame(int frameCount) //Frame count is 0 based here, should it be?
@ -133,7 +136,7 @@ namespace BizHawk.MultiClient
public void WriteText(StreamWriter sw)
{
int length = Length();
int length = MovieLength();
for (int x = 0; x < length; x++)
{
sw.WriteLine(GetFrame(x));

View File

@ -64,7 +64,8 @@
this.ReadOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.InsertOneFrame = new System.Windows.Forms.ToolStripMenuItem();
this.Insert = new System.Windows.Forms.ToolStripMenuItem();
this.Delete = new System.Windows.Forms.ToolStripMenuItem();
this.SelectAll = new System.Windows.Forms.ToolStripMenuItem();
this.ControllerBox = new System.Windows.Forms.GroupBox();
this.ControllersContext = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -82,7 +83,6 @@
this.TASView = new BizHawk.VirtualListView();
this.Frame = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Log = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DeleteFrames = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.ControllersContext.SuspendLayout();
@ -294,18 +294,25 @@
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.InsertOneFrame,
this.DeleteFrames,
this.Insert,
this.Delete,
this.SelectAll});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(157, 70);
//
// InsertOneFrame
// Insert
//
this.InsertOneFrame.Name = "InsertOneFrame";
this.InsertOneFrame.Size = new System.Drawing.Size(156, 22);
this.InsertOneFrame.Text = "Insert Frame";
this.InsertOneFrame.Click += new System.EventHandler(this.InsertOneFrame_Click);
this.Insert.Name = "Insert";
this.Insert.Size = new System.Drawing.Size(156, 22);
this.Insert.Text = "Insert Frame(s)";
this.Insert.Click += new System.EventHandler(this.Insert_Click);
//
// Delete
//
this.Delete.Name = "Delete";
this.Delete.Size = new System.Drawing.Size(156, 22);
this.Delete.Text = "Delete Frame(s)";
this.Delete.Click += new System.EventHandler(this.Delete_Click);
//
// SelectAll
//
@ -483,13 +490,6 @@
this.Log.Text = "Log";
this.Log.Width = 201;
//
// DeleteFrames
//
this.DeleteFrames.Name = "DeleteFrames";
this.DeleteFrames.Size = new System.Drawing.Size(156, 22);
this.DeleteFrames.Text = "Delete Frame(s)";
this.DeleteFrames.Click += new System.EventHandler(this.DeleteFrames_Click);
//
// TAStudio
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -551,7 +551,7 @@
private System.Windows.Forms.ToolStripButton FastFowardToEnd;
private System.Windows.Forms.ToolStripMenuItem insertFrameToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem InsertOneFrame;
private System.Windows.Forms.ToolStripMenuItem Insert;
private System.Windows.Forms.ToolStripMenuItem SelectAll;
private System.Windows.Forms.GroupBox ControllerBox;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
@ -564,6 +564,6 @@
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem1;
private System.Windows.Forms.ToolStripButton FastForward;
private System.Windows.Forms.ToolStripButton TurboFastForward;
private System.Windows.Forms.ToolStripMenuItem DeleteFrames;
private System.Windows.Forms.ToolStripMenuItem Delete;
}
}

View File

@ -104,9 +104,9 @@ namespace BizHawk.MultiClient
private void TASView_QueryItemBkColor(int index, int column, ref Color color)
{
if (index <= Global.MovieSession.Movie.LastValidState())
if (index < Global.MovieSession.Movie.ValidStateCount())
color = Color.LightGreen;
else if (Global.MovieSession.Movie.GetInputFrame(index)[1] == 'L')
else if ("" != Global.MovieSession.Movie.GetInputFrame(index) && Global.MovieSession.Movie.GetInputFrame(index)[1] == 'L')
color = Color.Pink;
if (index == Global.Emulator.Frame)
{
@ -117,15 +117,25 @@ namespace BizHawk.MultiClient
private void TASView_QueryItemText(int index, int column, out string text)
{
text = "";
if (column == 0)
text = String.Format("{0:#,##0}", index);
if (column == 1)
text = Global.MovieSession.Movie.GetInputFrame(index);
//If this is just for an actual frame and not just the list view cursor at the end
if (Global.MovieSession.Movie.LogLength() != index)
{
if (column == 0)
text = String.Format("{0:#,##0}", index);
if (column == 1)
text = Global.MovieSession.Movie.GetInputFrame(index);
}
}
private void DisplayList()
{
TASView.ItemCount = Global.MovieSession.Movie.Length();
TASView.ItemCount = Global.MovieSession.Movie.LogLength();
if (Global.MovieSession.Movie.LogLength() == Global.Emulator.Frame && Global.MovieSession.Movie.StateLength() == Global.Emulator.Frame)
{
//If we're at the end of the movie add one to show the cursor as a blank frame
TASView.ItemCount++;
}
TASView.ensureVisible(Global.Emulator.Frame-1);
}
@ -473,15 +483,23 @@ namespace BizHawk.MultiClient
Global.MovieSession.Movie.RewindToFrame(TASView.selectedItem);
}
private void InsertOneFrame_Click(object sender, EventArgs e)
private void Insert_Click(object sender, EventArgs e)
{
Global.MovieSession.Movie.InsertFrame(Global.MovieSession.Movie.GetInputFrame(TASView.selectedItem), TASView.selectedItem);
ListView.SelectedIndexCollection list = TASView.SelectedIndices;
for (int index = 0; index < list.Count; index++)
{
Global.MovieSession.Movie.InsertFrame(Global.MovieSession.Movie.GetInputFrame(list[index]), (int)list[index]);
}
Global.MovieSession.Movie.RewindToFrame(TASView.selectedItem);
}
private void DeleteFrames_Click(object sender, EventArgs e)
private void Delete_Click(object sender, EventArgs e)
{
Global.MovieSession.Movie.DeleteFrame(TASView.selectedItem);
ListView.SelectedIndexCollection list = TASView.SelectedIndices;
for (int index = 0; index < list.Count; index++)
{
Global.MovieSession.Movie.DeleteFrame(TASView.selectedItem);
}
}
}
}