diff --git a/BizHawk.Client.Common/inputAdapters/InputAdapters.cs b/BizHawk.Client.Common/inputAdapters/InputAdapters.cs index d1efb0cfc6..2dfa295cf6 100644 --- a/BizHawk.Client.Common/inputAdapters/InputAdapters.cs +++ b/BizHawk.Client.Common/inputAdapters/InputAdapters.cs @@ -6,6 +6,7 @@ using BizHawk.Common; using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; + namespace BizHawk.Client.Common { /// diff --git a/BizHawk.Client.Common/tools/Watch.cs b/BizHawk.Client.Common/tools/Watch.cs index 2152fa6048..065f89f62f 100644 --- a/BizHawk.Client.Common/tools/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Globalization; using BizHawk.Common; +using BizHawk.Common.NumberExtensions; +using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common @@ -161,7 +163,7 @@ namespace BizHawk.Client.Common { if (_domain != null) { - return "X" + IntHelpers.GetNumDigits(this._domain.Size - 1); + return "X" + (_domain.Size - 1).NumHexDigits(); } return string.Empty; diff --git a/BizHawk.Client.Common/tools/WatchList.cs b/BizHawk.Client.Common/tools/WatchList.cs index 01c54b2759..6e0414925e 100644 --- a/BizHawk.Client.Common/tools/WatchList.cs +++ b/BizHawk.Client.Common/tools/WatchList.cs @@ -4,7 +4,7 @@ using System.IO; using System.Linq; using System.Text; -using BizHawk.Common; +using BizHawk.Common.NumberExtensions; using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; @@ -37,7 +37,7 @@ namespace BizHawk.Client.Common { if (_domain != null) { - return "{0:X" + IntHelpers.GetNumDigits(this._domain.Size - 1) + "}"; + return "{0:X" + (_domain.Size - 1).NumHexDigits() + "}"; } return string.Empty; diff --git a/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs b/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs index e88461068c..17ffdc0eab 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.Windows.Forms; using BizHawk.Common; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Client.EmuHawk { @@ -30,7 +31,7 @@ namespace BizHawk.Client.EmuHawk public void SetHexProperties(int domainSize) { _maxSize = domainSize - 1; - MaxLength = IntHelpers.GetNumDigits(_maxSize.Value); + MaxLength = _maxSize.Value.NumHexDigits(); _addressFormatStr = "{0:X" + MaxLength + "}"; ResetText(); diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index 0e8f4e3c12..7539362e5b 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -10,6 +10,7 @@ using System.Text; using System.Windows.Forms; using BizHawk.Common; +using BizHawk.Common.NumberExtensions; using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk @@ -114,7 +115,7 @@ namespace BizHawk.Client.EmuHawk SpecificValueBox.Type = _settings.Type; MessageLabel.Text = string.Empty; - SpecificAddressBox.MaxLength = IntHelpers.GetNumDigits(Global.Emulator.MemoryDomains.MainMemory.Size); + SpecificAddressBox.MaxLength = (Global.Emulator.MemoryDomains.MainMemory.Size - 1).NumHexDigits(); HardSetSizeDropDown(_settings.Size); PopulateTypeDropDown(); HardSetDisplayTypeDropDown(_settings.Type); @@ -546,7 +547,7 @@ namespace BizHawk.Client.EmuHawk { _settings.Domain = Global.Emulator.MemoryDomains[name]; SetReboot(true); - SpecificAddressBox.MaxLength = IntHelpers.GetNumDigits(_settings.Domain.Size); + SpecificAddressBox.MaxLength = (_settings.Domain.Size - 1).NumHexDigits(); DoDomainSizeCheck(); } diff --git a/BizHawk.Common/BizHawk.Common.csproj b/BizHawk.Common/BizHawk.Common.csproj index e7a63094d0..9df2146e11 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -54,6 +54,7 @@ + @@ -67,7 +68,6 @@ - diff --git a/BizHawk.Common/StringHelpers.cs b/BizHawk.Common/StringHelpers.cs deleted file mode 100644 index 736535ec09..0000000000 --- a/BizHawk.Common/StringHelpers.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Linq; - -namespace BizHawk.Common -{ - // TODO: put it in its own file - public static class IntHelpers // TODO: a less lame name - { - public static int GetNumDigits(int i) - { - if (i < 0x100) - { - return 2; - } - - if (i < 0x10000) - { - return 4; - } - - if (i < 0x1000000) - { - return 6; - } - - return 8; - } - } -}