Temp Files addition to Debug Tab

This commit is contained in:
Ottermandias 2021-07-11 00:59:53 +02:00
parent cf223c927c
commit b05ff66773
2 changed files with 161 additions and 45 deletions

View file

@ -12,7 +12,7 @@ namespace Penumbra.Meta
{ {
public class MetaManager : IDisposable public class MetaManager : IDisposable
{ {
private class FileInformation internal class FileInformation
{ {
public readonly object Data; public readonly object Data;
public bool Changed; public bool Changed;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using System.Reflection; using System.Reflection;
@ -10,6 +9,7 @@ using ImGuiNET;
using Penumbra.Game; using Penumbra.Game;
using Penumbra.Game.Enums; using Penumbra.Game.Enums;
using Penumbra.Interop; using Penumbra.Interop;
using Penumbra.Meta;
using Penumbra.Mods; using Penumbra.Mods;
using Penumbra.Util; using Penumbra.Util;
@ -28,52 +28,79 @@ namespace Penumbra.UI
.GetField( "_equip", BindingFlags.Instance | BindingFlags.NonPublic ) .GetField( "_equip", BindingFlags.Instance | BindingFlags.NonPublic )
?.GetValue( _plugin.PlayerWatcher ) ?.GetValue( _plugin.PlayerWatcher )
?? new Dictionary< string, CharEquipment >(); ?? new Dictionary< string, CharEquipment >();
if( !actors.Any() )
{
return;
}
if( actors.Any() && ImGui.BeginTable( "##ActorTable", 13, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX ) ) if( ImGui.BeginTable( "##ActorTable", 13, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX,
new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 4 * actors.Count ) ) )
{ {
var identifier = Service< ObjectIdentification >.Get(); var identifier = Service< ObjectIdentification >.Get();
ImGui.TableNextRow();
foreach( var actor in actors ) foreach( var actor in actors )
{ {
// @formatter:off
ImGui.TableNextRow();
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( actor.Key ); ImGui.Text( actor.Key );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( ImGui.Text( $"{actor.Value.Mainhand}" );
$"{actor.Value.Mainhand} {identifier.Identify( actor.Value.Mainhand._1, actor.Value.Mainhand._2, actor.Value.Mainhand._3, EquipSlot.MainHand )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( ImGui.Text( $"{actor.Value.Head}" );
$"{actor.Value.Offhand} {identifier.Identify( actor.Value.Offhand._1, actor.Value.Offhand._2, actor.Value.Offhand._3, EquipSlot.Offhand )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( ImGui.Text( $"{actor.Value.Body}" );
$"{actor.Value.Head} {identifier.Identify( actor.Value.Head._1, actor.Value.Head._2, 0, EquipSlot.Head )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( ImGui.Text( $"{actor.Value.Hands}" );
$"{actor.Value.Body} {identifier.Identify( actor.Value.Body._1, actor.Value.Body._2, 0, EquipSlot.Body )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( ImGui.Text( $"{actor.Value.Legs}" );
$"{actor.Value.Hands} {identifier.Identify( actor.Value.Hands._1, actor.Value.Hands._2, 0, EquipSlot.Hands )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( ImGui.Text( $"{actor.Value.Feet}" );
$"{actor.Value.Legs} {identifier.Identify( actor.Value.Legs._1, actor.Value.Legs._2, 0, EquipSlot.Legs )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn();
ImGui.Text(
$"{actor.Value.Feet} {identifier.Identify( actor.Value.Feet._1, actor.Value.Feet._2, 0, EquipSlot.Feet )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn();
ImGui.Text(
$"{actor.Value.Ear} {identifier.Identify( actor.Value.Ear._1, actor.Value.Ear._2, 0, EquipSlot.Ears )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn();
ImGui.Text(
$"{actor.Value.Neck} {identifier.Identify( actor.Value.Neck._1, actor.Value.Neck._2, 0, EquipSlot.Neck )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn();
ImGui.Text(
$"{actor.Value.Wrist} {identifier.Identify( actor.Value.Wrist._1, actor.Value.Wrist._2, 0, EquipSlot.Wrists )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn();
ImGui.Text(
$"{actor.Value.LFinger} {identifier.Identify( actor.Value.LFinger._1, actor.Value.LFinger._2, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextColumn();
ImGui.Text(
$"{actor.Value.RFinger} {identifier.Identify( actor.Value.RFinger._1, actor.Value.RFinger._2, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown"}" );
ImGui.TableNextRow(); ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Mainhand._1, actor.Value.Mainhand._2, actor.Value.Mainhand._3, EquipSlot.MainHand )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Head._1, actor.Value.Head._2, 0, EquipSlot.Head )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Body._1, actor.Value.Body._2, 0, EquipSlot.Body )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Hands._1, actor.Value.Hands._2, 0, EquipSlot.Hands )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Legs._1, actor.Value.Legs._2, 0, EquipSlot.Legs )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Feet._1, actor.Value.Feet._2, 0, EquipSlot.Feet )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.Text( $"{actor.Value.Offhand}" );
ImGui.TableNextColumn();
ImGui.Text( $"{actor.Value.Ear}" );
ImGui.TableNextColumn();
ImGui.Text( $"{actor.Value.Neck}" );
ImGui.TableNextColumn();
ImGui.Text( $"{actor.Value.Wrist}" );
ImGui.TableNextColumn();
ImGui.Text( $"{actor.Value.LFinger}" );
ImGui.TableNextColumn();
ImGui.Text( $"{actor.Value.RFinger}" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Offhand._1, actor.Value.Offhand._2, actor.Value.Offhand._3, EquipSlot.Offhand )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Ear._1, actor.Value.Ear._2, 0, EquipSlot.Ears )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Neck._1, actor.Value.Neck._2, 0, EquipSlot.Neck )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.Wrist._1, actor.Value.Wrist._2, 0, EquipSlot.Wrists )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.LFinger._1, actor.Value.LFinger._2, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( actor.Value.RFinger._1, actor.Value.RFinger._2, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown" );
// @formatter:on
} }
ImGui.EndTable(); ImGui.EndTable();
@ -87,7 +114,19 @@ namespace Penumbra.UI
return; return;
} }
ImGui.Text( $"Active Collection: {Service< ModManager >.Get().Collections.ActiveCollection.Name}" ); if( !ImGui.BeginTable( "##DebugGeneralTable", 2, ImGuiTableFlags.SizingFixedFit,
new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 1 ) ) )
{
return;
}
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Active Collection" );
ImGui.TableNextColumn();
ImGui.Text( Service< ModManager >.Get().Collections.ActiveCollection.Name );
ImGui.EndTable();
} }
@ -131,32 +170,104 @@ namespace Penumbra.UI
? ( ActorRefresher.LoadingFlags? )Marshal.ReadInt32( ActorRefresher.RenderPtr( currentActor ) ) ? ( ActorRefresher.LoadingFlags? )Marshal.ReadInt32( ActorRefresher.RenderPtr( currentActor ) )
: null; : null;
ImGui.Text( $"Current Frame: {currentFrame?.ToString() ?? "null"}" ); if( ImGui.BeginTable( "##RedrawData", 2, ImGuiTableFlags.SizingFixedFit,
ImGui.Text( $"Current Changed Settings: {changedSettings?.ToString() ?? "null"}" ); new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 7 ) ) )
ImGui.Text( $"Current Actor Id: {currentActorId?.ToString( "X8" ) ?? "null"}" );
ImGui.Text( $"Current Actor Name: {currentActorName ?? "null"}" );
ImGui.Text( $"Current Actor Redraw: {currentActorRedraw.ToString() ?? "null"}" );
ImGui.Text( $"Current Actor Address: {currentActor?.Address.ToString( "X16" ) ?? "null"}" );
ImGui.Text( $"Current Actor Render Flags: {( ( int? )currentRender )?.ToString( "X8" ) ?? "null"}" );
if( queue.Any() && ImGui.BeginTable( "##RedrawTable", 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX ) )
{ {
ImGui.TableNextRow(); ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Frame" );
ImGui.TableNextColumn();
ImGui.Text( currentFrame?.ToString() ?? "null" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Changed Settings" );
ImGui.TableNextColumn();
ImGui.Text( changedSettings?.ToString() ?? "null" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Actor Id" );
ImGui.TableNextColumn();
ImGui.Text( currentActorId?.ToString( "X8" ) ?? "null" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Actor Name" );
ImGui.TableNextColumn();
ImGui.Text( currentActorName ?? "null" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Actor Redraw" );
ImGui.TableNextColumn();
ImGui.Text( currentActorRedraw?.ToString() ?? "null" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Actor Address" );
ImGui.TableNextColumn();
ImGui.Text( currentActor?.Address.ToString( "X16" ) ?? "null" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( "Current Actor Render Flags" );
ImGui.TableNextColumn();
ImGui.Text( ( ( int? )currentRender )?.ToString( "X8" ) ?? "null" );
ImGui.EndTable();
}
if( queue.Any()
&& ImGui.BeginTable( "##RedrawTable", 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX,
new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * queue.Count ) ) )
{
foreach( var (actorId, actorName, redraw) in queue ) foreach( var (actorId, actorName, redraw) in queue )
{ {
ImGui.TableNextRow();
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( actorName ); ImGui.Text( actorName );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( $"0x{actorId:X8}" ); ImGui.Text( $"0x{actorId:X8}" );
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text( redraw.ToString() ); ImGui.Text( redraw.ToString() );
ImGui.TableNextRow();
} }
ImGui.EndTable(); ImGui.EndTable();
} }
} }
private void DrawDebugTabTempFiles()
{
if( !ImGui.CollapsingHeader( "Temporary Files##Debug" ) )
{
return;
}
if( !ImGui.BeginTable( "##tempFileTable", 4, ImGuiTableFlags.SizingFixedFit ) )
{
return;
}
foreach( var collection in Service< ModManager >.Get().Collections.Collections.Values.Where( c => c.Cache != null ) )
{
var manip = collection.Cache!.MetaManipulations;
var files = ( Dictionary< GamePath, MetaManager.FileInformation >? )manip.GetType()
.GetField( "_currentFiles", BindingFlags.NonPublic | BindingFlags.Instance )?.GetValue( manip )
?? new Dictionary< GamePath, MetaManager.FileInformation >();
foreach( var file in files )
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( file.Value.CurrentFile?.FullName ?? "None" );
ImGui.TableNextColumn();
ImGui.Text( file.Key );
ImGui.TableNextColumn();
file.Value.CurrentFile?.Refresh();
ImGui.Text( file.Value.CurrentFile?.Exists ?? false ? "Exists" : "Missing" );
ImGui.TableNextColumn();
ImGui.Text( file.Value.Changed ? "Data Changed" : "Unchanged" );
}
}
ImGui.EndTable();
}
private void DrawDebugTab() private void DrawDebugTab()
{ {
if( !ImGui.BeginTabItem( "Debug Tab" ) ) if( !ImGui.BeginTabItem( "Debug Tab" ) )
@ -165,8 +276,13 @@ namespace Penumbra.UI
} }
DrawDebugTabGeneral(); DrawDebugTabGeneral();
ImGui.NewLine();
DrawDebugTabRedraw(); DrawDebugTabRedraw();
ImGui.NewLine();
DrawDebugTabActors(); DrawDebugTabActors();
ImGui.NewLine();
DrawDebugTabTempFiles();
ImGui.NewLine();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }