* most of the groups refactoring on client * register OnMethods for group stuff * start implementing client (still pretty broken) * finish implementing new api first iteration * idk rework everything for pair shit (still WIP); goal is to remove PairedClients and GroupPairClients from ApiController * move everything to PairManager, remove dictionaries from APiController * remove admin stuff from client, cleanup * adjust reconnection handling, add new settings, todo still to remove access from old stuff that's marked obsolete from config * add back adding servers, fix intro ui * fix obsolete calls * adjust config namespace * add UI for setting animation/sound permissions to syncshells * add ConfigurationService to hot reload config on change from external * move transient data cache to configuration * add deleting service to ui * fix saving of transient resources * fix group pair user assignments * halt scanner when penumbra inactive, add visible/online/offline split to individual pairs and tags * add presence to syncshell ui * move fullpause from config to server config * fixes in code style * more codestyle * show info icon on player in shells, don't show icon when no changes from default state are made, add online notifs * fixes to intro UI --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
90 lines
3.3 KiB
C#
90 lines
3.3 KiB
C#
using Newtonsoft.Json;
|
|
using System.Text;
|
|
using MareSynchronos.Utils;
|
|
using MareSynchronos.API.Data.Enum;
|
|
using MareSynchronos.API.Data;
|
|
|
|
namespace MareSynchronos.Models;
|
|
|
|
[JsonObject(MemberSerialization.OptIn)]
|
|
public class CharacterData
|
|
{
|
|
[JsonProperty]
|
|
public Dictionary<ObjectKind, List<FileReplacement>> FileReplacements { get; set; } = new();
|
|
|
|
[JsonProperty]
|
|
public Dictionary<ObjectKind, string> GlamourerString { get; set; } = new();
|
|
|
|
public bool IsReady => FileReplacements.SelectMany(k => k.Value).All(f => f.Computed);
|
|
|
|
[JsonProperty]
|
|
public string ManipulationString { get; set; } = string.Empty;
|
|
|
|
[JsonProperty]
|
|
public float HeelsOffset { get; set; } = 0f;
|
|
|
|
[JsonProperty]
|
|
public string CustomizePlusScale { get; set; } = string.Empty;
|
|
|
|
public void AddFileReplacement(ObjectKind objectKind, FileReplacement fileReplacement)
|
|
{
|
|
if (!fileReplacement.HasFileReplacement) return;
|
|
|
|
if (!FileReplacements.ContainsKey(objectKind)) FileReplacements.Add(objectKind, new List<FileReplacement>());
|
|
|
|
var existingReplacement = FileReplacements[objectKind].SingleOrDefault(f => string.Equals(f.ResolvedPath, fileReplacement.ResolvedPath, StringComparison.OrdinalIgnoreCase));
|
|
if (existingReplacement != null)
|
|
{
|
|
existingReplacement.GamePaths.AddRange(fileReplacement.GamePaths.Where(e => !existingReplacement.GamePaths.Contains(e, StringComparer.OrdinalIgnoreCase)));
|
|
}
|
|
else
|
|
{
|
|
FileReplacements[objectKind].Add(fileReplacement);
|
|
}
|
|
}
|
|
|
|
public API.Data.CharacterData ToAPI()
|
|
{
|
|
var fileReplacements = FileReplacements.ToDictionary(k => k.Key, k => k.Value.Where(f => f.HasFileReplacement && !f.IsFileSwap).GroupBy(f => f.Hash, StringComparer.OrdinalIgnoreCase).Select(g =>
|
|
{
|
|
return new FileReplacementData()
|
|
{
|
|
GamePaths = g.SelectMany(f => f.GamePaths).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(),
|
|
Hash = g.First().Hash,
|
|
};
|
|
}).ToList());
|
|
|
|
Logger.Debug("Adding fileSwaps");
|
|
foreach (var item in FileReplacements)
|
|
{
|
|
Logger.Debug("Checking fileSwaps for " + item.Key);
|
|
var fileSwapsToAdd = item.Value.Where(f => f.IsFileSwap).Select(f => f.ToFileReplacementDto());
|
|
Logger.Debug("Adding " + fileSwapsToAdd.Count() + " file swaps");
|
|
foreach (var swap in fileSwapsToAdd)
|
|
{
|
|
Logger.Debug("Adding: " + swap.GamePaths.First() + ":" + swap.FileSwapPath);
|
|
}
|
|
fileReplacements[item.Key].AddRange(fileSwapsToAdd);
|
|
}
|
|
|
|
return new API.Data.CharacterData()
|
|
{
|
|
FileReplacements = fileReplacements,
|
|
GlamourerData = GlamourerString.ToDictionary(d => d.Key, d => d.Value),
|
|
ManipulationData = ManipulationString,
|
|
HeelsOffset = HeelsOffset,
|
|
CustomizePlusData = CustomizePlusScale,
|
|
};
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
StringBuilder stringBuilder = new();
|
|
foreach (var fileReplacement in FileReplacements.SelectMany(k => k.Value).OrderBy(a => a.GamePaths[0], StringComparer.Ordinal))
|
|
{
|
|
stringBuilder.AppendLine(fileReplacement.ToString());
|
|
}
|
|
return stringBuilder.ToString();
|
|
}
|
|
}
|