-
Notifications
You must be signed in to change notification settings - Fork 6
/
DishonoredSettings.cs
124 lines (103 loc) · 6.72 KB
/
DishonoredSettings.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
using System;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
namespace LiveSplit.Dishonored
{
public partial class DishonoredSettings : UserControl
{
public bool AutoStart { get; set; }
public bool AutoReset { get; set; }
public bool ResetProtection { get; set; }
public bool AutoSplitIntroEnd { get; set; }
public bool AutoSplitMissionEnd { get; set; }
public bool AutoSplitPrisonEscape { get; set; }
public bool AutoSplitOutsidersDream { get; set; }
public bool AutoSplitWeepers { get; set; }
public bool AutoSplitEmily { get; set; }
public bool AutoSplitDLC06IntroEnd { get; set; }
public bool EnableSpeedups { get; set; }
public bool SpeedupMovies { get; set; }
public bool SpeedupInGameCutscenes { get; set; }
public bool SpeedupLoadDelays { get; set; }
public bool SpeedupLoadPositions { get; set; }
public DishonoredSettings()
{
InitializeComponent();
chkAutoStart.DataBindings.Add("Checked", this, "AutoStart", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoReset.DataBindings.Add("Checked", this, "AutoReset", false, DataSourceUpdateMode.OnPropertyChanged);
chkResetProtection.DataBindings.Add("Checked", this, "ResetProtection", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitIntroEnd.DataBindings.Add("Checked", this, "AutoSplitIntroEnd", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitMissionEnd.DataBindings.Add("Checked", this, "AutoSplitMissionEnd", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitPrisonEscape.DataBindings.Add("Checked", this, "AutoSplitPrisonEscape", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitOutsidersDream.DataBindings.Add("Checked", this, "AutoSplitOutsidersDream", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitWeepers.DataBindings.Add("Checked", this, "AutoSplitWeepers", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitEmily.DataBindings.Add("Checked", this, "AutoSplitEmily", false, DataSourceUpdateMode.OnPropertyChanged);
chkAutoSplitDLC06IntroEnd.DataBindings.Add("Checked", this, "AutoSplitDLC06IntroEnd", false, DataSourceUpdateMode.OnPropertyChanged);
chkEnableSpeedups.DataBindings.Add("Checked", this, "EnableSpeedups", false, DataSourceUpdateMode.OnPropertyChanged);
chkSpeedupMovies.DataBindings.Add("Checked", this, "SpeedupMovies", false, DataSourceUpdateMode.OnPropertyChanged);
chkSpeedupInGameCutscenes.DataBindings.Add("Checked", this, "SpeedupInGameCutscenes", false, DataSourceUpdateMode.OnPropertyChanged);
chkSpeedupLoadDelays.DataBindings.Add("Checked", this, "SpeedupLoadDelays", false, DataSourceUpdateMode.OnPropertyChanged);
chkSpeedupLoadPositions.DataBindings.Add("Checked", this, "SpeedupLoadPositions", false, DataSourceUpdateMode.OnPropertyChanged);
// defaults
AutoStart = true;
AutoReset = true;
SpeedupMovies = true;
SpeedupInGameCutscenes = true;
SpeedupLoadDelays = true;
SpeedupLoadPositions = true;
}
public XmlNode GetSettings(XmlDocument doc)
{
XmlElement settingsNode = doc.CreateElement("Settings");
settingsNode.AppendChild(ToElement(doc, "Version", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)));
settingsNode.AppendChild(ToElement(doc, "AutoStart", AutoStart));
settingsNode.AppendChild(ToElement(doc, "AutoReset", AutoReset));
settingsNode.AppendChild(ToElement(doc, "ResetProtection", ResetProtection));
settingsNode.AppendChild(ToElement(doc, "AutoSplitIntroEnd", AutoSplitIntroEnd));
settingsNode.AppendChild(ToElement(doc, "AutoSplitMissionEnd", AutoSplitMissionEnd));
settingsNode.AppendChild(ToElement(doc, "AutoSplitPrisonEscape", AutoSplitPrisonEscape));
settingsNode.AppendChild(ToElement(doc, "AutoSplitOutsidersDream", AutoSplitOutsidersDream));
settingsNode.AppendChild(ToElement(doc, "AutoSplitWeepers", AutoSplitWeepers));
settingsNode.AppendChild(ToElement(doc, "AutoSplitEmily", AutoSplitEmily));
settingsNode.AppendChild(ToElement(doc, "AutoSplitDLC06IntroEnd", AutoSplitDLC06IntroEnd));
settingsNode.AppendChild(ToElement(doc, "EnableSpeedups", EnableSpeedups));
settingsNode.AppendChild(ToElement(doc, "SpeedupMovies", SpeedupMovies));
settingsNode.AppendChild(ToElement(doc, "SpeedupInGameCutscenes", SpeedupInGameCutscenes));
settingsNode.AppendChild(ToElement(doc, "SpeedupLoadDelays", SpeedupLoadDelays));
settingsNode.AppendChild(ToElement(doc, "SpeedupLoadPositions", SpeedupLoadPositions));
return settingsNode;
}
public void SetSettings(XmlNode settings)
{
var autoStartEnd = ParseBool(settings, "AutoStartEnd", true);
AutoStart = ParseBool(settings, "AutoStart", autoStartEnd);
AutoReset = ParseBool(settings, "AutoReset", autoStartEnd);
ResetProtection = ParseBool(settings, "ResetProtection");
AutoSplitIntroEnd = ParseBool(settings, "AutoSplitIntroEnd");
AutoSplitMissionEnd = ParseBool(settings, "AutoSplitMissionEnd");
AutoSplitPrisonEscape = ParseBool(settings, "AutoSplitPrisonEscape");
AutoSplitOutsidersDream = ParseBool(settings, "AutoSplitOutsidersDream");
AutoSplitWeepers = ParseBool(settings, "AutoSplitWeepers");
AutoSplitEmily = ParseBool(settings, "AutoSplitEmily", autoStartEnd);
AutoSplitDLC06IntroEnd = ParseBool(settings, "AutoSplitDLC06IntroEnd");
EnableSpeedups = ParseBool(settings, "EnableSpeedups");
SpeedupMovies = ParseBool(settings, "SpeedupMovies", true);
SpeedupInGameCutscenes = ParseBool(settings, "SpeedupInGameCutscenes", true);
SpeedupLoadDelays = ParseBool(settings, "SpeedupLoadDelays", true);
SpeedupLoadPositions = ParseBool(settings, "SpeedupLoadPositions", true);
}
static bool ParseBool(XmlNode settings, string setting, bool default_ = false)
{
return settings[setting] != null ?
(Boolean.TryParse(settings[setting].InnerText, out var val) ? val : default_)
: default_;
}
static XmlElement ToElement<T>(XmlDocument document, string name, T value)
{
XmlElement str = document.CreateElement(name);
str.InnerText = value.ToString();
return str;
}
}
}