44 lines
2.2 KiB
C#
44 lines
2.2 KiB
C#
using Dalamud.Configuration;
|
|
using ICRebuild.Core;
|
|
|
|
namespace ICRebuild;
|
|
|
|
[Serializable]
|
|
public sealed class Configuration : IPluginConfiguration
|
|
{
|
|
public int Version { get; set; } = 1;
|
|
public Dictionary<int, float> Values { get; set; } = [];
|
|
public HashSet<int> Requested { get; set; } = [];
|
|
public HashSet<uint> BlockedTimelines { get; set; } = [];
|
|
public HashSet<uint> BlockedStatuses { get; set; } = [StatusBlockPolicy.DefaultStatusId];
|
|
public bool BlockListed { get; set; } = true;
|
|
public DashFilterMode? DashMode { get; set; }
|
|
public string MovementListGameVersion { get; set; } = "";
|
|
public float KnockSeconds { get; set; }
|
|
public bool AutoSaveCapture { get; set; } = true;
|
|
private SettingsSnapshot published = new(new Dictionary<int,float>(),Array.Empty<uint>(),true,0);
|
|
[Newtonsoft.Json.JsonIgnore]
|
|
public SettingsSnapshot Published => Volatile.Read(ref published);
|
|
public string OpcodeUrl { get; set; } = "https://raw.githubusercontent.com/extrant/FFXIV.EXE/main/Opcode/all_opcodes.json";
|
|
public float Value(int id)
|
|
{
|
|
return Published.Value(id);
|
|
}
|
|
public void Normalize()
|
|
{
|
|
Values ??= []; Requested ??= []; BlockedTimelines ??= [];
|
|
BlockedStatuses ??= [StatusBlockPolicy.DefaultStatusId];
|
|
BlockedStatuses.RemoveWhere(id=>!StatusCatalog.AuditedBlockCandidates.Contains(id));
|
|
foreach (var feature in Features.All) Values[feature.Id] = Policies.FiniteClamp(Values.GetValueOrDefault(feature.Id,feature.Default),feature.Min,feature.Max,feature.Default);
|
|
foreach (var id in Values.Keys.Where(id => !Features.All.Any(f => f.Id == id)).ToArray()) Values.Remove(id);
|
|
Requested.RemoveWhere(id => !Features.All.Any(f => f.Id == id));
|
|
KnockSeconds = Policies.FiniteClamp(KnockSeconds, 0, 5);
|
|
BlockedTimelines.Remove(0);
|
|
BlockedTimelines.RemoveWhere(x=>x>ushort.MaxValue);
|
|
DashMode ??= BlockedTimelines.Count==0 ? DashFilterMode.AllLocal : BlockListed ? DashFilterMode.BlockListed : DashFilterMode.AllowListed;
|
|
if(!Enum.IsDefined(DashMode.Value)) DashMode=DashFilterMode.AllLocal;
|
|
Version=2;
|
|
Volatile.Write(ref published,new(Values,BlockedTimelines,BlockListed,KnockSeconds,DashMode.Value,BlockedStatuses));
|
|
}
|
|
}
|