tastudio: attach usertext to branches, make it editable from menu.

moved branch functions and menu items around.
This commit is contained in:
feos 2015-11-23 23:26:56 +03:00
parent 9b0a94dd8e
commit 1f1382ceb7
6 changed files with 298 additions and 196 deletions

View File

@ -65,6 +65,8 @@ namespace BizHawk.Client.Common
public static BinaryStateLump BranchHeader { get; private set; } public static BinaryStateLump BranchHeader { get; private set; }
[Name("Branches\\Markers", "txt")] [Name("Branches\\Markers", "txt")]
public static BinaryStateLump BranchMarkers { get; private set; } public static BinaryStateLump BranchMarkers { get; private set; }
[Name("Branches\\UserText", "txt")]
public static BinaryStateLump BranchUserText { get; private set; }
[Name("Branches\\GreenZone")] [Name("Branches\\GreenZone")]
public static BinaryStateLump BranchStateHistory { get; private set; } public static BinaryStateLump BranchStateHistory { get; private set; }

View File

@ -19,6 +19,7 @@ namespace BizHawk.Client.Common
public DateTime TimeStamp { get; set; } public DateTime TimeStamp { get; set; }
public TasMovieMarkerList Markers { get; set; } public TasMovieMarkerList Markers { get; set; }
public Guid UniqueIdentifier { get; set; } public Guid UniqueIdentifier { get; set; }
public string UserText { get; set; }
} }
public class TasBranchCollection : List<TasBranch> public class TasBranchCollection : List<TasBranch>
@ -44,6 +45,7 @@ namespace BizHawk.Client.Common
var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer); var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer);
var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog); var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog);
var nmarkers = new IndexedStateLump(BinaryStateLump.BranchMarkers); var nmarkers = new IndexedStateLump(BinaryStateLump.BranchMarkers);
var nusertext = new IndexedStateLump(BinaryStateLump.BranchUserText);
foreach (var b in this) foreach (var b in this)
{ {
bs.PutLump(nheader, delegate(TextWriter tw) bs.PutLump(nheader, delegate(TextWriter tw)
@ -85,12 +87,18 @@ namespace BizHawk.Client.Common
tw.WriteLine(b.Markers.ToString()); tw.WriteLine(b.Markers.ToString());
}); });
bs.PutLump(nusertext, delegate(TextWriter tw)
{
tw.WriteLine(b.UserText);
});
nheader.Increment(); nheader.Increment();
ncore.Increment(); ncore.Increment();
ninput.Increment(); ninput.Increment();
nframebuffer.Increment(); nframebuffer.Increment();
nlaglog.Increment(); nlaglog.Increment();
nmarkers.Increment(); nmarkers.Increment();
nusertext.Increment();
} }
} }
@ -102,6 +110,7 @@ namespace BizHawk.Client.Common
var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer); var nframebuffer = new IndexedStateLump(BinaryStateLump.BranchFrameBuffer);
var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog); var nlaglog = new IndexedStateLump(BinaryStateLump.BranchLagLog);
var nmarkers = new IndexedStateLump(BinaryStateLump.BranchMarkers); var nmarkers = new IndexedStateLump(BinaryStateLump.BranchMarkers);
var nusertext = new IndexedStateLump(BinaryStateLump.BranchUserText);
Clear(); Clear();
@ -179,6 +188,19 @@ namespace BizHawk.Client.Common
} }
}); });
bl.GetLump(nusertext, false, delegate(TextReader tr)
{
string line;
if ((line = tr.ReadLine()) != null)
{
if (!string.IsNullOrWhiteSpace(line))
{
b.UserText = line;
}
}
});
Add(b); Add(b);
nheader.Increment(); nheader.Increment();
@ -187,6 +209,7 @@ namespace BizHawk.Client.Common
nframebuffer.Increment(); nframebuffer.Increment();
nlaglog.Increment(); nlaglog.Increment();
nmarkers.Increment(); nmarkers.Increment();
nusertext.Increment();
} }
} }
} }

View File

