ShiftOS_TheReturn/ShiftOS.Objects/UserConfig.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2017-05-21 12:21:41 +00:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ShiftOS.Objects
{
public class UserConfig
{
2017-06-19 14:18:55 +00:00
public string Language { get; set; }
2017-05-21 12:21:41 +00:00
public string DigitalSocietyAddress { get; set; }
public int DigitalSocietyPort { get; set; }
2017-07-26 03:25:52 +00:00
public int ScreenWidth = 1920;
public int ScreenHeight = 1080;
2017-05-21 12:21:41 +00:00
private static UserConfig def = new UserConfig
2017-05-21 12:21:41 +00:00
{
2017-06-19 14:18:55 +00:00
Language = "english",
2017-05-21 12:21:41 +00:00
DigitalSocietyAddress = "michaeltheshifter.me",
DigitalSocietyPort = 13370
};
public static UserConfig current = null;
public static UserConfig Get()
{
if (current != null)
return current;
2017-07-26 03:25:52 +00:00
if (File.Exists("config.json"))
current = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("config.json"));
2017-05-21 12:21:41 +00:00
else
{
2017-07-26 03:25:52 +00:00
File.WriteAllText("config.json", JsonConvert.SerializeObject(def, Formatting.Indented));
current = def;
2017-05-21 12:21:41 +00:00
}
return current;
2017-05-21 12:21:41 +00:00
}
}
}