-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOptionsData.cs
42 lines (37 loc) · 1.21 KB
/
OptionsData.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
using System;
using System.Collections.Generic;
using System.IO;
namespace JxUnity.SaveDatas
{
public static class OptionsData
{
public static SaveData Data { get; private set; }
public static readonly string WorkingFolderName = "Config";
public static readonly string Filename = "Options.cfg";
public static readonly string FullFilename = WorkingFolderName + "/" + Filename;
public static readonly string WorkingFolderPath = PathHelper.GetWritablePath() + "/" + WorkingFolderName;
public static void Reload()
{
if (!File.Exists(FullFilename))
{
Data = new SaveData();
return;
}
var fs = File.Open(FullFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
Data = SaveData.Load(fs);
fs.Close();
}
public static void Save()
{
if (Data == null)
{
return;
}
if (!Directory.Exists(WorkingFolderPath))
{
Directory.CreateDirectory(WorkingFolderPath);
}
File.WriteAllText(FullFilename, Data.SerializeText());
}
}
}