This repository has been archived on 2025-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
ShiftOS_TheReturn/ShiftOS.Objects/UserConfig.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2017-05-21 08:21:41 -04: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 10:18:55 -04:00
public string Language { get; set; }
2017-05-21 08:21:41 -04:00
public string DigitalSocietyAddress { get; set; }
public int DigitalSocietyPort { get; set; }
2017-07-25 23:25:52 -04:00
public int ScreenWidth = 1920;
public int ScreenHeight = 1080;
public bool Fullscreen = true;
2017-05-21 08:21:41 -04:00
private static UserConfig def = new UserConfig
{
Language = "english",
DigitalSocietyAddress = "michaeltheshifter.me",
DigitalSocietyPort = 13370,
Fullscreen = true,
ScreenWidth = 1920,
ScreenHeight = 1080,
2017-05-21 08:21:41 -04:00
};
public static UserConfig current = null;
public static UserConfig Get()
{
if (current != null)
return current;
2017-07-25 23:25:52 -04:00
if (File.Exists("config.json"))
current = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("config.json"));
2017-05-21 08:21:41 -04:00
else
{
2017-07-25 23:25:52 -04:00
File.WriteAllText("config.json", JsonConvert.SerializeObject(def, Formatting.Indented));
current = def;
2017-05-21 08:21:41 -04:00
}
return current;
2017-05-21 08:21:41 -04:00
}
}
}