TAStudio - ability to add markers, very crude implementation for now

This commit is contained in:
adelikat 2014-07-15 23:43:17 +00:00
parent c06fe4bddb
commit 8c064875c2
10 changed files with 81 additions and 27 deletions

View File

@ -21,6 +21,7 @@ namespace BizHawk.Client.Common
{
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
Markers = new TasMovieMarkerList();
Markers.Add(0, StartsFromSavestate ? "Savestate" : "Power on");
}
public override string PreferredExtension
@ -56,6 +57,8 @@ namespace BizHawk.Client.Common
StateManager.Clear();
Markers.Clear();
base.StartNewRecording();
Markers.Add(0, StartsFromSavestate ? "Savestate" : "Power on");
}
/// <summary>

View File

@ -61,16 +61,6 @@ namespace BizHawk.Client.Common
}
}
public static bool operator ==(TasMovieMarker a, TasMovieMarker b)
{
return a.Frame == b.Frame;
}
public static bool operator !=(TasMovieMarker a, TasMovieMarker b)
{
return a.Frame != b.Frame;
}
public static bool operator ==(TasMovieMarker marker, int frame)
{
return marker.Frame == frame;
@ -125,9 +115,9 @@ namespace BizHawk.Client.Common
public TasMovieMarker Previous(int currentFrame)
{
return this
.Where(m => m.Frame < currentFrame)
.Where(m => m.Frame <= currentFrame)
.OrderBy(m => m.Frame)
.Last();
.LastOrDefault();
}
public TasMovieMarker Next(int currentFrame)
@ -135,7 +125,7 @@ namespace BizHawk.Client.Common
return this
.Where(m => m.Frame > currentFrame)
.OrderBy(m => m.Frame)
.First();
.FirstOrDefault();
}
}
}

View File

@ -1479,9 +1479,9 @@ namespace BizHawk.Client.EmuHawk
{
var inputPrompt = new InputPrompt { Text = "Go to Address", StartLocation = GetPromptPoint() };
inputPrompt.SetMessage("Enter a hexadecimal value");
inputPrompt.ShowHawkDialog();
var result = inputPrompt.ShowHawkDialog();
if (inputPrompt.UserOk && inputPrompt.UserText.IsHex())
if (result == DialogResult.OK && inputPrompt.UserText.IsHex())
{
GoToAddress(int.Parse(inputPrompt.UserText, NumberStyles.HexNumber));
}

View File

@ -14,12 +14,10 @@ namespace BizHawk.Client.EmuHawk
public InputPrompt()
{
InitializeComponent();
UserText = string.Empty;
StartLocation = new Point(-1, -1);
}
public enum InputType { Hex, Unsigned, Signed, Text }
public bool UserOk { get; set; } // Will be true if the user selects Ok
public string UserText { get; set; } // What the user selected
public Point StartLocation { get; set; }
public InputType TextInputType { get; set; }
@ -54,14 +52,14 @@ namespace BizHawk.Client.EmuHawk
private void Ok_Click(object sender, EventArgs e)
{
UserOk = true;
DialogResult = DialogResult.OK;
UserText = PromptBox.Text;
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
UserOk = false;
DialogResult = DialogResult.Cancel;
Close();
}

View File

@ -28,11 +28,23 @@
/// </summary>
private void InitializeComponent()
{
this.AddBtn = new System.Windows.Forms.Button();
this.MarkerView = new BizHawk.Client.EmuHawk.VirtualListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SuspendLayout();
//
// AddBtn
//
this.AddBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.AddBtn.Location = new System.Drawing.Point(157, 214);
this.AddBtn.Name = "AddBtn";
this.AddBtn.Size = new System.Drawing.Size(44, 23);
this.AddBtn.TabIndex = 6;
this.AddBtn.Text = "Add";
this.AddBtn.UseVisualStyleBackColor = true;
this.AddBtn.Click += new System.EventHandler(this.AddBtn_Click);
//
// MarkerView
//
this.MarkerView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -72,9 +84,10 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.AddBtn);
this.Controls.Add(this.MarkerView);
this.Name = "MarkerControl";
this.Size = new System.Drawing.Size(204, 215);
this.Size = new System.Drawing.Size(204, 241);
this.Load += new System.EventHandler(this.MarkerControl_Load);
this.ResumeLayout(false);
@ -85,6 +98,7 @@
private VirtualListView MarkerView;
public System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Button AddBtn;
}
}