@ -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.BranchView = new BizHawk.Client.EmuHawk.InputRoll();
this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.LoadBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.LoadBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.UpdateBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.UpdateBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AddContextMenu = new System.Windows.Forms.ToolStripMenuItem(); this.AddBranchContextMenu = new System.Windows.Forms.ToolStripMenuItem();
this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BranchView = new BizHawk.Client.EmuHawk.InputRoll(); this.EditBranchTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AddBranchWithTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BookmarksBranchesGroupBox.SuspendLayout(); this.BookmarksBranchesGroupBox.SuspendLayout();
this.BranchesContextMenu.SuspendLayout(); this.BranchesContextMenu.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -54,54 +56,6 @@
this.BookmarksBranchesGroupBox.TabStop = false; this.BookmarksBranchesGroupBox.TabStop = false;
this.BookmarksBranchesGroupBox.Text = "Branches"; this.BookmarksBranchesGroupBox.Text = "Branches";
// //
// BranchesContextMenu
//
this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.LoadBranchContextMenuItem,
this.toolStripSeparator1,
this.UpdateBranchContextMenuItem,
this.AddContextMenu,
this.RemoveBranchContextMenuItem});
this.BranchesContextMenu.Name = "BranchesContextMenu";
this.BranchesContextMenu.Size = new System.Drawing.Size(118, 98);
this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
//
// LoadBranchContextMenuItem
//
this.LoadBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Debugger;
this.LoadBranchContextMenuItem.Name = "LoadBranchContextMenuItem";
this.LoadBranchContextMenuItem.Size = new System.Drawing.Size(117, 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(114, 6);
//
// UpdateBranchContextMenuItem
//
this.UpdateBranchContextMenuItem.Name = "UpdateBranchContextMenuItem";
this.UpdateBranchContextMenuItem.Size = new System.Drawing.Size(117, 22);
this.UpdateBranchContextMenuItem.Text = "&Update";
this.UpdateBranchContextMenuItem.Click += new System.EventHandler(this.UpdateBranchContextMenuItem_Click);
//
// AddContextMenu
//
this.AddContextMenu.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.add;
this.AddContextMenu.Name = "AddContextMenu";
this.AddContextMenu.Size = new System.Drawing.Size(117, 22);
this.AddContextMenu.Text = "Add";
this.AddContextMenu.Click += new System.EventHandler(this.AddContextMenu_Click);
//
// RemoveBranchContextMenuItem
//
this.RemoveBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Delete;
this.RemoveBranchContextMenuItem.Name = "RemoveBranchContextMenuItem";
this.RemoveBranchContextMenuItem.Size = new System.Drawing.Size(117, 22);
this.RemoveBranchContextMenuItem.Text = "Remove";
this.RemoveBranchContextMenuItem.Click += new System.EventHandler(this.RemoveBranchContextMenuItem_Click);
//
// BranchView // BranchView
// //
this.BranchView.AllowColumnReorder = false; this.BranchView.AllowColumnReorder = false;
@ -112,6 +66,10 @@
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.BranchView.CellHeightPadding = 0; this.BranchView.CellHeightPadding = 0;
this.BranchView.ContextMenuStrip = this.BranchesContextMenu; this.BranchView.ContextMenuStrip = this.BranchesContextMenu;
this.BranchView.denoteMarkersWithBGColor = false;
this.BranchView.denoteMarkersWithIcons = false;
this.BranchView.denoteStatesWithBGColor = false;
this.BranchView.denoteStatesWithIcons = false;
this.BranchView.FullRowSelect = true; this.BranchView.FullRowSelect = true;
this.BranchView.HideWasLagFrames = false; this.BranchView.HideWasLagFrames = false;
this.BranchView.HorizontalOrientation = false; this.BranchView.HorizontalOrientation = false;
@ -133,6 +91,73 @@
this.BranchView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseMove); this.BranchView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseMove);
this.BranchView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseUp); this.BranchView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseUp);
// //
// BranchesContextMenu
//
this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.LoadBranchContextMenuItem,
this.toolStripSeparator1,
this.AddBranchContextMenu,
this.AddBranchWithTextToolStripMenuItem,
this.UpdateBranchContextMenuItem,
this.EditBranchTextToolStripMenuItem,
this.RemoveBranchContextMenuItem});
this.BranchesContextMenu.Name = "BranchesContextMenu";
this.BranchesContextMenu.Size = new System.Drawing.Size(153, 164);
this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
//
// LoadBranchContextMenuItem
//
this.LoadBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Debugger;
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);
//
// UpdateBranchContextMenuItem
//
this.UpdateBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.reboot;
this.UpdateBranchContextMenuItem.Name = "UpdateBranchContextMenuItem";
this.UpdateBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
this.UpdateBranchContextMenuItem.Text = "&Update";
this.UpdateBranchContextMenuItem.Click += new System.EventHandler(this.UpdateBranchContextMenuItem_Click);
//
// AddBranchContextMenu
//
this.AddBranchContextMenu.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.add;
this.AddBranchContextMenu.Name = "AddBranchContextMenu";
this.AddBranchContextMenu.Size = new System.Drawing.Size(152, 22);
this.AddBranchContextMenu.Text = "Add";
this.AddBranchContextMenu.Click += new System.EventHandler(this.AddContextMenu_Click);
//
// RemoveBranchContextMenuItem
//
this.RemoveBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Delete;
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);
//
// EditBranchTextToolStripMenuItem
//
this.EditBranchTextToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.pencil;
this.EditBranchTextToolStripMenuItem.Name = "EditBranchTextToolStripMenuItem";
this.EditBranchTextToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.EditBranchTextToolStripMenuItem.Text = "Edit Text";
this.EditBranchTextToolStripMenuItem.Click += new System.EventHandler(this.EditBranchTextToolStripMenuItem_Click);
//
// AddBranchWithTextToolStripMenuItem
//
this.AddBranchWithTextToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.add;
this.AddBranchWithTextToolStripMenuItem.Name = "AddBranchWithTextToolStripMenuItem";
this.AddBranchWithTextToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.AddBranchWithTextToolStripMenuItem.Text = "Add with Text";
this.AddBranchWithTextToolStripMenuItem.Click += new System.EventHandler(this.AddBranchWithTextToolStripMenuItem_Click);
//
// BookmarksBranchesBox // BookmarksBranchesBox
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -150,10 +175,12 @@
private System.Windows.Forms.GroupBox BookmarksBranchesGroupBox; private System.Windows.Forms.GroupBox BookmarksBranchesGroupBox;
private InputRoll BranchView; private InputRoll BranchView;
private System.Windows.Forms.ContextMenuStrip BranchesContextMenu; private System.Windows.Forms.ContextMenuStrip BranchesContextMenu;
private System.Windows.Forms.ToolStripMenuItem AddContextMenu; private System.Windows.Forms.ToolStripMenuItem AddBranchContextMenu;
private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem; private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem;
private System.Windows.Forms.ToolStripMenuItem LoadBranchContextMenuItem; private System.Windows.Forms.ToolStripMenuItem LoadBranchContextMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem UpdateBranchContextMenuItem; private System.Windows.Forms.ToolStripMenuItem UpdateBranchContextMenuItem;
private System.Windows.Forms.ToolStripMenuItem EditBranchTextToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem AddBranchWithTextToolStripMenuItem;
} }
} }

