TAStudio cleanup

This commit is contained in:
adelikat 2017-05-24 10:49:35 -05:00
parent 50b5f4a1a9
commit b03e224c5e
18 changed files with 1021 additions and 597 deletions

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -13,32 +7,32 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class DefaultGreenzoneSettings : Form public partial class DefaultGreenzoneSettings : Form
{ {
TasStateManagerSettings settings; private TasStateManagerSettings _settings;
public DefaultGreenzoneSettings() public DefaultGreenzoneSettings()
{ {
InitializeComponent(); InitializeComponent();
settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings); _settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);
SettingsPropertyGrid.SelectedObject = settings; SettingsPropertyGrid.SelectedObject = _settings;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
Global.Config.DefaultTasProjSettings = settings; Global.Config.DefaultTasProjSettings = _settings;
this.Close(); Close();
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
{ {
this.Close(); Close();
} }
private void DefaultsButton_Click(object sender, EventArgs e) private void DefaultsButton_Click(object sender, EventArgs e)
{ {
settings = new TasStateManagerSettings(); _settings = new TasStateManagerSettings();
SettingsPropertyGrid.SelectedObject = settings; SettingsPropertyGrid.SelectedObject = _settings;
} }
} }
} }

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -16,10 +10,7 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
public int Frames public int Frames => NumFramesBox.ToRawInt() ?? 0;
{
get { return NumFramesBox.ToRawInt() ?? 0; }
}
private void FramesPrompt_Load(object sender, EventArgs e) private void FramesPrompt_Load(object sender, EventArgs e)
{ {

View File

@ -1,14 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -17,11 +10,12 @@ namespace BizHawk.Client.EmuHawk
{ {
public IStatable Statable { get; set; } public IStatable Statable { get; set; }
private readonly TasStateManagerSettings Settings; private readonly TasStateManagerSettings _settings;
private decimal _stateSizeMb; private decimal _stateSizeMb;
public StateHistorySettingsForm(TasStateManagerSettings settings) public StateHistorySettingsForm(TasStateManagerSettings settings)
{ {
Settings = settings; _settings = settings;
InitializeComponent(); InitializeComponent();
} }
@ -30,38 +24,38 @@ namespace BizHawk.Client.EmuHawk
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024; _stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
if (Environment.Is64BitProcess) // ? if (Environment.Is64BitProcess) // ?
{
MemCapacityNumeric.Maximum = 1024 * 8; MemCapacityNumeric.Maximum = 1024 * 8;
}
else else
{
MemCapacityNumeric.Maximum = 1024; MemCapacityNumeric.Maximum = 1024;
}
MemCapacityNumeric.Value = Settings.Capacitymb < MemCapacityNumeric.Maximum ? MemCapacityNumeric.Value = _settings.Capacitymb < MemCapacityNumeric.Maximum ?
Settings.Capacitymb : MemCapacityNumeric.Maximum; _settings.Capacitymb : MemCapacityNumeric.Maximum;
DiskCapacityNumeric.Value = Settings.DiskCapacitymb < MemCapacityNumeric.Maximum ? DiskCapacityNumeric.Value = _settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
Settings.DiskCapacitymb : MemCapacityNumeric.Maximum; _settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
SaveCapacityNumeric.Value = Settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ? SaveCapacityNumeric.Value = _settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
Settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum; _settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
StateGap.Value = Settings.StateGap; StateGap.Value = _settings.StateGap;
SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb"; SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb";
CapacityNumeric_ValueChanged(null, null); CapacityNumeric_ValueChanged(null, null);
SaveCapacityNumeric_ValueChanged(null, null); SaveCapacityNumeric_ValueChanged(null, null);
BranchStatesInTasproj.Checked = Settings.BranchStatesInTasproj; BranchStatesInTasproj.Checked = _settings.BranchStatesInTasproj;
EraseBranchStatesFirst.Checked = Settings.EraseBranchStatesFirst; EraseBranchStatesFirst.Checked = _settings.EraseBranchStatesFirst;
} }
private int MaxStatesInCapacity private int MaxStatesInCapacity => (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
{ + (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
get { return (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
+ (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
}
}
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
Settings.Capacitymb = (int)MemCapacityNumeric.Value; _settings.Capacitymb = (int)MemCapacityNumeric.Value;
Settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value; _settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value;
Settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value; _settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value;
Settings.StateGap = (int)StateGap.Value; _settings.StateGap = (int)StateGap.Value;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
@ -86,17 +80,19 @@ namespace BizHawk.Client.EmuHawk
private void BranchStatesInTasproj_CheckedChanged(object sender, EventArgs e) private void BranchStatesInTasproj_CheckedChanged(object sender, EventArgs e)
{ {
Settings.BranchStatesInTasproj = BranchStatesInTasproj.Checked; _settings.BranchStatesInTasproj = BranchStatesInTasproj.Checked;
} }
private void EraseBranchStatesFIrst_CheckedChanged(object sender, EventArgs e) private void EraseBranchStatesFIrst_CheckedChanged(object sender, EventArgs e)
{ {
Settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked; _settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked;
} }
private void StateGap_ValueChanged(object sender, EventArgs e) private void StateGap_ValueChanged(object sender, EventArgs e)
{ {
NumFramesLabel.Text = ((StateGap.Value == 0) ? "frame" : (1 << (int)StateGap.Value).ToString() + " frames"); NumFramesLabel.Text = StateGap.Value == 0
? "frame"
: $"{1 << (int)StateGap.Value} frames";
} }
} }
} }

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -13,36 +7,37 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class MovieHeaderEditor : Form public partial class MovieHeaderEditor : Form
{ {
private readonly IMovie Movie; private readonly IMovie _movie;
public MovieHeaderEditor(IMovie movie) public MovieHeaderEditor(IMovie movie)
{ {
Movie = movie; _movie = movie;
InitializeComponent(); InitializeComponent();
} }
private void MovieHeaderEditor_Load(object sender, EventArgs e) private void MovieHeaderEditor_Load(object sender, EventArgs e)
{ {
AuthorTextBox.Text = Movie.Author; AuthorTextBox.Text = _movie.Author;
EmulatorVersionTextBox.Text = Movie.EmulatorVersion; EmulatorVersionTextBox.Text = _movie.EmulatorVersion;
PlatformTextBox.Text = Movie.SystemID; PlatformTextBox.Text = _movie.SystemID;
CoreTextBox.Text = Movie.Core; CoreTextBox.Text = _movie.Core;
BoardNameTextBox.Text = Movie.BoardName; BoardNameTextBox.Text = _movie.BoardName;
GameNameTextBox.Text = Movie.GameName; GameNameTextBox.Text = _movie.GameName;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
Movie.Author = AuthorTextBox.Text; _movie.Author = AuthorTextBox.Text;
if (MakeDefaultCheckbox.Checked) if (MakeDefaultCheckbox.Checked)
{ {
Global.Config.DefaultAuthor = AuthorTextBox.Text; Global.Config.DefaultAuthor = AuthorTextBox.Text;
} }
Movie.EmulatorVersion = EmulatorVersionTextBox.Text; _movie.EmulatorVersion = EmulatorVersionTextBox.Text;
Movie.SystemID = PlatformTextBox.Text; _movie.SystemID = PlatformTextBox.Text;
Movie.Core = CoreTextBox.Text; _movie.Core = CoreTextBox.Text;
Movie.BoardName = BoardNameTextBox.Text; _movie.BoardName = BoardNameTextBox.Text;
Movie.GameName = GameNameTextBox.Text; _movie.GameName = GameNameTextBox.Text;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();

View File

@ -2,13 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -16,13 +13,13 @@ namespace BizHawk.Client.EmuHawk
public partial class MarkerControl : UserControl public partial class MarkerControl : UserControl
{ {
public TAStudio Tastudio { get; set; } public TAStudio Tastudio { get; set; }
public TasMovieMarkerList Markers { get { return Tastudio.CurrentTasMovie.Markers; } } public TasMovieMarkerList Markers => Tastudio.CurrentTasMovie.Markers;
public MarkerControl() public MarkerControl()
{ {
InitializeComponent(); InitializeComponent();
MarkerView.AllColumns.AddRange(new InputRoll.RollColumn[] MarkerView.AllColumns.AddRange(new[]
{ {
new InputRoll.RollColumn new InputRoll.RollColumn
{ {
@ -44,15 +41,14 @@ namespace BizHawk.Client.EmuHawk
private void MarkerControl_Load(object sender, EventArgs e) private void MarkerControl_Load(object sender, EventArgs e)
{ {
} }
public InputRoll MarkerInputRoll { get { return MarkerView; } } public InputRoll MarkerInputRoll => MarkerView;
private void MarkerView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) private void MarkerView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color)
{ {
var prev = Markers.PreviousOrCurrent(Tastudio.Emulator.Frame); var prev = Markers.PreviousOrCurrent(Tastudio.Emulator.Frame);
if (prev != null && index == Markers.IndexOf(prev)) if (prev != null && index == Markers.IndexOf(prev))
{ {
// feos: taseditor doesn't have it, so we're free to set arbitrary color scheme. and I prefer consistency // feos: taseditor doesn't have it, so we're free to set arbitrary color scheme. and I prefer consistency
@ -80,7 +76,9 @@ namespace BizHawk.Client.EmuHawk
} }
} }
else else
{
color = Color.White; color = Color.White;
}
} }
private void MarkerView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) private void MarkerView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY)
@ -165,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
if (editText) if (editText)
{ {
InputPrompt i = new InputPrompt var i = new InputPrompt
{ {
Text = "Marker for frame " + markerFrame, Text = "Marker for frame " + markerFrame,
TextInputType = InputPrompt.InputType.Text, TextInputType = InputPrompt.InputType.Text,
@ -191,6 +189,7 @@ namespace BizHawk.Client.EmuHawk
Markers.Add(new TasMovieMarker(markerFrame, "")); Markers.Add(new TasMovieMarker(markerFrame, ""));
UpdateValues(); UpdateValues();
} }
Tastudio.RefreshDialog(); Tastudio.RefreshDialog();
} }
@ -198,15 +197,15 @@ namespace BizHawk.Client.EmuHawk
{ {
var markerFrame = marker.Frame; var markerFrame = marker.Frame;
var point = default(Point); var point = default(Point);
InputPrompt i = new InputPrompt var i = new InputPrompt
{ {
Text = "Marker for frame " + markerFrame, Text = "Marker for frame " + markerFrame,
TextInputType = InputPrompt.InputType.Text, TextInputType = InputPrompt.InputType.Text,
Message = "Enter a message", Message = "Enter a message",
InitialValue = InitialValue =
Markers.IsMarker(markerFrame) ? Markers.IsMarker(markerFrame)
Markers.PreviousOrCurrent(markerFrame).Message : ? Markers.PreviousOrCurrent(markerFrame).Message
"" : ""
}; };
if (followCursor) if (followCursor)
@ -214,6 +213,7 @@ namespace BizHawk.Client.EmuHawk
point = Cursor.Position; point = Cursor.Position;
point.Offset(i.Width / -2, i.Height / -2); point.Offset(i.Width / -2, i.Height / -2);
} }
var result = i.ShowHawkDialog(position: point); var result = i.ShowHawkDialog(position: point);
if (result == DialogResult.OK) if (result == DialogResult.OK)
@ -225,10 +225,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues() public void UpdateValues()
{ {
if (MarkerView != null && if (MarkerView != null && Tastudio?.CurrentTasMovie != null && Markers != null)
Tastudio != null &&
Tastudio.CurrentTasMovie != null &&
Markers != null)
{ {
MarkerView.RowCount = Markers.Count; MarkerView.RowCount = Markers.Count;
} }
@ -270,8 +267,7 @@ namespace BizHawk.Client.EmuHawk
// A much more useful feature would be to easily jump to it. // A much more useful feature would be to easily jump to it.
private void MarkerView_MouseDoubleClick(object sender, MouseEventArgs e) private void MarkerView_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
if (MarkerView.CurrentCell != null && MarkerView.CurrentCell.RowIndex.HasValue && if (MarkerView.CurrentCell?.RowIndex != null && MarkerView.CurrentCell.RowIndex < MarkerView.RowCount)
MarkerView.CurrentCell.RowIndex < MarkerView.RowCount)
{ {
var marker = Markers[MarkerView.CurrentCell.RowIndex.Value]; var marker = Markers[MarkerView.CurrentCell.RowIndex.Value];
Tastudio.GoToFrame(marker.Frame); Tastudio.GoToFrame(marker.Frame);
@ -284,8 +280,10 @@ namespace BizHawk.Client.EmuHawk
{ {
var index = MarkerView.SelectedRows.First(); var index = MarkerView.SelectedRows.First();
var marker = Markers[index]; var marker = Markers[index];
return marker.Frame; return marker.Frame;
} }
return -1; return -1;
} }

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -13,17 +8,32 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class PatternsForm : Form public partial class PatternsForm : Form
{ {
private TAStudio tastudio; private readonly TAStudio _tastudio;
private readonly List<int> _counts = new List<int>();
private readonly List<string> _values = new List<string>();
private int _loopAt;
private bool _updating;
private string SelectedButton => ButtonBox.Text;
private bool IsBool => SelectedButton == "Default bool Auto-Fire" || Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(SelectedButton);
public PatternsForm(TAStudio owner) public PatternsForm(TAStudio owner)
{ {
InitializeComponent(); InitializeComponent();
tastudio = owner; _tastudio = owner;
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons) foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons)
{
ButtonBox.Items.Add(button); ButtonBox.Items.Add(button);
}
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.FloatControls) foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.FloatControls)
{
ButtonBox.Items.Add(button); ButtonBox.Items.Add(button);
}
ButtonBox.Items.Add("Default bool Auto-Fire"); ButtonBox.Items.Add("Default bool Auto-Fire");
ButtonBox.Items.Add("Default float Auto-Fire"); ButtonBox.Items.Add("Default float Auto-Fire");
} }
@ -33,18 +43,12 @@ namespace BizHawk.Client.EmuHawk
ButtonBox.SelectedIndex = 0; ButtonBox.SelectedIndex = 0;
} }
List<int> counts = new List<int>();
List<string> values = new List<string>();
int loopAt;
string selectedButton { get { return ButtonBox.Text; } }
bool isBool { get { return selectedButton == "Default bool Auto-Fire" || Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(selectedButton); } }
private void ButtonBox_SelectedIndexChanged(object sender, EventArgs e) private void ButtonBox_SelectedIndexChanged(object sender, EventArgs e)
{ {
GetPattern(); GetPattern();
UpdateDisplay(); UpdateDisplay();
if (isBool) if (IsBool)
{ {
OnOffBox.Visible = true; OnOffBox.Visible = true;
ValueNum.Visible = false; ValueNum.Visible = false;
@ -54,22 +58,28 @@ namespace BizHawk.Client.EmuHawk
ValueNum.Visible = true; ValueNum.Visible = true;
OnOffBox.Visible = false; OnOffBox.Visible = false;
} }
CountNum.Value = counts[0];
CountNum.Value = _counts[0];
} }
private void PatternList_SelectedIndexChanged(object sender, EventArgs e) private void PatternList_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (!_updating) if (!_updating)
{
UpdateDisplay(); UpdateDisplay();
}
} }
private void InsertButton_Click(object sender, EventArgs e) private void InsertButton_Click(object sender, EventArgs e)
{ {
counts.Insert(PatternList.SelectedIndex, 1); _counts.Insert(PatternList.SelectedIndex, 1);
string defaultStr = "false"; string defaultStr = "false";
if (!isBool) if (!IsBool)
{
defaultStr = "0"; defaultStr = "0";
values.Insert(PatternList.SelectedIndex, defaultStr); }
_values.Insert(PatternList.SelectedIndex, defaultStr);
UpdatePattern(); UpdatePattern();
UpdateDisplay(); UpdateDisplay();
@ -77,8 +87,8 @@ namespace BizHawk.Client.EmuHawk
private void DeleteButton_Click(object sender, EventArgs e) private void DeleteButton_Click(object sender, EventArgs e)
{ {
counts.RemoveAt(PatternList.SelectedIndex); _counts.RemoveAt(PatternList.SelectedIndex);
values.RemoveAt(PatternList.SelectedIndex); _values.RemoveAt(PatternList.SelectedIndex);
UpdatePattern(); UpdatePattern();
UpdateDisplay(); UpdateDisplay();
} }
@ -90,36 +100,48 @@ namespace BizHawk.Client.EmuHawk
private void ValueNum_ValueChanged(object sender, EventArgs e) private void ValueNum_ValueChanged(object sender, EventArgs e)
{ {
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= counts.Count) if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= _counts.Count)
{
return; return;
}
values[PatternList.SelectedIndex] = ValueNum.Value.ToString(); _values[PatternList.SelectedIndex] = ValueNum.Value.ToString();
UpdatePattern(); UpdatePattern();
UpdateDisplay(); UpdateDisplay();
} }
private void OnOffBox_CheckedChanged(object sender, EventArgs e) private void OnOffBox_CheckedChanged(object sender, EventArgs e)
{ {
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= counts.Count) if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= _counts.Count)
{
return; return;
}
values[PatternList.SelectedIndex] = OnOffBox.Checked.ToString(); _values[PatternList.SelectedIndex] = OnOffBox.Checked.ToString();
UpdatePattern(); UpdatePattern();
UpdateDisplay(); UpdateDisplay();
} }
private void CountNum_ValueChanged(object sender, EventArgs e) private void CountNum_ValueChanged(object sender, EventArgs e)
{ {
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex > counts.Count) if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex > _counts.Count)
{
return; return;
}
if (PatternList.SelectedIndex == counts.Count) if (PatternList.SelectedIndex == _counts.Count)
loopAt = (int)CountNum.Value; {
_loopAt = (int)CountNum.Value;
}
else else
counts[PatternList.SelectedIndex] = (int)CountNum.Value; {
_counts[PatternList.SelectedIndex] = (int)CountNum.Value;
}
UpdatePattern(); UpdatePattern();
UpdateDisplay(); UpdateDisplay();
} }
private bool _updating = false;
private void UpdateDisplay() private void UpdateDisplay()
{ {
_updating = true; _updating = true;
@ -127,52 +149,71 @@ namespace BizHawk.Client.EmuHawk
int oldIndex = PatternList.SelectedIndex; int oldIndex = PatternList.SelectedIndex;
if (oldIndex == -1) if (oldIndex == -1)
{
oldIndex = 0; oldIndex = 0;
}
PatternList.Items.Clear(); PatternList.Items.Clear();
int index = 0; int index = 0;
for (int i = 0; i < counts.Count; i++) for (int i = 0; i < _counts.Count; i++)
{ {
string str = index.ToString() + ": "; string str = index + ": ";
if (isBool) if (IsBool)
str += values[i][0] == 'T' ? "On" : "Off"; {
str += _values[i][0] == 'T' ? "On" : "Off";
}
else else
str += values[i].ToString(); {
str += _values[i];
}
PatternList.Items.Add(str + ("\t(x" + counts[i] + ")")); PatternList.Items.Add(str + ("\t(x" + _counts[i] + ")"));
index += counts[i]; index += _counts[i];
} }
PatternList.Items.Add("Loop to: " + loopAt);
PatternList.Items.Add("Loop to: " + _loopAt);
if (oldIndex >= PatternList.Items.Count) if (oldIndex >= PatternList.Items.Count)
{
oldIndex = PatternList.Items.Count - 1; oldIndex = PatternList.Items.Count - 1;
}
PatternList.SelectedIndex = oldIndex; PatternList.SelectedIndex = oldIndex;
if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < values.Count) if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < _values.Count)
{ {
index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton); index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton);
if (selectedButton == "Default bool Auto-Fire") if (SelectedButton == "Default bool Auto-Fire")
index = tastudio.BoolPatterns.Length + 1; {
index = _tastudio.BoolPatterns.Length + 1;
}
if (index != -1) if (index != -1)
{ {
LagBox.Checked = tastudio.BoolPatterns[index].SkipsLag; LagBox.Checked = _tastudio.BoolPatterns[index].SkipsLag;
OnOffBox.Checked = values[PatternList.SelectedIndex][0] == 'T'; OnOffBox.Checked = _values[PatternList.SelectedIndex][0] == 'T';
CountNum.Value = (decimal)counts[PatternList.SelectedIndex]; CountNum.Value = _counts[PatternList.SelectedIndex];
} }
else else
{ {
if (selectedButton == "Default float Auto-Fire") if (SelectedButton == "Default float Auto-Fire")
index = tastudio.FloatPatterns.Length + 1; {
index = _tastudio.FloatPatterns.Length + 1;
}
else else
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton); {
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
}
LagBox.Checked = tastudio.FloatPatterns[index].SkipsLag; LagBox.Checked = _tastudio.FloatPatterns[index].SkipsLag;
ValueNum.Value = Convert.ToDecimal(values[PatternList.SelectedIndex]); ValueNum.Value = Convert.ToDecimal(_values[PatternList.SelectedIndex]);
CountNum.Value = (decimal)counts[PatternList.SelectedIndex]; CountNum.Value = _counts[PatternList.SelectedIndex];
} }
} }
else if (PatternList.SelectedIndex == values.Count) else if (PatternList.SelectedIndex == _values.Count)
CountNum.Value = (decimal)loopAt; {
CountNum.Value = _loopAt;
}
PatternList.ResumeLayout(); PatternList.ResumeLayout();
_updating = false; _updating = false;
@ -180,91 +221,116 @@ namespace BizHawk.Client.EmuHawk
private void UpdatePattern() private void UpdatePattern()
{ {
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton); int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton);
if (selectedButton == "Default bool Auto-Fire") if (SelectedButton == "Default bool Auto-Fire")
index = tastudio.BoolPatterns.Length + 1; {
index = _tastudio.BoolPatterns.Length + 1;
}
if (index != -1) if (index != -1)
{ {
List<bool> p = new List<bool>(); List<bool> p = new List<bool>();
for (int i = 0; i < counts.Count; i++) for (int i = 0; i < _counts.Count; i++)
{ {
for (int c = 0; c < counts[i]; c++) for (int c = 0; c < _counts[i]; c++)
p.Add(Convert.ToBoolean(values[i])); {
p.Add(Convert.ToBoolean(_values[i]));
}
} }
tastudio.BoolPatterns[index] = new AutoPatternBool(p.ToArray(), LagBox.Checked, 0, loopAt);
_tastudio.BoolPatterns[index] = new AutoPatternBool(p.ToArray(), LagBox.Checked, 0, _loopAt);
} }
else else
{ {
if (selectedButton == "Default float Auto-Fire") if (SelectedButton == "Default float Auto-Fire")
index = tastudio.FloatPatterns.Length + 1;
else
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
List<float> p = new List<float>();
for (int i = 0; i < counts.Count; i++)
{ {
for (int c = 0; c < counts[i]; c++) index = _tastudio.FloatPatterns.Length + 1;
p.Add(Convert.ToSingle(values[i]));
} }
tastudio.FloatPatterns[index] = new AutoPatternFloat(p.ToArray(), LagBox.Checked, 0, loopAt); else
{
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
}
List<float> p = new List<float>();
for (int i = 0; i < _counts.Count; i++)
{
for (int c = 0; c < _counts[i]; c++)
{
p.Add(Convert.ToSingle(_values[i]));
}
}
_tastudio.FloatPatterns[index] = new AutoPatternFloat(p.ToArray(), LagBox.Checked, 0, _loopAt);
} }
tastudio.UpdateAutoFire(selectedButton, null); _tastudio.UpdateAutoFire(SelectedButton, null);
} }
private void GetPattern() private void GetPattern()
{ {
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton); int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton);
if (selectedButton == "Default bool Auto-Fire") if (SelectedButton == "Default bool Auto-Fire")
index = tastudio.BoolPatterns.Length + 1; {
index = _tastudio.BoolPatterns.Length + 1;
}
if (index != -1) if (index != -1)
{ {
bool[] p = tastudio.BoolPatterns[index].Pattern; bool[] p = _tastudio.BoolPatterns[index].Pattern;
bool lastValue = p[0]; bool lastValue = p[0];
counts.Clear(); _counts.Clear();
values.Clear(); _values.Clear();
counts.Add(1); _counts.Add(1);
values.Add(lastValue.ToString()); _values.Add(lastValue.ToString());
for (int i = 1; i < p.Length; i++) for (int i = 1; i < p.Length; i++)
{ {
if (p[i] == lastValue) if (p[i] == lastValue)
counts[counts.Count - 1]++; {
_counts[_counts.Count - 1]++;
}
else else
{ {
counts.Add(1); _counts.Add(1);
values.Add(p[i].ToString()); _values.Add(p[i].ToString());
lastValue = p[i]; lastValue = p[i];
} }
} }
loopAt = tastudio.BoolPatterns[index].Loop;
_loopAt = _tastudio.BoolPatterns[index].Loop;
} }
else else
{ {
if (selectedButton == "Default float Auto-Fire") if (SelectedButton == "Default float Auto-Fire")
index = tastudio.FloatPatterns.Length + 1; {
index = _tastudio.FloatPatterns.Length + 1;
}
else else
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton); {
float[] p = tastudio.FloatPatterns[index].Pattern; index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
}
float[] p = _tastudio.FloatPatterns[index].Pattern;
float lastValue = p[0]; float lastValue = p[0];
counts.Clear(); _counts.Clear();
values.Clear(); _values.Clear();
counts.Add(1); _counts.Add(1);
values.Add(lastValue.ToString()); _values.Add(lastValue.ToString());
for (int i = 1; i < p.Length; i++) for (int i = 1; i < p.Length; i++)
{ {
if (p[i] == lastValue) if (p[i] == lastValue)
counts[counts.Count - 1]++; {
_counts[_counts.Count - 1]++;
}
else else
{ {
counts.Add(1); _counts.Add(1);
values.Add(p[i].ToString()); _values.Add(p[i].ToString());
lastValue = p[i]; lastValue = p[i];
} }
} }
loopAt = tastudio.FloatPatterns[index].Loop;
_loopAt = _tastudio.FloatPatterns[index].Loop;
} }
} }
} }
} }

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -18,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
public TAStudio Tastudio { get; set; } public TAStudio Tastudio { get; set; }
[Browsable(true)] [Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool TurboSeek public bool TurboSeek
{ {
get get
@ -33,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
} }
[Browsable(true)] [Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool AutoRestore public bool AutoRestore
{ {
get get
@ -48,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
} }
[Browsable(true)] [Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool FollowCursor public bool FollowCursor
{ {
get get
@ -63,7 +58,7 @@ namespace BizHawk.Client.EmuHawk
} }
[Browsable(true)] [Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool RecordingMode public bool RecordingMode
{ {
get get
@ -83,6 +78,7 @@ namespace BizHawk.Client.EmuHawk
{ {
Global.MovieSession.Movie.SwitchToPlay(); Global.MovieSession.Movie.SwitchToPlay();
} }
GlobalWin.MainForm.SetMainformMovieInfo(); GlobalWin.MainForm.SetMainformMovieInfo();
} }
} }
@ -191,7 +187,5 @@ namespace BizHawk.Client.EmuHawk
{ {
GlobalWin.MainForm.HoldFrameAdvance = false; GlobalWin.MainForm.HoldFrameAdvance = false;
} }
} }
} }