View File

@ -14,6 +14,7 @@ namespace BizHawk.Client.EmuHawk
public partial class MarkerControl : UserControl
{
public TasMovieMarkerList Markers {get; set; }
public Action AddCallback { get; set; }
public MarkerControl()
{
@ -34,7 +35,15 @@ namespace BizHawk.Client.EmuHawk
private void MarkerView_QueryItemBkColor(int index, int column, ref Color color)
{
var prev = Markers.Previous(Global.Emulator.Frame);
if (prev != null)
{
if (index == Markers.IndexOf(prev))
{
color = Color.LightGreen;
}
}
}
private void MarkerView_QueryItemText(int index, int column, out string text)
@ -50,5 +59,20 @@ namespace BizHawk.Client.EmuHawk
text = Markers[index].Message;
}
}
private void AddBtn_Click(object sender, EventArgs e)
{
AddCallback();
}
public new void Refresh()
{
if (MarkerView != null && Markers != null)
{
MarkerView.ItemCount = Markers.Count;
}
base.Refresh();
}
}
}

View File

@ -692,8 +692,8 @@ namespace BizHawk.Client.EmuHawk
this.TasView.View = System.Windows.Forms.View.Details;
this.TasView.SelectedIndexChanged += new System.EventHandler(this.TasView_SelectedIndexChanged);
this.TasView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDown);
this.TasView.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseWheel);
this.TasView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseUp);
this.TasView.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseWheel);
//
// Frame
//

View File

@ -68,6 +68,7 @@ namespace BizHawk.Client.EmuHawk
public TAStudio()
{
InitializeComponent();
MarkerControl.AddCallback = CallAddMarkerPopUp;
TasView.QueryItemText += TasView_QueryItemText;
TasView.QueryItemBkColor += TasView_QueryItemBkColor;
TasView.VirtualMode = true;
@ -212,6 +213,10 @@ namespace BizHawk.Client.EmuHawk
private void RefreshDialog()
{
TasView.ItemCount = _tas.InputLogLength;
if (MarkerControl != null)
{
MarkerControl.Refresh();
}
}
// TODO: a better name
@ -288,7 +293,7 @@ namespace BizHawk.Client.EmuHawk
Global.Emulator.FrameAdvance(true);
GlobalWin.DisplayManager.NeedsToPaint = true;
TasView.ensureVisible(frame);
TasView.Refresh();
RefreshDialog();
}
else
{
@ -322,6 +327,26 @@ namespace BizHawk.Client.EmuHawk
Owner = Global.Config.TAStudioSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
private void CallAddMarkerPopUp()
{
InputPrompt i = new InputPrompt
{
Text = "Marker for frame " + Global.Emulator.Frame,
TextInputType = InputPrompt.InputType.Text
};
i.SetMessage("Enter a message");
var result = i.ShowHawkDialog();
if (result == DialogResult.OK)
{
_tas.Markers.Add(Global.Emulator.Frame, i.UserText);
MarkerControl.Refresh();
}
MarkerControl.Refresh();
}
private void UpdateChangesIndicator()
{
// TODO

View File

@ -286,8 +286,8 @@ namespace BizHawk.Client.EmuHawk
prompt.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString());
prompt.TextInputType = InputPrompt.InputType.Unsigned;
prompt.StartLocation = GetPromptPoint();
prompt.ShowDialog();
if (prompt.UserOk)
var result = prompt.ShowHawkDialog();
if (result == DialogResult.OK)
{
var max = int.Parse(prompt.UserText);
if (max > 0)

View File

@ -914,9 +914,9 @@ namespace BizHawk.Client.EmuHawk
WatchListView.SelectedIndices.Clear();
var prompt = new InputPrompt { Text = "Go to Address", StartLocation = GetPromptPoint() };
prompt.SetMessage("Enter a hexadecimal value");
prompt.ShowHawkDialog();
var result = prompt.ShowHawkDialog();
if (prompt.UserOk)
if (result == DialogResult.OK)
{
if (prompt.UserText.IsHex())
{