forked from austinvaness/CameraLCD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraLCDSettings.cs
More file actions
60 lines (52 loc) · 1.74 KB
/
CameraLCDSettings.cs
File metadata and controls
60 lines (52 loc) · 1.74 KB
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
using Sandbox.ModAPI;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using VRage.FileSystem;
namespace avaness.CameraLCD
{
public class CameraLCDSettings
{
private const string fileName = "CameraLCDSettings.xml";
private static string FilePath => Path.Combine(MyFileSystem.UserDataPath, "Storage", fileName);
protected CameraLCDSettings()
{ }
public bool Enabled { get; set; } = true;
public int Ratio { get; set; } = 2;
public bool UpdateLOD { get; set; } = false;
public bool HeadFix { get; set; } = true;
public int Range { get; set; } = 40;
public bool LockAspectRatio { get; set; } = false;
public static CameraLCDSettings Load()
{
string file = FilePath;
if(File.Exists(file))
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(CameraLCDSettings));
using (XmlReader xml = XmlReader.Create(file))
{
return (CameraLCDSettings)serializer.Deserialize(xml);
}
}
catch { }
}
return new CameraLCDSettings();
}
public void Save()
{
try
{
string file = FilePath;
Directory.CreateDirectory(Path.GetDirectoryName(file));
XmlSerializer serializer = new XmlSerializer(typeof(CameraLCDSettings));
using (StreamWriter stream = File.CreateText(file))
{
serializer.Serialize(stream, this);
}
}
catch { }
}
}
}