View File

@ -1,32 +1,30 @@
// We pretend it's a tooltip kind of thing, so show only the actual contents using System.Drawing;
// and avoid stealing forcus, while still being topmost
// http://stackoverflow.com/a/25219399/2792852
// This is not an actual tooltip, because they can't reliably fade in and out with trasparency
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.Common;
// We pretend it's a tooltip kind of thing, so show only the actual contents
// and avoid stealing forcus, while still being topmost
// http://stackoverflow.com/a/25219399/2792852
// This is not an actual tooltip, because they can't reliably fade in and out with trasparency
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class ScreenshotForm : Form public partial class ScreenshotForm : Form
{ {
private Timer _showTimer = new Timer(); // but still appear topmost
private Timer _hideTimer = new Timer(); private const int WS_EX_TOPMOST = 0x00000008;
private int _widthCap = 320;
private int _heightCap = 240; private const int WidthCap = 320;
private int _interval = 40; private const int HeightCap = 240;
private double _alphaStep = 0.125; private const int Interval = 40;
public TasBranch Branch { get; set; } private const double AlphaStep = 0.125;
public FontStyle FontStyle;
public int FontSize; private readonly Timer _showTimer = new Timer();
public int DrawingHeight; private readonly Timer _hideTimer = new Timer();
private TasBranch _branch;
private int _drawingHeight;
new public Font Font; new public Font Font;
new public int Padding; new public int Padding;
new public string Text; new public string Text;
@ -35,67 +33,73 @@ namespace BizHawk.Client.EmuHawk
{ {
InitializeComponent(); InitializeComponent();
Width = _widthCap; Width = WidthCap;
Height = _heightCap; Height = HeightCap;
FontSize = 10; var fontSize = 10;
FontStyle = FontStyle.Regular; var fontStyle = FontStyle.Regular;
Font = new Font(FontFamily.GenericMonospace, FontSize, FontStyle); Font = new Font(FontFamily.GenericMonospace, fontSize, fontStyle);
DrawingHeight = 0; _drawingHeight = 0;
Padding = 0; Padding = 0;
Opacity = 0; Opacity = 0;
_showTimer.Interval = _interval; _showTimer.Interval = Interval;
_showTimer.Tick += new EventHandler((sender, e) => _showTimer.Tick += (sender, e) =>
{ {
if ((Opacity += _alphaStep) >= 1) if ((Opacity += AlphaStep) >= 1)
{
_showTimer.Stop(); _showTimer.Stop();
}); }
};
_hideTimer.Interval = _interval; _hideTimer.Interval = Interval;
_hideTimer.Tick += new EventHandler((sender, e) => _hideTimer.Tick += (sender, e) =>
{ {
if ((Opacity -= _alphaStep) <= 0) if ((Opacity -= AlphaStep) <= 0)
{ {
_hideTimer.Stop(); _hideTimer.Stop();
Hide(); Hide();
} }
}); };
} }
public void UpdateValues(TasBranch branch, Point location , int width, int height, int padding) public void UpdateValues(TasBranch branch, Point location , int width, int height, int padding)
{ {
Branch = branch; _branch = branch;
Width = width; Width = width;
Padding = padding; Padding = padding;
DrawingHeight = height; _drawingHeight = height;
Text = Branch.UserText; Text = _branch.UserText;
Location = location; Location = location;
// Set the screenshot to "1x" resolution of the core // Set the screenshot to "1x" resolution of the core
// cores like n64 and psx are going to still have sizes too big for the control, so cap them // cores like n64 and psx are going to still have sizes too big for the control, so cap them
if (Width > _widthCap) if (Width > WidthCap)
{ {
double ratio = (double)_widthCap / (double)Width; double ratio = WidthCap / (double)Width;
Width = _widthCap; Width = WidthCap;
DrawingHeight = (int)((double)(DrawingHeight) * ratio); _drawingHeight = (int)((double)(_drawingHeight) * ratio);
} }
if (Padding > 0) if (Padding > 0)
{
Padding += 2; Padding += 2;
Height = DrawingHeight + Padding; }
Height = _drawingHeight + Padding;
Refresh(); Refresh();
} }
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)
{ {
Branch.OSDFrameBuffer.DiscardAlpha(); _branch.OSDFrameBuffer.DiscardAlpha();
var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap(); var bitmap = _branch.OSDFrameBuffer.ToSysdrawingBitmap();
e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, DrawingHeight)); e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, _drawingHeight));
if (Padding > 0) if (Padding > 0)
{ {
e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, DrawingHeight), new Size(Width - 1, Padding - 1))); e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, _drawingHeight), new Size(Width - 1, Padding - 1)));
e.Graphics.DrawString(Text, Font, Brushes.Black, new Rectangle(2, DrawingHeight, Width - 2, Height)); e.Graphics.DrawString(Text, Font, Brushes.Black, new Rectangle(2, _drawingHeight, Width - 2, Height));
} }
base.OnPaint(e); base.OnPaint(e);
} }
@ -115,13 +119,8 @@ namespace BizHawk.Client.EmuHawk
} }
// avoid stealing focus // avoid stealing focus
protected override bool ShowWithoutActivation protected override bool ShowWithoutActivation => true;
{
get { return true; }
}
// but still appear topmost
private const int WS_EX_TOPMOST = 0x00000008;
protected override CreateParams CreateParams protected override CreateParams CreateParams
{ {
get get

View File

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -16,40 +14,22 @@ namespace BizHawk.Client.EmuHawk
private Color? GetColorOverride(int index, InputRoll.RollColumn column) private Color? GetColorOverride(int index, InputRoll.RollColumn column)
{ {
if (QueryItemBgColorCallback != null) return QueryItemBgColorCallback?.Invoke(index, column.Name);
{
return QueryItemBgColorCallback(index, column.Name);
}
return null;
} }
private string GetTextOverride(int index, InputRoll.RollColumn column) private string GetTextOverride(int index, InputRoll.RollColumn column)
{ {
if (QueryItemTextCallback != null) return QueryItemTextCallback?.Invoke(index, column.Name);
{
return QueryItemTextCallback(index, column.Name);
}
return null;
} }
private Bitmap GetIconOverride(int index, InputRoll.RollColumn column) private Bitmap GetIconOverride(int index, InputRoll.RollColumn column)
{ {
if (QueryItemIconCallback != null) return QueryItemIconCallback?.Invoke(index, column.Name);
{
return QueryItemIconCallback(index, column.Name);
}
return null;
} }
private void GreenzoneInvalidated(int index) private void GreenzoneInvalidated(int index)
{ {
if (GreenzoneInvalidatedCallback != null) GreenzoneInvalidatedCallback?.Invoke(index);
{
GreenzoneInvalidatedCallback(index);
}
} }
} }
} }

View File

@ -348,14 +348,14 @@ namespace BizHawk.Client.EmuHawk
this.saveSelectionToMacroToolStripMenuItem.Name = "saveSelectionToMacroToolStripMenuItem"; this.saveSelectionToMacroToolStripMenuItem.Name = "saveSelectionToMacroToolStripMenuItem";
this.saveSelectionToMacroToolStripMenuItem.Size = new System.Drawing.Size(201, 22); this.saveSelectionToMacroToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.saveSelectionToMacroToolStripMenuItem.Text = "Save Selection to Macro"; this.saveSelectionToMacroToolStripMenuItem.Text = "Save Selection to Macro";
this.saveSelectionToMacroToolStripMenuItem.Click += new System.EventHandler(this.saveSelectionToMacroToolStripMenuItem_Click); this.saveSelectionToMacroToolStripMenuItem.Click += new System.EventHandler(this.SaveSelectionToMacroMenuItem_Click);
// //
// placeMacroAtSelectionToolStripMenuItem // placeMacroAtSelectionToolStripMenuItem
// //
this.placeMacroAtSelectionToolStripMenuItem.Name = "placeMacroAtSelectionToolStripMenuItem"; this.placeMacroAtSelectionToolStripMenuItem.Name = "placeMacroAtSelectionToolStripMenuItem";
this.placeMacroAtSelectionToolStripMenuItem.Size = new System.Drawing.Size(201, 22); this.placeMacroAtSelectionToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.placeMacroAtSelectionToolStripMenuItem.Text = "Place Macro at Selection"; this.placeMacroAtSelectionToolStripMenuItem.Text = "Place Macro at Selection";
this.placeMacroAtSelectionToolStripMenuItem.Click += new System.EventHandler(this.placeMacroAtSelectionToolStripMenuItem_Click); this.placeMacroAtSelectionToolStripMenuItem.Click += new System.EventHandler(this.PlaceMacroAtSelectionMenuItem_Click);
// //
// recentMacrosToolStripMenuItem // recentMacrosToolStripMenuItem
// //
@ -365,7 +365,7 @@ namespace BizHawk.Client.EmuHawk
this.recentMacrosToolStripMenuItem.Name = "recentMacrosToolStripMenuItem"; this.recentMacrosToolStripMenuItem.Name = "recentMacrosToolStripMenuItem";
this.recentMacrosToolStripMenuItem.Size = new System.Drawing.Size(201, 22); this.recentMacrosToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.recentMacrosToolStripMenuItem.Text = "Recent Macros"; this.recentMacrosToolStripMenuItem.Text = "Recent Macros";
this.recentMacrosToolStripMenuItem.DropDownOpened += new System.EventHandler(this.recentMacrosToolStripMenuItem_DropDownOpened); this.recentMacrosToolStripMenuItem.DropDownOpened += new System.EventHandler(this.RecentMacrosMenuItem_DropDownOpened);
// //
// toolStripSeparator22 // toolStripSeparator22
// //
@ -453,7 +453,7 @@ namespace BizHawk.Client.EmuHawk
this.showUndoHistoryToolStripMenuItem.Name = "showUndoHistoryToolStripMenuItem"; this.showUndoHistoryToolStripMenuItem.Name = "showUndoHistoryToolStripMenuItem";
this.showUndoHistoryToolStripMenuItem.Size = new System.Drawing.Size(291, 22); this.showUndoHistoryToolStripMenuItem.Size = new System.Drawing.Size(291, 22);
this.showUndoHistoryToolStripMenuItem.Text = "Show Undo History"; this.showUndoHistoryToolStripMenuItem.Text = "Show Undo History";
this.showUndoHistoryToolStripMenuItem.Click += new System.EventHandler(this.showUndoHistoryToolStripMenuItem_Click); this.showUndoHistoryToolStripMenuItem.Click += new System.EventHandler(this.ShowUndoHistoryMenuItem_Click);
// //
// SelectionUndoMenuItem // SelectionUndoMenuItem
// //
@ -753,7 +753,7 @@ namespace BizHawk.Client.EmuHawk
this.applyPatternToPaintedInputToolStripMenuItem.Name = "applyPatternToPaintedInputToolStripMenuItem"; this.applyPatternToPaintedInputToolStripMenuItem.Name = "applyPatternToPaintedInputToolStripMenuItem";
this.applyPatternToPaintedInputToolStripMenuItem.Size = new System.Drawing.Size(255, 22); this.applyPatternToPaintedInputToolStripMenuItem.Size = new System.Drawing.Size(255, 22);
this.applyPatternToPaintedInputToolStripMenuItem.Text = "Apply Pattern to painted input"; this.applyPatternToPaintedInputToolStripMenuItem.Text = "Apply Pattern to painted input";
this.applyPatternToPaintedInputToolStripMenuItem.CheckedChanged += new System.EventHandler(this.applyPatternToPaintedInputToolStripMenuItem_CheckedChanged); this.applyPatternToPaintedInputToolStripMenuItem.CheckedChanged += new System.EventHandler(this.ApplyPatternToPaintedInputMenuItem_CheckedChanged);
// //
// onlyOnAutoFireColumnsToolStripMenuItem // onlyOnAutoFireColumnsToolStripMenuItem
// //
@ -872,7 +872,7 @@ namespace BizHawk.Client.EmuHawk
this.autoHoldToolStripMenuItem.Name = "autoHoldToolStripMenuItem"; this.autoHoldToolStripMenuItem.Name = "autoHoldToolStripMenuItem";
this.autoHoldToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.autoHoldToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.autoHoldToolStripMenuItem.Text = "Auto-Hold"; this.autoHoldToolStripMenuItem.Text = "Auto-Hold";
this.autoHoldToolStripMenuItem.CheckedChanged += new System.EventHandler(this.autoHoldToolStripMenuItem_CheckedChanged); this.autoHoldToolStripMenuItem.CheckedChanged += new System.EventHandler(this.AutoHoldMenuItem_CheckedChanged);
// //
// autoFireToolStripMenuItem // autoFireToolStripMenuItem
// //
@ -880,7 +880,7 @@ namespace BizHawk.Client.EmuHawk
this.autoFireToolStripMenuItem.Name = "autoFireToolStripMenuItem"; this.autoFireToolStripMenuItem.Name = "autoFireToolStripMenuItem";
this.autoFireToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.autoFireToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.autoFireToolStripMenuItem.Text = "Auto-Fire"; this.autoFireToolStripMenuItem.Text = "Auto-Fire";
this.autoFireToolStripMenuItem.CheckedChanged += new System.EventHandler(this.autoFireToolStripMenuItem_CheckedChanged); this.autoFireToolStripMenuItem.CheckedChanged += new System.EventHandler(this.AutoFireMenuItem_CheckedChanged);
// //
// customPatternToolStripMenuItem // customPatternToolStripMenuItem
// //
@ -888,7 +888,7 @@ namespace BizHawk.Client.EmuHawk
this.customPatternToolStripMenuItem.Name = "customPatternToolStripMenuItem"; this.customPatternToolStripMenuItem.Name = "customPatternToolStripMenuItem";
this.customPatternToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.customPatternToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.customPatternToolStripMenuItem.Text = "Custom Pattern"; this.customPatternToolStripMenuItem.Text = "Custom Pattern";
this.customPatternToolStripMenuItem.CheckedChanged += new System.EventHandler(this.customPatternToolStripMenuItem_CheckedChanged); this.customPatternToolStripMenuItem.CheckedChanged += new System.EventHandler(this.CustomPatternMenuItem_CheckedChanged);
// //
// setpToolStripMenuItem // setpToolStripMenuItem
// //
@ -900,7 +900,7 @@ namespace BizHawk.Client.EmuHawk
this.setCustomsToolStripMenuItem.Name = "setCustomsToolStripMenuItem"; this.setCustomsToolStripMenuItem.Name = "setCustomsToolStripMenuItem";
this.setCustomsToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.setCustomsToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.setCustomsToolStripMenuItem.Text = "Set Customs..."; this.setCustomsToolStripMenuItem.Text = "Set Customs...";
this.setCustomsToolStripMenuItem.Click += new System.EventHandler(this.setCustomsToolStripMenuItem_Click); this.setCustomsToolStripMenuItem.Click += new System.EventHandler(this.SetCustomsMenuItem_Click);
// //
// MetaSubMenu // MetaSubMenu
// //
@ -1039,7 +1039,7 @@ namespace BizHawk.Client.EmuHawk
this.hideWasLagFramesToolStripMenuItem.Name = "hideWasLagFramesToolStripMenuItem"; this.hideWasLagFramesToolStripMenuItem.Name = "hideWasLagFramesToolStripMenuItem";
this.hideWasLagFramesToolStripMenuItem.Size = new System.Drawing.Size(185, 22); this.hideWasLagFramesToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
this.hideWasLagFramesToolStripMenuItem.Text = "Hide WasLag Frames"; this.hideWasLagFramesToolStripMenuItem.Text = "Hide WasLag Frames";
this.hideWasLagFramesToolStripMenuItem.Click += new System.EventHandler(this.hideWasLagFramesToolStripMenuItem_Click); this.hideWasLagFramesToolStripMenuItem.Click += new System.EventHandler(this.HideWasLagFramesMenuItem_Click);
// //
// iconsToolStripMenuItem // iconsToolStripMenuItem
// //
@ -1051,7 +1051,7 @@ namespace BizHawk.Client.EmuHawk
this.iconsToolStripMenuItem.Name = "iconsToolStripMenuItem"; this.iconsToolStripMenuItem.Name = "iconsToolStripMenuItem";
this.iconsToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.iconsToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.iconsToolStripMenuItem.Text = "Icons"; this.iconsToolStripMenuItem.Text = "Icons";
this.iconsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.iconsToolStripMenuItem_DropDownOpened); this.iconsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.IconsMenuItem_DropDownOpened);
// //
// DenoteStatesWithIconsToolStripMenuItem // DenoteStatesWithIconsToolStripMenuItem
// //
@ -1102,7 +1102,7 @@ namespace BizHawk.Client.EmuHawk
this.followCursorToolStripMenuItem.Name = "followCursorToolStripMenuItem"; this.followCursorToolStripMenuItem.Name = "followCursorToolStripMenuItem";
this.followCursorToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.followCursorToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.followCursorToolStripMenuItem.Text = "Follow Cursor"; this.followCursorToolStripMenuItem.Text = "Follow Cursor";
this.followCursorToolStripMenuItem.DropDownOpened += new System.EventHandler(this.followCursorToolStripMenuItem_DropDownOpened); this.followCursorToolStripMenuItem.DropDownOpened += new System.EventHandler(this.FollowCursorMenuItem_DropDownOpened);
// //
// alwaysScrollToolStripMenuItem // alwaysScrollToolStripMenuItem
// //
@ -1110,7 +1110,7 @@ namespace BizHawk.Client.EmuHawk
this.alwaysScrollToolStripMenuItem.Name = "alwaysScrollToolStripMenuItem"; this.alwaysScrollToolStripMenuItem.Name = "alwaysScrollToolStripMenuItem";
this.alwaysScrollToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.alwaysScrollToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.alwaysScrollToolStripMenuItem.Text = "Always Scroll"; this.alwaysScrollToolStripMenuItem.Text = "Always Scroll";
this.alwaysScrollToolStripMenuItem.Click += new System.EventHandler(this.alwaysScrollToolStripMenuItem_Click); this.alwaysScrollToolStripMenuItem.Click += new System.EventHandler(this.AlwaysScrollMenuItem_Click);
// //
// toolStripSeparator24 // toolStripSeparator24
// //
@ -1125,7 +1125,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToViewToolStripMenuItem.Name = "scrollToViewToolStripMenuItem"; this.scrollToViewToolStripMenuItem.Name = "scrollToViewToolStripMenuItem";
this.scrollToViewToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.scrollToViewToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.scrollToViewToolStripMenuItem.Text = "Scroll to View"; this.scrollToViewToolStripMenuItem.Text = "Scroll to View";
this.scrollToViewToolStripMenuItem.Click += new System.EventHandler(this.scrollToViewToolStripMenuItem_Click); this.scrollToViewToolStripMenuItem.Click += new System.EventHandler(this.ScrollToViewMenuItem_Click);
// //
// scrollToTopToolStripMenuItem // scrollToTopToolStripMenuItem
// //
@ -1133,7 +1133,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToTopToolStripMenuItem.Name = "scrollToTopToolStripMenuItem"; this.scrollToTopToolStripMenuItem.Name = "scrollToTopToolStripMenuItem";
this.scrollToTopToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.scrollToTopToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.scrollToTopToolStripMenuItem.Text = "Scroll to Top"; this.scrollToTopToolStripMenuItem.Text = "Scroll to Top";
this.scrollToTopToolStripMenuItem.Click += new System.EventHandler(this.scrollToTopToolStripMenuItem_Click); this.scrollToTopToolStripMenuItem.Click += new System.EventHandler(this.ScrollToTopMenuItem_Click);
// //
// scrollToBottomToolStripMenuItem // scrollToBottomToolStripMenuItem
// //
@ -1141,7 +1141,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToBottomToolStripMenuItem.Name = "scrollToBottomToolStripMenuItem"; this.scrollToBottomToolStripMenuItem.Name = "scrollToBottomToolStripMenuItem";
this.scrollToBottomToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.scrollToBottomToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.scrollToBottomToolStripMenuItem.Text = "Scroll to Bottom"; this.scrollToBottomToolStripMenuItem.Text = "Scroll to Bottom";
this.scrollToBottomToolStripMenuItem.Click += new System.EventHandler(this.scrollToBottomToolStripMenuItem_Click); this.scrollToBottomToolStripMenuItem.Click += new System.EventHandler(this.ScrollToBottomMenuItem_Click);
// //
// scrollToCenterToolStripMenuItem // scrollToCenterToolStripMenuItem
// //
@ -1149,7 +1149,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToCenterToolStripMenuItem.Name = "scrollToCenterToolStripMenuItem"; this.scrollToCenterToolStripMenuItem.Name = "scrollToCenterToolStripMenuItem";
this.scrollToCenterToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.scrollToCenterToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.scrollToCenterToolStripMenuItem.Text = "Scroll to Center"; this.scrollToCenterToolStripMenuItem.Text = "Scroll to Center";
this.scrollToCenterToolStripMenuItem.Click += new System.EventHandler(this.scrollToCenterToolStripMenuItem_Click); this.scrollToCenterToolStripMenuItem.Click += new System.EventHandler(this.ScrollToCenterMenuItem_Click);
// //
// toolStripSeparator25 // toolStripSeparator25
// //
@ -1161,7 +1161,7 @@ namespace BizHawk.Client.EmuHawk
this.wheelScrollSpeedToolStripMenuItem.Name = "wheelScrollSpeedToolStripMenuItem"; this.wheelScrollSpeedToolStripMenuItem.Name = "wheelScrollSpeedToolStripMenuItem";
this.wheelScrollSpeedToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.wheelScrollSpeedToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.wheelScrollSpeedToolStripMenuItem.Text = "Wheel Scroll Speed..."; this.wheelScrollSpeedToolStripMenuItem.Text = "Wheel Scroll Speed...";
this.wheelScrollSpeedToolStripMenuItem.Click += new System.EventHandler(this.wheelScrollSpeedToolStripMenuItem_Click); this.wheelScrollSpeedToolStripMenuItem.Click += new System.EventHandler(this.WheelScrollSpeedMenuItem_Click);
// //
// ColumnsSubMenu // ColumnsSubMenu
// //

