diff --git a/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs b/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs
index a46c1191a4..b12033b7f7 100644
--- a/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs
+++ b/BizHawk.Client.Common/movie/MnemonicGenerators/BooleanControllerMnemonicGenerator.cs
@@ -21,6 +21,8 @@ namespace BizHawk.Client.Common
}
}
+ public bool IsFloat { get { return true; } }
+
public void Add(string key, char value)
{
_controllerMnemonics.Add(key, value);
diff --git a/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs b/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs
index aa5a8c5320..52aa6c461c 100644
--- a/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs
+++ b/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicGenerator.cs
@@ -21,12 +21,14 @@ namespace BizHawk.Client.Common
bool IsEmpty { get; }
string MnemonicString { get; }
+ bool IsFloat { get; } // Float or Boolean
+
///
/// Gets a string that represents an empty or default mnemonic
///
string EmptyMnemonicString { get; }
- // Analog TODO: this assumes the Generator is boolean
+ // Analog TODO: this assumes the Generator is boolean, pass an object structure that contains both the boolean and float dictionaries
///
/// Parses a segment of a full mnemonic string (the content between pipes)
/// Note: this assume the pipes are not being passed in!
diff --git a/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicPorts.cs b/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicPorts.cs
index dc740e5cbe..1101e39e2c 100644
--- a/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicPorts.cs
+++ b/BizHawk.Client.Common/movie/MnemonicGenerators/IMnemonicPorts.cs
@@ -34,11 +34,8 @@ namespace BizHawk.Client.Common
Dictionary ParseMnemonicString(string mnemonicStr);
- // Analog TODO: this assume the generators are boolean
Dictionary GetBoolButtons();
-
- // TODO: this shouldn't be required, refactor MovieRecord
- string GenerateMnemonicString(Dictionary buttons);
+ Dictionary GetFloatButtons();
string EmptyMnemonic { get; }
diff --git a/BizHawk.Client.Common/movie/MnemonicGenerators/NesMnemonicGenerator.cs b/BizHawk.Client.Common/movie/MnemonicGenerators/NesMnemonicGenerator.cs
index 75c231b22a..3801662705 100644
--- a/BizHawk.Client.Common/movie/MnemonicGenerators/NesMnemonicGenerator.cs
+++ b/BizHawk.Client.Common/movie/MnemonicGenerators/NesMnemonicGenerator.cs
@@ -8,7 +8,10 @@ namespace BizHawk.Client.Common
{
public class NesMnemonicGenerator : IMnemonicPorts
{
- public NesMnemonicGenerator(IController source, bool fds = false, bool isFourscore = false)
+ private bool _isFds;
+ private bool _isFourscore;
+
+ public NesMnemonicGenerator(IController source, bool fds = false, bool isFourscore = false)
{
Source = source;
_isFds = fds;
@@ -33,6 +36,15 @@ namespace BizHawk.Client.Common
#region IMnemonicPorts Implementation
+ public string EmptyMnemonic
+ {
+ get
+ {
+ var blah = AvailableGenerators.Select(x => x.EmptyMnemonicString);
+ return "|" + string.Join("|", blah) + "|";
+ }
+ }
+
public int Count
{
get { return _isFourscore ? 4 : 2; }
@@ -47,7 +59,7 @@ namespace BizHawk.Client.Common
{
yield return ConsoleControls;
- for (int i = 0; i < Count; i++)
+ for (var i = 0; i < Count; i++)
{
yield return _controllerPorts[i];
}
@@ -99,9 +111,9 @@ namespace BizHawk.Client.Common
public Dictionary ParseMnemonicString(string mnemonicStr)
{
var segments = mnemonicStr.Split('|');
- var kvps = new List>();
+ var kvps = new List>();
var generators = AvailableGenerators.ToList();
- for(int i = 0; i < mnemonicStr.Length; i++)
+ for (var i = 0; i < mnemonicStr.Length; i++)
{
kvps.AddRange(generators[i].ParseMnemonicSegment(segments[i]));
}
@@ -111,48 +123,18 @@ namespace BizHawk.Client.Common
public Dictionary GetBoolButtons()
{
- List generators = AvailableGenerators.ToList();
-
- return generators
+ return AvailableGenerators
+ .Where(g => g.IsFloat)
.SelectMany(mc => mc.AvailableMnemonics)
- .ToDictionary(kvp => kvp.Key, kvp => this.Source.IsPressed(kvp.Key));
+ .ToDictionary(kvp => kvp.Key, kvp => Source.IsPressed(kvp.Key));
}
- // TODO: this shouldn't be required, refactor MovieRecord
- public string GenerateMnemonicString(Dictionary buttons)
+ public Dictionary GetFloatButtons()
{
- var mnemonics = AvailableMnemonics;
-
- var sb = new StringBuilder();
- sb.Append('|');
-
- foreach (var generator in AvailableGenerators)
- {
- foreach (var blah in generator.AvailableMnemonics)
- {
- if (buttons.ContainsKey(blah.Key))
- {
- sb.Append(buttons[blah.Key] ? blah.Value : '.');
- }
- else
- {
- sb.Append('.');
- }
- }
- }
-
- sb.Append('|');
-
- return sb.ToString();
- }
-
- public string EmptyMnemonic
- {
- get
- {
- var blah = AvailableGenerators.Select(x => x.EmptyMnemonicString);
- return "|" + String.Join("|", blah) + "|";
- }
+ return AvailableGenerators
+ .Where(g => !g.IsFloat)
+ .SelectMany(mc => mc.AvailableMnemonics)
+ .ToDictionary(kvp => kvp.Key, kvp => Source.GetFloat(kvp.Key));
}
// TODO: refactor me!
@@ -178,9 +160,6 @@ namespace BizHawk.Client.Common
#region Privates
- private bool _isFds;
- private bool _isFourscore;
-
private static readonly Dictionary _basicController = new Dictionary
{
{ "Up", 'U' },
@@ -202,7 +181,7 @@ namespace BizHawk.Client.Common
}
)
{
- ControllerPrefix = String.Empty
+ ControllerPrefix = string.Empty
};
private readonly BooleanControllerMnemonicGenerator _fdsConsoleControls = new BooleanControllerMnemonicGenerator(
@@ -217,7 +196,7 @@ namespace BizHawk.Client.Common
}
)
{
- ControllerPrefix = String.Empty
+ ControllerPrefix = string.Empty
};
private readonly List _controllerPorts =
diff --git a/BizHawk.Client.EmuHawk/AVOut/NumericTextBox.cs b/BizHawk.Client.EmuHawk/AVOut/NumericTextBox.cs
index b5d5162f34..084ffffacb 100644
--- a/BizHawk.Client.EmuHawk/AVOut/NumericTextBox.cs
+++ b/BizHawk.Client.EmuHawk/AVOut/NumericTextBox.cs
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Windows.Forms;
using System.Globalization;
@@ -16,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
{
base.OnKeyPress(e);
- NumberFormatInfo numberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
+ var numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat;
string decimalSeparator = numberFormatInfo.NumberDecimalSeparator;
string groupSeparator = numberFormatInfo.NumberGroupSeparator;
string negativeSign = numberFormatInfo.NegativeSign;
diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs
index 5c4fc8223a..b82e754a09 100644
--- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs
+++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs
@@ -1334,11 +1334,11 @@ namespace BizHawk.Client.EmuHawk
private void GoToAddressMenuItem_Click(object sender, EventArgs e)
{
- var inputPrompt = new InputPrompt { Text = "Go to Address", _Location = GetPromptPoint() };
+ var inputPrompt = new InputPrompt { Text = "Go to Address", StartLocation = GetPromptPoint() };
inputPrompt.SetMessage("Enter a hexadecimal value");
inputPrompt.ShowHawkDialog();
- if (inputPrompt.UserOK && InputValidate.IsHex(inputPrompt.UserText))
+ if (inputPrompt.UserOk && InputValidate.IsHex(inputPrompt.UserText))
{
GoToAddress(int.Parse(inputPrompt.UserText, NumberStyles.HexNumber));
}
diff --git a/BizHawk.Client.EmuHawk/tools/InputPrompt.Designer.cs b/BizHawk.Client.EmuHawk/tools/InputPrompt.Designer.cs
index 8494a29c30..f5e5a0769b 100644
--- a/BizHawk.Client.EmuHawk/tools/InputPrompt.Designer.cs
+++ b/BizHawk.Client.EmuHawk/tools/InputPrompt.Designer.cs
@@ -59,7 +59,7 @@
this.OK.TabIndex = 2;
this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true;
- this.OK.Click += new System.EventHandler(this.OK_Click);
+ this.OK.Click += new System.EventHandler(this.Ok_Click);
//
// Cancel
//
diff --git a/BizHawk.Client.EmuHawk/tools/InputPrompt.cs b/BizHawk.Client.EmuHawk/tools/InputPrompt.cs
index 77951a049c..d03e5ae1c3 100644
--- a/BizHawk.Client.EmuHawk/tools/InputPrompt.cs
+++ b/BizHawk.Client.EmuHawk/tools/InputPrompt.cs
@@ -11,23 +11,19 @@ namespace BizHawk.Client.EmuHawk
///
public partial class InputPrompt : Form
{
- public enum InputType { HEX, UNSIGNED, SIGNED, TEXT };
- public bool UserOK; //Will be true if the user selects Ok
- public string UserText = ""; //What the user selected
- public Point _Location = new Point(-1, -1);
- private InputType itype = InputType.TEXT;
-
- public InputType TextInputType
- {
- get { return itype; }
- set { itype = value; }
- }
-
public InputPrompt()
{
InitializeComponent();
+ UserText = string.Empty;
+ StartLocation = new Point(-1, -1);
}
+ public enum InputType { Hex, Unsigned, Signed, Text }
+ public bool UserOk { get; set; } // Will be true if the user selects Ok
+ public string UserText { get; set; } // What the user selected
+ public Point StartLocation { get; set; }
+ public InputType TextInputType { get; set; }
+
public void SetMessage(string message)
{
PromptLabel.Text = message;
@@ -50,61 +46,67 @@ namespace BizHawk.Client.EmuHawk
private void InputPrompt_Load(object sender, EventArgs e)
{
- if (_Location.X > 0 && _Location.Y > 0)
+ if (StartLocation.X > 0 && StartLocation.Y > 0)
{
- Location = _Location;
+ Location = StartLocation;
}
}
- private void OK_Click(object sender, EventArgs e)
+ private void Ok_Click(object sender, EventArgs e)
{
- UserOK = true;
+ UserOk = true;
UserText = PromptBox.Text;
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
- UserOK = false;
+ UserOk = false;
Close();
}
private void PromptBox_KeyPress(object sender, KeyPressEventArgs e)
{
- switch (itype)
+ switch (TextInputType)
{
default:
- case InputType.TEXT:
+ case InputType.Text:
break;
- case InputType.HEX:
+ case InputType.Hex:
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{
return;
}
- else if (!InputValidate.IsHex(e.KeyChar))
+
+ if (!InputValidate.IsHex(e.KeyChar))
{
e.Handled = true;
}
+
break;
- case InputType.SIGNED:
+ case InputType.Signed:
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{
return;
}
- else if (!InputValidate.IsUnsigned(e.KeyChar))
+
+ if (!InputValidate.IsUnsigned(e.KeyChar))
{
e.Handled = true;
}
+
break;
- case InputType.UNSIGNED:
+ case InputType.Unsigned:
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{
return;
}
- else if (!InputValidate.IsSigned(e.KeyChar))
+
+ if (!InputValidate.IsSigned(e.KeyChar))
{
e.Handled = true;
}
+
break;
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs
index 2d5a12a3f0..c79584a135 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs
@@ -1039,7 +1039,7 @@ namespace BizHawk.Client.EmuHawk
InputPrompt gotodialog = new InputPrompt();
gotodialog.FormClosing += (s, a) =>
{
- if (gotodialog.UserOK)
+ if (gotodialog.UserOk)
{
int x;
diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs
index 8d7f7bf068..0f00caf731 100644
--- a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs
+++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs
@@ -280,10 +280,10 @@ namespace BizHawk.Client.EmuHawk
var prompt = new InputPrompt();
prompt.SetMessage("Max lines to display in the window");
prompt.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString());
- prompt.TextInputType = InputPrompt.InputType.UNSIGNED;
- prompt._Location = GetPromptPoint();
+ prompt.TextInputType = InputPrompt.InputType.Unsigned;
+ prompt.StartLocation = GetPromptPoint();
prompt.ShowDialog();
- if (prompt.UserOK)
+ if (prompt.UserOk)
{
var max = int.Parse(prompt.UserText);
if (max > 0)
diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
index 464a5de215..465f7eb98d 100644
--- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
+++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
@@ -898,11 +898,11 @@ namespace BizHawk.Client.EmuHawk
private void GoToSpecifiedAddress()
{
WatchListView.SelectedIndices.Clear();
- var prompt = new InputPrompt { Text = "Go to Address", _Location = GetPromptPoint() };
+ var prompt = new InputPrompt { Text = "Go to Address", StartLocation = GetPromptPoint() };
prompt.SetMessage("Enter a hexadecimal value");
prompt.ShowHawkDialog();
- if (prompt.UserOK)
+ if (prompt.UserOk)
{
if (InputValidate.IsHex(prompt.UserText))
{