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

View File

@ -1,10 +1,4 @@
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;
namespace BizHawk.Client.EmuHawk
@ -16,10 +10,7 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent();
}
public int Frames
{
get { return NumFramesBox.ToRawInt() ?? 0; }
}
public int Frames => NumFramesBox.ToRawInt() ?? 0;
private void FramesPrompt_Load(object sender, EventArgs e)
{

View File

@ -1,14 +1,7 @@
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 BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
@ -17,11 +10,12 @@ namespace BizHawk.Client.EmuHawk
{
public IStatable Statable { get; set; }
private readonly TasStateManagerSettings Settings;
private readonly TasStateManagerSettings _settings;
private decimal _stateSizeMb;
public StateHistorySettingsForm(TasStateManagerSettings settings)
{
Settings = settings;
_settings = settings;
InitializeComponent();
}
@ -30,38 +24,38 @@ namespace BizHawk.Client.EmuHawk
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
if (Environment.Is64BitProcess) // ?
{
MemCapacityNumeric.Maximum = 1024 * 8;
}
else
{
MemCapacityNumeric.Maximum = 1024;
}
MemCapacityNumeric.Value = Settings.Capacitymb < MemCapacityNumeric.Maximum ?
Settings.Capacitymb : MemCapacityNumeric.Maximum;
DiskCapacityNumeric.Value = Settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
Settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
SaveCapacityNumeric.Value = Settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
Settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
MemCapacityNumeric.Value = _settings.Capacitymb < MemCapacityNumeric.Maximum ?
_settings.Capacitymb : MemCapacityNumeric.Maximum;
DiskCapacityNumeric.Value = _settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
_settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
SaveCapacityNumeric.Value = _settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
_settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
StateGap.Value = Settings.StateGap;
StateGap.Value = _settings.StateGap;
SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb";
CapacityNumeric_ValueChanged(null, null);
SaveCapacityNumeric_ValueChanged(null, null);
BranchStatesInTasproj.Checked = Settings.BranchStatesInTasproj;
EraseBranchStatesFirst.Checked = Settings.EraseBranchStatesFirst;
BranchStatesInTasproj.Checked = _settings.BranchStatesInTasproj;
EraseBranchStatesFirst.Checked = _settings.EraseBranchStatesFirst;
}
private int MaxStatesInCapacity
{
get { return (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
+ (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
}
}
private int MaxStatesInCapacity => (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
+ (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
private void OkBtn_Click(object sender, EventArgs e)
{
Settings.Capacitymb = (int)MemCapacityNumeric.Value;
Settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value;
Settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value;
Settings.StateGap = (int)StateGap.Value;
_settings.Capacitymb = (int)MemCapacityNumeric.Value;
_settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value;
_settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value;
_settings.StateGap = (int)StateGap.Value;
DialogResult = DialogResult.OK;
Close();
}
@ -86,17 +80,19 @@ namespace BizHawk.Client.EmuHawk
private void BranchStatesInTasproj_CheckedChanged(object sender, EventArgs e)
{
Settings.BranchStatesInTasproj = BranchStatesInTasproj.Checked;
_settings.BranchStatesInTasproj = BranchStatesInTasproj.Checked;
}
private void EraseBranchStatesFIrst_CheckedChanged(object sender, EventArgs e)
{
Settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked;
_settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked;
}
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.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
@ -13,36 +7,37 @@ namespace BizHawk.Client.EmuHawk
{
public partial class MovieHeaderEditor : Form
{
private readonly IMovie Movie;
private readonly IMovie _movie;
public MovieHeaderEditor(IMovie movie)
{
Movie = movie;
_movie = movie;
InitializeComponent();
}
private void MovieHeaderEditor_Load(object sender, EventArgs e)
{
AuthorTextBox.Text = Movie.Author;
EmulatorVersionTextBox.Text = Movie.EmulatorVersion;
PlatformTextBox.Text = Movie.SystemID;
CoreTextBox.Text = Movie.Core;
BoardNameTextBox.Text = Movie.BoardName;
GameNameTextBox.Text = Movie.GameName;
AuthorTextBox.Text = _movie.Author;
EmulatorVersionTextBox.Text = _movie.EmulatorVersion;
PlatformTextBox.Text = _movie.SystemID;
CoreTextBox.Text = _movie.Core;
BoardNameTextBox.Text = _movie.BoardName;
GameNameTextBox.Text = _movie.GameName;
}
private void OkBtn_Click(object sender, EventArgs e)
{
Movie.Author = AuthorTextBox.Text;
_movie.Author = AuthorTextBox.Text;
if (MakeDefaultCheckbox.Checked)
{
Global.Config.DefaultAuthor = AuthorTextBox.Text;
}
Movie.EmulatorVersion = EmulatorVersionTextBox.Text;
Movie.SystemID = PlatformTextBox.Text;
Movie.Core = CoreTextBox.Text;
Movie.BoardName = BoardNameTextBox.Text;
Movie.GameName = GameNameTextBox.Text;
_movie.EmulatorVersion = EmulatorVersionTextBox.Text;
_movie.SystemID = PlatformTextBox.Text;
_movie.Core = CoreTextBox.Text;
_movie.BoardName = BoardNameTextBox.Text;
_movie.GameName = GameNameTextBox.Text;
DialogResult = DialogResult.OK;
Close();

View File

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

View File

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

View File

@ -1,10 +1,5 @@
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 BizHawk.Client.Common;
@ -18,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
public TAStudio Tastudio { get; set; }
[Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool TurboSeek
{
get
@ -33,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
}
[Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool AutoRestore
{
get
@ -48,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
}
[Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool FollowCursor
{
get
@ -63,7 +58,7 @@ namespace BizHawk.Client.EmuHawk
}
[Browsable(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool RecordingMode
{
get
@ -83,6 +78,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.MovieSession.Movie.SwitchToPlay();
}
GlobalWin.MainForm.SetMainformMovieInfo();
}
}
@ -191,7 +187,5 @@ namespace BizHawk.Client.EmuHawk
{
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
// 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.Drawing;
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
{
public partial class ScreenshotForm : Form
{
private Timer _showTimer = new Timer();
private Timer _hideTimer = new Timer();
private int _widthCap = 320;
private int _heightCap = 240;
private int _interval = 40;
private double _alphaStep = 0.125;
public TasBranch Branch { get; set; }
public FontStyle FontStyle;
public int FontSize;
public int DrawingHeight;
{
// but still appear topmost
private const int WS_EX_TOPMOST = 0x00000008;
private const int WidthCap = 320;
private const int HeightCap = 240;
private const int Interval = 40;
private const double AlphaStep = 0.125;
private readonly Timer _showTimer = new Timer();
private readonly Timer _hideTimer = new Timer();
private TasBranch _branch;
private int _drawingHeight;
new public Font Font;
new public int Padding;
new public string Text;
@ -35,67 +33,73 @@ namespace BizHawk.Client.EmuHawk
{
InitializeComponent();
Width = _widthCap;
Height = _heightCap;
FontSize = 10;
FontStyle = FontStyle.Regular;
Font = new Font(FontFamily.GenericMonospace, FontSize, FontStyle);
DrawingHeight = 0;
Width = WidthCap;
Height = HeightCap;
var fontSize = 10;
var fontStyle = FontStyle.Regular;
Font = new Font(FontFamily.GenericMonospace, fontSize, fontStyle);
_drawingHeight = 0;
Padding = 0;
Opacity = 0;
_showTimer.Interval = _interval;
_showTimer.Tick += new EventHandler((sender, e) =>
_showTimer.Interval = Interval;
_showTimer.Tick += (sender, e) =>
{
if ((Opacity += _alphaStep) >= 1)
if ((Opacity += AlphaStep) >= 1)
{
_showTimer.Stop();
});
}
};
_hideTimer.Interval = _interval;
_hideTimer.Tick += new EventHandler((sender, e) =>
_hideTimer.Interval = Interval;
_hideTimer.Tick += (sender, e) =>
{
if ((Opacity -= _alphaStep) <= 0)
if ((Opacity -= AlphaStep) <= 0)
{
_hideTimer.Stop();
Hide();
}
});
};
}
public void UpdateValues(TasBranch branch, Point location , int width, int height, int padding)
{
Branch = branch;
_branch = branch;
Width = width;
Padding = padding;
DrawingHeight = height;
Text = Branch.UserText;
_drawingHeight = height;
Text = _branch.UserText;
Location = location;
// 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
if (Width > _widthCap)
if (Width > WidthCap)
{
double ratio = (double)_widthCap / (double)Width;
Width = _widthCap;
DrawingHeight = (int)((double)(DrawingHeight) * ratio);
double ratio = WidthCap / (double)Width;
Width = WidthCap;
_drawingHeight = (int)((double)(_drawingHeight) * ratio);
}
if (Padding > 0)
{
Padding += 2;
Height = DrawingHeight + Padding;
}
Height = _drawingHeight + Padding;
Refresh();
}
protected override void OnPaint(PaintEventArgs e)
{
Branch.OSDFrameBuffer.DiscardAlpha();
var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap();
e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, DrawingHeight));
_branch.OSDFrameBuffer.DiscardAlpha();
var bitmap = _branch.OSDFrameBuffer.ToSysdrawingBitmap();
e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, _drawingHeight));
if (Padding > 0)
{
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.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));
}
base.OnPaint(e);
}
@ -115,13 +119,8 @@ namespace BizHawk.Client.EmuHawk
}
// avoid stealing focus
protected override bool ShowWithoutActivation
{
get { return true; }
}
protected override bool ShowWithoutActivation => true;
// but still appear topmost
private const int WS_EX_TOPMOST = 0x00000008;
protected override CreateParams CreateParams
{
get

View File

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

View File

@ -348,14 +348,14 @@ namespace BizHawk.Client.EmuHawk
this.saveSelectionToMacroToolStripMenuItem.Name = "saveSelectionToMacroToolStripMenuItem";
this.saveSelectionToMacroToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
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
//
this.placeMacroAtSelectionToolStripMenuItem.Name = "placeMacroAtSelectionToolStripMenuItem";
this.placeMacroAtSelectionToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
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
//
@ -365,7 +365,7 @@ namespace BizHawk.Client.EmuHawk
this.recentMacrosToolStripMenuItem.Name = "recentMacrosToolStripMenuItem";
this.recentMacrosToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.recentMacrosToolStripMenuItem.Text = "Recent Macros";
this.recentMacrosToolStripMenuItem.DropDownOpened += new System.EventHandler(this.recentMacrosToolStripMenuItem_DropDownOpened);
this.recentMacrosToolStripMenuItem.DropDownOpened += new System.EventHandler(this.RecentMacrosMenuItem_DropDownOpened);
//
// toolStripSeparator22
//
@ -453,7 +453,7 @@ namespace BizHawk.Client.EmuHawk
this.showUndoHistoryToolStripMenuItem.Name = "showUndoHistoryToolStripMenuItem";
this.showUndoHistoryToolStripMenuItem.Size = new System.Drawing.Size(291, 22);
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
//
@ -753,7 +753,7 @@ namespace BizHawk.Client.EmuHawk
this.applyPatternToPaintedInputToolStripMenuItem.Name = "applyPatternToPaintedInputToolStripMenuItem";
this.applyPatternToPaintedInputToolStripMenuItem.Size = new System.Drawing.Size(255, 22);
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
//
@ -872,7 +872,7 @@ namespace BizHawk.Client.EmuHawk
this.autoHoldToolStripMenuItem.Name = "autoHoldToolStripMenuItem";
this.autoHoldToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.autoHoldToolStripMenuItem.Text = "Auto-Hold";
this.autoHoldToolStripMenuItem.CheckedChanged += new System.EventHandler(this.autoHoldToolStripMenuItem_CheckedChanged);
this.autoHoldToolStripMenuItem.CheckedChanged += new System.EventHandler(this.AutoHoldMenuItem_CheckedChanged);
//
// autoFireToolStripMenuItem
//
@ -880,7 +880,7 @@ namespace BizHawk.Client.EmuHawk
this.autoFireToolStripMenuItem.Name = "autoFireToolStripMenuItem";
this.autoFireToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.autoFireToolStripMenuItem.Text = "Auto-Fire";
this.autoFireToolStripMenuItem.CheckedChanged += new System.EventHandler(this.autoFireToolStripMenuItem_CheckedChanged);
this.autoFireToolStripMenuItem.CheckedChanged += new System.EventHandler(this.AutoFireMenuItem_CheckedChanged);
//
// customPatternToolStripMenuItem
//
@ -888,7 +888,7 @@ namespace BizHawk.Client.EmuHawk
this.customPatternToolStripMenuItem.Name = "customPatternToolStripMenuItem";
this.customPatternToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.customPatternToolStripMenuItem.Text = "Custom Pattern";
this.customPatternToolStripMenuItem.CheckedChanged += new System.EventHandler(this.customPatternToolStripMenuItem_CheckedChanged);
this.customPatternToolStripMenuItem.CheckedChanged += new System.EventHandler(this.CustomPatternMenuItem_CheckedChanged);
//
// setpToolStripMenuItem
//
@ -900,7 +900,7 @@ namespace BizHawk.Client.EmuHawk
this.setCustomsToolStripMenuItem.Name = "setCustomsToolStripMenuItem";
this.setCustomsToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.setCustomsToolStripMenuItem.Text = "Set Customs...";
this.setCustomsToolStripMenuItem.Click += new System.EventHandler(this.setCustomsToolStripMenuItem_Click);
this.setCustomsToolStripMenuItem.Click += new System.EventHandler(this.SetCustomsMenuItem_Click);
//
// MetaSubMenu
//
@ -1039,7 +1039,7 @@ namespace BizHawk.Client.EmuHawk
this.hideWasLagFramesToolStripMenuItem.Name = "hideWasLagFramesToolStripMenuItem";
this.hideWasLagFramesToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
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
//
@ -1051,7 +1051,7 @@ namespace BizHawk.Client.EmuHawk
this.iconsToolStripMenuItem.Name = "iconsToolStripMenuItem";
this.iconsToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.iconsToolStripMenuItem.Text = "Icons";
this.iconsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.iconsToolStripMenuItem_DropDownOpened);
this.iconsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.IconsMenuItem_DropDownOpened);
//
// DenoteStatesWithIconsToolStripMenuItem
//
@ -1102,7 +1102,7 @@ namespace BizHawk.Client.EmuHawk
this.followCursorToolStripMenuItem.Name = "followCursorToolStripMenuItem";
this.followCursorToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.followCursorToolStripMenuItem.Text = "Follow Cursor";
this.followCursorToolStripMenuItem.DropDownOpened += new System.EventHandler(this.followCursorToolStripMenuItem_DropDownOpened);
this.followCursorToolStripMenuItem.DropDownOpened += new System.EventHandler(this.FollowCursorMenuItem_DropDownOpened);
//
// alwaysScrollToolStripMenuItem
//
@ -1110,7 +1110,7 @@ namespace BizHawk.Client.EmuHawk
this.alwaysScrollToolStripMenuItem.Name = "alwaysScrollToolStripMenuItem";
this.alwaysScrollToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.alwaysScrollToolStripMenuItem.Text = "Always Scroll";
this.alwaysScrollToolStripMenuItem.Click += new System.EventHandler(this.alwaysScrollToolStripMenuItem_Click);
this.alwaysScrollToolStripMenuItem.Click += new System.EventHandler(this.AlwaysScrollMenuItem_Click);
//
// toolStripSeparator24
//
@ -1125,7 +1125,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToViewToolStripMenuItem.Name = "scrollToViewToolStripMenuItem";
this.scrollToViewToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
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
//
@ -1133,7 +1133,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToTopToolStripMenuItem.Name = "scrollToTopToolStripMenuItem";
this.scrollToTopToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
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
//
@ -1141,7 +1141,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToBottomToolStripMenuItem.Name = "scrollToBottomToolStripMenuItem";
this.scrollToBottomToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
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
//
@ -1149,7 +1149,7 @@ namespace BizHawk.Client.EmuHawk
this.scrollToCenterToolStripMenuItem.Name = "scrollToCenterToolStripMenuItem";
this.scrollToCenterToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
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
//
@ -1161,7 +1161,7 @@ namespace BizHawk.Client.EmuHawk
this.wheelScrollSpeedToolStripMenuItem.Name = "wheelScrollSpeedToolStripMenuItem";
this.wheelScrollSpeedToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
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
//

View File

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

View File

@ -1,7 +1,6 @@
using System.Windows.Forms;
using BizHawk.Client.Common;
using System.Collections.Generic;
using System;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
@ -23,33 +22,46 @@ namespace BizHawk.Client.EmuHawk
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
public bool UpdateBefore { get { return false; } }
public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { }
private int lastRefresh = 0;
private int _lastRefresh;
public void UpdateValues()
{
if (!IsHandleCreated || IsDisposed || CurrentTasMovie == null)
{
return;
}
if (_hackyDontUpdate)
{
return;
}
if (_exiting)
{
return;
}
bool refreshNeeded = false;
if (AutoadjustInputMenuItem.Checked)
{
refreshNeeded = AutoAdjustInput();
}
if (TasView.RowCount != CurrentTasMovie.InputLogLength + 1)
{
TasView.RowCount = CurrentTasMovie.InputLogLength + 1;
}
MaybeFollowCursor();
if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(lastRefresh))
if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(_lastRefresh))
{
refreshNeeded = true;
}
RefreshDialog(refreshNeeded);
}

View File

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

View File

@ -25,7 +25,6 @@ namespace BizHawk.Client.EmuHawk
SaveTASMenuItem.Enabled =
!string.IsNullOrWhiteSpace(CurrentTasMovie.Filename) &&
(CurrentTasMovie.Filename != DefaultTasProjName());
}
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)
{
if (string.IsNullOrEmpty(CurrentTasMovie.Filename) ||
CurrentTasMovie.Filename == DefaultTasProjName())
if (string.IsNullOrEmpty(CurrentTasMovie.Filename)
|| CurrentTasMovie.Filename == DefaultTasProjName())
{
SaveAsTas(sender, e);
}
@ -106,14 +105,17 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop();
GlobalWin.Sound.StopSound();
MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor;
Cursor = Cursors.WaitCursor;
Update();
CurrentTasMovie.Save();
if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start();
}
MessageStatusLabel.Text = CurrentTasMovie.Name + " saved.";
Settings.RecentTas.Add(CurrentTasMovie.Filename);
this.Cursor = Cursors.Default;
Cursor = Cursors.Default;
GlobalWin.Sound.StartSound();
}
}
@ -123,7 +125,9 @@ namespace BizHawk.Client.EmuHawk
{
SaveTas(sender, e);
if (Settings.BackupPerFileSave)
{
SaveBackupMenuItem_Click(sender, e);
}
}
private void SaveAsTas(object sender, EventArgs e)
@ -147,17 +151,21 @@ namespace BizHawk.Client.EmuHawk
{
CurrentTasMovie.Filename = file.FullName;
MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor;
Cursor = Cursors.WaitCursor;
Update();
CurrentTasMovie.Save();
Settings.RecentTas.Add(CurrentTasMovie.Filename);
SetTextProperty();
MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.";
this.Cursor = Cursors.Default;
Cursor = Cursors.Default;
}
// keep insisting
if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start();
}
GlobalWin.Sound.StartSound();
}
@ -166,13 +174,15 @@ namespace BizHawk.Client.EmuHawk
{
SaveAsTas(sender, e);
if (Settings.BackupPerFileSave)
{
SaveBackupMenuItem_Click(sender, e);
}
}
private void SaveBackupMenuItem_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(CurrentTasMovie.Filename) ||
CurrentTasMovie.Filename == DefaultTasProjName())
if (string.IsNullOrEmpty(CurrentTasMovie.Filename)
|| CurrentTasMovie.Filename == DefaultTasProjName())
{
SaveAsTas(sender, e);
}
@ -181,14 +191,17 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop();
GlobalWin.Sound.StopSound();
MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor;
Cursor = Cursors.WaitCursor;
Update();
CurrentTasMovie.SaveBackup();
if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start();
}
MessageStatusLabel.Text = "Backup .tasproj saved to \"Movie backups\" path.";
Settings.RecentTas.Add(CurrentTasMovie.Filename);
this.Cursor = Cursors.Default;
Cursor = Cursors.Default;
GlobalWin.Sound.StartSound();
}
}
@ -198,31 +211,41 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop();
var bk2 = CurrentTasMovie.ToBk2(copy: true, backup: true);
MessageStatusLabel.Text = "Exporting to .bk2...";
this.Cursor = Cursors.WaitCursor;
Cursor = Cursors.WaitCursor;
Update();
bk2.SaveBackup();
if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start();
}
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)
{
TasView.SelectRow(CurrentTasMovie.InputLogLength, false);
}
if (!TasView.AnyRowsSelected)
{
return;
}
MovieZone macro = new MovieZone(CurrentTasMovie, TasView.FirstSelectedIndex.Value,
TasView.LastSelectedIndex.Value - TasView.FirstSelectedIndex.Value + 1);
MacroInputTool.SaveMacroAs(macro);
}
private void placeMacroAtSelectionToolStripMenuItem_Click(object sender, EventArgs e)
private void PlaceMacroAtSelectionMenuItem_Click(object sender, EventArgs e)
{
if (!TasView.AnyRowsSelected)
{
return;
}
MovieZone macro = MacroInputTool.LoadMacro();
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.AddRange(Global.Config.RecentMacros.RecentMenu(DummyLoadMacro));
@ -243,13 +266,16 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Stop();
var bk2 = CurrentTasMovie.ToBk2(true);
MessageStatusLabel.Text = "Exporting to .bk2...";
this.Cursor = Cursors.WaitCursor;
Cursor = Cursors.WaitCursor;
Update();
bk2.Save();
if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Start();
}
MessageStatusLabel.Text = bk2.Name + " exported.";
this.Cursor = Cursors.Default;
Cursor = Cursors.Default;
}
private void ExitMenuItem_Click(object sender, EventArgs e)
@ -313,30 +339,38 @@ namespace BizHawk.Client.EmuHawk
private void UndoMenuItem_Click(object sender, EventArgs e)
{
if (CurrentTasMovie.ChangeLog.Undo() < Emulator.Frame)
{
GoToFrame(CurrentTasMovie.ChangeLog.PreviousUndoFrame);
}
else
{
RefreshDialog();
}
// 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;
}
private void RedoMenuItem_Click(object sender, EventArgs e)
{
if (CurrentTasMovie.ChangeLog.Redo() < Emulator.Frame)
{
GoToFrame(CurrentTasMovie.ChangeLog.PreviousRedoFrame);
}
else
{
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;
}
private void showUndoHistoryToolStripMenuItem_Click(object sender, EventArgs e)
private void ShowUndoHistoryMenuItem_Click(object sender, EventArgs e)
{
_undoForm = new UndoHistoryForm(this);
_undoForm.Owner = this;
_undoForm = new UndoHistoryForm(this) { Owner = this };
_undoForm.Show();
_undoForm.UpdateValues();
}
@ -360,13 +394,14 @@ namespace BizHawk.Client.EmuHawk
var prevMarker = CurrentTasMovie.Markers.PreviousOrCurrent(TasView.LastSelectedIndex.Value);
var nextMarker = CurrentTasMovie.Markers.Next(TasView.LastSelectedIndex.Value);
int prev = prevMarker != null ? prevMarker.Frame : 0;
int next = nextMarker != null ? nextMarker.Frame : CurrentTasMovie.InputLogLength;
int prev = prevMarker?.Frame ?? 0;
int next = nextMarker?.Frame ?? CurrentTasMovie.InputLogLength;
for (int i = prev; i < next; i++)
{
TasView.SelectRow(i, true);
}
SetSplicer();
RefreshTasView();
}
@ -379,6 +414,7 @@ namespace BizHawk.Client.EmuHawk
{
TasView.SelectRow(item.Frame, true);
}
SetSplicer();
RefreshTasView();
}
@ -395,7 +431,10 @@ namespace BizHawk.Client.EmuHawk
{
var input = CurrentTasMovie.GetInputState(index);
if (input == null)
{
break;
}
_tasClipboard.Add(new TasClipboardEntry(index, input));
var lg = CurrentTasMovie.LogGeneratorInstance();
lg.SetSource(input);
@ -411,7 +450,6 @@ namespace BizHawk.Client.EmuHawk
{
// 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
var wasPaused = Mainform.EmulatorPaused;
// copypaste from PasteInsertMenuItem_Click!
@ -429,9 +467,13 @@ namespace BizHawk.Client.EmuHawk
{
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
if (line == null)
{
return;
}
else
{
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
}
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -469,9 +511,13 @@ namespace BizHawk.Client.EmuHawk
{
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
if (line == null)
{
return;
}
else
{
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
}
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -506,7 +552,10 @@ namespace BizHawk.Client.EmuHawk
{
var input = CurrentTasMovie.GetInputState(index);
if (input == null)
{
break;
}
_tasClipboard.Add(new TasClipboardEntry(index, input));
var lg = CurrentTasMovie.LogGeneratorInstance();
lg.SetSource(input);
@ -516,7 +565,7 @@ namespace BizHawk.Client.EmuHawk
Clipboard.SetDataObject(sb.ToString());
CurrentTasMovie.RemoveFrames(list);
SetSplicer();
//TasView.DeselectAll(); feos: what if I want to continuously cut?
////TasView.DeselectAll(); feos: what if I want to continuously cut?
if (needsToRollback)
{
@ -543,6 +592,7 @@ namespace BizHawk.Client.EmuHawk
{
CurrentTasMovie.ClearFrame(frame);
}
CurrentTasMovie.ChangeLog.EndBatch();
if (needsToRollback)
@ -564,7 +614,8 @@ namespace BizHawk.Client.EmuHawk
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
var rollBackFrame = TasView.FirstSelectedIndex.Value;
if (rollBackFrame >= CurrentTasMovie.InputLogLength)
{ // Cannot delete non-existant frames
{
// Cannot delete non-existant frames
RefreshDialog();
return;
}
@ -634,7 +685,7 @@ namespace BizHawk.Client.EmuHawk
{
int insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0;
FramesPrompt framesPrompt = new FramesPrompt();
var framesPrompt = new FramesPrompt();
DialogResult result = framesPrompt.ShowDialog();
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);
if (result != DialogResult.OK)
{
return;
}
}
foreach (var index in TasView.SelectedRows)
{
MarkerControl.AddMarker(false, index);
@ -689,6 +743,7 @@ namespace BizHawk.Client.EmuHawk
{
CurrentTasMovie.Markers.Remove(m);
}
RefreshDialog();
}
@ -702,9 +757,10 @@ namespace BizHawk.Client.EmuHawk
{
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)
== System.Windows.Forms.DialogResult.No)
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)
{
return;
}
}
GoToFrame(0);
@ -727,7 +783,8 @@ namespace BizHawk.Client.EmuHawk
lastState = Emulator.Frame;
}
} while (Emulator.Frame < goToFrame);
}
while (Emulator.Frame < goToFrame);
MessageBox.Show("Integrity Check passed");
}
@ -762,7 +819,9 @@ namespace BizHawk.Client.EmuHawk
{
int val = int.Parse(prompt.PromptText);
if (val > 0)
{
CurrentTasMovie.ChangeLog.MaxSteps = val;
}
}
}
}
@ -854,7 +913,7 @@ namespace BizHawk.Client.EmuHawk
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;
}
@ -884,7 +943,7 @@ namespace BizHawk.Client.EmuHawk
Settings.AutoRestoreOnMouseUpOnly ^= true;
}
private void autoHoldToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
private void AutoHoldMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (autoHoldToolStripMenuItem.Checked)
{
@ -892,10 +951,13 @@ namespace BizHawk.Client.EmuHawk
customPatternToolStripMenuItem.Checked = false;
if (!keepSetPatternsToolStripMenuItem.Checked)
{
UpdateAutoFire();
}
}
}
private void autoFireToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
private void AutoFireMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (autoFireToolStripMenuItem.Checked)
{
@ -903,10 +965,13 @@ namespace BizHawk.Client.EmuHawk
customPatternToolStripMenuItem.Checked = false;
if (!keepSetPatternsToolStripMenuItem.Checked)
{
UpdateAutoFire();
}
}
}
private void customPatternToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
private void CustomPatternMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (customPatternToolStripMenuItem.Checked)
{
@ -914,15 +979,17 @@ namespace BizHawk.Client.EmuHawk
autoFireToolStripMenuItem.Checked = false;
if (!keepSetPatternsToolStripMenuItem.Checked)
{
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 UndoForm are caught, which makes it weirder.
PatternsForm pForm = new PatternsForm(this);
pForm.Owner = this;
var pForm = new PatternsForm(this) { Owner = this };
pForm.Show();
}
@ -993,7 +1060,7 @@ namespace BizHawk.Client.EmuHawk
hideWasLagFramesToolStripMenuItem.Checked = TasView.HideWasLagFrames;
}
private void iconsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
private void IconsMenuItem_DropDownOpened(object sender, EventArgs e)
{
DenoteStatesWithIconsToolStripMenuItem.Checked = Settings.DenoteStatesWithIcons;
DenoteStatesWithBGColorToolStripMenuItem.Checked = Settings.DenoteStatesWithBGColor;
@ -1001,7 +1068,7 @@ namespace BizHawk.Client.EmuHawk
DenoteMarkersWithBGColorToolStripMenuItem.Checked = Settings.DenoteMarkersWithBGColor;
}
private void followCursorToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
private void FollowCursorMenuItem_DropDownOpened(object sender, EventArgs e)
{
alwaysScrollToolStripMenuItem.Checked = Settings.FollowCursorAlwaysScroll;
scrollToViewToolStripMenuItem.Checked = false;
@ -1009,13 +1076,21 @@ namespace BizHawk.Client.EmuHawk
scrollToBottomToolStripMenuItem.Checked = false;
scrollToCenterToolStripMenuItem.Checked = false;
if (TasView.ScrollMethod == "near")
{
scrollToViewToolStripMenuItem.Checked = true;
}
else if (TasView.ScrollMethod == "top")
{
scrollToTopToolStripMenuItem.Checked = true;
}
else if (TasView.ScrollMethod == "bottom")
{
scrollToBottomToolStripMenuItem.Checked = true;
}
else
{
scrollToCenterToolStripMenuItem.Checked = true;
}
}
private void RotateMenuItem_Click(object sender, EventArgs e)
@ -1031,32 +1106,32 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog();
}
private void hideWasLagFramesToolStripMenuItem_Click(object sender, EventArgs e)
private void HideWasLagFramesMenuItem_Click(object sender, EventArgs e)
{
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;
}
private void scrollToViewToolStripMenuItem_Click(object sender, EventArgs e)
private void ScrollToViewMenuItem_Click(object sender, EventArgs e)
{
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";
}
private void scrollToBottomToolStripMenuItem_Click(object sender, EventArgs e)
private void ScrollToBottomMenuItem_Click(object sender, EventArgs e)
{
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";
}
@ -1085,18 +1160,19 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog();
}
private void wheelScrollSpeedToolStripMenuItem_Click(object sender, EventArgs e)
private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e)
{
InputPrompt inputpromt = new InputPrompt();
inputpromt.TextInputType = InputPrompt.InputType.Unsigned;
inputpromt.Message = "Frames per tick:";
inputpromt.InitialValue = TasView.ScrollSpeed.ToString();
if (inputpromt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
var inputpromt = new InputPrompt
{
TextInputType = InputPrompt.InputType.Unsigned,
Message = "Frames per tick:",
InitialValue = TasView.ScrollSpeed.ToString()
};
if (inputpromt.ShowDialog() == DialogResult.OK)
{
TasView.ScrollSpeed = int.Parse(inputpromt.PromptText);
Settings.ScrollSpeed = TasView.ScrollSpeed;
}
}
#endregion
@ -1117,7 +1193,6 @@ namespace BizHawk.Client.EmuHawk
{
playerMenus[i] = new ToolStripMenuItem("Player " + i);
}
int player = 0;
foreach (InputRoll.RollColumn column in columns)
{
@ -1140,6 +1215,7 @@ namespace BizHawk.Client.EmuHawk
(sender.OwnerItem as ToolStripMenuItem).ShowDropDown();
};
int player;
if (column.Name.StartsWith("P") && column.Name.Length > 1 && char.IsNumber(column.Name, 1))
{
player = int.Parse(column.Name[1].ToString());
@ -1153,14 +1229,18 @@ namespace BizHawk.Client.EmuHawk
}
for (int i = 1; i < playerMenus.Length; i++)
{
ColumnsSubMenu.DropDownItems.Add(playerMenus[i]);
}
ColumnsSubMenu.DropDownItems.Add(new ToolStripSeparator());
for (int i = 1; i < playerMenus.Length; i++)
{
ToolStripMenuItem item = new ToolStripMenuItem("Show Player " + i);
item.CheckOnClick = true;
item.Checked = true;
var item = new ToolStripMenuItem("Show Player " + i)
{
CheckOnClick = true,
Checked = true
};
int dummyInt = i;
ToolStripMenuItem dummyObject = playerMenus[i];
@ -1217,7 +1297,6 @@ namespace BizHawk.Client.EmuHawk
TruncateContextMenuItem.Enabled =
TasView.AnyRowsSelected;
StartNewProjectFromNowMenuItem.Visible =
TasView.SelectedRows.Count() == 1
&& TasView.SelectedRows.Contains(Emulator.Frame)
@ -1228,7 +1307,7 @@ namespace BizHawk.Client.EmuHawk
&& SaveRamEmulator != null
&& !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).
CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue;
BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame;

View File

@ -1,7 +1,4 @@
using System.Linq;
using System.IO;
using BizHawk.Client.Common;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
@ -18,12 +15,13 @@ namespace BizHawk.Client.EmuHawk
if (frame <= Emulator.Frame)
{
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking) &&
!CurrentTasMovie.LastPositionStable)
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking)
&& !CurrentTasMovie.LastPositionStable)
{
LastPositionFrame = Emulator.Frame;
CurrentTasMovie.LastPositionStable = true; // until new frame is emulated
}
GoToFrame(frame);
}
}
@ -51,7 +49,9 @@ namespace BizHawk.Client.EmuHawk
bool wasPaused = Mainform.EmulatorPaused;
Mainform.FrameAdvance();
if (!wasPaused)
{
Mainform.UnpauseEmulator();
}
}
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]
if (lastState > Emulator.Frame)
{
LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS
}
StartSeeking(frame);
}
@ -87,7 +89,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator.Frame > 0)
{
var prevMarker = CurrentTasMovie.Markers.Previous(Emulator.Frame);
var prev = prevMarker != null ? prevMarker.Frame : 0;
var prev = prevMarker?.Frame ?? 0;
GoToFrame(prev);
}
}
@ -95,7 +97,7 @@ namespace BizHawk.Client.EmuHawk
public void GoToNextMarker()
{
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);
}
@ -110,7 +112,9 @@ namespace BizHawk.Client.EmuHawk
public void SetVisibleIndex(int? indexThatMustBeVisible = null)
{
if (!indexThatMustBeVisible.HasValue)
{
indexThatMustBeVisible = Emulator.Frame;
}
TasView.ScrollToIndex(indexThatMustBeVisible.Value);
}
@ -118,7 +122,9 @@ namespace BizHawk.Client.EmuHawk
private void MaybeFollowCursor()
{
if (TasPlaybackBox.FollowCursor)
{
SetVisibleIndex();
}
}
}
}

