This commit is contained in:
Ottermandias 2022-03-13 11:13:50 +01:00
parent 46581780e0
commit de082439a4
28 changed files with 766 additions and 835 deletions

View file

@ -20,6 +20,7 @@ using Penumbra.Meta;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
using CharacterUtility = Penumbra.Interop.Structs.CharacterUtility;
using ResourceHandle = Penumbra.Interop.Structs.ResourceHandle;
using Utf8String = Penumbra.GameData.ByteString.Utf8String;
@ -164,12 +165,6 @@ public partial class SettingsInterface
PrintValue( "Mod Manager BasePath Exists",
manager.BasePath != null ? Directory.Exists( manager.BasePath.FullName ).ToString() : false.ToString() );
PrintValue( "Mod Manager Valid", manager.Valid.ToString() );
PrintValue( "Mod Manager Temp Path", manager.TempPath?.FullName ?? "NULL" );
PrintValue( "Mod Manager Temp Path IsRooted",
( !Penumbra.Config.TempDirectory.Any() || Path.IsPathRooted( Penumbra.Config.TempDirectory ) ).ToString() );
PrintValue( "Mod Manager Temp Path Exists",
manager.TempPath != null ? Directory.Exists( manager.TempPath.FullName ).ToString() : false.ToString() );
PrintValue( "Mod Manager Temp Path IsWritable", manager.TempWritable.ToString() );
//PrintValue( "Resource Loader Enabled", _penumbra.ResourceLoader.IsEnabled.ToString() );
}
@ -273,43 +268,6 @@ public partial class SettingsInterface
}
}
private static void DrawDebugTabTempFiles()
{
if( !ImGui.CollapsingHeader( "Temporary Files##Debug" ) )
{
return;
}
if( !ImGui.BeginTable( "##tempFileTable", 4, ImGuiTableFlags.SizingFixedFit ) )
{
return;
}
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTable );
foreach( var collection in Penumbra.ModManager.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, info) in files )
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( info.CurrentFile?.FullName ?? "None" );
ImGui.TableNextColumn();
ImGui.Text( file );
ImGui.TableNextColumn();
ImGui.Text( info.CurrentFile?.Exists ?? false ? "Exists" : "Missing" );
ImGui.TableNextColumn();
ImGui.Text( info.Changed ? "Data Changed" : "Unchanged" );
}
}
}
private void DrawDebugTabIpc()
{
if( !ImGui.CollapsingHeader( "IPC##Debug" ) )
@ -369,7 +327,7 @@ public partial class SettingsInterface
return;
}
var cache = Penumbra.ModManager.Collections.CurrentCollection.Cache;
var cache = Penumbra.ModManager.Collections.CurrentCollection.Cache;
if( cache == null || !ImGui.BeginTable( "##MissingFilesDebugList", 1, ImGuiTableFlags.RowBg, -Vector2.UnitX ) )
{
return;
@ -397,9 +355,9 @@ public partial class SettingsInterface
return;
}
_penumbra.ResourceLoader.UpdateDebugInfo();
Penumbra.ResourceLoader.UpdateDebugInfo();
if( _penumbra.ResourceLoader.DebugList.Count == 0
if( Penumbra.ResourceLoader.DebugList.Count == 0
|| !ImGui.BeginTable( "##ReplacedResourcesDebugList", 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, -Vector2.UnitX ) )
{
return;
@ -407,7 +365,7 @@ public partial class SettingsInterface
using var end = ImGuiRaii.DeferredEnd( ImGui.EndTable );
foreach( var data in _penumbra.ResourceLoader.DebugList.Values.ToArray() )
foreach( var data in Penumbra.ResourceLoader.DebugList.Values.ToArray() )
{
var refCountManip = data.ManipulatedResource == null ? 0 : data.ManipulatedResource->RefCount;
var refCountOrig = data.OriginalResource == null ? 0 : data.OriginalResource->RefCount;
@ -426,6 +384,52 @@ public partial class SettingsInterface
}
}
public unsafe void DrawDebugCharacterUtility()
{
if( !ImGui.CollapsingHeader( "Character Utility##Debug" ) )
{
return;
}
if( !ImGui.BeginTable( "##CharacterUtilityDebugList", 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, -Vector2.UnitX ) )
{
return;
}
using var end = ImGuiRaii.DeferredEnd( ImGui.EndTable );
for( var i = 0; i < CharacterUtility.NumRelevantResources; ++i )
{
var resource = ( ResourceHandle* )Penumbra.CharacterUtility.Address->Resources[ i ];
ImGui.TableNextColumn();
ImGui.Text( $"0x{( ulong )resource:X}" );
ImGui.TableNextColumn();
ImGuiNative.igTextUnformatted( resource->FileName(), resource->FileName() + resource->FileNameLength );
ImGui.TableNextColumn();
ImGui.Text( $"0x{resource->GetData().Data:X}" );
if( ImGui.IsItemClicked() )
{
var (data, length) = resource->GetData();
ImGui.SetClipboardText( string.Join( " ",
new ReadOnlySpan< byte >( ( byte* )data, length ).ToArray().Select( b => b.ToString( "X2" ) ) ) );
}
ImGui.TableNextColumn();
ImGui.Text( $"{resource->GetData().Length}" );
ImGui.TableNextColumn();
ImGui.Text( $"0x{Penumbra.CharacterUtility.DefaultResources[ i ].Address:X}" );
if( ImGui.IsItemClicked() )
{
ImGui.SetClipboardText( string.Join( " ",
new ReadOnlySpan< byte >( ( byte* )Penumbra.CharacterUtility.DefaultResources[ i ].Address,
Penumbra.CharacterUtility.DefaultResources[ i ].Size ).ToArray().Select( b => b.ToString( "X2" ) ) ) );
}
ImGui.TableNextColumn();
ImGui.Text( $"{Penumbra.CharacterUtility.DefaultResources[ i ].Size}" );
}
}
private unsafe void DrawPathResolverDebug()
{
if( !ImGui.CollapsingHeader( "Path Resolver##Debug" ) )
@ -479,6 +483,14 @@ public partial class SettingsInterface
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTabItem );
if( !ImGui.BeginChild( "##DebugChild", -Vector2.One ) )
{
ImGui.EndChild();
return;
}
raii.Push( ImGui.EndChild );
DrawDebugTabGeneral();
ImGui.NewLine();
DrawDebugTabReplacedResources();
@ -491,12 +503,12 @@ public partial class SettingsInterface
ImGui.NewLine();
DrawPathResolverDebug();
ImGui.NewLine();
DrawDebugCharacterUtility();
ImGui.NewLine();
DrawDebugTabRedraw();
ImGui.NewLine();
DrawDebugTabPlayers();
ImGui.NewLine();
DrawDebugTabTempFiles();
ImGui.NewLine();
DrawDebugTabIpc();
ImGui.NewLine();
}

