mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Merge branch 'master' into api4-b
# Conflicts: # Penumbra/Interop/GameResourceManagement.cs # Penumbra/Penumbra.cs # Penumbra/Penumbra.csproj
This commit is contained in:
commit
34b21c2fde
8 changed files with 164 additions and 16 deletions
BIN
FFXIVClientStructs.Common.dll
Normal file
BIN
FFXIVClientStructs.Common.dll
Normal file
Binary file not shown.
BIN
FFXIVClientStructs.Generators.dll
Normal file
BIN
FFXIVClientStructs.Generators.dll
Normal file
Binary file not shown.
BIN
FFXIVClientStructs.dll
Normal file
BIN
FFXIVClientStructs.dll
Normal file
Binary file not shown.
|
|
@ -4,6 +4,8 @@ using System.Runtime.InteropServices;
|
||||||
using Dalamud.Logging;
|
using Dalamud.Logging;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Penumbra.Structs;
|
using Penumbra.Structs;
|
||||||
|
using Reloaded.Hooks.Definitions.X64;
|
||||||
|
using ResourceHandle = FFXIVClientStructs.FFXIV.Client.System.Resource.Handle.ResourceHandle;
|
||||||
|
|
||||||
namespace Penumbra.Interop
|
namespace Penumbra.Interop
|
||||||
{
|
{
|
||||||
|
|
@ -85,9 +87,11 @@ namespace Penumbra.Interop
|
||||||
|
|
||||||
for( var i = 0; i < NumResources; i++ )
|
for( var i = 0; i < NumResources; i++ )
|
||||||
{
|
{
|
||||||
|
var handle = ( ResourceHandle* )oldResources[ i ];
|
||||||
if( oldResources[ i ].ToPointer() == pResources[ i ] )
|
if( oldResources[ i ].ToPointer() == pResources[ i ] )
|
||||||
{
|
{
|
||||||
PluginLog.Debug( $"Unchanged resource: {ResourceToPath( ( byte* )oldResources[ i ].ToPointer() )}" );
|
PluginLog.Debug( $"Unchanged resource: {ResourceToPath( ( byte* )oldResources[ i ].ToPointer() )}" );
|
||||||
|
( ( ResourceHandle* )oldResources[ i ] )->DecRef();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,6 +100,13 @@ namespace Penumbra.Interop
|
||||||
+ $"{ResourceToPath( ( byte* )pResources[ i ] )}" );
|
+ $"{ResourceToPath( ( byte* )pResources[ i ] )}" );
|
||||||
|
|
||||||
UnloadCharacterResource( oldResources[ i ] );
|
UnloadCharacterResource( oldResources[ i ] );
|
||||||
|
// Temporary fix against crashes?
|
||||||
|
if( handle->RefCount <= 0 )
|
||||||
|
{
|
||||||
|
handle->RefCount = 1;
|
||||||
|
handle->IncRef();
|
||||||
|
handle->RefCount = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ namespace Penumbra
|
||||||
|
|
||||||
public Penumbra( DalamudPluginInterface pluginInterface )
|
public Penumbra( DalamudPluginInterface pluginInterface )
|
||||||
{
|
{
|
||||||
|
FFXIVClientStructs.Resolver.Initialize();
|
||||||
Dalamud.Initialize( pluginInterface );
|
Dalamud.Initialize( pluginInterface );
|
||||||
GameData.GameData.GetIdentifier( Dalamud.GameData, Dalamud.ClientState.ClientLanguage );
|
GameData.GameData.GetIdentifier( Dalamud.GameData, Dalamud.ClientState.ClientLanguage );
|
||||||
Config = Configuration.Load();
|
Config = Configuration.Load();
|
||||||
|
|
|
||||||
|
|
@ -29,38 +29,48 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ILRepack" Version="2.0.18" GeneratePathProperty="true" />
|
||||||
<Reference Include="Dalamud">
|
<Reference Include="Dalamud">
|
||||||
<HintPath>$(DALAMUD_ROOT)\Dalamud.dll</HintPath>
|
|
||||||
<HintPath>..\libs\Dalamud.dll</HintPath>
|
|
||||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
|
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ImGui.NET">
|
<Reference Include="ImGui.NET">
|
||||||
<HintPath>$(DALAMUD_ROOT)\ImGui.NET.dll</HintPath>
|
|
||||||
<HintPath>..\libs\ImGui.NET.dll</HintPath>
|
|
||||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll</HintPath>
|
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ImGuiScene">
|
<Reference Include="ImGuiScene">
|
||||||
<HintPath>$(DALAMUD_ROOT)\ImGuiScene.dll</HintPath>
|
|
||||||
<HintPath>..\libs\ImGuiScene.dll</HintPath>
|
|
||||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll</HintPath>
|
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Lumina">
|
<Reference Include="Lumina">
|
||||||
<HintPath>$(DALAMUD_ROOT)\Lumina.dll</HintPath>
|
|
||||||
<HintPath>..\libs\Lumina.dll</HintPath>
|
|
||||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.dll</HintPath>
|
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Lumina.Excel">
|
<Reference Include="Lumina.Excel">
|
||||||
<HintPath>$(DALAMUD_ROOT)\Lumina.Excel.dll</HintPath>
|
|
||||||
<HintPath>..\libs\Lumina.Excel.dll</HintPath>
|
|
||||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll</HintPath>
|
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="FFXIVClientStructs">
|
||||||
|
<HintPath>..\FFXIVClientStructs.dll</HintPath>
|
||||||
|
<Private>true</Private>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="ILRepack" AfterTargets="Build">
|
||||||
|
<ItemGroup>
|
||||||
|
<InputAssemblies Include="$(TargetPath)"/>
|
||||||
|
<InputAssemblies Include="$(TargetDir)Penumbra.dll $(TargetDir)FFXIVClientStructs.dll" Exclude="$(TargetPath)"/>
|
||||||
|
</ItemGroup>
|
||||||
|
<Exec Command="$(ILRepack) /lib:$(TargetDir) /lib:$(AppData)\XIVLauncher\addon\Hooks\dev /out:$(TargetDir)$(TargetFileName) @(InputAssemblies, ' ')"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="EmbedIO" Version="3.4.3" />
|
<PackageReference Include="EmbedIO" Version="3.4.3" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
|
|
||||||
125
Penumbra/UI/MenuTabs/TabResourceManager.cs
Normal file
125
Penumbra/UI/MenuTabs/TabResourceManager.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
using System.Numerics;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
||||||
|
using FFXIVClientStructs.STD;
|
||||||
|
using ImGuiNET;
|
||||||
|
using ResourceHandle = FFXIVClientStructs.FFXIV.Client.System.Resource.Handle.ResourceHandle;
|
||||||
|
using ResourceManager = FFXIVClientStructs.FFXIV.Client.System.Resource.ResourceManager;
|
||||||
|
|
||||||
|
namespace Penumbra.UI
|
||||||
|
{
|
||||||
|
public partial class SettingsInterface
|
||||||
|
{
|
||||||
|
private static string GetNodeLabel( string label, uint type, ulong count )
|
||||||
|
{
|
||||||
|
var byte1 = type >> 24;
|
||||||
|
var byte2 = ( type >> 16 ) & 0xFF;
|
||||||
|
var byte3 = ( type >> 8 ) & 0xFF;
|
||||||
|
var byte4 = type & 0xFF;
|
||||||
|
return byte1 == 0
|
||||||
|
? $"{( char )byte2}{( char )byte3}{( char )byte4} - {count}###{label}{type}Debug"
|
||||||
|
: $"{( char )byte1}{( char )byte2}{( char )byte3}{( char )byte4} - {count}###{label}{type}Debug";
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void DrawResourceMap( string label, StdMap< uint, Pointer< ResourceHandle > >* typeMap )
|
||||||
|
{
|
||||||
|
if( typeMap == null || !ImGui.TreeNodeEx( label ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( typeMap->Count == 0 || !ImGui.BeginTable( $"##{label}_table", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg ) )
|
||||||
|
{
|
||||||
|
ImGui.TreePop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TableSetupColumn( "Hash", ImGuiTableColumnFlags.WidthFixed, 100 );
|
||||||
|
ImGui.TableSetupColumn( "Ptr", ImGuiTableColumnFlags.WidthFixed, 100 );
|
||||||
|
ImGui.TableSetupColumn( "Path", ImGuiTableColumnFlags.WidthFixed, ImGui.GetWindowContentRegionWidth() - 300 );
|
||||||
|
ImGui.TableSetupColumn( "Refs", ImGuiTableColumnFlags.WidthFixed, 30 );
|
||||||
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
|
var node = typeMap->SmallestValue;
|
||||||
|
while( !node->IsNil )
|
||||||
|
{
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.Text( node->KeyValuePair.Item1.ToString() );
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
var address = $"0x{( ulong )node->KeyValuePair.Item2.Value:X}";
|
||||||
|
ImGui.Text( address );
|
||||||
|
if( ImGui.IsItemClicked() )
|
||||||
|
{
|
||||||
|
ImGui.SetClipboardText( address );
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.Text( node->KeyValuePair.Item2.Value->FileName.ToString() );
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.Text( node->KeyValuePair.Item2.Value->RefCount.ToString() );
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void DrawCategoryContainer( string label, ResourceGraph.CategoryContainer container )
|
||||||
|
{
|
||||||
|
var map = container.MainMap;
|
||||||
|
if( map == null || !ImGui.TreeNodeEx( $"{label} - {map->Count}###{label}Debug" ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var node = map->SmallestValue;
|
||||||
|
while( !node->IsNil )
|
||||||
|
{
|
||||||
|
DrawResourceMap( GetNodeLabel( label, node->KeyValuePair.Item1, node->KeyValuePair.Item2.Value->Count ),
|
||||||
|
node->KeyValuePair.Item2.Value );
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void DrawResourceManagerTab()
|
||||||
|
{
|
||||||
|
if( !ImGui.BeginTabItem( "Resource Manager Tab" ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var resourceHandler = *( ResourceManager** )( _plugin.PluginInterface.TargetModuleScanner.Module.BaseAddress + 0x1D93AC0 );
|
||||||
|
|
||||||
|
if( resourceHandler == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ImGui.BeginChild( "##ResourceManagerChild", -Vector2.One, true ) )
|
||||||
|
{
|
||||||
|
DrawCategoryContainer( "Common", resourceHandler->ResourceGraph->CommonContainer );
|
||||||
|
DrawCategoryContainer( "BgCommon", resourceHandler->ResourceGraph->BgCommonContainer );
|
||||||
|
DrawCategoryContainer( "Bg", resourceHandler->ResourceGraph->BgContainer );
|
||||||
|
DrawCategoryContainer( "Cut", resourceHandler->ResourceGraph->CutContainer );
|
||||||
|
DrawCategoryContainer( "Chara", resourceHandler->ResourceGraph->CharaContainer );
|
||||||
|
DrawCategoryContainer( "Shader", resourceHandler->ResourceGraph->ShaderContainer );
|
||||||
|
DrawCategoryContainer( "Ui", resourceHandler->ResourceGraph->UiContainer );
|
||||||
|
DrawCategoryContainer( "Sound", resourceHandler->ResourceGraph->SoundContainer );
|
||||||
|
DrawCategoryContainer( "Vfx", resourceHandler->ResourceGraph->VfxContainer );
|
||||||
|
DrawCategoryContainer( "UiScript", resourceHandler->ResourceGraph->UiScriptContainer );
|
||||||
|
DrawCategoryContainer( "Exd", resourceHandler->ResourceGraph->ExdContainer );
|
||||||
|
DrawCategoryContainer( "GameScript", resourceHandler->ResourceGraph->GameScriptContainer );
|
||||||
|
DrawCategoryContainer( "Music", resourceHandler->ResourceGraph->MusicContainer );
|
||||||
|
DrawCategoryContainer( "SqpackTest", resourceHandler->ResourceGraph->SqpackTestContainer );
|
||||||
|
DrawCategoryContainer( "Debug", resourceHandler->ResourceGraph->DebugContainer );
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndChild();
|
||||||
|
|
||||||
|
ImGui.EndTabItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -80,6 +80,7 @@ namespace Penumbra.UI
|
||||||
if( DebugTabVisible )
|
if( DebugTabVisible )
|
||||||
{
|
{
|
||||||
_base.DrawDebugTab();
|
_base.DrawDebugTab();
|
||||||
|
_base.DrawResourceManagerTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabBar();
|
ImGui.EndTabBar();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue