misc cleanups in tastudio files, mostly typos and redundant code

This commit is contained in:
adelikat 2019-06-28 17:51:03 -05:00
parent db0af57f54
commit 512b03f1b4
9 changed files with 80 additions and 64 deletions

View File

@ -445,7 +445,7 @@ namespace BizHawk.Client.EmuHawk
case "Delete Branch":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.RemoveBranchExtrenal();
GlobalWin.Tools.TAStudio.RemoveBranchExternal();
}
else
{

View File

@ -448,7 +448,7 @@ namespace BizHawk.Client.EmuHawk
UpdateBranchToolStripMenuItem_Click(null, null);
}
public void RemoveBranchExtrenal()
public void RemoveBranchExternal()
{
RemoveBranchToolStripMenuItem_Click(null, null);
}

View File

@ -69,10 +69,10 @@
public bool WantsToControlStopMovie { get; private set; }
public void StopMovie(bool supressSave)
public void StopMovie(bool suppressSave)
{
Focus();
_suppressAskSave = supressSave;
_suppressAskSave = suppressSave;
NewTasMenuItem_Click(null, null);
_suppressAskSave = false;
}
@ -86,7 +86,7 @@
public bool Rewind()
{
// copypasted from TasView_MouseWheel(), just without notch logic
// copy pasted from TasView_MouseWheel(), just without notch logic
if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
{
Mainform.PauseOnFrame--;
@ -104,7 +104,7 @@
}
else
{
StopSeeking(); // late breaking memo: dont know whether this is needed
StopSeeking(); // late breaking memo: don't know whether this is needed
GoToPreviousFrame();
}

View File

@ -44,23 +44,23 @@ namespace BizHawk.Client.EmuHawk
private readonly List<int> _extraFloatRows = new List<int>();
// Right-click dragging
private string[] _rightClickInput = null;
private string[] _rightClickOverInput = null;
private string[] _rightClickInput;
private string[] _rightClickOverInput;
private int _rightClickFrame = -1;
private int _rightClickLastFrame = -1;
private bool _rightClickShift, _rightClickControl, _rightClickAlt;
private bool _leftButtonHeld = false;
private bool _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 _unpauseAfterSeeking = false;
private bool? _autoRestorePaused;
private int? _seekStartFrame;
private bool _unpauseAfterSeeking;
private ControllerDefinition ControllerType => Global.MovieSession.MovieControllerAdapter.Definition;
public bool WasRecording;
public bool WasRecording { get; set; }
public AutoPatternBool[] BoolPatterns;
public AutoPatternFloat[] FloatPatterns;
@ -225,10 +225,12 @@ namespace BizHawk.Client.EmuHawk
}
string columnName = column.Name;
if (columnName == CursorColumnName)
{
color = Color.FromArgb(0xFEFFFF);
}
if (columnName == FrameColumnName)
{
if (Emulator.Frame != index && CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithBGColor)
@ -379,14 +381,14 @@ namespace BizHawk.Client.EmuHawk
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName))
{
if (Control.ModifierKeys != Keys.Alt)
if (ModifierKeys != Keys.Alt)
{
// nifty taseditor logic
bool allPressed = true;
foreach (var index in TasView.SelectedRows)
{
if ((index == CurrentTasMovie.FrameCount) // last movie frame can't have input, but can be selected
|| (!CurrentTasMovie.BoolIsPressed(index, buttonName)))
if (index == CurrentTasMovie.FrameCount // last movie frame can't have input, but can be selected
|| !CurrentTasMovie.BoolIsPressed(index, buttonName))
{
allPressed = false;
break;
@ -412,6 +414,7 @@ namespace BizHawk.Client.EmuHawk
_triggerAutoRestore = true;
JumpToGreenzone();
}
RefreshDialog();
}
}
@ -424,6 +427,7 @@ namespace BizHawk.Client.EmuHawk
RefreshTasView();
}
private void UpdateAutoFire()
{
for (int i = 2; i < TasView.AllColumns.Count; i++)
@ -431,6 +435,7 @@ namespace BizHawk.Client.EmuHawk
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.
@ -546,7 +551,7 @@ namespace BizHawk.Client.EmuHawk
// SuuperW: Exit float editing mode, or re-enter mouse editing
if (FloatEditingMode)
{
if (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift)
if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)
{
_extraFloatRows.Clear();
_extraFloatRows.AddRange(TasView.SelectedRows);
@ -585,7 +590,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (TasView.CurrentCell.Column.Name == FrameColumnName)
{
if (Control.ModifierKeys == Keys.Alt && CurrentTasMovie.Markers.IsMarker(frame))
if (ModifierKeys == Keys.Alt && CurrentTasMovie.Markers.IsMarker(frame))
{
// TODO
TasView.DragCurrentCell();
@ -596,7 +601,7 @@ namespace BizHawk.Client.EmuHawk
_selectionDragState = TasView.SelectedRows.Contains(frame);
}
}
else if (TasView.CurrentCell.Column.Type != InputRoll.RollColumn.InputType.Text)// User changed input
else if (TasView.CurrentCell.Column.Type != InputRoll.RollColumn.InputType.Text) // User changed input
{
bool wasPaused = Mainform.EmulatorPaused;
@ -627,8 +632,8 @@ namespace BizHawk.Client.EmuHawk
bool allPressed = true;
for (int i = firstSel; i <= frame; i++)
{
if ((i == CurrentTasMovie.FrameCount) // last movie frame can't have input, but can be selected
|| (!CurrentTasMovie.BoolIsPressed(i, buttonName)))
if (i == CurrentTasMovie.FrameCount // last movie frame can't have input, but can be selected
|| !CurrentTasMovie.BoolIsPressed(i, buttonName))
{
allPressed = false;
break;
@ -640,7 +645,7 @@ namespace BizHawk.Client.EmuHawk
JumpToGreenzone();
RefreshDialog();
}
else if (Control.ModifierKeys == Keys.Shift && Control.ModifierKeys == Keys.Alt) //Does not work?
else if (ModifierKeys == Keys.Shift && ModifierKeys == Keys.Alt) // Does not work?
{
// TODO: Pattern drawing from selection to current cell
}
@ -720,9 +725,9 @@ namespace BizHawk.Client.EmuHawk
{
if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength)
{
_rightClickControl = (Control.ModifierKeys | Keys.Control) == Control.ModifierKeys;
_rightClickShift = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys;
_rightClickAlt = (Control.ModifierKeys | Keys.Alt) == Control.ModifierKeys;
_rightClickControl = (ModifierKeys | Keys.Control) == ModifierKeys;
_rightClickShift = (ModifierKeys | Keys.Shift) == ModifierKeys;
_rightClickAlt = (ModifierKeys | Keys.Alt) == ModifierKeys;
if (TasView.SelectedRows.Contains(frame))
{
_rightClickInput = new string[TasView.SelectedRows.Count()];
@ -825,7 +830,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (e.Button == MouseButtons.Left)
{
if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift))
if (FloatEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
{
_leftButtonHeld = false;
_startSelectionDrag = false;
@ -978,7 +983,7 @@ namespace BizHawk.Client.EmuHawk
for (var i = startVal; i <= endVal; i++)
{
TasView.SelectRow(i, _selectionDragState);
if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift))
if (FloatEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
{
if (_selectionDragState)
{
@ -1014,7 +1019,9 @@ namespace BizHawk.Client.EmuHawk
}
if (startVal < _rightClickLastFrame)
{
shouldInsert = false;
}
if (shouldInsert)
{
@ -1375,19 +1382,12 @@ namespace BizHawk.Client.EmuHawk
}
else if (e.KeyCode == Keys.Enter)
{
if (_floatEditYPos != -1)
{
_floatEditYPos = -1;
}
_floatEditYPos = -1;
floatEditRow = -1;
}
else if (e.KeyCode == Keys.Escape)
{
if (_floatEditYPos != -1)
{
_floatEditYPos = -1;
}
_floatEditYPos = -1;
if (_floatBackupState != _floatPaintState)
{
@ -1411,7 +1411,7 @@ namespace BizHawk.Client.EmuHawk
changeBy = -1;
}
if (Control.ModifierKeys == Keys.Shift)
if (ModifierKeys == Keys.Shift)
{
changeBy *= 10;
}
@ -1476,7 +1476,7 @@ namespace BizHawk.Client.EmuHawk
private void TasView_KeyDown(object sender, KeyEventArgs e)
{
//taseditor uses Ctrl for selection and Shift for framecourser
// taseditor uses Ctrl for selection and Shift for framecourser
if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.PageUp) // Shift + Page Up
{
GoToPreviousMarker();

View File

@ -482,10 +482,10 @@ namespace BizHawk.Client.EmuHawk
if (TasView.AnyRowsSelected)
{
// TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
// FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs
// FCEUX Taseditor doesn't do this, but I think it is the expected behavior in editor programs
var wasPaused = Mainform.EmulatorPaused;
// copypaste from PasteInsertMenuItem_Click!
// copy paste from PasteInsertMenuItem_Click!
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.StringFormat))
{
@ -532,7 +532,7 @@ namespace BizHawk.Client.EmuHawk
{
var wasPaused = Mainform.EmulatorPaused;
// copypaste from PasteMenuItem_Click!
// copy paste from PasteMenuItem_Click!
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.StringFormat))
{
@ -652,7 +652,7 @@ namespace BizHawk.Client.EmuHawk
var rollBackFrame = TasView.FirstSelectedIndex.Value;
if (rollBackFrame >= CurrentTasMovie.InputLogLength)
{
// Cannot delete non-existant frames
// Cannot delete non-existent frames
RefreshDialog();
return;
}
@ -1165,7 +1165,7 @@ namespace BizHawk.Client.EmuHawk
private void HideLagFramesX_Click(object sender, EventArgs e)
{
TasView.LagFramesToHide = (int)(sender as ToolStripMenuItem).Tag;
TasView.LagFramesToHide = (int)((ToolStripMenuItem)sender).Tag;
MaybeFollowCursor();
RefreshDialog();
}
@ -1226,15 +1226,15 @@ namespace BizHawk.Client.EmuHawk
private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e)
{
var inputpromt = new InputPrompt
var inputPrompt = new InputPrompt
{
TextInputType = InputPrompt.InputType.Unsigned,
Message = "Frames per tick:",
InitialValue = TasView.ScrollSpeed.ToString()
};
if (inputpromt.ShowDialog() == DialogResult.OK)
if (inputPrompt.ShowDialog() == DialogResult.OK)
{
TasView.ScrollSpeed = int.Parse(inputpromt.PromptText);
TasView.ScrollSpeed = int.Parse(inputPrompt.PromptText);
Settings.ScrollSpeed = TasView.ScrollSpeed;
}
}
@ -1254,7 +1254,7 @@ namespace BizHawk.Client.EmuHawk
int workingHeight = Screen.FromControl(this).WorkingArea.Height;
int rowHeight = ColumnsSubMenu.Height + 4;
int maxRows = workingHeight / rowHeight;
int keyCount = columns.Where(c => c.Name.StartsWith("Key ")).Count();
int keyCount = columns.Count(c => c.Name.StartsWith("Key "));
int keysMenusCount = (int)Math.Ceiling((double)keyCount / maxRows);
ToolStripMenuItem[] keysMenus = new ToolStripMenuItem[keysMenusCount];
@ -1296,8 +1296,7 @@ namespace BizHawk.Client.EmuHawk
if (column.Name.StartsWith("Key "))
{
keysMenus
.Where(m => m.DropDownItems.Count < maxRows)
.FirstOrDefault()
.First(m => m.DropDownItems.Count < maxRows)
.DropDownItems
.Add(menuItem);
}
@ -1487,7 +1486,11 @@ namespace BizHawk.Client.EmuHawk
if (SaveRamEmulator.CloneSaveRam() != null)
{
int index = 0;
if (TasView.SelectedRows.Count() > 0) { index = TasView.SelectedRows.First(); }
if (TasView.SelectedRows.Any())
{
index = TasView.SelectedRows.First();
}
GoToFrame(index);
TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie(
SaveRamEmulator.CloneSaveRam());

View File

@ -11,8 +11,6 @@ namespace BizHawk.Client.EmuHawk
{
if (frame != Emulator.Frame) // Don't go to a frame if you are already on it!
{
int restoreFrame = Emulator.Frame;
if (frame <= Emulator.Frame)
{
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking)
@ -32,7 +30,6 @@ namespace BizHawk.Client.EmuHawk
{
// If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
// Otherwise, load the latest state (if not already there) and seek while recording.
WasRecording = CurrentTasMovie.IsRecording || WasRecording;
if (frame <= CurrentTasMovie.InputLogLength)

View File

@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
private Timer _autosaveTimer;
/// <summary>
/// Gets or sets a value that separates "restore last position" logic from seeking caused by navigation.
/// Gets 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; private set; }
@ -399,7 +399,7 @@ namespace BizHawk.Client.EmuHawk
}
}
// Start Scenario 3: No movie, but user wants to autload their last project
// Start Scenario 3: No movie, but user wants to autoload their last project
else if (Settings.RecentTas.AutoLoad && !string.IsNullOrEmpty(Settings.RecentTas.MostRecent))
{
bool result = LoadFile(new FileInfo(Settings.RecentTas.MostRecent));
@ -974,9 +974,9 @@ namespace BizHawk.Client.EmuHawk
BookMarkControl.AddBranchExternal();
}
public void RemoveBranchExtrenal()
public void RemoveBranchExternal()
{
BookMarkControl.RemoveBranchExtrenal();
BookMarkControl.RemoveBranchExternal();
}
private void UpdateOtherTools() // a hack probably, surely there is a better way to do this
@ -1036,11 +1036,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void DeleteFrames(int beginningFrame, int numberofFrames)
public void DeleteFrames(int beginningFrame, int numberOfFrames)
{
if (beginningFrame < CurrentTasMovie.InputLogLength)
{
int[] framesToRemove = Enumerable.Range(beginningFrame, numberofFrames).ToArray();
int[] framesToRemove = Enumerable.Range(beginningFrame, numberOfFrames).ToArray();
CurrentTasMovie.RemoveFrames(framesToRemove);
SetSplicer();

View File

@ -14,8 +14,8 @@ namespace BizHawk.Client.EmuHawk
ControllerState = controllerState;
}
public int Frame { get; private set; }
public IController ControllerState { get; private set; }
public int Frame { get; }
public IController ControllerState { get; }
public override string ToString()
{

View File

@ -106,6 +106,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SHA/@EntryIndexedValue">SHA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TA/@EntryIndexedValue">TA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TAS/@EntryIndexedValue">TAS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TIA/@EntryIndexedValue">TIA</s:String>
@ -174,9 +175,24 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=addr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autohold/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autoload/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autorestore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bsnes/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=feos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzone/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzoned/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mainform/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=savestate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=savestates/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasproj/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Screenshot/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=sSeeki/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Statable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=taseditor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasproj/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tastudio/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unpause/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unpaused/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>