View file

@ -192,8 +192,9 @@ public partial class SettingsInterface
}
else if( ( row -= activeResolved ) < activeMeta )
{
var (manip, mod) = activeCollection!.MetaManipulations.Manipulations.ElementAt( row );
DrawLine( manip.ToString(), mod.Data.Meta.Name );
// TODO
//var (manip, mod) = activeCollection!.MetaManipulations.Manipulations.ElementAt( row );
DrawLine( 0.ToString(), 0.ToString() );
}
else if( ( row -= activeMeta ) < forcedResolved )
{
@ -202,9 +203,10 @@ public partial class SettingsInterface
}
else
{
// TODO
row -= forcedResolved;
var (manip, mod) = forcedCollection!.MetaManipulations.Manipulations.ElementAt( row );
DrawLine( manip.ToString(), mod.Data.Meta.Name );
//var (manip, mod) = forcedCollection!.MetaManipulations.Manipulations.ElementAt( row );
DrawLine( 0.ToString(), 0.ToString() );
}
}
}

View file

@ -426,8 +426,7 @@ public partial class SettingsInterface
foreach( var collection in modManager.Collections.Collections.Values
.Where( c => c.Cache != null && c.Settings[ Mod!.Data.BasePath.Name ].Enabled ) )
{
collection.CalculateEffectiveFileList( modManager.TempPath, false,
collection == modManager.Collections.ActiveCollection );
collection.CalculateEffectiveFileList( false, collection == modManager.Collections.ActiveCollection );
}
// If the mod is enabled in the current collection, its conflicts may have changed.

View file

