Skip to content

Commit b4aadd5

Browse files
committed
Merge pull request #37 from Apokee/topic/fix_configuration_reverting
Fix configuration reverting
2 parents 1ba386d + d9a2bbc commit b4aadd5

File tree

4 files changed

+9
-45
lines changed

4 files changed

+9
-45
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## v0.4.1-alpha
2+
##### Fixes
3+
- Fix for configuration settings reverting to default after two reloads of KSP.
24

35
## v0.4.0
46
##### New

Source/HotSpot/Configuration/ContextMenu/MetricNode.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,23 @@ namespace HotSpot.Configuration.ContextMenu
55
{
66
internal sealed class MetricNode
77
{
8-
private readonly bool _origEnable;
9-
private readonly Unit _origUnit;
10-
118
public Metric Name { get; }
129
public bool Enable { get; set; }
1310
public Unit Unit { get; set; }
1411

1512
private MetricNode(Metric name, bool enable, Unit unit)
1613
{
17-
_origEnable = enable;
18-
_origUnit = unit;
19-
2014
Name = name;
2115
Enable = enable;
2216
Unit = unit;
2317
}
2418

2519
public bool Save(ConfigNode node)
2620
{
27-
var save = false;
28-
29-
if (_origEnable != Enable)
30-
{
31-
node.AddValue("%enable", Enable);
32-
save = true;
33-
}
34-
35-
if (_origUnit != Unit)
36-
{
37-
node.AddValue("%unit", Unit);
38-
save = true;
39-
}
21+
node.AddValue("%enable", Enable);
22+
node.AddValue("%unit", Unit);
4023

41-
return save;
24+
return true;
4225
}
4326

4427
public static MetricNode TryParse(ConfigNode node)

Source/HotSpot/Configuration/Overlay/MetricNode.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ namespace HotSpot.Configuration.Overlay
77
{
88
internal sealed class MetricNode
99
{
10-
private readonly string _origScheme;
11-
1210
private readonly Dictionary<string, SchemeNode> _schemesDictionary;
1311

1412
public Metric Name { get; }
@@ -17,8 +15,6 @@ internal sealed class MetricNode
1715

1816
private MetricNode(Metric name, string scheme, SchemeNode[] schemes)
1917
{
20-
_origScheme = scheme;
21-
2218
Name = name;
2319
Scheme = scheme;
2420
Schemes = schemes;
@@ -32,15 +28,9 @@ public SchemeNode GetActiveScheme()
3228

3329
public bool Save(ConfigNode node)
3430
{
35-
var save = false;
36-
37-
if (_origScheme != Scheme)
38-
{
39-
node.AddValue("%scheme", Scheme);
40-
save = true;
41-
}
31+
node.AddValue("%scheme", Scheme);
4232

43-
return save;
33+
return true;
4434
}
4535

4636
public static MetricNode TryParse(ConfigNode node)

Source/HotSpot/Configuration/OverlayNode.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ internal sealed class OverlayNode
1010
{
1111
private readonly Dictionary<string, MetricNode> _metricsDictionary;
1212

13-
private readonly string _origMetric;
14-
1513
public bool Enable { get; }
1614
public bool EnableScreenMessage { get; }
1715
public Metric Metric { get; set; }
1816
public MetricNode[] Metrics { get; }
1917

2018
private OverlayNode(bool enable, bool enableScreenMessage, Metric metric, MetricNode[] metrics)
2119
{
22-
_origMetric = metric.Name;
23-
2420
Enable = enable;
2521
EnableScreenMessage = enableScreenMessage;
2622
Metric = metric;
@@ -35,13 +31,7 @@ public MetricNode GetActiveMetric()
3531

3632
public bool Save(ConfigNode node)
3733
{
38-
var save = false;
39-
40-
if (_origMetric != Metric.Name)
41-
{
42-
node.AddValue("%metric", Metric.Name);
43-
save = true;
44-
}
34+
node.AddValue("%metric", Metric.Name);
4535

4636
foreach (var metric in Metrics)
4737
{
@@ -50,11 +40,10 @@ public bool Save(ConfigNode node)
5040
if (metric.Save(metricNode))
5141
{
5242
node.AddNode(metricNode);
53-
save = true;
5443
}
5544
}
5645

57-
return save;
46+
return true;
5847
}
5948

6049
public static OverlayNode GetDefault()

0 commit comments

Comments
 (0)