View File

@ -1,53 +1,59 @@
using System; namespace BizHawk.Client.EmuHawk
using System.Collections.Generic;
namespace BizHawk.Client.EmuHawk
{ {
public partial class TAStudio : IControlMainform public partial class TAStudio : IControlMainform
{ {
private bool _suppressAskSave = false; private bool _suppressAskSave;
public bool NamedStatePending = false; public bool NamedStatePending { get; set; }
public bool WantsToControlSavestates { get { return !NamedStatePending; } } public bool WantsToControlSavestates => !NamedStatePending;
public void SaveState() public void SaveState()
{ {
BookMarkControl.UpdateBranchExternal(); BookMarkControl.UpdateBranchExternal();
} }
public void LoadState() public void LoadState()
{ {
BookMarkControl.LoadBranchExternal(); BookMarkControl.LoadBranchExternal();
} }
public void SaveStateAs() public void SaveStateAs()
{ {
// dummy // dummy
} }
public void LoadStateAs() public void LoadStateAs()
{ {
// dummy // dummy
} }
public void SaveQuickSave(int slot) public void SaveQuickSave(int slot)
{ {
BookMarkControl.UpdateBranchExternal(slot); BookMarkControl.UpdateBranchExternal(slot);
} }
public void LoadQuickSave(int slot) public void LoadQuickSave(int slot)
{ {
BookMarkControl.LoadBranchExternal(slot); BookMarkControl.LoadBranchExternal(slot);
} }
public void SelectSlot(int slot) public void SelectSlot(int slot)
{ {
BookMarkControl.SelectBranchExternal(slot); BookMarkControl.SelectBranchExternal(slot);
} }
public void PreviousSlot() public void PreviousSlot()
{ {
BookMarkControl.SelectBranchExternal(false); BookMarkControl.SelectBranchExternal(false);
} }
public void NextSlot() public void NextSlot()
{ {
BookMarkControl.SelectBranchExternal(true); BookMarkControl.SelectBranchExternal(true);
} }
public bool WantsToControlReadOnly { get { return true; } } public bool WantsToControlReadOnly => true;
public void ToggleReadOnly() public void ToggleReadOnly()
{ {
@ -65,13 +71,13 @@ namespace BizHawk.Client.EmuHawk
public void StopMovie(bool supressSave) public void StopMovie(bool supressSave)
{ {
this.Focus(); Focus();
_suppressAskSave = supressSave; _suppressAskSave = supressSave;
NewTasMenuItem_Click(null, null); NewTasMenuItem_Click(null, null);
_suppressAskSave = false; _suppressAskSave = false;
} }
public bool WantsToControlRewind { get { return true; } } public bool WantsToControlRewind => true;
public void CaptureRewind() public void CaptureRewind()
{ {
@ -84,6 +90,7 @@ namespace BizHawk.Client.EmuHawk
if (Mainform.IsSeeking && !Mainform.EmulatorPaused) if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
{ {
Mainform.PauseOnFrame--; Mainform.PauseOnFrame--;
// that's a weird condition here, but for whatever reason it works best // that's a weird condition here, but for whatever reason it works best
if (Emulator.Frame >= Mainform.PauseOnFrame) if (Emulator.Frame >= Mainform.PauseOnFrame)
{ {
@ -92,17 +99,19 @@ namespace BizHawk.Client.EmuHawk
StopSeeking(); StopSeeking();
GoToPreviousFrame(); GoToPreviousFrame();
} }
RefreshDialog(); RefreshDialog();
} }
else else
{ {
StopSeeking(); //late breaking memo: dont know whether this is needed StopSeeking(); // late breaking memo: dont know whether this is needed
GoToPreviousFrame(); GoToPreviousFrame();
} }
return true; return true;
} }
public bool WantsToControlRestartMovie { get; private set; } public bool WantsToControlRestartMovie { get; }
public void RestartMovie() public void RestartMovie()
{ {

View File

@ -1,7 +1,6 @@
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using System.Collections.Generic;
using System;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -23,33 +22,46 @@ namespace BizHawk.Client.EmuHawk
private bool _hackyDontUpdate; private bool _hackyDontUpdate;
private bool _initializing; // If true, will bypass restart logic, this is necessary since loading projects causes a movie to load which causes a rom to reload causing dialogs to restart private bool _initializing; // If true, will bypass restart logic, this is necessary since loading projects causes a movie to load which causes a rom to reload causing dialogs to restart
public bool UpdateBefore { get { return false; } } public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { } public void NewUpdate(ToolFormUpdateType type) { }
private int lastRefresh = 0; private int _lastRefresh;
public void UpdateValues() public void UpdateValues()
{ {
if (!IsHandleCreated || IsDisposed || CurrentTasMovie == null) if (!IsHandleCreated || IsDisposed || CurrentTasMovie == null)
{
return; return;
}
if (_hackyDontUpdate) if (_hackyDontUpdate)
{
return; return;
}
if (_exiting) if (_exiting)
{
return; return;
}
bool refreshNeeded = false; bool refreshNeeded = false;
if (AutoadjustInputMenuItem.Checked) if (AutoadjustInputMenuItem.Checked)
{
refreshNeeded = AutoAdjustInput(); refreshNeeded = AutoAdjustInput();
}
if (TasView.RowCount != CurrentTasMovie.InputLogLength + 1) if (TasView.RowCount != CurrentTasMovie.InputLogLength + 1)
{
TasView.RowCount = CurrentTasMovie.InputLogLength + 1; TasView.RowCount = CurrentTasMovie.InputLogLength + 1;
}
MaybeFollowCursor(); MaybeFollowCursor();
if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(lastRefresh)) if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(_lastRefresh))
{
refreshNeeded = true; refreshNeeded = true;
}
RefreshDialog(refreshNeeded); RefreshDialog(refreshNeeded);
} }

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -29,12 +29,18 @@ namespace BizHawk.Client.EmuHawk
private int _floatEditRow = -1; private int _floatEditRow = -1;
private string _floatTypedValue; private string _floatTypedValue;
private int _floatEditYPos = -1; private int _floatEditYPos = -1;
private int floatEditRow { set { private int floatEditRow
_floatEditRow = value; {
TasView.suspendHotkeys = FloatEditingMode; set
} } {
public bool FloatEditingMode { get { return _floatEditRow != -1; } } _floatEditRow = value;
private List<int> _extraFloatRows = new List<int>(); TasView.suspendHotkeys = FloatEditingMode;
}
}
public bool FloatEditingMode => _floatEditRow != -1;
private readonly List<int> _extraFloatRows = new List<int>();
// Right-click dragging // Right-click dragging
private string[] _rightClickInput = null; private string[] _rightClickInput = null;
@ -43,14 +49,17 @@ namespace BizHawk.Client.EmuHawk
private int _rightClickLastFrame = -1; private int _rightClickLastFrame = -1;
private bool _rightClickShift, _rightClickControl, _rightClickAlt; private bool _rightClickShift, _rightClickControl, _rightClickAlt;
private bool _leftButtonHeld = false; private bool _leftButtonHeld = false;
private bool mouseButtonHeld { get { return _rightClickFrame != -1 || _leftButtonHeld; } }
private bool MouseButtonHeld => _rightClickFrame != -1 || _leftButtonHeld;
private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up
private bool? _autoRestorePaused = null; private bool? _autoRestorePaused = null;
private int? _seekStartFrame = null; private int? _seekStartFrame = null;
private bool _shouldUnpauseFromRewind = false; private bool _shouldUnpauseFromRewind = false;
private Emulation.Common.ControllerDefinition controllerType { get {
return Global.MovieSession.MovieControllerAdapter.Definition; } } private ControllerDefinition ControllerType => Global.MovieSession.MovieControllerAdapter.Definition;
public bool WasRecording = false;
public bool WasRecording;
public AutoPatternBool[] BoolPatterns; public AutoPatternBool[] BoolPatterns;
public AutoPatternFloat[] FloatPatterns; public AutoPatternFloat[] FloatPatterns;
@ -69,10 +78,14 @@ namespace BizHawk.Client.EmuHawk
private void StartSeeking(int? frame) private void StartSeeking(int? frame)
{ {
if (!frame.HasValue) if (!frame.HasValue)
{
return; return;
}
if (Mainform.PauseOnFrame != null) if (Mainform.PauseOnFrame != null)
{
StopSeeking(true); // don't restore rec mode just yet, as with heavy editing checkbox updating causes lag StopSeeking(true); // don't restore rec mode just yet, as with heavy editing checkbox updating causes lag
}
_seekStartFrame = Emulator.Frame; _seekStartFrame = Emulator.Frame;
Mainform.PauseOnFrame = frame.Value; Mainform.PauseOnFrame = frame.Value;
@ -83,7 +96,9 @@ namespace BizHawk.Client.EmuHawk
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows) if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows)
{
_seekBackgroundWorker.RunWorkerAsync(); _seekBackgroundWorker.RunWorkerAsync();
}
} }
public void StopSeeking(bool skipRecModeCheck = false) public void StopSeeking(bool skipRecModeCheck = false)
@ -94,45 +109,49 @@ namespace BizHawk.Client.EmuHawk
TastudioRecordMode(); TastudioRecordMode();
WasRecording = false; WasRecording = false;
} }
Mainform.PauseOnFrame = null; Mainform.PauseOnFrame = null;
if (_shouldUnpauseFromRewind) if (_shouldUnpauseFromRewind)
{ {
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
_shouldUnpauseFromRewind = false; _shouldUnpauseFromRewind = false;
} }
if (CurrentTasMovie != null) if (CurrentTasMovie != null)
{
RefreshDialog(); RefreshDialog();
}
} }
#region Query callbacks #region Query callbacks
// public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why? // public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why?
public static Color CurrentFrame_InputLog = Color.FromArgb(0x00B5E7F7); public static Color CurrentFrame_InputLog => Color.FromArgb(0x00B5E7F7);
public static Color SeekFrame_InputLog = Color.FromArgb(0x70B5E7F7); public static Color SeekFrame_InputLog => Color.FromArgb(0x70B5E7F7);
public static Color GreenZone_FrameCol = Color.FromArgb(0xDDFFDD); public static Color GreenZone_FrameCol => Color.FromArgb(0xDDFFDD);
public static Color GreenZone_InputLog = Color.FromArgb(0xD2F9D3); public static Color GreenZone_InputLog => Color.FromArgb(0xD2F9D3);
public static Color GreenZone_InputLog_Stated = Color.FromArgb(0xC4F7C8); public static Color GreenZone_InputLog_Stated => Color.FromArgb(0xC4F7C8);
public static Color GreenZone_InputLog_Invalidated = Color.FromArgb(0xE0FBE0); public static Color GreenZone_InputLog_Invalidated => Color.FromArgb(0xE0FBE0);
public static Color LagZone_FrameCol = Color.FromArgb(0xFFDCDD); public static Color LagZone_FrameCol => Color.FromArgb(0xFFDCDD);
public static Color LagZone_InputLog = Color.FromArgb(0xF4DADA); public static Color LagZone_InputLog => Color.FromArgb(0xF4DADA);
public static Color LagZone_InputLog_Stated = Color.FromArgb(0xF0D0D2); public static Color LagZone_InputLog_Stated => Color.FromArgb(0xF0D0D2);
public static Color LagZone_InputLog_Invalidated = Color.FromArgb(0xF7E5E5); public static Color LagZone_InputLog_Invalidated => Color.FromArgb(0xF7E5E5);
public static Color Marker_FrameCol = Color.FromArgb(0xF7FFC9); public static Color Marker_FrameCol => Color.FromArgb(0xF7FFC9);
public static Color AnalogEdit_Col = Color.FromArgb(0x909070); // SuuperW: When editing an analog value, it will be a gray color. public static Color AnalogEdit_Col => Color.FromArgb(0x909070); // SuuperW: When editing an analog value, it will be a gray color.
private Bitmap ts_v_arrow_green_blue = Properties.Resources.ts_v_arrow_green_blue; private Bitmap ts_v_arrow_green_blue => Properties.Resources.ts_v_arrow_green_blue;
private Bitmap ts_h_arrow_green_blue = Properties.Resources.ts_h_arrow_green_blue; private Bitmap ts_h_arrow_green_blue => Properties.Resources.ts_h_arrow_green_blue;
private Bitmap ts_v_arrow_blue = Properties.Resources.ts_v_arrow_blue; private Bitmap ts_v_arrow_blue => Properties.Resources.ts_v_arrow_blue;
private Bitmap ts_h_arrow_blue = Properties.Resources.ts_h_arrow_blue; private Bitmap ts_h_arrow_blue => Properties.Resources.ts_h_arrow_blue;
private Bitmap ts_v_arrow_green = Properties.Resources.ts_v_arrow_green; private Bitmap ts_v_arrow_green => Properties.Resources.ts_v_arrow_green;
private Bitmap ts_h_arrow_green = Properties.Resources.ts_h_arrow_green; private Bitmap ts_h_arrow_green => Properties.Resources.ts_h_arrow_green;
private Bitmap icon_marker = Properties.Resources.icon_marker; private Bitmap icon_marker => Properties.Resources.icon_marker;
private Bitmap icon_anchor_lag = Properties.Resources.icon_anchor_lag; private Bitmap icon_anchor_lag => Properties.Resources.icon_anchor_lag;
private Bitmap icon_anchor = Properties.Resources.icon_anchor; private Bitmap icon_anchor => Properties.Resources.icon_anchor;
private void TasView_QueryItemIcon(int index, InputRoll.RollColumn column, ref Bitmap bitmap, ref int offsetX, ref int offsetY) private void TasView_QueryItemIcon(int index, InputRoll.RollColumn column, ref Bitmap bitmap, ref int offsetX, ref int offsetY)
{ {
@ -174,13 +193,19 @@ namespace BizHawk.Client.EmuHawk
offsetY = 1; offsetY = 1;
if (CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithIcons) if (CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithIcons)
{
bitmap = icon_marker; bitmap = icon_marker;
}
else if (record.HasState && Settings.DenoteStatesWithIcons) else if (record.HasState && Settings.DenoteStatesWithIcons)
{ {
if (record.Lagged.HasValue && record.Lagged.Value) if (record.Lagged.HasValue && record.Lagged.Value)
{
bitmap = icon_anchor_lag; bitmap = icon_anchor_lag;
}
else else
{
bitmap = icon_anchor; bitmap = icon_anchor;
}
} }
} }
} }
@ -203,20 +228,27 @@ namespace BizHawk.Client.EmuHawk
if (columnName == FrameColumnName) if (columnName == FrameColumnName)
{ {
if (Emulator.Frame != index && CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithBGColor) if (Emulator.Frame != index && CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithBGColor)
{
color = Marker_FrameCol; color = Marker_FrameCol;
}
else else
{
color = Color.FromArgb(0x60FFFFFF); color = Color.FromArgb(0x60FFFFFF);
}
} }
else if (FloatEditingMode && else if (FloatEditingMode &&
(index == _floatEditRow || _extraFloatRows.Contains(index)) && (index == _floatEditRow || _extraFloatRows.Contains(index)) &&
columnName == _floatEditColumn) columnName == _floatEditColumn)
{ // SuuperW: Analog editing is indicated by a color change. {
// SuuperW: Analog editing is indicated by a color change.
color = AnalogEdit_Col; color = AnalogEdit_Col;
} }
int player = Emulator.ControllerDefinition.PlayerNumber(columnName); int player = Emulator.ControllerDefinition.PlayerNumber(columnName);
if (player != 0 && player % 2 == 0) if (player != 0 && player % 2 == 0)
{
color = Color.FromArgb(0x0D000000); color = Color.FromArgb(0x0D000000);
}
} }
private void TasView_QueryRowBkColor(int index, ref Color color) private void TasView_QueryRowBkColor(int index, ref Color color)
@ -234,13 +266,17 @@ namespace BizHawk.Client.EmuHawk
else if (record.Lagged.HasValue) else if (record.Lagged.HasValue)
{ {
if (!record.HasState && Settings.DenoteStatesWithBGColor) if (!record.HasState && Settings.DenoteStatesWithBGColor)
color = record.Lagged.Value ? {
LagZone_InputLog : color = record.Lagged.Value
GreenZone_InputLog; ? LagZone_InputLog
: GreenZone_InputLog;
}
else else
color = record.Lagged.Value ? {
LagZone_InputLog_Stated : color = record.Lagged.Value
GreenZone_InputLog_Stated; ? LagZone_InputLog_Stated
: GreenZone_InputLog_Stated;
}
} }
else if (record.WasLagged.HasValue) else if (record.WasLagged.HasValue)
{ {
@ -279,23 +315,27 @@ namespace BizHawk.Client.EmuHawk
else if (columnName == FrameColumnName) else if (columnName == FrameColumnName)
{ {
offsetX = 7; offsetX = 7;
text = (index).ToString().PadLeft(CurrentTasMovie.InputLogLength.ToString().Length, '0'); text = index.ToString().PadLeft(CurrentTasMovie.InputLogLength.ToString().Length, '0');
} }
else else
{ {
// Display typed float value (string "-" can't be parsed, so CurrentTasMovie.DisplayValue can't return it) // Display typed float value (string "-" can't be parsed, so CurrentTasMovie.DisplayValue can't return it)
if (index == _floatEditRow && columnName == _floatEditColumn) if (index == _floatEditRow && columnName == _floatEditColumn)
{
text = _floatTypedValue; text = _floatTypedValue;
}
else if (index < CurrentTasMovie.InputLogLength) else if (index < CurrentTasMovie.InputLogLength)
{ {
text = CurrentTasMovie.DisplayValue(index, columnName); text = CurrentTasMovie.DisplayValue(index, columnName);
if (column.Type == InputRoll.RollColumn.InputType.Float) if (column.Type == InputRoll.RollColumn.InputType.Float)
{ {
// feos: this could be cashed, but I don't notice any slowdown this way either // feos: this could be cashed, but I don't notice any slowdown this way either
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)]; [Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)];
if (text == range.Mid.ToString()) if (text == range.Mid.ToString())
{
text = ""; text = "";
}
} }
} }
} }
@ -345,11 +385,13 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
float state = CurrentTasMovie.GetFloatState(frame, buttonName); float state = CurrentTasMovie.GetFloatState(frame, buttonName);
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)]; [Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)];
if (state != range.Mid) if (state != range.Mid)
{
state = range.Mid; state = range.Mid;
}
foreach (var index in TasView.SelectedRows) foreach (var index in TasView.SelectedRows)
{ {
@ -375,33 +417,59 @@ namespace BizHawk.Client.EmuHawk
private void UpdateAutoFire() private void UpdateAutoFire()
{ {
for (int i = 2; i < TasView.AllColumns.Count; i++) for (int i = 2; i < TasView.AllColumns.Count; i++)
{
UpdateAutoFire(TasView.AllColumns[i].Name, TasView.AllColumns[i].Emphasis); UpdateAutoFire(TasView.AllColumns[i].Name, TasView.AllColumns[i].Emphasis);
}
} }
public void UpdateAutoFire(string button, bool? isOn) public void UpdateAutoFire(string button, bool? isOn)
{ {
if (!isOn.HasValue) // No value means don't change whether it's on or off. if (!isOn.HasValue) // No value means don't change whether it's on or off.
{
isOn = TasView.AllColumns.Find(c => c.Name == button).Emphasis; isOn = TasView.AllColumns.Find(c => c.Name == button).Emphasis;
}
int index = 0; int index = 0;
if (autoHoldToolStripMenuItem.Checked) index = 1; if (autoHoldToolStripMenuItem.Checked)
if (autoFireToolStripMenuItem.Checked) index = 2; {
if (controllerType.BoolButtons.Contains(button)) index = 1;
}
if (autoFireToolStripMenuItem.Checked)
{
index = 2;
}
if (ControllerType.BoolButtons.Contains(button))
{ {
if (index == 0) if (index == 0)
index = controllerType.BoolButtons.IndexOf(button); {
index = ControllerType.BoolButtons.IndexOf(button);
}
else else
index += controllerType.BoolButtons.Count - 1; {
index += ControllerType.BoolButtons.Count - 1;
}
AutoPatternBool p = BoolPatterns[index]; AutoPatternBool p = BoolPatterns[index];
Global.AutofireStickyXORAdapter.SetSticky(button, isOn.Value, p); Global.AutofireStickyXORAdapter.SetSticky(button, isOn.Value, p);
} }
else else
{ {
if (index == 0) if (index == 0)
index = controllerType.FloatControls.IndexOf(button); {
index = ControllerType.FloatControls.IndexOf(button);
}
else else
index += controllerType.FloatControls.Count - 1; {
index += ControllerType.FloatControls.Count - 1;
}
float? value = null; float? value = null;
if (isOn.Value) value = 0f; if (isOn.Value)
{
value = 0f;
}
AutoPatternFloat p = FloatPatterns[index]; AutoPatternFloat p = FloatPatterns[index];
Global.AutofireStickyXORAdapter.SetFloat(button, value, p); Global.AutofireStickyXORAdapter.SetFloat(button, value, p);
} }
@ -414,15 +482,19 @@ namespace BizHawk.Client.EmuHawk
private void TasView_MouseEnter(object sender, EventArgs e) private void TasView_MouseEnter(object sender, EventArgs e)
{ {
if (this.ContainsFocus) if (ContainsFocus)
{
TasView.Focus(); TasView.Focus();
}
} }
private void TasView_MouseDown(object sender, MouseEventArgs e) private void TasView_MouseDown(object sender, MouseEventArgs e)
{ {
// Clicking with left while right is held or vice versa does weird stuff // Clicking with left while right is held or vice versa does weird stuff
if (mouseButtonHeld) if (MouseButtonHeld)
{
return; return;
}
if (e.Button == MouseButtons.Middle) if (e.Button == MouseButtons.Middle)
{ {
@ -430,20 +502,27 @@ namespace BizHawk.Client.EmuHawk
{ {
TasMovieRecord record = CurrentTasMovie[LastPositionFrame]; TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame) if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame)
{
StartSeeking(LastPositionFrame); StartSeeking(LastPositionFrame);
}
else else
{
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
}
} }
else else
{ {
Mainform.PauseEmulator(); Mainform.PauseEmulator();
} }
return; return;
} }
// SuuperW: Moved these. // SuuperW: Moved these.
if (TasView.CurrentCell == null || !TasView.CurrentCell.RowIndex.HasValue || TasView.CurrentCell.Column == null) if (TasView.CurrentCell?.RowIndex == null || TasView.CurrentCell.Column == null)
{
return; return;
}
int frame = TasView.CurrentCell.RowIndex.Value; int frame = TasView.CurrentCell.RowIndex.Value;
string buttonName = TasView.CurrentCell.Column.Name; string buttonName = TasView.CurrentCell.Column.Name;
@ -453,6 +532,7 @@ namespace BizHawk.Client.EmuHawk
{ {
bool wasHeld = _leftButtonHeld; bool wasHeld = _leftButtonHeld;
_leftButtonHeld = true; _leftButtonHeld = true;
// SuuperW: Exit float editing mode, or re-enter mouse editing // SuuperW: Exit float editing mode, or re-enter mouse editing
if (FloatEditingMode) if (FloatEditingMode)
{ {
@ -479,6 +559,7 @@ namespace BizHawk.Client.EmuHawk
floatEditRow = frame; floatEditRow = frame;
RefreshTasView(); RefreshTasView();
} }
_floatEditYPos = e.Y; _floatEditYPos = e.Y;
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName); _floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
_triggerAutoRestore = true; _triggerAutoRestore = true;
@ -521,18 +602,22 @@ namespace BizHawk.Client.EmuHawk
_startBoolDrawColumn = buttonName; _startBoolDrawColumn = buttonName;
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName); _boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
if (applyPatternToPaintedInputToolStripMenuItem.Checked && if (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked
(!onlyOnAutoFireColumnsToolStripMenuItem.Checked || TasView.CurrentCell.Column.Emphasis)) || TasView.CurrentCell.Column.Emphasis))
{ {
BoolPatterns[controllerType.BoolButtons.IndexOf(buttonName)].Reset(); BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].Reset();
BoolPatterns[controllerType.BoolButtons.IndexOf(buttonName)].GetNextValue(); BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].GetNextValue();
_patternPaint = true; _patternPaint = true;
} }
else else
{
_patternPaint = false; _patternPaint = false;
}
if (!Settings.AutoRestoreOnMouseUpOnly) if (!Settings.AutoRestoreOnMouseUpOnly)
{
DoTriggeredAutoRestoreIfNeeded(); DoTriggeredAutoRestoreIfNeeded();
}
} }
else else
{ {
@ -545,16 +630,17 @@ namespace BizHawk.Client.EmuHawk
JumpToGreenzone(); JumpToGreenzone();
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName); _floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
if (applyPatternToPaintedInputToolStripMenuItem.Checked && if (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked
(!onlyOnAutoFireColumnsToolStripMenuItem.Checked || TasView.CurrentCell.Column.Emphasis)) || TasView.CurrentCell.Column.Emphasis))
{ {
FloatPatterns[controllerType.FloatControls.IndexOf(buttonName)].Reset(); FloatPatterns[ControllerType.FloatControls.IndexOf(buttonName)].Reset();
CurrentTasMovie.SetFloatState(frame, buttonName, CurrentTasMovie.SetFloatState(frame, buttonName, FloatPatterns[ControllerType.FloatControls.IndexOf(buttonName)].GetNextValue());
FloatPatterns[controllerType.FloatControls.IndexOf(buttonName)].GetNextValue());
_patternPaint = true; _patternPaint = true;
} }
else else
{
_patternPaint = false; _patternPaint = false;
}
if (e.Clicks != 2 && !Settings.SingleClickFloatEdit) if (e.Clicks != 2 && !Settings.SingleClickFloatEdit)
@ -565,7 +651,9 @@ namespace BizHawk.Client.EmuHawk
else // Double-click enters float editing mode else // Double-click enters float editing mode
{ {
if (_floatEditColumn == buttonName && _floatEditRow == frame) if (_floatEditColumn == buttonName && _floatEditRow == frame)
{
floatEditRow = -1; floatEditRow = -1;
}
else else
{ {
CurrentTasMovie.ChangeLog.BeginNewBatch("Float Edit: " + frame); CurrentTasMovie.ChangeLog.BeginNewBatch("Float Edit: " + frame);
@ -575,16 +663,19 @@ namespace BizHawk.Client.EmuHawk
_floatEditYPos = e.Y; _floatEditYPos = e.Y;
_floatBackupState = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn); _floatBackupState = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn);
} }
RefreshDialog(); RefreshDialog();
} }
} }
// taseditor behavior // taseditor behavior
if (!wasPaused) if (!wasPaused)
{
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
}
} }
} }
else if (e.Button == System.Windows.Forms.MouseButtons.Right) else if (e.Button == MouseButtons.Right)
{ {
if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength) if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength)
{ {
@ -601,7 +692,9 @@ namespace BizHawk.Client.EmuHawk
} }
catch { } catch { }
if (_rightClickControl && _rightClickShift) if (_rightClickControl && _rightClickShift)
{
_rightClickFrame += _rightClickInput.Length; _rightClickFrame += _rightClickInput.Length;
}
} }
else else
{ {
@ -609,26 +702,35 @@ namespace BizHawk.Client.EmuHawk
_rightClickInput[0] = CurrentTasMovie.GetLogEntries()[frame]; _rightClickInput[0] = CurrentTasMovie.GetLogEntries()[frame];
_rightClickFrame = frame; _rightClickFrame = frame;
} }
_rightClickLastFrame = -1; _rightClickLastFrame = -1;
if (_rightClickAlt || _rightClickControl || _rightClickShift) if (_rightClickAlt || _rightClickControl || _rightClickShift)
{ {
JumpToGreenzone(); JumpToGreenzone();
// TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here. // TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here.
string undoStepName = "Right-Click Edit:"; string undoStepName = "Right-Click Edit:";
if (_rightClickShift) if (_rightClickShift)
{ {
undoStepName += " Extend Input"; undoStepName += " Extend Input";
if (_rightClickControl) if (_rightClickControl)
{
undoStepName += ", Insert"; undoStepName += ", Insert";
}
} }
else else
{ {
if (_rightClickControl) if (_rightClickControl)
{
undoStepName += " Copy"; undoStepName += " Copy";
}
else // _rightClickAlt else // _rightClickAlt
{
undoStepName += " Move"; undoStepName += " Move";
}
} }
CurrentTasMovie.ChangeLog.BeginNewBatch(undoStepName); CurrentTasMovie.ChangeLog.BeginNewBatch(undoStepName);
} }
} }
@ -642,6 +744,7 @@ namespace BizHawk.Client.EmuHawk
_startBoolDrawColumn = ""; _startBoolDrawColumn = "";
_startFloatDrawColumn = ""; _startFloatDrawColumn = "";
TasView.ReleaseCurrentCell(); TasView.ReleaseCurrentCell();
// Exit float editing if value was changed with cursor // Exit float editing if value was changed with cursor
if (FloatEditingMode && _floatPaintState != CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn)) if (FloatEditingMode && _floatPaintState != CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn))
{ {
@ -686,10 +789,12 @@ namespace BizHawk.Client.EmuHawk
_startSelectionDrag = false; _startSelectionDrag = false;
} }
else else
{
ClearLeftMouseStates(); ClearLeftMouseStates();
}
} }
if (e.Button == System.Windows.Forms.MouseButtons.Right) if (e.Button == MouseButtons.Right)
{ {
if (_rightClickFrame != -1) if (_rightClickFrame != -1)
{ {
@ -712,12 +817,15 @@ namespace BizHawk.Client.EmuHawk
_supressContextMenu = true; _supressContextMenu = true;
int notch = e.Delta / 120; int notch = e.Delta / 120;
if (notch > 1) if (notch > 1)
{
notch *= 2; notch *= 2;
}
// warning: tastudio rewind hotkey/button logic is copypasted from here! // warning: tastudio rewind hotkey/button logic is copypasted from here!
if (Mainform.IsSeeking && !Mainform.EmulatorPaused) if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
{ {
Mainform.PauseOnFrame -= notch; Mainform.PauseOnFrame -= notch;
// that's a weird condition here, but for whatever reason it works best // that's a weird condition here, but for whatever reason it works best
if (notch > 0 && Emulator.Frame >= Mainform.PauseOnFrame) if (notch > 0 && Emulator.Frame >= Mainform.PauseOnFrame)
{ {
@ -726,6 +834,7 @@ namespace BizHawk.Client.EmuHawk
StopSeeking(); StopSeeking();
GoToFrame(Emulator.Frame - notch); GoToFrame(Emulator.Frame - notch);
} }
RefreshDialog(); RefreshDialog();
} }
else else
@ -738,7 +847,9 @@ namespace BizHawk.Client.EmuHawk
private void TasView_MouseDoubleClick(object sender, MouseEventArgs e) private void TasView_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
if (TasView.CurrentCell.Column == null) if (TasView.CurrentCell.Column == null)
{
return; return;
}
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
@ -815,19 +926,26 @@ namespace BizHawk.Client.EmuHawk
if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift)) if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift))
{ {
if (_selectionDragState) if (_selectionDragState)
{
_extraFloatRows.Add(i); _extraFloatRows.Add(i);
}
else else
{
_extraFloatRows.Remove(i); _extraFloatRows.Remove(i);
}
} }
} }
SetSplicer(); SetSplicer();
} }
} }
else if (_rightClickFrame != -1) else if (_rightClickFrame != -1)
{ {
if (frame > CurrentTasMovie.InputLogLength - _rightClickInput.Length) if (frame > CurrentTasMovie.InputLogLength - _rightClickInput.Length)
{
frame = CurrentTasMovie.InputLogLength - _rightClickInput.Length; frame = CurrentTasMovie.InputLogLength - _rightClickInput.Length;
}
if (_rightClickShift) if (_rightClickShift)
{ {
if (_rightClickControl) // Insert if (_rightClickControl) // Insert
@ -835,16 +953,20 @@ namespace BizHawk.Client.EmuHawk
// If going backwards, delete! // If going backwards, delete!
bool shouldInsert = true; bool shouldInsert = true;
if (startVal < _rightClickFrame) if (startVal < _rightClickFrame)
{ // Cloning to a previous frame makes no sense. {
// Cloning to a previous frame makes no sense.
startVal = _rightClickFrame - 1; startVal = _rightClickFrame - 1;
} }
if (startVal < _rightClickLastFrame) if (startVal < _rightClickLastFrame)
shouldInsert = false; shouldInsert = false;
if (shouldInsert) if (shouldInsert)
{ {
for (int i = startVal + 1; i <= endVal; i++) for (int i = startVal + 1; i <= endVal; i++)
{
CurrentTasMovie.InsertInput(i, _rightClickInput[(i - _rightClickFrame).Mod(_rightClickInput.Length)]); CurrentTasMovie.InsertInput(i, _rightClickInput[(i - _rightClickFrame).Mod(_rightClickInput.Length)]);
}
} }
else else
{ {
@ -856,7 +978,9 @@ namespace BizHawk.Client.EmuHawk
else // Overwrite else // Overwrite
{ {
for (int i = startVal; i <= endVal; i++) for (int i = startVal; i <= endVal; i++)
{
CurrentTasMovie.SetFrame(i, _rightClickInput[(i - _rightClickFrame).Mod(_rightClickInput.Length)]); CurrentTasMovie.SetFrame(i, _rightClickInput[(i - _rightClickFrame).Mod(_rightClickInput.Length)]);
}
} }
} }
else else
@ -864,21 +988,29 @@ namespace BizHawk.Client.EmuHawk
if (_rightClickControl) if (_rightClickControl)
{ {
for (int i = 0; i < _rightClickInput.Length; i++) // Re-set initial range, just to verify it's still there. for (int i = 0; i < _rightClickInput.Length; i++) // Re-set initial range, just to verify it's still there.
{
CurrentTasMovie.SetFrame(_rightClickFrame + i, _rightClickInput[i]); CurrentTasMovie.SetFrame(_rightClickFrame + i, _rightClickInput[i]);
}
if (_rightClickOverInput != null) // Restore overwritten input from previous movement if (_rightClickOverInput != null) // Restore overwritten input from previous movement
{ {
for (int i = 0; i < _rightClickOverInput.Length; i++) for (int i = 0; i < _rightClickOverInput.Length; i++)
{
CurrentTasMovie.SetFrame(_rightClickLastFrame + i, _rightClickOverInput[i]); CurrentTasMovie.SetFrame(_rightClickLastFrame + i, _rightClickOverInput[i]);
}
} }
else else
{
_rightClickOverInput = new string[_rightClickInput.Length]; _rightClickOverInput = new string[_rightClickInput.Length];
}
_rightClickLastFrame = frame; // Set new restore log _rightClickLastFrame = frame; // Set new restore log
CurrentTasMovie.GetLogEntries().CopyTo(frame, _rightClickOverInput, 0, _rightClickOverInput.Length); CurrentTasMovie.GetLogEntries().CopyTo(frame, _rightClickOverInput, 0, _rightClickOverInput.Length);
for (int i = 0; i < _rightClickInput.Length; i++) // Place copied input for (int i = 0; i < _rightClickInput.Length; i++) // Place copied input
{
CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]); CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]);
}
} }
else if (_rightClickAlt) else if (_rightClickAlt)
{ {
@ -886,18 +1018,26 @@ namespace BizHawk.Client.EmuHawk
string[] shiftInput = new string[Math.Abs(shiftBy)]; string[] shiftInput = new string[Math.Abs(shiftBy)];
int shiftFrom = frame; int shiftFrom = frame;
if (shiftBy < 0) if (shiftBy < 0)
{
shiftFrom = _rightClickFrame + _rightClickInput.Length; shiftFrom = _rightClickFrame + _rightClickInput.Length;
}
CurrentTasMovie.GetLogEntries().CopyTo(shiftFrom, shiftInput, 0, shiftInput.Length); CurrentTasMovie.GetLogEntries().CopyTo(shiftFrom, shiftInput, 0, shiftInput.Length);
int shiftTo = shiftFrom + (_rightClickInput.Length * Math.Sign(shiftBy)); int shiftTo = shiftFrom + (_rightClickInput.Length * Math.Sign(shiftBy));
for (int i = 0; i < shiftInput.Length; i++) for (int i = 0; i < shiftInput.Length; i++)
{
CurrentTasMovie.SetFrame(shiftTo + i, shiftInput[i]); CurrentTasMovie.SetFrame(shiftTo + i, shiftInput[i]);
}
for (int i = 0; i < _rightClickInput.Length; i++) for (int i = 0; i < _rightClickInput.Length; i++)
{
CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]); CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]);
}
_rightClickFrame = frame; _rightClickFrame = frame;
} }
} }
if (_rightClickAlt || _rightClickControl || _rightClickShift) if (_rightClickAlt || _rightClickControl || _rightClickShift)
{ {
JumpToGreenzone(); JumpToGreenzone();
@ -905,6 +1045,7 @@ namespace BizHawk.Client.EmuHawk
_supressContextMenu = true; _supressContextMenu = true;
} }
} }
// Left-click // Left-click
else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startBoolDrawColumn)) else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startBoolDrawColumn))
{ {
@ -918,10 +1059,15 @@ namespace BizHawk.Client.EmuHawk
if (_patternPaint && _boolPaintState) if (_patternPaint && _boolPaintState)
{ {
if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value) if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value)
{
setVal = CurrentTasMovie.BoolIsPressed(i - 1, _startBoolDrawColumn); setVal = CurrentTasMovie.BoolIsPressed(i - 1, _startBoolDrawColumn);
}
else else
setVal = BoolPatterns[controllerType.BoolButtons.IndexOf(_startBoolDrawColumn)].GetNextValue(); {
setVal = BoolPatterns[ControllerType.BoolButtons.IndexOf(_startBoolDrawColumn)].GetNextValue();
}
} }
CurrentTasMovie.SetBoolState(i, _startBoolDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column CurrentTasMovie.SetBoolState(i, _startBoolDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column
JumpToGreenzone(); JumpToGreenzone();
} }
@ -946,10 +1092,15 @@ namespace BizHawk.Client.EmuHawk
if (_patternPaint) if (_patternPaint)
{ {
if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value) if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value)
{
setVal = CurrentTasMovie.GetFloatState(i - 1, _startFloatDrawColumn); setVal = CurrentTasMovie.GetFloatState(i - 1, _startFloatDrawColumn);
}
else else
setVal = FloatPatterns[controllerType.FloatControls.IndexOf(_startFloatDrawColumn)].GetNextValue(); {
setVal = FloatPatterns[ControllerType.FloatControls.IndexOf(_startFloatDrawColumn)].GetNextValue();
}
} }
CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column
JumpToGreenzone(); JumpToGreenzone();
} }
@ -964,10 +1115,11 @@ namespace BizHawk.Client.EmuHawk
Global.MovieSession.Movie.IsCountingRerecords = wasCountingRerecords; Global.MovieSession.Movie.IsCountingRerecords = wasCountingRerecords;
if (mouseButtonHeld) if (MouseButtonHeld)
{ {
TasView.MakeIndexVisible(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed TasView.MakeIndexVisible(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed
} }
RefreshTasView(); RefreshTasView();
} }
@ -979,8 +1131,9 @@ namespace BizHawk.Client.EmuHawk
return; return;
float value = _floatPaintState + increment; float value = _floatPaintState + increment;
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)]; [Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)];
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed in ControllerDefinition.cs. // Range for N64 Y axis has max -128 and min 127. That should probably be fixed in ControllerDefinition.cs.
// SuuperW: I really don't think changing it would break anything, but adelikat isn't so sure. // SuuperW: I really don't think changing it would break anything, but adelikat isn't so sure.
float rMax = range.Max; float rMax = range.Max;
@ -990,10 +1143,15 @@ namespace BizHawk.Client.EmuHawk
rMax = range.Min; rMax = range.Min;
rMin = range.Max; rMin = range.Max;
} }
if (value > rMax) if (value > rMax)
{
value = rMax; value = rMax;
}
else if (value < rMin) else if (value < rMin)
{
value = rMin; value = rMin;
}
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value); CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
_floatTypedValue = value.ToString(); _floatTypedValue = value.ToString();
@ -1012,53 +1170,68 @@ namespace BizHawk.Client.EmuHawk
public void AnalogIncrementByOne() public void AnalogIncrementByOne()
{ {
if (FloatEditingMode) if (FloatEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Up)); EditAnalogProgrammatically(new KeyEventArgs(Keys.Up));
}
} }
public void AnalogDecrementByOne() public void AnalogDecrementByOne()
{ {
if (FloatEditingMode) if (FloatEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Down)); EditAnalogProgrammatically(new KeyEventArgs(Keys.Down));
}
} }
public void AnalogIncrementByTen() public void AnalogIncrementByTen()
{ {
if (FloatEditingMode) if (FloatEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Up | Keys.Shift)); EditAnalogProgrammatically(new KeyEventArgs(Keys.Up | Keys.Shift));
}
} }
public void AnalogDecrementByTen() public void AnalogDecrementByTen()
{ {
if (FloatEditingMode) if (FloatEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Down | Keys.Shift)); EditAnalogProgrammatically(new KeyEventArgs(Keys.Down | Keys.Shift));
}
} }
public void AnalogMax() public void AnalogMax()
{ {
if (FloatEditingMode) if (FloatEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Right)); EditAnalogProgrammatically(new KeyEventArgs(Keys.Right));
}
} }
public void AnalogMin() public void AnalogMin()
{ {
if (FloatEditingMode) if (FloatEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Left)); EditAnalogProgrammatically(new KeyEventArgs(Keys.Left));
}
} }
public void EditAnalogProgrammatically(KeyEventArgs e) public void EditAnalogProgrammatically(KeyEventArgs e)
{ {
if (!FloatEditingMode) if (!FloatEditingMode)
{
return; return;
}
float value = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn); float value = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn);
float prev = value; float prev = value;
string prevTyped = _floatTypedValue; string prevTyped = _floatTypedValue;
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)]; [Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)];
float rMax = range.Max; float rMax = range.Max;
float rMin = range.Min; float rMin = range.Min;
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed ControllerDefinition.cs, but I'll put a quick fix here anyway. // Range for N64 Y axis has max -128 and min 127. That should probably be fixed ControllerDefinition.cs, but I'll put a quick fix here anyway.
if (rMax < rMin) if (rMax < rMin)
{ {
@ -1095,31 +1268,48 @@ namespace BizHawk.Client.EmuHawk
else if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) else if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
{ {
if (curDigits >= maxDigits) if (curDigits >= maxDigits)
{
_floatTypedValue = curMinus; _floatTypedValue = curMinus;
}
_floatTypedValue += e.KeyCode - Keys.D0; _floatTypedValue += e.KeyCode - Keys.D0;
} }
else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
{ {
if (curDigits >= maxDigits) if (curDigits >= maxDigits)
{
_floatTypedValue = curMinus; _floatTypedValue = curMinus;
}
_floatTypedValue += e.KeyCode - Keys.NumPad0; _floatTypedValue += e.KeyCode - Keys.NumPad0;
} }
else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract) else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract)
{ {
if (_floatTypedValue.StartsWith("-")) if (_floatTypedValue.StartsWith("-"))
{
_floatTypedValue = _floatTypedValue.Substring(1); _floatTypedValue = _floatTypedValue.Substring(1);
}
else else
{
_floatTypedValue = "-" + _floatTypedValue; _floatTypedValue = "-" + _floatTypedValue;
}
} }
else if (e.KeyCode == Keys.Back) else if (e.KeyCode == Keys.Back)
{ {
if (_floatTypedValue == "") // Very first key press is backspace? if (_floatTypedValue == "") // Very first key press is backspace?
{
_floatTypedValue = value.ToString(); _floatTypedValue = value.ToString();
}
_floatTypedValue = _floatTypedValue.Substring(0, _floatTypedValue.Length - 1); _floatTypedValue = _floatTypedValue.Substring(0, _floatTypedValue.Length - 1);
if (_floatTypedValue == "" || _floatTypedValue == "-") if (_floatTypedValue == "" || _floatTypedValue == "-")
{
value = 0f; value = 0f;
}
else else
{
value = Convert.ToSingle(_floatTypedValue); value = Convert.ToSingle(_floatTypedValue);
}
} }
else if (e.KeyCode == Keys.Enter) else if (e.KeyCode == Keys.Enter)
{ {
@ -1127,6 +1317,7 @@ namespace BizHawk.Client.EmuHawk
{ {
_floatEditYPos = -1; _floatEditYPos = -1;
} }
floatEditRow = -1; floatEditRow = -1;
} }
else if (e.KeyCode == Keys.Escape) else if (e.KeyCode == Keys.Escape)
@ -1135,6 +1326,7 @@ namespace BizHawk.Client.EmuHawk
{ {
_floatEditYPos = -1; _floatEditYPos = -1;
} }
if (_floatBackupState != _floatPaintState) if (_floatBackupState != _floatPaintState)
{ {
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, _floatBackupState); CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, _floatBackupState);
@ -1142,24 +1334,37 @@ namespace BizHawk.Client.EmuHawk
JumpToGreenzone(); JumpToGreenzone();
DoTriggeredAutoRestoreIfNeeded(); DoTriggeredAutoRestoreIfNeeded();
} }
floatEditRow = -1; floatEditRow = -1;
} }
else else
{ {
float changeBy = 0; float changeBy = 0;
if (e.KeyCode == Keys.Up) if (e.KeyCode == Keys.Up)
{
changeBy = 1; // We're assuming for now that ALL float controls should contain integers. changeBy = 1; // We're assuming for now that ALL float controls should contain integers.
}
else if (e.KeyCode == Keys.Down) else if (e.KeyCode == Keys.Down)
{
changeBy = -1; changeBy = -1;
}
if (Control.ModifierKeys == Keys.Shift) if (Control.ModifierKeys == Keys.Shift)
{
changeBy *= 10; changeBy *= 10;
}
value += changeBy; value += changeBy;
if (changeBy != 0) if (changeBy != 0)
{
_floatTypedValue = value.ToString(); _floatTypedValue = value.ToString();
}
} }
if (!FloatEditingMode) if (!FloatEditingMode)
{
CurrentTasMovie.ChangeLog.EndBatch(); CurrentTasMovie.ChangeLog.EndBatch();
}
else else
{ {
if (_floatTypedValue == "") if (_floatTypedValue == "")
@ -1175,9 +1380,14 @@ namespace BizHawk.Client.EmuHawk
if (float.TryParse(_floatTypedValue, out value)) // String "-" can't be parsed. if (float.TryParse(_floatTypedValue, out value)) // String "-" can't be parsed.
{ {
if (value > rMax) if (value > rMax)
{
value = rMax; value = rMax;
}
else if (value < rMin) else if (value < rMin)
{
value = rMin; value = rMin;
}
_floatTypedValue = value.ToString(); _floatTypedValue = value.ToString();
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value); CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
} }
@ -1198,6 +1408,7 @@ namespace BizHawk.Client.EmuHawk
DoTriggeredAutoRestoreIfNeeded(); DoTriggeredAutoRestoreIfNeeded();
} }
} }
RefreshDialog(); RefreshDialog();
} }
@ -1212,10 +1423,13 @@ namespace BizHawk.Client.EmuHawk
GoToNextMarker(); GoToNextMarker();
} }
if (FloatEditingMode && if (FloatEditingMode && e.KeyCode != Keys.Right
e.KeyCode != Keys.Right && e.KeyCode != Keys.Left && && e.KeyCode != Keys.Left
e.KeyCode != Keys.Up && e.KeyCode != Keys.Down) && e.KeyCode != Keys.Up
&& e.KeyCode != Keys.Down)
{
EditAnalogProgrammatically(e); EditAnalogProgrammatically(e);
}
RefreshDialog(); RefreshDialog();
} }
@ -1226,8 +1440,11 @@ namespace BizHawk.Client.EmuHawk
private void TasView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) private void TasView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{ {
if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
{
e.IsInputKey = true; e.IsInputKey = true;
}
} }
#endregion #endregion
} }
} }

