3
3
using System . Diagnostics . Contracts ;
4
4
using System . Globalization ;
5
5
using ReClassNET . UI ;
6
+ using ReClassNET . Util ;
6
7
7
8
namespace ReClassNET . Nodes
8
9
{
9
10
public abstract class BaseHexNode : BaseNode
10
11
{
11
- private readonly byte [ ] buffer ;
12
- private DateTime highlightUntil ;
13
- private readonly Dictionary < IntPtr , Tuple < byte [ ] , DateTime > > highlightHistory ;
14
-
15
12
public static DateTime CurrentHighlightTime ;
16
13
public static readonly TimeSpan HightlightDuration = TimeSpan . FromSeconds ( 1 ) ;
17
14
15
+ private static readonly Dictionary < IntPtr , ValueTypeWrapper < DateTime > > highlight = new Dictionary < IntPtr , ValueTypeWrapper < DateTime > > ( ) ;
16
+
17
+ private readonly byte [ ] buffer ;
18
+
18
19
protected BaseHexNode ( )
19
20
{
20
21
Contract . Ensures ( buffer != null ) ;
21
22
22
23
buffer = new byte [ MemorySize ] ;
23
- highlightHistory = new Dictionary < IntPtr , Tuple < byte [ ] , DateTime > > ( ) ;
24
24
}
25
25
26
26
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)
47
47
48
48
view . Memory . ReadBytes ( Offset , buffer ) ;
49
49
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
+ }
53
79
54
80
for ( var i = 0 ; i < length ; ++ i )
55
81
{
0 commit comments