From 81b2a5d597cc58b928bb8d723675c1f3f9aecff4 Mon Sep 17 00:00:00 2001 From: Suuper Date: Fri, 29 Jan 2016 12:22:28 -0600 Subject: [PATCH] Fixed #533. (Use TryParse, don't try to use a value that can't be parsed.) Made numpad minus key work when typing a float value. Made current typed float value display (so that "-" can show up). --- .../tools/TAStudio/TAStudio.ListView.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index b15ad1a9d0..b916085532 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -244,7 +244,10 @@ namespace BizHawk.Client.EmuHawk } else { - if (index < CurrentTasMovie.InputLogLength) + // Display typed float value (string "-" can't be parsed, so CurrentTasMovie.DisplayValue can't return it) + if (index == _floatEditRow && columnName == _floatEditColumn) + text = _floatTypedValue; + else if (index < CurrentTasMovie.InputLogLength) text = CurrentTasMovie.DisplayValue(index, columnName); } } @@ -885,7 +888,7 @@ namespace BizHawk.Client.EmuHawk _floatTypedValue += e.KeyCode - Keys.D0; else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) _floatTypedValue += e.KeyCode - Keys.NumPad0; - else if (e.KeyCode == Keys.OemMinus) + else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract) { if (_floatTypedValue.StartsWith("-")) _floatTypedValue = _floatTypedValue.Substring(1); @@ -939,12 +942,14 @@ namespace BizHawk.Client.EmuHawk } else { - value = Convert.ToSingle(_floatTypedValue); - if (value > rMax) - value = rMax; - else if (value < rMin) - value = rMin; - CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value); + if (float.TryParse(_floatTypedValue, out value)) // String "-" can't be parsed. + { + if (value > rMax) + value = rMax; + else if (value < rMin) + value = rMin; + CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value); + } } if (value != prev) // Auto-restore {