Skip to content

Commit 5f4a79c

Browse files
committed
Use proper highlighting.
1 parent 36b71d0 commit 5f4a79c

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

Nodes/BaseHexNode.cs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
using System.Diagnostics.Contracts;
44
using System.Globalization;
55
using ReClassNET.UI;
6+
using ReClassNET.Util;
67

78
namespace ReClassNET.Nodes
89
{
910
public abstract class BaseHexNode : BaseNode
1011
{
11-
private readonly byte[] buffer;
12-
private DateTime highlightUntil;
13-
private readonly Dictionary<IntPtr, Tuple<byte[], DateTime>> highlightHistory;
14-
1512
public static DateTime CurrentHighlightTime;
1613
public static readonly TimeSpan HightlightDuration = TimeSpan.FromSeconds(1);
1714

15+
private static readonly Dictionary<IntPtr, ValueTypeWrapper<DateTime>> highlight = new Dictionary<IntPtr, ValueTypeWrapper<DateTime>>();
16+
17+
private readonly byte[] buffer;
18+
1819
protected BaseHexNode()
1920
{
2021
Contract.Ensures(buffer != null);
2122

2223
buffer = new byte[MemorySize];
23-
highlightHistory = new Dictionary<IntPtr, Tuple<byte[], DateTime>>();
2424
}
2525

2626
protected int Draw(ViewInfo view, int x, int y, string text, int length)
@@ -47,9 +47,35 @@ protected int Draw(ViewInfo view, int x, int y, string text, int length)
4747

4848
view.Memory.ReadBytes(Offset, buffer);
4949

50-
var color = view.Settings.HighlightChangedValues && view.Memory.HasChanged(Offset, MemorySize)
51-
? view.Settings.HighlightColor
52-
: view.Settings.HexColor;
50+
var color = view.Settings.HexColor;
51+
if (view.Settings.HighlightChangedValues)
52+
{
53+
var address = view.Address.Add(Offset);
54+
55+
ValueTypeWrapper<DateTime> until;
56+
if (highlight.TryGetValue(address, out until))
57+
{
58+
if (until.Value >= CurrentHighlightTime)
59+
{
60+
color = view.Settings.HighlightColor;
61+
62+
if (view.Memory.HasChanged(Offset, MemorySize))
63+
{
64+
until.Value = CurrentHighlightTime.Add(HightlightDuration);
65+
}
66+
}
67+
else
68+
{
69+
highlight.Remove(address);
70+
}
71+
}
72+
else if (view.Memory.HasChanged(Offset, MemorySize))
73+
{
74+
highlight.Add(address, CurrentHighlightTime.Add(HightlightDuration));
75+
76+
color = view.Settings.HighlightColor;
77+
}
78+
}
5379

5480
for (var i = 0; i < length; ++i)
5581
{

0 commit comments

Comments
 (0)