Tastudio - use global references less in favor of internal properties

This commit is contained in:
adelikat 2019-12-06 17:14:27 -06:00
parent 0c3cb5b053
commit 7ac720d931
3 changed files with 21 additions and 19 deletions

View File

@ -336,9 +336,9 @@ namespace BizHawk.Client.EmuHawk
text = CurrentTasMovie.DisplayValue(index, columnName); text = CurrentTasMovie.DisplayValue(index, columnName);
if (column.Type == ColumnType.Float) if (column.Type == ColumnType.Float)
{ {
// feos: this could be cashed, but I don't notice any slowdown this way either // feos: this could be cached, but I don't notice any slowdown this way either
ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = ControllerType.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)]; [ControllerType.FloatControls.IndexOf(columnName)];
if (text == range.Mid.ToString()) if (text == range.Mid.ToString())
{ {
text = ""; text = "";
@ -380,7 +380,7 @@ namespace BizHawk.Client.EmuHawk
int frame = TasView.SelectedRows.FirstOrDefault(); int frame = TasView.SelectedRows.FirstOrDefault();
string buttonName = TasView.CurrentCell.Column.Name; string buttonName = TasView.CurrentCell.Column.Name;
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName)) if (ControllerType.BoolButtons.Contains(buttonName))
{ {
if (ModifierKeys != Keys.Alt) if (ModifierKeys != Keys.Alt)
{ {
@ -606,7 +606,7 @@ namespace BizHawk.Client.EmuHawk
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = Mainform.EmulatorPaused;
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName)) if (ControllerType.BoolButtons.Contains(buttonName))
{ {
_patternPaint = false; _patternPaint = false;
_startBoolDrawColumn = buttonName; _startBoolDrawColumn = buttonName;
@ -811,7 +811,7 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Right && !TasView.IsPointingAtColumnHeader && if (e.Button == MouseButtons.Right && !TasView.IsPointingAtColumnHeader &&
!_suppressContextMenu && TasView.SelectedRows.Any() && !_leftButtonHeld) !_suppressContextMenu && TasView.SelectedRows.Any() && !_leftButtonHeld)
{ {
if (Global.MovieSession.Movie.FrameCount < TasView.SelectedRows.Max()) if (CurrentTasMovie.FrameCount < TasView.SelectedRows.Max())
{ {
// trying to be smart here // trying to be smart here
// if a loaded branch log is shorter than selection, keep selection until you attempt to call context menu // if a loaded branch log is shorter than selection, keep selection until you attempt to call context menu
@ -947,7 +947,7 @@ namespace BizHawk.Client.EmuHawk
// skip rerecord counting on drawing entirely, mouse down is enough // skip rerecord counting on drawing entirely, mouse down is enough
// avoid introducing another global // avoid introducing another global
bool wasCountingRerecords = Global.MovieSession.Movie.IsCountingRerecords; bool wasCountingRerecords = CurrentTasMovie.IsCountingRerecords;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording || WasRecording;
int startVal, endVal; int startVal, endVal;
@ -1107,7 +1107,7 @@ namespace BizHawk.Client.EmuHawk
// Left-click // Left-click
else if (TasView.IsPaintDown && !string.IsNullOrEmpty(_startBoolDrawColumn)) else if (TasView.IsPaintDown && !string.IsNullOrEmpty(_startBoolDrawColumn))
{ {
Global.MovieSession.Movie.IsCountingRerecords = false; CurrentTasMovie.IsCountingRerecords = false;
for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down) for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down)
{ {
@ -1136,7 +1136,7 @@ namespace BizHawk.Client.EmuHawk
else if (TasView.IsPaintDown && !string.IsNullOrEmpty(_startFloatDrawColumn)) else if (TasView.IsPaintDown && !string.IsNullOrEmpty(_startFloatDrawColumn))
{ {
Global.MovieSession.Movie.IsCountingRerecords = false; CurrentTasMovie.IsCountingRerecords = false;
for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down) for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down)
{ {
@ -1158,7 +1158,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
Global.MovieSession.Movie.IsCountingRerecords = wasCountingRerecords; CurrentTasMovie.IsCountingRerecords = wasCountingRerecords;
if (MouseButtonHeld) if (MouseButtonHeld)
{ {
@ -1175,11 +1175,13 @@ namespace BizHawk.Client.EmuHawk
{ {
int increment = (_floatEditYPos - e.Y) / 4; int increment = (_floatEditYPos - e.Y) / 4;
if (_floatEditYPos == -1) if (_floatEditYPos == -1)
{
return; return;
}
float value = _floatPaintState + increment; float value = _floatPaintState + increment;
ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = ControllerType.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)]; [ControllerType.FloatControls.IndexOf(_floatEditColumn)];
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed in ControllerDefinition.cs. // Range for N64 Y axis has max -128 and min 127. That should probably be fixed in ControllerDefinition.cs.
// SuuperW: I really don't think changing it would break anything, but adelikat isn't so sure. // SuuperW: I really don't think changing it would break anything, but adelikat isn't so sure.
@ -1272,8 +1274,8 @@ namespace BizHawk.Client.EmuHawk
float prev = value; float prev = value;
string prevTyped = _floatTypedValue; string prevTyped = _floatTypedValue;
ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = ControllerType.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)]; [ControllerType.FloatControls.IndexOf(_floatEditColumn)];
float rMax = range.Max; float rMax = range.Max;
float rMin = range.Min; float rMin = range.Min;

View File

@ -1099,7 +1099,7 @@ namespace BizHawk.Client.EmuHawk
private void SubtitlesMenuItem_Click(object sender, EventArgs e) private void SubtitlesMenuItem_Click(object sender, EventArgs e)
{ {
var form = new EditSubtitlesForm { ReadOnly = false }; var form = new EditSubtitlesForm { ReadOnly = false };
form.GetMovie(Global.MovieSession.Movie); form.GetMovie(CurrentTasMovie);
form.ShowDialog(); form.ShowDialog();
} }

View File

@ -366,7 +366,7 @@ namespace BizHawk.Client.EmuHawk
StartNewTasMovie(); StartNewTasMovie();
} }
if (Global.Emulator is NullEmulator) if (Emulator.IsNull())
{ {
DisengageTastudio(); DisengageTastudio();
return false; return false;
@ -416,10 +416,10 @@ namespace BizHawk.Client.EmuHawk
{ {
ColumnType type; ColumnType type;
int digits; int digits;
if (Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.Contains(kvp.Key)) if (ControllerType.FloatControls.Contains(kvp.Key))
{ {
ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges ControllerDefinition.FloatRange range = ControllerType.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(kvp.Key)]; [ControllerType.FloatControls.IndexOf(kvp.Key)];
type = ColumnType.Float; type = ColumnType.Float;
digits = Math.Max(kvp.Value.Length, range.MaxDigits()); digits = Math.Max(kvp.Value.Length, range.MaxDigits());
} }