2024-03-02 01:31:18 +01:00
|
|
|
|
using Dalamud.Configuration;
|
|
|
|
|
using Dalamud.Plugin;
|
2024-03-02 17:15:18 +01:00
|
|
|
|
using Ktisis.Structs.Env;
|
|
|
|
|
using Newtonsoft.Json;
|
2024-03-02 01:31:18 +01:00
|
|
|
|
using System;
|
2024-03-02 17:15:18 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Xml.Linq;
|
2024-03-02 01:31:18 +01:00
|
|
|
|
|
|
|
|
|
namespace VoidBox;
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class Configuration : IPluginConfiguration
|
|
|
|
|
{
|
2024-03-02 17:15:18 +01:00
|
|
|
|
private static readonly JsonSerializer _jsonSerializer = JsonSerializer.CreateDefault();
|
|
|
|
|
|
|
|
|
|
[NonSerialized]
|
2024-07-15 23:53:09 +02:00
|
|
|
|
private IDalamudPluginInterface? _pluginInterface;
|
2024-03-02 17:15:18 +01:00
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
private Guid _loginGuid;
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
private SavedEnv? _loginEnv;
|
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
2024-03-03 18:39:54 +01:00
|
|
|
|
private Guid _housingGuid = new("4e4e2dbc-6bda-4b33-95f1-0865d939498a");
|
2024-03-02 17:15:18 +01:00
|
|
|
|
[NonSerialized]
|
|
|
|
|
private SavedEnv? _housingEnv;
|
|
|
|
|
|
2024-03-02 01:31:18 +01:00
|
|
|
|
public int Version { get; set; } = 0;
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled = true;
|
|
|
|
|
|
2024-03-02 17:15:18 +01:00
|
|
|
|
public List<SavedEnv> Envs = [];
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public SavedEnv? LoginEnv
|
|
|
|
|
{
|
|
|
|
|
get => _loginEnv;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_loginEnv = value;
|
|
|
|
|
_loginGuid = value?.Id ?? default;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public SavedEnv? HousingEnv
|
|
|
|
|
{
|
|
|
|
|
get => _housingEnv;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_housingEnv = value;
|
|
|
|
|
_housingGuid = value?.Id ?? default;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-02 01:31:18 +01:00
|
|
|
|
|
2024-07-15 23:53:09 +02:00
|
|
|
|
internal void Initialize(IDalamudPluginInterface pluginInterface)
|
2024-03-02 01:31:18 +01:00
|
|
|
|
{
|
2024-03-02 17:15:18 +01:00
|
|
|
|
_pluginInterface = pluginInterface;
|
|
|
|
|
|
|
|
|
|
_loginEnv = Service.Envs.FirstOrDefault(v => v.Env.Id == _loginGuid).Env;
|
|
|
|
|
_housingEnv = Service.Envs.FirstOrDefault(v => v.Env.Id == _housingGuid).Env;
|
2024-03-02 01:31:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
2024-03-02 17:15:18 +01:00
|
|
|
|
_pluginInterface!.SavePluginConfig(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed record SavedEnv
|
|
|
|
|
{
|
|
|
|
|
public static readonly SavedEnv Unchanged = new(default, "Unchanged", null);
|
|
|
|
|
|
|
|
|
|
public SavedEnv(string name, EnvState env)
|
|
|
|
|
: this(Guid.NewGuid(), name, new EnvState?(env))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SavedEnv(Guid id, string name, EnvState? env)
|
|
|
|
|
{
|
|
|
|
|
Id = id;
|
|
|
|
|
Name = name;
|
|
|
|
|
Env = env;
|
2024-03-02 01:31:18 +01:00
|
|
|
|
}
|
2024-03-02 17:15:18 +01:00
|
|
|
|
|
|
|
|
|
public Guid Id { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public EnvState? Env { get; }
|
2024-03-02 01:31:18 +01:00
|
|
|
|
}
|