mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
added function to redraw all actors or actors with specific names (inspired by / shamelessly stolen from Anamnesis).
This commit is contained in:
parent
ec915368b3
commit
bea196e4b6
3 changed files with 72 additions and 0 deletions
62
Penumbra/Game/RefreshActors.cs
Normal file
62
Penumbra/Game/RefreshActors.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Dalamud.Game.ClientState.Actors;
|
||||||
|
using Dalamud.Game.ClientState.Actors.Types;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Penumbra
|
||||||
|
{
|
||||||
|
public static class RefreshActors
|
||||||
|
{
|
||||||
|
private const int ObjectKindOffset = 0x008C;
|
||||||
|
private const int RenderModeOffset = 0x0104;
|
||||||
|
private const int RenderTaskDelay = 75;
|
||||||
|
|
||||||
|
private enum RenderMode : int
|
||||||
|
{
|
||||||
|
Draw = 0,
|
||||||
|
Unload = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async void Redraw(Actor actor)
|
||||||
|
{
|
||||||
|
var ptr = actor.Address;
|
||||||
|
var objectKindPtr = ptr + ObjectKindOffset;
|
||||||
|
var renderModePtr = ptr + RenderModeOffset;
|
||||||
|
|
||||||
|
async void DrawObject()
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(renderModePtr, (int) RenderMode.Unload);
|
||||||
|
await Task.Delay(RenderTaskDelay);
|
||||||
|
Marshal.WriteInt32(renderModePtr, (int) RenderMode.Draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actor.ObjectKind == Dalamud.Game.ClientState.Actors.ObjectKind.Player)
|
||||||
|
{
|
||||||
|
Marshal.WriteByte(objectKindPtr, (byte) Dalamud.Game.ClientState.Actors.ObjectKind.BattleNpc);
|
||||||
|
DrawObject();
|
||||||
|
await Task.Delay(RenderTaskDelay);
|
||||||
|
Marshal.WriteByte(objectKindPtr, (byte) Dalamud.Game.ClientState.Actors.ObjectKind.Player);
|
||||||
|
Marshal.WriteInt32(renderModePtr, (int) RenderMode.Draw);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DrawObject();
|
||||||
|
await Task.Delay(RenderTaskDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RedrawSpecific(ActorTable actors, string name)
|
||||||
|
{
|
||||||
|
if (name?.Length == 0)
|
||||||
|
RedrawAll(actors);
|
||||||
|
|
||||||
|
foreach (var actor in actors)
|
||||||
|
if (actor.Name == name)
|
||||||
|
Redraw(actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RedrawAll(ActorTable actors)
|
||||||
|
{
|
||||||
|
foreach (var actor in actors)
|
||||||
|
Redraw(actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Linq;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using EmbedIO;
|
using EmbedIO;
|
||||||
|
|
@ -118,6 +119,14 @@ namespace Penumbra
|
||||||
$"Reloaded Penumbra mods. You have {ModManager.Mods.ModSettings.Count} mods, {ModManager.Mods.EnabledMods.Length} of which are enabled."
|
$"Reloaded Penumbra mods. You have {ModManager.Mods.ModSettings.Count} mods, {ModManager.Mods.EnabledMods.Length} of which are enabled."
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case "redraw":
|
||||||
|
{
|
||||||
|
if (args.Length > 1)
|
||||||
|
RefreshActors.RedrawSpecific(PluginInterface.ClientState.Actors, string.Join(" ", args.Skip(1)));
|
||||||
|
else
|
||||||
|
RefreshActors.RedrawAll(PluginInterface.ClientState.Actors);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
_config.IsEnabled = enabled;
|
_config.IsEnabled = enabled;
|
||||||
_configChanged = true;
|
_configChanged = true;
|
||||||
|
RefreshActors.RedrawAll(_base._plugin.PluginInterface.ClientState.Actors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue