forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseMatrixNode.cs
More file actions
144 lines (108 loc) · 3.19 KB
/
BaseMatrixNode.cs
File metadata and controls
144 lines (108 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System.Diagnostics.Contracts;
using System.Drawing;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public abstract class BaseMatrixNode : BaseNode
{
/// <summary>Size of the value type in bytes.</summary>
public abstract int ValueTypeSize { get; }
protected BaseMatrixNode()
{
LevelsOpen.DefaultValue = true;
}
protected delegate void DrawMatrixValues(int x, ref int maxX, ref int y);
protected Size DrawMatrixType(ViewInfo view, int x, int y, string type, DrawMatrixValues drawValues)
{
Contract.Requires(view != null);
Contract.Requires(type != null);
Contract.Requires(drawValues != null);
if (IsHidden && !IsWrapped)
{
return DrawHidden(view, x, y);
}
var origX = x;
var origY = y;
AddSelection(view, x, y, view.Font.Height);
x += TextPadding;
x = AddIcon(view, x, y, Icons.Matrix, HotSpot.NoneId, HotSpotType.None);
var tx = x;
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
if (!IsWrapped)
{
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
}
x = AddOpenCloseIcon(view, x, y);
x += view.Font.Width;
x = AddComment(view, x, y);
DrawInvalidMemoryIndicatorIcon(view, y);
AddContextDropDownIcon(view, y);
AddDeleteIcon(view, y);
if (LevelsOpen[view.Level])
{
drawValues(tx, ref x, ref y);
}
return new Size(x - origX, y - origY + view.Font.Height);
}
protected delegate void DrawVectorValues(ref int x, ref int y);
protected Size DrawVectorType(ViewInfo view, int x, int y, string type, DrawVectorValues drawValues)
{
Contract.Requires(view != null);
Contract.Requires(type != null);
Contract.Requires(drawValues != null);
if (IsHidden && !IsWrapped)
{
return DrawHidden(view, x, y);
}
DrawInvalidMemoryIndicatorIcon(view, y);
var origX = x;
var origY = y;
AddSelection(view, x, y, view.Font.Height);
x += TextPadding;
x = AddIcon(view, x, y, Icons.Vector, HotSpot.NoneId, HotSpotType.None);
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
if (!IsWrapped)
{
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
}
x = AddOpenCloseIcon(view, x, y);
if (LevelsOpen[view.Level])
{
drawValues(ref x, ref y);
}
x += view.Font.Width;
x = AddComment(view, x, y);
AddContextDropDownIcon(view, y);
AddDeleteIcon(view, y);
return new Size(x - origX, y - origY + view.Font.Height);
}
public override int CalculateDrawnHeight(ViewInfo view)
{
if (IsHidden && !IsWrapped)
{
return HiddenHeight;
}
var height = view.Font.Height;
if (LevelsOpen[view.Level])
{
height += CalculateValuesHeight(view);
}
return height;
}
protected abstract int CalculateValuesHeight(ViewInfo view);
public void Update(HotSpot spot, int max)
{
Contract.Requires(spot != null);
base.Update(spot);
if (spot.Id >= 0 && spot.Id < max)
{
if (float.TryParse(spot.Text, out var val))
{
spot.Process.WriteRemoteMemory(spot.Address + spot.Id * ValueTypeSize, val);
}
}
}
}
}