Client rework for API change and paradigm shift (#39)
* 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>
This commit is contained in:
@@ -1,33 +1,29 @@
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using LZ4;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.Managers;
|
||||
using MareSynchronos.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
|
||||
namespace MareSynchronos.Export;
|
||||
public class MareCharaFileManager
|
||||
{
|
||||
private readonly FileCacheManager _manager;
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly ConfigurationService _configService;
|
||||
private readonly DalamudUtil _dalamudUtil;
|
||||
private readonly MareCharaFileDataFactory _factory;
|
||||
public MareCharaFileHeader? LoadedCharaFile { get; private set; }
|
||||
public bool CurrentlyWorking { get; private set; } = false;
|
||||
|
||||
public MareCharaFileManager(FileCacheManager manager, IpcManager ipcManager, Configuration configuration, DalamudUtil dalamudUtil)
|
||||
public MareCharaFileManager(FileCacheManager manager, IpcManager ipcManager, ConfigurationService configService, DalamudUtil dalamudUtil)
|
||||
{
|
||||
_factory = new(manager);
|
||||
_manager = manager;
|
||||
_ipcManager = ipcManager;
|
||||
_configuration = configuration;
|
||||
_configService = configService;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
}
|
||||
|
||||
@@ -46,44 +42,46 @@ public class MareCharaFileManager
|
||||
using var reader = new BinaryReader(lz4Stream);
|
||||
LoadedCharaFile = MareCharaFileHeader.FromBinaryReader(filePath, reader);
|
||||
Logger.Debug("Read Mare Chara File");
|
||||
Logger.Debug("Version: " + LoadedCharaFile.Version);
|
||||
Logger.Debug("Version: " + (LoadedCharaFile?.Version ?? -1));
|
||||
|
||||
}
|
||||
catch { throw; }
|
||||
finally { CurrentlyWorking = false; }
|
||||
}
|
||||
|
||||
public async Task ApplyMareCharaFile(GameObject charaTarget)
|
||||
public async Task ApplyMareCharaFile(GameObject? charaTarget)
|
||||
{
|
||||
Dictionary<string, string> extractedFiles = new();
|
||||
Dictionary<string, string> extractedFiles = new(StringComparer.Ordinal);
|
||||
CurrentlyWorking = true;
|
||||
try
|
||||
{
|
||||
if (LoadedCharaFile == null || charaTarget == null || !File.Exists(LoadedCharaFile.FilePath)) return;
|
||||
|
||||
using var unwrapped = File.OpenRead(LoadedCharaFile.FilePath);
|
||||
using var lz4Stream = new LZ4Stream(unwrapped, LZ4StreamMode.Decompress, LZ4StreamFlags.HighCompression);
|
||||
using var reader = new BinaryReader(lz4Stream);
|
||||
LoadedCharaFile.AdvanceReaderToData(reader);
|
||||
Logger.Debug("Applying to " + charaTarget.Name.TextValue);
|
||||
extractedFiles = ExtractFilesFromCharaFile(LoadedCharaFile, reader);
|
||||
Dictionary<string, string> fileSwaps = new(StringComparer.Ordinal);
|
||||
foreach (var fileSwap in LoadedCharaFile.CharaFileData.FileSwaps)
|
||||
var unwrapped = File.OpenRead(LoadedCharaFile.FilePath);
|
||||
await using (unwrapped.ConfigureAwait(false))
|
||||
{
|
||||
foreach (var path in fileSwap.GamePaths)
|
||||
using var lz4Stream = new LZ4Stream(unwrapped, LZ4StreamMode.Decompress, LZ4StreamFlags.HighCompression);
|
||||
using var reader = new BinaryReader(lz4Stream);
|
||||
LoadedCharaFile.AdvanceReaderToData(reader);
|
||||
Logger.Debug("Applying to " + charaTarget.Name.TextValue);
|
||||
extractedFiles = ExtractFilesFromCharaFile(LoadedCharaFile, reader);
|
||||
Dictionary<string, string> fileSwaps = new(StringComparer.Ordinal);
|
||||
foreach (var fileSwap in LoadedCharaFile.CharaFileData.FileSwaps)
|
||||
{
|
||||
fileSwaps.Add(path, fileSwap.FileSwapPath);
|
||||
foreach (var path in fileSwap.GamePaths)
|
||||
{
|
||||
fileSwaps.Add(path, fileSwap.FileSwapPath);
|
||||
}
|
||||
}
|
||||
_ipcManager.ToggleGposeQueueMode(on: true);
|
||||
_ipcManager.PenumbraRemoveTemporaryCollection(charaTarget.Name.TextValue);
|
||||
_ipcManager.PenumbraSetTemporaryMods(charaTarget.Name.TextValue,
|
||||
extractedFiles.Union(fileSwaps).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal),
|
||||
LoadedCharaFile.CharaFileData.ManipulationData);
|
||||
_ipcManager.GlamourerApplyAll(LoadedCharaFile.CharaFileData.GlamourerData, charaTarget.Address);
|
||||
_dalamudUtil.WaitWhileGposeCharacterIsDrawing(charaTarget.Address);
|
||||
_ipcManager.PenumbraRemoveTemporaryCollection(charaTarget.Name.TextValue);
|
||||
_ipcManager.ToggleGposeQueueMode(on: false);
|
||||
}
|
||||
_ipcManager.ToggleGposeQueueMode(true);
|
||||
_ipcManager.PenumbraRemoveTemporaryCollection(charaTarget.Name.TextValue);
|
||||
_ipcManager.PenumbraSetTemporaryMods(charaTarget.Name.TextValue,
|
||||
extractedFiles.Union(fileSwaps).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal),
|
||||
LoadedCharaFile.CharaFileData.ManipulationData);
|
||||
_ipcManager.GlamourerApplyAll(LoadedCharaFile.CharaFileData.GlamourerData, charaTarget.Address);
|
||||
_dalamudUtil.WaitWhileGposeCharacterIsDrawing(charaTarget.Address);
|
||||
_ipcManager.PenumbraRemoveTemporaryCollection(charaTarget.Name.TextValue);
|
||||
_ipcManager.ToggleGposeQueueMode(false);
|
||||
}
|
||||
catch { throw; }
|
||||
finally
|
||||
@@ -104,7 +102,7 @@ public class MareCharaFileManager
|
||||
int i = 0;
|
||||
foreach (var fileData in charaFileHeader.CharaFileData.Files)
|
||||
{
|
||||
var fileName = Path.Combine(_configuration.CacheFolder, "mare_" + (i++) + ".tmp");
|
||||
var fileName = Path.Combine(_configService.Current.CacheFolder, "mare_" + (i++) + ".tmp");
|
||||
var length = fileData.Length;
|
||||
var bufferSize = 4 * 1024 * 1024;
|
||||
var buffer = new byte[bufferSize];
|
||||
@@ -127,7 +125,7 @@ public class MareCharaFileManager
|
||||
return gamePathToFilePath;
|
||||
}
|
||||
|
||||
public void SaveMareCharaFile(CharacterCacheDto? dto, string description, string filePath)
|
||||
public void SaveMareCharaFile(CharacterData? dto, string description, string filePath)
|
||||
{
|
||||
CurrentlyWorking = true;
|
||||
try
|
||||
@@ -148,7 +146,7 @@ public class MareCharaFileManager
|
||||
{
|
||||
foreach (var file in replacement.Select(item => _manager.GetFileCacheByHash(item.Hash)).Where(file => file != null))
|
||||
{
|
||||
var length = new FileInfo(file.ResolvedFilepath).Length;
|
||||
var length = new FileInfo(file!.ResolvedFilepath).Length;
|
||||
using var fsRead = File.OpenRead(file.ResolvedFilepath);
|
||||
using var br = new BinaryReader(fsRead);
|
||||
int readBytes = 0;
|
||||
|
||||
Reference in New Issue
Block a user