Skip to content

Commit e305156

Browse files
committed
Split values to make them editable.
1 parent 5e3ba59 commit e305156

File tree

12 files changed

+58
-27
lines changed

12 files changed

+58
-27
lines changed

ReClass.NET/Extensions/StringExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Diagnostics.Contracts;
55
using System.Linq;
6+
using System.Text.RegularExpressions;
67

78
namespace ReClassNET.Util
89
{
@@ -84,5 +85,14 @@ public static string LimitLength(this string s, int length)
8485
}
8586
return s.Substring(0, length);
8687
}
88+
89+
private static readonly Regex HexRegex = new Regex("(0x|h)?([0-9A-F]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
90+
public static bool TryGetHexString(this string s, out string value)
91+
{
92+
var match = HexRegex.Match(s);
93+
value = match.Success ? match.Groups[2].Value : null;
94+
95+
return match.Success;
96+
}
8797
}
8898
}

ReClass.NET/Nodes/BaseNumericNode.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ public abstract class BaseNumericNode : BaseNode
1313
/// <param name="icon">The icon of the node.</param>
1414
/// <param name="type">The type of the node.</param>
1515
/// <param name="value">The value of the node.</param>
16+
/// <param name="alternativeValue">An alternative value of the node.</param>
1617
/// <returns>The pixel size the node occupies.</returns>
17-
protected Size DrawNumeric(ViewInfo view, int x, int y, Image icon, string type, string value)
18+
protected Size DrawNumeric(ViewInfo view, int x, int y, Image icon, string type, string value, string alternativeValue)
1819
{
1920
Contract.Requires(view != null);
2021
Contract.Requires(icon != null);
@@ -41,6 +42,10 @@ protected Size DrawNumeric(ViewInfo view, int x, int y, Image icon, string type,
4142
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
4243
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NoneId, "=") + view.Font.Width;
4344
x = AddText(view, x, y, view.Settings.ValueColor, 0, value) + view.Font.Width;
45+
if (alternativeValue != null)
46+
{
47+
x = AddText(view, x, y, view.Settings.ValueColor, 1, alternativeValue) + view.Font.Width;
48+
}
4449

4550
x = AddComment(view, x, y);
4651

ReClass.NET/Nodes/DoubleNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class DoubleNode : BaseNumericNode
1010

1111
public override Size Draw(ViewInfo view, int x, int y)
1212
{
13-
return DrawNumeric(view, x, y, Icons.Double, "Double", ReadValueFromMemory(view.Memory).ToString("0.000"));
13+
return DrawNumeric(view, x, y, Icons.Double, "Double", ReadValueFromMemory(view.Memory).ToString("0.000"), null);
1414
}
1515

1616
public override void Update(HotSpot spot)

ReClass.NET/Nodes/FloatNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class FloatNode : BaseNumericNode
1010

1111
public override Size Draw(ViewInfo view, int x, int y)
1212
{
13-
return DrawNumeric(view, x, y, Icons.Float, "Float", ReadValueFromMemory(view.Memory).ToString("0.000"));
13+
return DrawNumeric(view, x, y, Icons.Float, "Float", ReadValueFromMemory(view.Memory).ToString("0.000"), null);
1414
}
1515

1616
public override void Update(HotSpot spot)

ReClass.NET/Nodes/Int16Node.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
2+
using System.Globalization;
23
using ReClassNET.Memory;
34
using ReClassNET.UI;
5+
using ReClassNET.Util;
46

57
namespace ReClassNET.Nodes
68
{
@@ -11,16 +13,16 @@ public class Int16Node : BaseNumericNode
1113
public override Size Draw(ViewInfo view, int x, int y)
1214
{
1315
var value = ReadValueFromMemory(view.Memory);
14-
return DrawNumeric(view, x, y, Icons.Signed, "Int16", $"{value} (0x{value:X})");
16+
return DrawNumeric(view, x, y, Icons.Signed, "Int16", value.ToString(), $"0x{value:X}");
1517
}
1618

1719
public override void Update(HotSpot spot)
1820
{
1921
base.Update(spot);
2022

21-
if (spot.Id == 0)
23+
if (spot.Id == 0 || spot.Id == 1)
2224
{
23-
if (short.TryParse(spot.Text, out var val))
25+
if (short.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && short.TryParse(hexValue, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
2426
{
2527
spot.Memory.Process.WriteRemoteMemory(spot.Address, val);
2628
}

ReClass.NET/Nodes/Int32Node.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
2+
using System.Globalization;
23
using ReClassNET.Memory;
34
using ReClassNET.UI;
5+
using ReClassNET.Util;
46

57
namespace ReClassNET.Nodes
68
{
@@ -11,16 +13,16 @@ public class Int32Node : BaseNumericNode
1113
public override Size Draw(ViewInfo view, int x, int y)
1214
{
1315
var value = ReadValueFromMemory(view.Memory);
14-
return DrawNumeric(view, x, y, Icons.Signed, "Int32", $"{value} (0x{value:X})");
16+
return DrawNumeric(view, x, y, Icons.Signed, "Int32", value.ToString(), $"0x{value:X}");
1517
}
1618

1719
public override void Update(HotSpot spot)
1820
{
1921
base.Update(spot);
2022

21-
if (spot.Id == 0)
23+
if (spot.Id == 0 || spot.Id == 1)
2224
{
23-
if (int.TryParse(spot.Text, out var val))
25+
if (int.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && int.TryParse(hexValue, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
2426
{
2527
spot.Memory.Process.WriteRemoteMemory(spot.Address, val);
2628
}

ReClass.NET/Nodes/Int64Node.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
2+
using System.Globalization;
23
using ReClassNET.Memory;
34
using ReClassNET.UI;
5+
using ReClassNET.Util;
46

57
namespace ReClassNET.Nodes
68
{
@@ -11,16 +13,16 @@ public class Int64Node : BaseNumericNode
1113
public override Size Draw(ViewInfo view, int x, int y)
1214
{
1315
var value = ReadValueFromMemory(view.Memory);
14-
return DrawNumeric(view, x, y, Icons.Signed, "Int64", $"{value} (0x{value:X})");
16+
return DrawNumeric(view, x, y, Icons.Signed, "Int64", value.ToString(), $"0x{value:X}");
1517
}
1618

1719
public override void Update(HotSpot spot)
1820
{
1921
base.Update(spot);
2022

21-
if (spot.Id == 0)
23+
if (spot.Id == 0 || spot.Id == 1)
2224
{
23-
if (long.TryParse(spot.Text, out var val))
25+
if (long.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && long.TryParse(hexValue, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
2426
{
2527
spot.Memory.Process.WriteRemoteMemory(spot.Address, val);
2628
}

ReClass.NET/Nodes/Int8Node.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
2+
using System.Globalization;
23
using ReClassNET.Memory;
34
using ReClassNET.UI;
5+
using ReClassNET.Util;
46

57
namespace ReClassNET.Nodes
68
{
@@ -11,16 +13,16 @@ public class Int8Node : BaseNumericNode
1113
public override Size Draw(ViewInfo view, int x, int y)
1214
{
1315
var value = ReadValueFromMemory(view.Memory);
14-
return DrawNumeric(view, x, y, Icons.Signed, "Int8", $"{value} (0x{value:X})");
16+
return DrawNumeric(view, x, y, Icons.Signed, "Int8", value.ToString(), $"0x{value:X}");
1517
}
1618

1719
public override void Update(HotSpot spot)
1820
{
1921
base.Update(spot);
2022

21-
if (spot.Id == 0)
23+
if (spot.Id == 0 || spot.Id == 1)
2224
{
23-
if (sbyte.TryParse(spot.Text, out var val))
25+
if (sbyte.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && sbyte.TryParse(hexValue, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
2426
{
2527
spot.Memory.Process.WriteRemoteMemory(spot.Address, val);
2628
}

ReClass.NET/Nodes/UInt16Node.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
2+
using System.Globalization;
23
using ReClassNET.Memory;
34
using ReClassNET.UI;
5+
using ReClassNET.Util;
46

57
namespace ReClassNET.Nodes
68
{
@@ -11,16 +13,16 @@ public class UInt16Node : BaseNumericNode
1113
public override Size Draw(ViewInfo view, int x, int y)
1214
{
1315
var value = ReadValueFromMemory(view.Memory);
14-
return DrawNumeric(view, x, y, Icons.Unsigned, "UInt16", $"{value} (0x{value:X})");
16+
return DrawNumeric(view, x, y, Icons.Unsigned, "UInt16", value.ToString(), $"0x{value:X}");
1517
}
1618

1719
public override void Update(HotSpot spot)
1820
{
1921
base.Update(spot);
2022

21-
if (spot.Id == 0)
23+
if (spot.Id == 0 || spot.Id == 1)
2224
{
23-
if (ushort.TryParse(spot.Text, out var val))
25+
if (ushort.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && ushort.TryParse(hexValue, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
2426
{
2527
spot.Memory.Process.WriteRemoteMemory(spot.Address, val);
2628
}

ReClass.NET/Nodes/UInt32Node.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
2+
using System.Globalization;
23
using ReClassNET.Memory;
34
using ReClassNET.UI;
5+
using ReClassNET.Util;
46

57
namespace ReClassNET.Nodes
68
{
@@ -11,16 +13,16 @@ public class UInt32Node : BaseNumericNode
1113
public override Size Draw(ViewInfo view, int x, int y)
1214
{
1315
var value = ReadValueFromMemory(view.Memory);
14-
return DrawNumeric(view, x, y, Icons.Unsigned, "UInt32", $"{value} (0x{value:X})");
16+
return DrawNumeric(view, x, y, Icons.Unsigned, "UInt32", value.ToString(), $"0x{value:X}");
1517
}
1618

1719
public override void Update(HotSpot spot)
1820
{
1921
base.Update(spot);
2022

21-
if (spot.Id == 0)
23+
if (spot.Id == 0 || spot.Id == 1)
2224
{
23-
if (uint.TryParse(spot.Text, out var val))
25+
if (uint.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && uint.TryParse(hexValue, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
2426
{
2527
spot.Memory.Process.WriteRemoteMemory(spot.Address, val);
2628
}

0 commit comments

Comments
 (0)