From a2965505ba050ab05f4ef54e8eb6a2e7d1324ea4 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 6 Dec 2021 18:14:33 -0500 Subject: [PATCH] fix: update for 6.0 --- Glamaholic/GameFunctions.cs | 12 ++++++++---- Glamaholic/Glamaholic.csproj | 21 +++++++++++++++------ Glamaholic/Glamaholic.yaml | 2 +- Glamaholic/PluginUi.cs | 3 ++- Glamaholic/Ui/Helpers/ExamineHelper.cs | 4 +--- Glamaholic/Ui/Helpers/TryOnHelper.cs | 19 ++++++++++--------- 6 files changed, 37 insertions(+), 24 deletions(-) diff --git a/Glamaholic/GameFunctions.cs b/Glamaholic/GameFunctions.cs index 12006e5..b0eca4e 100755 --- a/Glamaholic/GameFunctions.cs +++ b/Glamaholic/GameFunctions.cs @@ -86,7 +86,8 @@ namespace Glamaholic { var list = new List(); var agents = Framework.Instance()->GetUiModule()->GetAgentModule(); - var dresserAgent = agents->GetAgentByInternalId(AgentId.MiragePrismPrismBox); + // TODO: replace with AgentId.MiragePrismPrismBox when ClientStructs is updated + var dresserAgent = agents->GetAgentByInternalId((AgentId) 292); var itemsStart = *(IntPtr*) ((IntPtr) dresserAgent + 0x28); if (itemsStart == IntPtr.Zero) { @@ -94,7 +95,7 @@ namespace Glamaholic { } for (var i = 0; i < 400; i++) { - var glamItem = *(GlamourItem*) (itemsStart + i * 32); + var glamItem = *(GlamourItem*) (itemsStart + i * 28); if (glamItem.ItemId == 0) { continue; } @@ -120,6 +121,7 @@ namespace Glamaholic { var plate = new Dictionary(); foreach (var slot in (PlateSlot[]) Enum.GetValues(typeof(PlateSlot))) { + // Updated: 6.0 // from SetGlamourPlateSlot var itemId = *(uint*) (editorInfo + 44 * (int) slot + 7956); var stainId = *(byte*) (editorInfo + 44 * (int) slot + 7980); @@ -138,7 +140,7 @@ namespace Glamaholic { } } - private static unsafe AgentInterface* EditorAgent => Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId((AgentId) 293); + private static unsafe AgentInterface* EditorAgent => Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId((AgentId) 294); internal unsafe void SetGlamourPlateSlot(MirageSource source, int glamId, uint itemId, byte stainId) { this._setGlamourPlateSlot((IntPtr) EditorAgent, source, glamId, itemId, stainId); @@ -175,6 +177,7 @@ namespace Glamaholic { return; } + // Updated: 6.0 var editorInfo = *(IntPtr*) ((IntPtr) agent + 0x28); if (editorInfo == IntPtr.Zero) { return; @@ -184,6 +187,7 @@ namespace Glamaholic { var current = CurrentPlate; var usedStains = new Dictionary<(uint, uint), uint>(); + // Updated: 6.0 var slotPtr = (PlateSlot*) (editorInfo + 0x18); var initialSlot = *slotPtr; foreach (var (slot, item) in plate.Items) { @@ -378,7 +382,7 @@ namespace Glamaholic { } } - [StructLayout(LayoutKind.Explicit, Size = 32)] + [StructLayout(LayoutKind.Explicit, Size = 28)] internal readonly struct GlamourItem { [FieldOffset(4)] internal readonly uint Index; diff --git a/Glamaholic/Glamaholic.csproj b/Glamaholic/Glamaholic.csproj index bf97403..d8af2a2 100755 --- a/Glamaholic/Glamaholic.csproj +++ b/Glamaholic/Glamaholic.csproj @@ -52,18 +52,27 @@ - - - - + + + + - + - + diff --git a/Glamaholic/Glamaholic.yaml b/Glamaholic/Glamaholic.yaml index f5aad75..5d12b1d 100755 --- a/Glamaholic/Glamaholic.yaml +++ b/Glamaholic/Glamaholic.yaml @@ -5,4 +5,4 @@ description: | at once at the Glamour Dresser. Supports exporting and importing plates for easy sharing. punchline: Save and swap your glamour plates. -repo_url: https://git.sr.ht/~jkcclemens/Glamaholic +repo_url: https://git.annaclemens.io/ascclemens/Glamaholic diff --git a/Glamaholic/PluginUi.cs b/Glamaholic/PluginUi.cs index a59bebd..d4ae73c 100755 --- a/Glamaholic/PluginUi.cs +++ b/Glamaholic/PluginUi.cs @@ -94,7 +94,8 @@ namespace Glamaholic { internal unsafe void TryOn(IEnumerable items) { void SetTryOnSave(bool save) { - var tryOnAgent = (IntPtr) Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Tryon); + // TODO: replace with AgentId.Tryon once ClientStructs is updated for new agents + var tryOnAgent = (IntPtr) Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId((AgentId) 147); if (tryOnAgent != IntPtr.Zero) { *(byte*) (tryOnAgent + 0x2E2) = (byte) (save ? 1 : 0); } diff --git a/Glamaholic/Ui/Helpers/ExamineHelper.cs b/Glamaholic/Ui/Helpers/ExamineHelper.cs index 07e5a76..010beff 100755 --- a/Glamaholic/Ui/Helpers/ExamineHelper.cs +++ b/Glamaholic/Ui/Helpers/ExamineHelper.cs @@ -58,9 +58,7 @@ namespace Glamaholic.Ui.Helpers { var stainId = item.Stain; - // TODO: remove this logic in endwalker - var slot = i > 5 ? i - 1 : i; - items[(PlateSlot) slot] = new SavedGlamourItem { + items[(PlateSlot) i] = new SavedGlamourItem { ItemId = itemId, StainId = stainId, }; diff --git a/Glamaholic/Ui/Helpers/TryOnHelper.cs b/Glamaholic/Ui/Helpers/TryOnHelper.cs index 00fbbe1..352fa8c 100755 --- a/Glamaholic/Ui/Helpers/TryOnHelper.cs +++ b/Glamaholic/Ui/Helpers/TryOnHelper.cs @@ -42,13 +42,14 @@ namespace Glamaholic.Ui.Helpers { } private static unsafe Dictionary GetTryOnItems() { - var agent = (IntPtr) Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Tryon); + // TODO: replace with AgentId.Tryon once ClientStructs is updated for new agents + var agent = (IntPtr) Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId((AgentId) 147); var firstItem = agent + 0x2E8; var items = new Dictionary(); - + for (var i = 0; i < 12; i++) { - var item = (TryOnItem*) (firstItem + i * 24); + var item = (TryOnItem*) (firstItem + i * 28); if (item->Slot == 14 || item->ItemId == 0) { continue; } @@ -57,10 +58,10 @@ namespace Glamaholic.Ui.Helpers { if (item->GlamourId != 0) { itemId = item->GlamourId; } - - // TODO: remove this logic in endwalker + + // for some reason, this still accounts for belts in EW var slot = item->Slot > 5 ? item->Slot - 1 : item->Slot; - items[(PlateSlot) slot] =new SavedGlamourItem { + items[(PlateSlot) slot] = new SavedGlamourItem { ItemId = itemId % Util.HqItemOffset, StainId = item->StainId, }; @@ -69,7 +70,7 @@ namespace Glamaholic.Ui.Helpers { return items; } - [StructLayout(LayoutKind.Explicit, Size = 24)] + [StructLayout(LayoutKind.Explicit, Size = 28)] private readonly struct TryOnItem { [FieldOffset(0)] internal readonly byte Slot; @@ -80,10 +81,10 @@ namespace Glamaholic.Ui.Helpers { [FieldOffset(5)] internal readonly byte UnknownByte; - [FieldOffset(8)] + [FieldOffset(12)] internal readonly uint ItemId; - [FieldOffset(12)] + [FieldOffset(16)] internal readonly uint GlamourId; } }