-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathBoolNode.cs
More file actions
68 lines (53 loc) · 1.8 KB
/
BoolNode.cs
File metadata and controls
68 lines (53 loc) · 1.8 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
using System.Drawing;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public class BoolNode : BaseNumericNode
{
/// <summary>Size of the node in bytes.</summary>
public override int MemorySize => 1;
/// <summary>Draws this node.</summary>
/// <param name="view">The view information.</param>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <returns>The pixel size the node occupies.</returns>
public override Size Draw(ViewInfo view, int x, int y)
{
if (IsHidden)
{
return DrawHidden(view, x, y);
}
DrawInvalidMemoryIndicator(view, y);
var origX = x;
AddSelection(view, x, y, view.Font.Height);
x += TextPadding + Icons.Dimensions;
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, "Bool") + view.Font.Width;
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NoneId, "=") + view.Font.Width;
var value = view.Memory.ReadUInt8(Offset);
x = AddText(view, x, y, view.Settings.ValueColor, 0, value == 0 ? "false" : "true") + view.Font.Width;
x = AddComment(view, x, y);
AddTypeDrop(view, y);
AddDelete(view, y);
return new Size(x - origX, view.Font.Height);
}
public override int CalculateDrawnHeight(ViewInfo view)
{
return IsHidden ? HiddenHeight : view.Font.Height;
}
/// <summary>Updates the node from the given spot and sets the value.</summary>
/// <param name="spot">The spot.</param>
public override void Update(HotSpot spot)
{
base.Update(spot);
if (spot.Id == 0)
{
if (bool.TryParse(spot.Text, out var val))
{
spot.Memory.Process.WriteRemoteMemory(spot.Address, (byte)(val ? 1 : 0));
}
}
}
}
}