@ -1,18 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
using Lumina.Data.Files;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using Penumbra.Meta;
using Penumbra.Meta.Files;
using Penumbra.Meta.Manipulations;
using Penumbra.UI.Custom;
using Penumbra.Util;
using ObjectType = Penumbra.GameData.Enums.ObjectType;
namespace Penumbra.UI
@ -255,7 +249,6 @@ namespace Penumbra.UI
private bool DrawGmpRow( int manipIdx, IList< MetaManipulation > list )
{
var defaults = ( GmpEntry )Penumbra.MetaDefaults.GetDefaultValue( list[ manipIdx ] )!;
var ret = false;
//var id = list[ manipIdx ].GmpIdentifier;
//var val = list[ manipIdx ].GmpValue;
@ -365,7 +358,6 @@ namespace Penumbra.UI
private bool DrawEqdpRow( int manipIdx, IList< MetaManipulation > list )
{
var defaults = ( EqdpEntry )Penumbra.MetaDefaults.GetDefaultValue( list[ manipIdx ] )!;
var ret = false;
//var id = list[ manipIdx ].EqdpIdentifier;
//var val = list[ manipIdx ].EqdpValue;
@ -402,7 +394,6 @@ namespace Penumbra.UI
private bool DrawEstRow( int manipIdx, IList< MetaManipulation > list )
{
var defaults = ( ushort )Penumbra.MetaDefaults.GetDefaultValue( list[ manipIdx ] )!;
var ret = false;
//var id = list[ manipIdx ].EstIdentifier;
//var val = list[ manipIdx ].EstValue;
@ -434,7 +425,6 @@ namespace Penumbra.UI
private bool DrawImcRow( int manipIdx, IList< MetaManipulation > list )
{
var defaults = ( ImcFile.ImageChangeData )Penumbra.MetaDefaults.GetDefaultValue( list[ manipIdx ] )!;
var ret = false;
//var id = list[ manipIdx ].ImcIdentifier;
//var val = list[ manipIdx ].ImcValue;
@ -493,7 +483,6 @@ namespace Penumbra.UI
private bool DrawRspRow( int manipIdx, IList< MetaManipulation > list )
{
var defaults = ( float )Penumbra.MetaDefaults.GetDefaultValue( list[ manipIdx ] )!;
var ret = false;
//var id = list[ manipIdx ].RspIdentifier;
//var val = list[ manipIdx ].RspValue;

View file

@ -529,8 +529,7 @@ public partial class SettingsInterface
var collection = Penumbra.ModManager.Collections.CurrentCollection;
if( collection.Cache != null )
{
collection.CalculateEffectiveFileList( Penumbra.ModManager.TempPath, metaManips,
collection == Penumbra.ModManager.Collections.ActiveCollection );
collection.CalculateEffectiveFileList( metaManips, collection == Penumbra.ModManager.Collections.ActiveCollection );
}
collection.Save();

View file

@ -82,7 +82,7 @@ public partial class SettingsInterface
if( ImGui.IsItemClicked() )
{
var data = ( ( Interop.Structs.ResourceHandle* )r )->GetData();
ImGui.SetClipboardText( ((IntPtr)( ( Interop.Structs.ResourceHandle* )r )->Data->VTable).ToString("X") + string.Join( " ",
ImGui.SetClipboardText( string.Join( " ",
new ReadOnlySpan< byte >( ( byte* )data.Data, data.Length ).ToArray().Select( b => b.ToString( "X2" ) ) ) );
//ImGuiNative.igSetClipboardText( ( byte* )Structs.ResourceHandle.GetData( ( IntPtr )r ) );
}

View file

@ -24,8 +24,6 @@ public partial class SettingsInterface
private readonly Configuration _config;
private bool _configChanged;
private string _newModDirectory;
private string _newTempDirectory;
public TabSettings( SettingsInterface ui )
{
@ -33,7 +31,6 @@ public partial class SettingsInterface
_config = Penumbra.Config;
_configChanged = false;
_newModDirectory = _config.ModDirectory;
_newTempDirectory = _config.TempDirectory;
}
private static bool DrawPressEnterWarning( string old )
@ -91,33 +88,6 @@ public partial class SettingsInterface
}
}
private void DrawTempFolder()
{
ImGui.BeginGroup();
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth );
var save = ImGui.InputText( "Temp Directory", ref _newTempDirectory, 255, ImGuiInputTextFlags.EnterReturnsTrue );
ImGui.SameLine();
ImGuiComponents.HelpMarker( "This is where Penumbra will store temporary meta manipulation files.\n"
+ "Leave this blank if you have no reason not to.\n"
+ "A directory 'penumbrametatmp' will be created as a sub-directory to the specified directory.\n"
+ "If none is specified (i.e. this is blank) this directory will be created in the root directory instead.\n" );
ImGui.SameLine();
var modManager = Penumbra.ModManager;
DrawOpenDirectoryButton( 1, modManager.TempPath, modManager.TempWritable );
ImGui.EndGroup();
if( _newTempDirectory == _config.TempDirectory )
{
return;
}
if( save || DrawPressEnterWarning( _config.TempDirectory ) )
{
modManager.SetTempDirectory( _newTempDirectory );
_newTempDirectory = _config.TempDirectory;
}
}
private void DrawRediscoverButton()
{
if( ImGui.Button( "Rediscover Mods" ) )
@ -326,11 +296,11 @@ public partial class SettingsInterface
{
if( tmp )
{
_base._penumbra.ResourceLoader.EnableFullLogging();
Penumbra.ResourceLoader.EnableFullLogging();
}
else
{
_base._penumbra.ResourceLoader.DisableFullLogging();
Penumbra.ResourceLoader.DisableFullLogging();
}
_config.EnableFullResourceLogging = tmp;
@ -348,11 +318,11 @@ public partial class SettingsInterface
{
if( tmp )
{
_base._penumbra.ResourceLoader.EnableDebug();
Penumbra.ResourceLoader.EnableDebug();
}
else
{
_base._penumbra.ResourceLoader.DisableDebug();
Penumbra.ResourceLoader.DisableDebug();
}
_config.DebugMode = tmp;
@ -388,7 +358,6 @@ public partial class SettingsInterface
private void DrawAdvancedSettings()
{
DrawTempFolder();
DrawRequestedResourceLogging();
DrawDisableSoundStreamingBox();
DrawLogLoadedFilesBox();

View file

@ -68,7 +68,7 @@ public partial class SettingsInterface : IDisposable
var current = modManager.Collections.CurrentCollection;
if( current.Cache != null )
{
current.CalculateEffectiveFileList( modManager.TempPath, recalculateMeta,
current.CalculateEffectiveFileList( recalculateMeta,
current == modManager.Collections.ActiveCollection );
_menu.InstalledTab.Selector.Cache.TriggerFilterReset();
}