From 864d3ede2f53ad83f0591c431140fd252df9f50c Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 11 Jan 2014 15:05:41 +0000 Subject: [PATCH] Nitpicky cleanups on movie 2.0 code --- .../BooleanControllerMnemonicGenerator.cs | 6 +++--- .../MnemonicGenerators/IMnemonicGenerator.cs | 15 ++++----------- BizHawk.Client.Common/movie/MovieRecord.cs | 10 +++------- BizHawk.Client.Common/movie/MovieRecordList.cs | 4 ++-- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs b/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs index 10cc44d602..a46c1191a4 100644 --- a/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs +++ b/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs @@ -10,9 +10,9 @@ namespace BizHawk.Client.Common { public class BooleanControllerMnemonicGenerator : IMnemonicGenerator { - private NamedDictionary _controllerMnemonics; + private readonly NamedDictionary _controllerMnemonics; - public BooleanControllerMnemonicGenerator(string name, IDictionary mnemonics) + public BooleanControllerMnemonicGenerator(string name, IEnumerable> mnemonics) { _controllerMnemonics = new NamedDictionary(name); foreach (var kvp in mnemonics) @@ -90,7 +90,7 @@ namespace BizHawk.Client.Common var buttons = new Dictionary(); var keys = _controllerMnemonics.Select(kvp => kvp.Key).ToList(); - for (int i = 0; i < mnemonicSegment.Length; i++) + for (var i = 0; i < mnemonicSegment.Length; i++) { buttons.Add(keys[i], mnemonicSegment[i] != '.'); } diff --git a/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs b/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs index 86a9bd6d21..aa5a8c5320 100644 --- a/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs +++ b/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common @@ -14,8 +10,8 @@ namespace BizHawk.Client.Common string Name { get; } /// - /// Will be prepended to all button names - /// Example: "P1" + /// Gets or sets the prefix that will be prepended to all button names + /// Example: "P1" would combine with "Up" to make "P1 Up" /// string ControllerPrefix { get; set; } @@ -26,7 +22,7 @@ namespace BizHawk.Client.Common string MnemonicString { get; } /// - /// Returns a string that represents an empty or default mnemonic + /// Gets a string that represents an empty or default mnemonic /// string EmptyMnemonicString { get; } @@ -37,9 +33,6 @@ namespace BizHawk.Client.Common /// IDictionary ParseMnemonicSegment(string mnemonicSegment); - // Analog Support TODO: this assume the Generator is boolean - //Dictionary GetBoolButtons(); - Dictionary AvailableMnemonics { get; } } } diff --git a/BizHawk.Client.Common/movie/MovieRecord.cs b/BizHawk.Client.Common/movie/MovieRecord.cs index e4e655730d..2353e6829b 100644 --- a/BizHawk.Client.Common/movie/MovieRecord.cs +++ b/BizHawk.Client.Common/movie/MovieRecord.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; - -using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { @@ -37,7 +33,7 @@ namespace BizHawk.Client.Common public void SetButton(string button, bool pressed) { - InputChanged(new Dictionary() { { button, pressed } }); + InputChanged(new Dictionary { { button, pressed } }); _boolButtons[button] = pressed; } @@ -96,7 +92,7 @@ namespace BizHawk.Client.Common public delegate void InputEventHandler(object sender, InputEventArgs e); public event InputEventHandler OnChanged; - private void InputChanged(Dictionary editedButtons) + private void InputChanged(Dictionary editedButtons) { if (OnChanged != null) { diff --git a/BizHawk.Client.Common/movie/MovieRecordList.cs b/BizHawk.Client.Common/movie/MovieRecordList.cs index af78bb9166..6530fcfd15 100644 --- a/BizHawk.Client.Common/movie/MovieRecordList.cs +++ b/BizHawk.Client.Common/movie/MovieRecordList.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; using System.Text; namespace BizHawk.Client.Common @@ -8,8 +9,7 @@ namespace BizHawk.Client.Common /// /// DONT USE ME RIGHT NOW /// - /// - public void WriteToText(System.IO.TextWriter tw) + public void WriteToText(TextWriter tw) { tw.WriteLine("[Input]"); tw.WriteLine("Frame {0}", Global.Emulator.Frame);