forked from Da-Teach/Questor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cs
260 lines (193 loc) · 10.1 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
// ------------------------------------------------------------------------------
// <copyright from='2010' to='2015' company='THEHACKERWITHIN.COM'>
// Copyright (c) TheHackerWithin.COM. All Rights Reserved.
//
// Please look in the accompanying license.htm file for the license that
// applies to this source code. (a copy can also be found at:
// http://www.thehackerwithin.com/license.htm)
// </copyright>
// -------------------------------------------------------------------------------
namespace Questor.Modules
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml.Linq;
public class Settings
{
/// <summary>
/// Singleton implementation
/// </summary>
public static Settings Instance = new Settings();
private string _characterName;
private DateTime _lastModifiedDate;
public Settings()
{
Ammo = new List<Ammo>();
Blacklist = new List<string>();
}
public bool DebugStates { get; set; }
public bool DebugPerformance { get; set; }
public bool AutoStart { get; set; }
public int RandomDelay { get; set; }
public bool EnableStorylines { get; set; }
public string CombatShipName { get; set; }
public string SalvageShipName { get; set; }
public string LootHangar { get; set; }
public string AmmoHangar { get; set; }
public bool CreateSalvageBookmarks { get; set; }
public string BookmarkPrefix { get; set; }
public int MinimumWreckCount { get; set; }
public bool AfterMissionSalvaging { get; set; }
public bool UnloadLootAtStation { get; set; }
public string AgentName { get; set; }
public string MissionsPath { get; set; }
public int MaximumHighValueTargets { get; set; }
public int MaximumLowValueTargets { get; set; }
public List<Ammo> Ammo { get; private set; }
public int MinimumAmmoCharges { get; set; }
public int WeaponGroupId { get; set; }
public int ReserveCargoCapacity { get; set; }
public int MaximumWreckTargets { get; set; }
public bool SpeedTank { get; set; }
public int OrbitDistance { get; set; }
public int ActivateRepairModules { get; set; }
public int DeactivateRepairModules { get; set; }
public int MinimumShieldPct { get; set; }
public int MinimumArmorPct { get; set; }
public int MinimumCapacitorPct { get; set; }
public int SafeShieldPct { get; set; }
public int SafeArmorPct { get; set; }
public int SafeCapacitorPct { get; set; }
public bool LootEverything { get; set; }
public bool UseDrones { get; set; }
public int DroneTypeId { get; set; }
public int DroneControlRange { get; set; }
public int DroneMinimumShieldPct { get; set; }
public int DroneMinimumArmorPct { get; set; }
public int DroneMinimumCapacitorPct { get; set; }
public int DroneRecallShieldPct { get; set; }
public int DroneRecallArmorPct { get; set; }
public int DroneRecallCapacitorPct { get; set; }
public int LongRangeDroneRecallShieldPct { get; set; }
public int LongRangeDroneRecallArmorPct { get; set; }
public int LongRangeDroneRecallCapacitorPct { get; set; }
public List<string> Blacklist { get; private set; }
public int? WindowXPosition { get; set; }
public int? WindowYPosition { get; set; }
public event EventHandler<EventArgs> SettingsLoaded;
public void LoadSettings()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var settingsPath = Path.Combine(path, Cache.Instance.FilterPath(_characterName) + ".xml");
var reloadSettings = _characterName != Cache.Instance.DirectEve.Me.Name;
if (File.Exists(settingsPath))
reloadSettings = _lastModifiedDate != File.GetLastWriteTime(settingsPath);
if (!reloadSettings)
return;
_characterName = Cache.Instance.DirectEve.Me.Name;
_lastModifiedDate = File.GetLastWriteTime(settingsPath);
if (!File.Exists(settingsPath))
{
// Clear settings
AgentName = string.Empty;
AutoStart = false;
RandomDelay = 0;
WindowXPosition = null;
WindowYPosition = null;
LootHangar = string.Empty;
AmmoHangar = string.Empty;
MissionsPath = Path.Combine(path, "Missions");
MaximumHighValueTargets = 0;
MaximumLowValueTargets = 0;
Ammo.Clear();
MinimumAmmoCharges = 0;
WeaponGroupId = 0;
ReserveCargoCapacity = 0;
MaximumWreckTargets = 0;
SpeedTank = false;
OrbitDistance = 0;
ActivateRepairModules = 0;
DeactivateRepairModules = 0;
MinimumShieldPct = 0;
MinimumArmorPct = 0;
MinimumCapacitorPct = 0;
SafeShieldPct = 0;
SafeArmorPct = 0;
SafeCapacitorPct = 0;
UseDrones = false;
DroneTypeId = 0;
DroneControlRange = 0;
DroneMinimumShieldPct = 0;
DroneMinimumArmorPct = 0;
DroneMinimumCapacitorPct = 0;
DroneRecallCapacitorPct = 0;
LongRangeDroneRecallCapacitorPct = 0;
Blacklist.Clear();
return;
}
var xml = XDocument.Load(settingsPath).Root;
DebugStates = (bool?) xml.Element("debugStates") ?? false;
DebugPerformance = (bool?) xml.Element("debugPerformance") ?? false;
AutoStart = (bool?) xml.Element("autoStart") ?? false;
RandomDelay = (int?) xml.Element("randomDelay") ?? 0;
EnableStorylines = (bool?) xml.Element("enableStorylines") ?? false;
WindowXPosition = (int?) xml.Element("windowXPosition");
WindowYPosition = (int?) xml.Element("windowYPosition");
CombatShipName = (string) xml.Element("combatShipName");
SalvageShipName = (string) xml.Element("salvageShipName");
LootHangar = (string) xml.Element("lootHangar");
AmmoHangar = (string) xml.Element("ammoHangar");
CreateSalvageBookmarks = (bool?) xml.Element("createSalvageBookmarks") ?? false;
BookmarkPrefix = (string) xml.Element("bookmarkPrefix") ?? "Salvage:";
MinimumWreckCount = (int?) xml.Element("minimumWreckCount") ?? 1;
AfterMissionSalvaging = (bool?) xml.Element("afterMissionSalvaging") ?? false;
UnloadLootAtStation = (bool?) xml.Element("unloadLootAtStation") ?? false;
AgentName = (string) xml.Element("agentName");
var missionsPath = (string) xml.Element("missionsPath");
MissionsPath = !string.IsNullOrEmpty(missionsPath) ? Path.Combine(path, missionsPath) : Path.Combine(path, "Missions");
MaximumHighValueTargets = (int?) xml.Element("maximumHighValueTargets") ?? 2;
MaximumLowValueTargets = (int?) xml.Element("maximumLowValueTargets") ?? 2;
Ammo.Clear();
var ammoTypes = xml.Element("ammoTypes");
if (ammoTypes != null)
foreach (var ammo in ammoTypes.Elements("ammoType"))
Ammo.Add(new Ammo(ammo));
MinimumAmmoCharges = (int?) xml.Element("minimumAmmoCharges") ?? 0;
WeaponGroupId = (int?) xml.Element("weaponGroupId") ?? 0;
ReserveCargoCapacity = (int?) xml.Element("reserveCargoCapacity") ?? 0;
MaximumWreckTargets = (int?) xml.Element("maximumWreckTargets") ?? 0;
SpeedTank = (bool?) xml.Element("speedTank") ?? false;
OrbitDistance = (int?) xml.Element("orbitDistance") ?? 0;
ActivateRepairModules = (int?) xml.Element("activateRepairModules") ?? 65;
DeactivateRepairModules = (int?) xml.Element("deactivateRepairModules") ?? 95;
MinimumShieldPct = (int?) xml.Element("minimumShieldPct") ?? 100;
MinimumArmorPct = (int?) xml.Element("minimumArmorPct") ?? 100;
MinimumCapacitorPct = (int?) xml.Element("minimumCapacitorPct") ?? 50;
SafeShieldPct = (int?)xml.Element("safeShieldPct") ?? 0;
SafeArmorPct = (int?)xml.Element("safeArmorPct") ?? 0;
SafeCapacitorPct = (int?)xml.Element("safeCapacitorPct") ?? 0;
LootEverything = (bool?) xml.Element("lootEverything") ?? true;
UseDrones = (bool?) xml.Element("useDrones") ?? true;
DroneTypeId = (int?) xml.Element("droneTypeId") ?? 0;
DroneControlRange = (int?) xml.Element("droneControlRange") ?? 0;
DroneMinimumShieldPct = (int?) xml.Element("droneMinimumShieldPct") ?? 50;
DroneMinimumArmorPct = (int?) xml.Element("droneMinimumArmorPct") ?? 50;
DroneMinimumCapacitorPct = (int?) xml.Element("droneMinimumCapacitorPct") ?? 0;
DroneRecallShieldPct = (int?) xml.Element("droneRecallShieldPct") ?? 0;
DroneRecallArmorPct = (int?) xml.Element("droneRecallArmorPct") ?? 0;
DroneRecallCapacitorPct = (int?) xml.Element("droneRecallCapacitorPct") ?? 0;
LongRangeDroneRecallShieldPct = (int?) xml.Element("longRangeDroneRecallShieldPct") ?? 0;
LongRangeDroneRecallArmorPct = (int?) xml.Element("longRangeDroneRecallArmorPct") ?? 0;
LongRangeDroneRecallCapacitorPct = (int?) xml.Element("longRangeDroneRecallCapacitorPct") ?? 0;
Blacklist.Clear();
var blacklist = xml.Element("blacklist");
if (blacklist != null)
foreach (var mission in blacklist.Elements("mission"))
Blacklist.Add((string) mission);
if (SettingsLoaded != null)
SettingsLoaded(this, new EventArgs());
}
}
}