 30caedbf3a
			
		
	
	30caedbf3a
	
	
	
		
			
			* update api * mcd online editor impl * most of chara data hub impl * some state of things * some refactoring * random bullshit go * more nearby impl * add uid to peformance msg * cleanup/homogenization * some split, update nuget packages * migrate to latest packages where possible, remove lz4net, do some split, idk * some polish and cleanup * more cleanup, beautification, etc. * fixes and cleanups --------- Co-authored-by: Stanley Dimant <root.darkarchon@outlook.com>
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using MareSynchronos.API.Data;
 | |
| using MareSynchronos.API.Data.Enum;
 | |
| using MareSynchronos.FileCache;
 | |
| using System.Text;
 | |
| using System.Text.Json;
 | |
| 
 | |
| namespace MareSynchronos.Services.CharaData.Models;
 | |
| 
 | |
| 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 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;
 | |
|         ManipulationData = dto.ManipulationData;
 | |
| 
 | |
|         if (dto.FileReplacements.TryGetValue(ObjectKind.Player, out var fileReplacements))
 | |
|         {
 | |
|             var grouped = fileReplacements.GroupBy(f => f.Hash, StringComparer.OrdinalIgnoreCase);
 | |
| 
 | |
|             foreach (var file in grouped)
 | |
|             {
 | |
|                 if (string.IsNullOrEmpty(file.Key))
 | |
|                 {
 | |
|                     foreach (var item in file)
 | |
|                     {
 | |
|                         FileSwaps.Add(new FileSwap(item.GamePaths, item.FileSwapPath));
 | |
|                     }
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     var filePath = manager.GetFileCacheByHash(file.First().Hash)?.ResolvedFilepath;
 | |
|                     if (filePath != null)
 | |
|                     {
 | |
|                         Files.Add(new FileData(file.SelectMany(f => f.GamePaths), (int)new FileInfo(filePath).Length, file.First().Hash));
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     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, int Length, string Hash);
 | |
| } |