This repository has been archived by the owner on Feb 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QS_Settings.cs
68 lines (58 loc) · 2.17 KB
/
QS_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
/*
QuickStart
Copyright 2016 Malah
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.IO;
namespace QuickStart {
public class QSettings : QuickStart {
[KSPField(isPersistant = true)] private static readonly QSettings instance = new QSettings ();
public static QSettings Instance {
get {
if (!instance.isLoaded) {
instance.Load ();
}
return instance;
}
}
internal static readonly string FileConfig = KSPUtil.ApplicationRootPath + "GameData/" + MOD + "/Config.txt";
[KSPField(isPersistant = true)] private bool isLoaded = false;
[Persistent] internal bool Enabled = true;
[Persistent] internal bool Debug = true;
[Persistent] internal float WaitLoading = 0.5f;
[Persistent] internal float editorTimeToSave = 30;
[Persistent] internal bool enableEditorAutoSaveShip = true;
[Persistent] internal bool enableEditorLoadAutoSave = true;
[Persistent] internal bool enablePauseOnFlight = true;
[Persistent] internal int gameScene = (int)GameScenes.SPACECENTER;
[Persistent] internal int editorFacility = (int)EditorFacility.VAB;
public void Save() {
ConfigNode _temp = ConfigNode.CreateConfigFromObject(this, new ConfigNode());
_temp.Save(FileConfig);
Log ("Settings Saved", "QSettings", true);
}
public void Load() {
if (File.Exists (FileConfig)) {
try {
ConfigNode _temp = ConfigNode.Load (FileConfig);
ConfigNode.LoadObjectFromConfig (this, _temp);
} catch {
Save ();
}
Log ("Settings Loaded", "QSettings", true);
} else {
Save ();
}
isLoaded = true;
}
}
}