Again some Actor Refresher changes.

This commit is contained in:
Ottermandias 2021-07-12 16:51:17 +02:00
parent 92e95400b0
commit bb6c6aed8a
2 changed files with 32 additions and 47 deletions

View file

@ -40,11 +40,12 @@ namespace Penumbra.Interop
private readonly ModManager _mods;
private readonly Queue< (int actorId, string name, Redraw s) > _actorIds = new();
private int _currentFrame = 0;
private bool _changedSettings = false;
private int _currentActorId = -1;
private string? _currentActorName = null;
private Redraw _currentActorRedraw = Redraw.Unload;
private int _currentFrame = 0;
private bool _changedSettings = false;
private int _currentActorId = -1;
private string? _currentActorName = null;
private LoadingFlags _currentActorStartState = 0;
private Redraw _currentActorRedraw = Redraw.Unload;
public static IntPtr RenderPtr( Actor actor )
=> actor.Address + RenderModeOffset;
@ -70,15 +71,16 @@ namespace Penumbra.Interop
_changedSettings = false;
}
private static unsafe void WriteInvisible( IntPtr renderPtr )
private unsafe void WriteInvisible( IntPtr renderPtr )
{
if( renderPtr != IntPtr.Zero )
{
_currentActorStartState = *( LoadingFlags* )renderPtr;
*( LoadingFlags* )renderPtr |= LoadingFlags.Invisibility;
}
}
private static unsafe bool StillLoading( IntPtr renderPtr )
private unsafe bool StillLoading( IntPtr renderPtr )
{
const LoadingFlags stillLoadingFlags = LoadingFlags.SomeNpcFlag
| LoadingFlags.MaybeCulled
@ -88,6 +90,10 @@ namespace Penumbra.Interop
if( renderPtr != IntPtr.Zero )
{
var loadingFlags = *( LoadingFlags* )renderPtr;
if( loadingFlags == _currentActorStartState )
{
return false;
}
return !( loadingFlags == 0 || ( loadingFlags & stillLoadingFlags ) != 0 );
}
@ -152,11 +158,6 @@ namespace Penumbra.Interop
return;
}
if( StillLoading( RenderPtr( actor ) ) )
{
return;
}
switch( _currentActorRedraw )
{
case Redraw.Unload:

View file

@ -173,6 +173,10 @@ namespace Penumbra.UI
.GetField( "_currentActorName", BindingFlags.Instance | BindingFlags.NonPublic )
?.GetValue( _plugin.ActorRefresher );
var currentActorStartState = ( ActorRefresher.LoadingFlags? )_plugin.ActorRefresher.GetType()
.GetField( "_currentActorStartState", BindingFlags.Instance | BindingFlags.NonPublic )
?.GetValue( _plugin.ActorRefresher );
var currentActorRedraw = ( Redraw? )_plugin.ActorRefresher.GetType()
.GetField( "_currentActorRedraw", BindingFlags.Instance | BindingFlags.NonPublic )
?.GetValue( _plugin.ActorRefresher );
@ -188,41 +192,14 @@ namespace Penumbra.UI
if( ImGui.BeginTable( "##RedrawData", 2, ImGuiTableFlags.SizingFixedFit,
new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 7 ) ) )
{
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" );
PrintValue( "Current Frame", currentFrame?.ToString() ?? "null" );
PrintValue( "Current Changed Settings", changedSettings?.ToString() ?? "null" );
PrintValue( "Current Actor Id", currentActorId?.ToString( "X8" ) ?? "null" );
PrintValue( "Current Actor Name", currentActorName ?? "null" );
PrintValue( "Current Actor Start State", ( ( int? )currentActorStartState )?.ToString( "X8" ) ?? "null" );
PrintValue( "Current Actor Redraw", currentActorRedraw?.ToString() ?? "null" );
PrintValue( "Current Actor Address", currentActor?.Address.ToString( "X16" ) ?? "null" );
PrintValue( "Current Actor Render Flags", ( ( int? )currentRender )?.ToString( "X8" ) ?? "null" );
ImGui.EndTable();
}
@ -243,6 +220,13 @@ namespace Penumbra.UI
ImGui.EndTable();
}
if( queue.Any() && ImGui.Button( "Clear" ) )
{
queue.Clear();
_plugin.ActorRefresher.GetType()
.GetField( "_currentFrame", BindingFlags.Instance | BindingFlags.NonPublic )?.SetValue( _plugin.ActorRefresher, 0 );
}
}
private void DrawDebugTabTempFiles()