View File

@ -25,7 +25,6 @@ namespace BizHawk.Client.EmuHawk
SaveTASMenuItem.Enabled = SaveTASMenuItem.Enabled =
!string.IsNullOrWhiteSpace(CurrentTasMovie.Filename) && !string.IsNullOrWhiteSpace(CurrentTasMovie.Filename) &&
(CurrentTasMovie.Filename != DefaultTasProjName()); (CurrentTasMovie.Filename != DefaultTasProjName());
} }
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e) private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
@ -92,12 +91,12 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private bool _exiting = false; private bool _exiting;
private void SaveTas(object sender, EventArgs e) private void SaveTas(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(CurrentTasMovie.Filename) || if (string.IsNullOrEmpty(CurrentTasMovie.Filename)
CurrentTasMovie.Filename == DefaultTasProjName()) || CurrentTasMovie.Filename == DefaultTasProjName())
{ {
SaveAsTas(sender, e); SaveAsTas(sender, e);
} }
@ -106,14 +105,17 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop(); _autosaveTimer.Stop();
GlobalWin.Sound.StopSound(); GlobalWin.Sound.StopSound();
MessageStatusLabel.Text = "Saving..."; MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
Update(); Update();
CurrentTasMovie.Save(); CurrentTasMovie.Save();
if (Settings.AutosaveInterval > 0) if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start(); _autosaveTimer.Start();
}
MessageStatusLabel.Text = CurrentTasMovie.Name + " saved."; MessageStatusLabel.Text = CurrentTasMovie.Name + " saved.";
Settings.RecentTas.Add(CurrentTasMovie.Filename); Settings.RecentTas.Add(CurrentTasMovie.Filename);
this.Cursor = Cursors.Default; Cursor = Cursors.Default;
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
} }
} }
@ -123,7 +125,9 @@ namespace BizHawk.Client.EmuHawk
{ {
SaveTas(sender, e); SaveTas(sender, e);
if (Settings.BackupPerFileSave) if (Settings.BackupPerFileSave)
{
SaveBackupMenuItem_Click(sender, e); SaveBackupMenuItem_Click(sender, e);
}
} }
private void SaveAsTas(object sender, EventArgs e) private void SaveAsTas(object sender, EventArgs e)
@ -147,17 +151,21 @@ namespace BizHawk.Client.EmuHawk
{ {
CurrentTasMovie.Filename = file.FullName; CurrentTasMovie.Filename = file.FullName;
MessageStatusLabel.Text = "Saving..."; MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
Update(); Update();
CurrentTasMovie.Save(); CurrentTasMovie.Save();
Settings.RecentTas.Add(CurrentTasMovie.Filename); Settings.RecentTas.Add(CurrentTasMovie.Filename);
SetTextProperty(); SetTextProperty();
MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved."; MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.";
this.Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
// keep insisting // keep insisting
if (Settings.AutosaveInterval > 0) if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start(); _autosaveTimer.Start();
}
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
} }
@ -166,13 +174,15 @@ namespace BizHawk.Client.EmuHawk
{ {
SaveAsTas(sender, e); SaveAsTas(sender, e);
if (Settings.BackupPerFileSave) if (Settings.BackupPerFileSave)
{
SaveBackupMenuItem_Click(sender, e); SaveBackupMenuItem_Click(sender, e);
}
} }
private void SaveBackupMenuItem_Click(object sender, EventArgs e) private void SaveBackupMenuItem_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(CurrentTasMovie.Filename) || if (string.IsNullOrEmpty(CurrentTasMovie.Filename)
CurrentTasMovie.Filename == DefaultTasProjName()) || CurrentTasMovie.Filename == DefaultTasProjName())
{ {
SaveAsTas(sender, e); SaveAsTas(sender, e);
} }
@ -181,14 +191,17 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop(); _autosaveTimer.Stop();
GlobalWin.Sound.StopSound(); GlobalWin.Sound.StopSound();
MessageStatusLabel.Text = "Saving..."; MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
Update(); Update();
CurrentTasMovie.SaveBackup(); CurrentTasMovie.SaveBackup();
if (Settings.AutosaveInterval > 0) if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start(); _autosaveTimer.Start();
}
MessageStatusLabel.Text = "Backup .tasproj saved to \"Movie backups\" path."; MessageStatusLabel.Text = "Backup .tasproj saved to \"Movie backups\" path.";
Settings.RecentTas.Add(CurrentTasMovie.Filename); Settings.RecentTas.Add(CurrentTasMovie.Filename);
this.Cursor = Cursors.Default; Cursor = Cursors.Default;
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
} }
} }
@ -198,31 +211,41 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop(); _autosaveTimer.Stop();
var bk2 = CurrentTasMovie.ToBk2(copy: true, backup: true); var bk2 = CurrentTasMovie.ToBk2(copy: true, backup: true);
MessageStatusLabel.Text = "Exporting to .bk2..."; MessageStatusLabel.Text = "Exporting to .bk2...";
this.Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
Update(); Update();
bk2.SaveBackup(); bk2.SaveBackup();
if (Settings.AutosaveInterval > 0) if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start(); _autosaveTimer.Start();
}
MessageStatusLabel.Text = "Backup .bk2 saved to \"Movie backups\" path."; MessageStatusLabel.Text = "Backup .bk2 saved to \"Movie backups\" path.";
this.Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
private void saveSelectionToMacroToolStripMenuItem_Click(object sender, EventArgs e) private void SaveSelectionToMacroMenuItem_Click(object sender, EventArgs e)
{ {
if (TasView.LastSelectedIndex == CurrentTasMovie.InputLogLength) if (TasView.LastSelectedIndex == CurrentTasMovie.InputLogLength)
{
TasView.SelectRow(CurrentTasMovie.InputLogLength, false); TasView.SelectRow(CurrentTasMovie.InputLogLength, false);
}
if (!TasView.AnyRowsSelected) if (!TasView.AnyRowsSelected)
{
return; return;
}
MovieZone macro = new MovieZone(CurrentTasMovie, TasView.FirstSelectedIndex.Value, MovieZone macro = new MovieZone(CurrentTasMovie, TasView.FirstSelectedIndex.Value,
TasView.LastSelectedIndex.Value - TasView.FirstSelectedIndex.Value + 1); TasView.LastSelectedIndex.Value - TasView.FirstSelectedIndex.Value + 1);
MacroInputTool.SaveMacroAs(macro); MacroInputTool.SaveMacroAs(macro);
} }
private void placeMacroAtSelectionToolStripMenuItem_Click(object sender, EventArgs e)
private void PlaceMacroAtSelectionMenuItem_Click(object sender, EventArgs e)
{ {
if (!TasView.AnyRowsSelected) if (!TasView.AnyRowsSelected)
{
return; return;
}
MovieZone macro = MacroInputTool.LoadMacro(); MovieZone macro = MacroInputTool.LoadMacro();
if (macro != null) if (macro != null)
@ -232,7 +255,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void recentMacrosToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void RecentMacrosMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
recentMacrosToolStripMenuItem.DropDownItems.Clear(); recentMacrosToolStripMenuItem.DropDownItems.Clear();
recentMacrosToolStripMenuItem.DropDownItems.AddRange(Global.Config.RecentMacros.RecentMenu(DummyLoadMacro)); recentMacrosToolStripMenuItem.DropDownItems.AddRange(Global.Config.RecentMacros.RecentMenu(DummyLoadMacro));
@ -243,13 +266,16 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop(); _autosaveTimer.Stop();
var bk2 = CurrentTasMovie.ToBk2(true); var bk2 = CurrentTasMovie.ToBk2(true);
MessageStatusLabel.Text = "Exporting to .bk2..."; MessageStatusLabel.Text = "Exporting to .bk2...";
this.Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
Update(); Update();
bk2.Save(); bk2.Save();
if (Settings.AutosaveInterval > 0) if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start(); _autosaveTimer.Start();
}
MessageStatusLabel.Text = bk2.Name + " exported."; MessageStatusLabel.Text = bk2.Name + " exported.";
this.Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
private void ExitMenuItem_Click(object sender, EventArgs e) private void ExitMenuItem_Click(object sender, EventArgs e)
@ -313,30 +339,38 @@ namespace BizHawk.Client.EmuHawk
private void UndoMenuItem_Click(object sender, EventArgs e) private void UndoMenuItem_Click(object sender, EventArgs e)
{ {
if (CurrentTasMovie.ChangeLog.Undo() < Emulator.Frame) if (CurrentTasMovie.ChangeLog.Undo() < Emulator.Frame)
{
GoToFrame(CurrentTasMovie.ChangeLog.PreviousUndoFrame); GoToFrame(CurrentTasMovie.ChangeLog.PreviousUndoFrame);
}
else else
{
RefreshDialog(); RefreshDialog();
}
// Currently I don't have a way to easily detect when CanUndo changes, so this button should be enabled always. // Currently I don't have a way to easily detect when CanUndo changes, so this button should be enabled always.
//UndoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanUndo; // UndoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanUndo;
RedoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanRedo; RedoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanRedo;
} }
private void RedoMenuItem_Click(object sender, EventArgs e) private void RedoMenuItem_Click(object sender, EventArgs e)
{ {
if (CurrentTasMovie.ChangeLog.Redo() < Emulator.Frame) if (CurrentTasMovie.ChangeLog.Redo() < Emulator.Frame)
{
GoToFrame(CurrentTasMovie.ChangeLog.PreviousRedoFrame); GoToFrame(CurrentTasMovie.ChangeLog.PreviousRedoFrame);
}
else else
{
RefreshDialog(); RefreshDialog();
}
//UndoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanUndo; // Currently I don't have a way to easily detect when CanUndo changes, so this button should be enabled always.
// UndoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanUndo;
RedoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanRedo; RedoMenuItem.Enabled = CurrentTasMovie.ChangeLog.CanRedo;
} }
private void showUndoHistoryToolStripMenuItem_Click(object sender, EventArgs e) private void ShowUndoHistoryMenuItem_Click(object sender, EventArgs e)
{ {
_undoForm = new UndoHistoryForm(this); _undoForm = new UndoHistoryForm(this) { Owner = this };
_undoForm.Owner = this;
_undoForm.Show(); _undoForm.Show();
_undoForm.UpdateValues(); _undoForm.UpdateValues();
} }
@ -360,13 +394,14 @@ namespace BizHawk.Client.EmuHawk
var prevMarker = CurrentTasMovie.Markers.PreviousOrCurrent(TasView.LastSelectedIndex.Value); var prevMarker = CurrentTasMovie.Markers.PreviousOrCurrent(TasView.LastSelectedIndex.Value);
var nextMarker = CurrentTasMovie.Markers.Next(TasView.LastSelectedIndex.Value); var nextMarker = CurrentTasMovie.Markers.Next(TasView.LastSelectedIndex.Value);
int prev = prevMarker != null ? prevMarker.Frame : 0; int prev = prevMarker?.Frame ?? 0;
int next = nextMarker != null ? nextMarker.Frame : CurrentTasMovie.InputLogLength; int next = nextMarker?.Frame ?? CurrentTasMovie.InputLogLength;
for (int i = prev; i < next; i++) for (int i = prev; i < next; i++)
{ {
TasView.SelectRow(i, true); TasView.SelectRow(i, true);
} }
SetSplicer(); SetSplicer();
RefreshTasView(); RefreshTasView();
} }
@ -379,6 +414,7 @@ namespace BizHawk.Client.EmuHawk
{ {
TasView.SelectRow(item.Frame, true); TasView.SelectRow(item.Frame, true);
} }
SetSplicer(); SetSplicer();
RefreshTasView(); RefreshTasView();
} }
@ -395,7 +431,10 @@ namespace BizHawk.Client.EmuHawk
{ {
var input = CurrentTasMovie.GetInputState(index); var input = CurrentTasMovie.GetInputState(index);
if (input == null) if (input == null)
{
break; break;
}
_tasClipboard.Add(new TasClipboardEntry(index, input)); _tasClipboard.Add(new TasClipboardEntry(index, input));
var lg = CurrentTasMovie.LogGeneratorInstance(); var lg = CurrentTasMovie.LogGeneratorInstance();
lg.SetSource(input); lg.SetSource(input);
@ -411,7 +450,6 @@ namespace BizHawk.Client.EmuHawk
{ {
// TODO: if highlighting 2 rows and pasting 3, only paste 2 of them // TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
// FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs // FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs
var wasPaused = Mainform.EmulatorPaused; var wasPaused = Mainform.EmulatorPaused;
// copypaste from PasteInsertMenuItem_Click! // copypaste from PasteInsertMenuItem_Click!
@ -429,9 +467,13 @@ namespace BizHawk.Client.EmuHawk
{ {
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]); var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
if (line == null) if (line == null)
{
return; return;
}
else else
{
_tasClipboard.Add(new TasClipboardEntry(i, line)); _tasClipboard.Add(new TasClipboardEntry(i, line));
}
} }
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -469,9 +511,13 @@ namespace BizHawk.Client.EmuHawk
{ {
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]); var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
if (line == null) if (line == null)
{
return; return;
}
else else
{
_tasClipboard.Add(new TasClipboardEntry(i, line)); _tasClipboard.Add(new TasClipboardEntry(i, line));
}
} }
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -506,7 +552,10 @@ namespace BizHawk.Client.EmuHawk
{ {
var input = CurrentTasMovie.GetInputState(index); var input = CurrentTasMovie.GetInputState(index);
if (input == null) if (input == null)
{
break; break;
}
_tasClipboard.Add(new TasClipboardEntry(index, input)); _tasClipboard.Add(new TasClipboardEntry(index, input));
var lg = CurrentTasMovie.LogGeneratorInstance(); var lg = CurrentTasMovie.LogGeneratorInstance();
lg.SetSource(input); lg.SetSource(input);
@ -516,7 +565,7 @@ namespace BizHawk.Client.EmuHawk
Clipboard.SetDataObject(sb.ToString()); Clipboard.SetDataObject(sb.ToString());
CurrentTasMovie.RemoveFrames(list); CurrentTasMovie.RemoveFrames(list);
SetSplicer(); SetSplicer();
//TasView.DeselectAll(); feos: what if I want to continuously cut? ////TasView.DeselectAll(); feos: what if I want to continuously cut?
if (needsToRollback) if (needsToRollback)
{ {
@ -543,6 +592,7 @@ namespace BizHawk.Client.EmuHawk
{ {
CurrentTasMovie.ClearFrame(frame); CurrentTasMovie.ClearFrame(frame);
} }
CurrentTasMovie.ChangeLog.EndBatch(); CurrentTasMovie.ChangeLog.EndBatch();
if (needsToRollback) if (needsToRollback)
@ -564,7 +614,8 @@ namespace BizHawk.Client.EmuHawk
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
var rollBackFrame = TasView.FirstSelectedIndex.Value; var rollBackFrame = TasView.FirstSelectedIndex.Value;
if (rollBackFrame >= CurrentTasMovie.InputLogLength) if (rollBackFrame >= CurrentTasMovie.InputLogLength)
{ // Cannot delete non-existant frames {
// Cannot delete non-existant frames
RefreshDialog(); RefreshDialog();
return; return;
} }
@ -634,7 +685,7 @@ namespace BizHawk.Client.EmuHawk
{ {
int insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0; int insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0;
FramesPrompt framesPrompt = new FramesPrompt(); var framesPrompt = new FramesPrompt();
DialogResult result = framesPrompt.ShowDialog(); DialogResult result = framesPrompt.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
@ -669,8 +720,11 @@ namespace BizHawk.Client.EmuHawk
{ {
var result = MessageBox.Show("Are you sure you want to add more than 50 markers?", "Add markers", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); var result = MessageBox.Show("Are you sure you want to add more than 50 markers?", "Add markers", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result != DialogResult.OK) if (result != DialogResult.OK)
{
return; return;
}
} }
foreach (var index in TasView.SelectedRows) foreach (var index in TasView.SelectedRows)
{ {
MarkerControl.AddMarker(false, index); MarkerControl.AddMarker(false, index);
@ -689,6 +743,7 @@ namespace BizHawk.Client.EmuHawk
{ {
CurrentTasMovie.Markers.Remove(m); CurrentTasMovie.Markers.Remove(m);
} }
RefreshDialog(); RefreshDialog();
} }
@ -702,9 +757,10 @@ namespace BizHawk.Client.EmuHawk
{ {
if (!Emulator.DeterministicEmulation) if (!Emulator.DeterministicEmulation)
{ {
if (MessageBox.Show("The emulator is not deterministic. It might fail even if the difference isn't enough to cause a desync.\nContinue with check?", "Not Deterministic", MessageBoxButtons.YesNo) if (MessageBox.Show("The emulator is not deterministic. It might fail even if the difference isn't enough to cause a desync.\nContinue with check?", "Not Deterministic", MessageBoxButtons.YesNo) == DialogResult.No)
== System.Windows.Forms.DialogResult.No) {
return; return;
}
} }
GoToFrame(0); GoToFrame(0);
@ -727,7 +783,8 @@ namespace BizHawk.Client.EmuHawk
lastState = Emulator.Frame; lastState = Emulator.Frame;
} }
} while (Emulator.Frame < goToFrame); }
while (Emulator.Frame < goToFrame);
MessageBox.Show("Integrity Check passed"); MessageBox.Show("Integrity Check passed");
} }
@ -762,7 +819,9 @@ namespace BizHawk.Client.EmuHawk
{ {
int val = int.Parse(prompt.PromptText); int val = int.Parse(prompt.PromptText);
if (val > 0) if (val > 0)
{
CurrentTasMovie.ChangeLog.MaxSteps = val; CurrentTasMovie.ChangeLog.MaxSteps = val;
}
} }
} }
} }
@ -854,7 +913,7 @@ namespace BizHawk.Client.EmuHawk
TasView.InputPaintingMode = Settings.DrawInput ^= true; TasView.InputPaintingMode = Settings.DrawInput ^= true;
} }
private void applyPatternToPaintedInputToolStripMenuItem_CheckedChanged(object sender, EventArgs e) private void ApplyPatternToPaintedInputMenuItem_CheckedChanged(object sender, EventArgs e)
{ {
onlyOnAutoFireColumnsToolStripMenuItem.Enabled = applyPatternToPaintedInputToolStripMenuItem.Checked; onlyOnAutoFireColumnsToolStripMenuItem.Enabled = applyPatternToPaintedInputToolStripMenuItem.Checked;
} }
@ -884,7 +943,7 @@ namespace BizHawk.Client.EmuHawk
Settings.AutoRestoreOnMouseUpOnly ^= true; Settings.AutoRestoreOnMouseUpOnly ^= true;
} }
private void autoHoldToolStripMenuItem_CheckedChanged(object sender, EventArgs e) private void AutoHoldMenuItem_CheckedChanged(object sender, EventArgs e)
{ {
if (autoHoldToolStripMenuItem.Checked) if (autoHoldToolStripMenuItem.Checked)
{ {
@ -892,10 +951,13 @@ namespace BizHawk.Client.EmuHawk
customPatternToolStripMenuItem.Checked = false; customPatternToolStripMenuItem.Checked = false;
if (!keepSetPatternsToolStripMenuItem.Checked) if (!keepSetPatternsToolStripMenuItem.Checked)
{
UpdateAutoFire(); UpdateAutoFire();
}
} }
} }
private void autoFireToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
private void AutoFireMenuItem_CheckedChanged(object sender, EventArgs e)
{ {
if (autoFireToolStripMenuItem.Checked) if (autoFireToolStripMenuItem.Checked)
{ {
@ -903,10 +965,13 @@ namespace BizHawk.Client.EmuHawk
customPatternToolStripMenuItem.Checked = false; customPatternToolStripMenuItem.Checked = false;
if (!keepSetPatternsToolStripMenuItem.Checked) if (!keepSetPatternsToolStripMenuItem.Checked)
{
UpdateAutoFire(); UpdateAutoFire();
}
} }
} }
private void customPatternToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
private void CustomPatternMenuItem_CheckedChanged(object sender, EventArgs e)
{ {
if (customPatternToolStripMenuItem.Checked) if (customPatternToolStripMenuItem.Checked)
{ {
@ -914,15 +979,17 @@ namespace BizHawk.Client.EmuHawk
autoFireToolStripMenuItem.Checked = false; autoFireToolStripMenuItem.Checked = false;
if (!keepSetPatternsToolStripMenuItem.Checked) if (!keepSetPatternsToolStripMenuItem.Checked)
{
UpdateAutoFire(); UpdateAutoFire();
}
} }
} }
private void setCustomsToolStripMenuItem_Click(object sender, EventArgs e)
private void SetCustomsMenuItem_Click(object sender, EventArgs e)
{ {
// Exceptions in PatternsForm are not caught by the debugger, I have no idea why. // Exceptions in PatternsForm are not caught by the debugger, I have no idea why.
// Exceptions in UndoForm are caught, which makes it weirder. // Exceptions in UndoForm are caught, which makes it weirder.
PatternsForm pForm = new PatternsForm(this); var pForm = new PatternsForm(this) { Owner = this };
pForm.Owner = this;
pForm.Show(); pForm.Show();
} }
@ -993,7 +1060,7 @@ namespace BizHawk.Client.EmuHawk
hideWasLagFramesToolStripMenuItem.Checked = TasView.HideWasLagFrames; hideWasLagFramesToolStripMenuItem.Checked = TasView.HideWasLagFrames;
} }
private void iconsToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void IconsMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
DenoteStatesWithIconsToolStripMenuItem.Checked = Settings.DenoteStatesWithIcons; DenoteStatesWithIconsToolStripMenuItem.Checked = Settings.DenoteStatesWithIcons;
DenoteStatesWithBGColorToolStripMenuItem.Checked = Settings.DenoteStatesWithBGColor; DenoteStatesWithBGColorToolStripMenuItem.Checked = Settings.DenoteStatesWithBGColor;
@ -1001,7 +1068,7 @@ namespace BizHawk.Client.EmuHawk
DenoteMarkersWithBGColorToolStripMenuItem.Checked = Settings.DenoteMarkersWithBGColor; DenoteMarkersWithBGColorToolStripMenuItem.Checked = Settings.DenoteMarkersWithBGColor;
} }
private void followCursorToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void FollowCursorMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
alwaysScrollToolStripMenuItem.Checked = Settings.FollowCursorAlwaysScroll; alwaysScrollToolStripMenuItem.Checked = Settings.FollowCursorAlwaysScroll;
scrollToViewToolStripMenuItem.Checked = false; scrollToViewToolStripMenuItem.Checked = false;
@ -1009,13 +1076,21 @@ namespace BizHawk.Client.EmuHawk
scrollToBottomToolStripMenuItem.Checked = false; scrollToBottomToolStripMenuItem.Checked = false;
scrollToCenterToolStripMenuItem.Checked = false; scrollToCenterToolStripMenuItem.Checked = false;
if (TasView.ScrollMethod == "near") if (TasView.ScrollMethod == "near")
{
scrollToViewToolStripMenuItem.Checked = true; scrollToViewToolStripMenuItem.Checked = true;
}
else if (TasView.ScrollMethod == "top") else if (TasView.ScrollMethod == "top")
{
scrollToTopToolStripMenuItem.Checked = true; scrollToTopToolStripMenuItem.Checked = true;
}
else if (TasView.ScrollMethod == "bottom") else if (TasView.ScrollMethod == "bottom")
{
scrollToBottomToolStripMenuItem.Checked = true; scrollToBottomToolStripMenuItem.Checked = true;
}
else else
{
scrollToCenterToolStripMenuItem.Checked = true; scrollToCenterToolStripMenuItem.Checked = true;
}
} }
private void RotateMenuItem_Click(object sender, EventArgs e) private void RotateMenuItem_Click(object sender, EventArgs e)
@ -1031,32 +1106,32 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog(); RefreshDialog();
} }
private void hideWasLagFramesToolStripMenuItem_Click(object sender, EventArgs e) private void HideWasLagFramesMenuItem_Click(object sender, EventArgs e)
{ {
TasView.HideWasLagFrames ^= true; TasView.HideWasLagFrames ^= true;
} }
private void alwaysScrollToolStripMenuItem_Click(object sender, EventArgs e) private void AlwaysScrollMenuItem_Click(object sender, EventArgs e)
{ {
TasView.AlwaysScroll = Settings.FollowCursorAlwaysScroll = alwaysScrollToolStripMenuItem.Checked; TasView.AlwaysScroll = Settings.FollowCursorAlwaysScroll = alwaysScrollToolStripMenuItem.Checked;
} }
private void scrollToViewToolStripMenuItem_Click(object sender, EventArgs e) private void ScrollToViewMenuItem_Click(object sender, EventArgs e)
{ {
TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "near"; TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "near";
} }
private void scrollToTopToolStripMenuItem_Click(object sender, EventArgs e) private void ScrollToTopMenuItem_Click(object sender, EventArgs e)
{ {
TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "top"; TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "top";
} }
private void scrollToBottomToolStripMenuItem_Click(object sender, EventArgs e) private void ScrollToBottomMenuItem_Click(object sender, EventArgs e)
{ {
TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "bottom"; TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "bottom";
} }
private void scrollToCenterToolStripMenuItem_Click(object sender, EventArgs e) private void ScrollToCenterMenuItem_Click(object sender, EventArgs e)
{ {
TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "center"; TasView.ScrollMethod = Settings.FollowCursorScrollMethod = "center";
} }
@ -1085,18 +1160,19 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog(); RefreshDialog();
} }
private void wheelScrollSpeedToolStripMenuItem_Click(object sender, EventArgs e) private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e)
{ {
InputPrompt inputpromt = new InputPrompt(); var inputpromt = new InputPrompt
inputpromt.TextInputType = InputPrompt.InputType.Unsigned; {
inputpromt.Message = "Frames per tick:"; TextInputType = InputPrompt.InputType.Unsigned,
inputpromt.InitialValue = TasView.ScrollSpeed.ToString(); Message = "Frames per tick:",
if (inputpromt.ShowDialog() == System.Windows.Forms.DialogResult.OK) InitialValue = TasView.ScrollSpeed.ToString()
};
if (inputpromt.ShowDialog() == DialogResult.OK)
{ {
TasView.ScrollSpeed = int.Parse(inputpromt.PromptText); TasView.ScrollSpeed = int.Parse(inputpromt.PromptText);
Settings.ScrollSpeed = TasView.ScrollSpeed; Settings.ScrollSpeed = TasView.ScrollSpeed;
} }
} }
#endregion #endregion
@ -1117,7 +1193,6 @@ namespace BizHawk.Client.EmuHawk
{ {
playerMenus[i] = new ToolStripMenuItem("Player " + i); playerMenus[i] = new ToolStripMenuItem("Player " + i);
} }
int player = 0;
foreach (InputRoll.RollColumn column in columns) foreach (InputRoll.RollColumn column in columns)
{ {
@ -1140,6 +1215,7 @@ namespace BizHawk.Client.EmuHawk
(sender.OwnerItem as ToolStripMenuItem).ShowDropDown(); (sender.OwnerItem as ToolStripMenuItem).ShowDropDown();
}; };
int player;
if (column.Name.StartsWith("P") && column.Name.Length > 1 && char.IsNumber(column.Name, 1)) if (column.Name.StartsWith("P") && column.Name.Length > 1 && char.IsNumber(column.Name, 1))
{ {
player = int.Parse(column.Name[1].ToString()); player = int.Parse(column.Name[1].ToString());
@ -1153,14 +1229,18 @@ namespace BizHawk.Client.EmuHawk
} }
for (int i = 1; i < playerMenus.Length; i++) for (int i = 1; i < playerMenus.Length; i++)
{
ColumnsSubMenu.DropDownItems.Add(playerMenus[i]); ColumnsSubMenu.DropDownItems.Add(playerMenus[i]);
}
ColumnsSubMenu.DropDownItems.Add(new ToolStripSeparator()); ColumnsSubMenu.DropDownItems.Add(new ToolStripSeparator());
for (int i = 1; i < playerMenus.Length; i++) for (int i = 1; i < playerMenus.Length; i++)
{ {
ToolStripMenuItem item = new ToolStripMenuItem("Show Player " + i); var item = new ToolStripMenuItem("Show Player " + i)
item.CheckOnClick = true; {
item.Checked = true; CheckOnClick = true,
Checked = true
};
int dummyInt = i; int dummyInt = i;
ToolStripMenuItem dummyObject = playerMenus[i]; ToolStripMenuItem dummyObject = playerMenus[i];
@ -1217,7 +1297,6 @@ namespace BizHawk.Client.EmuHawk
TruncateContextMenuItem.Enabled = TruncateContextMenuItem.Enabled =
TasView.AnyRowsSelected; TasView.AnyRowsSelected;
StartNewProjectFromNowMenuItem.Visible = StartNewProjectFromNowMenuItem.Visible =
TasView.SelectedRows.Count() == 1 TasView.SelectedRows.Count() == 1
&& TasView.SelectedRows.Contains(Emulator.Frame) && TasView.SelectedRows.Contains(Emulator.Frame)
@ -1228,7 +1307,7 @@ namespace BizHawk.Client.EmuHawk
&& SaveRamEmulator != null && SaveRamEmulator != null
&& !CurrentTasMovie.StartsFromSavestate; && !CurrentTasMovie.StartsFromSavestate;
StartFromNowSeparator.Visible =StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible; StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible;
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this). RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue; CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue;
BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame; BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame;

View File

@ -1,7 +1,4 @@
using System.Linq; using BizHawk.Client.Common;
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -18,12 +15,13 @@ namespace BizHawk.Client.EmuHawk
if (frame <= Emulator.Frame) if (frame <= Emulator.Frame)
{ {
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking) && if ((Mainform.EmulatorPaused || !Mainform.IsSeeking)
!CurrentTasMovie.LastPositionStable) && !CurrentTasMovie.LastPositionStable)
{ {
LastPositionFrame = Emulator.Frame; LastPositionFrame = Emulator.Frame;
CurrentTasMovie.LastPositionStable = true; // until new frame is emulated CurrentTasMovie.LastPositionStable = true; // until new frame is emulated
} }
GoToFrame(frame); GoToFrame(frame);
} }
} }
@ -51,7 +49,9 @@ namespace BizHawk.Client.EmuHawk
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = Mainform.EmulatorPaused;
Mainform.FrameAdvance(); Mainform.FrameAdvance();
if (!wasPaused) if (!wasPaused)
{
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -59,7 +59,9 @@ namespace BizHawk.Client.EmuHawk
int lastState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame).Key; // Simply getting the last state doesn't work if that state is the frame. [dispaly isn't saved in the state, need to emulate to frame] int lastState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame).Key; // Simply getting the last state doesn't work if that state is the frame. [dispaly isn't saved in the state, need to emulate to frame]
if (lastState > Emulator.Frame) if (lastState > Emulator.Frame)
{
LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS
}
StartSeeking(frame); StartSeeking(frame);
} }
@ -87,7 +89,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator.Frame > 0) if (Emulator.Frame > 0)
{ {
var prevMarker = CurrentTasMovie.Markers.Previous(Emulator.Frame); var prevMarker = CurrentTasMovie.Markers.Previous(Emulator.Frame);
var prev = prevMarker != null ? prevMarker.Frame : 0; var prev = prevMarker?.Frame ?? 0;
GoToFrame(prev); GoToFrame(prev);
} }
} }
@ -95,7 +97,7 @@ namespace BizHawk.Client.EmuHawk
public void GoToNextMarker() public void GoToNextMarker()
{ {
var nextMarker = CurrentTasMovie.Markers.Next(Emulator.Frame); var nextMarker = CurrentTasMovie.Markers.Next(Emulator.Frame);
var next = nextMarker != null ? nextMarker.Frame : CurrentTasMovie.InputLogLength - 1; var next = nextMarker?.Frame ?? CurrentTasMovie.InputLogLength - 1;
GoToFrame(next); GoToFrame(next);
} }
@ -110,7 +112,9 @@ namespace BizHawk.Client.EmuHawk
public void SetVisibleIndex(int? indexThatMustBeVisible = null) public void SetVisibleIndex(int? indexThatMustBeVisible = null)
{ {
if (!indexThatMustBeVisible.HasValue) if (!indexThatMustBeVisible.HasValue)
{
indexThatMustBeVisible = Emulator.Frame; indexThatMustBeVisible = Emulator.Frame;
}
TasView.ScrollToIndex(indexThatMustBeVisible.Value); TasView.ScrollToIndex(indexThatMustBeVisible.Value);
} }
@ -118,7 +122,9 @@ namespace BizHawk.Client.EmuHawk
private void MaybeFollowCursor() private void MaybeFollowCursor()
{ {
if (TasPlaybackBox.FollowCursor) if (TasPlaybackBox.FollowCursor)
{
SetVisibleIndex(); SetVisibleIndex();
}
} }
} }
} }

