Include a number of frames to wait after zone changes before redrawing, configurable in advanced settings.

This commit is contained in:
Ottermandias 2021-07-26 16:48:49 +02:00
parent 12ee42df8e
commit 7793b9beec
4 changed files with 42 additions and 4 deletions

View file

@ -22,6 +22,7 @@ namespace Penumbra
public bool EnableHttpApi { get; set; } public bool EnableHttpApi { get; set; }
public bool EnableActorWatch { get; set; } = false; public bool EnableActorWatch { get; set; } = false;
public int WaitFrames { get; set; } = 30;
public string ModDirectory { get; set; } = string.Empty; public string ModDirectory { get; set; } = string.Empty;

View file

@ -36,6 +36,9 @@ namespace Penumbra.Interop
private readonly ModManager _mods; private readonly ModManager _mods;
private readonly Queue< (int actorId, string name, RedrawType s) > _actorIds = new(); private readonly Queue< (int actorId, string name, RedrawType s) > _actorIds = new();
internal int DefaultWaitFrames;
private int _waitFrames = 0;
private int _currentFrame = 0; private int _currentFrame = 0;
private bool _changedSettings = false; private bool _changedSettings = false;
private int _currentActorId = -1; private int _currentActorId = -1;
@ -46,10 +49,11 @@ namespace Penumbra.Interop
public static IntPtr RenderPtr( Actor actor ) public static IntPtr RenderPtr( Actor actor )
=> actor.Address + RenderModeOffset; => actor.Address + RenderModeOffset;
public ActorRefresher( DalamudPluginInterface pi, ModManager mods ) public ActorRefresher( DalamudPluginInterface pi, ModManager mods, int defaultWaitFrames )
{ {
_pi = pi; _pi = pi;
_mods = mods; _mods = mods;
DefaultWaitFrames = defaultWaitFrames;
} }
private void ChangeSettings() private void ChangeSettings()
@ -251,6 +255,13 @@ namespace Penumbra.Interop
{ {
if( _pi.ClientState.Condition[ ConditionFlag.BetweenAreas51 ] || _pi.ClientState.Condition[ ConditionFlag.BetweenAreas ] ) if( _pi.ClientState.Condition[ ConditionFlag.BetweenAreas51 ] || _pi.ClientState.Condition[ ConditionFlag.BetweenAreas ] )
{ {
_waitFrames = DefaultWaitFrames;
return;
}
if( _waitFrames > 0 )
{
--_waitFrames;
return; return;
} }

View file

@ -57,7 +57,7 @@ namespace Penumbra
modManager.DiscoverMods(); modManager.DiscoverMods();
ActorRefresher = new ActorRefresher( PluginInterface, modManager ); ActorRefresher = new ActorRefresher( PluginInterface, modManager, Configuration.WaitFrames );
ResourceLoader = new ResourceLoader( this ); ResourceLoader = new ResourceLoader( this );

View file

@ -21,6 +21,7 @@ namespace Penumbra.UI
private const string LabelOpenFolder = "Open Mods Folder"; private const string LabelOpenFolder = "Open Mods Folder";
private const string LabelEnabled = "Enable Mods"; private const string LabelEnabled = "Enable Mods";
private const string LabelEnabledPlayerWatch = "Enable automatic Character Redraws"; private const string LabelEnabledPlayerWatch = "Enable automatic Character Redraws";
private const string LabelWaitFrames = "Wait Frames";
private const string LabelScaleModSelector = "Scale Mod Selector With Window Size"; private const string LabelScaleModSelector = "Scale Mod Selector With Window Size";
private const string LabelShowAdvanced = "Show Advanced Settings"; private const string LabelShowAdvanced = "Show Advanced Settings";
private const string LabelLogLoadedFiles = "Log all loaded files"; private const string LabelLogLoadedFiles = "Log all loaded files";
@ -174,6 +175,31 @@ namespace Penumbra.UI
"If this setting is enabled, penumbra will keep tabs on characters that have a corresponding collection setup in the Collections tab.\n" "If this setting is enabled, penumbra will keep tabs on characters that have a corresponding collection setup in the Collections tab.\n"
+ "Penumbra will try to automatically redraw those characters using their collection when they first appear in an instance, or when they change their current equip." ); + "Penumbra will try to automatically redraw those characters using their collection when they first appear in an instance, or when they change their current equip." );
} }
if( _config.EnableActorWatch && _config.ShowAdvanced )
{
var waitFrames = _config.WaitFrames;
ImGui.SameLine();
ImGui.SetNextItemWidth( 50 );
if( ImGui.InputInt( LabelWaitFrames, ref waitFrames, 0, 0 )
&& waitFrames != _config.WaitFrames
&& waitFrames > 0
&& waitFrames < 3000 )
{
_base._plugin.ActorRefresher.DefaultWaitFrames = waitFrames;
_config.WaitFrames = waitFrames;
_configChanged = true;
}
if( ImGui.IsItemHovered() )
{
ImGui.SetTooltip(
"The number of frames penumbra waits after some events (like zone changes) until it starts trying to redraw actors again, in a range of [1, 3001].\n"
+ "Keep this as low as possible while producing stable results." );
}
;
}
} }
private static void DrawReloadResourceButton() private static void DrawReloadResourceButton()