Tastudio - branches - ability to load a branch, currently the frame buffer does not have OSD info
This commit is contained in:
parent
2201d01982
commit
4188f2105e
|
@ -106,6 +106,17 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PopulateFramebuffer(byte[] bytes)
|
||||||
|
{
|
||||||
|
using (var ms = new MemoryStream(bytes))
|
||||||
|
{
|
||||||
|
using (var br = new BinaryReader(ms))
|
||||||
|
{
|
||||||
|
PopulateFramebuffer(br);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool LoadStateFile(string path, string name)
|
public static bool LoadStateFile(string path, string name)
|
||||||
{
|
{
|
||||||
var core = Global.Emulator.AsStatable();
|
var core = Global.Emulator.AsStatable();
|
||||||
|
|
|
@ -9,7 +9,8 @@ namespace BizHawk.Client.Common
|
||||||
public int Frame { get; set; }
|
public int Frame { get; set; }
|
||||||
public byte[] CoreData { get; set; }
|
public byte[] CoreData { get; set; }
|
||||||
public List<string> InputLog { get; set; }
|
public List<string> InputLog { get; set; }
|
||||||
public byte[] OSDFrameBuffer { get; set; }
|
public int[] OSDFrameBuffer { get; set; }
|
||||||
|
public TasLagLog LagLog { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TasBranchCollection : List<TasBranch>
|
public class TasBranchCollection : List<TasBranch>
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace BizHawk.Client.Common
|
||||||
public class TasLagLog
|
public class TasLagLog
|
||||||
{
|
{
|
||||||
// TODO: Change this into a regular list.
|
// TODO: Change this into a regular list.
|
||||||
private readonly List<bool> LagLog = new List<bool>();
|
private List<bool> LagLog = new List<bool>();
|
||||||
|
|
||||||
private readonly List<bool> WasLag = new List<bool>();
|
private List<bool> WasLag = new List<bool>();
|
||||||
|
|
||||||
public bool? this[int frame]
|
public bool? this[int frame]
|
||||||
{
|
{
|
||||||
|
@ -155,6 +155,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int LastValidFrame
|
public int LastValidFrame
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -164,5 +165,20 @@ namespace BizHawk.Client.Common
|
||||||
return LagLog.Count - 1;
|
return LagLog.Count - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TasLagLog Clone()
|
||||||
|
{
|
||||||
|
var log = new TasLagLog();
|
||||||
|
log.LagLog = LagLog.ToList();
|
||||||
|
log.WasLag = LagLog.ToList();
|
||||||
|
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FromLagLog(TasLagLog log)
|
||||||
|
{
|
||||||
|
LagLog = log.LagLog;
|
||||||
|
WasLag = log.WasLag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -455,5 +455,16 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadBranch(TasBranch branch)
|
||||||
|
{
|
||||||
|
// TODO: undo?
|
||||||
|
_log = branch.InputLog;
|
||||||
|
_changes = true;
|
||||||
|
StateManager.ClearStateHistory();
|
||||||
|
StateManager.SetState(branch.Frame, branch.CoreData);
|
||||||
|
LagLog.Clear();
|
||||||
|
LagLog.FromLagLog(branch.LagLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,8 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
File.Delete(path);
|
File.Delete(path);
|
||||||
}
|
}
|
||||||
private void SetState(int frame, byte[] state)
|
|
||||||
|
internal void SetState(int frame, byte[] state)
|
||||||
{
|
{
|
||||||
if (States.ContainsKey(frame))
|
if (States.ContainsKey(frame))
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,13 +30,15 @@
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
this.BookmarksBranchesGroupBox = new System.Windows.Forms.GroupBox();
|
this.BookmarksBranchesGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
|
||||||
this.AddContextMenu = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.BranchView = new BizHawk.Client.EmuHawk.VirtualListView();
|
this.BranchView = new BizHawk.Client.EmuHawk.VirtualListView();
|
||||||
this.BranchNumberColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.BranchNumberColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.FrameColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.FrameColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.TimeColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.TimeColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
|
this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.AddContextMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.LoadBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.BookmarksBranchesGroupBox.SuspendLayout();
|
this.BookmarksBranchesGroupBox.SuspendLayout();
|
||||||
this.BranchesContextMenu.SuspendLayout();
|
this.BranchesContextMenu.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
|
@ -54,29 +56,6 @@
|
||||||
this.BookmarksBranchesGroupBox.TabStop = false;
|
this.BookmarksBranchesGroupBox.TabStop = false;
|
||||||
this.BookmarksBranchesGroupBox.Text = "Bookmarks / Branches";
|
this.BookmarksBranchesGroupBox.Text = "Bookmarks / Branches";
|
||||||
//
|
//
|
||||||
// BranchesContextMenu
|
|
||||||
//
|
|
||||||
this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.AddContextMenu,
|
|
||||||
this.RemoveBranchContextMenuItem});
|
|
||||||
this.BranchesContextMenu.Name = "BranchesContextMenu";
|
|
||||||
this.BranchesContextMenu.Size = new System.Drawing.Size(153, 70);
|
|
||||||
this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
|
|
||||||
//
|
|
||||||
// AddContextMenu
|
|
||||||
//
|
|
||||||
this.AddContextMenu.Name = "AddContextMenu";
|
|
||||||
this.AddContextMenu.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.AddContextMenu.Text = "Add";
|
|
||||||
this.AddContextMenu.Click += new System.EventHandler(this.AddContextMenu_Click);
|
|
||||||
//
|
|
||||||
// RemoveBranchContextMenuItem
|
|
||||||
//
|
|
||||||
this.RemoveBranchContextMenuItem.Name = "RemoveBranchContextMenuItem";
|
|
||||||
this.RemoveBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.RemoveBranchContextMenuItem.Text = "Remove";
|
|
||||||
this.RemoveBranchContextMenuItem.Click += new System.EventHandler(this.RemoveBranchContextMenuItem_Click);
|
|
||||||
//
|
|
||||||
// BranchView
|
// BranchView
|
||||||
//
|
//
|
||||||
this.BranchView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.BranchView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
@ -118,6 +97,43 @@
|
||||||
this.TimeColumn.Text = "Length";
|
this.TimeColumn.Text = "Length";
|
||||||
this.TimeColumn.Width = 83;
|
this.TimeColumn.Width = 83;
|
||||||
//
|
//
|
||||||
|
// BranchesContextMenu
|
||||||
|
//
|
||||||
|
this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.LoadBranchContextMenuItem,
|
||||||
|
this.toolStripSeparator1,
|
||||||
|
this.AddContextMenu,
|
||||||
|
this.RemoveBranchContextMenuItem});
|
||||||
|
this.BranchesContextMenu.Name = "BranchesContextMenu";
|
||||||
|
this.BranchesContextMenu.Size = new System.Drawing.Size(153, 98);
|
||||||
|
this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
|
||||||
|
//
|
||||||
|
// AddContextMenu
|
||||||
|
//
|
||||||
|
this.AddContextMenu.Name = "AddContextMenu";
|
||||||
|
this.AddContextMenu.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.AddContextMenu.Text = "Add";
|
||||||
|
this.AddContextMenu.Click += new System.EventHandler(this.AddContextMenu_Click);
|
||||||
|
//
|
||||||
|
// RemoveBranchContextMenuItem
|
||||||
|
//
|
||||||
|
this.RemoveBranchContextMenuItem.Name = "RemoveBranchContextMenuItem";
|
||||||
|
this.RemoveBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.RemoveBranchContextMenuItem.Text = "Remove";
|
||||||
|
this.RemoveBranchContextMenuItem.Click += new System.EventHandler(this.RemoveBranchContextMenuItem_Click);
|
||||||
|
//
|
||||||
|
// LoadBranchContextMenuItem
|
||||||
|
//
|
||||||
|
this.LoadBranchContextMenuItem.Name = "LoadBranchContextMenuItem";
|
||||||
|
this.LoadBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.LoadBranchContextMenuItem.Text = "Load";
|
||||||
|
this.LoadBranchContextMenuItem.Click += new System.EventHandler(this.LoadBranchContextMenuItem_Click);
|
||||||
|
//
|
||||||
|
// toolStripSeparator1
|
||||||
|
//
|
||||||
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
|
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
|
||||||
|
//
|
||||||
// BookmarksBranchesBox
|
// BookmarksBranchesBox
|
||||||
//
|
//
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||||
|
@ -140,5 +156,7 @@
|
||||||
private System.Windows.Forms.ContextMenuStrip BranchesContextMenu;
|
private System.Windows.Forms.ContextMenuStrip BranchesContextMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem AddContextMenu;
|
private System.Windows.Forms.ToolStripMenuItem AddContextMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem LoadBranchContextMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using System.Windows.Forms;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
using BizHawk.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -77,9 +78,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var branch = new TasBranch
|
var branch = new TasBranch
|
||||||
{
|
{
|
||||||
Frame = Global.Emulator.Frame,
|
Frame = Global.Emulator.Frame,
|
||||||
CoreData = (Global.Emulator as IStatable).SaveStateBinary(),
|
CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()),
|
||||||
InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(),
|
InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(),
|
||||||
OSDFrameBuffer = GlobalWin.MainForm.CurrentFrameBuffer(captureOSD: true)
|
//OSDFrameBuffer = GlobalWin.MainForm.CurrentFrameBuffer(captureOSD: true),
|
||||||
|
OSDFrameBuffer = (int[])(Global.Emulator.VideoProvider().GetVideoBuffer().Clone()),
|
||||||
|
LagLog = Tastudio.CurrentTasMovie.TasLagLog.Clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
Branches.Add(branch);
|
Branches.Add(branch);
|
||||||
|
@ -94,9 +97,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadBranchContextMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (SelectedBranch != null)
|
||||||
|
{
|
||||||
|
LoadBranch(SelectedBranch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void BranchesContextMenu_Opening(object sender, CancelEventArgs e)
|
private void BranchesContextMenu_Opening(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
RemoveBranchContextMenuItem.Enabled = SelectedBranch != null;
|
RemoveBranchContextMenuItem.Enabled =
|
||||||
|
LoadBranchContextMenuItem.Enabled =
|
||||||
|
SelectedBranch != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveBranchContextMenuItem_Click(object sender, EventArgs e)
|
private void RemoveBranchContextMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -108,9 +121,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Temp(int[] framebuffer)
|
||||||
|
{
|
||||||
|
var buff = Global.Emulator.VideoProvider().GetVideoBuffer();
|
||||||
|
for (int i = 0; i < buff.Length; i++)
|
||||||
|
{
|
||||||
|
buff[i] = framebuffer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadBranch(TasBranch branch)
|
private void LoadBranch(TasBranch branch)
|
||||||
{
|
{
|
||||||
MessageBox.Show("TODO: load this branch");
|
Tastudio.CurrentTasMovie.LoadBranch(branch);
|
||||||
|
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||||
|
var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData);
|
||||||
|
Tastudio.LoadState(stateInfo);
|
||||||
|
//SavestateManager.PopulateFramebuffer(branch.OSDFrameBuffer);
|
||||||
|
Temp(branch.OSDFrameBuffer);
|
||||||
|
GlobalWin.MainForm.PauseEmulator();
|
||||||
|
GlobalWin.MainForm.PauseOnFrame = null;
|
||||||
|
Tastudio.RefreshDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,7 +558,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadState(KeyValuePair<int, byte[]> state)
|
public void LoadState(KeyValuePair<int, byte[]> state)
|
||||||
{
|
{
|
||||||
StatableEmulator.LoadStateBinary(new BinaryReader(new MemoryStream(state.Value.ToArray())));
|
StatableEmulator.LoadStateBinary(new BinaryReader(new MemoryStream(state.Value.ToArray())));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue