Files
ClubPenguinClient/MareSynchronos/PlayerData/Export/MareCharaFileData.cs
rootdarkarchon 14575a4a6b Mare 0.9 (#65)
* add jwt expiry

* start of 0.9 api impl

* some stuff idk

* some more impl

* some cleanup

* remove grouppair, add configuration, rework some pair drawing stuff

* do some stuff

* rework some ui

* I don't even know anymore

* add cancellationtoken

* token bla

* ui fixes etc

* probably individual adding/removing now working fully as expected

* add working report popup

* I guess it's more syncshell shit or so

* popup shit idk

* work out most of the syncshell bullshit I guess

* delete some old crap

* are we actually getting closer to the end

* update pair info stuff

* more fixes/adjustments, idk

* refactor some things

* some rework

* some more cleanup

* cleanup

* make menu buttons w i d e

* better icon text buttons

* add all syncshell folder and ordering fixes

---------

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
2023-10-17 21:36:44 +02:00

67 lines
2.3 KiB
C#

using MareSynchronos.API.Data;
using MareSynchronos.API.Data.Enum;
using MareSynchronos.FileCache;
using System.Text;
using System.Text.Json;
namespace MareSynchronos.PlayerData.Export;
public record MareCharaFileData
{
public string Description { get; set; } = string.Empty;
public string GlamourerData { get; set; } = string.Empty;
public string CustomizePlusData { get; set; } = string.Empty;
public string PalettePlusData { get; set; } = string.Empty;
public string ManipulationData { get; set; } = string.Empty;
public List<FileData> Files { get; set; } = [];
public List<FileSwap> FileSwaps { get; set; } = [];
public MareCharaFileData() { }
public MareCharaFileData(FileCacheManager manager, string description, CharacterData dto)
{
Description = description;
if (dto.GlamourerData.TryGetValue(ObjectKind.Player, out var glamourerData))
{
GlamourerData = glamourerData;
}
dto.CustomizePlusData.TryGetValue(ObjectKind.Player, out var customizePlusData);
CustomizePlusData = customizePlusData ?? string.Empty;
PalettePlusData = dto.PalettePlusData;
ManipulationData = dto.ManipulationData;
if (dto.FileReplacements.TryGetValue(ObjectKind.Player, out var fileReplacements))
{
foreach (var file in fileReplacements)
{
if (!string.IsNullOrEmpty(file.FileSwapPath))
{
FileSwaps.Add(new FileSwap(file.GamePaths, file.FileSwapPath));
}
else
{
var filePath = manager.GetFileCacheByHash(file.Hash)?.ResolvedFilepath;
if (filePath != null)
{
Files.Add(new FileData(file.GamePaths, new FileInfo(filePath).Length));
}
}
}
}
}
public byte[] ToByteArray()
{
return Encoding.UTF8.GetBytes(JsonSerializer.Serialize(this));
}
public static MareCharaFileData FromByteArray(byte[] data)
{
return JsonSerializer.Deserialize<MareCharaFileData>(Encoding.UTF8.GetString(data))!;
}
public record FileSwap(IEnumerable<string> GamePaths, string FileSwapPath);
public record FileData(IEnumerable<string> GamePaths, long Length);
}