mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-17 22:24:25 +01:00
Use refactored Penumbra options to allow for fixed designs on NPCs.
This commit is contained in:
parent
9d5f811a44
commit
9dc1b92c9a
3 changed files with 14 additions and 51 deletions
|
|
@ -43,11 +43,6 @@ namespace Glamourer.Gui
|
||||||
Dalamud.PluginInterface.UiBuilder.Draw += Draw;
|
Dalamud.PluginInterface.UiBuilder.Draw += Draw;
|
||||||
Dalamud.PluginInterface.UiBuilder.OpenConfigUi += ToggleVisibility;
|
Dalamud.PluginInterface.UiBuilder.OpenConfigUi += ToggleVisibility;
|
||||||
|
|
||||||
_characterConstructor = typeof(Character).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new[]
|
|
||||||
{
|
|
||||||
typeof(IntPtr),
|
|
||||||
}, null)!;
|
|
||||||
|
|
||||||
_equipSlotNames = GetEquipSlotNames();
|
_equipSlotNames = GetEquipSlotNames();
|
||||||
|
|
||||||
_stains = GameData.Stains(Dalamud.GameData);
|
_stains = GameData.Stains(Dalamud.GameData);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ using Glamourer.Customization;
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
using Glamourer.FileSystem;
|
using Glamourer.FileSystem;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using Penumbra.PlayerWatch;
|
||||||
|
|
||||||
namespace Glamourer.Gui
|
namespace Glamourer.Gui
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +23,6 @@ namespace Glamourer.Gui
|
||||||
private const string DesignNamePopupLabel = "Save Design As...";
|
private const string DesignNamePopupLabel = "Save Design As...";
|
||||||
private const uint RedHeaderColor = 0xFF1818C0;
|
private const uint RedHeaderColor = 0xFF1818C0;
|
||||||
private const uint GreenHeaderColor = 0xFF18C018;
|
private const uint GreenHeaderColor = 0xFF18C018;
|
||||||
private readonly ConstructorInfo _characterConstructor;
|
|
||||||
|
|
||||||
private void DrawPlayerHeader()
|
private void DrawPlayerHeader()
|
||||||
{
|
{
|
||||||
|
|
@ -111,49 +111,16 @@ namespace Glamourer.Gui
|
||||||
Glamourer.Penumbra.UpdateCharacters(player, fallback);
|
Glamourer.Penumbra.UpdateCharacters(player, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int ModelTypeOffset = 0x01B4;
|
|
||||||
|
|
||||||
private static unsafe int ModelType(GameObject actor)
|
|
||||||
=> *(int*) (actor.Address + ModelTypeOffset);
|
|
||||||
|
|
||||||
private static unsafe void SetModelType(GameObject actor, int value)
|
|
||||||
=> *(int*) (actor.Address + ModelTypeOffset) = value;
|
|
||||||
|
|
||||||
private Character Character(IntPtr address)
|
|
||||||
=> (Character) _characterConstructor.Invoke(new object[]
|
|
||||||
{
|
|
||||||
address,
|
|
||||||
});
|
|
||||||
|
|
||||||
private Character? CreateCharacter(GameObject? actor)
|
|
||||||
{
|
|
||||||
if (actor == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return actor switch
|
|
||||||
{
|
|
||||||
PlayerCharacter p => p,
|
|
||||||
BattleChara b => b,
|
|
||||||
_ => actor.ObjectKind switch
|
|
||||||
{
|
|
||||||
ObjectKind.BattleNpc => Character(actor.Address),
|
|
||||||
ObjectKind.Companion => Character(actor.Address),
|
|
||||||
ObjectKind.EventNpc => Character(actor.Address),
|
|
||||||
_ => null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static Character? TransformToCustomizable(Character? actor)
|
private static Character? TransformToCustomizable(Character? actor)
|
||||||
{
|
{
|
||||||
if (actor == null)
|
if (actor == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (ModelType(actor) == 0)
|
if (actor.ModelType() == 0)
|
||||||
return actor;
|
return actor;
|
||||||
|
|
||||||
SetModelType(actor, 0);
|
actor.SetModelType(0);
|
||||||
CharacterCustomization.Default.Write(actor.Address);
|
CharacterCustomization.Default.Write(actor.Address);
|
||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +130,7 @@ namespace Glamourer.Gui
|
||||||
if (!ImGui.Button("Apply to Target"))
|
if (!ImGui.Button("Apply to Target"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var player = TransformToCustomizable(CreateCharacter(Dalamud.Targets.Target));
|
var player = TransformToCustomizable(CharacterFactory.Convert(Dalamud.Targets.Target));
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -224,7 +191,7 @@ namespace Glamourer.Gui
|
||||||
DrawTargetPlayerButton();
|
DrawTargetPlayerButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentModel = ModelType(_player!);
|
var currentModel = _player!.ModelType();
|
||||||
using var raii = new ImGuiRaii();
|
using var raii = new ImGuiRaii();
|
||||||
if (!raii.Begin(() => ImGui.BeginCombo("Model Id", currentModel.ToString()), ImGui.EndCombo))
|
if (!raii.Begin(() => ImGui.BeginCombo("Model Id", currentModel.ToString()), ImGui.EndCombo))
|
||||||
return;
|
return;
|
||||||
|
|
@ -234,7 +201,7 @@ namespace Glamourer.Gui
|
||||||
if (!ImGui.Selectable($"{id:D6}##models", id == currentModel) || id == currentModel)
|
if (!ImGui.Selectable($"{id:D6}##models", id == currentModel) || id == currentModel)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SetModelType(_player!, (int) id);
|
_player!.SetModelType((int) id);
|
||||||
Glamourer.Penumbra.UpdateCharacters(_player!);
|
Glamourer.Penumbra.UpdateCharacters(_player!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +253,7 @@ namespace Glamourer.Gui
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_player == null || ModelType(_player) == 0)
|
if (_player == null || _player.ModelType() == 0)
|
||||||
DrawPlayerPanel();
|
DrawPlayerPanel();
|
||||||
else
|
else
|
||||||
DrawMonsterPanel();
|
DrawMonsterPanel();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using Penumbra.PlayerWatch;
|
||||||
|
|
||||||
namespace Glamourer.Gui
|
namespace Glamourer.Gui
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +44,7 @@ namespace Glamourer.Gui
|
||||||
if (player.ObjectKind == ObjectKind.Player)
|
if (player.ObjectKind == ObjectKind.Player)
|
||||||
return num == 1 ? playerName : $"{playerName} #{num}";
|
return num == 1 ? playerName : $"{playerName} #{num}";
|
||||||
|
|
||||||
if (ModelType(player) == 0)
|
if (player.ModelType() == 0)
|
||||||
return num == 1 ? $"{playerName} (NPC)" : $"{playerName} #{num} (NPC)";
|
return num == 1 ? $"{playerName} (NPC)" : $"{playerName} #{num} (NPC)";
|
||||||
|
|
||||||
return num == 1 ? $"{playerName} (Monster)" : $"{playerName} #{num} (Monster)";
|
return num == 1 ? $"{playerName} (Monster)" : $"{playerName} #{num} (Monster)";
|
||||||
|
|
@ -112,7 +113,7 @@ namespace Glamourer.Gui
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ImGui.Button(FontAwesomeIcon.HandPointer.ToIconString(), buttonWidth))
|
if (ImGui.Button(FontAwesomeIcon.HandPointer.ToIconString(), buttonWidth))
|
||||||
select = CreateCharacter(Dalamud.Targets.Target);
|
select = CharacterFactory.Convert(Dalamud.Targets.Target);
|
||||||
}
|
}
|
||||||
|
|
||||||
raii.PopFonts();
|
raii.PopFonts();
|
||||||
|
|
@ -142,7 +143,7 @@ namespace Glamourer.Gui
|
||||||
_gPoseActors.Clear();
|
_gPoseActors.Clear();
|
||||||
for (var i = GPoseObjectId; i < GPoseObjectId + 48; ++i)
|
for (var i = GPoseObjectId; i < GPoseObjectId + 48; ++i)
|
||||||
{
|
{
|
||||||
var player = CreateCharacter(Dalamud.Objects[i]);
|
var player = CharacterFactory.Convert(Dalamud.Objects[i]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -151,14 +152,14 @@ namespace Glamourer.Gui
|
||||||
|
|
||||||
for (var i = 0; i < GPoseObjectId; ++i)
|
for (var i = 0; i < GPoseObjectId; ++i)
|
||||||
{
|
{
|
||||||
var player = CreateCharacter(Dalamud.Objects[i])!;
|
var player = CharacterFactory.Convert(Dalamud.Objects[i])!;
|
||||||
if (player != null)
|
if (player != null)
|
||||||
DrawPlayerSelectable(player);
|
DrawPlayerSelectable(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = GPoseObjectId + 48; i < Dalamud.Objects.Length; ++i)
|
for (var i = GPoseObjectId + 48; i < Dalamud.Objects.Length; ++i)
|
||||||
{
|
{
|
||||||
var player = CreateCharacter(Dalamud.Objects[i])!;
|
var player = CharacterFactory.Convert(Dalamud.Objects[i])!;
|
||||||
if (player != null)
|
if (player != null)
|
||||||
DrawPlayerSelectable(player);
|
DrawPlayerSelectable(player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue