-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathChangeSet.cs
69 lines (63 loc) · 1.49 KB
/
ChangeSet.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
using System;
using System.Collections.Generic;
using UnityEngine;
namespace KerbalChangelog
{
public class ChangeSet : IComparable
{
public ChangelogVersion version { get; private set; }
List<Change> changes = new List<Change>();
public ChangeSet(ChangelogVersion v, List<Change> ch)
{
version = v;
changes = ch;
}
public ChangeSet(ConfigNode vn, string cfgDirName)
{
string _version = "";
if (!vn.TryGetValue("version", ref _version))
{
Debug.Log("[KCL] Badly formatted version in directory " + cfgDirName);
_version = "null";
}
string _versionName = "";
if(!vn.TryGetValue("versionName", ref _versionName))
{
version = new ChangelogVersion(_version, cfgDirName);
}
else
{
version = new ChangelogVersion(_version, cfgDirName, _versionName);
}
//loads change fields (needed for backwards compatibility
foreach (string change in vn.GetValues("change"))
{
changes.Add(new Change(change, new List<string>()));
}
//loads change nodes
foreach(ConfigNode chn in vn.GetNodes("CHANGE"))
{
changes.Add(new Change(chn, cfgDirName));
}
}
public override string ToString()
{
string ret = version + "\n";
foreach (Change c in changes)
{
ret += c.ToString();
}
return ret + "\n";
}
public int CompareTo(object obj)
{
if (obj == null)
return 1;
if (obj is ChangeSet cs)
{
return version.CompareTo(cs.version);
}
throw new ArgumentException("Object is not a ChangeSet");
}
}
}