View File

@ -8,6 +8,7 @@ using System.ComponentModel;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Client.Common;
using BizHawk.Client.Common.MovieConversionExtensions;
@ -20,11 +21,12 @@ namespace BizHawk.Client.EmuHawk
public partial class TAStudio : ToolFormBase, IToolFormAutoConfig, IControlMainform
{
// TODO: UI flow that conveniently allows to start from savestate
public TasMovie CurrentTasMovie { get { return Global.MovieSession.Movie as TasMovie; } }
public MainForm Mainform { get { return GlobalWin.MainForm; } }
public TasMovie CurrentTasMovie => Global.MovieSession.Movie as TasMovie;
private MainForm Mainform => GlobalWin.MainForm;
public bool IsInMenuLoop { get; private set; }
public string statesPath { get {
return PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null); } }
public string StatesPath => PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null);
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
private const string CursorColumnName = "CursorColumn";
private const string FrameColumnName = "FrameColumn";
@ -34,16 +36,16 @@ namespace BizHawk.Client.EmuHawk
private Timer _autosaveTimer;
/// <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.
/// </summary>
public int LastPositionFrame { get; set; }
public int LastPositionFrame { get; private set; }
private Dictionary<string, string> GenerateColumnNames()
{
var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.MovieSession.MovieControllerAdapter);
return (lg as Bk2LogEntryGenerator).Map();
return ((Bk2LogEntryGenerator)lg).Map();
}
[ConfigPersist]
@ -68,6 +70,7 @@ namespace BizHawk.Client.EmuHawk
AutosaveAsBackupFile = false;
BackupPerFileSave = false;
SingleClickFloatEdit = false;
// default to taseditor fashion
DenoteStatesWithIcons = false;
DenoteStatesWithBGColor = true;
@ -75,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
DenoteMarkersWithBGColor = true;
}
public RecentFiles RecentTas { get; set; }
public RecentFiles RecentTas { get; }
public bool DrawInput { get; set; }
public bool AutoPause { get; set; }
public bool AutoRestoreLastPosition { get; set; }
@ -100,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
public int BranchMarkerSplitDistance { get; set; }
}
#region "Initializing"
#region Initializing
public TAStudio()
{
@ -109,7 +112,7 @@ namespace BizHawk.Client.EmuHawk
InitializeSeekWorker();
// TODO: show this at all times or hide it when saving is done?
this.SavingProgressBar.Visible = false;
SavingProgressBar.Visible = false;
WantsToControlStopMovie = true;
WantsToControlRestartMovie = true;
@ -130,24 +133,36 @@ namespace BizHawk.Client.EmuHawk
private void AutosaveTimerEventProcessor(object sender, EventArgs e)
{
if (CurrentTasMovie == null)
{
return;
}
if (!CurrentTasMovie.Changes || Settings.AutosaveInterval == 0)
{
return;
}
if (Settings.AutosaveAsBackupFile)
{
if (Settings.AutosaveAsBk2)
{
SaveBk2BackupMenuItem_Click(sender, e);
}
else
{
SaveBackupMenuItem_Click(sender, e);
}
}
else
{
if (Settings.AutosaveAsBk2)
{
ToBk2MenuItem_Click(sender, e);
}
else
{
SaveTas(sender, e);
}
}
}
@ -159,15 +174,17 @@ namespace BizHawk.Client.EmuHawk
_seekBackgroundWorker = null; // Idk if this line is even useful.
}
_seekBackgroundWorker = new BackgroundWorker();
_seekBackgroundWorker.WorkerReportsProgress = true;
_seekBackgroundWorker.WorkerSupportsCancellation = true;
_seekBackgroundWorker = new BackgroundWorker
{
WorkerReportsProgress = true,
WorkerSupportsCancellation = true
};
_seekBackgroundWorker.DoWork += (s, e) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = "Seeking...");
this.Invoke(() => this.SavingProgressBar.Visible = true);
for ( ; ; )
this.Invoke(() => MessageStatusLabel.Text = "Seeking...");
this.Invoke(() => SavingProgressBar.Visible = true);
for (;;)
{
if (_seekBackgroundWorker.CancellationPending || !this.IsHandleCreated)
{
@ -180,9 +197,14 @@ namespace BizHawk.Client.EmuHawk
double progress = 0;
if (diff != 0 && unit != 0)
{
progress = (double)100d / unit * diff;
}
if (progress < 0)
{
progress = 0;
}
_seekBackgroundWorker.ReportProgress((int)progress);
System.Threading.Thread.Sleep(1);
@ -191,18 +213,18 @@ namespace BizHawk.Client.EmuHawk
_seekBackgroundWorker.ProgressChanged += (s, e) =>
{
this.Invoke(() => this.SavingProgressBar.Value = e.ProgressPercentage);
this.Invoke(() => SavingProgressBar.Value = e.ProgressPercentage);
};
_seekBackgroundWorker.RunWorkerCompleted += (s, e) =>
{
this.Invoke(() => this.SavingProgressBar.Visible = false);
this.Invoke(() => this.MessageStatusLabel.Text = "");
this.Invoke(() => SavingProgressBar.Visible = false);
this.Invoke(() => MessageStatusLabel.Text = "");
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)
{
if (!InitializeOnLoad())
@ -279,9 +301,9 @@ namespace BizHawk.Client.EmuHawk
Mainform.PauseEmulator();
// 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")
{
var box = new CustomControls.MsgBox(
@ -362,7 +384,10 @@ namespace BizHawk.Client.EmuHawk
private void SetTasMovieCallbacks(TasMovie movie = null)
{
if (movie == null)
{
movie = CurrentTasMovie;
}
movie.ClientSettingsForSave = ClientSettingsForSave;
movie.GetClientSettingsOnLoad = GetClientSettingsOnLoad;
}
@ -384,13 +409,13 @@ namespace BizHawk.Client.EmuHawk
AddColumn(FrameColumnName, "Frame#", 68);
var columnNames = GenerateColumnNames();
InputRoll.RollColumn.InputType type;
int digits = 1;
foreach (var kvp in columnNames)
{
InputRoll.RollColumn.InputType type;
int digits;
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)];
type = InputRoll.RollColumn.InputType.Float;
digits = Math.Max(kvp.Value.Length, range.MaxDigits());
@ -400,21 +425,21 @@ namespace BizHawk.Client.EmuHawk
type = InputRoll.RollColumn.InputType.Boolean;
digits = kvp.Value.Length;
}
AddColumn(kvp.Key, kvp.Value, (digits * 6) + 14, type); // magic numbers reused in EditBranchTextPopUp()
}
var columnsToHide = TasView.AllColumns
.Where(c =>
// todo: make a proper user editable list?
c.Name == "Power" ||
c.Name == "Reset" ||
c.Name == "Light Sensor" ||
c.Name == "Open" ||
c.Name == "Close" ||
c.Name == "Disc Select" ||
c.Name.StartsWith("Tilt") ||
c.Name.StartsWith("Key ")
);
c.Name == "Power"
|| c.Name == "Reset"
|| c.Name == "Light Sensor"
|| c.Name == "Open"
|| c.Name == "Close"
|| c.Name == "Disc Select"
|| c.Name.StartsWith("Tilt")
|| c.Name.StartsWith("Key "));
foreach (var column in columnsToHide)
{
@ -428,34 +453,39 @@ namespace BizHawk.Client.EmuHawk
int fStart = 0;
if (BoolPatterns == null)
{
BoolPatterns = new AutoPatternBool[controllerType.BoolButtons.Count + 2];
FloatPatterns = new AutoPatternFloat[controllerType.FloatControls.Count + 2];
BoolPatterns = new AutoPatternBool[ControllerType.BoolButtons.Count + 2];
FloatPatterns = new AutoPatternFloat[ControllerType.FloatControls.Count + 2];
}
else
{
bStart = BoolPatterns.Length - 2;
fStart = FloatPatterns.Length - 2;
Array.Resize(ref BoolPatterns, controllerType.BoolButtons.Count + 2);
Array.Resize(ref FloatPatterns, controllerType.FloatControls.Count + 2);
Array.Resize(ref BoolPatterns, ControllerType.BoolButtons.Count + 2);
Array.Resize(ref FloatPatterns, ControllerType.FloatControls.Count + 2);
}
for (int i = bStart; i < BoolPatterns.Length - 2; i++)
{
BoolPatterns[i] = new AutoPatternBool(1, 1);
}
BoolPatterns[BoolPatterns.Length - 2] = new AutoPatternBool(1, 0);
BoolPatterns[BoolPatterns.Length - 1] = new AutoPatternBool(
Global.Config.AutofireOn, Global.Config.AutofireOff);
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(
1f, Global.Config.AutofireOn, 0f, Global.Config.AutofireOff);
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)
{
@ -487,7 +517,7 @@ namespace BizHawk.Client.EmuHawk
#endregion
#region "Loading"
#region Loading
private void ConvertCurrentMovieToTasproj()
{
@ -511,23 +541,35 @@ namespace BizHawk.Client.EmuHawk
newMovie.Filename = file.FullName;
if (!HandleMovieLoadStuff(newMovie))
{
return false;
}
Settings.RecentTas.Add(newMovie.Filename); // only add if it did load
if (startsFromSavestate)
{
GoToFrame(0);
}
else if (gotoFrame > 0)
{
GoToFrame(gotoFrame);
}
else
{
GoToFrame(CurrentTasMovie.Session.CurrentFrame);
}
if (TasView.AllColumns.Count == 0 || file.Extension != "." + TasMovie.Extension)
{
SetUpColumns();
}
else
{
SetUpToolStripColumns();
}
CurrentTasMovie.PropertyChanged += new PropertyChangedEventHandler(this.TasMovie_OnPropertyChanged);
CurrentTasMovie.PropertyChanged += TasMovie_OnPropertyChanged;
CurrentTasMovie.CurrentBranch = CurrentTasMovie.Session.CurrentBranch;
BookMarkControl.UpdateTextColumnWidth();
@ -545,16 +587,17 @@ namespace BizHawk.Client.EmuHawk
if (AskSaveChanges())
{
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.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.PopulateWithDefaultHeaderValues();
SetTasMovieCallbacks();
CurrentTasMovie.ClearChanges(); // Don't ask to save changes here.
HandleMovieLoadStuff();
CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always.
// clear all selections
TasView.DeselectAll();
BookMarkControl.Restart();
@ -580,7 +623,9 @@ namespace BizHawk.Client.EmuHawk
}
if (!result)
{
return false;
}
WantsToControlStopMovie = true;
@ -598,7 +643,9 @@ namespace BizHawk.Client.EmuHawk
_initializing = true;
if (movie == null)
{
movie = CurrentTasMovie;
}
SetTasMovieCallbacks(movie as TasMovie);
@ -609,7 +656,7 @@ namespace BizHawk.Client.EmuHawk
BookMarkControl.UpdateTextColumnWidth();
}
TastudioPlayMode();
TastudioPlayMode();
_initializing = false;
@ -619,20 +666,23 @@ namespace BizHawk.Client.EmuHawk
private void DummyLoadProject(string path)
{
if (AskSaveChanges())
{
LoadFile(new FileInfo(path));
}
}
private void DummyLoadMacro(string path)
{
if (!TasView.AnyRowsSelected)
return;
MovieZone loadZone = new MovieZone(path);
if (loadZone != null)
{
loadZone.Start = TasView.FirstSelectedIndex.Value;
loadZone.PlaceZone(CurrentTasMovie);
return;
}
MovieZone loadZone = new MovieZone(path)
{
Start = TasView.FirstSelectedIndex.Value
};
loadZone.PlaceZone(CurrentTasMovie);
}
private void SetColumnsFromCurrentStickies()
@ -672,9 +722,10 @@ namespace BizHawk.Client.EmuHawk
Mainform.TakeBackControl();
Global.Config.MovieEndAction = _originalEndAction;
Mainform.SetMainformMovieInfo();
// Do not keep TAStudio's disk save states.
//if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true);
//TODO - do we need to dispose something here instead?
// if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true);
// TODO - do we need to dispose something here instead?
}
/// <summary>
@ -690,7 +741,6 @@ namespace BizHawk.Client.EmuHawk
/// <summary>
/// Used for things like SaveFile dialogs to suggest a name to the user
/// </summary>
/// <returns></returns>
private static string SuggestedTasProjName()
{
return Path.Combine(
@ -706,7 +756,7 @@ namespace BizHawk.Client.EmuHawk
text += " - " + CurrentTasMovie.Name + (CurrentTasMovie.Changes ? "*" : "");
}
if (this.InvokeRequired)
if (InvokeRequired)
{
this.Invoke(() => Text = text);
}
@ -724,32 +774,39 @@ namespace BizHawk.Client.EmuHawk
public void RefreshDialog(bool refreshTasView = true)
{
if (_exiting)
{
return;
}
if (refreshTasView)
{
RefreshTasView();
}
if (MarkerControl != null)
MarkerControl.UpdateValues();
MarkerControl?.UpdateValues();
if (BookMarkControl != null)
BookMarkControl.UpdateValues();
BookMarkControl?.UpdateValues();
if (_undoForm != null && !_undoForm.IsDisposed)
{
_undoForm.UpdateValues();
}
}
private void RefreshTasView()
{
CurrentTasMovie.UseInputCache = true;
if (TasView.RowCount != CurrentTasMovie.InputLogLength + 1)
{
TasView.RowCount = CurrentTasMovie.InputLogLength + 1;
}
TasView.Refresh();
CurrentTasMovie.FlushInputCache();
CurrentTasMovie.UseInputCache = false;
lastRefresh = Emulator.Frame;
_lastRefresh = Emulator.Frame;
}
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
Mainform.UnpauseEmulator();
}
_autoRestorePaused = null;
}
//_autoRestoreFrame = null;
}
private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRewinding)
@ -790,25 +847,31 @@ namespace BizHawk.Client.EmuHawk
{
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.
//i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing
//PauseOnFrame = frame;
// 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
// PauseOnFrame = frame;
//can't re-enter lua while doing this
// can't re-enter lua while doing this
Mainform.SuppressLua = true;
while (Emulator.Frame != frame)
{
Mainform.SeekFrameAdvance();
}
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)
{
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
@ -820,9 +883,9 @@ namespace BizHawk.Client.EmuHawk
}
else
{
//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)
//users who are clicking around.. I dont know.
// 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)
// users who are clicking around.. I dont know.
}
}
}
@ -937,7 +1000,9 @@ namespace BizHawk.Client.EmuHawk
private void Tastudio_Closing(object sender, FormClosingEventArgs e)
{
if (!_initialized)
{
return;
}
_exiting = true;
@ -953,12 +1018,11 @@ namespace BizHawk.Client.EmuHawk
_exiting = false;
}
if (_undoForm != null)
_undoForm.Close();
_undoForm?.Close();
}
/// <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>
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;
}
private void TAStudio_DragDrop(object sender, DragEventArgs e)
{
if (!AskSaveChanges())
{
return;
}
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(filePaths[0]) == "." + TasMovie.Extension)
@ -992,9 +1059,9 @@ namespace BizHawk.Client.EmuHawk
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Tab ||
keyData == (Keys.Shift | Keys.Tab) ||
keyData == Keys.Space)
if (keyData == Keys.Tab
|| keyData == (Keys.Shift | Keys.Tab)
|| keyData == Keys.Space)
{
return true;
}
@ -1012,7 +1079,8 @@ namespace BizHawk.Client.EmuHawk
if (lagLog.WasLagged.HasValue)
{
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));
bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording;
CurrentTasMovie.ChangeLog.IsRecording = false;
@ -1059,8 +1127,7 @@ namespace BizHawk.Client.EmuHawk
private void TasView_CellDropped(object sender, InputRoll.CellEventArgs e)
{
if (e.NewCell != null && e.NewCell.RowIndex.HasValue &&
!CurrentTasMovie.Markers.IsMarker(e.NewCell.RowIndex.Value))
if (e.NewCell?.RowIndex != null && !CurrentTasMovie.Markers.IsMarker(e.NewCell.RowIndex.Value))
{
var currentMarker = CurrentTasMovie.Markers.Single(m => m.Frame == e.OldCell.RowIndex.Value);
int newFrame = e.NewCell.RowIndex.Value;

View File

@ -95,14 +95,14 @@
this.undoHereToolStripMenuItem.Name = "undoHereToolStripMenuItem";
this.undoHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
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
//
this.redoHereToolStripMenuItem.Name = "redoHereToolStripMenuItem";
this.redoHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
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
//
@ -114,7 +114,7 @@
this.clearHistoryToHereToolStripMenuItem.Name = "clearHistoryToHereToolStripMenuItem";
this.clearHistoryToHereToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
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
//

View File

@ -1,150 +1,171 @@
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 BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
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)
{
InitializeComponent();
tastudio = owner;
_tastudio = owner;
HistoryView.QueryItemText += HistoryView_QueryItemText;
HistoryView.QueryItemBkColor += HistoryView_QueryItemBkColor;
HistoryView.Columns[1].Width = 280;
MaxStepsNum.Value = log.MaxSteps;
}
private Common.TasMovieChangeLog log
{
get { return tastudio.CurrentTasMovie.ChangeLog; }
MaxStepsNum.Value = Log.MaxSteps;
}
private void HistoryView_QueryItemText(int row, int column, out string text)
{
if (column == 1)
text = log.Names[row];
else
text = row.ToString();
text = column == 1
? Log.Names[row]
: row.ToString();
}
private void HistoryView_QueryItemBkColor(int row, int column, ref Color color)
{
if (column == 0)
{
return;
}
if (row == log.UndoIndex)
if (row == Log.UndoIndex)
{
color = TAStudio.GreenZone_InputLog;
else if (row > log.UndoIndex)
}
else if (row > Log.UndoIndex)
{
color = TAStudio.LagZone_InputLog;
}
}
private string _lastUndoAction = null;
public void UpdateValues()
{
HistoryView.ItemCount = log.Names.Count;
if (AutoScrollCheck.Checked && _lastUndoAction != log.NextUndoStepName)
HistoryView.ItemCount = Log.Names.Count;
if (AutoScrollCheck.Checked && _lastUndoAction != Log.NextUndoStepName)
{
HistoryView.ensureVisible(log.UndoIndex);
HistoryView.ensureVisible(Log.UndoIndex);
HistoryView.clearSelection();
HistoryView.SelectItem(log.UndoIndex - 1, true);
HistoryView.SelectItem(Log.UndoIndex - 1, true);
}
_lastUndoAction = log.NextUndoStepName;
_lastUndoAction = Log.NextUndoStepName;
HistoryView.Refresh();
}
private void ClearButton_Click(object sender, EventArgs e)
{
log.ClearLog();
Log.ClearLog();
UpdateValues();
}
private void UndoButton_Click(object sender, EventArgs e)
{
log.Undo();
tastudio.RefreshDialog();
}
private void RedoButton_Click(object sender, EventArgs e)
{
log.Redo();
tastudio.RefreshDialog();
Log.Undo();
_tastudio.RefreshDialog();
}
private void RedoButton_Click(object sender, EventArgs e)
{
Log.Redo();
_tastudio.RefreshDialog();
}
private void HistoryView_DoubleClick(object sender, EventArgs e)
{
if (log.UndoIndex <= HistoryView.selectedItem)
if (Log.UndoIndex <= HistoryView.selectedItem)
{
return;
}
do
{
log.Undo();
} while (log.UndoIndex > HistoryView.selectedItem);
Log.Undo();
}
while (Log.UndoIndex > HistoryView.selectedItem);
UpdateValues();
}
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);
else if (e.Button == System.Windows.Forms.MouseButtons.Left)
}
else if (e.Button == MouseButtons.Left)
{
if (HistoryView.selectedItem == -1)
{
HistoryView.SelectItem(_hackSelect, true);
}
}
}
// 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)
{
HistoryView.SelectItem(e.Y / HistoryView.LineHeight + HistoryView.VScrollPos - 1, true);
HistoryView.SelectItem((e.Y / HistoryView.LineHeight) + HistoryView.VScrollPos - 1, true);
_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;
}
do
{
log.Undo();
} while (log.UndoIndex >= HistoryView.selectedItem);
Log.Undo();
}
while (Log.UndoIndex >= HistoryView.selectedItem);
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;
}
do
{
log.Redo();
} while (log.UndoIndex < HistoryView.selectedItem);
Log.Redo();
}
while (Log.UndoIndex < HistoryView.selectedItem);
UpdateValues();
}
private void clearHistoryToHereToolStripMenuItem_Click(object sender, EventArgs e)
private void ClearHistoryToHereMenuItem_Click(object sender, EventArgs e)
{
if (HistoryView.selectedItem != -1)
log.ClearLog(HistoryView.selectedItem);
{
Log.ClearLog(HistoryView.selectedItem);
}
UpdateValues();
}
private void MaxStepsNum_ValueChanged(object sender, EventArgs e)
{
log.MaxSteps = (int)MaxStepsNum.Value;
Log.MaxSteps = (int)MaxStepsNum.Value;
}
}
}