mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add testing to IPC Meta.
This commit is contained in:
parent
c8ad4bc106
commit
242c0ee38f
4 changed files with 29 additions and 13 deletions
|
|
@ -146,11 +146,12 @@ public class MetaApi(IFramework framework, CollectionResolver collectionResolver
|
|||
/// The empty string is treated as an empty set.
|
||||
/// Only returns true if all conversions are successful and distinct.
|
||||
/// </summary>
|
||||
internal static bool ConvertManips(string manipString, [NotNullWhen(true)] out MetaDictionary? manips)
|
||||
internal static bool ConvertManips(string manipString, [NotNullWhen(true)] out MetaDictionary? manips, out byte version)
|
||||
{
|
||||
if (manipString.Length == 0)
|
||||
{
|
||||
manips = new MetaDictionary();
|
||||
version = byte.MaxValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +165,7 @@ public class MetaApi(IFramework framework, CollectionResolver collectionResolver
|
|||
resultStream.Flush();
|
||||
resultStream.Position = 0;
|
||||
var data = resultStream.GetBuffer().AsSpan(0, (int)resultStream.Length);
|
||||
var version = data[0];
|
||||
version = data[0];
|
||||
data = data[1..];
|
||||
switch (version)
|
||||
{
|
||||
|
|
@ -180,6 +181,7 @@ public class MetaApi(IFramework framework, CollectionResolver collectionResolver
|
|||
{
|
||||
Penumbra.Log.Debug($"Error decompressing manipulations:\n{ex}");
|
||||
manips = null;
|
||||
version = byte.MaxValue;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -291,11 +293,11 @@ public class MetaApi(IFramework framework, CollectionResolver collectionResolver
|
|||
var v1Time = watch.ElapsedMilliseconds;
|
||||
|
||||
watch.Restart();
|
||||
var v1Success = ConvertManips(v1, out var v1Roundtrip);
|
||||
var v1Success = ConvertManips(v1, out var v1Roundtrip, out _);
|
||||
var v1RoundtripTime = watch.ElapsedMilliseconds;
|
||||
|
||||
watch.Restart();
|
||||
var v0Success = ConvertManips(v0, out var v0Roundtrip);
|
||||
var v0Success = ConvertManips(v0, out var v0Roundtrip, out _);
|
||||
var v0RoundtripTime = watch.ElapsedMilliseconds;
|
||||
|
||||
Penumbra.Log.Information($"Version | Count | Time | Length | Success | ReCount | ReTime | Equal");
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class TemporaryApi(
|
|||
if (!ConvertPaths(paths, out var p))
|
||||
return ApiHelpers.Return(PenumbraApiEc.InvalidGamePath, args);
|
||||
|
||||
if (!MetaApi.ConvertManips(manipString, out var m))
|
||||
if (!MetaApi.ConvertManips(manipString, out var m, out _))
|
||||
return ApiHelpers.Return(PenumbraApiEc.InvalidManipulation, args);
|
||||
|
||||
var ret = tempMods.Register(tag, null, p, m, new ModPriority(priority)) switch
|
||||
|
|
@ -86,7 +86,7 @@ public class TemporaryApi(
|
|||
if (!ConvertPaths(paths, out var p))
|
||||
return ApiHelpers.Return(PenumbraApiEc.InvalidGamePath, args);
|
||||
|
||||
if (!MetaApi.ConvertManips(manipString, out var m))
|
||||
if (!MetaApi.ConvertManips(manipString, out var m, out _))
|
||||
return ApiHelpers.Return(PenumbraApiEc.InvalidManipulation, args);
|
||||
|
||||
var ret = tempMods.Register(tag, collection, p, m, new ModPriority(priority)) switch
|
||||
|
|
|
|||
|
|
@ -2,13 +2,19 @@ using Dalamud.Plugin;
|
|||
using ImGuiNET;
|
||||
using OtterGui.Raii;
|
||||
using OtterGui.Services;
|
||||
using OtterGui.Text;
|
||||
using Penumbra.Api.Api;
|
||||
using Penumbra.Api.IpcSubscribers;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
||||
namespace Penumbra.Api.IpcTester;
|
||||
|
||||
public class MetaIpcTester(IDalamudPluginInterface pi) : IUiService
|
||||
{
|
||||
private int _gameObjectIndex;
|
||||
private string _metaBase64 = string.Empty;
|
||||
private MetaDictionary _metaDict = new();
|
||||
private byte _parsedVersion = byte.MaxValue;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
|
|
@ -17,6 +23,11 @@ public class MetaIpcTester(IDalamudPluginInterface pi) : IUiService
|
|||
return;
|
||||
|
||||
ImGui.InputInt("##metaIdx", ref _gameObjectIndex, 0, 0);
|
||||
if (ImUtf8.InputText("##metaText"u8, ref _metaBase64, "Base64 Metadata..."u8))
|
||||
if (!MetaApi.ConvertManips(_metaBase64, out _metaDict, out _parsedVersion))
|
||||
_metaDict ??= new MetaDictionary();
|
||||
|
||||
|
||||
using var table = ImRaii.Table(string.Empty, 3, ImGuiTableFlags.SizingFixedFit);
|
||||
if (!table)
|
||||
return;
|
||||
|
|
@ -34,5 +45,8 @@ public class MetaIpcTester(IDalamudPluginInterface pi) : IUiService
|
|||
var base64 = new GetMetaManipulations(pi).Invoke(_gameObjectIndex);
|
||||
ImGui.SetClipboardText(base64);
|
||||
}
|
||||
|
||||
IpcTester.DrawIntro(string.Empty, "Parsed Data");
|
||||
ImUtf8.Text($"Version: {_parsedVersion}, Count: {_metaDict.Count}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public abstract class MetaDrawer<TIdentifier, TEntry>(ModMetaEditor editor, Meta
|
|||
if (!ImUtf8.IconButton(FontAwesomeIcon.Clipboard, tooltip))
|
||||
return;
|
||||
|
||||
var text = Functions.ToCompressedBase64(manipulations.Value, MetaApi.CurrentVersion);
|
||||
var text = Functions.ToCompressedBase64(manipulations.Value, 0);
|
||||
if (text.Length > 0)
|
||||
ImGui.SetClipboardText(text);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue