2015-06-02 17:52:22 -06:00
|
|
|
|
using System;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2015-06-16 21:32:07 -04:00
|
|
|
|
namespace TrueCraft.Core
|
2015-06-02 17:52:22 -06:00
|
|
|
|
{
|
|
|
|
|
public class UserSettings
|
|
|
|
|
{
|
|
|
|
|
public static UserSettings Local { get; set; }
|
|
|
|
|
|
2015-06-02 18:40:53 -06:00
|
|
|
|
public static string SettingsPath
|
2015-06-02 17:52:22 -06:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2015-06-02 18:40:53 -06:00
|
|
|
|
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
|
|
|
|
".truecraft", "settings.json");
|
2015-06-02 17:52:22 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AutoLogin { get; set; }
|
|
|
|
|
public string Username { get; set; }
|
|
|
|
|
public string Password { get; set; }
|
2015-06-02 18:40:53 -06:00
|
|
|
|
public string LastIP { get; set; }
|
2015-06-16 21:32:07 -04:00
|
|
|
|
public string SelectedTexturePack { get; set; }
|
2015-06-02 18:40:53 -06:00
|
|
|
|
public FavoriteServer[] FavoriteServers { get; set; }
|
2015-06-02 17:52:22 -06:00
|
|
|
|
|
|
|
|
|
public UserSettings()
|
|
|
|
|
{
|
|
|
|
|
AutoLogin = false;
|
|
|
|
|
Username = "";
|
|
|
|
|
Password = "";
|
2015-06-02 18:40:53 -06:00
|
|
|
|
LastIP = "";
|
2015-06-16 23:31:56 -04:00
|
|
|
|
SelectedTexturePack = TexturePack.DefaultID;
|
2015-06-02 20:31:43 -06:00
|
|
|
|
FavoriteServers = new FavoriteServer[0];
|
2015-06-02 17:52:22 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Load()
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(SettingsPath))
|
|
|
|
|
JsonConvert.PopulateObject(File.ReadAllText(SettingsPath), this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(SettingsPath));
|
2015-06-02 18:40:53 -06:00
|
|
|
|
File.WriteAllText(SettingsPath, JsonConvert.SerializeObject(this, Formatting.Indented));
|
2015-06-02 17:52:22 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-02 18:40:53 -06:00
|
|
|
|
|
|
|
|
|
public class FavoriteServer
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Address { get; set; }
|
|
|
|
|
}
|
2015-06-02 17:52:22 -06:00
|
|
|
|
}
|