View File

@ -58,19 +58,6 @@ namespace BizHawk.Client.EmuHawk
BranchView.QueryItemBkColor += QueryItemBkColor; BranchView.QueryItemBkColor += QueryItemBkColor;
} }
public TasBranch SelectedBranch
{
get
{
if (BranchView.AnyRowsSelected)
{
return GetBranch(BranchView.SelectedRows.First());
}
return null;
}
}
private void QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) private void QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY)
{ {
text = string.Empty; text = string.Empty;
@ -125,19 +112,63 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void AddContextMenu_Click(object sender, EventArgs e) public void Branch()
{ {
Branch(); TasBranch branch = CreateBranch();
Movie.AddBranch(branch);
BranchView.RowCount = Movie.BranchCount;
Movie.CurrentBranch = Movie.BranchCount - 1;
BranchView.Refresh();
Tastudio.RefreshDialog();
} }
private void BranchView_MouseDoubleClick(object sender, MouseEventArgs e) public TasBranch SelectedBranch
{ {
LoadSelectedBranch(); get
{
if (BranchView.AnyRowsSelected)
{
return GetBranch(BranchView.SelectedRows.First());
}
return null;
}
} }
private void LoadBranchContextMenuItem_Click(object sender, EventArgs e) private TasBranch CreateBranch()
{ {
LoadSelectedBranch(); // TODO: don't use Global.Emulator
return new TasBranch
{
Frame = Global.Emulator.Frame,
CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()),
InputLog = Movie.InputLog.Clone(),
OSDFrameBuffer = GlobalWin.MainForm.CaptureOSD(),
LagLog = Movie.TasLagLog.Clone(),
ChangeLog = new TasMovieChangeLog(Movie),
TimeStamp = DateTime.Now,
Markers = Movie.Markers.DeepClone(),
UserText = ""
};
}
private void LoadBranch(TasBranch branch)
{
Tastudio.CurrentTasMovie.LoadBranch(branch);
GlobalWin.DisplayManager.NeedsToPaint = true;
var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData);
Tastudio.LoadState(stateInfo);
QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.OSDFrameBuffer), Global.Emulator.VideoProvider());
GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.PauseOnFrame = null;
Tastudio.RefreshDialog();
}
private void UpdateBranch(TasBranch branch)
{
Movie.UpdateBranch(branch, CreateBranch());
BranchView.Refresh();
Tastudio.RefreshDialog();
} }
private void LoadSelectedBranch() private void LoadSelectedBranch()
@ -161,6 +192,40 @@ namespace BizHawk.Client.EmuHawk
SelectedBranch != null; SelectedBranch != null;
} }
private void AddContextMenu_Click(object sender, EventArgs e)
{
Branch();
}
private void AddBranchWithTextToolStripMenuItem_Click(object sender, EventArgs e)
{
Branch();
Tastudio.CallEditBranchTextPopUp(Movie.CurrentBranch);
}
private void LoadBranchContextMenuItem_Click(object sender, EventArgs e)
{
LoadSelectedBranch();
}
private void UpdateBranchContextMenuItem_Click(object sender, EventArgs e)
{
if (SelectedBranch != null)
{
UpdateBranch(SelectedBranch);
Movie.CurrentBranch = BranchView.SelectedRows.First();
}
}
private void EditBranchTextToolStripMenuItem_Click(object sender, EventArgs e)
{
if (SelectedBranch != null)
{
int index = BranchView.SelectedRows.First();
Tastudio.CallEditBranchTextPopUp(index);
}
}
private void RemoveBranchContextMenuItem_Click(object sender, EventArgs e) private void RemoveBranchContextMenuItem_Click(object sender, EventArgs e)
{ {
if (SelectedBranch != null) if (SelectedBranch != null)
@ -188,18 +253,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void LoadBranch(TasBranch branch)
{
Tastudio.CurrentTasMovie.LoadBranch(branch);
GlobalWin.DisplayManager.NeedsToPaint = true;
var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData);
Tastudio.LoadState(stateInfo);
QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.OSDFrameBuffer), Global.Emulator.VideoProvider());
GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.PauseOnFrame = null;
Tastudio.RefreshDialog();
}
public void UpdateValues() public void UpdateValues()
{ {
BranchView.RowCount = Movie.BranchCount; BranchView.RowCount = Movie.BranchCount;
@ -213,30 +266,68 @@ namespace BizHawk.Client.EmuHawk
BranchView.Refresh(); BranchView.Refresh();
} }
public void Branch() private void ScreenShotPopUp(TasBranch branch, int index)
{ {
TasBranch branch = CreateBranch(); Point locationOnForm = this.FindForm().PointToClient(
Movie.AddBranch(branch); this.Parent.PointToScreen(this.Location));
BranchView.RowCount = Movie.BranchCount;
Movie.CurrentBranch = Movie.BranchCount - 1; int x = locationOnForm.X - Tastudio.ScreenshotControl.Width;
BranchView.Refresh(); int y = locationOnForm.Y; // keep consistent height, helps when conparing screenshots
Tastudio.RefreshDialog();
if (x < 1) x = 1;
Tastudio.ScreenshotControl.Location = new Point(x, y);
Tastudio.ScreenshotControl.Visible = true;
Tastudio.ScreenshotControl.Branch = branch;
Tastudio.ScreenshotControl.RecalculateHeight();
Tastudio.ScreenshotControl.Refresh();
} }
private TasBranch CreateBranch() private void CloseScreenShotPopUp()
{ {
// TODO: don't use Global.Emulator Tastudio.ScreenshotControl.Visible = false;
return new TasBranch }
private void BranchView_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
{ {
Frame = Global.Emulator.Frame, if (BranchView.CurrentCell != null && BranchView.CurrentCell.IsDataCell
CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()), && BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
InputLog = Movie.InputLog.Clone(), {
OSDFrameBuffer = GlobalWin.MainForm.CaptureOSD(), BranchView.DragCurrentCell();
LagLog = Movie.TasLagLog.Clone(), }
ChangeLog = new TasMovieChangeLog(Movie), }
TimeStamp = DateTime.Now, }
Markers = Movie.Markers.DeepClone()
}; private void BranchView_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
BranchView.ReleaseCurrentCell();
}
}
private void BranchView_MouseDoubleClick(object sender, MouseEventArgs e)
{
LoadSelectedBranch();
}
private void BranchView_MouseMove(object sender, MouseEventArgs e)
{
if (BranchView.CurrentCell == null || !BranchView.CurrentCell.RowIndex.HasValue || BranchView.CurrentCell.Column == null)
{
CloseScreenShotPopUp();
}
else if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
{
BranchView.Refresh();
}
}
private void BranchView_MouseLeave(object sender, EventArgs e)
{
// Tastudio.ScreenshotControl.Visible = false;
} }
private void BranchView_CellHovered(object sender, InputRoll.CellEventArgs e) private void BranchView_CellHovered(object sender, InputRoll.CellEventArgs e)
@ -258,82 +349,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void BranchView_MouseMove(object sender, MouseEventArgs e)
{
if (BranchView.CurrentCell == null || !BranchView.CurrentCell.RowIndex.HasValue || BranchView.CurrentCell.Column == null)
{
CloseScreenShotPopUp();
}
else if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
{
BranchView.Refresh();
}
}
private void CloseScreenShotPopUp()
{
Tastudio.ScreenshotControl.Visible = false;
}
private void BranchView_MouseLeave(object sender, EventArgs e)
{
// Tastudio.ScreenshotControl.Visible = false;
}
private void ScreenShotPopUp(TasBranch branch, int index)
{
Point locationOnForm = this.FindForm().PointToClient(
this.Parent.PointToScreen(this.Location));
int x = locationOnForm.X - Tastudio.ScreenshotControl.Width;
int y = locationOnForm.Y; // keep consistent height, helps when conparing screenshots
if (x < 1) x = 1;
Tastudio.ScreenshotControl.UserText = "";
Tastudio.ScreenshotControl.RecalculatePadding();
Tastudio.ScreenshotControl.Location = new Point(x, y);
Tastudio.ScreenshotControl.Visible = true;
Tastudio.ScreenshotControl.Branch = branch;
Tastudio.ScreenshotControl.Refresh();
}
private void UpdateBranchContextMenuItem_Click(object sender, EventArgs e)
{
if (SelectedBranch != null)
{
UpdateBranch(SelectedBranch);
Movie.CurrentBranch = BranchView.SelectedRows.First();
}
}
private void UpdateBranch(TasBranch branch)
{
Movie.UpdateBranch(branch, CreateBranch());
BranchView.Refresh();
Tastudio.RefreshDialog();
}
private void BranchView_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (BranchView.CurrentCell != null && BranchView.CurrentCell.IsDataCell
&& BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
{
BranchView.DragCurrentCell();
}
}
}
private void BranchView_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
BranchView.ReleaseCurrentCell();
}
}
private void BranchView_CellDropped(object sender, InputRoll.CellEventArgs e) private void BranchView_CellDropped(object sender, InputRoll.CellEventArgs e)
{ {
if (e.NewCell != null && e.NewCell.IsDataCell && e.OldCell.RowIndex.Value < Movie.BranchCount) if (e.NewCell != null && e.NewCell.IsDataCell && e.OldCell.RowIndex.Value < Movie.BranchCount)

View File

@ -9,6 +9,14 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class ScreenshotPopupControl : UserControl public partial class ScreenshotPopupControl : UserControl
{ {
public TasBranch Branch { get; set; }
public int DrawingHeight = 0;
public int UserPadding = 0;
public int UserFontSize = 10; // because why not?
public FontStyle UserFontStyle = FontStyle.Regular;
public string UserText;
private Font UserFont;
public ScreenshotPopupControl() public ScreenshotPopupControl()
{ {
SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true);
@ -18,13 +26,6 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
public TasBranch Branch { get; set; }
private void ScreenshotPopupControl_Load(object sender, EventArgs e)
{
}
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)
{ {
var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap(); var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap();
@ -32,11 +33,31 @@ namespace BizHawk.Client.EmuHawk
if (UserPadding > 0) if (UserPadding > 0)
{ {
e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, DrawingHeight), new Size(Width - 1, UserPadding - 1))); e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, DrawingHeight), new Size(Width - 1, UserPadding - 1)));
e.Graphics.DrawString(UserText, _font, Brushes.Black, new Rectangle(1, DrawingHeight, Width - 1, Height)); e.Graphics.DrawString(UserText, UserFont, Brushes.Black, new Rectangle(2, DrawingHeight, Width - 2, Height));
} }
base.OnPaint(e); base.OnPaint(e);
} }
public void SetFontStyle(FontStyle style)
{
UserFontStyle = style;
}
public void SetFontSize(int size)
{
UserFontSize = size;
}
public void RecalculateHeight()
{
UserFont = new Font(FontFamily.GenericMonospace, UserFontSize, UserFontStyle);
UserText = Branch.UserText;
UserPadding = (int)Graphics.FromHwnd(this.Handle).MeasureString(UserText, UserFont, Width).Height;
if (UserPadding > 0)
UserPadding += 2;
Height = DrawingHeight + UserPadding;
}
private void ScreenshotPopupControl_MouseLeave(object sender, EventArgs e) private void ScreenshotPopupControl_MouseLeave(object sender, EventArgs e)
{ {
Visible = false; Visible = false;
@ -47,18 +68,9 @@ namespace BizHawk.Client.EmuHawk
// todo: switch screenshots by hotkey // todo: switch screenshots by hotkey
} }
public void RecalculatePadding() private void ScreenshotPopupControl_Load(object sender, EventArgs e)
{ {
UserPadding = (int)Graphics.FromHwnd(this.Handle).MeasureString(UserText, _font, Width).Height;
if (UserPadding > 0)
UserPadding += 2;
Height = DrawingHeight + UserPadding;
} }
public int DrawingHeight = 0;
public int UserPadding = 0;
public string UserText;
private Font _font = new Font(new FontFamily("Courier New"), 8);
} }
} }

View File

@ -755,6 +755,29 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void CallEditBranchTextPopUp(int index)
{
TasBranch branch = CurrentTasMovie.GetBranch(index);
if (branch == null)
return;
InputPrompt i = new InputPrompt
{
Text = "Text for branch " + index,
TextInputType = InputPrompt.InputType.Text,
Message = "Enter a message",
InitialValue = branch.UserText
};
var result = i.ShowHawkDialog();
if (result == DialogResult.OK)
{
branch.UserText = i.PromptText;
BookMarkControl.UpdateValues();
}
}
private void UpdateChangesIndicator() private void UpdateChangesIndicator()
{ {
// TODO // TODO