From 8d0cfc60dc2002d3590563e0461102afadace93a Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 9 Jul 2014 23:04:22 +0000 Subject: [PATCH] TAStudio - some reorg --- .../BizHawk.Client.EmuHawk.csproj | 4 + .../tools/TAStudio/TAStudio.ListView.cs | 138 ++++++++++++++++++ .../tools/TAStudio/TAStudio.cs | 123 ---------------- 3 files changed, 142 insertions(+), 123 deletions(-) create mode 100644 BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index c632505dfa..4d93e776ac 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -879,6 +879,10 @@ TAStudio.cs + + TAStudio.cs + Form + Form diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs new file mode 100644 index 0000000000..f381ca1bc2 --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -0,0 +1,138 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +using BizHawk.Client.Common; + +namespace BizHawk.Client.EmuHawk +{ + public partial class TAStudio + { + #region Query callbacks + + private void TasView_QueryItemBkColor(int index, int column, ref Color color) + { + var record = _tas[index]; + if (Global.Emulator.Frame == index + 1) + { + color = Color.LightBlue; + } + else if (!record.HasState) + { + color = BackColor; + } + else + { + color = record.Lagged ? Color.Pink : Color.LightGreen; + } + } + + private void TasView_QueryItemText(int index, int column, out string text) + { + try + { + var columnName = TasView.Columns[column].Name; + //var columnText = TasView.Columns[column].Text; + + if (columnName == MarkerColumnName) + { + text = Global.Emulator.Frame == index + 1 ? ">" : string.Empty; + } + else if (columnName == FrameColumnName) + { + text = (index + 1).ToString().PadLeft(5, '0'); + } + else + { + //Serialize TODO + //text = _tas[index].IsPressed(columnName) ? columnText : string.Empty; + text = string.Empty; + } + } + catch (Exception ex) + { + text = string.Empty; + MessageBox.Show("oops\n" + ex); + } + } + + #endregion + + #region Events + + private void TasView_MouseDown(object sender, MouseEventArgs e) + { + if (TasView.PointedCell.Row.HasValue && !string.IsNullOrEmpty(TasView.PointedCell.Column)) + { + if (TasView.PointedCell.Column == MarkerColumnName) + { + _startMarkerDrag = true; + } + else if (TasView.PointedCell.Column == FrameColumnName) + { + _startFrameDrag = true; + } + else + { + //_tas.ToggleButton(TasView.PointedCell.Row.Value, TasView.PointedCell.Column); + TasView.Refresh(); + + _startDrawColumn = TasView.PointedCell.Column; + //_startOn = _tas.IsPressed(TasView.PointedCell.Row.Value, TasView.PointedCell.Column); + } + } + } + + private void TasView_MouseUp(object sender, MouseEventArgs e) + { + _startMarkerDrag = false; + _startFrameDrag = false; + _startDrawColumn = string.Empty; + } + + private void TasView_PointedCellChanged(object sender, TasListView.CellEventArgs e) + { + if (_startMarkerDrag) + { + if (e.NewCell.Row.HasValue) + { + GoToFrame(e.NewCell.Row.Value); + } + } + else if (_startFrameDrag) + { + if (e.OldCell.Row.HasValue && e.NewCell.Row.HasValue) + { + int startVal, endVal; + if (e.OldCell.Row.Value < e.NewCell.Row.Value) + { + startVal = e.OldCell.Row.Value; + endVal = e.NewCell.Row.Value; + } + else + { + startVal = e.NewCell.Row.Value; + endVal = e.OldCell.Row.Value; + } + + for (var i = startVal + 1; i <= endVal; i++) + { + TasView.SelectItem(i, true); + } + } + } + else if (TasView.IsPaintDown && e.NewCell.Row.HasValue && !string.IsNullOrEmpty(_startDrawColumn)) + { + //_tas.SetBoolButton(e.NewCell.Row.Value, _startDrawColumn, /*_startOn*/ false); // Notice it uses new row, old column, you can only paint across a single column + TasView.Refresh(); + } + } + + private void TasView_SelectedIndexChanged(object sender, EventArgs e) + { + SetSplicer(); + } + + #endregion + } +} diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 848b61f7ef..748569283c 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -60,52 +60,6 @@ namespace BizHawk.Client.EmuHawk TasView.PointedCellChanged += TasView_PointedCellChanged; } - private void TasView_QueryItemBkColor(int index, int column, ref Color color) - { - var record = _tas[index]; - if (Global.Emulator.Frame == index + 1) - { - color = Color.LightBlue; - } - else if (!record.HasState) - { - color = BackColor; - } - else - { - color = record.Lagged ? Color.Pink : Color.LightGreen; - } - } - - private void TasView_QueryItemText(int index, int column, out string text) - { - try - { - var columnName = TasView.Columns[column].Name; - //var columnText = TasView.Columns[column].Text; - - if (columnName == MarkerColumnName) - { - text = Global.Emulator.Frame == index + 1 ? ">" : string.Empty; - } - else if (columnName == FrameColumnName) - { - text = (index + 1).ToString().PadLeft(5, '0'); - } - else - { - //Serialize TODO - //text = _tas[index].IsPressed(columnName) ? columnText : string.Empty; - text = string.Empty; - } - } - catch (Exception ex) - { - text = string.Empty; - MessageBox.Show("oops\n" + ex); - } - } - private void Tastudio_Load(object sender, EventArgs e) { // Start Scenario 1: A regular movie is active @@ -495,83 +449,6 @@ namespace BizHawk.Client.EmuHawk #endregion - #region TASView Events - - private void TasView_MouseDown(object sender, MouseEventArgs e) - { - if (TasView.PointedCell.Row.HasValue && !string.IsNullOrEmpty(TasView.PointedCell.Column)) - { - if (TasView.PointedCell.Column == MarkerColumnName) - { - _startMarkerDrag = true; - } - else if (TasView.PointedCell.Column == FrameColumnName) - { - _startFrameDrag = true; - } - else - { - //_tas.ToggleButton(TasView.PointedCell.Row.Value, TasView.PointedCell.Column); - TasView.Refresh(); - - _startDrawColumn = TasView.PointedCell.Column; - //_startOn = _tas.IsPressed(TasView.PointedCell.Row.Value, TasView.PointedCell.Column); - } - } - } - - private void TasView_MouseUp(object sender, MouseEventArgs e) - { - _startMarkerDrag = false; - _startFrameDrag = false; - _startDrawColumn = string.Empty; - } - - private void TasView_PointedCellChanged(object sender, TasListView.CellEventArgs e) - { - if (_startMarkerDrag) - { - if (e.NewCell.Row.HasValue) - { - GoToFrame(e.NewCell.Row.Value); - } - } - else if (_startFrameDrag) - { - if (e.OldCell.Row.HasValue && e.NewCell.Row.HasValue) - { - int startVal, endVal; - if (e.OldCell.Row.Value < e.NewCell.Row.Value) - { - startVal = e.OldCell.Row.Value; - endVal = e.NewCell.Row.Value; - } - else - { - startVal = e.NewCell.Row.Value; - endVal = e.OldCell.Row.Value; - } - - for (var i = startVal + 1; i <= endVal; i++) - { - TasView.SelectItem(i, true); - } - } - } - else if (TasView.IsPaintDown && e.NewCell.Row.HasValue && !string.IsNullOrEmpty(_startDrawColumn)) - { - //_tas.SetBoolButton(e.NewCell.Row.Value, _startDrawColumn, /*_startOn*/ false); // Notice it uses new row, old column, you can only paint across a single column - TasView.Refresh(); - } - } - - private void TasView_SelectedIndexChanged(object sender, EventArgs e) - { - SetSplicer(); - } - - #endregion - #region Dialog Events protected override void OnShown(EventArgs e)