add debug button to copy character data

This commit is contained in:
rootdarkarchon
2023-01-14 20:41:50 +01:00
parent 89eb6b448e
commit aaf11043fe
4 changed files with 24 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using MareSynchronos.Models; using MareSynchronos.Models;
using MareSynchronos.FileCache; using MareSynchronos.FileCache;
using MareSynchronos.UI;
#if DEBUG #if DEBUG
using Newtonsoft.Json; using Newtonsoft.Json;
#endif #endif
@@ -25,6 +26,7 @@ public class PlayerManager : IDisposable
private readonly DalamudUtil _dalamudUtil; private readonly DalamudUtil _dalamudUtil;
private readonly TransientResourceManager _transientResourceManager; private readonly TransientResourceManager _transientResourceManager;
private readonly PeriodicFileScanner _periodicFileScanner; private readonly PeriodicFileScanner _periodicFileScanner;
private readonly SettingsUi _settingsUi;
private readonly IpcManager _ipcManager; private readonly IpcManager _ipcManager;
public event PlayerHasChanged? PlayerHasChanged; public event PlayerHasChanged? PlayerHasChanged;
public CharacterCacheDto? LastCreatedCharacterData { get; private set; } public CharacterCacheDto? LastCreatedCharacterData { get; private set; }
@@ -38,7 +40,7 @@ public class PlayerManager : IDisposable
public unsafe PlayerManager(ApiController apiController, IpcManager ipcManager, public unsafe PlayerManager(ApiController apiController, IpcManager ipcManager,
CharacterDataFactory characterDataFactory, DalamudUtil dalamudUtil, TransientResourceManager transientResourceManager, CharacterDataFactory characterDataFactory, DalamudUtil dalamudUtil, TransientResourceManager transientResourceManager,
PeriodicFileScanner periodicFileScanner) PeriodicFileScanner periodicFileScanner, SettingsUi settingsUi)
{ {
Logger.Verbose("Creating " + nameof(PlayerManager)); Logger.Verbose("Creating " + nameof(PlayerManager));
@@ -48,6 +50,7 @@ public class PlayerManager : IDisposable
_dalamudUtil = dalamudUtil; _dalamudUtil = dalamudUtil;
_transientResourceManager = transientResourceManager; _transientResourceManager = transientResourceManager;
_periodicFileScanner = periodicFileScanner; _periodicFileScanner = periodicFileScanner;
_settingsUi = settingsUi;
_apiController.Connected += ApiControllerOnConnected; _apiController.Connected += ApiControllerOnConnected;
_apiController.Disconnected += ApiController_Disconnected; _apiController.Disconnected += ApiController_Disconnected;
_transientResourceManager.TransientResourceLoaded += HandleTransientResourceLoad; _transientResourceManager.TransientResourceLoaded += HandleTransientResourceLoad;
@@ -268,6 +271,8 @@ public class PlayerManager : IDisposable
} }
if (cacheDto == null || token.IsCancellationRequested) return; if (cacheDto == null || token.IsCancellationRequested) return;
_settingsUi.LastCreatedCharacterData = cacheDto;
#if DEBUG #if DEBUG
//var json = JsonConvert.SerializeObject(cacheDto, Formatting.Indented); //var json = JsonConvert.SerializeObject(cacheDto, Formatting.Indented);
//Logger.Verbose(json); //Logger.Verbose(json);

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.6.0</Version> <Version>0.6.1</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -188,7 +188,7 @@ public sealed class Plugin : IDalamudPlugin
var characterCacheFactory = var characterCacheFactory =
new CharacterDataFactory(_dalamudUtil, _ipcManager, _transientResourceManager, _fileReplacementFactory); new CharacterDataFactory(_dalamudUtil, _ipcManager, _transientResourceManager, _fileReplacementFactory);
_playerManager = new PlayerManager(_apiController, _ipcManager, _playerManager = new PlayerManager(_apiController, _ipcManager,
characterCacheFactory, _dalamudUtil, _transientResourceManager, _periodicFileScanner); characterCacheFactory, _dalamudUtil, _transientResourceManager, _periodicFileScanner, _settingsUi);
_characterCacheManager = new OnlinePlayerManager(_apiController, _characterCacheManager = new OnlinePlayerManager(_apiController,
_dalamudUtil, _ipcManager, _playerManager, _fileCacheManager, _configuration); _dalamudUtil, _ipcManager, _playerManager, _fileCacheManager, _configuration);
} }

View File

@@ -12,6 +12,7 @@ using MareSynchronos.API;
using MareSynchronos.Utils; using MareSynchronos.Utils;
using MareSynchronos.WebAPI.Utils; using MareSynchronos.WebAPI.Utils;
using Dalamud.Utility; using Dalamud.Utility;
using Newtonsoft.Json;
namespace MareSynchronos.UI; namespace MareSynchronos.UI;
@@ -22,6 +23,8 @@ public class SettingsUi : Window, IDisposable
private readonly WindowSystem _windowSystem; private readonly WindowSystem _windowSystem;
private readonly ApiController _apiController; private readonly ApiController _apiController;
private readonly UiShared _uiShared; private readonly UiShared _uiShared;
public CharacterCacheDto LastCreatedCharacterData { private get; set; }
public event SwitchUi? SwitchToIntroUi; public event SwitchUi? SwitchToIntroUi;
private bool _overwriteExistingLabels = false; private bool _overwriteExistingLabels = false;
private bool? _notesSuccessfullyApplied = null; private bool? _notesSuccessfullyApplied = null;
@@ -542,6 +545,19 @@ public class SettingsUi : Window, IDisposable
{ {
_uiShared.DrawServiceSelection(() => { }); _uiShared.DrawServiceSelection(() => { });
} }
if (UiShared.IconTextButton(FontAwesomeIcon.Copy, "[DEBUG] Copy Last created Character Data to clipboard"))
{
if (LastCreatedCharacterData != null)
{
ImGui.SetClipboardText(JsonConvert.SerializeObject(LastCreatedCharacterData, Formatting.Indented));
}
else
{
ImGui.SetClipboardText("ERROR: No created character data, cannot copy.");
}
}
UiShared.AttachToolTip("Use this when reporting mods being rejected from the server.");
} }
private void DrawBlockedTransfers() private void DrawBlockedTransfers()