forked from ReClassNET/ReClass.NET
/
Settings.cs
221 lines (159 loc) · 6.22 KB
/
Settings.cs
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
using System.Diagnostics.Contracts;
using System.Drawing;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using ReClassNET.Util;
namespace ReClassNET
{
public class Settings
{
public static Settings Load(string filename)
{
Contract.Requires(!string.IsNullOrEmpty(filename));
try
{
if (File.Exists(filename))
{
using (var sr = new StreamReader(filename))
{
return (Settings)new XmlSerializer(typeof(Settings)).Deserialize(sr);
}
}
}
catch
{
}
return new Settings();
}
public static void Save(Settings settings, string filename)
{
Contract.Requires(settings != null);
Contract.Requires(!string.IsNullOrEmpty(filename));
using (var sr = new StreamWriter(filename))
{
new XmlSerializer(typeof(Settings)).Serialize(sr, settings);
}
}
// Application Settings
public string LastProcess { get; set; } = string.Empty;
public bool StayOnTop { get; set; } = false;
// Node Drawing Settings
public bool ShowNodeAddress { get; set; } = true;
public bool ShowNodeOffset { get; set; } = true;
public bool ShowNodeText { get; set; } = true;
public bool HighlightChangedValues { get; set; } = true;
// Comment Drawing Settings
public bool ShowCommentFloat { get; set; } = true;
public bool ShowCommentInteger { get; set; } = true;
public bool ShowCommentPointer { get; set; } = true;
public bool ShowCommentRtti { get; set; } = true;
public bool ShowCommentSymbol { get; set; } = true;
public bool ShowCommentString { get; set; } = true;
public bool ShowCommentPluginInfo { get; set; } = true;
// Colors
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color BackgroundColor { get; set; } = Color.FromArgb(255, 255, 255);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color SelectedColor { get; set; } = Color.FromArgb(240, 240, 240);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color HiddenColor { get; set; } = Color.FromArgb(240, 240, 240);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color OffsetColor { get; set; } = Color.FromArgb(255, 0, 0);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color AddressColor { get; set; } = Color.FromArgb(0, 200, 0);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color HexColor { get; set; } = Color.FromArgb(0, 0, 0);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color TypeColor { get; set; } = Color.FromArgb(0, 0, 255);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color NameColor { get; set; } = Color.FromArgb(32, 32, 128);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color ValueColor { get; set; } = Color.FromArgb(255, 128, 0);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color IndexColor { get; set; } = Color.FromArgb(32, 200, 200);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color CommentColor { get; set; } = Color.FromArgb(0, 200, 0);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color TextColor { get; set; } = Color.FromArgb(0, 0, 255);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color VTableColor { get; set; } = Color.FromArgb(0, 255, 0);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color PluginColor { get; set; } = Color.FromArgb(255, 0, 255);
[XmlElement(Type = typeof(XmlColorWrapper))]
public Color CustomColor { get; set; } = Color.FromArgb(64, 128, 64);
private static readonly Color[] highlightColors = {
Color.Aqua, Color.Aquamarine, Color.Blue, Color.BlueViolet, Color.Chartreuse, Color.Crimson, Color.LawnGreen, Color.Magenta
};
[XmlIgnore]
public Color HighlightColor => highlightColors[Program.GlobalRandom.Next(highlightColors.Length)];
// Type Definitions
public string TypePadding { get; set; } = "char";
public string TypeBool { get; set; } = "bool";
public string TypeInt8 { get; set; } = "int8_t";
public string TypeInt16 { get; set; } = "int16_t";
public string TypeInt32 { get; set; } = "int32_t";
public string TypeInt64 { get; set; } = "int64_t";
public string TypeUInt8 { get; set; } = "uint8_t";
public string TypeUInt16 { get; set; } = "uint16_t";
public string TypeUInt32 { get; set; } = "uint32_t";
public string TypeUInt64 { get; set; } = "uint64_t";
public string TypeFloat { get; set; } = "float";
public string TypeDouble { get; set; } = "double";
public string TypeVector2 { get; set; } = "Vector2";
public string TypeVector3 { get; set; } = "Vector3";
public string TypeVector4 { get; set; } = "Vector4";
public string TypeMatrix3x3 { get; set; } = "Matrix3x3";
public string TypeMatrix3x4 { get; set; } = "Matrix3x4";
public string TypeMatrix4x4 { get; set; } = "Matrix4x4";
public string TypeUTF8Text { get; set; } = "char";
public string TypeUTF8TextPtr { get; set; } = "char*";
public string TypeUTF16Text { get; set; } = "wchar_t"; // Should be char16_t, but this type isn't well supported at the moment.
public string TypeUTF16TextPtr { get; set; } = "wchar_t*";
public string TypeUTF32Text { get; set; } = "char32_t";
public string TypeUTF32PtrText { get; set; } = "char32_t*";
public string TypeFunctionPtr { get; set; } = "void*";
public Settings Clone() => MemberwiseClone() as Settings;
}
public class XmlColorWrapper : IXmlSerializable
{
private Color color;
public XmlColorWrapper()
: this(Color.Empty)
{
}
public XmlColorWrapper(Color color)
{
this.color = color;
}
public XmlSchema GetSchema()
{
return null;
}
public void ReadXml(XmlReader reader)
{
color = Color.FromArgb((int)(0xFF000000 | reader.ReadElementContentAsInt()));
}
public void WriteXml(XmlWriter writer)
{
writer.WriteString(color.ToRgb().ToString());
}
public static implicit operator XmlColorWrapper(Color color)
{
if (color != Color.Empty)
{
return new XmlColorWrapper(color);
}
return null;
}
public static implicit operator Color(XmlColorWrapper wrapper)
{
if (wrapper != null)
{
return wrapper.color;
}
return Color.Empty;
}
}
}