View File

@ -8,6 +8,7 @@ using System.ComponentModel;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Client.Common.MovieConversionExtensions; using BizHawk.Client.Common.MovieConversionExtensions;
@ -20,11 +21,12 @@ namespace BizHawk.Client.EmuHawk
public partial class TAStudio : ToolFormBase, IToolFormAutoConfig, IControlMainform public partial class TAStudio : ToolFormBase, IToolFormAutoConfig, IControlMainform
{ {
// TODO: UI flow that conveniently allows to start from savestate // TODO: UI flow that conveniently allows to start from savestate
public TasMovie CurrentTasMovie { get { return Global.MovieSession.Movie as TasMovie; } } public TasMovie CurrentTasMovie => Global.MovieSession.Movie as TasMovie;
public MainForm Mainform { get { return GlobalWin.MainForm; } } private MainForm Mainform => GlobalWin.MainForm;
public bool IsInMenuLoop { get; private set; } public bool IsInMenuLoop { get; private set; }
public string statesPath { get { public string StatesPath => PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null);
return PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null); } }
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>(); private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
private const string CursorColumnName = "CursorColumn"; private const string CursorColumnName = "CursorColumn";
private const string FrameColumnName = "FrameColumn"; private const string FrameColumnName = "FrameColumn";
@ -34,16 +36,16 @@ namespace BizHawk.Client.EmuHawk
private Timer _autosaveTimer; private Timer _autosaveTimer;
/// <summary> /// <summary>
/// Separates "restore last position" logic from seeking caused by navigation. /// Gets or sets a value that separates "restore last position" logic from seeking caused by navigation.
/// TASEditor never kills LastPositionFrame, and it only pauses on it, if it hasn't been greenzoned beforehand and middle mouse button was pressed. /// TASEditor never kills LastPositionFrame, and it only pauses on it, if it hasn't been greenzoned beforehand and middle mouse button was pressed.
/// </summary> /// </summary>
public int LastPositionFrame { get; set; } public int LastPositionFrame { get; private set; }
private Dictionary<string, string> GenerateColumnNames() private Dictionary<string, string> GenerateColumnNames()
{ {
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.MovieSession.MovieControllerAdapter); lg.SetSource(Global.MovieSession.MovieControllerAdapter);
return (lg as Bk2LogEntryGenerator).Map(); return ((Bk2LogEntryGenerator)lg).Map();
} }
[ConfigPersist] [ConfigPersist]
@ -68,6 +70,7 @@ namespace BizHawk.Client.EmuHawk
AutosaveAsBackupFile = false; AutosaveAsBackupFile = false;
BackupPerFileSave = false; BackupPerFileSave = false;
SingleClickFloatEdit = false; SingleClickFloatEdit = false;
// default to taseditor fashion // default to taseditor fashion
DenoteStatesWithIcons = false; DenoteStatesWithIcons = false;
DenoteStatesWithBGColor = true; DenoteStatesWithBGColor = true;
@ -75,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
DenoteMarkersWithBGColor = true; DenoteMarkersWithBGColor = true;
} }
public RecentFiles RecentTas { get; set; } public RecentFiles RecentTas { get; }
public bool DrawInput { get; set; } public bool DrawInput { get; set; }
public bool AutoPause { get; set; } public bool AutoPause { get; set; }
public bool AutoRestoreLastPosition { get; set; } public bool AutoRestoreLastPosition { get; set; }
@ -100,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
public int BranchMarkerSplitDistance { get; set; } public int BranchMarkerSplitDistance { get; set; }
} }
#region "Initializing" #region Initializing
public TAStudio() public TAStudio()
{ {
@ -109,7 +112,7 @@ namespace BizHawk.Client.EmuHawk
InitializeSeekWorker(); InitializeSeekWorker();
// TODO: show this at all times or hide it when saving is done? // TODO: show this at all times or hide it when saving is done?
this.SavingProgressBar.Visible = false; SavingProgressBar.Visible = false;
WantsToControlStopMovie = true; WantsToControlStopMovie = true;
WantsToControlRestartMovie = true; WantsToControlRestartMovie = true;
@ -130,24 +133,36 @@ namespace BizHawk.Client.EmuHawk
private void AutosaveTimerEventProcessor(object sender, EventArgs e) private void AutosaveTimerEventProcessor(object sender, EventArgs e)
{ {
if (CurrentTasMovie == null) if (CurrentTasMovie == null)
{
return; return;
}
if (!CurrentTasMovie.Changes || Settings.AutosaveInterval == 0) if (!CurrentTasMovie.Changes || Settings.AutosaveInterval == 0)
{
return; return;
}
if (Settings.AutosaveAsBackupFile) if (Settings.AutosaveAsBackupFile)
{ {
if (Settings.AutosaveAsBk2) if (Settings.AutosaveAsBk2)
{
SaveBk2BackupMenuItem_Click(sender, e); SaveBk2BackupMenuItem_Click(sender, e);
}
else else
{
SaveBackupMenuItem_Click(sender, e); SaveBackupMenuItem_Click(sender, e);
}
} }
else else
{ {
if (Settings.AutosaveAsBk2) if (Settings.AutosaveAsBk2)
{
ToBk2MenuItem_Click(sender, e); ToBk2MenuItem_Click(sender, e);
}
else else
{
SaveTas(sender, e); SaveTas(sender, e);
}
} }
} }
@ -159,15 +174,17 @@ namespace BizHawk.Client.EmuHawk
_seekBackgroundWorker = null; // Idk if this line is even useful. _seekBackgroundWorker = null; // Idk if this line is even useful.
} }
_seekBackgroundWorker = new BackgroundWorker(); _seekBackgroundWorker = new BackgroundWorker
_seekBackgroundWorker.WorkerReportsProgress = true; {
_seekBackgroundWorker.WorkerSupportsCancellation = true; WorkerReportsProgress = true,
WorkerSupportsCancellation = true
};
_seekBackgroundWorker.DoWork += (s, e) => _seekBackgroundWorker.DoWork += (s, e) =>
{ {
this.Invoke(() => this.MessageStatusLabel.Text = "Seeking..."); this.Invoke(() => MessageStatusLabel.Text = "Seeking...");
this.Invoke(() => this.SavingProgressBar.Visible = true); this.Invoke(() => SavingProgressBar.Visible = true);
for ( ; ; ) for (;;)
{ {
if (_seekBackgroundWorker.CancellationPending || !this.IsHandleCreated) if (_seekBackgroundWorker.CancellationPending || !this.IsHandleCreated)
{ {
@ -180,9 +197,14 @@ namespace BizHawk.Client.EmuHawk
double progress = 0; double progress = 0;
if (diff != 0 && unit != 0) if (diff != 0 && unit != 0)
{
progress = (double)100d / unit * diff; progress = (double)100d / unit * diff;
}
if (progress < 0) if (progress < 0)
{
progress = 0; progress = 0;
}
_seekBackgroundWorker.ReportProgress((int)progress); _seekBackgroundWorker.ReportProgress((int)progress);
System.Threading.Thread.Sleep(1); System.Threading.Thread.Sleep(1);
@ -191,18 +213,18 @@ namespace BizHawk.Client.EmuHawk
_seekBackgroundWorker.ProgressChanged += (s, e) => _seekBackgroundWorker.ProgressChanged += (s, e) =>
{ {
this.Invoke(() => this.SavingProgressBar.Value = e.ProgressPercentage); this.Invoke(() => SavingProgressBar.Value = e.ProgressPercentage);
}; };
_seekBackgroundWorker.RunWorkerCompleted += (s, e) => _seekBackgroundWorker.RunWorkerCompleted += (s, e) =>
{ {
this.Invoke(() => this.SavingProgressBar.Visible = false); this.Invoke(() => SavingProgressBar.Visible = false);
this.Invoke(() => this.MessageStatusLabel.Text = ""); this.Invoke(() => MessageStatusLabel.Text = "");
InitializeSeekWorker(); // Required, or it will error when trying to report progress again. InitializeSeekWorker(); // Required, or it will error when trying to report progress again.
}; };
} }
private bool _initialized = false; private bool _initialized;
private void Tastudio_Load(object sender, EventArgs e) private void Tastudio_Load(object sender, EventArgs e)
{ {
if (!InitializeOnLoad()) if (!InitializeOnLoad())
@ -279,9 +301,9 @@ namespace BizHawk.Client.EmuHawk
Mainform.PauseEmulator(); Mainform.PauseEmulator();
// Start Scenario 0: bsnes in performance mode (copied from RecordMovieMenuItem_Click()) // Start Scenario 0: bsnes in performance mode (copied from RecordMovieMenuItem_Click())
if (Emulator is BizHawk.Emulation.Cores.Nintendo.SNES.LibsnesCore) if (Emulator is LibsnesCore)
{ {
var snes = (BizHawk.Emulation.Cores.Nintendo.SNES.LibsnesCore)Emulator; var snes = (LibsnesCore)Emulator;
if (snes.CurrentProfile == "Performance") if (snes.CurrentProfile == "Performance")
{ {
var box = new CustomControls.MsgBox( var box = new CustomControls.MsgBox(
@ -362,7 +384,10 @@ namespace BizHawk.Client.EmuHawk
private void SetTasMovieCallbacks(TasMovie movie = null) private void SetTasMovieCallbacks(TasMovie movie = null)
{ {
if (movie == null) if (movie == null)
{
movie = CurrentTasMovie; movie = CurrentTasMovie;
}
movie.ClientSettingsForSave = ClientSettingsForSave; movie.ClientSettingsForSave = ClientSettingsForSave;
movie.GetClientSettingsOnLoad = GetClientSettingsOnLoad; movie.GetClientSettingsOnLoad = GetClientSettingsOnLoad;
} }
@ -384,13 +409,13 @@ namespace BizHawk.Client.EmuHawk
AddColumn(FrameColumnName, "Frame#", 68); AddColumn(FrameColumnName, "Frame#", 68);
var columnNames = GenerateColumnNames(); var columnNames = GenerateColumnNames();
InputRoll.RollColumn.InputType type;
int digits = 1;
foreach (var kvp in columnNames) foreach (var kvp in columnNames)
{ {
InputRoll.RollColumn.InputType type;
int digits;
if (Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.Contains(kvp.Key)) if (Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.Contains(kvp.Key))
{ {
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(kvp.Key)]; [Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(kvp.Key)];
type = InputRoll.RollColumn.InputType.Float; type = InputRoll.RollColumn.InputType.Float;
digits = Math.Max(kvp.Value.Length, range.MaxDigits()); digits = Math.Max(kvp.Value.Length, range.MaxDigits());
@ -400,21 +425,21 @@ namespace BizHawk.Client.EmuHawk
type = InputRoll.RollColumn.InputType.Boolean; type = InputRoll.RollColumn.InputType.Boolean;
digits = kvp.Value.Length; digits = kvp.Value.Length;
} }
AddColumn(kvp.Key, kvp.Value, (digits * 6) + 14, type); // magic numbers reused in EditBranchTextPopUp() AddColumn(kvp.Key, kvp.Value, (digits * 6) + 14, type); // magic numbers reused in EditBranchTextPopUp()
} }
var columnsToHide = TasView.AllColumns var columnsToHide = TasView.AllColumns
.Where(c => .Where(c =>
// todo: make a proper user editable list? // todo: make a proper user editable list?
c.Name == "Power" || c.Name == "Power"
c.Name == "Reset" || || c.Name == "Reset"
c.Name == "Light Sensor" || || c.Name == "Light Sensor"
c.Name == "Open" || || c.Name == "Open"
c.Name == "Close" || || c.Name == "Close"
c.Name == "Disc Select" || || c.Name == "Disc Select"
c.Name.StartsWith("Tilt") || || c.Name.StartsWith("Tilt")
c.Name.StartsWith("Key ") || c.Name.StartsWith("Key "));
);
foreach (var column in columnsToHide) foreach (var column in columnsToHide)
{ {
@ -428,34 +453,39 @@ namespace BizHawk.Client.EmuHawk
int fStart = 0; int fStart = 0;
if (BoolPatterns == null) if (BoolPatterns == null)
{ {
BoolPatterns = new AutoPatternBool[controllerType.BoolButtons.Count + 2]; BoolPatterns = new AutoPatternBool[ControllerType.BoolButtons.Count + 2];
FloatPatterns = new AutoPatternFloat[controllerType.FloatControls.Count + 2]; FloatPatterns = new AutoPatternFloat[ControllerType.FloatControls.Count + 2];
} }
else else
{ {
bStart = BoolPatterns.Length - 2; bStart = BoolPatterns.Length - 2;
fStart = FloatPatterns.Length - 2; fStart = FloatPatterns.Length - 2;
Array.Resize(ref BoolPatterns, controllerType.BoolButtons.Count + 2); Array.Resize(ref BoolPatterns, ControllerType.BoolButtons.Count + 2);
Array.Resize(ref FloatPatterns, controllerType.FloatControls.Count + 2); Array.Resize(ref FloatPatterns, ControllerType.FloatControls.Count + 2);
} }
for (int i = bStart; i < BoolPatterns.Length - 2; i++) for (int i = bStart; i < BoolPatterns.Length - 2; i++)
{
BoolPatterns[i] = new AutoPatternBool(1, 1); BoolPatterns[i] = new AutoPatternBool(1, 1);
}
BoolPatterns[BoolPatterns.Length - 2] = new AutoPatternBool(1, 0); BoolPatterns[BoolPatterns.Length - 2] = new AutoPatternBool(1, 0);
BoolPatterns[BoolPatterns.Length - 1] = new AutoPatternBool( BoolPatterns[BoolPatterns.Length - 1] = new AutoPatternBool(
Global.Config.AutofireOn, Global.Config.AutofireOff); Global.Config.AutofireOn, Global.Config.AutofireOff);
for (int i = fStart; i < FloatPatterns.Length - 2; i++) for (int i = fStart; i < FloatPatterns.Length - 2; i++)
FloatPatterns[i] = new AutoPatternFloat(new float[] { 1f }); {
FloatPatterns[FloatPatterns.Length - 2] = new AutoPatternFloat(new float[] { 1f }); FloatPatterns[i] = new AutoPatternFloat(new[] { 1f });
}
FloatPatterns[FloatPatterns.Length - 2] = new AutoPatternFloat(new[] { 1f });
FloatPatterns[FloatPatterns.Length - 1] = new AutoPatternFloat( FloatPatterns[FloatPatterns.Length - 1] = new AutoPatternFloat(
1f, Global.Config.AutofireOn, 0f, Global.Config.AutofireOff); 1f, Global.Config.AutofireOn, 0f, Global.Config.AutofireOff);
SetUpToolStripColumns(); SetUpToolStripColumns();
} }
public void AddColumn(string columnName, string columnText, int columnWidth, InputRoll.RollColumn.InputType columnType = InputRoll.RollColumn.InputType.Boolean) private void AddColumn(string columnName, string columnText, int columnWidth, InputRoll.RollColumn.InputType columnType = InputRoll.RollColumn.InputType.Boolean)
{ {
if (TasView.AllColumns[columnName] == null) if (TasView.AllColumns[columnName] == null)
{ {
@ -487,7 +517,7 @@ namespace BizHawk.Client.EmuHawk
#endregion #endregion
#region "Loading" #region Loading
private void ConvertCurrentMovieToTasproj() private void ConvertCurrentMovieToTasproj()
{ {
@ -511,23 +541,35 @@ namespace BizHawk.Client.EmuHawk
newMovie.Filename = file.FullName; newMovie.Filename = file.FullName;
if (!HandleMovieLoadStuff(newMovie)) if (!HandleMovieLoadStuff(newMovie))
{
return false; return false;
}
Settings.RecentTas.Add(newMovie.Filename); // only add if it did load Settings.RecentTas.Add(newMovie.Filename); // only add if it did load
if (startsFromSavestate) if (startsFromSavestate)
{
GoToFrame(0); GoToFrame(0);
}
else if (gotoFrame > 0) else if (gotoFrame > 0)
{
GoToFrame(gotoFrame); GoToFrame(gotoFrame);
}
else else
{
GoToFrame(CurrentTasMovie.Session.CurrentFrame); GoToFrame(CurrentTasMovie.Session.CurrentFrame);
}
if (TasView.AllColumns.Count == 0 || file.Extension != "." + TasMovie.Extension) if (TasView.AllColumns.Count == 0 || file.Extension != "." + TasMovie.Extension)
{
SetUpColumns(); SetUpColumns();
}
else else
{
SetUpToolStripColumns(); SetUpToolStripColumns();
}
CurrentTasMovie.PropertyChanged += new PropertyChangedEventHandler(this.TasMovie_OnPropertyChanged); CurrentTasMovie.PropertyChanged += TasMovie_OnPropertyChanged;
CurrentTasMovie.CurrentBranch = CurrentTasMovie.Session.CurrentBranch; CurrentTasMovie.CurrentBranch = CurrentTasMovie.Session.CurrentBranch;
BookMarkControl.UpdateTextColumnWidth(); BookMarkControl.UpdateTextColumnWidth();
@ -545,16 +587,17 @@ namespace BizHawk.Client.EmuHawk
if (AskSaveChanges()) if (AskSaveChanges())
{ {
Global.MovieSession.Movie = new TasMovie(false, _seekBackgroundWorker); Global.MovieSession.Movie = new TasMovie(false, _seekBackgroundWorker);
var stateManager = (Global.MovieSession.Movie as TasMovie).TasStateManager; var stateManager = ((TasMovie)Global.MovieSession.Movie).TasStateManager;
stateManager.MountWriteAccess(); stateManager.MountWriteAccess();
stateManager.InvalidateCallback = GreenzoneInvalidated; stateManager.InvalidateCallback = GreenzoneInvalidated;
CurrentTasMovie.PropertyChanged += new PropertyChangedEventHandler(this.TasMovie_OnPropertyChanged); CurrentTasMovie.PropertyChanged += TasMovie_OnPropertyChanged;
CurrentTasMovie.Filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename CurrentTasMovie.Filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename
CurrentTasMovie.PopulateWithDefaultHeaderValues(); CurrentTasMovie.PopulateWithDefaultHeaderValues();
SetTasMovieCallbacks(); SetTasMovieCallbacks();
CurrentTasMovie.ClearChanges(); // Don't ask to save changes here. CurrentTasMovie.ClearChanges(); // Don't ask to save changes here.
HandleMovieLoadStuff(); HandleMovieLoadStuff();
CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always. CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always.
// clear all selections // clear all selections
TasView.DeselectAll(); TasView.DeselectAll();
BookMarkControl.Restart(); BookMarkControl.Restart();
@ -580,7 +623,9 @@ namespace BizHawk.Client.EmuHawk
} }
if (!result) if (!result)
{
return false; return false;
}
WantsToControlStopMovie = true; WantsToControlStopMovie = true;
@ -598,7 +643,9 @@ namespace BizHawk.Client.EmuHawk
_initializing = true; _initializing = true;
if (movie == null) if (movie == null)
{
movie = CurrentTasMovie; movie = CurrentTasMovie;
}
SetTasMovieCallbacks(movie as TasMovie); SetTasMovieCallbacks(movie as TasMovie);
@ -609,7 +656,7 @@ namespace BizHawk.Client.EmuHawk
BookMarkControl.UpdateTextColumnWidth(); BookMarkControl.UpdateTextColumnWidth();
} }
TastudioPlayMode(); TastudioPlayMode();
_initializing = false; _initializing = false;
@ -619,20 +666,23 @@ namespace BizHawk.Client.EmuHawk
private void DummyLoadProject(string path) private void DummyLoadProject(string path)
{ {
if (AskSaveChanges()) if (AskSaveChanges())
{
LoadFile(new FileInfo(path)); LoadFile(new FileInfo(path));
}
} }
private void DummyLoadMacro(string path) private void DummyLoadMacro(string path)
{ {
if (!TasView.AnyRowsSelected) if (!TasView.AnyRowsSelected)
return;
MovieZone loadZone = new MovieZone(path);
if (loadZone != null)
{ {
loadZone.Start = TasView.FirstSelectedIndex.Value; return;
loadZone.PlaceZone(CurrentTasMovie);
} }
MovieZone loadZone = new MovieZone(path)
{
Start = TasView.FirstSelectedIndex.Value
};
loadZone.PlaceZone(CurrentTasMovie);
} }
private void SetColumnsFromCurrentStickies() private void SetColumnsFromCurrentStickies()
@ -672,9 +722,10 @@ namespace BizHawk.Client.EmuHawk
Mainform.TakeBackControl(); Mainform.TakeBackControl();
Global.Config.MovieEndAction = _originalEndAction; Global.Config.MovieEndAction = _originalEndAction;
Mainform.SetMainformMovieInfo(); Mainform.SetMainformMovieInfo();
// Do not keep TAStudio's disk save states. // Do not keep TAStudio's disk save states.
//if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true); // if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true);
//TODO - do we need to dispose something here instead? // TODO - do we need to dispose something here instead?
} }
/// <summary> /// <summary>
@ -690,7 +741,6 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// Used for things like SaveFile dialogs to suggest a name to the user /// Used for things like SaveFile dialogs to suggest a name to the user
/// </summary> /// </summary>
/// <returns></returns>
private static string SuggestedTasProjName() private static string SuggestedTasProjName()
{ {
return Path.Combine( return Path.Combine(
@ -706,7 +756,7 @@ namespace BizHawk.Client.EmuHawk
text += " - " + CurrentTasMovie.Name + (CurrentTasMovie.Changes ? "*" : ""); text += " - " + CurrentTasMovie.Name + (CurrentTasMovie.Changes ? "*" : "");
} }
if (this.InvokeRequired) if (InvokeRequired)
{ {
this.Invoke(() => Text = text); this.Invoke(() => Text = text);
} }
@ -724,32 +774,39 @@ namespace BizHawk.Client.EmuHawk
public void RefreshDialog(bool refreshTasView = true) public void RefreshDialog(bool refreshTasView = true)
{ {
if (_exiting) if (_exiting)
{
return; return;
}
if (refreshTasView) if (refreshTasView)
{
RefreshTasView(); RefreshTasView();
}
if (MarkerControl != null) MarkerControl?.UpdateValues();
MarkerControl.UpdateValues();
if (BookMarkControl != null) BookMarkControl?.UpdateValues();
BookMarkControl.UpdateValues();
if (_undoForm != null && !_undoForm.IsDisposed) if (_undoForm != null && !_undoForm.IsDisposed)
{
_undoForm.UpdateValues(); _undoForm.UpdateValues();
}
} }
private void RefreshTasView() private void RefreshTasView()
{ {
CurrentTasMovie.UseInputCache = true; CurrentTasMovie.UseInputCache = true;
if (TasView.RowCount != CurrentTasMovie.InputLogLength + 1) if (TasView.RowCount != CurrentTasMovie.InputLogLength + 1)
{
TasView.RowCount = CurrentTasMovie.InputLogLength + 1; TasView.RowCount = CurrentTasMovie.InputLogLength + 1;
}
TasView.Refresh(); TasView.Refresh();
CurrentTasMovie.FlushInputCache(); CurrentTasMovie.FlushInputCache();
CurrentTasMovie.UseInputCache = false; CurrentTasMovie.UseInputCache = false;
lastRefresh = Emulator.Frame; _lastRefresh = Emulator.Frame;
} }
private void DoAutoRestore() private void DoAutoRestore()
@ -768,9 +825,9 @@ namespace BizHawk.Client.EmuHawk
// this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses // this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses
Mainform.UnpauseEmulator(); Mainform.UnpauseEmulator();
} }
_autoRestorePaused = null; _autoRestorePaused = null;
} }
//_autoRestoreFrame = null;
} }
private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRewinding) private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRewinding)
@ -790,25 +847,31 @@ namespace BizHawk.Client.EmuHawk
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = Mainform.EmulatorPaused;
//why not use this? because I'm not letting the form freely run. it all has to be under this loop. // why not use this? because I'm not letting the form freely run. it all has to be under this loop.
//i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing // i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing
//PauseOnFrame = frame; // PauseOnFrame = frame;
//can't re-enter lua while doing this // can't re-enter lua while doing this
Mainform.SuppressLua = true; Mainform.SuppressLua = true;
while (Emulator.Frame != frame) while (Emulator.Frame != frame)
{
Mainform.SeekFrameAdvance(); Mainform.SeekFrameAdvance();
}
Mainform.SuppressLua = false; Mainform.SuppressLua = false;
if(!wasPaused) Mainform.UnpauseEmulator(); if (!wasPaused)
{
Mainform.UnpauseEmulator();
}
//lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened // lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened
if (WasRecording) if (WasRecording)
{ {
TastudioRecordMode(); TastudioRecordMode();
} }
//now the next section won't happen since we're at the right spot // now the next section won't happen since we're at the right spot
} }
// frame == Emulator.Frame when frame == 0 // frame == Emulator.Frame when frame == 0
@ -820,9 +883,9 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
//GUI users may want to be protected from clobbering their video when skipping around... // GUI users may want to be protected from clobbering their video when skipping around...
//well, users who are rewinding arent. (that gets done through the seeking system in the call above) // well, users who are rewinding arent. (that gets done through the seeking system in the call above)
//users who are clicking around.. I dont know. // users who are clicking around.. I dont know.
} }
} }
} }
@ -937,7 +1000,9 @@ namespace BizHawk.Client.EmuHawk
private void Tastudio_Closing(object sender, FormClosingEventArgs e) private void Tastudio_Closing(object sender, FormClosingEventArgs e)
{ {
if (!_initialized) if (!_initialized)
{
return; return;
}
_exiting = true; _exiting = true;
@ -953,12 +1018,11 @@ namespace BizHawk.Client.EmuHawk
_exiting = false; _exiting = false;
} }
if (_undoForm != null) _undoForm?.Close();
_undoForm.Close();
} }
/// <summary> /// <summary>
/// This method is called everytime the Changes property is toggled on a TasMovie instance. /// This method is called every time the Changes property is toggled on a <see cref="TasMovie"/> instance.
/// </summary> /// </summary>
private void TasMovie_OnPropertyChanged(object sender, PropertyChangedEventArgs e) private void TasMovie_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
@ -969,10 +1033,13 @@ namespace BizHawk.Client.EmuHawk
{ {
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
} }
private void TAStudio_DragDrop(object sender, DragEventArgs e) private void TAStudio_DragDrop(object sender, DragEventArgs e)
{ {
if (!AskSaveChanges()) if (!AskSaveChanges())
{
return; return;
}
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(filePaths[0]) == "." + TasMovie.Extension) if (Path.GetExtension(filePaths[0]) == "." + TasMovie.Extension)
@ -992,9 +1059,9 @@ namespace BizHawk.Client.EmuHawk
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{ {
if (keyData == Keys.Tab || if (keyData == Keys.Tab
keyData == (Keys.Shift | Keys.Tab) || || keyData == (Keys.Shift | Keys.Tab)
keyData == Keys.Space) || keyData == Keys.Space)
{ {
return true; return true;
} }
@ -1012,7 +1079,8 @@ namespace BizHawk.Client.EmuHawk
if (lagLog.WasLagged.HasValue) if (lagLog.WasLagged.HasValue)
{ {
if (lagLog.WasLagged.Value && !isLag) if (lagLog.WasLagged.Value && !isLag)
{ // Deleting this frame requires rewinding a frame. {
// Deleting this frame requires rewinding a frame.
CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, "Bind Input; Delete " + (Emulator.Frame - 1)); CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, "Bind Input; Delete " + (Emulator.Frame - 1));
bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording; bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording;
CurrentTasMovie.ChangeLog.IsRecording = false; CurrentTasMovie.ChangeLog.IsRecording = false;
@ -1059,8 +1127,7 @@ namespace BizHawk.Client.EmuHawk
private void TasView_CellDropped(object sender, InputRoll.CellEventArgs e) private void TasView_CellDropped(object sender, InputRoll.CellEventArgs e)
{ {
if (e.NewCell != null && e.NewCell.RowIndex.HasValue && if (e.NewCell?.RowIndex != null && !CurrentTasMovie.Markers.IsMarker(e.NewCell.RowIndex.Value))
!CurrentTasMovie.Markers.IsMarker(e.NewCell.RowIndex.Value))
{ {
var currentMarker = CurrentTasMovie.Markers.Single(m => m.Frame == e.OldCell.RowIndex.Value); var currentMarker = CurrentTasMovie.Markers.Single(m => m.Frame == e.OldCell.RowIndex.Value);
int newFrame = e.NewCell.RowIndex.Value; int newFrame = e.NewCell.RowIndex.Value;

View File

@ -95,14 +95,14 @@
this.undoHereToolStripMenuItem.Name = "undoHereToolStripMenuItem"; this.undoHereToolStripMenuItem.Name = "undoHereToolStripMenuItem";
this.undoHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22); this.undoHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
this.undoHereToolStripMenuItem.Text = "Undo To Selection"; this.undoHereToolStripMenuItem.Text = "Undo To Selection";
this.undoHereToolStripMenuItem.Click += new System.EventHandler(this.undoHereToolStripMenuItem_Click); this.undoHereToolStripMenuItem.Click += new System.EventHandler(this.UndoHereMenuItem_Click);
// //
// redoHereToolStripMenuItem // redoHereToolStripMenuItem
// //
this.redoHereToolStripMenuItem.Name = "redoHereToolStripMenuItem"; this.redoHereToolStripMenuItem.Name = "redoHereToolStripMenuItem";
this.redoHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22); this.redoHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
this.redoHereToolStripMenuItem.Text = "Redo To Selection"; this.redoHereToolStripMenuItem.Text = "Redo To Selection";
this.redoHereToolStripMenuItem.Click += new System.EventHandler(this.redoHereToolStripMenuItem_Click); this.redoHereToolStripMenuItem.Click += new System.EventHandler(this.RedoHereMenuItem_Click);
// //
// sepToolStripMenuItem // sepToolStripMenuItem
// //
@ -114,7 +114,7 @@
this.clearHistoryToHereToolStripMenuItem.Name = "clearHistoryToHereToolStripMenuItem"; this.clearHistoryToHereToolStripMenuItem.Name = "clearHistoryToHereToolStripMenuItem";
this.clearHistoryToHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22); this.clearHistoryToHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
this.clearHistoryToHereToolStripMenuItem.Text = "Clear History To Selection"; this.clearHistoryToHereToolStripMenuItem.Text = "Clear History To Selection";
this.clearHistoryToHereToolStripMenuItem.Click += new System.EventHandler(this.clearHistoryToHereToolStripMenuItem_Click); this.clearHistoryToHereToolStripMenuItem.Click += new System.EventHandler(this.ClearHistoryToHereMenuItem_Click);
// //
// AutoScrollCheck // AutoScrollCheck
// //

View File

@ -1,150 +1,171 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class UndoHistoryForm : Form public partial class UndoHistoryForm : Form
{ {
private TAStudio tastudio; private readonly TAStudio _tastudio;
private string _lastUndoAction;
private TasMovieChangeLog Log => _tastudio.CurrentTasMovie.ChangeLog;
public UndoHistoryForm(TAStudio owner) public UndoHistoryForm(TAStudio owner)
{ {
InitializeComponent(); InitializeComponent();
tastudio = owner; _tastudio = owner;
HistoryView.QueryItemText += HistoryView_QueryItemText; HistoryView.QueryItemText += HistoryView_QueryItemText;
HistoryView.QueryItemBkColor += HistoryView_QueryItemBkColor; HistoryView.QueryItemBkColor += HistoryView_QueryItemBkColor;
HistoryView.Columns[1].Width = 280; HistoryView.Columns[1].Width = 280;
MaxStepsNum.Value = log.MaxSteps; MaxStepsNum.Value = Log.MaxSteps;
}
private Common.TasMovieChangeLog log
{
get { return tastudio.CurrentTasMovie.ChangeLog; }
} }
private void HistoryView_QueryItemText(int row, int column, out string text) private void HistoryView_QueryItemText(int row, int column, out string text)
{ {
if (column == 1) text = column == 1
text = log.Names[row]; ? Log.Names[row]
else : row.ToString();
text = row.ToString();
} }
private void HistoryView_QueryItemBkColor(int row, int column, ref Color color) private void HistoryView_QueryItemBkColor(int row, int column, ref Color color)
{ {
if (column == 0) if (column == 0)
{
return; return;
}
if (row == log.UndoIndex) if (row == Log.UndoIndex)
{
color = TAStudio.GreenZone_InputLog; color = TAStudio.GreenZone_InputLog;
else if (row > log.UndoIndex) }
else if (row > Log.UndoIndex)
{
color = TAStudio.LagZone_InputLog; color = TAStudio.LagZone_InputLog;
}
} }
private string _lastUndoAction = null;
public void UpdateValues() public void UpdateValues()
{ {
HistoryView.ItemCount = log.Names.Count; HistoryView.ItemCount = Log.Names.Count;
if (AutoScrollCheck.Checked && _lastUndoAction != log.NextUndoStepName) if (AutoScrollCheck.Checked && _lastUndoAction != Log.NextUndoStepName)
{ {
HistoryView.ensureVisible(log.UndoIndex); HistoryView.ensureVisible(Log.UndoIndex);
HistoryView.clearSelection(); HistoryView.clearSelection();
HistoryView.SelectItem(log.UndoIndex - 1, true); HistoryView.SelectItem(Log.UndoIndex - 1, true);
} }
_lastUndoAction = log.NextUndoStepName;
_lastUndoAction = Log.NextUndoStepName;
HistoryView.Refresh(); HistoryView.Refresh();
} }
private void ClearButton_Click(object sender, EventArgs e) private void ClearButton_Click(object sender, EventArgs e)
{ {
log.ClearLog(); Log.ClearLog();
UpdateValues(); UpdateValues();
} }
private void UndoButton_Click(object sender, EventArgs e) private void UndoButton_Click(object sender, EventArgs e)
{ {
log.Undo(); Log.Undo();
tastudio.RefreshDialog(); _tastudio.RefreshDialog();
}
private void RedoButton_Click(object sender, EventArgs e)
{
log.Redo();
tastudio.RefreshDialog();
} }
private void RedoButton_Click(object sender, EventArgs e)
{
Log.Redo();
_tastudio.RefreshDialog();
}
private void HistoryView_DoubleClick(object sender, EventArgs e) private void HistoryView_DoubleClick(object sender, EventArgs e)
{ {
if (log.UndoIndex <= HistoryView.selectedItem) if (Log.UndoIndex <= HistoryView.selectedItem)
{
return; return;
}
do do
{ {
log.Undo(); Log.Undo();
} while (log.UndoIndex > HistoryView.selectedItem); }
while (Log.UndoIndex > HistoryView.selectedItem);
UpdateValues(); UpdateValues();
} }
private void HistoryView_MouseUp(object sender, MouseEventArgs e) private void HistoryView_MouseUp(object sender, MouseEventArgs e)
{ {
if (e.Button == System.Windows.Forms.MouseButtons.Right) if (e.Button == MouseButtons.Right)
{
RightClickMenu.Show(HistoryView, e.X, e.Y); RightClickMenu.Show(HistoryView, e.X, e.Y);
else if (e.Button == System.Windows.Forms.MouseButtons.Left) }
else if (e.Button == MouseButtons.Left)
{ {
if (HistoryView.selectedItem == -1) if (HistoryView.selectedItem == -1)
{
HistoryView.SelectItem(_hackSelect, true); HistoryView.SelectItem(_hackSelect, true);
}
} }
} }
// Hacky way to select a row by clicking the names row // Hacky way to select a row by clicking the names row
int _hackSelect = -1; private int _hackSelect = -1;
private void HistoryView_MouseDown(object sender, MouseEventArgs e) private void HistoryView_MouseDown(object sender, MouseEventArgs e)
{ {
HistoryView.SelectItem(e.Y / HistoryView.LineHeight + HistoryView.VScrollPos - 1, true); HistoryView.SelectItem((e.Y / HistoryView.LineHeight) + HistoryView.VScrollPos - 1, true);
_hackSelect = HistoryView.selectedItem; _hackSelect = HistoryView.selectedItem;
} }
private void undoHereToolStripMenuItem_Click(object sender, EventArgs e) private void UndoHereMenuItem_Click(object sender, EventArgs e)
{ {
if (HistoryView.selectedItem == -1 || log.UndoIndex < HistoryView.selectedItem) if (HistoryView.selectedItem == -1 || Log.UndoIndex < HistoryView.selectedItem)
{
return; return;
}
do do
{ {
log.Undo(); Log.Undo();
} while (log.UndoIndex >= HistoryView.selectedItem); }
while (Log.UndoIndex >= HistoryView.selectedItem);
UpdateValues(); UpdateValues();
} }
private void redoHereToolStripMenuItem_Click(object sender, EventArgs e)
private void RedoHereMenuItem_Click(object sender, EventArgs e)
{ {
if (HistoryView.selectedItem == -1 || log.UndoIndex >= HistoryView.selectedItem) if (HistoryView.selectedItem == -1 || Log.UndoIndex >= HistoryView.selectedItem)
{
return; return;
}
do do
{ {
log.Redo(); Log.Redo();
} while (log.UndoIndex < HistoryView.selectedItem); }
while (Log.UndoIndex < HistoryView.selectedItem);
UpdateValues(); UpdateValues();
} }
private void clearHistoryToHereToolStripMenuItem_Click(object sender, EventArgs e)
private void ClearHistoryToHereMenuItem_Click(object sender, EventArgs e)
{ {
if (HistoryView.selectedItem != -1) if (HistoryView.selectedItem != -1)
log.ClearLog(HistoryView.selectedItem); {
Log.ClearLog(HistoryView.selectedItem);
}
UpdateValues(); UpdateValues();
} }
private void MaxStepsNum_ValueChanged(object sender, EventArgs e) private void MaxStepsNum_ValueChanged(object sender, EventArgs e)
{ {
log.MaxSteps = (int)MaxStepsNum.Value; Log.MaxSteps = (int)MaxStepsNum.Value;
} }
} }
} }