From 960548f7b27d24afd124cadb0234bf7e48fc74f2 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 1 Jun 2024 22:12:12 +0000 Subject: [PATCH 001/401] [CI] Updating repo.json for 1.2.3.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 7b730f3..af81105 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.2.3.0", - "TestingAssemblyVersion": "1.2.3.0", + "AssemblyVersion": "1.2.3.1", + "TestingAssemblyVersion": "1.2.3.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -26,9 +26,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From eb7cc6ffa02f82ab33136d75e8062851e2354c13 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 5 Jun 2024 11:28:58 +0200 Subject: [PATCH 002/401] Add IpcPending. --- Glamourer/Interop/Material/MaterialManager.cs | 5 +++++ Glamourer/State/StateListener.cs | 6 ++++++ Glamourer/State/StateSource.cs | 21 +++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 8e3936e..b8941e0 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -96,6 +96,11 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, StateSource.Manual), out _); break; + case StateSource.IpcPending: + materialValue.Model.Apply(ref row); + state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, StateSource.IpcManual), + out _); + break; case StateSource.IpcManual: case StateSource.Manual: deleteList.Add(idx); diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 73c8f0d..bd75faf 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -800,6 +800,12 @@ public class StateListener : IDisposable if (_config.UseAdvancedParameters) model.ApplySingleParameterData(flag, state.ModelData.Parameters); break; + case StateSource.IpcPending: + state.BaseData.Parameters.Set(flag, newValue); + state.Sources[flag] = StateSource.IpcManual; + if (_config.UseAdvancedParameters) + model.ApplySingleParameterData(flag, state.ModelData.Parameters); + break; } } } diff --git a/Glamourer/State/StateSource.cs b/Glamourer/State/StateSource.cs index d489814..9a12214 100644 --- a/Glamourer/State/StateSource.cs +++ b/Glamourer/State/StateSource.cs @@ -10,8 +10,9 @@ public enum StateSource : byte IpcFixed, IpcManual, - // Only used for CustomizeParameters. + // Only used for CustomizeParameters and advanced dyes. Pending, + IpcPending, } public static class StateSourceExtensions @@ -19,9 +20,10 @@ public static class StateSourceExtensions public static StateSource Base(this StateSource source) => source switch { - StateSource.Manual or StateSource.IpcManual or StateSource.Pending => StateSource.Manual, - StateSource.Fixed or StateSource.IpcFixed => StateSource.Fixed, - _ => StateSource.Game, + StateSource.Manual or StateSource.Pending => StateSource.Manual, + StateSource.IpcManual or StateSource.IpcPending => StateSource.Manual, + StateSource.Fixed or StateSource.IpcFixed => StateSource.Fixed, + _ => StateSource.Game, }; public static bool IsGame(this StateSource source) @@ -34,7 +36,12 @@ public static class StateSourceExtensions => source.Base() is StateSource.Fixed; public static StateSource SetPending(this StateSource source) - => source is StateSource.Manual ? StateSource.Pending : source; + => source switch + { + StateSource.Manual => StateSource.Pending, + StateSource.IpcManual => StateSource.IpcPending, + _ => source, + }; public static bool RequiresChange(this StateSource source) => source switch @@ -46,7 +53,7 @@ public static class StateSourceExtensions }; public static bool IsIpc(this StateSource source) - => source is StateSource.IpcManual or StateSource.IpcFixed; + => source is StateSource.IpcManual or StateSource.IpcFixed or StateSource.IpcPending; } public unsafe struct StateSources @@ -97,6 +104,7 @@ public unsafe struct StateSources case (byte)StateSource.Manual | ((byte)StateSource.Fixed << 4): case (byte)StateSource.IpcFixed | ((byte)StateSource.Fixed << 4): case (byte)StateSource.Pending | ((byte)StateSource.Fixed << 4): + case (byte)StateSource.IpcPending | ((byte)StateSource.Fixed << 4): case (byte)StateSource.IpcManual | ((byte)StateSource.Fixed << 4): _data[i] = (byte)((value & 0x0F) | ((byte)StateSource.Manual << 4)); break; @@ -104,6 +112,7 @@ public unsafe struct StateSources case ((byte)StateSource.Manual << 4) | (byte)StateSource.Fixed: case ((byte)StateSource.IpcFixed << 4) | (byte)StateSource.Fixed: case ((byte)StateSource.Pending << 4) | (byte)StateSource.Fixed: + case ((byte)StateSource.IpcPending << 4) | (byte)StateSource.Fixed: case ((byte)StateSource.IpcManual << 4) | (byte)StateSource.Fixed: _data[i] = (byte)((value & 0xF0) | (byte)StateSource.Manual); break; From dec3598eff4f93ed54d0d608fc70f8c826366ca5 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 7 Jun 2024 14:41:01 +0000 Subject: [PATCH 003/401] [CI] Updating repo.json for 1.2.3.2 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index af81105..451bd6c 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.2.3.1", - "TestingAssemblyVersion": "1.2.3.1", + "AssemblyVersion": "1.2.3.2", + "TestingAssemblyVersion": "1.2.3.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -26,9 +26,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.2/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 6207f3a67fefd88e19f4945546ac1cf73eaa63d8 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 11 Jun 2024 12:30:24 +0200 Subject: [PATCH 004/401] Fix an exception. --- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 8febcd9..8371232 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -39,8 +39,8 @@ public class ActorPanel private readonly DictModelChara _modelChara; private readonly CustomizeParameterDrawer _parameterDrawer; private readonly AdvancedDyePopup _advancedDyes; - private readonly HeaderDrawer.Button[] _leftButtons; - private readonly HeaderDrawer.Button[] _rightButtons; + private readonly HeaderDrawer.Button[] _leftButtons; + private readonly HeaderDrawer.Button[] _rightButtons; public ActorPanel(ActorSelector selector, StateManager stateManager, @@ -167,7 +167,8 @@ public class ActorPanel DrawHumanPanel(); else DrawMonsterPanel(); - _advancedDyes.Draw(_data.Objects.Last(), _state); + if (_data.Objects.Count > 0) + _advancedDyes.Draw(_data.Objects.Last(), _state); } private void DrawHumanPanel() From 089c7d392d6f115a07bb406a6e8e890c566701b1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 11 Jun 2024 12:30:52 +0200 Subject: [PATCH 005/401] Update submodules. --- OtterGui | 2 +- Penumbra.GameData | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OtterGui b/OtterGui index 0b5afff..e95c0f0 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 0b5afffda19d3e16aec9e8682d18c8f11f67f1c6 +Subproject commit e95c0f04edc7e85aea67498fd8bf495a7fe6d3c8 diff --git a/Penumbra.GameData b/Penumbra.GameData index fed687b..6aeae34 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit fed687b536b7c709484db251b690b8821c5ef403 +Subproject commit 6aeae346332a255b7575ccfca554afb0f3cf1494 From cd498b539b0e30a9665fbfb5619c24ae041824e2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 11 Jun 2024 12:48:57 +0200 Subject: [PATCH 006/401] Ugh. --- Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs index e49b8d1..b4d3740 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs @@ -86,7 +86,7 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule if (ImUtf8.IconButton(FontAwesomeIcon.Trash, $"Delete this cheat code.{(canDelete ? string.Empty : $"\nHold {config.DeleteDesignModifier} while clicking to delete.")}", - !canDelete)) + disabled: !canDelete)) { action!(false); config.Codes.RemoveAt(i--); From 205a95b254c0b5e56ab824407c1fb8cb36af71e8 Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 11 Jun 2024 10:50:56 +0000 Subject: [PATCH 007/401] [CI] Updating repo.json for 1.2.3.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 451bd6c..3798270 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.2.3.2", - "TestingAssemblyVersion": "1.2.3.2", + "AssemblyVersion": "1.2.3.3", + "TestingAssemblyVersion": "1.2.3.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -26,9 +26,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.2/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.2/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 5cf6b0eb7558de2cbbca7b1c184ff6768707291d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 15 Jun 2024 11:52:38 +0200 Subject: [PATCH 008/401] Fix issue with Penumbra load order and visor state. --- Glamourer/Events/PenumbraReloaded.cs | 3 +++ Glamourer/Interop/VisorService.cs | 32 ++++++++++++++++++++++------ Glamourer/State/StateListener.cs | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Glamourer/Events/PenumbraReloaded.cs b/Glamourer/Events/PenumbraReloaded.cs index 7df8b3f..20b58f9 100644 --- a/Glamourer/Events/PenumbraReloaded.cs +++ b/Glamourer/Events/PenumbraReloaded.cs @@ -12,5 +12,8 @@ public sealed class PenumbraReloaded() { /// ChangeCustomizeService = 0, + + /// + VisorService = 0, } } diff --git a/Glamourer/Interop/VisorService.cs b/Glamourer/Interop/VisorService.cs index af66dd6..9763682 100644 --- a/Glamourer/Interop/VisorService.cs +++ b/Glamourer/Interop/VisorService.cs @@ -9,17 +9,24 @@ namespace Glamourer.Interop; public class VisorService : IDisposable { - public readonly VisorStateChanged Event; + private readonly PenumbraReloaded _penumbra; + private readonly IGameInteropProvider _interop; + public readonly VisorStateChanged Event; - public unsafe VisorService(VisorStateChanged visorStateChanged, IGameInteropProvider interop) + public VisorService(VisorStateChanged visorStateChanged, IGameInteropProvider interop, PenumbraReloaded penumbra) { + _interop = interop; + _penumbra = penumbra; Event = visorStateChanged; - _setupVisorHook = interop.HookFromAddress((nint)Human.MemberFunctionPointers.SetupVisor, SetupVisorDetour); - _setupVisorHook.Enable(); + _setupVisorHook = Create(); + _penumbra.Subscribe(Restore, PenumbraReloaded.Priority.VisorService); } public void Dispose() - => _setupVisorHook.Dispose(); + { + _setupVisorHook.Dispose(); + _penumbra.Unsubscribe(Restore); + } /// Obtain the current state of the Visor for the given draw object (true: toggled). public static unsafe bool GetVisorState(Model characterBase) @@ -45,7 +52,7 @@ public class VisorService : IDisposable private delegate void UpdateVisorDelegateInternal(nint humanPtr, ushort modelId, byte on); - private readonly Hook _setupVisorHook; + private Hook _setupVisorHook; private void SetupVisorDetour(nint human, ushort modelId, byte value) { @@ -72,4 +79,17 @@ public class VisorService : IDisposable human.AsCharacterBase->VisorToggled = on; _setupVisorHook.Original(human.Address, modelId, on ? (byte)1 : (byte)0); } + + private unsafe Hook Create() + { + var hook = _interop.HookFromAddress((nint)Human.MemberFunctionPointers.SetupVisor, SetupVisorDetour); + hook.Enable(); + return hook; + } + + private void Restore() + { + _setupVisorHook.Dispose(); + _setupVisorHook = Create(); + } } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index bd75faf..f3657a7 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -578,6 +578,8 @@ public class StateListener : IDisposable // We do not need to handle fixed designs, // since a fixed design would already have established state-tracking. var actor = _penumbra.GameObjectFromDrawObject(model); + if (!actor.IsCharacter) + return; // Only actually change anything if the actor state changed, // when equipping headgear the method is called with the current draw object state, From 52b89a4177b0375cda0dd27e70707aef5005acac Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 15 Jun 2024 11:52:58 +0200 Subject: [PATCH 009/401] Do not apply auto designs to transformed actors maybe? --- Glamourer/Automation/AutoDesignApplier.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index f2ac1b3..f90cb9b 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -280,6 +280,9 @@ public sealed class AutoDesignApplier : IDisposable if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId)) return; + if (actor.IsTransformed) + return; + var mergedDesign = _designMerger.Merge( set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); From 3f99d111794da2fd00c1a1781c2fc4271953aae0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 23 Jun 2024 22:55:31 +0200 Subject: [PATCH 010/401] Add support info to Glamourer. --- Glamourer/Glamourer.cs | 93 ++++++++++++++++++- Glamourer/Gui/MainWindow.cs | 37 +++++++- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 9 +- Glamourer/Services/CodeService.cs | 3 + Glamourer/Services/ServiceManager.cs | 5 +- Glamourer/State/StateIndex.cs | 2 +- OtterGui | 2 +- 7 files changed, 138 insertions(+), 13 deletions(-) diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index b368195..5dd6040 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -1,5 +1,7 @@ using Dalamud.Plugin; using Glamourer.Api; +using Glamourer.Automation; +using Glamourer.Designs; using Glamourer.Gui; using Glamourer.Interop; using Glamourer.Services; @@ -30,7 +32,7 @@ public class Glamourer : IDalamudPlugin { try { - _services = StaticServiceManager.CreateProvider(pluginInterface, Log); + _services = StaticServiceManager.CreateProvider(pluginInterface, Log, this); Messager = _services.GetService(); _services.EnsureRequiredServices(); @@ -50,6 +52,95 @@ public class Glamourer : IDalamudPlugin } } + public string GatherSupportInformation() + { + var sb = new StringBuilder(10240); + var config = _services.GetService(); + sb.AppendLine("**Settings**"); + sb.Append($"> **`Plugin Version: `** {Version}\n"); + sb.Append($"> **`Commit Hash: `** {CommitHash}\n"); + sb.Append($"> **`Enable Auto Designs: `** {config.EnableAutoDesigns}\n"); + sb.Append($"> **`Gear Protection: `** {config.UseRestrictedGearProtection}\n"); + sb.Append($"> **`Item Restriction: `** {config.UnlockedItemMode}\n"); + sb.Append($"> **`Keep Manual Changes: `** {config.RespectManualOnAutomationUpdate}\n"); + sb.Append($"> **`Auto-Reload Gear: `** {config.AutoRedrawEquipOnChanges}\n"); + sb.Append($"> **`Revert on Zone Change:`** {config.RevertManualChangesOnZoneChange}\n"); + sb.Append($"> **`Festival Easter-Eggs: `** {config.DisableFestivals}\n"); + sb.Append($"> **`Advanced Customize: `** {config.UseAdvancedParameters}\n"); + sb.Append($"> **`Advanced Dye: `** {config.UseAdvancedDyes}\n"); + sb.Append($"> **`Apply Entire Weapon: `** {config.ChangeEntireItem}\n"); + sb.Append($"> **`Apply Associated Mods:`** {config.AlwaysApplyAssociatedMods}\n"); + sb.Append($"> **`Show QDB: `** {config.Ephemeral.ShowDesignQuickBar}\n"); + sb.Append($"> **`QDB Hotkey: `** {config.ToggleQuickDesignBar}\n"); + sb.Append($"> **`Smaller Equip Display:`** {config.SmallEquip}\n"); + sb.Append($"> **`Debug Mode: `** {config.DebugMode}\n"); + sb.Append($"> **`Cheat Codes: `** {(ulong)_services.GetService().AllEnabled:X8}\n"); + sb.AppendLine("**Plugins**"); + GatherRelevantPlugins(sb); + var designManager = _services.GetService(); + var autoManager = _services.GetService(); + var stateManager = _services.GetService(); + var objectManager = _services.GetService(); + var currentPlayer = objectManager.PlayerData.Identifier; + var states = stateManager.Where(kvp => objectManager.ContainsKey(kvp.Key)).ToList(); + + sb.AppendLine("**Statistics**"); + sb.Append($"> **`Current Player: `** {(currentPlayer.IsValid ? currentPlayer.Incognito(null) : "None")}\n"); + sb.Append($"> **`Saved Designs: `** {designManager.Designs.Count}\n"); + sb.Append($"> **`Automation Sets: `** {autoManager.Count} ({autoManager.Count(set => set.Enabled)} Enabled)\n"); + sb.Append( + $"> **`Actor States: `** {stateManager.Count} ({states.Count} Visible, {stateManager.Values.Count(s => s.IsLocked)} Locked)\n"); + + var enabledAutomation = autoManager.Where(s => s.Enabled).ToList(); + if (enabledAutomation.Count > 0) + { + sb.AppendLine("**Enabled Automation**"); + foreach (var set in enabledAutomation) + { + sb.Append( + $"> **`{set.Identifiers.First().Incognito(null) + ':',-24}`** {(set.Name.Length >= 2 ? $"{set.Name.AsSpan(0, 2)}..." : set.Name)} ({set.Designs.Count} {(set.Designs.Count == 1 ? "Design" : "Designs")})\n"); + } + } + + if (states.Count > 0) + { + sb.AppendLine("**State**"); + foreach (var (ident, state) in states) + { + var sources = Enum.GetValues().Select(s => (0, s)).ToArray(); + foreach (var source in StateIndex.All.Select(s => state.Sources[s])) + ++sources[(int)source].Item1; + foreach (var material in state.Materials.Values) + ++sources[(int)material.Value.Source].Item1; + var sourcesString = string.Join(", ", sources.Where(s => s.Item1 > 0).Select(s => $"{s.s} {s.Item1}")); + sb.Append( + $"> **`{ident.Incognito(null) + ':',-24}`** {(state.IsLocked ? "Locked, " : string.Empty)}Job {state.LastJob.Id}, Zone {state.LastTerritory}, Materials {state.Materials.Values.Count}, {sourcesString}\n"); + } + } + + return sb.ToString(); + } + + + private void GatherRelevantPlugins(StringBuilder sb) + { + ReadOnlySpan relevantPlugins = + [ + "Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge", + ]; + var plugins = _services.GetService().InstalledPlugins + .GroupBy(p => p.InternalName) + .ToDictionary(g => g.Key, g => + { + var item = g.OrderByDescending(p => p.IsLoaded).ThenByDescending(p => p.Version).First(); + return (item.IsLoaded, item.Version, item.Name); + }); + foreach (var plugin in relevantPlugins) + { + if (plugins.TryGetValue(plugin, out var data)) + sb.Append($"> **`{data.Name + ':',-22}`** {data.Version}{(data.IsLoaded ? string.Empty : " (Disabled)")}\n"); + } + } public void Dispose() => _services?.Dispose(); diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs index f7cd589..007d936 100644 --- a/Glamourer/Gui/MainWindow.cs +++ b/Glamourer/Gui/MainWindow.cs @@ -1,4 +1,5 @@ -using Dalamud.Interface.Windowing; +using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.Windowing; using Dalamud.Plugin; using Glamourer.Designs; using Glamourer.Events; @@ -13,6 +14,7 @@ using Glamourer.Gui.Tabs.UnlocksTab; using Glamourer.Interop.Penumbra; using ImGuiNET; using OtterGui; +using OtterGui.Classes; using OtterGui.Custom; using OtterGui.Raii; using OtterGui.Services; @@ -131,7 +133,12 @@ public class MainWindow : Window, IDisposable if (_penumbra.CurrentMajor == 0) DrawProblemWindow( "Could not attach to Penumbra. Please make sure Penumbra is installed and running.\n\nPenumbra is required for Glamourer to work properly."); - else if (_penumbra is { CurrentMajor: PenumbraService.RequiredPenumbraBreakingVersion, CurrentMinor: >= PenumbraService.RequiredPenumbraFeatureVersion }) + else if (_penumbra is + { + + CurrentMajor: PenumbraService.RequiredPenumbraBreakingVersion, + CurrentMinor: >= PenumbraService.RequiredPenumbraFeatureVersion, + }) DrawProblemWindow( $"You are currently not attached to Penumbra, seemingly by manually detaching from it.\n\nPenumbra's last API Version was {_penumbra.CurrentMajor}.{_penumbra.CurrentMinor}.\n\nPenumbra is required for Glamourer to work properly."); else @@ -184,22 +191,42 @@ public class MainWindow : Window, IDisposable return TabType.None; } + /// The longest support button text. + public static ReadOnlySpan SupportInfoButtonText + => "Copy Support Info to Clipboard"u8; + /// Draw the support button group on the right-hand side of the window. - public static void DrawSupportButtons(Changelog changelog) + public static void DrawSupportButtons(Glamourer glamourer, Changelog changelog) { - var width = ImGui.CalcTextSize("Join Discord for Support").X + ImGui.GetStyle().FramePadding.X * 2; + var width = ImUtf8.CalcTextSize(SupportInfoButtonText).X + ImGui.GetStyle().FramePadding.X * 2; var xPos = ImGui.GetWindowWidth() - width; ImGui.SetCursorPos(new Vector2(xPos, 0)); CustomGui.DrawDiscordButton(Glamourer.Messager, width); ImGui.SetCursorPos(new Vector2(xPos, ImGui.GetFrameHeightWithSpacing())); - CustomGui.DrawGuideButton(Glamourer.Messager, width); + DrawSupportButton(glamourer); ImGui.SetCursorPos(new Vector2(xPos, 2 * ImGui.GetFrameHeightWithSpacing())); + CustomGui.DrawGuideButton(Glamourer.Messager, width); + + ImGui.SetCursorPos(new Vector2(xPos, 3 * ImGui.GetFrameHeightWithSpacing())); if (ImGui.Button("Show Changelogs", new Vector2(width, 0))) changelog.ForceOpen = true; } + /// + /// Draw a button that copies the support info to clipboards. + /// + private static void DrawSupportButton(Glamourer glamourer) + { + if (!ImUtf8.Button(SupportInfoButtonText)) + return; + + var text = glamourer.GatherSupportInformation(); + ImGui.SetClipboardText(text); + Glamourer.Messager.NotificationMessage("Copied Support Info to Clipboard.", NotificationType.Success, false); + } + private void OnTabSelected(TabType type, Design? _) { SelectTab = type; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 6259f06..834b9fc 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -10,6 +10,7 @@ using Glamourer.Interop.PalettePlus; using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.SettingsTab; @@ -25,7 +26,8 @@ public class SettingsTab( PaletteImport paletteImport, PalettePlusChecker paletteChecker, CollectionOverrideDrawer overrides, - CodeDrawer codeDrawer) + CodeDrawer codeDrawer, + Glamourer glamourer) : ITab { private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray(); @@ -45,8 +47,9 @@ public class SettingsTab( ImGui.NewLine(); ImGui.NewLine(); ImGui.NewLine(); + ImGui.NewLine(); - using (var child2 = ImRaii.Child("SettingsChild")) + using (ImRaii.Child("SettingsChild")) { DrawBehaviorSettings(); DrawInterfaceSettings(); @@ -55,7 +58,7 @@ public class SettingsTab( codeDrawer.Draw(); } - MainWindow.DrawSupportButtons(changelog.Changelog); + MainWindow.DrawSupportButtons(glamourer, changelog.Changelog); } private void DrawBehaviorSettings() diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index 7d513dd..61339e1 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -50,6 +50,9 @@ public class CodeService private CodeFlag _enabled; + public CodeFlag AllEnabled + => _enabled; + public bool Enabled(CodeFlag flag) => _enabled.HasFlag(flag); diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index f06e014..005944e 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -33,7 +33,7 @@ namespace Glamourer.Services; public static class StaticServiceManager { - public static ServiceManager CreateProvider(DalamudPluginInterface pi, Logger log) + public static ServiceManager CreateProvider(DalamudPluginInterface pi, Logger log, Glamourer glamourer) { EventWrapperBase.ChangeLogger(log); var services = new ServiceManager(log) @@ -44,7 +44,8 @@ public static class StaticServiceManager .AddData() .AddDesigns() .AddState() - .AddUi(); + .AddUi() + .AddExistingService(glamourer); DalamudServices.AddServices(services, pi); services.AddIServices(typeof(EquipItem).Assembly); services.AddIServices(typeof(Glamourer).Assembly); diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index a55d6b1..28cc722 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -200,7 +200,7 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators All + public static IEnumerable All => Enumerable.Range(0, Size - 1).Select(i => new StateIndex(i)); public bool GetApply(DesignBase data) diff --git a/OtterGui b/OtterGui index e95c0f0..fd79128 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit e95c0f04edc7e85aea67498fd8bf495a7fe6d3c8 +Subproject commit fd791285606d49a7644762ea0b4dc2bbb1368eac From c1d9af2dd0c0b0e44874befd2b6947bfab773f82 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 11 Jul 2024 14:20:19 +0200 Subject: [PATCH 011/401] Update Item API. --- Glamourer.Api | 2 +- Glamourer/Api/IpcProviders.cs | 9 ++++++++- Glamourer/Api/ItemsApi.cs | 12 ++++++------ Penumbra.Api | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index a20d4ab..4aaece3 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit a20d4ab1811a7f66918afab9b41ec723f75054f5 +Subproject commit 4aaece34289d64363bc32aaa8fe52c8e7d3dce32 diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 638d228..efbc368 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -2,6 +2,8 @@ using Dalamud.Plugin; using Glamourer.Api.Api; using Glamourer.Api.Helpers; using OtterGui.Services; +using System.Reflection.Emit; +using Glamourer.Api.Enums; namespace Glamourer.Api; @@ -12,7 +14,7 @@ public sealed class IpcProviders : IDisposable, IApiService private readonly EventProvider _disposedProvider; private readonly EventProvider _initializedProvider; - public IpcProviders(DalamudPluginInterface pi, IGlamourerApi api) + public IpcProviders(IDalamudPluginInterface pi, IGlamourerApi api) { _disposedProvider = IpcSubscribers.Disposed.Provider(pi); _initializedProvider = IpcSubscribers.Initialized.Provider(pi); @@ -28,6 +30,11 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.SetItem.Provider(pi, api.Items), IpcSubscribers.SetItemName.Provider(pi, api.Items), + // backward compatibility + new FuncProvider(pi, IpcSubscribers.Legacy.SetItemV2.Label, + (a, b, c, d, e, f) => (int)api.Items.SetItem(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)), + new FuncProvider(pi, IpcSubscribers.Legacy.SetItemName.Label, + (a, b, c, d, e, f) => (int)api.Items.SetItemName(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)), IpcSubscribers.GetState.Provider(pi, api.State), IpcSubscribers.GetStateName.Provider(pi, api.State), diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index cda1980..a2e3533 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -11,9 +11,9 @@ namespace Glamourer.Api; public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager stateManager) : IGlamourerApiItems, IApiService { - public GlamourerApiEc SetItem(int objectIndex, ApiEquipSlot slot, ulong itemId, byte stain, uint key, ApplyFlag flags) + public GlamourerApiEc SetItem(int objectIndex, ApiEquipSlot slot, ulong itemId, IReadOnlyList stains, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Index", objectIndex, "Slot", slot, "ID", itemId, "Stain", stain, "Key", key, "Flags", flags); + var args = ApiHelpers.Args("Index", objectIndex, "Slot", slot, "ID", itemId, "Stains", stains, "Key", key, "Flags", flags); if (!ResolveItem(slot, itemId, out var item)) return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); @@ -27,14 +27,14 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key); - stateManager.ChangeEquip(state, (EquipSlot)slot, item, stain, settings); + stateManager.ChangeEquip(state, (EquipSlot)slot, item, new StainIds(stains), settings); ApiHelpers.Lock(state, key, flags); return GlamourerApiEc.Success; } - public GlamourerApiEc SetItemName(string playerName, ApiEquipSlot slot, ulong itemId, byte stain, uint key, ApplyFlag flags) + public GlamourerApiEc SetItemName(string playerName, ApiEquipSlot slot, ulong itemId, IReadOnlyList stains, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Name", playerName, "Slot", slot, "ID", itemId, "Stain", stain, "Key", key, "Flags", flags); + var args = ApiHelpers.Args("Name", playerName, "Slot", slot, "ID", itemId, "Stains", stains, "Key", key, "Flags", flags); if (!ResolveItem(slot, itemId, out var item)) return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); @@ -53,7 +53,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager continue; anyUnlocked = true; - stateManager.ChangeEquip(state, (EquipSlot)slot, item, stain, settings); + stateManager.ChangeEquip(state, (EquipSlot)slot, item, new StainIds(stains), settings); ApiHelpers.Lock(state, key, flags); } diff --git a/Penumbra.Api b/Penumbra.Api index f1e4e52..f4c6144 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit f1e4e520daaa8f23e5c8b71d55e5992b8f6768e2 +Subproject commit f4c6144ca2012b279e6d8aa52b2bef6cc2ba32d9 From 7caf6cc08a69e865a8dd8e02d661a872626e400f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 11 Jul 2024 14:21:25 +0200 Subject: [PATCH 012/401] Initial Update for multiple stains, some facewear support, and API X --- Glamourer/Automation/AutoDesignManager.cs | 2 +- Glamourer/Automation/FixedDesignMigrator.cs | 2 +- Glamourer/Configuration.cs | 2 +- Glamourer/Designs/Design.cs | 2 +- Glamourer/Designs/DesignBase.cs | 15 +- Glamourer/Designs/DesignBase64Migration.cs | 9 +- Glamourer/Designs/DesignColors.cs | 2 +- Glamourer/Designs/DesignConverter.cs | 8 +- Glamourer/Designs/DesignData.cs | 150 ++++++++++-------- Glamourer/Designs/DesignEditor.cs | 17 +- Glamourer/Designs/DesignFileSystem.cs | 2 +- Glamourer/Designs/IDesignEditor.cs | 6 +- Glamourer/Designs/Links/DesignLinkLoader.cs | 3 +- Glamourer/EphemeralConfig.cs | 2 +- Glamourer/Events/MovedEquipment.cs | 2 +- Glamourer/GameData/CustomizeManager.cs | 13 +- Glamourer/GameData/CustomizeSetFactory.cs | 12 +- Glamourer/GameData/NpcCustomizeSet.cs | 60 +++---- Glamourer/GameData/NpcData.cs | 27 ++-- Glamourer/Glamourer.cs | 4 +- Glamourer/Glamourer.csproj | 1 + Glamourer/Glamourer.json | 2 +- .../CustomizationDrawer.GenderRace.cs | 11 +- .../Customization/CustomizationDrawer.Icon.cs | 23 ++- .../Gui/Customization/CustomizationDrawer.cs | 27 +--- Glamourer/Gui/Equipment/EquipDrawData.cs | 14 +- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 49 +++--- Glamourer/Gui/GlamourerWindowSystem.cs | 4 +- Glamourer/Gui/MainWindow.cs | 4 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 4 +- .../Gui/Tabs/DebugTab/ActiveStatePanel.cs | 4 +- .../Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 14 +- Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs | 4 +- .../DebugTab/IpcTester/DesignIpcTester.cs | 2 +- .../Tabs/DebugTab/IpcTester/IpcTesterPanel.cs | 2 +- .../Tabs/DebugTab/IpcTester/ItemsIpcTester.cs | 6 +- .../Tabs/DebugTab/IpcTester/StateIpcTester.cs | 4 +- .../Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 42 ++++- .../Gui/Tabs/DesignTab/DesignDetailTab.cs | 2 +- .../DesignTab/DesignFileSystemSelector.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 6 +- Glamourer/Gui/Tabs/DesignTab/DesignTab.cs | 2 +- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 2 +- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 2 +- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 3 +- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 17 +- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 70 +++++++- Glamourer/Interop/ChangeCustomizeService.cs | 2 +- Glamourer/Interop/CharaFile/CharaFile.cs | 4 +- Glamourer/Interop/CharaFile/CmaFile.cs | 10 +- Glamourer/Interop/ContextMenuService.cs | 18 ++- Glamourer/Interop/CrestService.cs | 17 +- Glamourer/Interop/ImportService.cs | 2 +- Glamourer/Interop/InventoryService.cs | 82 +++++----- Glamourer/Interop/Material/MaterialManager.cs | 9 +- .../Interop/Material/MaterialValueIndex.cs | 4 +- .../Interop/Material/MaterialValueManager.cs | 2 +- Glamourer/Interop/Material/PrepareColorSet.cs | 26 +-- Glamourer/Interop/MetaService.cs | 12 +- Glamourer/Interop/ObjectManager.cs | 2 +- .../Interop/PalettePlus/PaletteImport.cs | 2 +- .../Interop/PalettePlus/PalettePlusChecker.cs | 8 +- Glamourer/Interop/Penumbra/PenumbraService.cs | 6 +- Glamourer/Interop/ScalingService.cs | 15 +- Glamourer/Interop/UpdateSlotService.cs | 34 +++- Glamourer/Interop/WeaponService.cs | 6 +- .../Services/CollectionOverrideService.cs | 4 +- Glamourer/Services/CustomizeService.cs | 18 --- Glamourer/Services/DalamudServices.cs | 2 +- Glamourer/Services/FilenameService.cs | 2 +- Glamourer/Services/HeightService.cs | 3 +- Glamourer/Services/ItemManager.cs | 10 +- Glamourer/Services/ServiceManager.cs | 5 +- Glamourer/Services/TextureService.cs | 6 +- Glamourer/State/FunEquipSet.cs | 7 +- Glamourer/State/FunModule.cs | 43 +++-- Glamourer/State/InternalStateEditor.cs | 16 +- Glamourer/State/StateApplier.cs | 26 +-- Glamourer/State/StateEditor.cs | 38 ++--- Glamourer/State/StateListener.cs | 34 ++-- Glamourer/State/StateManager.cs | 20 +-- Glamourer/State/WorldSets.cs | 2 +- Glamourer/Unlocks/CustomizeUnlockManager.cs | 7 +- Glamourer/Unlocks/FavoriteManager.cs | 2 +- Glamourer/Unlocks/ItemUnlockManager.cs | 12 +- Glamourer/Unlocks/UnlockDictionaryHelpers.cs | 2 +- OtterGui | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- repo.json | 2 +- 90 files changed, 654 insertions(+), 537 deletions(-) diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index 1b95f73..da9b014 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -1,5 +1,5 @@ using Dalamud.Game.ClientState.Objects.Enums; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Designs.Special; using Glamourer.Events; diff --git a/Glamourer/Automation/FixedDesignMigrator.cs b/Glamourer/Automation/FixedDesignMigrator.cs index 856561a..fb9bca4 100644 --- a/Glamourer/Automation/FixedDesignMigrator.cs +++ b/Glamourer/Automation/FixedDesignMigrator.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Interop; using Newtonsoft.Json.Linq; diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index dbd245f..d0b3f98 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -1,6 +1,6 @@ using Dalamud.Configuration; using Dalamud.Game.ClientState.Keys; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Gui; using Glamourer.Gui.Tabs.DesignTab; diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index f09e7bc..b8dc0a2 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Automation; using Glamourer.Designs.Links; using Glamourer.Interop.Material; diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 4910793..3791442 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Services; @@ -257,10 +257,10 @@ public class DesignBase foreach (var slot in EquipSlotExtensions.EqdpSlots.Prepend(EquipSlot.OffHand).Prepend(EquipSlot.MainHand)) { var item = _designData.Item(slot); - var stain = _designData.Stain(slot); + var stains = _designData.Stain(slot); var crestSlot = slot.ToCrestFlag(); var crest = _designData.Crest(crestSlot); - ret[slot.ToString()] = Serialize(item.Id, stain, crest, DoApplyEquip(slot), DoApplyStain(slot), DoApplyCrest(crestSlot)); + ret[slot.ToString()] = Serialize(item.Id, stains, crest, DoApplyEquip(slot), DoApplyStain(slot), DoApplyCrest(crestSlot)); } ret["Hat"] = new QuadBool(_designData.IsHatVisible(), DoApplyMeta(MetaIndex.HatState)).ToJObject("Show", "Apply"); @@ -274,16 +274,15 @@ public class DesignBase return ret; - static JObject Serialize(CustomItemId id, StainId stain, bool crest, bool apply, bool applyStain, bool applyCrest) - => new() + static JObject Serialize(CustomItemId id, StainIds stains, bool crest, bool apply, bool applyStain, bool applyCrest) + => stains.AddToObject(new JObject { ["ItemId"] = id.Id, - ["Stain"] = stain.Id, ["Crest"] = crest, ["Apply"] = apply, ["ApplyStain"] = applyStain, ["ApplyCrest"] = applyCrest, - }; + }); } protected JObject SerializeCustomize() @@ -522,7 +521,7 @@ public class DesignBase return; } - static (CustomItemId, StainId, bool, bool, bool, bool) ParseItem(EquipSlot slot, JToken? item) + static (CustomItemId, StainIds, bool, bool, bool, bool) ParseItem(EquipSlot slot, JToken? item) { var id = item?["ItemId"]?.ToObject() ?? ItemManager.NothingId(slot).Id; var stain = (StainId)(item?["Stain"]?.ToObject() ?? 0); diff --git a/Glamourer/Designs/DesignBase64Migration.cs b/Glamourer/Designs/DesignBase64Migration.cs index a8b2f7b..d6d0886 100644 --- a/Glamourer/Designs/DesignBase64Migration.cs +++ b/Glamourer/Designs/DesignBase64Migration.cs @@ -1,5 +1,4 @@ using Glamourer.Services; -using Glamourer.State; using OtterGui; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; @@ -117,7 +116,7 @@ public class DesignBase64Migration } data.SetItem(slot, item); - data.SetStain(slot, mdl.Stain); + data.SetStain(slot, mdl.Stains); } var main = cur[0].Skeleton.Id == 0 @@ -130,7 +129,7 @@ public class DesignBase64Migration } data.SetItem(EquipSlot.MainHand, main); - data.SetStain(EquipSlot.MainHand, cur[0].Stain); + data.SetStain(EquipSlot.MainHand, cur[0].Stains); EquipItem off; // Fist weapon hack @@ -141,7 +140,7 @@ public class DesignBase64Migration if (gauntlet.Valid) { data.SetItem(EquipSlot.Hands, gauntlet); - data.SetStain(EquipSlot.Hands, cur[0].Stain); + data.SetStain(EquipSlot.Hands, cur[0].Stains); } } else @@ -158,7 +157,7 @@ public class DesignBase64Migration } data.SetItem(EquipSlot.OffHand, off); - data.SetStain(EquipSlot.OffHand, cur[1].Stain); + data.SetStain(EquipSlot.OffHand, cur[1].Stains); return data; } } diff --git a/Glamourer/Designs/DesignColors.cs b/Glamourer/Designs/DesignColors.cs index 8bc5539..5577c2c 100644 --- a/Glamourer/Designs/DesignColors.cs +++ b/Glamourer/Designs/DesignColors.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility.Raii; using Glamourer.Gui; using Glamourer.Services; diff --git a/Glamourer/Designs/DesignConverter.cs b/Glamourer/Designs/DesignConverter.cs index f3955c5..b1b5c61 100644 --- a/Glamourer/Designs/DesignConverter.cs +++ b/Glamourer/Designs/DesignConverter.cs @@ -176,7 +176,7 @@ public class DesignConverter( return System.Convert.ToBase64String(compressed); } - public IEnumerable<(EquipSlot Slot, EquipItem Item, StainId Stain)> FromDrawData(IReadOnlyList armors, + public IEnumerable<(EquipSlot Slot, EquipItem Item, StainIds Stains)> FromDrawData(IReadOnlyList armors, CharacterWeapon mainhand, CharacterWeapon offhand, bool skipWarnings) { if (armors.Count != 10) @@ -194,7 +194,7 @@ public class DesignConverter( item = ItemManager.NothingItem(slot); } - yield return (slot, item, armor.Stain); + yield return (slot, item, armor.Stains); } var mh = _items.Identify(EquipSlot.MainHand, mainhand.Skeleton, mainhand.Weapon, mainhand.Variant); @@ -204,7 +204,7 @@ public class DesignConverter( mh = _items.DefaultSword; } - yield return (EquipSlot.MainHand, mh, mainhand.Stain); + yield return (EquipSlot.MainHand, mh, mainhand.Stains); var oh = _items.Identify(EquipSlot.OffHand, offhand.Skeleton, offhand.Weapon, offhand.Variant, mh.Type); if (!skipWarnings && !oh.Valid) @@ -215,7 +215,7 @@ public class DesignConverter( oh = ItemManager.NothingItem(FullEquipType.Shield); } - yield return (EquipSlot.OffHand, oh, offhand.Stain); + yield return (EquipSlot.OffHand, oh, offhand.Stains); } private static void ComputeMaterials(DesignMaterialManager manager, in StateMaterialManager materials, diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index 6b84768..a762a84 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -9,6 +9,8 @@ namespace Glamourer.Designs; public unsafe struct DesignData { + public const int EquipmentByteSize = 10 * CharacterArmor.Size; + private string _nameHead = string.Empty; private string _nameBody = string.Empty; private string _nameHands = string.Empty; @@ -21,15 +23,14 @@ public unsafe struct DesignData private string _nameLFinger = string.Empty; private string _nameMainhand = string.Empty; private string _nameOffhand = string.Empty; + private string _nameFaceWear = string.Empty; private fixed uint _itemIds[12]; - private fixed ushort _iconIds[12]; - private fixed byte _equipmentBytes[48]; + private fixed uint _iconIds[12]; + private fixed byte _equipmentBytes[EquipmentByteSize + 16]; public CustomizeParameterData Parameters; public CustomizeArray Customize = CustomizeArray.Default; public uint ModelId; public CrestFlag CrestVisibility; - private SecondaryId _secondaryMainhand; - private SecondaryId _secondaryOffhand; private FullEquipType _typeMainhand; private FullEquipType _typeOffhand; private byte _states; @@ -50,12 +51,19 @@ public unsafe struct DesignData || name.IsContained(_nameRFinger) || name.IsContained(_nameLFinger) || name.IsContained(_nameMainhand) - || name.IsContained(_nameOffhand); + || name.IsContained(_nameOffhand) + || name.IsContained(_nameFaceWear); - public readonly StainId Stain(EquipSlot slot) + public readonly StainIds Stain(EquipSlot slot) { var index = slot.ToIndex(); - return index > 11 ? (StainId)0 : _equipmentBytes[4 * index + 3]; + return index switch + { + < 10 => new StainIds(_equipmentBytes[CharacterArmor.Size * index + 3], _equipmentBytes[CharacterArmor.Size * index + 4]), + 10 => new StainIds(_equipmentBytes[EquipmentByteSize + 6], _equipmentBytes[EquipmentByteSize + 7]), + 11 => new StainIds(_equipmentBytes[EquipmentByteSize + 14], _equipmentBytes[EquipmentByteSize + 15]), + _ => StainIds.None, + }; } public readonly bool Crest(CrestFlag slot) @@ -69,24 +77,29 @@ public unsafe struct DesignData => _typeOffhand; public readonly EquipItem Item(EquipSlot slot) - => slot.ToIndex() switch + { + fixed (byte* ptr = _equipmentBytes) { + return slot.ToIndex() switch + { // @formatter:off - 0 => EquipItem.FromIds((ItemId)_itemIds[ 0], (IconId)_iconIds[ 0], (PrimaryId)(_equipmentBytes[ 0] | (_equipmentBytes[ 1] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[ 2], FullEquipType.Head, name: _nameHead ), - 1 => EquipItem.FromIds((ItemId)_itemIds[ 1], (IconId)_iconIds[ 1], (PrimaryId)(_equipmentBytes[ 4] | (_equipmentBytes[ 5] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[ 6], FullEquipType.Body, name: _nameBody ), - 2 => EquipItem.FromIds((ItemId)_itemIds[ 2], (IconId)_iconIds[ 2], (PrimaryId)(_equipmentBytes[ 8] | (_equipmentBytes[ 9] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[10], FullEquipType.Hands, name: _nameHands ), - 3 => EquipItem.FromIds((ItemId)_itemIds[ 3], (IconId)_iconIds[ 3], (PrimaryId)(_equipmentBytes[12] | (_equipmentBytes[13] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[14], FullEquipType.Legs, name: _nameLegs ), - 4 => EquipItem.FromIds((ItemId)_itemIds[ 4], (IconId)_iconIds[ 4], (PrimaryId)(_equipmentBytes[16] | (_equipmentBytes[17] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[18], FullEquipType.Feet, name: _nameFeet ), - 5 => EquipItem.FromIds((ItemId)_itemIds[ 5], (IconId)_iconIds[ 5], (PrimaryId)(_equipmentBytes[20] | (_equipmentBytes[21] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[22], FullEquipType.Ears, name: _nameEars ), - 6 => EquipItem.FromIds((ItemId)_itemIds[ 6], (IconId)_iconIds[ 6], (PrimaryId)(_equipmentBytes[24] | (_equipmentBytes[25] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[26], FullEquipType.Neck, name: _nameNeck ), - 7 => EquipItem.FromIds((ItemId)_itemIds[ 7], (IconId)_iconIds[ 7], (PrimaryId)(_equipmentBytes[28] | (_equipmentBytes[29] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[30], FullEquipType.Wrists, name: _nameWrists ), - 8 => EquipItem.FromIds((ItemId)_itemIds[ 8], (IconId)_iconIds[ 8], (PrimaryId)(_equipmentBytes[32] | (_equipmentBytes[33] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[34], FullEquipType.Finger, name: _nameRFinger ), - 9 => EquipItem.FromIds((ItemId)_itemIds[ 9], (IconId)_iconIds[ 9], (PrimaryId)(_equipmentBytes[36] | (_equipmentBytes[37] << 8)), (SecondaryId)0, (Variant)_equipmentBytes[38], FullEquipType.Finger, name: _nameLFinger ), - 10 => EquipItem.FromIds((ItemId)_itemIds[10], (IconId)_iconIds[10], (PrimaryId)(_equipmentBytes[40] | (_equipmentBytes[41] << 8)), _secondaryMainhand, (Variant)_equipmentBytes[42], _typeMainhand, name: _nameMainhand), - 11 => EquipItem.FromIds((ItemId)_itemIds[11], (IconId)_iconIds[11], (PrimaryId)(_equipmentBytes[44] | (_equipmentBytes[45] << 8)), _secondaryOffhand, (Variant)_equipmentBytes[46], _typeOffhand, name: _nameOffhand ), + 0 => EquipItem.FromIds(_itemIds[ 0], _iconIds[ 0], ((CharacterArmor*)ptr)[0].Set, 0, ((CharacterArmor*)ptr)[0].Variant, FullEquipType.Head, name: _nameHead ), + 1 => EquipItem.FromIds(_itemIds[ 1], _iconIds[ 1], ((CharacterArmor*)ptr)[1].Set, 0, ((CharacterArmor*)ptr)[1].Variant, FullEquipType.Body, name: _nameBody ), + 2 => EquipItem.FromIds(_itemIds[ 2], _iconIds[ 2], ((CharacterArmor*)ptr)[2].Set, 0, ((CharacterArmor*)ptr)[2].Variant, FullEquipType.Hands, name: _nameHands ), + 3 => EquipItem.FromIds(_itemIds[ 3], _iconIds[ 3], ((CharacterArmor*)ptr)[3].Set, 0, ((CharacterArmor*)ptr)[3].Variant, FullEquipType.Legs, name: _nameLegs ), + 4 => EquipItem.FromIds(_itemIds[ 4], _iconIds[ 4], ((CharacterArmor*)ptr)[4].Set, 0, ((CharacterArmor*)ptr)[4].Variant, FullEquipType.Feet, name: _nameFeet ), + 5 => EquipItem.FromIds(_itemIds[ 5], _iconIds[ 5], ((CharacterArmor*)ptr)[5].Set, 0, ((CharacterArmor*)ptr)[5].Variant, FullEquipType.Ears, name: _nameEars ), + 6 => EquipItem.FromIds(_itemIds[ 6], _iconIds[ 6], ((CharacterArmor*)ptr)[6].Set, 0, ((CharacterArmor*)ptr)[6].Variant, FullEquipType.Neck, name: _nameNeck ), + 7 => EquipItem.FromIds(_itemIds[ 7], _iconIds[ 7], ((CharacterArmor*)ptr)[7].Set, 0, ((CharacterArmor*)ptr)[7].Variant, FullEquipType.Wrists, name: _nameWrists ), + 8 => EquipItem.FromIds(_itemIds[ 8], _iconIds[ 8], ((CharacterArmor*)ptr)[8].Set, 0, ((CharacterArmor*)ptr)[8].Variant, FullEquipType.Finger, name: _nameRFinger ), + 9 => EquipItem.FromIds(_itemIds[ 9], _iconIds[ 9], ((CharacterArmor*)ptr)[9].Set, 0, ((CharacterArmor*)ptr)[9].Variant, FullEquipType.Finger, name: _nameLFinger ), + 10 => EquipItem.FromIds(_itemIds[10], _iconIds[10], *(PrimaryId*)(ptr + EquipmentByteSize + 0), *(SecondaryId*)(ptr + EquipmentByteSize + 2), *(Variant*)(ptr + EquipmentByteSize + 4), _typeMainhand, name: _nameMainhand), + 11 => EquipItem.FromIds(_itemIds[11], _iconIds[11], *(PrimaryId*)(ptr + EquipmentByteSize + 4), *(SecondaryId*)(ptr + EquipmentByteSize + 2), *(Variant*)(ptr + EquipmentByteSize + 4), _typeOffhand, name: _nameOffhand ), _ => new EquipItem(), - // @formatter:on - }; + // @formatter:on + }; + } + } public readonly CharacterArmor Armor(EquipSlot slot) { @@ -113,8 +126,8 @@ public unsafe struct DesignData { fixed (byte* ptr = _equipmentBytes) { - var armorPtr = (CharacterArmor*)ptr; - return slot is EquipSlot.MainHand ? armorPtr[10].ToWeapon(_secondaryMainhand) : armorPtr[11].ToWeapon(_secondaryOffhand); + var weaponPtr = (CharacterWeapon*)(ptr + EquipmentByteSize); + return weaponPtr[slot is EquipSlot.MainHand ? 0 : 1]; } } @@ -124,11 +137,11 @@ public unsafe struct DesignData if (index > 11) return false; - _itemIds[index] = item.ItemId.Id; - _iconIds[index] = item.IconId.Id; - _equipmentBytes[4 * index + 0] = (byte)item.PrimaryId.Id; - _equipmentBytes[4 * index + 1] = (byte)(item.PrimaryId.Id >> 8); - _equipmentBytes[4 * index + 2] = item.Variant.Id; + _itemIds[index] = item.ItemId.Id; + _iconIds[index] = item.IconId.Id; + _equipmentBytes[CharacterArmor.Size * index + 0] = (byte)item.PrimaryId.Id; + _equipmentBytes[CharacterArmor.Size * index + 1] = (byte)(item.PrimaryId.Id >> 8); + _equipmentBytes[CharacterArmor.Size * index + 2] = item.Variant.Id; switch (index) { // @formatter:off @@ -144,36 +157,40 @@ public unsafe struct DesignData case 9: _nameLFinger = item.Name; return true; // @formatter:on case 10: - _nameMainhand = item.Name; - _secondaryMainhand = item.SecondaryId; - _typeMainhand = item.Type; + _nameMainhand = item.Name; + _equipmentBytes[EquipmentByteSize + 2] = (byte)item.SecondaryId.Id; + _equipmentBytes[EquipmentByteSize + 3] = (byte)(item.SecondaryId.Id >> 8); + _typeMainhand = item.Type; return true; case 11: - _nameOffhand = item.Name; - _secondaryOffhand = item.SecondaryId; - _typeOffhand = item.Type; + _nameOffhand = item.Name; + _equipmentBytes[EquipmentByteSize + 2] = (byte)item.SecondaryId.Id; + _equipmentBytes[EquipmentByteSize + 3] = (byte)(item.SecondaryId.Id >> 8); + _typeOffhand = item.Type; return true; } return true; } - public bool SetStain(EquipSlot slot, StainId stain) + public bool SetStain(EquipSlot slot, StainIds stains) => slot.ToIndex() switch { - 0 => SetIfDifferent(ref _equipmentBytes[3], stain.Id), - 1 => SetIfDifferent(ref _equipmentBytes[7], stain.Id), - 2 => SetIfDifferent(ref _equipmentBytes[11], stain.Id), - 3 => SetIfDifferent(ref _equipmentBytes[15], stain.Id), - 4 => SetIfDifferent(ref _equipmentBytes[19], stain.Id), - 5 => SetIfDifferent(ref _equipmentBytes[23], stain.Id), - 6 => SetIfDifferent(ref _equipmentBytes[27], stain.Id), - 7 => SetIfDifferent(ref _equipmentBytes[31], stain.Id), - 8 => SetIfDifferent(ref _equipmentBytes[35], stain.Id), - 9 => SetIfDifferent(ref _equipmentBytes[39], stain.Id), - 10 => SetIfDifferent(ref _equipmentBytes[43], stain.Id), - 11 => SetIfDifferent(ref _equipmentBytes[47], stain.Id), - _ => false, + // @formatter:off + 0 => SetIfDifferent(ref _equipmentBytes[0 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[0 * CharacterArmor.Size + 4], stains.Stain2.Id), + 1 => SetIfDifferent(ref _equipmentBytes[1 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[1 * CharacterArmor.Size + 4], stains.Stain2.Id), + 2 => SetIfDifferent(ref _equipmentBytes[2 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[2 * CharacterArmor.Size + 4], stains.Stain2.Id), + 3 => SetIfDifferent(ref _equipmentBytes[3 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[3 * CharacterArmor.Size + 4], stains.Stain2.Id), + 4 => SetIfDifferent(ref _equipmentBytes[4 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[4 * CharacterArmor.Size + 4], stains.Stain2.Id), + 5 => SetIfDifferent(ref _equipmentBytes[5 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[5 * CharacterArmor.Size + 4], stains.Stain2.Id), + 6 => SetIfDifferent(ref _equipmentBytes[6 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[6 * CharacterArmor.Size + 4], stains.Stain2.Id), + 7 => SetIfDifferent(ref _equipmentBytes[7 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[7 * CharacterArmor.Size + 4], stains.Stain2.Id), + 8 => SetIfDifferent(ref _equipmentBytes[8 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[8 * CharacterArmor.Size + 4], stains.Stain2.Id), + 9 => SetIfDifferent(ref _equipmentBytes[9 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[9 * CharacterArmor.Size + 4], stains.Stain2.Id), + 10 => SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 6], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 7], stains.Stain2.Id), + 11 => SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 14], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 15], stains.Stain2.Id), + _ => false, + // @formatter:on }; public bool SetCrest(CrestFlag slot, bool visible) @@ -260,15 +277,15 @@ public unsafe struct DesignData foreach (var slot in EquipSlotExtensions.EqdpSlots) { SetItem(slot, ItemManager.NothingItem(slot)); - SetStain(slot, 0); + SetStain(slot, StainIds.None); SetCrest(slot.ToCrestFlag(), false); } SetItem(EquipSlot.MainHand, items.DefaultSword); - SetStain(EquipSlot.MainHand, 0); + SetStain(EquipSlot.MainHand, StainIds.None); SetCrest(CrestFlag.MainHand, false); SetItem(EquipSlot.OffHand, ItemManager.NothingItem(FullEquipType.Shield)); - SetStain(EquipSlot.OffHand, 0); + SetStain(EquipSlot.OffHand, StainIds.None); SetCrest(CrestFlag.OffHand, false); } @@ -291,21 +308,22 @@ public unsafe struct DesignData MemoryUtility.MemSet(ptr, 0, 10 * 4); } - fixed (ushort* ptr = _iconIds) + fixed (uint* ptr = _iconIds) { MemoryUtility.MemSet(ptr, 0, 10 * 2); } - _nameHead = string.Empty; - _nameBody = string.Empty; - _nameHands = string.Empty; - _nameLegs = string.Empty; - _nameFeet = string.Empty; - _nameEars = string.Empty; - _nameNeck = string.Empty; - _nameWrists = string.Empty; - _nameRFinger = string.Empty; - _nameLFinger = string.Empty; + _nameHead = string.Empty; + _nameBody = string.Empty; + _nameHands = string.Empty; + _nameLegs = string.Empty; + _nameFeet = string.Empty; + _nameEars = string.Empty; + _nameNeck = string.Empty; + _nameWrists = string.Empty; + _nameRFinger = string.Empty; + _nameLFinger = string.Empty; + _nameFaceWear = string.Empty; return true; } @@ -322,7 +340,7 @@ public unsafe struct DesignData public readonly byte[] GetEquipmentBytes() { - var ret = new byte[40]; + var ret = new byte[80]; fixed (byte* retPtr = ret, inPtr = _equipmentBytes) { MemoryUtility.MemCpyUnchecked(retPtr, inPtr, ret.Length); @@ -343,8 +361,8 @@ public unsafe struct DesignData { fixed (byte* dataPtr = _equipmentBytes) { - var data = new Span(dataPtr, 40); - return Convert.TryFromBase64String(base64, data, out var written) && written == 40; + var data = new Span(dataPtr, 80); + return Convert.TryFromBase64String(base64, data, out var written) && written == 80; } } diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index 91050ec..32e38ac 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -3,7 +3,6 @@ using Glamourer.Events; using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Services; -using Glamourer.State; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -167,29 +166,29 @@ public class DesignEditor( } /// - public void ChangeStain(object data, EquipSlot slot, StainId stain, ApplySettings _ = default) + public void ChangeStains(object data, EquipSlot slot, StainIds stains, ApplySettings _ = default) { var design = (Design)data; - if (Items.ValidateStain(stain, out var _, false).Length > 0) + if (Items.ValidateStain(stains, out var _, false).Length > 0) return; var oldStain = design.DesignData.Stain(slot); - if (!design.GetDesignDataRef().SetStain(slot, stain)) + if (!design.GetDesignDataRef().SetStain(slot, stains)) return; design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); - Glamourer.Log.Debug($"Set stain of {slot} equipment piece to {stain.Id}."); - DesignChanged.Invoke(DesignChanged.Type.Stain, design, (oldStain, stain, slot)); + Glamourer.Log.Debug($"Set stain of {slot} equipment piece to {stains}."); + DesignChanged.Invoke(DesignChanged.Type.Stain, design, (oldStain, stains, slot)); } /// - public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainId? stain, ApplySettings _ = default) + public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainIds? stains, ApplySettings _ = default) { if (item.HasValue) ChangeItem(data, slot, item.Value, _); - if (stain.HasValue) - ChangeStain(data, slot, stain.Value, _); + if (stains.HasValue) + ChangeStains(data, slot, stains.Value, _); } /// diff --git a/Glamourer/Designs/DesignFileSystem.cs b/Glamourer/Designs/DesignFileSystem.cs index 00277c2..f154684 100644 --- a/Glamourer/Designs/DesignFileSystem.cs +++ b/Glamourer/Designs/DesignFileSystem.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Events; using Glamourer.Services; using Newtonsoft.Json; diff --git a/Glamourer/Designs/IDesignEditor.cs b/Glamourer/Designs/IDesignEditor.cs index a0aab84..cd51cf2 100644 --- a/Glamourer/Designs/IDesignEditor.cs +++ b/Glamourer/Designs/IDesignEditor.cs @@ -65,11 +65,11 @@ public interface IDesignEditor => ChangeEquip(data, slot, item, null, settings); /// Change the stain for any equipment piece. - public void ChangeStain(object data, EquipSlot slot, StainId stain, ApplySettings settings = default) - => ChangeEquip(data, slot, null, stain, settings); + public void ChangeStains(object data, EquipSlot slot, StainIds stains, ApplySettings settings = default) + => ChangeEquip(data, slot, null, stains, settings); /// Change an equipment piece and its stain at the same time. - public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainId? stain, ApplySettings settings = default); + public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainIds? stains, ApplySettings settings = default); /// Change the crest visibility for any equipment piece. public void ChangeCrest(object data, CrestFlag slot, bool crest, ApplySettings settings = default); diff --git a/Glamourer/Designs/Links/DesignLinkLoader.cs b/Glamourer/Designs/Links/DesignLinkLoader.cs index 4d438bd..fc7a26d 100644 --- a/Glamourer/Designs/Links/DesignLinkLoader.cs +++ b/Glamourer/Designs/Links/DesignLinkLoader.cs @@ -1,7 +1,8 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using OtterGui; using OtterGui.Classes; using OtterGui.Services; +using Notification = OtterGui.Classes.Notification; namespace Glamourer.Designs.Links; diff --git a/Glamourer/EphemeralConfig.cs b/Glamourer/EphemeralConfig.cs index 027685f..3e13dc4 100644 --- a/Glamourer/EphemeralConfig.cs +++ b/Glamourer/EphemeralConfig.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Gui; using Glamourer.Services; using Newtonsoft.Json; diff --git a/Glamourer/Events/MovedEquipment.cs b/Glamourer/Events/MovedEquipment.cs index 53491f1..9d24a03 100644 --- a/Glamourer/Events/MovedEquipment.cs +++ b/Glamourer/Events/MovedEquipment.cs @@ -11,7 +11,7 @@ namespace Glamourer.Events; /// /// public sealed class MovedEquipment() - : EventWrapper<(EquipSlot, uint, StainId)[], MovedEquipment.Priority>(nameof(MovedEquipment)) + : EventWrapper<(EquipSlot, uint, StainIds)[], MovedEquipment.Priority>(nameof(MovedEquipment)) { public enum Priority { diff --git a/Glamourer/GameData/CustomizeManager.cs b/Glamourer/GameData/CustomizeManager.cs index 57df104..5a06cf4 100644 --- a/Glamourer/GameData/CustomizeManager.cs +++ b/Glamourer/GameData/CustomizeManager.cs @@ -1,4 +1,5 @@ -using Dalamud.Interface.Internal; +using Dalamud.Interface.Textures; +using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Plugin.Services; using OtterGui.Classes; using OtterGui.Services; @@ -32,8 +33,8 @@ public class CustomizeManager : IAsyncDataContainer } /// Get specific icons. - public IDalamudTextureWrap GetIcon(uint id) - => _icons.LoadIcon(id)!; + public ISharedImmediateTexture GetIcon(uint id) + => _icons.TextureProvider.GetFromGameIcon(id); /// Iterate over all supported genders and clans. public static IEnumerable<(SubRace Clan, Gender Gender)> AllSets() @@ -47,8 +48,8 @@ public class CustomizeManager : IAsyncDataContainer public CustomizeManager(ITextureProvider textures, IDataManager gameData, IPluginLog log, NpcCustomizeSet npcCustomizeSet) { - _icons = new IconStorage(textures, gameData); - var stopwatch = new Stopwatch(); + _icons = new TextureCache(gameData, textures); + var stopwatch = new Stopwatch(); var tmpTask = Task.Run(() => { stopwatch.Start(); @@ -72,7 +73,7 @@ public class CustomizeManager : IAsyncDataContainer public bool Finished => Awaiter.IsCompletedSuccessfully; - private readonly IconStorage _icons; + private readonly TextureCache _icons; private static readonly int ListSize = Clans.Count * Genders.Count; private readonly CustomizeSet[] _customizationSets = new CustomizeSet[ListSize]; diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index ba892ec..850c7c9 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -1,4 +1,5 @@ using Dalamud; +using Dalamud.Game; using Dalamud.Plugin.Services; using Dalamud.Utility; using Lumina.Excel; @@ -13,11 +14,11 @@ namespace Glamourer.GameData; internal class CustomizeSetFactory( IDataManager _gameData, IPluginLog _log, - IconStorage _icons, + TextureCache _icons, NpcCustomizeSet _npcCustomizeSet, ColorParameters _colors) { - public CustomizeSetFactory(IDataManager gameData, IPluginLog log, IconStorage icons, NpcCustomizeSet npcCustomizeSet) + public CustomizeSetFactory(IDataManager gameData, IPluginLog log, TextureCache icons, NpcCustomizeSet npcCustomizeSet) : this(gameData, log, icons, npcCustomizeSet, new ColorParameters(gameData, log)) { } @@ -87,7 +88,8 @@ internal class CustomizeSetFactory( var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)>(); _npcCustomizeSet.Awaiter.Wait(); - foreach (var customize in _npcCustomizeSet.Select(s => s.Customize).Where(c => c.Clan == race && c.Gender == gender && c.BodyType.Value == 1)) + foreach (var customize in _npcCustomizeSet.Select(s => s.Customize) + .Where(c => c.Clan == race && c.Gender == gender && c.BodyType.Value == 1)) { foreach (var customizeIndex in customizeIndices) { @@ -346,10 +348,6 @@ internal class CustomizeSetFactory( /// Set the availability of options according to actual availability. private static void SetAvailability(CustomizeSet set, CharaMakeParams row) { - // TODO: Hrothgar female - if (set is { Race: Race.Hrothgar, Gender: Gender.Female }) - return; - Set(true, CustomizeIndex.Height); Set(set.Faces.Count > 0, CustomizeIndex.Face); Set(true, CustomizeIndex.Hairstyle); diff --git a/Glamourer/GameData/NpcCustomizeSet.cs b/Glamourer/GameData/NpcCustomizeSet.cs index d9d8f27..dbf74cc 100644 --- a/Glamourer/GameData/NpcCustomizeSet.cs +++ b/Glamourer/GameData/NpcCustomizeSet.cs @@ -80,25 +80,9 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList // Event NPCs have a reference to NpcEquip but also contain the appearance in their own row. // Prefer the NpcEquip reference if it is set, otherwise use the own. if (row.NpcEquip.Row != 0 && row.NpcEquip.Value is { } equip) - { ApplyNpcEquip(ref ret, equip); - } else - { - ret.Set(0, row.ModelHead | (row.DyeHead.Row << 24)); - ret.Set(1, row.ModelBody | (row.DyeBody.Row << 24)); - ret.Set(2, row.ModelHands | (row.DyeHands.Row << 24)); - ret.Set(3, row.ModelLegs | (row.DyeLegs.Row << 24)); - ret.Set(4, row.ModelFeet | (row.DyeFeet.Row << 24)); - ret.Set(5, row.ModelEars | (row.DyeEars.Row << 24)); - ret.Set(6, row.ModelNeck | (row.DyeNeck.Row << 24)); - ret.Set(7, row.ModelWrists | (row.DyeWrists.Row << 24)); - ret.Set(8, row.ModelRightRing | (row.DyeRightRing.Row << 24)); - ret.Set(9, row.ModelLeftRing | (row.DyeLeftRing.Row << 24)); - ret.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.Row << 48)); - ret.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.Row << 48)); - ret.VisorToggled = row.Visor; - } + ApplyNpcEquip(ref ret, row); list.Add(ret); } @@ -202,18 +186,36 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// Apply equipment from a NpcEquip row. private static void ApplyNpcEquip(ref NpcData data, NpcEquip row) { - data.Set(0, row.ModelHead | (row.DyeHead.Row << 24)); - data.Set(1, row.ModelBody | (row.DyeBody.Row << 24)); - data.Set(2, row.ModelHands | (row.DyeHands.Row << 24)); - data.Set(3, row.ModelLegs | (row.DyeLegs.Row << 24)); - data.Set(4, row.ModelFeet | (row.DyeFeet.Row << 24)); - data.Set(5, row.ModelEars | (row.DyeEars.Row << 24)); - data.Set(6, row.ModelNeck | (row.DyeNeck.Row << 24)); - data.Set(7, row.ModelWrists | (row.DyeWrists.Row << 24)); - data.Set(8, row.ModelRightRing | (row.DyeRightRing.Row << 24)); - data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.Row << 24)); - data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.Row << 48)); - data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.Row << 48)); + data.Set(0, row.ModelHead | (row.DyeHead.Row << 24) | ((ulong)row.Dye2Head.Row << 32)); + data.Set(1, row.ModelBody | (row.DyeBody.Row << 24) | ((ulong)row.Dye2Body.Row << 32)); + data.Set(2, row.ModelHands | (row.DyeHands.Row << 24) | ((ulong)row.Dye2Hands.Row << 32)); + data.Set(3, row.ModelLegs | (row.DyeLegs.Row << 24) | ((ulong)row.Dye2Legs.Row << 32)); + data.Set(4, row.ModelFeet | (row.DyeFeet.Row << 24) | ((ulong)row.Dye2Feet.Row << 32)); + data.Set(5, row.ModelEars | (row.DyeEars.Row << 24) | ((ulong)row.Dye2Ears.Row << 32)); + data.Set(6, row.ModelNeck | (row.DyeNeck.Row << 24) | ((ulong)row.Dye2Neck.Row << 32)); + data.Set(7, row.ModelWrists | (row.DyeWrists.Row << 24) | ((ulong)row.Dye2Wrists.Row << 32)); + data.Set(8, row.ModelRightRing | (row.DyeRightRing.Row << 24) | ((ulong)row.Dye2RightRing.Row << 32)); + data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.Row << 24) | ((ulong)row.Dye2LeftRing.Row << 32)); + data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.Row << 48) | ((ulong)row.Dye2MainHand.Row << 56)); + data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.Row << 48) | ((ulong)row.Dye2OffHand.Row << 56)); + data.VisorToggled = row.Visor; + } + + /// Apply equipment from a ENpcBase Row row. + private static void ApplyNpcEquip(ref NpcData data, ENpcBase row) + { + data.Set(0, row.ModelHead | (row.DyeHead.Row << 24) | ((ulong)row.Dye2Head.Row << 32)); + data.Set(1, row.ModelBody | (row.DyeBody.Row << 24) | ((ulong)row.Dye2Body.Row << 32)); + data.Set(2, row.ModelHands | (row.DyeHands.Row << 24) | ((ulong)row.Dye2Hands.Row << 32)); + data.Set(3, row.ModelLegs | (row.DyeLegs.Row << 24) | ((ulong)row.Dye2Legs.Row << 32)); + data.Set(4, row.ModelFeet | (row.DyeFeet.Row << 24) | ((ulong)row.Dye2Feet.Row << 32)); + data.Set(5, row.ModelEars | (row.DyeEars.Row << 24) | ((ulong)row.Dye2Ears.Row << 32)); + data.Set(6, row.ModelNeck | (row.DyeNeck.Row << 24) | ((ulong)row.Dye2Neck.Row << 32)); + data.Set(7, row.ModelWrists | (row.DyeWrists.Row << 24) | ((ulong)row.Dye2Wrists.Row << 32)); + data.Set(8, row.ModelRightRing | (row.DyeRightRing.Row << 24) | ((ulong)row.Dye2RightRing.Row << 32)); + data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.Row << 24) | ((ulong)row.Dye2LeftRing.Row << 32)); + data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.Row << 48) | ((ulong)row.Dye2MainHand.Row << 56)); + data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.Row << 48) | ((ulong)row.Dye2OffHand.Row << 56)); data.VisorToggled = row.Visor; } diff --git a/Glamourer/GameData/NpcData.cs b/Glamourer/GameData/NpcData.cs index 6b5f2bd..0076bb6 100644 --- a/Glamourer/GameData/NpcData.cs +++ b/Glamourer/GameData/NpcData.cs @@ -13,7 +13,7 @@ public unsafe struct NpcData public CustomizeArray Customize; /// The equipment appearance of the NPC, 10 * CharacterArmor. - private fixed byte _equip[40]; + private fixed byte _equip[CharacterArmor.Size * 10]; /// The mainhand weapon appearance of the NPC. public CharacterWeapon Mainhand; @@ -54,36 +54,35 @@ public unsafe struct NpcData { sb.Append(span[i].Set.Id.ToString("D4")) .Append('-') - .Append(span[i].Variant.Id.ToString("D3")) - .Append('-') - .Append(span[i].Stain.Id.ToString("D3")) - .Append(", "); + .Append(span[i].Variant.Id.ToString("D3")); + foreach (var stain in span[i].Stains) + sb.Append('-').Append(stain.Id.ToString("D3")); } sb.Append(Mainhand.Skeleton.Id.ToString("D4")) .Append('-') .Append(Mainhand.Weapon.Id.ToString("D4")) .Append('-') - .Append(Mainhand.Variant.Id.ToString("D3")) - .Append('-') - .Append(Mainhand.Stain.Id.ToString("D4")) - .Append(", ") + .Append(Mainhand.Variant.Id.ToString("D3")); + foreach (var stain in Mainhand.Stains) + sb.Append('-').Append(stain.Id.ToString("D3")); + sb.Append(", ") .Append(Offhand.Skeleton.Id.ToString("D4")) .Append('-') .Append(Offhand.Weapon.Id.ToString("D4")) .Append('-') - .Append(Offhand.Variant.Id.ToString("D3")) - .Append('-') - .Append(Offhand.Stain.Id.ToString("D3")); + .Append(Offhand.Variant.Id.ToString("D3")); + foreach (var stain in Mainhand.Stains) + sb.Append('-').Append(stain.Id.ToString("D3")); return sb.ToString(); } /// Set an equipment piece to a given value. - internal void Set(int idx, uint value) + internal void Set(int idx, ulong value) { fixed (byte* ptr = _equip) { - ((uint*)ptr)[idx] = value; + ((ulong*)ptr)[idx] = value; } } diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 5dd6040..84312d9 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -28,7 +28,7 @@ public class Glamourer : IDalamudPlugin private readonly ServiceManager _services; - public Glamourer(DalamudPluginInterface pluginInterface) + public Glamourer(IDalamudPluginInterface pluginInterface) { try { @@ -128,7 +128,7 @@ public class Glamourer : IDalamudPlugin [ "Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge", ]; - var plugins = _services.GetService().InstalledPlugins + var plugins = _services.GetService().InstalledPlugins .GroupBy(p => p.InternalName) .ToDictionary(g => g.Key, g => { diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 9a1b95b..3251543 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -49,6 +49,7 @@ $(AppData)\XIVLauncher\addon\Hooks\dev\ + H:\Projects\FFPlugins\Dalamud\bin\Release\ diff --git a/Glamourer/Glamourer.json b/Glamourer/Glamourer.json index cdf2cba..08c18f5 100644 --- a/Glamourer/Glamourer.json +++ b/Glamourer/Glamourer.json @@ -8,7 +8,7 @@ "AssemblyVersion": "9.0.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 9, + "DalamudApiLevel": 10, "ImageUrls": null, "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/master/images/icon.png" } \ No newline at end of file diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs index ae64075..2f67012 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs @@ -34,14 +34,13 @@ public partial class CustomizationDrawer private void DrawGenderSelector() { - using (var disabled = ImRaii.Disabled(_locked || _lockedRedraw)) + using (ImRaii.Disabled(_locked || _lockedRedraw)) { var icon = _customize.Gender switch { - Gender.Male when _customize.Race is Race.Hrothgar => FontAwesomeIcon.MarsDouble, - Gender.Male => FontAwesomeIcon.Mars, - Gender.Female => FontAwesomeIcon.Venus, - _ => FontAwesomeIcon.Question, + Gender.Male => FontAwesomeIcon.Mars, + Gender.Female => FontAwesomeIcon.Venus, + _ => FontAwesomeIcon.Question, }; if (ImGuiUtil.DrawDisabledButton(icon.ToIconString(), _framedIconSize, string.Empty, @@ -56,7 +55,7 @@ public partial class CustomizationDrawer private void DrawRaceCombo() { - using (var disabled = ImRaii.Disabled(_locked || _lockedRedraw)) + using (ImRaii.Disabled(_locked || _lockedRedraw)) { ImGui.SetNextItemWidth(_raceSelectorWidth); using (var combo = ImRaii.Combo("##subRaceCombo", _service.ClanName(_customize.Clan, _customize.Gender))) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index c0c45d2..8631481 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -29,10 +29,11 @@ public partial class CustomizationDrawer npc = true; } - var icon = _service.Manager.GetIcon(custom!.Value.IconId); + var icon = _service.Manager.GetIcon(custom!.Value.IconId); + var hasIcon = icon.TryGetWrap(out var wrap, out _); using (_ = ImRaii.Disabled(_locked || _currentIndex is CustomizeIndex.Face && _lockedRedraw)) { - if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize)) + if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize)) { ImGui.OpenPopup(IconSelectorPopup); } @@ -43,7 +44,8 @@ public partial class CustomizationDrawer } } - ImGuiUtil.HoverIconTooltip(icon, _iconSize); + if (hasIcon) + ImGuiUtil.HoverIconTooltip(wrap!, _iconSize); ImGui.SameLine(); using (_ = ImRaii.Group()) @@ -83,8 +85,9 @@ public partial class CustomizationDrawer using var frameColor = current == i ? ImRaii.PushColor(ImGuiCol.Button, Colors.SelectedRed) : ImRaii.PushColor(ImGuiCol.Button, ColorId.FavoriteStarOn.Value(), isFavorite); + var hasIcon = icon.TryGetWrap(out var wrap, out var _); - if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize)) + if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize)) { UpdateValue(custom.Value); ImGui.CloseCurrentPopup(); @@ -96,8 +99,9 @@ public partial class CustomizationDrawer else _favorites.TryAdd(_set.Gender, _set.Clan, _currentIndex, custom.Value); - ImGuiUtil.HoverIconTooltip(icon, _iconSize, - FavoriteManager.TypeAllowed(_currentIndex) ? "Right-Click to toggle favorite." : string.Empty); + if (hasIcon) + ImGuiUtil.HoverIconTooltip(wrap!, _iconSize, + FavoriteManager.TypeAllowed(_currentIndex) ? "Right-Click to toggle favorite." : string.Empty); var text = custom.Value.ToString(); var textWidth = ImGui.CalcTextSize(text).X; @@ -199,14 +203,17 @@ public partial class CustomizationDrawer var icon = featureIdx == CustomizeIndex.LegacyTattoo ? _legacyTattoo ?? _service.Manager.GetIcon(feature.IconId) : _service.Manager.GetIcon(feature.IconId); - if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize, Vector2.Zero, Vector2.One, (int)ImGui.GetStyle().FramePadding.X, + var hasIcon = icon.TryGetWrap(out var wrap, out _); + if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize, Vector2.Zero, Vector2.One, + (int)ImGui.GetStyle().FramePadding.X, Vector4.Zero, enabled ? Vector4.One : _redTint)) { _customize.Set(featureIdx, enabled ? CustomizeValue.Zero : CustomizeValue.Max); Changed |= _currentFlag; } - ImGuiUtil.HoverIconTooltip(icon, _iconSize); + if (hasIcon) + ImGuiUtil.HoverIconTooltip(wrap!, _iconSize); if (idx % 4 != 3) ImGui.SameLine(); } diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 60251df..384307c 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -1,4 +1,6 @@ using Dalamud.Interface.Internal; +using Dalamud.Interface.Textures; +using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Interface.Utility; using Dalamud.Plugin; using Glamourer.GameData; @@ -6,6 +8,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; +using OtterGui.Classes; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -13,16 +16,15 @@ using Penumbra.GameData.Structs; namespace Glamourer.Gui.Customization; public partial class CustomizationDrawer( - DalamudPluginInterface pi, + TextureCache textureCache, CustomizeService _service, CodeService _codes, Configuration _config, FavoriteManager _favorites, HeightService _heightService) - : IDisposable { - private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f); - private readonly IDalamudTextureWrap? _legacyTattoo = GetLegacyTattooIcon(pi); + private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f); + private readonly ISharedImmediateTexture? _legacyTattoo = GetLegacyTattooIcon(textureCache); private Exception? _terminate; @@ -47,9 +49,6 @@ public partial class CustomizationDrawer( private float _raceSelectorWidth; private bool _withApply; - public void Dispose() - => _legacyTattoo?.Dispose(); - public bool Draw(CustomizeArray current, bool locked, bool lockedRedraw) { _withApply = false; @@ -190,16 +189,6 @@ public partial class CustomizationDrawer( _raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X; } - private static IDalamudTextureWrap? GetLegacyTattooIcon(DalamudPluginInterface pi) - { - using var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Glamourer.LegacyTattoo.raw"); - if (resource == null) - return null; - - var rawImage = new byte[resource.Length]; - var length = resource.Read(rawImage, 0, (int)resource.Length); - return length == resource.Length - ? pi.UiBuilder.LoadImageRaw(rawImage, 192, 192, 4) - : null; - } + private static ISharedImmediateTexture? GetLegacyTattooIcon(TextureCache icons) + => icons.TextureProvider.GetFromManifestResource(Assembly.GetExecutingAssembly(), "Glamourer.LegacyTattoo.raw"); } diff --git a/Glamourer/Gui/Equipment/EquipDrawData.cs b/Glamourer/Gui/Equipment/EquipDrawData.cs index e6b5d0d..58f7efc 100644 --- a/Glamourer/Gui/Equipment/EquipDrawData.cs +++ b/Glamourer/Gui/Equipment/EquipDrawData.cs @@ -23,8 +23,8 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) public readonly void SetItem(EquipItem item) => _editor.ChangeItem(_object, Slot, item, ApplySettings.Manual); - public readonly void SetStain(StainId stain) - => _editor.ChangeStain(_object, Slot, stain, ApplySettings.Manual); + public readonly void SetStains(StainIds stains) + => _editor.ChangeStains(_object, Slot, stains, ApplySettings.Manual); public readonly void SetApplyItem(bool value) { @@ -40,10 +40,10 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) manager.ChangeApplyStain(design, Slot, value); } - public EquipItem CurrentItem = designData.Item(slot); - public StainId CurrentStain = designData.Stain(slot); - public EquipItem GameItem = default; - public StainId GameStain = default; + public EquipItem CurrentItem = designData.Item(slot); + public StainIds CurrentStains = designData.Stain(slot); + public EquipItem GameItem = default; + public StainIds GameStains = default; public bool CurrentApply; public bool CurrentApplyStain; @@ -69,7 +69,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) Locked = state.IsLocked, DisplayApplication = false, GameItem = state.BaseData.Item(slot), - GameStain = state.BaseData.Stain(slot), + GameStains = state.BaseData.Stain(slot), AllowRevert = true, }; } diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index c5e5f7e..53e8ed8 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -8,6 +8,7 @@ using Glamourer.Unlocks; using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; @@ -236,14 +237,18 @@ public class EquipmentDrawer /// Draw an input for stain that can set arbitrary values instead of choosing valid stains. private static void DrawStainArtisan(EquipDrawData data) { - int stainId = data.CurrentStain.Id; - ImGui.SetNextItemWidth(40 * ImGuiHelpers.GlobalScale); - if (!ImGui.InputInt("##stain", ref stainId, 0, 0)) - return; + foreach (var (stain, index) in data.CurrentStains.WithIndex()) + { + using var id = ImUtf8.PushId(index); + int stainId = stain.Id; + ImGui.SetNextItemWidth(40 * ImGuiHelpers.GlobalScale); + if (!ImGui.InputInt("##stain", ref stainId, 0, 0)) + return; - var newStainId = (StainId)Math.Clamp(stainId, 0, byte.MaxValue); - if (newStainId != data.CurrentStain.Id) - data.SetStain(newStainId); + var newStainId = (StainId)Math.Clamp(stainId, 0, byte.MaxValue); + if (newStainId != stain.Id) + data.SetStains(data.CurrentStains.With(index, newStainId)); + } } /// Draw an input for armor that can set arbitrary values instead of choosing items. @@ -441,19 +446,27 @@ public class EquipmentDrawer private void DrawStain(in EquipDrawData data, bool small) { - var found = _stainData.TryGetValue(data.CurrentStain, out var stain); using var disabled = ImRaii.Disabled(data.Locked); - var change = small - ? _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss) - : _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss, _comboLength); - if (change) - if (_stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out stain)) - data.SetStain(stain.RowIndex); - else if (_stainCombo.CurrentSelection.Key == Stain.None.RowIndex) - data.SetStain(Stain.None.RowIndex); + var width = (_comboLength - ImUtf8.ItemInnerSpacing.X * (data.CurrentStains.Count - 1)) / data.CurrentStains.Count; + foreach (var (stainId, index) in data.CurrentStains.WithIndex()) + { + using var id = ImUtf8.PushId(index); + var found = _stainData.TryGetValue(stainId, out var stain); + var change = small + ? _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss) + : _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss, width); + if (index < data.CurrentStains.Count - 1) + ImUtf8.SameLineInner(); - if (ResetOrClear(data.Locked, false, data.AllowRevert, true, data.CurrentStain, data.GameStain, Stain.None.RowIndex, out var newStain)) - data.SetStain(newStain); + if (change) + if (_stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out stain)) + data.SetStains(data.CurrentStains.With(index, stain.RowIndex)); + else if (_stainCombo.CurrentSelection.Key == Stain.None.RowIndex) + data.SetStains(data.CurrentStains.With(index, Stain.None.RowIndex)); + if (ResetOrClear(data.Locked, false, data.AllowRevert, true, stainId, data.GameStains[index], Stain.None.RowIndex, + out var newStain)) + data.SetStains(data.CurrentStains.With(index, newStain)); + } } private void DrawItem(in EquipDrawData data, out string label, bool small, bool clear, bool open) diff --git a/Glamourer/Gui/GlamourerWindowSystem.cs b/Glamourer/Gui/GlamourerWindowSystem.cs index 6b34c78..f86f42b 100644 --- a/Glamourer/Gui/GlamourerWindowSystem.cs +++ b/Glamourer/Gui/GlamourerWindowSystem.cs @@ -7,11 +7,11 @@ namespace Glamourer.Gui; public class GlamourerWindowSystem : IDisposable { private readonly WindowSystem _windowSystem = new("Glamourer"); - private readonly UiBuilder _uiBuilder; + private readonly IUiBuilder _uiBuilder; private readonly MainWindow _ui; private readonly PenumbraChangedItemTooltip _penumbraTooltip; - public GlamourerWindowSystem(UiBuilder uiBuilder, MainWindow ui, GenericPopupWindow popups, PenumbraChangedItemTooltip penumbraTooltip, + public GlamourerWindowSystem(IUiBuilder uiBuilder, MainWindow ui, GenericPopupWindow popups, PenumbraChangedItemTooltip penumbraTooltip, Configuration config, UnlocksTab unlocksTab, GlamourerChangelog changelog, DesignQuickBar quick) { _uiBuilder = uiBuilder; diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs index 007d936..f21a2b7 100644 --- a/Glamourer/Gui/MainWindow.cs +++ b/Glamourer/Gui/MainWindow.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Windowing; using Dalamud.Plugin; using Glamourer.Designs; @@ -64,7 +64,7 @@ public class MainWindow : Window, IDisposable public TabType SelectTab; - public MainWindow(DalamudPluginInterface pi, Configuration config, SettingsTab settings, ActorTab actors, DesignTab designs, + public MainWindow(IDalamudPluginInterface pi, Configuration config, SettingsTab settings, ActorTab actors, DesignTab designs, DebugTab debugTab, AutomationTab automation, UnlocksTab unlocks, TabSelected @event, MessagesTab messages, DesignQuickBar quickBar, NpcTab npcs, MainWindowPosition position, PenumbraService penumbra) : base("GlamourerMainWindow") diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 8371232..5218581 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -1,6 +1,6 @@ using Dalamud.Game.ClientState.Conditions; using Dalamud.Interface; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; using Glamourer.Automation; @@ -208,7 +208,7 @@ public class ActorPanel var data = EquipDrawData.FromState(_stateManager, _state!, slot); _equipmentDrawer.DrawEquip(data); if (usedAllStain) - _stateManager.ChangeStain(_state, slot, newAllStain, ApplySettings.Manual); + _stateManager.ChangeStains(_state, slot, newAllStain, ApplySettings.Manual); } var mainhand = EquipDrawData.FromState(_stateManager, _state, EquipSlot.MainHand); diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index 4aa0163..0a29314 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -87,8 +87,8 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM foreach (var slot in EquipSlotExtensions.EqdpSlots.Prepend(EquipSlot.OffHand).Prepend(EquipSlot.MainHand)) { PrintRow(slot.ToName(), ItemString(state.BaseData, slot), ItemString(state.ModelData, slot), state.Sources[slot, false]); - ImGuiUtil.DrawTableColumn(state.BaseData.Stain(slot).Id.ToString()); - ImGuiUtil.DrawTableColumn(state.ModelData.Stain(slot).Id.ToString()); + ImGuiUtil.DrawTableColumn(state.BaseData.Stain(slot).ToString()); + ImGuiUtil.DrawTableColumn(state.ModelData.Stain(slot).ToString()); ImGuiUtil.DrawTableColumn(state.Sources[slot, true].ToString()); } diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index 2129c1f..ff9c2b8 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -8,8 +8,10 @@ using Glamourer.Services; using Glamourer.State; using ImGuiNET; using OtterGui; +using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.DebugTab; @@ -51,7 +53,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer using (ImRaii.Group()) { ImGuiUtil.CopyOnClickSelectable($"0x{(ulong)manager:X}"); - ImGui.TextUnformatted(manager == null ? "-" : manager->GlamourPlatesSpan.Length.ToString()); + ImGui.TextUnformatted(manager == null ? "-" : manager->GlamourPlates.Length.ToString()); ImGui.TextUnformatted(manager == null ? "-" : manager->GlamourPlatesRequested.ToString()); ImGui.SameLine(); if (ImGui.SmallButton("Request Update")) @@ -67,13 +69,13 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer var (identifier, data) = _objects.PlayerData; var enabled = data.Valid && _state.GetOrCreate(identifier, data.Objects[0], out state); - for (var i = 0; i < manager->GlamourPlatesSpan.Length; ++i) + for (var i = 0; i < manager->GlamourPlates.Length; ++i) { using var tree = ImRaii.TreeNode($"Plate #{i + 1:D2}"); if (!tree) continue; - ref var plate = ref manager->GlamourPlatesSpan[i]; + ref var plate = ref manager->GlamourPlates[i]; if (ImGuiUtil.DrawDisabledButton("Apply to Player", Vector2.Zero, string.Empty, !enabled)) { var design = CreateDesign(plate); @@ -90,12 +92,12 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer using (ImRaii.Group()) { foreach (var (_, index) in EquipSlotExtensions.FullSlots.WithIndex()) - ImGui.TextUnformatted($"{plate.ItemIds[index]:D6}, {plate.StainIds[index]:D3}"); + ImGui.TextUnformatted($"{plate.ItemIds[index]:D6}, {StainIds.FromGlamourPlate(plate, index)}"); } } } - [Signature("E8 ?? ?? ?? ?? 32 C0 48 8B 5C 24 ?? 48 8B 6C 24 ?? 48 83 C4 ?? 5F")] + [Signature(Sigs.RequestGlamourPlates)] private readonly delegate* unmanaged _requestUpdate = null!; public void RequestGlamour() @@ -126,7 +128,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer continue; design.GetDesignDataRef().SetItem(slot, item); - design.GetDesignDataRef().SetStain(slot, plate.StainIds[index]); + design.GetDesignDataRef().SetStain(slot, StainIds.FromGlamourPlate(plate, index)); design.ApplyEquip |= slot.ToBothFlags(); } diff --git a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs index bd447e7..b021656 100644 --- a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs @@ -43,8 +43,8 @@ public unsafe class InventoryPanel : IGameDataDrawer } else { - ImGuiUtil.DrawTableColumn(item->ItemID.ToString()); - ImGuiUtil.DrawTableColumn(item->GlamourID.ToString()); + ImGuiUtil.DrawTableColumn(item->ItemId.ToString()); + ImGuiUtil.DrawTableColumn(item->GlamourId.ToString()); ImGui.TableNextColumn(); ImGuiUtil.CopyOnClickSelectable($"0x{(ulong)item:X}"); } diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs index 1a74778..918c7ad 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs @@ -10,7 +10,7 @@ using OtterGui.Services; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; -public class DesignIpcTester(DalamudPluginInterface pluginInterface) : IUiService +public class DesignIpcTester(IDalamudPluginInterface pluginInterface) : IUiService { private Dictionary _designs = []; private int _gameObjectIndex; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs index 5e6f4a2..8f561af 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs @@ -7,7 +7,7 @@ using Penumbra.GameData.Gui.Debug; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; public class IpcTesterPanel( - DalamudPluginInterface pluginInterface, + IDalamudPluginInterface pluginInterface, DesignIpcTester designs, ItemsIpcTester items, StateIpcTester state, diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs index 3d61df7..5f9e748 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs @@ -11,7 +11,7 @@ using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; -public class ItemsIpcTester(DalamudPluginInterface pluginInterface) : IUiService +public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiService { private int _gameObjectIndex; private string _gameObjectName = string.Empty; @@ -40,12 +40,12 @@ public class ItemsIpcTester(DalamudPluginInterface pluginInterface) : IUiService IpcTesterHelpers.DrawIntro(SetItem.Label); if (ImGui.Button("Set##Idx")) - _lastError = new SetItem(pluginInterface).Invoke(_gameObjectIndex, (ApiEquipSlot)_slot, _customItemId.Id, _stainId.Id, _key, + _lastError = new SetItem(pluginInterface).Invoke(_gameObjectIndex, (ApiEquipSlot)_slot, _customItemId.Id, [_stainId.Id], _key, _flags); IpcTesterHelpers.DrawIntro(SetItemName.Label); if (ImGui.Button("Set##Name")) - _lastError = new SetItemName(pluginInterface).Invoke(_gameObjectName, (ApiEquipSlot)_slot, _customItemId.Id, _stainId.Id, _key, + _lastError = new SetItemName(pluginInterface).Invoke(_gameObjectName, (ApiEquipSlot)_slot, _customItemId.Id, [_stainId.Id], _key, _flags); } diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index 81c8cab..f378625 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -18,7 +18,7 @@ namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; public class StateIpcTester : IUiService, IDisposable { - private readonly DalamudPluginInterface _pluginInterface; + private readonly IDalamudPluginInterface _pluginInterface; private int _gameObjectIndex; private string _gameObjectName = string.Empty; @@ -41,7 +41,7 @@ public class StateIpcTester : IUiService, IDisposable private int _numUnlocked; - public StateIpcTester(DalamudPluginInterface pluginInterface) + public StateIpcTester(IDalamudPluginInterface pluginInterface) { _pluginInterface = pluginInterface; StateChanged = Api.IpcSubscribers.StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged); diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index c557064..ddf42f1 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -5,6 +5,8 @@ using Glamourer.Interop.Structs; using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; +using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; using Penumbra.GameData.Interop; @@ -18,7 +20,8 @@ public unsafe class ModelEvaluationPanel( VisorService _visorService, UpdateSlotService _updateSlotService, ChangeCustomizeService _changeCustomizeService, - CrestService _crestService) : IGameDataDrawer + CrestService _crestService, + DictGlasses _glasses) : IGameDataDrawer { public string Label => "Model Evaluation"; @@ -177,7 +180,7 @@ public unsafe class ModelEvaluationPanel( { using var id = ImRaii.PushId("Wetness"); ImGuiUtil.DrawTableColumn("Wetness"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.AsCharacter->IsGPoseWet ? "GPose" : "None" : "No Character"); + ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.IsGPoseWet ? "GPose" : "None" : "No Character"); var modelString = model.IsCharacterBase ? $"{model.AsCharacterBase->SwimmingWetness:F4} Swimming\n" + $"{model.AsCharacterBase->WeatherWetness:F4} Weather\n" @@ -190,13 +193,13 @@ public unsafe class ModelEvaluationPanel( return; if (ImGui.SmallButton("GPose On")) - actor.AsCharacter->IsGPoseWet = true; + actor.IsGPoseWet = true; ImGui.SameLine(); if (ImGui.SmallButton("GPose Off")) - actor.AsCharacter->IsGPoseWet = false; + actor.IsGPoseWet = false; ImGui.SameLine(); if (ImGui.SmallButton("GPose Toggle")) - actor.AsCharacter->IsGPoseWet = !actor.AsCharacter->IsGPoseWet; + actor.IsGPoseWet = !actor.IsGPoseWet; } private void DrawEquip(Actor actor, Model model) @@ -214,14 +217,39 @@ public unsafe class ModelEvaluationPanel( if (ImGui.SmallButton("Change Piece")) _updateSlotService.UpdateArmor(model, slot, - new CharacterArmor((PrimaryId)(slot == EquipSlot.Hands ? 6064 : slot == EquipSlot.Head ? 6072 : 1), 1, 0)); + new CharacterArmor((PrimaryId)(slot == EquipSlot.Hands ? 6064 : slot == EquipSlot.Head ? 6072 : 1), 1, StainIds.None)); ImGui.SameLine(); if (ImGui.SmallButton("Change Stain")) - _updateSlotService.UpdateStain(model, slot, 5); + _updateSlotService.UpdateStain(model, slot, new StainIds(5, 7)); ImGui.SameLine(); if (ImGui.SmallButton("Reset")) _updateSlotService.UpdateSlot(model, slot, actor.GetArmor(slot)); } + + using (ImRaii.PushId((int)EquipSlot.FaceWear)) + { + ImGuiUtil.DrawTableColumn(EquipSlot.FaceWear.ToName()); + if (!actor.IsCharacter) + { + ImGuiUtil.DrawTableColumn("No Character"); + } + else + { + var glassesId = actor.AsCharacter->DrawData.GlassesIds[(int)EquipSlot.FaceWear.ToBonusIndex()]; + if (_glasses.TryGetValue(glassesId, out var glasses)) + ImGuiUtil.DrawTableColumn($"{glasses.Id.Id},{glasses.Variant.Id} ({glassesId})"); + else + ImGuiUtil.DrawTableColumn($"{glassesId}"); + } + + ImGuiUtil.DrawTableColumn(model.IsHuman ? model.GetArmor(EquipSlot.FaceWear).ToString() : "No Human"); + ImGui.TableNextColumn(); + if (ImUtf8.SmallButton("Change Piece"u8)) + { + var data = model.GetArmor(EquipSlot.FaceWear); + _updateSlotService.UpdateSlot(model, EquipSlot.FaceWear, data with { Variant = (Variant)((data.Variant.Id + 1) % 12) }); + } + } } private void DrawCustomize(Actor actor, Model model) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index ecac046..e9fbcf4 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Services; using ImGuiNET; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index 2608dd3..11147c8 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin.Services; using Glamourer.Designs; using Glamourer.Events; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index bf9ba69..50fd936 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -1,6 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.ImGuiFileDialog; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.System.Framework; using Glamourer.Automation; using Glamourer.Designs; @@ -106,7 +106,7 @@ public class DesignPanel var data = EquipDrawData.FromDesign(_manager, _selector.Selected!, slot); _equipmentDrawer.DrawEquip(data); if (usedAllStain) - _manager.ChangeStain(_selector.Selected, slot, newAllStain); + _manager.ChangeStains(_selector.Selected, slot, newAllStain); } var mainhand = EquipDrawData.FromDesign(_manager, _selector.Selected!, EquipSlot.MainHand); @@ -453,7 +453,7 @@ public class DesignPanel } private static unsafe string GetUserPath() - => Framework.Instance()->UserPath; + => Framework.Instance()->UserPathString; private sealed class LockButton(DesignPanel panel) : Button diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs index 7fca8c2..9832451 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility; using Glamourer.Designs; using Glamourer.Interop; diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 1915241..9db8c19 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility; using Dalamud.Utility; using Glamourer.Designs; diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index c08d5c9..974912e 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.Designs; using Glamourer.Gui.Customization; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 834b9fc..f38d81d 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -10,7 +10,6 @@ using Glamourer.Interop.PalettePlus; using ImGuiNET; using OtterGui; using OtterGui.Raii; -using OtterGui.Text; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.SettingsTab; @@ -19,7 +18,7 @@ public class SettingsTab( Configuration config, DesignFileSystemSelector selector, ContextMenuService contextMenuService, - UiBuilder uiBuilder, + IUiBuilder uiBuilder, GlamourerChangelog changelog, IKeyState keys, DesignColorUi designColorUi, diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index aa67fb4..9749ce6 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -116,20 +116,20 @@ public class UnlockOverview var unlocked = _customizeUnlocks.IsUnlocked(customize, out var time); var icon = _customizations.Manager.GetIcon(customize.IconId); - - ImGui.Image(icon.ImGuiHandle, iconSize, Vector2.Zero, Vector2.One, + var hasIcon = icon.TryGetWrap(out var wrap, out _); + ImGui.Image(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, iconSize, Vector2.Zero, Vector2.One, unlocked || _codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (_favorites.Contains(_selected3, _selected2, customize.Index, customize.Value)) ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), 12 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 6 * ImGuiHelpers.GlobalScale); - if (ImGui.IsItemHovered()) + if (hasIcon && ImGui.IsItemHovered()) { using var tt = ImRaii.Tooltip(); - var size = new Vector2(icon.Width, icon.Height); + var size = new Vector2(wrap!.Width, wrap.Height); if (size.X >= iconSize.X && size.Y >= iconSize.Y) - ImGui.Image(icon.ImGuiHandle, size); + ImGui.Image(wrap.ImGuiHandle, size); ImGui.TextUnformatted(unlockData.Name); ImGui.TextUnformatted($"{customize.Index.ToDefaultName()} {customize.Value.Value}"); ImGui.TextUnformatted(unlocked ? $"Unlocked on {time:g}" : "Not unlocked."); @@ -191,7 +191,8 @@ public class UnlockOverview var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); - ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked || _codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); + ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, + unlocked || _codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (_favorites.Contains(item)) ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), 2 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * ImGuiHelpers.GlobalScale); @@ -233,8 +234,8 @@ public class UnlockOverview ImGui.TextUnformatted($"For all {_jobs.AllJobGroups[item.JobRestrictions.Id].Name} of at least Level {item.Level}"); } - if (item.Flags.HasFlag(ItemFlags.IsDyable)) - ImGui.TextUnformatted("Dyable"); + if (item.Flags.HasFlag(ItemFlags.IsDyable1)) + ImGui.TextUnformatted(item.Flags.HasFlag(ItemFlags.IsDyable2) ? "Dyable (2 Slots)" : "Dyable"); if (item.Flags.HasFlag(ItemFlags.IsTradable)) ImGui.TextUnformatted("Tradable"); if (item.Flags.HasFlag(ItemFlags.IsCrestWorthy)) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index d4fd4b0..600546f 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -1,4 +1,5 @@ using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Interface; using Dalamud.Interface.Utility; using Glamourer.Events; using Glamourer.Interop; @@ -249,7 +250,7 @@ public class UnlockTable : Table, IDisposable => 70 * ImGuiHelpers.GlobalScale; public override int ToValue(EquipItem item) - => (int) item.Id.Id; + => (int)item.Id.Id; public ItemIdColumn() : base(ComparisonMethod.Equal) @@ -378,13 +379,68 @@ public class UnlockTable : Table, IDisposable } } - private sealed class DyableColumn : YesNoColumn - { - public DyableColumn() - => Tooltip = "Whether the item is dyable."; - protected override bool GetValue(EquipItem item) - => item.Flags.HasFlag(ItemFlags.IsDyable); + private sealed class DyableColumn : ColumnFlags + { + [Flags] + public enum Dyable : byte + { + No = 1, + Yes = 2, + Two = 4, + } + + private Dyable _filterValue; + + public DyableColumn() + { + AllFlags = Dyable.No | Dyable.Yes | Dyable.Two; + Flags &= ~ImGuiTableColumnFlags.NoResize; + _filterValue = AllFlags; + } + + public override Dyable FilterValue + => _filterValue; + + protected override void SetValue(Dyable value, bool enable) + => _filterValue = enable ? _filterValue | value : _filterValue & ~value; + + public override float Width + => ImGui.GetFrameHeight() * 2; + + public override bool FilterFunc(EquipItem item) + => GetValue(item) switch + { + 0 => _filterValue.HasFlag(Dyable.No), + ItemFlags.IsDyable2 => _filterValue.HasFlag(Dyable.Yes), + ItemFlags.IsDyable1 => _filterValue.HasFlag(Dyable.Yes), + _ => _filterValue.HasFlag(Dyable.Two), + }; + + public override int Compare(EquipItem lhs, EquipItem rhs) + => GetValue(lhs).CompareTo(GetValue(rhs)); + + public override void DrawColumn(EquipItem item, int idx) + { + using (ImRaii.PushFont(UiBuilder.IconFont)) + { + ImGuiUtil.Center(Icon(item)); + } + + ImGuiUtil.HoverTooltip("Whether the item is dyable, and how many slots it has."); + } + + private static string Icon(EquipItem item) + => GetValue(item) switch + { + 0 => FontAwesomeIcon.Times.ToIconString(), + ItemFlags.IsDyable2 => FontAwesomeIcon.Check.ToIconString(), + ItemFlags.IsDyable1 => FontAwesomeIcon.Check.ToIconString(), + _ => FontAwesomeIcon.DiceTwo.ToIconString(), + }; + + private static ItemFlags GetValue(EquipItem item) + => item.Flags & (ItemFlags.IsDyable1 | ItemFlags.IsDyable2); } private sealed class TradableColumn : YesNoColumn diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index cfff90f..495d69c 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -17,7 +17,7 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 _original; + private readonly delegate* unmanaged _original; private readonly Post _postEvent = new(); diff --git a/Glamourer/Interop/CharaFile/CharaFile.cs b/Glamourer/Interop/CharaFile/CharaFile.cs index 0613fb3..4bf08cd 100644 --- a/Glamourer/Interop/CharaFile/CharaFile.cs +++ b/Glamourer/Interop/CharaFile/CharaFile.cs @@ -60,7 +60,7 @@ public sealed class CharaFile return; data.SetItem(slot, item); - data.SetStain(slot, dye); + data.SetStain(slot, new StainIds(dye)); flags |= slot.ToFlag(); flags |= slot.ToStainFlag(); } @@ -79,7 +79,7 @@ public sealed class CharaFile return; data.SetItem(slot, item); - data.SetStain(slot, dye); + data.SetStain(slot, new StainIds(dye)); flags |= slot.ToFlag(); flags |= slot.ToStainFlag(); } diff --git a/Glamourer/Interop/CharaFile/CmaFile.cs b/Glamourer/Interop/CharaFile/CmaFile.cs index dab91ac..da3fb43 100644 --- a/Glamourer/Interop/CharaFile/CmaFile.cs +++ b/Glamourer/Interop/CharaFile/CmaFile.cs @@ -61,7 +61,7 @@ public sealed class CmaFile var armor = ((CharacterArmor*)ptr)[idx]; var item = items.Identify(slot, armor.Set, armor.Variant); data.SetItem(slot, item); - data.SetStain(slot, armor.Stain); + data.SetStain(slot, armor.Stains); } data.Customize.Read(ptr); @@ -74,7 +74,7 @@ public sealed class CmaFile if (mainhand == null) { data.SetItem(EquipSlot.MainHand, items.DefaultSword); - data.SetStain(EquipSlot.MainHand, 0); + data.SetStain(EquipSlot.MainHand, StainIds.None); return; } @@ -85,7 +85,7 @@ public sealed class CmaFile var item = items.Identify(EquipSlot.MainHand, set, type, variant); data.SetItem(EquipSlot.MainHand, item.Valid ? item : items.DefaultSword); - data.SetStain(EquipSlot.MainHand, stain); + data.SetStain(EquipSlot.MainHand, new StainIds(stain)); } private static void ParseOffHand(ItemManager items, JObject jObj, ref DesignData data) @@ -95,7 +95,7 @@ public sealed class CmaFile if (offhand == null) { data.SetItem(EquipSlot.MainHand, defaultOffhand); - data.SetStain(EquipSlot.MainHand, defaultOffhand.PrimaryId.Id == 0 ? 0 : data.Stain(EquipSlot.MainHand)); + data.SetStain(EquipSlot.MainHand, defaultOffhand.PrimaryId.Id == 0 ? StainIds.None : data.Stain(EquipSlot.MainHand)); return; } @@ -106,6 +106,6 @@ public sealed class CmaFile var item = items.Identify(EquipSlot.OffHand, set, type, variant, data.MainhandType); data.SetItem(EquipSlot.OffHand, item.Valid ? item : defaultOffhand); - data.SetStain(EquipSlot.OffHand, defaultOffhand.PrimaryId.Id == 0 ? 0 : (StainId)stain); + data.SetStain(EquipSlot.OffHand, defaultOffhand.PrimaryId.Id == 0 ? StainIds.None : new StainIds(stain)); } } diff --git a/Glamourer/Interop/ContextMenuService.cs b/Glamourer/Interop/ContextMenuService.cs index 8cd5391..19a805f 100644 --- a/Glamourer/Interop/ContextMenuService.cs +++ b/Glamourer/Interop/ContextMenuService.cs @@ -20,7 +20,7 @@ public class ContextMenuService : IDisposable private readonly ObjectManager _objects; private readonly IGameGui _gameGui; private EquipItem _lastItem; - private StainId _lastStain; + private readonly StainId[] _lastStains = new StainId[StainId.NumStains]; private readonly MenuItem _inventoryItem; @@ -47,14 +47,15 @@ public class ContextMenuService : IDisposable }; } - private unsafe void OnMenuOpened(MenuOpenedArgs args) + private unsafe void OnMenuOpened(IMenuOpenedArgs args) { if (args.MenuType is ContextMenuType.Inventory) { var arg = (MenuTargetInventory)args.Target; if (arg.TargetItem.HasValue && HandleItem(arg.TargetItem.Value.ItemId)) { - _lastStain = arg.TargetItem.Value.Stain; + for (var i = 0; i < arg.TargetItem.Value.Stains.Length; ++i) + _lastStains[i] = (StainId)arg.TargetItem.Value.Stains[i]; args.AddMenuItem(_inventoryItem); } } @@ -77,7 +78,8 @@ public class ContextMenuService : IDisposable if (HandleItem(*(ItemId*)(agent + ChatLogContextItemId))) { - _lastStain = 0; + for (var i = 0; i < _lastStains.Length; ++i) + _lastStains[i] = 0; args.AddMenuItem(_inventoryItem); } @@ -96,7 +98,7 @@ public class ContextMenuService : IDisposable public void Dispose() => Disable(); - private void OnClick(MenuItemClickedArgs _) + private void OnClick(IMenuItemClickedArgs _) { var (id, playerData) = _objects.PlayerData; if (!playerData.Valid) @@ -106,15 +108,15 @@ public class ContextMenuService : IDisposable return; var slot = _lastItem.Type.ToSlot(); - _state.ChangeEquip(state, slot, _lastItem, _lastStain, ApplySettings.Manual); + _state.ChangeEquip(state, slot, _lastItem, _lastStains[0], ApplySettings.Manual); if (!_lastItem.Type.ValidOffhand().IsOffhandType()) return; if (_lastItem.PrimaryId.Id is > 1600 and < 1651 && _items.ItemData.TryGetValue(_lastItem.ItemId, EquipSlot.Hands, out var gauntlets)) - _state.ChangeEquip(state, EquipSlot.Hands, gauntlets, _lastStain, ApplySettings.Manual); + _state.ChangeEquip(state, EquipSlot.Hands, gauntlets, _lastStains[0], ApplySettings.Manual); if (_items.ItemData.TryGetValue(_lastItem.ItemId, EquipSlot.OffHand, out var offhand)) - _state.ChangeEquip(state, EquipSlot.OffHand, offhand, _lastStain, ApplySettings.Manual); + _state.ChangeEquip(state, EquipSlot.OffHand, offhand, _lastStains[0], ApplySettings.Manual); } private bool HandleItem(ItemId id) diff --git a/Glamourer/Interop/CrestService.cs b/Glamourer/Interop/CrestService.cs index 75e2a81..2b6f1ac 100644 --- a/Glamourer/Interop/CrestService.cs +++ b/Glamourer/Interop/CrestService.cs @@ -4,6 +4,7 @@ using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using OtterGui.Classes; +using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; @@ -30,9 +31,9 @@ public sealed unsafe class CrestService : EventWrapperRef3(_humanVTable[96], HumanSetFreeCompanyCrestVisibleOnSlotDetour); + interop.HookFromAddress(_humanVTable[109], HumanSetFreeCompanyCrestVisibleOnSlotDetour); _weaponSetFreeCompanyCrestVisibleOnSlot = - interop.HookFromAddress(_weaponVTable[96], WeaponSetFreeCompanyCrestVisibleOnSlotDetour); + interop.HookFromAddress(_weaponVTable[109], WeaponSetFreeCompanyCrestVisibleOnSlotDetour); _humanSetFreeCompanyCrestVisibleOnSlot.Enable(); _weaponSetFreeCompanyCrestVisibleOnSlot.Enable(); _crestChangeHook.Enable(); @@ -63,7 +64,7 @@ public sealed unsafe class CrestService : EventWrapperRef3 _crestChangeHook = null!; private void CrestChangeDetour(Character* character, byte crestFlags) @@ -96,8 +97,7 @@ public sealed unsafe class CrestService : EventWrapperRef3)((nint*)model.AsCharacterBase->VTable)[95]; - return getter(model.AsHuman, index) != 0; + return model.AsHuman->IsFreeCompanyCrestVisibleOnSlot(index) != 0; } case CrestType.Offhand: { @@ -105,8 +105,7 @@ public sealed unsafe class CrestService : EventWrapperRef3)((nint*)model.AsCharacterBase->VTable)[95]; - return getter(model.AsWeapon, index) != 0; + return model.AsWeapon->IsFreeCompanyCrestVisibleOnSlot(index) != 0; } } @@ -117,10 +116,10 @@ public sealed unsafe class CrestService : EventWrapperRef3 _humanSetFreeCompanyCrestVisibleOnSlot; diff --git a/Glamourer/Interop/ImportService.cs b/Glamourer/Interop/ImportService.cs index 9587feb..7dc3313 100644 --- a/Glamourer/Interop/ImportService.cs +++ b/Glamourer/Interop/ImportService.cs @@ -1,5 +1,5 @@ using Dalamud.Interface.DragDrop; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Interop.CharaFile; using Glamourer.Services; diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 9ad8737..6d8e58b 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -12,9 +12,9 @@ namespace Glamourer.Interop; public sealed unsafe class InventoryService : IDisposable, IRequiredService { - private readonly MovedEquipment _movedItemsEvent; - private readonly EquippedGearset _gearsetEvent; - private readonly List<(EquipSlot, uint, StainId)> _itemList = new(12); + private readonly MovedEquipment _movedItemsEvent; + private readonly EquippedGearset _gearsetEvent; + private readonly List<(EquipSlot, uint, StainIds)> _itemList = new(12); public InventoryService(MovedEquipment movedItemsEvent, IGameInteropProvider interop, EquippedGearset gearsetEvent) { @@ -60,56 +60,56 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService if (glamourPlateId != 0) { - void Add(EquipSlot slot, uint glamourId, StainId glamourStain, ref RaptureGearsetModule.GearsetItem item) + void Add(EquipSlot slot, uint glamourId, StainIds glamourStain, ref RaptureGearsetModule.GearsetItem item) { - if (item.ItemID == 0) - _itemList.Add((slot, 0, 0)); + if (item.ItemId == 0) + _itemList.Add((slot, 0, StainIds.None)); else if (glamourId != 0) _itemList.Add((slot, glamourId, glamourStain)); else if (item.GlamourId != 0) - _itemList.Add((slot, item.GlamourId, item.Stain)); + _itemList.Add((slot, item.GlamourId, StainIds.FromGearsetItem(item))); else - _itemList.Add((slot, FixId(item.ItemID), item.Stain)); + _itemList.Add((slot, FixId(item.ItemId), StainIds.FromGearsetItem(item))); } - var plate = MirageManager.Instance()->GlamourPlatesSpan[glamourPlateId - 1]; - Add(EquipSlot.MainHand, plate.ItemIds[0], plate.StainIds[0], ref entry->ItemsSpan[0]); - Add(EquipSlot.OffHand, plate.ItemIds[1], plate.StainIds[1], ref entry->ItemsSpan[1]); - Add(EquipSlot.Head, plate.ItemIds[2], plate.StainIds[2], ref entry->ItemsSpan[2]); - Add(EquipSlot.Body, plate.ItemIds[3], plate.StainIds[3], ref entry->ItemsSpan[3]); - Add(EquipSlot.Hands, plate.ItemIds[4], plate.StainIds[4], ref entry->ItemsSpan[5]); - Add(EquipSlot.Legs, plate.ItemIds[5], plate.StainIds[5], ref entry->ItemsSpan[6]); - Add(EquipSlot.Feet, plate.ItemIds[6], plate.StainIds[6], ref entry->ItemsSpan[7]); - Add(EquipSlot.Ears, plate.ItemIds[7], plate.StainIds[7], ref entry->ItemsSpan[8]); - Add(EquipSlot.Neck, plate.ItemIds[8], plate.StainIds[8], ref entry->ItemsSpan[9]); - Add(EquipSlot.Wrists, plate.ItemIds[9], plate.StainIds[9], ref entry->ItemsSpan[10]); - Add(EquipSlot.RFinger, plate.ItemIds[10], plate.StainIds[10], ref entry->ItemsSpan[11]); - Add(EquipSlot.LFinger, plate.ItemIds[11], plate.StainIds[11], ref entry->ItemsSpan[12]); + var plate = MirageManager.Instance()->GlamourPlates[glamourPlateId - 1]; + Add(EquipSlot.MainHand, plate.ItemIds[0], StainIds.FromGlamourPlate(plate, 0), ref entry->Items[0]); + Add(EquipSlot.OffHand, plate.ItemIds[1], StainIds.FromGlamourPlate(plate, 1), ref entry->Items[1]); + Add(EquipSlot.Head, plate.ItemIds[2], StainIds.FromGlamourPlate(plate, 2), ref entry->Items[2]); + Add(EquipSlot.Body, plate.ItemIds[3], StainIds.FromGlamourPlate(plate, 3), ref entry->Items[3]); + Add(EquipSlot.Hands, plate.ItemIds[4], StainIds.FromGlamourPlate(plate, 4), ref entry->Items[5]); + Add(EquipSlot.Legs, plate.ItemIds[5], StainIds.FromGlamourPlate(plate, 5), ref entry->Items[6]); + Add(EquipSlot.Feet, plate.ItemIds[6], StainIds.FromGlamourPlate(plate, 6), ref entry->Items[7]); + Add(EquipSlot.Ears, plate.ItemIds[7], StainIds.FromGlamourPlate(plate, 7), ref entry->Items[8]); + Add(EquipSlot.Neck, plate.ItemIds[8], StainIds.FromGlamourPlate(plate, 8), ref entry->Items[9]); + Add(EquipSlot.Wrists, plate.ItemIds[9], StainIds.FromGlamourPlate(plate, 9), ref entry->Items[10]); + Add(EquipSlot.RFinger, plate.ItemIds[10], StainIds.FromGlamourPlate(plate, 10), ref entry->Items[11]); + Add(EquipSlot.LFinger, plate.ItemIds[11], StainIds.FromGlamourPlate(plate, 11), ref entry->Items[12]); } else { void Add(EquipSlot slot, ref RaptureGearsetModule.GearsetItem item) { - if (item.ItemID == 0) - _itemList.Add((slot, 0, 0)); + if (item.ItemId == 0) + _itemList.Add((slot, 0, StainIds.None)); else if (item.GlamourId != 0) - _itemList.Add((slot, item.GlamourId, item.Stain)); + _itemList.Add((slot, item.GlamourId, StainIds.FromGearsetItem(item))); else - _itemList.Add((slot, FixId(item.ItemID), item.Stain)); + _itemList.Add((slot, FixId(item.ItemId), StainIds.FromGearsetItem(item))); } - Add(EquipSlot.MainHand, ref entry->ItemsSpan[0]); - Add(EquipSlot.OffHand, ref entry->ItemsSpan[1]); - Add(EquipSlot.Head, ref entry->ItemsSpan[2]); - Add(EquipSlot.Body, ref entry->ItemsSpan[3]); - Add(EquipSlot.Hands, ref entry->ItemsSpan[5]); - Add(EquipSlot.Legs, ref entry->ItemsSpan[6]); - Add(EquipSlot.Feet, ref entry->ItemsSpan[7]); - Add(EquipSlot.Ears, ref entry->ItemsSpan[8]); - Add(EquipSlot.Neck, ref entry->ItemsSpan[9]); - Add(EquipSlot.Wrists, ref entry->ItemsSpan[10]); - Add(EquipSlot.RFinger, ref entry->ItemsSpan[11]); - Add(EquipSlot.LFinger, ref entry->ItemsSpan[12]); + Add(EquipSlot.MainHand, ref entry->Items[0]); + Add(EquipSlot.OffHand, ref entry->Items[1]); + Add(EquipSlot.Head, ref entry->Items[2]); + Add(EquipSlot.Body, ref entry->Items[3]); + Add(EquipSlot.Hands, ref entry->Items[5]); + Add(EquipSlot.Legs, ref entry->Items[6]); + Add(EquipSlot.Feet, ref entry->Items[7]); + Add(EquipSlot.Ears, ref entry->Items[8]); + Add(EquipSlot.Neck, ref entry->Items[9]); + Add(EquipSlot.Wrists, ref entry->Items[10]); + Add(EquipSlot.RFinger, ref entry->Items[11]); + Add(EquipSlot.LFinger, ref entry->Items[12]); } _movedItemsEvent.Invoke(_itemList.ToArray()); @@ -155,7 +155,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService return ret; } - private static bool InvokeSource(InventoryType sourceContainer, uint sourceSlot, out (EquipSlot, uint, StainId) tuple) + private static bool InvokeSource(InventoryType sourceContainer, uint sourceSlot, out (EquipSlot, uint, StainIds) tuple) { tuple = default; if (sourceContainer is not InventoryType.EquippedItems) @@ -165,12 +165,12 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService if (slot is EquipSlot.Unknown) return false; - tuple = (slot, 0u, 0); + tuple = (slot, 0u, StainIds.None); return true; } private static bool InvokeTarget(InventoryManager* manager, InventoryType targetContainer, uint targetSlot, - out (EquipSlot, uint, StainId) tuple) + out (EquipSlot, uint, StainIds) tuple) { tuple = default; if (targetContainer is not InventoryType.EquippedItems) @@ -189,7 +189,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService if (item == null) return false; - tuple = (slot, item->GlamourID != 0 ? item->GlamourID : item->ItemID, item->Stain); + tuple = (slot, item->GlamourId != 0 ? item->GlamourId : item->ItemId, new StainIds(item->Stains)); return true; } diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index b8941e0..3e984c8 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -169,13 +169,13 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable if (!actor.AsObject->IsCharacter()) return false; - if (actor.AsCharacter->DrawData.WeaponDataSpan[0].DrawObject == characterBase) + if (actor.AsCharacter->DrawData.WeaponData[0].DrawObject == characterBase) { type = MaterialValueIndex.DrawObjectType.Mainhand; return true; } - if (actor.AsCharacter->DrawData.WeaponDataSpan[1].DrawObject == characterBase) + if (actor.AsCharacter->DrawData.WeaponData[1].DrawObject == characterBase) { type = MaterialValueIndex.DrawObjectType.Offhand; return true; @@ -199,10 +199,11 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// private static CharacterWeapon GetTempSlot(Weapon* weapon) { + // TODO: Fix offset var changedData = *(void**)((byte*)weapon + 0x918); if (changedData == null) - return new CharacterWeapon(weapon->ModelSetId, weapon->SecondaryId, (Variant)weapon->Variant, (StainId)weapon->ModelUnknown); + return new CharacterWeapon(weapon->ModelSetId, weapon->SecondaryId, (Variant)weapon->Variant, StainIds.FromWeapon(*weapon)); - return new CharacterWeapon(weapon->ModelSetId, *(SecondaryId*)changedData, ((Variant*)changedData)[2], ((StainId*)changedData)[3]); + return new CharacterWeapon(weapon->ModelSetId, *(SecondaryId*)changedData, ((Variant*)changedData)[2], new StainIds(((StainId*)changedData)[3], ((StainId*)changedData)[4])); } } diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 9bfcc4c..2096bc7 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -62,8 +62,8 @@ public readonly record struct MaterialValueIndex( model = DrawObject switch { DrawObjectType.Human => actor.Model, - DrawObjectType.Mainhand => actor.IsCharacter ? actor.AsCharacter->DrawData.WeaponDataSpan[0].DrawObject : Model.Null, - DrawObjectType.Offhand => actor.IsCharacter ? actor.AsCharacter->DrawData.WeaponDataSpan[1].DrawObject : Model.Null, + DrawObjectType.Mainhand => actor.IsCharacter ? actor.AsCharacter->DrawData.WeaponData[0].DrawObject : Model.Null, + DrawObjectType.Offhand => actor.IsCharacter ? actor.AsCharacter->DrawData.WeaponData[1].DrawObject : Model.Null, _ => Model.Null, }; return model.IsCharacterBase; diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index 483e6af..ae08c71 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -203,7 +203,7 @@ public struct MaterialValueState( => DrawData.Skeleton == rhsData.Skeleton && DrawData.Weapon == rhsData.Weapon && DrawData.Variant == rhsData.Variant - && DrawData.Stain == rhsData.Stain + && DrawData.Stains == rhsData.Stains && Game.NearEqual(rhsRow); public readonly MaterialValueDesign Convert() diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 1661037..3866d74 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -4,6 +4,7 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using OtterGui.Classes; using OtterGui.Services; +using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Interop; @@ -22,7 +23,7 @@ public sealed unsafe class PrepareColorSet public PrepareColorSet(HookManager hooks) : base("Prepare Color Set ") - => _task = hooks.CreateHook(Name, "40 55 56 41 56 48 83 EC ?? 80 BA", Detour, true); + => _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, true); private readonly Task> _task; @@ -54,7 +55,7 @@ public sealed unsafe class PrepareColorSet return _task.Result.Original(characterBase, material, stainId); } - public static bool TryGetColorTable(CharacterBase* characterBase, MaterialResourceHandle* material, StainId stainId, + public static bool TryGetColorTable(CharacterBase* characterBase, MaterialResourceHandle* material, StainIds stainIds, out LegacyColorTable table) { if (material->ColorTable == null) @@ -64,8 +65,9 @@ public sealed unsafe class PrepareColorSet } var newTable = *(LegacyColorTable*)material->ColorTable; - if (stainId.Id != 0) - characterBase->ReadStainingTemplate(material, stainId.Id, (Half*)(&newTable)); + // TODO + //if (stainIds.Stain1.Id != 0 || stainIds.Stain2.Id != 0) + // characterBase->ReadStainingTemplate(material, stainId.Id, (Half*)(&newTable)); table = newTable; return true; } @@ -84,21 +86,21 @@ public sealed unsafe class PrepareColorSet return false; } - return TryGetColorTable(model.AsCharacterBase, handle, GetStain(), out table); + return TryGetColorTable(model.AsCharacterBase, handle, GetStains(), out table); - StainId GetStain() + StainIds GetStains() { switch (index.DrawObject) { case MaterialValueIndex.DrawObjectType.Human: - return index.SlotIndex < 10 ? actor.Model.GetArmor(((uint)index.SlotIndex).ToEquipSlot()).Stain : 0; + return index.SlotIndex < 10 ? actor.Model.GetArmor(((uint)index.SlotIndex).ToEquipSlot()).Stains : StainIds.None; case MaterialValueIndex.DrawObjectType.Mainhand: - var mainhand = (Model)actor.AsCharacter->DrawData.WeaponDataSpan[1].DrawObject; - return mainhand.IsWeapon ? (StainId)mainhand.AsWeapon->ModelUnknown : 0; + var mainhand = (Model)actor.AsCharacter->DrawData.WeaponData[1].DrawObject; + return mainhand.IsWeapon ? StainIds.FromWeapon(*mainhand.AsWeapon) : StainIds.None; case MaterialValueIndex.DrawObjectType.Offhand: - var offhand = (Model)actor.AsCharacter->DrawData.WeaponDataSpan[1].DrawObject; - return offhand.IsWeapon ? (StainId)offhand.AsWeapon->ModelUnknown : 0; - default: return 0; + var offhand = (Model)actor.AsCharacter->DrawData.WeaponData[1].DrawObject; + return offhand.IsWeapon ? StainIds.FromWeapon(*offhand.AsWeapon) : StainIds.None; + default: return StainIds.None; } } } diff --git a/Glamourer/Interop/MetaService.cs b/Glamourer/Interop/MetaService.cs index 1bc7a32..062986b 100644 --- a/Glamourer/Interop/MetaService.cs +++ b/Glamourer/Interop/MetaService.cs @@ -49,11 +49,11 @@ public unsafe class MetaService : IDisposable return; // The function seems to not do anything if the head is 0, but also breaks for carbuncles turned human, sometimes? - var old = actor.AsCharacter->DrawData.Head.Id; + var old = actor.AsCharacter->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Head).Id; if (old == 0 && actor.AsCharacter->CharacterData.ModelCharaId == 0) - actor.AsCharacter->DrawData.Head.Id = 1; + actor.AsCharacter->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Head).Id = 1; _hideHatGearHook.Original(&actor.AsCharacter->DrawData, 0, (byte)(value ? 0 : 1)); - actor.AsCharacter->DrawData.Head.Id = old; + actor.AsCharacter->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Head).Id = old; } public void SetWeaponState(Actor actor, bool value) @@ -72,7 +72,7 @@ public unsafe class MetaService : IDisposable return; } - Actor actor = drawData->Parent; + Actor actor = drawData->OwnerObject; var v = value == 0; _headGearEvent.Invoke(actor, ref v); value = (byte)(v ? 0 : 1); @@ -82,7 +82,7 @@ public unsafe class MetaService : IDisposable private void HideWeaponsDetour(DrawDataContainer* drawData, bool value) { - Actor actor = drawData->Parent; + Actor actor = drawData->OwnerObject; value = !value; _weaponEvent.Invoke(actor, ref value); value = !value; @@ -92,7 +92,7 @@ public unsafe class MetaService : IDisposable private void ToggleVisorDetour(DrawDataContainer* drawData, bool value) { - Actor actor = drawData->Parent; + Actor actor = drawData->OwnerObject; _visorEvent.Invoke(actor.Model, true, ref value); Glamourer.Log.Verbose($"[MetaService] Toggle Visor triggered with 0x{(nint)drawData:X} {value} for {actor.Utf8Name}."); _toggleVisorHook.Original(drawData, value); diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs index f59e95c..f8f5813 100644 --- a/Glamourer/Interop/ObjectManager.cs +++ b/Glamourer/Interop/ObjectManager.cs @@ -14,7 +14,7 @@ public class ObjectManager( IFramework framework, IClientState clientState, IObjectTable objects, - DalamudPluginInterface pi, + IDalamudPluginInterface pi, Logger log, ActorManager actors, ITargetManager targets) diff --git a/Glamourer/Interop/PalettePlus/PaletteImport.cs b/Glamourer/Interop/PalettePlus/PaletteImport.cs index 8513036..93c3fa2 100644 --- a/Glamourer/Interop/PalettePlus/PaletteImport.cs +++ b/Glamourer/Interop/PalettePlus/PaletteImport.cs @@ -6,7 +6,7 @@ using OtterGui.Services; namespace Glamourer.Interop.PalettePlus; -public class PaletteImport(DalamudPluginInterface pluginInterface, DesignManager designManager, DesignFileSystem designFileSystem) : IService +public class PaletteImport(IDalamudPluginInterface pluginInterface, DesignManager designManager, DesignFileSystem designFileSystem) : IService { private string ConfigFile => Path.Combine(Path.GetDirectoryName(pluginInterface.GetPluginConfigDirectory())!, "PalettePlus.json"); diff --git a/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs b/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs index 6a23e90..a5a5ed9 100644 --- a/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs +++ b/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs @@ -1,7 +1,7 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin; -using OtterGui.Classes; using OtterGui.Services; +using Notification = OtterGui.Classes.Notification; namespace Glamourer.Interop.PalettePlus; @@ -9,9 +9,9 @@ public sealed class PalettePlusChecker : IRequiredService, IDisposable { private readonly Timer _paletteTimer; private readonly Configuration _config; - private readonly DalamudPluginInterface _pluginInterface; + private readonly IDalamudPluginInterface _pluginInterface; - public PalettePlusChecker(Configuration config, DalamudPluginInterface pluginInterface) + public PalettePlusChecker(Configuration config, IDalamudPluginInterface pluginInterface) { _config = config; _pluginInterface = pluginInterface; diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 58422d7..85235e7 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin; using Glamourer.Events; using OtterGui.Classes; @@ -36,7 +36,7 @@ public unsafe class PenumbraService : IDisposable public const int RequiredPenumbraBreakingVersion = 5; public const int RequiredPenumbraFeatureVersion = 0; - private readonly DalamudPluginInterface _pluginInterface; + private readonly IDalamudPluginInterface _pluginInterface; private readonly EventSubscriber _tooltipSubscriber; private readonly EventSubscriber _clickSubscriber; private readonly EventSubscriber _creatingCharacterBase; @@ -68,7 +68,7 @@ public unsafe class PenumbraService : IDisposable public int CurrentMinor { get; private set; } public DateTime AttachTime { get; private set; } - public PenumbraService(DalamudPluginInterface pi, PenumbraReloaded penumbraReloaded) + public PenumbraService(IDalamudPluginInterface pi, PenumbraReloaded penumbraReloaded) { _pluginInterface = pi; _penumbraReloaded = penumbraReloaded; diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index 66036d9..f7b8f08 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -3,6 +3,7 @@ using Dalamud.Hooking; using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; +using Penumbra.GameData; using Penumbra.GameData.Interop; using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character; @@ -14,7 +15,7 @@ public unsafe class ScalingService : IDisposable { interop.InitializeFromAttributes(this); _setupMountHook = - interop.HookFromAddress((nint)Character.MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); + interop.HookFromAddress((nint)MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); _setupOrnamentHook = interop.HookFromAddress((nint)Ornament.MemberFunctionPointers.SetupOrnament, SetupOrnamentDetour); _calculateHeightHook = interop.HookFromAddress((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); @@ -33,7 +34,7 @@ public unsafe class ScalingService : IDisposable _calculateHeightHook.Dispose(); } - private delegate void SetupMount(Character.MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4); + private delegate void SetupMount(MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4); private delegate void SetupOrnament(Ornament* ornament, uint* unk1, float* unk2); private delegate void PlaceMinion(Companion* character); private delegate float CalculateHeight(Character* character); @@ -45,15 +46,15 @@ public unsafe class ScalingService : IDisposable private readonly Hook _calculateHeightHook; // TODO: Use client structs sig. - [Signature("48 89 5C 24 ?? 55 57 41 57 48 8D 6C 24", DetourName = nameof(PlaceMinionDetour))] + [Signature(Sigs.PlaceMinion, DetourName = nameof(PlaceMinionDetour))] private readonly Hook _placeMinionHook = null!; - private void SetupMountDetour(Character.MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4) + private void SetupMountDetour(MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4) { - var (race, clan, gender) = GetScaleRelevantCustomize(&container->OwnerObject->Character); - SetScaleCustomize(&container->OwnerObject->Character, container->OwnerObject->Character.GameObject.DrawObject); + var (race, clan, gender) = GetScaleRelevantCustomize(container->OwnerObject); + SetScaleCustomize(container->OwnerObject, container->OwnerObject->DrawObject); _setupMountHook.Original(container, mountId, unk1, unk2, unk3, unk4); - SetScaleCustomize(&container->OwnerObject->Character, race, clan, gender); + SetScaleCustomize(container->OwnerObject, race, clan, gender); } private void SetupOrnamentDetour(Ornament* ornament, uint* unk1, float* unk2) diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index f2f7423..65a168e 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -18,33 +18,44 @@ public unsafe class UpdateSlotService : IDisposable SlotUpdatingEvent = slotUpdating; interop.InitializeFromAttributes(this); _flagSlotForUpdateHook.Enable(); + _flagBonusSlotForUpdateHook.Enable(); } public void Dispose() - => _flagSlotForUpdateHook.Dispose(); + { + _flagSlotForUpdateHook.Dispose(); + _flagBonusSlotForUpdateHook.Dispose(); + } public void UpdateSlot(Model drawObject, EquipSlot slot, CharacterArmor data) { if (!drawObject.IsCharacterBase) return; - FlagSlotForUpdateInterop(drawObject, slot, data); + var bonusSlot = slot.ToBonusIndex(); + if (bonusSlot == uint.MaxValue) + FlagSlotForUpdateInterop(drawObject, slot, data); + else + _flagBonusSlotForUpdateHook.Original(drawObject.Address, bonusSlot, &data); } - public void UpdateArmor(Model drawObject, EquipSlot slot, CharacterArmor armor, StainId stain) - => UpdateSlot(drawObject, slot, armor.With(stain)); + public void UpdateArmor(Model drawObject, EquipSlot slot, CharacterArmor armor, StainIds stains) + => UpdateSlot(drawObject, slot, armor.With(stains)); public void UpdateArmor(Model drawObject, EquipSlot slot, CharacterArmor armor) - => UpdateArmor(drawObject, slot, armor, drawObject.GetArmor(slot).Stain); + => UpdateArmor(drawObject, slot, armor, drawObject.GetArmor(slot).Stains); - public void UpdateStain(Model drawObject, EquipSlot slot, StainId stain) - => UpdateArmor(drawObject, slot, drawObject.GetArmor(slot), stain); + public void UpdateStain(Model drawObject, EquipSlot slot, StainIds stains) + => UpdateArmor(drawObject, slot, drawObject.GetArmor(slot), stains); private delegate ulong FlagSlotForUpdateDelegateIntern(nint drawObject, uint slot, CharacterArmor* data); [Signature(Sigs.FlagSlotForUpdate, DetourName = nameof(FlagSlotForUpdateDetour))] private readonly Hook _flagSlotForUpdateHook = null!; + [Signature(Sigs.FlagBonusSlotForUpdate, DetourName = nameof(FlagBonusSlotForUpdateDetour))] + private readonly Hook _flagBonusSlotForUpdateHook = null!; + private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { var slot = slotIdx.ToEquipSlot(); @@ -54,6 +65,15 @@ public unsafe class UpdateSlotService : IDisposable return returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; } + private ulong FlagBonusSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) + { + var slot = slotIdx.ToBonusSlot(); + var returnValue = ulong.MaxValue; + SlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); + Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); + return returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; + } + private ulong FlagSlotForUpdateInterop(Model drawObject, EquipSlot slot, CharacterArmor armor) => _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); } diff --git a/Glamourer/Interop/WeaponService.cs b/Glamourer/Interop/WeaponService.cs index d2aac1a..5ab2a40 100644 --- a/Glamourer/Interop/WeaponService.cs +++ b/Glamourer/Interop/WeaponService.cs @@ -70,7 +70,7 @@ public unsafe class WeaponService : IDisposable if (tmpWeapon.Value != weapon.Value) { if (tmpWeapon.Skeleton.Id == 0) - tmpWeapon.Stain = 0; + tmpWeapon.Stains = StainIds.None; _loadWeaponHook.Original(drawData, slot, tmpWeapon.Value, 1, unk2, 1, unk4); } @@ -107,12 +107,12 @@ public unsafe class WeaponService : IDisposable } } - public void LoadStain(Actor character, EquipSlot slot, StainId stain) + public void LoadStain(Actor character, EquipSlot slot, StainIds stains) { var mdl = character.Model; var (_, _, mh, oh) = mdl.GetWeapons(character); var value = slot == EquipSlot.OffHand ? oh : mh; - var weapon = value.With(value.Skeleton.Id == 0 ? 0 : stain); + var weapon = value.With(value.Skeleton.Id == 0 ? StainIds.None : stains); LoadWeapon(character, slot, weapon); } } diff --git a/Glamourer/Services/CollectionOverrideService.cs b/Glamourer/Services/CollectionOverrideService.cs index 691118f..fcc9998 100644 --- a/Glamourer/Services/CollectionOverrideService.cs +++ b/Glamourer/Services/CollectionOverrideService.cs @@ -1,13 +1,13 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Interop.Penumbra; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; -using OtterGui.Classes; using OtterGui.Filesystem; using OtterGui.Services; using Penumbra.GameData.Actors; using Penumbra.GameData.Interop; +using Notification = OtterGui.Classes.Notification; namespace Glamourer.Services; diff --git a/Glamourer/Services/CustomizeService.cs b/Glamourer/Services/CustomizeService.cs index bb9737d..6505846 100644 --- a/Glamourer/Services/CustomizeService.cs +++ b/Glamourer/Services/CustomizeService.cs @@ -161,13 +161,6 @@ public sealed class CustomizeService( return $"The gender {gender.ToName()} is unknown, reset to {Gender.Male.ToName()}."; } - // TODO: Female Hrothgar - if (gender is Gender.Female && race is Race.Hrothgar) - { - actualGender = Gender.Male; - return $"{Race.Hrothgar.ToName()} do not currently support {Gender.Female.ToName()} characters, reset to {Gender.Male.ToName()}."; - } - actualGender = gender; return string.Empty; } @@ -225,13 +218,6 @@ public sealed class CustomizeService( customize.Race = newRace; customize.Clan = newClan; - // TODO Female Hrothgar - if (newRace == Race.Hrothgar) - { - customize.Gender = Gender.Male; - flags |= CustomizeFlag.Gender; - } - var set = Manager.GetSet(customize.Clan, customize.Gender); return FixValues(set, ref customize) | flags; } @@ -242,10 +228,6 @@ public sealed class CustomizeService( if (customize.Gender == newGender) return 0; - // TODO Female Hrothgar - if (customize.Race is Race.Hrothgar) - return 0; - if (ValidateGender(customize.Race, newGender, out newGender).Length > 0) return 0; diff --git a/Glamourer/Services/DalamudServices.cs b/Glamourer/Services/DalamudServices.cs index fd001d7..02df634 100644 --- a/Glamourer/Services/DalamudServices.cs +++ b/Glamourer/Services/DalamudServices.cs @@ -8,7 +8,7 @@ namespace Glamourer.Services; public class DalamudServices { - public static void AddServices(ServiceManager services, DalamudPluginInterface pi) + public static void AddServices(ServiceManager services, IDalamudPluginInterface pi) { services.AddExistingService(pi); services.AddExistingService(pi.UiBuilder); diff --git a/Glamourer/Services/FilenameService.cs b/Glamourer/Services/FilenameService.cs index e19e289..cd25c64 100644 --- a/Glamourer/Services/FilenameService.cs +++ b/Glamourer/Services/FilenameService.cs @@ -19,7 +19,7 @@ public class FilenameService public readonly string NpcAppearanceFile; public readonly string CollectionOverrideFile; - public FilenameService(DalamudPluginInterface pi) + public FilenameService(IDalamudPluginInterface pi) { ConfigDirectory = pi.ConfigDirectory.FullName; ConfigFile = pi.ConfigFile.FullName; diff --git a/Glamourer/Services/HeightService.cs b/Glamourer/Services/HeightService.cs index 48f0dd6..0a6c7bb 100644 --- a/Glamourer/Services/HeightService.cs +++ b/Glamourer/Services/HeightService.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using OtterGui.Services; +using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -9,7 +10,7 @@ namespace Glamourer.Services; public unsafe class HeightService : IService { - [Signature("E8 ?? ?? ?? FF 48 8B 0D ?? ?? ?? ?? 0F 28 F0")] + [Signature(Sigs.CalculateHeight)] private readonly delegate* unmanaged[Stdcall] _calculateHeight = null!; public HeightService(IGameInteropProvider interop) diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 8f52815..c5f537f 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -195,16 +195,16 @@ public class ItemManager /// The returned stain id is either the input or 0. /// The return value is an empty string if there was no problem and a warning otherwise. /// - public string ValidateStain(StainId stain, out StainId ret, bool allowUnknown) + public string ValidateStain(StainIds stains, out StainIds ret, bool allowUnknown) { - if (allowUnknown || IsStainValid(stain)) + if (allowUnknown || stains.All(IsStainValid)) { - ret = stain; + ret = stains; return string.Empty; } - ret = 0; - return $"The Stain {stain} does not exist, reset to unstained."; + ret = StainIds.None; + return $"The Stain {stains} does not exist, reset to unstained."; } /// Returns whether an offhand is valid given the required offhand type. diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 005944e..48632ab 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -33,7 +33,7 @@ namespace Glamourer.Services; public static class StaticServiceManager { - public static ServiceManager CreateProvider(DalamudPluginInterface pi, Logger log, Glamourer glamourer) + public static ServiceManager CreateProvider(IDalamudPluginInterface pi, Logger log, Glamourer glamourer) { EventWrapperBase.ChangeLogger(log); var services = new ServiceManager(log) @@ -165,5 +165,6 @@ public static class StaticServiceManager .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton(); + .AddSingleton() + .AddSingleton(); } diff --git a/Glamourer/Services/TextureService.cs b/Glamourer/Services/TextureService.cs index 0619279..99436e4 100644 --- a/Glamourer/Services/TextureService.cs +++ b/Glamourer/Services/TextureService.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using Dalamud.Interface.Internal; +using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Plugin.Services; using OtterGui.Classes; using Penumbra.GameData.Enums; @@ -7,7 +7,7 @@ using Penumbra.GameData.Structs; namespace Glamourer.Services; -public sealed class TextureService(UiBuilder uiBuilder, IDataManager dataManager, ITextureProvider textureProvider) +public sealed class TextureService(IUiBuilder uiBuilder, IDataManager dataManager, ITextureProvider textureProvider) : TextureCache(dataManager, textureProvider), IDisposable { private readonly IDalamudTextureWrap?[] _slotIcons = CreateSlotIcons(uiBuilder); @@ -32,7 +32,7 @@ public sealed class TextureService(UiBuilder uiBuilder, IDataManager dataManager } } - private static IDalamudTextureWrap?[] CreateSlotIcons(UiBuilder uiBuilder) + private static IDalamudTextureWrap?[] CreateSlotIcons(IUiBuilder uiBuilder) { var ret = new IDalamudTextureWrap?[12]; diff --git a/Glamourer/State/FunEquipSet.cs b/Glamourer/State/FunEquipSet.cs index 91e6419..c1ae02e 100644 --- a/Glamourer/State/FunEquipSet.cs +++ b/Glamourer/State/FunEquipSet.cs @@ -1,5 +1,4 @@ -using Glamourer.Interop.Structs; -using Penumbra.GameData.Structs; +using Penumbra.GameData.Structs; namespace Glamourer.State; @@ -21,8 +20,8 @@ internal class FunEquipSet { public Group(ushort headS, byte headV, ushort bodyS, byte bodyV, ushort handsS, byte handsV, ushort legsS, byte legsV, ushort feetS, byte feetV, StainId[]? stains = null) - : this(new CharacterArmor(headS, headV, 0), new CharacterArmor(bodyS, bodyV, 0), new CharacterArmor(handsS, handsV, 0), - new CharacterArmor(legsS, legsV, 0), new CharacterArmor(feetS, feetV, 0), stains) + : this(new CharacterArmor(headS, headV, StainIds.None), new CharacterArmor(bodyS, bodyV, StainIds.None), new CharacterArmor(handsS, handsV, StainIds.None), + new CharacterArmor(legsS, legsV, StainIds.None), new CharacterArmor(feetS, feetV, StainIds.None), stains) { } public static Group FullSetWithoutHat(ushort modelSet, byte variant, StainId[]? stains = null) diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index 25b8946..a9ce8e2 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -1,5 +1,5 @@ -using Dalamud.Game.ClientState.Objects.Enums; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; +using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.Designs; using Glamourer.Gui; using Glamourer.Services; @@ -106,7 +106,7 @@ public unsafe class FunModule : IDisposable && actor.OnlineStatus is OnlineStatus.PvEMentor or OnlineStatus.PvPMentor or OnlineStatus.TradeMentor && slot.IsEquipment()) { - armor = new CharacterArmor(6117, 1, 0); + armor = new CharacterArmor(6117, 1, StainIds.None); return; } @@ -171,7 +171,7 @@ public unsafe class FunModule : IDisposable break; case CodeService.CodeFlag.Dolphins: SetDolphin(EquipSlot.Body, ref armor[1]); - SetDolphin(EquipSlot.Head, ref armor[0]); + SetDolphin(EquipSlot.Head, ref armor[0]); break; case CodeService.CodeFlag.World when actor.Index != 0: _worldSets.Apply(actor, _rng, armor); @@ -198,7 +198,7 @@ public unsafe class FunModule : IDisposable private static bool ValidFunTarget(Actor actor) => actor.IsCharacter - && actor.AsObject->ObjectKind is (byte)ObjectKind.Player + && actor.AsObject->ObjectKind is ObjectKind.Pc && !actor.IsTransformed && actor.AsCharacter->CharacterData.ModelCharaId == 0; @@ -208,7 +208,7 @@ public unsafe class FunModule : IDisposable private void SetRandomDye(ref CharacterArmor armor) { var stainIdx = _rng.Next(0, _stains.Length - 1); - armor.Stain = _stains[stainIdx]; + armor.Stains = _stains[stainIdx]; } private void SetRandomItem(EquipSlot slot, ref CharacterArmor armor) @@ -235,17 +235,17 @@ public unsafe class FunModule : IDisposable private static IReadOnlyList DolphinBodies => [ - new CharacterArmor(6089, 1, 4), // Toad - new CharacterArmor(6089, 1, 4), // Toad - new CharacterArmor(6089, 1, 4), // Toad - new CharacterArmor(6023, 1, 4), // Swine - new CharacterArmor(6023, 1, 4), // Swine - new CharacterArmor(6023, 1, 4), // Swine - new CharacterArmor(6133, 1, 4), // Gaja - new CharacterArmor(6182, 1, 3), // Imp - new CharacterArmor(6182, 1, 3), // Imp - new CharacterArmor(6182, 1, 4), // Imp - new CharacterArmor(6182, 1, 4), // Imp + new CharacterArmor(6089, 1, new StainIds(4)), // Toad + new CharacterArmor(6089, 1, new StainIds(4)), // Toad + new CharacterArmor(6089, 1, new StainIds(4)), // Toad + new CharacterArmor(6023, 1, new StainIds(4)), // Swine + new CharacterArmor(6023, 1, new StainIds(4)), // Swine + new CharacterArmor(6023, 1, new StainIds(4)), // Swine + new CharacterArmor(6133, 1, new StainIds(4)), // Gaja + new CharacterArmor(6182, 1, new StainIds(3)), // Imp + new CharacterArmor(6182, 1, new StainIds(3)), // Imp + new CharacterArmor(6182, 1, new StainIds(4)), // Imp + new CharacterArmor(6182, 1, new StainIds(4)), // Imp ]; private void SetDolphin(EquipSlot slot, ref CharacterArmor armor) @@ -253,7 +253,7 @@ public unsafe class FunModule : IDisposable armor = slot switch { EquipSlot.Body => DolphinBodies[_rng.Next(0, DolphinBodies.Count - 1)], - EquipSlot.Head => new CharacterArmor(5040, 1, 0), + EquipSlot.Head => new CharacterArmor(5040, 1, StainIds.None), _ => armor, }; } @@ -270,7 +270,7 @@ public unsafe class FunModule : IDisposable private static void SetCrown(Span armor) { - var clown = new CharacterArmor(6117, 1, 0); + var clown = new CharacterArmor(6117, 1, StainIds.None); armor[0] = clown; armor[1] = clown; armor[2] = clown; @@ -285,15 +285,12 @@ public unsafe class FunModule : IDisposable return; var targetClan = (SubRace)((int)race * 2 - (int)customize.Clan % 2); - // TODO Female Hrothgar - if (race is Race.Hrothgar && customize.Gender is Gender.Female) - targetClan = targetClan is SubRace.Lost ? SubRace.Seawolf : SubRace.Hellsguard; _customizations.ChangeClan(ref customize, targetClan); } private void SetGender(ref CustomizeArray customize) { - if (!_codes.Enabled(CodeService.CodeFlag.SixtyThree) || customize.Race is Race.Hrothgar) // TODO Female Hrothgar + if (!_codes.Enabled(CodeService.CodeFlag.SixtyThree)) return; _customizations.ChangeGender(ref customize, customize.Gender is Gender.Male ? Gender.Female : Gender.Male); diff --git a/Glamourer/State/InternalStateEditor.cs b/Glamourer/State/InternalStateEditor.cs index eaf7c21..17072e7 100644 --- a/Glamourer/State/InternalStateEditor.cs +++ b/Glamourer/State/InternalStateEditor.cs @@ -152,11 +152,11 @@ public class InternalStateEditor( } /// Change a single piece of equipment including stain. - public bool ChangeEquip(ActorState state, EquipSlot slot, EquipItem item, StainId stain, StateSource source, out EquipItem oldItem, - out StainId oldStain, uint key = 0) + public bool ChangeEquip(ActorState state, EquipSlot slot, EquipItem item, StainIds stains, StateSource source, out EquipItem oldItem, + out StainIds oldStains, uint key = 0) { oldItem = state.ModelData.Item(slot); - oldStain = state.ModelData.Stain(slot); + oldStains = state.ModelData.Stain(slot); if (!state.CanUnlock(key)) return false; @@ -168,7 +168,7 @@ public class InternalStateEditor( return false; var old = oldItem; - var oldS = oldStain; + var oldS = oldStains; gPose.AddActionOnLeave(() => { if (old.Type == state.BaseData.Item(slot).Type) @@ -177,20 +177,20 @@ public class InternalStateEditor( } state.ModelData.SetItem(slot, item); - state.ModelData.SetStain(slot, stain); + state.ModelData.SetStain(slot, stains); state.Sources[slot, false] = source; state.Sources[slot, true] = source; return true; } /// Change only the stain of an equipment piece. - public bool ChangeStain(ActorState state, EquipSlot slot, StainId stain, StateSource source, out StainId oldStain, uint key = 0) + public bool ChangeStains(ActorState state, EquipSlot slot, StainIds stains, StateSource source, out StainIds oldStains, uint key = 0) { - oldStain = state.ModelData.Stain(slot); + oldStains = state.ModelData.Stain(slot); if (!state.CanUnlock(key)) return false; - state.ModelData.SetStain(slot, stain); + state.ModelData.SetStain(slot, stains); state.Sources[slot, true] = source; return true; } diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 9c06ce5..bf0fc30 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -130,22 +130,22 @@ public class StateApplier( /// Change the stain of a single piece of armor or weapon. /// If the offhand is empty, the stain will be fixed to 0 to prevent crashes. /// - public void ChangeStain(ActorData data, EquipSlot slot, StainId stain) + public void ChangeStain(ActorData data, EquipSlot slot, StainIds stains) { var idx = slot.ToIndex(); switch (idx) { case < 10: foreach (var actor in data.Objects.Where(a => a.Model.IsHuman)) - _updateSlot.UpdateStain(actor.Model, slot, stain); + _updateSlot.UpdateStain(actor.Model, slot, stains); break; case 10: foreach (var actor in data.Objects.Where(a => a.Model.IsHuman)) - _weapon.LoadStain(actor, EquipSlot.MainHand, stain); + _weapon.LoadStain(actor, EquipSlot.MainHand, stains); break; case 11: foreach (var actor in data.Objects.Where(a => a.Model.IsHuman)) - _weapon.LoadStain(actor, EquipSlot.OffHand, stain); + _weapon.LoadStain(actor, EquipSlot.OffHand, stains); break; } } @@ -162,12 +162,12 @@ public class StateApplier( /// Apply a weapon to the appropriate slot. - public void ChangeWeapon(ActorData data, EquipSlot slot, EquipItem item, StainId stain) + public void ChangeWeapon(ActorData data, EquipSlot slot, EquipItem item, StainIds stains) { if (slot is EquipSlot.MainHand) - ChangeMainhand(data, item, stain); + ChangeMainhand(data, item, stains); else - ChangeOffhand(data, item, stain); + ChangeOffhand(data, item, stains); } /// @@ -186,19 +186,19 @@ public class StateApplier( /// /// Apply a weapon to the mainhand. If the weapon type has no associated offhand type, apply both. /// - public void ChangeMainhand(ActorData data, EquipItem weapon, StainId stain) + public void ChangeMainhand(ActorData data, EquipItem weapon, StainIds stains) { var slot = weapon.Type.ValidOffhand() == FullEquipType.Unknown ? EquipSlot.BothHand : EquipSlot.MainHand; foreach (var actor in data.Objects.Where(a => a.Model.IsHuman)) - _weapon.LoadWeapon(actor, slot, weapon.Weapon().With(stain)); + _weapon.LoadWeapon(actor, slot, weapon.Weapon().With(stains)); } /// Apply a weapon to the offhand. - public void ChangeOffhand(ActorData data, EquipItem weapon, StainId stain) + public void ChangeOffhand(ActorData data, EquipItem weapon, StainIds stains) { - stain = weapon.PrimaryId.Id == 0 ? 0 : stain; + stains = weapon.PrimaryId.Id == 0 ? StainIds.None : stains; foreach (var actor in data.Objects.Where(a => a.Model.IsHuman)) - _weapon.LoadWeapon(actor, EquipSlot.OffHand, weapon.Weapon().With(stain)); + _weapon.LoadWeapon(actor, EquipSlot.OffHand, weapon.Weapon().With(stains)); } /// Change a meta state. @@ -209,7 +209,7 @@ public class StateApplier( case MetaIndex.Wetness: { foreach (var actor in data.Objects.Where(a => a.IsCharacter)) - actor.AsCharacter->IsGPoseWet = value; + actor.IsGPoseWet = value; return; } case MetaIndex.HatState: diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index c20a69d..dccb283 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -90,22 +90,22 @@ public class StateEditor( } /// - public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainId? stain, ApplySettings settings) + public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainIds? stains, ApplySettings settings) { - switch (item.HasValue, stain.HasValue) + switch (item.HasValue, stains.HasValue) { case (false, false): return; case (true, false): ChangeItem(data, slot, item!.Value, settings); return; case (false, true): - ChangeStain(data, slot, stain!.Value, settings); + ChangeStains(data, slot, stains!.Value, settings); return; } var state = (ActorState)data; - if (!Editor.ChangeEquip(state, slot, item ?? state.ModelData.Item(slot), stain ?? state.ModelData.Stain(slot), settings.Source, - out var old, out var oldStain, settings.Key)) + if (!Editor.ChangeEquip(state, slot, item ?? state.ModelData.Item(slot), stains ?? state.ModelData.Stain(slot), settings.Source, + out var old, out var oldStains, settings.Key)) return; var type = slot.ToIndex() < 10 ? StateChangeType.Equip : StateChangeType.Weapon; @@ -115,25 +115,25 @@ public class StateEditor( item!.Value.Type != (slot is EquipSlot.MainHand ? state.BaseData.MainhandType : state.BaseData.OffhandType)); if (slot is EquipSlot.MainHand) - ApplyMainhandPeriphery(state, item, stain, settings); + ApplyMainhandPeriphery(state, item, stains, settings); Glamourer.Log.Verbose( - $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStain.Id} to {stain!.Value.Id}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(type, settings.Source, state, actors, (old, item!.Value, slot)); - StateChanged.Invoke(StateChangeType.Stain, settings.Source, state, actors, (oldStain, stain!.Value, slot)); + $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStains} to {stains!.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); + StateChanged.Invoke(type, settings.Source, state, actors, (old, item!.Value, slot)); + StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, (oldStains, stains!.Value, slot)); } /// - public void ChangeStain(object data, EquipSlot slot, StainId stain, ApplySettings settings) + public void ChangeStains(object data, EquipSlot slot, StainIds stains, ApplySettings settings) { var state = (ActorState)data; - if (!Editor.ChangeStain(state, slot, stain, settings.Source, out var old, settings.Key)) + if (!Editor.ChangeStains(state, slot, stains, settings.Source, out var old, settings.Key)) return; var actors = Applier.ChangeStain(state, slot, settings.Source.RequiresChange()); Glamourer.Log.Verbose( - $"Set {slot.ToName()} stain in state {state.Identifier.Incognito(null)} from {old.Id} to {stain.Id}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Stain, settings.Source, state, actors, (old, stain, slot)); + $"Set {slot.ToName()} stain in state {state.Identifier.Incognito(null)} from {old} to {stains}. [Affecting {actors.ToLazyString("nothing")}.]"); + StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, (old, stains, slot)); } /// @@ -269,7 +269,7 @@ public class StateEditor( if (mergedDesign.Design.DoApplyStain(slot)) if (!settings.RespectManual || !state.Sources[slot, true].IsManual()) - Editor.ChangeStain(state, slot, mergedDesign.Design.DesignData.Stain(slot), + Editor.ChangeStains(state, slot, mergedDesign.Design.DesignData.Stain(slot), Source(slot.ToState(true)), out _, settings.Key); } @@ -277,7 +277,7 @@ public class StateEditor( { if (mergedDesign.Design.DoApplyStain(weaponSlot)) if (!settings.RespectManual || !state.Sources[weaponSlot, true].IsManual()) - Editor.ChangeStain(state, weaponSlot, mergedDesign.Design.DesignData.Stain(weaponSlot), + Editor.ChangeStains(state, weaponSlot, mergedDesign.Design.DesignData.Stain(weaponSlot), Source(weaponSlot.ToState(true)), out _, settings.Key); if (!mergedDesign.Design.DoApplyEquip(weaponSlot)) @@ -392,19 +392,19 @@ public class StateEditor( /// Apply offhand item and potentially gauntlets if configured. - private void ApplyMainhandPeriphery(ActorState state, EquipItem? newMainhand, StainId? newStain, ApplySettings settings) + private void ApplyMainhandPeriphery(ActorState state, EquipItem? newMainhand, StainIds? newStains, ApplySettings settings) { if (!Config.ChangeEntireItem || !settings.Source.IsManual()) return; var mh = newMainhand ?? state.ModelData.Item(EquipSlot.MainHand); var offhand = newMainhand != null ? Items.GetDefaultOffhand(mh) : state.ModelData.Item(EquipSlot.OffHand); - var stain = newStain ?? state.ModelData.Stain(EquipSlot.MainHand); + var stains = newStains ?? state.ModelData.Stain(EquipSlot.MainHand); if (offhand.Valid) - ChangeEquip(state, EquipSlot.OffHand, offhand, stain, settings); + ChangeEquip(state, EquipSlot.OffHand, offhand, stains, settings); if (mh is { Type: FullEquipType.Fists } && Items.ItemData.Tertiary.TryGetValue(mh.ItemId, out var gauntlets)) ChangeEquip(state, EquipSlot.Hands, newMainhand != null ? gauntlets : state.ModelData.Item(EquipSlot.Hands), - stain, settings); + stains, settings); } } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index f3657a7..8b3b5e7 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -227,7 +227,7 @@ public class StateListener : IDisposable (_, armor) = _items.RestrictedGear.ResolveRestricted(armor, slot, customize.Race, customize.Gender); } - private void OnMovedEquipment((EquipSlot, uint, StainId)[] items) + private void OnMovedEquipment((EquipSlot, uint, StainIds)[] items) { _objects.Update(); var (identifier, objects) = _objects.PlayerData; @@ -250,14 +250,14 @@ public class StateListener : IDisposable && current.Weapon == changed.Weapon && !state.Sources[slot, false].IsFixed(); - var stainChanged = current.Stain == changed.Stain && !state.Sources[slot, true].IsFixed(); + var stainChanged = current.Stains == changed.Stains && !state.Sources[slot, true].IsFixed(); switch ((itemChanged, stainChanged)) { case (true, true): - _manager.ChangeEquip(state, slot, currentItem, current.Stain, ApplySettings.Game); + _manager.ChangeEquip(state, slot, currentItem, current.Stains, ApplySettings.Game); if (slot is EquipSlot.MainHand or EquipSlot.OffHand) - _applier.ChangeWeapon(objects, slot, currentItem, current.Stain); + _applier.ChangeWeapon(objects, slot, currentItem, current.Stains); else _applier.ChangeArmor(objects, slot, current.ToArmor(), !state.Sources[slot, false].IsFixed(), state.ModelData.IsHatVisible()); @@ -265,14 +265,14 @@ public class StateListener : IDisposable case (true, false): _manager.ChangeItem(state, slot, currentItem, ApplySettings.Game); if (slot is EquipSlot.MainHand or EquipSlot.OffHand) - _applier.ChangeWeapon(objects, slot, currentItem, model.Stain); + _applier.ChangeWeapon(objects, slot, currentItem, model.Stains); else - _applier.ChangeArmor(objects, slot, current.ToArmor(model.Stain), !state.Sources[slot, false].IsFixed(), + _applier.ChangeArmor(objects, slot, current.ToArmor(model.Stains), !state.Sources[slot, false].IsFixed(), state.ModelData.IsHatVisible()); break; case (false, true): - _manager.ChangeStain(state, slot, current.Stain, ApplySettings.Game); - _applier.ChangeStain(objects, slot, current.Stain); + _manager.ChangeStains(state, slot, current.Stains, ApplySettings.Game); + _applier.ChangeStain(objects, slot, current.Stains); break; } } @@ -308,7 +308,7 @@ public class StateListener : IDisposable apply = true; if (!state.Sources[slot, true].IsFixed()) - _manager.ChangeStain(state, slot, state.BaseData.Stain(slot), ApplySettings.Game); + _manager.ChangeStains(state, slot, state.BaseData.Stain(slot), ApplySettings.Game); else apply = true; break; @@ -332,7 +332,7 @@ public class StateListener : IDisposable else { if (weapon.Skeleton.Id != 0) - weapon = weapon.With(newWeapon.Stain); + weapon = weapon.With(newWeapon.Stains); // Force unlock if necessary. _manager.ChangeItem(state, slot, state.BaseData.Item(slot), ApplySettings.Game with { Key = state.Combination }); } @@ -341,7 +341,7 @@ public class StateListener : IDisposable // Fist Weapon Offhand hack. if (slot is EquipSlot.MainHand && weapon.Skeleton.Id is > 1600 and < 1651) _lastFistOffhand = new CharacterWeapon((PrimaryId)(weapon.Skeleton.Id + 50), weapon.Weapon, weapon.Variant, - weapon.Stain); + weapon.Stains); _funModule.ApplyFunToWeapon(actor, ref weapon, slot); } @@ -365,7 +365,7 @@ public class StateListener : IDisposable { var item = _items.Identify(slot, actorArmor.Set, actorArmor.Variant); state.BaseData.SetItem(EquipSlot.Head, item); - state.BaseData.SetStain(EquipSlot.Head, actorArmor.Stain); + state.BaseData.SetStain(EquipSlot.Head, actorArmor.Stains); return UpdateState.Change; } @@ -378,9 +378,9 @@ public class StateListener : IDisposable var baseData = state.BaseData.Armor(slot); var change = UpdateState.NoChange; - if (baseData.Stain != armor.Stain) + if (baseData.Stains != armor.Stains) { - state.BaseData.SetStain(slot, armor.Stain); + state.BaseData.SetStain(slot, armor.Stains); change = UpdateState.Change; } @@ -418,7 +418,7 @@ public class StateListener : IDisposable apply = true; if (!state.Sources[slot, true].IsFixed()) - _manager.ChangeStain(state, slot, state.BaseData.Stain(slot), ApplySettings.Game); + _manager.ChangeStains(state, slot, state.BaseData.Stain(slot), ApplySettings.Game); else apply = true; @@ -503,9 +503,9 @@ public class StateListener : IDisposable if (slot is EquipSlot.OffHand && weapon.Value == 0 && actor.GetMainhand().Skeleton.Id is > 1600 and < 1651) return UpdateState.NoChange; - if (baseData.Stain != weapon.Stain) + if (baseData.Stains != weapon.Stains) { - state.BaseData.SetStain(slot, weapon.Stain); + state.BaseData.SetStain(slot, weapon.Stains); change = UpdateState.Change; } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index f057580..92cf6e5 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -117,7 +117,7 @@ public sealed class StateManager( if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId)) { ret.LoadNonHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId, *(CustomizeArray*)&actor.AsCharacter->DrawData.CustomizeData, - (nint)(&actor.AsCharacter->DrawData.Head)); + (nint)Unsafe.AsPointer(ref actor.AsCharacter->DrawData.EquipmentModelIds[0])); return ret; } @@ -141,7 +141,7 @@ public sealed class StateManager( var head = ret.IsHatVisible() || ignoreHatState ? model.GetArmor(EquipSlot.Head) : actor.GetArmor(EquipSlot.Head); var headItem = Items.Identify(EquipSlot.Head, head.Set, head.Variant); ret.SetItem(EquipSlot.Head, headItem); - ret.SetStain(EquipSlot.Head, head.Stain); + ret.SetStain(EquipSlot.Head, head.Stains); // The other slots can be used from the draw object. foreach (var slot in EquipSlotExtensions.EqdpSlots.Skip(1)) @@ -149,7 +149,7 @@ public sealed class StateManager( var armor = model.GetArmor(slot); var item = Items.Identify(slot, armor.Set, armor.Variant); ret.SetItem(slot, item); - ret.SetStain(slot, armor.Stain); + ret.SetStain(slot, armor.Stains); } // Weapons use the draw objects of the weapons, but require the game object either way. @@ -171,7 +171,7 @@ public sealed class StateManager( var armor = actor.GetArmor(slot); var item = Items.Identify(slot, armor.Set, armor.Variant); ret.SetItem(slot, item); - ret.SetStain(slot, armor.Stain); + ret.SetStain(slot, armor.Stains); } main = actor.GetMainhand(); @@ -187,13 +187,13 @@ public sealed class StateManager( var mainItem = Items.Identify(EquipSlot.MainHand, main.Skeleton, main.Weapon, main.Variant); var offItem = Items.Identify(EquipSlot.OffHand, off.Skeleton, off.Weapon, off.Variant, mainItem.Type); ret.SetItem(EquipSlot.MainHand, mainItem); - ret.SetStain(EquipSlot.MainHand, main.Stain); + ret.SetStain(EquipSlot.MainHand, main.Stains); ret.SetItem(EquipSlot.OffHand, offItem); - ret.SetStain(EquipSlot.OffHand, off.Stain); + ret.SetStain(EquipSlot.OffHand, off.Stains); // Wetness can technically only be set in GPose or via external tools. // It is only available in the game object. - ret.SetIsWet(actor.AsCharacter->IsGPoseWet); + ret.SetIsWet(actor.IsGPoseWet); // Weapon visibility could technically be inferred from the weapon draw objects, // but since we use hat visibility from the game object we can also use weapon visibility from it. @@ -214,7 +214,7 @@ public sealed class StateManager( offhand.Variant = mainhand.Variant; offhand.Weapon = mainhand.Weapon; ret.SetItem(EquipSlot.Hands, gauntlets); - ret.SetStain(EquipSlot.Hands, mainhand.Stain); + ret.SetStain(EquipSlot.Hands, mainhand.Stains); } /// Turn an actor human. @@ -414,7 +414,9 @@ public sealed class StateManager( public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source) { var data = Applier.ApplyAll(state, - forceRedraw || !actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); + forceRedraw + || !actor.Model.IsHuman + || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); } diff --git a/Glamourer/State/WorldSets.cs b/Glamourer/State/WorldSets.cs index eca0988..6a497ea 100644 --- a/Glamourer/State/WorldSets.cs +++ b/Glamourer/State/WorldSets.cs @@ -22,7 +22,7 @@ public class WorldSets [(Gender.Male, Race.AuRa)] = FunEquipSet.Group.FullSetWithoutHat(0257, 2), [(Gender.Female, Race.AuRa)] = FunEquipSet.Group.FullSetWithoutHat(0258, 2), [(Gender.Male, Race.Hrothgar)] = FunEquipSet.Group.FullSetWithoutHat(0597, 1), - [(Gender.Female, Race.Hrothgar)] = FunEquipSet.Group.FullSetWithoutHat(0000, 0), // TODO Hrothgar Female + [(Gender.Female, Race.Hrothgar)] = FunEquipSet.Group.FullSetWithoutHat(0829, 1), [(Gender.Male, Race.Viera)] = FunEquipSet.Group.FullSetWithoutHat(0744, 1), [(Gender.Female, Race.Viera)] = FunEquipSet.Group.FullSetWithoutHat(0581, 1), }; diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index b63a98e..a204a1c 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -1,4 +1,4 @@ -using Dalamud; +using Dalamud.Game; using Dalamud.Hooking; using Dalamud.Plugin.Services; using Dalamud.Utility; @@ -8,6 +8,7 @@ using Glamourer.GameData; using Glamourer.Events; using Glamourer.Services; using Lumina.Excel.GeneratedSheets; +using Penumbra.GameData; using Penumbra.GameData.Enums; namespace Glamourer.Unlocks; @@ -127,8 +128,8 @@ public class CustomizeUnlockManager : IDisposable, ISavable } private delegate void SetUnlockLinkValueDelegate(nint uiState, uint data, byte value); - - [Signature("48 83 EC ?? 8B C2 44 8B D2", DetourName = nameof(SetUnlockLinkValueDetour))] + + [Signature(Sigs.SetUnlockLinkValue, DetourName = nameof(SetUnlockLinkValueDetour))] private readonly Hook _setUnlockLinkValueHook = null!; private void SetUnlockLinkValueDetour(nint uiState, uint data, byte value) diff --git a/Glamourer/Unlocks/FavoriteManager.cs b/Glamourer/Unlocks/FavoriteManager.cs index 33242c9..de22ea8 100644 --- a/Glamourer/Unlocks/FavoriteManager.cs +++ b/Glamourer/Unlocks/FavoriteManager.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Glamourer.Services; using Newtonsoft.Json; using OtterGui.Classes; diff --git a/Glamourer/Unlocks/ItemUnlockManager.cs b/Glamourer/Unlocks/ItemUnlockManager.cs index de35335..0b95b94 100644 --- a/Glamourer/Unlocks/ItemUnlockManager.cs +++ b/Glamourer/Unlocks/ItemUnlockManager.cs @@ -144,8 +144,7 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionary(mirageManager->PrismBoxItemIds, 800); + var span = mirageManager->PrismBoxItemIds; foreach (var item in span) changes |= AddItem(item, time); } @@ -154,10 +153,9 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionaryGlamourPlatesSpan) + foreach (var plate in mirageManager->GlamourPlates) { - // TODO: Make independent from hardcoded value - var span = new ReadOnlySpan(plate.ItemIds, 12); + var span = plate.ItemIds; foreach (var item in span) changes |= AddItem(item, time); } @@ -176,8 +174,8 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionaryGetInventorySlot(_currentInventoryIndex++); if (item != null) { - changes |= AddItem(item->ItemID, time); - changes |= AddItem(item->GlamourID, time); + changes |= AddItem(item->ItemId, time); + changes |= AddItem(item->GlamourId, time); } } else diff --git a/Glamourer/Unlocks/UnlockDictionaryHelpers.cs b/Glamourer/Unlocks/UnlockDictionaryHelpers.cs index 28f5793..edc9472 100644 --- a/Glamourer/Unlocks/UnlockDictionaryHelpers.cs +++ b/Glamourer/Unlocks/UnlockDictionaryHelpers.cs @@ -1,4 +1,4 @@ -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using OtterGui.Classes; namespace Glamourer.Unlocks; diff --git a/OtterGui b/OtterGui index fd79128..c2738e1 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit fd791285606d49a7644762ea0b4dc2bbb1368eac +Subproject commit c2738e1d42974cddbe5a31238c6ed236a831d17d diff --git a/Penumbra.GameData b/Penumbra.GameData index 6aeae34..8ec296d 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 6aeae346332a255b7575ccfca554afb0f3cf1494 +Subproject commit 8ec296d1f8113ae2ba509527749cd3e8f54debbf diff --git a/Penumbra.String b/Penumbra.String index caa58c5..f04abba 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit caa58c5c92710e69ce07b9d736ebe2d228cb4488 +Subproject commit f04abbabedf5e757c5cbb970f3e513fef23e53cf diff --git a/repo.json b/repo.json index 3798270..c5ef399 100644 --- a/repo.json +++ b/repo.json @@ -21,7 +21,7 @@ "TestingAssemblyVersion": "1.2.3.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 9, + "DalamudApiLevel": 10, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From 7a602d6ec5cf9c4a985fe26dfbe70f24508b70bd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 11 Jul 2024 19:45:54 +0200 Subject: [PATCH 013/401] Extricate bonus slots somewhat. --- Glamourer/Events/BonusSlotUpdating.cs | 25 ++++++++++ .../{SlotUpdating.cs => EquipSlotUpdating.cs} | 8 ++-- .../Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 23 ++++----- Glamourer/Interop/UpdateSlotService.cs | 47 ++++++++++++++----- Glamourer/Services/ServiceManager.cs | 2 +- Glamourer/State/StateApplier.cs | 4 +- Glamourer/State/StateListener.cs | 12 ++--- Penumbra.GameData | 2 +- 8 files changed, 86 insertions(+), 37 deletions(-) create mode 100644 Glamourer/Events/BonusSlotUpdating.cs rename Glamourer/Events/{SlotUpdating.cs => EquipSlotUpdating.cs} (80%) diff --git a/Glamourer/Events/BonusSlotUpdating.cs b/Glamourer/Events/BonusSlotUpdating.cs new file mode 100644 index 0000000..3685f3c --- /dev/null +++ b/Glamourer/Events/BonusSlotUpdating.cs @@ -0,0 +1,25 @@ +using OtterGui.Classes; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; +using Penumbra.GameData.Structs; + +namespace Glamourer.Events; + +/// +/// Triggered when a model flags a bonus slot for an update. +/// +/// Parameter is the model with a flagged slot. +/// Parameter is the bonus slot changed. +/// Parameter is the model values to change the bonus piece to. +/// Parameter is the return value the function should return, if it is ulong.MaxValue, the original will be called and returned. +/// +/// +public sealed class BonusSlotUpdating() + : EventWrapperRef34(nameof(BonusSlotUpdating)) +{ + public enum Priority + { + /// + StateListener = 0, + } +} diff --git a/Glamourer/Events/SlotUpdating.cs b/Glamourer/Events/EquipSlotUpdating.cs similarity index 80% rename from Glamourer/Events/SlotUpdating.cs rename to Glamourer/Events/EquipSlotUpdating.cs index 8a766fb..a2daf85 100644 --- a/Glamourer/Events/SlotUpdating.cs +++ b/Glamourer/Events/EquipSlotUpdating.cs @@ -14,12 +14,12 @@ namespace Glamourer.Events; /// Parameter is the return value the function should return, if it is ulong.MaxValue, the original will be called and returned. /// /// -public sealed class SlotUpdating() - : EventWrapperRef34(nameof(SlotUpdating)) +public sealed class EquipSlotUpdating() + : EventWrapperRef34(nameof(EquipSlotUpdating)) { public enum Priority { - /// + /// StateListener = 0, } -} +} \ No newline at end of file diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index ddf42f1..dd1c125 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -90,7 +90,7 @@ public unsafe class ModelEvaluationPanel( : "No CharacterBase"); } - private void DrawParameters(Actor actor, Model model) + private static void DrawParameters(Actor actor, Model model) { if (!model.IsHuman) return; @@ -140,13 +140,13 @@ public unsafe class ModelEvaluationPanel( return; if (ImGui.SmallButton("Hide")) - _updateSlotService.UpdateSlot(model, EquipSlot.Head, CharacterArmor.Empty); + _updateSlotService.UpdateEquipSlot(model, EquipSlot.Head, CharacterArmor.Empty); ImGui.SameLine(); if (ImGui.SmallButton("Show")) - _updateSlotService.UpdateSlot(model, EquipSlot.Head, actor.GetArmor(EquipSlot.Head)); + _updateSlotService.UpdateEquipSlot(model, EquipSlot.Head, actor.GetArmor(EquipSlot.Head)); ImGui.SameLine(); if (ImGui.SmallButton("Toggle")) - _updateSlotService.UpdateSlot(model, EquipSlot.Head, + _updateSlotService.UpdateEquipSlot(model, EquipSlot.Head, model.AsHuman->Head.Value == 0 ? actor.GetArmor(EquipSlot.Head) : CharacterArmor.Empty); } @@ -223,31 +223,32 @@ public unsafe class ModelEvaluationPanel( _updateSlotService.UpdateStain(model, slot, new StainIds(5, 7)); ImGui.SameLine(); if (ImGui.SmallButton("Reset")) - _updateSlotService.UpdateSlot(model, slot, actor.GetArmor(slot)); + _updateSlotService.UpdateEquipSlot(model, slot, actor.GetArmor(slot)); } - using (ImRaii.PushId((int)EquipSlot.FaceWear)) + foreach (var slot in BonusSlotExtensions.AllFlags) { - ImGuiUtil.DrawTableColumn(EquipSlot.FaceWear.ToName()); + using var id2 = ImRaii.PushId((int)slot.ToModelIndex()); + ImGuiUtil.DrawTableColumn(slot.ToName()); if (!actor.IsCharacter) { ImGuiUtil.DrawTableColumn("No Character"); } else { - var glassesId = actor.AsCharacter->DrawData.GlassesIds[(int)EquipSlot.FaceWear.ToBonusIndex()]; + var glassesId = actor.GetBonusSlot(slot); if (_glasses.TryGetValue(glassesId, out var glasses)) ImGuiUtil.DrawTableColumn($"{glasses.Id.Id},{glasses.Variant.Id} ({glassesId})"); else ImGuiUtil.DrawTableColumn($"{glassesId}"); } - ImGuiUtil.DrawTableColumn(model.IsHuman ? model.GetArmor(EquipSlot.FaceWear).ToString() : "No Human"); + ImGuiUtil.DrawTableColumn(model.IsHuman ? model.GetBonus(slot).ToString() : "No Human"); ImGui.TableNextColumn(); if (ImUtf8.SmallButton("Change Piece"u8)) { - var data = model.GetArmor(EquipSlot.FaceWear); - _updateSlotService.UpdateSlot(model, EquipSlot.FaceWear, data with { Variant = (Variant)((data.Variant.Id + 1) % 12) }); + var data = model.GetBonus(slot); + _updateSlotService.UpdateBonusSlot(model, slot, data with { Variant = (Variant)((data.Variant.Id + 1) % 12) }); } } } diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 65a168e..2be31cf 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -3,6 +3,7 @@ using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using Glamourer.Events; using Penumbra.GameData; +using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; @@ -11,11 +12,16 @@ namespace Glamourer.Interop; public unsafe class UpdateSlotService : IDisposable { - public readonly SlotUpdating SlotUpdatingEvent; + public readonly EquipSlotUpdating EquipSlotUpdatingEvent; + public readonly BonusSlotUpdating BonusSlotUpdatingEvent; + private readonly DictGlasses _glasses; - public UpdateSlotService(SlotUpdating slotUpdating, IGameInteropProvider interop) + public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, IGameInteropProvider interop, + DictGlasses glasses) { - SlotUpdatingEvent = slotUpdating; + EquipSlotUpdatingEvent = equipSlotUpdating; + BonusSlotUpdatingEvent = bonusSlotUpdating; + _glasses = glasses; interop.InitializeFromAttributes(this); _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); @@ -27,20 +33,37 @@ public unsafe class UpdateSlotService : IDisposable _flagBonusSlotForUpdateHook.Dispose(); } - public void UpdateSlot(Model drawObject, EquipSlot slot, CharacterArmor data) + public void UpdateEquipSlot(Model drawObject, EquipSlot slot, CharacterArmor data) { if (!drawObject.IsCharacterBase) return; - var bonusSlot = slot.ToBonusIndex(); - if (bonusSlot == uint.MaxValue) - FlagSlotForUpdateInterop(drawObject, slot, data); - else - _flagBonusSlotForUpdateHook.Original(drawObject.Address, bonusSlot, &data); + FlagSlotForUpdateInterop(drawObject, slot, data); + } + + public void UpdateBonusSlot(Model drawObject, BonusEquipFlag slot, CharacterArmor data) + { + if (!drawObject.IsCharacterBase) + return; + + var index = slot.ToIndex(); + if (index == uint.MaxValue) + return; + + _flagBonusSlotForUpdateHook.Original(drawObject.Address, index, &data); + } + + public void UpdateGlasses(Model drawObject, GlassesId id) + { + if (!_glasses.TryGetValue(id, out var glasses)) + return; + + var armor = new CharacterArmor(glasses.Id, glasses.Variant, StainIds.None); + _flagBonusSlotForUpdateHook.Original(drawObject.Address, BonusEquipFlag.Glasses.ToIndex(), &armor); } public void UpdateArmor(Model drawObject, EquipSlot slot, CharacterArmor armor, StainIds stains) - => UpdateSlot(drawObject, slot, armor.With(stains)); + => UpdateEquipSlot(drawObject, slot, armor.With(stains)); public void UpdateArmor(Model drawObject, EquipSlot slot, CharacterArmor armor) => UpdateArmor(drawObject, slot, armor, drawObject.GetArmor(slot).Stains); @@ -60,7 +83,7 @@ public unsafe class UpdateSlotService : IDisposable { var slot = slotIdx.ToEquipSlot(); var returnValue = ulong.MaxValue; - SlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); + EquipSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); return returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; } @@ -69,7 +92,7 @@ public unsafe class UpdateSlotService : IDisposable { var slot = slotIdx.ToBonusSlot(); var returnValue = ulong.MaxValue; - SlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); + BonusSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); return returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; } diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 48632ab..baae507 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -70,7 +70,7 @@ public static class StaticServiceManager private static ServiceManager AddEvents(this ServiceManager services) => services.AddSingleton() - .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index bf0fc30..5a6c21e 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -105,11 +105,11 @@ public class StateApplier( { var customize = mdl.GetCustomize(); var (_, resolvedItem) = _items.ResolveRestrictedGear(armor, slot, customize.Race, customize.Gender); - _updateSlot.UpdateSlot(actor.Model, slot, resolvedItem); + _updateSlot.UpdateEquipSlot(actor.Model, slot, resolvedItem); } else { - _updateSlot.UpdateSlot(actor.Model, slot, armor); + _updateSlot.UpdateEquipSlot(actor.Model, slot, armor); } } } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 8b3b5e7..72b3122 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -32,7 +32,7 @@ public class StateListener : IDisposable private readonly ItemManager _items; private readonly CustomizeService _customizations; private readonly PenumbraService _penumbra; - private readonly SlotUpdating _slotUpdating; + private readonly EquipSlotUpdating _equipSlotUpdating; private readonly WeaponLoading _weaponLoading; private readonly HeadGearVisibilityChanged _headGearVisibility; private readonly VisorStateChanged _visorState; @@ -52,7 +52,7 @@ public class StateListener : IDisposable private CharacterWeapon _lastFistOffhand = CharacterWeapon.Empty; public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorManager actors, Configuration config, - SlotUpdating slotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, + EquipSlotUpdating equipSlotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, GPoseService gPose, ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, CrestService crestService) @@ -62,7 +62,7 @@ public class StateListener : IDisposable _penumbra = penumbra; _actors = actors; _config = config; - _slotUpdating = slotUpdating; + _equipSlotUpdating = equipSlotUpdating; _weaponLoading = weaponLoading; _visorState = visorState; _weaponVisibility = weaponVisibility; @@ -202,7 +202,7 @@ public class StateListener : IDisposable /// A draw model loads a new equipment piece. /// Update base data, apply or update model data, and protect against restricted gear. /// - private void OnSlotUpdating(Model model, EquipSlot slot, ref CharacterArmor armor, ref ulong returnValue) + private void OnEquipSlotUpdating(Model model, EquipSlot slot, ref CharacterArmor armor, ref ulong returnValue) { var actor = _penumbra.GameObjectFromDrawObject(model); if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) @@ -699,7 +699,7 @@ public class StateListener : IDisposable { _penumbra.CreatingCharacterBase += OnCreatingCharacterBase; _penumbra.CreatedCharacterBase += OnCreatedCharacterBase; - _slotUpdating.Subscribe(OnSlotUpdating, SlotUpdating.Priority.StateListener); + _equipSlotUpdating.Subscribe(OnEquipSlotUpdating, EquipSlotUpdating.Priority.StateListener); _movedEquipment.Subscribe(OnMovedEquipment, MovedEquipment.Priority.StateListener); _weaponLoading.Subscribe(OnWeaponLoading, WeaponLoading.Priority.StateListener); _visorState.Subscribe(OnVisorChange, VisorStateChanged.Priority.StateListener); @@ -715,7 +715,7 @@ public class StateListener : IDisposable { _penumbra.CreatingCharacterBase -= OnCreatingCharacterBase; _penumbra.CreatedCharacterBase -= OnCreatedCharacterBase; - _slotUpdating.Unsubscribe(OnSlotUpdating); + _equipSlotUpdating.Unsubscribe(OnEquipSlotUpdating); _movedEquipment.Unsubscribe(OnMovedEquipment); _weaponLoading.Unsubscribe(OnWeaponLoading); _visorState.Unsubscribe(OnVisorChange); diff --git a/Penumbra.GameData b/Penumbra.GameData index 8ec296d..d83303c 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 8ec296d1f8113ae2ba509527749cd3e8f54debbf +Subproject commit d83303ccc3ec5d7237f5da621e9c2433ad28f9e1 From 81059411e5e21df5ef17e21ed6a70ac591bde5bf Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 15 Jul 2024 15:19:51 +0200 Subject: [PATCH 014/401] Current state. --- Glamourer.Api | 2 +- Glamourer/Api/ApiHelpers.cs | 13 +- Glamourer/Automation/ApplicationType.cs | 17 +- Glamourer/Automation/AutoDesign.cs | 2 +- Glamourer/Designs/ApplicationCollection.cs | 61 +++++++ Glamourer/Designs/ApplicationRules.cs | 52 ++---- Glamourer/Designs/DesignBase.cs | 171 +++++++++--------- Glamourer/Designs/DesignColors.cs | 2 +- Glamourer/Designs/DesignConverter.cs | 18 +- Glamourer/Designs/DesignData.cs | 95 +++++++--- Glamourer/Designs/DesignEditor.cs | 5 + Glamourer/Designs/DesignManager.cs | 12 ++ Glamourer/Designs/IDesignEditor.cs | 3 + Glamourer/Designs/Links/DesignMerger.cs | 41 +++-- Glamourer/Designs/Links/MergedDesign.cs | 8 +- Glamourer/Events/BonusSlotUpdating.cs | 2 +- Glamourer/Events/DesignChanged.cs | 3 + Glamourer/Gui/DesignQuickBar.cs | 3 +- Glamourer/Gui/Equipment/BonusDrawData.cs | 57 ++++++ Glamourer/Gui/Equipment/BonusItemCombo.cs | 123 +++++++++++++ Glamourer/Gui/Equipment/EquipDrawData.cs | 2 +- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 103 ++++++++++- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 3 + Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 6 + Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 6 +- .../Gui/Tabs/DebugTab/DesignManagerPanel.cs | 2 +- .../Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 8 +- .../Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 20 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 23 ++- Glamourer/Gui/UiHelpers.cs | 67 ++++--- .../Interop/Material/MaterialValueIndex.cs | 6 + .../Interop/PalettePlus/PaletteImport.cs | 8 +- Glamourer/Interop/UpdateSlotService.cs | 16 +- Glamourer/Services/ItemManager.cs | 32 +++- Glamourer/State/InternalStateEditor.cs | 12 ++ Glamourer/State/StateApplier.cs | 27 +++ Glamourer/State/StateEditor.cs | 23 ++- Glamourer/State/StateIndex.cs | 28 +-- Glamourer/State/StateListener.cs | 68 ++++++- Glamourer/State/StateManager.cs | 32 ++++ Glamourer/Unlocks/FavoriteManager.cs | 49 +++-- Penumbra.GameData | 2 +- 42 files changed, 913 insertions(+), 320 deletions(-) create mode 100644 Glamourer/Designs/ApplicationCollection.cs create mode 100644 Glamourer/Gui/Equipment/BonusDrawData.cs create mode 100644 Glamourer/Gui/Equipment/BonusItemCombo.cs diff --git a/Glamourer.Api b/Glamourer.Api index 4aaece3..ca00339 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 4aaece34289d64363bc32aaa8fe52c8e7d3dce32 +Subproject commit ca003395306791b9e595683c47824b4718385311 diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index cf67912..a54a0ec 100644 --- a/Glamourer/Api/ApiHelpers.cs +++ b/Glamourer/Api/ApiHelpers.cs @@ -35,7 +35,8 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM state = null; return GlamourerApiEc.ActorNotFound; } - stateManager.TryGetValue(identifier, out state); + + stateManager.TryGetValue(identifier, out state); return GlamourerApiEc.Success; } @@ -54,12 +55,10 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM internal static DesignBase.FlagRestrictionResetter Restrict(DesignBase design, ApplyFlag flags) => (flags & (ApplyFlag.Equipment | ApplyFlag.Customization)) switch { - ApplyFlag.Equipment => design.TemporarilyRestrictApplication(EquipFlagExtensions.All, 0, CrestExtensions.All, 0), - ApplyFlag.Customization => design.TemporarilyRestrictApplication(0, CustomizeFlagExtensions.All, 0, - CustomizeParameterExtensions.All), - ApplyFlag.Equipment | ApplyFlag.Customization => design.TemporarilyRestrictApplication(EquipFlagExtensions.All, - CustomizeFlagExtensions.All, CrestExtensions.All, CustomizeParameterExtensions.All), - _ => design.TemporarilyRestrictApplication(0, 0, 0, 0), + ApplyFlag.Equipment => design.TemporarilyRestrictApplication(ApplicationCollection.Equipment), + ApplyFlag.Customization => design.TemporarilyRestrictApplication(ApplicationCollection.Customizations), + ApplyFlag.Equipment | ApplyFlag.Customization => design.TemporarilyRestrictApplication(ApplicationCollection.All), + _ => design.TemporarilyRestrictApplication(ApplicationCollection.None), }; [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] diff --git a/Glamourer/Automation/ApplicationType.cs b/Glamourer/Automation/ApplicationType.cs index 12dac50..3d409cb 100644 --- a/Glamourer/Automation/ApplicationType.cs +++ b/Glamourer/Automation/ApplicationType.cs @@ -28,8 +28,7 @@ public static class ApplicationTypeExtensions (ApplicationType.Weapons, "Apply all weapon changes that are enabled in this design and that are valid with the current weapon worn."), ]; - public static (EquipFlag Equip, CustomizeFlag Customize, CrestFlag Crest, CustomizeParameterFlag Parameters, MetaFlag Meta) ApplyWhat( - this ApplicationType type, IDesignStandIn designStandIn) + public static ApplicationCollection Collection(this ApplicationType type) { var equipFlags = (type.HasFlag(ApplicationType.Weapons) ? WeaponFlags : 0) | (type.HasFlag(ApplicationType.Armor) ? ArmorFlags : 0) @@ -37,18 +36,18 @@ public static class ApplicationTypeExtensions | (type.HasFlag(ApplicationType.GearCustomization) ? StainFlags : 0); var customizeFlags = type.HasFlag(ApplicationType.Customizations) ? CustomizeFlagExtensions.All : 0; var parameterFlags = type.HasFlag(ApplicationType.Customizations) ? CustomizeParameterExtensions.All : 0; - var crestFlag = type.HasFlag(ApplicationType.GearCustomization) ? CrestExtensions.AllRelevant : 0; - var metaFlag = (type.HasFlag(ApplicationType.Armor) ? MetaFlag.HatState | MetaFlag.VisorState : 0) + var crestFlags = type.HasFlag(ApplicationType.GearCustomization) ? CrestExtensions.AllRelevant : 0; + var metaFlags = (type.HasFlag(ApplicationType.Armor) ? MetaFlag.HatState | MetaFlag.VisorState : 0) | (type.HasFlag(ApplicationType.Weapons) ? MetaFlag.WeaponState : 0) | (type.HasFlag(ApplicationType.Customizations) ? MetaFlag.Wetness : 0); + var bonusFlags = type.HasFlag(ApplicationType.Armor) ? BonusExtensions.All : 0; - if (designStandIn is not DesignBase design) - return (equipFlags, customizeFlags, crestFlag, parameterFlags, metaFlag); - - return (equipFlags & design!.ApplyEquip, customizeFlags & design.ApplyCustomize, crestFlag & design.ApplyCrest, - parameterFlags & design.ApplyParameters, metaFlag & design.ApplyMeta); + return new ApplicationCollection(equipFlags, bonusFlags, customizeFlags, crestFlags, parameterFlags, metaFlags); } + public static ApplicationCollection ApplyWhat(this ApplicationType type, IDesignStandIn designStandIn) + => designStandIn is not DesignBase design ? type.Collection() : type.Collection().Restrict(design.Application); + public const EquipFlag WeaponFlags = EquipFlag.Mainhand | EquipFlag.Offhand; public const EquipFlag ArmorFlags = EquipFlag.Head | EquipFlag.Body | EquipFlag.Hands | EquipFlag.Legs | EquipFlag.Feet; public const EquipFlag AccessoryFlags = EquipFlag.Ears | EquipFlag.Neck | EquipFlag.Wrist | EquipFlag.RFinger | EquipFlag.LFinger; diff --git a/Glamourer/Automation/AutoDesign.cs b/Glamourer/Automation/AutoDesign.cs index 9fc8ca7..e31fb16 100644 --- a/Glamourer/Automation/AutoDesign.cs +++ b/Glamourer/Automation/AutoDesign.cs @@ -61,6 +61,6 @@ public class AutoDesign return ret; } - public (EquipFlag Equip, CustomizeFlag Customize, CrestFlag Crest, CustomizeParameterFlag Parameters, MetaFlag Meta) ApplyWhat() + public ApplicationCollection ApplyWhat() => Type.ApplyWhat(Design); } diff --git a/Glamourer/Designs/ApplicationCollection.cs b/Glamourer/Designs/ApplicationCollection.cs new file mode 100644 index 0000000..b31ff2e --- /dev/null +++ b/Glamourer/Designs/ApplicationCollection.cs @@ -0,0 +1,61 @@ +using Glamourer.GameData; +using ImGuiNET; +using Penumbra.GameData.Enums; + +namespace Glamourer.Designs; + +public record struct ApplicationCollection( + EquipFlag Equip, + BonusItemFlag BonusItem, + CustomizeFlag Customize, + CrestFlag Crest, + CustomizeParameterFlag Parameters, + MetaFlag Meta) +{ + public static readonly ApplicationCollection All = new(EquipFlagExtensions.All, BonusExtensions.All, + CustomizeFlagExtensions.AllRelevant, CrestExtensions.AllRelevant, CustomizeParameterExtensions.All, MetaExtensions.All); + + public static readonly ApplicationCollection None = new(0, 0, 0, 0, 0, 0); + + public static readonly ApplicationCollection Equipment = new(EquipFlagExtensions.All, BonusExtensions.All, + 0, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState); + + public static readonly ApplicationCollection Customizations = new(0, 0, CustomizeFlagExtensions.AllRelevant, 0, + CustomizeParameterExtensions.All, MetaFlag.Wetness); + + public static readonly ApplicationCollection Default = new(EquipFlagExtensions.All, BonusExtensions.All, + CustomizeFlagExtensions.AllRelevant, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState); + + public static ApplicationCollection FromKeys() + => (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch + { + (false, false) => All, + (true, true) => All, + (true, false) => Equipment, + (false, true) => Customizations, + }; + + public void RemoveEquip() + { + Equip = 0; + BonusItem = 0; + Crest = 0; + Meta &= ~(MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState); + } + + public void RemoveCustomize() + { + Customize = 0; + Parameters = 0; + Meta &= MetaFlag.Wetness; + } + + public ApplicationCollection Restrict(ApplicationCollection old) + => new(old.Equip & Equip, old.BonusItem & BonusItem, old.Customize & Customize, old.Crest & Crest, + old.Parameters & Parameters, old.Meta & Meta); + + public ApplicationCollection CloneSecure() + => new(Equip & EquipFlagExtensions.All, BonusItem & BonusExtensions.All, + (Customize & CustomizeFlagExtensions.AllRelevant) | CustomizeFlag.BodyType, Crest & CrestExtensions.AllRelevant, + Parameters & CustomizeParameterExtensions.All, Meta & MetaExtensions.All); +} diff --git a/Glamourer/Designs/ApplicationRules.cs b/Glamourer/Designs/ApplicationRules.cs index c15b26a..3c5fed2 100644 --- a/Glamourer/Designs/ApplicationRules.cs +++ b/Glamourer/Designs/ApplicationRules.cs @@ -5,16 +5,9 @@ using Penumbra.GameData.Enums; namespace Glamourer.Designs; -public readonly struct ApplicationRules( - EquipFlag equip, - CustomizeFlag customize, - CrestFlag crest, - CustomizeParameterFlag parameters, - MetaFlag meta, - bool materials) +public readonly struct ApplicationRules(ApplicationCollection application, bool materials) { - public static readonly ApplicationRules All = new(EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, - CrestExtensions.AllRelevant, CustomizeParameterExtensions.All, MetaExtensions.All, true); + public static readonly ApplicationRules All = new(ApplicationCollection.All, true); public static ApplicationRules FromModifiers(ActorState state) => FromModifiers(state, ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift); @@ -23,54 +16,43 @@ public readonly struct ApplicationRules( => NpcFromModifiers(ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift); public static ApplicationRules AllButParameters(ActorState state) - => new(All.Equip, All.Customize, All.Crest, ComputeParameters(state.ModelData, state.BaseData, All.Parameters), All.Meta, true); + => new(ApplicationCollection.All with { Parameters = ComputeParameters(state.ModelData, state.BaseData, All.Parameters) }, true); public static ApplicationRules AllWithConfig(Configuration config) - => new(All.Equip, All.Customize, All.Crest, config.UseAdvancedParameters ? All.Parameters : 0, All.Meta, config.UseAdvancedDyes); + => new(ApplicationCollection.All with { Parameters = config.UseAdvancedParameters ? All.Parameters : 0 }, config.UseAdvancedDyes); public static ApplicationRules NpcFromModifiers(bool ctrl, bool shift) - => new(ctrl || !shift ? EquipFlagExtensions.All : 0, - !ctrl || shift ? CustomizeFlagExtensions.AllRelevant : 0, - 0, - 0, - ctrl || !shift ? MetaFlag.VisorState : 0, false); + { + var equip = ctrl || !shift ? EquipFlagExtensions.All : 0; + var customize = !ctrl || shift ? CustomizeFlagExtensions.AllRelevant : 0; + var visor = equip != 0 ? MetaFlag.VisorState : 0; + return new ApplicationRules(new ApplicationCollection(equip, 0, customize, 0, 0, visor), false); + } public static ApplicationRules FromModifiers(ActorState state, bool ctrl, bool shift) { var equip = ctrl || !shift ? EquipFlagExtensions.All : 0; var customize = !ctrl || shift ? CustomizeFlagExtensions.AllRelevant : 0; + var bonus = equip == 0 ? 0 : BonusExtensions.All; var crest = equip == 0 ? 0 : CrestExtensions.AllRelevant; var parameters = customize == 0 ? 0 : CustomizeParameterExtensions.All; var meta = state.ModelData.IsWet() ? MetaFlag.Wetness : 0; if (equip != 0) meta |= MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState; - return new ApplicationRules(equip, customize, crest, ComputeParameters(state.ModelData, state.BaseData, parameters), meta, equip != 0); + var collection = new ApplicationCollection(equip, bonus, customize, crest, + ComputeParameters(state.ModelData, state.BaseData, parameters), meta); + return new ApplicationRules(collection, equip != 0); } public void Apply(DesignBase design) - { - design.ApplyEquip = Equip; - design.ApplyCustomize = Customize; - design.ApplyCrest = Crest; - design.ApplyParameters = Parameters; - design.ApplyMeta = Meta; - } + => design.Application = application; public EquipFlag Equip - => equip & EquipFlagExtensions.All; - - public CustomizeFlag Customize - => customize & CustomizeFlagExtensions.AllRelevant; - - public CrestFlag Crest - => crest & CrestExtensions.AllRelevant; + => application.Equip & EquipFlagExtensions.All; public CustomizeParameterFlag Parameters - => parameters & CustomizeParameterExtensions.All; - - public MetaFlag Meta - => meta & MetaExtensions.All; + => application.Parameters & CustomizeParameterExtensions.All; public bool Materials => materials; diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 3791442..be12737 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -42,23 +42,19 @@ public class DesignBase /// Used when importing .cma or .chara files. internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags) { - _designData = designData; - ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant; - ApplyEquip = equipFlags & EquipFlagExtensions.All; - ApplyMeta = 0; - CustomizeSet = SetCustomizationSet(customize); + _designData = designData; + ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant; + Application.Equip = equipFlags & EquipFlagExtensions.All; + Application.Meta = 0; + CustomizeSet = SetCustomizationSet(customize); } internal DesignBase(DesignBase clone) { - _designData = clone._designData; - _materials = clone._materials.Clone(); - CustomizeSet = clone.CustomizeSet; - ApplyCustomize = clone.ApplyCustomizeRaw; - ApplyEquip = clone.ApplyEquip & EquipFlagExtensions.All; - ApplyParameters = clone.ApplyParameters & CustomizeParameterExtensions.All; - ApplyCrest = clone.ApplyCrest & CrestExtensions.All; - ApplyMeta = clone.ApplyMeta & MetaExtensions.All; + _designData = clone._designData; + _materials = clone._materials.Clone(); + CustomizeSet = clone.CustomizeSet; + Application = clone.Application.CloneSecure(); } /// Ensure that the customization set is updated when the design data changes. @@ -70,27 +66,20 @@ public class DesignBase #region Application Data - private CustomizeFlag _applyCustomize = CustomizeFlagExtensions.AllRelevant; - public CustomizeSet CustomizeSet { get; private set; } + public CustomizeSet CustomizeSet { get; private set; } - public CustomizeParameterFlag ApplyParameters { get; internal set; } + public ApplicationCollection Application = ApplicationCollection.Default; internal CustomizeFlag ApplyCustomize { - get => _applyCustomize.FixApplication(CustomizeSet); - set => _applyCustomize = (value & CustomizeFlagExtensions.AllRelevant) | CustomizeFlag.BodyType; + get => Application.Customize.FixApplication(CustomizeSet); + set => Application.Customize = (value & CustomizeFlagExtensions.AllRelevant) | CustomizeFlag.BodyType; } internal CustomizeFlag ApplyCustomizeExcludingBodyType - => _applyCustomize.FixApplication(CustomizeSet) & ~CustomizeFlag.BodyType; + => Application.Customize.FixApplication(CustomizeSet) & ~CustomizeFlag.BodyType; - internal CustomizeFlag ApplyCustomizeRaw - => _applyCustomize; - - internal EquipFlag ApplyEquip = EquipFlagExtensions.All; - internal CrestFlag ApplyCrest = CrestExtensions.AllRelevant; - internal MetaFlag ApplyMeta = MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState; - private bool _writeProtected; + private bool _writeProtected; public bool SetCustomize(CustomizeService customizeService, CustomizeArray customize) { @@ -103,18 +92,18 @@ public class DesignBase } public bool DoApplyMeta(MetaIndex index) - => ApplyMeta.HasFlag(index.ToFlag()); + => Application.Meta.HasFlag(index.ToFlag()); public bool WriteProtected() => _writeProtected; public bool SetApplyMeta(MetaIndex index, bool value) { - var newFlag = value ? ApplyMeta | index.ToFlag() : ApplyMeta & ~index.ToFlag(); - if (newFlag == ApplyMeta) + var newFlag = value ? Application.Meta | index.ToFlag() : Application.Meta & ~index.ToFlag(); + if (newFlag == Application.Meta) return false; - ApplyMeta = newFlag; + Application.Meta = newFlag; return true; } @@ -128,103 +117,100 @@ public class DesignBase } public bool DoApplyEquip(EquipSlot slot) - => ApplyEquip.HasFlag(slot.ToFlag()); + => Application.Equip.HasFlag(slot.ToFlag()); public bool DoApplyStain(EquipSlot slot) - => ApplyEquip.HasFlag(slot.ToStainFlag()); + => Application.Equip.HasFlag(slot.ToStainFlag()); public bool DoApplyCustomize(CustomizeIndex idx) - => ApplyCustomize.HasFlag(idx.ToFlag()); + => Application.Customize.HasFlag(idx.ToFlag()); public bool DoApplyCrest(CrestFlag slot) - => ApplyCrest.HasFlag(slot); + => Application.Crest.HasFlag(slot); public bool DoApplyParameter(CustomizeParameterFlag flag) - => ApplyParameters.HasFlag(flag); + => Application.Parameters.HasFlag(flag); + + public bool DoApplyBonusItem(BonusItemFlag slot) + => Application.BonusItem.HasFlag(slot); internal bool SetApplyEquip(EquipSlot slot, bool value) { - var newValue = value ? ApplyEquip | slot.ToFlag() : ApplyEquip & ~slot.ToFlag(); - if (newValue == ApplyEquip) + var newValue = value ? Application.Equip | slot.ToFlag() : Application.Equip & ~slot.ToFlag(); + if (newValue == Application.Equip) return false; - ApplyEquip = newValue; + Application.Equip = newValue; + return true; + } + + internal bool SetApplyBonusItem(BonusItemFlag slot, bool value) + { + var newValue = value ? Application.BonusItem | slot : Application.BonusItem & ~slot; + if (newValue == Application.BonusItem) + return false; + + Application.BonusItem = newValue; return true; } internal bool SetApplyStain(EquipSlot slot, bool value) { - var newValue = value ? ApplyEquip | slot.ToStainFlag() : ApplyEquip & ~slot.ToStainFlag(); - if (newValue == ApplyEquip) + var newValue = value ? Application.Equip | slot.ToStainFlag() : Application.Equip & ~slot.ToStainFlag(); + if (newValue == Application.Equip) return false; - ApplyEquip = newValue; + Application.Equip = newValue; return true; } internal bool SetApplyCustomize(CustomizeIndex idx, bool value) { - var newValue = value ? _applyCustomize | idx.ToFlag() : _applyCustomize & ~idx.ToFlag(); - if (newValue == _applyCustomize) + var newValue = value ? Application.Customize | idx.ToFlag() : Application.Customize & ~idx.ToFlag(); + if (newValue == Application.Customize) return false; - _applyCustomize = newValue; + Application.Customize = newValue; return true; } internal bool SetApplyCrest(CrestFlag slot, bool value) { - var newValue = value ? ApplyCrest | slot : ApplyCrest & ~slot; - if (newValue == ApplyCrest) + var newValue = value ? Application.Crest | slot : Application.Crest & ~slot; + if (newValue == Application.Crest) return false; - ApplyCrest = newValue; + Application.Crest = newValue; return true; } internal bool SetApplyParameter(CustomizeParameterFlag flag, bool value) { - var newValue = value ? ApplyParameters | flag : ApplyParameters & ~flag; - if (newValue == ApplyParameters) + var newValue = value ? Application.Parameters | flag : Application.Parameters & ~flag; + if (newValue == Application.Parameters) return false; - ApplyParameters = newValue; + Application.Parameters = newValue; return true; } - internal FlagRestrictionResetter TemporarilyRestrictApplication(EquipFlag equipFlags, CustomizeFlag customizeFlags, CrestFlag crestFlags, - CustomizeParameterFlag parameterFlags) - => new(this, equipFlags, customizeFlags, crestFlags, parameterFlags); + internal FlagRestrictionResetter TemporarilyRestrictApplication(ApplicationCollection restrictions) + => new(this, restrictions); internal readonly struct FlagRestrictionResetter : IDisposable { - private readonly DesignBase _design; - private readonly EquipFlag _oldEquipFlags; - private readonly CustomizeFlag _oldCustomizeFlags; - private readonly CrestFlag _oldCrestFlags; - private readonly CustomizeParameterFlag _oldParameterFlags; + private readonly DesignBase _design; + private readonly ApplicationCollection _oldFlags; - public FlagRestrictionResetter(DesignBase d, EquipFlag equipFlags, CustomizeFlag customizeFlags, CrestFlag crestFlags, - CustomizeParameterFlag parameterFlags) + public FlagRestrictionResetter(DesignBase d, ApplicationCollection restrictions) { - _design = d; - _oldEquipFlags = d.ApplyEquip; - _oldCustomizeFlags = d.ApplyCustomizeRaw; - _oldCrestFlags = d.ApplyCrest; - _oldParameterFlags = d.ApplyParameters; - d.ApplyEquip &= equipFlags; - d.ApplyCustomize &= customizeFlags; - d.ApplyCrest &= crestFlags; - d.ApplyParameters &= parameterFlags; + _design = d; + _oldFlags = d.Application; + _design.Application = restrictions.Restrict(_oldFlags); } public void Dispose() - { - _design.ApplyEquip = _oldEquipFlags; - _design.ApplyCustomize = _oldCustomizeFlags; - _design.ApplyCrest = _oldCrestFlags; - _design.ApplyParameters = _oldParameterFlags; - } + => _design.Application = _oldFlags; } private CustomizeSet SetCustomizationSet(CustomizeService customize) @@ -285,6 +271,22 @@ public class DesignBase }); } + protected JObject SerializeBonusItems() + { + var ret = new JObject(); + foreach (var slot in BonusExtensions.AllFlags) + { + var item = _designData.BonusItem(slot); + ret[slot.ToString()] = new JObject() + { + ["BonusId"] = item.ModelId.Id, + ["Apply"] = DoApplyBonusItem(slot), + }; + } + + return ret; + } + protected JObject SerializeCustomize() { var ret = new JObject() @@ -299,7 +301,7 @@ public class DesignBase ret[idx.ToString()] = new JObject() { ["Value"] = customize[idx].Value, - ["Apply"] = ApplyCustomizeRaw.HasFlag(idx.ToFlag()), + ["Apply"] = Application.Customize.HasFlag(idx.ToFlag()), }; } else @@ -382,7 +384,7 @@ public class DesignBase { var k = uint.Parse(key.Name, NumberStyles.HexNumber); var v = value.ToObject(); - if (!MaterialValueIndex.FromKey(k, out var idx)) + if (!MaterialValueIndex.FromKey(k, out _)) { Glamourer.Messager.NotificationMessage($"Invalid material value key {k} for design {name}, skipped.", NotificationType.Warning); @@ -429,7 +431,7 @@ public class DesignBase { if (parameters == null) { - design.ApplyParameters = 0; + design.Application.Parameters = 0; design.GetDesignDataRef().Parameters = default; return; } @@ -490,7 +492,7 @@ public class DesignBase return true; } - design.ApplyParameters &= ~flag; + design.Application.Parameters &= ~flag; design.GetDesignDataRef().Parameters[flag] = CustomizeParameterValue.Zero; return false; } @@ -669,11 +671,12 @@ public class DesignBase { _designData = DesignBase64Migration.MigrateBase64(items, humans, base64, out var equipFlags, out var customizeFlags, out var writeProtected, out var applyMeta); - ApplyEquip = equipFlags; - ApplyCustomize = customizeFlags; - ApplyParameters = 0; - ApplyCrest = 0; - ApplyMeta = applyMeta; + Application.Equip = equipFlags; + ApplyCustomize = customizeFlags; + Application.Parameters = 0; + Application.Crest = 0; + Application.Meta = applyMeta; + Application.BonusItem = 0; SetWriteProtected(writeProtected); CustomizeSet = SetCustomizationSet(customize); } diff --git a/Glamourer/Designs/DesignColors.cs b/Glamourer/Designs/DesignColors.cs index 5577c2c..96592bf 100644 --- a/Glamourer/Designs/DesignColors.cs +++ b/Glamourer/Designs/DesignColors.cs @@ -270,7 +270,7 @@ public class DesignColors : ISavable, IReadOnlyDictionary public static uint AutoColor(DesignBase design) { var customize = design.ApplyCustomizeExcludingBodyType == 0; - var equip = design.ApplyEquip == 0; + var equip = design.Application.Equip == 0; return (customize, equip) switch { (true, true) => ColorId.StateDesign.Value(), diff --git a/Glamourer/Designs/DesignConverter.cs b/Glamourer/Designs/DesignConverter.cs index b1b5c61..21172fe 100644 --- a/Glamourer/Designs/DesignConverter.cs +++ b/Glamourer/Designs/DesignConverter.cs @@ -72,16 +72,11 @@ public class DesignConverter( ? Design.LoadDesign(_customize, _items, _linkLoader, jObject) : DesignBase.LoadDesignBase(_customize, _items, jObject); - ret.SetApplyMeta(MetaIndex.Wetness, customize); if (!customize) - ret.ApplyCustomize = 0; + ret.Application.RemoveCustomize(); if (!equip) - { - ret.ApplyEquip = 0; - ret.ApplyCrest = 0; - ret.ApplyMeta &= ~(MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState); - } + ret.Application.RemoveEquip(); return ret; } @@ -155,16 +150,11 @@ public class DesignConverter( return null; } - ret.SetApplyMeta(MetaIndex.Wetness, customize); if (!customize) - ret.ApplyCustomize = 0; + ret.Application.RemoveCustomize(); if (!equip) - { - ret.ApplyEquip = 0; - ret.ApplyCrest = 0; - ret.ApplyMeta &= ~(MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState); - } + ret.Application.RemoveEquip(); return ret; } diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index a762a84..7fb2f72 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -9,24 +9,31 @@ namespace Glamourer.Designs; public unsafe struct DesignData { - public const int EquipmentByteSize = 10 * CharacterArmor.Size; + public const int NumEquipment = 10; + public const int EquipmentByteSize = NumEquipment * CharacterArmor.Size; + public const int NumBonusItems = 1; + public const int NumWeapons = 2; - private string _nameHead = string.Empty; - private string _nameBody = string.Empty; - private string _nameHands = string.Empty; - private string _nameLegs = string.Empty; - private string _nameFeet = string.Empty; - private string _nameEars = string.Empty; - private string _nameNeck = string.Empty; - private string _nameWrists = string.Empty; - private string _nameRFinger = string.Empty; - private string _nameLFinger = string.Empty; - private string _nameMainhand = string.Empty; - private string _nameOffhand = string.Empty; - private string _nameFaceWear = string.Empty; - private fixed uint _itemIds[12]; - private fixed uint _iconIds[12]; - private fixed byte _equipmentBytes[EquipmentByteSize + 16]; + private string _nameHead = string.Empty; + private string _nameBody = string.Empty; + private string _nameHands = string.Empty; + private string _nameLegs = string.Empty; + private string _nameFeet = string.Empty; + private string _nameEars = string.Empty; + private string _nameNeck = string.Empty; + private string _nameWrists = string.Empty; + private string _nameRFinger = string.Empty; + private string _nameLFinger = string.Empty; + private string _nameMainhand = string.Empty; + private string _nameOffhand = string.Empty; + private string _nameGlasses = string.Empty; + + private fixed uint _itemIds[NumEquipment + NumWeapons]; + private fixed uint _iconIds[NumEquipment + NumWeapons + NumBonusItems]; + private fixed byte _equipmentBytes[EquipmentByteSize + NumWeapons * CharacterWeapon.Size]; + private fixed ushort _bonusIds[NumBonusItems]; + private fixed ushort _bonusModelIds[NumBonusItems]; + private fixed byte _bonusVariants[NumBonusItems]; public CustomizeParameterData Parameters; public CustomizeArray Customize = CustomizeArray.Default; public uint ModelId; @@ -52,7 +59,7 @@ public unsafe struct DesignData || name.IsContained(_nameLFinger) || name.IsContained(_nameMainhand) || name.IsContained(_nameOffhand) - || name.IsContained(_nameFaceWear); + || name.IsContained(_nameGlasses); public readonly StainIds Stain(EquipSlot slot) { @@ -101,6 +108,15 @@ public unsafe struct DesignData } } + public readonly BonusItem BonusItem(BonusItemFlag slot) + => slot switch + { + // @formatter:off + BonusItemFlag.Glasses => new BonusItem(_nameGlasses, _iconIds[12], _bonusIds[0], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses), + _ => Penumbra.GameData.Structs.BonusItem.Empty(slot), + // @formatter:on + }; + public readonly CharacterArmor Armor(EquipSlot slot) { fixed (byte* ptr = _equipmentBytes) @@ -134,7 +150,7 @@ public unsafe struct DesignData public bool SetItem(EquipSlot slot, EquipItem item) { var index = slot.ToIndex(); - if (index > 11) + if (index > NumEquipment + NumWeapons) return false; _itemIds[index] = item.ItemId.Id; @@ -173,6 +189,25 @@ public unsafe struct DesignData return true; } + public bool SetBonusItem(BonusItemFlag slot, BonusItem item) + { + var index = slot.ToIndex(); + if (index > NumBonusItems) + return false; + + _iconIds[NumEquipment + NumWeapons + index] = item.Icon.Id; + _bonusIds[index] = item.Id.Id; + _bonusModelIds[index] = item.ModelId.Id; + _bonusVariants[index] = item.Variant.Id; + switch (index) + { + case 0: + _nameGlasses = item.Name; + return true; + default: return false; + } + } + public bool SetStain(EquipSlot slot, StainIds stains) => slot.ToIndex() switch { @@ -313,17 +348,17 @@ public unsafe struct DesignData MemoryUtility.MemSet(ptr, 0, 10 * 2); } - _nameHead = string.Empty; - _nameBody = string.Empty; - _nameHands = string.Empty; - _nameLegs = string.Empty; - _nameFeet = string.Empty; - _nameEars = string.Empty; - _nameNeck = string.Empty; - _nameWrists = string.Empty; - _nameRFinger = string.Empty; - _nameLFinger = string.Empty; - _nameFaceWear = string.Empty; + _nameHead = string.Empty; + _nameBody = string.Empty; + _nameHands = string.Empty; + _nameLegs = string.Empty; + _nameFeet = string.Empty; + _nameEars = string.Empty; + _nameNeck = string.Empty; + _nameWrists = string.Empty; + _nameRFinger = string.Empty; + _nameLFinger = string.Empty; + _nameGlasses = string.Empty; return true; } diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index 32e38ac..08cb241 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -165,6 +165,11 @@ public class DesignEditor( } } + public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) + { + + } + /// public void ChangeStains(object data, EquipSlot slot, StainIds stains, ApplySettings _ = default) { diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 7bd949c..725d562 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -347,6 +347,18 @@ public sealed class DesignManager : DesignEditor DesignChanged.Invoke(DesignChanged.Type.ApplyEquip, design, slot); } + /// Change whether to apply a specific equipment piece. + public void ChangeApplyBonusItem(Design design, BonusItemFlag slot, bool value) + { + if (!design.SetApplyBonusItem(slot, value)) + return; + + design.LastEdit = DateTimeOffset.UtcNow; + SaveService.QueueSave(design); + Glamourer.Log.Debug($"Set applying of {slot} bonus item to {value}."); + DesignChanged.Invoke(DesignChanged.Type.ApplyBonus, design, slot); + } + /// Change whether to apply a specific stain. public void ChangeApplyStain(Design design, EquipSlot slot, bool value) { diff --git a/Glamourer/Designs/IDesignEditor.cs b/Glamourer/Designs/IDesignEditor.cs index cd51cf2..9eefa63 100644 --- a/Glamourer/Designs/IDesignEditor.cs +++ b/Glamourer/Designs/IDesignEditor.cs @@ -64,6 +64,9 @@ public interface IDesignEditor public void ChangeItem(object data, EquipSlot slot, EquipItem item, ApplySettings settings = default) => ChangeEquip(data, slot, item, null, settings); + /// Change a bonus item. + public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default); + /// Change the stain for any equipment piece. public void ChangeStains(object data, EquipSlot slot, StainIds stains, ApplySettings settings = default) => ChangeEquip(data, slot, null, stains, settings); diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index 558377a..9832ead 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -42,14 +42,15 @@ public class DesignMerger( if (!data.IsHuman) continue; - var (equipFlags, customizeFlags, crestFlags, parameterFlags, applyMeta) = type.ApplyWhat(design); - ReduceMeta(data, applyMeta, ret, source); - ReduceCustomize(data, customizeFlags, ref fixFlags, ret, source, respectOwnership, startBodyType); - ReduceEquip(data, equipFlags, ret, source, respectOwnership); - ReduceMainhands(data, jobs, equipFlags, ret, source, respectOwnership); - ReduceOffhands(data, jobs, equipFlags, ret, source, respectOwnership); - ReduceCrests(data, crestFlags, ret, source); - ReduceParameters(data, parameterFlags, ret, source); + var collection = type.ApplyWhat(design); + ReduceMeta(data, collection.Meta, ret, source); + ReduceCustomize(data, collection.Customize, ref fixFlags, ret, source, respectOwnership, startBodyType); + ReduceEquip(data, collection.Equip, ret, source, respectOwnership); + ReduceBonusItems(data, collection.BonusItem, ret, source, respectOwnership); + ReduceMainhands(data, jobs, collection.Equip, ret, source, respectOwnership); + ReduceOffhands(data, jobs, collection.Equip, ret, source, respectOwnership); + ReduceCrests(data, collection.Crest, ret, source); + ReduceParameters(data, collection.Parameters, ret, source); ReduceMods(design as Design, ret, modAssociations); if (type.HasFlag(ApplicationType.GearCustomization)) ReduceMaterials(design, ret); @@ -83,7 +84,7 @@ public class DesignMerger( private static void ReduceMeta(in DesignData design, MetaFlag applyMeta, MergedDesign ret, StateSource source) { - applyMeta &= ~ret.Design.ApplyMeta; + applyMeta &= ~ret.Design.Application.Meta; if (applyMeta == 0) return; @@ -100,7 +101,7 @@ public class DesignMerger( private static void ReduceCrests(in DesignData design, CrestFlag crestFlags, MergedDesign ret, StateSource source) { - crestFlags &= ~ret.Design.ApplyCrest; + crestFlags &= ~ret.Design.Application.Crest; if (crestFlags == 0) return; @@ -118,7 +119,7 @@ public class DesignMerger( private static void ReduceParameters(in DesignData design, CustomizeParameterFlag parameterFlags, MergedDesign ret, StateSource source) { - parameterFlags &= ~ret.Design.ApplyParameters; + parameterFlags &= ~ret.Design.Application.Parameters; if (parameterFlags == 0) return; @@ -136,7 +137,7 @@ public class DesignMerger( private void ReduceEquip(in DesignData design, EquipFlag equipFlags, MergedDesign ret, StateSource source, bool respectOwnership) { - equipFlags &= ~ret.Design.ApplyEquip; + equipFlags &= ~ret.Design.Application.Equip; if (equipFlags == 0) return; @@ -174,6 +175,22 @@ public class DesignMerger( } } + private void ReduceBonusItems(in DesignData design, BonusItemFlag bonusItems, MergedDesign ret, StateSource source, bool respectOwnership) + { + bonusItems &= ~ret.Design.Application.BonusItem; + if (bonusItems == 0) + return; + + foreach (var slot in BonusExtensions.AllFlags.Where(b => bonusItems.HasFlag(b))) + { + var item = design.BonusItem(slot); + if (!respectOwnership || true) // TODO: maybe check unlocks + ret.Design.GetDesignDataRef().SetBonusItem(slot, item); + ret.Design.SetApplyBonusItem(slot, true); + ret.Sources[slot] = source; + } + } + private void ReduceMainhands(in DesignData design, JobFlag allowedJobs, EquipFlag equipFlags, MergedDesign ret, StateSource source, bool respectOwnership) { diff --git a/Glamourer/Designs/Links/MergedDesign.cs b/Glamourer/Designs/Links/MergedDesign.cs index d3c7664..da6cb54 100644 --- a/Glamourer/Designs/Links/MergedDesign.cs +++ b/Glamourer/Designs/Links/MergedDesign.cs @@ -64,12 +64,8 @@ public sealed class MergedDesign { public MergedDesign(DesignManager designManager) { - Design = designManager.CreateTemporary(); - Design.ApplyEquip = 0; - Design.ApplyCustomize = 0; - Design.ApplyCrest = 0; - Design.ApplyParameters = 0; - Design.ApplyMeta = 0; + Design = designManager.CreateTemporary(); + Design.Application = ApplicationCollection.None; } public MergedDesign(DesignBase design) diff --git a/Glamourer/Events/BonusSlotUpdating.cs b/Glamourer/Events/BonusSlotUpdating.cs index 3685f3c..3f6e761 100644 --- a/Glamourer/Events/BonusSlotUpdating.cs +++ b/Glamourer/Events/BonusSlotUpdating.cs @@ -15,7 +15,7 @@ namespace Glamourer.Events; /// /// public sealed class BonusSlotUpdating() - : EventWrapperRef34(nameof(BonusSlotUpdating)) + : EventWrapperRef34(nameof(BonusSlotUpdating)) { public enum Priority { diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 1837aad..1588a96 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -89,6 +89,9 @@ public sealed class DesignChanged() /// An existing design changed whether a specific equipment piece is applied. Data is the slot of the equipment [EquipSlot]. ApplyEquip, + /// An existing design changed whether a specific bonus item is applied. Data is the slot of the item [BonusItemFlag]. + ApplyBonus, + /// An existing design changed whether a specific stain is applied. Data is the slot of the equipment [EquipSlot]. ApplyStain, diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index a0a341a..c3829fa 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -179,8 +179,7 @@ public sealed class DesignQuickBar : Window, IDisposable return; } - var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags(); - using var _ = design!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters); + using var _ = design!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks); } diff --git a/Glamourer/Gui/Equipment/BonusDrawData.cs b/Glamourer/Gui/Equipment/BonusDrawData.cs new file mode 100644 index 0000000..d2a6b2e --- /dev/null +++ b/Glamourer/Gui/Equipment/BonusDrawData.cs @@ -0,0 +1,57 @@ +using Glamourer.Designs; +using Glamourer.State; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; + +namespace Glamourer.Gui.Equipment; + +public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) +{ + private IDesignEditor _editor; + private object _object; + public readonly BonusItemFlag Slot = slot; + public bool Locked; + public bool DisplayApplication; + public bool AllowRevert; + + public readonly bool IsDesign + => _object is Design; + + public readonly bool IsState + => _object is ActorState; + + public readonly void SetItem(BonusItem item) + => _editor.ChangeBonusItem(_object, Slot, item, ApplySettings.Manual); + + public readonly void SetApplyItem(bool value) + { + var manager = (DesignManager)_editor; + var design = (Design)_object; + manager.ChangeApplyBonusItem(design, Slot, value); + } + + public BonusItem CurrentItem = designData.BonusItem(slot); + public BonusItem GameItem = default; + public bool CurrentApply; + + public static BonusDrawData FromDesign(DesignManager manager, Design design, BonusItemFlag slot) + => new(slot, design.DesignData) + { + _editor = manager, + _object = design, + CurrentApply = design.DoApplyBonusItem(slot), + Locked = design.WriteProtected(), + DisplayApplication = true, + }; + + public static BonusDrawData FromState(StateManager manager, ActorState state, BonusItemFlag slot) + => new(slot, state.ModelData) + { + _editor = manager, + _object = state, + Locked = state.IsLocked, + DisplayApplication = false, + GameItem = state.BaseData.BonusItem(slot), + AllowRevert = true, + }; +} diff --git a/Glamourer/Gui/Equipment/BonusItemCombo.cs b/Glamourer/Gui/Equipment/BonusItemCombo.cs new file mode 100644 index 0000000..ae8bf19 --- /dev/null +++ b/Glamourer/Gui/Equipment/BonusItemCombo.cs @@ -0,0 +1,123 @@ +using Dalamud.Plugin.Services; +using Glamourer.Services; +using Glamourer.Unlocks; +using ImGuiNET; +using Lumina.Excel.GeneratedSheets; +using OtterGui; +using OtterGui.Classes; +using OtterGui.Log; +using OtterGui.Raii; +using OtterGui.Widgets; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; + +namespace Glamourer.Gui.Equipment; + +public sealed class BonusItemCombo : FilterComboCache +{ + private readonly FavoriteManager _favorites; + public readonly string Label; + private BonusItemId _currentItem; + private float _innerWidth; + + public PrimaryId CustomSetId { get; private set; } + public Variant CustomVariant { get; private set; } + + public BonusItemCombo(IDataManager gameData, ItemManager items, BonusItemFlag slot, Logger log, FavoriteManager favorites) + : base(() => GetItems(favorites, items, slot), MouseWheelType.Control, log) + { + _favorites = favorites; + Label = GetLabel(gameData, slot); + _currentItem = 0; + SearchByParts = true; + } + + protected override void DrawList(float width, float itemHeight) + { + base.DrawList(width, itemHeight); + if (NewSelection != null && Items.Count > NewSelection.Value) + CurrentSelection = Items[NewSelection.Value]; + } + + protected override int UpdateCurrentSelected(int currentSelected) + { + if (CurrentSelection.Id == _currentItem) + return currentSelected; + + CurrentSelectionIdx = Items.IndexOf(i => i.Id == _currentItem); + CurrentSelection = CurrentSelectionIdx >= 0 ? Items[CurrentSelectionIdx] : default; + return base.UpdateCurrentSelected(CurrentSelectionIdx); + } + + public bool Draw(string previewName, BonusItemId previewIdx, float width, float innerWidth) + { + _innerWidth = innerWidth; + _currentItem = previewIdx; + CustomVariant = 0; + return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()); + } + + protected override float GetFilterWidth() + => _innerWidth - 2 * ImGui.GetStyle().FramePadding.X; + + protected override bool DrawSelectable(int globalIdx, bool selected) + { + var obj = Items[globalIdx]; + var name = ToString(obj); + if (UiHelpers.DrawFavoriteStar(_favorites, obj) && CurrentSelectionIdx == globalIdx) + { + CurrentSelectionIdx = -1; + _currentItem = obj.Id; + CurrentSelection = default; + } + + ImGui.SameLine(); + var ret = ImGui.Selectable(name, selected); + ImGui.SameLine(); + using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); + ImGuiUtil.RightAlign($"({obj.ModelId.Id}-{obj.Variant.Id})"); + return ret; + } + + protected override bool IsVisible(int globalIndex, LowerString filter) + => base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].ModelId.Id.ToString()); + + protected override string ToString(BonusItem obj) + => obj.Name; + + private static string GetLabel(IDataManager gameData, BonusItemFlag slot) + { + var sheet = gameData.GetExcelSheet()!; + + return slot switch + { + BonusItemFlag.Glasses => sheet.GetRow(16050)?.Text.ToString() ?? "Facewear", + BonusItemFlag.UnkSlot => sheet.GetRow(16051)?.Text.ToString() ?? "Facewear", + + _ => string.Empty, + }; + } + + private static List GetItems(FavoriteManager favorites, ItemManager items, BonusItemFlag slot) + { + var nothing = BonusItem.Empty(slot); + if (slot is not BonusItemFlag.Glasses) + return [nothing]; + + return items.DictBonusItems.Values.OrderByDescending(favorites.Contains).ThenBy(i => i.Id.Id).Prepend(nothing).ToList(); + } + + protected override void OnClosePopup() + { + // If holding control while the popup closes, try to parse the input as a full pair of set id and variant, and set a custom item for that. + if (!ImGui.GetIO().KeyCtrl) + return; + + var split = Filter.Text.Split('-', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + if (split.Length != 2 || !ushort.TryParse(split[0], out var setId) || !byte.TryParse(split[1], out var variant)) + return; + + CustomSetId = setId; + CustomVariant = variant; + } +} diff --git a/Glamourer/Gui/Equipment/EquipDrawData.cs b/Glamourer/Gui/Equipment/EquipDrawData.cs index 58f7efc..8058169 100644 --- a/Glamourer/Gui/Equipment/EquipDrawData.cs +++ b/Glamourer/Gui/Equipment/EquipDrawData.cs @@ -72,4 +72,4 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) GameStains = state.BaseData.Stain(slot), AllowRevert = true, }; -} +} \ No newline at end of file diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 53e8ed8..afd3fe5 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -24,6 +24,7 @@ public class EquipmentDrawer private readonly GlamourerColorCombo _stainCombo; private readonly DictStain _stainData; private readonly ItemCombo[] _itemCombo; + private readonly BonusItemCombo[] _bonusItemCombo; private readonly Dictionary _weaponCombo; private readonly CodeService _codes; private readonly TextureService _textures; @@ -37,16 +38,17 @@ public class EquipmentDrawer public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, CodeService codes, TextureService textures, Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes) { - _items = items; - _codes = codes; - _textures = textures; - _config = config; - _gPose = gPose; - _advancedDyes = advancedDyes; - _stainData = items.Stains; - _stainCombo = new GlamourerColorCombo(DefaultWidth - 20, _stainData, favorites); - _itemCombo = EquipSlotExtensions.EqdpSlots.Select(e => new ItemCombo(gameData, items, e, Glamourer.Log, favorites)).ToArray(); - _weaponCombo = new Dictionary(FullEquipTypeExtensions.WeaponTypes.Count * 2); + _items = items; + _codes = codes; + _textures = textures; + _config = config; + _gPose = gPose; + _advancedDyes = advancedDyes; + _stainData = items.Stains; + _stainCombo = new GlamourerColorCombo(DefaultWidth - 20, _stainData, favorites); + _itemCombo = EquipSlotExtensions.EqdpSlots.Select(e => new ItemCombo(gameData, items, e, Glamourer.Log, favorites)).ToArray(); + _bonusItemCombo = BonusExtensions.AllFlags.Select(f => new BonusItemCombo(gameData, items, f, Glamourer.Log, favorites)).ToArray(); + _weaponCombo = new Dictionary(FullEquipTypeExtensions.WeaponTypes.Count * 2); foreach (var type in Enum.GetValues()) { if (type.ToSlot() is EquipSlot.MainHand) @@ -100,6 +102,21 @@ public class EquipmentDrawer DrawEquipNormal(equipDrawData); } + public void DrawBonusItem(BonusDrawData bonusDrawData) + { + if (_config.HideApplyCheckmarks) + bonusDrawData.DisplayApplication = false; + + using var id = ImRaii.PushId(100 + (int)bonusDrawData.Slot); + var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; + using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); + + if (_config.SmallEquip) + DrawBonusItemSmall(bonusDrawData); + else + DrawBonusItemNormal(bonusDrawData); + } + public void DrawWeapons(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) { if (mainhand.CurrentItem.PrimaryId.Id == 0) @@ -302,6 +319,25 @@ public class EquipmentDrawer ImGui.TextUnformatted(label); } + private void DrawBonusItemSmall(in BonusDrawData bonusDrawData) + { + ImGui.Dummy(new Vector2(StainId.NumStains * ImUtf8.FrameHeight + (StainId.NumStains - 1) * ImUtf8.ItemSpacing.X, ImUtf8.FrameHeight)); + ImGui.SameLine(); + DrawBonusItem(bonusDrawData, out var label, true, false, false); + if (bonusDrawData.DisplayApplication) + { + ImGui.SameLine(); + DrawApply(bonusDrawData); + } + else if (bonusDrawData.IsState) + { + _advancedDyes.DrawButton(bonusDrawData.Slot); + } + + ImGui.SameLine(); + ImGui.TextUnformatted(label); + } + private void DrawWeaponsSmall(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) { DrawStain(mainhand, true); @@ -382,6 +418,27 @@ public class EquipmentDrawer } } + private void DrawBonusItemNormal(in BonusDrawData bonusDrawData) + { + ImGui.Dummy(_iconSize with { Y = ImUtf8.FrameHeight }); + var right = ImGui.IsItemClicked(ImGuiMouseButton.Right); + var left = ImGui.IsItemClicked(ImGuiMouseButton.Left); + ImGui.SameLine(); + DrawBonusItem(bonusDrawData, out var label, false, right, left); + if (bonusDrawData.DisplayApplication) + { + ImGui.SameLine(); + DrawApply(bonusDrawData); + } + else if (bonusDrawData.IsState) + { + _advancedDyes.DrawButton(bonusDrawData.Slot); + } + + ImGui.SameLine(); + ImGui.TextUnformatted(label); + } + private void DrawWeaponsNormal(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) { using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, @@ -491,6 +548,25 @@ public class EquipmentDrawer data.SetItem(item); } + private void DrawBonusItem(in BonusDrawData data, out string label, bool small, bool clear, bool open) + { + var combo = _bonusItemCombo[data.Slot.ToIndex()]; + label = combo.Label; + if (!data.Locked && open) + UiHelpers.OpenCombo($"##{combo.Label}"); + + using var disabled = ImRaii.Disabled(data.Locked); + var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, + _requiredComboWidth); + if (change) + data.SetItem(combo.CurrentSelection); + else if (combo.CustomVariant.Id > 0) + data.SetItem(_items.Identify(data.Slot, combo.CustomSetId, combo.CustomVariant)); + + if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, BonusItem.Empty(data.Slot), out var item)) + data.SetItem(item); + } + private static bool ResetOrClear(bool locked, bool clicked, bool allowRevert, bool allowClear, in T currentItem, in T revertItem, in T clearItem, out T? item) where T : IEquatable { @@ -590,6 +666,13 @@ public class EquipmentDrawer data.SetApplyItem(enabled); } + private static void DrawApply(in BonusDrawData data) + { + if (UiHelpers.DrawCheckbox($"##apply{data.Slot}", "Apply this bonus item when applying the Design.", data.CurrentApply, out var enabled, + data.Locked)) + data.SetApplyItem(enabled); + } + private static void DrawApplyStain(in EquipDrawData data) { if (UiHelpers.DrawCheckbox($"##applyStain{data.Slot}", "Apply this dye to the item when applying the Design.", data.CurrentApplyStain, diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 232541e..3160bcb 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -46,6 +46,9 @@ public sealed unsafe class AdvancedDyePopup( public void DrawButton(EquipSlot slot) => DrawButton(MaterialValueIndex.FromSlot(slot)); + public void DrawButton(BonusItemFlag slot) + => DrawButton(MaterialValueIndex.FromSlot(slot)); + private void DrawButton(MaterialValueIndex index) { if (!config.UseAdvancedDyes) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 5218581..4074574 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -215,6 +215,12 @@ public class ActorPanel var offhand = EquipDrawData.FromState(_stateManager, _state, EquipSlot.OffHand); _equipmentDrawer.DrawWeapons(mainhand, offhand, GameMain.IsInGPose()); + foreach (var slot in BonusExtensions.AllFlags) + { + var data = BonusDrawData.FromState(_stateManager, _state!, slot); + _equipmentDrawer.DrawBonusItem(data); + } + ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); DrawEquipmentMetaToggles(); ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 7da95a3..8d52a76 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -277,13 +277,13 @@ public class SetPanel( var size = new Vector2(ImGui.GetFrameHeight()); size.X += ImGuiHelpers.GlobalScale; - var (equipFlags, customizeFlags, _, _, _) = design.ApplyWhat(); + var collection = design.ApplyWhat(); var sb = new StringBuilder(); var designData = design.Design.GetDesignData(default); foreach (var slot in EquipSlotExtensions.EqdpSlots.Append(EquipSlot.MainHand).Append(EquipSlot.OffHand)) { var flag = slot.ToFlag(); - if (!equipFlags.HasFlag(flag)) + if (!collection.Equip.HasFlag(flag)) continue; var item = designData.Item(slot); @@ -308,7 +308,7 @@ public class SetPanel( foreach (var type in CustomizationExtensions.All) { var flag = type.ToFlag(); - if (!customizeFlags.HasFlag(flag)) + if (!collection.Customize.HasFlag(flag)) continue; if (flag.RequiresRedraw()) diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs index 85b4010..b562ecf 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs @@ -25,7 +25,7 @@ public class DesignManagerPanel(DesignManager _designManager, DesignFileSystem _ continue; DrawDesign(design, _designFileSystem); - var base64 = DesignBase64Migration.CreateOldBase64(design.DesignData, design.ApplyEquip, design.ApplyCustomizeRaw, design.ApplyMeta, + var base64 = DesignBase64Migration.CreateOldBase64(design.DesignData, design.Application.Equip, design.Application.Customize, design.Application.Meta, design.WriteProtected()); using var font = ImRaii.PushFont(UiBuilder.MonoFont); ImGuiUtil.TextWrapped(base64); diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index ff9c2b8..394bd7f 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -112,11 +112,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer public DesignBase CreateDesign(in MirageManager.GlamourPlate plate) { var design = _design.CreateTemporary(); - design.ApplyCustomize = 0; - design.ApplyCrest = 0; - design.ApplyMeta = 0; - design.ApplyParameters = 0; - design.ApplyEquip = 0; + design.Application = ApplicationCollection.None; foreach (var (slot, index) in EquipSlotExtensions.FullSlots.WithIndex()) { var itemId = plate.ItemIds[index]; @@ -129,7 +125,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer design.GetDesignDataRef().SetItem(slot, item); design.GetDesignDataRef().SetStain(slot, StainIds.FromGlamourPlate(plate, index)); - design.ApplyEquip |= slot.ToBothFlags(); + design.Application.Equip |= slot.ToBothFlags(); } return design; diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index dd1c125..7307f22 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -21,7 +21,7 @@ public unsafe class ModelEvaluationPanel( UpdateSlotService _updateSlotService, ChangeCustomizeService _changeCustomizeService, CrestService _crestService, - DictGlasses _glasses) : IGameDataDrawer + DictBonusItems bonusItems) : IGameDataDrawer { public string Label => "Model Evaluation"; @@ -57,6 +57,16 @@ public unsafe class ModelEvaluationPanel( ImGui.TextUnformatted($"Transformation Id: {actor.AsCharacter->CharacterData.TransformationId}"); if (actor.AsCharacter->CharacterData.ModelCharaId_2 != -1) ImGui.TextUnformatted($"ModelChara2 {actor.AsCharacter->CharacterData.ModelCharaId_2}"); + + ImGuiUtil.DrawTableColumn("Character Mode"); + ImGuiUtil.DrawTableColumn($"{actor.AsCharacter->Mode}"); + ImGui.TableNextColumn(); + ImGui.TableNextColumn(); + + ImGuiUtil.DrawTableColumn("Animation"); + ImGuiUtil.DrawTableColumn($"{((ushort*)&actor.AsCharacter->Timeline)[0x78]}"); + ImGui.TableNextColumn(); + ImGui.TableNextColumn(); } ImGuiUtil.DrawTableColumn("Mainhand"); @@ -226,7 +236,7 @@ public unsafe class ModelEvaluationPanel( _updateSlotService.UpdateEquipSlot(model, slot, actor.GetArmor(slot)); } - foreach (var slot in BonusSlotExtensions.AllFlags) + foreach (var slot in BonusExtensions.AllFlags) { using var id2 = ImRaii.PushId((int)slot.ToModelIndex()); ImGuiUtil.DrawTableColumn(slot.ToName()); @@ -236,9 +246,9 @@ public unsafe class ModelEvaluationPanel( } else { - var glassesId = actor.GetBonusSlot(slot); - if (_glasses.TryGetValue(glassesId, out var glasses)) - ImGuiUtil.DrawTableColumn($"{glasses.Id.Id},{glasses.Variant.Id} ({glassesId})"); + var glassesId = actor.GetBonusItem(slot); + if (bonusItems.TryGetValue(glassesId, out var glasses)) + ImGuiUtil.DrawTableColumn($"{glasses.ModelId.Id},{glasses.Variant.Id} ({glassesId})"); else ImGuiUtil.DrawTableColumn($"{glassesId}"); } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 50fd936..b20e00d 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -112,6 +112,13 @@ public class DesignPanel var mainhand = EquipDrawData.FromDesign(_manager, _selector.Selected!, EquipSlot.MainHand); var offhand = EquipDrawData.FromDesign(_manager, _selector.Selected!, EquipSlot.OffHand); _equipmentDrawer.DrawWeapons(mainhand, offhand, true); + + foreach (var slot in BonusExtensions.AllFlags) + { + var data = BonusDrawData.FromDesign(_manager, _selector.Selected!, slot); + _equipmentDrawer.DrawBonusItem(data); + } + ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); DrawEquipmentMetaToggles(); ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); @@ -149,7 +156,7 @@ public class DesignPanel if (!h) return; - if (_customizationDrawer.Draw(_selector.Selected!.DesignData.Customize, _selector.Selected.ApplyCustomizeRaw, + if (_customizationDrawer.Draw(_selector.Selected!.DesignData.Customize, _selector.Selected.Application.Customize, _selector.Selected!.WriteProtected(), false)) foreach (var idx in Enum.GetValues()) { @@ -224,7 +231,7 @@ public class DesignPanel private void DrawCrestApplication() { using var id = ImRaii.PushId("Crests"); - var flags = (uint)_selector.Selected!.ApplyCrest; + var flags = (uint)_selector.Selected!.Application.Crest; var bigChange = ImGui.CheckboxFlags("Apply All Crests", ref flags, (uint)CrestExtensions.AllRelevant); foreach (var flag in CrestExtensions.AllRelevantSet) { @@ -255,7 +262,7 @@ public class DesignPanel { void ApplyEquip(string label, EquipFlag allFlags, bool stain, IEnumerable slots) { - var flags = (uint)(allFlags & _selector.Selected!.ApplyEquip); + var flags = (uint)(allFlags & _selector.Selected!.Application.Equip); using var id = ImRaii.PushId(label); var bigChange = ImGui.CheckboxFlags($"Apply All {label}", ref flags, (uint)allFlags); if (stain) @@ -302,7 +309,7 @@ public class DesignPanel { using var id = ImRaii.PushId("Meta"); const uint all = (uint)MetaExtensions.All; - var flags = (uint)_selector.Selected!.ApplyMeta; + var flags = (uint)_selector.Selected!.Application.Meta; var bigChange = ImGui.CheckboxFlags("Apply All Meta Changes", ref flags, all); var labels = new[] @@ -324,7 +331,7 @@ public class DesignPanel private void DrawParameterApplication() { using var id = ImRaii.PushId("Parameter"); - var flags = (uint)_selector.Selected!.ApplyParameters; + var flags = (uint)_selector.Selected!.Application.Parameters; var bigChange = ImGui.CheckboxFlags("Apply All Customize Parameters", ref flags, (uint)CustomizeParameterExtensions.All); foreach (var flag in CustomizeParameterExtensions.AllFlags) { @@ -408,8 +415,7 @@ public class DesignPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { - var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags(); - using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters); + using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks); } } @@ -427,8 +433,7 @@ public class DesignPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { - var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags(); - using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters); + using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks); } } diff --git a/Glamourer/Gui/UiHelpers.cs b/Glamourer/Gui/UiHelpers.cs index 7e22ff1..88f51f5 100644 --- a/Glamourer/Gui/UiHelpers.cs +++ b/Glamourer/Gui/UiHelpers.cs @@ -1,6 +1,5 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; -using Glamourer.GameData; using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; @@ -98,15 +97,6 @@ public static class UiHelpers return (currentValue != newValue, currentApply != newApply); } - public static (EquipFlag, CustomizeFlag, CrestFlag, CustomizeParameterFlag) ConvertKeysToFlags() - => (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch - { - (false, false) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.All, CustomizeParameterExtensions.All), - (true, true) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.All, CustomizeParameterExtensions.All), - (true, false) => (EquipFlagExtensions.All, (CustomizeFlag)0, CrestExtensions.All, 0), - (false, true) => ((EquipFlag)0, CustomizeFlagExtensions.AllRelevant, 0, CustomizeParameterExtensions.All), - }; - public static (bool, bool) ConvertKeysToBool() => (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch { @@ -126,16 +116,36 @@ public static class UiHelpers using var c = ImRaii.PushColor(ImGuiCol.Text, hovering ? ColorId.FavoriteStarHovered.Value() : favorite ? ColorId.FavoriteStarOn.Value() : ColorId.FavoriteStarOff.Value()); ImGui.TextUnformatted(FontAwesomeIcon.Star.ToIconString()); - if (ImGui.IsItemClicked()) - { - if (favorite) - favorites.Remove(item); - else - favorites.TryAdd(item); - return true; - } + if (!ImGui.IsItemClicked()) + return false; + + if (favorite) + favorites.Remove(item); + else + favorites.TryAdd(item); + return true; + + } + + public static bool DrawFavoriteStar(FavoriteManager favorites, BonusItem item) + { + var favorite = favorites.Contains(item); + var hovering = ImGui.IsMouseHoveringRect(ImGui.GetCursorScreenPos(), + ImGui.GetCursorScreenPos() + new Vector2(ImGui.GetTextLineHeight())); + + using var font = ImRaii.PushFont(UiBuilder.IconFont); + using var c = ImRaii.PushColor(ImGuiCol.Text, + hovering ? ColorId.FavoriteStarHovered.Value() : favorite ? ColorId.FavoriteStarOn.Value() : ColorId.FavoriteStarOff.Value()); + ImGui.TextUnformatted(FontAwesomeIcon.Star.ToIconString()); + if (!ImGui.IsItemClicked()) + return false; + + if (favorite) + favorites.Remove(item); + else + favorites.TryAdd(item); + return true; - return false; } public static bool DrawFavoriteStar(FavoriteManager favorites, StainId stain) @@ -149,15 +159,14 @@ public static class UiHelpers hovering ? ColorId.FavoriteStarHovered.Value() : favorite ? ColorId.FavoriteStarOn.Value() : ColorId.FavoriteStarOff.Value()); ImGui.AlignTextToFramePadding(); ImGui.TextUnformatted(FontAwesomeIcon.Star.ToIconString()); - if (ImGui.IsItemClicked()) - { - if (favorite) - favorites.Remove(stain); - else - favorites.TryAdd(stain); - return true; - } + if (!ImGui.IsItemClicked()) + return false; + + if (favorite) + favorites.Remove(stain); + else + favorites.TryAdd(stain); + return true; - return false; } -} +} \ No newline at end of file diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 2096bc7..254675e 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -42,6 +42,12 @@ public readonly record struct MaterialValueIndex( return Invalid; } + public static MaterialValueIndex FromSlot(BonusItemFlag slot) + { + var idx = slot.ToIndex(); + return idx > 2 ? Invalid : new MaterialValueIndex(DrawObjectType.Human, (byte)(idx + 16), 0, 0); + } + public EquipSlot ToEquipSlot() => DrawObject switch { diff --git a/Glamourer/Interop/PalettePlus/PaletteImport.cs b/Glamourer/Interop/PalettePlus/PaletteImport.cs index 93c3fa2..4887255 100644 --- a/Glamourer/Interop/PalettePlus/PaletteImport.cs +++ b/Glamourer/Interop/PalettePlus/PaletteImport.cs @@ -37,17 +37,13 @@ public class PaletteImport(IDalamudPluginInterface pluginInterface, DesignManage } var design = designManager.CreateEmpty(fullPath, true); - design.ApplyCustomize = 0; - design.ApplyEquip = 0; - design.ApplyCrest = 0; - designManager.ChangeApplyMeta(design, MetaIndex.VisorState, false); - designManager.ChangeApplyMeta(design, MetaIndex.HatState, false); - designManager.ChangeApplyMeta(design, MetaIndex.WeaponState, false); + design.Application = ApplicationCollection.None; foreach (var flag in flags.Iterate()) { designManager.ChangeApplyParameter(design, flag, true); designManager.ChangeCustomizeParameter(design, flag, palette[flag]); } + Glamourer.Log.Information($"Added design for palette {name} at {fullPath}."); } } diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 2be31cf..55db36d 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -14,14 +14,14 @@ public unsafe class UpdateSlotService : IDisposable { public readonly EquipSlotUpdating EquipSlotUpdatingEvent; public readonly BonusSlotUpdating BonusSlotUpdatingEvent; - private readonly DictGlasses _glasses; + private readonly DictBonusItems _bonusItems; public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, IGameInteropProvider interop, - DictGlasses glasses) + DictBonusItems bonusItems) { EquipSlotUpdatingEvent = equipSlotUpdating; BonusSlotUpdatingEvent = bonusSlotUpdating; - _glasses = glasses; + _bonusItems = bonusItems; interop.InitializeFromAttributes(this); _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); @@ -41,7 +41,7 @@ public unsafe class UpdateSlotService : IDisposable FlagSlotForUpdateInterop(drawObject, slot, data); } - public void UpdateBonusSlot(Model drawObject, BonusEquipFlag slot, CharacterArmor data) + public void UpdateBonusSlot(Model drawObject, BonusItemFlag slot, CharacterArmor data) { if (!drawObject.IsCharacterBase) return; @@ -53,13 +53,13 @@ public unsafe class UpdateSlotService : IDisposable _flagBonusSlotForUpdateHook.Original(drawObject.Address, index, &data); } - public void UpdateGlasses(Model drawObject, GlassesId id) + public void UpdateGlasses(Model drawObject, BonusItemId id) { - if (!_glasses.TryGetValue(id, out var glasses)) + if (!_bonusItems.TryGetValue(id, out var glasses)) return; - var armor = new CharacterArmor(glasses.Id, glasses.Variant, StainIds.None); - _flagBonusSlotForUpdateHook.Original(drawObject.Address, BonusEquipFlag.Glasses.ToIndex(), &armor); + var armor = new CharacterArmor(glasses.ModelId, glasses.Variant, StainIds.None); + _flagBonusSlotForUpdateHook.Original(drawObject.Address, BonusItemFlag.Glasses.ToIndex(), &armor); } public void UpdateArmor(Model drawObject, EquipSlot slot, CharacterArmor armor, StainIds stains) diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index c5f537f..7b83199 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -20,12 +20,13 @@ public class ItemManager public readonly ExcelSheet ItemSheet; public readonly DictStain Stains; public readonly ItemData ItemData; + public readonly DictBonusItems DictBonusItems; public readonly RestrictedGear RestrictedGear; public readonly EquipItem DefaultSword; public ItemManager(Configuration config, IDataManager gameData, ObjectIdentification objectIdentification, - ItemData itemData, DictStain stains, RestrictedGear restrictedGear) + ItemData itemData, DictStain stains, RestrictedGear restrictedGear, DictBonusItems dictBonusItems) { _config = config; ItemSheet = gameData.GetExcelSheet()!; @@ -33,6 +34,7 @@ public class ItemManager ItemData = itemData; Stains = stains; RestrictedGear = restrictedGear; + DictBonusItems = dictBonusItems; DefaultSword = EquipItem.FromMainhand(ItemSheet.GetRow(1601)!); // Weathered Shortsword } @@ -124,6 +126,22 @@ public class ItemManager } } + public BonusItem Identify(BonusItemFlag slot, PrimaryId id, Variant variant) + { + var index = slot.ToIndex(); + if (index == uint.MaxValue) + return new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot); + + if (id.Id == 0) + return BonusItem.Empty(slot); + + return ObjectIdentification.Identify(id, variant, slot) + .FirstOrDefault(new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot)); + } + + public BonusItem Resolve(BonusItemFlag slot, BonusItemId id) + => IsBonusItemValid(slot, id, out var item) ? item : new BonusItem($"Invalid ({id.Id})", 0, id, 0, 0, slot); + /// Return the default offhand for a given mainhand, that is for both handed weapons, return the correct offhand part, and for everything else Nothing. public EquipItem GetDefaultOffhand(EquipItem mainhand) { @@ -161,6 +179,18 @@ public class ItemManager return item.Valid; } + /// Returns whether a bonus item id represents a valid item for a slot and gives the item. + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] + public bool IsBonusItemValid(BonusItemFlag slot, BonusItemId itemId, out BonusItem item) + { + if (itemId.Id != 0) + return DictBonusItems.TryGetValue(itemId, out item) && slot == item.Slot; + + item = BonusItem.Empty(slot); + return true; + } + + /// /// Check whether an item id resolves to an existing item of the correct slot (which should not be weapons.) /// The returned item is either the resolved correct item, or the Nothing item for that slot. diff --git a/Glamourer/State/InternalStateEditor.cs b/Glamourer/State/InternalStateEditor.cs index 17072e7..71af0aa 100644 --- a/Glamourer/State/InternalStateEditor.cs +++ b/Glamourer/State/InternalStateEditor.cs @@ -151,6 +151,18 @@ public class InternalStateEditor( return true; } + /// Change a single bonus item. + public bool ChangeBonusItem(ActorState state, BonusItemFlag slot, BonusItem item, StateSource source, out BonusItem oldItem, uint key = 0) + { + oldItem = state.ModelData.BonusItem(slot); + if (!state.CanUnlock(key)) + return false; + + state.ModelData.SetBonusItem(slot, item); + state.Sources[slot] = source; + return true; + } + /// Change a single piece of equipment including stain. public bool ChangeEquip(ActorState state, EquipSlot slot, EquipItem item, StainIds stains, StateSource source, out EquipItem oldItem, out StainIds oldStains, uint key = 0) diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 5a6c21e..a4a1df4 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -125,6 +125,33 @@ public class StateApplier( return data; } + public void ChangeBonusItem(ActorData data, BonusItemFlag slot, PrimaryId id, Variant variant) + { + var item = new CharacterArmor(id, variant, StainIds.None); + foreach (var actor in data.Objects.Where(a => a.IsCharacter)) + { + var mdl = actor.Model; + if (!mdl.IsHuman) + continue; + + _updateSlot.UpdateBonusSlot(actor.Model, slot, item); + } + } + + /// + public ActorData ChangeBonusItem(ActorState state, BonusItemFlag slot, bool apply) + { + // If the source is not IPC we do not want to apply restrictions. + var data = GetData(state); + if (apply) + { + var item = state.ModelData.BonusItem(slot); + ChangeBonusItem(data, slot, item.ModelId, item.Variant); + } + + return data; + } + /// /// Change the stain of a single piece of armor or weapon. diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index dccb283..c39fd31 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -89,6 +89,18 @@ public class StateEditor( StateChanged.Invoke(type, settings.Source, state, actors, (old, item, slot)); } + public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) + { + var state = (ActorState)data; + if (!Editor.ChangeBonusItem(state, slot, item, settings.Source, out var old, settings.Key)) + return; + + var actors = Applier.ChangeBonusItem(state, slot, settings.Source.RequiresChange()); + Glamourer.Log.Verbose( + $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.Id}) to {item.Name} ({item.Id}). [Affecting {actors.ToLazyString("nothing")}.]"); + StateChanged.Invoke(StateChangeType.BonusItem, settings.Source, state, actors, (old, item, slot)); + } + /// public void ChangeEquip(object data, EquipSlot slot, EquipItem? item, StainIds? stains, ApplySettings settings) { @@ -226,7 +238,7 @@ public class StateEditor( out _, settings.Key); } - var customizeFlags = mergedDesign.Design.ApplyCustomizeRaw; + var customizeFlags = mergedDesign.Design.Application.Customize; if (mergedDesign.Design.DoApplyCustomize(CustomizeIndex.Clan)) customizeFlags |= CustomizeFlag.Race; @@ -245,7 +257,7 @@ public class StateEditor( state.Sources[parameter] = StateSource.Game; } - foreach (var parameter in mergedDesign.Design.ApplyParameters.Iterate()) + foreach (var parameter in mergedDesign.Design.Application.Parameters.Iterate()) { if (settings.RespectManual && state.Sources[parameter].IsManual()) continue; @@ -273,6 +285,13 @@ public class StateEditor( Source(slot.ToState(true)), out _, settings.Key); } + foreach (var slot in BonusExtensions.AllFlags) + { + if (mergedDesign.Design.DoApplyBonusItem(slot)) + if (!settings.RespectManual || !state.Sources[slot].IsManual()) + Editor.ChangeBonusItem(state, slot, mergedDesign.Design.DesignData.BonusItem(slot), Source(slot), out _, settings.Key); + } + foreach (var weaponSlot in EquipSlotExtensions.WeaponSlots) { if (mergedDesign.Design.DoApplyStain(weaponSlot)) diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index 28cc722..a569499 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -38,6 +38,13 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators Invalid, }; + public static implicit operator StateIndex(BonusItemFlag flag) + => flag switch + { + BonusItemFlag.Glasses => new StateIndex(BonusItemGlasses), + _ => Invalid, + }; + public static implicit operator StateIndex(CustomizeIndex index) => index switch { @@ -198,23 +205,13 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators All => Enumerable.Range(0, Size - 1).Select(i => new StateIndex(i)); - public bool GetApply(DesignBase data) - => GetFlag() switch - { - EquipFlag e => data.ApplyEquip.HasFlag(e), - CustomizeFlag c => data.ApplyCustomize.HasFlag(c), - MetaFlag m => data.ApplyMeta.HasFlag(m), - CrestFlag c => data.ApplyCrest.HasFlag(c), - CustomizeParameterFlag c => data.ApplyParameters.HasFlag(c), - bool v => v, - _ => false, - }; - public string ToName() => GetFlag() switch { @@ -223,6 +220,7 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators m.ToIndex().ToName(), CrestFlag c => c.ToLabel(), CustomizeParameterFlag c => c.ToName(), + BonusItemFlag b => b.ToName(), bool v => "Model ID", _ => "Unknown", }; @@ -317,6 +315,8 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators CustomizeParameterFlag.FacePaintUvOffset, ParamDecalColor => CustomizeParameterFlag.DecalColor, + BonusItemGlasses => BonusItemFlag.Glasses, + _ => -1, }; @@ -411,6 +411,8 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators data.Parameters[CustomizeParameterFlag.FacePaintUvOffset], ParamDecalColor => data.Parameters[CustomizeParameterFlag.DecalColor], + BonusItemGlasses => data.BonusItem(BonusItemFlag.Glasses), + _ => null, }; } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 72b3122..f82b2fc 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -32,7 +32,8 @@ public class StateListener : IDisposable private readonly ItemManager _items; private readonly CustomizeService _customizations; private readonly PenumbraService _penumbra; - private readonly EquipSlotUpdating _equipSlotUpdating; + private readonly EquipSlotUpdating _equipSlotUpdating; + private readonly BonusSlotUpdating _bonusSlotUpdating; private readonly WeaponLoading _weaponLoading; private readonly HeadGearVisibilityChanged _headGearVisibility; private readonly VisorStateChanged _visorState; @@ -52,17 +53,18 @@ public class StateListener : IDisposable private CharacterWeapon _lastFistOffhand = CharacterWeapon.Empty; public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorManager actors, Configuration config, - EquipSlotUpdating equipSlotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, - HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, - StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, GPoseService gPose, - ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, CrestService crestService) + EquipSlotUpdating equipSlotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, + WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, + FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, + GPoseService gPose, ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, + CrestService crestService, BonusSlotUpdating bonusSlotUpdating) { _manager = manager; _items = items; _penumbra = penumbra; _actors = actors; _config = config; - _equipSlotUpdating = equipSlotUpdating; + _equipSlotUpdating = equipSlotUpdating; _weaponLoading = weaponLoading; _visorState = visorState; _weaponVisibility = weaponVisibility; @@ -78,6 +80,7 @@ public class StateListener : IDisposable _customizations = customizations; _condition = condition; _crestService = crestService; + _bonusSlotUpdating = bonusSlotUpdating; Subscribe(); } @@ -227,6 +230,35 @@ public class StateListener : IDisposable (_, armor) = _items.RestrictedGear.ResolveRestricted(armor, slot, customize.Race, customize.Gender); } + private void OnBonusSlotUpdating(Model model, BonusItemFlag slot, ref CharacterArmor item, ref ulong returnValue) + { + var actor = _penumbra.GameObjectFromDrawObject(model); + if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) + return; + + if (actor.Identifier(_actors, out var identifier) + && _manager.TryGetValue(identifier, out var state)) + switch (UpdateBaseData(actor, state, slot, item)) + { + // Base data changed equipment while actors were not there. + // Update model state if not on fixed design. + case UpdateState.Change: + var apply = false; + if (!state.Sources[slot].IsFixed()) + _manager.ChangeBonusItem(state, slot, state.BaseData.BonusItem(slot), ApplySettings.Game); + else + apply = true; + if (apply) + item = state.ModelData.BonusItem(slot).ToArmor(); + break; + // Use current model data. + case UpdateState.NoChange: + item = state.ModelData.BonusItem(slot).ToArmor(); + break; + case UpdateState.Transformed: break; + } + } + private void OnMovedEquipment((EquipSlot, uint, StainIds)[] items) { _objects.Update(); @@ -403,6 +435,28 @@ public class StateListener : IDisposable } } + private UpdateState UpdateBaseData(Actor actor, ActorState state, BonusItemFlag slot, CharacterArmor item) + { + var actorItemId = actor.GetBonusItem(slot); + if (!_items.IsBonusItemValid(slot, actorItemId, out var actorItem)) + return UpdateState.NoChange; + + // The actor item does not correspond to the model item, thus the actor is transformed. + if (actorItem.ModelId != item.Set || actorItem.Variant != item.Variant) + return UpdateState.Transformed; + + var baseData = state.BaseData.BonusItem(slot); + var change = UpdateState.NoChange; + if (baseData.Id != actorItem.Id || baseData.ModelId != item.Set || baseData.Variant != item.Variant) + { + var identified = _items.Identify(slot, item.Set, item.Variant); + state.BaseData.SetBonusItem(slot, identified); + change = UpdateState.Change; + } + + return change; + } + /// Handle a full equip slot update for base data and model data. private void HandleEquipSlot(Actor actor, ActorState state, EquipSlot slot, ref CharacterArmor armor) { @@ -700,6 +754,7 @@ public class StateListener : IDisposable _penumbra.CreatingCharacterBase += OnCreatingCharacterBase; _penumbra.CreatedCharacterBase += OnCreatedCharacterBase; _equipSlotUpdating.Subscribe(OnEquipSlotUpdating, EquipSlotUpdating.Priority.StateListener); + _bonusSlotUpdating.Subscribe(OnBonusSlotUpdating, BonusSlotUpdating.Priority.StateListener); _movedEquipment.Subscribe(OnMovedEquipment, MovedEquipment.Priority.StateListener); _weaponLoading.Subscribe(OnWeaponLoading, WeaponLoading.Priority.StateListener); _visorState.Subscribe(OnVisorChange, VisorStateChanged.Priority.StateListener); @@ -716,6 +771,7 @@ public class StateListener : IDisposable _penumbra.CreatingCharacterBase -= OnCreatingCharacterBase; _penumbra.CreatedCharacterBase -= OnCreatedCharacterBase; _equipSlotUpdating.Unsubscribe(OnEquipSlotUpdating); + _bonusSlotUpdating.Unsubscribe(OnBonusSlotUpdating); _movedEquipment.Unsubscribe(OnMovedEquipment); _weaponLoading.Unsubscribe(OnWeaponLoading); _visorState.Unsubscribe(OnVisorChange); diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 92cf6e5..5033577 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -160,6 +160,13 @@ public sealed class StateManager( foreach (var slot in CrestExtensions.AllRelevantSet) ret.SetCrest(slot, CrestService.GetModelCrest(actor, slot)); + + foreach (var slot in BonusExtensions.AllFlags) + { + var data = model.GetBonus(slot); + var item = Items.Identify(slot, data.Set, data.Variant); + ret.SetBonusItem(slot, item); + } } else { @@ -181,6 +188,13 @@ public sealed class StateManager( foreach (var slot in CrestExtensions.AllRelevantSet) ret.SetCrest(slot, actor.GetCrest(slot)); + + foreach (var slot in BonusExtensions.AllFlags) + { + var id = actor.GetBonusItem(slot); + var item = Items.Resolve(slot, id); + ret.SetBonusItem(slot, item); + } } // Set the weapons regardless of source. @@ -241,6 +255,9 @@ public sealed class StateManager( state.Sources[slot, false] = StateSource.Game; } + foreach (var slot in BonusExtensions.AllFlags) + state.Sources[slot] = StateSource.Game; + foreach (var type in Enum.GetValues()) state.Sources[type] = StateSource.Game; @@ -328,6 +345,12 @@ public sealed class StateManager( state.ModelData.IsHatVisible()); } + foreach (var slot in BonusExtensions.AllFlags) + { + var item = state.ModelData.BonusItem(slot); + Applier.ChangeBonusItem(actors, slot, item.ModelId, item.Variant); + } + var mainhandActors = state.ModelData.MainhandType != state.BaseData.MainhandType ? actors.OnlyGPose() : actors; Applier.ChangeMainhand(mainhandActors, state.ModelData.Item(EquipSlot.MainHand), state.ModelData.Stain(EquipSlot.MainHand)); var offhandActors = state.ModelData.OffhandType != state.BaseData.OffhandType ? actors.OnlyGPose() : actors; @@ -364,6 +387,15 @@ public sealed class StateManager( } } + foreach (var slot in BonusExtensions.AllFlags) + { + if (state.Sources[slot] is StateSource.Fixed) + { + state.Sources[slot] = StateSource.Game; + state.ModelData.SetBonusItem(slot, state.BaseData.BonusItem(slot)); + } + } + foreach (var slot in CrestExtensions.AllRelevantSet) { if (state.Sources[slot] is StateSource.Fixed) diff --git a/Glamourer/Unlocks/FavoriteManager.cs b/Glamourer/Unlocks/FavoriteManager.cs index de22ea8..f4576c6 100644 --- a/Glamourer/Unlocks/FavoriteManager.cs +++ b/Glamourer/Unlocks/FavoriteManager.cs @@ -25,6 +25,7 @@ public class FavoriteManager : ISavable private readonly HashSet _favorites = []; private readonly HashSet _favoriteColors = []; private readonly HashSet _favoriteHairStyles = []; + private readonly HashSet _favoriteBonusItems = []; public FavoriteManager(SaveService saveService) { @@ -62,6 +63,7 @@ public class FavoriteManager : ISavable _favorites.UnionWith(load!.FavoriteItems.Select(i => (ItemId)i)); _favoriteColors.UnionWith(load!.FavoriteColors.Select(i => (StainId)i)); _favoriteHairStyles.UnionWith(load!.FavoriteHairStyles.Select(t => new FavoriteHairStyle(t))); + _favoriteBonusItems.UnionWith(load!.FavoriteBonusItems.Select(b => new BonusItemId(b))); break; default: throw new Exception($"Unknown Version {load?.Version ?? 0}"); @@ -109,6 +111,11 @@ public class FavoriteManager : ISavable foreach (var hairStyle in _favoriteHairStyles) j.WriteValue(hairStyle.ToValue()); j.WriteEndArray(); + j.WriteStartArray(); + j.WritePropertyName(nameof(LoadIntermediary.FavoriteBonusItems)); + foreach (var item in _favoriteBonusItems) + j.WriteValue(item.Id); + j.WriteEndArray(); j.WriteEndObject(); } @@ -124,9 +131,6 @@ public class FavoriteManager : ISavable return true; } - public bool TryAdd(Stain stain) - => TryAdd(stain.RowIndex); - public bool TryAdd(StainId stain) { if (stain.Id == 0 || !_favoriteColors.Add(stain)) @@ -136,6 +140,15 @@ public class FavoriteManager : ISavable return true; } + public bool TryAdd(BonusItem bonusItem) + { + if (bonusItem.Id == 0 || !_favoriteBonusItems.Add(bonusItem.Id)) + return false; + + Save(); + return true; + } + public bool TryAdd(Gender gender, SubRace race, CustomizeIndex type, CustomizeValue value) { if (!TypeAllowed(type) || !_favoriteHairStyles.Add(new FavoriteHairStyle(gender, race, type, value))) @@ -157,9 +170,6 @@ public class FavoriteManager : ISavable return true; } - public bool Remove(Stain stain) - => Remove(stain.RowIndex); - public bool Remove(StainId stain) { if (!_favoriteColors.Remove(stain)) @@ -169,6 +179,15 @@ public class FavoriteManager : ISavable return true; } + public bool Remove(BonusItem bonusItem) + { + if (!_favoriteBonusItems.Remove(bonusItem.Id)) + return false; + + Save(); + return true; + } + public bool Remove(Gender gender, SubRace race, CustomizeIndex type, CustomizeValue value) { if (!_favoriteHairStyles.Remove(new FavoriteHairStyle(gender, race, type, value))) @@ -181,23 +200,21 @@ public class FavoriteManager : ISavable public bool Contains(EquipItem item) => _favorites.Contains(item.ItemId); - public bool Contains(Stain stain) - => _favoriteColors.Contains(stain.RowIndex); - - public bool Contains(ItemId item) - => _favorites.Contains(item); - public bool Contains(StainId stain) => _favoriteColors.Contains(stain); + public bool Contains(BonusItem bonusItem) + => _favoriteBonusItems.Contains(bonusItem.Id); + public bool Contains(Gender gender, SubRace race, CustomizeIndex type, CustomizeValue value) => _favoriteHairStyles.Contains(new FavoriteHairStyle(gender, race, type, value)); private class LoadIntermediary { - public int Version = CurrentVersion; - public uint[] FavoriteItems = []; - public byte[] FavoriteColors = []; - public uint[] FavoriteHairStyles = []; + public int Version = CurrentVersion; + public uint[] FavoriteItems = []; + public byte[] FavoriteColors = []; + public uint[] FavoriteHairStyles = []; + public ushort[] FavoriteBonusItems = []; } } diff --git a/Penumbra.GameData b/Penumbra.GameData index d83303c..8928015 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit d83303ccc3ec5d7237f5da621e9c2433ad28f9e1 +Subproject commit 8928015f38f951810a9a6fbb44fb4a0cb9a712dd From 9529963aa2a8db7b6b5ac4573c237c0b563f748c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 18:19:34 +0200 Subject: [PATCH 015/401] Update other things. --- Glamourer/Designs/Design.cs | 2 + Glamourer/Designs/DesignBase.cs | 97 +++++++---- Glamourer/Designs/DesignConverter.cs | 2 +- Glamourer/Designs/DesignData.cs | 43 +++-- Glamourer/Designs/DesignEditor.cs | 14 +- Glamourer/Designs/DesignManager.cs | 2 +- Glamourer/Events/DesignChanged.cs | 5 +- Glamourer/GameData/CustomizeParameterData.cs | 95 +++++++--- Glamourer/GameData/CustomizeParameterFlag.cs | 13 +- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 12 +- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 12 +- Glamourer/Gui/Materials/ColorRowClipboard.cs | 6 +- Glamourer/Gui/Materials/MaterialDrawer.cs | 4 +- .../Gui/Tabs/DebugTab/ActiveStatePanel.cs | 4 +- .../DebugTab/AdvancedCustomizationDrawer.cs | 135 ++++++++++++++ Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs | 3 +- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 164 ++++++++++++------ Glamourer/Gui/UiHelpers.cs | 26 ++- Glamourer/Interop/Material/DirectXService.cs | 18 +- .../Material/LiveColorTablePreviewer.cs | 8 +- Glamourer/Interop/Material/MaterialManager.cs | 4 +- Glamourer/Interop/Material/MaterialService.cs | 14 +- .../Interop/Material/MaterialValueIndex.cs | 2 +- .../Interop/Material/MaterialValueManager.cs | 4 +- Glamourer/Interop/Material/PrepareColorSet.cs | 6 +- Glamourer/Interop/WeaponService.cs | 1 - Glamourer/Services/TextureService.cs | 53 ++++-- Glamourer/State/StateApplier.cs | 9 + Glamourer/State/StateEditor.cs | 2 +- Glamourer/State/StateIndex.cs | 107 +----------- Penumbra.GameData | 2 +- 31 files changed, 575 insertions(+), 294 deletions(-) create mode 100644 Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index b8dc0a2..05ee948 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -106,6 +106,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn ["Tags"] = JArray.FromObject(Tags), ["WriteProtected"] = WriteProtected(), ["Equipment"] = SerializeEquipment(), + ["Bonus"] = SerializeBonusItems(), ["Customize"] = SerializeCustomize(), ["Parameters"] = SerializeParameters(), ["Materials"] = SerializeMaterials(), @@ -171,6 +172,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn design.SetWriteProtected(json["WriteProtected"]?.ToObject() ?? false); LoadCustomize(customizations, json["Customize"], design, design.Name, true, false); LoadEquip(items, json["Equipment"], design, design.Name, true); + LoadBonus(items, design, json["Bonus"]); LoadMods(json["Mods"], design); LoadParameters(json["Parameters"], design, design.Name); LoadMaterials(json["Materials"], design, design.Name); diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index be12737..06e55d7 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -228,6 +228,7 @@ public class DesignBase { ["FileVersion"] = FileVersion, ["Equipment"] = SerializeEquipment(), + ["Bonus"] = SerializeBonusItems(), ["Customize"] = SerializeCustomize(), ["Parameters"] = SerializeParameters(), ["Materials"] = SerializeMaterials(), @@ -279,7 +280,7 @@ public class DesignBase var item = _designData.BonusItem(slot); ret[slot.ToString()] = new JObject() { - ["BonusId"] = item.ModelId.Id, + ["BonusId"] = item.Id.Id, ["Apply"] = DoApplyBonusItem(slot), }; } @@ -424,19 +425,44 @@ public class DesignBase LoadEquip(items, json["Equipment"], ret, "Temporary Design", true); LoadParameters(json["Parameters"], ret, "Temporary Design"); LoadMaterials(json["Materials"], ret, "Temporary Design"); + LoadBonus(items, ret, json["Bonus"]); return ret; } + protected static void LoadBonus(ItemManager items, DesignBase design, JToken? json) + { + if (json is not JObject obj) + { + design.Application.BonusItem = 0; + return; + } + + foreach (var slot in BonusExtensions.AllFlags) + { + var itemJson = json[slot.ToString()] as JObject; + if (itemJson == null) + { + design.Application.BonusItem &= ~slot; + design.GetDesignDataRef().SetBonusItem(slot, BonusItem.Empty(slot)); + continue; + } + + design.SetApplyBonusItem(slot, itemJson["Apply"]?.ToObject() ?? false); + var id = itemJson["BonusId"]?.ToObject() ?? 0; + var item = items.Resolve(slot, id); + design.GetDesignDataRef().SetBonusItem(slot, item); + } + } + protected static void LoadParameters(JToken? parameters, DesignBase design, string name) { if (parameters == null) { - design.Application.Parameters = 0; + design.Application.Parameters = 0; design.GetDesignDataRef().Parameters = default; return; } - foreach (var flag in CustomizeParameterExtensions.ValueFlags) { if (!TryGetToken(flag, out var token)) @@ -492,7 +518,7 @@ public class DesignBase return true; } - design.Application.Parameters &= ~flag; + design.Application.Parameters &= ~flag; design.GetDesignDataRef().Parameters[flag] = CustomizeParameterValue.Zero; return false; } @@ -523,32 +549,15 @@ public class DesignBase return; } - static (CustomItemId, StainIds, bool, bool, bool, bool) ParseItem(EquipSlot slot, JToken? item) - { - var id = item?["ItemId"]?.ToObject() ?? ItemManager.NothingId(slot).Id; - var stain = (StainId)(item?["Stain"]?.ToObject() ?? 0); - var crest = item?["Crest"]?.ToObject() ?? false; - var apply = item?["Apply"]?.ToObject() ?? false; - var applyStain = item?["ApplyStain"]?.ToObject() ?? false; - var applyCrest = item?["ApplyCrest"]?.ToObject() ?? false; - return (id, stain, crest, apply, applyStain, applyCrest); - } - - void PrintWarning(string msg) - { - if (msg.Length > 0 && name != "Temporary Design") - Glamourer.Messager.NotificationMessage($"{msg} ({name})", NotificationType.Warning); - } - foreach (var slot in EquipSlotExtensions.EqdpSlots) { - var (id, stain, crest, apply, applyStain, applyCrest) = ParseItem(slot, equip[slot.ToString()]); + var (id, stains, crest, apply, applyStain, applyCrest) = ParseItem(slot, equip[slot.ToString()]); PrintWarning(items.ValidateItem(slot, id, out var item, allowUnknown)); - PrintWarning(items.ValidateStain(stain, out stain, allowUnknown)); + PrintWarning(items.ValidateStain(stains, out stains, allowUnknown)); var crestSlot = slot.ToCrestFlag(); design._designData.SetItem(slot, item); - design._designData.SetStain(slot, stain); + design._designData.SetStain(slot, stains); design._designData.SetCrest(crestSlot, crest); design.SetApplyEquip(slot, apply); design.SetApplyStain(slot, applyStain); @@ -556,21 +565,21 @@ public class DesignBase } { - var (id, stain, crest, apply, applyStain, applyCrest) = ParseItem(EquipSlot.MainHand, equip[EquipSlot.MainHand.ToString()]); + var (id, stains, crest, apply, applyStain, applyCrest) = ParseItem(EquipSlot.MainHand, equip[EquipSlot.MainHand.ToString()]); if (id == ItemManager.NothingId(EquipSlot.MainHand)) id = items.DefaultSword.ItemId; - var (idOff, stainOff, crestOff, applyOff, applyStainOff, applyCrestOff) = + var (idOff, stainsOff, crestOff, applyOff, applyStainOff, applyCrestOff) = ParseItem(EquipSlot.OffHand, equip[EquipSlot.OffHand.ToString()]); if (id == ItemManager.NothingId(EquipSlot.OffHand)) id = ItemManager.NothingId(FullEquipType.Shield); PrintWarning(items.ValidateWeapons(id, idOff, out var main, out var off, allowUnknown)); - PrintWarning(items.ValidateStain(stain, out stain, allowUnknown)); - PrintWarning(items.ValidateStain(stainOff, out stainOff, allowUnknown)); + PrintWarning(items.ValidateStain(stains, out stains, allowUnknown)); + PrintWarning(items.ValidateStain(stainsOff, out stainsOff, allowUnknown)); design._designData.SetItem(EquipSlot.MainHand, main); design._designData.SetItem(EquipSlot.OffHand, off); - design._designData.SetStain(EquipSlot.MainHand, stain); - design._designData.SetStain(EquipSlot.OffHand, stainOff); + design._designData.SetStain(EquipSlot.MainHand, stains); + design._designData.SetStain(EquipSlot.OffHand, stainsOff); design._designData.SetCrest(CrestFlag.MainHand, crest); design._designData.SetCrest(CrestFlag.OffHand, crestOff); design.SetApplyEquip(EquipSlot.MainHand, apply); @@ -591,6 +600,24 @@ public class DesignBase metaValue = QuadBool.FromJObject(equip["Visor"], "IsToggled", "Apply", QuadBool.NullFalse); design.SetApplyMeta(MetaIndex.VisorState, metaValue.Enabled); design._designData.SetVisor(metaValue.ForcedValue); + return; + + void PrintWarning(string msg) + { + if (msg.Length > 0 && name != "Temporary Design") + Glamourer.Messager.NotificationMessage($"{msg} ({name})", NotificationType.Warning); + } + + static (CustomItemId, StainIds, bool, bool, bool, bool) ParseItem(EquipSlot slot, JToken? item) + { + var id = item?["ItemId"]?.ToObject() ?? ItemManager.NothingId(slot).Id; + var stains = StainIds.ParseFromObject(item as JObject); + var crest = item?["Crest"]?.ToObject() ?? false; + var apply = item?["Apply"]?.ToObject() ?? false; + var applyStain = item?["ApplyStain"]?.ToObject() ?? false; + var applyCrest = item?["ApplyCrest"]?.ToObject() ?? false; + return (id, stains, crest, apply, applyStain, applyCrest); + } } protected static void LoadCustomize(CustomizeService customizations, JToken? json, DesignBase design, string name, bool forbidNonHuman, @@ -671,12 +698,12 @@ public class DesignBase { _designData = DesignBase64Migration.MigrateBase64(items, humans, base64, out var equipFlags, out var customizeFlags, out var writeProtected, out var applyMeta); - Application.Equip = equipFlags; - ApplyCustomize = customizeFlags; + Application.Equip = equipFlags; + ApplyCustomize = customizeFlags; Application.Parameters = 0; - Application.Crest = 0; - Application.Meta = applyMeta; - Application.BonusItem = 0; + Application.Crest = 0; + Application.Meta = applyMeta; + Application.BonusItem = 0; SetWriteProtected(writeProtected); CustomizeSet = SetCustomizationSet(customize); } diff --git a/Glamourer/Designs/DesignConverter.cs b/Glamourer/Designs/DesignConverter.cs index 21172fe..c3235ab 100644 --- a/Glamourer/Designs/DesignConverter.cs +++ b/Glamourer/Designs/DesignConverter.cs @@ -214,7 +214,7 @@ public class DesignConverter( foreach (var (key, value) in materials.Values) { var idx = MaterialValueIndex.FromKey(key); - if (idx.RowIndex >= LegacyColorTable.NumUsedRows) + if (idx.RowIndex >= ColorTable.NumUsedRows) continue; if (idx.MaterialIndex >= MaterialService.MaterialsPerModel) continue; diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index 7fb2f72..0a52861 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -101,7 +101,7 @@ public unsafe struct DesignData 8 => EquipItem.FromIds(_itemIds[ 8], _iconIds[ 8], ((CharacterArmor*)ptr)[8].Set, 0, ((CharacterArmor*)ptr)[8].Variant, FullEquipType.Finger, name: _nameRFinger ), 9 => EquipItem.FromIds(_itemIds[ 9], _iconIds[ 9], ((CharacterArmor*)ptr)[9].Set, 0, ((CharacterArmor*)ptr)[9].Variant, FullEquipType.Finger, name: _nameLFinger ), 10 => EquipItem.FromIds(_itemIds[10], _iconIds[10], *(PrimaryId*)(ptr + EquipmentByteSize + 0), *(SecondaryId*)(ptr + EquipmentByteSize + 2), *(Variant*)(ptr + EquipmentByteSize + 4), _typeMainhand, name: _nameMainhand), - 11 => EquipItem.FromIds(_itemIds[11], _iconIds[11], *(PrimaryId*)(ptr + EquipmentByteSize + 4), *(SecondaryId*)(ptr + EquipmentByteSize + 2), *(Variant*)(ptr + EquipmentByteSize + 4), _typeOffhand, name: _nameOffhand ), + 11 => EquipItem.FromIds(_itemIds[11], _iconIds[11], *(PrimaryId*)(ptr + EquipmentByteSize + 8), *(SecondaryId*)(ptr + EquipmentByteSize + 10), *(Variant*)(ptr + EquipmentByteSize + 12), _typeOffhand, name: _nameOffhand ), _ => new EquipItem(), // @formatter:on }; @@ -176,13 +176,15 @@ public unsafe struct DesignData _nameMainhand = item.Name; _equipmentBytes[EquipmentByteSize + 2] = (byte)item.SecondaryId.Id; _equipmentBytes[EquipmentByteSize + 3] = (byte)(item.SecondaryId.Id >> 8); + _equipmentBytes[EquipmentByteSize + 4] = item.Variant.Id; _typeMainhand = item.Type; return true; case 11: - _nameOffhand = item.Name; - _equipmentBytes[EquipmentByteSize + 2] = (byte)item.SecondaryId.Id; - _equipmentBytes[EquipmentByteSize + 3] = (byte)(item.SecondaryId.Id >> 8); - _typeOffhand = item.Type; + _nameOffhand = item.Name; + _equipmentBytes[EquipmentByteSize + 10] = (byte)item.SecondaryId.Id; + _equipmentBytes[EquipmentByteSize + 11] = (byte)(item.SecondaryId.Id >> 8); + _equipmentBytes[EquipmentByteSize + 12] = item.Variant.Id; + _typeOffhand = item.Type; return true; } @@ -212,18 +214,18 @@ public unsafe struct DesignData => slot.ToIndex() switch { // @formatter:off - 0 => SetIfDifferent(ref _equipmentBytes[0 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[0 * CharacterArmor.Size + 4], stains.Stain2.Id), - 1 => SetIfDifferent(ref _equipmentBytes[1 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[1 * CharacterArmor.Size + 4], stains.Stain2.Id), - 2 => SetIfDifferent(ref _equipmentBytes[2 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[2 * CharacterArmor.Size + 4], stains.Stain2.Id), - 3 => SetIfDifferent(ref _equipmentBytes[3 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[3 * CharacterArmor.Size + 4], stains.Stain2.Id), - 4 => SetIfDifferent(ref _equipmentBytes[4 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[4 * CharacterArmor.Size + 4], stains.Stain2.Id), - 5 => SetIfDifferent(ref _equipmentBytes[5 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[5 * CharacterArmor.Size + 4], stains.Stain2.Id), - 6 => SetIfDifferent(ref _equipmentBytes[6 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[6 * CharacterArmor.Size + 4], stains.Stain2.Id), - 7 => SetIfDifferent(ref _equipmentBytes[7 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[7 * CharacterArmor.Size + 4], stains.Stain2.Id), - 8 => SetIfDifferent(ref _equipmentBytes[8 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[8 * CharacterArmor.Size + 4], stains.Stain2.Id), - 9 => SetIfDifferent(ref _equipmentBytes[9 * CharacterArmor.Size + 3], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[9 * CharacterArmor.Size + 4], stains.Stain2.Id), - 10 => SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 6], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 7], stains.Stain2.Id), - 11 => SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 14], stains.Stain1.Id) || SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 15], stains.Stain2.Id), + 0 => SetIfDifferent(ref _equipmentBytes[0 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[0 * CharacterArmor.Size + 4], stains.Stain2.Id), + 1 => SetIfDifferent(ref _equipmentBytes[1 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[1 * CharacterArmor.Size + 4], stains.Stain2.Id), + 2 => SetIfDifferent(ref _equipmentBytes[2 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[2 * CharacterArmor.Size + 4], stains.Stain2.Id), + 3 => SetIfDifferent(ref _equipmentBytes[3 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[3 * CharacterArmor.Size + 4], stains.Stain2.Id), + 4 => SetIfDifferent(ref _equipmentBytes[4 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[4 * CharacterArmor.Size + 4], stains.Stain2.Id), + 5 => SetIfDifferent(ref _equipmentBytes[5 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[5 * CharacterArmor.Size + 4], stains.Stain2.Id), + 6 => SetIfDifferent(ref _equipmentBytes[6 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[6 * CharacterArmor.Size + 4], stains.Stain2.Id), + 7 => SetIfDifferent(ref _equipmentBytes[7 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[7 * CharacterArmor.Size + 4], stains.Stain2.Id), + 8 => SetIfDifferent(ref _equipmentBytes[8 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[8 * CharacterArmor.Size + 4], stains.Stain2.Id), + 9 => SetIfDifferent(ref _equipmentBytes[9 * CharacterArmor.Size + 3], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[9 * CharacterArmor.Size + 4], stains.Stain2.Id), + 10 => SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 6], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 7], stains.Stain2.Id), + 11 => SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 14], stains.Stain1.Id) | SetIfDifferent(ref _equipmentBytes[EquipmentByteSize + 15], stains.Stain2.Id), _ => false, // @formatter:on }; @@ -322,6 +324,13 @@ public unsafe struct DesignData SetItem(EquipSlot.OffHand, ItemManager.NothingItem(FullEquipType.Shield)); SetStain(EquipSlot.OffHand, StainIds.None); SetCrest(CrestFlag.OffHand, false); + SetDefaultBonusItems(); + } + + public void SetDefaultBonusItems() + { + foreach (var slot in BonusExtensions.AllFlags) + SetBonusItem(slot, Penumbra.GameData.Structs.BonusItem.Empty(slot)); } diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index 08cb241..4a104ca 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -165,9 +165,21 @@ public class DesignEditor( } } + /// public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) { - + var design = (Design)data; + if (!Items.IsBonusItemValid(slot, item.Id, out item)) + return; + + var oldItem = design.DesignData.BonusItem(slot); + if (!design.GetDesignDataRef().SetBonusItem(slot, item)) + return; + + design.LastEdit = DateTimeOffset.UtcNow; + SaveService.QueueSave(design); + Glamourer.Log.Debug($"Set {slot} bonus item to {item}."); + DesignChanged.Invoke(DesignChanged.Type.BonusItem, design, (oldItem, item, slot)); } /// diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 725d562..97058a9 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -356,7 +356,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of {slot} bonus item to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyBonus, design, slot); + DesignChanged.Invoke(DesignChanged.Type.ApplyBonusItem, design, slot); } /// Change whether to apply a specific stain. diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 1588a96..199c7d4 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -62,6 +62,9 @@ public sealed class DesignChanged() /// An existing design had an equipment piece changed. Data is the old value, the new value and the slot [(EquipItem, EquipItem, EquipSlot)]. Equip, + /// An existing design had a bonus item changed. Data is the old value, the new value and the slot [(BonusItem, BonusItem, BonusItemFlag)]. + BonusItem, + /// An existing design had its weapons changed. Data is the old mainhand, the old offhand, the new mainhand, the new offhand (if any) and the new gauntlets (if any). [(EquipItem, EquipItem, EquipItem, EquipItem?, EquipItem?)]. Weapon, @@ -90,7 +93,7 @@ public sealed class DesignChanged() ApplyEquip, /// An existing design changed whether a specific bonus item is applied. Data is the slot of the item [BonusItemFlag]. - ApplyBonus, + ApplyBonusItem, /// An existing design changed whether a specific stain is applied. Data is the slot of the equipment [EquipSlot]. ApplyStain, diff --git a/Glamourer/GameData/CustomizeParameterData.cs b/Glamourer/GameData/CustomizeParameterData.cs index f10289f..09ce65a 100644 --- a/Glamourer/GameData/CustomizeParameterData.cs +++ b/Glamourer/GameData/CustomizeParameterData.cs @@ -12,7 +12,9 @@ public struct CustomizeParameterData public Vector3 HairSpecular; public Vector3 HairHighlight; public Vector3 LeftEye; + public float LeftScleraIntensity; public Vector3 RightEye; + public float RightScleraIntensity; public Vector3 FeatureColor; public float FacePaintUvMultiplier; public float FacePaintUvOffset; @@ -33,7 +35,9 @@ public struct CustomizeParameterData CustomizeParameterFlag.HairSpecular => new CustomizeParameterValue(HairSpecular), CustomizeParameterFlag.HairHighlight => new CustomizeParameterValue(HairHighlight), CustomizeParameterFlag.LeftEye => new CustomizeParameterValue(LeftEye), + CustomizeParameterFlag.LeftScleraIntensity => new CustomizeParameterValue(LeftScleraIntensity), CustomizeParameterFlag.RightEye => new CustomizeParameterValue(RightEye), + CustomizeParameterFlag.RightScleraIntensity => new CustomizeParameterValue(RightScleraIntensity), CustomizeParameterFlag.FeatureColor => new CustomizeParameterValue(FeatureColor), CustomizeParameterFlag.DecalColor => new CustomizeParameterValue(DecalColor), CustomizeParameterFlag.FacePaintUvMultiplier => new CustomizeParameterValue(FacePaintUvMultiplier), @@ -57,7 +61,9 @@ public struct CustomizeParameterData CustomizeParameterFlag.HairSpecular => SetIfDifferent(ref HairSpecular, value.InternalTriple), CustomizeParameterFlag.HairHighlight => SetIfDifferent(ref HairHighlight, value.InternalTriple), CustomizeParameterFlag.LeftEye => SetIfDifferent(ref LeftEye, value.InternalTriple), + CustomizeParameterFlag.LeftScleraIntensity => SetIfDifferent(ref LeftScleraIntensity, value.Single), CustomizeParameterFlag.RightEye => SetIfDifferent(ref RightEye, value.InternalTriple), + CustomizeParameterFlag.RightScleraIntensity => SetIfDifferent(ref RightScleraIntensity, value.Single), CustomizeParameterFlag.FeatureColor => SetIfDifferent(ref FeatureColor, value.InternalTriple), CustomizeParameterFlag.DecalColor => SetIfDifferent(ref DecalColor, value.InternalQuadruple), CustomizeParameterFlag.FacePaintUvMultiplier => SetIfDifferent(ref FacePaintUvMultiplier, value.Single), @@ -67,7 +73,7 @@ public struct CustomizeParameterData } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public readonly void Apply(ref CustomizeParameter parameters, CustomizeParameterFlag flags = CustomizeParameterExtensions.All) + public readonly unsafe void Apply(ref CustomizeParameter parameters, CustomizeParameterFlag flags = CustomizeParameterExtensions.All) { parameters.SkinColor = (flags & (CustomizeParameterFlag.SkinDiffuse | CustomizeParameterFlag.MuscleTone)) switch { @@ -77,20 +83,20 @@ public struct CustomizeParameterData _ => new CustomizeParameterValue(SkinDiffuse, MuscleTone).XivQuadruple, }; - parameters.LeftColor = (flags & (CustomizeParameterFlag.LeftEye | CustomizeParameterFlag.FacePaintUvMultiplier)) switch + parameters.LeftColor = (flags & (CustomizeParameterFlag.LeftEye | CustomizeParameterFlag.LeftScleraIntensity)) switch { - 0 => parameters.LeftColor, - CustomizeParameterFlag.LeftEye => new CustomizeParameterValue(LeftEye, parameters.LeftColor.W).XivQuadruple, - CustomizeParameterFlag.FacePaintUvMultiplier => parameters.LeftColor with { W = FacePaintUvMultiplier }, - _ => new CustomizeParameterValue(LeftEye, FacePaintUvMultiplier).XivQuadruple, + 0 => parameters.LeftColor, + CustomizeParameterFlag.LeftEye => new CustomizeParameterValue(LeftEye, parameters.LeftColor.W).XivQuadruple, + CustomizeParameterFlag.LeftScleraIntensity => parameters.LeftColor with { W = LeftScleraIntensity }, + _ => new CustomizeParameterValue(LeftEye, LeftScleraIntensity).XivQuadruple, }; - parameters.RightColor = (flags & (CustomizeParameterFlag.RightEye | CustomizeParameterFlag.FacePaintUvOffset)) switch + parameters.RightColor = (flags & (CustomizeParameterFlag.RightEye | CustomizeParameterFlag.RightScleraIntensity)) switch { - 0 => parameters.RightColor, - CustomizeParameterFlag.RightEye => new CustomizeParameterValue(RightEye, parameters.RightColor.W).XivQuadruple, - CustomizeParameterFlag.FacePaintUvOffset => parameters.RightColor with { W = FacePaintUvOffset }, - _ => new CustomizeParameterValue(RightEye, FacePaintUvOffset).XivQuadruple, + 0 => parameters.RightColor, + CustomizeParameterFlag.RightEye => new CustomizeParameterValue(RightEye, parameters.RightColor.W).XivQuadruple, + CustomizeParameterFlag.RightScleraIntensity => parameters.RightColor with { W = RightScleraIntensity }, + _ => new CustomizeParameterValue(RightEye, RightScleraIntensity).XivQuadruple, }; if (flags.HasFlag(CustomizeParameterFlag.SkinSpecular)) @@ -101,6 +107,10 @@ public struct CustomizeParameterData parameters.HairFresnelValue0 = new CustomizeParameterValue(HairSpecular).XivTriple; if (flags.HasFlag(CustomizeParameterFlag.HairHighlight)) parameters.MeshColor = new CustomizeParameterValue(HairHighlight).XivTriple; + if (flags.HasFlag(CustomizeParameterFlag.FacePaintUvMultiplier)) + GetUvMultiplierWrite(ref parameters) = FacePaintUvMultiplier; + if (flags.HasFlag(CustomizeParameterFlag.FacePaintUvOffset)) + GetUvOffsetWrite(ref parameters) = FacePaintUvOffset; if (flags.HasFlag(CustomizeParameterFlag.LipDiffuse)) parameters.LipColor = new CustomizeParameterValue(LipDiffuse).XivQuadruple; if (flags.HasFlag(CustomizeParameterFlag.FeatureColor)) @@ -115,7 +125,7 @@ public struct CustomizeParameterData } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public readonly void ApplySingle(ref CustomizeParameter parameters, CustomizeParameterFlag flag) + public readonly unsafe void ApplySingle(ref CustomizeParameter parameters, CustomizeParameterFlag flag) { switch (flag) { @@ -150,19 +160,25 @@ public struct CustomizeParameterData parameters.OptionColor = new CustomizeParameterValue(FeatureColor).XivTriple; break; case CustomizeParameterFlag.FacePaintUvMultiplier: - parameters.LeftColor.W = FacePaintUvMultiplier; + GetUvMultiplierWrite(ref parameters) = FacePaintUvMultiplier; break; case CustomizeParameterFlag.FacePaintUvOffset: - parameters.RightColor.W = FacePaintUvOffset; + GetUvOffsetWrite(ref parameters) = FacePaintUvOffset; + break; + case CustomizeParameterFlag.LeftScleraIntensity: + parameters.LeftColor.W = LeftScleraIntensity; + break; + case CustomizeParameterFlag.RightScleraIntensity: + parameters.RightColor.W = RightScleraIntensity; break; } } - public static CustomizeParameterData FromParameters(in CustomizeParameter parameter, in DecalParameters decal) + public static unsafe CustomizeParameterData FromParameters(in CustomizeParameter parameter, in DecalParameters decal) => new() { - FacePaintUvOffset = parameter.RightColor.W, - FacePaintUvMultiplier = parameter.LeftColor.W, + FacePaintUvOffset = GetUvOffset(parameter), + FacePaintUvMultiplier = GetUvMultiplier(parameter), MuscleTone = parameter.SkinColor.W, SkinDiffuse = new CustomizeParameterValue(parameter.SkinColor).InternalTriple, SkinSpecular = new CustomizeParameterValue(parameter.SkinFresnelValue0).InternalTriple, @@ -171,12 +187,14 @@ public struct CustomizeParameterData HairSpecular = new CustomizeParameterValue(parameter.HairFresnelValue0).InternalTriple, HairHighlight = new CustomizeParameterValue(parameter.MeshColor).InternalTriple, LeftEye = new CustomizeParameterValue(parameter.LeftColor).InternalTriple, + LeftScleraIntensity = new CustomizeParameterValue(parameter.LeftColor.W).Single, RightEye = new CustomizeParameterValue(parameter.RightColor).InternalTriple, + RightScleraIntensity = new CustomizeParameterValue(parameter.RightColor.W).Single, FeatureColor = new CustomizeParameterValue(parameter.OptionColor).InternalTriple, DecalColor = FromParameter(decal), }; - public static CustomizeParameterValue FromParameter(in CustomizeParameter parameter, CustomizeParameterFlag flag) + public static unsafe CustomizeParameterValue FromParameter(in CustomizeParameter parameter, CustomizeParameterFlag flag) => flag switch { CustomizeParameterFlag.SkinDiffuse => new CustomizeParameterValue(parameter.SkinColor), @@ -189,8 +207,8 @@ public struct CustomizeParameterData CustomizeParameterFlag.LeftEye => new CustomizeParameterValue(parameter.LeftColor), CustomizeParameterFlag.RightEye => new CustomizeParameterValue(parameter.RightColor), CustomizeParameterFlag.FeatureColor => new CustomizeParameterValue(parameter.OptionColor), - CustomizeParameterFlag.FacePaintUvMultiplier => new CustomizeParameterValue(parameter.LeftColor.W), - CustomizeParameterFlag.FacePaintUvOffset => new CustomizeParameterValue(parameter.RightColor.W), + CustomizeParameterFlag.FacePaintUvMultiplier => new CustomizeParameterValue(GetUvMultiplier(parameter)), + CustomizeParameterFlag.FacePaintUvOffset => new CustomizeParameterValue(GetUvOffset(parameter)), _ => CustomizeParameterValue.Zero, }; @@ -223,4 +241,41 @@ public struct CustomizeParameterData val = @new; return true; } + + + private static unsafe float GetUvOffset(in CustomizeParameter parameter) + { + // TODO CS Update + fixed (CustomizeParameter* ptr = ¶meter) + { + return ((float*)ptr)[23]; + } + } + + private static unsafe ref float GetUvOffsetWrite(ref CustomizeParameter parameter) + { + // TODO CS Update + fixed (CustomizeParameter* ptr = ¶meter) + { + return ref ((float*)ptr)[23]; + } + } + + private static unsafe float GetUvMultiplier(in CustomizeParameter parameter) + { + // TODO CS Update + fixed (CustomizeParameter* ptr = ¶meter) + { + return ((float*)ptr)[15]; + } + } + + private static unsafe ref float GetUvMultiplierWrite(ref CustomizeParameter parameter) + { + // TODO CS Update + fixed (CustomizeParameter* ptr = ¶meter) + { + return ref ((float*)ptr)[15]; + } + } } diff --git a/Glamourer/GameData/CustomizeParameterFlag.cs b/Glamourer/GameData/CustomizeParameterFlag.cs index 59a3511..aabcdae 100644 --- a/Glamourer/GameData/CustomizeParameterFlag.cs +++ b/Glamourer/GameData/CustomizeParameterFlag.cs @@ -16,17 +16,24 @@ public enum CustomizeParameterFlag : ushort FacePaintUvMultiplier = 0x0400, FacePaintUvOffset = 0x0800, DecalColor = 0x1000, + LeftScleraIntensity = 0x2000, + RightScleraIntensity = 0x4000, } public static class CustomizeParameterExtensions { - public const CustomizeParameterFlag All = (CustomizeParameterFlag)0x1FFF; + // Speculars are not available anymore. + public const CustomizeParameterFlag All = (CustomizeParameterFlag)0x1FDB; public const CustomizeParameterFlag RgbTriples = All & ~(RgbaQuadruples | Percentages | Values); public const CustomizeParameterFlag RgbaQuadruples = CustomizeParameterFlag.DecalColor | CustomizeParameterFlag.LipDiffuse; - public const CustomizeParameterFlag Percentages = CustomizeParameterFlag.MuscleTone; + + public const CustomizeParameterFlag Percentages = CustomizeParameterFlag.MuscleTone + | CustomizeParameterFlag.LeftScleraIntensity + | CustomizeParameterFlag.RightScleraIntensity; + public const CustomizeParameterFlag Values = CustomizeParameterFlag.FacePaintUvOffset | CustomizeParameterFlag.FacePaintUvMultiplier; public static readonly IReadOnlyList AllFlags = [.. Enum.GetValues()]; @@ -60,6 +67,8 @@ public static class CustomizeParameterExtensions CustomizeParameterFlag.FacePaintUvMultiplier => "Multiplier for Face Paint", CustomizeParameterFlag.FacePaintUvOffset => "Offset of Face Paint", CustomizeParameterFlag.DecalColor => "Face Paint Color", + CustomizeParameterFlag.LeftScleraIntensity => "Left Sclera Intensity", + CustomizeParameterFlag.RightScleraIntensity => "Right Sclera Intensity", _ => string.Empty, }; } diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index afd3fe5..e65981e 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -158,22 +158,22 @@ public class EquipmentDrawer } } - public bool DrawAllStain(out StainId ret, bool locked) + public bool DrawAllStain(out StainIds ret, bool locked) { using var disabled = ImRaii.Disabled(locked); var change = _stainCombo.Draw("Dye All Slots", Stain.None.RgbaColor, string.Empty, false, false, MouseWheelType.None); - ret = Stain.None.RowIndex; + ret = StainIds.None; if (change) if (_stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out var stain)) - ret = stain.RowIndex; + ret = StainIds.All(stain.RowIndex); else if (_stainCombo.CurrentSelection.Key == Stain.None.RowIndex) - ret = Stain.None.RowIndex; + ret = StainIds.None; if (!locked) { if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && _config.DeleteDesignModifier.IsActive()) { - ret = Stain.None.RowIndex; + ret = StainIds.None; change = true; } @@ -420,7 +420,7 @@ public class EquipmentDrawer private void DrawBonusItemNormal(in BonusDrawData bonusDrawData) { - ImGui.Dummy(_iconSize with { Y = ImUtf8.FrameHeight }); + bonusDrawData.CurrentItem.DrawIcon(_textures, _iconSize, bonusDrawData.Slot); var right = ImGui.IsItemClicked(ImGuiMouseButton.Right); var left = ImGui.IsItemClicked(ImGuiMouseButton.Left); ImGui.SameLine(); diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 3160bcb..173109b 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -51,6 +51,8 @@ public sealed unsafe class AdvancedDyePopup( private void DrawButton(MaterialValueIndex index) { + // TODO fix when working + return; if (!config.UseAdvancedDyes) return; @@ -193,11 +195,11 @@ public sealed unsafe class AdvancedDyePopup( DrawWindow(textures); } - private void DrawTable(MaterialValueIndex materialIndex, in LegacyColorTable table) + private void DrawTable(MaterialValueIndex materialIndex, in ColorTable table) { using var disabled = ImRaii.Disabled(_state.IsLocked); _anyChanged = false; - for (byte i = 0; i < LegacyColorTable.NumUsedRows; ++i) + for (byte i = 0; i < ColorTable.NumUsedRows; ++i) { var index = materialIndex with { RowIndex = i }; ref var row = ref table[i]; @@ -208,7 +210,7 @@ public sealed unsafe class AdvancedDyePopup( DrawAllRow(materialIndex, table); } - private void DrawAllRow(MaterialValueIndex materialIndex, in LegacyColorTable table) + private void DrawAllRow(MaterialValueIndex materialIndex, in ColorTable table) { using var id = ImRaii.PushId(100); var buttonSize = new Vector2(ImGui.GetFrameHeight()); @@ -245,11 +247,11 @@ public sealed unsafe class AdvancedDyePopup( ImGui.SameLine(0, spacing); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.UndoAlt.ToIconString(), buttonSize, "Reset this table to game state.", !_anyChanged, true)) - for (byte i = 0; i < LegacyColorTable.NumUsedRows; ++i) + for (byte i = 0; i < ColorTable.NumUsedRows; ++i) stateManager.ResetMaterialValue(_state, materialIndex with { RowIndex = i }, ApplySettings.Game); } - private void DrawRow(ref LegacyColorTable.Row row, MaterialValueIndex index, in LegacyColorTable table) + private void DrawRow(ref ColorTable.Row row, MaterialValueIndex index, in ColorTable table) { using var id = ImRaii.PushId(index.RowIndex); var changed = _state.Materials.TryGetValue(index, out var value); diff --git a/Glamourer/Gui/Materials/ColorRowClipboard.cs b/Glamourer/Gui/Materials/ColorRowClipboard.cs index 4d99018..4213cc5 100644 --- a/Glamourer/Gui/Materials/ColorRowClipboard.cs +++ b/Glamourer/Gui/Materials/ColorRowClipboard.cs @@ -5,14 +5,14 @@ namespace Glamourer.Gui.Materials; public static class ColorRowClipboard { - private static ColorRow _row; - private static LegacyColorTable _table; + private static ColorRow _row; + private static ColorTable _table; public static bool IsSet { get; private set; } public static bool IsTableSet { get; private set; } - public static LegacyColorTable Table + public static ColorTable Table { get => _table; set diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 26432e9..e7a061f 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -175,9 +175,9 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) { _newRowIdx += 1; ImGui.SetNextItemWidth(ImGui.CalcTextSize("Row #0000").X); - if (ImGui.DragInt("##Row", ref _newRowIdx, 0.01f, 1, LegacyColorTable.NumUsedRows, "Row #%i")) + if (ImGui.DragInt("##Row", ref _newRowIdx, 0.01f, 1, ColorTable.NumUsedRows, "Row #%i")) { - _newRowIdx = Math.Clamp(_newRowIdx, 1, LegacyColorTable.NumUsedRows); + _newRowIdx = Math.Clamp(_newRowIdx, 1, ColorTable.NumUsedRows); _newKey = _newKey with { RowIndex = (byte)(_newRowIdx - 1) }; } diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index 0a29314..c875cf1 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -9,6 +9,7 @@ using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using FFXIVClientStructs.FFXIV.Shader; namespace Glamourer.Gui.Tabs.DebugTab; @@ -94,7 +95,8 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM foreach (var type in Enum.GetValues()) { - PrintRow(type.ToDefaultName(), state.BaseData.Customize[type].Value, state.ModelData.Customize[type].Value, state.Sources[type]); + PrintRow(type.ToDefaultName(), state.BaseData.Customize[type].Value, state.ModelData.Customize[type].Value, + state.Sources[type]); ImGui.TableNextRow(); } diff --git a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs new file mode 100644 index 0000000..4d6a2cd --- /dev/null +++ b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs @@ -0,0 +1,135 @@ +using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; +using Glamourer.Interop; +using ImGuiNET; +using OtterGui.Raii; +using OtterGui.Text; +using Penumbra.GameData.Gui.Debug; + +namespace Glamourer.Gui.Tabs.DebugTab; + +public unsafe class AdvancedCustomizationDrawer(ObjectManager objects) : IGameDataDrawer +{ + public string Label + => "Advanced Customizations"; + + public bool Disabled + => false; + + public void Draw() + { + var (player, data) = objects.PlayerData; + if (!data.Valid) + { + ImUtf8.Text("Invalid player."u8); + return; + } + + var model = data.Objects[0].Model; + if (!model.IsHuman) + { + ImUtf8.Text("Invalid model."u8); + return; + } + + DrawCBuffer("Customize"u8, model.AsHuman->CustomizeParameterCBuffer, 0); + DrawCBuffer("Decal"u8, model.AsHuman->DecalColorCBuffer, 1); + DrawCBuffer("Unk1"u8, *(ConstantBuffer**)((byte*)model.AsHuman + 0xBA0), 2); + DrawCBuffer("Unk2"u8, *(ConstantBuffer**)((byte*)model.AsHuman + 0xBA8), 3); + } + + + private static void DrawCBuffer(ReadOnlySpan label, ConstantBuffer* cBuffer, int type) + { + using var tree = ImUtf8.TreeNode(label); + if (!tree) + return; + + if (cBuffer == null) + { + ImUtf8.Text("Invalid CBuffer."u8); + return; + } + + ImUtf8.Text($"{cBuffer->ByteSize / 4}"); + ImUtf8.Text($"{cBuffer->Flags}"); + ImUtf8.Text($"0x{(ulong)cBuffer:X}"); + var parameters = (float*)cBuffer->UnsafeSourcePointer; + if (parameters == null) + { + ImUtf8.Text("No Parameters."u8); + return; + } + + var start = parameters; + using (ImUtf8.Group()) + { + for (var end = start + cBuffer->ByteSize / 4; parameters < end; parameters += 2) + DrawParameters(parameters, type, (int)(parameters - start)); + } + + ImGui.SameLine(0, 50 * ImUtf8.GlobalScale); + parameters = start + 1; + using (ImUtf8.Group()) + { + for (var end = start + cBuffer->ByteSize / 4; parameters < end; parameters += 2) + DrawParameters(parameters, type, (int)(parameters - start)); + } + } + + private static void DrawParameters(float* param, int type, int idx) + { + using var id = ImUtf8.PushId((nint)param); + ImUtf8.TextFrameAligned($"{idx:D2}: "); + ImUtf8.SameLineInner(); + ImGui.SetNextItemWidth(200 * ImUtf8.GlobalScale); + if (TryGetKnown(type, idx, out var known)) + { + ImUtf8.DragScalar(known, ref *param, float.MinValue, float.MaxValue, 0.01f); + } + else + { + using var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImUtf8.DragScalar($"+0x{idx * 4:X2}", ref *param, float.MinValue, float.MaxValue, 0.01f); + } + } + + private static bool TryGetKnown(int type, int idx, out ReadOnlySpan text) + { + if (type == 0) + text = idx switch + { + 0 => "Diffuse.R"u8, + 1 => "Diffuse.G"u8, + 2 => "Diffuse.B"u8, + 3 => "Muscle Tone"u8, + 8 => "Lipstick.R"u8, + 9 => "Lipstick.G"u8, + 10 => "Lipstick.B"u8, + 11 => "Lipstick.Opacity"u8, + 12 => "Hair.R"u8, + 13 => "Hair.G"u8, + 14 => "Hair.B"u8, + 15 => "Facepaint.Offset"u8, + 20 => "Highlight.R"u8, + 21 => "Highlight.G"u8, + 22 => "Highlight.B"u8, + 23 => "Facepaint.Multiplier"u8, + 24 => "LeftEye.R"u8, + 25 => "LeftEye.G"u8, + 26 => "LeftEye.B"u8, + 27 => "LeftSclera"u8, + 28 => "RightEye.R"u8, + 29 => "RightEye.G"u8, + 30 => "RightEye.B"u8, + 31 => "RightSclera"u8, + 32 => "Feature.R"u8, + 33 => "Feature.G"u8, + 34 => "Feature.B"u8, + _ => [], + }; + else + text = []; + + return text.Length > 0; + } +} diff --git a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs index 3dce124..90282e8 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs @@ -38,7 +38,8 @@ public class DebugTabHeader(string label, params IGameDataDrawer[] subTrees) provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), - provider.GetRequiredService() + provider.GetRequiredService(), + provider.GetRequiredService() ); public static DebugTabHeader CreateGameData(IServiceProvider provider) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index 9749ce6..d1624f6 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -1,5 +1,6 @@ using Dalamud.Game.Text.SeStringHandling; using Dalamud.Interface.Utility; +using Glamourer.Designs; using Glamourer.GameData; using Glamourer.Interop; using Glamourer.Services; @@ -12,23 +13,23 @@ using ImGuiClip = OtterGui.ImGuiClip; namespace Glamourer.Gui.Tabs.UnlocksTab; -public class UnlockOverview +public class UnlockOverview( + ItemManager items, + CustomizeService customizations, + ItemUnlockManager itemUnlocks, + CustomizeUnlockManager customizeUnlocks, + PenumbraChangedItemTooltip tooltip, + TextureService textures, + CodeService codes, + JobService jobs, + FavoriteManager favorites) { - private readonly ItemManager _items; - private readonly ItemUnlockManager _itemUnlocks; - private readonly CustomizeService _customizations; - private readonly CustomizeUnlockManager _customizeUnlocks; - private readonly PenumbraChangedItemTooltip _tooltip; - private readonly TextureService _textures; - private readonly CodeService _codes; - private readonly JobService _jobs; - private readonly FavoriteManager _favorites; - private static readonly Vector4 UnavailableTint = new(0.3f, 0.3f, 0.3f, 1.0f); private FullEquipType _selected1 = FullEquipType.Unknown; private SubRace _selected2 = SubRace.Unknown; private Gender _selected3 = Gender.Unknown; + private BonusItemFlag _selected4 = BonusItemFlag.Unknown; private void DrawSelector() { @@ -38,7 +39,7 @@ public class UnlockOverview foreach (var type in Enum.GetValues()) { - if (type.IsOffhandType() || !_items.ItemData.ByType.TryGetValue(type, out var items) || items.Count == 0) + if (type.IsOffhandType() || !items.ItemData.ByType.TryGetValue(type, out var value) || value.Count == 0) continue; if (ImGui.Selectable(type.ToName(), _selected1 == type)) @@ -46,12 +47,21 @@ public class UnlockOverview _selected1 = type; _selected2 = SubRace.Unknown; _selected3 = Gender.Unknown; + _selected4 = BonusItemFlag.Unknown; } } + if (ImGui.Selectable("Bonus Items", _selected4 == BonusItemFlag.Glasses)) + { + _selected1 = FullEquipType.Unknown; + _selected2 = SubRace.Unknown; + _selected3 = Gender.Unknown; + _selected4 = BonusItemFlag.Glasses; + } + foreach (var (clan, gender) in CustomizeManager.AllSets()) { - if (_customizations.Manager.GetSet(clan, gender).HairStyles.Count == 0) + if (customizations.Manager.GetSet(clan, gender).HairStyles.Count == 0) continue; if (ImGui.Selectable($"{(gender is Gender.Male ? '♂' : '♀')} {clan.ToShortName()} Hair & Paint", @@ -60,25 +70,11 @@ public class UnlockOverview _selected1 = FullEquipType.Unknown; _selected2 = clan; _selected3 = gender; + _selected4 = BonusItemFlag.Unknown; } } } - public UnlockOverview(ItemManager items, CustomizeService customizations, ItemUnlockManager itemUnlocks, - CustomizeUnlockManager customizeUnlocks, PenumbraChangedItemTooltip tooltip, TextureService textures, CodeService codes, - JobService jobs, FavoriteManager favorites) - { - _items = items; - _customizations = customizations; - _itemUnlocks = itemUnlocks; - _customizeUnlocks = customizeUnlocks; - _tooltip = tooltip; - _textures = textures; - _codes = codes; - _jobs = jobs; - _favorites = favorites; - } - public void Draw() { using var color = ImRaii.PushColor(ImGuiCol.Border, ImGui.GetColorU32(ImGuiCol.TableBorderStrong)); @@ -97,11 +93,13 @@ public class UnlockOverview DrawItems(); else if (_selected2 is not SubRace.Unknown && _selected3 is not Gender.Unknown) DrawCustomizations(); + else if (_selected4 is not BonusItemFlag.Unknown) + DrawBonusItems(); } private void DrawCustomizations() { - var set = _customizations.Manager.GetSet(_selected2, _selected3); + var set = customizations.Manager.GetSet(_selected2, _selected3); var spacing = IconSpacing; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); @@ -111,16 +109,16 @@ public class UnlockOverview var counter = 0; foreach (var customize in set.HairStyles.Concat(set.FacePaints)) { - if (!_customizeUnlocks.Unlockable.TryGetValue(customize, out var unlockData)) + if (!customizeUnlocks.Unlockable.TryGetValue(customize, out var unlockData)) continue; - var unlocked = _customizeUnlocks.IsUnlocked(customize, out var time); - var icon = _customizations.Manager.GetIcon(customize.IconId); + var unlocked = customizeUnlocks.IsUnlocked(customize, out var time); + var icon = customizations.Manager.GetIcon(customize.IconId); var hasIcon = icon.TryGetWrap(out var wrap, out _); ImGui.Image(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, iconSize, Vector2.Zero, Vector2.One, - unlocked || _codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); + unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); - if (_favorites.Contains(_selected3, _selected2, customize.Index, customize.Value)) + if (favorites.Contains(_selected3, _selected2, customize.Index, customize.Value)) ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), 12 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 6 * ImGuiHelpers.GlobalScale); @@ -147,24 +145,90 @@ public class UnlockOverview } } + private void DrawBonusItems() + { + var spacing = IconSpacing; + using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); + var iconSize = ImGuiHelpers.ScaledVector2(64); + var iconsPerRow = IconsPerRow(iconSize.X, spacing.X); + var numRows = (items.DictBonusItems.Count + iconsPerRow - 1) / iconsPerRow; + var numVisibleRows = (int)(Math.Ceiling(ImGui.GetContentRegionAvail().Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; + + var skips = ImGuiClip.GetNecessarySkips(iconSize.Y + spacing.Y); + var start = skips * iconsPerRow; + var end = Math.Min(numVisibleRows * iconsPerRow + skips * iconsPerRow, items.DictBonusItems.Count); + var counter = 0; + + foreach (var item in items.DictBonusItems.Values.Skip(start).Take(end - start)) + { + DrawItem(item); + if (counter != iconsPerRow - 1) + { + ImGui.SameLine(); + ++counter; + } + else + { + counter = 0; + } + } + + if (ImGui.GetCursorPosX() != 0) + ImGui.NewLine(); + var remainder = numRows - numVisibleRows - skips; + if (remainder > 0) + ImGuiClip.DrawEndDummy(remainder, iconSize.Y + spacing.Y); + + void DrawItem(BonusItem item) + { + // TODO check unlocks + var unlocked = true; + if (!textures.TryLoadIcon(item.Icon.Id, out var iconHandle)) + return; + + var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); + + ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, + unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); + if (favorites.Contains(item)) + ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), + 2 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * ImGuiHelpers.GlobalScale); + + // TODO handle clicking + if (ImGui.IsItemHovered()) + { + using var tt = ImRaii.Tooltip(); + if (size.X >= iconSize.X && size.Y >= iconSize.Y) + ImGui.Image(icon, size); + ImGui.TextUnformatted(item.Name); + ImGui.TextUnformatted($"{item.Slot.ToName()}"); + ImGui.TextUnformatted($"{item.ModelId.Id}-{item.Variant.Id}"); + // TODO + ImGui.TextUnformatted("Always Unlocked"); // : $"Unlocked on {time:g}" : "Not Unlocked."); + // TODO + //tooltip.CreateTooltip(item, string.Empty, false); + } + } + } + private void DrawItems() { - if (!_items.ItemData.ByType.TryGetValue(_selected1, out var items)) + if (!items.ItemData.ByType.TryGetValue(_selected1, out var value)) return; var spacing = IconSpacing; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); var iconSize = ImGuiHelpers.ScaledVector2(64); var iconsPerRow = IconsPerRow(iconSize.X, spacing.X); - var numRows = (items.Count + iconsPerRow - 1) / iconsPerRow; + var numRows = (value.Count + iconsPerRow - 1) / iconsPerRow; var numVisibleRows = (int)(Math.Ceiling(ImGui.GetContentRegionAvail().Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; var skips = ImGuiClip.GetNecessarySkips(iconSize.Y + spacing.Y); - var end = Math.Min(numVisibleRows * iconsPerRow + skips * iconsPerRow, items.Count); + var end = Math.Min(numVisibleRows * iconsPerRow + skips * iconsPerRow, value.Count); var counter = 0; for (var idx = skips * iconsPerRow; idx < end; ++idx) { - DrawItem(items[idx]); + DrawItem(value[idx]); if (counter != iconsPerRow - 1) { ImGui.SameLine(); @@ -185,23 +249,23 @@ public class UnlockOverview void DrawItem(EquipItem item) { - var unlocked = _itemUnlocks.IsUnlocked(item.Id, out var time); - if (!_textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) + var unlocked = itemUnlocks.IsUnlocked(item.Id, out var time); + if (!textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) return; var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, - unlocked || _codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); - if (_favorites.Contains(item)) + unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); + if (favorites.Contains(item)) ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), 2 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * ImGuiHelpers.GlobalScale); if (ImGui.IsItemClicked()) Glamourer.Messager.Chat.Print(new SeStringBuilder().AddItemLink(item.ItemId.Id, false).BuiltString); - if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && _tooltip.Player(out var state)) - _tooltip.ApplyItem(state, item); + if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && tooltip.Player(out var state)) + tooltip.ApplyItem(state, item); if (ImGui.IsItemHovered()) { @@ -213,7 +277,7 @@ public class UnlockOverview ImGui.TextUnformatted($"{item.Type.ToName()} ({slot.ToName()})"); if (item.Type.ValidOffhand().IsOffhandType()) ImGui.TextUnformatted( - $"{item.Weapon()}{(_items.ItemData.TryGetValue(item.ItemId, EquipSlot.OffHand, out var offhand) ? $" | {offhand.Weapon()}" : string.Empty)}"); + $"{item.Weapon()}{(items.ItemData.TryGetValue(item.ItemId, EquipSlot.OffHand, out var offhand) ? $" | {offhand.Weapon()}" : string.Empty)}"); else ImGui.TextUnformatted(slot is EquipSlot.MainHand ? $"{item.Weapon()}" : $"{item.Armor()}"); ImGui.TextUnformatted( @@ -221,17 +285,17 @@ public class UnlockOverview if (item.Level.Value <= 1) { - if (item.JobRestrictions.Id <= 1 || item.JobRestrictions.Id >= _jobs.AllJobGroups.Count) + if (item.JobRestrictions.Id <= 1 || item.JobRestrictions.Id >= jobs.AllJobGroups.Count) ImGui.TextUnformatted("For Everyone"); else - ImGui.TextUnformatted($"For all {_jobs.AllJobGroups[item.JobRestrictions.Id].Name}"); + ImGui.TextUnformatted($"For all {jobs.AllJobGroups[item.JobRestrictions.Id].Name}"); } else { - if (item.JobRestrictions.Id <= 1 || item.JobRestrictions.Id >= _jobs.AllJobGroups.Count) + if (item.JobRestrictions.Id <= 1 || item.JobRestrictions.Id >= jobs.AllJobGroups.Count) ImGui.TextUnformatted($"For Everyone of at least Level {item.Level}"); else - ImGui.TextUnformatted($"For all {_jobs.AllJobGroups[item.JobRestrictions.Id].Name} of at least Level {item.Level}"); + ImGui.TextUnformatted($"For all {jobs.AllJobGroups[item.JobRestrictions.Id].Name} of at least Level {item.Level}"); } if (item.Flags.HasFlag(ItemFlags.IsDyable1)) @@ -240,7 +304,7 @@ public class UnlockOverview ImGui.TextUnformatted("Tradable"); if (item.Flags.HasFlag(ItemFlags.IsCrestWorthy)) ImGui.TextUnformatted("Can apply Crest"); - _tooltip.CreateTooltip(item, string.Empty, false); + tooltip.CreateTooltip(item, string.Empty, false); } } } diff --git a/Glamourer/Gui/UiHelpers.cs b/Glamourer/Gui/UiHelpers.cs index 88f51f5..8499728 100644 --- a/Glamourer/Gui/UiHelpers.cs +++ b/Glamourer/Gui/UiHelpers.cs @@ -29,8 +29,30 @@ public static class UiHelpers if (empty) { var (bgColor, tint) = isEmpty - ? (ImGui.GetColorU32(ImGuiCol.FrameBg), new Vector4(0.1f, 0.1f, 0.1f, 0.5f)) - : (ImGui.GetColorU32(ImGuiCol.FrameBgActive), new Vector4(0.3f, 0.3f, 0.3f, 0.8f)); + ? (ImGui.GetColorU32(ImGuiCol.FrameBg), Vector4.One) + : (ImGui.GetColorU32(ImGuiCol.FrameBgActive), new Vector4(0.3f, 0.3f, 0.3f, 1f)); + var pos = ImGui.GetCursorScreenPos(); + ImGui.GetWindowDrawList().AddRectFilled(pos, pos + size, bgColor, 5 * ImGuiHelpers.GlobalScale); + if (ptr != nint.Zero) + ImGui.Image(ptr, size, Vector2.Zero, Vector2.One, tint); + else + ImGui.Dummy(size); + } + else + { + ImGuiUtil.HoverIcon(ptr, textureSize, size); + } + } + + public static void DrawIcon(this BonusItem item, TextureService textures, Vector2 size, BonusItemFlag slot) + { + var isEmpty = item.ModelId.Id == 0; + var (ptr, textureSize, empty) = textures.GetIcon(item, slot); + if (empty) + { + var (bgColor, tint) = isEmpty + ? (ImGui.GetColorU32(ImGuiCol.FrameBg), Vector4.One) + : (ImGui.GetColorU32(ImGuiCol.FrameBgActive), new Vector4(0.3f, 0.3f, 0.3f, 1f)); var pos = ImGui.GetCursorScreenPos(); ImGui.GetWindowDrawList().AddRectFilled(pos, pos + size, bgColor, 5 * ImGuiHelpers.GlobalScale); if (ptr != nint.Zero) diff --git a/Glamourer/Interop/Material/DirectXService.cs b/Glamourer/Interop/Material/DirectXService.cs index 6d9c71b..3316491 100644 --- a/Glamourer/Interop/Material/DirectXService.cs +++ b/Glamourer/Interop/Material/DirectXService.cs @@ -15,13 +15,13 @@ namespace Glamourer.Interop.Material; public unsafe class DirectXService(IFramework framework) : IService { private readonly object _lock = new(); - private readonly ConcurrentDictionary _textures = []; + private readonly ConcurrentDictionary _textures = []; /// Generate a color table the way the game does inside the original texture, and release the original. /// The original texture that will be replaced with a new one. /// The input color table. /// Success or failure. - public bool ReplaceColorTable(Texture** original, in LegacyColorTable colorTable) + public bool ReplaceColorTable(Texture** original, in ColorTable colorTable) { if (original == null) return false; @@ -38,7 +38,7 @@ public unsafe class DirectXService(IFramework framework) : IService if (texture.IsInvalid) return false; - fixed (LegacyColorTable* ptr = &colorTable) + fixed (ColorTable* ptr = &colorTable) { if (!texture.Texture->InitializeContents(ptr)) return false; @@ -51,7 +51,7 @@ public unsafe class DirectXService(IFramework framework) : IService return true; } - public bool TryGetColorTable(Texture* texture, out LegacyColorTable table) + public bool TryGetColorTable(Texture* texture, out ColorTable table) { if (_textures.TryGetValue((nint)texture, out var p) && framework.LastUpdateUTC == p.Update) { @@ -73,7 +73,7 @@ public unsafe class DirectXService(IFramework framework) : IService /// A pointer to the internal texture struct containing the GPU handle. /// The returned color table. /// Whether the table could be fetched. - private static bool TextureColorTable(Texture* texture, out LegacyColorTable table) + private static bool TextureColorTable(Texture* texture, out ColorTable table) { if (texture == null) { @@ -114,7 +114,7 @@ public unsafe class DirectXService(IFramework framework) : IService } /// Turn a mapped texture into a color table. - private static LegacyColorTable GetTextureData(ID3D11Texture2D1 resource, MappedSubresource map) + private static ColorTable GetTextureData(ID3D11Texture2D1 resource, MappedSubresource map) { var desc = resource.Description1; @@ -133,14 +133,14 @@ public unsafe class DirectXService(IFramework framework) : IService /// The height of the texture. (Needs to be 16). /// The stride in the texture data. /// - private static LegacyColorTable ReadTexture(nint data, int length, int height, int pitch) + private static ColorTable ReadTexture(nint data, int length, int height, int pitch) { // Check that the data has sufficient dimension and size. var expectedSize = sizeof(Half) * MaterialService.TextureWidth * height * 4; - if (length < expectedSize || sizeof(LegacyColorTable) != expectedSize || height != MaterialService.TextureHeight) + if (length < expectedSize || sizeof(ColorTable) != expectedSize || height != MaterialService.TextureHeight) return default; - var ret = new LegacyColorTable(); + var ret = new ColorTable(); var target = (byte*)&ret; // If the stride is the same as in the table, just copy. if (pitch == MaterialService.TextureWidth) diff --git a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs index aa4c358..a9f3a74 100644 --- a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs +++ b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs @@ -13,11 +13,11 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable private readonly DirectXService _directXService; public MaterialValueIndex LastValueIndex { get; private set; } = MaterialValueIndex.Invalid; - public LegacyColorTable LastOriginalColorTable { get; private set; } + public ColorTable LastOriginalColorTable { get; private set; } private MaterialValueIndex _valueIndex = MaterialValueIndex.Invalid; private ObjectIndex _lastObjectIndex = ObjectIndex.AnyIndex; private ObjectIndex _objectIndex = ObjectIndex.AnyIndex; - private LegacyColorTable _originalColorTable; + private ColorTable _originalColorTable; public LiveColorTablePreviewer(global::Penumbra.GameData.Interop.ObjectManager objects, IFramework framework, DirectXService directXService) { @@ -78,7 +78,7 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable } else { - for (var i = 0; i < LegacyColorTable.NumUsedRows; ++i) + for (var i = 0; i < ColorTable.NumUsedRows; ++i) { table[i].Diffuse = diffuse; table[i].Emissive = emissive; @@ -92,7 +92,7 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable _objectIndex = ObjectIndex.AnyIndex; } - public void OnHover(MaterialValueIndex index, ObjectIndex objectIndex, LegacyColorTable table) + public void OnHover(MaterialValueIndex index, ObjectIndex objectIndex, ColorTable table) { if (_valueIndex.DrawObject is not MaterialValueIndex.DrawObjectType.Invalid) return; diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 3e984c8..5f2b553 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -40,6 +40,8 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable private void OnPrepareColorSet(CharacterBase* characterBase, MaterialResourceHandle* material, ref StainId stain, ref nint ret) { + // TODO fix when working + return; if (!_config.UseAdvancedDyes) return; @@ -76,7 +78,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// Update and apply the glamourer state of an actor according to the application sources when updated by the game. private void UpdateMaterialValues(ActorState state, ReadOnlySpan<(uint Key, MaterialValueState Value)> values, CharacterWeapon drawData, - ref LegacyColorTable colorTable) + ref ColorTable colorTable) { var deleteList = _deleteList.Value!; deleteList.Clear(); diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index 4c8706c..b2626be 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -9,11 +9,11 @@ namespace Glamourer.Interop.Material; public static unsafe class MaterialService { - public const int TextureWidth = 4; - public const int TextureHeight = LegacyColorTable.NumUsedRows; - public const int MaterialsPerModel = 4; + public const int TextureWidth = 8; + public const int TextureHeight = ColorTable.NumUsedRows; + public const int MaterialsPerModel = 10; - public static bool GenerateNewColorTable(in LegacyColorTable colorTable, out Texture* texture) + public static bool GenerateNewColorTable(in ColorTable colorTable, out Texture* texture) { var textureSize = stackalloc int[2]; textureSize[0] = TextureWidth; @@ -24,7 +24,7 @@ public static unsafe class MaterialService if (texture == null) return false; - fixed (LegacyColorTable* ptr = &colorTable) + fixed (ColorTable* ptr = &colorTable) { return texture->InitializeContents(ptr); } @@ -53,7 +53,7 @@ public static unsafe class MaterialService /// The model slot. /// The material slot in the model. /// A pointer to the color table or null. - public static LegacyColorTable* GetMaterialColorTable(Model model, int modelSlot, byte materialSlot) + public static ColorTable* GetMaterialColorTable(Model model, int modelSlot, byte materialSlot) { if (!model.IsCharacterBase) return null; @@ -66,6 +66,6 @@ public static unsafe class MaterialService if (material == null || material->ColorTable == null) return null; - return (LegacyColorTable*)material->ColorTable; + return (ColorTable*)material->ColorTable; } } diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 254675e..8101c05 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -149,7 +149,7 @@ public readonly record struct MaterialValueIndex( => materialIndex < MaterialService.MaterialsPerModel; public static bool ValidateRow(byte rowIndex) - => rowIndex < LegacyColorTable.NumUsedRows; + => rowIndex < ColorTable.NumUsedRows; private static uint ToKey(DrawObjectType type, byte slotIndex, byte materialIndex, byte rowIndex) { diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index ae08c71..897f1bf 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -21,7 +21,7 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa public float SpecularStrength = specularStrength; public float GlossStrength = glossStrength; - public ColorRow(in LegacyColorTable.Row row) + public ColorRow(in ColorTable.Row row) : this(Root(row.Diffuse), Root(row.Specular), Root(row.Emissive), row.SpecularStrength, row.GlossStrength) { } @@ -44,7 +44,7 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa private static float Root(float value) => value < 0 ? MathF.Sqrt(-value) : MathF.Sqrt(value); - public readonly bool Apply(ref LegacyColorTable.Row row) + public readonly bool Apply(ref ColorTable.Row row) { var ret = false; var d = Square(Diffuse); diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 3866d74..cdbff11 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -56,7 +56,7 @@ public sealed unsafe class PrepareColorSet } public static bool TryGetColorTable(CharacterBase* characterBase, MaterialResourceHandle* material, StainIds stainIds, - out LegacyColorTable table) + out ColorTable table) { if (material->ColorTable == null) { @@ -64,7 +64,7 @@ public sealed unsafe class PrepareColorSet return false; } - var newTable = *(LegacyColorTable*)material->ColorTable; + var newTable = *(ColorTable*)material->ColorTable; // TODO //if (stainIds.Stain1.Id != 0 || stainIds.Stain2.Id != 0) // characterBase->ReadStainingTemplate(material, stainId.Id, (Half*)(&newTable)); @@ -73,7 +73,7 @@ public sealed unsafe class PrepareColorSet } /// Assumes the actor is valid. - public static bool TryGetColorTable(Actor actor, MaterialValueIndex index, out LegacyColorTable table) + public static bool TryGetColorTable(Actor actor, MaterialValueIndex index, out ColorTable table) { var idx = index.SlotIndex * MaterialService.MaterialsPerModel + index.MaterialIndex; if (!index.TryGetModel(actor, out var model)) diff --git a/Glamourer/Interop/WeaponService.cs b/Glamourer/Interop/WeaponService.cs index 5ab2a40..b0bdd19 100644 --- a/Glamourer/Interop/WeaponService.cs +++ b/Glamourer/Interop/WeaponService.cs @@ -13,7 +13,6 @@ public unsafe class WeaponService : IDisposable private readonly WeaponLoading _event; private readonly ThreadLocal _inUpdate = new(() => false); - private readonly delegate* unmanaged[Stdcall] _original; diff --git a/Glamourer/Services/TextureService.cs b/Glamourer/Services/TextureService.cs index 99436e4..e08ab44 100644 --- a/Glamourer/Services/TextureService.cs +++ b/Glamourer/Services/TextureService.cs @@ -23,6 +23,21 @@ public sealed class TextureService(IUiBuilder uiBuilder, IDataManager dataManage : (nint.Zero, Vector2.Zero, true); } + public (nint, Vector2, bool) GetIcon(BonusItem item, BonusItemFlag slot) + { + if (item.Icon.Id != 0 && TryLoadIcon(item.Icon.Id, out var ret)) + return (ret.ImGuiHandle, new Vector2(ret.Width, ret.Height), false); + + var idx = slot.ToIndex(); + if (idx == uint.MaxValue) + return (nint.Zero, Vector2.Zero, true); + + idx += 12; + return idx < 13 && _slotIcons[idx] != null + ? (_slotIcons[idx]!.ImGuiHandle, new Vector2(_slotIcons[idx]!.Width, _slotIcons[idx]!.Height), true) + : (nint.Zero, Vector2.Zero, true); + } + public void Dispose() { for (var i = 0; i < _slotIcons.Length; ++i) @@ -34,9 +49,9 @@ public sealed class TextureService(IUiBuilder uiBuilder, IDataManager dataManage private static IDalamudTextureWrap?[] CreateSlotIcons(IUiBuilder uiBuilder) { - var ret = new IDalamudTextureWrap?[12]; + var ret = new IDalamudTextureWrap?[13]; - using var uldWrapper = uiBuilder.LoadUld("ui/uld/ArmouryBoard.uld"); + using var uldWrapper = uiBuilder.LoadUld("ui/uld/Character.uld"); if (!uldWrapper.Valid) { @@ -44,33 +59,37 @@ public sealed class TextureService(IUiBuilder uiBuilder, IDataManager dataManage return ret; } - SetIcon(EquipSlot.Head, 1); - SetIcon(EquipSlot.Body, 2); - SetIcon(EquipSlot.Hands, 3); - SetIcon(EquipSlot.Legs, 5); - SetIcon(EquipSlot.Feet, 6); - SetIcon(EquipSlot.Ears, 8); - SetIcon(EquipSlot.Neck, 9); - SetIcon(EquipSlot.Wrists, 10); - SetIcon(EquipSlot.RFinger, 11); - SetIcon(EquipSlot.MainHand, 0); - SetIcon(EquipSlot.OffHand, 7); + SetIcon(EquipSlot.Head, 19); + SetIcon(EquipSlot.Body, 20); + SetIcon(EquipSlot.Hands, 21); + SetIcon(EquipSlot.Legs, 23); + SetIcon(EquipSlot.Feet, 24); + SetIcon(EquipSlot.Ears, 25); + SetIcon(EquipSlot.Neck, 26); + SetIcon(EquipSlot.Wrists, 27); + SetIcon(EquipSlot.RFinger, 28); + SetIcon(EquipSlot.MainHand, 17); + SetIcon(EquipSlot.OffHand, 18); + Set(BonusItemFlag.Glasses.ToName(), (int) BonusItemFlag.Glasses.ToIndex() + 12, 55); ret[EquipSlot.LFinger.ToIndex()] = ret[EquipSlot.RFinger.ToIndex()]; return ret; - void SetIcon(EquipSlot slot, int index) + void Set(string name, int slot, int index) { try { - ret[slot.ToIndex()] = uldWrapper.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", index)!; + ret[slot] = uldWrapper.LoadTexturePart("ui/uld/Character_hr1.tex", index)!; } catch (Exception ex) { - Glamourer.Log.Error($"Could not get empty slot texture for {slot.ToName()}, icon will be left empty. " + Glamourer.Log.Error($"Could not get empty slot texture for {name}, icon will be left empty. " + $"This may be because of incompatible mods affecting your character screen interface:\n{ex}"); - ret[slot.ToIndex()] = null; + ret[slot] = null; } } + + void SetIcon(EquipSlot slot, int index) + => Set(slot.ToName(), (int)slot.ToIndex(), index); } } diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index a4a1df4..2af6437 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -306,6 +306,8 @@ public class StateApplier( public unsafe void ChangeMaterialValue(ActorData data, MaterialValueIndex index, ColorRow? value, bool force) { + // TODO fix when working + return; if (!force && !_config.UseAdvancedDyes) return; @@ -338,6 +340,8 @@ public class StateApplier( public unsafe void ChangeMaterialValues(ActorData data, in StateMaterialManager materials, bool force) { + // TODO: fix when working + return; if (!force && !_config.UseAdvancedDyes) return; @@ -383,6 +387,11 @@ public class StateApplier( ChangeCustomize(actors, state.ModelData.Customize); foreach (var slot in EquipSlotExtensions.EqdpSlots) ChangeArmor(actors, slot, state.ModelData.Armor(slot), !state.Sources[slot, false].IsIpc(), state.ModelData.IsHatVisible()); + foreach (var slot in BonusExtensions.AllFlags) + { + var item = state.ModelData.BonusItem(slot); + ChangeBonusItem(actors, slot, item.ModelId, item.Variant); + } var mainhandActors = state.ModelData.MainhandType != state.BaseData.MainhandType ? actors.OnlyGPose() : actors; ChangeMainhand(mainhandActors, state.ModelData.Item(EquipSlot.MainHand), state.ModelData.Stain(EquipSlot.MainHand)); diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index c39fd31..c627564 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -175,7 +175,7 @@ public class StateEditor( var @new = state.ModelData.Parameters[flag]; var actors = Applier.ChangeParameters(state, flag, settings.Source.RequiresChange()); Glamourer.Log.Verbose( - $"Set {flag} crest in state {state.Identifier.Incognito(null)} from {old} to {@new}. [Affecting {actors.ToLazyString("nothing")}.]"); + $"Set {flag} in state {state.Identifier.Incognito(null)} from {old} to {@new}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Parameter, settings.Source, state, actors, (old, @new, flag)); } diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index a569499..e1c4ea0 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -110,7 +110,9 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators new StateIndex(ParamHairSpecular), CustomizeParameterFlag.HairHighlight => new StateIndex(ParamHairHighlight), CustomizeParameterFlag.LeftEye => new StateIndex(ParamLeftEye), + CustomizeParameterFlag.LeftScleraIntensity => new StateIndex(ParamLeftScleraIntensity), CustomizeParameterFlag.RightEye => new StateIndex(ParamRightEye), + CustomizeParameterFlag.RightScleraIntensity => new StateIndex(ParamRightScleraIntensity), CustomizeParameterFlag.FeatureColor => new StateIndex(ParamFeatureColor), CustomizeParameterFlag.FacePaintUvMultiplier => new StateIndex(ParamFacePaintUvMultiplier), CustomizeParameterFlag.FacePaintUvOffset => new StateIndex(ParamFacePaintUvOffset), @@ -199,8 +201,10 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators CustomizeParameterFlag.HairSpecular, ParamHairHighlight => CustomizeParameterFlag.HairHighlight, ParamLeftEye => CustomizeParameterFlag.LeftEye, + ParamLeftScleraIntensity => CustomizeParameterFlag.LeftScleraIntensity, ParamRightEye => CustomizeParameterFlag.RightEye, + ParamRightScleraIntensity => CustomizeParameterFlag.RightScleraIntensity, ParamFeatureColor => CustomizeParameterFlag.FeatureColor, ParamFacePaintUvMultiplier => CustomizeParameterFlag.FacePaintUvMultiplier, ParamFacePaintUvOffset => CustomizeParameterFlag.FacePaintUvOffset, @@ -320,103 +326,6 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators -1, }; - public object? GetValue(in DesignData data) - { - return Value switch - { - EquipHead => data.Item(EquipSlot.Head), - EquipBody => data.Item(EquipSlot.Body), - EquipHands => data.Item(EquipSlot.Hands), - EquipLegs => data.Item(EquipSlot.Legs), - EquipFeet => data.Item(EquipSlot.Feet), - EquipEars => data.Item(EquipSlot.Ears), - EquipNeck => data.Item(EquipSlot.Neck), - EquipWrist => data.Item(EquipSlot.Wrists), - EquipRFinger => data.Item(EquipSlot.RFinger), - EquipLFinger => data.Item(EquipSlot.LFinger), - EquipMainhand => data.Item(EquipSlot.MainHand), - EquipOffhand => data.Item(EquipSlot.OffHand), - - StainHead => data.Stain(EquipSlot.Head), - StainBody => data.Stain(EquipSlot.Body), - StainHands => data.Stain(EquipSlot.Hands), - StainLegs => data.Stain(EquipSlot.Legs), - StainFeet => data.Stain(EquipSlot.Feet), - StainEars => data.Stain(EquipSlot.Ears), - StainNeck => data.Stain(EquipSlot.Neck), - StainWrist => data.Stain(EquipSlot.Wrists), - StainRFinger => data.Stain(EquipSlot.RFinger), - StainLFinger => data.Stain(EquipSlot.LFinger), - StainMainhand => data.Stain(EquipSlot.MainHand), - StainOffhand => data.Stain(EquipSlot.OffHand), - - CustomizeRace => data.Customize[CustomizeIndex.Race], - CustomizeGender => data.Customize[CustomizeIndex.Gender], - CustomizeBodyType => data.Customize[CustomizeIndex.BodyType], - CustomizeHeight => data.Customize[CustomizeIndex.Height], - CustomizeClan => data.Customize[CustomizeIndex.Clan], - CustomizeFace => data.Customize[CustomizeIndex.Face], - CustomizeHairstyle => data.Customize[CustomizeIndex.Hairstyle], - CustomizeHighlights => data.Customize[CustomizeIndex.Highlights], - CustomizeSkinColor => data.Customize[CustomizeIndex.SkinColor], - CustomizeEyeColorRight => data.Customize[CustomizeIndex.EyeColorRight], - CustomizeHairColor => data.Customize[CustomizeIndex.HairColor], - CustomizeHighlightsColor => data.Customize[CustomizeIndex.HighlightsColor], - CustomizeFacialFeature1 => data.Customize[CustomizeIndex.FacialFeature1], - CustomizeFacialFeature2 => data.Customize[CustomizeIndex.FacialFeature2], - CustomizeFacialFeature3 => data.Customize[CustomizeIndex.FacialFeature3], - CustomizeFacialFeature4 => data.Customize[CustomizeIndex.FacialFeature4], - CustomizeFacialFeature5 => data.Customize[CustomizeIndex.FacialFeature5], - CustomizeFacialFeature6 => data.Customize[CustomizeIndex.FacialFeature6], - CustomizeFacialFeature7 => data.Customize[CustomizeIndex.FacialFeature7], - CustomizeLegacyTattoo => data.Customize[CustomizeIndex.LegacyTattoo], - CustomizeTattooColor => data.Customize[CustomizeIndex.TattooColor], - CustomizeEyebrows => data.Customize[CustomizeIndex.Eyebrows], - CustomizeEyeColorLeft => data.Customize[CustomizeIndex.EyeColorLeft], - CustomizeEyeShape => data.Customize[CustomizeIndex.EyeShape], - CustomizeSmallIris => data.Customize[CustomizeIndex.SmallIris], - CustomizeNose => data.Customize[CustomizeIndex.Nose], - CustomizeJaw => data.Customize[CustomizeIndex.Jaw], - CustomizeMouth => data.Customize[CustomizeIndex.Mouth], - CustomizeLipstick => data.Customize[CustomizeIndex.Lipstick], - CustomizeLipColor => data.Customize[CustomizeIndex.LipColor], - CustomizeMuscleMass => data.Customize[CustomizeIndex.MuscleMass], - CustomizeTailShape => data.Customize[CustomizeIndex.TailShape], - CustomizeBustSize => data.Customize[CustomizeIndex.BustSize], - CustomizeFacePaint => data.Customize[CustomizeIndex.FacePaint], - CustomizeFacePaintReversed => data.Customize[CustomizeIndex.FacePaintReversed], - CustomizeFacePaintColor => data.Customize[CustomizeIndex.FacePaintColor], - - MetaWetness => data.GetMeta(MetaIndex.Wetness), - MetaHatState => data.GetMeta(MetaIndex.HatState), - MetaVisorState => data.GetMeta(MetaIndex.VisorState), - MetaWeaponState => data.GetMeta(MetaIndex.WeaponState), - MetaModelId => data.ModelId, - - CrestHead => data.Crest(CrestFlag.Head), - CrestBody => data.Crest(CrestFlag.Body), - CrestOffhand => data.Crest(CrestFlag.OffHand), - - ParamSkinDiffuse => data.Parameters[CustomizeParameterFlag.SkinDiffuse], - ParamMuscleTone => data.Parameters[CustomizeParameterFlag.MuscleTone], - ParamSkinSpecular => data.Parameters[CustomizeParameterFlag.SkinSpecular], - ParamLipDiffuse => data.Parameters[CustomizeParameterFlag.LipDiffuse], - ParamHairDiffuse => data.Parameters[CustomizeParameterFlag.HairDiffuse], - ParamHairSpecular => data.Parameters[CustomizeParameterFlag.HairSpecular], - ParamHairHighlight => data.Parameters[CustomizeParameterFlag.HairHighlight], - ParamLeftEye => data.Parameters[CustomizeParameterFlag.LeftEye], - ParamRightEye => data.Parameters[CustomizeParameterFlag.RightEye], - ParamFeatureColor => data.Parameters[CustomizeParameterFlag.FeatureColor], - ParamFacePaintUvMultiplier => data.Parameters[CustomizeParameterFlag.FacePaintUvMultiplier], - ParamFacePaintUvOffset => data.Parameters[CustomizeParameterFlag.FacePaintUvOffset], - ParamDecalColor => data.Parameters[CustomizeParameterFlag.DecalColor], - - BonusItemGlasses => data.BonusItem(BonusItemFlag.Glasses), - - _ => null, - }; - } - private static string GetName(EquipFlag flag) { var slot = flag.ToSlot(out var stain); diff --git a/Penumbra.GameData b/Penumbra.GameData index 8928015..491b619 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 8928015f38f951810a9a6fbb44fb4a0cb9a712dd +Subproject commit 491b61916951b7192bb2354d725363340ea153b5 From 717f9eb39390fac7400bb6d2ed0ce2340bf2f790 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 22:10:35 +0200 Subject: [PATCH 016/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 491b619..67109fa 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 491b61916951b7192bb2354d725363340ea153b5 +Subproject commit 67109fa9e89d5ff5c9f93705208db92e836e9ef4 From 303001fed0528e733a01d16b0f4ec25dc8b8fc5b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 22:57:37 +0200 Subject: [PATCH 017/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 67109fa..45f2c90 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 67109fa9e89d5ff5c9f93705208db92e836e9ef4 +Subproject commit 45f2c901b3a0131eaee18b3520184baeb0d1049d From d3824d6a23aa733ff42739a9b1fccf0cb20e8a41 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 22:59:56 +0200 Subject: [PATCH 018/401] Fix some hrothgar gender change remainders. --- Glamourer/Services/CustomizeService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Glamourer/Services/CustomizeService.cs b/Glamourer/Services/CustomizeService.cs index 6505846..99c2b78 100644 --- a/Glamourer/Services/CustomizeService.cs +++ b/Glamourer/Services/CustomizeService.cs @@ -35,11 +35,10 @@ public sealed class CustomizeService( } if (applyWhich.HasFlag(CustomizeFlag.Gender)) - if (ret.Race is not Race.Hrothgar || newValues.Gender is not Gender.Female) - { - changed |= ChangeGender(ref ret, newValues.Gender); - applied |= CustomizeFlag.Gender; - } + { + changed |= ChangeGender(ref ret, newValues.Gender); + applied |= CustomizeFlag.Gender; + } if (applyWhich.HasFlag(CustomizeFlag.BodyType)) { @@ -91,7 +90,7 @@ public sealed class CustomizeService( /// Returns whether a gender is valid for the given race. [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public bool IsGenderValid(Race race, Gender gender) - => race is Race.Hrothgar ? gender == Gender.Male : CustomizeManager.Genders.Contains(gender); + => CustomizeManager.Genders.Contains(gender); /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] From c75315f0f780480e07f97ed2dbba7c48b4d113de Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 23:01:27 +0200 Subject: [PATCH 019/401] Update Repo. --- repo.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repo.json b/repo.json index c5ef399..2b7305c 100644 --- a/repo.json +++ b/repo.json @@ -21,7 +21,8 @@ "TestingAssemblyVersion": "1.2.3.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 10, + "DalamudApiLevel": 9, + "TestingDalamudApiLevel": 10, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From a5f35dbd17a80de4f11f139a2851184a13ad0cb1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 23:30:02 +0200 Subject: [PATCH 020/401] Revert legacy tattoo changes. --- .../Customization/CustomizationDrawer.Icon.cs | 29 ++++++++++++------- .../Gui/Customization/CustomizationDrawer.cs | 29 ++++++++++++++----- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index 8631481..baedc05 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -1,4 +1,5 @@ -using Glamourer.GameData; +using Dalamud.Interface.Textures.TextureWraps; +using Glamourer.GameData; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; @@ -197,16 +198,24 @@ public partial class CustomizationDrawer var face = _set.DataByValue(CustomizeIndex.Face, _customize.Face, out _, _customize.Face) < 0 ? _set.Faces[0].Value : _customize.Face; foreach (var (featureIdx, idx) in options.WithIndex()) { - using var id = SetId(featureIdx); - var enabled = _customize.Get(featureIdx) != CustomizeValue.Zero; - var feature = _set.Data(featureIdx, 0, face); - var icon = featureIdx == CustomizeIndex.LegacyTattoo - ? _legacyTattoo ?? _service.Manager.GetIcon(feature.IconId) - : _service.Manager.GetIcon(feature.IconId); - var hasIcon = icon.TryGetWrap(out var wrap, out _); + using var id = SetId(featureIdx); + var enabled = _customize.Get(featureIdx) != CustomizeValue.Zero; + var feature = _set.Data(featureIdx, 0, face); + bool hasIcon; + IDalamudTextureWrap? wrap; + var icon = _service.Manager.GetIcon(feature.IconId); + if (featureIdx is CustomizeIndex.LegacyTattoo) + { + wrap = _legacyTattoo; + hasIcon = wrap != null; + } + else + { + hasIcon = icon.TryGetWrap(out wrap, out _); + } + if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize, Vector2.Zero, Vector2.One, - (int)ImGui.GetStyle().FramePadding.X, - Vector4.Zero, enabled ? Vector4.One : _redTint)) + (int)ImGui.GetStyle().FramePadding.X, Vector4.Zero, enabled ? Vector4.One : _redTint)) { _customize.Set(featureIdx, enabled ? CustomizeValue.Zero : CustomizeValue.Max); Changed |= _currentFlag; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 384307c..a7fcda7 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -1,14 +1,13 @@ -using Dalamud.Interface.Internal; -using Dalamud.Interface.Textures; +using Dalamud.Interface.Textures; using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Interface.Utility; using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Glamourer.GameData; using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; -using OtterGui.Classes; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -16,15 +15,16 @@ using Penumbra.GameData.Structs; namespace Glamourer.Gui.Customization; public partial class CustomizationDrawer( - TextureCache textureCache, + ITextureProvider textures, CustomizeService _service, CodeService _codes, Configuration _config, FavoriteManager _favorites, HeightService _heightService) + : IDisposable { - private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f); - private readonly ISharedImmediateTexture? _legacyTattoo = GetLegacyTattooIcon(textureCache); + private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f); + private readonly IDalamudTextureWrap? _legacyTattoo = GetLegacyTattooIcon(textures); private Exception? _terminate; @@ -49,6 +49,9 @@ public partial class CustomizationDrawer( private float _raceSelectorWidth; private bool _withApply; + public void Dispose() + => _legacyTattoo?.Dispose(); + public bool Draw(CustomizeArray current, bool locked, bool lockedRedraw) { _withApply = false; @@ -189,6 +192,16 @@ public partial class CustomizationDrawer( _raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X; } - private static ISharedImmediateTexture? GetLegacyTattooIcon(TextureCache icons) - => icons.TextureProvider.GetFromManifestResource(Assembly.GetExecutingAssembly(), "Glamourer.LegacyTattoo.raw"); + private static IDalamudTextureWrap? GetLegacyTattooIcon(ITextureProvider textures) + { + using var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Glamourer.LegacyTattoo.raw"); + if (resource == null) + return null; + + var rawImage = new byte[resource.Length]; + var length = resource.Read(rawImage, 0, (int)resource.Length); + return length == resource.Length + ? textures.CreateFromRaw(RawImageSpecification.Rgba32(192, 192), rawImage, "Glamourer.LegacyTattoo") + : null; + } } From 51c7fc83dd6e7a85eea6a6dde25a7299fa57f9fd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 23:34:45 +0200 Subject: [PATCH 021/401] Woops. --- Glamourer/Glamourer.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 3251543..9a1b95b 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -49,7 +49,6 @@ $(AppData)\XIVLauncher\addon\Hooks\dev\ - H:\Projects\FFPlugins\Dalamud\bin\Release\ From 25491adbe36177dbff1a9d51994cf822533ef592 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 16 Jul 2024 23:42:39 +0200 Subject: [PATCH 022/401] Rename Sclera to Limbal --- Glamourer/GameData/CustomizeParameterData.cs | 36 +++++++++---------- Glamourer/GameData/CustomizeParameterFlag.cs | 12 +++---- .../DebugTab/AdvancedCustomizationDrawer.cs | 4 +-- Glamourer/State/StateIndex.cs | 16 ++++----- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Glamourer/GameData/CustomizeParameterData.cs b/Glamourer/GameData/CustomizeParameterData.cs index 09ce65a..97d8222 100644 --- a/Glamourer/GameData/CustomizeParameterData.cs +++ b/Glamourer/GameData/CustomizeParameterData.cs @@ -12,9 +12,9 @@ public struct CustomizeParameterData public Vector3 HairSpecular; public Vector3 HairHighlight; public Vector3 LeftEye; - public float LeftScleraIntensity; + public float LeftLimbalIntensity; public Vector3 RightEye; - public float RightScleraIntensity; + public float RightLimbalIntensity; public Vector3 FeatureColor; public float FacePaintUvMultiplier; public float FacePaintUvOffset; @@ -35,9 +35,9 @@ public struct CustomizeParameterData CustomizeParameterFlag.HairSpecular => new CustomizeParameterValue(HairSpecular), CustomizeParameterFlag.HairHighlight => new CustomizeParameterValue(HairHighlight), CustomizeParameterFlag.LeftEye => new CustomizeParameterValue(LeftEye), - CustomizeParameterFlag.LeftScleraIntensity => new CustomizeParameterValue(LeftScleraIntensity), + CustomizeParameterFlag.LeftLimbalIntensity => new CustomizeParameterValue(LeftLimbalIntensity), CustomizeParameterFlag.RightEye => new CustomizeParameterValue(RightEye), - CustomizeParameterFlag.RightScleraIntensity => new CustomizeParameterValue(RightScleraIntensity), + CustomizeParameterFlag.RightLimbalIntensity => new CustomizeParameterValue(RightLimbalIntensity), CustomizeParameterFlag.FeatureColor => new CustomizeParameterValue(FeatureColor), CustomizeParameterFlag.DecalColor => new CustomizeParameterValue(DecalColor), CustomizeParameterFlag.FacePaintUvMultiplier => new CustomizeParameterValue(FacePaintUvMultiplier), @@ -61,9 +61,9 @@ public struct CustomizeParameterData CustomizeParameterFlag.HairSpecular => SetIfDifferent(ref HairSpecular, value.InternalTriple), CustomizeParameterFlag.HairHighlight => SetIfDifferent(ref HairHighlight, value.InternalTriple), CustomizeParameterFlag.LeftEye => SetIfDifferent(ref LeftEye, value.InternalTriple), - CustomizeParameterFlag.LeftScleraIntensity => SetIfDifferent(ref LeftScleraIntensity, value.Single), + CustomizeParameterFlag.LeftLimbalIntensity => SetIfDifferent(ref LeftLimbalIntensity, value.Single), CustomizeParameterFlag.RightEye => SetIfDifferent(ref RightEye, value.InternalTriple), - CustomizeParameterFlag.RightScleraIntensity => SetIfDifferent(ref RightScleraIntensity, value.Single), + CustomizeParameterFlag.RightLimbalIntensity => SetIfDifferent(ref RightLimbalIntensity, value.Single), CustomizeParameterFlag.FeatureColor => SetIfDifferent(ref FeatureColor, value.InternalTriple), CustomizeParameterFlag.DecalColor => SetIfDifferent(ref DecalColor, value.InternalQuadruple), CustomizeParameterFlag.FacePaintUvMultiplier => SetIfDifferent(ref FacePaintUvMultiplier, value.Single), @@ -83,20 +83,20 @@ public struct CustomizeParameterData _ => new CustomizeParameterValue(SkinDiffuse, MuscleTone).XivQuadruple, }; - parameters.LeftColor = (flags & (CustomizeParameterFlag.LeftEye | CustomizeParameterFlag.LeftScleraIntensity)) switch + parameters.LeftColor = (flags & (CustomizeParameterFlag.LeftEye | CustomizeParameterFlag.LeftLimbalIntensity)) switch { 0 => parameters.LeftColor, CustomizeParameterFlag.LeftEye => new CustomizeParameterValue(LeftEye, parameters.LeftColor.W).XivQuadruple, - CustomizeParameterFlag.LeftScleraIntensity => parameters.LeftColor with { W = LeftScleraIntensity }, - _ => new CustomizeParameterValue(LeftEye, LeftScleraIntensity).XivQuadruple, + CustomizeParameterFlag.LeftLimbalIntensity => parameters.LeftColor with { W = LeftLimbalIntensity }, + _ => new CustomizeParameterValue(LeftEye, LeftLimbalIntensity).XivQuadruple, }; - parameters.RightColor = (flags & (CustomizeParameterFlag.RightEye | CustomizeParameterFlag.RightScleraIntensity)) switch + parameters.RightColor = (flags & (CustomizeParameterFlag.RightEye | CustomizeParameterFlag.RightLimbalIntensity)) switch { 0 => parameters.RightColor, CustomizeParameterFlag.RightEye => new CustomizeParameterValue(RightEye, parameters.RightColor.W).XivQuadruple, - CustomizeParameterFlag.RightScleraIntensity => parameters.RightColor with { W = RightScleraIntensity }, - _ => new CustomizeParameterValue(RightEye, RightScleraIntensity).XivQuadruple, + CustomizeParameterFlag.RightLimbalIntensity => parameters.RightColor with { W = RightLimbalIntensity }, + _ => new CustomizeParameterValue(RightEye, RightLimbalIntensity).XivQuadruple, }; if (flags.HasFlag(CustomizeParameterFlag.SkinSpecular)) @@ -165,11 +165,11 @@ public struct CustomizeParameterData case CustomizeParameterFlag.FacePaintUvOffset: GetUvOffsetWrite(ref parameters) = FacePaintUvOffset; break; - case CustomizeParameterFlag.LeftScleraIntensity: - parameters.LeftColor.W = LeftScleraIntensity; + case CustomizeParameterFlag.LeftLimbalIntensity: + parameters.LeftColor.W = LeftLimbalIntensity; break; - case CustomizeParameterFlag.RightScleraIntensity: - parameters.RightColor.W = RightScleraIntensity; + case CustomizeParameterFlag.RightLimbalIntensity: + parameters.RightColor.W = RightLimbalIntensity; break; } } @@ -187,9 +187,9 @@ public struct CustomizeParameterData HairSpecular = new CustomizeParameterValue(parameter.HairFresnelValue0).InternalTriple, HairHighlight = new CustomizeParameterValue(parameter.MeshColor).InternalTriple, LeftEye = new CustomizeParameterValue(parameter.LeftColor).InternalTriple, - LeftScleraIntensity = new CustomizeParameterValue(parameter.LeftColor.W).Single, + LeftLimbalIntensity = new CustomizeParameterValue(parameter.LeftColor.W).Single, RightEye = new CustomizeParameterValue(parameter.RightColor).InternalTriple, - RightScleraIntensity = new CustomizeParameterValue(parameter.RightColor.W).Single, + RightLimbalIntensity = new CustomizeParameterValue(parameter.RightColor.W).Single, FeatureColor = new CustomizeParameterValue(parameter.OptionColor).InternalTriple, DecalColor = FromParameter(decal), }; diff --git a/Glamourer/GameData/CustomizeParameterFlag.cs b/Glamourer/GameData/CustomizeParameterFlag.cs index aabcdae..009cfc6 100644 --- a/Glamourer/GameData/CustomizeParameterFlag.cs +++ b/Glamourer/GameData/CustomizeParameterFlag.cs @@ -16,8 +16,8 @@ public enum CustomizeParameterFlag : ushort FacePaintUvMultiplier = 0x0400, FacePaintUvOffset = 0x0800, DecalColor = 0x1000, - LeftScleraIntensity = 0x2000, - RightScleraIntensity = 0x4000, + LeftLimbalIntensity = 0x2000, + RightLimbalIntensity = 0x4000, } public static class CustomizeParameterExtensions @@ -31,8 +31,8 @@ public static class CustomizeParameterExtensions public const CustomizeParameterFlag RgbaQuadruples = CustomizeParameterFlag.DecalColor | CustomizeParameterFlag.LipDiffuse; public const CustomizeParameterFlag Percentages = CustomizeParameterFlag.MuscleTone - | CustomizeParameterFlag.LeftScleraIntensity - | CustomizeParameterFlag.RightScleraIntensity; + | CustomizeParameterFlag.LeftLimbalIntensity + | CustomizeParameterFlag.RightLimbalIntensity; public const CustomizeParameterFlag Values = CustomizeParameterFlag.FacePaintUvOffset | CustomizeParameterFlag.FacePaintUvMultiplier; @@ -67,8 +67,8 @@ public static class CustomizeParameterExtensions CustomizeParameterFlag.FacePaintUvMultiplier => "Multiplier for Face Paint", CustomizeParameterFlag.FacePaintUvOffset => "Offset of Face Paint", CustomizeParameterFlag.DecalColor => "Face Paint Color", - CustomizeParameterFlag.LeftScleraIntensity => "Left Sclera Intensity", - CustomizeParameterFlag.RightScleraIntensity => "Right Sclera Intensity", + CustomizeParameterFlag.LeftLimbalIntensity => "Left Limbal Ring Intensity", + CustomizeParameterFlag.RightLimbalIntensity => "Right Limbal Ring Intensity", _ => string.Empty, }; } diff --git a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs index 4d6a2cd..6f6d27a 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs @@ -117,11 +117,11 @@ public unsafe class AdvancedCustomizationDrawer(ObjectManager objects) : IGameDa 24 => "LeftEye.R"u8, 25 => "LeftEye.G"u8, 26 => "LeftEye.B"u8, - 27 => "LeftSclera"u8, + 27 => "LeftLimbal"u8, 28 => "RightEye.R"u8, 29 => "RightEye.G"u8, 30 => "RightEye.B"u8, - 31 => "RightSclera"u8, + 31 => "RightLimbal"u8, 32 => "Feature.R"u8, 33 => "Feature.G"u8, 34 => "Feature.B"u8, diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index e1c4ea0..0ac52ec 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -110,9 +110,9 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators new StateIndex(ParamHairSpecular), CustomizeParameterFlag.HairHighlight => new StateIndex(ParamHairHighlight), CustomizeParameterFlag.LeftEye => new StateIndex(ParamLeftEye), - CustomizeParameterFlag.LeftScleraIntensity => new StateIndex(ParamLeftScleraIntensity), + CustomizeParameterFlag.LeftLimbalIntensity => new StateIndex(ParamLeftLimbalIntensity), CustomizeParameterFlag.RightEye => new StateIndex(ParamRightEye), - CustomizeParameterFlag.RightScleraIntensity => new StateIndex(ParamRightScleraIntensity), + CustomizeParameterFlag.RightLimbalIntensity => new StateIndex(ParamRightLimbalIntensity), CustomizeParameterFlag.FeatureColor => new StateIndex(ParamFeatureColor), CustomizeParameterFlag.FacePaintUvMultiplier => new StateIndex(ParamFacePaintUvMultiplier), CustomizeParameterFlag.FacePaintUvOffset => new StateIndex(ParamFacePaintUvOffset), @@ -201,10 +201,10 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators CustomizeParameterFlag.HairSpecular, ParamHairHighlight => CustomizeParameterFlag.HairHighlight, ParamLeftEye => CustomizeParameterFlag.LeftEye, - ParamLeftScleraIntensity => CustomizeParameterFlag.LeftScleraIntensity, + ParamLeftLimbalIntensity => CustomizeParameterFlag.LeftLimbalIntensity, ParamRightEye => CustomizeParameterFlag.RightEye, - ParamRightScleraIntensity => CustomizeParameterFlag.RightScleraIntensity, + ParamRightLimbalIntensity => CustomizeParameterFlag.RightLimbalIntensity, ParamFeatureColor => CustomizeParameterFlag.FeatureColor, ParamFacePaintUvMultiplier => CustomizeParameterFlag.FacePaintUvMultiplier, ParamFacePaintUvOffset => CustomizeParameterFlag.FacePaintUvOffset, From 951c1670583d18a3c1ad03c0db09a1a84581853d Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 16 Jul 2024 21:45:00 +0000 Subject: [PATCH 023/401] [CI] Updating repo.json for testing_1.3.0.0 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 2b7305c..a958f36 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.2.3.3", + "TestingAssemblyVersion": "1.3.0.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From a807c9088529215e076fba25e929c1fc73608138 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 17 Jul 2024 00:29:53 +0200 Subject: [PATCH 024/401] Disable the currently outdated preparecolorset hook. --- Glamourer/Interop/Material/PrepareColorSet.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index cdbff11..6595c8f 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -21,9 +21,10 @@ public sealed unsafe class PrepareColorSet MaterialManager = 0, } + // TODO enable when working public PrepareColorSet(HookManager hooks) : base("Prepare Color Set ") - => _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, true); + => _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, false); private readonly Task> _task; From 3484a29f7af5373120bbdad3c79ffdf69a2bf289 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 17 Jul 2024 00:30:16 +0200 Subject: [PATCH 025/401] Disable shine parameter application rules. --- Glamourer/GameData/CustomizeParameterFlag.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/GameData/CustomizeParameterFlag.cs b/Glamourer/GameData/CustomizeParameterFlag.cs index 009cfc6..0c11d48 100644 --- a/Glamourer/GameData/CustomizeParameterFlag.cs +++ b/Glamourer/GameData/CustomizeParameterFlag.cs @@ -36,7 +36,7 @@ public static class CustomizeParameterExtensions public const CustomizeParameterFlag Values = CustomizeParameterFlag.FacePaintUvOffset | CustomizeParameterFlag.FacePaintUvMultiplier; - public static readonly IReadOnlyList AllFlags = [.. Enum.GetValues()]; + public static readonly IReadOnlyList AllFlags = [.. Enum.GetValues().Where(f => All.HasFlag(f))]; public static readonly IReadOnlyList RgbaFlags = AllFlags.Where(f => RgbaQuadruples.HasFlag(f)).ToArray(); public static readonly IReadOnlyList RgbFlags = AllFlags.Where(f => RgbTriples.HasFlag(f)).ToArray(); public static readonly IReadOnlyList PercentageFlags = AllFlags.Where(f => Percentages.HasFlag(f)).ToArray(); From b3818a90dfabe6c975c7afdcb23ab57161d72dd6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 17 Jul 2024 02:01:14 +0200 Subject: [PATCH 026/401] Fix design migrations and cma import. --- Glamourer/Designs/DesignBase64Migration.cs | 23 ++++++++++++---------- Glamourer/Interop/CharaFile/CmaFile.cs | 4 ++-- Penumbra.GameData | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Glamourer/Designs/DesignBase64Migration.cs b/Glamourer/Designs/DesignBase64Migration.cs index d6d0886..a60c527 100644 --- a/Glamourer/Designs/DesignBase64Migration.cs +++ b/Glamourer/Designs/DesignBase64Migration.cs @@ -95,8 +95,8 @@ public class DesignBase64Migration fixed (byte* ptr = bytes) { - var cur = (CharacterWeapon*)(ptr + 30); - var eq = (CharacterArmor*)(cur + 2); + var cur = (LegacyCharacterWeapon*)(ptr + 30); + var eq = (LegacyCharacterArmor*)(cur + 2); if (!humans.IsHuman(data.ModelId)) { @@ -116,7 +116,7 @@ public class DesignBase64Migration } data.SetItem(slot, item); - data.SetStain(slot, mdl.Stains); + data.SetStain(slot, mdl.Stain); } var main = cur[0].Skeleton.Id == 0 @@ -129,7 +129,7 @@ public class DesignBase64Migration } data.SetItem(EquipSlot.MainHand, main); - data.SetStain(EquipSlot.MainHand, cur[0].Stains); + data.SetStain(EquipSlot.MainHand, cur[0].Stain); EquipItem off; // Fist weapon hack @@ -140,7 +140,7 @@ public class DesignBase64Migration if (gauntlet.Valid) { data.SetItem(EquipSlot.Hands, gauntlet); - data.SetStain(EquipSlot.Hands, cur[0].Stains); + data.SetStain(EquipSlot.Hands, cur[0].Stain); } } else @@ -157,12 +157,13 @@ public class DesignBase64Migration } data.SetItem(EquipSlot.OffHand, off); - data.SetStain(EquipSlot.OffHand, cur[1].Stains); + data.SetStain(EquipSlot.OffHand, cur[1].Stain); return data; } } - public static unsafe string CreateOldBase64(in DesignData save, EquipFlag equipFlags, CustomizeFlag customizeFlags, MetaFlag meta, bool writeProtected, float alpha = 1.0f) + public static unsafe string CreateOldBase64(in DesignData save, EquipFlag equipFlags, CustomizeFlag customizeFlags, MetaFlag meta, + bool writeProtected, float alpha = 1.0f) { var data = stackalloc byte[Base64SizeV4]; data[0] = 5; @@ -185,10 +186,12 @@ public class DesignBase64Migration | (equipFlags.HasFlag(EquipFlag.RFinger) ? 0x04 : 0) | (equipFlags.HasFlag(EquipFlag.LFinger) ? 0x08 : 0)); save.Customize.Write(data + 4); - ((CharacterWeapon*)(data + 30))[0] = save.Item(EquipSlot.MainHand).Weapon(save.Stain(EquipSlot.MainHand)); - ((CharacterWeapon*)(data + 30))[1] = save.Item(EquipSlot.OffHand).Weapon(save.Stain(EquipSlot.OffHand)); + ((LegacyCharacterWeapon*)(data + 30))[0] = + new LegacyCharacterWeapon(save.Item(EquipSlot.MainHand).Weapon(save.Stain(EquipSlot.MainHand))); + ((LegacyCharacterWeapon*)(data + 30))[1] = + new LegacyCharacterWeapon(save.Item(EquipSlot.OffHand).Weapon(save.Stain(EquipSlot.OffHand))); foreach (var slot in EquipSlotExtensions.EqdpSlots) - ((CharacterArmor*)(data + 44))[slot.ToIndex()] = save.Item(slot).Armor(save.Stain(slot)); + ((LegacyCharacterArmor*)(data + 44))[slot.ToIndex()] = new LegacyCharacterArmor(save.Item(slot).Armor(save.Stain(slot))); *(ushort*)(data + 84) = 1; // IsSet. *(float*)(data + 86) = 1f; data[90] = (byte)((save.IsHatVisible() ? 0x00 : 0x01) diff --git a/Glamourer/Interop/CharaFile/CmaFile.cs b/Glamourer/Interop/CharaFile/CmaFile.cs index da3fb43..2e06588 100644 --- a/Glamourer/Interop/CharaFile/CmaFile.cs +++ b/Glamourer/Interop/CharaFile/CmaFile.cs @@ -58,10 +58,10 @@ public sealed class CmaFile if (idx * 4 + 3 >= byteData.Length) continue; - var armor = ((CharacterArmor*)ptr)[idx]; + var armor = ((LegacyCharacterArmor*)ptr)[idx]; var item = items.Identify(slot, armor.Set, armor.Variant); data.SetItem(slot, item); - data.SetStain(slot, armor.Stains); + data.SetStain(slot, armor.Stain); } data.Customize.Read(ptr); diff --git a/Penumbra.GameData b/Penumbra.GameData index 45f2c90..c25ea7b 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 45f2c901b3a0131eaee18b3520184baeb0d1049d +Subproject commit c25ea7b19a6db37dd36e12b9a7a71f72a192ab57 From 1725dbb583648d9314dff4240dcb4ae00890a145 Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 17 Jul 2024 00:03:10 +0000 Subject: [PATCH 027/401] [CI] Updating repo.json for testing_1.3.0.1 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index a958f36..ff24a47 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.0", + "TestingAssemblyVersion": "1.3.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 124656c22e2c4e2cc0e7d2997c74c61f0d5a66a7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 17 Jul 2024 02:36:01 +0200 Subject: [PATCH 028/401] Fix advanced customize. --- Glamourer/GameData/CustomizeParameterData.cs | 26 +++++++++++++++----- Glamourer/GameData/CustomizeParameterFlag.cs | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Glamourer/GameData/CustomizeParameterData.cs b/Glamourer/GameData/CustomizeParameterData.cs index 97d8222..84d3e6a 100644 --- a/Glamourer/GameData/CustomizeParameterData.cs +++ b/Glamourer/GameData/CustomizeParameterData.cs @@ -73,7 +73,7 @@ public struct CustomizeParameterData } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public readonly unsafe void Apply(ref CustomizeParameter parameters, CustomizeParameterFlag flags = CustomizeParameterExtensions.All) + public readonly void Apply(ref CustomizeParameter parameters, CustomizeParameterFlag flags = CustomizeParameterExtensions.All) { parameters.SkinColor = (flags & (CustomizeParameterFlag.SkinDiffuse | CustomizeParameterFlag.MuscleTone)) switch { @@ -102,11 +102,25 @@ public struct CustomizeParameterData if (flags.HasFlag(CustomizeParameterFlag.SkinSpecular)) parameters.SkinFresnelValue0 = new CustomizeParameterValue(SkinSpecular).XivQuadruple; if (flags.HasFlag(CustomizeParameterFlag.HairDiffuse)) - parameters.MainColor = new CustomizeParameterValue(HairDiffuse).XivTriple; + { + // Vector3 is 0x10 byte for some reason. + var triple = new CustomizeParameterValue(HairDiffuse).XivTriple; + parameters.MainColor.X = triple.X; + parameters.MainColor.Y = triple.Y; + parameters.MainColor.Z = triple.Z; + } + if (flags.HasFlag(CustomizeParameterFlag.HairSpecular)) parameters.HairFresnelValue0 = new CustomizeParameterValue(HairSpecular).XivTriple; if (flags.HasFlag(CustomizeParameterFlag.HairHighlight)) - parameters.MeshColor = new CustomizeParameterValue(HairHighlight).XivTriple; + { + // Vector3 is 0x10 byte for some reason. + var triple = new CustomizeParameterValue(HairHighlight).XivTriple; + parameters.MeshColor.X = triple.X; + parameters.MeshColor.Y = triple.Y; + parameters.MeshColor.Z = triple.Z; + } + if (flags.HasFlag(CustomizeParameterFlag.FacePaintUvMultiplier)) GetUvMultiplierWrite(ref parameters) = FacePaintUvMultiplier; if (flags.HasFlag(CustomizeParameterFlag.FacePaintUvOffset)) @@ -125,7 +139,7 @@ public struct CustomizeParameterData } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public readonly unsafe void ApplySingle(ref CustomizeParameter parameters, CustomizeParameterFlag flag) + public readonly void ApplySingle(ref CustomizeParameter parameters, CustomizeParameterFlag flag) { switch (flag) { @@ -174,7 +188,7 @@ public struct CustomizeParameterData } } - public static unsafe CustomizeParameterData FromParameters(in CustomizeParameter parameter, in DecalParameters decal) + public static CustomizeParameterData FromParameters(in CustomizeParameter parameter, in DecalParameters decal) => new() { FacePaintUvOffset = GetUvOffset(parameter), @@ -194,7 +208,7 @@ public struct CustomizeParameterData DecalColor = FromParameter(decal), }; - public static unsafe CustomizeParameterValue FromParameter(in CustomizeParameter parameter, CustomizeParameterFlag flag) + public static CustomizeParameterValue FromParameter(in CustomizeParameter parameter, CustomizeParameterFlag flag) => flag switch { CustomizeParameterFlag.SkinDiffuse => new CustomizeParameterValue(parameter.SkinColor), diff --git a/Glamourer/GameData/CustomizeParameterFlag.cs b/Glamourer/GameData/CustomizeParameterFlag.cs index 0c11d48..3ef4cd4 100644 --- a/Glamourer/GameData/CustomizeParameterFlag.cs +++ b/Glamourer/GameData/CustomizeParameterFlag.cs @@ -23,7 +23,7 @@ public enum CustomizeParameterFlag : ushort public static class CustomizeParameterExtensions { // Speculars are not available anymore. - public const CustomizeParameterFlag All = (CustomizeParameterFlag)0x1FDB; + public const CustomizeParameterFlag All = (CustomizeParameterFlag)0x7FDB; public const CustomizeParameterFlag RgbTriples = All & ~(RgbaQuadruples | Percentages | Values); From 608ab7beb92cd22c1fce5ba3607a5a6bc82ab6b1 Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 17 Jul 2024 13:05:02 +0000 Subject: [PATCH 029/401] [CI] Updating repo.json for testing_1.3.0.2 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index ff24a47..922cd9d 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.1", + "TestingAssemblyVersion": "1.3.0.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From dae3fbc901f1c85eb6f7a3211531235c530e3754 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 17 Jul 2024 18:35:34 +0200 Subject: [PATCH 030/401] Update single-setter for 0x10 Vector3, too. --- Glamourer/GameData/CustomizeParameterData.cs | 12 ++++++++++-- Glamourer/GameData/CustomizeParameterFlag.cs | 2 +- Penumbra.GameData | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Glamourer/GameData/CustomizeParameterData.cs b/Glamourer/GameData/CustomizeParameterData.cs index 84d3e6a..3a04938 100644 --- a/Glamourer/GameData/CustomizeParameterData.cs +++ b/Glamourer/GameData/CustomizeParameterData.cs @@ -156,13 +156,21 @@ public struct CustomizeParameterData parameters.LipColor = new CustomizeParameterValue(LipDiffuse).XivQuadruple; break; case CustomizeParameterFlag.HairDiffuse: - parameters.MainColor = new CustomizeParameterValue(HairDiffuse).XivTriple; + // Vector3 is 0x10 byte for some reason. + var triple1 = new CustomizeParameterValue(HairDiffuse).XivTriple; + parameters.MainColor.X = triple1.X; + parameters.MainColor.Y = triple1.Y; + parameters.MainColor.Z = triple1.Z; break; case CustomizeParameterFlag.HairSpecular: parameters.HairFresnelValue0 = new CustomizeParameterValue(HairSpecular).XivTriple; break; case CustomizeParameterFlag.HairHighlight: - parameters.MeshColor = new CustomizeParameterValue(HairHighlight).XivTriple; + // Vector3 is 0x10 byte for some reason. + var triple2 = new CustomizeParameterValue(HairHighlight).XivTriple; + parameters.MeshColor.X = triple2.X; + parameters.MeshColor.Y = triple2.Y; + parameters.MeshColor.Z = triple2.Z; break; case CustomizeParameterFlag.LeftEye: parameters.LeftColor = new CustomizeParameterValue(LeftEye, parameters.LeftColor.W).XivQuadruple; diff --git a/Glamourer/GameData/CustomizeParameterFlag.cs b/Glamourer/GameData/CustomizeParameterFlag.cs index 3ef4cd4..ff804d4 100644 --- a/Glamourer/GameData/CustomizeParameterFlag.cs +++ b/Glamourer/GameData/CustomizeParameterFlag.cs @@ -63,7 +63,7 @@ public static class CustomizeParameterExtensions CustomizeParameterFlag.HairHighlight => "Hair Highlights", CustomizeParameterFlag.LeftEye => "Left Eye Color", CustomizeParameterFlag.RightEye => "Right Eye Color", - CustomizeParameterFlag.FeatureColor => "Tattoo Color", + CustomizeParameterFlag.FeatureColor => "Feature Color", CustomizeParameterFlag.FacePaintUvMultiplier => "Multiplier for Face Paint", CustomizeParameterFlag.FacePaintUvOffset => "Offset of Face Paint", CustomizeParameterFlag.DecalColor => "Face Paint Color", diff --git a/Penumbra.GameData b/Penumbra.GameData index c25ea7b..1236ae5 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit c25ea7b19a6db37dd36e12b9a7a71f72a192ab57 +Subproject commit 1236ae5cd1fd81d4f115789b48977a7ea3294332 From de9fb1fd9fef5047614923ac53867ba2b4ef354d Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 17 Jul 2024 16:41:59 +0000 Subject: [PATCH 031/401] [CI] Updating repo.json for testing_1.3.0.3 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 922cd9d..63922e6 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.2", + "TestingAssemblyVersion": "1.3.0.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 2f95a4ea34ea5bae25af3068f48d17ea07e57ff5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 19 Jul 2024 17:27:30 +0200 Subject: [PATCH 032/401] Update Advanced Dyes. --- Glamourer/Designs/DesignConverter.cs | 38 ++++++--- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 78 +++++++++++-------- Glamourer/Gui/Materials/MaterialDrawer.cs | 4 +- .../Material/LiveColorTablePreviewer.cs | 2 +- Glamourer/Interop/Material/MaterialManager.cs | 7 +- Glamourer/Interop/Material/MaterialService.cs | 10 +-- .../Interop/Material/MaterialValueIndex.cs | 22 +++++- Glamourer/Interop/Material/PrepareColorSet.cs | 67 ++++++++++++---- Glamourer/Interop/Material/UpdateColorSets.cs | 25 ++++++ Glamourer/State/StateApplier.cs | 4 - 10 files changed, 180 insertions(+), 77 deletions(-) create mode 100644 Glamourer/Interop/Material/UpdateColorSets.cs diff --git a/Glamourer/Designs/DesignConverter.cs b/Glamourer/Designs/DesignConverter.cs index c3235ab..2ebcea0 100644 --- a/Glamourer/Designs/DesignConverter.cs +++ b/Glamourer/Designs/DesignConverter.cs @@ -209,25 +209,43 @@ public class DesignConverter( } private static void ComputeMaterials(DesignMaterialManager manager, in StateMaterialManager materials, - EquipFlag equipFlags = EquipFlagExtensions.All) + EquipFlag equipFlags = EquipFlagExtensions.All, BonusItemFlag bonusFlags = BonusExtensions.All) { foreach (var (key, value) in materials.Values) { var idx = MaterialValueIndex.FromKey(key); - if (idx.RowIndex >= ColorTable.NumUsedRows) + if (idx.RowIndex >= ColorTable.NumRows) continue; if (idx.MaterialIndex >= MaterialService.MaterialsPerModel) continue; - var slot = idx.DrawObject switch + switch (idx.DrawObject) { - MaterialValueIndex.DrawObjectType.Human => idx.SlotIndex < 10 ? ((uint)idx.SlotIndex).ToEquipSlot() : EquipSlot.Unknown, - MaterialValueIndex.DrawObjectType.Mainhand when idx.SlotIndex == 0 => EquipSlot.MainHand, - MaterialValueIndex.DrawObjectType.Offhand when idx.SlotIndex == 0 => EquipSlot.OffHand, - _ => EquipSlot.Unknown, - }; - if (slot is EquipSlot.Unknown || (slot.ToBothFlags() & equipFlags) == 0) - continue; + case MaterialValueIndex.DrawObjectType.Mainhand when idx.SlotIndex == 0: + if ((equipFlags & (EquipFlag.Mainhand | EquipFlag.MainhandStain)) == 0) + continue; + + break; + case MaterialValueIndex.DrawObjectType.Offhand when idx.SlotIndex == 0: + if ((equipFlags & (EquipFlag.Offhand | EquipFlag.OffhandStain)) == 0) + continue; + + break; + case MaterialValueIndex.DrawObjectType.Human: + if (idx.SlotIndex < 10) + { + if ((((uint)idx.SlotIndex).ToEquipSlot().ToBothFlags() & equipFlags) == 0) + continue; + } + else if (idx.SlotIndex >= 16) + { + if (((idx.SlotIndex - 16u).ToBonusSlot() & bonusFlags) == 0) + continue; + } + + break; + default: continue; + } manager.AddOrUpdateValue(idx, value.Convert()); } diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 173109b..56f4d24 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -1,7 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; -using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using FFXIVClientStructs.Interop; using Glamourer.Designs; using Glamourer.Interop.Material; @@ -10,6 +9,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Services; +using OtterGui.Widgets; using Penumbra.GameData.Enums; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Interop; @@ -29,6 +29,9 @@ public sealed unsafe class AdvancedDyePopup( private byte _selectedMaterial = byte.MaxValue; private bool _anyChanged; + private const int RowsPerPage = 16; + private int _rowOffset; + private bool ShouldBeDrawn() { if (!config.UseAdvancedDyes) @@ -51,8 +54,6 @@ public sealed unsafe class AdvancedDyePopup( private void DrawButton(MaterialValueIndex index) { - // TODO fix when working - return; if (!config.UseAdvancedDyes) return; @@ -78,8 +79,8 @@ public sealed unsafe class AdvancedDyePopup( private (string Path, string GamePath) ResourceName(MaterialValueIndex index) { - var materialHandle = (MaterialResourceHandle*)_actor.Model.AsCharacterBase->MaterialsSpan[ - index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value; + var materialHandle = + _actor.Model.AsCharacterBase->Materials()[index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value; var model = _actor.Model.AsCharacterBase->ModelsSpan[index.SlotIndex].Value; var modelHandle = model == null ? null : model->ModelResourceHandle; var path = materialHandle == null @@ -129,17 +130,30 @@ public sealed unsafe class AdvancedDyePopup( if ((tab.Success || select is ImGuiTabItemFlags.SetSelected) && available) { _selectedMaterial = i; + DrawToggle(); DrawTable(index, table); } } + } - using (ImRaii.PushFont(UiBuilder.IconFont)) + private void DrawToggle() + { + var buttonWidth = new Vector2(ImGui.GetContentRegionAvail().X / 2, 0); + using var font = ImRaii.PushFont(UiBuilder.MonoFont); + using (ImRaii.Disabled(_rowOffset == 0)) { - if (ImGui.TabItemButton($"{FontAwesomeIcon.Times.ToIconString()} ", ImGuiTabItemFlags.NoTooltip)) - _drawIndex = null; + if (ToggleButton.ButtonEx("Row 1-16 ", buttonWidth, ImGuiButtonFlags.MouseButtonLeft, ImDrawFlags.RoundCornersLeft)) + _rowOffset = 0; } - ImGuiUtil.HoverTooltip("Close the advanced dye window."); + ImGui.SameLine(0, 0); + + + using (ImRaii.Disabled(_rowOffset == RowsPerPage)) + { + if (ToggleButton.ButtonEx("Row 17-32", buttonWidth, ImGuiButtonFlags.MouseButtonLeft, ImDrawFlags.RoundCornersRight)) + _rowOffset = RowsPerPage; + } } private void DrawContent(ReadOnlySpan> textures) @@ -169,7 +183,7 @@ public sealed unsafe class AdvancedDyePopup( } var size = new Vector2(7 * ImGui.GetFrameHeight() + 3 * ImGui.GetStyle().ItemInnerSpacing.X + 300 * ImGuiHelpers.GlobalScale, - 18 * ImGui.GetFrameHeightWithSpacing() + ImGui.GetStyle().WindowPadding.Y + 2 * ImGui.GetStyle().ItemSpacing.Y); + 19 * ImGui.GetFrameHeightWithSpacing() + ImGui.GetStyle().WindowPadding.Y + 3 * ImGui.GetStyle().ItemSpacing.Y); ImGui.SetNextWindowSize(size); var window = ImGui.Begin("###Glamourer Advanced Dyes", flags); @@ -197,12 +211,16 @@ public sealed unsafe class AdvancedDyePopup( private void DrawTable(MaterialValueIndex materialIndex, in ColorTable table) { + if (!materialIndex.Valid) + return; + using var disabled = ImRaii.Disabled(_state.IsLocked); _anyChanged = false; - for (byte i = 0; i < ColorTable.NumUsedRows; ++i) + for (byte i = 0; i < RowsPerPage; ++i) { - var index = materialIndex with { RowIndex = i }; - ref var row = ref table[i]; + var actualI = (byte)(i + _rowOffset); + var index = materialIndex with { RowIndex = actualI }; + ref var row = ref table[actualI]; DrawRow(ref row, index, table); } @@ -222,7 +240,7 @@ public sealed unsafe class AdvancedDyePopup( ImGui.AlignTextToFramePadding(); using (ImRaii.PushFont(UiBuilder.MonoFont)) { - ImGui.TextUnformatted("All Color Rows"); + ImGui.TextUnformatted("All Color Rows (1-32)"); } var spacing = ImGui.GetStyle().ItemInnerSpacing.X; @@ -247,7 +265,7 @@ public sealed unsafe class AdvancedDyePopup( ImGui.SameLine(0, spacing); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.UndoAlt.ToIconString(), buttonSize, "Reset this table to game state.", !_anyChanged, true)) - for (byte i = 0; i < ColorTable.NumUsedRows; ++i) + for (byte i = 0; i < ColorTable.NumRows; ++i) stateManager.ResetMaterialValue(_state, materialIndex with { RowIndex = i }, ApplySettings.Game); } @@ -259,9 +277,13 @@ public sealed unsafe class AdvancedDyePopup( { var internalRow = new ColorRow(row); var slot = index.ToEquipSlot(); - var weapon = slot is EquipSlot.MainHand or EquipSlot.OffHand - ? _state.ModelData.Weapon(slot) - : _state.ModelData.Armor(slot).ToWeapon(0); + var weapon = slot switch + { + EquipSlot.MainHand => _state.ModelData.Weapon(EquipSlot.MainHand), + EquipSlot.OffHand => _state.ModelData.Weapon(EquipSlot.OffHand), + EquipSlot.Unknown => _state.ModelData.BonusItem((index.SlotIndex - 16u).ToBonusSlot()).ToArmor().ToWeapon(0), + _ => _state.ModelData.Armor(slot).ToWeapon(0), + }; value = new MaterialValueState(internalRow, internalRow, weapon, StateSource.Manual); } else @@ -327,11 +349,11 @@ public sealed unsafe class AdvancedDyePopup( private struct LabelStruct { - private fixed byte _label[12]; + private fixed byte _label[5]; public ImRaii.IEndObject TabItem(byte materialIndex, ImGuiTabItemFlags flags) { - _label[10] = (byte)('1' + materialIndex); + _label[4] = (byte)('A' + materialIndex); fixed (byte* ptr = _label) { return ImRaii.TabItem(ptr, flags | ImGuiTabItemFlags.NoTooltip); @@ -340,17 +362,11 @@ public sealed unsafe class AdvancedDyePopup( public LabelStruct() { - _label[0] = (byte)'M'; - _label[1] = (byte)'a'; - _label[2] = (byte)'t'; - _label[3] = (byte)'e'; - _label[4] = (byte)'r'; - _label[5] = (byte)'i'; - _label[6] = (byte)'a'; - _label[7] = (byte)'l'; - _label[8] = (byte)' '; - _label[9] = (byte)'#'; - _label[11] = 0; + _label[0] = (byte)'M'; + _label[1] = (byte)'a'; + _label[2] = (byte)'t'; + _label[3] = (byte)' '; + _label[5] = 0; } } } diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index e7a061f..445184d 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -175,9 +175,9 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) { _newRowIdx += 1; ImGui.SetNextItemWidth(ImGui.CalcTextSize("Row #0000").X); - if (ImGui.DragInt("##Row", ref _newRowIdx, 0.01f, 1, ColorTable.NumUsedRows, "Row #%i")) + if (ImGui.DragInt("##Row", ref _newRowIdx, 0.01f, 1, ColorTable.NumRows, "Row #%i")) { - _newRowIdx = Math.Clamp(_newRowIdx, 1, ColorTable.NumUsedRows); + _newRowIdx = Math.Clamp(_newRowIdx, 1, ColorTable.NumRows); _newKey = _newKey with { RowIndex = (byte)(_newRowIdx - 1) }; } diff --git a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs index a9f3a74..1df85f6 100644 --- a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs +++ b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs @@ -78,7 +78,7 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable } else { - for (var i = 0; i < ColorTable.NumUsedRows; ++i) + for (var i = 0; i < ColorTable.NumRows; ++i) { table[i].Diffuse = diffuse; table[i].Emissive = emissive; diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 5f2b553..fe786d7 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -38,10 +38,8 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable public void Dispose() => _event.Unsubscribe(OnPrepareColorSet); - private void OnPrepareColorSet(CharacterBase* characterBase, MaterialResourceHandle* material, ref StainId stain, ref nint ret) + private void OnPrepareColorSet(CharacterBase* characterBase, MaterialResourceHandle* material, ref StainIds stain, ref nint ret) { - // TODO fix when working - return; if (!_config.UseAdvancedDyes) return; @@ -50,7 +48,6 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable var (slotId, materialId) = FindMaterial(characterBase, material); if (!validType - || slotId > 9 || type is not MaterialValueIndex.DrawObjectType.Human && slotId > 0 || !actor.Identifier(_actors, out var identifier) || !_stateManager.TryGetValue(identifier, out var state)) @@ -62,7 +59,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable if (values.Length == 0) return; - if (!PrepareColorSet.TryGetColorTable(characterBase, material, stain, out var baseColorSet)) + if (!PrepareColorSet.TryGetColorTable(material, stain, out var baseColorSet)) return; var drawData = type switch diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index b2626be..3e972a8 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -10,7 +10,7 @@ namespace Glamourer.Interop.Material; public static unsafe class MaterialService { public const int TextureWidth = 8; - public const int TextureHeight = ColorTable.NumUsedRows; + public const int TextureHeight = ColorTable.NumRows; public const int MaterialsPerModel = 10; public static bool GenerateNewColorTable(in ColorTable colorTable, out Texture* texture) @@ -41,10 +41,10 @@ public static unsafe class MaterialService return null; var index = modelSlot * MaterialsPerModel + materialSlot; - if (index < 0 || index >= model.AsCharacterBase->ColorTableTexturesSpan.Length) + if (index < 0 || index >= model.AsCharacterBase->ColorTableTextures().Length) return null; - var texture = (Texture**)Unsafe.AsPointer(ref model.AsCharacterBase->ColorTableTexturesSpan[index]); + var texture = (Texture**)Unsafe.AsPointer(ref model.AsCharacterBase->ColorTableTextures()[index]); return texture; } @@ -59,10 +59,10 @@ public static unsafe class MaterialService return null; var index = modelSlot * MaterialsPerModel + materialSlot; - if (index < 0 || index >= model.AsCharacterBase->MaterialsSpan.Length) + if (index < 0 || index >= model.AsCharacterBase->Materials().Length) return null; - var material = (MaterialResourceHandle*)model.AsCharacterBase->MaterialsSpan[index].Value; + var material = model.AsCharacterBase->Materials()[index].Value; if (material == null || material->ColorTable == null) return null; diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 8101c05..5c44e21 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -1,4 +1,6 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; +using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; +using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using FFXIVClientStructs.Interop; using Newtonsoft.Json; using Penumbra.GameData.Enums; @@ -79,13 +81,13 @@ public readonly record struct MaterialValueIndex( { if (!TryGetModel(actor, out var model) || SlotIndex >= model.AsCharacterBase->SlotCount - || model.AsCharacterBase->ColorTableTexturesSpan.Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) + || model.AsCharacterBase->ColorTableTextures().Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) { textures = []; return false; } - textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(SlotIndex * MaterialService.MaterialsPerModel, + textures = model.AsCharacterBase->ColorTableTextures().Slice(SlotIndex * MaterialService.MaterialsPerModel, MaterialService.MaterialsPerModel); return true; } @@ -139,7 +141,7 @@ public readonly record struct MaterialValueIndex( public static bool ValidateSlot(DrawObjectType type, byte slotIndex) => type switch { - DrawObjectType.Human => slotIndex < 14, + DrawObjectType.Human => slotIndex < 18, DrawObjectType.Mainhand => slotIndex == 0, DrawObjectType.Offhand => slotIndex == 0, _ => false, @@ -149,7 +151,7 @@ public readonly record struct MaterialValueIndex( => materialIndex < MaterialService.MaterialsPerModel; public static bool ValidateRow(byte rowIndex) - => rowIndex < ColorTable.NumUsedRows; + => rowIndex < ColorTable.NumRows; private static uint ToKey(DrawObjectType type, byte slotIndex, byte materialIndex, byte rowIndex) { @@ -174,6 +176,8 @@ public readonly record struct MaterialValueIndex( DrawObjectType.Human when SlotIndex == 11 => $"BodySlot.Face.ToString() Material #{MaterialIndex + 1} Row #{RowIndex + 1}", DrawObjectType.Human when SlotIndex == 12 => $"{BodySlot.Tail} / {BodySlot.Ear} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", DrawObjectType.Human when SlotIndex == 13 => $"Connectors Material #{MaterialIndex + 1} Row #{RowIndex + 1}", + DrawObjectType.Human when SlotIndex == 16 => $"{BonusItemFlag.Glasses.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", + DrawObjectType.Human when SlotIndex == 17 => $"{BonusItemFlag.UnkSlot.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", DrawObjectType.Mainhand when SlotIndex == 0 => $"{EquipSlot.MainHand.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", DrawObjectType.Offhand when SlotIndex == 0 => $"{EquipSlot.OffHand.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", _ => $"{DrawObject} Slot {SlotIndex} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", @@ -189,3 +193,13 @@ public readonly record struct MaterialValueIndex( => FromKey(serializer.Deserialize(reader), out var value) ? value : throw new Exception($"Invalid material key {value.Key}."); } } + +// TODO Remove when fixed in CS. +public static class ColorTableExtension +{ + public static unsafe Span> Materials(this ref CharacterBase character) + => new(character.Materials, character.SlotCount * MaterialService.MaterialsPerModel); + + public static unsafe Span> ColorTableTextures(this ref CharacterBase character) + => new(character.ColorTableTextures, character.SlotCount * MaterialService.MaterialsPerModel); +} diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 6595c8f..b8e31c2 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -13,18 +13,22 @@ using Penumbra.GameData.Structs; namespace Glamourer.Interop.Material; public sealed unsafe class PrepareColorSet - : EventWrapperPtr12Ref34, IHookService + : EventWrapperPtr12Ref34, IHookService { + private readonly UpdateColorSets _updateColorSets; + public enum Priority { /// MaterialManager = 0, } - // TODO enable when working - public PrepareColorSet(HookManager hooks) + public PrepareColorSet(HookManager hooks, UpdateColorSets updateColorSets) : base("Prepare Color Set ") - => _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, false); + { + _updateColorSets = updateColorSets; + _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, true); + } private readonly Task> _task; @@ -43,20 +47,25 @@ public sealed unsafe class PrepareColorSet public bool Finished => _task.IsCompletedSuccessfully; - private delegate Texture* Delegate(CharacterBase* characterBase, MaterialResourceHandle* material, StainId stainId); + private delegate Texture* Delegate(MaterialResourceHandle* material, StainId stainId1, StainId stainId2); - private Texture* Detour(CharacterBase* characterBase, MaterialResourceHandle* material, StainId stainId) + private Texture* Detour(MaterialResourceHandle* material, StainId stainId1, StainId stainId2) { - Glamourer.Log.Excessive($"[{Name}] Triggered with 0x{(nint)characterBase:X} 0x{(nint)material:X} {stainId.Id}."); - var ret = nint.Zero; - Invoke(characterBase, material, ref stainId, ref ret); + Glamourer.Log.Excessive($"[{Name}] Triggered with 0x{(nint)material:X} {stainId1.Id} {stainId2.Id}."); + var characterBase = _updateColorSets.Get(); + if (!characterBase.IsCharacterBase) + return _task.Result.Original(material, stainId1, stainId2); + + var ret = nint.Zero; + var stainIds = new StainIds(stainId1, stainId2); + Invoke(characterBase.AsCharacterBase, material, ref stainIds, ref ret); if (ret != nint.Zero) return (Texture*)ret; - return _task.Result.Original(characterBase, material, stainId); + return _task.Result.Original(material, stainIds.Stain1, stainIds.Stain2); } - public static bool TryGetColorTable(CharacterBase* characterBase, MaterialResourceHandle* material, StainIds stainIds, + public static bool TryGetColorTable(MaterialResourceHandle* material, StainIds stainIds, out ColorTable table) { if (material->ColorTable == null) @@ -66,9 +75,17 @@ public sealed unsafe class PrepareColorSet } var newTable = *(ColorTable*)material->ColorTable; - // TODO - //if (stainIds.Stain1.Id != 0 || stainIds.Stain2.Id != 0) - // characterBase->ReadStainingTemplate(material, stainId.Id, (Half*)(&newTable)); + if (GetDyeTable(material, out var dyeTable)) + { + if (stainIds.Stain1.Id != 0) + ((delegate* unmanaged)MaterialResourceHandle.MemberFunctionPointers + .ReadStainingTemplate)(material, dyeTable, stainIds.Stain1.Id, (Half*)(&newTable), 0); + + if (stainIds.Stain2.Id != 0) + ((delegate* unmanaged)MaterialResourceHandle.MemberFunctionPointers + .ReadStainingTemplate)(material, dyeTable, stainIds.Stain2.Id, (Half*)(&newTable), 1); + } + table = newTable; return true; } @@ -87,7 +104,7 @@ public sealed unsafe class PrepareColorSet return false; } - return TryGetColorTable(model.AsCharacterBase, handle, GetStains(), out table); + return TryGetColorTable(handle, GetStains(), out table); StainIds GetStains() { @@ -105,4 +122,24 @@ public sealed unsafe class PrepareColorSet } } } + + /// Get the correct dye table for a material. + private static bool GetDyeTable(MaterialResourceHandle* material, out ushort* ptr) + { + ptr = null; + if (material->AdditionalDataSize is 0 || material->AdditionalData is null) + return false; + + var flags1 = material->AdditionalData[0]; + if ((flags1 & 0xF0) is 0) + { + ptr = (ushort*)material + 0x100; + return true; + } + + var flags2 = material->AdditionalData[1]; + var offset = 4 * (1 << (flags1 >> 4)) * (1 << (flags2 & 0x0F)); + ptr = (ushort*)material->DataSet + offset; + return true; + } } diff --git a/Glamourer/Interop/Material/UpdateColorSets.cs b/Glamourer/Interop/Material/UpdateColorSets.cs new file mode 100644 index 0000000..a96c60f --- /dev/null +++ b/Glamourer/Interop/Material/UpdateColorSets.cs @@ -0,0 +1,25 @@ +using OtterGui.Services; +using Penumbra.GameData; +using Penumbra.GameData.Interop; + +namespace Glamourer.Interop.Material; + +public sealed class UpdateColorSets : FastHook +{ + public delegate void Delegate(Model model, uint unk); + + private readonly ThreadLocal _updatingModel = new(); + + public UpdateColorSets(HookManager hooks) + => Task = hooks.CreateHook("Update Color Sets", Sigs.UpdateColorSets, Detour, true); + + private void Detour(Model model, uint unk) + { + _updatingModel.Value = model; + Task.Result.Original(model, unk); + _updatingModel.Value = nint.Zero; + } + + public Model Get() + => _updatingModel.Value; +} diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 2af6437..66b83fb 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -306,8 +306,6 @@ public class StateApplier( public unsafe void ChangeMaterialValue(ActorData data, MaterialValueIndex index, ColorRow? value, bool force) { - // TODO fix when working - return; if (!force && !_config.UseAdvancedDyes) return; @@ -340,8 +338,6 @@ public class StateApplier( public unsafe void ChangeMaterialValues(ActorData data, in StateMaterialManager materials, bool force) { - // TODO: fix when working - return; if (!force && !_config.UseAdvancedDyes) return; From f66961661697b358eb3550c124c9ad1facdb3d9e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 19 Jul 2024 17:28:57 +0200 Subject: [PATCH 033/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 1236ae5..a304713 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 1236ae5cd1fd81d4f115789b48977a7ea3294332 +Subproject commit a30471344f971cc42828006dfa07d37317598a29 From ed329ec989afe55732d6c6d88c5e153b4d98b657 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 19 Jul 2024 15:30:58 +0000 Subject: [PATCH 034/401] [CI] Updating repo.json for testing_1.3.0.4 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 63922e6..38c9040 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.3", + "TestingAssemblyVersion": "1.3.0.4", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.4/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 3ad67f661a64454fc8e92a46236f0acfcecaa90c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 20 Jul 2024 21:41:43 +0200 Subject: [PATCH 035/401] Add Hrothgar face hacks to race changing fixing of values. --- Glamourer/Services/CustomizeService.cs | 24 +++++++++++++++++++++++- Penumbra.GameData | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Glamourer/Services/CustomizeService.cs b/Glamourer/Services/CustomizeService.cs index 99c2b78..74f0b5b 100644 --- a/Glamourer/Services/CustomizeService.cs +++ b/Glamourer/Services/CustomizeService.cs @@ -238,7 +238,29 @@ public sealed class CustomizeService( private static CustomizeFlag FixValues(CustomizeSet set, ref CustomizeArray customize) { CustomizeFlag flags = 0; - foreach (var idx in CustomizationExtensions.AllBasic) + + // Hrothgar face hack. + if (customize.Race is Race.Hrothgar) + { + if (customize.Face.Value is < 5) + { + customize.Face += 4; + flags |= CustomizeFlag.Face; + } + } + else if (customize.Face.Value is > 4 and < 9) + { + customize.Face -= 4; + flags |= CustomizeFlag.Face; + } + + if (ValidateCustomizeValue(set, customize.Face, CustomizeIndex.Face, customize.Face, out var fixedFace, false).Length > 0) + { + customize.Face = fixedFace; + flags |= CustomizeFlag.Face; + } + + foreach (var idx in CustomizationExtensions.AllBasicWithoutFace) { if (set.IsAvailable(idx)) { diff --git a/Penumbra.GameData b/Penumbra.GameData index a304713..da99d9b 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit a30471344f971cc42828006dfa07d37317598a29 +Subproject commit da99d9b2b3c51b2bbeb40226c692dff2cbcd5cbc From a885411a8c22d441ff70f3cda2bb928f264f8722 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 20 Jul 2024 21:47:00 +0200 Subject: [PATCH 036/401] Fix saving of favorites. --- Glamourer/Unlocks/FavoriteManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Glamourer/Unlocks/FavoriteManager.cs b/Glamourer/Unlocks/FavoriteManager.cs index f4576c6..229b8e6 100644 --- a/Glamourer/Unlocks/FavoriteManager.cs +++ b/Glamourer/Unlocks/FavoriteManager.cs @@ -94,28 +94,34 @@ public class FavoriteManager : ISavable using var j = new JsonTextWriter(writer); j.Formatting = Formatting.Indented; j.WriteStartObject(); + j.WritePropertyName(nameof(LoadIntermediary.Version)); j.WriteValue(CurrentVersion); + j.WritePropertyName(nameof(LoadIntermediary.FavoriteItems)); j.WriteStartArray(); foreach (var item in _favorites) j.WriteValue(item.Id); j.WriteEndArray(); + j.WritePropertyName(nameof(LoadIntermediary.FavoriteColors)); j.WriteStartArray(); foreach (var stain in _favoriteColors) j.WriteValue(stain.Id); j.WriteEndArray(); + j.WritePropertyName(nameof(LoadIntermediary.FavoriteHairStyles)); j.WriteStartArray(); foreach (var hairStyle in _favoriteHairStyles) j.WriteValue(hairStyle.ToValue()); j.WriteEndArray(); - j.WriteStartArray(); + j.WritePropertyName(nameof(LoadIntermediary.FavoriteBonusItems)); + j.WriteStartArray(); foreach (var item in _favoriteBonusItems) j.WriteValue(item.Id); j.WriteEndArray(); + j.WriteEndObject(); } From 55f2053fe67654fae3c4e89b288c232ad6e10042 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 20 Jul 2024 22:01:21 +0200 Subject: [PATCH 037/401] Fix BodyType not applying. --- Glamourer/Designs/ApplicationCollection.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Glamourer/Designs/ApplicationCollection.cs b/Glamourer/Designs/ApplicationCollection.cs index b31ff2e..0fd18f0 100644 --- a/Glamourer/Designs/ApplicationCollection.cs +++ b/Glamourer/Designs/ApplicationCollection.cs @@ -7,7 +7,7 @@ namespace Glamourer.Designs; public record struct ApplicationCollection( EquipFlag Equip, BonusItemFlag BonusItem, - CustomizeFlag Customize, + CustomizeFlag CustomizeRaw, CrestFlag Crest, CustomizeParameterFlag Parameters, MetaFlag Meta) @@ -15,10 +15,10 @@ public record struct ApplicationCollection( public static readonly ApplicationCollection All = new(EquipFlagExtensions.All, BonusExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.AllRelevant, CustomizeParameterExtensions.All, MetaExtensions.All); - public static readonly ApplicationCollection None = new(0, 0, 0, 0, 0, 0); + public static readonly ApplicationCollection None = new(0, 0, CustomizeFlag.BodyType, 0, 0, 0); public static readonly ApplicationCollection Equipment = new(EquipFlagExtensions.All, BonusExtensions.All, - 0, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState); + CustomizeFlag.BodyType, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState); public static readonly ApplicationCollection Customizations = new(0, 0, CustomizeFlagExtensions.AllRelevant, 0, CustomizeParameterExtensions.All, MetaFlag.Wetness); @@ -35,6 +35,12 @@ public record struct ApplicationCollection( (false, true) => Customizations, }; + public CustomizeFlag Customize + { + get => CustomizeRaw; + set => CustomizeRaw = value | CustomizeFlag.BodyType; + } + public void RemoveEquip() { Equip = 0; @@ -51,7 +57,7 @@ public record struct ApplicationCollection( } public ApplicationCollection Restrict(ApplicationCollection old) - => new(old.Equip & Equip, old.BonusItem & BonusItem, old.Customize & Customize, old.Crest & Crest, + => new(old.Equip & Equip, old.BonusItem & BonusItem, (old.Customize & Customize) | CustomizeFlag.BodyType, old.Crest & Crest, old.Parameters & Parameters, old.Meta & Meta); public ApplicationCollection CloneSecure() From 94b7ea2d9da66789c6bf36bf148c8f977be18ef7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 20 Jul 2024 23:42:04 +0200 Subject: [PATCH 038/401] Fix changed data offset for weapon. --- Glamourer/Interop/Material/MaterialManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index fe786d7..e695a90 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -198,11 +198,11 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// private static CharacterWeapon GetTempSlot(Weapon* weapon) { - // TODO: Fix offset - var changedData = *(void**)((byte*)weapon + 0x918); + var changedData = *(void**)((byte*)weapon + 0xA00); if (changedData == null) return new CharacterWeapon(weapon->ModelSetId, weapon->SecondaryId, (Variant)weapon->Variant, StainIds.FromWeapon(*weapon)); - return new CharacterWeapon(weapon->ModelSetId, *(SecondaryId*)changedData, ((Variant*)changedData)[2], new StainIds(((StainId*)changedData)[3], ((StainId*)changedData)[4])); + return new CharacterWeapon(weapon->ModelSetId, *(SecondaryId*)changedData, ((Variant*)changedData)[2], + new StainIds(((StainId*)changedData)[3], ((StainId*)changedData)[4])); } } From a7f36da3f5d79aaff722442ca94870b40efaebb7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 20 Jul 2024 23:42:29 +0200 Subject: [PATCH 039/401] Fix statesource overwriting data for characterweapon. --- Glamourer/Interop/Material/MaterialValueManager.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index 897f1bf..d5ac877 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -176,7 +176,6 @@ public struct MaterialValueDesign(ColorRow value, bool enabled, bool revert) } } -[StructLayout(LayoutKind.Explicit)] public struct MaterialValueState( in ColorRow game, in ColorRow model, @@ -187,17 +186,10 @@ public struct MaterialValueState( : this(gameRow, modelRow, armor.ToWeapon(0), source) { } - [FieldOffset(0)] - public ColorRow Game = game; - - [FieldOffset(44)] - public ColorRow Model = model; - - [FieldOffset(88)] + public ColorRow Game = game; + public ColorRow Model = model; public readonly CharacterWeapon DrawData = drawData; - - [FieldOffset(95)] - public readonly StateSource Source = source; + public readonly StateSource Source = source; public readonly bool EqualGame(in ColorRow rhsRow, CharacterWeapon rhsData) => DrawData.Skeleton == rhsData.Skeleton From b1c1cf0f992b2ae90a8898fc1c6242b4b57dd58b Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 20 Jul 2024 21:44:33 +0000 Subject: [PATCH 040/401] [CI] Updating repo.json for testing_1.3.0.5 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 38c9040..65b5414 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.4", + "TestingAssemblyVersion": "1.3.0.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.4/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.5/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From b2bb50b3d9b60a9de95773215327a85994f54f25 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 22 Jul 2024 16:04:16 +0200 Subject: [PATCH 041/401] Maybe fix an issue with monk fist weapons again. --- Glamourer/State/StateListener.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index f82b2fc..0568ce7 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -322,7 +322,11 @@ public class StateListener : IDisposable // Fist weapon gauntlet hack. if (slot is EquipSlot.OffHand && weapon.Variant == 0 && weapon.Weapon.Id != 0 && _lastFistOffhand.Weapon.Id != 0) - weapon = _lastFistOffhand; + { + Glamourer.Log.Excessive($"Applying stored fist weapon offhand {_lastFistOffhand}."); + weapon = _lastFistOffhand; + _lastFistOffhand = CharacterWeapon.Empty; + } if (!actor.Identifier(_actors, out var identifier) || !_manager.TryGetValue(identifier, out var state)) @@ -372,8 +376,11 @@ public class StateListener : IDisposable // Fist Weapon Offhand hack. if (slot is EquipSlot.MainHand && weapon.Skeleton.Id is > 1600 and < 1651) + { _lastFistOffhand = new CharacterWeapon((PrimaryId)(weapon.Skeleton.Id + 50), weapon.Weapon, weapon.Variant, weapon.Stains); + Glamourer.Log.Excessive($"Storing fist weapon offhand {_lastFistOffhand}."); + } _funModule.ApplyFunToWeapon(actor, ref weapon, slot); } From d256702005d32e0272435398cfb2f997165fceeb Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 22 Jul 2024 14:06:34 +0000 Subject: [PATCH 042/401] [CI] Updating repo.json for testing_1.3.0.6 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 65b5414..c05c338 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.5", + "TestingAssemblyVersion": "1.3.0.6", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.5/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.6/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From fb2b676ff0c7685398822d1e71c905defa28eac9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 26 Jul 2024 15:06:29 +0200 Subject: [PATCH 043/401] Remove no longer needed helpers. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 4 ++-- Glamourer/Interop/Material/MaterialService.cs | 8 ++++---- .../Interop/Material/MaterialValueIndex.cs | 18 +++--------------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 56f4d24..2521f83 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; +using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using FFXIVClientStructs.Interop; using Glamourer.Designs; using Glamourer.Interop.Material; @@ -79,8 +80,7 @@ public sealed unsafe class AdvancedDyePopup( private (string Path, string GamePath) ResourceName(MaterialValueIndex index) { - var materialHandle = - _actor.Model.AsCharacterBase->Materials()[index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value; + var materialHandle = (MaterialResourceHandle*)_actor.Model.AsCharacterBase->MaterialsSpan[index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value; var model = _actor.Model.AsCharacterBase->ModelsSpan[index.SlotIndex].Value; var modelHandle = model == null ? null : model->ModelResourceHandle; var path = materialHandle == null diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index 3e972a8..5adaf4d 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -41,10 +41,10 @@ public static unsafe class MaterialService return null; var index = modelSlot * MaterialsPerModel + materialSlot; - if (index < 0 || index >= model.AsCharacterBase->ColorTableTextures().Length) + if (index < 0 || index >= model.AsCharacterBase->ColorTableTexturesSpan.Length) return null; - var texture = (Texture**)Unsafe.AsPointer(ref model.AsCharacterBase->ColorTableTextures()[index]); + var texture = (Texture**)Unsafe.AsPointer(ref model.AsCharacterBase->ColorTableTexturesSpan[index]); return texture; } @@ -59,10 +59,10 @@ public static unsafe class MaterialService return null; var index = modelSlot * MaterialsPerModel + materialSlot; - if (index < 0 || index >= model.AsCharacterBase->Materials().Length) + if (index < 0 || index >= model.AsCharacterBase->MaterialsSpan.Length) return null; - var material = model.AsCharacterBase->Materials()[index].Value; + var material = (MaterialResourceHandle*) model.AsCharacterBase->MaterialsSpan[index].Value; if (material == null || material->ColorTable == null) return null; diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 5c44e21..5104713 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -1,6 +1,4 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; -using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; -using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using FFXIVClientStructs.Interop; using Newtonsoft.Json; using Penumbra.GameData.Enums; @@ -81,13 +79,13 @@ public readonly record struct MaterialValueIndex( { if (!TryGetModel(actor, out var model) || SlotIndex >= model.AsCharacterBase->SlotCount - || model.AsCharacterBase->ColorTableTextures().Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) + || model.AsCharacterBase->ColorTableTexturesSpan.Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) { textures = []; return false; } - textures = model.AsCharacterBase->ColorTableTextures().Slice(SlotIndex * MaterialService.MaterialsPerModel, + textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(SlotIndex * MaterialService.MaterialsPerModel, MaterialService.MaterialsPerModel); return true; } @@ -192,14 +190,4 @@ public readonly record struct MaterialValueIndex( JsonSerializer serializer) => FromKey(serializer.Deserialize(reader), out var value) ? value : throw new Exception($"Invalid material key {value.Key}."); } -} - -// TODO Remove when fixed in CS. -public static class ColorTableExtension -{ - public static unsafe Span> Materials(this ref CharacterBase character) - => new(character.Materials, character.SlotCount * MaterialService.MaterialsPerModel); - - public static unsafe Span> ColorTableTextures(this ref CharacterBase character) - => new(character.ColorTableTextures, character.SlotCount * MaterialService.MaterialsPerModel); -} +} \ No newline at end of file From 60302c37cd866fbe252b371d84082f74b75487b6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 26 Jul 2024 15:06:51 +0200 Subject: [PATCH 044/401] Fix minion placement. --- Glamourer/Interop/ScalingService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index f7b8f08..16b9a37 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -74,7 +74,8 @@ public unsafe class ScalingService : IDisposable private void PlaceMinionDetour(Companion* companion) { - var owner = (Actor)((nint*)companion)[0x386]; + // TODO Update CS + var owner = (Actor)((nint*)companion)[0x45C]; if (!owner.IsCharacter) { _placeMinionHook.Original(companion); From ff96e519636f7cc1c14f544562fe11f193fc3cd5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 26 Jul 2024 15:35:25 +0200 Subject: [PATCH 045/401] Maybe fix another issue with monk offhands. --- Glamourer/State/StateListener.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 0568ce7..34c9421 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -47,10 +47,11 @@ public class StateListener : IDisposable private readonly CrestService _crestService; private readonly ICondition _condition; + private readonly Dictionary _fistOffhands = []; + private ActorIdentifier _creatingIdentifier = ActorIdentifier.Invalid; private ActorState? _creatingState; private ActorState? _customizeState; - private CharacterWeapon _lastFistOffhand = CharacterWeapon.Empty; public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorManager actors, Configuration config, EquipSlotUpdating equipSlotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, @@ -321,11 +322,13 @@ public class StateListener : IDisposable return; // Fist weapon gauntlet hack. - if (slot is EquipSlot.OffHand && weapon.Variant == 0 && weapon.Weapon.Id != 0 && _lastFistOffhand.Weapon.Id != 0) + if (slot is EquipSlot.OffHand + && weapon.Variant == 0 + && weapon.Weapon.Id != 0 + && _fistOffhands.TryGetValue(actor, out var lastFistOffhand)) { - Glamourer.Log.Excessive($"Applying stored fist weapon offhand {_lastFistOffhand}."); - weapon = _lastFistOffhand; - _lastFistOffhand = CharacterWeapon.Empty; + Glamourer.Log.Information($"Applying stored fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); + weapon = lastFistOffhand; } if (!actor.Identifier(_actors, out var identifier) @@ -377,9 +380,10 @@ public class StateListener : IDisposable // Fist Weapon Offhand hack. if (slot is EquipSlot.MainHand && weapon.Skeleton.Id is > 1600 and < 1651) { - _lastFistOffhand = new CharacterWeapon((PrimaryId)(weapon.Skeleton.Id + 50), weapon.Weapon, weapon.Variant, + lastFistOffhand = new CharacterWeapon((PrimaryId)(weapon.Skeleton.Id + 50), weapon.Weapon, weapon.Variant, weapon.Stains); - Glamourer.Log.Excessive($"Storing fist weapon offhand {_lastFistOffhand}."); + _fistOffhands[actor] = lastFistOffhand; + Glamourer.Log.Excessive($"Storing fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); } _funModule.ApplyFunToWeapon(actor, ref weapon, slot); From 029cf12bed3029eb255c99a22b6c8bb5ad0695fe Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 26 Jul 2024 13:37:25 +0000 Subject: [PATCH 046/401] [CI] Updating repo.json for testing_1.3.0.7 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index c05c338..cf79426 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.6", + "TestingAssemblyVersion": "1.3.0.7", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.6/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.7/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 1bee5c680b389b0a023ab1ebec2f8ec29835c2e7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 27 Jul 2024 13:59:32 +0200 Subject: [PATCH 047/401] Add Facewear to application rules. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 60 +++++++++++++++------ 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index b20e00d..3fa8e74 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -14,6 +14,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using static Glamourer.Gui.Tabs.HeaderDrawer; @@ -250,11 +251,15 @@ public class DesignPanel using (var _ = ImRaii.Group()) { DrawCustomizeApplication(); - ImGui.NewLine(); + ImUtf8.IconDummy(); DrawCrestApplication(); - ImGui.NewLine(); + ImUtf8.IconDummy(); if (_config.UseAdvancedParameters) + { DrawMetaApplication(); + ImUtf8.IconDummy(); + DrawBonusSlotApplication(); + } } ImGui.SameLine(ImGui.GetContentRegionAvail().X / 2); @@ -287,24 +292,38 @@ public class DesignPanel EquipSlot.OffHand, }); - ImGui.NewLine(); + ImUtf8.IconDummy(); ApplyEquip("Armor", ApplicationTypeExtensions.ArmorFlags, false, EquipSlotExtensions.EquipmentSlots); - ImGui.NewLine(); + ImUtf8.IconDummy(); ApplyEquip("Accessories", ApplicationTypeExtensions.AccessoryFlags, false, EquipSlotExtensions.AccessorySlots); - ImGui.NewLine(); + ImUtf8.IconDummy(); ApplyEquip("Dyes", ApplicationTypeExtensions.StainFlags, true, EquipSlotExtensions.FullSlots); - ImGui.NewLine(); + ImUtf8.IconDummy(); if (_config.UseAdvancedParameters) + { DrawParameterApplication(); + } else + { DrawMetaApplication(); + ImUtf8.IconDummy(); + DrawBonusSlotApplication(); + } } } + private static readonly IReadOnlyList MetaLabels = + [ + "Apply Wetness", + "Apply Hat Visibility", + "Apply Visor State", + "Apply Weapon Visibility", + ]; + private void DrawMetaApplication() { using var id = ImRaii.PushId("Meta"); @@ -312,15 +331,7 @@ public class DesignPanel var flags = (uint)_selector.Selected!.Application.Meta; var bigChange = ImGui.CheckboxFlags("Apply All Meta Changes", ref flags, all); - var labels = new[] - { - "Apply Wetness", - "Apply Hat Visibility", - "Apply Visor State", - "Apply Weapon Visibility", - }; - - foreach (var (index, label) in MetaExtensions.AllRelevant.Zip(labels)) + foreach (var (index, label) in MetaExtensions.AllRelevant.Zip(MetaLabels)) { var apply = bigChange ? ((MetaFlag)flags).HasFlag(index.ToFlag()) : _selector.Selected!.DoApplyMeta(index); if (ImGui.Checkbox(label, ref apply) || bigChange) @@ -328,6 +339,25 @@ public class DesignPanel } } + private static readonly IReadOnlyList BonusSlotLabels = + [ + "Apply Facewear", + ]; + + private void DrawBonusSlotApplication() + { + using var id = ImUtf8.PushId("Bonus"u8); + var flags = _selector.Selected!.Application.BonusItem; + var bigChange = BonusExtensions.AllFlags.Count > 1 && ImUtf8.Checkbox("Apply All Bonus Slots"u8, ref flags, BonusExtensions.All); + foreach (var (index, label) in BonusExtensions.AllFlags.Zip(BonusSlotLabels)) + { + var apply = bigChange ? flags.HasFlag(index) : _selector.Selected!.DoApplyBonusItem(index); + if (ImUtf8.Checkbox(label, ref apply) || bigChange) + _manager.ChangeApplyBonusItem(_selector.Selected!, index, apply); + } + } + + private void DrawParameterApplication() { using var id = ImRaii.PushId("Parameter"); From 1e0b7fdfce62e770da391708f1338358ba738a00 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 28 Jul 2024 01:33:37 +0200 Subject: [PATCH 048/401] Improve respecting of design write protection. --- Glamourer/Gui/Customization/CustomizationDrawer.Color.cs | 6 ++++-- Glamourer/Gui/Materials/MaterialDrawer.cs | 9 +++++---- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 7 ++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs index fb50f55..4d34a05 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs @@ -22,8 +22,10 @@ public partial class CustomizationDrawer using (_ = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * ImGuiHelpers.GlobalScale, current < 0)) { if (ImGui.ColorButton($"{_customize[index].Value}##color", color, ImGuiColorEditFlags.None, _framedIconSize)) + { ImGui.OpenPopup(ColorPickerPopupName); - else if (current >= 0 && CaptureMouseWheel(ref current, 0, _currentCount)) + } + else if (current >= 0 && !_locked && CaptureMouseWheel(ref current, 0, _currentCount)) { var data = _set.Data(_currentIndex, current, _customize.Face); UpdateValue(data.Value); @@ -70,7 +72,7 @@ public partial class CustomizationDrawer for (var i = 0; i < _currentCount; ++i) { var custom = _set.Data(_currentIndex, i, _customize[CustomizeIndex.Face]); - if (ImGui.ColorButton(custom.Value.ToString(), ImGui.ColorConvertU32ToFloat4(custom.Color))) + if (ImGui.ColorButton(custom.Value.ToString(), ImGui.ColorConvertU32ToFloat4(custom.Color)) && !_locked) { UpdateValue(custom.Value); ImGui.CloseCurrentPopup(); diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 445184d..50cfb36 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -27,7 +27,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) public void Draw(Design design) { - var available = ImGui.GetContentRegionAvail().X; + var available = ImGui.GetContentRegionAvail().X; _spacing = ImGui.GetStyle().ItemInnerSpacing.X; _buttonSize = new Vector2(ImGui.GetFrameHeight()); var colorWidth = 4 * _buttonSize.X @@ -64,6 +64,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) ImGui.SameLine(0, _spacing); PasteButton(design, key); ImGui.SameLine(0, _spacing); + using var disabled = ImRaii.Disabled(design.WriteProtected()); EnabledToggle(design, key, value.Enabled); ImGui.SameLine(0, _spacing); DrawRow(design, key, value.Value, value.Revert); @@ -103,7 +104,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) var deleteEnabled = _config.DeleteDesignModifier.IsActive(); if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), _buttonSize, $"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {_config.DeleteDesignModifier} to delete.")}", - !deleteEnabled, true)) + !deleteEnabled || design.WriteProtected(), true)) return; _designManager.ChangeMaterialValue(design, index, null); @@ -121,7 +122,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) private void PasteButton(Design design, MaterialValueIndex index) { if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), _buttonSize, - "Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet, true)) + "Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet || design.WriteProtected(), true)) _designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row); } @@ -154,7 +155,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); var exists = design.GetMaterialDataRef().TryGetValue(_newKey, out _); if (ImGuiUtil.DrawDisabledButton("Add New Row", Vector2.Zero, - exists ? "The selected advanced dye row already exists." : "Add the selected advanced dye row.", exists, false)) + exists ? "The selected advanced dye row already exists." : "Add the selected advanced dye row.", exists || design.WriteProtected())) _designManager.ChangeMaterialValue(design, _newKey, ColorRow.Empty); } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 3fa8e74..1a072cb 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -248,6 +248,8 @@ public class DesignPanel if (!h) return; + using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected()); + using (var _ = ImRaii.Group()) { DrawCustomizeApplication(); @@ -548,7 +550,7 @@ public class DesignPanel => panel._selector.Selected != null; protected override bool Disabled - => !panel._manager.CanUndo(panel._selector.Selected); + => !panel._manager.CanUndo(panel._selector.Selected) || (panel._selector.Selected?.WriteProtected() ?? true); protected override string Description => "Undo the last change if you accidentally overwrote your design with a different one."; @@ -604,6 +606,9 @@ public class DesignPanel protected override string Description => "Overwrite this design with your character's current state."; + + protected override bool Disabled + => panel._selector.Selected?.WriteProtected() ?? true; protected override FontAwesomeIcon Icon => FontAwesomeIcon.UserEdit; From e87b2165416a1897b9218be6fe4537c674d172dd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 28 Jul 2024 14:11:56 +0200 Subject: [PATCH 049/401] Rename material stuff. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 40 ++++++++++++++------- Glamourer/Gui/Materials/MaterialDrawer.cs | 2 +- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 2521f83..61eea83 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -80,7 +80,9 @@ public sealed unsafe class AdvancedDyePopup( private (string Path, string GamePath) ResourceName(MaterialValueIndex index) { - var materialHandle = (MaterialResourceHandle*)_actor.Model.AsCharacterBase->MaterialsSpan[index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value; + var materialHandle = + (MaterialResourceHandle*)_actor.Model.AsCharacterBase->MaterialsSpan[ + index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value; var model = _actor.Model.AsCharacterBase->ModelsSpan[index.SlotIndex].Value; var modelHandle = model == null ? null : model->ModelResourceHandle; var path = materialHandle == null @@ -140,18 +142,19 @@ public sealed unsafe class AdvancedDyePopup( { var buttonWidth = new Vector2(ImGui.GetContentRegionAvail().X / 2, 0); using var font = ImRaii.PushFont(UiBuilder.MonoFont); - using (ImRaii.Disabled(_rowOffset == 0)) + using var hoverColor = ImRaii.PushColor(ImGuiCol.ButtonHovered, ImGui.GetColorU32(ImGuiCol.TabHovered)); + + using (ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(_rowOffset == 0 ? ImGuiCol.TabActive : ImGuiCol.Tab))) { - if (ToggleButton.ButtonEx("Row 1-16 ", buttonWidth, ImGuiButtonFlags.MouseButtonLeft, ImDrawFlags.RoundCornersLeft)) + if (ToggleButton.ButtonEx("Row Pairs 1-8 ", buttonWidth, ImGuiButtonFlags.MouseButtonLeft, ImDrawFlags.RoundCornersLeft)) _rowOffset = 0; } ImGui.SameLine(0, 0); - - using (ImRaii.Disabled(_rowOffset == RowsPerPage)) + using (ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(_rowOffset == RowsPerPage ? ImGuiCol.TabActive : ImGuiCol.Tab))) { - if (ToggleButton.ButtonEx("Row 17-32", buttonWidth, ImGuiButtonFlags.MouseButtonLeft, ImDrawFlags.RoundCornersRight)) + if (ToggleButton.ButtonEx("Row Pairs 9-16", buttonWidth, ImGuiButtonFlags.MouseButtonLeft, ImDrawFlags.RoundCornersRight)) _rowOffset = RowsPerPage; } } @@ -182,9 +185,14 @@ public sealed unsafe class AdvancedDyePopup( flags |= ImGuiWindowFlags.NoMove; } - var size = new Vector2(7 * ImGui.GetFrameHeight() + 3 * ImGui.GetStyle().ItemInnerSpacing.X + 300 * ImGuiHelpers.GlobalScale, - 19 * ImGui.GetFrameHeightWithSpacing() + ImGui.GetStyle().WindowPadding.Y + 3 * ImGui.GetStyle().ItemSpacing.Y); - ImGui.SetNextWindowSize(size); + var width = 7 * ImGui.GetFrameHeight() // Buttons + + 3 * ImGui.GetStyle().ItemSpacing.X // around text + + 7 * ImGui.GetStyle().ItemInnerSpacing.X + + 200 * ImGuiHelpers.GlobalScale // Drags + + 7 * UiBuilder.MonoFont.GetCharAdvance(' ') // Row + + 2 * ImGui.GetStyle().WindowPadding.X; + var height = 19 * ImGui.GetFrameHeightWithSpacing() + ImGui.GetStyle().WindowPadding.Y + 3 * ImGui.GetStyle().ItemSpacing.Y; + ImGui.SetNextWindowSize(new Vector2(width, height)); var window = ImGui.Begin("###Glamourer Advanced Dyes", flags); try @@ -240,11 +248,11 @@ public sealed unsafe class AdvancedDyePopup( ImGui.AlignTextToFramePadding(); using (ImRaii.PushFont(UiBuilder.MonoFont)) { - ImGui.TextUnformatted("All Color Rows (1-32)"); + ImGui.TextUnformatted("All Color Row Pairs (1-16)"); } var spacing = ImGui.GetStyle().ItemInnerSpacing.X; - ImGui.SameLine(ImGui.GetWindowSize().X - 3 * buttonSize.X - 3 * spacing); + ImGui.SameLine(ImGui.GetWindowSize().X - 3 * buttonSize.X - 2 * spacing - ImGui.GetStyle().WindowPadding.X); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), buttonSize, "Export this table to your clipboard.", false, true)) ColorRowClipboard.Table = table; @@ -302,7 +310,9 @@ public sealed unsafe class AdvancedDyePopup( ImGui.AlignTextToFramePadding(); using (ImRaii.PushFont(UiBuilder.MonoFont)) { - ImGui.TextUnformatted($"Row {index.RowIndex + 1:D2}"); + var rowIndex = index.RowIndex / 2 + 1; + var rowSuffix = (index.RowIndex & 1) == 0 ? 'A' : 'B'; + ImGui.TextUnformatted($"Row {rowIndex,2}{rowSuffix}"); } ImGui.SameLine(0, ImGui.GetStyle().ItemSpacing.X * 2); @@ -313,18 +323,22 @@ public sealed unsafe class AdvancedDyePopup( ImGui.SameLine(0, spacing.X); applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", value.Model.Specular, v => value.Model.Specular = v, "S"); + ImGui.SameLine(0, spacing.X); applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", value.Model.Emissive, v => value.Model.Emissive = v, "E"); + ImGui.SameLine(0, spacing.X); ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); applied |= ImGui.DragFloat("##Gloss", ref value.Model.GlossStrength, 0.01f, 0.001f, float.MaxValue, "%.3f G") && value.Model.GlossStrength > 0; ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); + ImGui.SameLine(0, spacing.X); ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Specular Strength", ref value.Model.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, "%.3f SS"); + applied |= ImGui.DragFloat("##Specular Strength", ref value.Model.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, "%.3f%% SS"); ImGuiUtil.HoverTooltip("Change the specular strength for this row."); + ImGui.SameLine(0, spacing.X); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), buttonSize, "Export this row to your clipboard.", false, true)) diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 50cfb36..95be750 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -200,7 +200,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); ImGui.SameLine(0, _spacing); ImGui.SetNextItemWidth(SpecularStrengthWidth * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Specular Strength", ref tmp.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, "%.3f SS"); + applied |= ImGui.DragFloat("##Specular Strength", ref tmp.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, "%.3f%% SS"); ImGuiUtil.HoverTooltip("Change the specular strength for this row."); if (applied) _designManager.ChangeMaterialValue(design, index, tmp); From d0d518ddc23ba6e7bc130536fe98eb10e07e265c Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 28 Jul 2024 12:14:04 +0000 Subject: [PATCH 050/401] [CI] Updating repo.json for testing_1.3.0.8 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index cf79426..0c672d6 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.7", + "TestingAssemblyVersion": "1.3.0.8", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.7/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.8/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 6446309bd79eadb2fbdbb48c06c148fe01868252 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 30 Jul 2024 20:23:59 +0200 Subject: [PATCH 051/401] Allow drag&drop on stains. --- Glamourer/Api/ApiHelpers.cs | 1 - Glamourer/Gui/Equipment/EquipmentDrawer.cs | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index a54a0ec..25af774 100644 --- a/Glamourer/Api/ApiHelpers.cs +++ b/Glamourer/Api/ApiHelpers.cs @@ -1,6 +1,5 @@ using Glamourer.Api.Enums; using Glamourer.Designs; -using Glamourer.GameData; using Glamourer.State; using OtterGui; using OtterGui.Log; diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index e65981e..83c560d 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -9,6 +9,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Text; +using OtterGui.Text.EndObjects; using OtterGui.Widgets; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; @@ -35,6 +36,8 @@ public class EquipmentDrawer private float _requiredComboWidthUnscaled; private float _requiredComboWidth; + private Stain? _draggedStain; + public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, CodeService codes, TextureService textures, Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes) { @@ -512,6 +515,10 @@ public class EquipmentDrawer var change = small ? _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss) : _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss, width); + + if (!change) + DrawStainDragDrop(data, index, stain, found); + if (index < data.CurrentStains.Count - 1) ImUtf8.SameLineInner(); @@ -526,6 +533,27 @@ public class EquipmentDrawer } } + private void DrawStainDragDrop(in EquipDrawData data, int index, Stain stain, bool found) + { + if (found) + { + using var dragSource = ImUtf8.DragDropSource(); + if (dragSource.Success) + { + if (DragDropSource.SetPayload("stainDragDrop"u8)) + _draggedStain = stain; + ImUtf8.Text($"Dragging {stain.Name}..."); + } + } + + using var dragTarget = ImUtf8.DragDropTarget(); + if (dragTarget.IsDropping("stainDragDrop"u8) && _draggedStain.HasValue) + { + data.SetStains(data.CurrentStains.With(index, _draggedStain.Value.RowIndex)); + _draggedStain = null; + } + } + private void DrawItem(in EquipDrawData data, out string label, bool small, bool clear, bool open) { Debug.Assert(data.Slot.IsEquipment() || data.Slot.IsAccessory(), $"Called {nameof(DrawItem)} on {data.Slot}."); From 9d569266b5bf8f5a7745f6fcf8deecdc5971897f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 31 Jul 2024 16:58:33 +0200 Subject: [PATCH 052/401] Improve job filter in unlocks tab. --- Glamourer.Api | 2 +- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 50 ++++++++++++++++---- OtterGui | 2 +- Penumbra.GameData | 2 +- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index ca00339..663702b 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit ca003395306791b9e595683c47824b4718385311 +Subproject commit 663702b57303368b3a897e9c6eae4b34b4339534 diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 600546f..558c4df 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -9,6 +9,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Table; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -23,16 +24,16 @@ public class UnlockTable : Table, IDisposable : base("ItemUnlockTable", new ItemList(items), new FavoriteColumn(favorites, @event) { Label = "F" }, new NameColumn(textures, tooltip) { Label = "Item Name..." }, - new SlotColumn() { Label = "Equip Slot" }, - new TypeColumn() { Label = "Item Type..." }, + new SlotColumn { Label = "Equip Slot" }, + new TypeColumn { Label = "Item Type..." }, new UnlockDateColumn(itemUnlocks) { Label = "Unlocked" }, - new ItemIdColumn() { Label = "Item Id..." }, + new ItemIdColumn { Label = "Item Id..." }, new ModelDataColumn(items) { Label = "Model Data..." }, new JobColumn(jobs) { Label = "Jobs" }, - new RequiredLevelColumn() { Label = "Level..." }, - new DyableColumn() { Label = "Dye" }, - new CrestColumn() { Label = "Crest" }, - new TradableColumn() { Label = "Trade" } + new RequiredLevelColumn { Label = "Level..." }, + new DyableColumn { Label = "Dye" }, + new CrestColumn { Label = "Crest" }, + new TradableColumn { Label = "Trade" } ) { _event = @event; @@ -334,11 +335,42 @@ public class UnlockTable : Table, IDisposable public JobColumn(JobService jobs) { _jobs = jobs; - _values = _jobs.Jobs.Values.Skip(1).Select(j => j.Flag).ToArray(); - _names = _jobs.Jobs.Values.Skip(1).Select(j => j.Abbreviation).ToArray(); + _values = _jobs.Jobs.Ordered.Select(j => j.Flag).ToArray(); + _names = _jobs.Jobs.Ordered.Select(j => j.Abbreviation).ToArray(); AllFlags = _values.Aggregate((l, r) => l | r); _filterValue = AllFlags; Flags &= ~ImGuiTableColumnFlags.NoResize; + ComboFlags |= ImGuiComboFlags.HeightLargest; + } + + protected override bool DrawCheckbox(int idx, out bool ret) + { + var job = _jobs.Jobs.Ordered[idx]; + var color = job.Role switch + { + Job.JobRole.Tank => 0xFFFFD0D0, + Job.JobRole.Melee => 0xFFD0D0FF, + Job.JobRole.RangedPhysical => 0xFFD0FFFF, + Job.JobRole.RangedMagical => 0xFFFFD0FF, + Job.JobRole.Healer => 0xFFD0FFD0, + Job.JobRole.Crafter => 0xFF808080, + Job.JobRole.Gatherer => 0xFFD0D0D0, + _ => ImGui.GetColorU32(ImGuiCol.Text), + }; + using var c = ImRaii.PushColor(ImGuiCol.Text, color); + var r = base.DrawCheckbox(idx, out ret); + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _filterValue = job.Flag & _filterValue; + ret = true; + r = true; + } + + ImUtf8.HoverTooltip("Right-Click to disable all other jobs."u8); + + if (idx < _names.Length - 1 && idx % 2 == 0) + ImGui.SameLine(ImGui.GetFrameHeight() * 4); + return r; } protected override void SetValue(JobFlag value, bool enable) diff --git a/OtterGui b/OtterGui index c2738e1..3a14692 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit c2738e1d42974cddbe5a31238c6ed236a831d17d +Subproject commit 3a14692e38708ca9f18652898e6f5c8cc87b517b diff --git a/Penumbra.GameData b/Penumbra.GameData index da99d9b..cd40d49 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit da99d9b2b3c51b2bbeb40226c692dff2cbcd5cbc +Subproject commit cd40d497f4791e946c0fd4bd5663da578f7680ed From f6434cbc619926cfba0fa0970ab5f4be1e6010d9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 31 Jul 2024 17:06:30 +0200 Subject: [PATCH 053/401] Rename stains. --- Glamourer/Designs/DesignEditor.cs | 2 +- Glamourer/Events/DesignChanged.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index 4a104ca..f68424c 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -196,7 +196,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set stain of {slot} equipment piece to {stains}."); - DesignChanged.Invoke(DesignChanged.Type.Stain, design, (oldStain, stains, slot)); + DesignChanged.Invoke(DesignChanged.Type.Stains, design, (oldStain, stains, slot)); } /// diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 199c7d4..a8f35d5 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -68,8 +68,8 @@ public sealed class DesignChanged() /// An existing design had its weapons changed. Data is the old mainhand, the old offhand, the new mainhand, the new offhand (if any) and the new gauntlets (if any). [(EquipItem, EquipItem, EquipItem, EquipItem?, EquipItem?)]. Weapon, - /// An existing design had a stain changed. Data is the old stain id, the new stain id and the slot [(StainId, StainId, EquipSlot)]. - Stain, + /// An existing design had a stain changed. Data is the old stain id, the new stain id and the slot [(StainIds, StainIds, EquipSlot)]. + Stains, /// An existing design had a crest visibility changed. Data is the old crest visibility, the new crest visibility and the slot [(bool, bool, EquipSlot)]. Crest, From d8085dc02298fe3a735ed26409c2a19e78411530 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 31 Jul 2024 19:33:23 +0200 Subject: [PATCH 054/401] Introduce history. --- Glamourer.Api | 2 +- Glamourer/Api/StateApi.cs | 7 +- Glamourer/Automation/AutoDesignManager.cs | 3 +- Glamourer/Designs/DesignEditor.cs | 32 +-- Glamourer/Designs/DesignFileSystem.cs | 7 +- Glamourer/Designs/DesignManager.cs | 46 +++-- .../Designs/History/DesignTransaction.cs | 181 +++++++++++++++++ Glamourer/Designs/History/EditorHistory.cs | 191 ++++++++++++++++++ Glamourer/Designs/History/Transaction.cs | 113 +++++++++++ Glamourer/Designs/Links/DesignLinkManager.cs | 3 +- Glamourer/Events/DesignChanged.cs | 77 +++---- Glamourer/Events/StateChanged.cs | 13 +- Glamourer/Gui/DesignCombo.cs | 7 +- Glamourer/Gui/Equipment/EquipDrawData.cs | 2 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 25 ++- .../DesignTab/DesignFileSystemSelector.cs | 3 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 2 +- .../Interop/Penumbra/PenumbraAutoRedraw.cs | 7 +- Glamourer/State/StateEditor.cs | 67 ++++-- 19 files changed, 682 insertions(+), 106 deletions(-) create mode 100644 Glamourer/Designs/History/DesignTransaction.cs create mode 100644 Glamourer/Designs/History/EditorHistory.cs create mode 100644 Glamourer/Designs/History/Transaction.cs diff --git a/Glamourer.Api b/Glamourer.Api index 663702b..4bad56d 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 663702b57303368b3a897e9c6eae4b34b4339534 +Subproject commit 4bad56d610132b419335b89896e1f387b9ba2039 diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 203f1b0..385cf3e 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -2,6 +2,7 @@ using Glamourer.Api.Enums; using Glamourer.Automation; using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.Events; using Glamourer.Interop.Structs; using Glamourer.State; @@ -41,13 +42,13 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable _objects = objects; _stateChanged = stateChanged; _gPose = gPose; - _stateChanged.Subscribe(OnStateChange, Events.StateChanged.Priority.GlamourerIpc); + _stateChanged.Subscribe(OnStateChanged, Events.StateChanged.Priority.GlamourerIpc); _gPose.Subscribe(OnGPoseChange, GPoseService.Priority.GlamourerIpc); } public void Dispose() { - _stateChanged.Unsubscribe(OnStateChange); + _stateChanged.Unsubscribe(OnStateChanged); _gPose.Unsubscribe(OnGPoseChange); } @@ -330,7 +331,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnGPoseChange(bool gPose) => GPoseChanged?.Invoke(gPose); - private void OnStateChange(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, object? _5) + private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { if (StateChanged != null) foreach (var actor in actors.Objects) diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index da9b014..474afdd 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -1,6 +1,7 @@ using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.Designs.Special; using Glamourer.Events; using Glamourer.Interop; @@ -620,7 +621,7 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos } } - private void OnDesignChange(DesignChanged.Type type, Design design, object? data) + private void OnDesignChange(DesignChanged.Type type, Design design, ITransaction? _) { if (type is not DesignChanged.Type.Deleted) return; diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index f68424c..df0e9ed 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -1,3 +1,4 @@ +using Glamourer.Designs.History; using Glamourer.Designs.Links; using Glamourer.Events; using Glamourer.GameData; @@ -72,7 +73,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; Glamourer.Log.Debug($"Changed customize {idx.ToDefaultName()} in design {design.Identifier} from {oldValue.Value} to {value.Value}."); SaveService.QueueSave(design); - DesignChanged.Invoke(DesignChanged.Type.Customize, design, (oldValue, value, idx)); + DesignChanged.Invoke(DesignChanged.Type.Customize, design, new CustomizeTransaction(idx, oldValue, value)); } /// @@ -88,7 +89,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; Glamourer.Log.Debug($"Changed entire customize with resulting flags {applied} and {changed}."); SaveService.QueueSave(design); - DesignChanged.Invoke(DesignChanged.Type.EntireCustomize, design, (oldCustomize, applied, changed)); + DesignChanged.Invoke(DesignChanged.Type.EntireCustomize, design, new EntireCustomizeTransaction(changed, oldCustomize, newCustomize)); } /// @@ -103,7 +104,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; Glamourer.Log.Debug($"Set customize parameter {flag} in design {design.Identifier} from {old} to {@new}."); SaveService.QueueSave(design); - DesignChanged.Invoke(DesignChanged.Type.Parameter, design, (old, @new, flag)); + DesignChanged.Invoke(DesignChanged.Type.Parameter, design, new ParameterTransaction(flag, old, @new)); } /// @@ -122,11 +123,14 @@ public class DesignEditor( if (!ChangeMainhandPeriphery(design, currentMain, currentOff, item, out var newOff, out var newGauntlets)) return; + var currentGauntlets = design.DesignData.Item(EquipSlot.Hands); design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug( $"Set {EquipSlot.MainHand.ToName()} weapon in design {design.Identifier} from {currentMain.Name} ({currentMain.ItemId}) to {item.Name} ({item.ItemId})."); - DesignChanged.Invoke(DesignChanged.Type.Weapon, design, (currentMain, currentOff, item, newOff, newGauntlets)); + DesignChanged.Invoke(DesignChanged.Type.Weapon, design, + new WeaponTransaction(currentMain, currentOff, currentGauntlets, item, newOff ?? currentOff, + newGauntlets ?? currentGauntlets)); return; } case EquipSlot.OffHand: @@ -139,11 +143,13 @@ public class DesignEditor( if (!design.GetDesignDataRef().SetItem(EquipSlot.OffHand, item)) return; + var currentGauntlets = design.DesignData.Item(EquipSlot.Hands); design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug( $"Set {EquipSlot.OffHand.ToName()} weapon in design {design.Identifier} from {currentOff.Name} ({currentOff.ItemId}) to {item.Name} ({item.ItemId})."); - DesignChanged.Invoke(DesignChanged.Type.Weapon, design, (currentMain, currentOff, currentMain, item)); + DesignChanged.Invoke(DesignChanged.Type.Weapon, design, + new WeaponTransaction(currentMain, currentOff, currentGauntlets, currentMain, item, currentGauntlets)); return; } default: @@ -159,7 +165,7 @@ public class DesignEditor( Glamourer.Log.Debug( $"Set {slot.ToName()} equipment piece in design {design.Identifier} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId})."); SaveService.QueueSave(design); - DesignChanged.Invoke(DesignChanged.Type.Equip, design, (old, item, slot)); + DesignChanged.Invoke(DesignChanged.Type.Equip, design, new EquipTransaction(slot, old, item)); return; } } @@ -179,7 +185,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set {slot} bonus item to {item}."); - DesignChanged.Invoke(DesignChanged.Type.BonusItem, design, (oldItem, item, slot)); + DesignChanged.Invoke(DesignChanged.Type.BonusItem, design, new BonusItemTransaction(slot, oldItem, item)); } /// @@ -196,7 +202,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set stain of {slot} equipment piece to {stains}."); - DesignChanged.Invoke(DesignChanged.Type.Stains, design, (oldStain, stains, slot)); + DesignChanged.Invoke(DesignChanged.Type.Stains, design, new StainTransaction(slot, oldStain, stains)); } /// @@ -219,7 +225,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set crest visibility of {slot} equipment piece to {crest}."); - DesignChanged.Invoke(DesignChanged.Type.Crest, design, (oldCrest, crest, slot)); + DesignChanged.Invoke(DesignChanged.Type.Crest, design, new CrestTransaction(slot, oldCrest, crest)); } /// @@ -232,7 +238,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set value of {metaIndex} to {value}."); - DesignChanged.Invoke(DesignChanged.Type.Other, design, (metaIndex, false, value)); + DesignChanged.Invoke(DesignChanged.Type.Other, design, new MetaTransaction(metaIndex, !value, value)); } public void ChangeMaterialRevert(Design design, MaterialValueIndex index, bool revert) @@ -245,7 +251,7 @@ public class DesignEditor( Glamourer.Log.Debug($"Changed advanced dye value for {index} to {(revert ? "Revert." : "no longer Revert.")}"); design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); - DesignChanged.Invoke(DesignChanged.Type.MaterialRevert, design, index); + DesignChanged.Invoke(DesignChanged.Type.MaterialRevert, design, new MaterialRevertTransaction(index, !revert, revert)); } public void ChangeMaterialValue(Design design, MaterialValueIndex index, ColorRow? row) @@ -280,7 +286,7 @@ public class DesignEditor( design.LastEdit = DateTimeOffset.UtcNow; SaveService.DelaySave(design); - DesignChanged.Invoke(DesignChanged.Type.Material, design, (oldValue, row, index)); + DesignChanged.Invoke(DesignChanged.Type.Material, design, new MaterialTransaction(index, oldValue.Value, row)); } public void ChangeApplyMaterialValue(Design design, MaterialValueIndex index, bool value) @@ -293,7 +299,7 @@ public class DesignEditor( Glamourer.Log.Debug($"Changed application of advanced dye for {index} to {value}."); design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); - DesignChanged.Invoke(DesignChanged.Type.ApplyMaterial, design, index); + DesignChanged.Invoke(DesignChanged.Type.ApplyMaterial, design, new ApplicationTransaction(index, !value, value)); } diff --git a/Glamourer/Designs/DesignFileSystem.cs b/Glamourer/Designs/DesignFileSystem.cs index f154684..e985e32 100644 --- a/Glamourer/Designs/DesignFileSystem.cs +++ b/Glamourer/Designs/DesignFileSystem.cs @@ -1,4 +1,5 @@ using Dalamud.Interface.ImGuiNotification; +using Glamourer.Designs.History; using Glamourer.Events; using Glamourer.Services; using Newtonsoft.Json; @@ -92,13 +93,13 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable _saveService.QueueSave(this); } - private void OnDesignChange(DesignChanged.Type type, Design design, object? data) + private void OnDesignChange(DesignChanged.Type type, Design design, ITransaction? data) { switch (type) { case DesignChanged.Type.Created: var parent = Root; - if (data is string path) + if ((data as CreationTransaction?)?.Path is { } path) try { parent = FindOrCreateAllFolders(path); @@ -119,7 +120,7 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable case DesignChanged.Type.ReloadedAll: Reload(); return; - case DesignChanged.Type.Renamed when data is string oldName: + case DesignChanged.Type.Renamed when (data as RenameTransaction?)?.Old is { } oldName: if (!FindLeaf(design, out var leaf2)) return; diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 97058a9..7eaad9d 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -1,4 +1,5 @@ using Dalamud.Utility; +using Glamourer.Designs.History; using Glamourer.Designs.Links; using Glamourer.Events; using Glamourer.GameData; @@ -107,7 +108,7 @@ public sealed class DesignManager : DesignEditor Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier}."); SaveService.ImmediateSave(design); - DesignChanged.Invoke(DesignChanged.Type.Created, design, path); + DesignChanged.Invoke(DesignChanged.Type.Created, design, new CreationTransaction(actualName, path)); return design; } @@ -127,7 +128,7 @@ public sealed class DesignManager : DesignEditor Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier} by cloning Temporary Design."); SaveService.ImmediateSave(design); - DesignChanged.Invoke(DesignChanged.Type.Created, design, path); + DesignChanged.Invoke(DesignChanged.Type.Created, design, new CreationTransaction(actualName, path)); return design; } @@ -147,7 +148,7 @@ public sealed class DesignManager : DesignEditor Glamourer.Log.Debug( $"Added new design {design.Identifier} by cloning {clone.Identifier.ToString()}."); SaveService.ImmediateSave(design); - DesignChanged.Invoke(DesignChanged.Type.Created, design, path); + DesignChanged.Invoke(DesignChanged.Type.Created, design, new CreationTransaction(actualName, path)); return design; } @@ -176,7 +177,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Renamed design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.Renamed, design, oldName); + DesignChanged.Invoke(DesignChanged.Type.Renamed, design, new RenameTransaction(oldName, newName)); } /// Change the description of a design. @@ -190,7 +191,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Changed description of design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.ChangedDescription, design, oldDescription); + DesignChanged.Invoke(DesignChanged.Type.ChangedDescription, design, new DescriptionTransaction(oldDescription, description)); } /// Change the associated color of a design. @@ -204,7 +205,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Changed color of design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.ChangedColor, design, oldColor); + DesignChanged.Invoke(DesignChanged.Type.ChangedColor, design, new DesignColorTransaction(oldColor, newColor)); } /// Add a new tag to a design. The tags remain sorted. @@ -218,7 +219,7 @@ public sealed class DesignManager : DesignEditor var idx = design.Tags.IndexOf(tag); SaveService.QueueSave(design); Glamourer.Log.Debug($"Added tag {tag} at {idx} to design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.AddedTag, design, (tag, idx)); + DesignChanged.Invoke(DesignChanged.Type.AddedTag, design, new TagAddedTransaction(tag, idx)); } /// Remove a tag from a design by its index. @@ -232,7 +233,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Removed tag {oldTag} at {tagIdx} from design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.RemovedTag, design, (oldTag, tagIdx)); + DesignChanged.Invoke(DesignChanged.Type.RemovedTag, design, new TagRemovedTransaction(oldTag, tagIdx)); } /// Rename a tag from a design by its index. The tags stay sorted. @@ -247,7 +248,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Renamed tag {oldTag} at {tagIdx} to {newTag} in design {design.Identifier} and reordered tags."); - DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design, (oldTag, newTag, tagIdx)); + DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design, new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag))); } /// Add an associated mod to a design. @@ -259,7 +260,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Added associated mod {mod.DirectoryName} to design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.AddedMod, design, (mod, settings)); + DesignChanged.Invoke(DesignChanged.Type.AddedMod, design, new ModAddedTransaction(mod, settings)); } /// Remove an associated mod from a design. @@ -271,17 +272,18 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Removed associated mod {mod.DirectoryName} from design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.RemovedMod, design, (mod, settings)); + DesignChanged.Invoke(DesignChanged.Type.RemovedMod, design, new ModRemovedTransaction(mod, settings)); } /// Add or update an associated mod to a design. public void UpdateMod(Design design, Mod mod, ModSettings settings) { + var oldSettings = design.AssociatedMods[mod]; design.AssociatedMods[mod] = settings; design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Updated (or added) associated mod {mod.DirectoryName} from design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.AddedMod, design, (mod, settings)); + DesignChanged.Invoke(DesignChanged.Type.UpdatedMod, design, new ModUpdatedTransaction(mod, oldSettings, settings)); } /// Set the write protection status of a design. @@ -292,7 +294,7 @@ public sealed class DesignManager : DesignEditor SaveService.QueueSave(design); Glamourer.Log.Debug($"Set design {design.Identifier} to {(value ? "no longer be " : string.Empty)} write-protected."); - DesignChanged.Invoke(DesignChanged.Type.WriteProtection, design, value); + DesignChanged.Invoke(DesignChanged.Type.WriteProtection, design, null); } /// Set the quick design bar display status of a design. @@ -305,7 +307,7 @@ public sealed class DesignManager : DesignEditor SaveService.QueueSave(design); Glamourer.Log.Debug( $"Set design {design.Identifier} to {(!value ? "no longer be " : string.Empty)} displayed in the quick design bar."); - DesignChanged.Invoke(DesignChanged.Type.QuickDesignBar, design, value); + DesignChanged.Invoke(DesignChanged.Type.QuickDesignBar, design, null); } #endregion @@ -332,7 +334,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of customization {idx.ToDefaultName()} to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyCustomize, design, idx); + DesignChanged.Invoke(DesignChanged.Type.ApplyCustomize, design, new ApplicationTransaction(idx, !value, value)); } /// Change whether to apply a specific equipment piece. @@ -344,7 +346,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of {slot} equipment piece to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyEquip, design, slot); + DesignChanged.Invoke(DesignChanged.Type.ApplyEquip, design, new ApplicationTransaction((slot, false), !value, value)); } /// Change whether to apply a specific equipment piece. @@ -356,11 +358,11 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of {slot} bonus item to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyBonusItem, design, slot); + DesignChanged.Invoke(DesignChanged.Type.ApplyBonusItem, design, new ApplicationTransaction(slot, !value, value)); } /// Change whether to apply a specific stain. - public void ChangeApplyStain(Design design, EquipSlot slot, bool value) + public void ChangeApplyStains(Design design, EquipSlot slot, bool value) { if (!design.SetApplyStain(slot, value)) return; @@ -368,7 +370,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of stain of {slot} equipment piece to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyStain, design, slot); + DesignChanged.Invoke(DesignChanged.Type.ApplyStain, design, new ApplicationTransaction((slot, true), !value, value)); } /// Change whether to apply a specific crest visibility. @@ -380,7 +382,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of crest visibility of {slot} equipment piece to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyCrest, design, slot); + DesignChanged.Invoke(DesignChanged.Type.ApplyCrest, design, new ApplicationTransaction(slot, !value, value)); } /// Change the application value of one of the meta flags. @@ -392,7 +394,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of {metaIndex} to {value}."); - DesignChanged.Invoke(DesignChanged.Type.Other, design, (metaIndex, true, value)); + DesignChanged.Invoke(DesignChanged.Type.Other, design, new ApplicationTransaction(metaIndex, !value, value)); } /// Change the application value of a customize parameter. @@ -404,7 +406,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Set applying of parameter {flag} to {value}."); - DesignChanged.Invoke(DesignChanged.Type.ApplyParameter, design, flag); + DesignChanged.Invoke(DesignChanged.Type.ApplyParameter, design, new ApplicationTransaction(flag, !value, value)); } #endregion diff --git a/Glamourer/Designs/History/DesignTransaction.cs b/Glamourer/Designs/History/DesignTransaction.cs new file mode 100644 index 0000000..98e3eec --- /dev/null +++ b/Glamourer/Designs/History/DesignTransaction.cs @@ -0,0 +1,181 @@ +using Glamourer.GameData; +using Glamourer.Interop.Material; +using Glamourer.Interop.Penumbra; +using Penumbra.GameData.Enums; + +namespace Glamourer.Designs.History; + +/// Only Designs. Can not be reverted. +public readonly record struct CreationTransaction(string Name, string? Path) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + { } +} + +/// Only Designs. +public readonly record struct RenameTransaction(string Old, string New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is RenameTransaction other ? new RenameTransaction(other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).Rename((Design)data, Old); +} + +/// Only Designs. +public readonly record struct DescriptionTransaction(string Old, string New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is DescriptionTransaction other ? new DescriptionTransaction(other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).ChangeDescription((Design)data, Old); +} + +/// Only Designs. +public readonly record struct DesignColorTransaction(string Old, string New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is DesignColorTransaction other ? new DesignColorTransaction(other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).ChangeColor((Design)data, Old); +} + +/// Only Designs. +public readonly record struct TagAddedTransaction(string New, int Index) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).RemoveTag((Design)data, Index); +} + +/// Only Designs. +public readonly record struct TagRemovedTransaction(string Old, int Index) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).AddTag((Design)data, Old); +} + +/// Only Designs. +public readonly record struct TagChangedTransaction(string Old, string New, int IndexOld, int IndexNew) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is TagChangedTransaction other && other.IndexNew == IndexOld + ? new TagChangedTransaction(other.Old, New, other.IndexOld, IndexNew) + : null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).RenameTag((Design)data, IndexNew, Old); +} + +/// Only Designs. +public readonly record struct ModAddedTransaction(Mod Mod, ModSettings Settings) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).RemoveMod((Design)data, Mod); +} + +/// Only Designs. +public readonly record struct ModRemovedTransaction(Mod Mod, ModSettings Settings) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).AddMod((Design)data, Mod, Settings); +} + +/// Only Designs. +public readonly record struct ModUpdatedTransaction(Mod Mod, ModSettings Old, ModSettings New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is ModUpdatedTransaction other && Mod == other.Mod ? new ModUpdatedTransaction(Mod, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).UpdateMod((Design)data, Mod, Old); +} + +/// Only Designs. +public readonly record struct MaterialTransaction(MaterialValueIndex Index, ColorRow? Old, ColorRow? New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is MaterialTransaction other && Index == other.Index ? new MaterialTransaction(Index, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).ChangeMaterialValue((Design)data, Index, Old); +} + +/// Only Designs. +public readonly record struct MaterialRevertTransaction(MaterialValueIndex Index, bool Old, bool New) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + => ((DesignManager)editor).ChangeMaterialRevert((Design)data, Index, Old); +} + +/// Only Designs. +public readonly record struct ApplicationTransaction(object Index, bool Old, bool New) + : ITransaction +{ + public ITransaction? Merge(ITransaction other) + => null; + + public void Revert(IDesignEditor editor, object data) + { + var manager = (DesignManager)editor; + var design = (Design)data; + switch (Index) + { + case CustomizeIndex idx: + manager.ChangeApplyCustomize(design, idx, Old); + break; + case (EquipSlot slot, true): + manager.ChangeApplyStains(design, slot, Old); + break; + case (EquipSlot slot, _): + manager.ChangeApplyItem(design, slot, Old); + break; + case BonusItemFlag slot: + manager.ChangeApplyBonusItem(design, slot, Old); + break; + case CrestFlag slot: + manager.ChangeApplyCrest(design, slot, Old); + break; + case MetaIndex slot: + manager.ChangeApplyMeta(design, slot, Old); + break; + case CustomizeParameterFlag slot: + manager.ChangeApplyParameter(design, slot, Old); + break; + case MaterialValueIndex slot: + manager.ChangeApplyMaterialValue(design, slot, Old); + break; + } + } +} diff --git a/Glamourer/Designs/History/EditorHistory.cs b/Glamourer/Designs/History/EditorHistory.cs new file mode 100644 index 0000000..6382b94 --- /dev/null +++ b/Glamourer/Designs/History/EditorHistory.cs @@ -0,0 +1,191 @@ +using Glamourer.Api.Enums; +using Glamourer.Events; +using Glamourer.Interop.Structs; +using Glamourer.State; +using OtterGui.Services; + +namespace Glamourer.Designs.History; + +public class EditorHistory : IDisposable, IService +{ + public const int MaxUndo = 16; + + private sealed class Queue : IReadOnlyList + { + private DateTime _lastAdd = DateTime.UtcNow; + + private readonly ITransaction[] _data = new ITransaction[MaxUndo]; + public int Offset { get; private set; } + public int Count { get; private set; } + + public void Add(ITransaction transaction) + { + if (!TryMerge(transaction)) + { + if (Count == MaxUndo) + { + _data[Offset] = transaction; + Offset = (Offset + 1) % MaxUndo; + } + else + { + if (Offset > 0) + { + _data[(Count + Offset) % MaxUndo] = transaction; + ++Count; + } + else + { + _data[Count] = transaction; + ++Count; + } + } + } + + _lastAdd = DateTime.UtcNow; + } + + private bool TryMerge(ITransaction newTransaction) + { + if (Count == 0) + return false; + + var time = DateTime.UtcNow; + if (time - _lastAdd > TimeSpan.FromMilliseconds(250)) + return false; + + var lastIdx = (Offset + Count - 1) % MaxUndo; + if (newTransaction.Merge(_data[lastIdx]) is not { } transaction) + return false; + + _data[lastIdx] = transaction; + return true; + } + + public ITransaction? RemoveLast() + { + if (Count == 0) + return null; + + --Count; + var idx = (Offset + Count) % MaxUndo; + return _data[idx]; + } + + public IEnumerator GetEnumerator() + { + var end = Offset + (Offset + Count) % MaxUndo; + for (var i = Offset; i < end; ++i) + yield return _data[i]; + + end = Count - end; + for (var i = 0; i < end; ++i) + yield return _data[i]; + } + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); + + public ITransaction this[int index] + => index < 0 || index >= Count + ? throw new IndexOutOfRangeException() + : _data[(Offset + index) % MaxUndo]; + } + + private readonly DesignEditor _designEditor; + private readonly StateEditor _stateEditor; + private readonly DesignChanged _designChanged; + private readonly StateChanged _stateChanged; + + private readonly Dictionary _stateEntries = []; + private readonly Dictionary _designEntries = []; + + private bool _undoMode; + + public EditorHistory(DesignManager designEditor, StateManager stateEditor, DesignChanged designChanged, StateChanged stateChanged) + { + _designEditor = designEditor; + _stateEditor = stateEditor; + _designChanged = designChanged; + _stateChanged = stateChanged; + + _designChanged.Subscribe(OnDesignChanged, DesignChanged.Priority.EditorHistory); + _stateChanged.Subscribe(OnStateChanged, StateChanged.Priority.EditorHistory); + } + + public void Dispose() + { + _designChanged.Unsubscribe(OnDesignChanged); + _stateChanged.Unsubscribe(OnStateChanged); + } + + public bool CanUndo(ActorState state) + => _stateEntries.TryGetValue(state, out var list) && list.Count > 0; + + public bool CanUndo(Design design) + => _designEntries.TryGetValue(design, out var list) && list.Count > 0; + + public bool Undo(ActorState state) + { + if (!_stateEntries.TryGetValue(state, out var list) || list.Count == 0) + return false; + + _undoMode = true; + list.RemoveLast()!.Revert(_stateEditor, state); + _undoMode = false; + return true; + } + + public bool Undo(Design design) + { + if (!_designEntries.TryGetValue(design, out var list) || list.Count == 0) + return false; + + _undoMode = true; + list.RemoveLast()!.Revert(_designEditor, design); + _undoMode = false; + return true; + } + + + private void AddStateTransaction(ActorState state, ITransaction transaction) + { + if (!_stateEntries.TryGetValue(state, out var list)) + { + list = new Queue(); + _stateEntries.Add(state, list); + } + + list.Add(transaction); + } + + private void AddDesignTransaction(Design design, ITransaction transaction) + { + if (!_designEntries.TryGetValue(design, out var list)) + { + list = new Queue(); + _designEntries.Add(design, list); + } + + list.Add(transaction); + } + + + private void OnStateChanged(StateChangeType type, StateSource source, ActorState state, ActorData actors, ITransaction? data) + { + if (_undoMode || source is not StateSource.Manual) + return; + + if (data is not null) + AddStateTransaction(state, data); + } + + private void OnDesignChanged(DesignChanged.Type type, Design design, ITransaction? data) + { + if (_undoMode) + return; + + if (data is not null) + AddDesignTransaction(design, data); + } +} diff --git a/Glamourer/Designs/History/Transaction.cs b/Glamourer/Designs/History/Transaction.cs new file mode 100644 index 0000000..ac310b0 --- /dev/null +++ b/Glamourer/Designs/History/Transaction.cs @@ -0,0 +1,113 @@ +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; +using Glamourer.GameData; + +namespace Glamourer.Designs.History; + +public interface ITransaction +{ + public ITransaction? Merge(ITransaction other); + public void Revert(IDesignEditor editor, object data); +} + +public readonly record struct CustomizeTransaction(CustomizeIndex Slot, CustomizeValue Old, CustomizeValue New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is CustomizeTransaction other && Slot == other.Slot ? new CustomizeTransaction(Slot, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeCustomize(data, Slot, Old, ApplySettings.Manual); +} + +public readonly record struct EntireCustomizeTransaction(CustomizeFlag Apply, CustomizeArray Old, CustomizeArray New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is EntireCustomizeTransaction other ? new EntireCustomizeTransaction(Apply | other.Apply, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeEntireCustomize(data, Old, Apply, ApplySettings.Manual); +} + +public readonly record struct EquipTransaction(EquipSlot Slot, EquipItem Old, EquipItem New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is EquipTransaction other && Slot == other.Slot ? new EquipTransaction(Slot, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeItem(data, Slot, Old, ApplySettings.Manual); +} + +public readonly record struct BonusItemTransaction(BonusItemFlag Slot, BonusItem Old, BonusItem New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is BonusItemTransaction other && Slot == other.Slot ? new BonusItemTransaction(Slot, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeBonusItem(data, Slot, Old, ApplySettings.Manual); +} + +public readonly record struct WeaponTransaction( + EquipItem OldMain, + EquipItem OldOff, + EquipItem OldGauntlets, + EquipItem NewMain, + EquipItem NewOff, + EquipItem NewGauntlets) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is WeaponTransaction other + ? new WeaponTransaction(other.OldMain, other.OldOff, other.OldGauntlets, NewMain, NewOff, NewGauntlets) + : null; + + public void Revert(IDesignEditor editor, object data) + { + editor.ChangeItem(data, EquipSlot.MainHand, OldMain, ApplySettings.Manual); + editor.ChangeItem(data, EquipSlot.OffHand, OldOff, ApplySettings.Manual); + editor.ChangeItem(data, EquipSlot.Hands, OldGauntlets, ApplySettings.Manual); + } +} + +public readonly record struct StainTransaction(EquipSlot Slot, StainIds Old, StainIds New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is StainTransaction other && Slot == other.Slot ? new StainTransaction(Slot, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeStains(data, Slot, Old, ApplySettings.Manual); +} + +public readonly record struct CrestTransaction(CrestFlag Slot, bool Old, bool New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is CrestTransaction other && Slot == other.Slot ? new CrestTransaction(Slot, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeCrest(data, Slot, Old, ApplySettings.Manual); +} + +public readonly record struct ParameterTransaction(CustomizeParameterFlag Slot, CustomizeParameterValue Old, CustomizeParameterValue New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => older is ParameterTransaction other && Slot == other.Slot ? new ParameterTransaction(Slot, other.Old, New) : null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeCustomizeParameter(data, Slot, Old, ApplySettings.Manual); +} + +public readonly record struct MetaTransaction(MetaIndex Slot, bool Old, bool New) + : ITransaction +{ + public ITransaction? Merge(ITransaction older) + => null; + + public void Revert(IDesignEditor editor, object data) + => editor.ChangeMetaState(data, Slot, Old, ApplySettings.Manual); +} diff --git a/Glamourer/Designs/Links/DesignLinkManager.cs b/Glamourer/Designs/Links/DesignLinkManager.cs index 76d9c9a..df1f147 100644 --- a/Glamourer/Designs/Links/DesignLinkManager.cs +++ b/Glamourer/Designs/Links/DesignLinkManager.cs @@ -1,4 +1,5 @@ using Glamourer.Automation; +using Glamourer.Designs.History; using Glamourer.Events; using Glamourer.Services; using OtterGui.Services; @@ -67,7 +68,7 @@ public sealed class DesignLinkManager : IService, IDisposable _event.Invoke(DesignChanged.Type.ChangedLink, parent, null); } - private void OnDesignChanged(DesignChanged.Type type, Design deletedDesign, object? _) + private void OnDesignChanged(DesignChanged.Type type, Design deletedDesign, ITransaction? _) { if (type is not DesignChanged.Type.Deleted) return; diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index a8f35d5..6c2ba8a 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -1,4 +1,5 @@ using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.Gui; using OtterGui.Classes; @@ -13,113 +14,116 @@ namespace Glamourer.Events; /// /// public sealed class DesignChanged() - : EventWrapper(nameof(DesignChanged)) + : EventWrapper(nameof(DesignChanged)) { public enum Type { - /// A new design was created. Data is a potential path to move it to [string?]. + /// A new design was created. Created, - /// An existing design was deleted. Data is null. + /// An existing design was deleted. Deleted, - /// Invoked on full reload. Design and Data are null. + /// Invoked on full reload. ReloadedAll, - /// An existing design was renamed. Data is the prior name [string]. + /// An existing design was renamed. Renamed, - /// An existing design had its description changed. Data is the prior description [string]. + /// An existing design had its description changed. ChangedDescription, - /// An existing design had its associated color changed. Data is the prior color [string]. + /// An existing design had its associated color changed. ChangedColor, - /// An existing design had a new tag added. Data is the new tag and the index it was added at [(string, int)]. + /// An existing design had a new tag added. AddedTag, - /// An existing design had an existing tag removed. Data is the removed tag and the index it had before removal [(string, int)]. + /// An existing design had an existing tag removed. RemovedTag, - /// An existing design had an existing tag renamed. Data is the old name of the tag, the new name of the tag, and the index it had before being resorted [(string, string, int)]. + /// An existing design had an existing tag renamed. ChangedTag, - /// An existing design had a new associated mod added. Data is the Mod and its Settings [(Mod, ModSettings)]. + /// An existing design had a new associated mod added. AddedMod, - /// An existing design had an existing associated mod removed. Data is the Mod and its Settings [(Mod, ModSettings)]. + /// An existing design had an existing associated mod removed. RemovedMod, - /// An existing design had a link to a different design added, removed or moved. Data is null. + /// An existing design had an existing associated mod updated. + UpdatedMod, + + /// An existing design had a link to a different design added, removed or moved. ChangedLink, - /// An existing design had a customization changed. Data is the old value, the new value and the type [(CustomizeValue, CustomizeValue, CustomizeIndex)]. + /// An existing design had a customization changed. Customize, - /// An existing design had its entire customize array changed. Data is the old array, the applied flags and the changed flags. [(CustomizeArray, CustomizeFlag, CustomizeFlag)]. + /// An existing design had its entire customize array changed. EntireCustomize, - /// An existing design had an equipment piece changed. Data is the old value, the new value and the slot [(EquipItem, EquipItem, EquipSlot)]. + /// An existing design had an equipment piece changed. Equip, - /// An existing design had a bonus item changed. Data is the old value, the new value and the slot [(BonusItem, BonusItem, BonusItemFlag)]. + /// An existing design had a bonus item changed. BonusItem, - /// An existing design had its weapons changed. Data is the old mainhand, the old offhand, the new mainhand, the new offhand (if any) and the new gauntlets (if any). [(EquipItem, EquipItem, EquipItem, EquipItem?, EquipItem?)]. + /// An existing design had its weapons changed. Weapon, - /// An existing design had a stain changed. Data is the old stain id, the new stain id and the slot [(StainIds, StainIds, EquipSlot)]. + /// An existing design had a stain changed. Stains, - /// An existing design had a crest visibility changed. Data is the old crest visibility, the new crest visibility and the slot [(bool, bool, EquipSlot)]. + /// An existing design had a crest visibility changed. Crest, - /// An existing design had a customize parameter changed. Data is the old value, the new value and the flag [(CustomizeParameterValue, CustomizeParameterValue, CustomizeParameterFlag)]. + /// An existing design had a customize parameter changed. Parameter, - /// An existing design had an advanced dye row added, changed, or deleted. Data is the old value, the new value and the index [(ColorRow?, ColorRow?, MaterialValueIndex)]. + /// An existing design had an advanced dye row added, changed, or deleted. Material, - /// An existing design had an advanced dye rows Revert state changed. Data is the index [MaterialValueIndex]. + /// An existing design had an advanced dye rows Revert state changed. MaterialRevert, /// An existing design had changed whether it always forces a redraw or not. ForceRedraw, - /// An existing design changed whether a specific customization is applied. Data is the type of customization [CustomizeIndex]. + /// An existing design changed whether a specific customization is applied. ApplyCustomize, - /// An existing design changed whether a specific equipment piece is applied. Data is the slot of the equipment [EquipSlot]. + /// An existing design changed whether a specific equipment piece is applied. ApplyEquip, - /// An existing design changed whether a specific bonus item is applied. Data is the slot of the item [BonusItemFlag]. + /// An existing design changed whether a specific bonus item is applied. ApplyBonusItem, - /// An existing design changed whether a specific stain is applied. Data is the slot of the equipment [EquipSlot]. + /// An existing design changed whether a specific stain is applied. ApplyStain, - /// An existing design changed whether a specific crest visibility is applied. Data is the slot of the equipment [EquipSlot]. + /// An existing design changed whether a specific crest visibility is applied. ApplyCrest, - /// An existing design changed whether a specific customize parameter is applied. Data is the flag for the parameter [CustomizeParameterFlag]. + /// An existing design changed whether a specific customize parameter is applied. ApplyParameter, - /// An existing design changed whether an advanced dye row is applied. Data is the index [MaterialValueIndex]. + /// An existing design changed whether an advanced dye row is applied. ApplyMaterial, - /// An existing design changed its write protection status. Data is the new value [bool]. + /// An existing design changed its write protection status. WriteProtection, - /// An existing design changed its display status for the quick design bar. Data is the new value [bool]. + /// An existing design changed its display status for the quick design bar. QuickDesignBar, - /// An existing design changed one of the meta flags. Data is the flag, whether it was about their applying and the new value [(MetaFlag, bool, bool)]. + /// An existing design changed one of the meta flags. Other, } public enum Priority { - /// + /// DesignLinkManager = 1, /// @@ -131,7 +135,10 @@ public sealed class DesignChanged() /// DesignFileSystemSelector = -1, - /// + /// DesignCombo = -2, + + /// + EditorHistory = -1000, } } diff --git a/Glamourer/Events/StateChanged.cs b/Glamourer/Events/StateChanged.cs index 641665c..c704195 100644 --- a/Glamourer/Events/StateChanged.cs +++ b/Glamourer/Events/StateChanged.cs @@ -1,4 +1,5 @@ using Glamourer.Api.Enums; +using Glamourer.Designs.History; using Glamourer.Interop.Structs; using Glamourer.State; using OtterGui.Classes; @@ -15,11 +16,17 @@ namespace Glamourer.Events; /// /// public sealed class StateChanged() - : EventWrapper(nameof(StateChanged)) + : EventWrapper(nameof(StateChanged)) { public enum Priority { - GlamourerIpc = int.MinValue, + /// + GlamourerIpc = int.MinValue, + + /// PenumbraAutoRedraw = 0, + + /// + EditorHistory = -1000, } -} \ No newline at end of file +} diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index 4bd18ab..dccfa44 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.Utility.Raii; using Glamourer.Automation; using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.Designs.Special; using Glamourer.Events; using ImGuiNET; @@ -29,7 +30,7 @@ public abstract class DesignComboBase : FilterComboCache "Undo the last change."; + + protected override FontAwesomeIcon Icon + => FontAwesomeIcon.Undo; + + public override bool Visible + => panel._state != null; + + protected override bool Disabled + => (panel._state?.IsLocked ?? true) || !panel._editorHistory.CanUndo(panel._state); + + protected override void OnClick() + => panel._editorHistory.Undo(panel._state!); + } + private sealed class LockedButton(ActorPanel panel) : HeaderDrawer.Button { protected override string Description diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index 11147c8..ea117c5 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin.Services; using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.Events; using Glamourer.Services; using ImGuiNET; @@ -178,7 +179,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector _config.OpenFoldersByDefault; - private void OnDesignChange(DesignChanged.Type type, Design design, object? oldData) + private void OnDesignChange(DesignChanged.Type type, Design design, ITransaction? _) { switch (type) { diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 1a072cb..07eb432 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -277,7 +277,7 @@ public class DesignPanel { var apply = bigChange ? ((EquipFlag)flags).HasFlag(slot.ToStainFlag()) : _selector.Selected!.DoApplyStain(slot); if (ImGui.Checkbox($"Apply {slot.ToName()} Dye", ref apply) || bigChange) - _manager.ChangeApplyStain(_selector.Selected!, slot, apply); + _manager.ChangeApplyStains(_selector.Selected!, slot, apply); } else foreach (var slot in slots) diff --git a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs index 72fb554..fbe0d9d 100644 --- a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs +++ b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs @@ -1,5 +1,6 @@ using Dalamud.Plugin.Services; using Glamourer.Api.Enums; +using Glamourer.Designs.History; using Glamourer.Events; using Glamourer.Interop.Structs; using Glamourer.State; @@ -30,21 +31,21 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService _stateChanged = stateChanged; _penumbra.ModSettingChanged += OnModSettingChange; _framework.Update += OnFramework; - _stateChanged.Subscribe(OnStateChange, StateChanged.Priority.PenumbraAutoRedraw); + _stateChanged.Subscribe(OnStateChanged, StateChanged.Priority.PenumbraAutoRedraw); } public void Dispose() { _penumbra.ModSettingChanged -= OnModSettingChange; _framework.Update -= OnFramework; - _stateChanged.Unsubscribe(OnStateChange); + _stateChanged.Unsubscribe(OnStateChanged); } private readonly ConcurrentQueue<(ActorState, Action, int)> _actions = []; private readonly ConcurrentSet _skips = []; private DateTime _frame; - private void OnStateChange(StateChangeType type, StateSource source, ActorState state, ActorData _1, object? _2) + private void OnStateChanged(StateChangeType type, StateSource source, ActorState state, ActorData _1, ITransaction? _2) { if (type is StateChangeType.Design && source.IsIpc()) _skips.TryAdd(state); diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index c627564..95c118d 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -1,5 +1,6 @@ using Glamourer.Api.Enums; using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.Designs.Links; using Glamourer.Events; using Glamourer.GameData; @@ -39,7 +40,7 @@ public class StateEditor( var actors = Applier.ForceRedraw(state, source.RequiresChange()); Glamourer.Log.Verbose( $"Set model id in state {state.Identifier.Incognito(null)} from {old} to {modelId}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Model, source, state, actors, (old, modelId)); + StateChanged.Invoke(StateChangeType.Model, source, state, actors, null); } /// @@ -52,7 +53,7 @@ public class StateEditor( var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set {idx.ToDefaultName()} customizations in state {state.Identifier.Incognito(null)} from {old.Value} to {value.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Customize, settings.Source, state, actors, (old, value, idx)); + StateChanged.Invoke(StateChangeType.Customize, settings.Source, state, actors, new CustomizeTransaction(idx, old, value)); } /// @@ -65,7 +66,8 @@ public class StateEditor( var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set {applied} customizations in state {state.Identifier.Incognito(null)} from {old} to {customizeInput}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.EntireCustomize, settings.Source, state, actors, (old, applied)); + StateChanged.Invoke(StateChangeType.EntireCustomize, settings.Source, state, actors, + new EntireCustomizeTransaction(applied, old, customizeInput)); } /// @@ -86,7 +88,25 @@ public class StateEditor( Glamourer.Log.Verbose( $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}). [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(type, settings.Source, state, actors, (old, item, slot)); + + if (type is StateChangeType.Equip) + { + StateChanged.Invoke(type, settings.Source, state, actors, new EquipTransaction(slot, old, item)); + } + else if (slot is EquipSlot.MainHand) + { + var oldOff = state.ModelData.Item(EquipSlot.OffHand); + var oldGauntlets = state.ModelData.Item(EquipSlot.Hands); + StateChanged.Invoke(type, settings.Source, state, actors, + new WeaponTransaction(old, oldOff, oldGauntlets, item, oldOff, oldGauntlets)); + } + else + { + var oldMain = state.ModelData.Item(EquipSlot.MainHand); + var oldGauntlets = state.ModelData.Item(EquipSlot.Hands); + StateChanged.Invoke(type, settings.Source, state, actors, + new WeaponTransaction(oldMain, old, oldGauntlets, oldMain, item, oldGauntlets)); + } } public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) @@ -98,7 +118,7 @@ public class StateEditor( var actors = Applier.ChangeBonusItem(state, slot, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.Id}) to {item.Name} ({item.Id}). [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.BonusItem, settings.Source, state, actors, (old, item, slot)); + StateChanged.Invoke(StateChangeType.BonusItem, settings.Source, state, actors, new BonusItemTransaction(slot, old, item)); } /// @@ -131,8 +151,26 @@ public class StateEditor( Glamourer.Log.Verbose( $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStains} to {stains!.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(type, settings.Source, state, actors, (old, item!.Value, slot)); - StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, (oldStains, stains!.Value, slot)); + if (type is StateChangeType.Equip) + { + StateChanged.Invoke(type, settings.Source, state, actors, new EquipTransaction(slot, old, item!.Value)); + } + else if (slot is EquipSlot.MainHand) + { + var oldOff = state.ModelData.Item(EquipSlot.OffHand); + var oldGauntlets = state.ModelData.Item(EquipSlot.Hands); + StateChanged.Invoke(type, settings.Source, state, actors, + new WeaponTransaction(old, oldOff, oldGauntlets, item!.Value, oldOff, oldGauntlets)); + } + else + { + var oldMain = state.ModelData.Item(EquipSlot.MainHand); + var oldGauntlets = state.ModelData.Item(EquipSlot.Hands); + StateChanged.Invoke(type, settings.Source, state, actors, + new WeaponTransaction(oldMain, old, oldGauntlets, oldMain, item!.Value, oldGauntlets)); + } + + StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, new StainTransaction(slot, oldStains, stains!.Value)); } /// @@ -145,7 +183,7 @@ public class StateEditor( var actors = Applier.ChangeStain(state, slot, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set {slot.ToName()} stain in state {state.Identifier.Incognito(null)} from {old} to {stains}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, (old, stains, slot)); + StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, new StainTransaction(slot, old, stains)); } /// @@ -158,7 +196,7 @@ public class StateEditor( var actors = Applier.ChangeCrests(state, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set {slot.ToLabel()} crest in state {state.Identifier.Incognito(null)} from {old} to {crest}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Crest, settings.Source, state, actors, (old, crest, slot)); + StateChanged.Invoke(StateChangeType.Crest, settings.Source, state, actors, new CrestTransaction(slot, old, crest)); } /// @@ -176,7 +214,7 @@ public class StateEditor( var actors = Applier.ChangeParameters(state, flag, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set {flag} in state {state.Identifier.Incognito(null)} from {old} to {@new}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Parameter, settings.Source, state, actors, (old, @new, flag)); + StateChanged.Invoke(StateChangeType.Parameter, settings.Source, state, actors, new ParameterTransaction(flag, old, @new)); } public void ChangeMaterialValue(object data, MaterialValueIndex index, in MaterialValueState newValue, ApplySettings settings) @@ -188,7 +226,8 @@ public class StateEditor( var actors = Applier.ChangeMaterialValue(state, index, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set material value in state {state.Identifier.Incognito(null)} from {oldValue} to {newValue.Game}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.MaterialValue, settings.Source, state, actors, (oldValue, newValue.Game, index)); + StateChanged.Invoke(StateChangeType.MaterialValue, settings.Source, state, actors, + new MaterialTransaction(index, oldValue, newValue.Game)); } public void ResetMaterialValue(object data, MaterialValueIndex index, ApplySettings settings) @@ -200,7 +239,7 @@ public class StateEditor( var actors = Applier.ChangeMaterialValue(state, index, true); Glamourer.Log.Verbose( $"Reset material value in state {state.Identifier.Incognito(null)} to game value. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.MaterialValue, settings.Source, state, actors, index); + StateChanged.Invoke(StateChangeType.MaterialValue, settings.Source, state, actors, new MaterialTransaction(index, null, null)); } /// @@ -213,7 +252,7 @@ public class StateEditor( var actors = Applier.ChangeMetaState(state, index, settings.Source.RequiresChange()); Glamourer.Log.Verbose( $"Set Head Gear Visibility in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Other, settings.Source, state, actors, (old, value, MetaIndex.HatState)); + StateChanged.Invoke(StateChangeType.Other, settings.Source, state, actors, new MetaTransaction(index, old, value)); } /// @@ -377,7 +416,7 @@ public class StateEditor( Glamourer.Log.Verbose( $"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, mergedDesign.Design); + StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later return; From ab771fd0105e76e937b4c5df6fc5e92a15818ba9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 31 Jul 2024 20:57:50 +0200 Subject: [PATCH 055/401] Add Undo to design panel. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 36 +++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 07eb432..e11a032 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -4,10 +4,12 @@ using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.System.Framework; using Glamourer.Automation; using Glamourer.Designs; +using Glamourer.Designs.History; using Glamourer.GameData; using Glamourer.Gui.Customization; using Glamourer.Gui.Equipment; using Glamourer.Gui.Materials; +using Glamourer.Gui.Tabs.ActorTab; using Glamourer.Interop; using Glamourer.State; using ImGuiNET; @@ -38,6 +40,7 @@ public class DesignPanel private readonly CustomizeParameterDrawer _parameterDrawer; private readonly DesignLinkDrawer _designLinkDrawer; private readonly MaterialDrawer _materials; + private readonly EditorHistory _history; private readonly Button[] _leftButtons; private readonly Button[] _rightButtons; @@ -56,7 +59,8 @@ public class DesignPanel MultiDesignPanel multiDesignPanel, CustomizeParameterDrawer parameterDrawer, DesignLinkDrawer designLinkDrawer, - MaterialDrawer materials) + MaterialDrawer materials, + EditorHistory history) { _selector = selector; _customizationDrawer = customizationDrawer; @@ -73,12 +77,14 @@ public class DesignPanel _parameterDrawer = parameterDrawer; _designLinkDrawer = designLinkDrawer; _materials = materials; + _history = history; _leftButtons = [ new SetFromClipboardButton(this), - new UndoButton(this), + new DesignUndoButton(this), new ExportToClipboardButton(this), new ApplyCharacterButton(this), + new UndoButton(this), ]; _rightButtons = [ @@ -544,7 +550,7 @@ public class DesignPanel } } - private sealed class UndoButton(DesignPanel panel) : Button + private sealed class DesignUndoButton(DesignPanel panel) : Button { public override bool Visible => panel._selector.Selected != null; @@ -553,10 +559,10 @@ public class DesignPanel => !panel._manager.CanUndo(panel._selector.Selected) || (panel._selector.Selected?.WriteProtected() ?? true); protected override string Description - => "Undo the last change if you accidentally overwrote your design with a different one."; + => "Undo the last time you applied an entire design onto this design, if you accidentally overwrote your design with a different one."; protected override FontAwesomeIcon Icon - => FontAwesomeIcon.Undo; + => FontAwesomeIcon.SyncAlt; protected override void OnClick() { @@ -606,7 +612,7 @@ public class DesignPanel protected override string Description => "Overwrite this design with your character's current state."; - + protected override bool Disabled => panel._selector.Selected?.WriteProtected() ?? true; @@ -632,4 +638,22 @@ public class DesignPanel } } } + + private sealed class UndoButton(DesignPanel panel) : Button + { + protected override string Description + => "Undo the last change."; + + protected override FontAwesomeIcon Icon + => FontAwesomeIcon.Undo; + + public override bool Visible + => panel._selector.Selected != null; + + protected override bool Disabled + => (panel._selector.Selected?.WriteProtected() ?? true) || !panel._history.CanUndo(panel._selector.Selected); + + protected override void OnClick() + => panel._history.Undo(panel._selector.Selected!); + } } From ad79d9cc079adb820e7c5febc01f9795ea6fd60e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 1 Aug 2024 17:06:10 +0200 Subject: [PATCH 056/401] Set focus on detached advanced dyes when opening or toggling with buttons. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 61eea83..a9ab805 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -29,6 +29,7 @@ public sealed unsafe class AdvancedDyePopup( private Actor _actor; private byte _selectedMaterial = byte.MaxValue; private bool _anyChanged; + private bool _forceFocus; private const int RowsPerPage = 16; private int _rowOffset; @@ -70,6 +71,7 @@ public sealed unsafe class AdvancedDyePopup( if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Palette.ToIconString(), new Vector2(ImGui.GetFrameHeight()), string.Empty, false, true)) { + _forceFocus = true; _selectedMaterial = byte.MaxValue; _drawIndex = isOpen ? null : index; } @@ -195,6 +197,12 @@ public sealed unsafe class AdvancedDyePopup( ImGui.SetNextWindowSize(new Vector2(width, height)); var window = ImGui.Begin("###Glamourer Advanced Dyes", flags); + if (ImGui.IsWindowAppearing() || _forceFocus) + { + ImGui.SetWindowFocus(); + _forceFocus = false; + } + try { if (window) From e516fd93189fba87f39b3f79e31d161dc6fc6b55 Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 1 Aug 2024 15:08:33 +0000 Subject: [PATCH 057/401] [CI] Updating repo.json for testing_1.3.0.9 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 0c672d6..ac8b996 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.8", + "TestingAssemblyVersion": "1.3.0.9", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.8/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.9/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 5460ffd0a07ecf8e11f996ff18a327da8210ae35 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 2 Aug 2024 17:02:28 +0200 Subject: [PATCH 058/401] Update world sets. --- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 8 +- Glamourer/State/WorldSets.cs | 96 ++++++++++++++++---- 2 files changed, 85 insertions(+), 19 deletions(-) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 558c4df..9651e85 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -357,8 +357,12 @@ public class UnlockTable : Table, IDisposable Job.JobRole.Gatherer => 0xFFD0D0D0, _ => ImGui.GetColorU32(ImGuiCol.Text), }; - using var c = ImRaii.PushColor(ImGuiCol.Text, color); - var r = base.DrawCheckbox(idx, out ret); + bool r; + using (ImRaii.PushColor(ImGuiCol.Text, color)) + { + r = base.DrawCheckbox(idx, out ret); + } + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) { _filterValue = job.Flag & _filterValue; diff --git a/Glamourer/State/WorldSets.cs b/Glamourer/State/WorldSets.cs index 6a497ea..314934b 100644 --- a/Glamourer/State/WorldSets.cs +++ b/Glamourer/State/WorldSets.cs @@ -70,6 +70,8 @@ public class WorldSets (CharacterWeapon.Int(2601, 13, 01), CharacterWeapon.Int(2651, 13, 1)), // DNC, High Steel Chakrams (CharacterWeapon.Int(2802, 13, 01), CharacterWeapon.Empty), // RPR, Deepgold War Scythe (CharacterWeapon.Int(2702, 08, 01), CharacterWeapon.Empty), // SGE, Stonegold Milpreves + (CharacterWeapon.Int(3101, 04, 03), CharacterWeapon.Int(3151, 04, 3)), // VPR, High Durium Twinfangs + (CharacterWeapon.Int(2901, 25, 01), CharacterWeapon.Int(2951, 25, 1)), // PCT, Chocobo Brush }; private static readonly (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)[] _50Artifact = @@ -115,6 +117,8 @@ public class WorldSets (FunEquipSet.Group.FullSet(204, 4), CharacterWeapon.Int(2601, 13, 1), CharacterWeapon.Int(2651, 13, 1)), // DNC, Softstepper, High Steel Chakrams (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 13, 1), CharacterWeapon.Empty), // RPR, Muzhik, Deepgold War Scythe (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 08, 1), CharacterWeapon.Empty), // SGE, Bookwyrm, Stonegold Milpreves + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 02, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; private static readonly (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)[] _60Artifact = @@ -160,6 +164,8 @@ public class WorldSets (FunEquipSet.Group.FullSet(204, 4), CharacterWeapon.Int(2601, 13, 1), CharacterWeapon.Int(2651, 13, 01)), // DNC, Softstepper, High Steel Chakrams (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 13, 1), CharacterWeapon.Empty), // RPR, Muzhik, Deepgold War Scythe (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 08, 1), CharacterWeapon.Empty), // SGE, Bookwyrm, Stonegold Milpreves + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 02, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; private static readonly (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)[] _70Artifact = @@ -205,6 +211,8 @@ public class WorldSets (FunEquipSet.Group.FullSet(204, 4), CharacterWeapon.Int(2601, 13, 1), CharacterWeapon.Int(2651, 13, 01)), // DNC, Softstepper, High Steel Chakrams (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 13, 1), CharacterWeapon.Empty), // RPR, Muzhik, Deepgold War Scythe (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 08, 1), CharacterWeapon.Empty), // SGE, Bookwyrm, Stonegold Milpreves + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 02, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; private static readonly (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)[] _80Artifact = @@ -250,6 +258,8 @@ public class WorldSets (FunEquipSet.Group.FullSet(543, 1), CharacterWeapon.Int(2601, 001, 1), CharacterWeapon.Int(2651, 01, 001)), // DNC, Dancer, Krishna (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 013, 1), CharacterWeapon.Empty), // RPR, Harvester's, Demon Slicer (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 008, 1), CharacterWeapon.Empty), // SGE, Therapeute's, Horkos + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 6, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 2, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; private static readonly (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)[] _90Artifact = @@ -295,29 +305,80 @@ public class WorldSets (FunEquipSet.Group.FullSet(694, 1), CharacterWeapon.Int(2607, 001, 1), CharacterWeapon.Int(2657, 001, 001)), // DNC, Etoile, Terpsichore (FunEquipSet.Group.FullSet(695, 1), CharacterWeapon.Int(2801, 001, 1), CharacterWeapon.Empty), // RPR, Reaper, Death Sickle (FunEquipSet.Group.FullSet(696, 1), CharacterWeapon.Int(2701, 006, 1), CharacterWeapon.Empty), // SGE, Didact, Hagneia + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 006, 1), CharacterWeapon.Int(3151, 006, 001)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 002, 1), CharacterWeapon.Int(2951, 002, 001)), // PCT, Painter's, Round Brush + }; + + private static readonly (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)[] _100Artifact = + { + (FunEquipSet.Group.FullSet(000, 0), CharacterWeapon.Empty, CharacterWeapon.Empty), // ADV, Nothing + (FunEquipSet.Group.FullSet(772, 1), CharacterWeapon.Int(0220, 002, 01), CharacterWeapon.Int(0114, 002, 001)), // GLA, Caballarius, Clarent, Galahad + (FunEquipSet.Group.FullSet(773, 1), CharacterWeapon.Int(0338, 001, 01), CharacterWeapon.Int(0388, 001, 001)), // PGL, Hesychast's, Suwaiyas + (FunEquipSet.Group.FullSet(774, 1), CharacterWeapon.Int(0417, 001, 01), CharacterWeapon.Empty), // MRD, Agoge, Ferocity + (FunEquipSet.Group.FullSet(775, 1), CharacterWeapon.Int(0528, 001, 01), CharacterWeapon.Empty), // LNC, Heavensbound, Gae Assail + (FunEquipSet.Group.FullSet(776, 1), CharacterWeapon.Int(0635, 001, 01), CharacterWeapon.Int(0698, 130, 001)), // ARC, Bihu, Gastraphetes + (FunEquipSet.Group.FullSet(777, 1), CharacterWeapon.Int(0831, 002, 01), CharacterWeapon.Empty), // CNJ, Theophany, Xoanon + (FunEquipSet.Group.FullSet(778, 1), CharacterWeapon.Int(1033, 002, 01), CharacterWeapon.Empty), // THM, Archmage's, Gridarvor + (FunEquipSet.Group.FullSet(791, 1), CharacterWeapon.Int(5004, 001, 16), CharacterWeapon.Int(5041, 001, 016)), // CRP, Millrise + (FunEquipSet.Group.FullSet(792, 1), CharacterWeapon.Int(5103, 001, 01), CharacterWeapon.Int(5141, 001, 017)), // BSM, Forgerise + (FunEquipSet.Group.FullSet(793, 1), CharacterWeapon.Int(5201, 011, 01), CharacterWeapon.Int(5241, 001, 017)), // ARM, Hammerrise + (FunEquipSet.Group.FullSet(794, 1), CharacterWeapon.Int(5301, 011, 01), CharacterWeapon.Int(5341, 001, 001)), // GSM, Gemrise + (FunEquipSet.Group.FullSet(795, 1), CharacterWeapon.Int(5405, 001, 01), CharacterWeapon.Int(5441, 001, 016)), // LTW, Hiderise + (FunEquipSet.Group.FullSet(796, 1), CharacterWeapon.Int(5503, 001, 01), CharacterWeapon.Int(5571, 001, 001)), // WVR, Boltrise + (FunEquipSet.Group.FullSet(797, 1), CharacterWeapon.Int(5603, 008, 01), CharacterWeapon.Int(5641, 001, 017)), // ALC, Cauldronrise + (FunEquipSet.Group.FullSet(798, 1), CharacterWeapon.Int(5701, 012, 01), CharacterWeapon.Int(5741, 001, 017)), // CUL, Galleyrise + (FunEquipSet.Group.FullSet(799, 1), CharacterWeapon.Int(7004, 001, 01), CharacterWeapon.Int(7051, 001, 017)), // MIN, Minerise + (FunEquipSet.Group.FullSet(800, 1), CharacterWeapon.Int(7101, 012, 01), CharacterWeapon.Int(7151, 001, 017)), // BTN, Fieldrise + (FunEquipSet.Group.FullSet(801, 1), CharacterWeapon.Int(7202, 001, 01), CharacterWeapon.Int(7255, 001, 001)), // FSH, Tacklerise + (FunEquipSet.Group.FullSet(772, 1), CharacterWeapon.Int(0220, 002, 01), CharacterWeapon.Int(0114, 002, 001)), // PLD, Caballarius, Clarent, Galahad + (FunEquipSet.Group.FullSet(773, 1), CharacterWeapon.Int(0338, 001, 01), CharacterWeapon.Int(0388, 001, 001)), // MNK, Hesychast's, Suwaiyas + (FunEquipSet.Group.FullSet(774, 1), CharacterWeapon.Int(0417, 001, 01), CharacterWeapon.Empty), // WAR, Agoge, Ferocity + (FunEquipSet.Group.FullSet(775, 1), CharacterWeapon.Int(0528, 001, 01), CharacterWeapon.Empty), // DRG, Heavensbound, Gae Assail + (FunEquipSet.Group.FullSet(776, 1), CharacterWeapon.Int(0635, 001, 01), CharacterWeapon.Int(0698, 130, 001)), // BRD, Bihu, Gastraphetes + (FunEquipSet.Group.FullSet(777, 1), CharacterWeapon.Int(0831, 002, 01), CharacterWeapon.Empty), // WHM, Theophany, Xoanon + (FunEquipSet.Group.FullSet(778, 1), CharacterWeapon.Int(1033, 002, 01), CharacterWeapon.Empty), // BLM, Archmage's, Gridarvor + (FunEquipSet.Group.FullSet(779, 1), CharacterWeapon.Int(1752, 001, 01), CharacterWeapon.Empty), // ACN, Glyphic, The Grand Grimoire + (FunEquipSet.Group.FullSet(779, 1), CharacterWeapon.Int(1752, 001, 01), CharacterWeapon.Empty), // SMN, Glyphic, The Grand Grimoire + (FunEquipSet.Group.FullSet(780, 1), CharacterWeapon.Int(1753, 001, 01), CharacterWeapon.Empty), // SCH, Pedagogy, Eclecticism + (FunEquipSet.Group.FullSet(781, 1), CharacterWeapon.Int(1801, 128, 01), CharacterWeapon.Int(1851, 128, 001)), // ROG, Momochi, Shiranui + (FunEquipSet.Group.FullSet(781, 1), CharacterWeapon.Int(1801, 128, 01), CharacterWeapon.Int(1851, 128, 001)), // NIN, Momochi, Shiranui + (FunEquipSet.Group.FullSet(783, 1), CharacterWeapon.Int(2026, 002, 01), CharacterWeapon.Int(2099, 001, 001)), // MCH, Forerider's, Sthalmann Special + (FunEquipSet.Group.FullSet(782, 1), CharacterWeapon.Int(1519, 002, 01), CharacterWeapon.Empty), // DRK, Fallen's, Maleficus + (FunEquipSet.Group.FullSet(784, 1), CharacterWeapon.Int(2136, 082, 01), CharacterWeapon.Int(2199, 001, 188)), // AST, Ephemerist's, Metis + (FunEquipSet.Group.FullSet(785, 1), CharacterWeapon.Int(2215, 001, 01), CharacterWeapon.Int(2259, 003, 001)), // SAM, Sakonji, Kogarasumaru + (FunEquipSet.Group.FullSet(786, 1), CharacterWeapon.Int(2301, 097, 01), CharacterWeapon.Int(2380, 001, 001)), // RDM, Roseblood, Colada + (FunEquipSet.Group.FullSet(811, 1), CharacterWeapon.Int(2401, 005, 01), CharacterWeapon.Empty), // BLU, Phantasmal, Blue-eyes + (FunEquipSet.Group.FullSet(787, 1), CharacterWeapon.Int(2501, 064, 01), CharacterWeapon.Empty), // GNB, Bastion's, Chastiefol + (FunEquipSet.Group.FullSet(788, 1), CharacterWeapon.Int(2611, 002, 01), CharacterWeapon.Int(2661, 002, 001)), // DNC, Horos, Soma + (FunEquipSet.Group.FullSet(790, 1), CharacterWeapon.Int(2816, 001, 01), CharacterWeapon.Empty), // RPR, Assassin's, Vendetta + (FunEquipSet.Group.FullSet(789, 1), CharacterWeapon.Int(2701, 026, 01), CharacterWeapon.Empty), // SGE, Metanoia, Asklepian + (FunEquipSet.Group.FullSet(840, 1), CharacterWeapon.Int(3101, 001, 01), CharacterWeapon.Int(3151, 001, 001)), // VPR, Viper's, Sargatanas + (FunEquipSet.Group.FullSet(841, 1), CharacterWeapon.Int(2901, 001, 01), CharacterWeapon.Int(2951, 001, 001)), // PCT, Pictomancer's, Angel Brush }; // @formatter:on private (FunEquipSet.Group, CharacterWeapon, CharacterWeapon)? GetGroup(byte level, byte job, Race race, Gender gender, Random rng) { - const int weight50 = 200; - const int weight60 = 500; - const int weight70 = 700; - const int weight80 = 800; - const int weight90 = 900; - const int weight100 = 1000; + const int weight50 = 200; + const int weight60 = 500; + const int weight70 = 700; + const int weight80 = 800; + const int weight90 = 900; + const int weight100 = 1000; + const int weight110 = 1100; if (job >= StarterWeapons.Length) return null; var maxWeight = level switch { - < 50 => weight50, - < 60 => weight60, - < 70 => weight70, - < 80 => weight80, - < 90 => weight90, - _ => weight100, + < 50 => weight50, + < 60 => weight60, + < 70 => weight70, + < 80 => weight80, + < 90 => weight90, + < 100 => weight100, + _ => weight110, }; var weight = rng.Next(0, maxWeight + 1); @@ -332,11 +393,12 @@ public class WorldSets var list = weight switch { - < weight60 => _50Artifact, - < weight70 => _60Artifact, - < weight80 => _70Artifact, - < weight90 => _80Artifact, - _ => _90Artifact, + < weight60 => _50Artifact, + < weight70 => _60Artifact, + < weight80 => _70Artifact, + < weight90 => _80Artifact, + < weight100 => _90Artifact, + _ => _100Artifact, }; Glamourer.Log.Verbose($"Chose weight {weight}/{maxWeight} for World set [Character: {level} {job} {race} {gender}]."); From 3a63a1b22d5a051f89fc469f62154f2c5ccaf30e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 3 Aug 2024 02:25:53 +0200 Subject: [PATCH 059/401] Add some codes. --- Glamourer/GameData/NpcCustomizeSet.cs | 4 +- Glamourer/Services/CodeService.cs | 57 ++++++++---- Glamourer/State/FunModule.cs | 127 +++++++++++++++++++++++++- 3 files changed, 165 insertions(+), 23 deletions(-) diff --git a/Glamourer/GameData/NpcCustomizeSet.cs b/Glamourer/GameData/NpcCustomizeSet.cs index dbf74cc..3c683a5 100644 --- a/Glamourer/GameData/NpcCustomizeSet.cs +++ b/Glamourer/GameData/NpcCustomizeSet.cs @@ -78,8 +78,8 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList }; // Event NPCs have a reference to NpcEquip but also contain the appearance in their own row. - // Prefer the NpcEquip reference if it is set, otherwise use the own. - if (row.NpcEquip.Row != 0 && row.NpcEquip.Value is { } equip) + // Prefer the NpcEquip reference if it is set and the own does not appear to be set, otherwise use the own. + if (row.NpcEquip.Row != 0 && row.NpcEquip.Value is { } equip && row is { ModelBody: 0, ModelLegs: 0 }) ApplyNpcEquip(ref ret, equip); else ApplyNpcEquip(ref ret, row); diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index 61339e1..5ab0d8f 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -30,13 +30,19 @@ public class CodeService Elephants = 0x020000, Crown = 0x040000, Dolphins = 0x080000, + Face = 0x100000, + Manderville = 0x200000, + Smiles = 0x400000, } public static readonly CodeFlag AllHintCodes = Enum.GetValues().Where(f => GetData(f).Display).Aggregate((CodeFlag)0, (f1, f2) => f1 | f2); - public const CodeFlag DyeCodes = CodeFlag.Clown | CodeFlag.World | CodeFlag.Elephants | CodeFlag.Dolphins; - public const CodeFlag GearCodes = CodeFlag.Emperor | CodeFlag.World | CodeFlag.Elephants | CodeFlag.Dolphins; + public const CodeFlag DyeCodes = + CodeFlag.Clown | CodeFlag.World | CodeFlag.Elephants | CodeFlag.Dolphins; + + public const CodeFlag GearCodes = + CodeFlag.Emperor | CodeFlag.World | CodeFlag.Elephants | CodeFlag.Dolphins; public const CodeFlag RaceCodes = CodeFlag.OopsHyur | CodeFlag.OopsElezen @@ -46,6 +52,8 @@ public class CodeService | CodeFlag.OopsAuRa | CodeFlag.OopsHrothgar; + public const CodeFlag FullCodes = CodeFlag.Face | CodeFlag.Manderville | CodeFlag.Smiles; + public const CodeFlag SizeCodes = CodeFlag.Dwarf | CodeFlag.Giant; private CodeFlag _enabled; @@ -161,26 +169,29 @@ public class CodeService private static CodeFlag GetMutuallyExclusive(CodeFlag flag) => flag switch { - CodeFlag.Clown => DyeCodes & ~CodeFlag.Clown, - CodeFlag.Emperor => GearCodes & ~CodeFlag.Emperor, - CodeFlag.Individual => 0, - CodeFlag.Dwarf => SizeCodes & ~CodeFlag.Dwarf, - CodeFlag.Giant => SizeCodes & ~CodeFlag.Giant, - CodeFlag.OopsHyur => RaceCodes & ~CodeFlag.OopsHyur, - CodeFlag.OopsElezen => RaceCodes & ~CodeFlag.OopsElezen, - CodeFlag.OopsLalafell => RaceCodes & ~CodeFlag.OopsLalafell, - CodeFlag.OopsMiqote => RaceCodes & ~CodeFlag.OopsMiqote, - CodeFlag.OopsRoegadyn => RaceCodes & ~CodeFlag.OopsRoegadyn, - CodeFlag.OopsAuRa => RaceCodes & ~CodeFlag.OopsAuRa, - CodeFlag.OopsHrothgar => RaceCodes & ~CodeFlag.OopsHrothgar, - CodeFlag.OopsViera => RaceCodes & ~CodeFlag.OopsViera, + CodeFlag.Clown => (FullCodes | DyeCodes) & ~CodeFlag.Clown, + CodeFlag.Emperor => (FullCodes | GearCodes) & ~CodeFlag.Emperor, + CodeFlag.Individual => FullCodes, + CodeFlag.Dwarf => (FullCodes | SizeCodes) & ~CodeFlag.Dwarf, + CodeFlag.Giant => (FullCodes | SizeCodes) & ~CodeFlag.Giant, + CodeFlag.OopsHyur => (FullCodes | RaceCodes) & ~CodeFlag.OopsHyur, + CodeFlag.OopsElezen => (FullCodes | RaceCodes) & ~CodeFlag.OopsElezen, + CodeFlag.OopsLalafell => (FullCodes | RaceCodes) & ~CodeFlag.OopsLalafell, + CodeFlag.OopsMiqote => (FullCodes | RaceCodes) & ~CodeFlag.OopsMiqote, + CodeFlag.OopsRoegadyn => (FullCodes | RaceCodes) & ~CodeFlag.OopsRoegadyn, + CodeFlag.OopsAuRa => (FullCodes | RaceCodes) & ~CodeFlag.OopsAuRa, + CodeFlag.OopsHrothgar => (FullCodes | RaceCodes) & ~CodeFlag.OopsHrothgar, + CodeFlag.OopsViera => (FullCodes | RaceCodes) & ~CodeFlag.OopsViera, CodeFlag.Artisan => 0, - CodeFlag.SixtyThree => 0, + CodeFlag.SixtyThree => FullCodes, CodeFlag.Shirts => 0, - CodeFlag.World => (DyeCodes | GearCodes) & ~CodeFlag.World, - CodeFlag.Elephants => (DyeCodes | GearCodes) & ~CodeFlag.Elephants, - CodeFlag.Crown => 0, - CodeFlag.Dolphins => (DyeCodes | GearCodes) & ~CodeFlag.Dolphins, + CodeFlag.World => (FullCodes | DyeCodes | GearCodes) & ~CodeFlag.World, + CodeFlag.Elephants => (FullCodes | DyeCodes | GearCodes) & ~CodeFlag.Elephants, + CodeFlag.Crown => FullCodes, + CodeFlag.Dolphins => (FullCodes | DyeCodes | GearCodes) & ~CodeFlag.Dolphins, + CodeFlag.Face => (FullCodes | RaceCodes | SizeCodes | GearCodes | DyeCodes | CodeFlag.Crown | CodeFlag.SixtyThree) & ~CodeFlag.Face, + CodeFlag.Manderville => (FullCodes | RaceCodes | SizeCodes | GearCodes | DyeCodes | CodeFlag.Crown | CodeFlag.SixtyThree) & ~CodeFlag.Manderville, + CodeFlag.Smiles => (FullCodes | RaceCodes | SizeCodes | GearCodes | DyeCodes | CodeFlag.Crown | CodeFlag.SixtyThree) & ~CodeFlag.Smiles, _ => 0, }; @@ -207,6 +218,9 @@ public class CodeService CodeFlag.Elephants => [ 0x9F, 0x4C, 0xCF, 0x6D, 0xC4, 0x01, 0x31, 0x46, 0x02, 0x05, 0x31, 0xED, 0xED, 0xB2, 0x66, 0x29, 0x31, 0x09, 0x1E, 0xE7, 0x47, 0xDE, 0x7B, 0x03, 0xB0, 0x3C, 0x06, 0x76, 0x26, 0x91, 0xDF, 0xB2 ], CodeFlag.Crown => [ 0x43, 0x8E, 0x34, 0x56, 0x24, 0xC9, 0xC6, 0xDE, 0x2A, 0x68, 0x3A, 0x5D, 0xF5, 0x8E, 0xCB, 0xEF, 0x0D, 0x4D, 0x5B, 0xDC, 0x23, 0xF9, 0xF9, 0xBD, 0xD9, 0x60, 0xAD, 0x53, 0xC5, 0xA0, 0x33, 0xC4 ], CodeFlag.Dolphins => [ 0x64, 0xC6, 0x2E, 0x7C, 0x22, 0x3A, 0x42, 0xF5, 0xC3, 0x93, 0x4F, 0x70, 0x1F, 0xFD, 0xFA, 0x3C, 0x98, 0xD2, 0x7C, 0xD8, 0x88, 0xA7, 0x3D, 0x1D, 0x0D, 0xD6, 0x70, 0x15, 0x28, 0x2E, 0x79, 0xE7 ], + CodeFlag.Face => [ 0xCA, 0x97, 0x81, 0x12, 0xCA, 0x1B, 0xBD, 0xCA, 0xFA, 0xC2, 0x31, 0xB3, 0x9A, 0x23, 0xDC, 0x4D, 0xA7, 0x86, 0xEF, 0xF8, 0x14, 0x7C, 0x4E, 0x72, 0xB9, 0x80, 0x77, 0x85, 0xAF, 0xEE, 0x48, 0xBB ], + CodeFlag.Manderville => [ 0x3E, 0x23, 0xE8, 0x16, 0x00, 0x39, 0x59, 0x4A, 0x33, 0x89, 0x4F, 0x65, 0x64, 0xE1, 0xB1, 0x34, 0x8B, 0xBD, 0x7A, 0x00, 0x88, 0xD4, 0x2C, 0x4A, 0xCB, 0x73, 0xEE, 0xAE, 0xD5, 0x9C, 0x00, 0x9D ], + CodeFlag.Smiles => [ 0x2E, 0x7D, 0x2C, 0x03, 0xA9, 0x50, 0x7A, 0xE2, 0x65, 0xEC, 0xF5, 0xB5, 0x35, 0x68, 0x85, 0xA5, 0x33, 0x93, 0xA2, 0x02, 0x9D, 0x24, 0x13, 0x94, 0x99, 0x72, 0x65, 0xA1, 0xA2, 0x5A, 0xEF, 0xC6 ], _ => [], }; @@ -233,6 +247,9 @@ public class CodeService CodeFlag.Crown => (true, 1, ".", "A famous Shakespearean line.", "Sets every player with a mentor symbol enabled to the clown's hat."), CodeFlag.Dolphins => (true, 5, ",", "The farewell of the second smartest species on Earth.", "Sets every player to a Namazu hat with different costume bodies."), CodeFlag.Artisan => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), + CodeFlag.Face => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), + CodeFlag.Manderville => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), + CodeFlag.Smiles => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), _ => (false, 0, string.Empty, string.Empty, string.Empty), }; } diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index a9ce8e2..f07ff93 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -1,6 +1,7 @@ using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.Designs; +using Glamourer.GameData; using Glamourer.Gui; using Glamourer.Services; using ImGuiNET; @@ -35,6 +36,7 @@ public unsafe class FunModule : IDisposable private readonly DesignConverter _designConverter; private readonly DesignManager _designManager; private readonly ObjectManager _objects; + private readonly NpcCustomizeSet _npcs; private readonly StainId[] _stains; public FestivalType CurrentFestival { get; private set; } = FestivalType.None; @@ -68,7 +70,7 @@ public unsafe class FunModule : IDisposable public FunModule(CodeService codes, CustomizeService customizations, ItemManager items, Configuration config, GenericPopupWindow popupWindow, StateManager stateManager, ObjectManager objects, DesignConverter designConverter, - DesignManager designManager) + DesignManager designManager, NpcCustomizeSet npcs) { _codes = codes; _customizations = customizations; @@ -79,6 +81,7 @@ public unsafe class FunModule : IDisposable _objects = objects; _designConverter = designConverter; _designManager = designManager; + _npcs = npcs; _rng = new Random(); _stains = _items.Stains.Keys.Prepend((StainId)0).ToArray(); ResetFestival(); @@ -102,6 +105,15 @@ public unsafe class FunModule : IDisposable return; } + switch (_codes.Masked(CodeService.FullCodes)) + { + case CodeService.CodeFlag.Face: + case CodeService.CodeFlag.Manderville: + case CodeService.CodeFlag.Smiles: + KeepOldArmor(actor, slot, ref armor); + return; + } + if (_codes.Enabled(CodeService.CodeFlag.Crown) && actor.OnlineStatus is OnlineStatus.PvEMentor or OnlineStatus.PvPMentor or OnlineStatus.TradeMentor && slot.IsEquipment()) @@ -130,11 +142,124 @@ public unsafe class FunModule : IDisposable } } + private sealed class PrioritizedList : List<(T Item, int Priority)> + { + private int _cumulative; + + public PrioritizedList(params (T Item, int Priority)[] list) + { + if (list.Length == 0) + return; + + AddRange(list.Where(p => p.Priority > 0).OrderByDescending(p => p.Priority).Select(p => (p.Item, _cumulative += p.Priority))); + } + + public T GetRandom(Random rng) + { + var val = rng.Next(0, _cumulative); + foreach (var (item, priority) in this) + { + if (val < priority) + return item; + } + + // Should never happen. + return this[^1].Item1; + } + } + + private static readonly PrioritizedList MandervilleMale = new + ( + (1008264, 30), // Hildi + (1008731, 10), // Hildi, slightly damaged + (1011668, 3), // Zombi + (1016617, 5), // Hildi, heavily damaged + (1042518, 1), // Hildi of Light + (1006339, 2), // Godbert, naked + (1008734, 10), // Godbert, shorts + (1015921, 5), // Godbert, ripped + (1041606, 5), // Godbert, only shorts + (1041605, 5), // Godbert, summer + (1024501, 30), // Godbert, fully clothed + (1045184, 3), // Godbrand + (1044749, 1) // Brandihild + ); + + private static readonly PrioritizedList MandervilleFemale = new + ( + (1025669, 5), // Hildi, Geisha + (1025670, 2), // Hildi, makeup, black + (1042477, 2), // Hildi, makeup, white + (1016798, 20), // Julyan, Winter + (1011707, 30), // Julyan + (1005714, 20), // Nashu + (1025668, 5), // Nashu, Kimono + (1025674, 5), // Nashu, fancy + (1042486, 30), // Nashu, inspector + (1017263, 3), // Gigi + (1017263, 1) // Gigi, buff + ); + + private static readonly PrioritizedList Smile = new + ( + (1046504, 75), // Normal + (1046501, 20), // Hat + (1050613, 4), // Armor + (1047625, 1) // Elephant + ); + + private static readonly PrioritizedList FaceMale = new + ( + (1016136, 35), // Gerolt + (1032667, 2), // Gerolt, Suit + (1030519, 35), // Grenoldt + (1030519, 20), // Grenoldt, Short + (1046262, 2), // Grenoldt, Suit + (1048084, 15) // Genolt + ); + + private static readonly PrioritizedList FaceFemale = new + ( + (1013713, 10), // Rowena, Togi + (1018496, 30), // Rowena, Poncho + (1032668, 2), // Rowena, Gown + (1042857, 10), // Rowena, Hannish + (1046255, 10), // Mowen, Miner + (1046263, 2), // Mowen, Gown + (1027544, 30), // Mowen, Bustle + (1049088, 15) // Rhodina + ); + + private bool ApplyFullCode(Actor actor, Span armor, ref CustomizeArray customize) + { + var id = _codes.Masked(CodeService.FullCodes) switch + { + CodeService.CodeFlag.Face when customize.Gender is Gender.Female && actor.Index != 0 => FaceFemale.GetRandom(_rng), + CodeService.CodeFlag.Face when actor.Index != 0 => FaceFemale.GetRandom(_rng), + CodeService.CodeFlag.Smiles => Smile.GetRandom(_rng), + CodeService.CodeFlag.Manderville when customize.Gender is Gender.Female => MandervilleFemale.GetRandom(_rng), + CodeService.CodeFlag.Manderville => MandervilleMale.GetRandom(_rng), + _ => (NpcId)0, + }; + + if (id.Id == 0 || !_npcs.FindFirst(n => n.Id == id, out var npc)) + return false; + + customize = npc.Customize; + var idx = 0; + foreach (ref var a in armor) + a = npc.Equip[idx++]; + return true; + } + public void ApplyFunOnLoad(Actor actor, Span armor, ref CustomizeArray customize) { if (!ValidFunTarget(actor)) return; + if (ApplyFullCode(actor, armor, ref customize)) + return; + // First set the race, if any. SetRace(ref customize); // Now apply the gender. From 34caf29b321d7811439abf51786a67886350a73f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 12:38:04 +0200 Subject: [PATCH 060/401] Add more Corgis to Glamourer. --- Glamourer/Configuration.cs | 2 ++ .../Customization/CustomizationDrawer.Simple.cs | 12 +++++++----- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 16 +++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index d0b3f98..11c45a8 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -21,6 +21,8 @@ public enum HeightDisplayType Metre, Wrong, WrongFoot, + Corgi, + OlympicPool, } public class Configuration : IPluginConfiguration, ISavable diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index 5bb98c9..2e5524f 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -43,11 +43,13 @@ public partial class CustomizationDrawer var heightString = _config.HeightDisplayType switch { - HeightDisplayType.Centimetre => FormattableString.Invariant($"({height * 100:F1} cm)"), - HeightDisplayType.Metre => FormattableString.Invariant($"({height:F2} m)"), - HeightDisplayType.Wrong => FormattableString.Invariant($"({height * 100 / 2.539:F1} in)"), - HeightDisplayType.WrongFoot => $"({(int)(height * 100 / 2.539 / 12)}'{(int)(height * 100 / 2.539) % 12}'')", - _ => FormattableString.Invariant($"({height})"), + HeightDisplayType.Centimetre => FormattableString.Invariant($"({height * 100:F1} cm)"), + HeightDisplayType.Metre => FormattableString.Invariant($"({height:F2} m)"), + HeightDisplayType.Wrong => FormattableString.Invariant($"({height * 100 / 2.539:F1} in)"), + HeightDisplayType.WrongFoot => $"({(int)(height * 100 / 2.539 / 12)}'{(int)(height * 100 / 2.539) % 12}'')", + HeightDisplayType.Corgi => FormattableString.Invariant($"({height * 100 / 40.0:F1} Corgis)"), + HeightDisplayType.OlympicPool => FormattableString.Invariant($"({height / 3.0:F3} Pools)"), + _ => FormattableString.Invariant($"({height})"), }; ImGui.TextUnformatted(heightString); } diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index f38d81d..1540696 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -401,14 +401,16 @@ public class SettingsTab( ImGuiUtil.HoverTooltip(tt); } - private string HeightDisplayTypeName(HeightDisplayType type) + private static string HeightDisplayTypeName(HeightDisplayType type) => type switch { - HeightDisplayType.None => "Do Not Display", - HeightDisplayType.Centimetre => "Centimetres (000.0 cm)", - HeightDisplayType.Metre => "Metres (0.00 m)", - HeightDisplayType.Wrong => "Inches (00.0 in)", - HeightDisplayType.WrongFoot => "Feet (0'00'')", - _ => string.Empty, + HeightDisplayType.None => "Do Not Display", + HeightDisplayType.Centimetre => "Centimetres (000.0 cm)", + HeightDisplayType.Metre => "Metres (0.00 m)", + HeightDisplayType.Wrong => "Inches (00.0 in)", + HeightDisplayType.WrongFoot => "Feet (0'00'')", + HeightDisplayType.Corgi => "Corgis (0.0 Corgis)", + HeightDisplayType.OlympicPool => "Olympic-size swimming Pools (0.000 Pools)", + _ => string.Empty, }; } From f69915dcb3079ca49bd2a9f57c30a634f96d7a9a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 12:38:38 +0200 Subject: [PATCH 061/401] Remove some warnings. --- Glamourer/Gui/DesignQuickBar.cs | 5 ++++- Glamourer/Interop/ObjectManager.cs | 2 +- Glamourer/Unlocks/CustomizeUnlockManager.cs | 16 +++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index c3829fa..31ca45e 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -70,6 +70,9 @@ public sealed class DesignQuickBar : Window, IDisposable IsOpen = _config.Ephemeral.ShowDesignQuickBar && _config.QdbButtons != 0; } + public override bool DrawConditions() + => _objects.Player.Valid; + public override void PreDraw() { Flags = GetFlags; @@ -112,7 +115,7 @@ public sealed class DesignQuickBar : Window, IDisposable ImGui.SameLine(); DrawApplyButton(buttonSize); } - + DrawRevertButton(buttonSize); DrawRevertEquipButton(buttonSize); DrawRevertCustomizeButton(buttonSize); diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs index f8f5813..b185f4a 100644 --- a/Glamourer/Interop/ObjectManager.cs +++ b/Glamourer/Interop/ObjectManager.cs @@ -40,7 +40,7 @@ public class ObjectManager( return false; _identifierUpdate = LastUpdate; - World = (ushort)(this[0].Valid ? this[0].HomeWorld : 0); + World = (ushort)(Player.Valid ? Player.HomeWorld : 0); _identifiers.Clear(); _allWorldIdentifiers.Clear(); _nonOwnedIdentifiers.Clear(); diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index a204a1c..801f211 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -6,6 +6,7 @@ using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.UI; using Glamourer.GameData; using Glamourer.Events; +using Glamourer.Interop; using Glamourer.Services; using Lumina.Excel.GeneratedSheets; using Penumbra.GameData; @@ -15,10 +16,10 @@ namespace Glamourer.Unlocks; public class CustomizeUnlockManager : IDisposable, ISavable { - private readonly SaveService _saveService; - private readonly IClientState _clientState; - private readonly ObjectUnlocked _event; - + private readonly SaveService _saveService; + private readonly IClientState _clientState; + private readonly ObjectUnlocked _event; + private readonly ObjectManager _objects; private readonly Dictionary _unlocked = new(); public readonly IReadOnlyDictionary Unlockable; @@ -27,12 +28,13 @@ public class CustomizeUnlockManager : IDisposable, ISavable => _unlocked; public CustomizeUnlockManager(SaveService saveService, CustomizeService customizations, IDataManager gameData, - IClientState clientState, ObjectUnlocked @event, IGameInteropProvider interop) + IClientState clientState, ObjectUnlocked @event, IGameInteropProvider interop, ObjectManager objects) { interop.InitializeFromAttributes(this); _saveService = saveService; _clientState = clientState; _event = @event; + _objects = objects; Unlockable = CreateUnlockableCustomizations(customizations, gameData); Load(); _setUnlockLinkValueHook.Enable(); @@ -94,7 +96,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable /// Scan and update all unlockable customizations for their current game state. public unsafe void Scan() { - if (_clientState.LocalPlayer == null) + if (!_objects.Player.Valid) return; Glamourer.Log.Debug("[UnlockManager] Scanning for new unlocked customizations."); @@ -128,7 +130,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable } private delegate void SetUnlockLinkValueDelegate(nint uiState, uint data, byte value); - + [Signature(Sigs.SetUnlockLinkValue, DetourName = nameof(SetUnlockLinkValueDetour))] private readonly Hook _setUnlockLinkValueHook = null!; From 9f04ee7695e168b691cbdd7e33ecbb60f0e02948 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 12:39:01 +0200 Subject: [PATCH 062/401] Fix visor state toggle. --- Glamourer/Interop/MetaService.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Glamourer/Interop/MetaService.cs b/Glamourer/Interop/MetaService.cs index 062986b..1dc4c1a 100644 --- a/Glamourer/Interop/MetaService.cs +++ b/Glamourer/Interop/MetaService.cs @@ -13,7 +13,7 @@ public unsafe class MetaService : IDisposable private readonly VisorStateChanged _visorEvent; private delegate void HideHatGearDelegate(DrawDataContainer* drawData, uint id, byte value); - private delegate void HideWeaponsDelegate(DrawDataContainer* drawData, bool value); + private delegate void HideWeaponsDelegate(DrawDataContainer* drawData, byte value); private readonly Hook _hideHatGearHook; private readonly Hook _hideWeaponsHook; @@ -61,7 +61,7 @@ public unsafe class MetaService : IDisposable if (!actor.IsCharacter) return; - _hideWeaponsHook.Original(&actor.AsCharacter->DrawData, !value); + _hideWeaponsHook.Original(&actor.AsCharacter->DrawData, (byte)(value ? 0 : 1)); } private void HideHatDetour(DrawDataContainer* drawData, uint id, byte value) @@ -80,21 +80,21 @@ public unsafe class MetaService : IDisposable _hideHatGearHook.Original(drawData, id, value); } - private void HideWeaponsDetour(DrawDataContainer* drawData, bool value) + private void HideWeaponsDetour(DrawDataContainer* drawData, byte value) { Actor actor = drawData->OwnerObject; - value = !value; - _weaponEvent.Invoke(actor, ref value); - value = !value; + var v = value == 0; + _weaponEvent.Invoke(actor, ref v); Glamourer.Log.Verbose($"[MetaService] Hide Weapon triggered with 0x{(nint)drawData:X} {value} for {actor.Utf8Name}."); - _hideWeaponsHook.Original(drawData, value); + _hideWeaponsHook.Original(drawData, (byte)(v ? 0 : 1)); } - private void ToggleVisorDetour(DrawDataContainer* drawData, bool value) + private void ToggleVisorDetour(DrawDataContainer* drawData, byte value) { Actor actor = drawData->OwnerObject; - _visorEvent.Invoke(actor.Model, true, ref value); + var v = value != 0; + _visorEvent.Invoke(actor.Model, true, ref v); Glamourer.Log.Verbose($"[MetaService] Toggle Visor triggered with 0x{(nint)drawData:X} {value} for {actor.Utf8Name}."); - _toggleVisorHook.Original(drawData, value); + _toggleVisorHook.Original(drawData, (byte)(v ? 1 : 0)); } } From e2ffcea0b2e2764309e6601fb5481c55ac2c10f3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 12:40:00 +0200 Subject: [PATCH 063/401] Fix some warnings. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index cd40d49..a62d62a 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit cd40d497f4791e946c0fd4bd5663da578f7680ed +Subproject commit a62d62a8532de528f43515233ea44892cdb974b5 From 68bffba3cd95c70136f1b882f5c1b569c40cd0fc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 14:14:10 +0200 Subject: [PATCH 064/401] Update for submodules. --- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 8 ++++---- Penumbra.Api | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index 6e4774b..c74d6a3 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -1,5 +1,4 @@ -using Dalamud; -using Glamourer.Designs; +using Glamourer.Designs; using Glamourer.Events; using Glamourer.Interop; using Glamourer.Interop.Penumbra; @@ -8,6 +7,7 @@ using Glamourer.State; using ImGuiNET; using OtterGui.Raii; using Penumbra.Api.Enums; +using Penumbra.GameData.Data; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -174,7 +174,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable CreateTooltip(item, "[Glamourer] ", false); return; case ChangedItemType.Customization: - var (race, gender, index, value) = ChangedItemExtensions.Split(id); + var (race, gender, index, value) = IdentifiedCustomization.Split(id); if (!_objects.Player.Model.IsHuman) return; @@ -218,7 +218,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable ApplyItem(state, item); return; case ChangedItemType.Customization: - var (race, gender, index, value) = ChangedItemExtensions.Split(id); + var (race, gender, index, value) = IdentifiedCustomization.Split(id); var customize = state.ModelData.Customize; if (CheckGenderRace(customize, race, gender) && VerifyValue(customize, index, value)) _stateManager.ChangeCustomize(state, index, value, ApplySettings.Manual); diff --git a/Penumbra.Api b/Penumbra.Api index f4c6144..759a8e9 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit f4c6144ca2012b279e6d8aa52b2bef6cc2ba32d9 +Subproject commit 759a8e9dc50b3453cdb7c3cba76de7174c94aba0 From 6115d24775882e5dc1b970002b475f1b7d309d6c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 14:36:00 +0200 Subject: [PATCH 065/401] Some changes for codes. --- Glamourer/State/FunModule.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index f07ff93..5d436c0 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -105,14 +105,15 @@ public unsafe class FunModule : IDisposable return; } - switch (_codes.Masked(CodeService.FullCodes)) - { - case CodeService.CodeFlag.Face: - case CodeService.CodeFlag.Manderville: - case CodeService.CodeFlag.Smiles: - KeepOldArmor(actor, slot, ref armor); - return; - } + if (actor.Index < ObjectIndex.CutsceneStart) + switch (_codes.Masked(CodeService.FullCodes)) + { + case CodeService.CodeFlag.Face when actor.Index != 0: + case CodeService.CodeFlag.Smiles: + case CodeService.CodeFlag.Manderville: + KeepOldArmor(actor, slot, ref armor); + return; + } if (_codes.Enabled(CodeService.CodeFlag.Crown) && actor.OnlineStatus is OnlineStatus.PvEMentor or OnlineStatus.PvPMentor or OnlineStatus.TradeMentor @@ -170,6 +171,7 @@ public unsafe class FunModule : IDisposable private static readonly PrioritizedList MandervilleMale = new ( + //(0000000, 400), // Nothing (1008264, 30), // Hildi (1008731, 10), // Hildi, slightly damaged (1011668, 3), // Zombi @@ -187,6 +189,7 @@ public unsafe class FunModule : IDisposable private static readonly PrioritizedList MandervilleFemale = new ( + //(0000000, 400), // Nothing (1025669, 5), // Hildi, Geisha (1025670, 2), // Hildi, makeup, black (1042477, 2), // Hildi, makeup, white @@ -210,6 +213,7 @@ public unsafe class FunModule : IDisposable private static readonly PrioritizedList FaceMale = new ( + //(0000000, 700), // Nothing (1016136, 35), // Gerolt (1032667, 2), // Gerolt, Suit (1030519, 35), // Grenoldt @@ -220,6 +224,7 @@ public unsafe class FunModule : IDisposable private static readonly PrioritizedList FaceFemale = new ( + //(0000000, 400), // Nothing (1013713, 10), // Rowena, Togi (1018496, 30), // Rowena, Poncho (1032668, 2), // Rowena, Gown @@ -232,13 +237,16 @@ public unsafe class FunModule : IDisposable private bool ApplyFullCode(Actor actor, Span armor, ref CustomizeArray customize) { + if (actor.Index >= ObjectIndex.CutsceneStart) + return false; + var id = _codes.Masked(CodeService.FullCodes) switch { CodeService.CodeFlag.Face when customize.Gender is Gender.Female && actor.Index != 0 => FaceFemale.GetRandom(_rng), - CodeService.CodeFlag.Face when actor.Index != 0 => FaceFemale.GetRandom(_rng), + CodeService.CodeFlag.Face when actor.Index != 0 => FaceMale.GetRandom(_rng), CodeService.CodeFlag.Smiles => Smile.GetRandom(_rng), CodeService.CodeFlag.Manderville when customize.Gender is Gender.Female => MandervilleFemale.GetRandom(_rng), - CodeService.CodeFlag.Manderville => MandervilleMale.GetRandom(_rng), + CodeService.CodeFlag.Manderville => MandervilleMale.GetRandom(_rng), _ => (NpcId)0, }; From 1cc7c2f0cd6a4bc738044a63227c9c6e7ff19848 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 5 Aug 2024 14:48:43 +0200 Subject: [PATCH 066/401] Add editable mod state and priority. --- Glamourer/Api/ApiHelpers.cs | 11 ++-- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 57 ++++++++++--------- OtterGui | 2 +- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index 25af774..ed58500 100644 --- a/Glamourer/Api/ApiHelpers.cs +++ b/Glamourer/Api/ApiHelpers.cs @@ -54,10 +54,10 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM internal static DesignBase.FlagRestrictionResetter Restrict(DesignBase design, ApplyFlag flags) => (flags & (ApplyFlag.Equipment | ApplyFlag.Customization)) switch { - ApplyFlag.Equipment => design.TemporarilyRestrictApplication(ApplicationCollection.Equipment), - ApplyFlag.Customization => design.TemporarilyRestrictApplication(ApplicationCollection.Customizations), + ApplyFlag.Equipment => design.TemporarilyRestrictApplication(ApplicationCollection.Equipment), + ApplyFlag.Customization => design.TemporarilyRestrictApplication(ApplicationCollection.Customizations), ApplyFlag.Equipment | ApplyFlag.Customization => design.TemporarilyRestrictApplication(ApplicationCollection.All), - _ => design.TemporarilyRestrictApplication(ApplicationCollection.None), + _ => design.TemporarilyRestrictApplication(ApplicationCollection.None), }; [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] @@ -112,7 +112,10 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM { sb.Append(arguments[2 * i]); sb.Append(" = "); - sb.Append(arguments[2 * i + 1]); + if (arguments[2 * i + 1] is IEnumerable e) + sb.Append($"[{string.Join(',', e)}]"); + else + sb.Append(arguments[2 * i + 1]); sb.Append(", "); } diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 9db8c19..3ebf78a 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -8,6 +8,9 @@ using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; +using OtterGui.Text.Widget; +using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.DesignTab; @@ -92,10 +95,10 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect ImGui.TableSetupColumn("##Buttons", ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight() * 3 + ImGui.GetStyle().ItemInnerSpacing.X * 2); - ImGui.TableSetupColumn("Mod Name", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("State").X); - ImGui.TableSetupColumn("Priority", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Priority").X); - ImGui.TableSetupColumn("##Options", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Applym").X); + ImGui.TableSetupColumn("Mod Name", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("State").X); + ImGui.TableSetupColumn("Priority", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Priority").X); + ImGui.TableSetupColumn("##Options", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Applym").X); ImGui.TableHeadersRow(); Mod? removedMod = null; @@ -124,20 +127,15 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect removedMod = null; updatedMod = null; ImGui.TableNextColumn(); - var buttonSize = new Vector2(ImGui.GetFrameHeight()); - var spacing = ImGui.GetStyle().ItemInnerSpacing.X; - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), buttonSize, - "Delete this mod from associations.", false, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Trash, "Delete this mod from associations."u8)) removedMod = mod; - ImGui.SameLine(0, spacing); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), buttonSize, - "Copy this mod setting to clipboard.", false, true)) + ImUtf8.SameLineInner(); + if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Copy this mod setting to clipboard."u8)) _copy = [(mod, settings)]; - ImGui.SameLine(0, spacing); - ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.RedoAlt.ToIconString(), buttonSize, - "Update the settings of this mod association.", false, true); + ImUtf8.SameLineInner(); + ImUtf8.IconButton(FontAwesomeIcon.RedoAlt, "Update the settings of this mod association."u8); if (ImGui.IsItemHovered()) { var newSettings = penumbra.GetModSettings(mod); @@ -145,16 +143,16 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect updatedMod = (mod, newSettings); using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale); - using var tt = ImRaii.Tooltip(); + using var tt = ImUtf8.Tooltip(); ImGui.Separator(); var namesDifferent = mod.Name != mod.DirectoryName; ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0)); using (ImRaii.Group()) { if (namesDifferent) - ImGui.TextUnformatted("Directory Name"); - ImGui.TextUnformatted("Enabled"); - ImGui.TextUnformatted("Priority"); + ImUtf8.Text("Directory Name"u8); + ImUtf8.Text("Enabled"u8); + ImUtf8.Text("Priority"u8); ModCombo.DrawSettingsLeft(newSettings); } @@ -162,27 +160,30 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect using (ImRaii.Group()) { if (namesDifferent) - ImGui.TextUnformatted(mod.DirectoryName); - ImGui.TextUnformatted(newSettings.Enabled.ToString()); - ImGui.TextUnformatted(newSettings.Priority.ToString()); + ImUtf8.Text(mod.DirectoryName); + + ImUtf8.Text(newSettings.Enabled.ToString()); + ImUtf8.Text(newSettings.Priority.ToString()); ModCombo.DrawSettingsRight(newSettings); } } ImGui.TableNextColumn(); - - if (ImGui.Selectable($"{mod.Name}##name")) + + if (ImUtf8.Selectable($"{mod.Name}##name")) penumbra.OpenModPage(mod); if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Mod Directory: {mod.DirectoryName}\n\nClick to open mod page in Penumbra."); ImGui.TableNextColumn(); - using (var font = ImRaii.PushFont(UiBuilder.IconFont)) - { - ImGuiUtil.Center((settings.Enabled ? FontAwesomeIcon.Check : FontAwesomeIcon.Times).ToIconString()); - } + var enabled = settings.Enabled; + if (TwoStateCheckbox.Instance.Draw("##Enabled"u8, ref enabled)) + updatedMod = (mod, settings with { Enabled = enabled }); ImGui.TableNextColumn(); - ImGuiUtil.RightAlign(settings.Priority.ToString()); + var priority = settings.Priority; + ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + if (ImUtf8.InputScalarOnDeactivated("##Priority"u8, ref priority)) + updatedMod = (mod, settings with { Priority = priority }); ImGui.TableNextColumn(); if (ImGuiUtil.DrawDisabledButton("Apply", new Vector2(ImGui.GetContentRegionAvail().X, 0), string.Empty, !penumbra.Available)) diff --git a/OtterGui b/OtterGui index 3a14692..51bab6d 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 3a14692e38708ca9f18652898e6f5c8cc87b517b +Subproject commit 51bab6dd1bd7d98cc468e8122f410e1c79e3c92d From 5bca4b91184b7400a2098e1802a2ea8db577aac6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 6 Aug 2024 17:38:53 +0200 Subject: [PATCH 067/401] Do not apply Nothing-shield for swords periphery. --- Glamourer/Designs/DesignEditor.cs | 2 +- Glamourer/State/StateEditor.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index df0e9ed..5328f03 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -360,7 +360,7 @@ public class DesignEditor( newOff = o; } - else if (!_forceFullItemOff && Config.ChangeEntireItem) + else if (!_forceFullItemOff && Config.ChangeEntireItem && newMain.Type is not FullEquipType.Sword) // Skip applying shields. { var defaultOffhand = Items.GetDefaultOffhand(newMain); if (Items.IsOffhandValid(newMain, defaultOffhand.ItemId, out var o)) diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 95c118d..50479b2 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -456,6 +456,10 @@ public class StateEditor( return; var mh = newMainhand ?? state.ModelData.Item(EquipSlot.MainHand); + // Do not change Shields to nothing. + if (mh.Type is FullEquipType.Sword) + return; + var offhand = newMainhand != null ? Items.GetDefaultOffhand(mh) : state.ModelData.Item(EquipSlot.OffHand); var stains = newStains ?? state.ModelData.Stain(EquipSlot.MainHand); if (offhand.Valid) From 2e52030c31bd710d11dc3208f8a49f9ed849209b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 6 Aug 2024 17:39:34 +0200 Subject: [PATCH 068/401] Fix issue with adding mods from clipboard --- Glamourer/Designs/DesignManager.cs | 17 +++++++++++++---- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 16 ++++++++++++---- Penumbra.GameData | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 7eaad9d..a31ba83 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -248,7 +248,8 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); Glamourer.Log.Debug($"Renamed tag {oldTag} at {tagIdx} to {newTag} in design {design.Identifier} and reordered tags."); - DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design, new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag))); + DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design, + new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag))); } /// Add an associated mod to a design. @@ -278,12 +279,20 @@ public sealed class DesignManager : DesignEditor /// Add or update an associated mod to a design. public void UpdateMod(Design design, Mod mod, ModSettings settings) { - var oldSettings = design.AssociatedMods[mod]; + var hasOldSettings = design.AssociatedMods.TryGetValue(mod, out var oldSettings); design.AssociatedMods[mod] = settings; design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); - Glamourer.Log.Debug($"Updated (or added) associated mod {mod.DirectoryName} from design {design.Identifier}."); - DesignChanged.Invoke(DesignChanged.Type.UpdatedMod, design, new ModUpdatedTransaction(mod, oldSettings, settings)); + if (hasOldSettings) + { + Glamourer.Log.Debug($"Updated associated mod {mod.DirectoryName} from design {design.Identifier}."); + DesignChanged.Invoke(DesignChanged.Type.UpdatedMod, design, new ModUpdatedTransaction(mod, oldSettings, settings)); + } + else + { + Glamourer.Log.Debug($"Added associated mod {mod.DirectoryName} from design {design.Identifier}."); + DesignChanged.Invoke(DesignChanged.Type.AddedMod, design, new ModAddedTransaction(mod, settings)); + } } /// Set the write protection status of a design. diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 3ebf78a..1f1e1ad 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -10,11 +10,10 @@ using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Text.Widget; -using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.DesignTab; -public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelector selector, DesignManager manager) +public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelector selector, DesignManager manager, Configuration config) { private readonly ModCombo _modCombo = new(penumbra, Glamourer.Log); private (Mod, ModSettings)[]? _copy; @@ -127,8 +126,17 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect removedMod = null; updatedMod = null; ImGui.TableNextColumn(); - if (ImUtf8.IconButton(FontAwesomeIcon.Trash, "Delete this mod from associations."u8)) - removedMod = mod; + var canDelete = config.DeleteDesignModifier.IsActive(); + if (canDelete) + { + if (ImUtf8.IconButton(FontAwesomeIcon.Trash, "Delete this mod from associations."u8)) + removedMod = mod; + } + else + { + ImUtf8.IconButton(FontAwesomeIcon.Trash, $"Delete this mod from associations.\nHold {config.DeleteDesignModifier} to delete.", + disabled: true); + } ImUtf8.SameLineInner(); if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Copy this mod setting to clipboard."u8)) diff --git a/Penumbra.GameData b/Penumbra.GameData index a62d62a..ad6973c 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit a62d62a8532de528f43515233ea44892cdb974b5 +Subproject commit ad6973c559b4c05aa3c3735ec7b53cc0f5d2f203 From 61cb46a298ca25ab9ecfd4c4110d86cde94c1f53 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 6 Aug 2024 18:25:00 +0200 Subject: [PATCH 069/401] Update for GameData update. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 13 ++++--- Glamourer/Gui/Materials/ColorRowClipboard.cs | 4 +-- Glamourer/Interop/Material/DirectXService.cs | 19 +++++----- .../Material/LiveColorTablePreviewer.cs | 14 ++++---- Glamourer/Interop/Material/MaterialManager.cs | 2 +- Glamourer/Interop/Material/MaterialService.cs | 8 ++--- .../Interop/Material/MaterialValueManager.cs | 35 ++++++++++--------- Glamourer/Interop/Material/PrepareColorSet.cs | 9 +++-- Penumbra.GameData | 2 +- 9 files changed, 57 insertions(+), 49 deletions(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index a9ab805..3ba2a1b 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -102,10 +102,12 @@ public sealed unsafe class AdvancedDyePopup( if (!bar) return; + var table = new ColorTable.Table(); for (byte i = 0; i < MaterialService.MaterialsPerModel; ++i) { var index = _drawIndex!.Value with { MaterialIndex = i }; - var available = index.TryGetTexture(textures, out var texture) && directX.TryGetColorTable(*texture, out var table); + var available = index.TryGetTexture(textures, out var texture) && directX.TryGetColorTable(*texture, out table); + if (index == preview.LastValueIndex with { RowIndex = 0 }) table = preview.LastOriginalColorTable; @@ -225,7 +227,7 @@ public sealed unsafe class AdvancedDyePopup( DrawWindow(textures); } - private void DrawTable(MaterialValueIndex materialIndex, in ColorTable table) + private void DrawTable(MaterialValueIndex materialIndex, ColorTable.Table table) { if (!materialIndex.Valid) return; @@ -244,7 +246,7 @@ public sealed unsafe class AdvancedDyePopup( DrawAllRow(materialIndex, table); } - private void DrawAllRow(MaterialValueIndex materialIndex, in ColorTable table) + private void DrawAllRow(MaterialValueIndex materialIndex, in ColorTable.Table table) { using var id = ImRaii.PushId(100); var buttonSize = new Vector2(ImGui.GetFrameHeight()); @@ -267,8 +269,9 @@ public sealed unsafe class AdvancedDyePopup( ImGui.SameLine(0, spacing); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), buttonSize, "Import an exported table from your clipboard onto this table.", !ColorRowClipboard.IsTableSet, true)) - foreach (var (row, idx) in ColorRowClipboard.Table.WithIndex()) + for (var idx = 0; idx < ColorTable.NumRows; ++idx) { + var row = ColorRowClipboard.Table[idx]; var internalRow = new ColorRow(row); var slot = materialIndex.ToEquipSlot(); var weapon = slot is EquipSlot.MainHand or EquipSlot.OffHand @@ -285,7 +288,7 @@ public sealed unsafe class AdvancedDyePopup( stateManager.ResetMaterialValue(_state, materialIndex with { RowIndex = i }, ApplySettings.Game); } - private void DrawRow(ref ColorTable.Row row, MaterialValueIndex index, in ColorTable table) + private void DrawRow(ref ColorTableRow row, MaterialValueIndex index, in ColorTable.Table table) { using var id = ImRaii.PushId(index.RowIndex); var changed = _state.Materials.TryGetValue(index, out var value); diff --git a/Glamourer/Gui/Materials/ColorRowClipboard.cs b/Glamourer/Gui/Materials/ColorRowClipboard.cs index 4213cc5..f7fac1d 100644 --- a/Glamourer/Gui/Materials/ColorRowClipboard.cs +++ b/Glamourer/Gui/Materials/ColorRowClipboard.cs @@ -6,13 +6,13 @@ namespace Glamourer.Gui.Materials; public static class ColorRowClipboard { private static ColorRow _row; - private static ColorTable _table; + private static ColorTable.Table _table; public static bool IsSet { get; private set; } public static bool IsTableSet { get; private set; } - public static ColorTable Table + public static ColorTable.Table Table { get => _table; set diff --git a/Glamourer/Interop/Material/DirectXService.cs b/Glamourer/Interop/Material/DirectXService.cs index 3316491..a809a34 100644 --- a/Glamourer/Interop/Material/DirectXService.cs +++ b/Glamourer/Interop/Material/DirectXService.cs @@ -15,13 +15,13 @@ namespace Glamourer.Interop.Material; public unsafe class DirectXService(IFramework framework) : IService { private readonly object _lock = new(); - private readonly ConcurrentDictionary _textures = []; + private readonly ConcurrentDictionary _textures = []; /// Generate a color table the way the game does inside the original texture, and release the original. /// The original texture that will be replaced with a new one. /// The input color table. /// Success or failure. - public bool ReplaceColorTable(Texture** original, in ColorTable colorTable) + public bool ReplaceColorTable(Texture** original, in ColorTable.Table colorTable) { if (original == null) return false; @@ -38,7 +38,7 @@ public unsafe class DirectXService(IFramework framework) : IService if (texture.IsInvalid) return false; - fixed (ColorTable* ptr = &colorTable) + fixed (ColorTable.Table* ptr = &colorTable) { if (!texture.Texture->InitializeContents(ptr)) return false; @@ -51,7 +51,7 @@ public unsafe class DirectXService(IFramework framework) : IService return true; } - public bool TryGetColorTable(Texture* texture, out ColorTable table) + public bool TryGetColorTable(Texture* texture, out ColorTable.Table table) { if (_textures.TryGetValue((nint)texture, out var p) && framework.LastUpdateUTC == p.Update) { @@ -73,7 +73,7 @@ public unsafe class DirectXService(IFramework framework) : IService /// A pointer to the internal texture struct containing the GPU handle. /// The returned color table. /// Whether the table could be fetched. - private static bool TextureColorTable(Texture* texture, out ColorTable table) + private static bool TextureColorTable(Texture* texture, out ColorTable.Table table) { if (texture == null) { @@ -92,6 +92,7 @@ public unsafe class DirectXService(IFramework framework) : IService } catch { + table = default; return false; } } @@ -114,7 +115,7 @@ public unsafe class DirectXService(IFramework framework) : IService } /// Turn a mapped texture into a color table. - private static ColorTable GetTextureData(ID3D11Texture2D1 resource, MappedSubresource map) + private static ColorTable.Table GetTextureData(ID3D11Texture2D1 resource, MappedSubresource map) { var desc = resource.Description1; @@ -133,14 +134,14 @@ public unsafe class DirectXService(IFramework framework) : IService /// The height of the texture. (Needs to be 16). /// The stride in the texture data. /// - private static ColorTable ReadTexture(nint data, int length, int height, int pitch) + private static ColorTable.Table ReadTexture(nint data, int length, int height, int pitch) { // Check that the data has sufficient dimension and size. var expectedSize = sizeof(Half) * MaterialService.TextureWidth * height * 4; - if (length < expectedSize || sizeof(ColorTable) != expectedSize || height != MaterialService.TextureHeight) + if (length < expectedSize || sizeof(ColorTable.Table) != expectedSize || height != MaterialService.TextureHeight) return default; - var ret = new ColorTable(); + var ret = new ColorTable.Table(); var target = (byte*)&ret; // If the stride is the same as in the table, just copy. if (pitch == MaterialService.TextureWidth) diff --git a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs index 1df85f6..94cb9ca 100644 --- a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs +++ b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs @@ -13,11 +13,11 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable private readonly DirectXService _directXService; public MaterialValueIndex LastValueIndex { get; private set; } = MaterialValueIndex.Invalid; - public ColorTable LastOriginalColorTable { get; private set; } + public ColorTable.Table LastOriginalColorTable { get; private set; } private MaterialValueIndex _valueIndex = MaterialValueIndex.Invalid; private ObjectIndex _lastObjectIndex = ObjectIndex.AnyIndex; private ObjectIndex _objectIndex = ObjectIndex.AnyIndex; - private ColorTable _originalColorTable; + private ColorTable.Table _originalColorTable; public LiveColorTablePreviewer(global::Penumbra.GameData.Interop.ObjectManager objects, IFramework framework, DirectXService directXService) { @@ -73,15 +73,15 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable var table = LastOriginalColorTable; if (_valueIndex.RowIndex != byte.MaxValue) { - table[_valueIndex.RowIndex].Diffuse = diffuse; - table[_valueIndex.RowIndex].Emissive = emissive; + table[_valueIndex.RowIndex].DiffuseColor = (HalfColor)diffuse; + table[_valueIndex.RowIndex].EmissiveColor = (HalfColor)emissive; } else { for (var i = 0; i < ColorTable.NumRows; ++i) { - table[i].Diffuse = diffuse; - table[i].Emissive = emissive; + table[i].DiffuseColor = (HalfColor)diffuse; + table[i].EmissiveColor = (HalfColor)emissive; } } @@ -92,7 +92,7 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable _objectIndex = ObjectIndex.AnyIndex; } - public void OnHover(MaterialValueIndex index, ObjectIndex objectIndex, ColorTable table) + public void OnHover(MaterialValueIndex index, ObjectIndex objectIndex, in ColorTable.Table table) { if (_valueIndex.DrawObject is not MaterialValueIndex.DrawObjectType.Invalid) return; diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index e695a90..3e0e35b 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -75,7 +75,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// Update and apply the glamourer state of an actor according to the application sources when updated by the game. private void UpdateMaterialValues(ActorState state, ReadOnlySpan<(uint Key, MaterialValueState Value)> values, CharacterWeapon drawData, - ref ColorTable colorTable) + ref ColorTable.Table colorTable) { var deleteList = _deleteList.Value!; deleteList.Clear(); diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index 5adaf4d..f7ffe0f 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -13,7 +13,7 @@ public static unsafe class MaterialService public const int TextureHeight = ColorTable.NumRows; public const int MaterialsPerModel = 10; - public static bool GenerateNewColorTable(in ColorTable colorTable, out Texture* texture) + public static bool GenerateNewColorTable(in ColorTable.Table colorTable, out Texture* texture) { var textureSize = stackalloc int[2]; textureSize[0] = TextureWidth; @@ -24,7 +24,7 @@ public static unsafe class MaterialService if (texture == null) return false; - fixed (ColorTable* ptr = &colorTable) + fixed (ColorTable.Table* ptr = &colorTable) { return texture->InitializeContents(ptr); } @@ -53,7 +53,7 @@ public static unsafe class MaterialService /// The model slot. /// The material slot in the model. /// A pointer to the color table or null. - public static ColorTable* GetMaterialColorTable(Model model, int modelSlot, byte materialSlot) + public static ColorTable.Table* GetMaterialColorTable(Model model, int modelSlot, byte materialSlot) { if (!model.IsCharacterBase) return null; @@ -66,6 +66,6 @@ public static unsafe class MaterialService if (material == null || material->ColorTable == null) return null; - return (ColorTable*)material->ColorTable; + return (ColorTable.Table*)material->ColorTable; } } diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index d5ac877..79338a0 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -21,8 +21,9 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa public float SpecularStrength = specularStrength; public float GlossStrength = glossStrength; - public ColorRow(in ColorTable.Row row) - : this(Root(row.Diffuse), Root(row.Specular), Root(row.Emissive), row.SpecularStrength, row.GlossStrength) + public ColorRow(in ColorTableRow row) + : this(Root((Vector3)row.DiffuseColor), Root((Vector3)row.SpecularColor), Root((Vector3)row.EmissiveColor), (float)row.SheenRate, + (float)row.Metalness) { } public readonly bool NearEqual(in ColorRow rhs) @@ -44,39 +45,39 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa private static float Root(float value) => value < 0 ? MathF.Sqrt(-value) : MathF.Sqrt(value); - public readonly bool Apply(ref ColorTable.Row row) + public readonly bool Apply(ref ColorTableRow row) { var ret = false; var d = Square(Diffuse); - if (!row.Diffuse.NearEqual(d)) + if (!((Vector3)row.DiffuseColor).NearEqual(d)) { - row.Diffuse = d; - ret = true; + row.DiffuseColor = (HalfColor)d; + ret = true; } var s = Square(Specular); - if (!row.Specular.NearEqual(s)) + if (!((Vector3)row.SpecularColor).NearEqual(s)) { - row.Specular = s; - ret = true; + row.SpecularColor = (HalfColor)s; + ret = true; } var e = Square(Emissive); - if (!row.Emissive.NearEqual(e)) + if (!((Vector3)row.EmissiveColor).NearEqual(e)) { - row.Emissive = e; - ret = true; + row.EmissiveColor = (HalfColor)e; + ret = true; } - if (!row.SpecularStrength.NearEqual(SpecularStrength)) + if (!((float)row.SheenRate).NearEqual(SpecularStrength)) { - row.SpecularStrength = SpecularStrength; - ret = true; + row.SheenRate = (Half)SpecularStrength; + ret = true; } - if (!row.GlossStrength.NearEqual(GlossStrength)) + if (!((float)row.Metalness).NearEqual(GlossStrength)) { - row.GlossStrength = GlossStrength; + row.Metalness = (Half)GlossStrength; ret = true; } diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index b8e31c2..6d65a6b 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -66,7 +66,7 @@ public sealed unsafe class PrepareColorSet } public static bool TryGetColorTable(MaterialResourceHandle* material, StainIds stainIds, - out ColorTable table) + out ColorTable.Table table) { if (material->ColorTable == null) { @@ -74,7 +74,7 @@ public sealed unsafe class PrepareColorSet return false; } - var newTable = *(ColorTable*)material->ColorTable; + var newTable = *(ColorTable.Table*)material->ColorTable; if (GetDyeTable(material, out var dyeTable)) { if (stainIds.Stain1.Id != 0) @@ -91,11 +91,14 @@ public sealed unsafe class PrepareColorSet } /// Assumes the actor is valid. - public static bool TryGetColorTable(Actor actor, MaterialValueIndex index, out ColorTable table) + public static bool TryGetColorTable(Actor actor, MaterialValueIndex index, out ColorTable.Table table) { var idx = index.SlotIndex * MaterialService.MaterialsPerModel + index.MaterialIndex; if (!index.TryGetModel(actor, out var model)) + { + table = default; return false; + } var handle = (MaterialResourceHandle*)model.AsCharacterBase->Materials[idx]; if (handle == null) diff --git a/Penumbra.GameData b/Penumbra.GameData index ad6973c..016da3c 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit ad6973c559b4c05aa3c3735ec7b53cc0f5d2f203 +Subproject commit 016da3c2219a3dbe4c2841ae0d1305ae0b2ad60f From a1b455d9a599bacd48c161a160f6662d7bc615f7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 7 Aug 2024 17:55:23 +0200 Subject: [PATCH 070/401] Update advanced dyes. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 50 ++++++++++----- Glamourer/Interop/Material/MaterialManager.cs | 14 +++-- .../Interop/Material/MaterialValueIndex.cs | 61 +++++++++++++++++-- .../Interop/Material/MaterialValueManager.cs | 47 ++++++++++---- Glamourer/Interop/Material/PrepareColorSet.cs | 13 +++- Glamourer/State/StateApplier.cs | 18 +++--- OtterGui | 2 +- 7 files changed, 157 insertions(+), 48 deletions(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 3ba2a1b..b857bf8 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; +using FFXIVClientStructs.FFXIV.Client.Graphics.Render; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using FFXIVClientStructs.Interop; using Glamourer.Designs; @@ -27,6 +28,7 @@ public sealed unsafe class AdvancedDyePopup( private MaterialValueIndex? _drawIndex; private ActorState _state = null!; private Actor _actor; + private ColorRow.Mode _mode; private byte _selectedMaterial = byte.MaxValue; private bool _anyChanged; private bool _forceFocus; @@ -96,7 +98,7 @@ public sealed unsafe class AdvancedDyePopup( return (path, gamePath); } - private void DrawTabBar(ReadOnlySpan> textures, ref bool firstAvailable) + private void DrawTabBar(ReadOnlySpan> textures, ReadOnlySpan> materials, ref bool firstAvailable) { using var bar = ImRaii.TabBar("tabs"); if (!bar) @@ -105,8 +107,9 @@ public sealed unsafe class AdvancedDyePopup( var table = new ColorTable.Table(); for (byte i = 0; i < MaterialService.MaterialsPerModel; ++i) { - var index = _drawIndex!.Value with { MaterialIndex = i }; - var available = index.TryGetTexture(textures, out var texture) && directX.TryGetColorTable(*texture, out table); + var index = _drawIndex!.Value with { MaterialIndex = i }; + var available = index.TryGetTexture(textures, materials, out var texture, out _mode) + && directX.TryGetColorTable(*texture, out table); if (index == preview.LastValueIndex with { RowIndex = 0 }) @@ -163,16 +166,16 @@ public sealed unsafe class AdvancedDyePopup( } } - private void DrawContent(ReadOnlySpan> textures) + private void DrawContent(ReadOnlySpan> textures, ReadOnlySpan> materials) { var firstAvailable = true; - DrawTabBar(textures, ref firstAvailable); + DrawTabBar(textures, materials, ref firstAvailable); if (firstAvailable) ImGui.TextUnformatted("No Editable Materials available."); } - private void DrawWindow(ReadOnlySpan> textures) + private void DrawWindow(ReadOnlySpan> textures, ReadOnlySpan> materials) { var flags = ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoCollapse @@ -208,7 +211,7 @@ public sealed unsafe class AdvancedDyePopup( try { if (window) - DrawContent(textures); + DrawContent(textures, materials); } finally { @@ -223,8 +226,8 @@ public sealed unsafe class AdvancedDyePopup( if (!ShouldBeDrawn()) return; - if (_drawIndex!.Value.TryGetTextures(actor, out var textures)) - DrawWindow(textures); + if (_drawIndex!.Value.TryGetTextures(actor, out var textures, out var materials)) + DrawWindow(textures, materials); } private void DrawTable(MaterialValueIndex materialIndex, ColorTable.Table table) @@ -340,15 +343,30 @@ public sealed unsafe class AdvancedDyePopup( v => value.Model.Emissive = v, "E"); ImGui.SameLine(0, spacing.X); - ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Gloss", ref value.Model.GlossStrength, 0.01f, 0.001f, float.MaxValue, "%.3f G") - && value.Model.GlossStrength > 0; - ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); + if (_mode is not ColorRow.Mode.Dawntrail) + { + ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); + applied |= ImGui.DragFloat("##Gloss", ref value.Model.GlossStrength, 0.01f, 0.001f, float.MaxValue, "%.3f G") + && value.Model.GlossStrength > 0; + ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); + } + else + { + ImGui.Dummy(new Vector2(100 * ImGuiHelpers.GlobalScale, 0)); + } ImGui.SameLine(0, spacing.X); - ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Specular Strength", ref value.Model.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, "%.3f%% SS"); - ImGuiUtil.HoverTooltip("Change the specular strength for this row."); + if (_mode is not ColorRow.Mode.Dawntrail) + { + ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); + applied |= ImGui.DragFloat("##Specular Strength", ref value.Model.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, + "%.3f%% SS"); + ImGuiUtil.HoverTooltip("Change the specular strength for this row."); + } + else + { + ImGui.Dummy(new Vector2(100 * ImGuiHelpers.GlobalScale, 0)); + } ImGui.SameLine(0, spacing.X); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), buttonSize, "Export this row to your clipboard.", false, diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 3e0e35b..7f13c2d 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -1,5 +1,6 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; +using FFXIVClientStructs.Havok.Animation.Rig; using Glamourer.Designs; using Glamourer.Interop.Penumbra; using Glamourer.State; @@ -67,7 +68,8 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable MaterialValueIndex.DrawObjectType.Human => GetTempSlot((Human*)characterBase, slotId), _ => GetTempSlot((Weapon*)characterBase), }; - UpdateMaterialValues(state, values, drawData, ref baseColorSet); + var mode = PrepareColorSet.GetMode(material); + UpdateMaterialValues(state, values, drawData, ref baseColorSet, mode); if (MaterialService.GenerateNewColorTable(baseColorSet, out var texture)) ret = (nint)texture; @@ -75,7 +77,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// Update and apply the glamourer state of an actor according to the application sources when updated by the game. private void UpdateMaterialValues(ActorState state, ReadOnlySpan<(uint Key, MaterialValueState Value)> values, CharacterWeapon drawData, - ref ColorTable.Table colorTable) + ref ColorTable.Table colorTable, ColorRow.Mode mode) { var deleteList = _deleteList.Value!; deleteList.Clear(); @@ -86,17 +88,17 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable ref var row = ref colorTable[idx.RowIndex]; var newGame = new ColorRow(row); if (materialValue.EqualGame(newGame, drawData)) - materialValue.Model.Apply(ref row); + materialValue.Model.Apply(ref row, mode); else switch (materialValue.Source) { case StateSource.Pending: - materialValue.Model.Apply(ref row); + materialValue.Model.Apply(ref row, mode); state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, StateSource.Manual), out _); break; case StateSource.IpcPending: - materialValue.Model.Apply(ref row); + materialValue.Model.Apply(ref row, mode); state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, StateSource.IpcManual), out _); break; @@ -106,7 +108,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable break; case StateSource.Fixed: case StateSource.IpcFixed: - materialValue.Model.Apply(ref row); + materialValue.Model.Apply(ref row, mode); state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, materialValue.Source), out _); break; diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 5104713..30f2e68 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -1,9 +1,11 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; +using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; using FFXIVClientStructs.Interop; using Newtonsoft.Json; using Penumbra.GameData.Enums; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Interop; +using CsMaterial = FFXIVClientStructs.FFXIV.Client.Graphics.Render.Material; namespace Glamourer.Interop.Material; @@ -75,21 +77,39 @@ public readonly record struct MaterialValueIndex( return model.IsCharacterBase; } + public unsafe bool TryGetTextures(Actor actor, out ReadOnlySpan> textures, out ReadOnlySpan> materials) + { + if (!TryGetModel(actor, out var model) + || SlotIndex >= model.AsCharacterBase->SlotCount + || model.AsCharacterBase->ColorTableTexturesSpan.Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) + { + textures = []; + materials = []; + return false; + } + + var from = SlotIndex * MaterialService.MaterialsPerModel; + textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(from, MaterialService.MaterialsPerModel); + materials = model.AsCharacterBase->MaterialsSpan.Slice(from, MaterialService.MaterialsPerModel); + return true; + } + public unsafe bool TryGetTextures(Actor actor, out ReadOnlySpan> textures) { if (!TryGetModel(actor, out var model) || SlotIndex >= model.AsCharacterBase->SlotCount || model.AsCharacterBase->ColorTableTexturesSpan.Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) { - textures = []; + textures = []; return false; } - textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(SlotIndex * MaterialService.MaterialsPerModel, - MaterialService.MaterialsPerModel); + var from = SlotIndex * MaterialService.MaterialsPerModel; + textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(from, MaterialService.MaterialsPerModel); return true; } + public unsafe bool TryGetTexture(Actor actor, out Texture** texture) { if (TryGetTextures(actor, out var textures)) @@ -99,6 +119,38 @@ public readonly record struct MaterialValueIndex( return false; } + public unsafe bool TryGetTexture(Actor actor, out Texture** texture, out ColorRow.Mode mode) + { + if (TryGetTextures(actor, out var textures, out var materials)) + return TryGetTexture(textures, materials, out texture, out mode); + + mode = ColorRow.Mode.Dawntrail; + texture = null; + return false; + } + + public unsafe bool TryGetTexture(ReadOnlySpan> textures, ReadOnlySpan> materials, + out Texture** texture, out ColorRow.Mode mode) + { + mode = MaterialIndex >= materials.Length + ? ColorRow.Mode.Dawntrail + : PrepareColorSet.GetMode((MaterialResourceHandle*)materials[MaterialIndex].Value); + + + if (MaterialIndex >= textures.Length || textures[MaterialIndex].Value == null) + { + texture = null; + return false; + } + + fixed (Pointer* ptr = textures) + { + texture = (Texture**)ptr + MaterialIndex; + } + + return true; + } + public unsafe bool TryGetTexture(ReadOnlySpan> textures, out Texture** texture) { if (MaterialIndex >= textures.Length || textures[MaterialIndex].Value == null) @@ -115,6 +167,7 @@ public readonly record struct MaterialValueIndex( return true; } + public static MaterialValueIndex FromKey(uint key) => new(key); @@ -190,4 +243,4 @@ public readonly record struct MaterialValueIndex( JsonSerializer serializer) => FromKey(serializer.Deserialize(reader), out var value) ? value : throw new Exception($"Invalid material key {value.Key}."); } -} \ No newline at end of file +} diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index 79338a0..cb3a7e2 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -13,6 +13,12 @@ namespace Glamourer.Interop.Material; /// Values are not squared. public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, float specularStrength, float glossStrength) { + public enum Mode + { + Legacy, + Dawntrail, + } + public static readonly ColorRow Empty = new(Vector3.Zero, Vector3.Zero, Vector3.Zero, 0, 0); public Vector3 Diffuse = diffuse; @@ -22,8 +28,9 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa public float GlossStrength = glossStrength; public ColorRow(in ColorTableRow row) - : this(Root((Vector3)row.DiffuseColor), Root((Vector3)row.SpecularColor), Root((Vector3)row.EmissiveColor), (float)row.SheenRate, - (float)row.Metalness) + : this(Root((Vector3)row.DiffuseColor), Root((Vector3)row.SpecularColor), Root((Vector3)row.EmissiveColor), + (float)row.LegacySpecularStrength(), + (float)row.LegacyGloss()) { } public readonly bool NearEqual(in ColorRow rhs) @@ -45,7 +52,7 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa private static float Root(float value) => value < 0 ? MathF.Sqrt(-value) : MathF.Sqrt(value); - public readonly bool Apply(ref ColorTableRow row) + public readonly bool Apply(ref ColorTableRow row, Mode mode) { var ret = false; var d = Square(Diffuse); @@ -69,22 +76,40 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa ret = true; } - if (!((float)row.SheenRate).NearEqual(SpecularStrength)) + if (mode is Mode.Legacy) { - row.SheenRate = (Half)SpecularStrength; - ret = true; - } + if (!((float)row.LegacySpecularStrength()).NearEqual(SpecularStrength)) + { + row.LegacySpecularStrengthWrite() = (Half)SpecularStrength; + ret = true; + } - if (!((float)row.Metalness).NearEqual(GlossStrength)) - { - row.Metalness = (Half)GlossStrength; - ret = true; + if (!((float)row.LegacyGloss()).NearEqual(GlossStrength)) + { + row.LegacyGlossWrite() = (Half)GlossStrength; + ret = true; + } } return ret; } } +internal static class ColorTableRowExtensions +{ + internal static Half LegacySpecularStrength(this in ColorTableRow row) + => row[7]; + + internal static Half LegacyGloss(this in ColorTableRow row) + => row[3]; + + internal static ref Half LegacySpecularStrengthWrite(this ref ColorTableRow row) + => ref row[7]; + + internal static ref Half LegacyGlossWrite(this ref ColorTableRow row) + => ref row[3]; +} + [JsonConverter(typeof(Converter))] public struct MaterialValueDesign(ColorRow value, bool enabled, bool revert) { diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 6d65a6b..b44246b 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -91,11 +91,12 @@ public sealed unsafe class PrepareColorSet } /// Assumes the actor is valid. - public static bool TryGetColorTable(Actor actor, MaterialValueIndex index, out ColorTable.Table table) + public static bool TryGetColorTable(Actor actor, MaterialValueIndex index, out ColorTable.Table table, out ColorRow.Mode mode) { var idx = index.SlotIndex * MaterialService.MaterialsPerModel + index.MaterialIndex; if (!index.TryGetModel(actor, out var model)) { + mode = ColorRow.Mode.Dawntrail; table = default; return false; } @@ -103,10 +104,12 @@ public sealed unsafe class PrepareColorSet var handle = (MaterialResourceHandle*)model.AsCharacterBase->Materials[idx]; if (handle == null) { + mode = ColorRow.Mode.Dawntrail; table = default; return false; } + mode = GetMode(handle); return TryGetColorTable(handle, GetStains(), out table); StainIds GetStains() @@ -126,6 +129,14 @@ public sealed unsafe class PrepareColorSet } } + /// Get the shader mode of the material. + public static ColorRow.Mode GetMode(MaterialResourceHandle* handle) + => handle == null + ? ColorRow.Mode.Dawntrail + : handle->ShpkNameSpan.SequenceEqual("characterlegacy.shpk"u8) + ? ColorRow.Mode.Legacy + : ColorRow.Mode.Dawntrail; + /// Get the correct dye table for a material. private static bool GetDyeTable(MaterialResourceHandle* material, out ushort* ptr) { diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 66b83fb..d6d5bde 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -75,7 +75,7 @@ public class StateApplier( } } - /// + /// public ActorData ChangeCustomize(ActorState state, bool apply) { var data = GetData(state); @@ -177,7 +177,7 @@ public class StateApplier( } } - /// + /// public ActorData ChangeStain(ActorState state, EquipSlot slot, bool apply) { var data = GetData(state); @@ -197,7 +197,7 @@ public class StateApplier( ChangeOffhand(data, item, stains); } - /// + /// public ActorData ChangeWeapon(ActorState state, EquipSlot slot, bool apply, bool onlyGPose) { var data = GetData(state); @@ -229,7 +229,7 @@ public class StateApplier( } /// Change a meta state. - public unsafe void ChangeMetaState(ActorData data, MetaIndex index, bool value) + public void ChangeMetaState(ActorData data, MetaIndex index, bool value) { switch (index) { @@ -311,15 +311,15 @@ public class StateApplier( foreach (var actor in data.Objects.Where(a => a is { IsCharacter: true, Model.IsHuman: true })) { - if (!index.TryGetTexture(actor, out var texture)) + if (!index.TryGetTexture(actor, out var texture, out var mode)) continue; if (!_directX.TryGetColorTable(*texture, out var table)) continue; if (value.HasValue) - value.Value.Apply(ref table[index.RowIndex]); - else if (PrepareColorSet.TryGetColorTable(actor, index, out var baseTable)) + value.Value.Apply(ref table[index.RowIndex], mode); + else if (PrepareColorSet.TryGetColorTable(actor, index, out var baseTable, out _)) table[index.RowIndex] = baseTable[index.RowIndex]; else continue; @@ -353,11 +353,11 @@ public class StateApplier( if (!mainKey.TryGetTexture(actor, out var texture)) continue; - if (!PrepareColorSet.TryGetColorTable(actor, mainKey, out var table)) + if (!PrepareColorSet.TryGetColorTable(actor, mainKey, out var table, out var mode)) continue; foreach (var (key, value) in values) - value.Model.Apply(ref table[key.RowIndex]); + value.Model.Apply(ref table[key.RowIndex], mode); _directX.ReplaceColorTable(texture, table); } diff --git a/OtterGui b/OtterGui index 51bab6d..d9486ae 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 51bab6dd1bd7d98cc468e8122f410e1c79e3c92d +Subproject commit d9486ae54b5a4b61cf74f79ed27daa659eb1ce5b From 1c8d01bdd3fc2bb22961c4665aa79787a91d4c26 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 7 Aug 2024 17:57:49 +0200 Subject: [PATCH 071/401] For later. --- Glamourer/Services/CodeService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index 5ab0d8f..73d27b4 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -218,9 +218,9 @@ public class CodeService CodeFlag.Elephants => [ 0x9F, 0x4C, 0xCF, 0x6D, 0xC4, 0x01, 0x31, 0x46, 0x02, 0x05, 0x31, 0xED, 0xED, 0xB2, 0x66, 0x29, 0x31, 0x09, 0x1E, 0xE7, 0x47, 0xDE, 0x7B, 0x03, 0xB0, 0x3C, 0x06, 0x76, 0x26, 0x91, 0xDF, 0xB2 ], CodeFlag.Crown => [ 0x43, 0x8E, 0x34, 0x56, 0x24, 0xC9, 0xC6, 0xDE, 0x2A, 0x68, 0x3A, 0x5D, 0xF5, 0x8E, 0xCB, 0xEF, 0x0D, 0x4D, 0x5B, 0xDC, 0x23, 0xF9, 0xF9, 0xBD, 0xD9, 0x60, 0xAD, 0x53, 0xC5, 0xA0, 0x33, 0xC4 ], CodeFlag.Dolphins => [ 0x64, 0xC6, 0x2E, 0x7C, 0x22, 0x3A, 0x42, 0xF5, 0xC3, 0x93, 0x4F, 0x70, 0x1F, 0xFD, 0xFA, 0x3C, 0x98, 0xD2, 0x7C, 0xD8, 0x88, 0xA7, 0x3D, 0x1D, 0x0D, 0xD6, 0x70, 0x15, 0x28, 0x2E, 0x79, 0xE7 ], - CodeFlag.Face => [ 0xCA, 0x97, 0x81, 0x12, 0xCA, 0x1B, 0xBD, 0xCA, 0xFA, 0xC2, 0x31, 0xB3, 0x9A, 0x23, 0xDC, 0x4D, 0xA7, 0x86, 0xEF, 0xF8, 0x14, 0x7C, 0x4E, 0x72, 0xB9, 0x80, 0x77, 0x85, 0xAF, 0xEE, 0x48, 0xBB ], - CodeFlag.Manderville => [ 0x3E, 0x23, 0xE8, 0x16, 0x00, 0x39, 0x59, 0x4A, 0x33, 0x89, 0x4F, 0x65, 0x64, 0xE1, 0xB1, 0x34, 0x8B, 0xBD, 0x7A, 0x00, 0x88, 0xD4, 0x2C, 0x4A, 0xCB, 0x73, 0xEE, 0xAE, 0xD5, 0x9C, 0x00, 0x9D ], - CodeFlag.Smiles => [ 0x2E, 0x7D, 0x2C, 0x03, 0xA9, 0x50, 0x7A, 0xE2, 0x65, 0xEC, 0xF5, 0xB5, 0x35, 0x68, 0x85, 0xA5, 0x33, 0x93, 0xA2, 0x02, 0x9D, 0x24, 0x13, 0x94, 0x99, 0x72, 0x65, 0xA1, 0xA2, 0x5A, 0xEF, 0xC6 ], + CodeFlag.Face => [ 0xCA, 0x97, 0x81, 0x12, 0xCA, 0x1B, 0xBD, 0xCA, 0xFA, 0xC2, 0x31, 0xB3, 0x9B, 0x23, 0xDC, 0x4D, 0xA7, 0x86, 0xEF, 0xF8, 0x14, 0x7C, 0x4E, 0x72, 0xB9, 0x80, 0x77, 0x85, 0xAF, 0xEE, 0x48, 0xBB ], + CodeFlag.Manderville => [ 0x3E, 0x23, 0xE8, 0x16, 0x00, 0x39, 0x59, 0x4A, 0x33, 0x89, 0x4F, 0x65, 0x65, 0xE1, 0xB1, 0x34, 0x8B, 0xBD, 0x7A, 0x00, 0x88, 0xD4, 0x2C, 0x4A, 0xCB, 0x73, 0xEE, 0xAE, 0xD5, 0x9C, 0x00, 0x9D ], + CodeFlag.Smiles => [ 0x2E, 0x7D, 0x2C, 0x03, 0xA9, 0x50, 0x7A, 0xE2, 0x65, 0xEC, 0xF5, 0xB5, 0x36, 0x68, 0x85, 0xA5, 0x33, 0x93, 0xA2, 0x02, 0x9D, 0x24, 0x13, 0x94, 0x99, 0x72, 0x65, 0xA1, 0xA2, 0x5A, 0xEF, 0xC6 ], _ => [], }; From d594082165afae0dd7e47f90081c73e7c2922d51 Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 7 Aug 2024 15:59:50 +0000 Subject: [PATCH 072/401] [CI] Updating repo.json for testing_1.3.0.10 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index ac8b996..fb27eac 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.9", + "TestingAssemblyVersion": "1.3.0.10", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.9/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.10/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From d7074c5791de557344334b7679d87d3c7f52f725 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 9 Aug 2024 16:01:17 +0200 Subject: [PATCH 073/401] Improve Gloss/Specular display --- Glamourer/Designs/Design.cs | 6 ++-- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 37 ++++++++++++++++++--- Glamourer/Gui/Materials/MaterialDrawer.cs | 5 +-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index 05ee948..8e4d366 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -228,10 +228,10 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn if (array == null) return; - foreach (var obj in array.OfType()) + foreach (var jObj in array.OfType()) { - var identifier = obj["Design"]?.ToObject() ?? throw new ArgumentNullException("Design"); - var type = (ApplicationType)(obj["Type"]?.ToObject() ?? 0); + var identifier = jObj["Design"]?.ToObject() ?? throw new ArgumentNullException(nameof(design)); + var type = (ApplicationType)(jObj["Type"]?.ToObject() ?? 0); linkLoader.AddObject(design, new LinkData(identifier, type, order)); } } diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index b857bf8..9991aae 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -11,6 +11,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Services; +using OtterGui.Text; using OtterGui.Widgets; using Penumbra.GameData.Enums; using Penumbra.GameData.Files.MaterialStructs; @@ -346,8 +347,7 @@ public sealed unsafe class AdvancedDyePopup( if (_mode is not ColorRow.Mode.Dawntrail) { ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Gloss", ref value.Model.GlossStrength, 0.01f, 0.001f, float.MaxValue, "%.3f G") - && value.Model.GlossStrength > 0; + applied |= DragGloss(ref value.Model.GlossStrength); ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); } else @@ -359,8 +359,7 @@ public sealed unsafe class AdvancedDyePopup( if (_mode is not ColorRow.Mode.Dawntrail) { ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Specular Strength", ref value.Model.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, - "%.3f%% SS"); + applied |= DragSpecularStrength(ref value.Model.SpecularStrength); ImGuiUtil.HoverTooltip("Change the specular strength for this row."); } else @@ -388,6 +387,36 @@ public sealed unsafe class AdvancedDyePopup( stateManager.ChangeMaterialValue(_state, index, value, ApplySettings.Manual); } + public static bool DragGloss(ref float value) + { + var tmp = value; + var minValue = ImGui.GetIO().KeyCtrl ? 0f : (float)Half.Epsilon; + if (!ImUtf8.DragScalar("##Gloss"u8, ref tmp, "%.1f G"u8, 0.001f, minValue, Math.Max(0.01f, 0.005f * value), ImGuiSliderFlags.AlwaysClamp)) + return false; + + var tmp2 = Math.Clamp(tmp, minValue, (float)Half.MaxValue); + if (tmp2 == value) + return false; + + value = tmp2; + return true; + } + + public static bool DragSpecularStrength(ref float value) + { + var tmp = value * 100f; + if (!ImUtf8.DragScalar("##SpecularStrength"u8, ref tmp, "%.0f%% SS"u8, 0f, (float)Half.MaxValue * 100f, 0.05f, + ImGuiSliderFlags.AlwaysClamp)) + return false; + + var tmp2 = Math.Clamp(tmp, 0f, (float)Half.MaxValue * 100f) / 100f; + if (tmp2 == value) + return false; + + value = tmp2; + return true; + } + private LabelStruct _label = new(); private struct LabelStruct diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 95be750..3fcdbe1 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; +using FFXIVClientStructs.FFXIV.Common.Lua; using Glamourer.Designs; using Glamourer.Interop.Material; using ImGuiNET; @@ -196,11 +197,11 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", row.Emissive, v => tmp.Emissive = v, "E"); ImGui.SameLine(0, _spacing); ImGui.SetNextItemWidth(GlossWidth * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Gloss", ref tmp.GlossStrength, 0.01f, 0.001f, float.MaxValue, "%.3f G"); + applied |= AdvancedDyePopup.DragGloss(ref tmp.GlossStrength); ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); ImGui.SameLine(0, _spacing); ImGui.SetNextItemWidth(SpecularStrengthWidth * ImGuiHelpers.GlobalScale); - applied |= ImGui.DragFloat("##Specular Strength", ref tmp.SpecularStrength, 0.01f, float.MinValue, float.MaxValue, "%.3f%% SS"); + applied |= AdvancedDyePopup.DragSpecularStrength(ref tmp.SpecularStrength); ImGuiUtil.HoverTooltip("Change the specular strength for this row."); if (applied) _designManager.ChangeMaterialValue(design, index, tmp); From 5cd224b164d92a47a4f03b5def720c99fa881277 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 9 Aug 2024 16:01:44 +0200 Subject: [PATCH 074/401] Add design migration for inverted gloss and specular, and a backup before doing that. --- Glamourer/Configuration.cs | 6 +- Glamourer/Designs/Design.cs | 75 ++++++++++++++++++-- Glamourer/Designs/DesignConverter.cs | 11 +-- Glamourer/Designs/DesignManager.cs | 2 +- Glamourer/Services/ConfigMigrationService.cs | 11 +++ 5 files changed, 91 insertions(+), 14 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 11c45a8..165e20d 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -143,10 +143,10 @@ public class Configuration : IPluginConfiguration, ISavable public static class Constants { - public const int CurrentVersion = 6; + public const int CurrentVersion = 7; public static readonly ISortMode[] ValidSortModes = - { + [ ISortMode.FoldersFirst, ISortMode.Lexicographical, new DesignFileSystem.CreationDate(), @@ -159,7 +159,7 @@ public class Configuration : IPluginConfiguration, ISavable ISortMode.InverseFoldersLast, ISortMode.InternalOrder, ISortMode.InverseInternalOrder, - }; + ]; } /// Convert SortMode Types to their name. diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index 8e4d366..fb18873 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui.Classes; using Penumbra.GameData.Structs; +using Notification = OtterGui.Classes.Notification; namespace Glamourer.Designs; @@ -34,7 +35,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn } // Metadata - public new const int FileVersion = 1; + public new const int FileVersion = 2; public Guid Identifier { get; internal init; } public DateTimeOffset CreationDate { get; internal init; } @@ -143,17 +144,81 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn #region Deserialization - public static Design LoadDesign(CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) + public static Design LoadDesign(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) { var version = json["FileVersion"]?.ToObject() ?? 0; return version switch { - FileVersion => LoadDesignV1(customizations, items, linkLoader, json), + 1 => LoadDesignV1(saveService, customizations, items, linkLoader, json), + FileVersion => LoadDesignV2(customizations, items, linkLoader, json), _ => throw new Exception("The design to be loaded has no valid Version."), }; } - private static Design LoadDesignV1(CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) + /// The values for gloss and specular strength were switched. Swap them for all appropriate designs. + private static Design LoadDesignV1(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) + { + var design = LoadDesignV2(customizations, items, linkLoader, json); + var materialDesignData = design.GetMaterialDataRef(); + if (materialDesignData.Values.Count == 0) + return design; + + var materialData = materialDesignData.Clone(); + // Guesstimate whether to migrate material rows: + // Update 1.3.0.10 released at that time, so any design last updated before that can be migrated. + if (design.LastEdit <= new DateTime(2024, 8, 7, 16, 0, 0, DateTimeKind.Utc)) + { + Migrate("because it was saved the wrong way around before 1.3.0.10, and this design was not changed since that release."); + } + else + { + var hasNegativeGloss = false; + var hasNonPositiveGloss = false; + var specularLarger = 0; + foreach (var (key, value) in materialData.GetValues(MaterialValueIndex.Min(), MaterialValueIndex.Max())) + { + hasNegativeGloss |= value.Value.GlossStrength < 0; + hasNonPositiveGloss |= value.Value.GlossStrength <= 0; + if (value.Value.SpecularStrength > value.Value.GlossStrength) + ++specularLarger; + } + + // If there is any negative gloss, this is wrong and can be migrated. + if (hasNegativeGloss) + Migrate("because it had a negative Gloss value, which is not supported and thus probably outdated."); + // If there is any non-positive Gloss and some specular values that are larger, it is probably wrong and can be migrated. + else if (hasNonPositiveGloss && specularLarger > 0) + Migrate("because it had a zero Gloss value, and at least one Specular Strength larger than the Gloss, which is unusual."); + // If most of the specular strengths are larger, it is probably wrong and can be migrated. + else if (specularLarger > materialData.Values.Count / 2) + Migrate("because most of its Specular Strength values were larger than the Gloss values, which is unusual."); + } + + return design; + + void Migrate(string reason) + { + materialDesignData.Clear(); + foreach (var (key, value) in materialData.GetValues(MaterialValueIndex.Min(), MaterialValueIndex.Max())) + { + var gloss = Math.Clamp(value.Value.SpecularStrength, 0, (float)Half.MaxValue); + var specularStrength = Math.Clamp(value.Value.GlossStrength, 0, (float)Half.MaxValue); + var colorRow = value.Value with + { + GlossStrength = gloss, + SpecularStrength = specularStrength, + }; + materialDesignData.AddOrUpdateValue(MaterialValueIndex.FromKey(key), value with { Value = colorRow }); + } + + Glamourer.Messager.AddMessage(new Notification( + $"Swapped Gloss and Specular Strength in {materialDesignData.Values.Count} Rows in design {design.Incognito} {reason}", + NotificationType.Info)); + saveService.Save(SaveType.ImmediateSync,design); + } + } + + private static Design LoadDesignV2(CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) { var creationDate = json["CreationDate"]?.ToObject() ?? throw new ArgumentNullException("CreationDate"); @@ -183,7 +248,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn static string[] ParseTags(JObject json) { - var tags = json["Tags"]?.ToObject() ?? Array.Empty(); + var tags = json["Tags"]?.ToObject() ?? []; return tags.OrderBy(t => t).Distinct().ToArray(); } } diff --git a/Glamourer/Designs/DesignConverter.cs b/Glamourer/Designs/DesignConverter.cs index 2ebcea0..058b023 100644 --- a/Glamourer/Designs/DesignConverter.cs +++ b/Glamourer/Designs/DesignConverter.cs @@ -13,6 +13,7 @@ using Penumbra.GameData.Structs; namespace Glamourer.Designs; public class DesignConverter( + SaveService saveService, ItemManager _items, DesignManager _designs, CustomizeService _customize, @@ -69,7 +70,7 @@ public class DesignConverter( try { var ret = jObject["Identifier"] != null - ? Design.LoadDesign(_customize, _items, _linkLoader, jObject) + ? Design.LoadDesign(saveService, _customize, _items, _linkLoader, jObject) : DesignBase.LoadDesignBase(_customize, _items, jObject); if (!customize) @@ -100,7 +101,7 @@ public class DesignConverter( case (byte)'{': var jObj1 = JObject.Parse(Encoding.UTF8.GetString(bytes)); ret = jObj1["Identifier"] != null - ? Design.LoadDesign(_customize, _items, _linkLoader, jObj1) + ? Design.LoadDesign(saveService, _customize, _items, _linkLoader, jObj1) : DesignBase.LoadDesignBase(_customize, _items, jObj1); break; case 1: @@ -115,7 +116,7 @@ public class DesignConverter( var jObj2 = JObject.Parse(decompressed); Debug.Assert(version == 3); ret = jObj2["Identifier"] != null - ? Design.LoadDesign(_customize, _items, _linkLoader, jObj2) + ? Design.LoadDesign(saveService, _customize, _items, _linkLoader, jObj2) : DesignBase.LoadDesignBase(_customize, _items, jObj2); break; } @@ -126,7 +127,7 @@ public class DesignConverter( var jObj2 = JObject.Parse(decompressed); Debug.Assert(version == 5); ret = jObj2["Identifier"] != null - ? Design.LoadDesign(_customize, _items, _linkLoader, jObj2) + ? Design.LoadDesign(saveService, _customize, _items, _linkLoader, jObj2) : DesignBase.LoadDesignBase(_customize, _items, jObj2); break; } @@ -136,7 +137,7 @@ public class DesignConverter( var jObj2 = JObject.Parse(decompressed); Debug.Assert(version == 6); ret = jObj2["Identifier"] != null - ? Design.LoadDesign(_customize, _items, _linkLoader, jObj2) + ? Design.LoadDesign(saveService, _customize, _items, _linkLoader, jObj2) : DesignBase.LoadDesignBase(_customize, _items, jObj2); break; } diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index a31ba83..63c98c0 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -53,7 +53,7 @@ public sealed class DesignManager : DesignEditor { var text = File.ReadAllText(f.FullName); var data = JObject.Parse(text); - var design = Design.LoadDesign(Customizations, Items, linkLoader, data); + var design = Design.LoadDesign(SaveService, Customizations, Items, linkLoader, data); designs.Value!.Add((design, f.FullName)); } catch (Exception ex) diff --git a/Glamourer/Services/ConfigMigrationService.cs b/Glamourer/Services/ConfigMigrationService.cs index 88eaf69..3f997c9 100644 --- a/Glamourer/Services/ConfigMigrationService.cs +++ b/Glamourer/Services/ConfigMigrationService.cs @@ -23,9 +23,20 @@ public class ConfigMigrationService(SaveService saveService, FixedDesignMigrator MigrateV2To4(); MigrateV4To5(); MigrateV5To6(); + MigrateV6To7(); AddColors(config, true); } + private void MigrateV6To7() + { + if (_config.Version > 6) + return; + + // Do not actually change anything in the config, just create a backup before designs are migrated. + backupService.CreateMigrationBackup("pre_gloss_specular_migration"); + _config.Version = 7; + } + private void MigrateV5To6() { if (_config.Version > 5) From 2282f3f87ae9e8e003249f58815f6b537a8078fd Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 9 Aug 2024 14:04:22 +0000 Subject: [PATCH 075/401] [CI] Updating repo.json for testing_1.3.0.11 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index fb27eac..cc7adf9 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.10", + "TestingAssemblyVersion": "1.3.0.11", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.10/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.11/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From af58a52a596021289f3295661617660f1ef1913c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 9 Aug 2024 16:27:12 +0200 Subject: [PATCH 076/401] Update display of saved material values. --- .../Interop/Material/MaterialValueIndex.cs | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 30f2e68..712b0d5 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -100,12 +100,12 @@ public readonly record struct MaterialValueIndex( || SlotIndex >= model.AsCharacterBase->SlotCount || model.AsCharacterBase->ColorTableTexturesSpan.Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel) { - textures = []; + textures = []; return false; } var from = SlotIndex * MaterialService.MaterialsPerModel; - textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(from, MaterialService.MaterialsPerModel); + textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(from, MaterialService.MaterialsPerModel); return true; } @@ -220,20 +220,27 @@ public readonly record struct MaterialValueIndex( public override string ToString() => DrawObject switch { - DrawObjectType.Invalid => "Invalid", - DrawObjectType.Human when SlotIndex < 10 => - $"{((uint)SlotIndex).ToEquipSlot().ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Human when SlotIndex == 10 => $"BodySlot.Hair.ToString() Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Human when SlotIndex == 11 => $"BodySlot.Face.ToString() Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Human when SlotIndex == 12 => $"{BodySlot.Tail} / {BodySlot.Ear} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Human when SlotIndex == 13 => $"Connectors Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Human when SlotIndex == 16 => $"{BonusItemFlag.Glasses.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Human when SlotIndex == 17 => $"{BonusItemFlag.UnkSlot.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Mainhand when SlotIndex == 0 => $"{EquipSlot.MainHand.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - DrawObjectType.Offhand when SlotIndex == 0 => $"{EquipSlot.OffHand.ToName()} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", - _ => $"{DrawObject} Slot {SlotIndex} Material #{MaterialIndex + 1} Row #{RowIndex + 1}", + DrawObjectType.Invalid => "Invalid", + DrawObjectType.Human when SlotIndex < 10 => $"{((uint)SlotIndex).ToEquipSlot().ToName()} {MaterialString()} {RowString()}", + DrawObjectType.Human when SlotIndex == 10 => $"{BodySlot.Hair} {MaterialString()} {RowString()}", + DrawObjectType.Human when SlotIndex == 11 => $"{BodySlot.Face} {MaterialString()} {RowString()}", + DrawObjectType.Human when SlotIndex == 12 => $"{BodySlot.Tail} / {BodySlot.Ear} {MaterialString()} {RowString()}", + DrawObjectType.Human when SlotIndex == 13 => $"Connectors {MaterialString()} {RowString()}", + DrawObjectType.Human when SlotIndex == 16 => $"{BonusItemFlag.Glasses.ToName()} {MaterialString()} {RowString()}", + DrawObjectType.Human when SlotIndex == 17 => $"{BonusItemFlag.UnkSlot.ToName()} {MaterialString()} {RowString()}", + DrawObjectType.Mainhand when SlotIndex == 0 => $"{EquipSlot.MainHand.ToName()} {MaterialString()} {RowString()}", + DrawObjectType.Offhand when SlotIndex == 0 => $"{EquipSlot.OffHand.ToName()} {MaterialString()} {RowString()}", + _ => $"{DrawObject} Slot {SlotIndex} {MaterialString()} {RowString()}", }; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private string MaterialString() + => $"Material {(char)(MaterialIndex + 'A')}"; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private string RowString() + => $"Row {RowIndex / 2 + 1}{(char)(RowIndex % 2 + 'A')}"; + private class Converter : JsonConverter { public override void WriteJson(JsonWriter writer, MaterialValueIndex value, JsonSerializer serializer) From edc54203b5b1c8113fddf2344c2d0cac804b9a79 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 9 Aug 2024 22:09:01 +0200 Subject: [PATCH 077/401] Fix display and initial values of design color rows. --- Glamourer/Gui/Materials/MaterialDrawer.cs | 87 +++++++++---------- .../Interop/Material/MaterialValueManager.cs | 2 +- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 3fcdbe1..dec1aae 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -1,12 +1,12 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; -using FFXIVClientStructs.FFXIV.Common.Lua; using Glamourer.Designs; using Glamourer.Interop.Material; using ImGuiNET; using OtterGui; using OtterGui.Services; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Gui; @@ -28,13 +28,13 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) public void Draw(Design design) { - var available = ImGui.GetContentRegionAvail().X; + var available = ImGui.GetContentRegionAvail().X; _spacing = ImGui.GetStyle().ItemInnerSpacing.X; _buttonSize = new Vector2(ImGui.GetFrameHeight()); var colorWidth = 4 * _buttonSize.X + (GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + 6 * _spacing - + ImGui.CalcTextSize("Revert").X; + + ImUtf8.CalcTextSize("Revert"u8).X; if (available > 1.95 * colorWidth) DrawSingleRow(design); else @@ -44,9 +44,9 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) private void DrawName(MaterialValueIndex index) { - using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale).Push(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); - using var color = ImRaii.PushColor(ImGuiCol.Border, ImGui.GetColorU32(ImGuiCol.Text)); - ImGuiUtil.DrawTextButton(index.ToString(), new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0), 0); + using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); + ImUtf8.TextFramed(index.ToString(), 0, new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0), + borderColor: ImGui.GetColorU32(ImGuiCol.Text)); } private void DrawSingleRow(Design design) @@ -55,11 +55,11 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) { using var id = ImRaii.PushId(i); var (idx, value) = design.Materials[i]; - var key = MaterialValueIndex.FromKey(idx); + var key = MaterialValueIndex.FromKey(idx); DrawName(key); ImGui.SameLine(0, _spacing); - DeleteButton(design, key, ref i); + DeleteButton(design, key, ref i); ImGui.SameLine(0, _spacing); CopyButton(value.Value); ImGui.SameLine(0, _spacing); @@ -91,7 +91,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) PasteButton(design, key); ImGui.SameLine(0, _spacing); EnabledToggle(design, key, value.Enabled); - + DrawRow(design, key, value.Value, value.Revert); ImGui.SameLine(0, _spacing); @@ -103,9 +103,9 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) private void DeleteButton(Design design, MaterialValueIndex index, ref int idx) { var deleteEnabled = _config.DeleteDesignModifier.IsActive(); - if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), _buttonSize, - $"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {_config.DeleteDesignModifier} to delete.")}", - !deleteEnabled || design.WriteProtected(), true)) + if (!ImUtf8.IconButton(FontAwesomeIcon.Trash, + $"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {_config.DeleteDesignModifier} to delete.")}", disabled: + !deleteEnabled || design.WriteProtected())) return; _designManager.ChangeMaterialValue(design, index, null); @@ -114,31 +114,29 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) private void CopyButton(in ColorRow row) { - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), _buttonSize, "Export this row to your clipboard.", - false, - true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this row to your clipboard."u8)) ColorRowClipboard.Row = row; } private void PasteButton(Design design, MaterialValueIndex index) { - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), _buttonSize, - "Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet || design.WriteProtected(), true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8, + disabled: !ColorRowClipboard.IsSet || design.WriteProtected())) _designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row); } private void EnabledToggle(Design design, MaterialValueIndex index, bool enabled) { - if (ImGui.Checkbox("Enabled", ref enabled)) + if (ImUtf8.Checkbox("Enabled"u8, ref enabled)) _designManager.ChangeApplyMaterialValue(design, index, enabled); } private void RevertToggle(Design design, MaterialValueIndex index, bool revert) { - if (ImGui.Checkbox("Revert", ref revert)) + if (ImUtf8.Checkbox("Revert"u8, ref revert)) _designManager.ChangeMaterialRevert(design, index, revert); - ImGuiUtil.HoverTooltip( - "If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."); + ImUtf8.HoverTooltip( + "If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."u8); } public void DrawNew(Design design) @@ -149,41 +147,38 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) MaterialIndex = (byte)_newMaterialIdx, RowIndex = (byte)_newRowIdx, }; - ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); + ImUtf8.SameLineInner(); DrawMaterialIdxDrag(); - ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); + ImUtf8.SameLineInner(); DrawRowIdxDrag(); - ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); + ImUtf8.SameLineInner(); var exists = design.GetMaterialDataRef().TryGetValue(_newKey, out _); - if (ImGuiUtil.DrawDisabledButton("Add New Row", Vector2.Zero, - exists ? "The selected advanced dye row already exists." : "Add the selected advanced dye row.", exists || design.WriteProtected())) + if (ImUtf8.ButtonEx("Add New Row"u8, + exists ? "The selected advanced dye row already exists."u8 : "Add the selected advanced dye row."u8, Vector2.Zero, + exists || design.WriteProtected())) _designManager.ChangeMaterialValue(design, _newKey, ColorRow.Empty); } private void DrawMaterialIdxDrag() { - _newMaterialIdx += 1; - ImGui.SetNextItemWidth(ImGui.CalcTextSize("Material #000").X); - if (ImGui.DragInt("##Material", ref _newMaterialIdx, 0.01f, 1, MaterialService.MaterialsPerModel, "Material #%i")) + ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Material AA"u8).X); + var format = $"Material {(char)('A' + _newMaterialIdx)}"; + if (ImUtf8.DragScalar("##Material"u8, ref _newMaterialIdx, format, 0, MaterialService.MaterialsPerModel - 1, 0.01f)) { - _newMaterialIdx = Math.Clamp(_newMaterialIdx, 1, MaterialService.MaterialsPerModel); - _newKey = _newKey with { MaterialIndex = (byte)(_newMaterialIdx - 1) }; + _newMaterialIdx = Math.Clamp(_newMaterialIdx, 0, MaterialService.MaterialsPerModel - 1); + _newKey = _newKey with { MaterialIndex = (byte)_newMaterialIdx }; } - - _newMaterialIdx -= 1; } private void DrawRowIdxDrag() { - _newRowIdx += 1; - ImGui.SetNextItemWidth(ImGui.CalcTextSize("Row #0000").X); - if (ImGui.DragInt("##Row", ref _newRowIdx, 0.01f, 1, ColorTable.NumRows, "Row #%i")) + ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Row 0000"u8).X); + var format = $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}"; + if (ImUtf8.DragScalar("##Row"u8, ref _newRowIdx, format, 0, ColorTable.NumRows - 1, 0.01f)) { - _newRowIdx = Math.Clamp(_newRowIdx, 1, ColorTable.NumRows); - _newKey = _newKey with { RowIndex = (byte)(_newRowIdx - 1) }; + _newRowIdx = Math.Clamp(_newRowIdx, 0, ColorTable.NumRows - 1); + _newKey = _newKey with { RowIndex = (byte)_newRowIdx }; } - - _newRowIdx -= 1; } private void DrawRow(Design design, MaterialValueIndex index, in ColorRow row, bool disabled) @@ -191,18 +186,18 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) var tmp = row; using var _ = ImRaii.Disabled(disabled); var applied = ImGuiUtil.ColorPicker("##diffuse", "Change the diffuse value for this row.", row.Diffuse, v => tmp.Diffuse = v, "D"); - ImGui.SameLine(0, _spacing); + ImUtf8.SameLineInner(); applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", row.Specular, v => tmp.Specular = v, "S"); - ImGui.SameLine(0, _spacing); + ImUtf8.SameLineInner(); applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", row.Emissive, v => tmp.Emissive = v, "E"); - ImGui.SameLine(0, _spacing); + ImUtf8.SameLineInner(); ImGui.SetNextItemWidth(GlossWidth * ImGuiHelpers.GlobalScale); applied |= AdvancedDyePopup.DragGloss(ref tmp.GlossStrength); - ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); - ImGui.SameLine(0, _spacing); + ImUtf8.HoverTooltip("Change the gloss strength for this row."u8); + ImUtf8.SameLineInner(); ImGui.SetNextItemWidth(SpecularStrengthWidth * ImGuiHelpers.GlobalScale); applied |= AdvancedDyePopup.DragSpecularStrength(ref tmp.SpecularStrength); - ImGuiUtil.HoverTooltip("Change the specular strength for this row."); + ImUtf8.HoverTooltip("Change the specular strength for this row."u8); if (applied) _designManager.ChangeMaterialValue(design, index, tmp); } diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index cb3a7e2..f1ec440 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -19,7 +19,7 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa Dawntrail, } - public static readonly ColorRow Empty = new(Vector3.Zero, Vector3.Zero, Vector3.Zero, 0, 0); + public static readonly ColorRow Empty = new(Vector3.Zero, Vector3.Zero, Vector3.Zero, 1f, 1f); public Vector3 Diffuse = diffuse; public Vector3 Specular = specular; From 3a07acbd05f7f2fdae71a1616be6160067cec1c0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 9 Aug 2024 23:50:59 +0200 Subject: [PATCH 078/401] 1.3.1.0 --- Glamourer/Gui/GlamourerChangelog.cs | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index e9173ec..cfa345f 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -34,6 +34,7 @@ public class GlamourerChangelog Add1_2_1_0(Changelog); AddDummy(Changelog); Add1_2_3_0(Changelog); + Add1_3_1_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -54,6 +55,47 @@ public class GlamourerChangelog } } + private static void Add1_3_1_0(Changelog log) + => log.NextVersion("Version 1.2.3.0") + .RegisterHighlight("Glamourer is now released for Dawntrail!") + .RegisterEntry("Added support for female Hrothgar.", 1) + .RegisterEntry("Added support for the Glasses slot.", 1) + .RegisterEntry("Added support for two dye slots.", 1) + .RegisterImportant( + "There were some issues with Advanced Dyes stored in Designs. When launching this update, Glamourer will try to migrate all your old designs into the new form.") + .RegisterEntry("Unfortunately, this is slightly based on guesswork and may cause false-positive migrations.", 1) + .RegisterEntry("In general, the values for Gloss and Specular Strength were swapped, so the migration swaps them back.", 1) + .RegisterEntry( + "In some cases this may not be correct, or the values stored were problematic to begin with and will now cause further issues.", + 1) + .RegisterImportant( + "If your designs lose their specular color, you need to verify that the Specular Strength is non-zero (usually in 0-100%).", 1) + .RegisterImportant( + "If your designs are extremely glossy and reflective, you need to verify that the Gloss value is greater than zero (usually a power of 2 >= 1, it should never be 0).", + 1) + .RegisterEntry( + "I am very sorry for the inconvenience but there is no way to salvage this sanely in all cases, especially with user-input values.", + 1) + .RegisterImportant( + "Any materials already using Dawntrails shaders will currently not be able to edit the Gloss or Specular Strength Values in Advanced Dyes.") + .RegisterImportant( + "Skin and Hair Shine from advanced customizations are not supported by the game any longer, so they are not displayed for the moment.") + .RegisterHighlight("All eyes now support Limbal rings (which use the Feature Color for their color).") + .RegisterHighlight("Dyes can now be dragged and dropped onto other dyes to replicate them.") + .RegisterEntry("The job filter in the Unlocks tab has been improved.") + .RegisterHighlight( + "Editing designs or actors now has a history and you can undo up to 16 of the last changes you made, separately per design or actor.") + .RegisterEntry( + "Some changes (like when a weapon applies its offhand) may count as multiple and have to be stepped back separately.", 1) + .RegisterEntry("You can now change the priority or enabled state of associated mods directly.") + .RegisterEntry("Glamourer now has a Support Info button akin to Penumbra's.") + .RegisterEntry("Glamourer now respects write protection on designs better.") + .RegisterEntry("The advanced dye window popup should now get focused when it is opening even in detached state.") + .RegisterHighlight("You can now display your characters height in Corgis or Olympic Swimming Pools.") + .RegisterEntry("Fixed some issues with advanced customizations and dyes applied via IPC. (1.2.3.2)") + .RegisterEntry( + "Glamourer now uses the last matching game object for advanced dyes instead of the first (mainly relevant for GPose). (1.2.3.1)"); + private static void Add1_2_3_0(Changelog log) => log.NextVersion("Version 1.2.3.0") .RegisterHighlight( From 9e0612509250c2a811ddbeb430e288b47891c4dd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 10 Aug 2024 00:57:10 +0200 Subject: [PATCH 079/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 016da3c..bf020eb 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 016da3c2219a3dbe4c2841ae0d1305ae0b2ad60f +Subproject commit bf020ebf5e4980f1814b336aabbaba5e2e00c362 From 5971592217e9f74662718a0e19014d69f05da1b8 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 10 Aug 2024 11:52:12 +0200 Subject: [PATCH 080/401] Add BonusItem API. --- Glamourer.Api | 2 +- Glamourer/Api/IpcProviders.cs | 3 +- Glamourer/Api/ItemsApi.cs | 69 +++++++++++++++++++ Glamourer/Gui/GlamourerChangelog.cs | 1 + .../Tabs/DebugTab/IpcTester/ItemsIpcTester.cs | 21 +++++- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 10 +-- Penumbra.GameData | 2 +- 7 files changed, 100 insertions(+), 8 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 4bad56d..b1b90e6 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 4bad56d610132b419335b89896e1f387b9ba2039 +Subproject commit b1b90e6ecfeee76a12cb27793753fa87af21083f diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index efbc368..8639a22 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -35,7 +35,8 @@ public sealed class IpcProviders : IDisposable, IApiService (a, b, c, d, e, f) => (int)api.Items.SetItem(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)), new FuncProvider(pi, IpcSubscribers.Legacy.SetItemName.Label, (a, b, c, d, e, f) => (int)api.Items.SetItemName(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)), - + IpcSubscribers.SetBonusItem.Provider(pi, api.Items), + IpcSubscribers.SetBonusItemName.Provider(pi, api.Items), IpcSubscribers.GetState.Provider(pi, api.State), IpcSubscribers.GetStateName.Provider(pi, api.State), IpcSubscribers.GetStateBase64.Provider(pi, api.State), diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index a2e3533..a516b68 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -57,6 +57,64 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager ApiHelpers.Lock(state, key, flags); } + if (!anyFound) + return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); + + if (!anyHuman) + return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args); + + if (!anyUnlocked) + return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); + + return ApiHelpers.Return(GlamourerApiEc.Success, args); + } + + public GlamourerApiEc SetBonusItem(int objectIndex, ApiBonusSlot slot, ulong bonusItemId, uint key, ApplyFlag flags) + { + var args = ApiHelpers.Args("Index", objectIndex, "Slot", slot, "ID", bonusItemId, "Key", key, "Flags", flags); + if (!ResolveBonusItem(slot, bonusItemId, out var item)) + return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); + + if (helpers.FindState(objectIndex) is not { } state) + return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); + + if (!state.ModelData.IsHuman) + return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args); + + if (!state.CanUnlock(key)) + return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); + + var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key); + stateManager.ChangeBonusItem(state, item.Slot, item, settings); + ApiHelpers.Lock(state, key, flags); + return GlamourerApiEc.Success; + } + + public GlamourerApiEc SetBonusItemName(string playerName, ApiBonusSlot slot, ulong bonusItemId, uint key, ApplyFlag flags) + { + var args = ApiHelpers.Args("Name", playerName, "Slot", slot, "ID", bonusItemId, "Key", key, "Flags", flags); + if (!ResolveBonusItem(slot, bonusItemId, out var item)) + return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); + + var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key); + var anyHuman = false; + var anyFound = false; + var anyUnlocked = false; + foreach (var state in helpers.FindStates(playerName)) + { + anyFound = true; + if (!state.ModelData.IsHuman) + continue; + + anyHuman = true; + if (!state.CanUnlock(key)) + continue; + + anyUnlocked = true; + stateManager.ChangeBonusItem(state, item.Slot, item, settings); + ApiHelpers.Lock(state, key, flags); + } + if (!anyFound) return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); @@ -79,4 +137,15 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager item = itemManager.Resolve(slot, id); return item.Valid; } + + private bool ResolveBonusItem(ApiBonusSlot apiSlot, ulong itemId, out BonusItem item) + { + var slot = apiSlot switch + { + ApiBonusSlot.Glasses => BonusItemFlag.Glasses, + _ => BonusItemFlag.Unknown, + }; + + return itemManager.IsBonusItemValid(slot, (BonusItemId)itemId, out item); + } } diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index cfa345f..ce0c5e0 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -91,6 +91,7 @@ public class GlamourerChangelog .RegisterEntry("Glamourer now has a Support Info button akin to Penumbra's.") .RegisterEntry("Glamourer now respects write protection on designs better.") .RegisterEntry("The advanced dye window popup should now get focused when it is opening even in detached state.") + .RegisterEntry("Added API and IPC for bonus items, i.e. the Glasses slot.") .RegisterHighlight("You can now display your characters height in Corgis or Olympic Swimming Pools.") .RegisterEntry("Fixed some issues with advanced customizations and dyes applied via IPC. (1.2.3.2)") .RegisterEntry( diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs index 5f9e748..1499fcb 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs @@ -19,7 +19,8 @@ public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiServic private ApplyFlag _flags = ApplyFlagEx.DesignDefault; private CustomItemId _customItemId; private StainId _stainId; - private EquipSlot _slot = EquipSlot.Head; + private EquipSlot _slot = EquipSlot.Head; + private BonusItemFlag _bonusSlot = BonusItemFlag.Glasses; private GlamourerApiEc _lastError; public void Draw() @@ -47,6 +48,16 @@ public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiServic if (ImGui.Button("Set##Name")) _lastError = new SetItemName(pluginInterface).Invoke(_gameObjectName, (ApiEquipSlot)_slot, _customItemId.Id, [_stainId.Id], _key, _flags); + + IpcTesterHelpers.DrawIntro(SetBonusItem.Label); + if (ImGui.Button("Set##BonusIdx")) + _lastError = new SetBonusItem(pluginInterface).Invoke(_gameObjectIndex, ToApi(_bonusSlot), _customItemId.Id, _key, + _flags); + + IpcTesterHelpers.DrawIntro(SetBonusItemName.Label); + if (ImGui.Button("Set##BonusName")) + _lastError = new SetBonusItemName(pluginInterface).Invoke(_gameObjectName, ToApi(_bonusSlot), _customItemId.Id, _key, + _flags); } private void DrawItemInput() @@ -57,6 +68,7 @@ public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiServic if (ImGuiUtil.InputUlong("Custom Item ID", ref tmp)) _customItemId = tmp; EquipSlotCombo.Draw("Equip Slot", string.Empty, ref _slot, width); + BonusSlotCombo.Draw("Bonus Slot", string.Empty, ref _bonusSlot, width); var value = (int)_stainId.Id; ImGui.SetNextItemWidth(width); if (ImGui.InputInt("Stain ID", ref value, 1, 3)) @@ -65,4 +77,11 @@ public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiServic _stainId = (StainId)value; } } + + private static ApiBonusSlot ToApi(BonusItemFlag slot) + => slot switch + { + BonusItemFlag.Glasses => ApiBonusSlot.Glasses, + _ => ApiBonusSlot.Unknown, + }; } diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index d1624f6..363cbcc 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -7,6 +7,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using ImGuiClip = OtterGui.ImGuiClip; @@ -200,11 +201,12 @@ public class UnlockOverview( using var tt = ImRaii.Tooltip(); if (size.X >= iconSize.X && size.Y >= iconSize.Y) ImGui.Image(icon, size); - ImGui.TextUnformatted(item.Name); - ImGui.TextUnformatted($"{item.Slot.ToName()}"); - ImGui.TextUnformatted($"{item.ModelId.Id}-{item.Variant.Id}"); + ImUtf8.Text(item.Name); + ImUtf8.Text($"{item.Slot.ToName()}"); + ImUtf8.Text($"{item.Id.Id}"); + ImUtf8.Text($"{item.ModelId.Id}-{item.Variant.Id}"); // TODO - ImGui.TextUnformatted("Always Unlocked"); // : $"Unlocked on {time:g}" : "Not Unlocked."); + ImUtf8.Text("Always Unlocked"); // : $"Unlocked on {time:g}" : "Not Unlocked."); // TODO //tooltip.CreateTooltip(item, string.Empty, false); } diff --git a/Penumbra.GameData b/Penumbra.GameData index bf020eb..3a65ed1 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit bf020ebf5e4980f1814b336aabbaba5e2e00c362 +Subproject commit 3a65ed1c86a2d5fd5794ff5c0559b02fc25d7224 From 6a46a410f7cdac0d6054204782e7219f7ac61359 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 10 Aug 2024 11:57:44 +0200 Subject: [PATCH 081/401] Update Penumbra API, increment API version. --- Glamourer/Api/GlamourerApi.cs | 2 +- Penumbra.Api | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index b9e21fd..24ed840 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -6,7 +6,7 @@ namespace Glamourer.Api; public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; - public const int CurrentApiVersionMinor = 2; + public const int CurrentApiVersionMinor = 3; public (int Major, int Minor) ApiVersion => (CurrentApiVersionMajor, CurrentApiVersionMinor); diff --git a/Penumbra.Api b/Penumbra.Api index 759a8e9..552246e 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 759a8e9dc50b3453cdb7c3cba76de7174c94aba0 +Subproject commit 552246e595ffab2aaba2c75f578d564f8938fc9a From 3880c1870b03d3609c617a683bfa1791d8b31fe5 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 10 Aug 2024 10:02:21 +0000 Subject: [PATCH 082/401] [CI] Updating repo.json for 1.3.1.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index cc7adf9..828a685 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.2.3.3", - "TestingAssemblyVersion": "1.3.0.11", + "AssemblyVersion": "1.3.1.0", + "TestingAssemblyVersion": "1.3.1.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 9, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.2.3.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.0.11/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 76cdacf80fb4cd05e55643863c629cc6c520146b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 10 Aug 2024 12:24:21 +0200 Subject: [PATCH 083/401] Update non-testing Dalamud API Level --- Glamourer/Gui/GlamourerChangelog.cs | 2 +- repo.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index ce0c5e0..a69a4c4 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -56,7 +56,7 @@ public class GlamourerChangelog } private static void Add1_3_1_0(Changelog log) - => log.NextVersion("Version 1.2.3.0") + => log.NextVersion("Version 1.3.1.0") .RegisterHighlight("Glamourer is now released for Dawntrail!") .RegisterEntry("Added support for female Hrothgar.", 1) .RegisterEntry("Added support for the Glasses slot.", 1) diff --git a/repo.json b/repo.json index 828a685..a065ebc 100644 --- a/repo.json +++ b/repo.json @@ -21,7 +21,7 @@ "TestingAssemblyVersion": "1.3.1.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 9, + "DalamudApiLevel": 10, "TestingDalamudApiLevel": 10, "IsHide": "False", "IsTestingExclusive": "False", From 38a489d7f08a7c5e56c5b309a7aae41b3f9efdc1 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 10 Aug 2024 10:27:38 +0000 Subject: [PATCH 084/401] [CI] Updating repo.json for 1.3.1.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index a065ebc..5be3916 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.1.0", - "TestingAssemblyVersion": "1.3.1.0", + "AssemblyVersion": "1.3.1.1", + "TestingAssemblyVersion": "1.3.1.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From a7c5d513d4438a7d6024c35d7f9d917e01c9602d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 13 Aug 2024 15:27:32 +0200 Subject: [PATCH 085/401] Maybe fix weapon hidden state when leaving gpose or changing zones. --- Glamourer/Interop/MetaService.cs | 2 ++ Glamourer/Interop/ScalingService.cs | 2 +- Glamourer/State/StateApplier.cs | 9 +++++++-- Glamourer/State/StateEditor.cs | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/MetaService.cs b/Glamourer/Interop/MetaService.cs index 1dc4c1a..1c79cec 100644 --- a/Glamourer/Interop/MetaService.cs +++ b/Glamourer/Interop/MetaService.cs @@ -61,7 +61,9 @@ public unsafe class MetaService : IDisposable if (!actor.IsCharacter) return; + var old = actor.AsCharacter->DrawData.IsWeaponHidden; _hideWeaponsHook.Original(&actor.AsCharacter->DrawData, (byte)(value ? 0 : 1)); + actor.AsCharacter->DrawData.IsWeaponHidden = old; } private void HideHatDetour(DrawDataContainer* drawData, uint id, byte value) diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index 16b9a37..c2eb32f 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -59,7 +59,7 @@ public unsafe class ScalingService : IDisposable private void SetupOrnamentDetour(Ornament* ornament, uint* unk1, float* unk2) { - var character = ornament->Character.GetParentCharacter(); + var character = ornament->GetParentCharacter(); if (character == null) { _setupOrnamentHook.Original(ornament, unk1, unk2); diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index d6d5bde..ed6f907 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -247,8 +247,13 @@ public class StateApplier( } case MetaIndex.WeaponState: { - foreach (var actor in data.Objects.Where(a => a.IsCharacter)) - _metaService.SetWeaponState(actor, value); + // Only apply to the GPose character because otherwise we get some weird incompatibility when leaving GPose. + if (_objects.IsInGPose) + foreach (var actor in data.Objects.Where(a => a.IsGPoseOrCutscene)) + _metaService.SetWeaponState(actor, value); + else + foreach (var actor in data.Objects.Where(a => a.IsCharacter)) + _metaService.SetWeaponState(actor, value); return; } case MetaIndex.VisorState: diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 50479b2..c7867e1 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -251,7 +251,7 @@ public class StateEditor( var actors = Applier.ChangeMetaState(state, index, settings.Source.RequiresChange()); Glamourer.Log.Verbose( - $"Set Head Gear Visibility in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); + $"Set {index.ToName()} in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Other, settings.Source, state, actors, new MetaTransaction(index, old, value)); } From fc6604fd5a6765cca0ee128e6e1223d9b84f2136 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 15 Aug 2024 15:58:04 +0200 Subject: [PATCH 086/401] Remove Artisan code. --- .../Gui/Customization/CustomizationDrawer.cs | 31 ----- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 118 +----------------- Glamourer/Services/CodeService.cs | 5 +- 3 files changed, 2 insertions(+), 152 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index a7fcda7..6b6cc0a 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -1,7 +1,5 @@ using Dalamud.Interface.Textures; using Dalamud.Interface.Textures.TextureWraps; -using Dalamud.Interface.Utility; -using Dalamud.Plugin; using Dalamud.Plugin.Services; using Glamourer.GameData; using Glamourer.Services; @@ -17,7 +15,6 @@ namespace Glamourer.Gui.Customization; public partial class CustomizationDrawer( ITextureProvider textures, CustomizeService _service, - CodeService _codes, Configuration _config, FavoriteManager _favorites, HeightService _heightService) @@ -119,9 +116,6 @@ public partial class CustomizationDrawer( try { - if (_codes.Enabled(CodeService.CodeFlag.Artisan)) - return DrawArtisan(); - DrawRaceGenderSelector(); DrawBodyType(); @@ -156,31 +150,6 @@ public partial class CustomizationDrawer( } } - private unsafe bool DrawArtisan() - { - for (var i = 0; i < CustomizeArray.Size; ++i) - { - using var id = ImRaii.PushId(i); - int value = _customize.Data[i]; - ImGui.SetNextItemWidth(40 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt(string.Empty, ref value, 0, 0)) - { - var newValue = (byte)Math.Clamp(value, 0, byte.MaxValue); - if (newValue != _customize.Data[i]) - foreach (var flag in Enum.GetValues()) - { - var (j, _) = flag.ToByteAndMask(); - if (j == i) - Changed |= flag.ToFlag(); - } - - _customize.Data[i] = newValue; - } - } - - return Changed != 0; - } - private void UpdateSizes() { _spacing = ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemInnerSpacing.X }; diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 83c560d..0844626 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -27,7 +27,6 @@ public class EquipmentDrawer private readonly ItemCombo[] _itemCombo; private readonly BonusItemCombo[] _bonusItemCombo; private readonly Dictionary _weaponCombo; - private readonly CodeService _codes; private readonly TextureService _textures; private readonly Configuration _config; private readonly GPoseService _gPose; @@ -38,11 +37,10 @@ public class EquipmentDrawer private Stain? _draggedStain; - public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, CodeService codes, TextureService textures, + public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, TextureService textures, Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes) { _items = items; - _codes = codes; _textures = textures; _config = config; _gPose = gPose; @@ -99,8 +97,6 @@ public class EquipmentDrawer if (_config.SmallEquip) DrawEquipSmall(equipDrawData); - else if (!equipDrawData.Locked && _codes.Enabled(CodeService.CodeFlag.Artisan)) - DrawEquipArtisan(equipDrawData); else DrawEquipNormal(equipDrawData); } @@ -137,8 +133,6 @@ public class EquipmentDrawer if (_config.SmallEquip) DrawWeaponsSmall(mainhand, offhand, allWeapons); - else if (!mainhand.Locked && _codes.Enabled(CodeService.CodeFlag.Artisan)) - DrawWeaponsArtisan(mainhand, offhand); else DrawWeaponsNormal(mainhand, offhand, allWeapons); } @@ -186,116 +180,6 @@ public class EquipmentDrawer return change; } - #region Artisan - - private void DrawEquipArtisan(EquipDrawData data) - { - DrawStainArtisan(data); - ImGui.SameLine(); - DrawArmorArtisan(data); - if (!data.DisplayApplication) - return; - - ImGui.SameLine(); - DrawApply(data); - ImGui.SameLine(); - DrawApplyStain(data); - } - - private void DrawWeaponsArtisan(in EquipDrawData mainhand, in EquipDrawData offhand) - { - using (var _ = ImRaii.PushId(0)) - { - DrawStainArtisan(mainhand); - ImGui.SameLine(); - DrawWeapon(mainhand); - } - - using (var _ = ImRaii.PushId(1)) - { - DrawStainArtisan(offhand); - ImGui.SameLine(); - DrawWeapon(offhand); - } - - return; - - void DrawWeapon(in EquipDrawData current) - { - int setId = current.CurrentItem.PrimaryId.Id; - int type = current.CurrentItem.SecondaryId.Id; - int variant = current.CurrentItem.Variant.Id; - ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt("##setId", ref setId, 0, 0)) - { - var newSetId = (PrimaryId)Math.Clamp(setId, 0, ushort.MaxValue); - if (newSetId.Id != current.CurrentItem.PrimaryId.Id) - current.SetItem(_items.Identify(current.Slot, newSetId, current.CurrentItem.SecondaryId, current.CurrentItem.Variant)); - } - - ImGui.SameLine(); - ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt("##type", ref type, 0, 0)) - { - var newType = (SecondaryId)Math.Clamp(type, 0, ushort.MaxValue); - if (newType.Id != current.CurrentItem.SecondaryId.Id) - current.SetItem(_items.Identify(current.Slot, current.CurrentItem.PrimaryId, newType, current.CurrentItem.Variant)); - } - - ImGui.SameLine(); - ImGui.SetNextItemWidth(40 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt("##variant", ref variant, 0, 0)) - { - var newVariant = (Variant)Math.Clamp(variant, 0, byte.MaxValue); - if (newVariant.Id != current.CurrentItem.Variant.Id) - current.SetItem(_items.Identify(current.Slot, current.CurrentItem.PrimaryId, current.CurrentItem.SecondaryId, - newVariant)); - } - } - } - - /// Draw an input for stain that can set arbitrary values instead of choosing valid stains. - private static void DrawStainArtisan(EquipDrawData data) - { - foreach (var (stain, index) in data.CurrentStains.WithIndex()) - { - using var id = ImUtf8.PushId(index); - int stainId = stain.Id; - ImGui.SetNextItemWidth(40 * ImGuiHelpers.GlobalScale); - if (!ImGui.InputInt("##stain", ref stainId, 0, 0)) - return; - - var newStainId = (StainId)Math.Clamp(stainId, 0, byte.MaxValue); - if (newStainId != stain.Id) - data.SetStains(data.CurrentStains.With(index, newStainId)); - } - } - - /// Draw an input for armor that can set arbitrary values instead of choosing items. - private void DrawArmorArtisan(EquipDrawData data) - { - int setId = data.CurrentItem.PrimaryId.Id; - int variant = data.CurrentItem.Variant.Id; - ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt("##setId", ref setId, 0, 0)) - { - var newSetId = (PrimaryId)Math.Clamp(setId, 0, ushort.MaxValue); - if (newSetId.Id != data.CurrentItem.PrimaryId.Id) - data.SetItem(_items.Identify(data.Slot, newSetId, data.CurrentItem.Variant)); - } - - ImGui.SameLine(); - ImGui.SetNextItemWidth(40 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt("##variant", ref variant, 0, 0)) - { - var newVariant = (byte)Math.Clamp(variant, 0, byte.MaxValue); - if (newVariant != data.CurrentItem.Variant) - data.SetItem(_items.Identify(data.Slot, data.CurrentItem.PrimaryId, newVariant)); - } - } - - #endregion - #region Small private void DrawEquipSmall(in EquipDrawData equipDrawData) diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index 73d27b4..af2e88b 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -23,7 +23,7 @@ public class CodeService OopsAuRa = 0x000400, OopsHrothgar = 0x000800, OopsViera = 0x001000, - Artisan = 0x002000, + //Artisan = 0x002000, SixtyThree = 0x004000, Shirts = 0x008000, World = 0x010000, @@ -182,7 +182,6 @@ public class CodeService CodeFlag.OopsAuRa => (FullCodes | RaceCodes) & ~CodeFlag.OopsAuRa, CodeFlag.OopsHrothgar => (FullCodes | RaceCodes) & ~CodeFlag.OopsHrothgar, CodeFlag.OopsViera => (FullCodes | RaceCodes) & ~CodeFlag.OopsViera, - CodeFlag.Artisan => 0, CodeFlag.SixtyThree => FullCodes, CodeFlag.Shirts => 0, CodeFlag.World => (FullCodes | DyeCodes | GearCodes) & ~CodeFlag.World, @@ -211,7 +210,6 @@ public class CodeService CodeFlag.OopsAuRa => [ 0x69, 0x93, 0xAF, 0xE4, 0xB8, 0xEC, 0x5F, 0x40, 0xEB, 0x8A, 0x6F, 0xD1, 0x9B, 0xD9, 0x56, 0x0B, 0xEA, 0x64, 0x79, 0x9B, 0x54, 0xA1, 0x41, 0xED, 0xBC, 0x3E, 0x6E, 0x5C, 0xF1, 0x23, 0x60, 0xF8 ], CodeFlag.OopsHrothgar => [ 0x41, 0xEC, 0x65, 0x05, 0x8D, 0x20, 0x68, 0x5A, 0xB7, 0xEB, 0x92, 0x15, 0x43, 0xCF, 0x15, 0x05, 0x27, 0x51, 0xFE, 0x20, 0xC9, 0xB6, 0x2B, 0x84, 0xD9, 0x6A, 0x49, 0x5A, 0x5B, 0x7F, 0x2E, 0xE7 ], CodeFlag.OopsViera => [ 0x16, 0xFF, 0x63, 0x85, 0x1C, 0xF5, 0x34, 0x33, 0x67, 0x8C, 0x46, 0x8E, 0x3E, 0xE3, 0xA6, 0x94, 0xF9, 0x74, 0x47, 0xAA, 0xC7, 0x29, 0x59, 0x1F, 0x6C, 0x6E, 0xF2, 0xF5, 0x87, 0x24, 0x9E, 0x2B ], - CodeFlag.Artisan => [ 0xDE, 0x01, 0x32, 0x1E, 0x7F, 0x22, 0x80, 0x3D, 0x76, 0xDF, 0x74, 0x0E, 0xEC, 0x33, 0xD3, 0xF4, 0x1A, 0x98, 0x9E, 0x9D, 0x22, 0x5C, 0xAC, 0x3B, 0xFE, 0x0B, 0xC2, 0x13, 0xB9, 0x91, 0x24, 0x61 ], CodeFlag.SixtyThree => [ 0xA1, 0x65, 0x60, 0x99, 0xB0, 0x9F, 0xBF, 0xD7, 0x20, 0xC8, 0x29, 0xF6, 0x7B, 0x86, 0x27, 0xF5, 0xBE, 0xA9, 0x5B, 0xB0, 0x20, 0x5E, 0x57, 0x7B, 0xFF, 0xBC, 0x1E, 0x8C, 0x04, 0xF9, 0x35, 0xD3 ], CodeFlag.Shirts => [ 0xD1, 0x35, 0xD7, 0x18, 0xBE, 0x45, 0x42, 0xBD, 0x88, 0x77, 0x7E, 0xC4, 0x41, 0x06, 0x34, 0x4D, 0x71, 0x3A, 0xC5, 0xCC, 0xA4, 0x1B, 0x7D, 0x3F, 0x3B, 0x86, 0x07, 0xCB, 0x63, 0xD7, 0xF9, 0xDB ], CodeFlag.World => [ 0xFD, 0xA2, 0xD2, 0xBC, 0xD9, 0x8A, 0x7E, 0x2B, 0x52, 0xCB, 0x57, 0x6E, 0x3A, 0x2E, 0x30, 0xBA, 0x4E, 0xAE, 0x42, 0xEA, 0x5C, 0x57, 0xDF, 0x17, 0x37, 0x3C, 0xCE, 0x17, 0x42, 0x43, 0xAE, 0xD0 ], @@ -246,7 +244,6 @@ public class CodeService CodeFlag.Elephants => (true, 1, "!", "Appropriate lyrics that can also be found in Glamourer's changelogs.", "Sets every player to the elephant costume in varying shades of pink."), CodeFlag.Crown => (true, 1, ".", "A famous Shakespearean line.", "Sets every player with a mentor symbol enabled to the clown's hat."), CodeFlag.Dolphins => (true, 5, ",", "The farewell of the second smartest species on Earth.", "Sets every player to a Namazu hat with different costume bodies."), - CodeFlag.Artisan => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), CodeFlag.Face => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), CodeFlag.Manderville => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), CodeFlag.Smiles => (false, 3, ",,!", string.Empty, "Enable a debugging mode for the UI. Not really useful."), From 773f526fba3e94008e393539ac910c85005ffcdc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 15 Aug 2024 17:23:51 +0200 Subject: [PATCH 087/401] Improve handling for bonus items in designs. --- Glamourer/Designs/DesignBase.cs | 9 +++-- Glamourer/Designs/DesignData.cs | 2 +- Glamourer/Designs/DesignEditor.cs | 2 +- Glamourer/Gui/Materials/MaterialDrawer.cs | 2 ++ Glamourer/Services/ItemManager.cs | 40 ++++++++++++++++++++--- Penumbra.GameData | 2 +- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 06e55d7..5c4996a 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -280,7 +280,7 @@ public class DesignBase var item = _designData.BonusItem(slot); ret[slot.ToString()] = new JObject() { - ["BonusId"] = item.Id.Id, + ["BonusId"] = item.CustomId.Id, ["Apply"] = DoApplyBonusItem(slot), }; } @@ -431,7 +431,7 @@ public class DesignBase protected static void LoadBonus(ItemManager items, DesignBase design, JToken? json) { - if (json is not JObject obj) + if (json is not JObject) { design.Application.BonusItem = 0; return; @@ -439,8 +439,7 @@ public class DesignBase foreach (var slot in BonusExtensions.AllFlags) { - var itemJson = json[slot.ToString()] as JObject; - if (itemJson == null) + if (json[slot.ToString()] is not JObject itemJson) { design.Application.BonusItem &= ~slot; design.GetDesignDataRef().SetBonusItem(slot, BonusItem.Empty(slot)); @@ -448,7 +447,7 @@ public class DesignBase } design.SetApplyBonusItem(slot, itemJson["Apply"]?.ToObject() ?? false); - var id = itemJson["BonusId"]?.ToObject() ?? 0; + var id = itemJson["BonusId"]?.ToObject() ?? 0; var item = items.Resolve(slot, id); design.GetDesignDataRef().SetBonusItem(slot, item); } diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index 0a52861..28944b9 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -112,7 +112,7 @@ public unsafe struct DesignData => slot switch { // @formatter:off - BonusItemFlag.Glasses => new BonusItem(_nameGlasses, _iconIds[12], _bonusIds[0], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses), + BonusItemFlag.Glasses => Penumbra.GameData.Structs.BonusItem.FromIds(_bonusIds[0], _iconIds[12], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses, _nameGlasses), _ => Penumbra.GameData.Structs.BonusItem.Empty(slot), // @formatter:on }; diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index 5328f03..a3e86a5 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -175,7 +175,7 @@ public class DesignEditor( public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) { var design = (Design)data; - if (!Items.IsBonusItemValid(slot, item.Id, out item)) + if (item.Slot != slot) return; var oldItem = design.DesignData.BonusItem(slot); diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index dec1aae..1b5e65a 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -139,6 +139,8 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) "If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."u8); } + public sealed class MaterialSlotCombo; + public void DrawNew(Design design) { if (EquipSlotCombo.Draw("##slot", "Choose a slot for an advanced dye row.", ref _newSlot)) diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 7b83199..8cfd387 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -132,16 +132,48 @@ public class ItemManager if (index == uint.MaxValue) return new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot); - if (id.Id == 0) - return BonusItem.Empty(slot); + var item = ObjectIdentification.Identify(id, variant, slot) + .FirstOrDefault(BonusItem.FromIds(BonusItemId.Invalid, 0, id, variant, slot)); + if (item.Id != BonusItemId.Invalid) + return item; - return ObjectIdentification.Identify(id, variant, slot) - .FirstOrDefault(new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot)); + if (slot is BonusItemFlag.Glasses) + { + var headItem = ObjectIdentification.Identify(id, 0, variant, EquipSlot.Head).FirstOrDefault(); + if (headItem.Valid) + return BonusItem.FromIds(BonusItemId.Invalid, headItem.IconId, id, variant, slot, $"{headItem.Name} ({EquipSlot.Head.ToName()}: {id}-{variant})"); + } + + return item; } public BonusItem Resolve(BonusItemFlag slot, BonusItemId id) => IsBonusItemValid(slot, id, out var item) ? item : new BonusItem($"Invalid ({id.Id})", 0, id, 0, 0, slot); + public BonusItem Resolve(BonusItemFlag slot, CustomItemId id) + { + // Only from early designs as migration. + if (!id.IsBonusItem) + { + IsBonusItemValid(slot, (BonusItemId)id.Id, out var item); + return item; + } + + if (!id.IsCustom) + { + if (IsBonusItemValid(slot, id.BonusItem, out var item)) + return item; + + return BonusItem.Empty(slot); + } + + var (model, variant, slot2) = id.SplitBonus; + if (slot != slot2) + return BonusItem.Empty(slot); + + return Identify(slot, model, variant); + } + /// Return the default offhand for a given mainhand, that is for both handed weapons, return the correct offhand part, and for everything else Nothing. public EquipItem GetDefaultOffhand(EquipItem mainhand) { diff --git a/Penumbra.GameData b/Penumbra.GameData index 3a65ed1..d9d4b28 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 3a65ed1c86a2d5fd5794ff5c0559b02fc25d7224 +Subproject commit d9d4b286d54ad4027a1e8a2bbf900ee79aefaa93 From 82536c75c9ca47722510ed0bd33c9c8a138f0f91 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 24 Aug 2024 20:40:02 +0200 Subject: [PATCH 088/401] Fix fun module RNG. --- Glamourer/State/FunModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index 5d436c0..de39a53 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -340,14 +340,14 @@ public unsafe class FunModule : IDisposable private void SetRandomDye(ref CharacterArmor armor) { - var stainIdx = _rng.Next(0, _stains.Length - 1); + var stainIdx = _rng.Next(0, _stains.Length); armor.Stains = _stains[stainIdx]; } private void SetRandomItem(EquipSlot slot, ref CharacterArmor armor) { var list = _items.ItemData.ByType[slot.ToEquipType()]; - var rng = _rng.Next(0, list.Count - 1); + var rng = _rng.Next(0, list.Count); var item = list[rng]; armor.Set = item.PrimaryId; armor.Variant = item.Variant; @@ -385,7 +385,7 @@ public unsafe class FunModule : IDisposable { armor = slot switch { - EquipSlot.Body => DolphinBodies[_rng.Next(0, DolphinBodies.Count - 1)], + EquipSlot.Body => DolphinBodies[_rng.Next(0, DolphinBodies.Count)], EquipSlot.Head => new CharacterArmor(5040, 1, StainIds.None), _ => armor, }; @@ -440,7 +440,7 @@ public unsafe class FunModule : IDisposable if (index is CustomizeIndex.Face || !set.IsAvailable(index)) continue; - var valueIdx = _rng.Next(0, set.Count(index) - 1); + var valueIdx = _rng.Next(0, set.Count(index)); customize[index] = set.Data(index, valueIdx).Value; } } From 03043ba2c96791f2febf59ceed82fd487b7296a9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 24 Aug 2024 20:40:26 +0200 Subject: [PATCH 089/401] Fix reversion. --- Glamourer/State/StateManager.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 5033577..24b025f 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -311,7 +311,8 @@ public sealed class StateManager( foreach (var flag in CustomizationExtensions.All) state.Sources[flag] = StateSource.Game; - state.ModelData = state.BaseData; + state.ModelData.ModelId = state.BaseData.ModelId; + state.ModelData.Customize = state.BaseData.Customize; var actors = ActorData.Invalid; if (source is not StateSource.Game) actors = Applier.ChangeCustomize(state, true); @@ -335,6 +336,13 @@ public sealed class StateManager( } } + foreach (var slot in BonusExtensions.AllFlags) + { + state.Sources[slot] = StateSource.Game; + if (source is not StateSource.Game) + state.ModelData.SetBonusItem(slot, state.BaseData.BonusItem(slot)); + } + var actors = ActorData.Invalid; if (source is not StateSource.Game) { From 9a02ba298724c68766b4a3fae4afeb00d8a072cd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 31 Aug 2024 20:51:38 +0200 Subject: [PATCH 090/401] Add support for previewing non-existing items from Penumbra. --- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 28 +++++++++++++++++-- Glamourer/Interop/Penumbra/PenumbraService.cs | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index c74d6a3..c6f2fc4 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -1,4 +1,4 @@ -using Glamourer.Designs; +using Glamourer.Designs; using Glamourer.Events; using Glamourer.Interop; using Glamourer.Interop.Penumbra; @@ -168,12 +168,23 @@ public sealed class PenumbraChangedItemTooltip : IDisposable { case ChangedItemType.ItemOffhand: case ChangedItemType.Item: + { if (!_items.ItemData.TryGetValue(id, type is ChangedItemType.Item ? EquipSlot.MainHand : EquipSlot.OffHand, out var item)) return; CreateTooltip(item, "[Glamourer] ", false); return; + } + case ChangedItemType.CustomArmor: + { + var (model, variant, slot) = IdentifiedItem.Split(id); + var item = _items.Identify(slot.ToSlot(), model, variant); + if (item.Valid) + CreateTooltip(item, "[Glamourer] ", false); + return; + } case ChangedItemType.Customization: + { var (race, gender, index, value) = IdentifiedCustomization.Split(id); if (!_objects.Player.Model.IsHuman) return; @@ -183,6 +194,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable ImGui.TextUnformatted("[Glamourer] Right-Click to apply to current actor."); return; + } } } @@ -212,17 +224,29 @@ public sealed class PenumbraChangedItemTooltip : IDisposable { case ChangedItemType.Item: case ChangedItemType.ItemOffhand: + { if (!_items.ItemData.TryGetValue(id, type is ChangedItemType.Item ? EquipSlot.MainHand : EquipSlot.OffHand, out var item)) return; ApplyItem(state, item); return; + } + case ChangedItemType.CustomArmor: + { + var (model, variant, slot) = IdentifiedItem.Split(id); + var item = _items.Identify(slot.ToSlot(), model, variant); + if (item.Valid) + ApplyItem(state, item); + return; + } case ChangedItemType.Customization: + { var (race, gender, index, value) = IdentifiedCustomization.Split(id); var customize = state.ModelData.Customize; if (CheckGenderRace(customize, race, gender) && VerifyValue(customize, index, value)) _stateManager.ChangeCustomize(state, index, value, ApplySettings.Manual); return; + } } } @@ -236,7 +260,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable else { var oldItem = state.ModelData.Item(slot); - if (oldItem.ItemId != item.ItemId) + if (oldItem.Id != item.Id) _lastItems[slot.ToIndex()] = oldItem; } } diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 85235e7..4f6c44a 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -31,7 +31,7 @@ public readonly record struct ModSettings(Dictionary> Setti => new(); } -public unsafe class PenumbraService : IDisposable +public class PenumbraService : IDisposable { public const int RequiredPenumbraBreakingVersion = 5; public const int RequiredPenumbraFeatureVersion = 0; diff --git a/Penumbra.Api b/Penumbra.Api index 552246e..97e9f42 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 552246e595ffab2aaba2c75f578d564f8938fc9a +Subproject commit 97e9f427406f82a59ddef764b44ecea654a51623 diff --git a/Penumbra.GameData b/Penumbra.GameData index d9d4b28..66bc00d 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit d9d4b286d54ad4027a1e8a2bbf900ee79aefaa93 +Subproject commit 66bc00dc8517204e58c6515af5aec0ba6d196716 From f473abb99c9e721812d82ebdc7780d53602e68e8 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Sep 2024 22:53:35 +0200 Subject: [PATCH 091/401] Fix chat log context menu try-on. --- Glamourer/Interop/ContextMenuService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Interop/ContextMenuService.cs b/Glamourer/Interop/ContextMenuService.cs index 19a805f..eeee70a 100644 --- a/Glamourer/Interop/ContextMenuService.cs +++ b/Glamourer/Interop/ContextMenuService.cs @@ -12,7 +12,7 @@ namespace Glamourer.Interop; public class ContextMenuService : IDisposable { public const int ItemSearchContextItemId = 0x1738; - public const int ChatLogContextItemId = 0x948; + public const int ChatLogContextItemId = 0x950; private readonly ItemManager _items; private readonly IContextMenu _contextMenu; From 1f1b04bdfe21a3aea9090d0d95f057e3d5bd4582 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Sep 2024 23:34:29 +0200 Subject: [PATCH 092/401] Update actions. --- .github/workflows/release.yml | 2 +- .github/workflows/test_release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 821f20b..e22a656 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: - name: Archive run: Compress-Archive -Path Glamourer/bin/Release/* -DestinationPath Glamourer.zip - name: Upload a Build Artifact - uses: actions/upload-artifact@v2.2.1 + uses: actions/upload-artifact@v4 with: path: | ./Glamourer/bin/Release/* diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml index 4435e39..b9d3672 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -37,7 +37,7 @@ jobs: - name: Archive run: Compress-Archive -Path Glamourer/bin/Debug/* -DestinationPath Glamourer.zip - name: Upload a Build Artifact - uses: actions/upload-artifact@v2.2.1 + uses: actions/upload-artifact@v4 with: path: | ./Glamourer/bin/Debug/* From be9c3eab4015015ec23970f2ff46c80e06ea9ec0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 21 Sep 2024 21:17:24 +0200 Subject: [PATCH 093/401] Add bonus item import from .chara files, fix small bugs when applying designs. --- Glamourer/Designs/DesignBase.cs | 13 +++++---- Glamourer/Designs/DesignEditor.cs | 6 ++++ Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 1 - Glamourer/Interop/CharaFile/CharaFile.cs | 31 +++++++++++++++++++++ Glamourer/Interop/ImportService.cs | 4 +-- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 5c4996a..a8e9986 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -40,13 +40,14 @@ public class DesignBase } /// Used when importing .cma or .chara files. - internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags) + internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags, BonusItemFlag bonusFlags) { - _designData = designData; - ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant; - Application.Equip = equipFlags & EquipFlagExtensions.All; - Application.Meta = 0; - CustomizeSet = SetCustomizationSet(customize); + _designData = designData; + ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant; + Application.Equip = equipFlags & EquipFlagExtensions.All; + Application.BonusItem = bonusFlags & BonusExtensions.All; + Application.Meta = 0; + CustomizeSet = SetCustomizationSet(customize); } internal DesignBase(DesignBase clone) diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index a3e86a5..a42971e 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -330,6 +330,12 @@ public class DesignEditor( _forceFullItemOff = false; + foreach (var slot in BonusExtensions.AllFlags) + { + if (other.DoApplyBonusItem(slot)) + ChangeBonusItem(design, slot, other.DesignData.BonusItem(slot)); + } + foreach (var slot in Enum.GetValues().Where(other.DoApplyCrest)) ChangeCrest(design, slot, other.DesignData.Crest(slot)); diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index e11a032..5fb2d57 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -9,7 +9,6 @@ using Glamourer.GameData; using Glamourer.Gui.Customization; using Glamourer.Gui.Equipment; using Glamourer.Gui.Materials; -using Glamourer.Gui.Tabs.ActorTab; using Glamourer.Interop; using Glamourer.State; using ImGuiNET; diff --git a/Glamourer/Interop/CharaFile/CharaFile.cs b/Glamourer/Interop/CharaFile/CharaFile.cs index 4bf08cd..f956379 100644 --- a/Glamourer/Interop/CharaFile/CharaFile.cs +++ b/Glamourer/Interop/CharaFile/CharaFile.cs @@ -13,6 +13,7 @@ public sealed class CharaFile public DesignData Data = new(); public CustomizeFlag ApplyCustomize; public EquipFlag ApplyEquip; + public BonusItemFlag ApplyBonus; public static CharaFile ParseData(ItemManager items, string data, string? name = null) { @@ -24,6 +25,7 @@ public sealed class CharaFile ret.Name = jObj["Nickname"]?.ToObject() ?? name ?? "New Design"; ret.ApplyCustomize = ParseCustomize(jObj, ref ret.Data.Customize); ret.ApplyEquip = ParseEquipment(items, jObj, ref ret.Data); + ret.ApplyBonus = ParseBonusItems(items, jObj, ref ret.Data); return ret; } @@ -45,6 +47,13 @@ public sealed class CharaFile return ret; } + private static BonusItemFlag ParseBonusItems(ItemManager items, JObject jObj, ref DesignData data) + { + BonusItemFlag ret = 0; + ParseBonus(items, jObj, "Glasses", "GlassesId", BonusItemFlag.Glasses, ref data, ref ret); + return ret; + } + private static void ParseWeapon(ItemManager items, JObject jObj, string property, EquipSlot slot, ref DesignData data, ref EquipFlag flags) { var jTok = jObj[property]; @@ -61,6 +70,8 @@ public sealed class CharaFile data.SetItem(slot, item); data.SetStain(slot, new StainIds(dye)); + if (slot is EquipSlot.MainHand) + data.SetItem(EquipSlot.OffHand, items.GetDefaultOffhand(item)); flags |= slot.ToFlag(); flags |= slot.ToStainFlag(); } @@ -84,6 +95,26 @@ public sealed class CharaFile flags |= slot.ToStainFlag(); } + private static void ParseBonus(ItemManager items, JObject jObj, string property, string subProperty, BonusItemFlag slot, + ref DesignData data, ref BonusItemFlag flags) + { + var id = jObj[property]?[subProperty]?.ToObject(); + if (id is null) + return; + + if (id is 0) + { + data.SetBonusItem(slot, BonusItem.Empty(slot)); + flags |= slot; + } + + if (!items.DictBonusItems.TryGetValue((BonusItemId)id.Value, out var item) || item.Slot != slot) + return; + + data.SetBonusItem(slot, item); + flags |= slot; + } + private static CustomizeFlag ParseCustomize(JObject jObj, ref CustomizeArray customize) { CustomizeFlag ret = 0; diff --git a/Glamourer/Interop/ImportService.cs b/Glamourer/Interop/ImportService.cs index 7dc3313..b9dfbe1 100644 --- a/Glamourer/Interop/ImportService.cs +++ b/Glamourer/Interop/ImportService.cs @@ -65,7 +65,7 @@ public class ImportService(CustomizeService _customizations, IDragDropManager _d var file = CharaFile.CharaFile.ParseData(_items, text, Path.GetFileNameWithoutExtension(path)); name = file.Name; - design = new DesignBase(_customizations, file.Data, file.ApplyEquip, file.ApplyCustomize); + design = new DesignBase(_customizations, file.Data, file.ApplyEquip, file.ApplyCustomize, file.ApplyBonus); } catch (Exception ex) { @@ -95,7 +95,7 @@ public class ImportService(CustomizeService _customizations, IDragDropManager _d throw new Exception(); name = file.Name; - design = new DesignBase(_customizations, file.Data, EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant); + design = new DesignBase(_customizations, file.Data, EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, 0); } catch (Exception ex) { From c8cc375d4b56911976110b4f8e9fd3613f1337e8 Mon Sep 17 00:00:00 2001 From: Ottermandias <70807659+Ottermandias@users.noreply.github.com> Date: Sat, 5 Oct 2024 02:15:23 +0200 Subject: [PATCH 094/401] Update WorldSets.cs --- Glamourer/State/WorldSets.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Glamourer/State/WorldSets.cs b/Glamourer/State/WorldSets.cs index 314934b..958a2ed 100644 --- a/Glamourer/State/WorldSets.cs +++ b/Glamourer/State/WorldSets.cs @@ -117,7 +117,7 @@ public class WorldSets (FunEquipSet.Group.FullSet(204, 4), CharacterWeapon.Int(2601, 13, 1), CharacterWeapon.Int(2651, 13, 1)), // DNC, Softstepper, High Steel Chakrams (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 13, 1), CharacterWeapon.Empty), // RPR, Muzhik, Deepgold War Scythe (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 08, 1), CharacterWeapon.Empty), // SGE, Bookwyrm, Stonegold Milpreves - (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 262, 8), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 02, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; @@ -164,7 +164,7 @@ public class WorldSets (FunEquipSet.Group.FullSet(204, 4), CharacterWeapon.Int(2601, 13, 1), CharacterWeapon.Int(2651, 13, 01)), // DNC, Softstepper, High Steel Chakrams (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 13, 1), CharacterWeapon.Empty), // RPR, Muzhik, Deepgold War Scythe (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 08, 1), CharacterWeapon.Empty), // SGE, Bookwyrm, Stonegold Milpreves - (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 262, 8), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 02, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; @@ -211,7 +211,7 @@ public class WorldSets (FunEquipSet.Group.FullSet(204, 4), CharacterWeapon.Int(2601, 13, 1), CharacterWeapon.Int(2651, 13, 01)), // DNC, Softstepper, High Steel Chakrams (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 13, 1), CharacterWeapon.Empty), // RPR, Muzhik, Deepgold War Scythe (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 08, 1), CharacterWeapon.Empty), // SGE, Bookwyrm, Stonegold Milpreves - (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 262, 8), CharacterWeapon.Int(3101, 06, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 02, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; @@ -258,7 +258,7 @@ public class WorldSets (FunEquipSet.Group.FullSet(543, 1), CharacterWeapon.Int(2601, 001, 1), CharacterWeapon.Int(2651, 01, 001)), // DNC, Dancer, Krishna (new FunEquipSet.Group(206, 7, 303, 3, 23, 109, 303, 3, 262, 7), CharacterWeapon.Int(2802, 013, 1), CharacterWeapon.Empty), // RPR, Harvester's, Demon Slicer (new FunEquipSet.Group(20, 46, 289, 6, 342, 3, 120, 9, 342, 3), CharacterWeapon.Int(2702, 008, 1), CharacterWeapon.Empty), // SGE, Therapeute's, Horkos - (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 6, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 262, 8), CharacterWeapon.Int(3101, 6, 1), CharacterWeapon.Int(3151, 6, 1)), // VPR, Snakebite, Twinfangs (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 2, 1), CharacterWeapon.Int(2951, 2, 1)), // PCT, Painter's, Round Brush }; @@ -305,7 +305,7 @@ public class WorldSets (FunEquipSet.Group.FullSet(694, 1), CharacterWeapon.Int(2607, 001, 1), CharacterWeapon.Int(2657, 001, 001)), // DNC, Etoile, Terpsichore (FunEquipSet.Group.FullSet(695, 1), CharacterWeapon.Int(2801, 001, 1), CharacterWeapon.Empty), // RPR, Reaper, Death Sickle (FunEquipSet.Group.FullSet(696, 1), CharacterWeapon.Int(2701, 006, 1), CharacterWeapon.Empty), // SGE, Didact, Hagneia - (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 288, 5), CharacterWeapon.Int(3101, 006, 1), CharacterWeapon.Int(3151, 006, 001)), // VPR, Snakebite, Twinfangs + (new FunEquipSet.Group(491, 3, 288, 5, 288, 5, 288, 5, 262, 8), CharacterWeapon.Int(3101, 006, 1), CharacterWeapon.Int(3151, 006, 001)), // VPR, Snakebite, Twinfangs (new FunEquipSet.Group(595, 3, 372, 3, 290, 6, 315, 3, 290, 6), CharacterWeapon.Int(2901, 002, 1), CharacterWeapon.Int(2951, 002, 001)), // PCT, Painter's, Round Brush }; From 9b5271bca4dd0ffeeb17ef72ea15f0cea465818a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 11:58:33 +0200 Subject: [PATCH 095/401] Update Gamedata. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 66bc00d..0dfe87d 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 66bc00dc8517204e58c6515af5aec0ba6d196716 +Subproject commit 0dfe87d59ea800e2bdb2b2f35680de79be2f5598 From 5da07381479442adc316023c34f4584087aa49bc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 12:45:58 +0200 Subject: [PATCH 096/401] Add a debug rider for actors. --- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 43 +++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index e6cdbd3..14a9e11 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -16,6 +16,8 @@ using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; +using OtterGui.Text.HelperObjects; using Penumbra.GameData.Actors; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; @@ -181,6 +183,7 @@ public class ActorPanel DrawCustomizationsHeader(); DrawEquipmentHeader(); DrawParameterHeader(); + DrawDebugData(); } private void DrawCustomizationsHeader() @@ -188,7 +191,7 @@ public class ActorPanel var header = _state!.ModelData.ModelId == 0 ? "Customization" : $"Customization (Model Id #{_state.ModelData.ModelId})###Customization"; - using var h = ImRaii.CollapsingHeader(header); + using var h = ImUtf8.CollapsingHeaderId(header); if (!h) return; @@ -201,7 +204,7 @@ public class ActorPanel private void DrawEquipmentHeader() { - using var h = ImRaii.CollapsingHeader("Equipment"); + using var h = ImUtf8.CollapsingHeaderId("Equipment"u8); if (!h) return; @@ -236,13 +239,47 @@ public class ActorPanel if (!_config.UseAdvancedParameters) return; - using var h = ImRaii.CollapsingHeader("Advanced Customizations"); + using var h = ImUtf8.CollapsingHeaderId("Advanced Customizations"u8); if (!h) return; _parameterDrawer.Draw(_stateManager, _state!); } + private unsafe void DrawDebugData() + { + if (!_config.DebugMode) + return; + + using var h = ImUtf8.CollapsingHeaderId("Debug Data"u8); + if (!h) + return; + + using var t = ImUtf8.Table("table"u8, 2, ImGuiTableFlags.SizingFixedFit); + if (!t) + return; + + ImUtf8.DrawTableColumn("Object Index"u8); + DrawCopyColumn($"{string.Join(", ", _data.Objects.Select(d => d.AsObject->ObjectIndex))}"); + ImUtf8.DrawTableColumn("Name ID"u8); + DrawCopyColumn($"{string.Join(", ", _data.Objects.Select(d => d.AsObject->GetNameId()))}"); + ImUtf8.DrawTableColumn("Base ID"u8); + DrawCopyColumn($"{string.Join(", ", _data.Objects.Select(d => d.AsObject->BaseId))}"); + ImUtf8.DrawTableColumn("Entity ID"u8); + DrawCopyColumn($"{string.Join(", ", _data.Objects.Select(d => d.AsObject->EntityId))}"); + ImUtf8.DrawTableColumn("Owner ID"u8); + DrawCopyColumn($"{string.Join(", ", _data.Objects.Select(d => d.AsObject->OwnerId))}"); + ImUtf8.DrawTableColumn("Game Object ID"u8); + DrawCopyColumn($"{string.Join(", ", _data.Objects.Select(d => d.AsObject->GetGameObjectId().ObjectId))}"); + + static void DrawCopyColumn(ref Utf8StringHandler text) + { + ImUtf8.DrawTableColumn(ref text); + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + ImUtf8.SetClipboardText(TextStringHandlerBuffer.Span); + } + } + private void DrawEquipmentMetaToggles() { using (_ = ImRaii.Group()) From 726eb52e4f42f61167da99d9efeffc12f34df7a8 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 12:46:50 +0200 Subject: [PATCH 097/401] Update Gamedata. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 0dfe87d..737f90e 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 0dfe87d59ea800e2bdb2b2f35680de79be2f5598 +Subproject commit 737f90e236418d5c4269aef7b16dd1ab74f298fa From 816e88e0bdb14ba5135637d2f1c4f9e974b5036d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 12:51:35 +0200 Subject: [PATCH 098/401] Make the advanced dye window non-docking. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 9991aae..520d2c1 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -181,7 +181,8 @@ public sealed unsafe class AdvancedDyePopup( var flags = ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoDecoration - | ImGuiWindowFlags.NoResize; + | ImGuiWindowFlags.NoResize + | ImGuiWindowFlags.NoDocking; // Set position to the right of the main window when attached // The downwards offset is implicit through child position. From 885063d38902d463fba7a2eb8299b951641650f3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 12:59:06 +0200 Subject: [PATCH 099/401] Make item combos search for entire model string. --- Glamourer/Gui/Equipment/ItemCombo.cs | 5 +++-- Glamourer/Gui/Equipment/WeaponCombo.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Glamourer/Gui/Equipment/ItemCombo.cs b/Glamourer/Gui/Equipment/ItemCombo.cs index 7e298c0..1dac468 100644 --- a/Glamourer/Gui/Equipment/ItemCombo.cs +++ b/Glamourer/Gui/Equipment/ItemCombo.cs @@ -7,6 +7,7 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -75,12 +76,12 @@ public sealed class ItemCombo : FilterComboCache var ret = ImGui.Selectable(name, selected); ImGui.SameLine(); using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); - ImGuiUtil.RightAlign($"({obj.ModelString})"); + ImUtf8.TextRightAligned($"({obj.PrimaryId.Id}-{obj.Variant.Id})"); return ret; } protected override bool IsVisible(int globalIndex, LowerString filter) - => base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].PrimaryId.Id.ToString()); + => base.IsVisible(globalIndex, filter) || Items[globalIndex].ModelString.StartsWith(filter.Lower); protected override string ToString(EquipItem obj) => obj.Name; diff --git a/Glamourer/Gui/Equipment/WeaponCombo.cs b/Glamourer/Gui/Equipment/WeaponCombo.cs index f6531a2..67f09f5 100644 --- a/Glamourer/Gui/Equipment/WeaponCombo.cs +++ b/Glamourer/Gui/Equipment/WeaponCombo.cs @@ -5,6 +5,7 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -69,12 +70,12 @@ public sealed class WeaponCombo : FilterComboCache var ret = ImGui.Selectable(name, selected); ImGui.SameLine(); using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); - ImGuiUtil.RightAlign($"({obj.PrimaryId.Id}-{obj.SecondaryId.Id}-{obj.Variant})"); + ImUtf8.TextRightAligned($"({obj.PrimaryId.Id}-{obj.SecondaryId.Id}-{obj.Variant.Id})"); return ret; } protected override bool IsVisible(int globalIndex, LowerString filter) - => base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].PrimaryId.Id.ToString()); + => base.IsVisible(globalIndex, filter) || Items[globalIndex].ModelString.StartsWith(filter.Lower); protected override string ToString(EquipItem obj) => obj.Name; From 83e1476e7f7eb5c7d6ea733c750a0bba3152c6a9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 12:59:15 +0200 Subject: [PATCH 100/401] Make unlocks tab non-docking. --- Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs index 1c82add..c2e06e5 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs @@ -20,7 +20,8 @@ public class UnlocksTab : Window, ITab _overview = overview; _table = table; - IsOpen = false; + Flags |= ImGuiWindowFlags.NoDocking; + IsOpen = false; SizeConstraints = new WindowSizeConstraints() { MinimumSize = new Vector2(700, 675), From ce02c64655afd4951896e125c1c52570a4d944aa Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 13:01:28 +0200 Subject: [PATCH 101/401] Update Gamedata. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 737f90e..dd86daf 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 737f90e236418d5c4269aef7b16dd1ab74f298fa +Subproject commit dd86dafb88ca4c7b662938bbc1310729ba7f788d From 65e33d91aca3d228f0558dbe2b7bba8a5cb6e6e1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 6 Oct 2024 15:03:58 +0200 Subject: [PATCH 102/401] 1.3.2.0 --- Glamourer/Gui/GlamourerChangelog.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index a69a4c4..77a5788 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -35,6 +35,7 @@ public class GlamourerChangelog AddDummy(Changelog); Add1_2_3_0(Changelog); Add1_3_1_0(Changelog); + Add1_3_2_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -55,6 +56,23 @@ public class GlamourerChangelog } } + private static void Add1_3_2_0(Changelog log) + => log.NextVersion("Version 1.3.2.0") + .RegisterEntry("Fixed an issue with weapon hiding when leaving GPose or changing zones.") + .RegisterEntry("Added support for unnamed items to be previewed from Penumbra.") + .RegisterEntry("Item combos filters now check if the model string starts with the current filter, instead of checking if the primary ID contains the current filter.") + .RegisterEntry("Improved the handling of bonus items (glasses) in designs.") + .RegisterEntry("Imported .chara files now import bonus items.") + .RegisterEntry("Added a Debug Data rider in the Actors tab that is visible if Debug Mode is enabled and (currently) contains some IDs.") + .RegisterEntry("Fixed bonus items not reverting correctly in some cases.") + .RegisterEntry("Fixed an issue with the RNG in cheat codes and events skipping some possible entries.") + .RegisterEntry("Fixed the chat log context menu for glamourer Try-On.") + .RegisterEntry("Fixed some issues with cheat code sets.") + .RegisterEntry("Made the popped out Advanced Dye Window and Unlocks Window non-docking as that caused issues when docked to the main Glamourer window.") + .RegisterEntry("Refreshed NPC name associations.") + .RegisterEntry("Removed a now useless cheat code.") + .RegisterEntry("Added API for Bonus Items. (1.3.1.1)"); + private static void Add1_3_1_0(Changelog log) => log.NextVersion("Version 1.3.1.0") .RegisterHighlight("Glamourer is now released for Dawntrail!") From ea8b23d3fdcf80eca69ed7d6b4362f90880e05c4 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 6 Oct 2024 13:05:46 +0000 Subject: [PATCH 103/401] [CI] Updating repo.json for 1.3.2.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 5be3916..f3ea329 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.1.1", - "TestingAssemblyVersion": "1.3.1.1", + "AssemblyVersion": "1.3.2.0", + "TestingAssemblyVersion": "1.3.2.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.1.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From d104b794aee21b91ba81e03865d60a5feeaf542e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 7 Oct 2024 18:34:52 +0200 Subject: [PATCH 104/401] Add owned NPC button for automation identifiers. --- Glamourer/Automation/AutoDesignApplier.cs | 9 ++++++++- Glamourer/Automation/AutoDesignManager.cs | 7 ++++--- .../Gui/Tabs/AutomationTab/IdentifierDrawer.cs | 9 +++++++++ Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 15 ++++++++++----- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index f90cb9b..22048a8 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -299,12 +299,19 @@ public sealed class AutoDesignApplier : IDisposable if (_manager.EnabledSets.TryGetValue(identifier, out set)) return true; - identifier = _actors.CreatePlayer(identifier.PlayerName, ushort.MaxValue); + identifier = _actors.CreatePlayer(identifier.PlayerName, WorldId.AnyWorld); return _manager.EnabledSets.TryGetValue(identifier, out set); case IdentifierType.Retainer: case IdentifierType.Npc: return _manager.EnabledSets.TryGetValue(identifier, out set); case IdentifierType.Owned: + if (_manager.EnabledSets.TryGetValue(identifier, out set)) + return true; + + identifier = _actors.CreateOwned(identifier.PlayerName, WorldId.AnyWorld, identifier.Kind, identifier.DataId); + if (_manager.EnabledSets.TryGetValue(identifier, out set)) + return true; + identifier = _actors.CreateNpc(identifier.Kind, identifier.DataId); return _manager.EnabledSets.TryGetValue(identifier, out set); default: diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index 474afdd..a219376 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -570,12 +570,13 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos IdentifierType.Player => true, IdentifierType.Retainer => true, IdentifierType.Npc => true, + IdentifierType.Owned => true, _ => false, }; if (!validType) { - group = Array.Empty(); + group = []; return false; } @@ -602,6 +603,7 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos : ActorIdentifier.RetainerType.Bell).CreatePermanent(), ], IdentifierType.Npc => CreateNpcs(_actors, identifier), + IdentifierType.Owned => CreateNpcs(_actors, identifier), _ => [], }; @@ -616,8 +618,7 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos }; return table.Where(kvp => kvp.Value == name) .Select(kvp => manager.CreateIndividualUnchecked(identifier.Type, identifier.PlayerName, identifier.HomeWorld.Id, - identifier.Kind, - kvp.Key)).ToArray(); + identifier.Kind, kvp.Key)).ToArray(); } } diff --git a/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs b/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs index 8498bc1..b197a1a 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs @@ -20,6 +20,7 @@ public class IdentifierDrawer public ActorIdentifier PlayerIdentifier { get; private set; } = ActorIdentifier.Invalid; public ActorIdentifier RetainerIdentifier { get; private set; } = ActorIdentifier.Invalid; public ActorIdentifier MannequinIdentifier { get; private set; } = ActorIdentifier.Invalid; + public ActorIdentifier OwnedIdentifier { get; private set; } = ActorIdentifier.Invalid; public IdentifierDrawer(ActorManager actors, DictWorld dictWorld, DictModelChara dictModelChara, DictBNpcNames bNpcNames, DictBNpc bNpc, HumanModelList humans) @@ -60,6 +61,9 @@ public class IdentifierDrawer public bool CanSetNpc => NpcIdentifier.IsValid; + public bool CanSetOwned + => OwnedIdentifier.IsValid; + private void UpdateIdentifiers() { if (ByteString.FromString(_characterName, out var byteName)) @@ -67,6 +71,11 @@ public class IdentifierDrawer PlayerIdentifier = _actors.CreatePlayer(byteName, _worldCombo.CurrentSelection.Key); RetainerIdentifier = _actors.CreateRetainer(byteName, ActorIdentifier.RetainerType.Bell); MannequinIdentifier = _actors.CreateRetainer(byteName, ActorIdentifier.RetainerType.Mannequin); + + if (_humanNpcCombo.CurrentSelection.Kind is ObjectKind.EventNpc or ObjectKind.BattleNpc) + OwnedIdentifier = _actors.CreateOwned(byteName, _worldCombo.CurrentSelection.Key, _humanNpcCombo.CurrentSelection.Kind, _humanNpcCombo.CurrentSelection.Ids[0]); + else + OwnedIdentifier = ActorIdentifier.Invalid; } NpcIdentifier = _humanNpcCombo.CurrentSelection.Kind is ObjectKind.EventNpc or ObjectKind.BattleNpc diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 8d52a76..ab2b3d6 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -10,6 +10,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Log; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -424,22 +425,26 @@ public class SetPanel( private void DrawIdentifierSelection(int setIndex) { - using var id = ImRaii.PushId("Identifiers"); + using var id = ImUtf8.PushId("Identifiers"u8); _identifierDrawer.DrawWorld(130); ImGui.SameLine(); _identifierDrawer.DrawName(200 - ImGui.GetStyle().ItemSpacing.X); _identifierDrawer.DrawNpcs(330); var buttonWidth = new Vector2(165 * ImGuiHelpers.GlobalScale - ImGui.GetStyle().ItemSpacing.X / 2, 0); - if (ImGuiUtil.DrawDisabledButton("Set to Character", buttonWidth, string.Empty, !_identifierDrawer.CanSetPlayer)) + if (ImUtf8.ButtonEx("Set to Character"u8, string.Empty, buttonWidth, !_identifierDrawer.CanSetPlayer)) _manager.ChangeIdentifier(setIndex, _identifierDrawer.PlayerIdentifier); ImGui.SameLine(); - if (ImGuiUtil.DrawDisabledButton("Set to NPC", buttonWidth, string.Empty, !_identifierDrawer.CanSetNpc)) + if (ImUtf8.ButtonEx("Set to NPC"u8, string.Empty, buttonWidth, !_identifierDrawer.CanSetNpc)) _manager.ChangeIdentifier(setIndex, _identifierDrawer.NpcIdentifier); - if (ImGuiUtil.DrawDisabledButton("Set to Retainer", buttonWidth, string.Empty, !_identifierDrawer.CanSetRetainer)) + + if (ImUtf8.ButtonEx("Set to Retainer"u8, string.Empty, buttonWidth, !_identifierDrawer.CanSetRetainer)) _manager.ChangeIdentifier(setIndex, _identifierDrawer.RetainerIdentifier); ImGui.SameLine(); - if (ImGuiUtil.DrawDisabledButton("Set to Mannequin", buttonWidth, string.Empty, !_identifierDrawer.CanSetRetainer)) + if (ImUtf8.ButtonEx("Set to Mannequin"u8, string.Empty, buttonWidth, !_identifierDrawer.CanSetRetainer)) _manager.ChangeIdentifier(setIndex, _identifierDrawer.MannequinIdentifier); + + if (ImUtf8.ButtonEx("Set to Owned NPC"u8, string.Empty, buttonWidth, !_identifierDrawer.CanSetOwned)) + _manager.ChangeIdentifier(setIndex, _identifierDrawer.OwnedIdentifier); } private sealed class JobGroupCombo(AutoDesignManager manager, JobService jobs, Logger log) From 8f53253bae474020a6cf4cccb6514af14fc1b718 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 7 Oct 2024 18:35:09 +0200 Subject: [PATCH 105/401] Add special filters to actor selector. --- Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs | 62 +++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs index e688bce..76f0ba4 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs @@ -1,11 +1,15 @@ -using Dalamud.Interface; +using System.Security.AccessControl; +using Dalamud.Interface; using Glamourer.Interop; using Glamourer.Interop.Structs; using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Actors; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.ActorTab; @@ -25,6 +29,7 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral private LowerString _actorFilter = LowerString.Empty; private Vector2 _defaultItemSpacing; + private WorldId _world; private float _width; public (ActorIdentifier Identifier, ActorData Data) Selection @@ -36,12 +41,43 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral public void Draw(float width) { _width = width; - using var group = ImRaii.Group(); + using var group = ImUtf8.Group(); _defaultItemSpacing = ImGui.GetStyle().ItemSpacing; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero) .Push(ImGuiStyleVar.FrameRounding, 0); ImGui.SetNextItemWidth(_width); LowerString.InputWithHint("##actorFilter", "Filter...", ref _actorFilter, 64); + if (ImGui.IsItemHovered()) + { + using var tt = ImUtf8.Tooltip(); + ImUtf8.Text("Filter for names containing the input."u8); + ImGui.Dummy(new Vector2(0, ImGui.GetTextLineHeight() / 2)); + ImUtf8.Text("Special filters are:"u8); + var color = ColorId.HeaderButtons.Value(); + ImUtf8.Text("

"u8, color); + ImGui.SameLine(0, 0); + ImUtf8.Text(": show only player characters."u8); + + ImUtf8.Text(""u8, color); + ImGui.SameLine(0, 0); + ImUtf8.Text(": show only owned game objects."u8); + + ImUtf8.Text(""u8, color); + ImGui.SameLine(0, 0); + ImUtf8.Text(": show only NPCs."u8); + + ImUtf8.Text(""u8, color); + ImGui.SameLine(0, 0); + ImUtf8.Text(": show only retainers."u8); + + ImUtf8.Text(""u8, color); + ImGui.SameLine(0, 0); + ImUtf8.Text(": show only special screen characters."u8); + + ImUtf8.Text(""u8, color); + ImGui.SameLine(0, 0); + ImUtf8.Text(": show only players from your world."u8); + } DrawSelector(); DrawSelectionButtons(); @@ -49,11 +85,12 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral private void DrawSelector() { - using var child = ImRaii.Child("##Selector", new Vector2(_width, -ImGui.GetFrameHeight()), true); + using var child = ImUtf8.Child("##Selector"u8, new Vector2(_width, -ImGui.GetFrameHeight()), true); if (!child) return; objects.Update(); + _world = new WorldId(objects.Player.Valid ? objects.Player.HomeWorld : (ushort)0); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight()); var remainder = ImGuiClip.FilteredClippedDraw(objects.Identifiers, skips, CheckFilter, DrawSelectable); @@ -61,12 +98,22 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral } private bool CheckFilter(KeyValuePair pair) - => _actorFilter.IsEmpty || pair.Value.Label.Contains(_actorFilter.Lower, StringComparison.OrdinalIgnoreCase); + => _actorFilter.Lower switch + { + "" => true, + "

" => pair.Key.Type is IdentifierType.Player, + "" => pair.Key.Type is IdentifierType.Owned, + "" => pair.Key.Type is IdentifierType.Npc, + "" => pair.Key.Type is IdentifierType.Retainer, + "" => pair.Key.Type is IdentifierType.Special, + "" => pair.Key.Type is IdentifierType.Player && pair.Key.HomeWorld == _world, + _ => _actorFilter.IsContained(pair.Value.Label), + }; private void DrawSelectable(KeyValuePair pair) { var equals = pair.Key.Equals(_identifier); - if (ImGui.Selectable(IncognitoMode ? pair.Key.Incognito(pair.Value.Label) : pair.Value.Label, equals) && !equals) + if (ImUtf8.Selectable(IncognitoMode ? pair.Key.Incognito(pair.Value.Label) : pair.Value.Label, equals) && !equals) _identifier = pair.Key.CreatePermanent(); } @@ -76,15 +123,14 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral .Push(ImGuiStyleVar.FrameRounding, 0); var buttonWidth = new Vector2(_width / 2, 0); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.UserCircle.ToIconString(), buttonWidth - , "Select the local player character.", !objects.Player, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.UserCircle, "Select the local player character."u8, buttonWidth, !objects.Player)) _identifier = objects.Player.GetIdentifier(actors); ImGui.SameLine(); var (id, data) = objects.TargetData; var tt = data.Valid ? $"Select the current target {id} in the list." : id.IsValid ? $"The target {id} is not in the list." : "No target selected."; - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.HandPointer.ToIconString(), buttonWidth, tt, objects.IsInGPose || !data.Valid, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.HandPointer, tt, buttonWidth, objects.IsInGPose || !data.Valid)) _identifier = id; } } From 9d99d936aa56673412d5f82229b1fef9381c816d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 11 Oct 2024 18:18:33 +0200 Subject: [PATCH 106/401] Remove BonusItem and replace with normal EquipItems everywhere. --- Glamourer/Api/ItemsApi.cs | 6 +-- Glamourer/Designs/DesignBase.cs | 4 +- Glamourer/Designs/DesignData.cs | 16 +++--- Glamourer/Designs/DesignEditor.cs | 4 +- Glamourer/Designs/History/Transaction.cs | 2 +- Glamourer/Designs/IDesignEditor.cs | 2 +- Glamourer/Glamourer.cs | 12 +++++ Glamourer/Gui/Equipment/BonusDrawData.cs | 6 +-- Glamourer/Gui/Equipment/BonusItemCombo.cs | 19 +++---- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 4 +- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 2 +- .../Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 2 +- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 8 +-- Glamourer/Gui/UiHelpers.cs | 25 +-------- Glamourer/Interop/CharaFile/CharaFile.cs | 4 +- Glamourer/Interop/UpdateSlotService.cs | 2 +- Glamourer/Services/ItemManager.cs | 37 +++++--------- Glamourer/Services/TextureService.cs | 4 +- Glamourer/State/InternalStateEditor.cs | 2 +- Glamourer/State/StateApplier.cs | 4 +- Glamourer/State/StateEditor.cs | 2 +- Glamourer/State/StateListener.cs | 8 +-- Glamourer/State/StateManager.cs | 2 +- Glamourer/Unlocks/FavoriteManager.cs | 51 ++++++++++++------- Penumbra.GameData | 2 +- 25 files changed, 112 insertions(+), 118 deletions(-) diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index a516b68..fd174ca 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -85,7 +85,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key); - stateManager.ChangeBonusItem(state, item.Slot, item, settings); + stateManager.ChangeBonusItem(state, item.Type.ToBonus(), item, settings); ApiHelpers.Lock(state, key, flags); return GlamourerApiEc.Success; } @@ -111,7 +111,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager continue; anyUnlocked = true; - stateManager.ChangeBonusItem(state, item.Slot, item, settings); + stateManager.ChangeBonusItem(state, item.Type.ToBonus(), item, settings); ApiHelpers.Lock(state, key, flags); } @@ -138,7 +138,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return item.Valid; } - private bool ResolveBonusItem(ApiBonusSlot apiSlot, ulong itemId, out BonusItem item) + private bool ResolveBonusItem(ApiBonusSlot apiSlot, ulong itemId, out EquipItem item) { var slot = apiSlot switch { diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index a8e9986..30d4ddd 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -281,7 +281,7 @@ public class DesignBase var item = _designData.BonusItem(slot); ret[slot.ToString()] = new JObject() { - ["BonusId"] = item.CustomId.Id, + ["BonusId"] = item.Id.Id, ["Apply"] = DoApplyBonusItem(slot), }; } @@ -443,7 +443,7 @@ public class DesignBase if (json[slot.ToString()] is not JObject itemJson) { design.Application.BonusItem &= ~slot; - design.GetDesignDataRef().SetBonusItem(slot, BonusItem.Empty(slot)); + design.GetDesignDataRef().SetBonusItem(slot, EquipItem.BonusItemNothing(slot)); continue; } diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index 28944b9..3e32eac 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -108,12 +108,12 @@ public unsafe struct DesignData } } - public readonly BonusItem BonusItem(BonusItemFlag slot) + public readonly EquipItem BonusItem(BonusItemFlag slot) => slot switch { // @formatter:off - BonusItemFlag.Glasses => Penumbra.GameData.Structs.BonusItem.FromIds(_bonusIds[0], _iconIds[12], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses, _nameGlasses), - _ => Penumbra.GameData.Structs.BonusItem.Empty(slot), + BonusItemFlag.Glasses => EquipItem.FromIds(_bonusIds[0], _iconIds[12], _bonusModelIds[0], 0, _bonusVariants[0], FullEquipType.Glasses, 0, _nameGlasses), + _ => EquipItem.BonusItemNothing(slot), // @formatter:on }; @@ -191,15 +191,15 @@ public unsafe struct DesignData return true; } - public bool SetBonusItem(BonusItemFlag slot, BonusItem item) + public bool SetBonusItem(BonusItemFlag slot, EquipItem item) { var index = slot.ToIndex(); if (index > NumBonusItems) return false; - _iconIds[NumEquipment + NumWeapons + index] = item.Icon.Id; - _bonusIds[index] = item.Id.Id; - _bonusModelIds[index] = item.ModelId.Id; + _iconIds[NumEquipment + NumWeapons + index] = item.IconId.Id; + _bonusIds[index] = item.Id.BonusItem.Id; + _bonusModelIds[index] = item.PrimaryId.Id; _bonusVariants[index] = item.Variant.Id; switch (index) { @@ -330,7 +330,7 @@ public unsafe struct DesignData public void SetDefaultBonusItems() { foreach (var slot in BonusExtensions.AllFlags) - SetBonusItem(slot, Penumbra.GameData.Structs.BonusItem.Empty(slot)); + SetBonusItem(slot, EquipItem.BonusItemNothing(slot)); } diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index a42971e..cfda047 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -172,10 +172,10 @@ public class DesignEditor( } /// - public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) + public void ChangeBonusItem(object data, BonusItemFlag slot, EquipItem item, ApplySettings settings = default) { var design = (Design)data; - if (item.Slot != slot) + if (item.Type.ToBonus() != slot) return; var oldItem = design.DesignData.BonusItem(slot); diff --git a/Glamourer/Designs/History/Transaction.cs b/Glamourer/Designs/History/Transaction.cs index ac310b0..47b10bf 100644 --- a/Glamourer/Designs/History/Transaction.cs +++ b/Glamourer/Designs/History/Transaction.cs @@ -40,7 +40,7 @@ public readonly record struct EquipTransaction(EquipSlot Slot, EquipItem Old, Eq => editor.ChangeItem(data, Slot, Old, ApplySettings.Manual); } -public readonly record struct BonusItemTransaction(BonusItemFlag Slot, BonusItem Old, BonusItem New) +public readonly record struct BonusItemTransaction(BonusItemFlag Slot, EquipItem Old, EquipItem New) : ITransaction { public ITransaction? Merge(ITransaction older) diff --git a/Glamourer/Designs/IDesignEditor.cs b/Glamourer/Designs/IDesignEditor.cs index 9eefa63..935263b 100644 --- a/Glamourer/Designs/IDesignEditor.cs +++ b/Glamourer/Designs/IDesignEditor.cs @@ -65,7 +65,7 @@ public interface IDesignEditor => ChangeEquip(data, slot, item, null, settings); ///

Change a bonus item. - public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default); + public void ChangeBonusItem(object data, BonusItemFlag slot, EquipItem item, ApplySettings settings = default); /// Change the stain for any equipment piece. public void ChangeStains(object data, EquipSlot slot, StainIds stains, ApplySettings settings = default) diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 84312d9..ee202d6 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -6,9 +6,12 @@ using Glamourer.Gui; using Glamourer.Interop; using Glamourer.Services; using Glamourer.State; +using OtterGui; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Services; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Files; namespace Glamourer; @@ -44,6 +47,15 @@ public class Glamourer : IDalamudPlugin _services.GetService(); // initialize commands. _services.GetService(); // initialize IPC. Log.Information($"Glamourer v{Version} loaded successfully."); + + //var text = File.ReadAllBytes(@"C:\FFXIVMods\PBDTest\files\human.pbd"); + //var pbd = new PbdFile(text); + //var roundtrip = pbd.Write(); + //File.WriteAllBytes(@"C:\FFXIVMods\PBDTest\files\Vanilla resaved save.pbd", roundtrip); + //var deformer = pbd.Deformers.FirstOrDefault(d => d.GenderRace is GenderRace.RoegadynFemale)!.RacialDeformer; + //deformer.DeformMatrices["ya_fukubu_phys"] = deformer.DeformMatrices["j_kosi"]; + //var aleks = pbd.Write(); + //File.WriteAllBytes(@"C:\FFXIVMods\PBDTest\files\rue.pbd", aleks); } catch { diff --git a/Glamourer/Gui/Equipment/BonusDrawData.cs b/Glamourer/Gui/Equipment/BonusDrawData.cs index d2a6b2e..9c023b8 100644 --- a/Glamourer/Gui/Equipment/BonusDrawData.cs +++ b/Glamourer/Gui/Equipment/BonusDrawData.cs @@ -20,7 +20,7 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) public readonly bool IsState => _object is ActorState; - public readonly void SetItem(BonusItem item) + public readonly void SetItem(EquipItem item) => _editor.ChangeBonusItem(_object, Slot, item, ApplySettings.Manual); public readonly void SetApplyItem(bool value) @@ -30,8 +30,8 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) manager.ChangeApplyBonusItem(design, Slot, value); } - public BonusItem CurrentItem = designData.BonusItem(slot); - public BonusItem GameItem = default; + public EquipItem CurrentItem = designData.BonusItem(slot); + public EquipItem GameItem = default; public bool CurrentApply; public static BonusDrawData FromDesign(DesignManager manager, Design design, BonusItemFlag slot) diff --git a/Glamourer/Gui/Equipment/BonusItemCombo.cs b/Glamourer/Gui/Equipment/BonusItemCombo.cs index ae8bf19..735a23f 100644 --- a/Glamourer/Gui/Equipment/BonusItemCombo.cs +++ b/Glamourer/Gui/Equipment/BonusItemCombo.cs @@ -13,11 +13,11 @@ using Penumbra.GameData.Structs; namespace Glamourer.Gui.Equipment; -public sealed class BonusItemCombo : FilterComboCache +public sealed class BonusItemCombo : FilterComboCache { private readonly FavoriteManager _favorites; public readonly string Label; - private BonusItemId _currentItem; + private CustomItemId _currentItem; private float _innerWidth; public PrimaryId CustomSetId { get; private set; } @@ -75,14 +75,14 @@ public sealed class BonusItemCombo : FilterComboCache var ret = ImGui.Selectable(name, selected); ImGui.SameLine(); using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); - ImGuiUtil.RightAlign($"({obj.ModelId.Id}-{obj.Variant.Id})"); + ImGuiUtil.RightAlign($"({obj.PrimaryId.Id}-{obj.Variant.Id})"); return ret; } protected override bool IsVisible(int globalIndex, LowerString filter) - => base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].ModelId.Id.ToString()); + => base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].PrimaryId.Id.ToString()); - protected override string ToString(BonusItem obj) + protected override string ToString(EquipItem obj) => obj.Name; private static string GetLabel(IDataManager gameData, BonusItemFlag slot) @@ -98,13 +98,10 @@ public sealed class BonusItemCombo : FilterComboCache }; } - private static List GetItems(FavoriteManager favorites, ItemManager items, BonusItemFlag slot) + private static List GetItems(FavoriteManager favorites, ItemManager items, BonusItemFlag slot) { - var nothing = BonusItem.Empty(slot); - if (slot is not BonusItemFlag.Glasses) - return [nothing]; - - return items.DictBonusItems.Values.OrderByDescending(favorites.Contains).ThenBy(i => i.Id.Id).Prepend(nothing).ToList(); + var nothing = EquipItem.BonusItemNothing(slot); + return items.ItemData.ByType[slot.ToEquipType()].OrderByDescending(favorites.Contains).ThenBy(i => i.Id.Id).Prepend(nothing).ToList(); } protected override void OnClosePopup() diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 0844626..38c8263 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -468,14 +468,14 @@ public class EquipmentDrawer UiHelpers.OpenCombo($"##{combo.Label}"); using var disabled = ImRaii.Disabled(data.Locked); - var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, + var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id.BonusItem, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth); if (change) data.SetItem(combo.CurrentSelection); else if (combo.CustomVariant.Id > 0) data.SetItem(_items.Identify(data.Slot, combo.CustomSetId, combo.CustomVariant)); - if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, BonusItem.Empty(data.Slot), out var item)) + if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, EquipItem.BonusItemNothing(data.Slot), out var item)) data.SetItem(item); } diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 520d2c1..0c2b11e 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -305,7 +305,7 @@ public sealed unsafe class AdvancedDyePopup( { EquipSlot.MainHand => _state.ModelData.Weapon(EquipSlot.MainHand), EquipSlot.OffHand => _state.ModelData.Weapon(EquipSlot.OffHand), - EquipSlot.Unknown => _state.ModelData.BonusItem((index.SlotIndex - 16u).ToBonusSlot()).ToArmor().ToWeapon(0), + EquipSlot.Unknown => _state.ModelData.BonusItem((index.SlotIndex - 16u).ToBonusSlot()).Armor().ToWeapon(0), // TODO: Handle better _ => _state.ModelData.Armor(slot).ToWeapon(0), }; value = new MaterialValueState(internalRow, internalRow, weapon, StateSource.Manual); diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index 7307f22..eeb6f3f 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -248,7 +248,7 @@ public unsafe class ModelEvaluationPanel( { var glassesId = actor.GetBonusItem(slot); if (bonusItems.TryGetValue(glassesId, out var glasses)) - ImGuiUtil.DrawTableColumn($"{glasses.ModelId.Id},{glasses.Variant.Id} ({glassesId})"); + ImGuiUtil.DrawTableColumn($"{glasses.PrimaryId.Id},{glasses.Variant.Id} ({glassesId})"); else ImGuiUtil.DrawTableColumn($"{glassesId}"); } diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index 363cbcc..efe2448 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -180,11 +180,11 @@ public class UnlockOverview( if (remainder > 0) ImGuiClip.DrawEndDummy(remainder, iconSize.Y + spacing.Y); - void DrawItem(BonusItem item) + void DrawItem(EquipItem item) { // TODO check unlocks var unlocked = true; - if (!textures.TryLoadIcon(item.Icon.Id, out var iconHandle)) + if (!textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) return; var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); @@ -202,9 +202,9 @@ public class UnlockOverview( if (size.X >= iconSize.X && size.Y >= iconSize.Y) ImGui.Image(icon, size); ImUtf8.Text(item.Name); - ImUtf8.Text($"{item.Slot.ToName()}"); + ImUtf8.Text($"{item.Type.ToName()}"); ImUtf8.Text($"{item.Id.Id}"); - ImUtf8.Text($"{item.ModelId.Id}-{item.Variant.Id}"); + ImUtf8.Text($"{item.PrimaryId.Id}-{item.Variant.Id}"); // TODO ImUtf8.Text("Always Unlocked"); // : $"Unlocked on {time:g}" : "Not Unlocked."); // TODO diff --git a/Glamourer/Gui/UiHelpers.cs b/Glamourer/Gui/UiHelpers.cs index 8499728..1ec79d7 100644 --- a/Glamourer/Gui/UiHelpers.cs +++ b/Glamourer/Gui/UiHelpers.cs @@ -44,9 +44,9 @@ public static class UiHelpers } } - public static void DrawIcon(this BonusItem item, TextureService textures, Vector2 size, BonusItemFlag slot) + public static void DrawIcon(this EquipItem item, TextureService textures, Vector2 size, BonusItemFlag slot) { - var isEmpty = item.ModelId.Id == 0; + var isEmpty = item.PrimaryId.Id == 0; var (ptr, textureSize, empty) = textures.GetIcon(item, slot); if (empty) { @@ -149,27 +149,6 @@ public static class UiHelpers } - public static bool DrawFavoriteStar(FavoriteManager favorites, BonusItem item) - { - var favorite = favorites.Contains(item); - var hovering = ImGui.IsMouseHoveringRect(ImGui.GetCursorScreenPos(), - ImGui.GetCursorScreenPos() + new Vector2(ImGui.GetTextLineHeight())); - - using var font = ImRaii.PushFont(UiBuilder.IconFont); - using var c = ImRaii.PushColor(ImGuiCol.Text, - hovering ? ColorId.FavoriteStarHovered.Value() : favorite ? ColorId.FavoriteStarOn.Value() : ColorId.FavoriteStarOff.Value()); - ImGui.TextUnformatted(FontAwesomeIcon.Star.ToIconString()); - if (!ImGui.IsItemClicked()) - return false; - - if (favorite) - favorites.Remove(item); - else - favorites.TryAdd(item); - return true; - - } - public static bool DrawFavoriteStar(FavoriteManager favorites, StainId stain) { var favorite = favorites.Contains(stain); diff --git a/Glamourer/Interop/CharaFile/CharaFile.cs b/Glamourer/Interop/CharaFile/CharaFile.cs index f956379..aabac2d 100644 --- a/Glamourer/Interop/CharaFile/CharaFile.cs +++ b/Glamourer/Interop/CharaFile/CharaFile.cs @@ -104,11 +104,11 @@ public sealed class CharaFile if (id is 0) { - data.SetBonusItem(slot, BonusItem.Empty(slot)); + data.SetBonusItem(slot, EquipItem.BonusItemNothing(slot)); flags |= slot; } - if (!items.DictBonusItems.TryGetValue((BonusItemId)id.Value, out var item) || item.Slot != slot) + if (!items.DictBonusItems.TryGetValue((BonusItemId)id.Value, out var item) || item.Type.ToBonus() != slot) return; data.SetBonusItem(slot, item); diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 55db36d..d1004e6 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -58,7 +58,7 @@ public unsafe class UpdateSlotService : IDisposable if (!_bonusItems.TryGetValue(id, out var glasses)) return; - var armor = new CharacterArmor(glasses.ModelId, glasses.Variant, StainIds.None); + var armor = new CharacterArmor(glasses.PrimaryId, glasses.Variant, StainIds.None); _flagBonusSlotForUpdateHook.Original(drawObject.Address, BonusItemFlag.Glasses.ToIndex(), &armor); } diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 8cfd387..6e55888 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -10,7 +10,7 @@ namespace Glamourer.Services; public class ItemManager { - public const string Nothing = "Nothing"; + public const string Nothing = EquipItem.Nothing; public const string SmallClothesNpc = "Smallclothes (NPC)"; public const ushort SmallClothesNpcModel = 9903; @@ -126,31 +126,20 @@ public class ItemManager } } - public BonusItem Identify(BonusItemFlag slot, PrimaryId id, Variant variant) + public EquipItem Identify(BonusItemFlag slot, PrimaryId id, Variant variant) { var index = slot.ToIndex(); if (index == uint.MaxValue) - return new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot); + return new EquipItem($"Invalid ({id.Id}-{variant})", 0, 0, id, 0, variant, slot.ToEquipType(), 0, 0, 0); - var item = ObjectIdentification.Identify(id, variant, slot) - .FirstOrDefault(BonusItem.FromIds(BonusItemId.Invalid, 0, id, variant, slot)); - if (item.Id != BonusItemId.Invalid) - return item; - - if (slot is BonusItemFlag.Glasses) - { - var headItem = ObjectIdentification.Identify(id, 0, variant, EquipSlot.Head).FirstOrDefault(); - if (headItem.Valid) - return BonusItem.FromIds(BonusItemId.Invalid, headItem.IconId, id, variant, slot, $"{headItem.Name} ({EquipSlot.Head.ToName()}: {id}-{variant})"); - } - - return item; + return ObjectIdentification.Identify(id, variant, slot) + .FirstOrDefault(new EquipItem($"Invalid ({id.Id}-{variant})", 0, 0, id, 0, variant, slot.ToEquipType(), 0, 0, 0)); } - public BonusItem Resolve(BonusItemFlag slot, BonusItemId id) - => IsBonusItemValid(slot, id, out var item) ? item : new BonusItem($"Invalid ({id.Id})", 0, id, 0, 0, slot); + public EquipItem Resolve(BonusItemFlag slot, BonusItemId id) + => IsBonusItemValid(slot, id, out var item) ? item : new EquipItem($"Invalid ({id.Id})", id, 0, 0, 0, 0, slot.ToEquipType(), 0, 0, 0); - public BonusItem Resolve(BonusItemFlag slot, CustomItemId id) + public EquipItem Resolve(BonusItemFlag slot, CustomItemId id) { // Only from early designs as migration. if (!id.IsBonusItem) @@ -164,12 +153,12 @@ public class ItemManager if (IsBonusItemValid(slot, id.BonusItem, out var item)) return item; - return BonusItem.Empty(slot); + return EquipItem.BonusItemNothing(slot); } var (model, variant, slot2) = id.SplitBonus; if (slot != slot2) - return BonusItem.Empty(slot); + return EquipItem.BonusItemNothing(slot); return Identify(slot, model, variant); } @@ -213,12 +202,12 @@ public class ItemManager /// Returns whether a bonus item id represents a valid item for a slot and gives the item. [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public bool IsBonusItemValid(BonusItemFlag slot, BonusItemId itemId, out BonusItem item) + public bool IsBonusItemValid(BonusItemFlag slot, BonusItemId itemId, out EquipItem item) { if (itemId.Id != 0) - return DictBonusItems.TryGetValue(itemId, out item) && slot == item.Slot; + return DictBonusItems.TryGetValue(itemId, out item) && slot == item.Type.ToBonus(); - item = BonusItem.Empty(slot); + item = new EquipItem(Nothing, (BonusItemId)0, 0, 0, 0, 0, slot.ToEquipType(), 0, 0, 0); return true; } diff --git a/Glamourer/Services/TextureService.cs b/Glamourer/Services/TextureService.cs index e08ab44..29c2343 100644 --- a/Glamourer/Services/TextureService.cs +++ b/Glamourer/Services/TextureService.cs @@ -23,9 +23,9 @@ public sealed class TextureService(IUiBuilder uiBuilder, IDataManager dataManage : (nint.Zero, Vector2.Zero, true); } - public (nint, Vector2, bool) GetIcon(BonusItem item, BonusItemFlag slot) + public (nint, Vector2, bool) GetIcon(EquipItem item, BonusItemFlag slot) { - if (item.Icon.Id != 0 && TryLoadIcon(item.Icon.Id, out var ret)) + if (item.IconId.Id != 0 && TryLoadIcon(item.IconId.Id, out var ret)) return (ret.ImGuiHandle, new Vector2(ret.Width, ret.Height), false); var idx = slot.ToIndex(); diff --git a/Glamourer/State/InternalStateEditor.cs b/Glamourer/State/InternalStateEditor.cs index 71af0aa..69051c2 100644 --- a/Glamourer/State/InternalStateEditor.cs +++ b/Glamourer/State/InternalStateEditor.cs @@ -152,7 +152,7 @@ public class InternalStateEditor( } /// Change a single bonus item. - public bool ChangeBonusItem(ActorState state, BonusItemFlag slot, BonusItem item, StateSource source, out BonusItem oldItem, uint key = 0) + public bool ChangeBonusItem(ActorState state, BonusItemFlag slot, EquipItem item, StateSource source, out EquipItem oldItem, uint key = 0) { oldItem = state.ModelData.BonusItem(slot); if (!state.CanUnlock(key)) diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index ed6f907..6ba6c06 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -146,7 +146,7 @@ public class StateApplier( if (apply) { var item = state.ModelData.BonusItem(slot); - ChangeBonusItem(data, slot, item.ModelId, item.Variant); + ChangeBonusItem(data, slot, item.PrimaryId, item.Variant); } return data; @@ -391,7 +391,7 @@ public class StateApplier( foreach (var slot in BonusExtensions.AllFlags) { var item = state.ModelData.BonusItem(slot); - ChangeBonusItem(actors, slot, item.ModelId, item.Variant); + ChangeBonusItem(actors, slot, item.PrimaryId, item.Variant); } var mainhandActors = state.ModelData.MainhandType != state.BaseData.MainhandType ? actors.OnlyGPose() : actors; diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index c7867e1..633fc10 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -109,7 +109,7 @@ public class StateEditor( } } - public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default) + public void ChangeBonusItem(object data, BonusItemFlag slot, EquipItem item, ApplySettings settings = default) { var state = (ActorState)data; if (!Editor.ChangeBonusItem(state, slot, item, settings.Source, out var old, settings.Key)) diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 34c9421..9c0dd67 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -250,11 +250,11 @@ public class StateListener : IDisposable else apply = true; if (apply) - item = state.ModelData.BonusItem(slot).ToArmor(); + item = state.ModelData.BonusItem(slot).Armor(); break; // Use current model data. case UpdateState.NoChange: - item = state.ModelData.BonusItem(slot).ToArmor(); + item = state.ModelData.BonusItem(slot).Armor(); break; case UpdateState.Transformed: break; } @@ -453,12 +453,12 @@ public class StateListener : IDisposable return UpdateState.NoChange; // The actor item does not correspond to the model item, thus the actor is transformed. - if (actorItem.ModelId != item.Set || actorItem.Variant != item.Variant) + if (actorItem.PrimaryId != item.Set || actorItem.Variant != item.Variant) return UpdateState.Transformed; var baseData = state.BaseData.BonusItem(slot); var change = UpdateState.NoChange; - if (baseData.Id != actorItem.Id || baseData.ModelId != item.Set || baseData.Variant != item.Variant) + if (baseData.Id != actorItem.Id || baseData.PrimaryId != item.Set || baseData.Variant != item.Variant) { var identified = _items.Identify(slot, item.Set, item.Variant); state.BaseData.SetBonusItem(slot, identified); diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 24b025f..4ff232a 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -356,7 +356,7 @@ public sealed class StateManager( foreach (var slot in BonusExtensions.AllFlags) { var item = state.ModelData.BonusItem(slot); - Applier.ChangeBonusItem(actors, slot, item.ModelId, item.Variant); + Applier.ChangeBonusItem(actors, slot, item.PrimaryId, item.Variant); } var mainhandActors = state.ModelData.MainhandType != state.BaseData.MainhandType ? actors.OnlyGPose() : actors; diff --git a/Glamourer/Unlocks/FavoriteManager.cs b/Glamourer/Unlocks/FavoriteManager.cs index 229b8e6..01a2507 100644 --- a/Glamourer/Unlocks/FavoriteManager.cs +++ b/Glamourer/Unlocks/FavoriteManager.cs @@ -12,7 +12,7 @@ public class FavoriteManager : ISavable private readonly record struct FavoriteHairStyle(Gender Gender, SubRace Race, CustomizeIndex Type, CustomizeValue Id) { public uint ToValue() - => (uint)Id.Value | ((uint)Type << 8) | ((uint)Race << 16) | ((uint)Gender << 24); + => Id.Value | ((uint)Type << 8) | ((uint)Race << 16) | ((uint)Gender << 24); public FavoriteHairStyle(uint value) : this((Gender)((value >> 24) & 0xFF), (SubRace)((value >> 16) & 0xFF), (CustomizeIndex)((value >> 8) & 0xFF), @@ -61,9 +61,9 @@ public class FavoriteManager : ISavable { case 1: _favorites.UnionWith(load!.FavoriteItems.Select(i => (ItemId)i)); - _favoriteColors.UnionWith(load!.FavoriteColors.Select(i => (StainId)i)); - _favoriteHairStyles.UnionWith(load!.FavoriteHairStyles.Select(t => new FavoriteHairStyle(t))); - _favoriteBonusItems.UnionWith(load!.FavoriteBonusItems.Select(b => new BonusItemId(b))); + _favoriteColors.UnionWith(load.FavoriteColors.Select(i => (StainId)i)); + _favoriteHairStyles.UnionWith(load.FavoriteHairStyles.Select(t => new FavoriteHairStyle(t))); + _favoriteBonusItems.UnionWith(load.FavoriteBonusItems.Select(b => new BonusItemId(b))); break; default: throw new Exception($"Unknown Version {load?.Version ?? 0}"); @@ -126,7 +126,12 @@ public class FavoriteManager : ISavable } public bool TryAdd(EquipItem item) - => TryAdd(item.ItemId); + { + if (item.Id.IsBonusItem) + return TryAdd(item.Id.BonusItem); + + return TryAdd(item.ItemId); + } public bool TryAdd(ItemId item) { @@ -137,18 +142,18 @@ public class FavoriteManager : ISavable return true; } - public bool TryAdd(StainId stain) + public bool TryAdd(BonusItemId item) { - if (stain.Id == 0 || !_favoriteColors.Add(stain)) + if (item.Id == 0 || !_favoriteBonusItems.Add(item)) return false; Save(); return true; } - public bool TryAdd(BonusItem bonusItem) + public bool TryAdd(StainId stain) { - if (bonusItem.Id == 0 || !_favoriteBonusItems.Add(bonusItem.Id)) + if (stain.Id == 0 || !_favoriteColors.Add(stain)) return false; Save(); @@ -165,7 +170,11 @@ public class FavoriteManager : ISavable } public bool Remove(EquipItem item) - => Remove(item.ItemId); + { + if (item.Id.IsBonusItem) + Remove(item.Id.BonusItem); + return Remove(item.ItemId); + } public bool Remove(ItemId item) { @@ -176,18 +185,18 @@ public class FavoriteManager : ISavable return true; } - public bool Remove(StainId stain) + public bool Remove(BonusItemId item) { - if (!_favoriteColors.Remove(stain)) + if (!_favoriteBonusItems.Remove(item)) return false; Save(); return true; } - public bool Remove(BonusItem bonusItem) + public bool Remove(StainId stain) { - if (!_favoriteBonusItems.Remove(bonusItem.Id)) + if (!_favoriteColors.Remove(stain)) return false; Save(); @@ -204,13 +213,21 @@ public class FavoriteManager : ISavable } public bool Contains(EquipItem item) - => _favorites.Contains(item.ItemId); + { + if (item.Id.IsBonusItem) + return _favoriteBonusItems.Contains(item.Id.BonusItem); + + return _favorites.Contains(item.ItemId); + } public bool Contains(StainId stain) => _favoriteColors.Contains(stain); - public bool Contains(BonusItem bonusItem) - => _favoriteBonusItems.Contains(bonusItem.Id); + public bool Contains(ItemId itemId) + => _favorites.Contains(itemId); + + public bool Contains(BonusItemId bonusItemId) + => _favoriteBonusItems.Contains(bonusItemId); public bool Contains(Gender gender, SubRace race, CustomizeIndex type, CustomizeValue value) => _favoriteHairStyles.Contains(new FavoriteHairStyle(gender, race, type, value)); diff --git a/Penumbra.GameData b/Penumbra.GameData index dd86daf..2f6acca 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit dd86dafb88ca4c7b662938bbc1310729ba7f788d +Subproject commit 2f6acca678b71203763ac4404c3f054747c14f75 From 210bca4c7c5e448dabf308d439fbe8b9cf99348a Mon Sep 17 00:00:00 2001 From: anya-hichu Date: Fri, 11 Oct 2024 19:55:05 +0200 Subject: [PATCH 107/401] Add ResetMaterials option to Design --- Glamourer/Automation/AutoDesignApplier.cs | 6 ++++-- Glamourer/Designs/Design.cs | 3 +++ Glamourer/Designs/DesignManager.cs | 11 +++++++++++ Glamourer/Designs/IDesignStandIn.cs | 2 ++ Glamourer/Designs/Links/DesignMerger.cs | 2 ++ Glamourer/Designs/Links/MergedDesign.cs | 1 + Glamourer/Designs/Special/QuickSelectedDesign.cs | 3 +++ Glamourer/Designs/Special/RandomDesign.cs | 3 +++ Glamourer/Designs/Special/RevertDesign.cs | 3 +++ Glamourer/Events/DesignChanged.cs | 3 +++ Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs | 7 +++++++ 11 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 22048a8..0e30244 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -154,7 +154,7 @@ public sealed class AutoDesignApplier : IDisposable { Reduce(data.Objects[0], state, newSet, _config.RespectManualOnAutomationUpdate, false, out var forcedRedraw); foreach (var actor in data.Objects) - _state.ReapplyState(actor, forcedRedraw,StateSource.Fixed); + _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); } } else if (_objects.TryGetValueAllWorld(id, out data) || _objects.TryGetValueNonOwned(id, out data)) @@ -286,7 +286,9 @@ public sealed class AutoDesignApplier : IDisposable var mergedDesign = _designMerger.Merge( set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); - _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false)); + + var resetMaterials = mergedDesign.ResetMaterials; + _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, resetMaterials)); forcedRedraw = mergedDesign.ForcedRedraw; } diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index fb18873..2add91c 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -45,6 +45,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn public string[] Tags { get; internal set; } = []; public int Index { get; internal set; } public bool ForcedRedraw { get; internal set; } + public bool ResetMaterials { get; internal set; } public bool QuickDesign { get; internal set; } = true; public string Color { get; internal set; } = string.Empty; public SortedList AssociatedMods { get; private set; } = []; @@ -102,6 +103,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn ["Name"] = Name.Text, ["Description"] = Description, ["ForcedRedraw"] = ForcedRedraw, + ["ResetMaterials"] = ResetMaterials, ["Color"] = Color, ["QuickDesign"] = QuickDesign, ["Tags"] = JArray.FromObject(Tags), @@ -244,6 +246,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn LoadLinks(linkLoader, json["Links"], design); design.Color = json["Color"]?.ToObject() ?? string.Empty; design.ForcedRedraw = json["ForcedRedraw"]?.ToObject() ?? false; + design.ResetMaterials = json["ResetMaterials"]?.ToObject() ?? false; return design; static string[] ParseTags(JObject json) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 63c98c0..8342898 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -334,6 +334,17 @@ public sealed class DesignManager : DesignEditor DesignChanged.Invoke(DesignChanged.Type.ForceRedraw, design, null); } + public void ChangeResetMaterials(Design design, bool resetMaterials) + { + if (design.ResetMaterials == resetMaterials) + return; + + design.ResetMaterials = resetMaterials; + SaveService.QueueSave(design); + Glamourer.Log.Debug($"Set {design.Identifier} to {(resetMaterials ? "not" : string.Empty)} reset materials."); + DesignChanged.Invoke(DesignChanged.Type.ResetMaterials, design, null); + } + /// Change whether to apply a specific customize value. public void ChangeApplyCustomize(Design design, CustomizeIndex idx, bool value) { diff --git a/Glamourer/Designs/IDesignStandIn.cs b/Glamourer/Designs/IDesignStandIn.cs index 492bc6b..73a4863 100644 --- a/Glamourer/Designs/IDesignStandIn.cs +++ b/Glamourer/Designs/IDesignStandIn.cs @@ -25,4 +25,6 @@ public interface IDesignStandIn : IEquatable public bool ChangeData(object data); public bool ForcedRedraw { get; } + + public bool ResetMaterials { get; } } diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index 9832ead..73e94c7 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -56,6 +56,8 @@ public class DesignMerger( ReduceMaterials(design, ret); if (design.ForcedRedraw) ret.ForcedRedraw = true; + if (design.ResetMaterials) + ret.ResetMaterials = true; } ApplyFixFlags(ret, fixFlags); diff --git a/Glamourer/Designs/Links/MergedDesign.cs b/Glamourer/Designs/Links/MergedDesign.cs index da6cb54..0fa148a 100644 --- a/Glamourer/Designs/Links/MergedDesign.cs +++ b/Glamourer/Designs/Links/MergedDesign.cs @@ -100,4 +100,5 @@ public sealed class MergedDesign public readonly SortedList AssociatedMods = []; public StateSources Sources = new(); public bool ForcedRedraw; + public bool ResetMaterials; } diff --git a/Glamourer/Designs/Special/QuickSelectedDesign.cs b/Glamourer/Designs/Special/QuickSelectedDesign.cs index c506f0a..476bd62 100644 --- a/Glamourer/Designs/Special/QuickSelectedDesign.cs +++ b/Glamourer/Designs/Special/QuickSelectedDesign.cs @@ -53,4 +53,7 @@ public class QuickSelectedDesign(QuickDesignCombo combo) : IDesignStandIn, IServ public bool ForcedRedraw => combo.Design?.ForcedRedraw ?? false; + + public bool ResetMaterials + => combo.Design?.ResetMaterials ?? false; } diff --git a/Glamourer/Designs/Special/RandomDesign.cs b/Glamourer/Designs/Special/RandomDesign.cs index 5fac61b..54ab4ab 100644 --- a/Glamourer/Designs/Special/RandomDesign.cs +++ b/Glamourer/Designs/Special/RandomDesign.cs @@ -81,4 +81,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public bool ForcedRedraw => false; + + public bool ResetMaterials + => false; } diff --git a/Glamourer/Designs/Special/RevertDesign.cs b/Glamourer/Designs/Special/RevertDesign.cs index 023d5eb..affa203 100644 --- a/Glamourer/Designs/Special/RevertDesign.cs +++ b/Glamourer/Designs/Special/RevertDesign.cs @@ -45,4 +45,7 @@ public class RevertDesign : IDesignStandIn public bool ForcedRedraw => false; + + public bool ResetMaterials + => false; } diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 6c2ba8a..22169c8 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -90,6 +90,9 @@ public sealed class DesignChanged() /// An existing design had changed whether it always forces a redraw or not. ForceRedraw, + /// An existing design had changed whether it always reset materials or not. + ResetMaterials, + /// An existing design changed whether a specific customization is applied. ApplyCustomize, diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index e9fbcf4..fddf8a2 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -143,6 +143,13 @@ public class DesignDetailTab _manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw); ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means."); + var resetMaterials = _selector.Selected!.ResetMaterials; + ImGuiUtil.DrawFrameColumn("Reset Materials"); + ImGui.TableNextColumn(); + if (ImGui.Checkbox("##ResetMaterials", ref resetMaterials)) + _manager.ChangeResetMaterials(_selector.Selected!, resetMaterials); + ImGuiUtil.HoverTooltip("Set this design to reset materials when it is applied through any means."); + ImGuiUtil.DrawFrameColumn("Color"); var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color; ImGui.TableNextColumn(); From cca2bf645fce57a1ad57915967bad260b0168367 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 12 Oct 2024 13:02:30 +0200 Subject: [PATCH 108/401] Fix PR. --- Glamourer/Automation/AutoDesignApplier.cs | 3 +- Glamourer/Designs/Design.cs | 78 ++++++++++--------- Glamourer/Designs/DesignEditor.cs | 4 +- Glamourer/Designs/DesignManager.cs | 10 +-- Glamourer/Designs/IDesignStandIn.cs | 2 +- Glamourer/Designs/Links/DesignMerger.cs | 4 +- Glamourer/Designs/Links/MergedDesign.cs | 2 +- .../Designs/Special/QuickSelectedDesign.cs | 4 +- Glamourer/Designs/Special/RandomDesign.cs | 2 +- Glamourer/Designs/Special/RevertDesign.cs | 4 +- Glamourer/Events/DesignChanged.cs | 4 +- .../Gui/Tabs/DesignTab/DesignDetailTab.cs | 10 +-- Glamourer/State/StateEditor.cs | 2 +- 13 files changed, 65 insertions(+), 64 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 0e30244..fba1a58 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -287,8 +287,7 @@ public sealed class AutoDesignApplier : IDisposable set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); - var resetMaterials = mergedDesign.ResetMaterials; - _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, resetMaterials)); + _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false)); forcedRedraw = mergedDesign.ForcedRedraw; } diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index 2add91c..c58d74f 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -37,19 +37,19 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn // Metadata public new const int FileVersion = 2; - public Guid Identifier { get; internal init; } - public DateTimeOffset CreationDate { get; internal init; } - public DateTimeOffset LastEdit { get; internal set; } - public LowerString Name { get; internal set; } = LowerString.Empty; - public string Description { get; internal set; } = string.Empty; - public string[] Tags { get; internal set; } = []; - public int Index { get; internal set; } - public bool ForcedRedraw { get; internal set; } - public bool ResetMaterials { get; internal set; } - public bool QuickDesign { get; internal set; } = true; - public string Color { get; internal set; } = string.Empty; - public SortedList AssociatedMods { get; private set; } = []; - public LinkContainer Links { get; private set; } = []; + public Guid Identifier { get; internal init; } + public DateTimeOffset CreationDate { get; internal init; } + public DateTimeOffset LastEdit { get; internal set; } + public LowerString Name { get; internal set; } = LowerString.Empty; + public string Description { get; internal set; } = string.Empty; + public string[] Tags { get; internal set; } = []; + public int Index { get; internal set; } + public bool ForcedRedraw { get; internal set; } + public bool ResetAdvancedDyes { get; internal set; } + public bool QuickDesign { get; internal set; } = true; + public string Color { get; internal set; } = string.Empty; + public SortedList AssociatedMods { get; private set; } = []; + public LinkContainer Links { get; private set; } = []; public string Incognito => Identifier.ToString()[..8]; @@ -96,25 +96,25 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn { var ret = new JObject() { - ["FileVersion"] = FileVersion, - ["Identifier"] = Identifier, - ["CreationDate"] = CreationDate, - ["LastEdit"] = LastEdit, - ["Name"] = Name.Text, - ["Description"] = Description, - ["ForcedRedraw"] = ForcedRedraw, - ["ResetMaterials"] = ResetMaterials, - ["Color"] = Color, - ["QuickDesign"] = QuickDesign, - ["Tags"] = JArray.FromObject(Tags), - ["WriteProtected"] = WriteProtected(), - ["Equipment"] = SerializeEquipment(), - ["Bonus"] = SerializeBonusItems(), - ["Customize"] = SerializeCustomize(), - ["Parameters"] = SerializeParameters(), - ["Materials"] = SerializeMaterials(), - ["Mods"] = SerializeMods(), - ["Links"] = Links.Serialize(), + ["FileVersion"] = FileVersion, + ["Identifier"] = Identifier, + ["CreationDate"] = CreationDate, + ["LastEdit"] = LastEdit, + ["Name"] = Name.Text, + ["Description"] = Description, + ["ForcedRedraw"] = ForcedRedraw, + ["ResetAdvancedDyes"] = ResetAdvancedDyes, + ["Color"] = Color, + ["QuickDesign"] = QuickDesign, + ["Tags"] = JArray.FromObject(Tags), + ["WriteProtected"] = WriteProtected(), + ["Equipment"] = SerializeEquipment(), + ["Bonus"] = SerializeBonusItems(), + ["Customize"] = SerializeCustomize(), + ["Parameters"] = SerializeParameters(), + ["Materials"] = SerializeMaterials(), + ["Mods"] = SerializeMods(), + ["Links"] = Links.Serialize(), }; return ret; } @@ -146,7 +146,8 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn #region Deserialization - public static Design LoadDesign(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) + public static Design LoadDesign(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, + JObject json) { var version = json["FileVersion"]?.ToObject() ?? 0; return version switch @@ -158,7 +159,8 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn } /// The values for gloss and specular strength were switched. Swap them for all appropriate designs. - private static Design LoadDesignV1(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json) + private static Design LoadDesignV1(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, + JObject json) { var design = LoadDesignV2(customizations, items, linkLoader, json); var materialDesignData = design.GetMaterialDataRef(); @@ -216,7 +218,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn Glamourer.Messager.AddMessage(new Notification( $"Swapped Gloss and Specular Strength in {materialDesignData.Values.Count} Rows in design {design.Incognito} {reason}", NotificationType.Info)); - saveService.Save(SaveType.ImmediateSync,design); + saveService.Save(SaveType.ImmediateSync, design); } } @@ -244,9 +246,9 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn LoadParameters(json["Parameters"], design, design.Name); LoadMaterials(json["Materials"], design, design.Name); LoadLinks(linkLoader, json["Links"], design); - design.Color = json["Color"]?.ToObject() ?? string.Empty; - design.ForcedRedraw = json["ForcedRedraw"]?.ToObject() ?? false; - design.ResetMaterials = json["ResetMaterials"]?.ToObject() ?? false; + design.Color = json["Color"]?.ToObject() ?? string.Empty; + design.ForcedRedraw = json["ForcedRedraw"]?.ToObject() ?? false; + design.ResetAdvancedDyes = json["ResetAdvancedDyes"]?.ToObject() ?? false; return design; static string[] ParseTags(JObject json) diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index cfda047..448e373 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -304,8 +304,8 @@ public class DesignEditor( /// - public void ApplyDesign(object data, MergedDesign other, ApplySettings _ = default) - => ApplyDesign(data, other.Design); + public void ApplyDesign(object data, MergedDesign other, ApplySettings settings = default) + => ApplyDesign(data, other.Design, settings); /// public void ApplyDesign(object data, DesignBase other, ApplySettings _ = default) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 8342898..a9ea66a 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -334,15 +334,15 @@ public sealed class DesignManager : DesignEditor DesignChanged.Invoke(DesignChanged.Type.ForceRedraw, design, null); } - public void ChangeResetMaterials(Design design, bool resetMaterials) + public void ChangeResetAdvancedDyes(Design design, bool resetAdvancedDyes) { - if (design.ResetMaterials == resetMaterials) + if (design.ResetAdvancedDyes == resetAdvancedDyes) return; - design.ResetMaterials = resetMaterials; + design.ResetAdvancedDyes = resetAdvancedDyes; SaveService.QueueSave(design); - Glamourer.Log.Debug($"Set {design.Identifier} to {(resetMaterials ? "not" : string.Empty)} reset materials."); - DesignChanged.Invoke(DesignChanged.Type.ResetMaterials, design, null); + Glamourer.Log.Debug($"Set {design.Identifier} to {(resetAdvancedDyes ? "not" : string.Empty)} reset advanced dyes."); + DesignChanged.Invoke(DesignChanged.Type.ResetAdvancedDyes, design, null); } /// Change whether to apply a specific customize value. diff --git a/Glamourer/Designs/IDesignStandIn.cs b/Glamourer/Designs/IDesignStandIn.cs index 73a4863..fd76b4b 100644 --- a/Glamourer/Designs/IDesignStandIn.cs +++ b/Glamourer/Designs/IDesignStandIn.cs @@ -26,5 +26,5 @@ public interface IDesignStandIn : IEquatable public bool ForcedRedraw { get; } - public bool ResetMaterials { get; } + public bool ResetAdvancedDyes { get; } } diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index 73e94c7..5767c7a 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -56,8 +56,8 @@ public class DesignMerger( ReduceMaterials(design, ret); if (design.ForcedRedraw) ret.ForcedRedraw = true; - if (design.ResetMaterials) - ret.ResetMaterials = true; + if (design.ResetAdvancedDyes) + ret.ResetAdvancedDyes = true; } ApplyFixFlags(ret, fixFlags); diff --git a/Glamourer/Designs/Links/MergedDesign.cs b/Glamourer/Designs/Links/MergedDesign.cs index 0fa148a..0748633 100644 --- a/Glamourer/Designs/Links/MergedDesign.cs +++ b/Glamourer/Designs/Links/MergedDesign.cs @@ -100,5 +100,5 @@ public sealed class MergedDesign public readonly SortedList AssociatedMods = []; public StateSources Sources = new(); public bool ForcedRedraw; - public bool ResetMaterials; + public bool ResetAdvancedDyes; } diff --git a/Glamourer/Designs/Special/QuickSelectedDesign.cs b/Glamourer/Designs/Special/QuickSelectedDesign.cs index 476bd62..1919929 100644 --- a/Glamourer/Designs/Special/QuickSelectedDesign.cs +++ b/Glamourer/Designs/Special/QuickSelectedDesign.cs @@ -54,6 +54,6 @@ public class QuickSelectedDesign(QuickDesignCombo combo) : IDesignStandIn, IServ public bool ForcedRedraw => combo.Design?.ForcedRedraw ?? false; - public bool ResetMaterials - => combo.Design?.ResetMaterials ?? false; + public bool ResetAdvancedDyes + => combo.Design?.ResetAdvancedDyes ?? false; } diff --git a/Glamourer/Designs/Special/RandomDesign.cs b/Glamourer/Designs/Special/RandomDesign.cs index 54ab4ab..bbb9b7d 100644 --- a/Glamourer/Designs/Special/RandomDesign.cs +++ b/Glamourer/Designs/Special/RandomDesign.cs @@ -82,6 +82,6 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public bool ForcedRedraw => false; - public bool ResetMaterials + public bool ResetAdvancedDyes => false; } diff --git a/Glamourer/Designs/Special/RevertDesign.cs b/Glamourer/Designs/Special/RevertDesign.cs index affa203..5f8d8c6 100644 --- a/Glamourer/Designs/Special/RevertDesign.cs +++ b/Glamourer/Designs/Special/RevertDesign.cs @@ -46,6 +46,6 @@ public class RevertDesign : IDesignStandIn public bool ForcedRedraw => false; - public bool ResetMaterials - => false; + public bool ResetAdvancedDyes + => true; } diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 22169c8..8cd8f5c 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -90,8 +90,8 @@ public sealed class DesignChanged() /// An existing design had changed whether it always forces a redraw or not. ForceRedraw, - /// An existing design had changed whether it always reset materials or not. - ResetMaterials, + /// An existing design had changed whether it always resets advanced dyes or not. + ResetAdvancedDyes, /// An existing design changed whether a specific customization is applied. ApplyCustomize, diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index fddf8a2..fea444c 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -143,12 +143,12 @@ public class DesignDetailTab _manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw); ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means."); - var resetMaterials = _selector.Selected!.ResetMaterials; - ImGuiUtil.DrawFrameColumn("Reset Materials"); + var resetMaterials = _selector.Selected!.ResetAdvancedDyes; + ImGuiUtil.DrawFrameColumn("Reset Advanced Dyes"); ImGui.TableNextColumn(); - if (ImGui.Checkbox("##ResetMaterials", ref resetMaterials)) - _manager.ChangeResetMaterials(_selector.Selected!, resetMaterials); - ImGuiUtil.HoverTooltip("Set this design to reset materials when it is applied through any means."); + if (ImGui.Checkbox("##ResetAdvancedDyes", ref resetMaterials)) + _manager.ChangeResetAdvancedDyes(_selector.Selected!, resetMaterials); + ImGuiUtil.HoverTooltip("Set this design to reset any previously applied advanced dyes when it is applied through any means."); ImGuiUtil.DrawFrameColumn("Color"); var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color; diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 633fc10..d74ddf7 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -380,7 +380,7 @@ public class StateEditor( Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key); } - if (settings.ResetMaterials) + if (settings.ResetMaterials || mergedDesign.ResetAdvancedDyes) state.Materials.Clear(); foreach (var (key, value) in mergedDesign.Design.Materials) From da944b50cc41c65fb0e162d47acb842442ff1393 Mon Sep 17 00:00:00 2001 From: anya-hichu Date: Sat, 12 Oct 2024 14:48:57 +0200 Subject: [PATCH 109/401] Fix inverted log --- Glamourer/Designs/DesignManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index a9ea66a..15e38ee 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -330,7 +330,7 @@ public sealed class DesignManager : DesignEditor design.ForcedRedraw = forcedRedraw; SaveService.QueueSave(design); - Glamourer.Log.Debug($"Set {design.Identifier} to {(forcedRedraw ? "not" : string.Empty)} force redraws."); + Glamourer.Log.Debug($"Set {design.Identifier} to {(forcedRedraw ? string.Empty : "not")} force redraws."); DesignChanged.Invoke(DesignChanged.Type.ForceRedraw, design, null); } @@ -341,7 +341,7 @@ public sealed class DesignManager : DesignEditor design.ResetAdvancedDyes = resetAdvancedDyes; SaveService.QueueSave(design); - Glamourer.Log.Debug($"Set {design.Identifier} to {(resetAdvancedDyes ? "not" : string.Empty)} reset advanced dyes."); + Glamourer.Log.Debug($"Set {design.Identifier} to {(resetAdvancedDyes ? string.Empty : "not")} reset advanced dyes."); DesignChanged.Invoke(DesignChanged.Type.ResetAdvancedDyes, design, null); } From 11111817d765b73130021a7928d09897231a6aac Mon Sep 17 00:00:00 2001 From: anya-hichu Date: Sat, 12 Oct 2024 15:02:55 +0200 Subject: [PATCH 110/401] Fix DesignInfoTable width --- Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index fea444c..0742197 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -58,7 +58,7 @@ public class DesignDetailTab if (!table) return; - ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); + ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Reset Advanced Dyes").X); ImGui.TableSetupColumn("Data", ImGuiTableColumnFlags.WidthStretch); ImGuiUtil.DrawFrameColumn("Design Name"); From 6db4a9623b548e7475bd9d5bef90b4a32a7aae99 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 12 Oct 2024 15:14:03 +0200 Subject: [PATCH 111/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 2f6acca..63cbf82 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 2f6acca678b71203763ac4404c3f054747c14f75 +Subproject commit 63cbf824178b5b1f91fd9edc22a6c2bbc2e1cd23 From 530166b81a8d9424876698f2549c278d80b8ab70 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 12 Oct 2024 13:16:00 +0000 Subject: [PATCH 112/401] [CI] Updating repo.json for testing_1.3.2.1 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index f3ea329..13c0105 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.2.0", - "TestingAssemblyVersion": "1.3.2.0", + "TestingAssemblyVersion": "1.3.2.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.2.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 87d8876972291724fdbc210c77208ca01df418e6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 13 Oct 2024 14:40:37 +0200 Subject: [PATCH 113/401] Fix some bonus item related things. --- Glamourer/Designs/DesignData.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs | 15 +++++++++++++-- Glamourer/Services/ItemManager.cs | 4 ++-- Penumbra.GameData | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index 3e32eac..4205996 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -112,7 +112,7 @@ public unsafe struct DesignData => slot switch { // @formatter:off - BonusItemFlag.Glasses => EquipItem.FromIds(_bonusIds[0], _iconIds[12], _bonusModelIds[0], 0, _bonusVariants[0], FullEquipType.Glasses, 0, _nameGlasses), + BonusItemFlag.Glasses => EquipItem.FromBonusIds(_bonusIds[0], _iconIds[12], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses, _nameGlasses), _ => EquipItem.BonusItemNothing(slot), // @formatter:on }; diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index c875cf1..f5fe088 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -9,7 +9,6 @@ using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; -using FFXIVClientStructs.FFXIV.Shader; namespace Glamourer.Gui.Tabs.DebugTab; @@ -67,7 +66,13 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM static string ItemString(in DesignData data, EquipSlot slot) { var item = data.Item(slot); - return $"{item.Name} ({item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; + return $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; + } + + static string BonusItemString(in DesignData data, BonusItemFlag slot) + { + var item = data.BonusItem(slot); + return $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; } PrintRow("Model ID", state.BaseData.ModelId, state.ModelData.ModelId, state.Sources[MetaIndex.ModelId]); @@ -93,6 +98,12 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM ImGuiUtil.DrawTableColumn(state.Sources[slot, true].ToString()); } + foreach (var slot in BonusExtensions.AllFlags) + { + PrintRow(slot.ToName(), BonusItemString(state.BaseData, slot), BonusItemString(state.ModelData, slot), state.Sources[slot]); + ImGui.TableNextRow(); + } + foreach (var type in Enum.GetValues()) { PrintRow(type.ToDefaultName(), state.BaseData.Customize[type].Value, state.ModelData.Customize[type].Value, diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 6e55888..07a4829 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -142,7 +142,7 @@ public class ItemManager public EquipItem Resolve(BonusItemFlag slot, CustomItemId id) { // Only from early designs as migration. - if (!id.IsBonusItem) + if (!id.IsBonusItem || id.Id == 0) { IsBonusItemValid(slot, (BonusItemId)id.Id, out var item); return item; @@ -207,7 +207,7 @@ public class ItemManager if (itemId.Id != 0) return DictBonusItems.TryGetValue(itemId, out item) && slot == item.Type.ToBonus(); - item = new EquipItem(Nothing, (BonusItemId)0, 0, 0, 0, 0, slot.ToEquipType(), 0, 0, 0); + item = EquipItem.BonusItemNothing(slot); return true; } diff --git a/Penumbra.GameData b/Penumbra.GameData index 63cbf82..554e28a 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 63cbf824178b5b1f91fd9edc22a6c2bbc2e1cd23 +Subproject commit 554e28a3d1fca9394a20fd9856f6387e2a5e4a57 From 667ff2490df2a63de63cfb3662fd2889c6400253 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 13 Oct 2024 12:42:47 +0000 Subject: [PATCH 114/401] [CI] Updating repo.json for testing_1.3.2.2 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 13c0105..d4497b4 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.2.0", - "TestingAssemblyVersion": "1.3.2.1", + "TestingAssemblyVersion": "1.3.2.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.2.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.2.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c49102959f9790f2a7140c9dd9302f37adc34b92 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 18 Oct 2024 15:34:39 +0200 Subject: [PATCH 115/401] Add tails and Height 255 to available NPC options. --- Glamourer/GameData/CustomizeManager.cs | 1 - Glamourer/GameData/CustomizeSetFactory.cs | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Glamourer/GameData/CustomizeManager.cs b/Glamourer/GameData/CustomizeManager.cs index 5a06cf4..9e065b4 100644 --- a/Glamourer/GameData/CustomizeManager.cs +++ b/Glamourer/GameData/CustomizeManager.cs @@ -1,5 +1,4 @@ using Dalamud.Interface.Textures; -using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Plugin.Services; using OtterGui.Classes; using OtterGui.Services; diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index 850c7c9..f626750 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -84,9 +84,13 @@ internal class CustomizeSetFactory( CustomizeIndex.TattooColor, CustomizeIndex.EyeColorLeft, CustomizeIndex.EyeColorRight, + CustomizeIndex.TailShape, }; - var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)>(); + var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)>() + { + (CustomizeIndex.Height, CustomizeValue.Max), + }; _npcCustomizeSet.Awaiter.Wait(); foreach (var customize in _npcCustomizeSet.Select(s => s.Customize) .Where(c => c.Clan == race && c.Gender == gender && c.BodyType.Value == 1)) From 4738830b8a32c9ca549a055910450af85a02a79b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 18 Oct 2024 16:02:30 +0200 Subject: [PATCH 116/401] 1.3.3.0 --- Glamourer/Gui/GlamourerChangelog.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 77a5788..4826839 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -36,6 +36,7 @@ public class GlamourerChangelog Add1_2_3_0(Changelog); Add1_3_1_0(Changelog); Add1_3_2_0(Changelog); + Add1_3_3_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -56,6 +57,14 @@ public class GlamourerChangelog } } + private static void Add1_3_3_0(Changelog log) + => log.NextVersion("Version 1.3.3.0") + .RegisterHighlight("Added the option to create automations for owned human NPCs (like trust avatars).") + .RegisterEntry("Added some special filters to the Actors tab selector, hover over it to see the options.") + .RegisterEntry("Added an option for designs to always reset all previously applied advanced dyes.") + .RegisterEntry("Added some new NPC-only customizations to the valid customizations.") + .RegisterEntry("Reworked quite a bit of things around face wear / bonus items. Please let me know if anything broke."); + private static void Add1_3_2_0(Changelog log) => log.NextVersion("Version 1.3.2.0") .RegisterEntry("Fixed an issue with weapon hiding when leaving GPose or changing zones.") From dd217a24759e24d7525317753838b7b696574ff8 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 18 Oct 2024 14:26:43 +0000 Subject: [PATCH 117/401] [CI] Updating repo.json for 1.3.3.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index d4497b4..b309240 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.2.0", - "TestingAssemblyVersion": "1.3.2.2", + "AssemblyVersion": "1.3.3.0", + "TestingAssemblyVersion": "1.3.3.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.2.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.2.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From a5998b84ba60c134707d1d2a801cc172ff23efad Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Nov 2024 10:20:30 +0100 Subject: [PATCH 118/401] Fix issues with ResetAdvancedDyes and weapon types. --- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 2 +- Glamourer/Gui/Equipment/WeaponCombo.cs | 2 +- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 10 +++++++--- Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs | 6 +++--- Glamourer/State/StateEditor.cs | 2 +- Penumbra.GameData | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 38c8263..601d3ae 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -558,7 +558,7 @@ public class EquipmentDrawer label = combo.Label; var locked = offhand.Locked - || !_gPose.InGPose && (offhand.CurrentItem.Type is FullEquipType.Unknown || mainhand.CurrentItem.Type is FullEquipType.Unknown); + || !_gPose.InGPose && (offhand.CurrentItem.Type.IsUnknown() || mainhand.CurrentItem.Type.IsUnknown()); using var disabled = ImRaii.Disabled(locked); if (!locked && open) UiHelpers.OpenCombo($"##{combo.Label}"); diff --git a/Glamourer/Gui/Equipment/WeaponCombo.cs b/Glamourer/Gui/Equipment/WeaponCombo.cs index 67f09f5..37d9d3c 100644 --- a/Glamourer/Gui/Equipment/WeaponCombo.cs +++ b/Glamourer/Gui/Equipment/WeaponCombo.cs @@ -81,7 +81,7 @@ public sealed class WeaponCombo : FilterComboCache => obj.Name; private static string GetLabel(FullEquipType type) - => type is FullEquipType.Unknown ? "Mainhand" : type.ToName(); + => type.IsUnknown() ? "Mainhand" : type.ToName(); private static IReadOnlyList GetWeapons(FavoriteManager favorites, ItemManager items, FullEquipType type) { diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index c6f2fc4..68ba18e 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -28,8 +28,10 @@ public sealed class PenumbraChangedItemTooltip : IDisposable => EquipSlotExtensions.EqdpSlots.Append(EquipSlot.MainHand).Append(EquipSlot.OffHand).Zip(_lastItems) .Select(p => new KeyValuePair(p.First, p.Second)); - public DateTime LastTooltip { get; private set; } = DateTime.MinValue; - public DateTime LastClick { get; private set; } = DateTime.MinValue; + public ChangedItemType LastType { get; private set; } = ChangedItemType.None; + public uint LastId { get; private set; } = 0; + public DateTime LastTooltip { get; private set; } = DateTime.MinValue; + public DateTime LastClick { get; private set; } = DateTime.MinValue; public PenumbraChangedItemTooltip(PenumbraService penumbra, StateManager stateManager, ItemManager items, ObjectManager objects, CustomizeService customize, GPoseService gpose) @@ -160,6 +162,8 @@ public sealed class PenumbraChangedItemTooltip : IDisposable private void OnPenumbraTooltip(ChangedItemType type, uint id) { + LastType = type; + LastId = id; LastTooltip = DateTime.UtcNow; if (!Player()) return; @@ -204,7 +208,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable return true; var main = _objects.Player.GetMainhand(); - var mainItem = _items.Identify(slot, main.Skeleton, main.Weapon, main.Variant); + var mainItem = _items.Identify(EquipSlot.MainHand, main.Skeleton, main.Weapon, main.Variant); if (slot == EquipSlot.MainHand) return item.Type == mainItem.Type; diff --git a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index f1097e8..3714c82 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -76,7 +76,7 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem } ImGuiUtil.DrawTableColumn("Last Tooltip Date"); - ImGuiUtil.DrawTableColumn(_penumbraTooltip.LastTooltip > DateTime.MinValue ? _penumbraTooltip.LastTooltip.ToLongTimeString() : "Never"); + ImGuiUtil.DrawTableColumn(_penumbraTooltip.LastTooltip > DateTime.MinValue ? $"{_penumbraTooltip.LastTooltip.ToLongTimeString()} ({_penumbraTooltip.LastType} {_penumbraTooltip.LastId})" : "Never"); ImGui.TableNextColumn(); ImGuiUtil.DrawTableColumn("Last Click Date"); diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index 0742197..bd74772 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -143,11 +143,11 @@ public class DesignDetailTab _manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw); ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means."); - var resetMaterials = _selector.Selected!.ResetAdvancedDyes; + var resetAdvancedDyes = _selector.Selected!.ResetAdvancedDyes; ImGuiUtil.DrawFrameColumn("Reset Advanced Dyes"); ImGui.TableNextColumn(); - if (ImGui.Checkbox("##ResetAdvancedDyes", ref resetMaterials)) - _manager.ChangeResetAdvancedDyes(_selector.Selected!, resetMaterials); + if (ImGui.Checkbox("##ResetAdvancedDyes", ref resetAdvancedDyes)) + _manager.ChangeResetAdvancedDyes(_selector.Selected!, resetAdvancedDyes); ImGuiUtil.HoverTooltip("Set this design to reset any previously applied advanced dyes when it is applied through any means."); ImGuiUtil.DrawFrameColumn("Color"); diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index d74ddf7..959d810 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -380,7 +380,7 @@ public class StateEditor( Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key); } - if (settings.ResetMaterials || mergedDesign.ResetAdvancedDyes) + if (settings.ResetMaterials || (!settings.RespectManual && mergedDesign.ResetAdvancedDyes)) state.Materials.Clear(); foreach (var (key, value) in mergedDesign.Design.Materials) diff --git a/Penumbra.GameData b/Penumbra.GameData index 554e28a..77d52b0 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 554e28a3d1fca9394a20fd9856f6387e2a5e4a57 +Subproject commit 77d52b02d21e770b30c08f89bdf06e0cb75562f7 From 2ce8076e9a5e1f1ee6cb5ea812a4f241323bdfc1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 16 Nov 2024 21:57:17 +0100 Subject: [PATCH 119/401] Current State. --- Glamourer/GameData/CharaMakeParams.cs | 126 -------------- Glamourer/GameData/CustomizeSet.cs | 41 ++--- Glamourer/GameData/CustomizeSetFactory.cs | 159 ++++++++---------- Glamourer/GameData/MenuType.cs | 14 ++ Glamourer/GameData/NpcCustomizeSet.cs | 81 +++++---- Glamourer/Glamourer.json | 2 +- .../Customization/CustomizationDrawer.Icon.cs | 2 +- .../Gui/Customization/CustomizationDrawer.cs | 12 +- Glamourer/Gui/Equipment/BonusItemCombo.cs | 6 +- Glamourer/Gui/Equipment/ItemCombo.cs | 24 +-- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 2 +- Glamourer/Interop/CrestService.cs | 12 +- Glamourer/Interop/ScalingService.cs | 32 ++-- Glamourer/Services/CommandService.cs | 2 +- Glamourer/Services/ItemManager.cs | 17 +- Glamourer/Unlocks/CustomizeUnlockManager.cs | 16 +- Glamourer/Unlocks/ItemUnlockManager.cs | 31 ++-- OtterGui | 2 +- Penumbra.GameData | 2 +- repo.json | 2 +- 20 files changed, 226 insertions(+), 359 deletions(-) delete mode 100644 Glamourer/GameData/CharaMakeParams.cs create mode 100644 Glamourer/GameData/MenuType.cs diff --git a/Glamourer/GameData/CharaMakeParams.cs b/Glamourer/GameData/CharaMakeParams.cs deleted file mode 100644 index 4db5825..0000000 --- a/Glamourer/GameData/CharaMakeParams.cs +++ /dev/null @@ -1,126 +0,0 @@ -using Lumina.Data; -using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; - -namespace Glamourer.GameData; - -/// A custom version of CharaMakeParams that is easier to parse. -[Sheet("CharaMakeParams")] -public class CharaMakeParams : ExcelRow -{ - public const int NumMenus = 28; - public const int NumVoices = 12; - public const int NumGraphics = 10; - public const int MaxNumValues = 100; - public const int NumFaces = 8; - public const int NumFeatures = 7; - public const int NumEquip = 3; - - public enum MenuType - { - ListSelector = 0, - IconSelector = 1, - ColorPicker = 2, - DoubleColorPicker = 3, - IconCheckmark = 4, - Percentage = 5, - Checkmark = 6, // custom - Nothing = 7, // custom - List1Selector = 8, // custom, 1-indexed lists - } - - public struct Menu - { - public uint Id; - public byte InitVal; - public MenuType Type; - public byte Size; - public byte LookAt; - public uint Mask; - public uint Customize; - public uint[] Values; - public byte[] Graphic; - } - - public struct FacialFeatures - { - public uint[] Icons; - } - - public LazyRow Race { get; set; } = null!; - public LazyRow Tribe { get; set; } = null!; - public sbyte Gender { get; set; } - - public Menu[] Menus { get; set; } = new Menu[NumMenus]; - public byte[] Voices { get; set; } = new byte[NumVoices]; - public FacialFeatures[] FacialFeatureByFace { get; set; } = new FacialFeatures[NumFaces]; - - public CharaMakeType.CharaMakeTypeUnkData3347Obj[] Equip { get; set; } = new CharaMakeType.CharaMakeTypeUnkData3347Obj[NumEquip]; - - public override void PopulateData(RowParser parser, Lumina.GameData gameData, Language language) - { - RowId = parser.RowId; - SubRowId = parser.SubRowId; - Race = new LazyRow(gameData, parser.ReadColumn(0), language); - Tribe = new LazyRow(gameData, parser.ReadColumn(1), language); - Gender = parser.ReadColumn(2); - int currentOffset; - for (var i = 0; i < NumMenus; ++i) - { - currentOffset = 3 + i; - Menus[i].Id = parser.ReadColumn(0 * NumMenus + currentOffset); - Menus[i].InitVal = parser.ReadColumn(1 * NumMenus + currentOffset); - Menus[i].Type = (MenuType)parser.ReadColumn(2 * NumMenus + currentOffset); - Menus[i].Size = parser.ReadColumn(3 * NumMenus + currentOffset); - Menus[i].LookAt = parser.ReadColumn(4 * NumMenus + currentOffset); - Menus[i].Mask = parser.ReadColumn(5 * NumMenus + currentOffset); - Menus[i].Customize = parser.ReadColumn(6 * NumMenus + currentOffset); - Menus[i].Values = new uint[Menus[i].Size]; - - switch (Menus[i].Type) - { - case MenuType.ColorPicker: - case MenuType.DoubleColorPicker: - case MenuType.Percentage: - break; - default: - currentOffset += 7 * NumMenus; - for (var j = 0; j < Menus[i].Size; ++j) - Menus[i].Values[j] = parser.ReadColumn(j * NumMenus + currentOffset); - break; - } - - Menus[i].Graphic = new byte[NumGraphics]; - currentOffset = 3 + (MaxNumValues + 7) * NumMenus + i; - for (var j = 0; j < NumGraphics; ++j) - Menus[i].Graphic[j] = parser.ReadColumn(j * NumMenus + currentOffset); - } - - currentOffset = 3 + (MaxNumValues + 7 + NumGraphics) * NumMenus; - for (var i = 0; i < NumVoices; ++i) - Voices[i] = parser.ReadColumn(currentOffset++); - - for (var i = 0; i < NumFaces; ++i) - { - currentOffset = 3 + (MaxNumValues + 7 + NumGraphics) * NumMenus + NumVoices + i; - FacialFeatureByFace[i].Icons = new uint[NumFeatures]; - for (var j = 0; j < NumFeatures; ++j) - FacialFeatureByFace[i].Icons[j] = (uint)parser.ReadColumn(j * NumFaces + currentOffset); - } - - for (var i = 0; i < NumEquip; ++i) - { - currentOffset = 3 + (MaxNumValues + 7 + NumGraphics) * NumMenus + NumVoices + NumFaces * NumFeatures + i * 7; - Equip[i] = new CharaMakeType.CharaMakeTypeUnkData3347Obj() - { - Helmet = parser.ReadColumn(currentOffset + 0), - Top = parser.ReadColumn(currentOffset + 1), - Gloves = parser.ReadColumn(currentOffset + 2), - Legs = parser.ReadColumn(currentOffset + 3), - Shoes = parser.ReadColumn(currentOffset + 4), - Weapon = parser.ReadColumn(currentOffset + 5), - SubWeapon = parser.ReadColumn(currentOffset + 6), - }; - } - } -} diff --git a/Glamourer/GameData/CustomizeSet.cs b/Glamourer/GameData/CustomizeSet.cs index 0c80e13..7fcf1d2 100644 --- a/Glamourer/GameData/CustomizeSet.cs +++ b/Glamourer/GameData/CustomizeSet.cs @@ -1,6 +1,7 @@ using OtterGui; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; +using Race = Penumbra.GameData.Enums.Race; namespace Glamourer.GameData; @@ -38,9 +39,9 @@ public class CustomizeSet public string Option(CustomizeIndex index) => OptionName[(int)index]; - public IReadOnlyList Voices { get; internal init; } = null!; - public IReadOnlyList Types { get; internal set; } = null!; - public IReadOnlyDictionary Order { get; internal set; } = null!; + public IReadOnlyList Voices { get; internal init; } = null!; + public IReadOnlyList Types { get; internal set; } = null!; + public IReadOnlyDictionary Order { get; internal set; } = null!; // Always list selector. @@ -97,9 +98,9 @@ public class CustomizeSet return type switch { - CharaMakeParams.MenuType.ListSelector => GetInteger0(out custom), - CharaMakeParams.MenuType.List1Selector => GetInteger1(out custom), - CharaMakeParams.MenuType.IconSelector => index switch + MenuType.ListSelector => GetInteger0(out custom), + MenuType.List1Selector => GetInteger1(out custom), + MenuType.IconSelector => index switch { CustomizeIndex.Face => Get(Faces, HrothgarFaceHack(value), out custom), CustomizeIndex.Hairstyle => Get((face = HrothgarFaceHack(face)).Value < HairByFace.Count ? HairByFace[face.Value] : HairStyles, @@ -109,7 +110,7 @@ public class CustomizeSet CustomizeIndex.LipColor => Get(LipColorsDark, value, out custom), _ => Invalid(out custom), }, - CharaMakeParams.MenuType.ColorPicker => index switch + MenuType.ColorPicker => index switch { CustomizeIndex.SkinColor => Get(SkinColors, value, out custom), CustomizeIndex.EyeColorLeft => Get(EyeColors, value, out custom), @@ -121,16 +122,16 @@ public class CustomizeSet CustomizeIndex.FacePaintColor => Get(FacePaintColorsDark.Concat(FacePaintColorsLight), value, out custom), _ => Invalid(out custom), }, - CharaMakeParams.MenuType.DoubleColorPicker => index switch + MenuType.DoubleColorPicker => index switch { CustomizeIndex.LipColor => Get(LipColorsDark.Concat(LipColorsLight), value, out custom), CustomizeIndex.FacePaintColor => Get(FacePaintColorsDark.Concat(FacePaintColorsLight), value, out custom), _ => Invalid(out custom), }, - CharaMakeParams.MenuType.IconCheckmark => GetBool(index, value, out custom), - CharaMakeParams.MenuType.Percentage => GetInteger0(out custom), - CharaMakeParams.MenuType.Checkmark => GetBool(index, value, out custom), - _ => Invalid(out custom), + MenuType.IconCheckmark => GetBool(index, value, out custom), + MenuType.Percentage => GetInteger0(out custom), + MenuType.Checkmark => GetBool(index, value, out custom), + _ => Invalid(out custom), }; int Get(IEnumerable list, CustomizeValue v, out CustomizeData? output) @@ -208,10 +209,10 @@ public class CustomizeSet switch (Types[(int)index]) { - case CharaMakeParams.MenuType.Percentage: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx); - case CharaMakeParams.MenuType.ListSelector: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx); - case CharaMakeParams.MenuType.List1Selector: return new CustomizeData(index, (CustomizeValue)(idx + 1), 0, (ushort)idx); - case CharaMakeParams.MenuType.Checkmark: return new CustomizeData(index, CustomizeValue.Bool(idx != 0), 0, (ushort)idx); + case MenuType.Percentage: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx); + case MenuType.ListSelector: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx); + case MenuType.List1Selector: return new CustomizeData(index, (CustomizeValue)(idx + 1), 0, (ushort)idx); + case MenuType.Checkmark: return new CustomizeData(index, CustomizeValue.Bool(idx != 0), 0, (ushort)idx); } return index switch @@ -241,7 +242,7 @@ public class CustomizeSet } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public CharaMakeParams.MenuType Type(CustomizeIndex index) + public MenuType Type(CustomizeIndex index) => Types[(int)index]; [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] @@ -256,9 +257,9 @@ public class CustomizeSet return Type(index) switch { - CharaMakeParams.MenuType.Percentage => 101, - CharaMakeParams.MenuType.IconCheckmark => 2, - CharaMakeParams.MenuType.Checkmark => 2, + MenuType.Percentage => 101, + MenuType.IconCheckmark => 2, + MenuType.Checkmark => 2, _ => index switch { CustomizeIndex.Face => Faces.Count, diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index f626750..36cdb1b 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -1,10 +1,10 @@ -using Dalamud; -using Dalamud.Game; +using Dalamud.Game; using Dalamud.Plugin.Services; using Dalamud.Utility; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using OtterGui.Classes; +using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using Race = Penumbra.GameData.Enums.Race; @@ -32,7 +32,7 @@ internal class CustomizeSetFactory( var set = new CustomizeSet(race, gender) { Name = GetName(race, gender), - Voices = row.Voices, + Voices = row.VoiceStruct, HairStyles = GetHairStyles(race, gender), HairColors = hair, SkinColors = skin, @@ -59,7 +59,7 @@ internal class CustomizeSetFactory( } /// Some data can not be set independently of the rest, so we need a post-processing step to finalize. - private void SetPostProcessing(CustomizeSet set, CharaMakeParams row) + private void SetPostProcessing(CustomizeSet set, in CharaMakeType row) { SetAvailability(set, row); SetFacialFeatures(set, row); @@ -112,10 +112,10 @@ internal class CustomizeSetFactory( } private readonly ColorParameters _colorParameters = new(_gameData, _log); - private readonly ExcelSheet _customizeSheet = _gameData.GetExcelSheet(ClientLanguage.English)!; - private readonly ExcelSheet _lobbySheet = _gameData.GetExcelSheet(ClientLanguage.English)!; - private readonly ExcelSheet _hairSheet = _gameData.GetExcelSheet(ClientLanguage.English)!; - private readonly ExcelSheet _tribeSheet = _gameData.GetExcelSheet(ClientLanguage.English)!; + private readonly ExcelSheet _customizeSheet = _gameData.GetExcelSheet(ClientLanguage.English); + private readonly ExcelSheet _lobbySheet = _gameData.GetExcelSheet(ClientLanguage.English); + private readonly ExcelSheet _hairSheet = _gameData.GetExcelSheet(ClientLanguage.English, "HairMakeType"); + private readonly ExcelSheet _tribeSheet = _gameData.GetExcelSheet(ClientLanguage.English); // Those color pickers are shared between all races. private readonly CustomizeData[] _highlightPicker = CreateColors(_colors, CustomizeIndex.HighlightsColor, 256, 192); @@ -126,12 +126,7 @@ internal class CustomizeSetFactory( private readonly CustomizeData[] _facePaintColorPickerLight = CreateColors(_colors, CustomizeIndex.FacePaintColor, 1152, 96, true); private readonly CustomizeData[] _tattooColorPicker = CreateColors(_colors, CustomizeIndex.TattooColor, 0, 192); - private readonly ExcelSheet _charaMakeSheet = _gameData.Excel - .GetType() - .GetMethod("GetSheet", BindingFlags.Instance | BindingFlags.NonPublic)? - .MakeGenericMethod(typeof(CharaMakeParams)) - .Invoke(_gameData.Excel, ["charamaketype", _gameData.Language.ToLumina(), null])! as ExcelSheet - ?? null!; + private readonly ExcelSheet _charaMakeSheet = _gameData.Excel.GetSheet(); /// Obtain available skin and hair colors for the given clan and gender. private (CustomizeData[] Skin, CustomizeData[] Hair) GetSkinHairColors(SubRace race, Gender gender) @@ -150,29 +145,28 @@ internal class CustomizeSetFactory( private string GetName(SubRace race, Gender gender) => gender switch { - Gender.Male => _tribeSheet.GetRow((uint)race)?.Masculine.ToDalamudString().TextValue ?? race.ToName(), - Gender.Female => _tribeSheet.GetRow((uint)race)?.Feminine.ToDalamudString().TextValue ?? race.ToName(), + Gender.Male => _tribeSheet.TryGetRow((uint)race, out var row) ? row.Masculine.ExtractText() : race.ToName(), + Gender.Female => _tribeSheet.TryGetRow((uint)race, out var row) ? row.Feminine.ExtractText() : race.ToName(), _ => "Unknown", }; /// Obtain available hairstyles via reflection from the Hair sheet for the given subrace and gender. private CustomizeData[] GetHairStyles(SubRace race, Gender gender) { - var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender)!; + var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender); // Unknown30 is the number of available hairstyles. - var hairList = new List(row.Unknown30); + var numHairs = row.ReadUInt8Column(30); + var hairList = new List(numHairs); // Hairstyles can be found starting at Unknown66. - for (var i = 0; i < row.Unknown30; ++i) + for (var i = 0; i < numHairs; ++i) { - var name = $"Unknown{66 + i * 9}"; - var customizeIdx = (uint?)row.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance)?.GetValue(row) - ?? uint.MaxValue; + // Hairs start at Unknown66. + var customizeIdx = row.ReadUInt32Column(66 + i * 9); if (customizeIdx == uint.MaxValue) continue; // Hair Row from CustomizeSheet might not be set in case of unlockable hair. - var hairRow = _customizeSheet.GetRow(customizeIdx); - if (hairRow == null) + if (_customizeSheet.TryGetRow(customizeIdx, out var hairRow)) hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)i, customizeIdx)); else if (_icons.IconExists(hairRow.Icon)) hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)hairRow.FeatureID, hairRow.Icon, @@ -183,45 +177,40 @@ internal class CustomizeSetFactory( } /// Specific icons for tails or ears. - private CustomizeData[] GetTailEarShapes(CharaMakeParams row) - => row.Menus.Cast() - .FirstOrDefault(m => m!.Value.Customize == CustomizeIndex.TailShape.ToByteAndMask().ByteIdx)?.Values - .Select((v, i) => FromValueAndIndex(CustomizeIndex.TailShape, v, i)).ToArray() - ?? []; + private CustomizeData[] GetTailEarShapes(CharaMakeType row) + => ExtractValues(row, CustomizeIndex.TailShape); /// Specific icons for faces. - private CustomizeData[] GetFaces(CharaMakeParams row) - => row.Menus.Cast().FirstOrDefault(m => m!.Value.Customize == CustomizeIndex.Face.ToByteAndMask().ByteIdx) - ?.Values - .Select((v, i) => FromValueAndIndex(CustomizeIndex.Face, v, i)).ToArray() - ?? []; + private CustomizeData[] GetFaces(CharaMakeType row) + => ExtractValues(row, CustomizeIndex.Face); /// Specific icons for Hrothgar patterns. - private CustomizeData[] HrothgarFurPattern(CharaMakeParams row) - => row.Menus.Cast() - .FirstOrDefault(m => m!.Value.Customize == CustomizeIndex.LipColor.ToByteAndMask().ByteIdx)?.Values - .Select((v, i) => FromValueAndIndex(CustomizeIndex.LipColor, v, i)).ToArray() - ?? []; + private CustomizeData[] HrothgarFurPattern(CharaMakeType row) + => ExtractValues(row, CustomizeIndex.LipColor); + + private CustomizeData[] ExtractValues(CharaMakeType row, CustomizeIndex type) + { + var data = row.CharaMakeStruct.FirstOrNull(m => m.Customize == CustomizeIndex.TailShape.ToByteAndMask().ByteIdx); + return data?.SubMenuParam.Take(data.Value.SubMenuNum).Select((v, i) => FromValueAndIndex(type, v, i)).ToArray() ?? []; + } /// Get face paints from the hair sheet via reflection since there are also unlockable face paints. private CustomizeData[] GetFacePaints(SubRace race, Gender gender) { - var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender)!; - var paintList = new List(row.Unknown37); + var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender); // Number of available face paints is at Unknown37. - for (var i = 0; i < row.Unknown37; ++i) + var numPaints = row.ReadUInt8Column(37); + var paintList = new List(numPaints); + + for (var i = 0; i < numPaints; ++i) { // Face paints start at Unknown73. - var name = $"Unknown{73 + i * 9}"; - var customizeIdx = - (uint?)row.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance)?.GetValue(row) - ?? uint.MaxValue; + var customizeIdx = row.ReadUInt32Column(73 + i * 9); if (customizeIdx == uint.MaxValue) continue; - var paintRow = _customizeSheet.GetRow(customizeIdx); // Face paint Row from CustomizeSheet might not be set in case of unlockable face paints. - if (paintRow != null) + if (_customizeSheet.TryGetRow(customizeIdx, out var paintRow)) paintList.Add(new CustomizeData(CustomizeIndex.FacePaint, (CustomizeValue)paintRow.FeatureID, paintRow.Icon, (ushort)paintRow.RowId)); else @@ -232,21 +221,18 @@ internal class CustomizeSetFactory( } /// Get List sizes. - private static int GetListSize(CharaMakeParams row, CustomizeIndex index) + private static int GetListSize(CharaMakeType row, CustomizeIndex index) { var gameId = index.ToByteAndMask().ByteIdx; - var menu = row.Menus.Cast().FirstOrDefault(m => m!.Value.Customize == gameId); - return menu?.Size ?? 0; + var menu = row.CharaMakeStruct.FirstOrNull(m => m.Customize == gameId); + return menu?.SubMenuNum ?? 0; } /// Get generic Features. private CustomizeData FromValueAndIndex(CustomizeIndex id, uint value, int index) - { - var row = _customizeSheet.GetRow(value); - return row == null - ? new CustomizeData(id, (CustomizeValue)(index + 1), value) - : new CustomizeData(id, (CustomizeValue)row.FeatureID, row.Icon, (ushort)row.RowId); - } + => _customizeSheet.TryGetRow(value, out var row) + ? new CustomizeData(id, (CustomizeValue)row.FeatureID, row.Icon, (ushort)row.RowId) + : new CustomizeData(id, (CustomizeValue)(index + 1), value); /// Create generic color sets from the parameters. private static CustomizeData[] CreateColors(ColorParameters colorParameters, CustomizeIndex index, int offset, int num, @@ -264,28 +250,27 @@ internal class CustomizeSetFactory( } /// Set the specific option names for the given set of parameters. - private string[] GetOptionNames(CharaMakeParams row) + private string[] GetOptionNames(CharaMakeType row) { var nameArray = Enum.GetValues().Select(c => { // Find the first menu that corresponds to the Id. var byteId = c.ToByteAndMask().ByteIdx; - var menu = row.Menus - .Cast() - .FirstOrDefault(m => m!.Value.Customize == byteId); + var menu = row.CharaMakeStruct.FirstOrNull(m => m.Customize == byteId); if (menu == null) { // If none exists and the id corresponds to highlights, set the Highlights name. if (c == CustomizeIndex.Highlights) - return string.Intern(_lobbySheet.GetRow(237)?.Text.ToDalamudString().ToString() ?? "Highlights"); + return string.Intern(_lobbySheet.TryGetRow(237, out var text) ? text.Text.ExtractText() : "Highlights"); // Otherwise there is an error and we use the default name. return c.ToDefaultName(); } // Otherwise all is normal, get the menu name or if it does not work the default name. - var textRow = _lobbySheet.GetRow(menu.Value.Id); - return string.Intern(textRow?.Text.ToDalamudString().ToString() ?? c.ToDefaultName()); + return string.Intern(_lobbySheet.TryGetRow(menu.Value.Menu.RowId, out var textRow) + ? textRow.Text.ExtractText() + : c.ToDefaultName()); }).ToArray(); // Add names for both eye colors. @@ -306,7 +291,7 @@ internal class CustomizeSetFactory( } /// Get the manu types for all available options. - private static CharaMakeParams.MenuType[] GetMenuTypes(CharaMakeParams row) + private static MenuType[] GetMenuTypes(CharaMakeType row) { // Set up the menu types for all customizations. return Enum.GetValues().Select(c => @@ -318,13 +303,13 @@ internal class CustomizeSetFactory( case CustomizeIndex.EyeColorLeft: case CustomizeIndex.EyeColorRight: case CustomizeIndex.FacePaintColor: - return CharaMakeParams.MenuType.ColorPicker; - case CustomizeIndex.BodyType: return CharaMakeParams.MenuType.Nothing; + return MenuType.ColorPicker; + case CustomizeIndex.BodyType: return MenuType.Nothing; case CustomizeIndex.FacePaintReversed: case CustomizeIndex.Highlights: case CustomizeIndex.SmallIris: case CustomizeIndex.Lipstick: - return CharaMakeParams.MenuType.Checkmark; + return MenuType.Checkmark; case CustomizeIndex.FacialFeature1: case CustomizeIndex.FacialFeature2: case CustomizeIndex.FacialFeature3: @@ -333,24 +318,22 @@ internal class CustomizeSetFactory( case CustomizeIndex.FacialFeature6: case CustomizeIndex.FacialFeature7: case CustomizeIndex.LegacyTattoo: - return CharaMakeParams.MenuType.IconCheckmark; + return MenuType.IconCheckmark; } var gameId = c.ToByteAndMask().ByteIdx; // Otherwise find the first menu corresponding to the id. // If there is none, assume a list. - var menu = row.Menus - .Cast() - .FirstOrDefault(m => m!.Value.Customize == gameId); - var ret = menu?.Type ?? CharaMakeParams.MenuType.ListSelector; - if (c is CustomizeIndex.TailShape && ret is CharaMakeParams.MenuType.ListSelector) - ret = CharaMakeParams.MenuType.List1Selector; + var menu = row.CharaMakeStruct.FirstOrNull(m => m.Customize == gameId); + var ret = (MenuType)(menu?.SubMenuType ?? (byte)MenuType.ListSelector); + if (c is CustomizeIndex.TailShape && ret is MenuType.ListSelector) + ret = MenuType.List1Selector; return ret; }).ToArray(); } /// Set the availability of options according to actual availability. - private static void SetAvailability(CustomizeSet set, CharaMakeParams row) + private static void SetAvailability(CustomizeSet set, CharaMakeType row) { Set(true, CustomizeIndex.Height); Set(set.Faces.Count > 0, CustomizeIndex.Face); @@ -401,7 +384,7 @@ internal class CustomizeSetFactory( ret[(int)CustomizeIndex.EyeColorRight] = CustomizeIndex.TattooColor; var dict = ret.Skip(2).Where(set.IsAvailable).GroupBy(set.Type).ToDictionary(k => k.Key, k => k.ToArray()); - foreach (var type in Enum.GetValues()) + foreach (var type in Enum.GetValues()) dict.TryAdd(type, []); set.Order = dict; } @@ -425,7 +408,7 @@ internal class CustomizeSetFactory( bool Valid(CustomizeData c) { - var data = _customizeSheet.GetRow(c.CustomizeId)?.Unknown6 ?? 0; + var data = _customizeSheet.TryGetRow(c.CustomizeId, out var customize) ? customize.Unknown0 : 0; return data == 0 || data == i + set.Faces.Count; } } @@ -437,7 +420,7 @@ internal class CustomizeSetFactory( /// Create a list of lists of facial features and the legacy tattoo. /// Facial Features are bools in a bitfield, so we supply an "off" and an "on" value for simplicity of use. /// - private static void SetFacialFeatures(CustomizeSet set, CharaMakeParams row) + private static void SetFacialFeatures(CustomizeSet set, in CharaMakeType row) { var count = set.Faces.Count; set.FacialFeature1 = new List<(CustomizeData, CustomizeData)>(count); @@ -446,14 +429,14 @@ internal class CustomizeSetFactory( var tmp = Enumerable.Repeat(0, 7).Select(_ => new (CustomizeData, CustomizeData)[count + 1]).ToArray(); for (var i = 0; i < count; ++i) { - var data = row.FacialFeatureByFace[i].Icons; - tmp[0][i + 1] = Create(CustomizeIndex.FacialFeature1, data[0]); - tmp[1][i + 1] = Create(CustomizeIndex.FacialFeature2, data[1]); - tmp[2][i + 1] = Create(CustomizeIndex.FacialFeature3, data[2]); - tmp[3][i + 1] = Create(CustomizeIndex.FacialFeature4, data[3]); - tmp[4][i + 1] = Create(CustomizeIndex.FacialFeature5, data[4]); - tmp[5][i + 1] = Create(CustomizeIndex.FacialFeature6, data[5]); - tmp[6][i + 1] = Create(CustomizeIndex.FacialFeature7, data[6]); + var data = row.FacialFeatureOption[i]; + tmp[0][i + 1] = Create(CustomizeIndex.FacialFeature1, (uint)data.Option1); + tmp[1][i + 1] = Create(CustomizeIndex.FacialFeature2, (uint)data.Option2); + tmp[2][i + 1] = Create(CustomizeIndex.FacialFeature3, (uint)data.Option3); + tmp[3][i + 1] = Create(CustomizeIndex.FacialFeature4, (uint)data.Option4); + tmp[4][i + 1] = Create(CustomizeIndex.FacialFeature5, (uint)data.Option5); + tmp[5][i + 1] = Create(CustomizeIndex.FacialFeature6, (uint)data.Option6); + tmp[6][i + 1] = Create(CustomizeIndex.FacialFeature7, (uint)data.Option7); } set.FacialFeature1 = tmp[0]; diff --git a/Glamourer/GameData/MenuType.cs b/Glamourer/GameData/MenuType.cs new file mode 100644 index 0000000..a1d727b --- /dev/null +++ b/Glamourer/GameData/MenuType.cs @@ -0,0 +1,14 @@ +namespace Glamourer.GameData; + +public enum MenuType +{ + ListSelector = 0, + IconSelector = 1, + ColorPicker = 2, + DoubleColorPicker = 3, + IconCheckmark = 4, + Percentage = 5, + Checkmark = 6, // custom + Nothing = 7, // custom + List1Selector = 8, // custom, 1-indexed lists +} diff --git a/Glamourer/GameData/NpcCustomizeSet.cs b/Glamourer/GameData/NpcCustomizeSet.cs index 3c683a5..72ed4b4 100644 --- a/Glamourer/GameData/NpcCustomizeSet.cs +++ b/Glamourer/GameData/NpcCustomizeSet.cs @@ -1,7 +1,7 @@ using Dalamud.Plugin.Services; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game.Object; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using OtterGui.Services; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Structs; @@ -52,15 +52,14 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// Create data from event NPCs. private static List CreateEnpcData(IDataManager data, DictENpc eNpcs) { - var enpcSheet = data.GetExcelSheet()!; + var enpcSheet = data.GetExcelSheet(); var list = new List(eNpcs.Count); // Go through all event NPCs already collected into a dictionary. foreach (var (id, name) in eNpcs) { - var row = enpcSheet.GetRow(id.Id); // We only accept NPCs with valid names. - if (row == null || name.IsNullOrWhitespace()) + if (!enpcSheet.TryGetRow(id.Id, out var row) || name.IsNullOrWhitespace()) continue; // Check if the customization is a valid human. @@ -72,14 +71,14 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList { Name = name, Customize = customize, - ModelId = row.ModelChara.Row, + ModelId = row.ModelChara.RowId, Id = id, Kind = ObjectKind.EventNpc, }; // Event NPCs have a reference to NpcEquip but also contain the appearance in their own row. // Prefer the NpcEquip reference if it is set and the own does not appear to be set, otherwise use the own. - if (row.NpcEquip.Row != 0 && row.NpcEquip.Value is { } equip && row is { ModelBody: 0, ModelLegs: 0 }) + if (row.NpcEquip.RowId != 0 && row.NpcEquip.Value is { } equip && row is { ModelBody: 0, ModelLegs: 0 }) ApplyNpcEquip(ref ret, equip); else ApplyNpcEquip(ref ret, row); @@ -93,14 +92,14 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// Create data from battle NPCs. private static List CreateBnpcData(IDataManager data, DictBNpc bNpcs, DictBNpcNames bNpcNames) { - var bnpcSheet = data.GetExcelSheet()!; - var list = new List((int)bnpcSheet.RowCount); + var bnpcSheet = data.GetExcelSheet(); + var list = new List(bnpcSheet.Count); // We go through all battle NPCs in the sheet because the dictionary refers to names. foreach (var baseRow in bnpcSheet) { // Only accept humans. - if (baseRow.ModelChara.Value!.Type != 1) + if (baseRow.ModelChara.Value.Type != 1) continue; var bnpcNameIds = bNpcNames[baseRow.RowId]; @@ -109,15 +108,15 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList continue; // Check if the customization is a valid human. - var (valid, customize) = FromBnpcCustomize(baseRow.BNpcCustomize.Value!); + var (valid, customize) = FromBnpcCustomize(baseRow.BNpcCustomize.Value); if (!valid) continue; - var equip = baseRow.NpcEquip.Value!; + var equip = baseRow.NpcEquip.Value; var ret = new NpcData { Customize = customize, - ModelId = baseRow.ModelChara.Row, + ModelId = baseRow.ModelChara.RowId, Id = baseRow.RowId, Kind = ObjectKind.BattleNpc, }; @@ -186,36 +185,36 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// Apply equipment from a NpcEquip row. private static void ApplyNpcEquip(ref NpcData data, NpcEquip row) { - data.Set(0, row.ModelHead | (row.DyeHead.Row << 24) | ((ulong)row.Dye2Head.Row << 32)); - data.Set(1, row.ModelBody | (row.DyeBody.Row << 24) | ((ulong)row.Dye2Body.Row << 32)); - data.Set(2, row.ModelHands | (row.DyeHands.Row << 24) | ((ulong)row.Dye2Hands.Row << 32)); - data.Set(3, row.ModelLegs | (row.DyeLegs.Row << 24) | ((ulong)row.Dye2Legs.Row << 32)); - data.Set(4, row.ModelFeet | (row.DyeFeet.Row << 24) | ((ulong)row.Dye2Feet.Row << 32)); - data.Set(5, row.ModelEars | (row.DyeEars.Row << 24) | ((ulong)row.Dye2Ears.Row << 32)); - data.Set(6, row.ModelNeck | (row.DyeNeck.Row << 24) | ((ulong)row.Dye2Neck.Row << 32)); - data.Set(7, row.ModelWrists | (row.DyeWrists.Row << 24) | ((ulong)row.Dye2Wrists.Row << 32)); - data.Set(8, row.ModelRightRing | (row.DyeRightRing.Row << 24) | ((ulong)row.Dye2RightRing.Row << 32)); - data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.Row << 24) | ((ulong)row.Dye2LeftRing.Row << 32)); - data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.Row << 48) | ((ulong)row.Dye2MainHand.Row << 56)); - data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.Row << 48) | ((ulong)row.Dye2OffHand.Row << 56)); + data.Set(0, row.ModelHead | (row.DyeHead.RowId << 24) | ((ulong)row.Dye2Head.RowId << 32)); + data.Set(1, row.ModelBody | (row.DyeBody.RowId << 24) | ((ulong)row.Dye2Body.RowId << 32)); + data.Set(2, row.ModelHands | (row.DyeHands.RowId << 24) | ((ulong)row.Dye2Hands.RowId << 32)); + data.Set(3, row.ModelLegs | (row.DyeLegs.RowId << 24) | ((ulong)row.Dye2Legs.RowId << 32)); + data.Set(4, row.ModelFeet | (row.DyeFeet.RowId << 24) | ((ulong)row.Dye2Feet.RowId << 32)); + data.Set(5, row.ModelEars | (row.DyeEars.RowId << 24) | ((ulong)row.Dye2Ears.RowId << 32)); + data.Set(6, row.ModelNeck | (row.DyeNeck.RowId << 24) | ((ulong)row.Dye2Neck.RowId << 32)); + data.Set(7, row.ModelWrists | (row.DyeWrists.RowId << 24) | ((ulong)row.Dye2Wrists.RowId << 32)); + data.Set(8, row.ModelRightRing | (row.DyeRightRing.RowId << 24) | ((ulong)row.Dye2RightRing.RowId << 32)); + data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.RowId << 24) | ((ulong)row.Dye2LeftRing.RowId << 32)); + data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.RowId << 48) | ((ulong)row.Dye2MainHand.RowId << 56)); + data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.RowId << 48) | ((ulong)row.Dye2OffHand.RowId << 56)); data.VisorToggled = row.Visor; } /// Apply equipment from a ENpcBase Row row. private static void ApplyNpcEquip(ref NpcData data, ENpcBase row) { - data.Set(0, row.ModelHead | (row.DyeHead.Row << 24) | ((ulong)row.Dye2Head.Row << 32)); - data.Set(1, row.ModelBody | (row.DyeBody.Row << 24) | ((ulong)row.Dye2Body.Row << 32)); - data.Set(2, row.ModelHands | (row.DyeHands.Row << 24) | ((ulong)row.Dye2Hands.Row << 32)); - data.Set(3, row.ModelLegs | (row.DyeLegs.Row << 24) | ((ulong)row.Dye2Legs.Row << 32)); - data.Set(4, row.ModelFeet | (row.DyeFeet.Row << 24) | ((ulong)row.Dye2Feet.Row << 32)); - data.Set(5, row.ModelEars | (row.DyeEars.Row << 24) | ((ulong)row.Dye2Ears.Row << 32)); - data.Set(6, row.ModelNeck | (row.DyeNeck.Row << 24) | ((ulong)row.Dye2Neck.Row << 32)); - data.Set(7, row.ModelWrists | (row.DyeWrists.Row << 24) | ((ulong)row.Dye2Wrists.Row << 32)); - data.Set(8, row.ModelRightRing | (row.DyeRightRing.Row << 24) | ((ulong)row.Dye2RightRing.Row << 32)); - data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.Row << 24) | ((ulong)row.Dye2LeftRing.Row << 32)); - data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.Row << 48) | ((ulong)row.Dye2MainHand.Row << 56)); - data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.Row << 48) | ((ulong)row.Dye2OffHand.Row << 56)); + data.Set(0, row.ModelHead | (row.DyeHead.RowId << 24) | ((ulong)row.Dye2Head.RowId << 32)); + data.Set(1, row.ModelBody | (row.DyeBody.RowId << 24) | ((ulong)row.Dye2Body.RowId << 32)); + data.Set(2, row.ModelHands | (row.DyeHands.RowId << 24) | ((ulong)row.Dye2Hands.RowId << 32)); + data.Set(3, row.ModelLegs | (row.DyeLegs.RowId << 24) | ((ulong)row.Dye2Legs.RowId << 32)); + data.Set(4, row.ModelFeet | (row.DyeFeet.RowId << 24) | ((ulong)row.Dye2Feet.RowId << 32)); + data.Set(5, row.ModelEars | (row.DyeEars.RowId << 24) | ((ulong)row.Dye2Ears.RowId << 32)); + data.Set(6, row.ModelNeck | (row.DyeNeck.RowId << 24) | ((ulong)row.Dye2Neck.RowId << 32)); + data.Set(7, row.ModelWrists | (row.DyeWrists.RowId << 24) | ((ulong)row.Dye2Wrists.RowId << 32)); + data.Set(8, row.ModelRightRing | (row.DyeRightRing.RowId << 24) | ((ulong)row.Dye2RightRing.RowId << 32)); + data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.RowId << 24) | ((ulong)row.Dye2LeftRing.RowId << 32)); + data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.RowId << 48) | ((ulong)row.Dye2MainHand.RowId << 56)); + data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.RowId << 48) | ((ulong)row.Dye2OffHand.RowId << 56)); data.VisorToggled = row.Visor; } @@ -223,11 +222,11 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList private static (bool, CustomizeArray) FromBnpcCustomize(BNpcCustomize bnpcCustomize) { var customize = new CustomizeArray(); - customize.SetByIndex(0, (CustomizeValue)(byte)bnpcCustomize.Race.Row); + customize.SetByIndex(0, (CustomizeValue)(byte)bnpcCustomize.Race.RowId); customize.SetByIndex(1, (CustomizeValue)bnpcCustomize.Gender); customize.SetByIndex(2, (CustomizeValue)bnpcCustomize.BodyType); customize.SetByIndex(3, (CustomizeValue)bnpcCustomize.Height); - customize.SetByIndex(4, (CustomizeValue)(byte)bnpcCustomize.Tribe.Row); + customize.SetByIndex(4, (CustomizeValue)(byte)bnpcCustomize.Tribe.RowId); customize.SetByIndex(5, (CustomizeValue)bnpcCustomize.Face); customize.SetByIndex(6, (CustomizeValue)bnpcCustomize.HairStyle); customize.SetByIndex(7, (CustomizeValue)bnpcCustomize.HairHighlight); @@ -261,15 +260,15 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// Obtain customizations from a ENpcBase row and check if the human is valid. private static (bool, CustomizeArray) FromEnpcBase(ENpcBase enpcBase) { - if (enpcBase.ModelChara.Value?.Type != 1) + if (enpcBase.ModelChara.ValueNullable?.Type != 1) return (false, CustomizeArray.Default); var customize = new CustomizeArray(); - customize.SetByIndex(0, (CustomizeValue)(byte)enpcBase.Race.Row); + customize.SetByIndex(0, (CustomizeValue)(byte)enpcBase.Race.RowId); customize.SetByIndex(1, (CustomizeValue)enpcBase.Gender); customize.SetByIndex(2, (CustomizeValue)enpcBase.BodyType); customize.SetByIndex(3, (CustomizeValue)enpcBase.Height); - customize.SetByIndex(4, (CustomizeValue)(byte)enpcBase.Tribe.Row); + customize.SetByIndex(4, (CustomizeValue)(byte)enpcBase.Tribe.RowId); customize.SetByIndex(5, (CustomizeValue)enpcBase.Face); customize.SetByIndex(6, (CustomizeValue)enpcBase.HairStyle); customize.SetByIndex(7, (CustomizeValue)enpcBase.HairHighlight); diff --git a/Glamourer/Glamourer.json b/Glamourer/Glamourer.json index 08c18f5..1e9edf7 100644 --- a/Glamourer/Glamourer.json +++ b/Glamourer/Glamourer.json @@ -8,7 +8,7 @@ "AssemblyVersion": "9.0.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 10, + "DalamudApiLevel": 11, "ImageUrls": null, "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/master/images/icon.png" } \ No newline at end of file diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index baedc05..486fdb4 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -193,7 +193,7 @@ public partial class CustomizationDrawer private void DrawMultiIcons() { - var options = _set.Order[CharaMakeParams.MenuType.IconCheckmark]; + var options = _set.Order[MenuType.IconCheckmark]; using var group = ImRaii.Group(); var face = _set.DataByValue(CustomizeIndex.Face, _customize.Face, out _, _customize.Face) < 0 ? _set.Faces[0].Value : _customize.Face; foreach (var (featureIdx, idx) in options.WithIndex()) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 6b6cc0a..4ec6146 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -121,22 +121,22 @@ public partial class CustomizationDrawer( _set = _service.Manager.GetSet(_customize.Clan, _customize.Gender); - foreach (var id in _set.Order[CharaMakeParams.MenuType.Percentage]) + foreach (var id in _set.Order[MenuType.Percentage]) PercentageSelector(id); - Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.IconSelector], DrawIconSelector, ImGui.SameLine); + Functions.IteratePairwise(_set.Order[MenuType.IconSelector], DrawIconSelector, ImGui.SameLine); DrawMultiIconSelector(); - foreach (var id in _set.Order[CharaMakeParams.MenuType.ListSelector]) + foreach (var id in _set.Order[MenuType.ListSelector]) DrawListSelector(id, false); - foreach (var id in _set.Order[CharaMakeParams.MenuType.List1Selector]) + foreach (var id in _set.Order[MenuType.List1Selector]) DrawListSelector(id, true); - Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.ColorPicker], DrawColorPicker, ImGui.SameLine); + Functions.IteratePairwise(_set.Order[MenuType.ColorPicker], DrawColorPicker, ImGui.SameLine); - Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.Checkmark], DrawCheckbox, + Functions.IteratePairwise(_set.Order[MenuType.Checkmark], DrawCheckbox, () => ImGui.SameLine(_comboSelectorSize - _framedIconSize.X + ImGui.GetStyle().WindowPadding.X)); return Changed != 0 || ChangeApply != _initialApply; } diff --git a/Glamourer/Gui/Equipment/BonusItemCombo.cs b/Glamourer/Gui/Equipment/BonusItemCombo.cs index 735a23f..c333a87 100644 --- a/Glamourer/Gui/Equipment/BonusItemCombo.cs +++ b/Glamourer/Gui/Equipment/BonusItemCombo.cs @@ -2,7 +2,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using OtterGui; using OtterGui.Classes; using OtterGui.Log; @@ -91,8 +91,8 @@ public sealed class BonusItemCombo : FilterComboCache return slot switch { - BonusItemFlag.Glasses => sheet.GetRow(16050)?.Text.ToString() ?? "Facewear", - BonusItemFlag.UnkSlot => sheet.GetRow(16051)?.Text.ToString() ?? "Facewear", + BonusItemFlag.Glasses => sheet.TryGetRow(16050, out var text) ? text.Text.ToString() : "Facewear", + BonusItemFlag.UnkSlot => sheet.TryGetRow(16051, out var text) ? text.Text.ToString() : "Facewear", _ => string.Empty, }; diff --git a/Glamourer/Gui/Equipment/ItemCombo.cs b/Glamourer/Gui/Equipment/ItemCombo.cs index 1dac468..f7c75e1 100644 --- a/Glamourer/Gui/Equipment/ItemCombo.cs +++ b/Glamourer/Gui/Equipment/ItemCombo.cs @@ -2,7 +2,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using OtterGui; using OtterGui.Classes; using OtterGui.Log; @@ -88,20 +88,20 @@ public sealed class ItemCombo : FilterComboCache private static string GetLabel(IDataManager gameData, EquipSlot slot) { - var sheet = gameData.GetExcelSheet()!; + var sheet = gameData.GetExcelSheet(); return slot switch { - EquipSlot.Head => sheet.GetRow(740)?.Text.ToString() ?? "Head", - EquipSlot.Body => sheet.GetRow(741)?.Text.ToString() ?? "Body", - EquipSlot.Hands => sheet.GetRow(742)?.Text.ToString() ?? "Hands", - EquipSlot.Legs => sheet.GetRow(744)?.Text.ToString() ?? "Legs", - EquipSlot.Feet => sheet.GetRow(745)?.Text.ToString() ?? "Feet", - EquipSlot.Ears => sheet.GetRow(746)?.Text.ToString() ?? "Ears", - EquipSlot.Neck => sheet.GetRow(747)?.Text.ToString() ?? "Neck", - EquipSlot.Wrists => sheet.GetRow(748)?.Text.ToString() ?? "Wrists", - EquipSlot.RFinger => sheet.GetRow(749)?.Text.ToString() ?? "Right Ring", - EquipSlot.LFinger => sheet.GetRow(750)?.Text.ToString() ?? "Left Ring", + EquipSlot.Head => sheet.TryGetRow(740, out var text) ? text.Text.ToString() : "Head", + EquipSlot.Body => sheet.TryGetRow(741, out var text) ? text.Text.ToString() : "Body", + EquipSlot.Hands => sheet.TryGetRow(742, out var text) ? text.Text.ToString() : "Hands", + EquipSlot.Legs => sheet.TryGetRow(744, out var text) ? text.Text.ToString() : "Legs", + EquipSlot.Feet => sheet.TryGetRow(745, out var text) ? text.Text.ToString() : "Feet", + EquipSlot.Ears => sheet.TryGetRow(746, out var text) ? text.Text.ToString() : "Ears", + EquipSlot.Neck => sheet.TryGetRow(747, out var text) ? text.Text.ToString() : "Neck", + EquipSlot.Wrists => sheet.TryGetRow(748, out var text) ? text.Text.ToString() : "Wrists", + EquipSlot.RFinger => sheet.TryGetRow(749, out var text) ? text.Text.ToString() : "Right Ring", + EquipSlot.LFinger => sheet.TryGetRow(750, out var text) ? text.Text.ToString() : "Left Ring", _ => string.Empty, }; } diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index efe2448..afc4f7b 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -40,7 +40,7 @@ public class UnlockOverview( foreach (var type in Enum.GetValues()) { - if (type.IsOffhandType() || !items.ItemData.ByType.TryGetValue(type, out var value) || value.Count == 0) + if (type.IsOffhandType() || type.IsBonus() || !items.ItemData.ByType.TryGetValue(type, out var value) || value.Count == 0) continue; if (ImGui.Selectable(type.ToName(), _selected1 == type)) diff --git a/Glamourer/Interop/CrestService.cs b/Glamourer/Interop/CrestService.cs index 2b6f1ac..8e217b6 100644 --- a/Glamourer/Interop/CrestService.cs +++ b/Glamourer/Interop/CrestService.cs @@ -47,7 +47,7 @@ public sealed unsafe class CrestService : EventWrapperRef3DrawData, (byte) flags); gameObject.CrestBitfield = currentCrests; } @@ -62,14 +62,14 @@ public sealed unsafe class CrestService : EventWrapperRef3 _crestChangeHook = null!; - private void CrestChangeDetour(Character* character, byte crestFlags) + private void CrestChangeDetour(DrawDataContainer* container, byte crestFlags) { - var actor = (Actor)character; + var actor = (Actor)container->OwnerObject; foreach (var slot in CrestExtensions.AllRelevantSet) { var newValue = ((CrestFlag)crestFlags).HasFlag(slot); @@ -78,9 +78,9 @@ public sealed unsafe class CrestService : EventWrapperRef3((nint)MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); - _setupOrnamentHook = interop.HookFromAddress((nint)Ornament.MemberFunctionPointers.SetupOrnament, SetupOrnamentDetour); _calculateHeightHook = - interop.HookFromAddress((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); + interop.HookFromAddress((nint)HeightContainer.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); _setupMountHook.Enable(); - _setupOrnamentHook.Enable(); + _updateOrnamentHook.Enable(); _placeMinionHook.Enable(); _calculateHeightHook.Enable(); } @@ -29,19 +30,21 @@ public unsafe class ScalingService : IDisposable public void Dispose() { _setupMountHook.Dispose(); - _setupOrnamentHook.Dispose(); + _updateOrnamentHook.Dispose(); _placeMinionHook.Dispose(); _calculateHeightHook.Dispose(); } private delegate void SetupMount(MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4); - private delegate void SetupOrnament(Ornament* ornament, uint* unk1, float* unk2); + private delegate void UpdateOrnament(OrnamentContainer* ornament); private delegate void PlaceMinion(Companion* character); private delegate float CalculateHeight(Character* character); private readonly Hook _setupMountHook; - private readonly Hook _setupOrnamentHook; + // TODO: Use client structs sig. + [Signature(Sigs.UpdateOrnament, DetourName = nameof(UpdateOrnamentDetour))] + private readonly Hook _updateOrnamentHook = null!; private readonly Hook _calculateHeightHook; @@ -57,19 +60,12 @@ public unsafe class ScalingService : IDisposable SetScaleCustomize(container->OwnerObject, race, clan, gender); } - private void SetupOrnamentDetour(Ornament* ornament, uint* unk1, float* unk2) + private void UpdateOrnamentDetour(OrnamentContainer* container) { - var character = ornament->GetParentCharacter(); - if (character == null) - { - _setupOrnamentHook.Original(ornament, unk1, unk2); - return; - } - - var (race, clan, gender) = GetScaleRelevantCustomize(character); - SetScaleCustomize(character, character->GameObject.DrawObject); - _setupOrnamentHook.Original(ornament, unk1, unk2); - SetScaleCustomize(character, race, clan, gender); + var (race, clan, gender) = GetScaleRelevantCustomize(container->OwnerObject); + SetScaleCustomize(container->OwnerObject, container->OwnerObject->DrawObject); + _updateOrnamentHook.Original(container); + SetScaleCustomize(container->OwnerObject, race, clan, gender); } private void PlaceMinionDetour(Companion* companion) diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index b18c817..6fb32e2 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -548,7 +548,7 @@ public class CommandService : IDisposable, IApiService if (baseValue != null) { var v = baseValue.Value; - if (set.Type(customizeIndex) is CharaMakeParams.MenuType.ListSelector) + if (set.Type(customizeIndex) is MenuType.ListSelector) --v; set.DataByValue(customizeIndex, new CustomizeValue(v), out var data, customize.Face); if (data != null) diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 07a4829..5d6f074 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -1,5 +1,6 @@ using Dalamud.Plugin.Services; using Lumina.Excel; +using Lumina.Excel.Sheets; using Penumbra.GameData.Data; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; @@ -16,12 +17,12 @@ public class ItemManager private readonly Configuration _config; - public readonly ObjectIdentification ObjectIdentification; - public readonly ExcelSheet ItemSheet; - public readonly DictStain Stains; - public readonly ItemData ItemData; - public readonly DictBonusItems DictBonusItems; - public readonly RestrictedGear RestrictedGear; + public readonly ObjectIdentification ObjectIdentification; + public readonly ExcelSheet ItemSheet; + public readonly DictStain Stains; + public readonly ItemData ItemData; + public readonly DictBonusItems DictBonusItems; + public readonly RestrictedGear RestrictedGear; public readonly EquipItem DefaultSword; @@ -29,13 +30,13 @@ public class ItemManager ItemData itemData, DictStain stains, RestrictedGear restrictedGear, DictBonusItems dictBonusItems) { _config = config; - ItemSheet = gameData.GetExcelSheet()!; + ItemSheet = gameData.GetExcelSheet(); ObjectIdentification = objectIdentification; ItemData = itemData; Stains = stains; RestrictedGear = restrictedGear; DictBonusItems = dictBonusItems; - DefaultSword = EquipItem.FromMainhand(ItemSheet.GetRow(1601)!); // Weathered Shortsword + DefaultSword = EquipItem.FromMainhand(ItemSheet.GetRow(1601)); // Weathered Shortsword } public (bool, CharacterArmor) ResolveRestrictedGear(CharacterArmor armor, EquipSlot slot, Race race, Gender gender) diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index 801f211..18f3cac 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -8,7 +8,7 @@ using Glamourer.GameData; using Glamourer.Events; using Glamourer.Interop; using Glamourer.Services; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using Penumbra.GameData; using Penumbra.GameData.Enums; @@ -183,25 +183,25 @@ public class CustomizeUnlockManager : IDisposable, ISavable var list = customizations.Manager.GetSet(clan, gender); foreach (var hair in list.HairStyles) { - var x = sheet.FirstOrDefault(f => f.FeatureID == hair.Value.Value); + var x = sheet.FirstOrNull(f => f.FeatureID == hair.Value.Value); if (x?.IsPurchasable == true) { - var name = x.FeatureID == 61 + var name = x.Value.FeatureID == 61 ? "Eternal Bond" - : x.HintItem.Value?.Name.ToDalamudString().ToString().Replace("Modern Aesthetics - ", string.Empty) + : x.Value.HintItem.ValueNullable?.Name.ExtractText().Replace("Modern Aesthetics - ", string.Empty) ?? string.Empty; - ret.TryAdd(hair, (x.Data, name)); + ret.TryAdd(hair, (x.Value.Data, name)); } } foreach (var paint in list.FacePaints) { - var x = sheet.FirstOrDefault(f => f.FeatureID == paint.Value.Value); + var x = sheet.FirstOrNull(f => f.FeatureID == paint.Value.Value); if (x?.IsPurchasable == true) { - var name = x.HintItem.Value?.Name.ToDalamudString().ToString().Replace("Modern Cosmetics - ", string.Empty) + var name = x.Value.HintItem.ValueNullable?.Name.ExtractText().Replace("Modern Cosmetics - ", string.Empty) ?? string.Empty; - ret.TryAdd(paint, (x.Data, name)); + ret.TryAdd(paint, (x.Value.Data, name)); } } } diff --git a/Glamourer/Unlocks/ItemUnlockManager.cs b/Glamourer/Unlocks/ItemUnlockManager.cs index 0b95b94..0fc1675 100644 --- a/Glamourer/Unlocks/ItemUnlockManager.cs +++ b/Glamourer/Unlocks/ItemUnlockManager.cs @@ -3,11 +3,11 @@ using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.UI; using Glamourer.Events; using Glamourer.Services; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using Penumbra.GameData.Data; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; -using Cabinet = Lumina.Excel.GeneratedSheets.Cabinet; +using Cabinet = Lumina.Excel.Sheets.Cabinet; namespace Glamourer.Unlocks; @@ -192,7 +192,7 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionary= _items.ItemSheet.RowCount) + if (itemId.Id >= (uint) _items.ItemSheet.Count) { time = DateTimeOffset.MinValue; return true; @@ -273,32 +273,31 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionary CreateUnlockData(IDataManager gameData, ItemManager items) { var ret = new Dictionary(); - var cabinet = gameData.GetExcelSheet()!; + var cabinet = gameData.GetExcelSheet(); foreach (var row in cabinet) { - if (items.ItemData.TryGetValue(row.Item.Row, EquipSlot.MainHand, out var item)) + if (items.ItemData.TryGetValue(row.Item.RowId, EquipSlot.MainHand, out var item)) ret.TryAdd(item.ItemId, new UnlockRequirements(row.RowId, 0, 0, 0, UnlockType.Cabinet)); } - var gilShopItem = gameData.GetExcelSheet()!; - var gilShop = gameData.GetExcelSheet()!; - foreach (var row in gilShopItem) + var gilShopItem = gameData.GetSubrowExcelSheet(); + var gilShop = gameData.GetExcelSheet(); + foreach (var row in gilShopItem.SelectMany(g => g)) { - if (!items.ItemData.TryGetValue(row.Item.Row, EquipSlot.MainHand, out var item)) + if (!items.ItemData.TryGetValue(row.Item.RowId, EquipSlot.MainHand, out var item)) continue; - var quest1 = row.QuestRequired[0].Row; - var quest2 = row.QuestRequired[1].Row; - var achievement = row.AchievementRequired.Row; + var quest1 = row.QuestRequired[0].RowId; + var quest2 = row.QuestRequired[1].RowId; + var achievement = row.AchievementRequired.RowId; var state = row.StateRequired; - var shop = gilShop.GetRow(row.RowId); - if (shop != null && shop.Quest.Row != 0) + if (gilShop.TryGetRow(row.RowId, out var shop) && shop.Quest.RowId != 0) { if (quest1 == 0) - quest1 = shop.Quest.Row; + quest1 = shop.Quest.RowId; else if (quest2 == 0) - quest2 = shop.Quest.Row; + quest2 = shop.Quest.RowId; } var type = (quest1 != 0 ? UnlockType.Quest1 : 0) diff --git a/OtterGui b/OtterGui index d9486ae..8ba88ef 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit d9486ae54b5a4b61cf74f79ed27daa659eb1ce5b +Subproject commit 8ba88eff15326bb28ed5e6157f5252c114d40b5f diff --git a/Penumbra.GameData b/Penumbra.GameData index 77d52b0..fb81a0b 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 77d52b02d21e770b30c08f89bdf06e0cb75562f7 +Subproject commit fb81a0b55d3c68f2b26357fac3049c79fb0c22fb diff --git a/repo.json b/repo.json index b309240..067cd7e 100644 --- a/repo.json +++ b/repo.json @@ -22,7 +22,7 @@ "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, - "TestingDalamudApiLevel": 10, + "TestingDalamudApiLevel": 11, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From fe028e5ec730a2786f41809d7e5cf72c54feaa9e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 17 Nov 2024 14:27:14 +0100 Subject: [PATCH 120/401] Fixes. --- Glamourer/Automation/AutoDesignApplier.cs | 2 +- Glamourer/GameData/CustomizeSetFactory.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 6 +++--- Glamourer/Interop/MetaService.cs | 2 +- Glamourer/Interop/ScalingService.cs | 2 +- Glamourer/State/FunModule.cs | 2 +- Glamourer/State/StateListener.cs | 2 +- Glamourer/State/StateManager.cs | 6 +++--- OtterGui | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index fba1a58..0ce34d4 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -277,7 +277,7 @@ public sealed class AutoDesignApplier : IDisposable } forcedRedraw = false; - if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId)) + if (!_humans.IsHuman((uint)actor.AsCharacter->ModelContainer.ModelCharaId)) return; if (actor.IsTransformed) diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index 36cdb1b..7d80454 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -166,7 +166,7 @@ internal class CustomizeSetFactory( continue; // Hair Row from CustomizeSheet might not be set in case of unlockable hair. - if (_customizeSheet.TryGetRow(customizeIdx, out var hairRow)) + if (!_customizeSheet.TryGetRow(customizeIdx, out var hairRow)) hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)i, customizeIdx)); else if (_icons.IconExists(hairRow.Icon)) hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)hairRow.FeatureID, hairRow.Icon, diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index eeb6f3f..c1b5847 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -52,11 +52,11 @@ public unsafe class ModelEvaluationPanel( ImGui.TableNextColumn(); if (actor.IsCharacter) { - ImGui.TextUnformatted(actor.AsCharacter->CharacterData.ModelCharaId.ToString()); + ImGui.TextUnformatted(actor.AsCharacter->ModelContainer.ModelCharaId.ToString()); if (actor.AsCharacter->CharacterData.TransformationId != 0) ImGui.TextUnformatted($"Transformation Id: {actor.AsCharacter->CharacterData.TransformationId}"); - if (actor.AsCharacter->CharacterData.ModelCharaId_2 != -1) - ImGui.TextUnformatted($"ModelChara2 {actor.AsCharacter->CharacterData.ModelCharaId_2}"); + if (actor.AsCharacter->ModelContainer.ModelCharaId_2 != -1) + ImGui.TextUnformatted($"ModelChara2 {actor.AsCharacter->ModelContainer.ModelCharaId_2}"); ImGuiUtil.DrawTableColumn("Character Mode"); ImGuiUtil.DrawTableColumn($"{actor.AsCharacter->Mode}"); diff --git a/Glamourer/Interop/MetaService.cs b/Glamourer/Interop/MetaService.cs index 1c79cec..6225986 100644 --- a/Glamourer/Interop/MetaService.cs +++ b/Glamourer/Interop/MetaService.cs @@ -50,7 +50,7 @@ public unsafe class MetaService : IDisposable // The function seems to not do anything if the head is 0, but also breaks for carbuncles turned human, sometimes? var old = actor.AsCharacter->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Head).Id; - if (old == 0 && actor.AsCharacter->CharacterData.ModelCharaId == 0) + if (old == 0 && actor.AsCharacter->ModelContainer.ModelCharaId == 0) actor.AsCharacter->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Head).Id = 1; _hideHatGearHook.Original(&actor.AsCharacter->DrawData, 0, (byte)(value ? 0 : 1)); actor.AsCharacter->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Head).Id = old; diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index f7f08f6..aa64b77 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -19,7 +19,7 @@ public unsafe class ScalingService : IDisposable _setupMountHook = interop.HookFromAddress((nint)MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); _calculateHeightHook = - interop.HookFromAddress((nint)HeightContainer.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); + interop.HookFromAddress((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); _setupMountHook.Enable(); _updateOrnamentHook.Enable(); diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index de39a53..1ca5c48 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -333,7 +333,7 @@ public unsafe class FunModule : IDisposable => actor.IsCharacter && actor.AsObject->ObjectKind is ObjectKind.Pc && !actor.IsTransformed - && actor.AsCharacter->CharacterData.ModelCharaId == 0; + && actor.AsCharacter->ModelContainer.ModelCharaId == 0; private static void KeepOldArmor(Actor actor, EquipSlot slot, ref CharacterArmor armor) => armor = actor.Model.Valid ? actor.Model.GetArmor(slot) : armor; diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 9c0dd67..d054a25 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -593,7 +593,7 @@ public class StateListener : IDisposable private unsafe UpdateState UpdateBaseData(Actor actor, ActorState state, uint modelId, nint customizeData, nint equipData) { // Model ID does not agree between game object and new draw object => Transformation. - if (modelId != (uint)actor.AsCharacter->CharacterData.ModelCharaId) + if (modelId != (uint)actor.AsCharacter->ModelContainer.ModelCharaId) return UpdateState.Transformed; // Model ID did not change to stored state. diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 4ff232a..f16dd22 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -114,14 +114,14 @@ public sealed class StateManager( // Model ID is only unambiguously contained in the game object. // The draw object only has the object type. // TODO reverse search model data to get model id from model. - if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId)) + if (!_humans.IsHuman((uint)actor.AsCharacter->ModelContainer.ModelCharaId)) { - ret.LoadNonHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId, *(CustomizeArray*)&actor.AsCharacter->DrawData.CustomizeData, + ret.LoadNonHuman((uint)actor.AsCharacter->ModelContainer.ModelCharaId, *(CustomizeArray*)&actor.AsCharacter->DrawData.CustomizeData, (nint)Unsafe.AsPointer(ref actor.AsCharacter->DrawData.EquipmentModelIds[0])); return ret; } - ret.ModelId = (uint)actor.AsCharacter->CharacterData.ModelCharaId; + ret.ModelId = (uint)actor.AsCharacter->ModelContainer.ModelCharaId; ret.IsHuman = true; CharacterWeapon main; diff --git a/OtterGui b/OtterGui index 8ba88ef..95b8d17 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 8ba88eff15326bb28ed5e6157f5252c114d40b5f +Subproject commit 95b8d177883b03f804d77434f45e9de97fdb9adf From c7b9791a6af078ca760b16e6d7eeb63f879dfe64 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 17 Nov 2024 14:29:11 +0100 Subject: [PATCH 121/401] Not yet increment API level. --- repo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo.json b/repo.json index 067cd7e..b309240 100644 --- a/repo.json +++ b/repo.json @@ -22,7 +22,7 @@ "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, - "TestingDalamudApiLevel": 11, + "TestingDalamudApiLevel": 10, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From 60c7debb5eb1f34a94ab7089512e925eeca023bc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 17 Nov 2024 18:13:20 +0100 Subject: [PATCH 122/401] Fix offset --- Glamourer/Interop/ScalingService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index aa64b77..2f7ba66 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -5,8 +5,7 @@ using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; using Penumbra.GameData; using Penumbra.GameData.Interop; -using Penumbra.GameData.Structs; -using System.ComponentModel; +using FFXIVClientStructs.FFXIV.Client.Game.Object; using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character; namespace Glamourer.Interop; @@ -70,8 +69,7 @@ public unsafe class ScalingService : IDisposable private void PlaceMinionDetour(Companion* companion) { - // TODO Update CS - var owner = (Actor)((nint*)companion)[0x45C]; + var owner = (Actor)(GameObject*)companion->Owner; if (!owner.IsCharacter) { _placeMinionHook.Original(companion); From db34255127297b8c87ee1d3acc7360235f9001f9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 17 Nov 2024 22:00:50 +0100 Subject: [PATCH 123/401] Fix customization bug. --- Glamourer/GameData/CustomizeSetFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index 7d80454..e2291d4 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -190,7 +190,7 @@ internal class CustomizeSetFactory( private CustomizeData[] ExtractValues(CharaMakeType row, CustomizeIndex type) { - var data = row.CharaMakeStruct.FirstOrNull(m => m.Customize == CustomizeIndex.TailShape.ToByteAndMask().ByteIdx); + var data = row.CharaMakeStruct.FirstOrNull(m => m.Customize == type.ToByteAndMask().ByteIdx); return data?.SubMenuParam.Take(data.Value.SubMenuNum).Select((v, i) => FromValueAndIndex(type, v, i)).ToArray() ?? []; } From de9d605fb09edd837168df47bbca2bde2a437887 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 17 Nov 2024 22:01:36 +0100 Subject: [PATCH 124/401] 1.3.3.1 --- .github/workflows/release.yml | 2 +- repo.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e22a656..bac600a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: dotnet restore - name: Download Dalamud run: | - Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip + Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev" - name: Build run: | diff --git a/repo.json b/repo.json index b309240..067cd7e 100644 --- a/repo.json +++ b/repo.json @@ -22,7 +22,7 @@ "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, - "TestingDalamudApiLevel": 10, + "TestingDalamudApiLevel": 11, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From 0ba9f538baf97591c2106dda2373627be826f160 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 17 Nov 2024 21:04:05 +0000 Subject: [PATCH 125/401] [CI] Updating repo.json for testing_1.3.3.1 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 067cd7e..edef16c 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.3.0", - "TestingAssemblyVersion": "1.3.3.0", + "TestingAssemblyVersion": "1.3.3.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.3.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 7605c7cb29d582685cfc03d739e43a55e19d84f3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 18 Nov 2024 00:29:24 +0100 Subject: [PATCH 126/401] Fix screen actor indices. --- Glamourer.sln | 2 ++ Penumbra.GameData | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Glamourer.sln b/Glamourer.sln index 254f8e4..4ac3356 100644 --- a/Glamourer.sln +++ b/Glamourer.sln @@ -6,7 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{383AEE76-D423-431C-893A-7AB3DEA13630}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + .github\workflows\release.yml = .github\workflows\release.yml repo.json = repo.json + .github\workflows\test_release.yml = .github\workflows\test_release.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Glamourer", "Glamourer\Glamourer.csproj", "{01EB903D-871F-4285-A8CF-6486561D5B5B}" diff --git a/Penumbra.GameData b/Penumbra.GameData index fb81a0b..79d8d78 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit fb81a0b55d3c68f2b26357fac3049c79fb0c22fb +Subproject commit 79d8d782b3b454a41f7f87f398806ec4d08d485f From f9c7e567b6e11318d645f226bb017c5d2401baee Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 17 Nov 2024 23:31:26 +0000 Subject: [PATCH 127/401] [CI] Updating repo.json for testing_1.3.3.2 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index edef16c..93738f1 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.3.0", - "TestingAssemblyVersion": "1.3.3.1", + "TestingAssemblyVersion": "1.3.3.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.3.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.3.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 86d370226a2931caa81770bbb01c36f5e0fd3d8b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 20 Nov 2024 11:50:30 +0100 Subject: [PATCH 128/401] Update weapon changed data offset. --- Glamourer/Interop/Material/MaterialManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 7f13c2d..f3c1875 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -200,7 +200,8 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// private static CharacterWeapon GetTempSlot(Weapon* weapon) { - var changedData = *(void**)((byte*)weapon + 0xA00); + // TODO: Use ClientStructs + var changedData = *(void**)((byte*)weapon + 0xA40); if (changedData == null) return new CharacterWeapon(weapon->ModelSetId, weapon->SecondaryId, (Variant)weapon->Variant, StainIds.FromWeapon(*weapon)); From b44a147fdd4c1900b57515e35cd806e4add84f73 Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 20 Nov 2024 13:01:59 +0000 Subject: [PATCH 129/401] [CI] Updating repo.json for testing_1.3.3.3 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 93738f1..d9d03e8 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.3.0", - "TestingAssemblyVersion": "1.3.3.2", + "TestingAssemblyVersion": "1.3.3.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.3.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.3.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 525f65e70aa0f60d447dde2496cb74ad29b5c945 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 22 Nov 2024 14:27:14 +0100 Subject: [PATCH 130/401] Fix issues with shared weapon types. --- Glamourer/Automation/AutoDesignApplier.cs | 4 ++-- Glamourer/Designs/Links/DesignMerger.cs | 4 ++-- Glamourer/Designs/Links/MergedDesign.cs | 8 ++++---- Glamourer/Glamourer.cs | 1 + Glamourer/State/JobChangeState.cs | 5 +++-- Glamourer/State/StateEditor.cs | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 0ce34d4..ccaae21 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -77,7 +77,7 @@ public sealed class AutoDesignApplier : IDisposable { case EquipSlot.MainHand: { - if (_jobChangeState.TryGetValue(current.Type, actor.Job, out var data)) + if (_jobChangeState.TryGetValue(current.Type, actor.Job, false, out var data)) { Glamourer.Log.Verbose( $"Changing Mainhand from {state.ModelData.Weapon(EquipSlot.MainHand)} | {state.BaseData.Weapon(EquipSlot.MainHand)} to {data.Item1} for 0x{actor.Address:X}."); @@ -89,7 +89,7 @@ public sealed class AutoDesignApplier : IDisposable } case EquipSlot.OffHand when current.Type == state.BaseData.MainhandType.Offhand(): { - if (_jobChangeState.TryGetValue(current.Type, actor.Job, out var data)) + if (_jobChangeState.TryGetValue(current.Type, actor.Job, false, out var data)) { Glamourer.Log.Verbose( $"Changing Offhand from {state.ModelData.Weapon(EquipSlot.OffHand)} | {state.BaseData.Weapon(EquipSlot.OffHand)} to {data.Item1} for 0x{actor.Address:X}."); diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index 5767c7a..e0e5d95 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -1,4 +1,5 @@ using Glamourer.Automation; +using Glamourer.Designs.Special; using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Services; @@ -23,8 +24,7 @@ public class DesignMerger( modAssociations); public MergedDesign Merge(IEnumerable<(IDesignStandIn, ApplicationType, JobFlag)> designs, in CustomizeArray currentCustomize, - in DesignData baseRef, - bool respectOwnership, bool modAssociations) + in DesignData baseRef, bool respectOwnership, bool modAssociations) { var ret = new MergedDesign(designManager); ret.Design.SetCustomize(_customize, currentCustomize); diff --git a/Glamourer/Designs/Links/MergedDesign.cs b/Glamourer/Designs/Links/MergedDesign.cs index 0748633..9c9e079 100644 --- a/Glamourer/Designs/Links/MergedDesign.cs +++ b/Glamourer/Designs/Links/MergedDesign.cs @@ -23,8 +23,8 @@ public readonly struct WeaponList _list.Add(type, list); } - var remainingFlags = list.Select(t => t.Item3) - .Aggregate(flags, (current, existingFlags) => current & ~existingFlags); + var existingFlags = list.Count == 0 ? 0 : list.Select(t => t.Item3).Aggregate((t, existing) => t | existing); + var remainingFlags = flags & ~existingFlags; if (remainingFlags == 0) return false; @@ -33,7 +33,7 @@ public readonly struct WeaponList return true; } - public bool TryGet(FullEquipType type, JobId id, out (EquipItem, StateSource) ret) + public bool TryGet(FullEquipType type, JobId id, bool gameStateAllowed, out (EquipItem, StateSource) ret) { if (!_list.TryGetValue(type, out var list)) { @@ -45,7 +45,7 @@ public readonly struct WeaponList foreach (var (item, source, flags) in list) { - if (flags.HasFlag(flag)) + if (flags.HasFlag(flag) && (gameStateAllowed || source is not StateSource.Game)) { ret = (item, source); return true; diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index ee202d6..b4489e8 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -139,6 +139,7 @@ public class Glamourer : IDalamudPlugin ReadOnlySpan relevantPlugins = [ "Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge", + "LoporritSync", ]; var plugins = _services.GetService().InstalledPlugins .GroupBy(p => p.InternalName) diff --git a/Glamourer/State/JobChangeState.cs b/Glamourer/State/JobChangeState.cs index 0fe1820..d568375 100644 --- a/Glamourer/State/JobChangeState.cs +++ b/Glamourer/State/JobChangeState.cs @@ -24,11 +24,12 @@ public sealed class JobChangeState : IService public ActorIdentifier Identifier => State?.Identifier ?? ActorIdentifier.Invalid; - public bool TryGetValue(FullEquipType slot, JobId jobId, out (EquipItem, StateSource) data) - => _weaponList.TryGet(slot, jobId, out data); + public bool TryGetValue(FullEquipType slot, JobId jobId, bool gameStateAllowed, out (EquipItem, StateSource) data) + => _weaponList.TryGet(slot, jobId, gameStateAllowed, out data); public void Set(ActorState state, IEnumerable<(EquipItem, StateSource, JobFlag)> items) { + Reset(); foreach (var (item, source, flags) in items.Where(p => p.Item1.Valid)) _weaponList.TryAdd(item.Type, item, source, flags); State = state; diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 959d810..59f27a2 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -359,7 +359,7 @@ public class StateEditor( } var currentType = state.BaseData.Item(weaponSlot).Type; - if (mergedDesign.Weapons.TryGet(currentType, state.LastJob, out var weapon)) + if (mergedDesign.Weapons.TryGet(currentType, state.LastJob, true, out var weapon)) { var source = settings.UseSingleSource ? settings.Source : weapon.Item2 is StateSource.Game ? StateSource.Game : settings.Source; From 5464fa3a0f631dac13a57a32021e6289de32bac4 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 22 Nov 2024 14:27:32 +0100 Subject: [PATCH 131/401] 1.3.4.0 --- Glamourer/Gui/GlamourerChangelog.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 4826839..57f7343 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -37,6 +37,7 @@ public class GlamourerChangelog Add1_3_1_0(Changelog); Add1_3_2_0(Changelog); Add1_3_3_0(Changelog); + Add1_3_4_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -57,6 +58,12 @@ public class GlamourerChangelog } } + private static void Add1_3_4_0(Changelog log) + => log.NextVersion("Version 1.3.4.0") + .RegisterEntry("Glamourer has been updated for Dalamud API 11 and patch 7.1.") + .RegisterEntry("Maybe fixed issues with shared weapon types and reset designs.") + .RegisterEntry("Fixed issues with resetting advanced dyes and certain weapon types"); + private static void Add1_3_3_0(Changelog log) => log.NextVersion("Version 1.3.3.0") .RegisterHighlight("Added the option to create automations for owned human NPCs (like trust avatars).") From 3722df199bb0c265cf64e2ab561814786d4180b8 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 22 Nov 2024 13:29:49 +0000 Subject: [PATCH 132/401] [CI] Updating repo.json for 1.3.4.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index d9d03e8..38fafa4 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.3.0", - "TestingAssemblyVersion": "1.3.3.3", + "AssemblyVersion": "1.3.4.0", + "TestingAssemblyVersion": "1.3.4.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.3.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.3.3/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 9ed8c9517bfabc05c2620a885d4abbc8630e54ac Mon Sep 17 00:00:00 2001 From: Ottermandias <70807659+Ottermandias@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:44:29 +0100 Subject: [PATCH 133/401] Update repo.json --- repo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo.json b/repo.json index 38fafa4..2fe08e4 100644 --- a/repo.json +++ b/repo.json @@ -21,7 +21,7 @@ "TestingAssemblyVersion": "1.3.4.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 10, + "DalamudApiLevel": 11, "TestingDalamudApiLevel": 11, "IsHide": "False", "IsTestingExclusive": "False", From 40a684ff465f9b778598bb0ed7050f05466995e4 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 23 Nov 2024 13:58:16 +0100 Subject: [PATCH 134/401] Fix CalculateHeight. --- Glamourer/Interop/ScalingService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index 2f7ba66..141d5f2 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -18,7 +18,7 @@ public unsafe class ScalingService : IDisposable _setupMountHook = interop.HookFromAddress((nint)MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); _calculateHeightHook = - interop.HookFromAddress((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); + interop.HookFromAddress((nint)ModelContainer.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); _setupMountHook.Enable(); _updateOrnamentHook.Enable(); @@ -37,7 +37,7 @@ public unsafe class ScalingService : IDisposable private delegate void SetupMount(MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4); private delegate void UpdateOrnament(OrnamentContainer* ornament); private delegate void PlaceMinion(Companion* character); - private delegate float CalculateHeight(Character* character); + private delegate float CalculateHeight(ModelContainer* character); private readonly Hook _setupMountHook; @@ -85,12 +85,12 @@ public unsafe class ScalingService : IDisposable } } - private float CalculateHeightDetour(Character* character) + private float CalculateHeightDetour(ModelContainer* container) { - var (gender, bodyType, clan, height) = GetHeightRelevantCustomize(character); - SetHeightCustomize(character, character->GameObject.DrawObject); - var ret = _calculateHeightHook.Original(character); - SetHeightCustomize(character, gender, bodyType, clan, height); + var (gender, bodyType, clan, height) = GetHeightRelevantCustomize(container->OwnerObject); + SetHeightCustomize(container->OwnerObject, container->OwnerObject->DrawObject); + var ret = _calculateHeightHook.Original(container); + SetHeightCustomize(container->OwnerObject, gender, bodyType, clan, height); return ret; } From 22c7e32760bdc22f608ae78cae4ae274ddcdfeae Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 24 Nov 2024 12:18:04 +0100 Subject: [PATCH 135/401] Fix some context menu things. --- Glamourer/Interop/ContextMenuService.cs | 47 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/Glamourer/Interop/ContextMenuService.cs b/Glamourer/Interop/ContextMenuService.cs index eeee70a..71a9280 100644 --- a/Glamourer/Interop/ContextMenuService.cs +++ b/Glamourer/Interop/ContextMenuService.cs @@ -11,27 +11,24 @@ namespace Glamourer.Interop; public class ContextMenuService : IDisposable { - public const int ItemSearchContextItemId = 0x1738; - public const int ChatLogContextItemId = 0x950; + public const int ChatLogContextItemId = 0x958; private readonly ItemManager _items; private readonly IContextMenu _contextMenu; private readonly StateManager _state; private readonly ObjectManager _objects; - private readonly IGameGui _gameGui; private EquipItem _lastItem; private readonly StainId[] _lastStains = new StainId[StainId.NumStains]; private readonly MenuItem _inventoryItem; - public ContextMenuService(ItemManager items, StateManager state, ObjectManager objects, IGameGui gameGui, Configuration config, + public ContextMenuService(ItemManager items, StateManager state, ObjectManager objects, Configuration config, IContextMenu context) { _contextMenu = context; _items = items; _state = state; _objects = objects; - _gameGui = gameGui; if (config.EnableGameContextMenu) Enable(); @@ -55,7 +52,7 @@ public class ContextMenuService : IDisposable if (arg.TargetItem.HasValue && HandleItem(arg.TargetItem.Value.ItemId)) { for (var i = 0; i < arg.TargetItem.Value.Stains.Length; ++i) - _lastStains[i] = (StainId)arg.TargetItem.Value.Stains[i]; + _lastStains[i] = arg.TargetItem.Value.Stains[i]; args.AddMenuItem(_inventoryItem); } } @@ -72,8 +69,8 @@ public class ContextMenuService : IDisposable } case "ChatLog": { - var agent = _gameGui.FindAgentInterface("ChatLog"); - if (agent == nint.Zero || !ValidateChatLogContext(agent)) + var agent = AgentChatLog.Instance(); + if (agent == null || !ValidateChatLogContext(agent)) return; if (HandleItem(*(ItemId*)(agent + ChatLogContextItemId))) @@ -83,6 +80,36 @@ public class ContextMenuService : IDisposable args.AddMenuItem(_inventoryItem); } + break; + } + case "RecipeNote": + { + var agent = AgentRecipeNote.Instance(); + if (agent == null) + return; + + if (HandleItem(agent->ContextMenuResultItemId)) + { + for (var i = 0; i < _lastStains.Length; ++i) + _lastStains[i] = 0; + args.AddMenuItem(_inventoryItem); + } + + break; + } + case "InclusionShop": + { + var agent = AgentRecipeItemContext.Instance(); + if (agent == null) + return; + + if (HandleItem(agent->ResultItemId)) + { + for (var i = 0; i < _lastStains.Length; ++i) + _lastStains[i] = 0; + args.AddMenuItem(_inventoryItem); + } + break; } } @@ -125,6 +152,6 @@ public class ContextMenuService : IDisposable return _items.ItemData.TryGetValue(itemId, EquipSlot.MainHand, out _lastItem); } - private static unsafe bool ValidateChatLogContext(nint agent) - => *(uint*)(agent + ChatLogContextItemId + 8) == 3; + private static unsafe bool ValidateChatLogContext(AgentChatLog* agent) + => *(&agent->ContextItemId + 8) == 3; } From 7f95726cc30748e27b1987915af508f387e15a9e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 25 Nov 2024 16:53:33 +0100 Subject: [PATCH 136/401] Do not use DX calls to read color tables except in UI. --- Glamourer/State/StateApplier.cs | 27 ++++++++++++++++----------- Glamourer/State/StateManager.cs | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 6ba6c06..2e086d6 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -309,27 +309,31 @@ public class StateApplier( return data; } - public unsafe void ChangeMaterialValue(ActorData data, MaterialValueIndex index, ColorRow? value, bool force) + public unsafe void ChangeMaterialValue(ActorState state, ActorData data, MaterialValueIndex changedIndex, ColorRow? changedValue, + bool force) { if (!force && !_config.UseAdvancedDyes) return; foreach (var actor in data.Objects.Where(a => a is { IsCharacter: true, Model.IsHuman: true })) { - if (!index.TryGetTexture(actor, out var texture, out var mode)) + if (!changedIndex.TryGetTexture(actor, out var texture)) continue; - if (!_directX.TryGetColorTable(*texture, out var table)) + if (!PrepareColorSet.TryGetColorTable(actor, changedIndex, out var baseTable, out var mode)) continue; - if (value.HasValue) - value.Value.Apply(ref table[index.RowIndex], mode); - else if (PrepareColorSet.TryGetColorTable(actor, index, out var baseTable, out _)) - table[index.RowIndex] = baseTable[index.RowIndex]; - else - continue; + foreach (var (index, value) in state.Materials.GetValues( + MaterialValueIndex.Min(changedIndex.DrawObject, changedIndex.SlotIndex, changedIndex.MaterialIndex), + MaterialValueIndex.Max(changedIndex.DrawObject, changedIndex.SlotIndex, changedIndex.MaterialIndex))) + { + if (index == changedIndex.Key) + changedValue?.Apply(ref baseTable[changedIndex.RowIndex], mode); + else + value.Model.Apply(ref baseTable[MaterialValueIndex.FromKey(index).RowIndex], mode); + } - _directX.ReplaceColorTable(texture, table); + _directX.ReplaceColorTable(texture, baseTable); } } @@ -337,7 +341,8 @@ public class StateApplier( { var data = GetData(state); if (apply) - ChangeMaterialValue(data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null, state.IsLocked); + ChangeMaterialValue(state, data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null, state.IsLocked); + return data; } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index f16dd22..eabaf2f 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -293,7 +293,7 @@ public sealed class StateManager( { actors = Applier.ChangeParameters(state, CustomizeParameterExtensions.All, true); foreach (var (idx, mat) in state.Materials.Values) - Applier.ChangeMaterialValue(actors, MaterialValueIndex.FromKey(idx), mat.Game, true); + Applier.ChangeMaterialValue(state, actors, MaterialValueIndex.FromKey(idx), mat.Game, true); } state.Materials.Clear(); From 9e09d64c66b75f04d7643456b26b9325e9f65134 Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 25 Nov 2024 16:00:32 +0000 Subject: [PATCH 137/401] [CI] Updating repo.json for 1.3.4.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 2fe08e4..6398610 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.4.0", - "TestingAssemblyVersion": "1.3.4.0", + "AssemblyVersion": "1.3.4.1", + "TestingAssemblyVersion": "1.3.4.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 66ed721105d0c8c021a858142a7e14e56bb5c8f3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 27 Nov 2024 23:07:42 +0100 Subject: [PATCH 138/401] Treat no Automation Set as empty automation set. --- Glamourer/Automation/AutoDesignApplier.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index ccaae21..e0a4c33 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -222,12 +222,11 @@ public sealed class AutoDesignApplier : IDisposable if (!_config.EnableAutoDesigns) return; - if (!GetPlayerSet(identifier, out var set)) - return; - if (reset) _state.ResetState(state, StateSource.Game); - Reduce(actor, state, set, false, false, out forcedRedraw); + + if (GetPlayerSet(identifier, out var set)) + Reduce(actor, state, set, false, false, out forcedRedraw); } public bool Reduce(Actor actor, ActorIdentifier identifier, [NotNullWhen(true)] out ActorState? state) @@ -284,7 +283,8 @@ public sealed class AutoDesignApplier : IDisposable return; var mergedDesign = _designMerger.Merge( - set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), + set.Designs.Where(d => d.IsActive(actor)) + .SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false)); From 533c53fd8d51801f6c40f407802bb111bfcf25eb Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 27 Nov 2024 23:28:56 +0100 Subject: [PATCH 139/401] Fix some issues with Crests --- Glamourer/Glamourer.cs | 2 +- Glamourer/Interop/CrestService.cs | 25 +++++++++++++++++++ .../Interop/Penumbra/ModSettingApplier.cs | 2 +- Penumbra.GameData | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index b4489e8..93173ba 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -139,7 +139,7 @@ public class Glamourer : IDalamudPlugin ReadOnlySpan relevantPlugins = [ "Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge", - "LoporritSync", + "LoporritSync", "GagSpeak", "RoleplayingVoiceDalamud", ]; var plugins = _services.GetService().InstalledPlugins .GroupBy(p => p.InternalName) diff --git a/Glamourer/Interop/CrestService.cs b/Glamourer/Interop/CrestService.cs index 8e217b6..95b3587 100644 --- a/Glamourer/Interop/CrestService.cs +++ b/Glamourer/Interop/CrestService.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; +using FFXIVClientStructs.FFXIV.Client.Game.Event; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using OtterGui.Classes; using Penumbra.GameData; @@ -37,6 +38,7 @@ public sealed unsafe class CrestService : EventWrapperRef3 _crestChangeCallerHook = null!; + + private delegate void CrestChangeCallerDelegate(DrawDataContainer* container, byte* data); + + private void CrestChangeCallerDetour(DrawDataContainer* container, byte* data) + { + var actor = (Actor)container->OwnerObject; + ref var flags = ref data[16]; + foreach (var slot in CrestExtensions.AllRelevantSet) + { + var newValue = ((CrestFlag)flags).HasFlag(slot); + Invoke(actor, slot, ref newValue); + flags = (byte)(newValue ? flags | (byte)slot : flags & (byte)~slot); + } + Glamourer.Log.Verbose( + $"Called inlined CrestChange via CrestChangeCaller on {(ulong)container:X} with {(flags & 0x1F):X} and prior flags {actor.CrestBitfield}."); + + using var _ = _inUpdate.EnterMethod(); + _crestChangeCallerHook.Original(container, data); + } + public static bool GetModelCrest(Actor gameObject, CrestFlag slot) { if (!gameObject.IsCharacter) diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index fcdc7b7..a6fe3e5 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -18,7 +18,7 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O if (!objects.TryGetValue(state.Identifier, out var data)) { Glamourer.Log.Verbose( - $"[Mod Applier] No mod settings applied because no actor for {state.Identifier} could be found to associate collection."); + $"[Mod Applier] No mod settings applied because no actor for {state.Identifier.Incognito(null)} could be found to associate collection."); return; } diff --git a/Penumbra.GameData b/Penumbra.GameData index 79d8d78..cceebd8 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 79d8d782b3b454a41f7f87f398806ec4d08d485f +Subproject commit cceebd89a19e27ac843b0a7d17d3c2bb41c77367 From 4215e0ad447cd425d6f9f4b27fe0d46db0cfd6ef Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 27 Nov 2024 23:44:30 +0100 Subject: [PATCH 140/401] Add default settings for design configuration. --- Glamourer/Configuration.cs | 9 +++++ Glamourer/Designs/Design.cs | 12 ++++--- Glamourer/Designs/DesignManager.cs | 36 +++++++++++-------- Glamourer/Designs/Links/LinkContainer.cs | 16 +++++++-- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 15 ++++++++ 5 files changed, 67 insertions(+), 21 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 165e20d..77fc84f 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -25,6 +25,13 @@ public enum HeightDisplayType OlympicPool, } +public class DefaultDesignSettings +{ + public bool AlwaysForceRedrawing = false; + public bool ResetAdvancedDyes = false; + public bool ShowQuickDesignBar = true; +} + public class Configuration : IPluginConfiguration, ISavable { [JsonIgnore] @@ -59,6 +66,8 @@ public class Configuration : IPluginConfiguration, ISavable public bool AllowDoubleClickToApply { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false; + public DefaultDesignSettings DefaultDesignSettings { get; set; } = new(); + public HeightDisplayType HeightDisplayType { get; set; } = HeightDisplayType.Centimetre; public RenameField ShowRename { get; set; } = RenameField.BothDataPrio; public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY); diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index c58d74f..6cc9eef 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -28,10 +28,14 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn internal Design(Design other) : base(other) { - Tags = [.. other.Tags]; - Description = other.Description; - QuickDesign = other.QuickDesign; - AssociatedMods = new SortedList(other.AssociatedMods); + Tags = [.. other.Tags]; + Description = other.Description; + QuickDesign = other.QuickDesign; + ForcedRedraw = other.ForcedRedraw; + ResetAdvancedDyes = other.ResetAdvancedDyes; + Color = other.Color; + AssociatedMods = new SortedList(other.AssociatedMods); + Links = Links.Clone(); } // Metadata diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 15e38ee..b889649 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -99,11 +99,14 @@ public sealed class DesignManager : DesignEditor var (actualName, path) = ParseName(name, handlePath); var design = new Design(Customizations, Items) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, + ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, + ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, + QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, }; Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier}."); @@ -118,11 +121,14 @@ public sealed class DesignManager : DesignEditor var (actualName, path) = ParseName(name, handlePath); var design = new Design(clone) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, + ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, + ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, + QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, }; Designs.Add(design); @@ -138,11 +144,11 @@ public sealed class DesignManager : DesignEditor var (actualName, path) = ParseName(name, handlePath); var design = new Design(clone) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, }; Designs.Add(design); Glamourer.Log.Debug( diff --git a/Glamourer/Designs/Links/LinkContainer.cs b/Glamourer/Designs/Links/LinkContainer.cs index ef67688..6cfc121 100644 --- a/Glamourer/Designs/Links/LinkContainer.cs +++ b/Glamourer/Designs/Links/LinkContainer.cs @@ -14,6 +14,16 @@ public sealed class LinkContainer : List public new int Count => base.Count + After.Count; + public LinkContainer Clone() + { + var ret = new LinkContainer(); + ret.EnsureCapacity(base.Count); + ret.After.EnsureCapacity(After.Count); + ret.AddRange(this); + ret.After.AddRange(After); + return ret; + } + public bool Reorder(int fromIndex, LinkOrder fromOrder, int toIndex, LinkOrder toOrder) { var fromList = fromOrder switch @@ -89,13 +99,15 @@ public sealed class LinkContainer : List if (GetAllLinks(parent).Any(l => l.Link.Link == child && l.Order != order)) { - error = $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the parent already links to the child in the opposite direction."; + error = + $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the parent already links to the child in the opposite direction."; return false; } if (GetAllLinks(child).Any(l => l.Link.Link == parent && l.Order == order)) { - error = $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the child already links to the parent in the opposite direction."; + error = + $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the child already links to the parent in the opposite direction."; return false; } diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 1540696..052c0b8 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -10,6 +10,7 @@ using Glamourer.Interop.PalettePlus; using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.SettingsTab; @@ -51,6 +52,7 @@ public class SettingsTab( using (ImRaii.Child("SettingsChild")) { DrawBehaviorSettings(); + DrawDesignDefaultSettings(); DrawInterfaceSettings(); DrawColorSettings(); overrides.Draw(); @@ -101,6 +103,19 @@ public class SettingsTab( ImGui.NewLine(); } + private void DrawDesignDefaultSettings() + { + if (!ImUtf8.CollapsingHeader("Design Defaults")) + return; + + Checkbox("Show in Quick Design Bar", "Newly created designs will be shown in the quick design bar by default.", + config.DefaultDesignSettings.ShowQuickDesignBar, v => config.DefaultDesignSettings.ShowQuickDesignBar = v); + Checkbox("Reset Advanced Dyes", "Newly created designs will be configured to reset advanced dyes on application by default.", + config.DefaultDesignSettings.ResetAdvancedDyes, v => config.DefaultDesignSettings.ResetAdvancedDyes = v); + Checkbox("Always Force Redraw", "Newly created designs will be configured to force character redraws on application by default.", + config.DefaultDesignSettings.AlwaysForceRedrawing, v => config.DefaultDesignSettings.AlwaysForceRedrawing = v); + } + private void DrawInterfaceSettings() { if (!ImGui.CollapsingHeader("Interface")) From 467dc2c22f7d4d6ffa1f1d6fd5737a1214eec467 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 29 Nov 2024 16:36:00 +0000 Subject: [PATCH 141/401] [CI] Updating repo.json for 1.3.4.2 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 6398610..186f396 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.4.1", - "TestingAssemblyVersion": "1.3.4.1", + "AssemblyVersion": "1.3.4.2", + "TestingAssemblyVersion": "1.3.4.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.2/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c9febe2c74d3ed7c94eaed5f4c59504842444108 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 30 Nov 2024 22:11:06 +0100 Subject: [PATCH 142/401] Try to make random designs in automation stick around when redrawing/changing zone. --- Glamourer/Automation/AutoDesignApplier.cs | 16 ++++++++-------- Glamourer/Designs/Design.cs | 2 +- Glamourer/Designs/IDesignStandIn.cs | 2 +- Glamourer/Designs/Special/QuickSelectedDesign.cs | 4 ++-- Glamourer/Designs/Special/RandomDesign.cs | 16 ++++++++-------- Glamourer/Designs/Special/RevertDesign.cs | 4 ++-- Glamourer/State/StateEditor.cs | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index e0a4c33..8e0b75c 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -152,7 +152,7 @@ public sealed class AutoDesignApplier : IDisposable { if (_state.GetOrCreate(id, data.Objects[0], out var state)) { - Reduce(data.Objects[0], state, newSet, _config.RespectManualOnAutomationUpdate, false, out var forcedRedraw); + Reduce(data.Objects[0], state, newSet, _config.RespectManualOnAutomationUpdate, false, true, out var forcedRedraw); foreach (var actor in data.Objects) _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); } @@ -164,7 +164,7 @@ public sealed class AutoDesignApplier : IDisposable var specificId = actor.GetIdentifier(_actors); if (_state.GetOrCreate(specificId, actor, out var state)) { - Reduce(actor, state, newSet, _config.RespectManualOnAutomationUpdate, false, out var forcedRedraw); + Reduce(actor, state, newSet, _config.RespectManualOnAutomationUpdate, false, true, out var forcedRedraw); _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); } } @@ -212,7 +212,7 @@ public sealed class AutoDesignApplier : IDisposable var respectManual = state.LastJob == newJob.Id; state.LastJob = actor.Job; - Reduce(actor, state, set, respectManual, true, out var forcedRedraw); + Reduce(actor, state, set, respectManual, true, true, out var forcedRedraw); _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); } @@ -226,7 +226,7 @@ public sealed class AutoDesignApplier : IDisposable _state.ResetState(state, StateSource.Game); if (GetPlayerSet(identifier, out var set)) - Reduce(actor, state, set, false, false, out forcedRedraw); + Reduce(actor, state, set, false, false, false, out forcedRedraw); } public bool Reduce(Actor actor, ActorIdentifier identifier, [NotNullWhen(true)] out ActorState? state) @@ -253,11 +253,11 @@ public sealed class AutoDesignApplier : IDisposable var respectManual = !state.UpdateTerritory(_clientState.TerritoryType) || !_config.RevertManualChangesOnZoneChange; if (!respectManual) _state.ResetState(state, StateSource.Game); - Reduce(actor, state, set, respectManual, false, out _); + Reduce(actor, state, set, respectManual, false, false, out _); return true; } - private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange, out bool forcedRedraw) + private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange, bool newApplication, out bool forcedRedraw) { if (set.BaseState is AutoDesignSet.Base.Game) { @@ -284,7 +284,7 @@ public sealed class AutoDesignApplier : IDisposable var mergedDesign = _designMerger.Merge( set.Designs.Where(d => d.IsActive(actor)) - .SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), + .SelectMany(d => d.Design.AllLinks(newApplication).Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false)); @@ -337,7 +337,7 @@ public sealed class AutoDesignApplier : IDisposable var respectManual = prior == id; NewGearsetId = id; - Reduce(data.Objects[0], state, set, respectManual, job != state.LastJob, out var forcedRedraw); + Reduce(data.Objects[0], state, set, respectManual, job != state.LastJob, prior == id, out var forcedRedraw); NewGearsetId = -1; foreach (var actor in data.Objects) _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index 6cc9eef..bafffc9 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -58,7 +58,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn public string Incognito => Identifier.ToString()[..8]; - public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks + public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication) => LinkContainer.GetAllLinks(this).Select(t => ((IDesignStandIn)t.Link.Link, t.Link.Type, JobFlag.All)); #endregion diff --git a/Glamourer/Designs/IDesignStandIn.cs b/Glamourer/Designs/IDesignStandIn.cs index fd76b4b..02baee4 100644 --- a/Glamourer/Designs/IDesignStandIn.cs +++ b/Glamourer/Designs/IDesignStandIn.cs @@ -16,7 +16,7 @@ public interface IDesignStandIn : IEquatable public string SerializeName(); public StateSource AssociatedSource(); - public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks { get; } + public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication); public void AddData(JObject jObj); diff --git a/Glamourer/Designs/Special/QuickSelectedDesign.cs b/Glamourer/Designs/Special/QuickSelectedDesign.cs index 1919929..31fb40f 100644 --- a/Glamourer/Designs/Special/QuickSelectedDesign.cs +++ b/Glamourer/Designs/Special/QuickSelectedDesign.cs @@ -39,8 +39,8 @@ public class QuickSelectedDesign(QuickDesignCombo combo) : IDesignStandIn, IServ public StateSource AssociatedSource() => StateSource.Manual; - public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks - => combo.Design?.AllLinks ?? []; + public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication) + => combo.Design?.AllLinks(newApplication) ?? []; public void AddData(JObject jObj) { } diff --git a/Glamourer/Designs/Special/RandomDesign.cs b/Glamourer/Designs/Special/RandomDesign.cs index bbb9b7d..13d914a 100644 --- a/Glamourer/Designs/Special/RandomDesign.cs +++ b/Glamourer/Designs/Special/RandomDesign.cs @@ -46,17 +46,17 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public StateSource AssociatedSource() => StateSource.Manual; - public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks + public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication) { - get - { + if (newApplication) _currentDesign = rng.Design(Predicates); - if (_currentDesign == null) - yield break; + else + _currentDesign ??= rng.Design(Predicates); + if (_currentDesign == null) + yield break; - foreach (var (link, type, jobs) in _currentDesign.AllLinks) - yield return (link, type, jobs); - } + foreach (var (link, type, jobs) in _currentDesign.AllLinks(newApplication)) + yield return (link, type, jobs); } public void AddData(JObject jObj) diff --git a/Glamourer/Designs/Special/RevertDesign.cs b/Glamourer/Designs/Special/RevertDesign.cs index 5f8d8c6..8704339 100644 --- a/Glamourer/Designs/Special/RevertDesign.cs +++ b/Glamourer/Designs/Special/RevertDesign.cs @@ -29,9 +29,9 @@ public class RevertDesign : IDesignStandIn public StateSource AssociatedSource() => StateSource.Game; - public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks + public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool _) { - get { yield return (this, ApplicationType.All, JobFlag.All); } + yield return (this, ApplicationType.All, JobFlag.All); } public void AddData(JObject jObj) diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 59f27a2..f9ddb89 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -437,7 +437,7 @@ public class StateEditor( if (!settings.MergeLinks || design is not Design d) merged = new MergedDesign(design); else - merged = merger.Merge(d.AllLinks, state.ModelData.IsHuman ? state.ModelData.Customize : CustomizeArray.Default, state.BaseData, + merged = merger.Merge(d.AllLinks(true), state.ModelData.IsHuman ? state.ModelData.Customize : CustomizeArray.Default, state.BaseData, false, Config.AlwaysApplyAssociatedMods); ApplyDesign(data, merged, settings with From 31cd8125194380e5ba7f099d18455c1c654eec62 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 9 Dec 2024 21:23:33 +0100 Subject: [PATCH 143/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index cceebd8..da74a4b 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit cceebd89a19e27ac843b0a7d17d3c2bb41c77367 +Subproject commit da74a4be9c9728c6c52134c42603cd8a7040c568 From 27e9223c814ee0071639e7340750532a0d78c8ae Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 9 Dec 2024 21:29:35 +0100 Subject: [PATCH 144/401] Again --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index da74a4b..fb692d1 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit da74a4be9c9728c6c52134c42603cd8a7040c568 +Subproject commit fb692d13205fed5e6c5f4c939477c28473198a3b From f424857bd399ef7182b2b568272905ba01aaa25d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 13 Dec 2024 15:42:49 +0100 Subject: [PATCH 145/401] Again. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index fb692d1..315258f 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit fb692d13205fed5e6c5f4c939477c28473198a3b +Subproject commit 315258f4f8a59d744aa4d2d1f8c31d410d041729 From c951854d5a6cc2c76deccbf4ce307b9f23214f5c Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 13 Dec 2024 17:14:14 +0000 Subject: [PATCH 146/401] [CI] Updating repo.json for 1.3.4.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 186f396..f7d8512 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.4.2", - "TestingAssemblyVersion": "1.3.4.2", + "AssemblyVersion": "1.3.4.3", + "TestingAssemblyVersion": "1.3.4.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.2/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.2/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From b90e68fbafb5d9e4c0b26f4afa3e7508e14aed35 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Dec 2024 14:17:47 +0100 Subject: [PATCH 147/401] Fix inverted application of apply flags in IPC --- Glamourer/Api/StateApi.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 385cf3e..331942b 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -322,8 +322,8 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable version = DesignConverter.Version; return state switch { - string s => _converter.FromBase64(s, (flags & ApplyFlag.Equipment) != 0, (flags & ApplyFlag.Customization) != 0, out version), - JObject j => _converter.FromJObject(j, (flags & ApplyFlag.Equipment) != 0, (flags & ApplyFlag.Customization) != 0), + string s => _converter.FromBase64(s, (flags & ApplyFlag.Customization) != 0, (flags & ApplyFlag.Equipment) != 0, out version), + JObject j => _converter.FromJObject(j, (flags & ApplyFlag.Customization) != 0, (flags & ApplyFlag.Equipment) != 0), _ => null, }; } From f3eb5429407fc427983f971df5fc0458b06bc299 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Dec 2024 14:18:34 +0100 Subject: [PATCH 148/401] Add option to always reset random designs. --- Glamourer/Designs/Special/RandomDesign.cs | 28 +++++++++++++------ Glamourer/Glamourer.cs | 2 +- .../AutomationTab/RandomRestrictionDrawer.cs | 6 ++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Glamourer/Designs/Special/RandomDesign.cs b/Glamourer/Designs/Special/RandomDesign.cs index 13d914a..a54ffcf 100644 --- a/Glamourer/Designs/Special/RandomDesign.cs +++ b/Glamourer/Designs/Special/RandomDesign.cs @@ -12,7 +12,8 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public const string ResolvedName = "Random"; private Design? _currentDesign; - public IReadOnlyList Predicates { get; private set; } = []; + public IReadOnlyList Predicates { get; private set; } = []; + public bool ResetOnRedraw { get; set; } = false; public string ResolveName(bool _) => ResolvedName; @@ -40,6 +41,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public bool Equals(IDesignStandIn? other) => other is RandomDesign r + && r.ResetOnRedraw == ResetOnRedraw && string.Equals(RandomPredicate.GeneratePredicateString(r.Predicates), RandomPredicate.GeneratePredicateString(Predicates), StringComparison.OrdinalIgnoreCase); @@ -48,7 +50,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication) { - if (newApplication) + if (newApplication || ResetOnRedraw) _currentDesign = rng.Design(Predicates); else _currentDesign ??= rng.Design(Predicates); @@ -61,22 +63,32 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn public void AddData(JObject jObj) { - jObj["Restrictions"] = RandomPredicate.GeneratePredicateString(Predicates); + jObj["Restrictions"] = RandomPredicate.GeneratePredicateString(Predicates); + jObj["ResetOnRedraw"] = ResetOnRedraw; } public void ParseData(JObject jObj) { var restrictions = jObj["Restrictions"]?.ToObject() ?? string.Empty; - Predicates = RandomPredicate.GeneratePredicates(restrictions); + Predicates = RandomPredicate.GeneratePredicates(restrictions); + ResetOnRedraw = jObj["ResetOnRedraw"]?.ToObject() ?? false; } public bool ChangeData(object data) { - if (data is not List predicates) - return false; + if (data is List predicates) + { + Predicates = predicates; + return true; + } - Predicates = predicates; - return true; + if (data is bool resetOnRedraw) + { + ResetOnRedraw = resetOnRedraw; + return true; + } + + return false; } public bool ForcedRedraw diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 93173ba..9c4583f 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -139,7 +139,7 @@ public class Glamourer : IDalamudPlugin ReadOnlySpan relevantPlugins = [ "Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge", - "LoporritSync", "GagSpeak", "RoleplayingVoiceDalamud", + "LoporritSync", "GagSpeak", "ProjectGagSpeak", "RoleplayingVoiceDalamud", ]; var plugins = _services.GetService().InstalledPlugins .GroupBy(p => p.InternalName) diff --git a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs index f125f36..e7efc09 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs @@ -8,6 +8,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Services; +using OtterGui.Text; namespace Glamourer.Gui.Tabs.AutomationTab; @@ -385,6 +386,11 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y + ImGuiHelpers.GlobalScale); ImGui.Separator(); ImGui.Dummy(Vector2.Zero); + var reset = random.ResetOnRedraw; + if (ImUtf8.Checkbox("Reset Chosen Design On Every Redraw"u8, ref reset)) + _autoDesignManager.ChangeData(_set!, _designIndex, reset); + ImGui.Separator(); + ImGui.Dummy(Vector2.Zero); var list = random.Predicates.ToList(); if (list.Count == 0) From 33bf5c53920194876a726bbe356b6242db4faa7d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Dec 2024 14:18:51 +0100 Subject: [PATCH 149/401] Update GameData versioning. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 315258f..983b018 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 315258f4f8a59d744aa4d2d1f8c31d410d041729 +Subproject commit 983b0184830bfe4336651ba94175526c0f891e10 From a1162439007212d7bf3cbb198ae7f6ad69215d1c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Dec 2024 14:29:32 +0100 Subject: [PATCH 150/401] Maybe fix disabling auto designs. --- Glamourer/Automation/AutoDesignApplier.cs | 21 +++++++++++++++---- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 10 +++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 8e0b75c..e506d9f 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -55,6 +55,15 @@ public sealed class AutoDesignApplier : IDisposable _equippedGearset.Subscribe(OnEquippedGearset, EquippedGearset.Priority.AutoDesignApplier); } + public void OnEnableAutoDesignsChanged(bool value) + { + if (value) + return; + + foreach (var state in _state.Values) + state.Sources.RemoveFixedDesignSources(); + } + public void Dispose() { _weapons.Unsubscribe(OnWeaponLoading); @@ -234,9 +243,6 @@ public sealed class AutoDesignApplier : IDisposable AutoDesignSet set; if (!_state.TryGetValue(identifier, out state)) { - if (!_config.EnableAutoDesigns) - return false; - if (!GetPlayerSet(identifier, out set!)) return false; @@ -257,7 +263,8 @@ public sealed class AutoDesignApplier : IDisposable return true; } - private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange, bool newApplication, out bool forcedRedraw) + private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange, bool newApplication, + out bool forcedRedraw) { if (set.BaseState is AutoDesignSet.Base.Game) { @@ -294,6 +301,12 @@ public sealed class AutoDesignApplier : IDisposable /// Get world-specific first and all-world afterward. private bool GetPlayerSet(ActorIdentifier identifier, [NotNullWhen(true)] out AutoDesignSet? set) { + if (!_config.EnableAutoDesigns) + { + set = null; + return false; + } + switch (identifier.Type) { case IdentifierType.Player: diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 052c0b8..c6d69fd 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -3,6 +3,7 @@ using Dalamud.Interface; using Dalamud.Interface.Components; using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; +using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; @@ -27,7 +28,8 @@ public class SettingsTab( PalettePlusChecker paletteChecker, CollectionOverrideDrawer overrides, CodeDrawer codeDrawer, - Glamourer glamourer) + Glamourer glamourer, + AutoDesignApplier autoDesignApplier) : ITab { private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray(); @@ -43,7 +45,11 @@ public class SettingsTab( Checkbox("Enable Auto Designs", "Enable the application of designs associated to characters in the Automation tab to be applied automatically.", - config.EnableAutoDesigns, v => config.EnableAutoDesigns = v); + config.EnableAutoDesigns, v => + { + config.EnableAutoDesigns = v; + autoDesignApplier.OnEnableAutoDesignsChanged(v); + }); ImGui.NewLine(); ImGui.NewLine(); ImGui.NewLine(); From 664b42eee849cf0c0f4cb2d68403372f03c7043f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 17 Dec 2024 18:05:07 +0100 Subject: [PATCH 151/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 983b018..6848397 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 983b0184830bfe4336651ba94175526c0f891e10 +Subproject commit 6848397dd77cfcdbff1accd860d5b7e95f8c9fe5 From 56d014e14fb8527d06e5221e51404bb730ed3443 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 25 Dec 2024 22:21:58 +0100 Subject: [PATCH 152/401] Fix ImGui Assertion. --- Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs | 2 +- OtterGui | 2 +- Penumbra.GameData | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index 2e5524f..2c797b8 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -295,7 +295,7 @@ public partial class CustomizationDrawer private void ApplyCheckbox(CustomizeIndex index) { - SetId(index); + using var id = SetId(index); if (UiHelpers.DrawCheckbox("##apply", $"Apply the {_currentOption} customization in this design.", _currentApply, out _, _locked)) ToggleApply(); } diff --git a/OtterGui b/OtterGui index 95b8d17..d9caded 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 95b8d177883b03f804d77434f45e9de97fdb9adf +Subproject commit d9caded5efb7c9db0a273a43bb5f6d53cf4ace7f diff --git a/Penumbra.GameData b/Penumbra.GameData index 6848397..ffc149c 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 6848397dd77cfcdbff1accd860d5b7e95f8c9fe5 +Subproject commit ffc149cc8c169c2c6e838cbd138676f6fe4daeea From ebd3fb3fbfb6ff9981e399b0d09c2a5c89decb3c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 29 Dec 2024 13:38:21 +0100 Subject: [PATCH 153/401] Update submodules. --- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Penumbra.Api b/Penumbra.Api index 97e9f42..882b778 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 97e9f427406f82a59ddef764b44ecea654a51623 +Subproject commit 882b778e78bb0806dd7d38e8b3670ff138a84a31 diff --git a/Penumbra.GameData b/Penumbra.GameData index ffc149c..19355cf 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit ffc149cc8c169c2c6e838cbd138676f6fe4daeea +Subproject commit 19355cfa0ec80e8d5a91de11ecffc49257b37b53 diff --git a/Penumbra.String b/Penumbra.String index f04abba..0647fbc 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit f04abbabedf5e757c5cbb970f3e513fef23e53cf +Subproject commit 0647fbc5017ef9ced3f3ce1c2496eefd57c5b7a8 From 70cf21cf57040fa54b8a7a55dc3507bba8b33c95 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 29 Dec 2024 15:48:54 +0100 Subject: [PATCH 154/401] Accept more colors in designs as valid (independently of clan/gender and mixing highlights/hair and both eyes). --- Glamourer/GameData/CustomizeSet.cs | 14 ++++-- Glamourer/GameData/CustomizeSetFactory.cs | 9 +--- Glamourer/GameData/NpcCustomizeSet.cs | 32 +++++++++++-- .../DebugTab/CustomizationServicePanel.cs | 48 ++++++++++++++++++- 4 files changed, 85 insertions(+), 18 deletions(-) diff --git a/Glamourer/GameData/CustomizeSet.cs b/Glamourer/GameData/CustomizeSet.cs index 7fcf1d2..178ef07 100644 --- a/Glamourer/GameData/CustomizeSet.cs +++ b/Glamourer/GameData/CustomizeSet.cs @@ -11,12 +11,15 @@ namespace Glamourer.GameData; /// public class CustomizeSet { - internal CustomizeSet(SubRace clan, Gender gender) + private NpcCustomizeSet _npcCustomizations; + + internal CustomizeSet(NpcCustomizeSet npcCustomizations, SubRace clan, Gender gender) { - Gender = gender; - Clan = clan; - Race = clan.ToRace(); - SettingAvailable = 0; + _npcCustomizations = npcCustomizations; + Gender = gender; + Clan = clan; + Race = clan.ToRace(); + SettingAvailable = 0; } public Gender Gender { get; } @@ -85,6 +88,7 @@ public class CustomizeSet { if (IsAvailable(index)) return DataByValue(index, value, out custom, face) >= 0 + || _npcCustomizations.CheckColor(index, value) || NpcOptions.Any(t => t.Type == index && t.Value == value); custom = null; diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index e2291d4..13a9865 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -1,6 +1,5 @@ using Dalamud.Game; using Dalamud.Plugin.Services; -using Dalamud.Utility; using Lumina.Excel; using Lumina.Excel.Sheets; using OtterGui.Classes; @@ -29,7 +28,7 @@ internal class CustomizeSetFactory( var row = _charaMakeSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender)!; var hrothgar = race.ToRace() == Race.Hrothgar; // Create the initial set with all the easily accessible parameters available for anyone. - var set = new CustomizeSet(race, gender) + var set = new CustomizeSet(_npcCustomizeSet, race, gender) { Name = GetName(race, gender), Voices = row.VoiceStruct, @@ -77,13 +76,7 @@ internal class CustomizeSetFactory( CustomizeIndex.Hairstyle, CustomizeIndex.LipColor, CustomizeIndex.SkinColor, - CustomizeIndex.FacePaintColor, - CustomizeIndex.HighlightsColor, - CustomizeIndex.HairColor, CustomizeIndex.FacePaint, - CustomizeIndex.TattooColor, - CustomizeIndex.EyeColorLeft, - CustomizeIndex.EyeColorRight, CustomizeIndex.TailShape, }; diff --git a/Glamourer/GameData/NpcCustomizeSet.cs b/Glamourer/GameData/NpcCustomizeSet.cs index 72ed4b4..4dbfd83 100644 --- a/Glamourer/GameData/NpcCustomizeSet.cs +++ b/Glamourer/GameData/NpcCustomizeSet.cs @@ -4,6 +4,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.Object; using Lumina.Excel.Sheets; using OtterGui.Services; using Penumbra.GameData.DataContainers; +using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; namespace Glamourer.GameData; @@ -35,6 +36,23 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// The list of data. private readonly List _data = []; + private readonly BitArray _hairColors = new(256); + private readonly BitArray _eyeColors = new(256); + private readonly BitArray _facepaintColors = new(256); + private readonly BitArray _tattooColors = new(256); + + public bool CheckColor(CustomizeIndex type, CustomizeValue value) + => type switch + { + CustomizeIndex.HairColor => _hairColors[value.Value], + CustomizeIndex.HighlightsColor => _hairColors[value.Value], + CustomizeIndex.EyeColorLeft => _eyeColors[value.Value], + CustomizeIndex.EyeColorRight => _eyeColors[value.Value], + CustomizeIndex.FacePaintColor => _facepaintColors[value.Value], + CustomizeIndex.TattooColor => _tattooColors[value.Value], + _ => false, + }; + /// Create the data when ready. public NpcCustomizeSet(IDataManager data, DictENpc eNpcs, DictBNpc bNpcs, DictBNpcNames bNpcNames) { @@ -147,6 +165,12 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList for (var i = 0; i < duplicates.Count; ++i) { var current = duplicates[i]; + _hairColors[current.Customize[CustomizeIndex.HairColor].Value] = true; + _hairColors[current.Customize[CustomizeIndex.HighlightsColor].Value] = true; + _eyeColors[current.Customize[CustomizeIndex.EyeColorLeft].Value] = true; + _eyeColors[current.Customize[CustomizeIndex.EyeColorRight].Value] = true; + _facepaintColors[current.Customize[CustomizeIndex.FacePaintColor].Value] = true; + _tattooColors[current.Customize[CustomizeIndex.TattooColor].Value] = true; for (var j = 0; j < i; ++j) { if (current.DataEquals(duplicates[j])) @@ -195,8 +219,8 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList data.Set(7, row.ModelWrists | (row.DyeWrists.RowId << 24) | ((ulong)row.Dye2Wrists.RowId << 32)); data.Set(8, row.ModelRightRing | (row.DyeRightRing.RowId << 24) | ((ulong)row.Dye2RightRing.RowId << 32)); data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.RowId << 24) | ((ulong)row.Dye2LeftRing.RowId << 32)); - data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.RowId << 48) | ((ulong)row.Dye2MainHand.RowId << 56)); - data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.RowId << 48) | ((ulong)row.Dye2OffHand.RowId << 56)); + data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.RowId << 48) | ((ulong)row.Dye2MainHand.RowId << 56)); + data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.RowId << 48) | ((ulong)row.Dye2OffHand.RowId << 56)); data.VisorToggled = row.Visor; } @@ -213,8 +237,8 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList data.Set(7, row.ModelWrists | (row.DyeWrists.RowId << 24) | ((ulong)row.Dye2Wrists.RowId << 32)); data.Set(8, row.ModelRightRing | (row.DyeRightRing.RowId << 24) | ((ulong)row.Dye2RightRing.RowId << 32)); data.Set(9, row.ModelLeftRing | (row.DyeLeftRing.RowId << 24) | ((ulong)row.Dye2LeftRing.RowId << 32)); - data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.RowId << 48) | ((ulong)row.Dye2MainHand.RowId << 56)); - data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.RowId << 48) | ((ulong)row.Dye2OffHand.RowId << 56)); + data.Mainhand = new CharacterWeapon(row.ModelMainHand | ((ulong)row.DyeMainHand.RowId << 48) | ((ulong)row.Dye2MainHand.RowId << 56)); + data.Offhand = new CharacterWeapon(row.ModelOffHand | ((ulong)row.DyeOffHand.RowId << 48) | ((ulong)row.Dye2OffHand.RowId << 56)); data.VisorToggled = row.Visor; } diff --git a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs index 17e180e..afc7d56 100644 --- a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs @@ -1,10 +1,13 @@ -using Glamourer.GameData; +using Dalamud.Interface; +using Glamourer.GameData; using Glamourer.Services; using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.DebugTab; @@ -24,6 +27,49 @@ public class CustomizationServicePanel(CustomizeService customize) : IGameDataDr DrawCustomizationInfo(set); DrawNpcCustomizationInfo(set); } + + DrawColorInfo(); + } + + private void DrawColorInfo() + { + using var tree = ImUtf8.TreeNode("NPC Colors"u8); + if (!tree) + return; + + using var table = ImUtf8.Table("data"u8, 5, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + if (!table) + return; + + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Id"u8); + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Hair"u8); + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Eyes"u8); + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Facepaint"u8); + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Tattoos"u8); + + for (var i = 192; i < 256; ++i) + { + var index = new CustomizeValue((byte)i); + ImUtf8.DrawTableColumn($"{i:D3}"); + using var font = ImRaii.PushFont(UiBuilder.IconFont); + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.HairColor, index) + ? FontAwesomeIcon.Check.ToIconString() + : FontAwesomeIcon.Times.ToIconString()); + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.EyeColorLeft, index) + ? FontAwesomeIcon.Check.ToIconString() + : FontAwesomeIcon.Times.ToIconString()); + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.FacePaintColor, index) + ? FontAwesomeIcon.Check.ToIconString() + : FontAwesomeIcon.Times.ToIconString()); + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.TattooColor, index) + ? FontAwesomeIcon.Check.ToIconString() + : FontAwesomeIcon.Times.ToIconString()); + } } private void DrawCustomizationInfo(CustomizeSet set) From 71e80740f679ae68f5d5deec6969455af13665a6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 31 Dec 2024 13:20:36 +0100 Subject: [PATCH 155/401] Add selection designs to chat commands. --- Glamourer/Services/CommandService.cs | 130 +++++--------------- Glamourer/Services/DesignResolver.cs | 173 +++++++++++++++++++++++++++ 2 files changed, 202 insertions(+), 101 deletions(-) create mode 100644 Glamourer/Services/DesignResolver.cs diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 6fb32e2..cee4f57 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -6,6 +6,7 @@ using Glamourer.Designs; using Glamourer.Designs.Special; using Glamourer.GameData; using Glamourer.Gui; +using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop.Penumbra; using Glamourer.State; using ImGuiNET; @@ -22,31 +23,30 @@ namespace Glamourer.Services; public class CommandService : IDisposable, IApiService { - private const string RandomString = "random"; private const string MainCommandString = "/glamourer"; private const string ApplyCommandString = "/glamour"; - private readonly ICommandManager _commands; - private readonly MainWindow _mainWindow; - private readonly IChatGui _chat; - private readonly ActorManager _actors; - private readonly ObjectManager _objects; - private readonly StateManager _stateManager; - private readonly AutoDesignApplier _autoDesignApplier; - private readonly AutoDesignManager _autoDesignManager; - private readonly DesignManager _designManager; - private readonly DesignConverter _converter; - private readonly DesignFileSystem _designFileSystem; - private readonly Configuration _config; - private readonly ModSettingApplier _modApplier; - private readonly ItemManager _items; - private readonly RandomDesignGenerator _randomDesign; - private readonly CustomizeService _customizeService; + private readonly ICommandManager _commands; + private readonly MainWindow _mainWindow; + private readonly IChatGui _chat; + private readonly ActorManager _actors; + private readonly ObjectManager _objects; + private readonly StateManager _stateManager; + private readonly AutoDesignApplier _autoDesignApplier; + private readonly AutoDesignManager _autoDesignManager; + private readonly Configuration _config; + private readonly ModSettingApplier _modApplier; + private readonly ItemManager _items; + private readonly CustomizeService _customizeService; + private readonly DesignManager _designManager; + private readonly DesignConverter _converter; + private readonly DesignResolver _resolver; public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorManager actors, ObjectManager objects, AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter, DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager, Configuration config, ModSettingApplier modApplier, - ItemManager items, RandomDesignGenerator randomDesign, CustomizeService customizeService) + ItemManager items, RandomDesignGenerator randomDesign, CustomizeService customizeService, DesignFileSystemSelector designSelector, + QuickDesignCombo quickDesignCombo, DesignResolver resolver) { _commands = commands; _mainWindow = mainWindow; @@ -57,13 +57,12 @@ public class CommandService : IDisposable, IApiService _stateManager = stateManager; _designManager = designManager; _converter = converter; - _designFileSystem = designFileSystem; _autoDesignManager = autoDesignManager; _config = config; _modApplier = modApplier; _items = items; - _randomDesign = randomDesign; _customizeService = customizeService; + _resolver = resolver; _commands.AddHandler(MainCommandString, new CommandInfo(OnGlamourer) { HelpMessage = "Open or close the Glamourer window." }); _commands.AddHandler(ApplyCommandString, @@ -611,7 +610,7 @@ public class CommandService : IDisposable, IApiService if (split.Length is not 2) { _chat.Print(new SeStringBuilder().AddText("Use with /glamour apply ") - .AddYellow("[Design Name, Path or Identifier, Random, or Clipboard]") + .AddYellow("[Design Name, Path or Identifier, Quick, Selection, Random, or Clipboard]") .AddText(" | ") .AddGreen("[Character Identifier]") .AddText("; ") @@ -628,6 +627,10 @@ public class CommandService : IDisposable, IApiService _chat.Print(new SeStringBuilder() .AddText(" 》 The design path is the folder path in the selector, with '/' as separators. It is also case-insensitive.") .BuiltString); + _chat.Print(new SeStringBuilder() + .AddText(" 》 Quick will use the design currently selected in the Quick Design Bar, if any.").BuiltString); + _chat.Print(new SeStringBuilder() + .AddText(" 》 Selection will use the design currently selected in the main interfaces Designs tab, if any.").BuiltString); _chat.Print(new SeStringBuilder() .AddText(" 》 Clipboard as a single word will try to apply a design string currently in your clipboard.").BuiltString); _chat.Print(new SeStringBuilder() @@ -656,7 +659,7 @@ public class CommandService : IDisposable, IApiService "y" => true, _ => false, }; - if (!GetDesign(split[0], out var design, true) || !IdentifierHandling(split2[0], out var identifiers, false, true)) + if (!_resolver.GetDesign(split[0], out var design, true) || !IdentifierHandling(split2[0], out var identifiers, false, true)) return false; _objects.Update(); @@ -688,7 +691,7 @@ public class CommandService : IDisposable, IApiService if (!applyMods || design is not Design d) return; - var (messages, appliedMods, collection, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor); + var (messages, appliedMods, _, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor); foreach (var message in messages) Glamourer.Messager.Chat.Print($"Error applying mod settings: {message}"); @@ -717,7 +720,7 @@ public class CommandService : IDisposable, IApiService return false; } - if (!GetDesign(argument, out var designBase, false) || designBase is not Design d) + if (!_resolver.GetDesign(argument, out var designBase, false) || designBase is not Design d) return false; _designManager.Delete(d); @@ -796,81 +799,6 @@ public class CommandService : IDisposable, IApiService return false; } - private bool GetDesign(string argument, [NotNullWhen(true)] out DesignBase? design, bool allowSpecial) - { - design = null; - if (argument.Length == 0) - return false; - - if (allowSpecial) - { - if (string.Equals("clipboard", argument, StringComparison.OrdinalIgnoreCase)) - { - try - { - var clipboardText = ImGui.GetClipboardText(); - if (clipboardText.Length > 0) - design = _converter.FromBase64(clipboardText, true, true, out _); - } - catch - { - // ignored - } - - if (design != null) - return true; - - _chat.Print(new SeStringBuilder().AddText("Your current clipboard did not contain a valid design string.").BuiltString); - return false; - } - - if (argument.StartsWith(RandomString, StringComparison.OrdinalIgnoreCase)) - { - try - { - if (argument.Length == RandomString.Length) - design = _randomDesign.Design(); - else if (argument[RandomString.Length] == ':') - design = _randomDesign.Design(argument[(RandomString.Length + 1)..]); - if (design == null) - { - _chat.Print(new SeStringBuilder().AddText("No design matched your restrictions.").BuiltString); - return false; - } - - _chat.Print($"Chose random design {((Design)design).Name}."); - } - catch (Exception ex) - { - _chat.Print(new SeStringBuilder().AddText($"Error in the restriction string: {ex.Message}").BuiltString); - return false; - } - - return true; - } - } - - if (Guid.TryParse(argument, out var guid)) - { - design = _designManager.Designs.ByIdentifier(guid); - } - else - { - var lower = argument.ToLowerInvariant(); - design = _designManager.Designs.FirstOrDefault(d - => d.Name.Lower == lower || lower.Length > 3 && d.Identifier.ToString().StartsWith(lower)); - if (design == null && _designFileSystem.Find(lower, out var child) && child is DesignFileSystem.Leaf leaf) - design = leaf.Value; - } - - if (design != null) - return true; - - _chat.Print(new SeStringBuilder().AddText("The token ").AddYellow(argument, true).AddText(" did not resolve to an existing design.") - .BuiltString); - return false; - } - private unsafe bool IdentifierHandling(string argument, out ActorIdentifier[] identifiers, bool allowAnyWorld, bool allowIndex) { try @@ -882,7 +810,7 @@ public class CommandService : IDisposable, IApiService { _chat.Print(new SeStringBuilder().AddText("The placeholder ").AddGreen(argument) .AddText(" did not resolve to a game object with a valid identifier.").BuiltString); - identifiers = Array.Empty(); + identifiers = []; return false; } @@ -913,7 +841,7 @@ public class CommandService : IDisposable, IApiService _chat.Print(new SeStringBuilder().AddText("The argument ").AddRed(argument, true) .AddText($" could not be converted to an identifier. {e.Message}") .BuiltString); - identifiers = Array.Empty(); + identifiers = []; return false; } } diff --git a/Glamourer/Services/DesignResolver.cs b/Glamourer/Services/DesignResolver.cs new file mode 100644 index 0000000..68b54bb --- /dev/null +++ b/Glamourer/Services/DesignResolver.cs @@ -0,0 +1,173 @@ +using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Plugin.Services; +using Glamourer.Designs; +using Glamourer.Designs.Special; +using Glamourer.Gui; +using Glamourer.Gui.Tabs.DesignTab; +using ImGuiNET; +using OtterGui.Services; +using OtterGui.Classes; + +namespace Glamourer.Services; + +public class DesignResolver( + DesignFileSystemSelector designSelector, + QuickDesignCombo quickDesignCombo, + DesignConverter converter, + DesignManager manager, + DesignFileSystem designFileSystem, + RandomDesignGenerator randomDesign, + IChatGui chat) : IService +{ + private const string RandomString = "random"; + + public bool GetDesign(string argument, [NotNullWhen(true)] out DesignBase? design, bool allowSpecial) + { + if (GetDesign(argument, out design, out var error, out var message, allowSpecial)) + { + if (message != null) + chat.Print(message); + return true; + } + + if (error != null) + chat.Print(error); + return false; + } + + public bool GetDesign(string argument, [NotNullWhen(true)] out DesignBase? design, out SeString? error, out SeString? message, + bool allowSpecial) + { + design = null; + error = null; + message = null; + + if (argument.Length == 0) + return false; + + if (allowSpecial) + { + if (string.Equals("selection", argument, StringComparison.OrdinalIgnoreCase)) + return GetSelectedDesign(ref design, ref error); + + if (string.Equals("quick", argument, StringComparison.OrdinalIgnoreCase)) + return GetQuickDesign(ref design, ref error); + + if (string.Equals("clipboard", argument, StringComparison.OrdinalIgnoreCase)) + return GetClipboardDesign(ref design, ref error); + + if (argument.StartsWith(RandomString, StringComparison.OrdinalIgnoreCase)) + return GetRandomDesign(argument, ref design, ref error, ref message); + } + + return GetStandardDesign(argument, ref design, ref error); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool GetSelectedDesign(ref DesignBase? design, ref SeString? error) + { + design = designSelector.Selected; + if (design != null) + return true; + + error = "You do not have selected any design in the Designs Tab."; + return false; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool GetQuickDesign(ref DesignBase? design, ref SeString? error) + { + design = quickDesignCombo.Design as Design; + if (design != null) + return true; + + error = "You do not have selected any design in the Quick Design Bar."; + return false; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool GetClipboardDesign(ref DesignBase? design, ref SeString? error) + { + try + { + var clipboardText = ImGui.GetClipboardText(); + if (clipboardText.Length > 0) + design = converter.FromBase64(clipboardText, true, true, out _); + } + catch + { + // ignored + } + + if (design != null) + return true; + + error = "Your current clipboard did not contain a valid design string."; + return false; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool GetRandomDesign(string argument, ref DesignBase? design, ref SeString? error, ref SeString? message) + { + try + { + if (argument.Length == RandomString.Length) + design = randomDesign.Design(); + else if (argument[RandomString.Length] == ':') + design = randomDesign.Design(argument[(RandomString.Length + 1)..]); + if (design == null) + { + error = "No design matched your restrictions."; + return false; + } + + message = $"Chose random design {((Design)design).Name}."; + } + catch (Exception ex) + { + error = $"Error in the restriction string: {ex.Message}"; + return false; + } + + return true; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool GetStandardDesign(string argument, ref DesignBase? design, ref SeString? error) + { + // As Guid + if (Guid.TryParse(argument, out var guid)) + { + design = manager.Designs.ByIdentifier(guid); + } + else + { + var lower = argument.ToLowerInvariant(); + // Search for design by name and partial identifier. + design = manager.Designs.FirstOrDefault(MatchNameAndIdentifier(lower)); + // Search for design by path, if nothing was found. + if (design == null && designFileSystem.Find(lower, out var child) && child is DesignFileSystem.Leaf leaf) + design = leaf.Value; + } + + if (design != null) + return true; + + error = new SeStringBuilder().AddText("The token ").AddYellow(argument, true).AddText(" did not resolve to an existing design.") + .BuiltString; + return false; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static Func MatchNameAndIdentifier(string lower) + { + // Check for names and identifiers, prefer names + if (lower.Length > 3) + return d => d.Name.Lower == lower || d.Identifier.ToString().StartsWith(lower); + + // Check only for names. + return d => d.Name.Lower == lower; + } +} From e41755ed7e9d5bc81db2afaa4e9edda6113adb6e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 31 Dec 2024 15:16:14 +0100 Subject: [PATCH 156/401] Freeze the application buttons at the top of the panels. --- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 8 ++- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 13 ++++- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 61 +++++++++++---------- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 14a9e11..2549240 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -154,10 +154,11 @@ public class ActorPanel private unsafe void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); - if (!child || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) + using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + if (!table || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) return; - + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableNextColumn(); var transformationId = _actor.IsCharacter ? _actor.AsCharacter->CharacterData.TransformationId : 0; if (transformationId != 0) ImGuiUtil.DrawTextButton($"Currently transformed to Transformation {transformationId}.", @@ -168,6 +169,7 @@ public class ActorPanel DrawApplyToTarget(); RevertButtons(); + ImGui.TableNextColumn(); using var disabled = ImRaii.Disabled(transformationId != 0); if (_state.ModelData.IsHuman) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 5fb2d57..26553a7 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -16,6 +16,7 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; +using OtterGuiInternal.Structs; using Penumbra.GameData.Enums; using static Glamourer.Gui.Tabs.HeaderDrawer; @@ -415,11 +416,16 @@ public class DesignPanel private void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); - if (!child || _selector.Selected == null) + using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + if (!table || _selector.Selected == null) + return; + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableNextColumn(); + if (_selector.Selected == null) return; - DrawButtonRow(); + ImGui.TableNextColumn(); + DrawCustomize(); DrawEquipment(); DrawCustomizeParameters(); @@ -432,6 +438,7 @@ public class DesignPanel private void DrawButtonRow() { + ImGui.Dummy(Vector2.Zero); DrawApplyToSelf(); ImGui.SameLine(); DrawApplyToTarget(); diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index 974912e..312bceb 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -11,6 +11,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using static Glamourer.Gui.Tabs.HeaderDrawer; @@ -30,8 +31,8 @@ public class NpcPanel private readonly StateManager _state; private readonly ObjectManager _objects; private readonly DesignColors _colors; - private readonly Button[] _leftButtons; - private readonly Button[] _rightButtons; + private readonly Button[] _leftButtons; + private readonly Button[] _rightButtons; public NpcPanel(NpcSelector selector, LocalNpcAppearanceData favorites, @@ -114,11 +115,16 @@ public class NpcPanel private void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); - if (!child || !_selector.HasSelection) + using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + if (!table || !_selector.HasSelection) return; + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableNextColumn(); + ImGui.Dummy(Vector2.Zero); DrawButtonRow(); + + ImGui.TableNextColumn(); DrawCustomization(); DrawEquipment(); DrawAppearanceInfo(); @@ -133,10 +139,9 @@ public class NpcPanel private void DrawCustomization() { - var header = _selector.Selection.ModelId == 0 - ? "Customization" - : $"Customization (Model Id #{_selector.Selection.ModelId})###Customization"; - using var h = ImRaii.CollapsingHeader(header); + using var h = _selector.Selection.ModelId == 0 + ? ImUtf8.CollapsingHeaderId("Customization"u8) + : ImUtf8.CollapsingHeaderId($"Customization (Model Id #{_selector.Selection.ModelId})###Customization"); if (!h) return; @@ -146,7 +151,7 @@ public class NpcPanel private void DrawEquipment() { - using var h = ImRaii.CollapsingHeader("Equipment"); + using var h = ImUtf8.CollapsingHeaderId("Equipment"u8); if (!h) return; @@ -185,9 +190,7 @@ public class NpcPanel private void DrawApplyToSelf() { var (id, data) = _objects.PlayerData; - if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero, - "Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations.", - !data.Valid)) + if (!ImUtf8.ButtonEx("Apply to Yourself"u8, "Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations."u8, Vector2.Zero, !data.Valid)) return; if (_state.GetOrCreate(id, data.Objects[0], out var state)) @@ -202,10 +205,10 @@ public class NpcPanel var (id, data) = _objects.TargetData; var tt = id.IsValid ? data.Valid - ? "Apply the current NPC appearance to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations." - : "The current target can not be manipulated." - : "No valid target selected."; - if (!ImGuiUtil.DrawDisabledButton("Apply to Target", Vector2.Zero, tt, !data.Valid)) + ? "Apply the current NPC appearance to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations."u8 + : "The current target can not be manipulated."u8 + : "No valid target selected."u8; + if (!ImUtf8.ButtonEx("Apply to Target"u8, tt, Vector2.Zero, !data.Valid)) return; if (_state.GetOrCreate(id, data.Objects[0], out var state)) @@ -218,28 +221,28 @@ public class NpcPanel private void DrawAppearanceInfo() { - using var h = ImRaii.CollapsingHeader("Appearance Details"); + using var h = ImUtf8.CollapsingHeaderId("Appearance Details"u8); if (!h) return; - using var table = ImRaii.Table("Details", 2); + using var table = ImUtf8.Table("Details"u8, 2); if (!table) return; using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); - ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); - ImGui.TableSetupColumn("Data", ImGuiTableColumnFlags.WidthStretch); + ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); + ImUtf8.TableSetupColumn("Data"u8, ImGuiTableColumnFlags.WidthStretch); var selection = _selector.Selection; - CopyButton("NPC Name", selection.Name); - CopyButton("NPC ID", selection.Id.Id.ToString()); + CopyButton("NPC Name"u8, selection.Name); + CopyButton("NPC ID"u8, selection.Id.Id.ToString()); ImGuiUtil.DrawFrameColumn("NPC Type"); ImGui.TableNextColumn(); var width = ImGui.GetContentRegionAvail().X; ImGuiUtil.DrawTextButton(selection.Kind is ObjectKind.BattleNpc ? "Battle NPC" : "Event NPC", new Vector2(width, 0), ImGui.GetColorU32(ImGuiCol.FrameBg)); - ImGuiUtil.DrawFrameColumn("Color"); + ImUtf8.DrawFrameColumn("Color"u8); var color = _favorites.GetColor(selection); var colorName = color.Length == 0 ? DesignColors.AutomaticName : color; ImGui.TableNextColumn(); @@ -272,18 +275,18 @@ public class NpcPanel var size = new Vector2(ImGui.GetFrameHeight()); using var font = ImRaii.PushFont(UiBuilder.IconFont); ImGuiUtil.DrawTextButton(FontAwesomeIcon.ExclamationCircle.ToIconString(), size, 0, _colors.MissingColor); - ImGuiUtil.HoverTooltip("The color associated with this design does not exist."); + ImUtf8.HoverTooltip("The color associated with this design does not exist."u8); } return; - static void CopyButton(string label, string text) + static void CopyButton(ReadOnlySpan label, string text) { - ImGuiUtil.DrawFrameColumn(label); + ImUtf8.DrawFrameColumn(label); ImGui.TableNextColumn(); - if (ImGui.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0))) - ImGui.SetClipboardText(text); - ImGuiUtil.HoverTooltip("Click to copy to clipboard."); + if (ImUtf8.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0))) + ImUtf8.SetClipboardText(text); + ImUtf8.HoverTooltip("Click to copy to clipboard."u8); } } From 24452f3c79e17baea103e1951e7d4a34a789c7f8 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 31 Dec 2024 16:35:08 +0100 Subject: [PATCH 157/401] Add initial support for setting temporary mod settings. --- Glamourer/Automation/AutoDesignApplier.cs | 2 + Glamourer/Automation/AutoDesignManager.cs | 9 +- Glamourer/Automation/AutoDesignSet.cs | 14 +- Glamourer/Configuration.cs | 8 +- Glamourer/Designs/Design.cs | 99 +++---- Glamourer/Designs/DesignManager.cs | 55 ++-- Glamourer/Designs/IDesignStandIn.cs | 3 +- Glamourer/Designs/Links/DesignMerger.cs | 2 + Glamourer/Designs/Links/MergedDesign.cs | 1 + .../Designs/Special/QuickSelectedDesign.cs | 3 + Glamourer/Designs/Special/RandomDesign.cs | 7 +- Glamourer/Designs/Special/RevertDesign.cs | 3 + Glamourer/Events/DesignChanged.cs | 3 + Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 1 + .../Gui/Tabs/DesignTab/DesignDetailTab.cs | 73 +++--- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 2 +- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 25 +- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 5 + .../Interop/Penumbra/ModSettingApplier.cs | 32 ++- Glamourer/Interop/Penumbra/PenumbraService.cs | 245 ++++++++++++------ Glamourer/Services/CommandService.cs | 2 +- Penumbra.Api | 2 +- 22 files changed, 394 insertions(+), 202 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index e506d9f..660acf4 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -293,6 +293,8 @@ public sealed class AutoDesignApplier : IDisposable set.Designs.Where(d => d.IsActive(actor)) .SelectMany(d => d.Design.AllLinks(newApplication).Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); + if (set.ResetTemporarySettings) + mergedDesign.ResetTemporarySettings = true; _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false)); forcedRedraw = mergedDesign.ForcedRedraw; diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index a219376..5d30de0 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -444,8 +444,9 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos var set = new AutoDesignSet(name, group) { - Enabled = obj["Enabled"]?.ToObject() ?? false, - BaseState = obj["BaseState"]?.ToObject() ?? AutoDesignSet.Base.Current, + Enabled = obj["Enabled"]?.ToObject() ?? false, + ResetTemporarySettings = obj["ResetTemporarySettings"]?.ToObject() ?? false, + BaseState = obj["BaseState"]?.ToObject() ?? AutoDesignSet.Base.Current, }; if (set.Enabled) @@ -602,9 +603,9 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos ? ActorIdentifier.RetainerType.Mannequin : ActorIdentifier.RetainerType.Bell).CreatePermanent(), ], - IdentifierType.Npc => CreateNpcs(_actors, identifier), + IdentifierType.Npc => CreateNpcs(_actors, identifier), IdentifierType.Owned => CreateNpcs(_actors, identifier), - _ => [], + _ => [], }; static ActorIdentifier[] CreateNpcs(ActorManager manager, ActorIdentifier identifier) diff --git a/Glamourer/Automation/AutoDesignSet.cs b/Glamourer/Automation/AutoDesignSet.cs index adaa355..f8987af 100644 --- a/Glamourer/Automation/AutoDesignSet.cs +++ b/Glamourer/Automation/AutoDesignSet.cs @@ -10,7 +10,8 @@ public class AutoDesignSet(string name, ActorIdentifier[] identifiers, List(other.AssociatedMods); - Links = Links.Clone(); + Tags = [.. other.Tags]; + Description = other.Description; + QuickDesign = other.QuickDesign; + ForcedRedraw = other.ForcedRedraw; + ResetAdvancedDyes = other.ResetAdvancedDyes; + ResetTemporarySettings = other.ResetTemporarySettings; + Color = other.Color; + AssociatedMods = new SortedList(other.AssociatedMods); + Links = Links.Clone(); } // Metadata public new const int FileVersion = 2; - public Guid Identifier { get; internal init; } - public DateTimeOffset CreationDate { get; internal init; } - public DateTimeOffset LastEdit { get; internal set; } - public LowerString Name { get; internal set; } = LowerString.Empty; - public string Description { get; internal set; } = string.Empty; - public string[] Tags { get; internal set; } = []; - public int Index { get; internal set; } - public bool ForcedRedraw { get; internal set; } - public bool ResetAdvancedDyes { get; internal set; } - public bool QuickDesign { get; internal set; } = true; - public string Color { get; internal set; } = string.Empty; - public SortedList AssociatedMods { get; private set; } = []; - public LinkContainer Links { get; private set; } = []; + public Guid Identifier { get; internal init; } + public DateTimeOffset CreationDate { get; internal init; } + public DateTimeOffset LastEdit { get; internal set; } + public LowerString Name { get; internal set; } = LowerString.Empty; + public string Description { get; internal set; } = string.Empty; + public string[] Tags { get; internal set; } = []; + public int Index { get; internal set; } + public bool ForcedRedraw { get; internal set; } + public bool ResetAdvancedDyes { get; internal set; } + public bool ResetTemporarySettings { get; internal set; } + public bool QuickDesign { get; internal set; } = true; + public string Color { get; internal set; } = string.Empty; + public SortedList AssociatedMods { get; private set; } = []; + public LinkContainer Links { get; private set; } = []; public string Incognito => Identifier.ToString()[..8]; @@ -100,25 +102,26 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn { var ret = new JObject() { - ["FileVersion"] = FileVersion, - ["Identifier"] = Identifier, - ["CreationDate"] = CreationDate, - ["LastEdit"] = LastEdit, - ["Name"] = Name.Text, - ["Description"] = Description, - ["ForcedRedraw"] = ForcedRedraw, - ["ResetAdvancedDyes"] = ResetAdvancedDyes, - ["Color"] = Color, - ["QuickDesign"] = QuickDesign, - ["Tags"] = JArray.FromObject(Tags), - ["WriteProtected"] = WriteProtected(), - ["Equipment"] = SerializeEquipment(), - ["Bonus"] = SerializeBonusItems(), - ["Customize"] = SerializeCustomize(), - ["Parameters"] = SerializeParameters(), - ["Materials"] = SerializeMaterials(), - ["Mods"] = SerializeMods(), - ["Links"] = Links.Serialize(), + ["FileVersion"] = FileVersion, + ["Identifier"] = Identifier, + ["CreationDate"] = CreationDate, + ["LastEdit"] = LastEdit, + ["Name"] = Name.Text, + ["Description"] = Description, + ["ForcedRedraw"] = ForcedRedraw, + ["ResetAdvancedDyes"] = ResetAdvancedDyes, + ["ResetTemporarySettings"] = ResetTemporarySettings, + ["Color"] = Color, + ["QuickDesign"] = QuickDesign, + ["Tags"] = JArray.FromObject(Tags), + ["WriteProtected"] = WriteProtected(), + ["Equipment"] = SerializeEquipment(), + ["Bonus"] = SerializeBonusItems(), + ["Customize"] = SerializeCustomize(), + ["Parameters"] = SerializeParameters(), + ["Materials"] = SerializeMaterials(), + ["Mods"] = SerializeMods(), + ["Links"] = Links.Serialize(), }; return ret; } @@ -250,9 +253,10 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn LoadParameters(json["Parameters"], design, design.Name); LoadMaterials(json["Materials"], design, design.Name); LoadLinks(linkLoader, json["Links"], design); - design.Color = json["Color"]?.ToObject() ?? string.Empty; - design.ForcedRedraw = json["ForcedRedraw"]?.ToObject() ?? false; - design.ResetAdvancedDyes = json["ResetAdvancedDyes"]?.ToObject() ?? false; + design.Color = json["Color"]?.ToObject() ?? string.Empty; + design.ForcedRedraw = json["ForcedRedraw"]?.ToObject() ?? false; + design.ResetAdvancedDyes = json["ResetAdvancedDyes"]?.ToObject() ?? false; + design.ResetTemporarySettings = json["ResetTemporarySettings"]?.ToObject() ?? false; return design; static string[] ParseTags(JObject json) @@ -278,12 +282,15 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn continue; } - var settingsDict = tok["Settings"]?.ToObject>>() ?? []; - var settings = new Dictionary>(settingsDict.Count); + var forceInherit = tok["Inherit"]?.ToObject() ?? false; + var removeSetting = tok["Remove"]?.ToObject() ?? false; + var settingsDict = tok["Settings"]?.ToObject>>() ?? []; + var settings = new Dictionary>(settingsDict.Count); foreach (var (key, value) in settingsDict) settings.Add(key, value); var priority = tok["Priority"]?.ToObject() ?? 0; - if (!design.AssociatedMods.TryAdd(new Mod(name, directory), new ModSettings(settings, priority, enabled.Value))) + if (!design.AssociatedMods.TryAdd(new Mod(name, directory), + new ModSettings(settings, priority, enabled.Value, forceInherit, removeSetting))) Glamourer.Messager.NotificationMessage("The loaded design contains a mod more than once, skipped.", NotificationType.Warning); } } diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index b889649..f931489 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -99,14 +99,15 @@ public sealed class DesignManager : DesignEditor var (actualName, path) = ParseName(name, handlePath); var design = new Design(Customizations, Items) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, - ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, - ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, - QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, + ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, + ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, + QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, + ResetTemporarySettings = Config.DefaultDesignSettings.ResetTemporarySettings, }; Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier}."); @@ -121,14 +122,15 @@ public sealed class DesignManager : DesignEditor var (actualName, path) = ParseName(name, handlePath); var design = new Design(clone) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, - ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, - ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, - QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, + ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, + ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, + QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, + ResetTemporarySettings = Config.DefaultDesignSettings.ResetTemporarySettings, }; Designs.Add(design); @@ -144,11 +146,11 @@ public sealed class DesignManager : DesignEditor var (actualName, path) = ParseName(name, handlePath); var design = new Design(clone) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, }; Designs.Add(design); Glamourer.Log.Debug( @@ -351,6 +353,17 @@ public sealed class DesignManager : DesignEditor DesignChanged.Invoke(DesignChanged.Type.ResetAdvancedDyes, design, null); } + public void ChangeResetTemporarySettings(Design design, bool resetTemporarySettings) + { + if (design.ResetTemporarySettings == resetTemporarySettings) + return; + + design.ResetTemporarySettings = resetTemporarySettings; + SaveService.QueueSave(design); + Glamourer.Log.Debug($"Set {design.Identifier} to {(resetTemporarySettings ? string.Empty : "not")} reset temporary settings."); + DesignChanged.Invoke(DesignChanged.Type.ResetTemporarySettings, design, null); + } + /// Change whether to apply a specific customize value. public void ChangeApplyCustomize(Design design, CustomizeIndex idx, bool value) { diff --git a/Glamourer/Designs/IDesignStandIn.cs b/Glamourer/Designs/IDesignStandIn.cs index 02baee4..d07acb9 100644 --- a/Glamourer/Designs/IDesignStandIn.cs +++ b/Glamourer/Designs/IDesignStandIn.cs @@ -26,5 +26,6 @@ public interface IDesignStandIn : IEquatable public bool ForcedRedraw { get; } - public bool ResetAdvancedDyes { get; } + public bool ResetAdvancedDyes { get; } + public bool ResetTemporarySettings { get; } } diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index e0e5d95..0284322 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -58,6 +58,8 @@ public class DesignMerger( ret.ForcedRedraw = true; if (design.ResetAdvancedDyes) ret.ResetAdvancedDyes = true; + if (design.ResetTemporarySettings) + ret.ResetTemporarySettings = true; } ApplyFixFlags(ret, fixFlags); diff --git a/Glamourer/Designs/Links/MergedDesign.cs b/Glamourer/Designs/Links/MergedDesign.cs index 9c9e079..3d81cda 100644 --- a/Glamourer/Designs/Links/MergedDesign.cs +++ b/Glamourer/Designs/Links/MergedDesign.cs @@ -101,4 +101,5 @@ public sealed class MergedDesign public StateSources Sources = new(); public bool ForcedRedraw; public bool ResetAdvancedDyes; + public bool ResetTemporarySettings; } diff --git a/Glamourer/Designs/Special/QuickSelectedDesign.cs b/Glamourer/Designs/Special/QuickSelectedDesign.cs index 31fb40f..740bb7f 100644 --- a/Glamourer/Designs/Special/QuickSelectedDesign.cs +++ b/Glamourer/Designs/Special/QuickSelectedDesign.cs @@ -56,4 +56,7 @@ public class QuickSelectedDesign(QuickDesignCombo combo) : IDesignStandIn, IServ public bool ResetAdvancedDyes => combo.Design?.ResetAdvancedDyes ?? false; + + public bool ResetTemporarySettings + => combo.Design?.ResetTemporarySettings ?? false; } diff --git a/Glamourer/Designs/Special/RandomDesign.cs b/Glamourer/Designs/Special/RandomDesign.cs index a54ffcf..844f203 100644 --- a/Glamourer/Designs/Special/RandomDesign.cs +++ b/Glamourer/Designs/Special/RandomDesign.cs @@ -92,8 +92,11 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn } public bool ForcedRedraw - => false; + => _currentDesign?.ForcedRedraw ?? false; public bool ResetAdvancedDyes - => false; + => _currentDesign?.ResetAdvancedDyes ?? false; + + public bool ResetTemporarySettings + => _currentDesign?.ResetTemporarySettings ?? false; } diff --git a/Glamourer/Designs/Special/RevertDesign.cs b/Glamourer/Designs/Special/RevertDesign.cs index 8704339..4caf7b6 100644 --- a/Glamourer/Designs/Special/RevertDesign.cs +++ b/Glamourer/Designs/Special/RevertDesign.cs @@ -48,4 +48,7 @@ public class RevertDesign : IDesignStandIn public bool ResetAdvancedDyes => true; + + public bool ResetTemporarySettings + => true; } diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 8cd8f5c..04bb46a 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -93,6 +93,9 @@ public sealed class DesignChanged() /// An existing design had changed whether it always resets advanced dyes or not. ResetAdvancedDyes, + /// An existing design had changed whether it always resets all prior temporary settings or not. + ResetTemporarySettings, + /// An existing design changed whether a specific customization is applied. ApplyCustomize, diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 2549240..265e1d9 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -159,6 +159,7 @@ public class ActorPanel return; ImGui.TableSetupScrollFreeze(0, 1); ImGui.TableNextColumn(); + ImGui.Dummy(Vector2.Zero); var transformationId = _actor.IsCharacter ? _actor.AsCharacter->CharacterData.TransformationId : 0; if (transformationId != 0) ImGuiUtil.DrawTextButton($"Currently transformed to Transformation {transformationId}.", diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index bd74772..1469deb 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -6,6 +6,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.DesignTab; @@ -41,7 +42,7 @@ public class DesignDetailTab public void Draw() { - using var h = ImRaii.CollapsingHeader("Design Details"); + using var h = ImUtf8.CollapsingHeaderId("Design Details"u8); if (!h) return; @@ -54,19 +55,19 @@ public class DesignDetailTab private void DrawDesignInfoTable() { using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); - using var table = ImRaii.Table("Details", 2); + using var table = ImUtf8.Table("Details"u8, 2); if (!table) return; - ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Reset Advanced Dyes").X); - ImGui.TableSetupColumn("Data", ImGuiTableColumnFlags.WidthStretch); + ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Reset Temporary Settings"u8).X); + ImUtf8.TableSetupColumn("Data"u8, ImGuiTableColumnFlags.WidthStretch); - ImGuiUtil.DrawFrameColumn("Design Name"); + ImUtf8.DrawFrameColumn("Design Name"u8); ImGui.TableNextColumn(); var width = new Vector2(ImGui.GetContentRegionAvail().X, 0); var name = _newName ?? _selector.Selected!.Name; ImGui.SetNextItemWidth(width.X); - if (ImGui.InputText("##Name", ref name, 128)) + if (ImUtf8.InputText("##Name"u8, ref name)) { _newName = name; _changeDesign = _selector.Selected; @@ -80,10 +81,10 @@ public class DesignDetailTab } var identifier = _selector.Selected!.Identifier.ToString(); - ImGuiUtil.DrawFrameColumn("Unique Identifier"); + ImUtf8.DrawFrameColumn("Unique Identifier"u8); ImGui.TableNextColumn(); var fileName = _saveService.FileNames.DesignFile(_selector.Selected!); - using (var mono = ImRaii.PushFont(UiBuilder.MonoFont)) + using (ImRaii.PushFont(UiBuilder.MonoFont)) { if (ImGui.Button(identifier, width)) try @@ -100,14 +101,14 @@ public class DesignDetailTab ImGui.SetClipboardText(identifier); } - ImGuiUtil.HoverTooltip( + ImUtf8.HoverTooltip( $"Open the file\n\t{fileName}\ncontaining this design in the .json-editor of your choice.\n\nRight-Click to copy identifier to clipboard."); - ImGuiUtil.DrawFrameColumn("Full Selector Path"); + ImUtf8.DrawFrameColumn("Full Selector Path"u8); ImGui.TableNextColumn(); var path = _newPath ?? _selector.SelectedLeaf!.FullName(); ImGui.SetNextItemWidth(width.X); - if (ImGui.InputText("##Path", ref path, 1024)) + if (ImUtf8.InputText("##Path"u8, ref path)) { _newPath = path; _changeLeaf = _selector.SelectedLeaf!; @@ -125,32 +126,42 @@ public class DesignDetailTab Glamourer.Messager.NotificationMessage(ex, ex.Message, "Could not rename or move design", NotificationType.Error); } - ImGuiUtil.DrawFrameColumn("Quick Design Bar"); + ImUtf8.DrawFrameColumn("Quick Design Bar"u8); ImGui.TableNextColumn(); - if (ImGui.RadioButton("Display##qdb", _selector.Selected.QuickDesign)) + if (ImUtf8.RadioButton("Display##qdb"u8, _selector.Selected.QuickDesign)) _manager.SetQuickDesign(_selector.Selected!, true); var hovered = ImGui.IsItemHovered(); ImGui.SameLine(); - if (ImGui.RadioButton("Hide##qdb", !_selector.Selected.QuickDesign)) + if (ImUtf8.RadioButton("Hide##qdb"u8, !_selector.Selected.QuickDesign)) _manager.SetQuickDesign(_selector.Selected!, false); if (hovered || ImGui.IsItemHovered()) - ImGui.SetTooltip("Display or hide this design in your quick design bar."); + { + using var tt = ImUtf8.Tooltip(); + ImUtf8.Text("Display or hide this design in your quick design bar."u8); + } var forceRedraw = _selector.Selected!.ForcedRedraw; - ImGuiUtil.DrawFrameColumn("Force Redrawing"); + ImUtf8.DrawFrameColumn("Force Redrawing"u8); ImGui.TableNextColumn(); - if (ImGui.Checkbox("##ForceRedraw", ref forceRedraw)) + if (ImUtf8.Checkbox("##ForceRedraw"u8, ref forceRedraw)) _manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw); - ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means."); + ImUtf8.HoverTooltip("Set this design to always force a redraw when it is applied through any means."u8); var resetAdvancedDyes = _selector.Selected!.ResetAdvancedDyes; - ImGuiUtil.DrawFrameColumn("Reset Advanced Dyes"); + ImUtf8.DrawFrameColumn("Reset Advanced Dyes"u8); ImGui.TableNextColumn(); - if (ImGui.Checkbox("##ResetAdvancedDyes", ref resetAdvancedDyes)) + if (ImUtf8.Checkbox("##ResetAdvancedDyes"u8, ref resetAdvancedDyes)) _manager.ChangeResetAdvancedDyes(_selector.Selected!, resetAdvancedDyes); - ImGuiUtil.HoverTooltip("Set this design to reset any previously applied advanced dyes when it is applied through any means."); + ImUtf8.HoverTooltip("Set this design to reset any previously applied advanced dyes when it is applied through any means."u8); - ImGuiUtil.DrawFrameColumn("Color"); + var resetTemporarySettings = _selector.Selected!.ResetTemporarySettings; + ImUtf8.DrawFrameColumn("Reset Temporary Settings"u8); + ImGui.TableNextColumn(); + if (ImUtf8.Checkbox("##ResetTemporarySettings"u8, ref resetTemporarySettings)) + _manager.ChangeResetTemporarySettings(_selector.Selected!, resetTemporarySettings); + ImUtf8.HoverTooltip("Set this design to reset any temporary settings previously applied to the associated collection when it is applied through any means."u8); + + ImUtf8.DrawFrameColumn("Color"u8); var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color; ImGui.TableNextColumn(); if (_colorCombo.Draw("##colorCombo", colorName, "Associate a color with this design.\n" @@ -178,18 +189,18 @@ public class DesignDetailTab var size = new Vector2(ImGui.GetFrameHeight()); using var font = ImRaii.PushFont(UiBuilder.IconFont); ImGuiUtil.DrawTextButton(FontAwesomeIcon.ExclamationCircle.ToIconString(), size, 0, _colors.MissingColor); - ImGuiUtil.HoverTooltip("The color associated with this design does not exist."); + ImUtf8.HoverTooltip("The color associated with this design does not exist."u8); } - ImGuiUtil.DrawFrameColumn("Creation Date"); + ImUtf8.DrawFrameColumn("Creation Date"u8); ImGui.TableNextColumn(); ImGuiUtil.DrawTextButton(_selector.Selected!.CreationDate.LocalDateTime.ToString("F"), width, 0); - ImGuiUtil.DrawFrameColumn("Last Update Date"); + ImUtf8.DrawFrameColumn("Last Update Date"u8); ImGui.TableNextColumn(); ImGuiUtil.DrawTextButton(_selector.Selected!.LastEdit.LocalDateTime.ToString("F"), width, 0); - ImGuiUtil.DrawFrameColumn("Tags"); + ImUtf8.DrawFrameColumn("Tags"u8); ImGui.TableNextColumn(); DrawTags(); } @@ -219,18 +230,18 @@ public class DesignDetailTab var size = new Vector2(ImGui.GetContentRegionAvail().X, 12 * ImGui.GetTextLineHeightWithSpacing()); if (!_editDescriptionMode) { - using (var textBox = ImRaii.ListBox("##desc", size)) + using (var textBox = ImUtf8.ListBox("##desc"u8, size)) { - ImGuiUtil.TextWrapped(desc); + ImUtf8.TextWrapped(desc); } - if (ImGui.Button("Edit Description")) + if (ImUtf8.Button("Edit Description"u8)) _editDescriptionMode = true; } else { var edit = _newDescription ?? desc; - if (ImGui.InputTextMultiline("##desc", ref edit, (uint)Math.Max(2000, 4 * edit.Length), size)) + if (ImUtf8.InputMultiLine("##desc"u8, ref edit, size)) _newDescription = edit; if (ImGui.IsItemDeactivatedAfterEdit()) @@ -239,7 +250,7 @@ public class DesignDetailTab _newDescription = null; } - if (ImGui.Button("Stop Editing")) + if (ImUtf8.Button("Stop Editing"u8)) _editDescriptionMode = false; } } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 26553a7..070ca1e 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -423,6 +423,7 @@ public class DesignPanel ImGui.TableNextColumn(); if (_selector.Selected == null) return; + ImGui.Dummy(Vector2.Zero); DrawButtonRow(); ImGui.TableNextColumn(); @@ -438,7 +439,6 @@ public class DesignPanel private void DrawButtonRow() { - ImGui.Dummy(Vector2.Zero); DrawApplyToSelf(); ImGui.SameLine(); DrawApplyToTarget(); diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 1f1e1ad..20ddbe8 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -88,16 +88,18 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect private void DrawTable() { - using var table = ImRaii.Table("Mods", 5, ImGuiTableFlags.RowBg); + using var table = ImUtf8.Table("Mods"u8, 7, ImGuiTableFlags.RowBg); if (!table) return; - ImGui.TableSetupColumn("##Buttons", ImGuiTableColumnFlags.WidthFixed, + ImUtf8.TableSetupColumn("##Buttons"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight() * 3 + ImGui.GetStyle().ItemInnerSpacing.X * 2); - ImGui.TableSetupColumn("Mod Name", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("State").X); - ImGui.TableSetupColumn("Priority", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Priority").X); - ImGui.TableSetupColumn("##Options", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Applym").X); + ImUtf8.TableSetupColumn("Mod Name"u8, ImGuiTableColumnFlags.WidthStretch); + ImUtf8.TableSetupColumn("Remove"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Remove"u8).X); + ImUtf8.TableSetupColumn("Inherit"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); + ImUtf8.TableSetupColumn("State"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("State"u8).X); + ImUtf8.TableSetupColumn("Priority"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Priority"u8).X); + ImUtf8.TableSetupColumn("##Options"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Applym"u8).X); ImGui.TableHeadersRow(); Mod? removedMod = null; @@ -183,6 +185,17 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Mod Directory: {mod.DirectoryName}\n\nClick to open mod page in Penumbra."); ImGui.TableNextColumn(); + var remove = settings.Remove; + if (TwoStateCheckbox.Instance.Draw("##Remove"u8, ref remove)) + updatedMod = (mod, settings with { Remove = remove }); + ImUtf8.HoverTooltip( + "Remove any temporary settings applied by Glamourer instead of applying the configured settings. Only works when using temporary settings, ignored otherwise."u8); + ImGui.TableNextColumn(); + var inherit = settings.ForceInherit; + if (TwoStateCheckbox.Instance.Draw("##Enabled"u8, ref inherit)) + updatedMod = (mod, settings with { ForceInherit = inherit }); + ImUtf8.HoverTooltip("Force the mod to inherit its settings from inherited collections."u8); + ImGui.TableNextColumn(); var enabled = settings.Enabled; if (TwoStateCheckbox.Instance.Draw("##Enabled"u8, ref enabled)) updatedMod = (mod, settings with { Enabled = enabled }); diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index c6d69fd..ab40a48 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -106,6 +106,9 @@ public class SettingsTab( + "Glamourer will NOT revert these applied settings automatically. This may mess up your collection and configuration.\n\n" + "If you enable this setting, you are aware that any resulting misconfiguration is your own fault.", config.AlwaysApplyAssociatedMods, v => config.AlwaysApplyAssociatedMods = v); + Checkbox("Use Temporary Mod Settings", + "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down.", config.UseTemporarySettings, + v => config.UseTemporarySettings = v); ImGui.NewLine(); } @@ -120,6 +123,8 @@ public class SettingsTab( config.DefaultDesignSettings.ResetAdvancedDyes, v => config.DefaultDesignSettings.ResetAdvancedDyes = v); Checkbox("Always Force Redraw", "Newly created designs will be configured to force character redraws on application by default.", config.DefaultDesignSettings.AlwaysForceRedrawing, v => config.DefaultDesignSettings.AlwaysForceRedrawing = v); + Checkbox("Reset Temporary Settings", "Newly created designs will be configured to clear all advanced settings applied by Glamourer to the collection by default.", + config.DefaultDesignSettings.ResetTemporarySettings, v => config.DefaultDesignSettings.ResetTemporarySettings = v); } private void DrawInterfaceSettings() diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index a6fe3e5..b804720 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -3,12 +3,15 @@ using Glamourer.Services; using Glamourer.State; using OtterGui.Services; using Penumbra.GameData.Interop; +using Penumbra.GameData.Structs; namespace Glamourer.Interop.Penumbra; public class ModSettingApplier(PenumbraService penumbra, Configuration config, ObjectManager objects, CollectionOverrideService overrides) : IService { + private readonly HashSet _collectionTracker = []; + public void HandleStateApplication(ActorState state, MergedDesign design) { if (!config.AlwaysApplyAssociatedMods || design.AssociatedMods.Count == 0) @@ -22,20 +25,20 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O return; } - var collections = new HashSet(); - + _collectionTracker.Clear(); foreach (var actor in data.Objects) { var (collection, _, overridden) = overrides.GetCollection(actor, state.Identifier); if (collection == Guid.Empty) continue; - if (!collections.Add(collection)) + if (!_collectionTracker.Add(collection)) continue; + var index = ResetOldSettings(collection, actor, design.ResetTemporarySettings); foreach (var (mod, setting) in design.AssociatedMods) { - var message = penumbra.SetMod(mod, setting, collection); + var message = penumbra.SetMod(mod, setting, collection, index); if (message.Length > 0) Glamourer.Log.Verbose($"[Mod Applier] Error applying mod settings: {message}"); else @@ -45,7 +48,8 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O } } - public (List Messages, int Applied, Guid Collection, string Name, bool Overridden) ApplyModSettings(IReadOnlyDictionary settings, Actor actor) + public (List Messages, int Applied, Guid Collection, string Name, bool Overridden) ApplyModSettings( + IReadOnlyDictionary settings, Actor actor, bool resetOther) { var (collection, name, overridden) = overrides.GetCollection(actor); if (collection == Guid.Empty) @@ -53,9 +57,11 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O var messages = new List(); var appliedMods = 0; + + var index = ResetOldSettings(collection, actor, resetOther); foreach (var (mod, setting) in settings) { - var message = penumbra.SetMod(mod, setting, collection); + var message = penumbra.SetMod(mod, setting, collection, index); if (message.Length > 0) messages.Add($"Error applying mod settings: {message}"); else @@ -64,4 +70,18 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O return (messages, appliedMods, collection, name, overridden); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private ObjectIndex? ResetOldSettings(Guid collection, Actor actor, bool resetOther) + { + ObjectIndex? index = actor.Valid ? actor.Index : null; + if (!resetOther) + return index; + + if (index == null) + penumbra.RemoveAllTemporarySettings(collection); + else + penumbra.RemoveAllTemporarySettings(index.Value); + return index; + } } diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 4f6c44a..868ce11 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -21,10 +21,10 @@ public readonly record struct Mod(string Name, string DirectoryName) : IComparab } } -public readonly record struct ModSettings(Dictionary> Settings, int Priority, bool Enabled) +public readonly record struct ModSettings(Dictionary> Settings, int Priority, bool Enabled, bool ForceInherit, bool Remove) { public ModSettings() - : this(new Dictionary>(), 0, false) + : this(new Dictionary>(), 0, false, false, false) { } public static ModSettings Empty @@ -33,30 +33,41 @@ public readonly record struct ModSettings(Dictionary> Setti public class PenumbraService : IDisposable { - public const int RequiredPenumbraBreakingVersion = 5; - public const int RequiredPenumbraFeatureVersion = 0; + public const int RequiredPenumbraBreakingVersion = 5; + public const int RequiredPenumbraFeatureVersion = 3; + public const int RequiredPenumbraFeatureVersionTemp = 4; - private readonly IDalamudPluginInterface _pluginInterface; + private const int Key = -1610; + + private readonly IDalamudPluginInterface _pluginInterface; + private readonly Configuration _config; private readonly EventSubscriber _tooltipSubscriber; private readonly EventSubscriber _clickSubscriber; private readonly EventSubscriber _creatingCharacterBase; private readonly EventSubscriber _createdCharacterBase; private readonly EventSubscriber _modSettingChanged; - private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; - private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; - private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw; - private global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo? _drawObjectInfo; - private global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex? _cutsceneParent; - private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; - private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; - private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; - private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings? _getCurrentSettings; - private global::Penumbra.Api.IpcSubscribers.TrySetMod? _setMod; - private global::Penumbra.Api.IpcSubscribers.TrySetModPriority? _setModPriority; - private global::Penumbra.Api.IpcSubscribers.TrySetModSetting? _setModSetting; - private global::Penumbra.Api.IpcSubscribers.TrySetModSettings? _setModSettings; - private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; + private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; + private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; + private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw; + private global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo? _drawObjectInfo; + private global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex? _cutsceneParent; + private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; + private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; + private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; + private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings? _getCurrentSettings; + private global::Penumbra.Api.IpcSubscribers.TryInheritMod? _inheritMod; + private global::Penumbra.Api.IpcSubscribers.TrySetMod? _setMod; + private global::Penumbra.Api.IpcSubscribers.TrySetModPriority? _setModPriority; + private global::Penumbra.Api.IpcSubscribers.TrySetModSetting? _setModSetting; + private global::Penumbra.Api.IpcSubscribers.TrySetModSettings? _setModSettings; + private global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings? _setTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer? _setTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings? _removeTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer? _removeTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; private readonly IDisposable _initializedEvent; private readonly IDisposable _disposedEvent; @@ -68,10 +79,11 @@ public class PenumbraService : IDisposable public int CurrentMinor { get; private set; } public DateTime AttachTime { get; private set; } - public PenumbraService(IDalamudPluginInterface pi, PenumbraReloaded penumbraReloaded) + public PenumbraService(IDalamudPluginInterface pi, PenumbraReloaded penumbraReloaded, Configuration config) { _pluginInterface = pi; _penumbraReloaded = penumbraReloaded; + _config = config; _initializedEvent = global::Penumbra.Api.IpcSubscribers.Initialized.Subscriber(pi, Reattach); _disposedEvent = global::Penumbra.Api.IpcSubscribers.Disposed.Subscriber(pi, Unattach); _tooltipSubscriber = global::Penumbra.Api.IpcSubscribers.ChangedItemTooltip.Subscriber(pi); @@ -128,7 +140,7 @@ public class PenumbraService : IDisposable if (ec is not PenumbraApiEc.Success) return ModSettings.Empty; - return tuple.HasValue ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1) : ModSettings.Empty; + return tuple.HasValue ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1, false, false) : ModSettings.Empty; } catch (Exception ex) { @@ -164,7 +176,7 @@ public class PenumbraService : IDisposable .Select(t => (new Mod(t.Item2, t.Item1), !t.Item3.Item2.HasValue ? ModSettings.Empty - : new ModSettings(t.Item3.Item2!.Value.Item3, t.Item3.Item2!.Value.Item2, t.Item3.Item2!.Value.Item1))) + : new ModSettings(t.Item3.Item2!.Value.Item3, t.Item3.Item2!.Value.Item2, t.Item3.Item2!.Value.Item1, false, false))) .OrderByDescending(p => p.Item2.Enabled) .ThenBy(p => p.Item1.Name) .ThenBy(p => p.Item1.DirectoryName) @@ -195,7 +207,7 @@ public class PenumbraService : IDisposable /// Try to set all mod settings as desired. Only sets when the mod should be enabled. /// If it is disabled, ignore all other settings. /// - public string SetMod(Mod mod, ModSettings settings, Guid? collectionInput = null) + public string SetMod(Mod mod, ModSettings settings, Guid? collectionInput = null, ObjectIndex? index = null) { if (!Available) return "Penumbra is not available."; @@ -204,40 +216,10 @@ public class PenumbraService : IDisposable try { var collection = collectionInput ?? _currentCollection!.Invoke(ApiCollectionType.Current)!.Value.Id; - var ec = _setMod!.Invoke(collection, mod.DirectoryName, settings.Enabled); - switch (ec) - { - case PenumbraApiEc.ModMissing: return $"The mod {mod.Name} [{mod.DirectoryName}] could not be found."; - case PenumbraApiEc.CollectionMissing: return $"The collection {collection} could not be found."; - } - - if (!settings.Enabled) - return string.Empty; - - ec = _setModPriority!.Invoke(collection, mod.DirectoryName, settings.Priority); - Debug.Assert(ec is PenumbraApiEc.Success or PenumbraApiEc.NothingChanged, "Setting Priority should not be able to fail."); - - foreach (var (setting, list) in settings.Settings) - { - ec = list.Count == 1 - ? _setModSetting!.Invoke(collection, mod.DirectoryName, setting, list[0]) - : _setModSettings!.Invoke(collection, mod.DirectoryName, setting, list); - switch (ec) - { - case PenumbraApiEc.OptionGroupMissing: - sb.AppendLine($"Could not find the option group {setting} in mod {mod.Name}."); - break; - case PenumbraApiEc.OptionMissing: - sb.AppendLine($"Could not find all desired options in the option group {setting} in mod {mod.Name}."); - break; - case PenumbraApiEc.Success: - case PenumbraApiEc.NothingChanged: - break; - default: - sb.AppendLine($"Could not apply options in the option group {setting} in mod {mod.Name} for unknown reason {ec}."); - break; - } - } + if (_config.UseTemporarySettings && _setTemporaryModSettings != null) + SetModTemporary(sb, mod, settings, collection, index); + else + SetModPermanent(sb, mod, settings, collection); return sb.ToString(); } @@ -247,6 +229,103 @@ public class PenumbraService : IDisposable } } + public void RemoveAllTemporarySettings(Guid collection) + => _removeAllTemporaryModSettings?.Invoke(collection, Key); + + public void RemoveAllTemporarySettings(ObjectIndex index) + => _removeAllTemporaryModSettingsPlayer?.Invoke(index.Index, Key); + + public void ClearAllTemporarySettings() + { + if (!Available || _removeAllTemporaryModSettings == null) + return; + + var collections = _collections!.Invoke(); + foreach (var collection in collections) + RemoveAllTemporarySettings(collection.Key); + } + + private void SetModTemporary(StringBuilder sb, Mod mod, ModSettings settings, Guid collection, ObjectIndex? index) + { + var ex = settings.Remove + ? index.HasValue + ? _removeTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, Key) + : _removeTemporaryModSettings!.Invoke(collection, mod.DirectoryName, Key) + : index.HasValue + ? _setTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, settings.ForceInherit, settings.Enabled, + settings.Priority, + settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), "Glamourer", Key) + : _setTemporaryModSettings!.Invoke(collection, mod.DirectoryName, settings.ForceInherit, settings.Enabled, settings.Priority, + settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), "Glamourer", Key); + switch (ex) + { + case PenumbraApiEc.InvalidArgument: + sb.Append($"No actor with index {index!.Value.Index} could be identified."); + return; + case PenumbraApiEc.ModMissing: + sb.Append($"The mod {mod.Name} [{mod.DirectoryName}] could not be found."); + return; + case PenumbraApiEc.CollectionMissing: + sb.Append($"The collection {collection} could not be found."); + return; + case PenumbraApiEc.TemporarySettingImpossible: + sb.Append($"The collection {collection} can not have settings."); + return; + case PenumbraApiEc.TemporarySettingDisallowed: + sb.Append($"The mod {mod.Name} [{mod.DirectoryName}] already has temporary settings with a different key in {collection}."); + return; + case PenumbraApiEc.OptionGroupMissing: + case PenumbraApiEc.OptionMissing: + sb.Append($"The provided settings for {mod.Name} [{mod.DirectoryName}] did not correspond to its actual options."); + return; + } + } + + private void SetModPermanent(StringBuilder sb, Mod mod, ModSettings settings, Guid collection) + { + var ec = settings.ForceInherit + ? _inheritMod!.Invoke(collection, mod.DirectoryName, true) + : _setMod!.Invoke(collection, mod.DirectoryName, settings.Enabled); + switch (ec) + { + case PenumbraApiEc.ModMissing: + sb.Append($"The mod {mod.Name} [{mod.DirectoryName}] could not be found."); + return; + case PenumbraApiEc.CollectionMissing: + sb.Append($"The collection {collection} could not be found."); + return; + } + + if (settings.ForceInherit || !settings.Enabled) + return; + + ec = _setModPriority!.Invoke(collection, mod.DirectoryName, settings.Priority); + Debug.Assert(ec is PenumbraApiEc.Success or PenumbraApiEc.NothingChanged, "Setting Priority should not be able to fail."); + + foreach (var (setting, list) in settings.Settings) + { + ec = list.Count == 1 + ? _setModSetting!.Invoke(collection, mod.DirectoryName, setting, list[0]) + : _setModSettings!.Invoke(collection, mod.DirectoryName, setting, list); + switch (ec) + { + case PenumbraApiEc.OptionGroupMissing: + sb.AppendLine($"Could not find the option group {setting} in mod {mod.Name}."); + break; + case PenumbraApiEc.OptionMissing: + sb.AppendLine($"Could not find all desired options in the option group {setting} in mod {mod.Name}."); + break; + case PenumbraApiEc.Success: + case PenumbraApiEc.NothingChanged: + break; + default: + sb.AppendLine($"Could not apply options in the option group {setting} in mod {mod.Name} for unknown reason {ec}."); + break; + } + } + } + + /// Obtain the name of the collection currently assigned to the player. public Guid GetCurrentPlayerCollection() { @@ -347,12 +426,24 @@ public class PenumbraService : IDisposable _getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface); _currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface); _getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface); + _inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface); _setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface); _setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface); _setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface); _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); - Available = true; + if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp) + { + _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); + _setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface); + _removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface); + _removeTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer(_pluginInterface); + _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); + _removeAllTemporaryModSettingsPlayer = + new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); + } + + Available = true; _penumbraReloaded.Invoke(); Glamourer.Log.Debug("Glamourer attached to Penumbra."); } @@ -373,27 +464,35 @@ public class PenumbraService : IDisposable _modSettingChanged.Disable(); if (Available) { - _collectionByIdentifier = null; - _collections = null; - _redraw = null; - _drawObjectInfo = null; - _cutsceneParent = null; - _objectCollection = null; - _getMods = null; - _currentCollection = null; - _getCurrentSettings = null; - _setMod = null; - _setModPriority = null; - _setModSetting = null; - _setModSettings = null; - _openModPage = null; - Available = false; + _collectionByIdentifier = null; + _collections = null; + _redraw = null; + _drawObjectInfo = null; + _cutsceneParent = null; + _objectCollection = null; + _getMods = null; + _currentCollection = null; + _getCurrentSettings = null; + _inheritMod = null; + _setMod = null; + _setModPriority = null; + _setModSetting = null; + _setModSettings = null; + _openModPage = null; + _setTemporaryModSettings = null; + _setTemporaryModSettingsPlayer = null; + _removeTemporaryModSettings = null; + _removeTemporaryModSettingsPlayer = null; + _removeAllTemporaryModSettings = null; + _removeAllTemporaryModSettingsPlayer = null; + Available = false; Glamourer.Log.Debug("Glamourer detached from Penumbra."); } } public void Dispose() { + ClearAllTemporarySettings(); Unattach(); _tooltipSubscriber.Dispose(); _clickSubscriber.Dispose(); diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index cee4f57..10f68ee 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -691,7 +691,7 @@ public class CommandService : IDisposable, IApiService if (!applyMods || design is not Design d) return; - var (messages, appliedMods, _, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor); + var (messages, appliedMods, _, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor, d.ResetTemporarySettings); foreach (var message in messages) Glamourer.Messager.Chat.Print($"Error applying mod settings: {message}"); diff --git a/Penumbra.Api b/Penumbra.Api index 882b778..de0f281 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 882b778e78bb0806dd7d38e8b3670ff138a84a31 +Subproject commit de0f281fbf9d8d9d3aa8463a28025d54877cde8d From 9b9e356ad199d8469aac8319af87dca4c96fe18d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 31 Dec 2024 16:36:05 +0100 Subject: [PATCH 158/401] Update Submodules. --- OtterGui | 2 +- Penumbra.GameData | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OtterGui b/OtterGui index d9caded..fcc96da 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit d9caded5efb7c9db0a273a43bb5f6d53cf4ace7f +Subproject commit fcc96daa02633f673325c14aeea6b6b568924f1e diff --git a/Penumbra.GameData b/Penumbra.GameData index 19355cf..33de79b 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 19355cfa0ec80e8d5a91de11ecffc49257b37b53 +Subproject commit 33de79bc62eb014298856ed5c6b6edbe819db26c From d57743763bccabda90dc68fd548cf142f8d4bed7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 31 Dec 2024 18:03:56 +0100 Subject: [PATCH 159/401] Update OtterGui. --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index fcc96da..fd38721 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit fcc96daa02633f673325c14aeea6b6b568924f1e +Subproject commit fd387218d2d2d237075cb35be6ca89eeb53e14e5 From 6475c3c65b4727fe055946e3e800eb9c422933d8 Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 31 Dec 2024 17:06:22 +0000 Subject: [PATCH 160/401] [CI] Updating repo.json for testing_1.3.4.4 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index f7d8512..f3066dd 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.4.3", - "TestingAssemblyVersion": "1.3.4.3", + "TestingAssemblyVersion": "1.3.4.4", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.4.4/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From d675cdc80492532f5f32878cd6053059403e71a5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 10 Jan 2025 19:59:52 +0100 Subject: [PATCH 161/401] Improve scaling of advanced dye window. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 0c2b11e..b842d7f 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -198,7 +198,7 @@ public sealed unsafe class AdvancedDyePopup( + 3 * ImGui.GetStyle().ItemSpacing.X // around text + 7 * ImGui.GetStyle().ItemInnerSpacing.X + 200 * ImGuiHelpers.GlobalScale // Drags - + 7 * UiBuilder.MonoFont.GetCharAdvance(' ') // Row + + 7 * UiBuilder.MonoFont.GetCharAdvance(' ') * ImGuiHelpers.GlobalScale // Row + 2 * ImGui.GetStyle().WindowPadding.X; var height = 19 * ImGui.GetFrameHeightWithSpacing() + ImGui.GetStyle().WindowPadding.Y + 3 * ImGui.GetStyle().ItemSpacing.Y; ImGui.SetNextWindowSize(new Vector2(width, height)); From 3d6d04dde149d9abd5bde84d0ee6f2b66689d28f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 10 Jan 2025 20:00:16 +0100 Subject: [PATCH 162/401] Fix bug in automation tab setting gearsets. --- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index ab2b3d6..924f822 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -230,6 +230,7 @@ public class SetPanel( } private int _tmpGearset = int.MaxValue; + private int _whichIndex = -1; private void DrawConditions(AutoDesign design, int idx) { @@ -245,14 +246,19 @@ public class SetPanel( ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); if (usingGearset) { - var set = 1 + (_tmpGearset == int.MaxValue ? design.GearsetIndex : _tmpGearset); + var set = 1 + (_tmpGearset == int.MaxValue || _whichIndex != idx ? design.GearsetIndex : _tmpGearset); ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); if (ImGui.InputInt("##whichGearset", ref set, 0, 0)) + { + _whichIndex = idx; _tmpGearset = Math.Clamp(set, 1, 100); + } + if (ImGui.IsItemDeactivatedAfterEdit()) { _manager.ChangeGearsetCondition(Selection, idx, (short)(_tmpGearset - 1)); _tmpGearset = int.MaxValue; + _whichIndex = -1; } } else From 8a87ff16b442efb9bf4e64ffae10cac258aa86eb Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 10 Jan 2025 20:00:28 +0100 Subject: [PATCH 163/401] Improve mod associations display. --- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 20ddbe8..b02ece6 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -88,15 +88,16 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect private void DrawTable() { - using var table = ImUtf8.Table("Mods"u8, 7, ImGuiTableFlags.RowBg); + using var table = ImUtf8.Table("Mods"u8, config.UseTemporarySettings ? 7 : 6, ImGuiTableFlags.RowBg); if (!table) return; ImUtf8.TableSetupColumn("##Buttons"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight() * 3 + ImGui.GetStyle().ItemInnerSpacing.X * 2); - ImUtf8.TableSetupColumn("Mod Name"u8, ImGuiTableColumnFlags.WidthStretch); - ImUtf8.TableSetupColumn("Remove"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Remove"u8).X); - ImUtf8.TableSetupColumn("Inherit"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); + ImUtf8.TableSetupColumn("Mod Name"u8, ImGuiTableColumnFlags.WidthStretch); + if (config.UseTemporarySettings) + ImUtf8.TableSetupColumn("Remove"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Remove"u8).X); + ImUtf8.TableSetupColumn("Inherit"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); ImUtf8.TableSetupColumn("State"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("State"u8).X); ImUtf8.TableSetupColumn("Priority"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Priority"u8).X); ImUtf8.TableSetupColumn("##Options"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Applym"u8).X); @@ -184,12 +185,16 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect penumbra.OpenModPage(mod); if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Mod Directory: {mod.DirectoryName}\n\nClick to open mod page in Penumbra."); - ImGui.TableNextColumn(); - var remove = settings.Remove; - if (TwoStateCheckbox.Instance.Draw("##Remove"u8, ref remove)) - updatedMod = (mod, settings with { Remove = remove }); - ImUtf8.HoverTooltip( - "Remove any temporary settings applied by Glamourer instead of applying the configured settings. Only works when using temporary settings, ignored otherwise."u8); + if (config.UseTemporarySettings) + { + ImGui.TableNextColumn(); + var remove = settings.Remove; + if (TwoStateCheckbox.Instance.Draw("##Remove"u8, ref remove)) + updatedMod = (mod, settings with { Remove = remove }); + ImUtf8.HoverTooltip( + "Remove any temporary settings applied by Glamourer instead of applying the configured settings. Only works when using temporary settings, ignored otherwise."u8); + } + ImGui.TableNextColumn(); var inherit = settings.ForceInherit; if (TwoStateCheckbox.Instance.Draw("##Enabled"u8, ref inherit)) From 157a5b150be60d8fdb8f8f0d42d258d46258be30 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 10 Jan 2025 20:01:39 +0100 Subject: [PATCH 164/401] Update Submodules. --- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Penumbra.Api b/Penumbra.Api index de0f281..f60de67 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit de0f281fbf9d8d9d3aa8463a28025d54877cde8d +Subproject commit f60de67d24afe6e175f17d03cd234f493ea91265 diff --git a/Penumbra.GameData b/Penumbra.GameData index 33de79b..63ffca0 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 33de79bc62eb014298856ed5c6b6edbe819db26c +Subproject commit 63ffca0ff0ad626605120e58809c888d92053d64 From 2e038350ef6930d72c4edbed92216857148d56eb Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 10 Jan 2025 20:13:51 +0100 Subject: [PATCH 165/401] 1.3.5.0 --- Glamourer/Gui/GlamourerChangelog.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 57f7343..0c9d99b 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -38,6 +38,7 @@ public class GlamourerChangelog Add1_3_2_0(Changelog); Add1_3_3_0(Changelog); Add1_3_4_0(Changelog); + Add1_3_5_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -58,11 +59,27 @@ public class GlamourerChangelog } } + private static void Add1_3_5_0(Changelog log) + => log.NextVersion("Version 1.3.5.0") + .RegisterHighlight("Added the usage of the new Temporary Mod Setting functionality from Penumbra to apply mod associations. This is on by default but can be turned back to permanent changes in the settings.") + .RegisterEntry("Designs now have a setting to always reset all prior temporary settings made by Glamourer on application.", 1) + .RegisterEntry("Automation Sets also have a setting to do this, independently of the designs contained in them.", 1) + .RegisterHighlight("More NPC customization options should now be accepted as valid for designs, regardless of clan/gender.") + .RegisterHighlight("The 'Apply' chat command had the currently selected design and the current quick bar design added as choices.") + .RegisterEntry("The application buttons for designs, NPCs or actors should now stick at the top of their respective panels even when scrolling down.") + .RegisterHighlight("Randomly chosen designs should now stay across loading screens or redrawing. (1.3.4.3)") + .RegisterEntry("In automation, Random designs now have an option to always choose another design, including during loading screens or redrawing.", 1) + .RegisterEntry("Fixed an issue where disabling auto designs did not work as expected.") + .RegisterEntry("Fixed the inversion of application flags in IPC calls.") + .RegisterEntry("Fixed an issue with the scaling of the Advanced Dye popup with increased font sizes.") + .RegisterEntry("Fixed a bug when editing gear set conditions in the automation tab.") + .RegisterEntry("Fixed some ImGui issues."); + private static void Add1_3_4_0(Changelog log) => log.NextVersion("Version 1.3.4.0") .RegisterEntry("Glamourer has been updated for Dalamud API 11 and patch 7.1.") .RegisterEntry("Maybe fixed issues with shared weapon types and reset designs.") - .RegisterEntry("Fixed issues with resetting advanced dyes and certain weapon types"); + .RegisterEntry("Fixed issues with resetting advanced dyes and certain weapon types."); private static void Add1_3_3_0(Changelog log) => log.NextVersion("Version 1.3.3.0") From c541fd62c44a4aec1e7377188e58b703043d6f29 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 10 Jan 2025 19:16:32 +0000 Subject: [PATCH 166/401] [CI] Updating repo.json for 1.3.5.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index f3066dd..5420efa 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.4.3", - "TestingAssemblyVersion": "1.3.4.4", + "AssemblyVersion": "1.3.5.0", + "TestingAssemblyVersion": "1.3.5.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.4.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.4.4/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 7d490f9cfb75f6c64bafae9650410f5522e5475b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 11 Jan 2025 13:47:39 +0100 Subject: [PATCH 167/401] Fix designs not resetting temporary settings if they do not have mod associations. --- Glamourer/Interop/Penumbra/ModSettingApplier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index b804720..5b27e6e 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -14,7 +14,7 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O public void HandleStateApplication(ActorState state, MergedDesign design) { - if (!config.AlwaysApplyAssociatedMods || design.AssociatedMods.Count == 0) + if (!config.AlwaysApplyAssociatedMods || (design.AssociatedMods.Count == 0 && !design.ResetTemporarySettings)) return; objects.Update(); From 02bfd177943f55c887ec12010b8eb3b36cdced1a Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 11 Jan 2025 12:49:40 +0000 Subject: [PATCH 168/401] [CI] Updating repo.json for 1.3.5.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 5420efa..a5754ab 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.5.0", - "TestingAssemblyVersion": "1.3.5.0", + "AssemblyVersion": "1.3.5.1", + "TestingAssemblyVersion": "1.3.5.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c83ddf054ae3e7dc3815aa577279d87e4809dcd7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 12 Jan 2025 00:03:54 +0100 Subject: [PATCH 169/401] Add counts to multi design selection. --- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 115 ++++++++++-------- 1 file changed, 64 insertions(+), 51 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 6e5b1b1..a1f17d4 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -3,79 +3,95 @@ using Dalamud.Interface.Utility; using Glamourer.Designs; using ImGuiNET; using OtterGui; -using OtterGui.Filesystem; using OtterGui.Raii; +using OtterGui.Text; namespace Glamourer.Gui.Tabs.DesignTab; -public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager _editor, DesignColors _colors) +public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager editor, DesignColors colors) { - private readonly DesignColorCombo _colorCombo = new(_colors, true); + private readonly DesignColorCombo _colorCombo = new(colors, true); public void Draw() { - if (_selector.SelectedPaths.Count == 0) + if (selector.SelectedPaths.Count == 0) return; var width = ImGuiHelpers.ScaledVector2(145, 0); ImGui.NewLine(); - DrawDesignList(); + var treeNodePos = ImGui.GetCursorPos(); + _numDesigns = DrawDesignList(); + DrawCounts(treeNodePos); var offset = DrawMultiTagger(width); DrawMultiColor(width, offset); DrawMultiQuickDesignBar(offset); } - private void DrawDesignList() + private void DrawCounts(Vector2 treeNodePos) { - using var tree = ImRaii.TreeNode("Currently Selected Objects", ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.NoTreePushOnOpen); + var startPos = ImGui.GetCursorPos(); + var numFolders = selector.SelectedPaths.Count - _numDesigns; + var text = (_numDesigns, numFolders) switch + { + (0, 0) => string.Empty, // should not happen + (> 0, 0) => $"{_numDesigns} Designs", + (0, > 0) => $"{numFolders} Folders", + _ => $"{_numDesigns} Designs, {numFolders} Folders", + }; + ImGui.SetCursorPos(treeNodePos); + ImUtf8.TextRightAligned(text); + ImGui.SetCursorPos(startPos); + } + + private int DrawDesignList() + { + using var tree = ImUtf8.TreeNode("Currently Selected Objects"u8, ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.NoTreePushOnOpen); ImGui.Separator(); if (!tree) - return; + return selector.SelectedPaths.Count(l => l is DesignFileSystem.Leaf); - var sizeType = ImGui.GetFrameHeight(); - var availableSizePercent = (ImGui.GetContentRegionAvail().X - sizeType - 4 * ImGui.GetStyle().CellPadding.X) / 100; + var sizeType = new Vector2(ImGui.GetFrameHeight()); + var availableSizePercent = (ImGui.GetContentRegionAvail().X - sizeType.X - 4 * ImGui.GetStyle().CellPadding.X) / 100; var sizeMods = availableSizePercent * 35; var sizeFolders = availableSizePercent * 65; _numQuickDesignEnabled = 0; - _numDesigns = 0; - using (var table = ImRaii.Table("mods", 3, ImGuiTableFlags.RowBg)) + var numDesigns = 0; + using (var table = ImUtf8.Table("mods"u8, 3, ImGuiTableFlags.RowBg)) { if (!table) - return; + return selector.SelectedPaths.Count(l => l is DesignFileSystem.Leaf); - ImGui.TableSetupColumn("type", ImGuiTableColumnFlags.WidthFixed, sizeType); - ImGui.TableSetupColumn("mod", ImGuiTableColumnFlags.WidthFixed, sizeMods); - ImGui.TableSetupColumn("path", ImGuiTableColumnFlags.WidthFixed, sizeFolders); + ImUtf8.TableSetupColumn("type"u8, ImGuiTableColumnFlags.WidthFixed, sizeType.X); + ImUtf8.TableSetupColumn("mod"u8, ImGuiTableColumnFlags.WidthFixed, sizeMods); + ImUtf8.TableSetupColumn("path"u8, ImGuiTableColumnFlags.WidthFixed, sizeFolders); var i = 0; - foreach (var (fullName, path) in _selector.SelectedPaths.Select(p => (p.FullName(), p)) + foreach (var (fullName, path) in selector.SelectedPaths.Select(p => (p.FullName(), p)) .OrderBy(p => p.Item1, StringComparer.OrdinalIgnoreCase)) { using var id = ImRaii.PushId(i++); + var (icon, text) = path is DesignFileSystem.Leaf l + ? (FontAwesomeIcon.FileCircleMinus, l.Value.Name.Text) + : (FontAwesomeIcon.FolderMinus, string.Empty); ImGui.TableNextColumn(); - var icon = (path is DesignFileSystem.Leaf ? FontAwesomeIcon.FileCircleMinus : FontAwesomeIcon.FolderMinus).ToIconString(); - if (ImGuiUtil.DrawDisabledButton(icon, new Vector2(sizeType), "Remove from selection.", false, true)) - _selector.RemovePathFromMultiSelection(path); + if (ImUtf8.IconButton(icon, "Remove from selection."u8, sizeType)) + selector.RemovePathFromMultiSelection(path); - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(path is DesignFileSystem.Leaf l ? l.Value.Name : string.Empty); - - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(fullName); + ImUtf8.DrawFrameColumn(text); + ImUtf8.DrawFrameColumn(fullName); if (path is not DesignFileSystem.Leaf l2) continue; - ++_numDesigns; + ++numDesigns; if (l2.Value.QuickDesign) ++_numQuickDesignEnabled; } } ImGui.Separator(); + return numDesigns; } private string _tag = string.Empty; @@ -86,12 +102,11 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager private float DrawMultiTagger(Vector2 width) { - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted("Multi Tagger:"); + ImUtf8.TextFrameAligned("Multi Tagger:"u8); ImGui.SameLine(); var offset = ImGui.GetItemRectSize().X; ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - 2 * (width.X + ImGui.GetStyle().ItemSpacing.X)); - ImGui.InputTextWithHint("##tag", "Tag Name...", ref _tag, 128); + ImUtf8.InputText("##tag"u8, ref _tag, "Tag Name..."u8); UpdateTagCache(); var label = _addDesigns.Count > 0 @@ -103,9 +118,9 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager : $"All designs selected already contain the tag \"{_tag}\"." : $"Add the tag \"{_tag}\" to {_addDesigns.Count} designs as a local tag:\n\n\t{string.Join("\n\t", _addDesigns.Select(m => m.Name.Text))}"; ImGui.SameLine(); - if (ImGuiUtil.DrawDisabledButton(label, width, tooltip, _addDesigns.Count == 0)) + if (ImUtf8.ButtonEx(label, tooltip, width, _addDesigns.Count == 0)) foreach (var design in _addDesigns) - _editor.AddTag(design, _tag); + editor.AddTag(design, _tag); label = _removeDesigns.Count > 0 ? $"Remove from {_removeDesigns.Count} Designs" @@ -116,41 +131,39 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager : $"No selected design contains the tag \"{_tag}\" locally." : $"Remove the local tag \"{_tag}\" from {_removeDesigns.Count} designs:\n\n\t{string.Join("\n\t", _removeDesigns.Select(m => m.Item1.Name.Text))}"; ImGui.SameLine(); - if (ImGuiUtil.DrawDisabledButton(label, width, tooltip, _removeDesigns.Count == 0)) + if (ImUtf8.ButtonEx(label, tooltip, width, _removeDesigns.Count == 0)) foreach (var (design, index) in _removeDesigns) - _editor.RemoveTag(design, index); + editor.RemoveTag(design, index); ImGui.Separator(); return offset; } private void DrawMultiQuickDesignBar(float offset) { - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted("Multi QDB:"); + ImUtf8.TextFrameAligned("Multi QDB:"u8); ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); var diff = _numDesigns - _numQuickDesignEnabled; var tt = diff == 0 ? $"All {_numDesigns} selected designs are already displayed in the quick design bar." : $"Display all {_numDesigns} selected designs in the quick design bar. Changes {diff} designs."; - if (ImGuiUtil.DrawDisabledButton("Display Selected Designs in QDB", buttonWidth, tt, diff == 0)) - foreach(var design in _selector.SelectedPaths.OfType()) - _editor.SetQuickDesign(design.Value, true); + if (ImUtf8.ButtonEx("Display Selected Designs in QDB"u8, tt, buttonWidth, diff == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.SetQuickDesign(design.Value, true); ImGui.SameLine(); tt = _numQuickDesignEnabled == 0 ? $"All {_numDesigns} selected designs are already hidden in the quick design bar." : $"Hide all {_numDesigns} selected designs in the quick design bar. Changes {_numQuickDesignEnabled} designs."; - if (ImGuiUtil.DrawDisabledButton("Hide Selected Designs in QDB", buttonWidth, tt, _numQuickDesignEnabled == 0)) - foreach (var design in _selector.SelectedPaths.OfType()) - _editor.SetQuickDesign(design.Value, false); + if (ImUtf8.ButtonEx("Hide Selected Designs in QDB"u8, tt, buttonWidth, _numQuickDesignEnabled == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.SetQuickDesign(design.Value, false); ImGui.Separator(); } private void DrawMultiColor(Vector2 width, float offset) { - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted("Multi Colors:"); + ImUtf8.TextFrameAligned("Multi Colors:"); ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); _colorCombo.Draw("##color", _colorCombo.CurrentSelection ?? string.Empty, "Select a design color.", ImGui.GetContentRegionAvail().X - 2 * (width.X + ImGui.GetStyle().ItemSpacing.X), ImGui.GetTextLineHeight()); @@ -168,9 +181,9 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager } : $"Set the color of {_addDesigns.Count} designs to \"{_colorCombo.CurrentSelection}\"\n\n\t{string.Join("\n\t", _addDesigns.Select(m => m.Name.Text))}"; ImGui.SameLine(); - if (ImGuiUtil.DrawDisabledButton(label, width, tooltip, _addDesigns.Count == 0)) + if (ImUtf8.ButtonEx(label, tooltip, width, _addDesigns.Count == 0)) foreach (var design in _addDesigns) - _editor.ChangeColor(design, _colorCombo.CurrentSelection!); + editor.ChangeColor(design, _colorCombo.CurrentSelection!); label = _removeDesigns.Count > 0 ? $"Unset {_removeDesigns.Count} Designs" @@ -179,9 +192,9 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager ? "No selected design is set to a non-automatic color." : $"Set {_removeDesigns.Count} designs to use automatic color again:\n\n\t{string.Join("\n\t", _removeDesigns.Select(m => m.Item1.Name.Text))}"; ImGui.SameLine(); - if (ImGuiUtil.DrawDisabledButton(label, width, tooltip, _removeDesigns.Count == 0)) + if (ImUtf8.ButtonEx(label, tooltip, width, _removeDesigns.Count == 0)) foreach (var (design, _) in _removeDesigns) - _editor.ChangeColor(design, string.Empty); + editor.ChangeColor(design, string.Empty); ImGui.Separator(); } @@ -193,7 +206,7 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager if (_tag.Length == 0) return; - foreach (var leaf in _selector.SelectedPaths.OfType()) + foreach (var leaf in selector.SelectedPaths.OfType()) { var index = leaf.Value.Tags.IndexOf(_tag); if (index >= 0) @@ -208,7 +221,7 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager _addDesigns.Clear(); _removeDesigns.Clear(); var selection = _colorCombo.CurrentSelection ?? DesignColors.AutomaticName; - foreach (var leaf in _selector.SelectedPaths.OfType()) + foreach (var leaf in selector.SelectedPaths.OfType()) { if (leaf.Value.Color.Length > 0) _removeDesigns.Add((leaf.Value, 0)); From 60a1ee728ad67750f219fccb5c58fc73c40aa8d5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 14 Jan 2025 14:51:36 +0100 Subject: [PATCH 170/401] Use current temporary settings for mod associations if they exist. --- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 2 +- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 6 ++++- Glamourer/Interop/Penumbra/PenumbraService.cs | 26 +++++++++++++++---- Penumbra.Api | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 601d3ae..c8a4b11 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -118,7 +118,7 @@ public class EquipmentDrawer public void DrawWeapons(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) { - if (mainhand.CurrentItem.PrimaryId.Id == 0) + if (mainhand.CurrentItem.PrimaryId.Id == 0 && !allWeapons) return; if (_config.HideApplyCheckmarks) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index b02ece6..5eda7cc 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -149,12 +149,14 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect ImUtf8.IconButton(FontAwesomeIcon.RedoAlt, "Update the settings of this mod association."u8); if (ImGui.IsItemHovered()) { - var newSettings = penumbra.GetModSettings(mod); + var newSettings = penumbra.GetModSettings(mod, out var source); if (ImGui.IsItemClicked()) updatedMod = (mod, newSettings); using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale); using var tt = ImUtf8.Tooltip(); + if (source.Length > 0) + ImUtf8.Text($"Using temporary settings made by {source}."); ImGui.Separator(); var namesDifferent = mod.Name != mod.DirectoryName; ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0)); @@ -162,6 +164,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect { if (namesDifferent) ImUtf8.Text("Directory Name"u8); + ImUtf8.Text("Force Inherit"u8); ImUtf8.Text("Enabled"u8); ImUtf8.Text("Priority"u8); ModCombo.DrawSettingsLeft(newSettings); @@ -173,6 +176,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect if (namesDifferent) ImUtf8.Text(mod.DirectoryName); + ImUtf8.Text(newSettings.ForceInherit.ToString()); ImUtf8.Text(newSettings.Enabled.ToString()); ImUtf8.Text(newSettings.Priority.ToString()); ModCombo.DrawSettingsRight(newSettings); diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 868ce11..13be628 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -33,9 +33,10 @@ public readonly record struct ModSettings(Dictionary> Setti public class PenumbraService : IDisposable { - public const int RequiredPenumbraBreakingVersion = 5; - public const int RequiredPenumbraFeatureVersion = 3; - public const int RequiredPenumbraFeatureVersionTemp = 4; + public const int RequiredPenumbraBreakingVersion = 5; + public const int RequiredPenumbraFeatureVersion = 3; + public const int RequiredPenumbraFeatureVersionTemp = 4; + public const int RequiredPenumbraFeatureVersionTemp2 = 5; private const int Key = -1610; @@ -67,6 +68,7 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer? _removeTemporaryModSettingsPlayer; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings? _queryTemporaryModSettings; private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; private readonly IDisposable _initializedEvent; @@ -128,19 +130,30 @@ public class PenumbraService : IDisposable public Dictionary GetCollections() => Available ? _collections!.Invoke() : []; - public ModSettings GetModSettings(in Mod mod) + public ModSettings GetModSettings(in Mod mod, out string source) { + source = string.Empty; if (!Available) return ModSettings.Empty; try { var collection = _currentCollection!.Invoke(ApiCollectionType.Current); + if (_queryTemporaryModSettings != null) + { + var tempEc = _queryTemporaryModSettings.Invoke(collection!.Value.Id, mod.DirectoryName, out var tempTuple, out source); + if (tempEc is PenumbraApiEc.Success && tempTuple != null) + return new ModSettings(tempTuple.Value.Settings, tempTuple.Value.Priority, tempTuple.Value.Enabled, + tempTuple.Value.ForceInherit, false); + } + var (ec, tuple) = _getCurrentSettings!.Invoke(collection!.Value.Id, mod.DirectoryName); if (ec is not PenumbraApiEc.Success) return ModSettings.Empty; - return tuple.HasValue ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1, false, false) : ModSettings.Empty; + return tuple.HasValue + ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1, false, false) + : ModSettings.Empty; } catch (Exception ex) { @@ -441,6 +454,8 @@ public class PenumbraService : IDisposable _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); _removeAllTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); + if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) + _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); } Available = true; @@ -485,6 +500,7 @@ public class PenumbraService : IDisposable _removeTemporaryModSettingsPlayer = null; _removeAllTemporaryModSettings = null; _removeAllTemporaryModSettingsPlayer = null; + _queryTemporaryModSettings = null; Available = false; Glamourer.Log.Debug("Glamourer detached from Penumbra."); } diff --git a/Penumbra.Api b/Penumbra.Api index f60de67..b4e716f 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit f60de67d24afe6e175f17d03cd234f493ea91265 +Subproject commit b4e716f86d94cd4d98d8f58e580ed5f619ea87ae From 8160f420db3ac048021bb1606775b5b1c35cf96d Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 15 Jan 2025 17:05:57 +0000 Subject: [PATCH 171/401] [CI] Updating repo.json for testing_1.3.5.2 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index a5754ab..dab02ea 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.5.1", - "TestingAssemblyVersion": "1.3.5.1", + "TestingAssemblyVersion": "1.3.5.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c605d1951031e95f0bc5923ebaa986f8f1057472 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Thu, 16 Jan 2025 19:34:46 -0800 Subject: [PATCH 172/401] Progress made. May be successful! --- Glamourer/Api/StateApi.cs | 2 + Glamourer/Automation/AutoDesignApplier.cs | 12 ++ Glamourer/Interop/ChangeCustomizeService.cs | 7 +- Glamourer/Interop/InventoryService.cs | 82 ++++++++----- Glamourer/Interop/JobService.cs | 2 +- Glamourer/Interop/UpdateSlotService.cs | 124 ++++++++++++++++++-- Glamourer/State/StateEditor.cs | 26 ++-- Glamourer/State/StateListener.cs | 5 +- Glamourer/State/StateManager.cs | 4 +- 9 files changed, 201 insertions(+), 63 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 331942b..ce7d226 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -333,6 +333,8 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { + Glamourer.Log.Error($"[OnStateChanged API CALL] Sending out OnStateChanged with type {type}."); + if (StateChanged != null) foreach (var actor in actors.Objects) StateChanged.Invoke(actor.Address); diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 660acf4..d49864f 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -1,4 +1,5 @@ using Dalamud.Plugin.Services; +using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using Glamourer.Designs; using Glamourer.Designs.Links; @@ -201,11 +202,22 @@ public sealed class AutoDesignApplier : IDisposable } } + /// + /// JOB CHANGE IS CALLED UPON HERE. + /// private void OnJobChange(Actor actor, Job oldJob, Job newJob) { + unsafe + { + var drawObject = actor.AsCharacter->DrawObject; + Glamourer.Log.Information($"[AutoDesignApplier][OnJobChange] 0x{(nint)drawObject:X} changed job from {oldJob} ({oldJob.Id}) to {newJob} ({newJob.Id})."); + } + if (!_config.EnableAutoDesigns || !actor.Identifier(_actors, out var id)) return; + Glamourer.Log.Information($"[AutoDesignApplier][OnJobChange] We had EnableAutoDesigns active, and are a valid actor!"); + if (!GetPlayerSet(id, out var set)) { if (_state.TryGetValue(id, out var s)) diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index 495d69c..032412e 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -64,12 +64,13 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 _changeCustomizeHook; + // manual invoke by calling the detours _original call to `execute to` instead of `listen to`. public bool UpdateCustomize(Model model, CustomizeArray customize) { if (!model.IsHuman) return false; - Glamourer.Log.Verbose($"[ChangeCustomize] Invoked on 0x{model.Address:X} with {customize}."); + Glamourer.Log.Information($"[ChangeCustomize] Glamour-Invoked on 0x{model.Address:X} with {customize}."); using var _ = InUpdate.EnterMethod(); var ret = _original(model.AsHuman, customize.Data, true); return ret; @@ -78,16 +79,20 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 UpdateCustomize(actor.Model, customize); + // detoured method. private bool ChangeCustomizeDetour(Human* human, byte* data, byte skipEquipment) { if (!InUpdate.InMethod) Invoke(human, ref *(CustomizeArray*)data); var ret = _changeCustomizeHook.Original(human, data, skipEquipment); + + Glamourer.Log.Information($"[ChangeCustomize] Called on with {*(CustomizeArray*)data} ({ret})."); _postEvent.Invoke(human); return ret; } + public void Subscribe(Action action, Post.Priority priority) => _postEvent.Subscribe(action, priority); diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 6d8e58b..605ca15 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -1,9 +1,11 @@ using Dalamud.Hooking; using Dalamud.Plugin.Services; +using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using Glamourer.Events; using OtterGui.Services; +using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using Penumbra.String; @@ -16,39 +18,48 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService private readonly EquippedGearset _gearsetEvent; private readonly List<(EquipSlot, uint, StainIds)> _itemList = new(12); + // This can be moved into client structs or penumbra.gamedata when needed. + public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; + private delegate nint ChangeGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); + + [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] + private readonly Hook _equipGearsetInternalHook = null!; + public InventoryService(MovedEquipment movedItemsEvent, IGameInteropProvider interop, EquippedGearset gearsetEvent) { _movedItemsEvent = movedItemsEvent; _gearsetEvent = gearsetEvent; _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); - _equipGearsetHook = - interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour); + _equipGearsetHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour); + interop.InitializeFromAttributes(this); _moveItemHook.Enable(); _equipGearsetHook.Enable(); + _equipGearsetInternalHook.Enable(); } public void Dispose() { _moveItemHook.Dispose(); _equipGearsetHook.Dispose(); + _equipGearsetInternalHook.Dispose(); } private delegate int EquipGearsetDelegate(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId); private readonly Hook _equipGearsetHook; - private int EquipGearSetDetour(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId) + private nint EquipGearSetInternalDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) { var prior = module->CurrentGearsetIndex; - var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); - var set = module->GetGearset(gearsetId); - _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), gearsetId, prior, glamourPlateId, set->ClassJob); - Glamourer.Log.Excessive($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); + var ret = _equipGearsetInternalHook.Original(module, gearsetId, glamourPlateId); + var set = module->GetGearset((int)gearsetId); + _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), (int)gearsetId, prior, glamourPlateId, set->ClassJob); + Glamourer.Log.Warning($"[InventoryService] [EquipInternal] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); if (ret == 0) { - var entry = module->GetGearset(gearsetId); + var entry = module->GetGearset((int)gearsetId); if (entry == null) return ret; @@ -73,18 +84,18 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService } var plate = MirageManager.Instance()->GlamourPlates[glamourPlateId - 1]; - Add(EquipSlot.MainHand, plate.ItemIds[0], StainIds.FromGlamourPlate(plate, 0), ref entry->Items[0]); - Add(EquipSlot.OffHand, plate.ItemIds[1], StainIds.FromGlamourPlate(plate, 1), ref entry->Items[1]); - Add(EquipSlot.Head, plate.ItemIds[2], StainIds.FromGlamourPlate(plate, 2), ref entry->Items[2]); - Add(EquipSlot.Body, plate.ItemIds[3], StainIds.FromGlamourPlate(plate, 3), ref entry->Items[3]); - Add(EquipSlot.Hands, plate.ItemIds[4], StainIds.FromGlamourPlate(plate, 4), ref entry->Items[5]); - Add(EquipSlot.Legs, plate.ItemIds[5], StainIds.FromGlamourPlate(plate, 5), ref entry->Items[6]); - Add(EquipSlot.Feet, plate.ItemIds[6], StainIds.FromGlamourPlate(plate, 6), ref entry->Items[7]); - Add(EquipSlot.Ears, plate.ItemIds[7], StainIds.FromGlamourPlate(plate, 7), ref entry->Items[8]); - Add(EquipSlot.Neck, plate.ItemIds[8], StainIds.FromGlamourPlate(plate, 8), ref entry->Items[9]); - Add(EquipSlot.Wrists, plate.ItemIds[9], StainIds.FromGlamourPlate(plate, 9), ref entry->Items[10]); - Add(EquipSlot.RFinger, plate.ItemIds[10], StainIds.FromGlamourPlate(plate, 10), ref entry->Items[11]); - Add(EquipSlot.LFinger, plate.ItemIds[11], StainIds.FromGlamourPlate(plate, 11), ref entry->Items[12]); + Add(EquipSlot.MainHand, plate.ItemIds[0], StainIds.FromGlamourPlate(plate, 0), ref entry->Items[0]); + Add(EquipSlot.OffHand, plate.ItemIds[1], StainIds.FromGlamourPlate(plate, 1), ref entry->Items[1]); + Add(EquipSlot.Head, plate.ItemIds[2], StainIds.FromGlamourPlate(plate, 2), ref entry->Items[2]); + Add(EquipSlot.Body, plate.ItemIds[3], StainIds.FromGlamourPlate(plate, 3), ref entry->Items[3]); + Add(EquipSlot.Hands, plate.ItemIds[4], StainIds.FromGlamourPlate(plate, 4), ref entry->Items[5]); + Add(EquipSlot.Legs, plate.ItemIds[5], StainIds.FromGlamourPlate(plate, 5), ref entry->Items[6]); + Add(EquipSlot.Feet, plate.ItemIds[6], StainIds.FromGlamourPlate(plate, 6), ref entry->Items[7]); + Add(EquipSlot.Ears, plate.ItemIds[7], StainIds.FromGlamourPlate(plate, 7), ref entry->Items[8]); + Add(EquipSlot.Neck, plate.ItemIds[8], StainIds.FromGlamourPlate(plate, 8), ref entry->Items[9]); + Add(EquipSlot.Wrists, plate.ItemIds[9], StainIds.FromGlamourPlate(plate, 9), ref entry->Items[10]); + Add(EquipSlot.RFinger, plate.ItemIds[10], StainIds.FromGlamourPlate(plate, 10), ref entry->Items[11]); + Add(EquipSlot.LFinger, plate.ItemIds[11], StainIds.FromGlamourPlate(plate, 11), ref entry->Items[12]); } else { @@ -99,17 +110,17 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService } Add(EquipSlot.MainHand, ref entry->Items[0]); - Add(EquipSlot.OffHand, ref entry->Items[1]); - Add(EquipSlot.Head, ref entry->Items[2]); - Add(EquipSlot.Body, ref entry->Items[3]); - Add(EquipSlot.Hands, ref entry->Items[5]); - Add(EquipSlot.Legs, ref entry->Items[6]); - Add(EquipSlot.Feet, ref entry->Items[7]); - Add(EquipSlot.Ears, ref entry->Items[8]); - Add(EquipSlot.Neck, ref entry->Items[9]); - Add(EquipSlot.Wrists, ref entry->Items[10]); - Add(EquipSlot.RFinger, ref entry->Items[11]); - Add(EquipSlot.LFinger, ref entry->Items[12]); + Add(EquipSlot.OffHand, ref entry->Items[1]); + Add(EquipSlot.Head, ref entry->Items[2]); + Add(EquipSlot.Body, ref entry->Items[3]); + Add(EquipSlot.Hands, ref entry->Items[5]); + Add(EquipSlot.Legs, ref entry->Items[6]); + Add(EquipSlot.Feet, ref entry->Items[7]); + Add(EquipSlot.Ears, ref entry->Items[8]); + Add(EquipSlot.Neck, ref entry->Items[9]); + Add(EquipSlot.Wrists, ref entry->Items[10]); + Add(EquipSlot.RFinger, ref entry->Items[11]); + Add(EquipSlot.LFinger, ref entry->Items[12]); } _movedItemsEvent.Invoke(_itemList.ToArray()); @@ -118,6 +129,13 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService return ret; } + private int EquipGearSetDetour(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId) + { + var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); + Glamourer.Log.Verbose($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); + return ret; + } + private static uint FixId(uint itemId) => itemId % 50000; @@ -130,7 +148,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService InventoryType targetContainer, ushort targetSlot, byte unk) { var ret = _moveItemHook.Original(manager, sourceContainer, sourceSlot, targetContainer, targetSlot, unk); - Glamourer.Log.Excessive($"[InventoryService] Moved {sourceContainer} {sourceSlot} {targetContainer} {targetSlot} (Returned {ret})"); + Glamourer.Log.Verbose($"[InventoryService] Moved {sourceContainer} {sourceSlot} {targetContainer} {targetSlot} (Returned {ret})"); if (ret == 0) { if (InvokeSource(sourceContainer, sourceSlot, out var source)) diff --git a/Glamourer/Interop/JobService.cs b/Glamourer/Interop/JobService.cs index 1797809..f687715 100644 --- a/Glamourer/Interop/JobService.cs +++ b/Glamourer/Interop/JobService.cs @@ -50,7 +50,7 @@ public class JobService : IDisposable var newJob = Jobs.TryGetValue(newJobIndex, out var j) ? j : Jobs[0]; var oldJob = Jobs.TryGetValue(oldJobIndex, out var o) ? o : Jobs[0]; - Glamourer.Log.Excessive($"{actor} changed job from {oldJob} to {newJob}."); + Glamourer.Log.Error($"{actor} changed job from {oldJob} to {newJob}."); JobChanged?.Invoke(actor, oldJob, newJob); } } diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index d1004e6..e43dc74 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -1,36 +1,124 @@ using Dalamud.Hooking; using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; +using FFXIVClientStructs.FFXIV.Client.Game.Character; using Glamourer.Events; using Penumbra.GameData; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; - namespace Glamourer.Interop; +/// +/// This struct is the struct that loadallequipment passes in as its gearsetData container. +/// +[StructLayout(LayoutKind.Explicit)] // Size of 70 bytes maybe? +public readonly struct GearsetItemDataStruct +{ + // Stores the weapon data. Includes both dyes in the data. + [FieldOffset(0)] public readonly WeaponModelId MainhandWeaponData; + [FieldOffset(8)] public readonly WeaponModelId OffhandWeaponData; + + [FieldOffset(16)] public readonly byte CrestBitField; // A Bitfield:: ShieldCrest == 1, HeadCrest == 2, Chest Crest == 4 + [FieldOffset(17)] public readonly byte JobId; // Job ID associated with the gearset change. + + // Flicks from 0 to 128 (anywhere inbetween), have yet to associate what it is linked to. Remains the same when flicking between gearsets of the same job. + [FieldOffset(18)] public readonly byte UNK_18; + [FieldOffset(19)] public readonly byte UNK_19; // I have never seen this be anything other than 0. + + // Legacy helmet equip slot armor for a character. + [FieldOffset(20)] public readonly LegacyCharacterArmor HeadSlotArmor; + [FieldOffset(24)] public readonly LegacyCharacterArmor TopSlotArmor; + [FieldOffset(28)] public readonly LegacyCharacterArmor ArmsSlotArmor; + [FieldOffset(32)] public readonly LegacyCharacterArmor LegsSlotArmor; + [FieldOffset(26)] public readonly LegacyCharacterArmor FeetSlotArmor; + [FieldOffset(40)] public readonly LegacyCharacterArmor EarSlotArmor; + [FieldOffset(44)] public readonly LegacyCharacterArmor NeckSlotArmor; + [FieldOffset(48)] public readonly LegacyCharacterArmor WristSlotArmor; + [FieldOffset(52)] public readonly LegacyCharacterArmor RFingerSlotArmor; + [FieldOffset(56)] public readonly LegacyCharacterArmor LFingerSlotArmor; + + // Byte array of all slot's secondary dyes. + [FieldOffset(60)] public readonly byte HeadSlotSecondaryDye; + [FieldOffset(61)] public readonly byte TopSlotSecondaryDye; + [FieldOffset(62)] public readonly byte ArmsSlotSecondaryDye; + [FieldOffset(63)] public readonly byte LegsSlotSecondaryDye; + [FieldOffset(64)] public readonly byte FeetSlotSecondaryDye; + [FieldOffset(65)] public readonly byte EarSlotSecondaryDye; + [FieldOffset(66)] public readonly byte NeckSlotSecondaryDye; + [FieldOffset(67)] public readonly byte WristSlotSecondaryDye; + [FieldOffset(68)] public readonly byte RFingerSlotSecondaryDye; + [FieldOffset(69)] public readonly byte LFingerSlotSecondaryDye; +} + public unsafe class UpdateSlotService : IDisposable { - public readonly EquipSlotUpdating EquipSlotUpdatingEvent; - public readonly BonusSlotUpdating BonusSlotUpdatingEvent; - private readonly DictBonusItems _bonusItems; + public readonly EquipSlotUpdating EquipSlotUpdatingEvent; + public readonly BonusSlotUpdating BonusSlotUpdatingEvent; + private readonly DictBonusItems _bonusItems; + + #region LoadAllEquipData + /////////////////////////////////////////////////// + // This is a currently undocumented signature that loads all equipment after changing a gearset. + // :: Signature Maintainers Note: + // To obtain this signature, get the stacktrace from FlagSlotForUpdate for human, and find func `sub_140842F50`. + // This function is what calls the weapon/equipment/crest loads, which call FlagSlotForUpdate if different. + // + // By detouring this function, and executing the original, then logic after, we have a consistant point in time where we know all + // slots have been flagged, meaning a consistant point in time that glamourer has processed all of its updates. + public const string LoadAllEquipmentSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; + private delegate Int64 LoadAllEquipmentDelegate(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData); + private Int64 LoadAllEquipmentDetour(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData) + { + // return original first so we can log the changes after + var ret = _loadAllEquipmentHook.Original(drawDataContainer, gearsetData); + + // perform logic stuff. + var owner = drawDataContainer->OwnerObject; + Glamourer.Log.Warning($"[LoadAllEquipmentDetour] Owner: 0x{(nint)owner->DrawObject:X} Finished Applying its GameState!"); + Glamourer.Log.Warning($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); + + // return original. + return ret; + } + + private string FormatWeaponModelId(WeaponModelId weaponModelId) => $"Id: {weaponModelId.Id}, Type: {weaponModelId.Type}, Variant: {weaponModelId.Variant}, Stain0: {weaponModelId.Stain0}, Stain1: {weaponModelId.Stain1}"; + + private string FormatGearsetItemDataStruct(GearsetItemDataStruct gearsetItemData) + { + string ret = $"\nMainhandWeaponData: {FormatWeaponModelId(gearsetItemData.MainhandWeaponData)}," + + $"\nOffhandWeaponData: {FormatWeaponModelId(gearsetItemData.OffhandWeaponData)}," + + $"\nCrestBitField: {gearsetItemData.CrestBitField} | JobId: {gearsetItemData.JobId} | UNK_18: {gearsetItemData.UNK_18} | UNK_19: {gearsetItemData.UNK_19}"; + // Iterate through offsets from 20 to 60 and format the CharacterArmor data + for (int offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) + { + LegacyCharacterArmor* equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetItemData + offset); + int dyeOffset = (offset - 20) / sizeof(LegacyCharacterArmor) + 60; // Calculate the corresponding dye offset + byte* dyePtr = (byte*)&gearsetItemData + dyeOffset; + ret += $"\nEquipSlot {((EquipSlot)(dyeOffset-60)).ToString()}:: Id: {(*equipSlotPtr).Set}, Variant: {(*equipSlotPtr).Variant}, Stain0: {(*equipSlotPtr).Stain.Id}, Stain1: {*dyePtr}"; + } + return ret; + } +#endregion LoadAllEquipData public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, IGameInteropProvider interop, DictBonusItems bonusItems) { EquipSlotUpdatingEvent = equipSlotUpdating; BonusSlotUpdatingEvent = bonusSlotUpdating; - _bonusItems = bonusItems; + _bonusItems = bonusItems; interop.InitializeFromAttributes(this); _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); + _loadAllEquipmentHook.Enable(); } public void Dispose() { _flagSlotForUpdateHook.Dispose(); _flagBonusSlotForUpdateHook.Dispose(); + _loadAllEquipmentHook.Dispose(); } public void UpdateEquipSlot(Model drawObject, EquipSlot slot, CharacterArmor data) @@ -79,24 +167,36 @@ public unsafe class UpdateSlotService : IDisposable [Signature(Sigs.FlagBonusSlotForUpdate, DetourName = nameof(FlagBonusSlotForUpdateDetour))] private readonly Hook _flagBonusSlotForUpdateHook = null!; + [Signature(LoadAllEquipmentSig, DetourName = nameof(LoadAllEquipmentDetour))] + private readonly Hook _loadAllEquipmentHook = null!; + private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToEquipSlot(); + var slot = slotIdx.ToEquipSlot(); var returnValue = ulong.MaxValue; + EquipSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); - Glamourer.Log.Excessive($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); - return returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; + Glamourer.Log.Information($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); + returnValue = returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; + + return returnValue; } private ulong FlagBonusSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToBonusSlot(); + var slot = slotIdx.ToBonusSlot(); var returnValue = ulong.MaxValue; + BonusSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); - Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); - return returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; + Glamourer.Log.Information($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); + returnValue = returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; + + return returnValue; } private ulong FlagSlotForUpdateInterop(Model drawObject, EquipSlot slot, CharacterArmor armor) - => _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); + { + Glamourer.Log.Warning($"Glamour-Invoked Equip Slot update for 0x{drawObject.Address:X} with {slot} and {armor}."); + return _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); + } } diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index f9ddb89..b592b65 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -51,7 +51,7 @@ public class StateEditor( return; var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); - Glamourer.Log.Verbose( + Glamourer.Log.Information( $"Set {idx.ToDefaultName()} customizations in state {state.Identifier.Incognito(null)} from {old.Value} to {value.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Customize, settings.Source, state, actors, new CustomizeTransaction(idx, old, value)); } @@ -64,7 +64,7 @@ public class StateEditor( return; var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); - Glamourer.Log.Verbose( + Glamourer.Log.Information( $"Set {applied} customizations in state {state.Identifier.Incognito(null)} from {old} to {customizeInput}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.EntireCustomize, settings.Source, state, actors, new EntireCustomizeTransaction(applied, old, customizeInput)); @@ -75,7 +75,10 @@ public class StateEditor( { var state = (ActorState)data; if (!Editor.ChangeItem(state, slot, item, settings.Source, out var old, settings.Key)) + { + Glamourer.Log.Information("Not Setting State or invoking, Editor requested us not to change it!"); return; + } var type = slot.ToIndex() < 10 ? StateChangeType.Equip : StateChangeType.Weapon; var actors = type is StateChangeType.Equip @@ -86,8 +89,8 @@ public class StateEditor( if (slot is EquipSlot.MainHand) ApplyMainhandPeriphery(state, item, null, settings); - Glamourer.Log.Verbose( - $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}). [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Debug( + $"[ChangeItem] Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}). [Affecting {actors.ToLazyString("nothing")}.]"); if (type is StateChangeType.Equip) { @@ -116,8 +119,8 @@ public class StateEditor( return; var actors = Applier.ChangeBonusItem(state, slot, settings.Source.RequiresChange()); - Glamourer.Log.Verbose( - $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.Id}) to {item.Name} ({item.Id}). [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Debug( + $"[ChangeBonus] Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.Id}) to {item.Name} ({item.Id}). [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.BonusItem, settings.Source, state, actors, new BonusItemTransaction(slot, old, item)); } @@ -149,8 +152,8 @@ public class StateEditor( if (slot is EquipSlot.MainHand) ApplyMainhandPeriphery(state, item, stains, settings); - Glamourer.Log.Verbose( - $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStains} to {stains!.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Debug( + $"[ChangeEquip] Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStains} to {stains!.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); if (type is StateChangeType.Equip) { StateChanged.Invoke(type, settings.Source, state, actors, new EquipTransaction(slot, old, item!.Value)); @@ -181,7 +184,7 @@ public class StateEditor( return; var actors = Applier.ChangeStain(state, slot, settings.Source.RequiresChange()); - Glamourer.Log.Verbose( + Glamourer.Log.Debug( $"Set {slot.ToName()} stain in state {state.Identifier.Incognito(null)} from {old} to {stains}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, new StainTransaction(slot, old, stains)); } @@ -250,7 +253,7 @@ public class StateEditor( return; var actors = Applier.ChangeMetaState(state, index, settings.Source.RequiresChange()); - Glamourer.Log.Verbose( + Glamourer.Log.Debug( $"Set {index.ToName()} in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Other, settings.Source, state, actors, new MetaTransaction(index, old, value)); } @@ -414,8 +417,7 @@ public class StateEditor( ? Applier.ApplyAll(state, requiresRedraw, false) : ActorData.Invalid; - Glamourer.Log.Verbose( - $"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Debug($"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later return; diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index d054a25..382e488 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -216,8 +216,7 @@ public class StateListener : IDisposable // then we do not want to use our restricted gear protection // since we assume the player has that gear modded to availability. var locked = false; - if (actor.Identifier(_actors, out var identifier) - && _manager.TryGetValue(identifier, out var state)) + if (actor.Identifier(_actors, out var identifier) && _manager.TryGetValue(identifier, out var state)) { HandleEquipSlot(actor, state, slot, ref armor); locked = state.Sources[slot, false] is StateSource.IpcFixed; @@ -383,7 +382,7 @@ public class StateListener : IDisposable lastFistOffhand = new CharacterWeapon((PrimaryId)(weapon.Skeleton.Id + 50), weapon.Weapon, weapon.Variant, weapon.Stains); _fistOffhands[actor] = lastFistOffhand; - Glamourer.Log.Excessive($"Storing fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); + Glamourer.Log.Verbose($"Storing fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); } _funModule.ApplyFunToWeapon(actor, ref weapon, slot); diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index eabaf2f..736dd6e 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -273,7 +273,7 @@ public sealed class StateManager( if (source is not StateSource.Game) actors = Applier.ApplyAll(state, redraw, true); - Glamourer.Log.Verbose( + Glamourer.Log.Debug( $"Reset entire state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); } @@ -298,7 +298,7 @@ public sealed class StateManager( state.Materials.Clear(); - Glamourer.Log.Verbose( + Glamourer.Log.Debug( $"Reset advanced customization and dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); } From e1a41b5f3c7d144cae20c291ff2ee2fe77978e87 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 17 Jan 2025 17:39:26 -0800 Subject: [PATCH 173/401] Implements true endpoints for all glamourer operations, also correctly marks reverts and gearsets. Replaced back excessive logging to maintain with logging formats expected by glamourer. --- Glamourer/Api/DesignsApi.cs | 2 +- Glamourer/Api/IpcProviders.cs | 1 + Glamourer/Api/StateApi.cs | 27 ++++- Glamourer/Automation/AutoDesignApplier.cs | 2 - Glamourer/Designs/IDesignEditor.cs | 6 +- Glamourer/Events/GearsetDataLoaded.cs | 23 ++++ Glamourer/Events/StateUpdated.cs | 26 +++++ Glamourer/Gui/DesignQuickBar.cs | 8 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 14 +-- .../Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 4 +- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 4 +- Glamourer/Interop/ChangeCustomizeService.cs | 4 +- Glamourer/Interop/InventoryService.cs | 10 +- Glamourer/Interop/JobService.cs | 2 +- .../Interop/Penumbra/PenumbraAutoRedraw.cs | 4 +- Glamourer/Interop/UpdateSlotService.cs | 100 ++++++++---------- Glamourer/Services/CommandService.cs | 8 +- Glamourer/State/StateEditor.cs | 5 + Glamourer/State/StateListener.cs | 29 ++++- Glamourer/State/StateManager.cs | 43 +++++++- 21 files changed, 225 insertions(+), 99 deletions(-) create mode 100644 Glamourer/Events/GearsetDataLoaded.cs create mode 100644 Glamourer/Events/StateUpdated.cs diff --git a/Glamourer/Api/DesignsApi.cs b/Glamourer/Api/DesignsApi.cs index ee49bd5..6c3037e 100644 --- a/Glamourer/Api/DesignsApi.cs +++ b/Glamourer/Api/DesignsApi.cs @@ -33,7 +33,7 @@ public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager { var once = (flags & ApplyFlag.Once) != 0; var settings = new ApplySettings(Source: once ? StateSource.IpcManual : StateSource.IpcFixed, Key: key, MergeLinks: true, - ResetMaterials: !once && key != 0); + ResetMaterials: !once && key != 0, SendStateUpdate: true); using var restrict = ApiHelpers.Restrict(design, flags); stateManager.ApplyDesign(state, design, settings); diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 8639a22..166245f 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -52,6 +52,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.RevertToAutomationName.Provider(pi, api.State), IpcSubscribers.StateChanged.Provider(pi, api.State), IpcSubscribers.StateChangedWithType.Provider(pi, api.State), + IpcSubscribers.StateUpdated.Provider(pi, api.State), IpcSubscribers.GPoseChanged.Provider(pi, api.State), ]; _initializedProvider.Invoke(); diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index ce7d226..248e294 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -11,9 +11,10 @@ using OtterGui.Services; using Penumbra.GameData.Interop; using ObjectManager = Glamourer.Interop.ObjectManager; using StateChanged = Glamourer.Events.StateChanged; +using StateUpdated = Glamourer.Events.StateUpdated; namespace Glamourer.Api; - + public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable { private readonly ApiHelpers _helpers; @@ -23,6 +24,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private readonly AutoDesignApplier _autoDesigns; private readonly ObjectManager _objects; private readonly StateChanged _stateChanged; + private readonly StateUpdated _stateUpdated; private readonly GPoseService _gPose; public StateApi(ApiHelpers helpers, @@ -32,6 +34,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable AutoDesignApplier autoDesigns, ObjectManager objects, StateChanged stateChanged, + StateUpdated stateUpdated, GPoseService gPose) { _helpers = helpers; @@ -41,8 +44,10 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable _autoDesigns = autoDesigns; _objects = objects; _stateChanged = stateChanged; + _stateUpdated = stateUpdated; _gPose = gPose; _stateChanged.Subscribe(OnStateChanged, Events.StateChanged.Priority.GlamourerIpc); + _stateUpdated.Subscribe(OnStateUpdated, Events.StateUpdated.Priority.GlamourerIpc); _gPose.Subscribe(OnGPoseChange, GPoseService.Priority.GlamourerIpc); } @@ -250,13 +255,14 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public event Action? StateChanged; public event Action? StateChangedWithType; + public event Action? StateUpdated; public event Action? GPoseChanged; private void ApplyDesign(ActorState state, DesignBase design, uint key, ApplyFlag flags) { var once = (flags & ApplyFlag.Once) != 0; var settings = new ApplySettings(Source: once ? StateSource.IpcManual : StateSource.IpcFixed, Key: key, MergeLinks: true, - ResetMaterials: !once && key != 0); + ResetMaterials: !once && key != 0, SendStateUpdate: true); _stateManager.ApplyDesign(state, design, settings); ApiHelpers.Lock(state, key, flags); } @@ -296,7 +302,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable { var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; _autoDesigns.ReapplyAutomation(actor, state.Identifier, state, true, out var forcedRedraw); - _stateManager.ReapplyState(actor, state, forcedRedraw, source); + _stateManager.ReapplyAutomationState(actor, state, forcedRedraw, true, source); ApiHelpers.Lock(state, key, flags); } @@ -333,7 +339,8 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { - Glamourer.Log.Error($"[OnStateChanged API CALL] Sending out OnStateChanged with type {type}."); + // Remove this comment before creating PR. + Glamourer.Log.Verbose($"[OnStateChanged] Sending out OnStateChanged with type {type}."); if (StateChanged != null) foreach (var actor in actors.Objects) @@ -343,4 +350,16 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable foreach (var actor in actors.Objects) StateChangedWithType.Invoke(actor.Address, type); } + + private void OnStateUpdated(StateUpdateType type, ActorData actors) + { + if (StateUpdated != null) + foreach (var actor in actors.Objects) + { + // Remove these before creating PR + Glamourer.Log.Information($"[ENDPOINT DEBUGGING] 0x{actor.Address:X} had update of type {type}."); + Glamourer.Log.Information("--------------------------------------------------------------"); + StateUpdated.Invoke(actor.Address, type); + } + } } diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index d49864f..bcc907c 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -216,8 +216,6 @@ public sealed class AutoDesignApplier : IDisposable if (!_config.EnableAutoDesigns || !actor.Identifier(_actors, out var id)) return; - Glamourer.Log.Information($"[AutoDesignApplier][OnJobChange] We had EnableAutoDesigns active, and are a valid actor!"); - if (!GetPlayerSet(id, out var set)) { if (_state.TryGetValue(id, out var s)) diff --git a/Glamourer/Designs/IDesignEditor.cs b/Glamourer/Designs/IDesignEditor.cs index 935263b..0178620 100644 --- a/Glamourer/Designs/IDesignEditor.cs +++ b/Glamourer/Designs/IDesignEditor.cs @@ -13,7 +13,8 @@ public readonly record struct ApplySettings( bool FromJobChange = false, bool UseSingleSource = false, bool MergeLinks = false, - bool ResetMaterials = false) + bool ResetMaterials = false, + bool SendStateUpdate = false) { public static readonly ApplySettings Manual = new() { @@ -24,6 +25,7 @@ public readonly record struct ApplySettings( UseSingleSource = false, MergeLinks = false, ResetMaterials = false, + SendStateUpdate = false, }; public static readonly ApplySettings ManualWithLinks = new() @@ -35,6 +37,7 @@ public readonly record struct ApplySettings( UseSingleSource = false, MergeLinks = true, ResetMaterials = false, + SendStateUpdate = false, }; public static readonly ApplySettings Game = new() @@ -46,6 +49,7 @@ public readonly record struct ApplySettings( UseSingleSource = false, MergeLinks = false, ResetMaterials = true, + SendStateUpdate = false, }; } diff --git a/Glamourer/Events/GearsetDataLoaded.cs b/Glamourer/Events/GearsetDataLoaded.cs new file mode 100644 index 0000000..47d0108 --- /dev/null +++ b/Glamourer/Events/GearsetDataLoaded.cs @@ -0,0 +1,23 @@ +using OtterGui.Classes; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; +using Penumbra.GameData.Structs; + +namespace Glamourer.Events; + +/// +/// Triggers when the equipped gearset finished running all of its LoadEquipment, LoadWeapon, and crest calls. +/// This defines a universal endpoint of base game state application to monitor. +/// +/// The model drawobject associated with the finished load (should always be ClientPlayer) +/// +/// +public sealed class GearsetDataLoaded() + : EventWrapper(nameof(GearsetDataLoaded)) +{ + public enum Priority + { + /// + StateListener = 0, + } +} \ No newline at end of file diff --git a/Glamourer/Events/StateUpdated.cs b/Glamourer/Events/StateUpdated.cs new file mode 100644 index 0000000..82d737f --- /dev/null +++ b/Glamourer/Events/StateUpdated.cs @@ -0,0 +1,26 @@ +using Glamourer.Api.Enums; +using Glamourer.Designs.History; +using Glamourer.Interop.Structs; +using Glamourer.State; +using OtterGui.Classes; + +namespace Glamourer.Events; + +/// +/// Triggered when a Design is edited in any way. +/// +/// Parameter is the type of the change +/// Parameter is the changed saved state. +/// Parameter is the existing actors using this saved state. +/// Parameter is any additional data depending on the type of change. +/// +/// +public sealed class StateUpdated() + : EventWrapper(nameof(StateUpdated)) +{ + public enum Priority + { + /// + GlamourerIpc = int.MinValue, + } +} diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index 31ca45e..bdc345f 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -183,7 +183,7 @@ public sealed class DesignQuickBar : Window, IDisposable } using var _ = design!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); - _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks); + _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); } private void DrawRevertButton(Vector2 buttonSize) @@ -213,7 +213,7 @@ public sealed class DesignQuickBar : Window, IDisposable var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, tooltip, available); ImGui.SameLine(); if (clicked) - _stateManager.ResetState(state!, StateSource.Manual); + _stateManager.ResetState(state!, StateSource.Manual, stateUpdate: true); } private void DrawRevertAutomationButton(Vector2 buttonSize) @@ -252,7 +252,7 @@ public sealed class DesignQuickBar : Window, IDisposable foreach (var actor in data.Objects) { _autoDesignApplier.ReapplyAutomation(actor, id, state!, true, out var forcedRedraw); - _stateManager.ReapplyState(actor, forcedRedraw, StateSource.Manual); + _stateManager.ReapplyAutomationState(actor, forcedRedraw, true, StateSource.Manual); } } @@ -292,7 +292,7 @@ public sealed class DesignQuickBar : Window, IDisposable foreach (var actor in data.Objects) { _autoDesignApplier.ReapplyAutomation(actor, id, state!, false, out var forcedRedraw); - _stateManager.ReapplyState(actor, forcedRedraw, StateSource.Manual); + _stateManager.ReapplyAutomationState(actor, forcedRedraw, false, StateSource.Manual); } } diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 265e1d9..ced78fb 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -385,7 +385,7 @@ public class ActorPanel { if (ImGuiUtil.DrawDisabledButton("Revert to Game", Vector2.Zero, "Revert the character to its actual state in the game.", _state!.IsLocked)) - _stateManager.ResetState(_state!, StateSource.Manual); + _stateManager.ResetState(_state!, StateSource.Manual, stateUpdate: true); ImGui.SameLine(); @@ -394,7 +394,7 @@ public class ActorPanel !_config.EnableAutoDesigns || _state!.IsLocked)) { _autoDesignApplier.ReapplyAutomation(_actor, _identifier, _state!, false, out var forcedRedraw); - _stateManager.ReapplyState(_actor, forcedRedraw, StateSource.Manual); + _stateManager.ReapplyAutomationState(_actor, forcedRedraw, false, StateSource.Manual); } ImGui.SameLine(); @@ -403,14 +403,14 @@ public class ActorPanel !_config.EnableAutoDesigns || _state!.IsLocked)) { _autoDesignApplier.ReapplyAutomation(_actor, _identifier, _state!, true, out var forcedRedraw); - _stateManager.ReapplyState(_actor, forcedRedraw, StateSource.Manual); + _stateManager.ReapplyAutomationState(_actor, forcedRedraw, true, StateSource.Manual); } ImGui.SameLine(); if (ImGuiUtil.DrawDisabledButton("Reapply", Vector2.Zero, "Try to reapply the configured state if something went wrong. Should generally not be necessary.", _state!.IsLocked)) - _stateManager.ReapplyState(_actor, false, StateSource.Manual); + _stateManager.ReapplyState(_actor, false, StateSource.Manual, true); } private void DrawApplyToSelf() @@ -423,7 +423,7 @@ public class ActorPanel if (_stateManager.GetOrCreate(id, data.Objects[0], out var state)) _stateManager.ApplyDesign(state, _converter.Convert(_state!, ApplicationRules.FromModifiers(_state!)), - ApplySettings.Manual); + ApplySettings.Manual with { SendStateUpdate = true }); } private void DrawApplyToTarget() @@ -440,7 +440,7 @@ public class ActorPanel if (_stateManager.GetOrCreate(id, data.Objects[0], out var state)) _stateManager.ApplyDesign(state, _converter.Convert(_state!, ApplicationRules.FromModifiers(_state!)), - ApplySettings.Manual); + ApplySettings.Manual with { SendStateUpdate = true }); } @@ -467,7 +467,7 @@ public class ActorPanel var text = ImGui.GetClipboardText(); var design = panel._converter.FromBase64(text, applyCustomize, applyGear, out _) ?? throw new Exception("The clipboard did not contain valid data."); - panel._stateManager.ApplyDesign(panel._state!, design, ApplySettings.ManualWithLinks); + panel._stateManager.ApplyDesign(panel._state!, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); } catch (Exception ex) { diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index 394bd7f..c44a722 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -79,7 +79,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer if (ImGuiUtil.DrawDisabledButton("Apply to Player", Vector2.Zero, string.Empty, !enabled)) { var design = CreateDesign(plate); - _state.ApplyDesign(state!, design, ApplySettings.Manual); + _state.ApplyDesign(state!, design, ApplySettings.Manual with { SendStateUpdate = true }); } using (ImRaii.Group()) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 070ca1e..fe71609 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -460,7 +460,7 @@ public class DesignPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); - _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks); + _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); } } @@ -478,7 +478,7 @@ public class DesignPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); - _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks); + _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); } } diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index 312bceb..345df11 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -196,7 +196,7 @@ public class NpcPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { var design = _converter.Convert(ToDesignData(), new StateMaterialManager(), ApplicationRules.NpcFromModifiers()); - _state.ApplyDesign(state, design, ApplySettings.Manual); + _state.ApplyDesign(state, design, ApplySettings.Manual with { SendStateUpdate = true }); } } @@ -214,7 +214,7 @@ public class NpcPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { var design = _converter.Convert(ToDesignData(), new StateMaterialManager(), ApplicationRules.NpcFromModifiers()); - _state.ApplyDesign(state, design, ApplySettings.Manual); + _state.ApplyDesign(state, design, ApplySettings.Manual with { SendStateUpdate = true }); } } diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index 032412e..10e3a12 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -70,7 +70,7 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 _itemList = new(12); - // This can be moved into client structs or penumbra.gamedata when needed. + // Called by EquipGearset, but returns a pointer instead of an int. + // This is the internal function processed by all sources of Equipping a gearset, + // such as hotbar gearset application and command gearset application public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; private delegate nint ChangeGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); @@ -56,7 +58,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService var ret = _equipGearsetInternalHook.Original(module, gearsetId, glamourPlateId); var set = module->GetGearset((int)gearsetId); _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), (int)gearsetId, prior, glamourPlateId, set->ClassJob); - Glamourer.Log.Warning($"[InventoryService] [EquipInternal] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); + Glamourer.Log.Verbose($"[InventoryService] [EquipInternal] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); if (ret == 0) { var entry = module->GetGearset((int)gearsetId); @@ -132,7 +134,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService private int EquipGearSetDetour(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId) { var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); - Glamourer.Log.Verbose($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); + Glamourer.Log.Excessive($"[InventoryService] (old) Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); return ret; } @@ -148,7 +150,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService InventoryType targetContainer, ushort targetSlot, byte unk) { var ret = _moveItemHook.Original(manager, sourceContainer, sourceSlot, targetContainer, targetSlot, unk); - Glamourer.Log.Verbose($"[InventoryService] Moved {sourceContainer} {sourceSlot} {targetContainer} {targetSlot} (Returned {ret})"); + Glamourer.Log.Excessive($"[InventoryService] Moved {sourceContainer} {sourceSlot} {targetContainer} {targetSlot} (Returned {ret})"); if (ret == 0) { if (InvokeSource(sourceContainer, sourceSlot, out var source)) diff --git a/Glamourer/Interop/JobService.cs b/Glamourer/Interop/JobService.cs index f687715..1797809 100644 --- a/Glamourer/Interop/JobService.cs +++ b/Glamourer/Interop/JobService.cs @@ -50,7 +50,7 @@ public class JobService : IDisposable var newJob = Jobs.TryGetValue(newJobIndex, out var j) ? j : Jobs[0]; var oldJob = Jobs.TryGetValue(oldJobIndex, out var o) ? o : Jobs[0]; - Glamourer.Log.Error($"{actor} changed job from {oldJob} to {newJob}."); + Glamourer.Log.Excessive($"{actor} changed job from {oldJob} to {newJob}."); JobChanged?.Invoke(actor, oldJob, newJob); } } diff --git a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs index fbe0d9d..3e48fe9 100644 --- a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs +++ b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs @@ -88,7 +88,7 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService _actions.Enqueue((state, () => { foreach (var actor in actors.Objects) - _state.ReapplyState(actor, state, false, StateSource.IpcManual); + _state.ReapplyState(actor, state, false, StateSource.IpcManual, true); Glamourer.Log.Debug($"Automatically applied mod settings of type {type} to {id.Incognito(null)}."); }, WaitFrames)); } @@ -108,7 +108,7 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService _frame = currentFrame; _framework.RunOnFrameworkThread(() => { - _state.ReapplyState(_objects.Player, false, StateSource.IpcManual); + _state.ReapplyState(_objects.Player, false, StateSource.IpcManual, true); Glamourer.Log.Debug( $"Automatically applied mod settings of type {type} to {_objects.PlayerData.Identifier.Incognito(null)} (Local Player)."); }); diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index e43dc74..7e5cf59 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -23,7 +23,7 @@ public readonly struct GearsetItemDataStruct [FieldOffset(16)] public readonly byte CrestBitField; // A Bitfield:: ShieldCrest == 1, HeadCrest == 2, Chest Crest == 4 [FieldOffset(17)] public readonly byte JobId; // Job ID associated with the gearset change. - // Flicks from 0 to 128 (anywhere inbetween), have yet to associate what it is linked to. Remains the same when flicking between gearsets of the same job. + // Flicks from 0 to 127 (anywhere inbetween), have yet to associate what it is linked to. Remains the same when flicking between gearsets of the same job. [FieldOffset(18)] public readonly byte UNK_18; [FieldOffset(19)] public readonly byte UNK_19; // I have never seen this be anything other than 0. @@ -56,69 +56,47 @@ public unsafe class UpdateSlotService : IDisposable { public readonly EquipSlotUpdating EquipSlotUpdatingEvent; public readonly BonusSlotUpdating BonusSlotUpdatingEvent; + public readonly GearsetDataLoaded GearsetDataLoadedEvent; private readonly DictBonusItems _bonusItems; - #region LoadAllEquipData - /////////////////////////////////////////////////// - // This is a currently undocumented signature that loads all equipment after changing a gearset. - // :: Signature Maintainers Note: - // To obtain this signature, get the stacktrace from FlagSlotForUpdate for human, and find func `sub_140842F50`. - // This function is what calls the weapon/equipment/crest loads, which call FlagSlotForUpdate if different. - // - // By detouring this function, and executing the original, then logic after, we have a consistant point in time where we know all - // slots have been flagged, meaning a consistant point in time that glamourer has processed all of its updates. - public const string LoadAllEquipmentSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; - private delegate Int64 LoadAllEquipmentDelegate(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData); - private Int64 LoadAllEquipmentDetour(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData) + // This function is what calls the weapon/equipment/crest loads, which call FlagSlotForUpdate if different. (MetaData not included) + public const string LoadGearsetDataSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; + private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData); + private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData) { - // return original first so we can log the changes after - var ret = _loadAllEquipmentHook.Original(drawDataContainer, gearsetData); + // Let the gearset data process all of its loads and slot flag update calls first. + var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); + // Ensure that the owner of the drawdata container is a character base. + Model ownerDrawObject = drawDataContainer->OwnerObject->DrawObject; + if (!ownerDrawObject.IsCharacterBase) + return ret; - // perform logic stuff. - var owner = drawDataContainer->OwnerObject; - Glamourer.Log.Warning($"[LoadAllEquipmentDetour] Owner: 0x{(nint)owner->DrawObject:X} Finished Applying its GameState!"); - Glamourer.Log.Warning($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); - - // return original. + // invoke the changed event for the state listener and return. + Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{ownerDrawObject.Address:X} Finished Applying its GameState!"); + // Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); + GearsetDataLoadedEvent.Invoke(drawDataContainer->OwnerObject->DrawObject); return ret; } - private string FormatWeaponModelId(WeaponModelId weaponModelId) => $"Id: {weaponModelId.Id}, Type: {weaponModelId.Type}, Variant: {weaponModelId.Variant}, Stain0: {weaponModelId.Stain0}, Stain1: {weaponModelId.Stain1}"; - - private string FormatGearsetItemDataStruct(GearsetItemDataStruct gearsetItemData) - { - string ret = $"\nMainhandWeaponData: {FormatWeaponModelId(gearsetItemData.MainhandWeaponData)}," + - $"\nOffhandWeaponData: {FormatWeaponModelId(gearsetItemData.OffhandWeaponData)}," + - $"\nCrestBitField: {gearsetItemData.CrestBitField} | JobId: {gearsetItemData.JobId} | UNK_18: {gearsetItemData.UNK_18} | UNK_19: {gearsetItemData.UNK_19}"; - // Iterate through offsets from 20 to 60 and format the CharacterArmor data - for (int offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) - { - LegacyCharacterArmor* equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetItemData + offset); - int dyeOffset = (offset - 20) / sizeof(LegacyCharacterArmor) + 60; // Calculate the corresponding dye offset - byte* dyePtr = (byte*)&gearsetItemData + dyeOffset; - ret += $"\nEquipSlot {((EquipSlot)(dyeOffset-60)).ToString()}:: Id: {(*equipSlotPtr).Set}, Variant: {(*equipSlotPtr).Variant}, Stain0: {(*equipSlotPtr).Stain.Id}, Stain1: {*dyePtr}"; - } - return ret; - } -#endregion LoadAllEquipData - - public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, IGameInteropProvider interop, - DictBonusItems bonusItems) + public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, GearsetDataLoaded gearsetDataLoaded, + IGameInteropProvider interop, DictBonusItems bonusItems) { EquipSlotUpdatingEvent = equipSlotUpdating; BonusSlotUpdatingEvent = bonusSlotUpdating; + GearsetDataLoadedEvent = gearsetDataLoaded; + _bonusItems = bonusItems; interop.InitializeFromAttributes(this); _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); - _loadAllEquipmentHook.Enable(); + _loadGearsetDataHook.Enable(); } public void Dispose() { _flagSlotForUpdateHook.Dispose(); _flagBonusSlotForUpdateHook.Dispose(); - _loadAllEquipmentHook.Dispose(); + _loadGearsetDataHook.Dispose(); } public void UpdateEquipSlot(Model drawObject, EquipSlot slot, CharacterArmor data) @@ -167,18 +145,16 @@ public unsafe class UpdateSlotService : IDisposable [Signature(Sigs.FlagBonusSlotForUpdate, DetourName = nameof(FlagBonusSlotForUpdateDetour))] private readonly Hook _flagBonusSlotForUpdateHook = null!; - [Signature(LoadAllEquipmentSig, DetourName = nameof(LoadAllEquipmentDetour))] - private readonly Hook _loadAllEquipmentHook = null!; + [Signature(LoadGearsetDataSig, DetourName = nameof(LoadGearsetDataDetour))] + private readonly Hook _loadGearsetDataHook = null!; private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { var slot = slotIdx.ToEquipSlot(); var returnValue = ulong.MaxValue; - EquipSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); - Glamourer.Log.Information($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); + Glamourer.Log.Excessive($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); returnValue = returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; - return returnValue; } @@ -186,17 +162,35 @@ public unsafe class UpdateSlotService : IDisposable { var slot = slotIdx.ToBonusSlot(); var returnValue = ulong.MaxValue; - BonusSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); - Glamourer.Log.Information($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); + Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); returnValue = returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; - return returnValue; } private ulong FlagSlotForUpdateInterop(Model drawObject, EquipSlot slot, CharacterArmor armor) { - Glamourer.Log.Warning($"Glamour-Invoked Equip Slot update for 0x{drawObject.Address:X} with {slot} and {armor}."); + Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Invoked by Glamourer on 0x{drawObject.Address:X} on {slot} with itemdata {armor}."); return _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); } + + // If you ever care to debug this, here is a formatted string output of this new gearsetDataPacket struct. + private string FormatGearsetItemDataStruct(GearsetItemDataStruct gearsetData) + { + string ret = + $"\nMainhandWeaponData: Id: {gearsetData.MainhandWeaponData.Id}, Type: {gearsetData.MainhandWeaponData.Type}, " + + $"Variant: {gearsetData.MainhandWeaponData.Variant}, Stain0: {gearsetData.MainhandWeaponData.Stain0}, Stain1: {gearsetData.MainhandWeaponData.Stain1}" + + $"\nOffhandWeaponData: Id: {gearsetData.OffhandWeaponData.Id}, Type: {gearsetData.OffhandWeaponData.Type}, " + + $"Variant: {gearsetData.OffhandWeaponData.Variant}, Stain0: {gearsetData.OffhandWeaponData.Stain0}, Stain1: {gearsetData.OffhandWeaponData.Stain1}" + + $"\nCrestBitField: {gearsetData.CrestBitField} | JobId: {gearsetData.JobId} | UNK_18: {gearsetData.UNK_18} | UNK_19: {gearsetData.UNK_19}"; + // Iterate through offsets from 20 to 60 and format the CharacterArmor data + for (int offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) + { + LegacyCharacterArmor* equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetData + offset); + int dyeOffset = (offset - 20) / sizeof(LegacyCharacterArmor) + 60; // Calculate the corresponding dye offset + byte* dyePtr = (byte*)&gearsetData + dyeOffset; + ret += $"\nEquipSlot {((EquipSlot)(dyeOffset - 60)).ToString()}:: Id: {(*equipSlotPtr).Set}, Variant: {(*equipSlotPtr).Variant}, Stain0: {(*equipSlotPtr).Stain.Id}, Stain1: {*dyePtr}"; + } + return ret; + } } diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 10f68ee..a869a09 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -329,7 +329,7 @@ public class CommandService : IDisposable, IApiService if (_stateManager.GetOrCreate(identifier, actor, out var state)) { _autoDesignApplier.ReapplyAutomation(actor, identifier, state, revert, out var forcedRedraw); - _stateManager.ReapplyState(actor, forcedRedraw, StateSource.Manual); + _stateManager.ReapplyAutomationState(actor, forcedRedraw, revert, StateSource.Manual); } } } @@ -378,7 +378,7 @@ public class CommandService : IDisposable, IApiService return true; foreach (var actor in data.Objects) - _stateManager.ReapplyState(actor, false, StateSource.Manual); + _stateManager.ReapplyState(actor, false, StateSource.Manual, true); } @@ -668,7 +668,7 @@ public class CommandService : IDisposable, IApiService if (!_objects.TryGetValue(identifier, out var actors)) { if (_stateManager.TryGetValue(identifier, out var state)) - _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks); + _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); } else { @@ -677,7 +677,7 @@ public class CommandService : IDisposable, IApiService if (_stateManager.GetOrCreate(actor.GetIdentifier(_actors), actor, out var state)) { ApplyModSettings(design, actor, applyMods); - _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks); + _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); } } } diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index b592b65..e1bd6a4 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -17,6 +17,7 @@ public class StateEditor( InternalStateEditor editor, StateApplier applier, StateChanged stateChanged, + StateUpdated stateUpdated, JobChangeState jobChange, Configuration config, ItemManager items, @@ -27,6 +28,7 @@ public class StateEditor( protected readonly InternalStateEditor Editor = editor; protected readonly StateApplier Applier = applier; protected readonly StateChanged StateChanged = stateChanged; + protected readonly StateUpdated StateUpdated = stateUpdated; protected readonly Configuration Config = config; protected readonly ItemManager Items = items; @@ -41,6 +43,7 @@ public class StateEditor( Glamourer.Log.Verbose( $"Set model id in state {state.Identifier.Incognito(null)} from {old} to {modelId}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Model, source, state, actors, null); + StateUpdated.Invoke(StateUpdateType.ModelChange, actors); } /// @@ -419,6 +422,8 @@ public class StateEditor( Glamourer.Log.Debug($"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later + if(settings.SendStateUpdate) + StateUpdated.Invoke(StateUpdateType.DesignApplied, actors); return; diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 382e488..4d10c49 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -14,6 +14,7 @@ using Penumbra.GameData.DataContainers; using Glamourer.Designs; using Penumbra.GameData.Interop; using ObjectManager = Glamourer.Interop.ObjectManager; +using Glamourer.Api.Enums; namespace Glamourer.State; @@ -34,10 +35,12 @@ public class StateListener : IDisposable private readonly PenumbraService _penumbra; private readonly EquipSlotUpdating _equipSlotUpdating; private readonly BonusSlotUpdating _bonusSlotUpdating; + private readonly GearsetDataLoaded _gearsetDataLoaded; private readonly WeaponLoading _weaponLoading; private readonly HeadGearVisibilityChanged _headGearVisibility; private readonly VisorStateChanged _visorState; private readonly WeaponVisibilityChanged _weaponVisibility; + private readonly StateUpdated _stateUpdated; private readonly AutoDesignApplier _autoDesignApplier; private readonly FunModule _funModule; private readonly HumanModelList _humans; @@ -54,11 +57,11 @@ public class StateListener : IDisposable private ActorState? _customizeState; public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorManager actors, Configuration config, - EquipSlotUpdating equipSlotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, + EquipSlotUpdating equipSlotUpdating, GearsetDataLoaded gearsetDataLoaded, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, GPoseService gPose, ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, - CrestService crestService, BonusSlotUpdating bonusSlotUpdating) + CrestService crestService, BonusSlotUpdating bonusSlotUpdating, StateUpdated stateUpdated) { _manager = manager; _items = items; @@ -66,6 +69,7 @@ public class StateListener : IDisposable _actors = actors; _config = config; _equipSlotUpdating = equipSlotUpdating; + _gearsetDataLoaded = gearsetDataLoaded; _weaponLoading = weaponLoading; _visorState = visorState; _weaponVisibility = weaponVisibility; @@ -82,6 +86,7 @@ public class StateListener : IDisposable _condition = condition; _crestService = crestService; _bonusSlotUpdating = bonusSlotUpdating; + _stateUpdated = stateUpdated; Subscribe(); } @@ -259,6 +264,22 @@ public class StateListener : IDisposable } } + private void OnGearsetDataLoaded(Model model) + { + var actor = _penumbra.GameObjectFromDrawObject(model); + if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) + return; + + // ensure actor and state are valid. + if (!actor.Identifier(_actors, out var identifier)) + return; + + _objects.Update(); + if (_objects.TryGetValue(identifier, out var actors) && actors.Valid) + _stateUpdated.Invoke(StateUpdateType.Gearset, actors); + } + + private void OnMovedEquipment((EquipSlot, uint, StainIds)[] items) { _objects.Update(); @@ -382,7 +403,7 @@ public class StateListener : IDisposable lastFistOffhand = new CharacterWeapon((PrimaryId)(weapon.Skeleton.Id + 50), weapon.Weapon, weapon.Variant, weapon.Stains); _fistOffhands[actor] = lastFistOffhand; - Glamourer.Log.Verbose($"Storing fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); + Glamourer.Log.Excessive($"Storing fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); } _funModule.ApplyFunToWeapon(actor, ref weapon, slot); @@ -765,6 +786,7 @@ public class StateListener : IDisposable _penumbra.CreatedCharacterBase += OnCreatedCharacterBase; _equipSlotUpdating.Subscribe(OnEquipSlotUpdating, EquipSlotUpdating.Priority.StateListener); _bonusSlotUpdating.Subscribe(OnBonusSlotUpdating, BonusSlotUpdating.Priority.StateListener); + _gearsetDataLoaded.Subscribe(OnGearsetDataLoaded, GearsetDataLoaded.Priority.StateListener); _movedEquipment.Subscribe(OnMovedEquipment, MovedEquipment.Priority.StateListener); _weaponLoading.Subscribe(OnWeaponLoading, WeaponLoading.Priority.StateListener); _visorState.Subscribe(OnVisorChange, VisorStateChanged.Priority.StateListener); @@ -782,6 +804,7 @@ public class StateListener : IDisposable _penumbra.CreatedCharacterBase -= OnCreatedCharacterBase; _equipSlotUpdating.Unsubscribe(OnEquipSlotUpdating); _bonusSlotUpdating.Unsubscribe(OnBonusSlotUpdating); + _gearsetDataLoaded.Unsubscribe(OnGearsetDataLoaded); _movedEquipment.Unsubscribe(OnMovedEquipment); _weaponLoading.Unsubscribe(OnWeaponLoading); _visorState.Unsubscribe(OnVisorChange); diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 736dd6e..129f8bb 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -21,6 +21,7 @@ public sealed class StateManager( ActorManager _actors, ItemManager items, StateChanged @event, + StateUpdated @event2, StateApplier applier, InternalStateEditor editor, HumanModelList _humans, @@ -30,7 +31,7 @@ public sealed class StateManager( DesignMerger merger, ModSettingApplier modApplier, GPoseService gPose) - : StateEditor(editor, applier, @event, jobChange, config, items, merger, modApplier, gPose), + : StateEditor(editor, applier, @event, @event2, jobChange, config, items, merger, modApplier, gPose), IReadOnlyDictionary { private readonly Dictionary _states = []; @@ -235,7 +236,7 @@ public sealed class StateManager( public void TurnHuman(ActorState state, StateSource source, uint key = 0) => ChangeModelId(state, 0, CustomizeArray.Default, nint.Zero, source, key); - public void ResetState(ActorState state, StateSource source, uint key = 0) + public void ResetState(ActorState state, StateSource source, uint key = 0, bool stateUpdate = false) { if (!state.Unlock(key)) return; @@ -276,6 +277,9 @@ public sealed class StateManager( Glamourer.Log.Debug( $"Reset entire state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); + // only invoke if we define this reset call as the final call in our state update. + if(stateUpdate) + StateUpdated.Invoke(StateUpdateType.Revert, actors); } public void ResetAdvancedState(ActorState state, StateSource source, uint key = 0) @@ -301,6 +305,8 @@ public sealed class StateManager( Glamourer.Log.Debug( $"Reset advanced customization and dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); + // Update that we have completed a full operation. (We can do this directly as nothing else is linked) + StateUpdated.Invoke(StateUpdateType.RevertAdvanced, actors); } public void ResetCustomize(ActorState state, StateSource source, uint key = 0) @@ -318,6 +324,8 @@ public sealed class StateManager( actors = Applier.ChangeCustomize(state, true); Glamourer.Log.Verbose( $"Reset customization state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); + // Update that we have completed a full operation. (We can do this directly as nothing else is linked) + StateUpdated.Invoke(StateUpdateType.RevertCustomize, actors); } public void ResetEquip(ActorState state, StateSource source, uint key = 0) @@ -367,6 +375,8 @@ public sealed class StateManager( Glamourer.Log.Verbose( $"Reset equipment state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); + // Update that we have completed a full operation. (We can do this directly as nothing else is linked) + StateUpdated.Invoke(StateUpdateType.RevertEquipment, actors); } public void ResetStateFixed(ActorState state, bool respectManualPalettes, uint key = 0) @@ -443,21 +453,44 @@ public sealed class StateManager( } } - public void ReapplyState(Actor actor, bool forceRedraw, StateSource source) + public void ReapplyState(Actor actor, bool forceRedraw, StateSource source, bool isUpdate = false) { if (!GetOrCreate(actor, out var state)) return; - ReapplyState(actor, state, forceRedraw, source); + ReapplyState(actor, state, forceRedraw, source, isUpdate); } - public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source) + public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source, bool isUpdate) { var data = Applier.ApplyAll(state, forceRedraw || !actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); + if(isUpdate) + StateUpdated.Invoke(StateUpdateType.Reapply, data); + } + + /// Automation variant for reapply, to fire the correct StateUpdateType once reapplied. + public void ReapplyAutomationState(Actor actor, bool forceRedraw, bool wasReset, StateSource source) + { + if (!GetOrCreate(actor, out var state)) + return; + + ReapplyAutomationState(actor, state, forceRedraw, wasReset, source); + } + + /// Automation variant for reapply, to fire the correct StateUpdateType once reapplied. + public void ReapplyAutomationState(Actor actor, ActorState state, bool forceRedraw, bool wasReset, StateSource source) + { + var data = Applier.ApplyAll(state, + forceRedraw + || !actor.Model.IsHuman + || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); + StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); + // invoke the automation update based on what reset is. + StateUpdated.Invoke(wasReset ? StateUpdateType.RevertAutomation : StateUpdateType.ReapplyAutomation, data); } public void DeleteState(ActorIdentifier identifier) From 8b609e5f0506e4d64f843631e47ecc6adcd10e90 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 17 Jan 2025 18:09:10 -0800 Subject: [PATCH 174/401] corrected comments and formatting to reflect Glamourer's main branch. --- Glamourer/Automation/AutoDesignApplier.cs | 9 ---- Glamourer/Events/GearsetDataLoaded.cs | 4 +- Glamourer/Events/StateUpdated.cs | 4 +- Glamourer/Interop/ChangeCustomizeService.cs | 3 -- Glamourer/Interop/InventoryService.cs | 38 +++++++-------- Glamourer/Interop/UpdateSlotService.cs | 51 ++++++++++----------- Glamourer/State/StateEditor.cs | 25 +++++----- Glamourer/State/StateListener.cs | 2 +- Glamourer/State/StateManager.cs | 12 ++--- 9 files changed, 64 insertions(+), 84 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index bcc907c..52956cc 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -202,17 +202,8 @@ public sealed class AutoDesignApplier : IDisposable } } - /// - /// JOB CHANGE IS CALLED UPON HERE. - /// private void OnJobChange(Actor actor, Job oldJob, Job newJob) { - unsafe - { - var drawObject = actor.AsCharacter->DrawObject; - Glamourer.Log.Information($"[AutoDesignApplier][OnJobChange] 0x{(nint)drawObject:X} changed job from {oldJob} ({oldJob.Id}) to {newJob} ({newJob.Id})."); - } - if (!_config.EnableAutoDesigns || !actor.Identifier(_actors, out var id)) return; diff --git a/Glamourer/Events/GearsetDataLoaded.cs b/Glamourer/Events/GearsetDataLoaded.cs index 47d0108..680ae3f 100644 --- a/Glamourer/Events/GearsetDataLoaded.cs +++ b/Glamourer/Events/GearsetDataLoaded.cs @@ -1,7 +1,5 @@ using OtterGui.Classes; -using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; -using Penumbra.GameData.Structs; namespace Glamourer.Events; @@ -9,7 +7,7 @@ namespace Glamourer.Events; /// Triggers when the equipped gearset finished running all of its LoadEquipment, LoadWeapon, and crest calls. /// This defines a universal endpoint of base game state application to monitor. /// -/// The model drawobject associated with the finished load (should always be ClientPlayer) +/// The model drawobject associated with the finished load (Also fired by other players on render) /// /// public sealed class GearsetDataLoaded() diff --git a/Glamourer/Events/StateUpdated.cs b/Glamourer/Events/StateUpdated.cs index 82d737f..f18a69a 100644 --- a/Glamourer/Events/StateUpdated.cs +++ b/Glamourer/Events/StateUpdated.cs @@ -9,10 +9,8 @@ namespace Glamourer.Events; /// /// Triggered when a Design is edited in any way. /// -/// Parameter is the type of the change -/// Parameter is the changed saved state. +/// Parameter is the operation that finished updating the saved state. /// Parameter is the existing actors using this saved state. -/// Parameter is any additional data depending on the type of change. /// /// public sealed class StateUpdated() diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index 10e3a12..495d69c 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -64,7 +64,6 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 _changeCustomizeHook; - // manual invoke by calling the detours _original call to `execute to` instead of `listen to`. public bool UpdateCustomize(Model model, CustomizeArray customize) { if (!model.IsHuman) @@ -79,7 +78,6 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 UpdateCustomize(actor.Model, customize); - // detoured method. private bool ChangeCustomizeDetour(Human* human, byte* data, byte skipEquipment) { if (!InUpdate.InMethod) @@ -90,7 +88,6 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2 action, Post.Priority priority) => _postEvent.Subscribe(action, priority); diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 743bea1..33ba5cf 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -5,7 +5,6 @@ using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using Glamourer.Events; using OtterGui.Services; -using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using Penumbra.String; @@ -14,10 +13,6 @@ namespace Glamourer.Interop; public sealed unsafe class InventoryService : IDisposable, IRequiredService { - private readonly MovedEquipment _movedItemsEvent; - private readonly EquippedGearset _gearsetEvent; - private readonly List<(EquipSlot, uint, StainIds)> _itemList = new(12); - // Called by EquipGearset, but returns a pointer instead of an int. // This is the internal function processed by all sources of Equipping a gearset, // such as hotbar gearset application and command gearset application @@ -27,10 +22,16 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] private readonly Hook _equipGearsetInternalHook = null!; + // The following above is currently pending for an accepted PR in FFXIVCLientStructs. + // Once accepted, remove everything above this comment and replace EquipGearset with EquipGearsetInternal. + + private readonly MovedEquipment _movedItemsEvent; + private readonly EquippedGearset _gearsetEvent; + private readonly List<(EquipSlot, uint, StainIds)> _itemList = new(12); public InventoryService(MovedEquipment movedItemsEvent, IGameInteropProvider interop, EquippedGearset gearsetEvent) { _movedItemsEvent = movedItemsEvent; - _gearsetEvent = gearsetEvent; + _gearsetEvent = gearsetEvent; _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); _equipGearsetHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour); @@ -58,7 +59,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService var ret = _equipGearsetInternalHook.Original(module, gearsetId, glamourPlateId); var set = module->GetGearset((int)gearsetId); _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), (int)gearsetId, prior, glamourPlateId, set->ClassJob); - Glamourer.Log.Verbose($"[InventoryService] [EquipInternal] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); + Glamourer.Log.Verbose($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); if (ret == 0) { var entry = module->GetGearset((int)gearsetId); @@ -131,9 +132,10 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService return ret; } + // Remove once internal is added. This no longer serves any purpose. private int EquipGearSetDetour(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId) { - var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); + var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); Glamourer.Log.Excessive($"[InventoryService] (old) Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); return ret; } @@ -216,18 +218,18 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService private static EquipSlot GetSlot(uint slot) => slot switch { - 0 => EquipSlot.MainHand, - 1 => EquipSlot.OffHand, - 2 => EquipSlot.Head, - 3 => EquipSlot.Body, - 4 => EquipSlot.Hands, - 6 => EquipSlot.Legs, - 7 => EquipSlot.Feet, - 8 => EquipSlot.Ears, - 9 => EquipSlot.Neck, + 0 => EquipSlot.MainHand, + 1 => EquipSlot.OffHand, + 2 => EquipSlot.Head, + 3 => EquipSlot.Body, + 4 => EquipSlot.Hands, + 6 => EquipSlot.Legs, + 7 => EquipSlot.Feet, + 8 => EquipSlot.Ears, + 9 => EquipSlot.Neck, 10 => EquipSlot.Wrists, 11 => EquipSlot.RFinger, 12 => EquipSlot.LFinger, - _ => EquipSlot.Unknown, + _ => EquipSlot.Unknown, }; } diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 7e5cf59..9ee8d8f 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -8,12 +8,11 @@ using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; + namespace Glamourer.Interop; -/// -/// This struct is the struct that loadallequipment passes in as its gearsetData container. -/// -[StructLayout(LayoutKind.Explicit)] // Size of 70 bytes maybe? +// This struct is implemented into a PR for FFXIVClientStructs. Once merged, remove this struct and reference the data in ClientStructs instead. +[StructLayout(LayoutKind.Explicit)] public readonly struct GearsetItemDataStruct { // Stores the weapon data. Includes both dyes in the data. @@ -54,30 +53,15 @@ public readonly struct GearsetItemDataStruct public unsafe class UpdateSlotService : IDisposable { + // This function is what calls the weapon/equipment/crest loads, which call FlagSlotForUpdate if different. (MetaData not included) + public const string LoadGearsetDataSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; + private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData); + // The above can be removed after the FFXIVClientStruct Merge is made! + public readonly EquipSlotUpdating EquipSlotUpdatingEvent; public readonly BonusSlotUpdating BonusSlotUpdatingEvent; public readonly GearsetDataLoaded GearsetDataLoadedEvent; private readonly DictBonusItems _bonusItems; - - // This function is what calls the weapon/equipment/crest loads, which call FlagSlotForUpdate if different. (MetaData not included) - public const string LoadGearsetDataSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; - private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData); - private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData) - { - // Let the gearset data process all of its loads and slot flag update calls first. - var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); - // Ensure that the owner of the drawdata container is a character base. - Model ownerDrawObject = drawDataContainer->OwnerObject->DrawObject; - if (!ownerDrawObject.IsCharacterBase) - return ret; - - // invoke the changed event for the state listener and return. - Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{ownerDrawObject.Address:X} Finished Applying its GameState!"); - // Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); - GearsetDataLoadedEvent.Invoke(drawDataContainer->OwnerObject->DrawObject); - return ret; - } - public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, GearsetDataLoaded gearsetDataLoaded, IGameInteropProvider interop, DictBonusItems bonusItems) { @@ -150,7 +134,7 @@ public unsafe class UpdateSlotService : IDisposable private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToEquipSlot(); + var slot = slotIdx.ToEquipSlot(); var returnValue = ulong.MaxValue; EquipSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); @@ -160,7 +144,7 @@ public unsafe class UpdateSlotService : IDisposable private ulong FlagBonusSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToBonusSlot(); + var slot = slotIdx.ToBonusSlot(); var returnValue = ulong.MaxValue; BonusSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); @@ -173,6 +157,20 @@ public unsafe class UpdateSlotService : IDisposable Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Invoked by Glamourer on 0x{drawObject.Address:X} on {slot} with itemdata {armor}."); return _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); } + private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData) + { + // Let the gearset data process all of its loads and slot flag update calls first. + var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); + Model ownerDrawObject = drawDataContainer->OwnerObject->DrawObject; + if (!ownerDrawObject.IsCharacterBase) + return ret; + + // invoke the changed event for the state listener and return. + Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{ownerDrawObject.Address:X} Finished Applying its GameState!"); + // Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); + GearsetDataLoadedEvent.Invoke(drawDataContainer->OwnerObject->DrawObject); + return ret; + } // If you ever care to debug this, here is a formatted string output of this new gearsetDataPacket struct. private string FormatGearsetItemDataStruct(GearsetItemDataStruct gearsetData) @@ -183,7 +181,6 @@ public unsafe class UpdateSlotService : IDisposable $"\nOffhandWeaponData: Id: {gearsetData.OffhandWeaponData.Id}, Type: {gearsetData.OffhandWeaponData.Type}, " + $"Variant: {gearsetData.OffhandWeaponData.Variant}, Stain0: {gearsetData.OffhandWeaponData.Stain0}, Stain1: {gearsetData.OffhandWeaponData.Stain1}" + $"\nCrestBitField: {gearsetData.CrestBitField} | JobId: {gearsetData.JobId} | UNK_18: {gearsetData.UNK_18} | UNK_19: {gearsetData.UNK_19}"; - // Iterate through offsets from 20 to 60 and format the CharacterArmor data for (int offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) { LegacyCharacterArmor* equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetData + offset); diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index e1bd6a4..891c61d 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -54,7 +54,7 @@ public class StateEditor( return; var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); - Glamourer.Log.Information( + Glamourer.Log.Verbose( $"Set {idx.ToDefaultName()} customizations in state {state.Identifier.Incognito(null)} from {old.Value} to {value.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Customize, settings.Source, state, actors, new CustomizeTransaction(idx, old, value)); } @@ -67,7 +67,7 @@ public class StateEditor( return; var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); - Glamourer.Log.Information( + Glamourer.Log.Verbose( $"Set {applied} customizations in state {state.Identifier.Incognito(null)} from {old} to {customizeInput}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.EntireCustomize, settings.Source, state, actors, new EntireCustomizeTransaction(applied, old, customizeInput)); @@ -78,10 +78,7 @@ public class StateEditor( { var state = (ActorState)data; if (!Editor.ChangeItem(state, slot, item, settings.Source, out var old, settings.Key)) - { - Glamourer.Log.Information("Not Setting State or invoking, Editor requested us not to change it!"); return; - } var type = slot.ToIndex() < 10 ? StateChangeType.Equip : StateChangeType.Weapon; var actors = type is StateChangeType.Equip @@ -92,8 +89,8 @@ public class StateEditor( if (slot is EquipSlot.MainHand) ApplyMainhandPeriphery(state, item, null, settings); - Glamourer.Log.Debug( - $"[ChangeItem] Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}). [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Verbose( + $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}). [Affecting {actors.ToLazyString("nothing")}.]"); if (type is StateChangeType.Equip) { @@ -122,8 +119,8 @@ public class StateEditor( return; var actors = Applier.ChangeBonusItem(state, slot, settings.Source.RequiresChange()); - Glamourer.Log.Debug( - $"[ChangeBonus] Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.Id}) to {item.Name} ({item.Id}). [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Verbose( + $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.Id}) to {item.Name} ({item.Id}). [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.BonusItem, settings.Source, state, actors, new BonusItemTransaction(slot, old, item)); } @@ -155,8 +152,8 @@ public class StateEditor( if (slot is EquipSlot.MainHand) ApplyMainhandPeriphery(state, item, stains, settings); - Glamourer.Log.Debug( - $"[ChangeEquip] Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStains} to {stains!.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Verbose( + $"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item!.Value.Name} ({item.Value.ItemId}) and its stain from {oldStains} to {stains!.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); if (type is StateChangeType.Equip) { StateChanged.Invoke(type, settings.Source, state, actors, new EquipTransaction(slot, old, item!.Value)); @@ -187,7 +184,7 @@ public class StateEditor( return; var actors = Applier.ChangeStain(state, slot, settings.Source.RequiresChange()); - Glamourer.Log.Debug( + Glamourer.Log.Verbose( $"Set {slot.ToName()} stain in state {state.Identifier.Incognito(null)} from {old} to {stains}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Stains, settings.Source, state, actors, new StainTransaction(slot, old, stains)); } @@ -419,8 +416,8 @@ public class StateEditor( var actors = settings.Source.RequiresChange() ? Applier.ApplyAll(state, requiresRedraw, false) : ActorData.Invalid; - - Glamourer.Log.Debug($"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); + + Glamourer.Log.Verbose($"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later if(settings.SendStateUpdate) StateUpdated.Invoke(StateUpdateType.DesignApplied, actors); diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 4d10c49..d312815 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -13,8 +13,8 @@ using Glamourer.GameData; using Penumbra.GameData.DataContainers; using Glamourer.Designs; using Penumbra.GameData.Interop; -using ObjectManager = Glamourer.Interop.ObjectManager; using Glamourer.Api.Enums; +using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.State; diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 129f8bb..0348148 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -274,7 +274,7 @@ public sealed class StateManager( if (source is not StateSource.Game) actors = Applier.ApplyAll(state, redraw, true); - Glamourer.Log.Debug( + Glamourer.Log.Verbose( $"Reset entire state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); // only invoke if we define this reset call as the final call in our state update. @@ -302,7 +302,7 @@ public sealed class StateManager( state.Materials.Clear(); - Glamourer.Log.Debug( + Glamourer.Log.Verbose( $"Reset advanced customization and dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) @@ -453,22 +453,22 @@ public sealed class StateManager( } } - public void ReapplyState(Actor actor, bool forceRedraw, StateSource source, bool isUpdate = false) + public void ReapplyState(Actor actor, bool forceRedraw, StateSource source, bool stateUpdate = false) { if (!GetOrCreate(actor, out var state)) return; - ReapplyState(actor, state, forceRedraw, source, isUpdate); + ReapplyState(actor, state, forceRedraw, source, stateUpdate); } - public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source, bool isUpdate) + public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source, bool stateUpdate) { var data = Applier.ApplyAll(state, forceRedraw || !actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); - if(isUpdate) + if(stateUpdate) StateUpdated.Invoke(StateUpdateType.Reapply, data); } From 9c57935a872dc98fa0ddfdcc81d891dada3b0054 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 17 Jan 2025 18:52:16 -0800 Subject: [PATCH 175/401] removed unessisary usings and corrected gearsetDataLoaded stateListener ref. --- Glamourer/Automation/AutoDesignApplier.cs | 1 - Glamourer/Events/GearsetDataLoaded.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 52956cc..660acf4 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -1,5 +1,4 @@ using Dalamud.Plugin.Services; -using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using Glamourer.Designs; using Glamourer.Designs.Links; diff --git a/Glamourer/Events/GearsetDataLoaded.cs b/Glamourer/Events/GearsetDataLoaded.cs index 680ae3f..dd12bc1 100644 --- a/Glamourer/Events/GearsetDataLoaded.cs +++ b/Glamourer/Events/GearsetDataLoaded.cs @@ -15,7 +15,7 @@ public sealed class GearsetDataLoaded() { public enum Priority { - /// + /// StateListener = 0, } } \ No newline at end of file From 1d185e9bfe8f9badb6b58c62f6cfda49bcefba8a Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Sun, 19 Jan 2025 09:07:43 -0800 Subject: [PATCH 176/401] Added Proper Unsubsribe from OnStateUpdated. Ensures that ReapplyAutomation is called from OnAutomationChange when change occurs. Reformatted temporary Signature locations and comments to align with the structure of the respective classes. --- Glamourer/Api/StateApi.cs | 1 + Glamourer/Automation/AutoDesignApplier.cs | 4 +-- Glamourer/Interop/InventoryService.cs | 35 ++++++------------ Glamourer/Interop/UpdateSlotService.cs | 44 +++++++++++++---------- 4 files changed, 39 insertions(+), 45 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 248e294..34f4ad9 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -54,6 +54,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public void Dispose() { _stateChanged.Unsubscribe(OnStateChanged); + _stateUpdated.Unsubscribe(OnStateUpdated); _gPose.Unsubscribe(OnGPoseChange); } diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 660acf4..1655c15 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -163,7 +163,7 @@ public sealed class AutoDesignApplier : IDisposable { Reduce(data.Objects[0], state, newSet, _config.RespectManualOnAutomationUpdate, false, true, out var forcedRedraw); foreach (var actor in data.Objects) - _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); + _state.ReapplyAutomationState(actor, forcedRedraw, false, StateSource.Fixed); } } else if (_objects.TryGetValueAllWorld(id, out data) || _objects.TryGetValueNonOwned(id, out data)) @@ -174,7 +174,7 @@ public sealed class AutoDesignApplier : IDisposable if (_state.GetOrCreate(specificId, actor, out var state)) { Reduce(actor, state, newSet, _config.RespectManualOnAutomationUpdate, false, true, out var forcedRedraw); - _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); + _state.ReapplyAutomationState(actor, forcedRedraw, false, StateSource.Fixed); } } } diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 33ba5cf..6c4a223 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -13,18 +13,6 @@ namespace Glamourer.Interop; public sealed unsafe class InventoryService : IDisposable, IRequiredService { - // Called by EquipGearset, but returns a pointer instead of an int. - // This is the internal function processed by all sources of Equipping a gearset, - // such as hotbar gearset application and command gearset application - public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; - private delegate nint ChangeGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); - - [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] - private readonly Hook _equipGearsetInternalHook = null!; - - // The following above is currently pending for an accepted PR in FFXIVCLientStructs. - // Once accepted, remove everything above this comment and replace EquipGearset with EquipGearsetInternal. - private readonly MovedEquipment _movedItemsEvent; private readonly EquippedGearset _gearsetEvent; private readonly List<(EquipSlot, uint, StainIds)> _itemList = new(12); @@ -34,24 +22,29 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService _gearsetEvent = gearsetEvent; _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); - _equipGearsetHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour); + // This can be uncommented after ClientStructs Updates with EquipGearsetInternal after merged PR. (See comment below) + //_equipGearsetInternalHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearsetInternal, EquipGearSetInternalDetour); + + // Can be removed after ClientStructs Update since this is only needed for current EquipGearsetInternal [Signature] interop.InitializeFromAttributes(this); _moveItemHook.Enable(); - _equipGearsetHook.Enable(); _equipGearsetInternalHook.Enable(); } public void Dispose() { _moveItemHook.Dispose(); - _equipGearsetHook.Dispose(); _equipGearsetInternalHook.Dispose(); } - private delegate int EquipGearsetDelegate(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId); + // This is the internal function processed by all sources of Equipping a gearset, such as hotbar gearset application and command gearset application. + // Currently is pending to ClientStructs for integration. See: https://github.com/aers/FFXIVClientStructs/pull/1277 + public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; + private delegate nint EquipGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); - private readonly Hook _equipGearsetHook; + [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] + private readonly Hook _equipGearsetInternalHook = null!; private nint EquipGearSetInternalDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) { @@ -132,14 +125,6 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService return ret; } - // Remove once internal is added. This no longer serves any purpose. - private int EquipGearSetDetour(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId) - { - var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); - Glamourer.Log.Excessive($"[InventoryService] (old) Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); - return ret; - } - private static uint FixId(uint itemId) => itemId % 50000; diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 9ee8d8f..5f6e9cb 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -11,9 +11,9 @@ using Penumbra.GameData.Structs; namespace Glamourer.Interop; -// This struct is implemented into a PR for FFXIVClientStructs. Once merged, remove this struct and reference the data in ClientStructs instead. +// Can be removed once merged with client structs and referenced directly. See: https://github.com/aers/FFXIVClientStructs/pull/1277/files [StructLayout(LayoutKind.Explicit)] -public readonly struct GearsetItemDataStruct +public readonly struct GearsetDataStruct { // Stores the weapon data. Includes both dyes in the data. [FieldOffset(0)] public readonly WeaponModelId MainhandWeaponData; @@ -53,11 +53,6 @@ public readonly struct GearsetItemDataStruct public unsafe class UpdateSlotService : IDisposable { - // This function is what calls the weapon/equipment/crest loads, which call FlagSlotForUpdate if different. (MetaData not included) - public const string LoadGearsetDataSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; - private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData); - // The above can be removed after the FFXIVClientStruct Merge is made! - public readonly EquipSlotUpdating EquipSlotUpdatingEvent; public readonly BonusSlotUpdating BonusSlotUpdatingEvent; public readonly GearsetDataLoaded GearsetDataLoadedEvent; @@ -68,9 +63,12 @@ public unsafe class UpdateSlotService : IDisposable EquipSlotUpdatingEvent = equipSlotUpdating; BonusSlotUpdatingEvent = bonusSlotUpdating; GearsetDataLoadedEvent = gearsetDataLoaded; - _bonusItems = bonusItems; + + // Usable after the merge with client structs. + //_loadGearsetDataHook = interop.HookFromAddress((nint)DrawDataContainer.MemberFunctionPointers.LoadGearsetData, LoadGearsetDataDetour); interop.InitializeFromAttributes(this); + _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); _loadGearsetDataHook.Enable(); @@ -129,6 +127,19 @@ public unsafe class UpdateSlotService : IDisposable [Signature(Sigs.FlagBonusSlotForUpdate, DetourName = nameof(FlagBonusSlotForUpdateDetour))] private readonly Hook _flagBonusSlotForUpdateHook = null!; + // This signature is what calls the weapon/equipment/crest load functions in the drawData container inherited from a human/characterBase. + // + // Contrary to assumption, this is not frequently fired when any slot changes, and is instead only called when another player + // initially loads, or when the client player changes gearsets. (Does not fire when another player or self is redrawn) + // + // This functions purpose is to iterate all Equipment/Weapon/Crest data on gearset change / initial player load, and determine which slots need to fire FlagSlotForUpdate. + // + // Because Glamourer processes GameState changes by detouring this method, this means by returning original after detour, any logic performed after will occur + // AFTER Glamourer finishes applying all changes to the game State, providing a gearset endpoint. (MetaData not included) + // Currently pending a merge to clientStructs, after which it can be removed, along with the explicit struct. See: https://github.com/aers/FFXIVClientStructs/pull/1277/files + public const string LoadGearsetDataSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; + private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, GearsetDataStruct* gearsetData); + [Signature(LoadGearsetDataSig, DetourName = nameof(LoadGearsetDataDetour))] private readonly Hook _loadGearsetDataHook = null!; @@ -157,23 +168,20 @@ public unsafe class UpdateSlotService : IDisposable Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Invoked by Glamourer on 0x{drawObject.Address:X} on {slot} with itemdata {armor}."); return _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); } - private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, GearsetItemDataStruct* gearsetData) + private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, GearsetDataStruct* gearsetData) { // Let the gearset data process all of its loads and slot flag update calls first. var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); - Model ownerDrawObject = drawDataContainer->OwnerObject->DrawObject; - if (!ownerDrawObject.IsCharacterBase) - return ret; - - // invoke the changed event for the state listener and return. - Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{ownerDrawObject.Address:X} Finished Applying its GameState!"); + Model drawObject = drawDataContainer->OwnerObject->DrawObject; + Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{drawObject.Address:X} Finished Applying its GameState!"); + GearsetDataLoadedEvent.Invoke(drawObject); + // Can use for debugging, if desired. // Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); - GearsetDataLoadedEvent.Invoke(drawDataContainer->OwnerObject->DrawObject); return ret; } - // If you ever care to debug this, here is a formatted string output of this new gearsetDataPacket struct. - private string FormatGearsetItemDataStruct(GearsetItemDataStruct gearsetData) + // If you ever care to debug this, here is a formatted string output of this new gearsetData struct. + private string FormatGearsetItemDataStruct(GearsetDataStruct gearsetData) { string ret = $"\nMainhandWeaponData: Id: {gearsetData.MainhandWeaponData.Id}, Type: {gearsetData.MainhandWeaponData.Type}, " + From 1cd8e5fb7ec29097aaa2e413fce01a8aadb7a0cf Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Sun, 19 Jan 2025 09:35:10 -0800 Subject: [PATCH 177/401] Corrected comments on StateApi for PR --- Glamourer/Api/StateApi.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 34f4ad9..cb7fe51 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -340,9 +340,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { - // Remove this comment before creating PR. - Glamourer.Log.Verbose($"[OnStateChanged] Sending out OnStateChanged with type {type}."); - + // Glamourer.Log.Verbose($"[OnStateChanged] Sending out OnStateChanged with type {type}."); if (StateChanged != null) foreach (var actor in actors.Objects) StateChanged.Invoke(actor.Address); @@ -354,13 +352,9 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnStateUpdated(StateUpdateType type, ActorData actors) { + // Glamourer.Log.Verbose($"[OnStateUpdated] Sending out OnStateUpdated with type {type}."); if (StateUpdated != null) foreach (var actor in actors.Objects) - { - // Remove these before creating PR - Glamourer.Log.Information($"[ENDPOINT DEBUGGING] 0x{actor.Address:X} had update of type {type}."); - Glamourer.Log.Information("--------------------------------------------------------------"); StateUpdated.Invoke(actor.Address, type); - } } } From ebdfd3f8bc56dcd7a12f4cb3e9f84164e8dd946e Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Sun, 19 Jan 2025 09:50:34 -0800 Subject: [PATCH 178/401] Correct spacing and formatting further to align with main Glamourer branch preferences. --- Glamourer/Interop/InventoryService.cs | 71 ++++++++++---------- Glamourer/Interop/UpdateSlotService.cs | 91 +++++++++++++------------- Glamourer/State/StateEditor.cs | 5 +- 3 files changed, 83 insertions(+), 84 deletions(-) diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 6c4a223..f0ed6b5 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -13,9 +13,10 @@ namespace Glamourer.Interop; public sealed unsafe class InventoryService : IDisposable, IRequiredService { - private readonly MovedEquipment _movedItemsEvent; - private readonly EquippedGearset _gearsetEvent; + private readonly MovedEquipment _movedItemsEvent; + private readonly EquippedGearset _gearsetEvent; private readonly List<(EquipSlot, uint, StainIds)> _itemList = new(12); + public InventoryService(MovedEquipment movedItemsEvent, IGameInteropProvider interop, EquippedGearset gearsetEvent) { _movedItemsEvent = movedItemsEvent; @@ -80,18 +81,18 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService } var plate = MirageManager.Instance()->GlamourPlates[glamourPlateId - 1]; - Add(EquipSlot.MainHand, plate.ItemIds[0], StainIds.FromGlamourPlate(plate, 0), ref entry->Items[0]); - Add(EquipSlot.OffHand, plate.ItemIds[1], StainIds.FromGlamourPlate(plate, 1), ref entry->Items[1]); - Add(EquipSlot.Head, plate.ItemIds[2], StainIds.FromGlamourPlate(plate, 2), ref entry->Items[2]); - Add(EquipSlot.Body, plate.ItemIds[3], StainIds.FromGlamourPlate(plate, 3), ref entry->Items[3]); - Add(EquipSlot.Hands, plate.ItemIds[4], StainIds.FromGlamourPlate(plate, 4), ref entry->Items[5]); - Add(EquipSlot.Legs, plate.ItemIds[5], StainIds.FromGlamourPlate(plate, 5), ref entry->Items[6]); - Add(EquipSlot.Feet, plate.ItemIds[6], StainIds.FromGlamourPlate(plate, 6), ref entry->Items[7]); - Add(EquipSlot.Ears, plate.ItemIds[7], StainIds.FromGlamourPlate(plate, 7), ref entry->Items[8]); - Add(EquipSlot.Neck, plate.ItemIds[8], StainIds.FromGlamourPlate(plate, 8), ref entry->Items[9]); - Add(EquipSlot.Wrists, plate.ItemIds[9], StainIds.FromGlamourPlate(plate, 9), ref entry->Items[10]); - Add(EquipSlot.RFinger, plate.ItemIds[10], StainIds.FromGlamourPlate(plate, 10), ref entry->Items[11]); - Add(EquipSlot.LFinger, plate.ItemIds[11], StainIds.FromGlamourPlate(plate, 11), ref entry->Items[12]); + Add(EquipSlot.MainHand, plate.ItemIds[0], StainIds.FromGlamourPlate(plate, 0), ref entry->Items[0]); + Add(EquipSlot.OffHand, plate.ItemIds[1], StainIds.FromGlamourPlate(plate, 1), ref entry->Items[1]); + Add(EquipSlot.Head, plate.ItemIds[2], StainIds.FromGlamourPlate(plate, 2), ref entry->Items[2]); + Add(EquipSlot.Body, plate.ItemIds[3], StainIds.FromGlamourPlate(plate, 3), ref entry->Items[3]); + Add(EquipSlot.Hands, plate.ItemIds[4], StainIds.FromGlamourPlate(plate, 4), ref entry->Items[5]); + Add(EquipSlot.Legs, plate.ItemIds[5], StainIds.FromGlamourPlate(plate, 5), ref entry->Items[6]); + Add(EquipSlot.Feet, plate.ItemIds[6], StainIds.FromGlamourPlate(plate, 6), ref entry->Items[7]); + Add(EquipSlot.Ears, plate.ItemIds[7], StainIds.FromGlamourPlate(plate, 7), ref entry->Items[8]); + Add(EquipSlot.Neck, plate.ItemIds[8], StainIds.FromGlamourPlate(plate, 8), ref entry->Items[9]); + Add(EquipSlot.Wrists, plate.ItemIds[9], StainIds.FromGlamourPlate(plate, 9), ref entry->Items[10]); + Add(EquipSlot.RFinger, plate.ItemIds[10], StainIds.FromGlamourPlate(plate, 10), ref entry->Items[11]); + Add(EquipSlot.LFinger, plate.ItemIds[11], StainIds.FromGlamourPlate(plate, 11), ref entry->Items[12]); } else { @@ -106,17 +107,17 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService } Add(EquipSlot.MainHand, ref entry->Items[0]); - Add(EquipSlot.OffHand, ref entry->Items[1]); - Add(EquipSlot.Head, ref entry->Items[2]); - Add(EquipSlot.Body, ref entry->Items[3]); - Add(EquipSlot.Hands, ref entry->Items[5]); - Add(EquipSlot.Legs, ref entry->Items[6]); - Add(EquipSlot.Feet, ref entry->Items[7]); - Add(EquipSlot.Ears, ref entry->Items[8]); - Add(EquipSlot.Neck, ref entry->Items[9]); - Add(EquipSlot.Wrists, ref entry->Items[10]); - Add(EquipSlot.RFinger, ref entry->Items[11]); - Add(EquipSlot.LFinger, ref entry->Items[12]); + Add(EquipSlot.OffHand, ref entry->Items[1]); + Add(EquipSlot.Head, ref entry->Items[2]); + Add(EquipSlot.Body, ref entry->Items[3]); + Add(EquipSlot.Hands, ref entry->Items[5]); + Add(EquipSlot.Legs, ref entry->Items[6]); + Add(EquipSlot.Feet, ref entry->Items[7]); + Add(EquipSlot.Ears, ref entry->Items[8]); + Add(EquipSlot.Neck, ref entry->Items[9]); + Add(EquipSlot.Wrists, ref entry->Items[10]); + Add(EquipSlot.RFinger, ref entry->Items[11]); + Add(EquipSlot.LFinger, ref entry->Items[12]); } _movedItemsEvent.Invoke(_itemList.ToArray()); @@ -203,18 +204,18 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService private static EquipSlot GetSlot(uint slot) => slot switch { - 0 => EquipSlot.MainHand, - 1 => EquipSlot.OffHand, - 2 => EquipSlot.Head, - 3 => EquipSlot.Body, - 4 => EquipSlot.Hands, - 6 => EquipSlot.Legs, - 7 => EquipSlot.Feet, - 8 => EquipSlot.Ears, - 9 => EquipSlot.Neck, + 0 => EquipSlot.MainHand, + 1 => EquipSlot.OffHand, + 2 => EquipSlot.Head, + 3 => EquipSlot.Body, + 4 => EquipSlot.Hands, + 6 => EquipSlot.Legs, + 7 => EquipSlot.Feet, + 8 => EquipSlot.Ears, + 9 => EquipSlot.Neck, 10 => EquipSlot.Wrists, 11 => EquipSlot.RFinger, 12 => EquipSlot.LFinger, - _ => EquipSlot.Unknown, + _ => EquipSlot.Unknown, }; } diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 5f6e9cb..e453c6e 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -11,46 +11,6 @@ using Penumbra.GameData.Structs; namespace Glamourer.Interop; -// Can be removed once merged with client structs and referenced directly. See: https://github.com/aers/FFXIVClientStructs/pull/1277/files -[StructLayout(LayoutKind.Explicit)] -public readonly struct GearsetDataStruct -{ - // Stores the weapon data. Includes both dyes in the data. - [FieldOffset(0)] public readonly WeaponModelId MainhandWeaponData; - [FieldOffset(8)] public readonly WeaponModelId OffhandWeaponData; - - [FieldOffset(16)] public readonly byte CrestBitField; // A Bitfield:: ShieldCrest == 1, HeadCrest == 2, Chest Crest == 4 - [FieldOffset(17)] public readonly byte JobId; // Job ID associated with the gearset change. - - // Flicks from 0 to 127 (anywhere inbetween), have yet to associate what it is linked to. Remains the same when flicking between gearsets of the same job. - [FieldOffset(18)] public readonly byte UNK_18; - [FieldOffset(19)] public readonly byte UNK_19; // I have never seen this be anything other than 0. - - // Legacy helmet equip slot armor for a character. - [FieldOffset(20)] public readonly LegacyCharacterArmor HeadSlotArmor; - [FieldOffset(24)] public readonly LegacyCharacterArmor TopSlotArmor; - [FieldOffset(28)] public readonly LegacyCharacterArmor ArmsSlotArmor; - [FieldOffset(32)] public readonly LegacyCharacterArmor LegsSlotArmor; - [FieldOffset(26)] public readonly LegacyCharacterArmor FeetSlotArmor; - [FieldOffset(40)] public readonly LegacyCharacterArmor EarSlotArmor; - [FieldOffset(44)] public readonly LegacyCharacterArmor NeckSlotArmor; - [FieldOffset(48)] public readonly LegacyCharacterArmor WristSlotArmor; - [FieldOffset(52)] public readonly LegacyCharacterArmor RFingerSlotArmor; - [FieldOffset(56)] public readonly LegacyCharacterArmor LFingerSlotArmor; - - // Byte array of all slot's secondary dyes. - [FieldOffset(60)] public readonly byte HeadSlotSecondaryDye; - [FieldOffset(61)] public readonly byte TopSlotSecondaryDye; - [FieldOffset(62)] public readonly byte ArmsSlotSecondaryDye; - [FieldOffset(63)] public readonly byte LegsSlotSecondaryDye; - [FieldOffset(64)] public readonly byte FeetSlotSecondaryDye; - [FieldOffset(65)] public readonly byte EarSlotSecondaryDye; - [FieldOffset(66)] public readonly byte NeckSlotSecondaryDye; - [FieldOffset(67)] public readonly byte WristSlotSecondaryDye; - [FieldOffset(68)] public readonly byte RFingerSlotSecondaryDye; - [FieldOffset(69)] public readonly byte LFingerSlotSecondaryDye; -} - public unsafe class UpdateSlotService : IDisposable { public readonly EquipSlotUpdating EquipSlotUpdatingEvent; @@ -145,22 +105,20 @@ public unsafe class UpdateSlotService : IDisposable private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToEquipSlot(); + var slot = slotIdx.ToEquipSlot(); var returnValue = ulong.MaxValue; EquipSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); - returnValue = returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; - return returnValue; + return returnValue == ulong.MaxValue ? _flagSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; } private ulong FlagBonusSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToBonusSlot(); + var slot = slotIdx.ToBonusSlot(); var returnValue = ulong.MaxValue; BonusSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); - returnValue = returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; - return returnValue; + return returnValue == ulong.MaxValue ? _flagBonusSlotForUpdateHook.Original(drawObject, slotIdx, data) : returnValue; } private ulong FlagSlotForUpdateInterop(Model drawObject, EquipSlot slot, CharacterArmor armor) @@ -175,7 +133,6 @@ public unsafe class UpdateSlotService : IDisposable Model drawObject = drawDataContainer->OwnerObject->DrawObject; Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{drawObject.Address:X} Finished Applying its GameState!"); GearsetDataLoadedEvent.Invoke(drawObject); - // Can use for debugging, if desired. // Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); return ret; } @@ -199,3 +156,43 @@ public unsafe class UpdateSlotService : IDisposable return ret; } } + +// Can be removed once merged with client structs and referenced directly. See: https://github.com/aers/FFXIVClientStructs/pull/1277/files +[StructLayout(LayoutKind.Explicit)] +public readonly struct GearsetDataStruct +{ + // Stores the weapon data. Includes both dyes in the data. + [FieldOffset(0)] public readonly WeaponModelId MainhandWeaponData; + [FieldOffset(8)] public readonly WeaponModelId OffhandWeaponData; + + [FieldOffset(16)] public readonly byte CrestBitField; // A Bitfield:: ShieldCrest == 1, HeadCrest == 2, Chest Crest == 4 + [FieldOffset(17)] public readonly byte JobId; // Job ID associated with the gearset change. + + // Flicks from 0 to 127 (anywhere inbetween), have yet to associate what it is linked to. Remains the same when flicking between gearsets of the same job. + [FieldOffset(18)] public readonly byte UNK_18; + [FieldOffset(19)] public readonly byte UNK_19; // I have never seen this be anything other than 0. + + // Legacy helmet equip slot armor for a character. + [FieldOffset(20)] public readonly LegacyCharacterArmor HeadSlotArmor; + [FieldOffset(24)] public readonly LegacyCharacterArmor TopSlotArmor; + [FieldOffset(28)] public readonly LegacyCharacterArmor ArmsSlotArmor; + [FieldOffset(32)] public readonly LegacyCharacterArmor LegsSlotArmor; + [FieldOffset(26)] public readonly LegacyCharacterArmor FeetSlotArmor; + [FieldOffset(40)] public readonly LegacyCharacterArmor EarSlotArmor; + [FieldOffset(44)] public readonly LegacyCharacterArmor NeckSlotArmor; + [FieldOffset(48)] public readonly LegacyCharacterArmor WristSlotArmor; + [FieldOffset(52)] public readonly LegacyCharacterArmor RFingerSlotArmor; + [FieldOffset(56)] public readonly LegacyCharacterArmor LFingerSlotArmor; + + // Byte array of all slot's secondary dyes. + [FieldOffset(60)] public readonly byte HeadSlotSecondaryDye; + [FieldOffset(61)] public readonly byte TopSlotSecondaryDye; + [FieldOffset(62)] public readonly byte ArmsSlotSecondaryDye; + [FieldOffset(63)] public readonly byte LegsSlotSecondaryDye; + [FieldOffset(64)] public readonly byte FeetSlotSecondaryDye; + [FieldOffset(65)] public readonly byte EarSlotSecondaryDye; + [FieldOffset(66)] public readonly byte NeckSlotSecondaryDye; + [FieldOffset(67)] public readonly byte WristSlotSecondaryDye; + [FieldOffset(68)] public readonly byte RFingerSlotSecondaryDye; + [FieldOffset(69)] public readonly byte LFingerSlotSecondaryDye; +} diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 891c61d..b122352 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -253,7 +253,7 @@ public class StateEditor( return; var actors = Applier.ChangeMetaState(state, index, settings.Source.RequiresChange()); - Glamourer.Log.Debug( + Glamourer.Log.Verbose( $"Set {index.ToName()} in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Other, settings.Source, state, actors, new MetaTransaction(index, old, value)); } @@ -417,7 +417,8 @@ public class StateEditor( ? Applier.ApplyAll(state, requiresRedraw, false) : ActorData.Invalid; - Glamourer.Log.Verbose($"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); + Glamourer.Log.Verbose( + $"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later if(settings.SendStateUpdate) StateUpdated.Invoke(StateUpdateType.DesignApplied, actors); From 8add6e5519c6998194ad4adc5f818704e5fa96d6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 20 Jan 2025 15:37:21 +0100 Subject: [PATCH 179/401] Fix some .net update issues. --- Glamourer/Gui/Customization/CustomizeParameterDrawData.cs | 4 ++-- Glamourer/Gui/Equipment/BonusDrawData.cs | 4 ++-- Glamourer/Gui/Equipment/EquipDrawData.cs | 4 ++-- Penumbra.GameData | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizeParameterDrawData.cs b/Glamourer/Gui/Customization/CustomizeParameterDrawData.cs index aa43b79..421caed 100644 --- a/Glamourer/Gui/Customization/CustomizeParameterDrawData.cs +++ b/Glamourer/Gui/Customization/CustomizeParameterDrawData.cs @@ -6,8 +6,8 @@ namespace Glamourer.Gui.Customization; public struct CustomizeParameterDrawData(CustomizeParameterFlag flag, in DesignData data) { - private IDesignEditor _editor; - private object _object; + private IDesignEditor _editor = null!; + private object _object = null!; public readonly CustomizeParameterFlag Flag = flag; public bool Locked; public bool DisplayApplication; diff --git a/Glamourer/Gui/Equipment/BonusDrawData.cs b/Glamourer/Gui/Equipment/BonusDrawData.cs index 9c023b8..e19287a 100644 --- a/Glamourer/Gui/Equipment/BonusDrawData.cs +++ b/Glamourer/Gui/Equipment/BonusDrawData.cs @@ -7,8 +7,8 @@ namespace Glamourer.Gui.Equipment; public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) { - private IDesignEditor _editor; - private object _object; + private IDesignEditor _editor = null!; + private object _object = null!; public readonly BonusItemFlag Slot = slot; public bool Locked; public bool DisplayApplication; diff --git a/Glamourer/Gui/Equipment/EquipDrawData.cs b/Glamourer/Gui/Equipment/EquipDrawData.cs index 9a3142b..b72e234 100644 --- a/Glamourer/Gui/Equipment/EquipDrawData.cs +++ b/Glamourer/Gui/Equipment/EquipDrawData.cs @@ -7,8 +7,8 @@ namespace Glamourer.Gui.Equipment; public struct EquipDrawData(EquipSlot slot, in DesignData designData) { - private IDesignEditor _editor; - private object _object; + private IDesignEditor _editor = null!; + private object _object = null!; public readonly EquipSlot Slot = slot; public bool Locked; public bool DisplayApplication; diff --git a/Penumbra.GameData b/Penumbra.GameData index 63ffca0..c525072 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 63ffca0ff0ad626605120e58809c888d92053d64 +Subproject commit c525072299d5febd2bb638ab229060b0073ba6a6 From cdc67a035c5efdc04801b8630e799ad59ea742f7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 20 Jan 2025 15:37:59 +0100 Subject: [PATCH 180/401] Check for ENPC player copies and treat them as transformations. --- Glamourer/State/StateListener.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index d054a25..651e63e 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -9,6 +9,7 @@ using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using Dalamud.Game.ClientState.Conditions; using Dalamud.Plugin.Services; +using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.GameData; using Penumbra.GameData.DataContainers; using Glamourer.Designs; @@ -50,6 +51,7 @@ public class StateListener : IDisposable private readonly Dictionary _fistOffhands = []; private ActorIdentifier _creatingIdentifier = ActorIdentifier.Invalid; + private bool _isPlayerNpc; private ActorState? _creatingState; private ActorState? _customizeState; @@ -117,11 +119,13 @@ public class StateListener : IDisposable return; _creatingIdentifier = actor.GetIdentifier(_actors); - ref var modelId = ref *(uint*)modelPtr; ref var customize = ref *(CustomizeArray*)customizePtr; if (_autoDesignApplier.Reduce(actor, _creatingIdentifier, out _creatingState)) { + _isPlayerNpc = _creatingIdentifier.Type is IdentifierType.Player + && actor.IsCharacter + && actor.AsCharacter->GetObjectKind() is ObjectKind.EventNpc; switch (UpdateBaseData(actor, _creatingState, modelId, customizePtr, equipDataPtr)) { // TODO handle right @@ -327,7 +331,7 @@ public class StateListener : IDisposable && weapon.Weapon.Id != 0 && _fistOffhands.TryGetValue(actor, out var lastFistOffhand)) { - Glamourer.Log.Information($"Applying stored fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); + Glamourer.Log.Verbose($"Applying stored fist weapon offhand {lastFistOffhand} for 0x{actor.Address:X}."); weapon = lastFistOffhand; } @@ -420,15 +424,22 @@ public class StateListener : IDisposable } var baseData = state.BaseData.Armor(slot); - var change = UpdateState.NoChange; + + var change = UpdateState.NoChange; if (baseData.Stains != armor.Stains) { + if (_isPlayerNpc) + return UpdateState.Transformed; + state.BaseData.SetStain(slot, armor.Stains); change = UpdateState.Change; } if (baseData.Set.Id != armor.Set.Id || baseData.Variant != armor.Variant && !fistWeapon) { + if (_isPlayerNpc) + return UpdateState.Transformed; + var item = _items.Identify(slot, armor.Set, armor.Variant); state.BaseData.SetItem(slot, item); change = UpdateState.Change; @@ -460,6 +471,9 @@ public class StateListener : IDisposable var change = UpdateState.NoChange; if (baseData.Id != actorItem.Id || baseData.PrimaryId != item.Set || baseData.Variant != item.Variant) { + if (_isPlayerNpc) + return UpdateState.Transformed; + var identified = _items.Identify(slot, item.Set, item.Variant); state.BaseData.SetBonusItem(slot, identified); change = UpdateState.Change; @@ -576,6 +590,9 @@ public class StateListener : IDisposable if (baseData.Skeleton.Id != weapon.Skeleton.Id || baseData.Weapon.Id != weapon.Weapon.Id || baseData.Variant != weapon.Variant) { + if (_isPlayerNpc) + return UpdateState.Transformed; + var item = _items.Identify(slot, weapon.Skeleton, weapon.Weapon, weapon.Variant, slot is EquipSlot.OffHand ? state.BaseData.MainhandType : FullEquipType.Unknown); state.BaseData.SetItem(slot, item); @@ -623,6 +640,10 @@ public class StateListener : IDisposable if (checkTransform && !actor.Customize->Equals(customize)) return UpdateState.Transformed; + // Check for player NPCs with a different game state. + if (_isPlayerNpc && !actor.Customize->Equals(state.BaseData.Customize)) + return UpdateState.Transformed; + // Customize array did not change to stored state. if (state.BaseData.Customize.Equals(customize)) return UpdateState.NoChange; // TODO: handle wrong base data. From 4db08224430ad4405a67b03c83e168b46841e173 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 20 Jan 2025 15:40:08 +0100 Subject: [PATCH 181/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index c525072..5bac66e 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit c525072299d5febd2bb638ab229060b0073ba6a6 +Subproject commit 5bac66e5ad73e57919aff7f8b046606b75e191a2 From 96dca5dbe7f4a61086b0f192521a60c3949372d2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 20 Jan 2025 17:47:36 +0100 Subject: [PATCH 182/401] Cherry-Pick from ebdfd3f8 to use EquipGearSetInternal. --- Glamourer/Interop/InventoryService.cs | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 6d8e58b..f0ed6b5 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -1,5 +1,6 @@ using Dalamud.Hooking; using Dalamud.Plugin.Services; +using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using Glamourer.Events; @@ -19,36 +20,43 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService public InventoryService(MovedEquipment movedItemsEvent, IGameInteropProvider interop, EquippedGearset gearsetEvent) { _movedItemsEvent = movedItemsEvent; - _gearsetEvent = gearsetEvent; + _gearsetEvent = gearsetEvent; _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); - _equipGearsetHook = - interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour); + // This can be uncommented after ClientStructs Updates with EquipGearsetInternal after merged PR. (See comment below) + //_equipGearsetInternalHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearsetInternal, EquipGearSetInternalDetour); + + // Can be removed after ClientStructs Update since this is only needed for current EquipGearsetInternal [Signature] + interop.InitializeFromAttributes(this); _moveItemHook.Enable(); - _equipGearsetHook.Enable(); + _equipGearsetInternalHook.Enable(); } public void Dispose() { _moveItemHook.Dispose(); - _equipGearsetHook.Dispose(); + _equipGearsetInternalHook.Dispose(); } - private delegate int EquipGearsetDelegate(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId); + // This is the internal function processed by all sources of Equipping a gearset, such as hotbar gearset application and command gearset application. + // Currently is pending to ClientStructs for integration. See: https://github.com/aers/FFXIVClientStructs/pull/1277 + public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; + private delegate nint EquipGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); - private readonly Hook _equipGearsetHook; + [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] + private readonly Hook _equipGearsetInternalHook = null!; - private int EquipGearSetDetour(RaptureGearsetModule* module, int gearsetId, byte glamourPlateId) + private nint EquipGearSetInternalDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) { var prior = module->CurrentGearsetIndex; - var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); - var set = module->GetGearset(gearsetId); - _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), gearsetId, prior, glamourPlateId, set->ClassJob); - Glamourer.Log.Excessive($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); + var ret = _equipGearsetInternalHook.Original(module, gearsetId, glamourPlateId); + var set = module->GetGearset((int)gearsetId); + _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), (int)gearsetId, prior, glamourPlateId, set->ClassJob); + Glamourer.Log.Verbose($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); if (ret == 0) { - var entry = module->GetGearset(gearsetId); + var entry = module->GetGearset((int)gearsetId); if (entry == null) return ret; From f1b335e794fe8e4bd72f6b08ba9b492c2dac6efc Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 20 Jan 2025 16:49:52 +0000 Subject: [PATCH 183/401] [CI] Updating repo.json for testing_1.3.5.3 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index dab02ea..5f4ae31 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.5.1", - "TestingAssemblyVersion": "1.3.5.2", + "TestingAssemblyVersion": "1.3.5.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c43ce9d978f57f10f62f8c981533a5344cd4b638 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Tue, 21 Jan 2025 10:47:12 -0800 Subject: [PATCH 184/401] Updated new functionality and internal gearset to use FFXIVClientStructs member functions and implemented structs, corrected remaining spacing issues. --- Glamourer/Api/StateApi.cs | 5 +- Glamourer/Events/GearsetDataLoaded.cs | 8 +-- Glamourer/Interop/InventoryService.cs | 20 ++---- Glamourer/Interop/UpdateSlotService.cs | 89 ++++++-------------------- Glamourer/State/StateEditor.cs | 2 +- Glamourer/State/StateListener.cs | 3 +- 6 files changed, 33 insertions(+), 94 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index cb7fe51..41f7650 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -14,7 +14,6 @@ using StateChanged = Glamourer.Events.StateChanged; using StateUpdated = Glamourer.Events.StateUpdated; namespace Glamourer.Api; - public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable { private readonly ApiHelpers _helpers; @@ -340,7 +339,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { - // Glamourer.Log.Verbose($"[OnStateChanged] Sending out OnStateChanged with type {type}."); + Glamourer.Log.Excessive($"[OnStateChanged] State Changed with Type {type} [Affecting {actors.ToLazyString("nothing")}.]"); if (StateChanged != null) foreach (var actor in actors.Objects) StateChanged.Invoke(actor.Address); @@ -352,7 +351,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void OnStateUpdated(StateUpdateType type, ActorData actors) { - // Glamourer.Log.Verbose($"[OnStateUpdated] Sending out OnStateUpdated with type {type}."); + Glamourer.Log.Verbose($"[OnStateUpdated] State Updated with Type {type}. [Affecting {actors.ToLazyString("nothing")}.]"); if (StateUpdated != null) foreach (var actor in actors.Objects) StateUpdated.Invoke(actor.Address, type); diff --git a/Glamourer/Events/GearsetDataLoaded.cs b/Glamourer/Events/GearsetDataLoaded.cs index dd12bc1..4750939 100644 --- a/Glamourer/Events/GearsetDataLoaded.cs +++ b/Glamourer/Events/GearsetDataLoaded.cs @@ -4,10 +4,10 @@ using Penumbra.GameData.Interop; namespace Glamourer.Events; /// -/// Triggers when the equipped gearset finished running all of its LoadEquipment, LoadWeapon, and crest calls. -/// This defines a universal endpoint of base game state application to monitor. +/// Triggers when the equipped gearset finished all LoadEquipment, LoadWeapon, and LoadCrest calls. (All Non-MetaData) +/// This defines an endpoint for when the gameState is updated. /// -/// The model drawobject associated with the finished load (Also fired by other players on render) +/// The model draw object associated with the finished load (Also fired by other players on render) /// /// public sealed class GearsetDataLoaded() @@ -18,4 +18,4 @@ public sealed class GearsetDataLoaded() /// StateListener = 0, } -} \ No newline at end of file +} diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index f0ed6b5..4b98d46 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -23,34 +23,26 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService _gearsetEvent = gearsetEvent; _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); - // This can be uncommented after ClientStructs Updates with EquipGearsetInternal after merged PR. (See comment below) - //_equipGearsetInternalHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearsetInternal, EquipGearSetInternalDetour); - - // Can be removed after ClientStructs Update since this is only needed for current EquipGearsetInternal [Signature] - interop.InitializeFromAttributes(this); + _equipGearsetHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearsetInternal, EquipGearSetDetour); _moveItemHook.Enable(); - _equipGearsetInternalHook.Enable(); + _equipGearsetHook.Enable(); } public void Dispose() { _moveItemHook.Dispose(); - _equipGearsetInternalHook.Dispose(); + _equipGearsetHook.Dispose(); } - // This is the internal function processed by all sources of Equipping a gearset, such as hotbar gearset application and command gearset application. - // Currently is pending to ClientStructs for integration. See: https://github.com/aers/FFXIVClientStructs/pull/1277 - public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; private delegate nint EquipGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); - [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] - private readonly Hook _equipGearsetInternalHook = null!; + private readonly Hook _equipGearsetHook = null!; - private nint EquipGearSetInternalDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) + private nint EquipGearSetDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) { var prior = module->CurrentGearsetIndex; - var ret = _equipGearsetInternalHook.Original(module, gearsetId, glamourPlateId); + var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); var set = module->GetGearset((int)gearsetId); _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), (int)gearsetId, prior, glamourPlateId, set->ClassJob); Glamourer.Log.Verbose($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index e453c6e..466f1ae 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; +using FFXIVClientStructs.FFXIV.Client.Game.Network; using Glamourer.Events; using Penumbra.GameData; using Penumbra.GameData.DataContainers; @@ -13,22 +14,20 @@ namespace Glamourer.Interop; public unsafe class UpdateSlotService : IDisposable { - public readonly EquipSlotUpdating EquipSlotUpdatingEvent; - public readonly BonusSlotUpdating BonusSlotUpdatingEvent; - public readonly GearsetDataLoaded GearsetDataLoadedEvent; - private readonly DictBonusItems _bonusItems; + public readonly EquipSlotUpdating EquipSlotUpdatingEvent; + public readonly BonusSlotUpdating BonusSlotUpdatingEvent; + public readonly GearsetDataLoaded GearsetDataLoadedEvent; + private readonly DictBonusItems _bonusItems; public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, GearsetDataLoaded gearsetDataLoaded, IGameInteropProvider interop, DictBonusItems bonusItems) { EquipSlotUpdatingEvent = equipSlotUpdating; BonusSlotUpdatingEvent = bonusSlotUpdating; GearsetDataLoadedEvent = gearsetDataLoaded; - _bonusItems = bonusItems; + _bonusItems = bonusItems; - // Usable after the merge with client structs. - //_loadGearsetDataHook = interop.HookFromAddress((nint)DrawDataContainer.MemberFunctionPointers.LoadGearsetData, LoadGearsetDataDetour); + _loadGearsetDataHook = interop.HookFromAddress((nint)DrawDataContainer.MemberFunctionPointers.LoadGearsetData, LoadGearsetDataDetour); interop.InitializeFromAttributes(this); - _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); _loadGearsetDataHook.Enable(); @@ -87,25 +86,15 @@ public unsafe class UpdateSlotService : IDisposable [Signature(Sigs.FlagBonusSlotForUpdate, DetourName = nameof(FlagBonusSlotForUpdateDetour))] private readonly Hook _flagBonusSlotForUpdateHook = null!; - // This signature is what calls the weapon/equipment/crest load functions in the drawData container inherited from a human/characterBase. - // - // Contrary to assumption, this is not frequently fired when any slot changes, and is instead only called when another player - // initially loads, or when the client player changes gearsets. (Does not fire when another player or self is redrawn) - // - // This functions purpose is to iterate all Equipment/Weapon/Crest data on gearset change / initial player load, and determine which slots need to fire FlagSlotForUpdate. - // - // Because Glamourer processes GameState changes by detouring this method, this means by returning original after detour, any logic performed after will occur - // AFTER Glamourer finishes applying all changes to the game State, providing a gearset endpoint. (MetaData not included) - // Currently pending a merge to clientStructs, after which it can be removed, along with the explicit struct. See: https://github.com/aers/FFXIVClientStructs/pull/1277/files - public const string LoadGearsetDataSig = "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B6 B9"; - private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, GearsetDataStruct* gearsetData); - - [Signature(LoadGearsetDataSig, DetourName = nameof(LoadGearsetDataDetour))] + /// Detours the func that makes all FlagSlotForUpdate calls on a gearset change or initial render of a given actor (Only Cases this is Called). + /// Logic done after returning the original hook executes After all equipment/weapon/crest data is loaded into the Actors BaseData. + /// + private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, PacketPlayerGearsetData* gearsetData); private readonly Hook _loadGearsetDataHook = null!; private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToEquipSlot(); + var slot = slotIdx.ToEquipSlot(); var returnValue = ulong.MaxValue; EquipSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); @@ -114,7 +103,7 @@ public unsafe class UpdateSlotService : IDisposable private ulong FlagBonusSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { - var slot = slotIdx.ToBonusSlot(); + var slot = slotIdx.ToBonusSlot(); var returnValue = ulong.MaxValue; BonusSlotUpdatingEvent.Invoke(drawObject, slot, ref *data, ref returnValue); Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Called with 0x{drawObject:X} for slot {slot} with {*data} ({returnValue:X})."); @@ -123,29 +112,27 @@ public unsafe class UpdateSlotService : IDisposable private ulong FlagSlotForUpdateInterop(Model drawObject, EquipSlot slot, CharacterArmor armor) { - Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Invoked by Glamourer on 0x{drawObject.Address:X} on {slot} with itemdata {armor}."); + Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Glamourer-Invoked on 0x{drawObject.Address:X} on {slot} with item data {armor}."); return _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); } - private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, GearsetDataStruct* gearsetData) + private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, PacketPlayerGearsetData* gearsetData) { - // Let the gearset data process all of its loads and slot flag update calls first. var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); Model drawObject = drawDataContainer->OwnerObject->DrawObject; - Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] Owner: 0x{drawObject.Address:X} Finished Applying its GameState!"); GearsetDataLoadedEvent.Invoke(drawObject); - // Glamourer.Log.Verbose($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); + // Glamourer.Log.Excessive($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); return ret; } // If you ever care to debug this, here is a formatted string output of this new gearsetData struct. - private string FormatGearsetItemDataStruct(GearsetDataStruct gearsetData) + private string FormatGearsetItemDataStruct(PacketPlayerGearsetData gearsetData) { string ret = $"\nMainhandWeaponData: Id: {gearsetData.MainhandWeaponData.Id}, Type: {gearsetData.MainhandWeaponData.Type}, " + $"Variant: {gearsetData.MainhandWeaponData.Variant}, Stain0: {gearsetData.MainhandWeaponData.Stain0}, Stain1: {gearsetData.MainhandWeaponData.Stain1}" + $"\nOffhandWeaponData: Id: {gearsetData.OffhandWeaponData.Id}, Type: {gearsetData.OffhandWeaponData.Type}, " + $"Variant: {gearsetData.OffhandWeaponData.Variant}, Stain0: {gearsetData.OffhandWeaponData.Stain0}, Stain1: {gearsetData.OffhandWeaponData.Stain1}" + - $"\nCrestBitField: {gearsetData.CrestBitField} | JobId: {gearsetData.JobId} | UNK_18: {gearsetData.UNK_18} | UNK_19: {gearsetData.UNK_19}"; + $"\nCrestBitField: {gearsetData.CrestBitField} | JobId: {gearsetData.JobId}"; for (int offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) { LegacyCharacterArmor* equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetData + offset); @@ -156,43 +143,3 @@ public unsafe class UpdateSlotService : IDisposable return ret; } } - -// Can be removed once merged with client structs and referenced directly. See: https://github.com/aers/FFXIVClientStructs/pull/1277/files -[StructLayout(LayoutKind.Explicit)] -public readonly struct GearsetDataStruct -{ - // Stores the weapon data. Includes both dyes in the data. - [FieldOffset(0)] public readonly WeaponModelId MainhandWeaponData; - [FieldOffset(8)] public readonly WeaponModelId OffhandWeaponData; - - [FieldOffset(16)] public readonly byte CrestBitField; // A Bitfield:: ShieldCrest == 1, HeadCrest == 2, Chest Crest == 4 - [FieldOffset(17)] public readonly byte JobId; // Job ID associated with the gearset change. - - // Flicks from 0 to 127 (anywhere inbetween), have yet to associate what it is linked to. Remains the same when flicking between gearsets of the same job. - [FieldOffset(18)] public readonly byte UNK_18; - [FieldOffset(19)] public readonly byte UNK_19; // I have never seen this be anything other than 0. - - // Legacy helmet equip slot armor for a character. - [FieldOffset(20)] public readonly LegacyCharacterArmor HeadSlotArmor; - [FieldOffset(24)] public readonly LegacyCharacterArmor TopSlotArmor; - [FieldOffset(28)] public readonly LegacyCharacterArmor ArmsSlotArmor; - [FieldOffset(32)] public readonly LegacyCharacterArmor LegsSlotArmor; - [FieldOffset(26)] public readonly LegacyCharacterArmor FeetSlotArmor; - [FieldOffset(40)] public readonly LegacyCharacterArmor EarSlotArmor; - [FieldOffset(44)] public readonly LegacyCharacterArmor NeckSlotArmor; - [FieldOffset(48)] public readonly LegacyCharacterArmor WristSlotArmor; - [FieldOffset(52)] public readonly LegacyCharacterArmor RFingerSlotArmor; - [FieldOffset(56)] public readonly LegacyCharacterArmor LFingerSlotArmor; - - // Byte array of all slot's secondary dyes. - [FieldOffset(60)] public readonly byte HeadSlotSecondaryDye; - [FieldOffset(61)] public readonly byte TopSlotSecondaryDye; - [FieldOffset(62)] public readonly byte ArmsSlotSecondaryDye; - [FieldOffset(63)] public readonly byte LegsSlotSecondaryDye; - [FieldOffset(64)] public readonly byte FeetSlotSecondaryDye; - [FieldOffset(65)] public readonly byte EarSlotSecondaryDye; - [FieldOffset(66)] public readonly byte NeckSlotSecondaryDye; - [FieldOffset(67)] public readonly byte WristSlotSecondaryDye; - [FieldOffset(68)] public readonly byte RFingerSlotSecondaryDye; - [FieldOffset(69)] public readonly byte LFingerSlotSecondaryDye; -} diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index b122352..13b0706 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -416,7 +416,7 @@ public class StateEditor( var actors = settings.Source.RequiresChange() ? Applier.ApplyAll(state, requiresRedraw, false) : ActorData.Invalid; - + Glamourer.Log.Verbose( $"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index d570805..c4c16b5 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -225,7 +225,8 @@ public class StateListener : IDisposable // then we do not want to use our restricted gear protection // since we assume the player has that gear modded to availability. var locked = false; - if (actor.Identifier(_actors, out var identifier) && _manager.TryGetValue(identifier, out var state)) + if (actor.Identifier(_actors, out var identifier) + && _manager.TryGetValue(identifier, out var state)) { HandleEquipSlot(actor, state, slot, ref armor); locked = state.Sources[slot, false] is StateSource.IpcFixed; From 70918e539379871eb256a21ebad833d13315031d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 15:04:22 +0100 Subject: [PATCH 185/401] Add AutoDesignSet toggle for resetting settings. --- Glamourer/Automation/AutoDesignManager.cs | 16 +++++ Glamourer/Events/AutomationChanged.cs | 3 + Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 71 ++++++++++++-------- 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index 5d30de0..6635a89 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -234,6 +234,22 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos _event.Invoke(AutomationChanged.Type.ChangedBase, set, (old, newBase)); } + public void ChangeResetSettings(int whichSet, bool newValue) + { + if (whichSet >= _data.Count || whichSet < 0) + return; + + var set = _data[whichSet]; + if (newValue == set.ResetTemporarySettings) + return; + + var old = set.ResetTemporarySettings; + set.ResetTemporarySettings = newValue; + Save(); + Glamourer.Log.Debug($"Changed resetting of temporary settings of set {whichSet + 1} from {old} to {newValue}."); + _event.Invoke(AutomationChanged.Type.ChangedTemporarySettingsReset, set, newValue); + } + public void AddDesign(AutoDesignSet set, IDesignStandIn design) { var newDesign = new AutoDesign() diff --git a/Glamourer/Events/AutomationChanged.cs b/Glamourer/Events/AutomationChanged.cs index 26f799a..c368899 100644 --- a/Glamourer/Events/AutomationChanged.cs +++ b/Glamourer/Events/AutomationChanged.cs @@ -37,6 +37,9 @@ public sealed class AutomationChanged() /// Change the used base state of a given set. Additional data is prior and new base. [(AutoDesignSet.Base, AutoDesignSet.Base)]. ChangedBase, + /// Change the resetting of temporary settings for a given set. Additional data is the new value. + ChangedTemporarySettingsReset, + /// Add a new associated design to a given set. Additional data is the index it got added at [int]. AddedDesign, diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 924f822..caa7d60 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -58,38 +58,53 @@ public class SetPanel( var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + using (ImUtf8.Group()) { - var enabled = Selection.Enabled; - if (ImGui.Checkbox("##Enabled", ref enabled)) - _manager.SetState(_selector.SelectionIndex, enabled); - ImGuiUtil.LabeledHelpMarker("Enabled", - "Whether the designs in this set should be applied at all. Only one set can be enabled for a character at the same time."); - } - - ImGui.SameLine(); - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) - { - var useGame = _selector.Selection!.BaseState is AutoDesignSet.Base.Game; - if (ImGui.Checkbox("##gameState", ref useGame)) - _manager.ChangeBaseState(_selector.SelectionIndex, useGame ? AutoDesignSet.Base.Game : AutoDesignSet.Base.Current); - ImGuiUtil.LabeledHelpMarker("Use Game State as Base", - "When this is enabled, the designs matching conditions will be applied successively on top of what your character is supposed to look like for the game. " - + "Otherwise, they will be applied on top of the characters actual current look using Glamourer."); - } - - ImGui.SameLine(); - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) - { - var editing = _config.ShowAutomationSetEditing; - if (ImGui.Checkbox("##Show Editing", ref editing)) + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) { - _config.ShowAutomationSetEditing = editing; - _config.Save(); + var enabled = Selection.Enabled; + if (ImGui.Checkbox("##Enabled", ref enabled)) + _manager.SetState(_selector.SelectionIndex, enabled); + ImGuiUtil.LabeledHelpMarker("Enabled", + "Whether the designs in this set should be applied at all. Only one set can be enabled for a character at the same time."); } - ImGuiUtil.LabeledHelpMarker("Show Editing", - "Show options to change the name or the associated character or NPC of this design set."); + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + { + var useGame = _selector.Selection!.BaseState is AutoDesignSet.Base.Game; + if (ImGui.Checkbox("##gameState", ref useGame)) + _manager.ChangeBaseState(_selector.SelectionIndex, useGame ? AutoDesignSet.Base.Game : AutoDesignSet.Base.Current); + ImGuiUtil.LabeledHelpMarker("Use Game State as Base", + "When this is enabled, the designs matching conditions will be applied successively on top of what your character is supposed to look like for the game. " + + "Otherwise, they will be applied on top of the characters actual current look using Glamourer."); + } + } + + ImGui.SameLine(); + using (ImUtf8.Group()) + { + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + { + var editing = _config.ShowAutomationSetEditing; + if (ImGui.Checkbox("##Show Editing", ref editing)) + { + _config.ShowAutomationSetEditing = editing; + _config.Save(); + } + + ImGuiUtil.LabeledHelpMarker("Show Editing", + "Show options to change the name or the associated character or NPC of this design set."); + } + + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + { + var resetSettings = _selector.Selection!.ResetTemporarySettings; + if (ImGui.Checkbox("##resetSettings", ref resetSettings)) + _manager.ChangeResetSettings(_selector.SelectionIndex, resetSettings); + + ImGuiUtil.LabeledHelpMarker("Reset Temporary Settings", + "Always reset all temporary settings applied by Glamourer when this automation set is applied, regardless of active designs."); + } } if (_config.ShowAutomationSetEditing) From 30468e0b09e892085c5d788e1e89d41dcadc927b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 15:04:30 +0100 Subject: [PATCH 186/401] Fix checkbox not working. --- Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 5eda7cc..021a396 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -201,7 +201,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect ImGui.TableNextColumn(); var inherit = settings.ForceInherit; - if (TwoStateCheckbox.Instance.Draw("##Enabled"u8, ref inherit)) + if (TwoStateCheckbox.Instance.Draw("##ForceInherit"u8, ref inherit)) updatedMod = (mod, settings with { ForceInherit = inherit }); ImUtf8.HoverTooltip("Force the mod to inherit its settings from inherited collections."u8); ImGui.TableNextColumn(); From 29166693193cee2201a069c0589475627ef0617a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 15:06:29 +0100 Subject: [PATCH 187/401] Change EquipGearsetInternal to CS. --- Glamourer/Interop/InventoryService.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index f0ed6b5..4b98d46 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -23,34 +23,26 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService _gearsetEvent = gearsetEvent; _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); - // This can be uncommented after ClientStructs Updates with EquipGearsetInternal after merged PR. (See comment below) - //_equipGearsetInternalHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearsetInternal, EquipGearSetInternalDetour); - - // Can be removed after ClientStructs Update since this is only needed for current EquipGearsetInternal [Signature] - interop.InitializeFromAttributes(this); + _equipGearsetHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearsetInternal, EquipGearSetDetour); _moveItemHook.Enable(); - _equipGearsetInternalHook.Enable(); + _equipGearsetHook.Enable(); } public void Dispose() { _moveItemHook.Dispose(); - _equipGearsetInternalHook.Dispose(); + _equipGearsetHook.Dispose(); } - // This is the internal function processed by all sources of Equipping a gearset, such as hotbar gearset application and command gearset application. - // Currently is pending to ClientStructs for integration. See: https://github.com/aers/FFXIVClientStructs/pull/1277 - public const string EquipGearsetInternal = "40 55 53 56 57 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 4C 63 FA"; private delegate nint EquipGearsetInternalDelegate(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId); - [Signature(EquipGearsetInternal, DetourName = nameof(EquipGearSetInternalDetour))] - private readonly Hook _equipGearsetInternalHook = null!; + private readonly Hook _equipGearsetHook = null!; - private nint EquipGearSetInternalDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) + private nint EquipGearSetDetour(RaptureGearsetModule* module, uint gearsetId, byte glamourPlateId) { var prior = module->CurrentGearsetIndex; - var ret = _equipGearsetInternalHook.Original(module, gearsetId, glamourPlateId); + var ret = _equipGearsetHook.Original(module, gearsetId, glamourPlateId); var set = module->GetGearset((int)gearsetId); _gearsetEvent.Invoke(new ByteString(set->Name).ToString(), (int)gearsetId, prior, glamourPlateId, set->ClassJob); Glamourer.Log.Verbose($"[InventoryService] Applied gear set {gearsetId} with glamour plate {glamourPlateId} (Returned {ret})"); From 7be283ca30629e648725e4e1861616d86eda7238 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 16:46:10 +0100 Subject: [PATCH 188/401] Apply API renames. --- Glamourer.Api | 2 +- Glamourer/Api/IpcProviders.cs | 2 +- Glamourer/Api/StateApi.cs | 8 ++++---- Glamourer/Events/StateUpdated.cs | 2 +- Glamourer/State/StateEditor.cs | 4 ++-- Glamourer/State/StateListener.cs | 2 +- Glamourer/State/StateManager.cs | 12 ++++++------ 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index b1b90e6..4ac38fb 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit b1b90e6ecfeee76a12cb27793753fa87af21083f +Subproject commit 4ac38fbed6fb0f31c0b75de26950ab82d3bee258 diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 166245f..515cd34 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -52,7 +52,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.RevertToAutomationName.Provider(pi, api.State), IpcSubscribers.StateChanged.Provider(pi, api.State), IpcSubscribers.StateChangedWithType.Provider(pi, api.State), - IpcSubscribers.StateUpdated.Provider(pi, api.State), + IpcSubscribers.StateFinalized.Provider(pi, api.State), IpcSubscribers.GPoseChanged.Provider(pi, api.State), ]; _initializedProvider.Invoke(); diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 41f7650..347d2b6 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -255,7 +255,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public event Action? StateChanged; public event Action? StateChangedWithType; - public event Action? StateUpdated; + public event Action? StateFinalized; public event Action? GPoseChanged; private void ApplyDesign(ActorState state, DesignBase design, uint key, ApplyFlag flags) @@ -349,11 +349,11 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable StateChangedWithType.Invoke(actor.Address, type); } - private void OnStateUpdated(StateUpdateType type, ActorData actors) + private void OnStateUpdated(StateFinalizationType type, ActorData actors) { Glamourer.Log.Verbose($"[OnStateUpdated] State Updated with Type {type}. [Affecting {actors.ToLazyString("nothing")}.]"); - if (StateUpdated != null) + if (StateFinalized != null) foreach (var actor in actors.Objects) - StateUpdated.Invoke(actor.Address, type); + StateFinalized.Invoke(actor.Address, type); } } diff --git a/Glamourer/Events/StateUpdated.cs b/Glamourer/Events/StateUpdated.cs index f18a69a..faaf33a 100644 --- a/Glamourer/Events/StateUpdated.cs +++ b/Glamourer/Events/StateUpdated.cs @@ -14,7 +14,7 @@ namespace Glamourer.Events; /// /// public sealed class StateUpdated() - : EventWrapper(nameof(StateUpdated)) + : EventWrapper(nameof(StateUpdated)) { public enum Priority { diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 13b0706..ebf347f 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -43,7 +43,7 @@ public class StateEditor( Glamourer.Log.Verbose( $"Set model id in state {state.Identifier.Incognito(null)} from {old} to {modelId}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Model, source, state, actors, null); - StateUpdated.Invoke(StateUpdateType.ModelChange, actors); + StateUpdated.Invoke(StateFinalizationType.ModelChange, actors); } /// @@ -421,7 +421,7 @@ public class StateEditor( $"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later if(settings.SendStateUpdate) - StateUpdated.Invoke(StateUpdateType.DesignApplied, actors); + StateUpdated.Invoke(StateFinalizationType.DesignApplied, actors); return; diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index c4c16b5..d8648bb 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -281,7 +281,7 @@ public class StateListener : IDisposable _objects.Update(); if (_objects.TryGetValue(identifier, out var actors) && actors.Valid) - _stateUpdated.Invoke(StateUpdateType.Gearset, actors); + _stateUpdated.Invoke(StateFinalizationType.Gearset, actors); } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 0348148..948e225 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -279,7 +279,7 @@ public sealed class StateManager( StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); // only invoke if we define this reset call as the final call in our state update. if(stateUpdate) - StateUpdated.Invoke(StateUpdateType.Revert, actors); + StateUpdated.Invoke(StateFinalizationType.Revert, actors); } public void ResetAdvancedState(ActorState state, StateSource source, uint key = 0) @@ -306,7 +306,7 @@ public sealed class StateManager( $"Reset advanced customization and dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) - StateUpdated.Invoke(StateUpdateType.RevertAdvanced, actors); + StateUpdated.Invoke(StateFinalizationType.RevertAdvanced, actors); } public void ResetCustomize(ActorState state, StateSource source, uint key = 0) @@ -325,7 +325,7 @@ public sealed class StateManager( Glamourer.Log.Verbose( $"Reset customization state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) - StateUpdated.Invoke(StateUpdateType.RevertCustomize, actors); + StateUpdated.Invoke(StateFinalizationType.RevertCustomize, actors); } public void ResetEquip(ActorState state, StateSource source, uint key = 0) @@ -376,7 +376,7 @@ public sealed class StateManager( Glamourer.Log.Verbose( $"Reset equipment state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) - StateUpdated.Invoke(StateUpdateType.RevertEquipment, actors); + StateUpdated.Invoke(StateFinalizationType.RevertEquipment, actors); } public void ResetStateFixed(ActorState state, bool respectManualPalettes, uint key = 0) @@ -469,7 +469,7 @@ public sealed class StateManager( || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); if(stateUpdate) - StateUpdated.Invoke(StateUpdateType.Reapply, data); + StateUpdated.Invoke(StateFinalizationType.Reapply, data); } /// Automation variant for reapply, to fire the correct StateUpdateType once reapplied. @@ -490,7 +490,7 @@ public sealed class StateManager( || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); // invoke the automation update based on what reset is. - StateUpdated.Invoke(wasReset ? StateUpdateType.RevertAutomation : StateUpdateType.ReapplyAutomation, data); + StateUpdated.Invoke(wasReset ? StateFinalizationType.RevertAutomation : StateFinalizationType.ReapplyAutomation, data); } public void DeleteState(ActorIdentifier identifier) From d9f9937d41390b34eab9d151e08f5b0e5d983789 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 17:50:58 +0100 Subject: [PATCH 189/401] Continue renames, some cleanup. --- Glamourer/Api/DesignsApi.cs | 2 +- Glamourer/Api/IpcProviders.cs | 1 - Glamourer/Api/StateApi.cs | 40 +++---- Glamourer/Designs/IDesignEditor.cs | 8 +- Glamourer/Events/GPoseService.cs | 4 +- .../{StateUpdated.cs => StateFinalized.cs} | 13 +-- Glamourer/Gui/DesignQuickBar.cs | 4 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 8 +- .../Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 2 +- .../Tabs/DebugTab/IpcTester/IpcTesterPanel.cs | 2 + .../Tabs/DebugTab/IpcTester/StateIpcTester.cs | 107 ++++++++++++------ Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 4 +- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 4 +- Glamourer/Interop/UpdateSlotService.cs | 29 ++--- Glamourer/Services/CommandService.cs | 4 +- Glamourer/State/StateEditor.cs | 27 ++--- Glamourer/State/StateListener.cs | 8 +- Glamourer/State/StateManager.cs | 42 +++---- 18 files changed, 175 insertions(+), 134 deletions(-) rename Glamourer/Events/{StateUpdated.cs => StateFinalized.cs} (53%) diff --git a/Glamourer/Api/DesignsApi.cs b/Glamourer/Api/DesignsApi.cs index 6c3037e..08f5ddc 100644 --- a/Glamourer/Api/DesignsApi.cs +++ b/Glamourer/Api/DesignsApi.cs @@ -33,7 +33,7 @@ public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager { var once = (flags & ApplyFlag.Once) != 0; var settings = new ApplySettings(Source: once ? StateSource.IpcManual : StateSource.IpcFixed, Key: key, MergeLinks: true, - ResetMaterials: !once && key != 0, SendStateUpdate: true); + ResetMaterials: !once && key != 0, IsFinal: true); using var restrict = ApiHelpers.Restrict(design, flags); stateManager.ApplyDesign(state, design, settings); diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 515cd34..704f008 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -2,7 +2,6 @@ using Dalamud.Plugin; using Glamourer.Api.Api; using Glamourer.Api.Helpers; using OtterGui.Services; -using System.Reflection.Emit; using Glamourer.Api.Enums; namespace Glamourer.Api; diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 347d2b6..eaf9d01 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -11,9 +11,9 @@ using OtterGui.Services; using Penumbra.GameData.Interop; using ObjectManager = Glamourer.Interop.ObjectManager; using StateChanged = Glamourer.Events.StateChanged; -using StateUpdated = Glamourer.Events.StateUpdated; namespace Glamourer.Api; + public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable { private readonly ApiHelpers _helpers; @@ -23,7 +23,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private readonly AutoDesignApplier _autoDesigns; private readonly ObjectManager _objects; private readonly StateChanged _stateChanged; - private readonly StateUpdated _stateUpdated; + private readonly StateFinalized _stateFinalized; private readonly GPoseService _gPose; public StateApi(ApiHelpers helpers, @@ -33,27 +33,27 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable AutoDesignApplier autoDesigns, ObjectManager objects, StateChanged stateChanged, - StateUpdated stateUpdated, + StateFinalized stateFinalized, GPoseService gPose) { - _helpers = helpers; - _stateManager = stateManager; - _converter = converter; - _config = config; - _autoDesigns = autoDesigns; - _objects = objects; - _stateChanged = stateChanged; - _stateUpdated = stateUpdated; - _gPose = gPose; + _helpers = helpers; + _stateManager = stateManager; + _converter = converter; + _config = config; + _autoDesigns = autoDesigns; + _objects = objects; + _stateChanged = stateChanged; + _stateFinalized = stateFinalized; + _gPose = gPose; _stateChanged.Subscribe(OnStateChanged, Events.StateChanged.Priority.GlamourerIpc); - _stateUpdated.Subscribe(OnStateUpdated, Events.StateUpdated.Priority.GlamourerIpc); - _gPose.Subscribe(OnGPoseChange, GPoseService.Priority.GlamourerIpc); + _stateFinalized.Subscribe(OnStateFinalized, Events.StateFinalized.Priority.StateApi); + _gPose.Subscribe(OnGPoseChange, GPoseService.Priority.StateApi); } public void Dispose() { _stateChanged.Unsubscribe(OnStateChanged); - _stateUpdated.Unsubscribe(OnStateUpdated); + _stateFinalized.Unsubscribe(OnStateFinalized); _gPose.Unsubscribe(OnGPoseChange); } @@ -253,16 +253,16 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } - public event Action? StateChanged; - public event Action? StateChangedWithType; + public event Action? StateChanged; + public event Action? StateChangedWithType; public event Action? StateFinalized; - public event Action? GPoseChanged; + public event Action? GPoseChanged; private void ApplyDesign(ActorState state, DesignBase design, uint key, ApplyFlag flags) { var once = (flags & ApplyFlag.Once) != 0; var settings = new ApplySettings(Source: once ? StateSource.IpcManual : StateSource.IpcFixed, Key: key, MergeLinks: true, - ResetMaterials: !once && key != 0, SendStateUpdate: true); + ResetMaterials: !once && key != 0, IsFinal: true); _stateManager.ApplyDesign(state, design, settings); ApiHelpers.Lock(state, key, flags); } @@ -349,7 +349,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable StateChangedWithType.Invoke(actor.Address, type); } - private void OnStateUpdated(StateFinalizationType type, ActorData actors) + private void OnStateFinalized(StateFinalizationType type, ActorData actors) { Glamourer.Log.Verbose($"[OnStateUpdated] State Updated with Type {type}. [Affecting {actors.ToLazyString("nothing")}.]"); if (StateFinalized != null) diff --git a/Glamourer/Designs/IDesignEditor.cs b/Glamourer/Designs/IDesignEditor.cs index 0178620..c18c98b 100644 --- a/Glamourer/Designs/IDesignEditor.cs +++ b/Glamourer/Designs/IDesignEditor.cs @@ -14,7 +14,7 @@ public readonly record struct ApplySettings( bool UseSingleSource = false, bool MergeLinks = false, bool ResetMaterials = false, - bool SendStateUpdate = false) + bool IsFinal = false) { public static readonly ApplySettings Manual = new() { @@ -25,7 +25,7 @@ public readonly record struct ApplySettings( UseSingleSource = false, MergeLinks = false, ResetMaterials = false, - SendStateUpdate = false, + IsFinal = false, }; public static readonly ApplySettings ManualWithLinks = new() @@ -37,7 +37,7 @@ public readonly record struct ApplySettings( UseSingleSource = false, MergeLinks = true, ResetMaterials = false, - SendStateUpdate = false, + IsFinal = false, }; public static readonly ApplySettings Game = new() @@ -49,7 +49,7 @@ public readonly record struct ApplySettings( UseSingleSource = false, MergeLinks = false, ResetMaterials = true, - SendStateUpdate = false, + IsFinal = false, }; } diff --git a/Glamourer/Events/GPoseService.cs b/Glamourer/Events/GPoseService.cs index a84f1d6..44421a0 100644 --- a/Glamourer/Events/GPoseService.cs +++ b/Glamourer/Events/GPoseService.cs @@ -13,8 +13,8 @@ public sealed class GPoseService : EventWrapper public enum Priority { - /// - GlamourerIpc = int.MinValue, + /// + StateApi = int.MinValue, } public bool InGPose { get; private set; } diff --git a/Glamourer/Events/StateUpdated.cs b/Glamourer/Events/StateFinalized.cs similarity index 53% rename from Glamourer/Events/StateUpdated.cs rename to Glamourer/Events/StateFinalized.cs index faaf33a..e8548e9 100644 --- a/Glamourer/Events/StateUpdated.cs +++ b/Glamourer/Events/StateFinalized.cs @@ -1,24 +1,23 @@ +using Glamourer.Api; using Glamourer.Api.Enums; -using Glamourer.Designs.History; using Glamourer.Interop.Structs; -using Glamourer.State; using OtterGui.Classes; namespace Glamourer.Events; /// -/// Triggered when a Design is edited in any way. +/// Triggered when a set of grouped changes finishes being applied to a Glamourer state. /// /// Parameter is the operation that finished updating the saved state. /// Parameter is the existing actors using this saved state. /// /// -public sealed class StateUpdated() - : EventWrapper(nameof(StateUpdated)) +public sealed class StateFinalized() + : EventWrapper(nameof(StateFinalized)) { public enum Priority { - /// - GlamourerIpc = int.MinValue, + /// + StateApi = int.MinValue, } } diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index bdc345f..50f86fd 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -183,7 +183,7 @@ public sealed class DesignQuickBar : Window, IDisposable } using var _ = design!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); - _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); + _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { IsFinal = true }); } private void DrawRevertButton(Vector2 buttonSize) @@ -213,7 +213,7 @@ public sealed class DesignQuickBar : Window, IDisposable var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, tooltip, available); ImGui.SameLine(); if (clicked) - _stateManager.ResetState(state!, StateSource.Manual, stateUpdate: true); + _stateManager.ResetState(state!, StateSource.Manual, isFinal: true); } private void DrawRevertAutomationButton(Vector2 buttonSize) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index ced78fb..d8f3cd1 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -385,7 +385,7 @@ public class ActorPanel { if (ImGuiUtil.DrawDisabledButton("Revert to Game", Vector2.Zero, "Revert the character to its actual state in the game.", _state!.IsLocked)) - _stateManager.ResetState(_state!, StateSource.Manual, stateUpdate: true); + _stateManager.ResetState(_state!, StateSource.Manual, isFinal: true); ImGui.SameLine(); @@ -423,7 +423,7 @@ public class ActorPanel if (_stateManager.GetOrCreate(id, data.Objects[0], out var state)) _stateManager.ApplyDesign(state, _converter.Convert(_state!, ApplicationRules.FromModifiers(_state!)), - ApplySettings.Manual with { SendStateUpdate = true }); + ApplySettings.Manual with { IsFinal = true }); } private void DrawApplyToTarget() @@ -440,7 +440,7 @@ public class ActorPanel if (_stateManager.GetOrCreate(id, data.Objects[0], out var state)) _stateManager.ApplyDesign(state, _converter.Convert(_state!, ApplicationRules.FromModifiers(_state!)), - ApplySettings.Manual with { SendStateUpdate = true }); + ApplySettings.Manual with { IsFinal = true }); } @@ -467,7 +467,7 @@ public class ActorPanel var text = ImGui.GetClipboardText(); var design = panel._converter.FromBase64(text, applyCustomize, applyGear, out _) ?? throw new Exception("The clipboard did not contain valid data."); - panel._stateManager.ApplyDesign(panel._state!, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); + panel._stateManager.ApplyDesign(panel._state!, design, ApplySettings.ManualWithLinks with { IsFinal = true }); } catch (Exception ex) { diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index c44a722..62f93e9 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -79,7 +79,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer if (ImGuiUtil.DrawDisabledButton("Apply to Player", Vector2.Zero, string.Empty, !enabled)) { var design = CreateDesign(plate); - _state.ApplyDesign(state!, design, ApplySettings.Manual with { SendStateUpdate = true }); + _state.ApplyDesign(state!, design, ApplySettings.Manual with { IsFinal = true }); } using (ImRaii.Group()) diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs index 8f561af..1a78b24 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs @@ -51,6 +51,7 @@ public class IpcTesterPanel( Glamourer.Log.Debug("[IPCTester] Subscribed to IPC events for IPC tester."); state.GPoseChanged.Enable(); state.StateChanged.Enable(); + state.StateFinalized.Enable(); framework.Update += CheckUnsubscribe; _subscribed = true; } @@ -73,5 +74,6 @@ public class IpcTesterPanel( _subscribed = false; state.GPoseChanged.Disable(); state.StateChanged.Disable(); + state.StateFinalized.Disable(); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index f378625..638bffc 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq; using OtterGui; using OtterGui.Raii; using OtterGui.Services; +using OtterGui.Text; using Penumbra.GameData.Interop; using Penumbra.String; @@ -31,9 +32,16 @@ public class StateIpcTester : IUiService, IDisposable private string? _getStateString; public readonly EventSubscriber StateChanged; - private nint _lastStateChangeActor; - private ByteString _lastStateChangeName = ByteString.Empty; - private DateTime _lastStateChangeTime; + private nint _lastStateChangeActor; + private ByteString _lastStateChangeName = ByteString.Empty; + private DateTime _lastStateChangeTime; + private StateChangeType _lastStateChangeType; + + public readonly EventSubscriber StateFinalized; + private nint _lastStateFinalizeActor; + private ByteString _lastStateFinalizeName = ByteString.Empty; + private DateTime _lastStateFinalizeTime; + private StateFinalizationType _lastStateFinalizeType; public readonly EventSubscriber GPoseChanged; private bool _lastGPoseChangeValue; @@ -44,15 +52,18 @@ public class StateIpcTester : IUiService, IDisposable public StateIpcTester(IDalamudPluginInterface pluginInterface) { _pluginInterface = pluginInterface; - StateChanged = Api.IpcSubscribers.StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged); + StateChanged = StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged); + StateFinalized = Api.IpcSubscribers.StateFinalized.Subscriber(_pluginInterface, OnStateFinalized); GPoseChanged = Api.IpcSubscribers.GPoseChanged.Subscriber(_pluginInterface, OnGPoseChange); StateChanged.Disable(); + StateFinalized.Disable(); GPoseChanged.Disable(); } public void Dispose() { StateChanged.Dispose(); + StateFinalized.Dispose(); GPoseChanged.Dispose(); } @@ -73,86 +84,88 @@ public class StateIpcTester : IUiService, IDisposable IpcTesterHelpers.DrawIntro("Last Error"); ImGui.TextUnformatted(_lastError.ToString()); IpcTesterHelpers.DrawIntro("Last State Change"); - PrintName(); + PrintChangeName(); + IpcTesterHelpers.DrawIntro("Last State Finalization"); + PrintFinalizeName(); IpcTesterHelpers.DrawIntro("Last GPose Change"); ImGui.TextUnformatted($"{_lastGPoseChangeValue} at {_lastGPoseChangeTime.ToLocalTime().TimeOfDay}"); IpcTesterHelpers.DrawIntro(GetState.Label); DrawStatePopup(); - if (ImGui.Button("Get##Idx")) + if (ImUtf8.Button("Get##Idx"u8)) { (_lastError, _state) = new GetState(_pluginInterface).Invoke(_gameObjectIndex, _key); _stateString = _state?.ToString(Formatting.Indented) ?? "No State Available"; - ImGui.OpenPopup("State"); + ImUtf8.OpenPopup("State"u8); } IpcTesterHelpers.DrawIntro(GetStateName.Label); - if (ImGui.Button("Get##Name")) + if (ImUtf8.Button("Get##Name"u8)) { (_lastError, _state) = new GetStateName(_pluginInterface).Invoke(_gameObjectName, _key); _stateString = _state?.ToString(Formatting.Indented) ?? "No State Available"; - ImGui.OpenPopup("State"); + ImUtf8.OpenPopup("State"u8); } IpcTesterHelpers.DrawIntro(GetStateBase64.Label); - if (ImGui.Button("Get##Base64Idx")) + if (ImUtf8.Button("Get##Base64Idx"u8)) { (_lastError, _getStateString) = new GetStateBase64(_pluginInterface).Invoke(_gameObjectIndex, _key); _stateString = _getStateString ?? "No State Available"; - ImGui.OpenPopup("State"); + ImUtf8.OpenPopup("State"u8); } IpcTesterHelpers.DrawIntro(GetStateBase64Name.Label); - if (ImGui.Button("Get##Base64Idx")) + if (ImUtf8.Button("Get##Base64Idx"u8)) { (_lastError, _getStateString) = new GetStateBase64Name(_pluginInterface).Invoke(_gameObjectName, _key); _stateString = _getStateString ?? "No State Available"; - ImGui.OpenPopup("State"); + ImUtf8.OpenPopup("State"u8); } IpcTesterHelpers.DrawIntro(ApplyState.Label); if (ImGuiUtil.DrawDisabledButton("Apply Last##Idx", Vector2.Zero, string.Empty, _state == null)) _lastError = new ApplyState(_pluginInterface).Invoke(_state!, _gameObjectIndex, _key, _flags); ImGui.SameLine(); - if (ImGui.Button("Apply Base64##Idx")) + if (ImUtf8.Button("Apply Base64##Idx"u8)) _lastError = new ApplyState(_pluginInterface).Invoke(_base64State, _gameObjectIndex, _key, _flags); IpcTesterHelpers.DrawIntro(ApplyStateName.Label); if (ImGuiUtil.DrawDisabledButton("Apply Last##Name", Vector2.Zero, string.Empty, _state == null)) _lastError = new ApplyStateName(_pluginInterface).Invoke(_state!, _gameObjectName, _key, _flags); ImGui.SameLine(); - if (ImGui.Button("Apply Base64##Name")) + if (ImUtf8.Button("Apply Base64##Name"u8)) _lastError = new ApplyStateName(_pluginInterface).Invoke(_base64State, _gameObjectName, _key, _flags); IpcTesterHelpers.DrawIntro(RevertState.Label); - if (ImGui.Button("Revert##Idx")) + if (ImUtf8.Button("Revert##Idx"u8)) _lastError = new RevertState(_pluginInterface).Invoke(_gameObjectIndex, _key, _flags); IpcTesterHelpers.DrawIntro(RevertStateName.Label); - if (ImGui.Button("Revert##Name")) + if (ImUtf8.Button("Revert##Name"u8)) _lastError = new RevertStateName(_pluginInterface).Invoke(_gameObjectName, _key, _flags); IpcTesterHelpers.DrawIntro(UnlockState.Label); - if (ImGui.Button("Unlock##Idx")) + if (ImUtf8.Button("Unlock##Idx"u8)) _lastError = new UnlockState(_pluginInterface).Invoke(_gameObjectIndex, _key); IpcTesterHelpers.DrawIntro(UnlockStateName.Label); - if (ImGui.Button("Unlock##Name")) + if (ImUtf8.Button("Unlock##Name"u8)) _lastError = new UnlockStateName(_pluginInterface).Invoke(_gameObjectName, _key); IpcTesterHelpers.DrawIntro(UnlockAll.Label); - if (ImGui.Button("Unlock##All")) + if (ImUtf8.Button("Unlock##All"u8)) _numUnlocked = new UnlockAll(_pluginInterface).Invoke(_key); ImGui.SameLine(); ImGui.TextUnformatted($"Unlocked {_numUnlocked}"); IpcTesterHelpers.DrawIntro(RevertToAutomation.Label); - if (ImGui.Button("Revert##AutomationIdx")) + if (ImUtf8.Button("Revert##AutomationIdx"u8)) _lastError = new RevertToAutomation(_pluginInterface).Invoke(_gameObjectIndex, _key, _flags); IpcTesterHelpers.DrawIntro(RevertToAutomationName.Label); - if (ImGui.Button("Revert##AutomationName")) + if (ImUtf8.Button("Revert##AutomationName"u8)) _lastError = new RevertToAutomationName(_pluginInterface).Invoke(_gameObjectName, _key, _flags); } @@ -162,44 +175,70 @@ public class StateIpcTester : IUiService, IDisposable if (_stateString == null) return; - using var p = ImRaii.Popup("State"); + using var p = ImUtf8.Popup("State"u8); if (!p) return; - if (ImGui.Button("Copy to Clipboard")) - ImGui.SetClipboardText(_stateString); + if (ImUtf8.Button("Copy to Clipboard"u8)) + ImUtf8.SetClipboardText(_stateString); if (_stateString[0] is '{') { ImGui.SameLine(); - if (ImGui.Button("Copy as Base64") && _state != null) - ImGui.SetClipboardText(DesignConverter.ToBase64(_state)); + if (ImUtf8.Button("Copy as Base64"u8) && _state != null) + ImUtf8.SetClipboardText(DesignConverter.ToBase64(_state)); } using var font = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(_stateString ?? string.Empty); + ImUtf8.TextWrapped(_stateString ?? string.Empty); - if (ImGui.Button("Close", -Vector2.UnitX) || !ImGui.IsWindowFocused()) + if (ImUtf8.Button("Close"u8, -Vector2.UnitX) || !ImGui.IsWindowFocused()) ImGui.CloseCurrentPopup(); } - private unsafe void PrintName() + private unsafe void PrintChangeName() { - ImGuiNative.igTextUnformatted(_lastStateChangeName.Path, _lastStateChangeName.Path + _lastStateChangeName.Length); + ImUtf8.Text(_lastStateChangeName.Span); + ImGui.SameLine(0, 0); + ImUtf8.Text($" ({_lastStateChangeType})"); ImGui.SameLine(); using (ImRaii.PushFont(UiBuilder.MonoFont)) { - ImGuiUtil.CopyOnClickSelectable($"0x{_lastStateChangeActor:X}"); + ImUtf8.CopyOnClickSelectable($"0x{_lastStateChangeActor:X}"); } ImGui.SameLine(); - ImGui.TextUnformatted($"at {_lastStateChangeTime.ToLocalTime().TimeOfDay}"); + ImUtf8.Text($"at {_lastStateChangeTime.ToLocalTime().TimeOfDay}"); } - private void OnStateChanged(nint actor, StateChangeType _) + private unsafe void PrintFinalizeName() + { + ImUtf8.Text(_lastStateFinalizeName.Span); + ImGui.SameLine(0, 0); + ImUtf8.Text($" ({_lastStateFinalizeType})"); + ImGui.SameLine(); + using (ImRaii.PushFont(UiBuilder.MonoFont)) + { + ImUtf8.CopyOnClickSelectable($"0x{_lastStateFinalizeActor:X}"); + } + + ImGui.SameLine(); + ImUtf8.Text($"at {_lastStateFinalizeTime.ToLocalTime().TimeOfDay}"); + } + + private void OnStateChanged(nint actor, StateChangeType type) { _lastStateChangeActor = actor; _lastStateChangeTime = DateTime.UtcNow; _lastStateChangeName = actor != nint.Zero ? ((Actor)actor).Utf8Name.Clone() : ByteString.Empty; + _lastStateChangeType = type; + } + + private void OnStateFinalized(nint actor, StateFinalizationType type) + { + _lastStateFinalizeActor = actor; + _lastStateFinalizeTime = DateTime.UtcNow; + _lastStateFinalizeName = actor != nint.Zero ? ((Actor)actor).Utf8Name.Clone() : ByteString.Empty; + _lastStateFinalizeType = type; } private void OnGPoseChange(bool value) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index fe71609..42eb8e9 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -460,7 +460,7 @@ public class DesignPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); - _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); + _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { IsFinal = true }); } } @@ -478,7 +478,7 @@ public class DesignPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys()); - _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); + _state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { IsFinal = true }); } } diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index 345df11..aeb96f6 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -196,7 +196,7 @@ public class NpcPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { var design = _converter.Convert(ToDesignData(), new StateMaterialManager(), ApplicationRules.NpcFromModifiers()); - _state.ApplyDesign(state, design, ApplySettings.Manual with { SendStateUpdate = true }); + _state.ApplyDesign(state, design, ApplySettings.Manual with { IsFinal = true }); } } @@ -214,7 +214,7 @@ public class NpcPanel if (_state.GetOrCreate(id, data.Objects[0], out var state)) { var design = _converter.Convert(ToDesignData(), new StateMaterialManager(), ApplicationRules.NpcFromModifiers()); - _state.ApplyDesign(state, design, ApplySettings.Manual with { SendStateUpdate = true }); + _state.ApplyDesign(state, design, ApplySettings.Manual with { IsFinal = true }); } } diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index 466f1ae..ffa6581 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -18,6 +18,7 @@ public unsafe class UpdateSlotService : IDisposable public readonly BonusSlotUpdating BonusSlotUpdatingEvent; public readonly GearsetDataLoaded GearsetDataLoadedEvent; private readonly DictBonusItems _bonusItems; + public UpdateSlotService(EquipSlotUpdating equipSlotUpdating, BonusSlotUpdating bonusSlotUpdating, GearsetDataLoaded gearsetDataLoaded, IGameInteropProvider interop, DictBonusItems bonusItems) { @@ -26,8 +27,8 @@ public unsafe class UpdateSlotService : IDisposable GearsetDataLoadedEvent = gearsetDataLoaded; _bonusItems = bonusItems; - _loadGearsetDataHook = interop.HookFromAddress((nint)DrawDataContainer.MemberFunctionPointers.LoadGearsetData, LoadGearsetDataDetour); interop.InitializeFromAttributes(this); + _loadGearsetDataHook = interop.HookFromAddress((nint)DrawDataContainer.MemberFunctionPointers.LoadGearsetData, LoadGearsetDataDetour); _flagSlotForUpdateHook.Enable(); _flagBonusSlotForUpdateHook.Enable(); _loadGearsetDataHook.Enable(); @@ -89,8 +90,8 @@ public unsafe class UpdateSlotService : IDisposable /// Detours the func that makes all FlagSlotForUpdate calls on a gearset change or initial render of a given actor (Only Cases this is Called). /// Logic done after returning the original hook executes After all equipment/weapon/crest data is loaded into the Actors BaseData. /// - private delegate Int64 LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, PacketPlayerGearsetData* gearsetData); - private readonly Hook _loadGearsetDataHook = null!; + private delegate ulong LoadGearsetDataDelegate(DrawDataContainer* drawDataContainer, PacketPlayerGearsetData* gearsetData); + private readonly Hook _loadGearsetDataHook; private ulong FlagSlotForUpdateDetour(nint drawObject, uint slotIdx, CharacterArmor* data) { @@ -115,30 +116,30 @@ public unsafe class UpdateSlotService : IDisposable Glamourer.Log.Excessive($"[FlagBonusSlotForUpdate] Glamourer-Invoked on 0x{drawObject.Address:X} on {slot} with item data {armor}."); return _flagSlotForUpdateHook.Original(drawObject.Address, slot.ToIndex(), &armor); } - private Int64 LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, PacketPlayerGearsetData* gearsetData) + private ulong LoadGearsetDataDetour(DrawDataContainer* drawDataContainer, PacketPlayerGearsetData* gearsetData) { var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); - Model drawObject = drawDataContainer->OwnerObject->DrawObject; + var drawObject = drawDataContainer->OwnerObject->DrawObject; GearsetDataLoadedEvent.Invoke(drawObject); - // Glamourer.Log.Excessive($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); + Glamourer.Log.Excessive($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); return ret; } - // If you ever care to debug this, here is a formatted string output of this new gearsetData struct. - private string FormatGearsetItemDataStruct(PacketPlayerGearsetData gearsetData) + + private static string FormatGearsetItemDataStruct(PacketPlayerGearsetData gearsetData) { - string ret = + var ret = $"\nMainhandWeaponData: Id: {gearsetData.MainhandWeaponData.Id}, Type: {gearsetData.MainhandWeaponData.Type}, " + $"Variant: {gearsetData.MainhandWeaponData.Variant}, Stain0: {gearsetData.MainhandWeaponData.Stain0}, Stain1: {gearsetData.MainhandWeaponData.Stain1}" + $"\nOffhandWeaponData: Id: {gearsetData.OffhandWeaponData.Id}, Type: {gearsetData.OffhandWeaponData.Type}, " + $"Variant: {gearsetData.OffhandWeaponData.Variant}, Stain0: {gearsetData.OffhandWeaponData.Stain0}, Stain1: {gearsetData.OffhandWeaponData.Stain1}" + $"\nCrestBitField: {gearsetData.CrestBitField} | JobId: {gearsetData.JobId}"; - for (int offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) + for (var offset = 20; offset <= 56; offset += sizeof(LegacyCharacterArmor)) { - LegacyCharacterArmor* equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetData + offset); - int dyeOffset = (offset - 20) / sizeof(LegacyCharacterArmor) + 60; // Calculate the corresponding dye offset - byte* dyePtr = (byte*)&gearsetData + dyeOffset; - ret += $"\nEquipSlot {((EquipSlot)(dyeOffset - 60)).ToString()}:: Id: {(*equipSlotPtr).Set}, Variant: {(*equipSlotPtr).Variant}, Stain0: {(*equipSlotPtr).Stain.Id}, Stain1: {*dyePtr}"; + var equipSlotPtr = (LegacyCharacterArmor*)((byte*)&gearsetData + offset); + var dyeOffset = (offset - 20) / sizeof(LegacyCharacterArmor) + 60; // Calculate the corresponding dye offset + var dyePtr = (byte*)&gearsetData + dyeOffset; + ret += $"\nEquipSlot {(EquipSlot)(dyeOffset - 60)}:: Id: {(*equipSlotPtr).Set}, Variant: {(*equipSlotPtr).Variant}, Stain0: {(*equipSlotPtr).Stain.Id}, Stain1: {*dyePtr}"; } return ret; } diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index a869a09..98dfa19 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -668,7 +668,7 @@ public class CommandService : IDisposable, IApiService if (!_objects.TryGetValue(identifier, out var actors)) { if (_stateManager.TryGetValue(identifier, out var state)) - _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); + _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { IsFinal = true }); } else { @@ -677,7 +677,7 @@ public class CommandService : IDisposable, IApiService if (_stateManager.GetOrCreate(actor.GetIdentifier(_actors), actor, out var state)) { ApplyModSettings(design, actor, applyMods); - _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true }); + _stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { IsFinal = true }); } } } diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index ebf347f..42058d2 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -17,7 +17,7 @@ public class StateEditor( InternalStateEditor editor, StateApplier applier, StateChanged stateChanged, - StateUpdated stateUpdated, + StateFinalized stateFinalized, JobChangeState jobChange, Configuration config, ItemManager items, @@ -25,12 +25,12 @@ public class StateEditor( ModSettingApplier modApplier, GPoseService gPose) : IDesignEditor { - protected readonly InternalStateEditor Editor = editor; - protected readonly StateApplier Applier = applier; - protected readonly StateChanged StateChanged = stateChanged; - protected readonly StateUpdated StateUpdated = stateUpdated; - protected readonly Configuration Config = config; - protected readonly ItemManager Items = items; + protected readonly InternalStateEditor Editor = editor; + protected readonly StateApplier Applier = applier; + protected readonly StateChanged StateChanged = stateChanged; + protected readonly StateFinalized StateFinalized = stateFinalized; + protected readonly Configuration Config = config; + protected readonly ItemManager Items = items; /// Turn an actor to. public void ChangeModelId(ActorState state, uint modelId, CustomizeArray customize, nint equipData, StateSource source, @@ -43,7 +43,7 @@ public class StateEditor( Glamourer.Log.Verbose( $"Set model id in state {state.Identifier.Incognito(null)} from {old} to {modelId}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Model, source, state, actors, null); - StateUpdated.Invoke(StateFinalizationType.ModelChange, actors); + StateFinalized.Invoke(StateFinalizationType.ModelChange, actors); } /// @@ -383,7 +383,7 @@ public class StateEditor( Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key); } - if (settings.ResetMaterials || (!settings.RespectManual && mergedDesign.ResetAdvancedDyes)) + if (settings.ResetMaterials || !settings.RespectManual && mergedDesign.ResetAdvancedDyes) state.Materials.Clear(); foreach (var (key, value) in mergedDesign.Design.Materials) @@ -420,8 +420,8 @@ public class StateEditor( Glamourer.Log.Verbose( $"Applied design to {state.Identifier.Incognito(null)}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Design, state.Sources[MetaIndex.Wetness], state, actors, null); // FIXME: maybe later - if(settings.SendStateUpdate) - StateUpdated.Invoke(StateFinalizationType.DesignApplied, actors); + if (settings.IsFinal) + StateFinalized.Invoke(StateFinalizationType.DesignApplied, actors); return; @@ -442,7 +442,8 @@ public class StateEditor( if (!settings.MergeLinks || design is not Design d) merged = new MergedDesign(design); else - merged = merger.Merge(d.AllLinks(true), state.ModelData.IsHuman ? state.ModelData.Customize : CustomizeArray.Default, state.BaseData, + merged = merger.Merge(d.AllLinks(true), state.ModelData.IsHuman ? state.ModelData.Customize : CustomizeArray.Default, + state.BaseData, false, Config.AlwaysApplyAssociatedMods); ApplyDesign(data, merged, settings with @@ -460,7 +461,7 @@ public class StateEditor( if (!Config.ChangeEntireItem || !settings.Source.IsManual()) return; - var mh = newMainhand ?? state.ModelData.Item(EquipSlot.MainHand); + var mh = newMainhand ?? state.ModelData.Item(EquipSlot.MainHand); // Do not change Shields to nothing. if (mh.Type is FullEquipType.Sword) return; diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index d8648bb..3a6d6ef 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -41,7 +41,7 @@ public class StateListener : IDisposable private readonly HeadGearVisibilityChanged _headGearVisibility; private readonly VisorStateChanged _visorState; private readonly WeaponVisibilityChanged _weaponVisibility; - private readonly StateUpdated _stateUpdated; + private readonly StateFinalized _stateFinalized; private readonly AutoDesignApplier _autoDesignApplier; private readonly FunModule _funModule; private readonly HumanModelList _humans; @@ -63,7 +63,7 @@ public class StateListener : IDisposable WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, GPoseService gPose, ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, - CrestService crestService, BonusSlotUpdating bonusSlotUpdating, StateUpdated stateUpdated) + CrestService crestService, BonusSlotUpdating bonusSlotUpdating, StateFinalized stateFinalized) { _manager = manager; _items = items; @@ -88,7 +88,7 @@ public class StateListener : IDisposable _condition = condition; _crestService = crestService; _bonusSlotUpdating = bonusSlotUpdating; - _stateUpdated = stateUpdated; + _stateFinalized = stateFinalized; Subscribe(); } @@ -281,7 +281,7 @@ public class StateListener : IDisposable _objects.Update(); if (_objects.TryGetValue(identifier, out var actors) && actors.Valid) - _stateUpdated.Invoke(StateFinalizationType.Gearset, actors); + _stateFinalized.Invoke(StateFinalizationType.Gearset, actors); } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 948e225..9b71586 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -18,20 +18,20 @@ using Penumbra.GameData.Interop; namespace Glamourer.State; public sealed class StateManager( - ActorManager _actors, + ActorManager actors, ItemManager items, - StateChanged @event, - StateUpdated @event2, + StateChanged changeEvent, + StateFinalized finalizeEvent, StateApplier applier, InternalStateEditor editor, - HumanModelList _humans, - IClientState _clientState, + HumanModelList humans, + IClientState clientState, Configuration config, JobChangeState jobChange, DesignMerger merger, ModSettingApplier modApplier, GPoseService gPose) - : StateEditor(editor, applier, @event, @event2, jobChange, config, items, merger, modApplier, gPose), + : StateEditor(editor, applier, changeEvent, finalizeEvent, jobChange, config, items, merger, modApplier, gPose), IReadOnlyDictionary { private readonly Dictionary _states = []; @@ -62,7 +62,7 @@ public sealed class StateManager( /// public bool GetOrCreate(Actor actor, [NotNullWhen(true)] out ActorState? state) - => GetOrCreate(actor.GetIdentifier(_actors), actor, out state); + => GetOrCreate(actor.GetIdentifier(actors), actor, out state); /// Try to obtain or create a new state for an existing actor. Returns false if no state could be created. public unsafe bool GetOrCreate(ActorIdentifier identifier, Actor actor, [NotNullWhen(true)] out ActorState? state) @@ -82,7 +82,7 @@ public sealed class StateManager( ModelData = FromActor(actor, true, false), BaseData = FromActor(actor, false, false), LastJob = (byte)(actor.IsCharacter ? actor.AsCharacter->CharacterData.ClassJob : 0), - LastTerritory = _clientState.TerritoryType, + LastTerritory = clientState.TerritoryType, }; // state.Identifier is owned. _states.Add(state.Identifier, state); @@ -115,7 +115,7 @@ public sealed class StateManager( // Model ID is only unambiguously contained in the game object. // The draw object only has the object type. // TODO reverse search model data to get model id from model. - if (!_humans.IsHuman((uint)actor.AsCharacter->ModelContainer.ModelCharaId)) + if (!humans.IsHuman((uint)actor.AsCharacter->ModelContainer.ModelCharaId)) { ret.LoadNonHuman((uint)actor.AsCharacter->ModelContainer.ModelCharaId, *(CustomizeArray*)&actor.AsCharacter->DrawData.CustomizeData, (nint)Unsafe.AsPointer(ref actor.AsCharacter->DrawData.EquipmentModelIds[0])); @@ -236,7 +236,7 @@ public sealed class StateManager( public void TurnHuman(ActorState state, StateSource source, uint key = 0) => ChangeModelId(state, 0, CustomizeArray.Default, nint.Zero, source, key); - public void ResetState(ActorState state, StateSource source, uint key = 0, bool stateUpdate = false) + public void ResetState(ActorState state, StateSource source, uint key = 0, bool isFinal = false) { if (!state.Unlock(key)) return; @@ -278,8 +278,8 @@ public sealed class StateManager( $"Reset entire state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); // only invoke if we define this reset call as the final call in our state update. - if(stateUpdate) - StateUpdated.Invoke(StateFinalizationType.Revert, actors); + if(isFinal) + StateFinalized.Invoke(StateFinalizationType.Revert, actors); } public void ResetAdvancedState(ActorState state, StateSource source, uint key = 0) @@ -306,7 +306,7 @@ public sealed class StateManager( $"Reset advanced customization and dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) - StateUpdated.Invoke(StateFinalizationType.RevertAdvanced, actors); + StateFinalized.Invoke(StateFinalizationType.RevertAdvanced, actors); } public void ResetCustomize(ActorState state, StateSource source, uint key = 0) @@ -325,7 +325,7 @@ public sealed class StateManager( Glamourer.Log.Verbose( $"Reset customization state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) - StateUpdated.Invoke(StateFinalizationType.RevertCustomize, actors); + StateFinalized.Invoke(StateFinalizationType.RevertCustomize, actors); } public void ResetEquip(ActorState state, StateSource source, uint key = 0) @@ -376,7 +376,7 @@ public sealed class StateManager( Glamourer.Log.Verbose( $"Reset equipment state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); // Update that we have completed a full operation. (We can do this directly as nothing else is linked) - StateUpdated.Invoke(StateFinalizationType.RevertEquipment, actors); + StateFinalized.Invoke(StateFinalizationType.RevertEquipment, actors); } public void ResetStateFixed(ActorState state, bool respectManualPalettes, uint key = 0) @@ -453,23 +453,23 @@ public sealed class StateManager( } } - public void ReapplyState(Actor actor, bool forceRedraw, StateSource source, bool stateUpdate = false) + public void ReapplyState(Actor actor, bool forceRedraw, StateSource source, bool isFinal = false) { if (!GetOrCreate(actor, out var state)) return; - ReapplyState(actor, state, forceRedraw, source, stateUpdate); + ReapplyState(actor, state, forceRedraw, source, isFinal); } - public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source, bool stateUpdate) + public void ReapplyState(Actor actor, ActorState state, bool forceRedraw, StateSource source, bool isFinal) { var data = Applier.ApplyAll(state, forceRedraw || !actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); - if(stateUpdate) - StateUpdated.Invoke(StateFinalizationType.Reapply, data); + if(isFinal) + StateFinalized.Invoke(StateFinalizationType.Reapply, data); } /// Automation variant for reapply, to fire the correct StateUpdateType once reapplied. @@ -490,7 +490,7 @@ public sealed class StateManager( || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); // invoke the automation update based on what reset is. - StateUpdated.Invoke(wasReset ? StateFinalizationType.RevertAutomation : StateFinalizationType.ReapplyAutomation, data); + StateFinalized.Invoke(wasReset ? StateFinalizationType.RevertAutomation : StateFinalizationType.ReapplyAutomation, data); } public void DeleteState(ActorIdentifier identifier) From 0123fe1fbd448df9fd2a3873f3d8c761938e7427 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 17:52:06 +0100 Subject: [PATCH 190/401] Increment minor API version. --- Glamourer/Api/GlamourerApi.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 24ed840..62107a9 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -6,7 +6,7 @@ namespace Glamourer.Api; public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; - public const int CurrentApiVersionMinor = 3; + public const int CurrentApiVersionMinor = 4; public (int Major, int Minor) ApiVersion => (CurrentApiVersionMajor, CurrentApiVersionMinor); From cd6a6a462db26d97799b7da11d2d3c12c72f5bb5 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 24 Jan 2025 16:54:22 +0000 Subject: [PATCH 191/401] [CI] Updating repo.json for testing_1.3.5.4 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 5f4ae31..076063b 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.5.1", - "TestingAssemblyVersion": "1.3.5.3", + "TestingAssemblyVersion": "1.3.5.4", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.4/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 356b814102b65e961a8f9c5c9a2e536df4f7f16a Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 11:14:50 -0800 Subject: [PATCH 192/401] Append conversion for SetMetaFlag -> MetaIndex for help in moving down the API call to the state editor call. --- Glamourer/Designs/MetaIndex.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Glamourer/Designs/MetaIndex.cs b/Glamourer/Designs/MetaIndex.cs index edbf7b6..9cf6472 100644 --- a/Glamourer/Designs/MetaIndex.cs +++ b/Glamourer/Designs/MetaIndex.cs @@ -1,4 +1,5 @@ -using Glamourer.State; +using Glamourer.Api.Enums; +using Glamourer.State; namespace Glamourer.Designs; @@ -37,6 +38,16 @@ public static class MetaExtensions _ => (MetaFlag)byte.MaxValue, }; + public static MetaIndex ToIndex(this SetMetaFlag index) + => index switch + { + SetMetaFlag.Wetness => MetaIndex.Wetness, + SetMetaFlag.HatState => MetaIndex.HatState, + SetMetaFlag.VisorState => MetaIndex.VisorState, + SetMetaFlag.WeaponState => MetaIndex.WeaponState, + _ => (MetaIndex)byte.MaxValue, + }; + public static MetaIndex ToIndex(this MetaFlag index) => index switch { From 091aadd4a62c81f5569746a2f6ed7b50a3d7c512 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 11:25:40 -0800 Subject: [PATCH 193/401] Add Yield return Indices List for setter helper --- Glamourer/Designs/MetaIndex.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Glamourer/Designs/MetaIndex.cs b/Glamourer/Designs/MetaIndex.cs index 9cf6472..9552e5a 100644 --- a/Glamourer/Designs/MetaIndex.cs +++ b/Glamourer/Designs/MetaIndex.cs @@ -48,6 +48,19 @@ public static class MetaExtensions _ => (MetaIndex)byte.MaxValue, }; + public static IEnumerable ToIndices(this SetMetaFlag index) + { + if (index.HasFlag(SetMetaFlag.Wetness)) + yield return MetaIndex.Wetness; + if (index.HasFlag(SetMetaFlag.HatState)) + yield return MetaIndex.HatState; + if (index.HasFlag(SetMetaFlag.VisorState)) + yield return MetaIndex.VisorState; + if (index.HasFlag(SetMetaFlag.WeaponState)) + yield return MetaIndex.WeaponState; + } + + public static MetaIndex ToIndex(this MetaFlag index) => index switch { From 439849edfac8cde614af660407cd229c0f1fd216 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 11:35:53 -0800 Subject: [PATCH 194/401] Append SetMetaState with object index. --- Glamourer/Api/ItemsApi.cs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index fd174ca..ef320f8 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -6,6 +6,7 @@ using Glamourer.State; using OtterGui.Services; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; +using static OtterGui.ItemSelector; namespace Glamourer.Api; @@ -96,9 +97,9 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager if (!ResolveBonusItem(slot, bonusItemId, out var item)) return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); - var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key); - var anyHuman = false; - var anyFound = false; + var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key); + var anyHuman = false; + var anyFound = false; var anyUnlocked = false; foreach (var state in helpers.FindStates(playerName)) { @@ -125,6 +126,29 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); return ApiHelpers.Return(GlamourerApiEc.Success, args); + } + + public GlamourerApiEc SetMetaState(int objectIndex, bool newValue, uint key, SetMetaFlag metaFlags) + { + var args = ApiHelpers.Args("Index", objectIndex, "Value", newValue, "Key", key, "Flags", metaFlags); + if (metaFlags == 0) + return ApiHelpers.Return(GlamourerApiEc.InvalidState, args); + + if (helpers.FindState(objectIndex) is not { } state) + return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); + + if (!state.ModelData.IsHuman) + return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args); + + if (!state.CanUnlock(key)) + return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); + + // Grab MetaIndices from attached flags, and update the states. + var indices = metaFlags.ToIndices(); + foreach (var index in indices) + stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); + + return GlamourerApiEc.Success; } private bool ResolveItem(ApiEquipSlot apiSlot, ulong itemId, out EquipItem item) From 0ed4603ba526371986eec7aaa9bc79dbc43205ac Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 11:42:52 -0800 Subject: [PATCH 195/401] Corrected Paramater fields to include ApplyFlags and removed unessisary using. --- Glamourer/Api/ItemsApi.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index ef320f8..307a94f 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -6,7 +6,6 @@ using Glamourer.State; using OtterGui.Services; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; -using static OtterGui.ItemSelector; namespace Glamourer.Api; @@ -128,10 +127,10 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.Success, args); } - public GlamourerApiEc SetMetaState(int objectIndex, bool newValue, uint key, SetMetaFlag metaFlags) + public GlamourerApiEc SetMetaState(int objectIndex, SetMetaFlag metaStates, bool newValue, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Index", objectIndex, "Value", newValue, "Key", key, "Flags", metaFlags); - if (metaFlags == 0) + var args = ApiHelpers.Args("Index", objectIndex, "MetaStates", metaStates, "NewValue", newValue, "Key", key, "ApplyFlags", flags); + if (metaStates == 0) return ApiHelpers.Return(GlamourerApiEc.InvalidState, args); if (helpers.FindState(objectIndex) is not { } state) @@ -144,7 +143,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); // Grab MetaIndices from attached flags, and update the states. - var indices = metaFlags.ToIndices(); + var indices = metaStates.ToIndices(); foreach (var index in indices) stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); From 611200d311f1a0d7a9ae816a26f3a4fea886fa13 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 11:43:26 -0800 Subject: [PATCH 196/401] Added setMetaState by name --- Glamourer/Api/ItemsApi.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index 307a94f..0dce795 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -150,6 +150,44 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return GlamourerApiEc.Success; } + public GlamourerApiEc SetMetaStateName(string playerName, SetMetaFlag metaStates, bool newValue, uint key, ApplyFlag flags) + { + var args = ApiHelpers.Args("Name", playerName, "MetaStates", metaStates, "NewValue", newValue, "Key", key, "ApplyFlags", flags); + if (metaStates == 0) + return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); + + var indices = metaStates.ToIndices(); + var anyHuman = false; + var anyFound = false; + var anyUnlocked = false; + foreach (var state in helpers.FindStates(playerName)) + { + anyFound = true; + if (!state.ModelData.IsHuman) + continue; + + anyHuman = true; + if (!state.CanUnlock(key)) + continue; + + anyUnlocked = true; + // update all MetaStates for this ActorState + foreach (var index in indices) + stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); + } + + if (!anyFound) + return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); + + if (!anyHuman) + return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args); + + if (!anyUnlocked) + return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); + + return ApiHelpers.Return(GlamourerApiEc.Success, args); + } + private bool ResolveItem(ApiEquipSlot apiSlot, ulong itemId, out EquipItem item) { var id = (CustomItemId)itemId; From 0f127a557d2e5dd4bb85b5e45e87bf1ba22b59a0 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 11:44:09 -0800 Subject: [PATCH 197/401] Introduced locks, if nessisary for change. --- Glamourer/Api/ItemsApi.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index 0dce795..c73c853 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -144,8 +144,11 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager // Grab MetaIndices from attached flags, and update the states. var indices = metaStates.ToIndices(); - foreach (var index in indices) - stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); + foreach (var index in indices) + { + stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); + ApiHelpers.Lock(state, key, flags); + } return GlamourerApiEc.Success; } @@ -172,8 +175,11 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager anyUnlocked = true; // update all MetaStates for this ActorState - foreach (var index in indices) - stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); + foreach (var index in indices) + { + stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); + ApiHelpers.Lock(state, key, flags); + } } if (!anyFound) From 5eb545f62d48ab5a653df95d97161edfa6234adc Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 24 Jan 2025 13:09:49 -0800 Subject: [PATCH 198/401] Namechange: SetMetaState -> SetMeta Help clear up confusion on if it is in the StateApi section or the ItemsApi section (Which it is currently in) --- Glamourer/Api/ItemsApi.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index c73c853..b27264d 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -127,10 +127,10 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.Success, args); } - public GlamourerApiEc SetMetaState(int objectIndex, SetMetaFlag metaStates, bool newValue, uint key, ApplyFlag flags) + public GlamourerApiEc SetMeta(int objectIndex, SetMetaFlag types, bool newValue, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Index", objectIndex, "MetaStates", metaStates, "NewValue", newValue, "Key", key, "ApplyFlags", flags); - if (metaStates == 0) + var args = ApiHelpers.Args("Index", objectIndex, "Meta Types", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags); + if (types == 0) return ApiHelpers.Return(GlamourerApiEc.InvalidState, args); if (helpers.FindState(objectIndex) is not { } state) @@ -143,7 +143,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); // Grab MetaIndices from attached flags, and update the states. - var indices = metaStates.ToIndices(); + var indices = types.ToIndices(); foreach (var index in indices) { stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); @@ -153,13 +153,13 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return GlamourerApiEc.Success; } - public GlamourerApiEc SetMetaStateName(string playerName, SetMetaFlag metaStates, bool newValue, uint key, ApplyFlag flags) + public GlamourerApiEc SetMetaState(string playerName, SetMetaFlag types, bool newValue, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Name", playerName, "MetaStates", metaStates, "NewValue", newValue, "Key", key, "ApplyFlags", flags); - if (metaStates == 0) + var args = ApiHelpers.Args("Name", playerName, "Meta Types", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags); + if (types == 0) return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); - var indices = metaStates.ToIndices(); + var indices = types.ToIndices(); var anyHuman = false; var anyFound = false; var anyUnlocked = false; From f6c9ecad6076e32a379f245479b900291de29ad2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 23:28:23 +0100 Subject: [PATCH 199/401] Move MetaFlag completely to API, rename, cleanup. --- Glamourer.Api | 2 +- Glamourer/Api/ItemsApi.cs | 11 +++-- Glamourer/Automation/ApplicationType.cs | 3 +- Glamourer/Designs/ApplicationCollection.cs | 1 + Glamourer/Designs/ApplicationRules.cs | 3 +- Glamourer/Designs/DesignBase64Migration.cs | 3 +- Glamourer/Designs/Links/DesignMerger.cs | 3 +- Glamourer/Designs/MetaIndex.cs | 46 ++++++--------------- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 1 + Glamourer/Gui/ToggleDrawData.cs | 3 +- Glamourer/State/StateIndex.cs | 3 +- 11 files changed, 33 insertions(+), 46 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 4ac38fb..8de6fa7 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 4ac38fbed6fb0f31c0b75de26950ab82d3bee258 +Subproject commit 8de6fa7246a403de50b3be4e17bb5f188717b279 diff --git a/Glamourer/Api/ItemsApi.cs b/Glamourer/Api/ItemsApi.cs index b27264d..ac971c9 100644 --- a/Glamourer/Api/ItemsApi.cs +++ b/Glamourer/Api/ItemsApi.cs @@ -127,9 +127,9 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return ApiHelpers.Return(GlamourerApiEc.Success, args); } - public GlamourerApiEc SetMeta(int objectIndex, SetMetaFlag types, bool newValue, uint key, ApplyFlag flags) + public GlamourerApiEc SetMetaState(int objectIndex, MetaFlag types, bool newValue, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Index", objectIndex, "Meta Types", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags); + var args = ApiHelpers.Args("Index", objectIndex, "MetaTypes", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags); if (types == 0) return ApiHelpers.Return(GlamourerApiEc.InvalidState, args); @@ -153,13 +153,12 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager return GlamourerApiEc.Success; } - public GlamourerApiEc SetMetaState(string playerName, SetMetaFlag types, bool newValue, uint key, ApplyFlag flags) + public GlamourerApiEc SetMetaStateName(string playerName, MetaFlag types, bool newValue, uint key, ApplyFlag flags) { - var args = ApiHelpers.Args("Name", playerName, "Meta Types", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags); + var args = ApiHelpers.Args("Name", playerName, "MetaTypes", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags); if (types == 0) return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args); - var indices = types.ToIndices(); var anyHuman = false; var anyFound = false; var anyUnlocked = false; @@ -175,7 +174,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager anyUnlocked = true; // update all MetaStates for this ActorState - foreach (var index in indices) + foreach (var index in types.ToIndices()) { stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual); ApiHelpers.Lock(state, key, flags); diff --git a/Glamourer/Automation/ApplicationType.cs b/Glamourer/Automation/ApplicationType.cs index 3d409cb..8871a0e 100644 --- a/Glamourer/Automation/ApplicationType.cs +++ b/Glamourer/Automation/ApplicationType.cs @@ -1,4 +1,5 @@ -using Glamourer.Designs; +using Glamourer.Api.Enums; +using Glamourer.Designs; using Glamourer.GameData; using Penumbra.GameData.Enums; diff --git a/Glamourer/Designs/ApplicationCollection.cs b/Glamourer/Designs/ApplicationCollection.cs index 0fd18f0..13813a3 100644 --- a/Glamourer/Designs/ApplicationCollection.cs +++ b/Glamourer/Designs/ApplicationCollection.cs @@ -1,3 +1,4 @@ +using Glamourer.Api.Enums; using Glamourer.GameData; using ImGuiNET; using Penumbra.GameData.Enums; diff --git a/Glamourer/Designs/ApplicationRules.cs b/Glamourer/Designs/ApplicationRules.cs index 3c5fed2..703a3ae 100644 --- a/Glamourer/Designs/ApplicationRules.cs +++ b/Glamourer/Designs/ApplicationRules.cs @@ -1,4 +1,5 @@ -using Glamourer.GameData; +using Glamourer.Api.Enums; +using Glamourer.GameData; using Glamourer.State; using ImGuiNET; using Penumbra.GameData.Enums; diff --git a/Glamourer/Designs/DesignBase64Migration.cs b/Glamourer/Designs/DesignBase64Migration.cs index a60c527..cab9e27 100644 --- a/Glamourer/Designs/DesignBase64Migration.cs +++ b/Glamourer/Designs/DesignBase64Migration.cs @@ -1,4 +1,5 @@ -using Glamourer.Services; +using Glamourer.Api.Enums; +using Glamourer.Services; using OtterGui; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index 0284322..847d5f1 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -1,4 +1,5 @@ -using Glamourer.Automation; +using Glamourer.Api.Enums; +using Glamourer.Automation; using Glamourer.Designs.Special; using Glamourer.GameData; using Glamourer.Interop.Material; diff --git a/Glamourer/Designs/MetaIndex.cs b/Glamourer/Designs/MetaIndex.cs index 9552e5a..3fc4655 100644 --- a/Glamourer/Designs/MetaIndex.cs +++ b/Glamourer/Designs/MetaIndex.cs @@ -12,15 +12,6 @@ public enum MetaIndex ModelId = StateIndex.MetaModelId, } -[Flags] -public enum MetaFlag : byte -{ - Wetness = 0x01, - HatState = 0x02, - VisorState = 0x04, - WeaponState = 0x08, -} - public static class MetaExtensions { public static readonly IReadOnlyList AllRelevant = @@ -38,29 +29,6 @@ public static class MetaExtensions _ => (MetaFlag)byte.MaxValue, }; - public static MetaIndex ToIndex(this SetMetaFlag index) - => index switch - { - SetMetaFlag.Wetness => MetaIndex.Wetness, - SetMetaFlag.HatState => MetaIndex.HatState, - SetMetaFlag.VisorState => MetaIndex.VisorState, - SetMetaFlag.WeaponState => MetaIndex.WeaponState, - _ => (MetaIndex)byte.MaxValue, - }; - - public static IEnumerable ToIndices(this SetMetaFlag index) - { - if (index.HasFlag(SetMetaFlag.Wetness)) - yield return MetaIndex.Wetness; - if (index.HasFlag(SetMetaFlag.HatState)) - yield return MetaIndex.HatState; - if (index.HasFlag(SetMetaFlag.VisorState)) - yield return MetaIndex.VisorState; - if (index.HasFlag(SetMetaFlag.WeaponState)) - yield return MetaIndex.WeaponState; - } - - public static MetaIndex ToIndex(this MetaFlag index) => index switch { @@ -68,9 +36,21 @@ public static class MetaExtensions MetaFlag.HatState => MetaIndex.HatState, MetaFlag.VisorState => MetaIndex.VisorState, MetaFlag.WeaponState => MetaIndex.WeaponState, - _ => (MetaIndex)byte.MaxValue, + _ => (MetaIndex)byte.MaxValue, }; + public static IEnumerable ToIndices(this MetaFlag index) + { + if (index.HasFlag(MetaFlag.Wetness)) + yield return MetaIndex.Wetness; + if (index.HasFlag(MetaFlag.HatState)) + yield return MetaIndex.HatState; + if (index.HasFlag(MetaFlag.VisorState)) + yield return MetaIndex.VisorState; + if (index.HasFlag(MetaFlag.WeaponState)) + yield return MetaIndex.WeaponState; + } + public static string ToName(this MetaIndex index) => index switch { diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 42eb8e9..dbe106b 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.ImGuiFileDialog; using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.System.Framework; +using Glamourer.Api.Enums; using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Designs.History; diff --git a/Glamourer/Gui/ToggleDrawData.cs b/Glamourer/Gui/ToggleDrawData.cs index 75edc72..28afc2c 100644 --- a/Glamourer/Gui/ToggleDrawData.cs +++ b/Glamourer/Gui/ToggleDrawData.cs @@ -1,4 +1,5 @@ -using Glamourer.Designs; +using Glamourer.Api.Enums; +using Glamourer.Designs; using Glamourer.State; using Penumbra.GameData.Enums; diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index 0ac52ec..e3f1863 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -1,4 +1,5 @@ -using Glamourer.Designs; +using Glamourer.Api.Enums; +using Glamourer.Designs; using Glamourer.GameData; using Penumbra.GameData.Enums; From 630c4dd894b64c1c0da4af547b51dfda97ef0bbd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 25 Jan 2025 14:00:36 +0100 Subject: [PATCH 200/401] Update Submodules. --- OtterGui | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OtterGui b/OtterGui index fd38721..3c1260c 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit fd387218d2d2d237075cb35be6ca89eeb53e14e5 +Subproject commit 3c1260c9833303c2d33d12d6f77dc2b1afea3f34 diff --git a/Penumbra.GameData b/Penumbra.GameData index 5bac66e..bb59614 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 5bac66e5ad73e57919aff7f8b046606b75e191a2 +Subproject commit bb596141bb582505ae9fae1dd2914773503f4fe7 diff --git a/Penumbra.String b/Penumbra.String index 0647fbc..0bc2b0f 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 0647fbc5017ef9ced3f3ce1c2496eefd57c5b7a8 +Subproject commit 0bc2b0f66eee1a02c9575b2bb30f27ce166f8632 From b3afa2067cc1d7cf4c8a61688886d240e7f1a1e2 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 25 Jan 2025 13:02:30 +0000 Subject: [PATCH 201/401] [CI] Updating repo.json for testing_1.3.5.5 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 076063b..6ee99a9 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.5.1", - "TestingAssemblyVersion": "1.3.5.4", + "TestingAssemblyVersion": "1.3.5.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.4/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.5/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 2a067ef60b9b345b1903b4e246d48dfdea900138 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 30 Jan 2025 13:36:06 +0100 Subject: [PATCH 202/401] Accept all existing facepaints. --- Glamourer/GameData/CustomizeSet.cs | 4 +- Glamourer/GameData/CustomizeSetFactory.cs | 1 - Glamourer/GameData/NpcCustomizeSet.cs | 45 ++++++++++++------- .../DebugTab/CustomizationServicePanel.cs | 34 ++++++++++++-- Penumbra.GameData | 2 +- 5 files changed, 63 insertions(+), 23 deletions(-) diff --git a/Glamourer/GameData/CustomizeSet.cs b/Glamourer/GameData/CustomizeSet.cs index 178ef07..d0193aa 100644 --- a/Glamourer/GameData/CustomizeSet.cs +++ b/Glamourer/GameData/CustomizeSet.cs @@ -11,7 +11,7 @@ namespace Glamourer.GameData; /// public class CustomizeSet { - private NpcCustomizeSet _npcCustomizations; + private readonly NpcCustomizeSet _npcCustomizations; internal CustomizeSet(NpcCustomizeSet npcCustomizations, SubRace clan, Gender gender) { @@ -88,7 +88,7 @@ public class CustomizeSet { if (IsAvailable(index)) return DataByValue(index, value, out custom, face) >= 0 - || _npcCustomizations.CheckColor(index, value) + || _npcCustomizations.CheckValue(index, value) || NpcOptions.Any(t => t.Type == index && t.Value == value); custom = null; diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index 13a9865..77a6973 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -76,7 +76,6 @@ internal class CustomizeSetFactory( CustomizeIndex.Hairstyle, CustomizeIndex.LipColor, CustomizeIndex.SkinColor, - CustomizeIndex.FacePaint, CustomizeIndex.TailShape, }; diff --git a/Glamourer/GameData/NpcCustomizeSet.cs b/Glamourer/GameData/NpcCustomizeSet.cs index 4dbfd83..3cc19cd 100644 --- a/Glamourer/GameData/NpcCustomizeSet.cs +++ b/Glamourer/GameData/NpcCustomizeSet.cs @@ -3,6 +3,7 @@ using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game.Object; using Lumina.Excel.Sheets; using OtterGui.Services; +using Penumbra.GameData.Data; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -40,17 +41,19 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList private readonly BitArray _eyeColors = new(256); private readonly BitArray _facepaintColors = new(256); private readonly BitArray _tattooColors = new(256); + private readonly BitArray _facepaints = new(128); - public bool CheckColor(CustomizeIndex type, CustomizeValue value) + public bool CheckValue(CustomizeIndex type, CustomizeValue value) => type switch { - CustomizeIndex.HairColor => _hairColors[value.Value], - CustomizeIndex.HighlightsColor => _hairColors[value.Value], - CustomizeIndex.EyeColorLeft => _eyeColors[value.Value], - CustomizeIndex.EyeColorRight => _eyeColors[value.Value], - CustomizeIndex.FacePaintColor => _facepaintColors[value.Value], - CustomizeIndex.TattooColor => _tattooColors[value.Value], - _ => false, + CustomizeIndex.HairColor => _hairColors[value.Value], + CustomizeIndex.HighlightsColor => _hairColors[value.Value], + CustomizeIndex.EyeColorLeft => _eyeColors[value.Value], + CustomizeIndex.EyeColorRight => _eyeColors[value.Value], + CustomizeIndex.FacePaintColor => _facepaintColors[value.Value], + CustomizeIndex.TattooColor => _tattooColors[value.Value], + CustomizeIndex.FacePaint when value.Value < 128 => _facepaints[value.Value], + _ => false, }; /// Create the data when ready. @@ -58,13 +61,14 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList { var waitTask = Task.WhenAll(eNpcs.Awaiter, bNpcs.Awaiter, bNpcNames.Awaiter); Awaiter = waitTask.ContinueWith(_ => - { - var watch = Stopwatch.StartNew(); - var eNpcTask = Task.Run(() => CreateEnpcData(data, eNpcs)); - var bNpcTask = Task.Run(() => CreateBnpcData(data, bNpcs, bNpcNames)); - FilterAndOrderNpcData(eNpcTask.Result, bNpcTask.Result); - Time = watch.ElapsedMilliseconds; - }); + { + var watch = Stopwatch.StartNew(); + var eNpcTask = Task.Run(() => CreateEnpcData(data, eNpcs)); + var bNpcTask = Task.Run(() => CreateBnpcData(data, bNpcs, bNpcNames)); + FilterAndOrderNpcData(eNpcTask.Result, bNpcTask.Result); + Time = watch.ElapsedMilliseconds; + }) + .ContinueWith(_ => CheckFacepaintFiles(data, _facepaints)); } /// Create data from event NPCs. @@ -323,6 +327,17 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList return (true, customize); } + /// Check decal files for existence. + private static void CheckFacepaintFiles(IDataManager data, BitArray facepaints) + { + for (var i = 0; i < 128; ++i) + { + var path = GamePaths.Character.Tex.DecalPath("face", (PrimaryId)i); + if (data.FileExists(path)) + facepaints[i] = true; + } + } + /// public IEnumerator GetEnumerator() => _data.GetEnumerator(); diff --git a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs index afc7d56..565b6ba 100644 --- a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs @@ -28,9 +28,35 @@ public class CustomizationServicePanel(CustomizeService customize) : IGameDataDr DrawNpcCustomizationInfo(set); } + DrawFacepaintInfo(); DrawColorInfo(); } + private void DrawFacepaintInfo() + { + using var tree = ImUtf8.TreeNode("NPC Facepaints"u8); + if (!tree) + return; + + using var table = ImUtf8.Table("data"u8, 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + if (!table) + return; + + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Id"u8); + ImGui.TableNextColumn(); + ImUtf8.TableHeader("Facepaint"u8); + + for (var i = 0; i < 128; ++i) + { + var index = new CustomizeValue((byte)i); + ImUtf8.DrawTableColumn($"{i:D3}"); + using var font = ImRaii.PushFont(UiBuilder.IconFont); + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.FacePaint, index) + ? FontAwesomeIcon.Check.ToIconString() + : FontAwesomeIcon.Times.ToIconString()); + } + } private void DrawColorInfo() { using var tree = ImUtf8.TreeNode("NPC Colors"u8); @@ -57,16 +83,16 @@ public class CustomizationServicePanel(CustomizeService customize) : IGameDataDr var index = new CustomizeValue((byte)i); ImUtf8.DrawTableColumn($"{i:D3}"); using var font = ImRaii.PushFont(UiBuilder.IconFont); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.HairColor, index) + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.HairColor, index) ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.EyeColorLeft, index) + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.EyeColorLeft, index) ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.FacePaintColor, index) + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.FacePaintColor, index) ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckColor(CustomizeIndex.TattooColor, index) + ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.TattooColor, index) ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); } diff --git a/Penumbra.GameData b/Penumbra.GameData index bb59614..4880433 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit bb596141bb582505ae9fae1dd2914773503f4fe7 +Subproject commit 488043381efd42238e9c1328ccab3b80abd81ea7 From 1f255a98e6aef912680f2d247133bdecccfea028 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 30 Jan 2025 13:55:28 +0100 Subject: [PATCH 203/401] Fix issue with scaling after zone change. --- Glamourer/Glamourer.cs | 9 ----- Glamourer/Interop/ScalingService.cs | 54 +++++++++++++++++++++++------ Penumbra.GameData | 2 +- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 9c4583f..cf0b278 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -47,15 +47,6 @@ public class Glamourer : IDalamudPlugin _services.GetService(); // initialize commands. _services.GetService(); // initialize IPC. Log.Information($"Glamourer v{Version} loaded successfully."); - - //var text = File.ReadAllBytes(@"C:\FFXIVMods\PBDTest\files\human.pbd"); - //var pbd = new PbdFile(text); - //var roundtrip = pbd.Write(); - //File.WriteAllBytes(@"C:\FFXIVMods\PBDTest\files\Vanilla resaved save.pbd", roundtrip); - //var deformer = pbd.Deformers.FirstOrDefault(d => d.GenderRace is GenderRace.RoegadynFemale)!.RacialDeformer; - //deformer.DeformMatrices["ya_fukubu_phys"] = deformer.DeformMatrices["j_kosi"]; - //var aleks = pbd.Write(); - //File.WriteAllBytes(@"C:\FFXIVMods\PBDTest\files\rue.pbd", aleks); } catch { diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index 141d5f2..68dc2e8 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -1,19 +1,27 @@ -using Dalamud.Game.ClientState.Objects.Enums; -using Dalamud.Hooking; +using Dalamud.Hooking; using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; using Penumbra.GameData; using Penumbra.GameData.Interop; using FFXIVClientStructs.FFXIV.Client.Game.Object; +using Glamourer.State; +using Penumbra.GameData.Actors; +using Penumbra.GameData.Enums; using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character; +using CustomizeIndex = Dalamud.Game.ClientState.Objects.Enums.CustomizeIndex; namespace Glamourer.Interop; public unsafe class ScalingService : IDisposable { - public ScalingService(IGameInteropProvider interop) + private readonly ActorManager _actors; + private readonly StateManager _state; + + public ScalingService(IGameInteropProvider interop, StateManager state, ActorManager actors) { + _state = state; + _actors = actors; interop.InitializeFromAttributes(this); _setupMountHook = interop.HookFromAddress((nint)MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); @@ -79,7 +87,16 @@ public unsafe class ScalingService : IDisposable var mdl = owner.Model; var oldRace = owner.AsCharacter->DrawData.CustomizeData.Race; if (mdl.IsHuman) + { owner.AsCharacter->DrawData.CustomizeData.Race = mdl.AsHuman->Customize.Race; + } + else + { + var actor = _actors.FromObject(owner, out _, true, false, true); + if (_state.TryGetValue(actor, out var state)) + owner.AsCharacter->DrawData.CustomizeData.Race = (byte)state.ModelData.Customize.Race; + } + _placeMinionHook.Original(companion); owner.AsCharacter->DrawData.CustomizeData.Race = oldRace; } @@ -103,12 +120,20 @@ public unsafe class ScalingService : IDisposable character->DrawData.CustomizeData.Tribe, character->DrawData.CustomizeData[(int)CustomizeIndex.Height]); [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - private static void SetScaleCustomize(Character* character, Model model) + private void SetScaleCustomize(Character* character, Model model) { - if (!model.IsHuman) + if (model.IsHuman) + { + SetScaleCustomize(character, model.AsHuman->Customize.Race, model.AsHuman->Customize.Tribe, model.AsHuman->Customize.Sex); + return; + } + + var actor = _actors.FromObject(character, out _, true, false, true); + if (!_state.TryGetValue(actor, out var state)) return; - SetScaleCustomize(character, model.AsHuman->Customize.Race, model.AsHuman->Customize.Tribe, model.AsHuman->Customize.Sex); + ref var customize = ref state.ModelData.Customize; + SetScaleCustomize(character, (byte)customize.Race, (byte)customize.Clan, customize.Gender.ToGameByte()); } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] @@ -120,13 +145,22 @@ public unsafe class ScalingService : IDisposable } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - private static void SetHeightCustomize(Character* character, Model model) + private void SetHeightCustomize(Character* character, Model model) { - if (!model.IsHuman) + if (model.IsHuman) + { + SetHeightCustomize(character, model.AsHuman->Customize.Sex, model.AsHuman->Customize.BodyType, model.AsHuman->Customize.Tribe, + model.AsHuman->Customize[(int)CustomizeIndex.Height]); + return; + } + + var actor = _actors.FromObject(character, out _, true, false, true); + if (!_state.TryGetValue(actor, out var state)) return; - SetHeightCustomize(character, model.AsHuman->Customize.Sex, model.AsHuman->Customize.BodyType, model.AsHuman->Customize.Tribe, - model.AsHuman->Customize[(int)CustomizeIndex.Height]); + ref var customize = ref state.ModelData.Customize; + SetHeightCustomize(character, customize.Gender.ToGameByte(), customize.BodyType.Value, (byte)customize.Clan, + customize[global::Penumbra.GameData.Enums.CustomizeIndex.Height].Value); } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] diff --git a/Penumbra.GameData b/Penumbra.GameData index 4880433..33fea10 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 488043381efd42238e9c1328ccab3b80abd81ea7 +Subproject commit 33fea10e18ec9f8a5b309890de557fcb25780086 From 8e0908dbf7fcfe4cd1ee87cb0bba7408cd63887a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 30 Jan 2025 22:39:57 +0100 Subject: [PATCH 204/401] Add more settings to multi design panel. --- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 139 +++++++++++++++++- 1 file changed, 131 insertions(+), 8 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index a1f17d4..3d10e64 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -25,6 +25,10 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e var offset = DrawMultiTagger(width); DrawMultiColor(width, offset); DrawMultiQuickDesignBar(offset); + DrawMultiLock(offset); + DrawMultiResetSettings(offset); + DrawMultiResetDyes(offset); + DrawMultiForceRedraw(offset); } private void DrawCounts(Vector2 treeNodePos) @@ -43,19 +47,46 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ImGui.SetCursorPos(startPos); } + private void ResetCounts() + { + _numQuickDesignEnabled = 0; + _numDesignsLocked = 0; + _numDesignsForcedRedraw = 0; + _numDesignsResetSettings = 0; + _numDesignsResetDyes = 0; + } + + private bool CountLeaves(DesignFileSystem.IPath path) + { + if (path is not DesignFileSystem.Leaf l) + return false; + + if (l.Value.QuickDesign) + ++_numQuickDesignEnabled; + if (l.Value.WriteProtected()) + ++_numDesignsLocked; + if (l.Value.ResetTemporarySettings) + ++_numDesignsResetSettings; + if (l.Value.ForcedRedraw) + ++_numDesignsForcedRedraw; + if (l.Value.ResetAdvancedDyes) + ++_numDesignsResetDyes; + return true; + } + private int DrawDesignList() { + ResetCounts(); using var tree = ImUtf8.TreeNode("Currently Selected Objects"u8, ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.NoTreePushOnOpen); ImGui.Separator(); if (!tree) - return selector.SelectedPaths.Count(l => l is DesignFileSystem.Leaf); + return selector.SelectedPaths.Count(CountLeaves); var sizeType = new Vector2(ImGui.GetFrameHeight()); var availableSizePercent = (ImGui.GetContentRegionAvail().X - sizeType.X - 4 * ImGui.GetStyle().CellPadding.X) / 100; var sizeMods = availableSizePercent * 35; var sizeFolders = availableSizePercent * 65; - _numQuickDesignEnabled = 0; var numDesigns = 0; using (var table = ImUtf8.Table("mods"u8, 3, ImGuiTableFlags.RowBg)) { @@ -81,12 +112,8 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ImUtf8.DrawFrameColumn(text); ImUtf8.DrawFrameColumn(fullName); - if (path is not DesignFileSystem.Leaf l2) - continue; - - ++numDesigns; - if (l2.Value.QuickDesign) - ++_numQuickDesignEnabled; + if (CountLeaves(path)) + ++numDesigns; } } @@ -96,6 +123,10 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e private string _tag = string.Empty; private int _numQuickDesignEnabled; + private int _numDesignsLocked; + private int _numDesignsForcedRedraw; + private int _numDesignsResetSettings; + private int _numDesignsResetDyes; private int _numDesigns; private readonly List _addDesigns = []; private readonly List<(Design, int)> _removeDesigns = []; @@ -161,6 +192,98 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ImGui.Separator(); } + private void DrawMultiLock(float offset) + { + ImUtf8.TextFrameAligned("Multi Lock:"u8); + ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); + var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); + var diff = _numDesigns - _numDesignsLocked; + var tt = diff == 0 + ? $"All {_numDesigns} selected designs are already write protected." + : $"Write-protect all {_numDesigns} designs. Changes {diff} designs."; + if (ImUtf8.ButtonEx("Turn Write-Protected"u8, tt, buttonWidth, diff == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.SetWriteProtection(design.Value, true); + + ImGui.SameLine(); + tt = _numDesignsLocked == 0 + ? $"None of the {_numDesigns} selected designs are write-protected." + : $"Remove the write protection of the {_numDesigns} selected designs. Changes {_numDesignsLocked} designs."; + if (ImUtf8.ButtonEx("Remove Write-Protection"u8, tt, buttonWidth, _numDesignsLocked == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.SetWriteProtection(design.Value, false); + ImGui.Separator(); + } + + private void DrawMultiResetSettings(float offset) + { + ImUtf8.TextFrameAligned("Settings:"u8); + ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); + var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); + var diff = _numDesigns - _numDesignsResetSettings; + var tt = diff == 0 + ? $"All {_numDesigns} selected designs already reset temporary settings." + : $"Make all {_numDesigns} selected designs reset temporary settings. Changes {diff} designs."; + if (ImUtf8.ButtonEx("Set Reset Settings"u8, tt, buttonWidth, diff == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.ChangeResetTemporarySettings(design.Value, true); + + ImGui.SameLine(); + tt = _numDesignsResetSettings == 0 + ? $"None of the {_numDesigns} selected designs reset temporary settings." + : $"Stop all {_numDesigns} selected designs from resetting temporary settings. Changes {_numDesignsResetSettings} designs."; + if (ImUtf8.ButtonEx("Remove Reset Settings"u8, tt, buttonWidth, _numDesignsResetSettings == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.ChangeResetTemporarySettings(design.Value, false); + ImGui.Separator(); + } + + private void DrawMultiResetDyes(float offset) + { + ImUtf8.TextFrameAligned("Adv. Dyes:"u8); + ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); + var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); + var diff = _numDesigns - _numDesignsResetDyes; + var tt = diff == 0 + ? $"All {_numDesigns} selected designs already reset advanced dyes." + : $"Make all {_numDesigns} selected designs reset advanced dyes. Changes {diff} designs."; + if (ImUtf8.ButtonEx("Set Reset Dyes"u8, tt, buttonWidth, diff == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.ChangeResetAdvancedDyes(design.Value, true); + + ImGui.SameLine(); + tt = _numDesignsLocked == 0 + ? $"None of the {_numDesigns} selected designs reset advanced dyes." + : $"Stop all {_numDesigns} selected designs from resetting advanced dyes. Changes {_numDesignsResetDyes} designs."; + if (ImUtf8.ButtonEx("Remove Reset Dyes"u8, tt, buttonWidth, _numDesignsResetDyes == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.ChangeResetAdvancedDyes(design.Value, false); + ImGui.Separator(); + } + + private void DrawMultiForceRedraw(float offset) + { + ImUtf8.TextFrameAligned("Redrawing:"u8); + ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); + var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); + var diff = _numDesigns - _numDesignsForcedRedraw; + var tt = diff == 0 + ? $"All {_numDesigns} selected designs already force redraws." + : $"Make all {_numDesigns} designs force redraws. Changes {diff} designs."; + if (ImUtf8.ButtonEx("Force Redraws"u8, tt, buttonWidth, diff == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.ChangeForcedRedraw(design.Value, true); + + ImGui.SameLine(); + tt = _numDesignsLocked == 0 + ? $"None of the {_numDesigns} selected designs force redraws." + : $"Stop all {_numDesigns} selected designs from forcing redraws. Changes {_numDesignsForcedRedraw} designs."; + if (ImUtf8.ButtonEx("Remove Forced Redraws"u8, tt, buttonWidth, _numDesignsForcedRedraw == 0)) + foreach (var design in selector.SelectedPaths.OfType()) + editor.ChangeForcedRedraw(design.Value, false); + ImGui.Separator(); + } + private void DrawMultiColor(Vector2 width, float offset) { ImUtf8.TextFrameAligned("Multi Colors:"); From 9a1cf3d9e6023de497d7fa2c29add8490ab539ee Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 30 Jan 2025 22:45:59 +0100 Subject: [PATCH 205/401] Better --- Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 3d10e64..9e894c4 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -224,7 +224,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e var tt = diff == 0 ? $"All {_numDesigns} selected designs already reset temporary settings." : $"Make all {_numDesigns} selected designs reset temporary settings. Changes {diff} designs."; - if (ImUtf8.ButtonEx("Set Reset Settings"u8, tt, buttonWidth, diff == 0)) + if (ImUtf8.ButtonEx("Set Reset Temp. Settings"u8, tt, buttonWidth, diff == 0)) foreach (var design in selector.SelectedPaths.OfType()) editor.ChangeResetTemporarySettings(design.Value, true); @@ -232,7 +232,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e tt = _numDesignsResetSettings == 0 ? $"None of the {_numDesigns} selected designs reset temporary settings." : $"Stop all {_numDesigns} selected designs from resetting temporary settings. Changes {_numDesignsResetSettings} designs."; - if (ImUtf8.ButtonEx("Remove Reset Settings"u8, tt, buttonWidth, _numDesignsResetSettings == 0)) + if (ImUtf8.ButtonEx("Remove Reset Temp. Settings"u8, tt, buttonWidth, _numDesignsResetSettings == 0)) foreach (var design in selector.SelectedPaths.OfType()) editor.ChangeResetTemporarySettings(design.Value, false); ImGui.Separator(); From da46705b52a4537621cc728dcf56bb7525fa950b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 31 Jan 2025 16:06:50 +0100 Subject: [PATCH 206/401] Use new settings API. --- Glamourer/Interop/Penumbra/PenumbraService.cs | 76 ++++++++++++++----- Penumbra.Api | 2 +- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 13be628..27446ea 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -37,6 +37,7 @@ public class PenumbraService : IDisposable public const int RequiredPenumbraFeatureVersion = 3; public const int RequiredPenumbraFeatureVersionTemp = 4; public const int RequiredPenumbraFeatureVersionTemp2 = 5; + public const int RequiredPenumbraFeatureVersionTemp3 = 6; private const int Key = -1610; @@ -56,7 +57,9 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; + private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp? _getCurrentSettingsWithTemp; private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings? _getCurrentSettings; + private global::Penumbra.Api.IpcSubscribers.GetAllModSettings? _getAllSettings; private global::Penumbra.Api.IpcSubscribers.TryInheritMod? _inheritMod; private global::Penumbra.Api.IpcSubscribers.TrySetMod? _setMod; private global::Penumbra.Api.IpcSubscribers.TrySetModPriority? _setModPriority; @@ -132,22 +135,28 @@ public class PenumbraService : IDisposable public ModSettings GetModSettings(in Mod mod, out string source) { - source = string.Empty; + source = string.Empty; if (!Available) return ModSettings.Empty; try { var collection = _currentCollection!.Invoke(ApiCollectionType.Current); - if (_queryTemporaryModSettings != null) - { - var tempEc = _queryTemporaryModSettings.Invoke(collection!.Value.Id, mod.DirectoryName, out var tempTuple, out source); - if (tempEc is PenumbraApiEc.Success && tempTuple != null) - return new ModSettings(tempTuple.Value.Settings, tempTuple.Value.Priority, tempTuple.Value.Enabled, - tempTuple.Value.ForceInherit, false); - } + return GetSettings(collection!.Value.Id, mod.DirectoryName, mod.Name, out source); + } + catch (Exception ex) + { + Glamourer.Log.Error($"Error fetching mod settings for {mod.DirectoryName} from Penumbra:\n{ex}"); + return ModSettings.Empty; + } + } - var (ec, tuple) = _getCurrentSettings!.Invoke(collection!.Value.Id, mod.DirectoryName); + private ModSettings GetSettings(Guid collection, string modDirectory, string modName, out string source) + { + if (_getCurrentSettingsWithTemp != null) + { + source = string.Empty; + var (ec, tuple) = _getCurrentSettingsWithTemp!.Invoke(collection, modDirectory, modName, false, false, Key); if (ec is not PenumbraApiEc.Success) return ModSettings.Empty; @@ -155,11 +164,23 @@ public class PenumbraService : IDisposable ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1, false, false) : ModSettings.Empty; } - catch (Exception ex) + + if (_queryTemporaryModSettings != null) { - Glamourer.Log.Error($"Error fetching mod settings for {mod.DirectoryName} from Penumbra:\n{ex}"); - return ModSettings.Empty; + var tempEc = _queryTemporaryModSettings.Invoke(collection, modDirectory, out var tempTuple, out source); + if (tempEc is PenumbraApiEc.Success && tempTuple != null) + return new ModSettings(tempTuple.Value.Settings, tempTuple.Value.Priority, tempTuple.Value.Enabled, + tempTuple.Value.ForceInherit, false); } + + source = string.Empty; + var (ec2, tuple2) = _getCurrentSettings!.Invoke(collection, modDirectory); + if (ec2 is not PenumbraApiEc.Success) + return ModSettings.Empty; + + return tuple2.HasValue + ? new ModSettings(tuple2.Value.Item3, tuple2.Value.Item2, tuple2.Value.Item1, false, false) + : ModSettings.Empty; } public (Guid Id, string Name)? CollectionByIdentifier(string identifier) @@ -183,13 +204,23 @@ public class PenumbraService : IDisposable { var allMods = _getMods!.Invoke(); var collection = _currentCollection!.Invoke(ApiCollectionType.Current); + if (_getAllSettings != null) + { + var allSettings = _getAllSettings.Invoke(collection!.Value.Id, false, false, Key); + if (allSettings.Item1 is PenumbraApiEc.Success) + return allMods.Select(m => (new Mod(m.Value, m.Key), + allSettings.Item2!.TryGetValue(m.Key, out var s) + ? new ModSettings(s.Item3, s.Item2, s.Item1, s.Item4 && s.Item5, false) + : ModSettings.Empty)) + .OrderByDescending(p => p.Item2.Enabled) + .ThenBy(p => p.Item1.Name) + .ThenBy(p => p.Item1.DirectoryName) + .ThenByDescending(p => p.Item2.Priority) + .ToList(); + } + return allMods - .Select(m => (m.Key, m.Value, _getCurrentSettings!.Invoke(collection!.Value.Id, m.Key))) - .Where(t => t.Item3.Item1 is PenumbraApiEc.Success) - .Select(t => (new Mod(t.Item2, t.Item1), - !t.Item3.Item2.HasValue - ? ModSettings.Empty - : new ModSettings(t.Item3.Item2!.Value.Item3, t.Item3.Item2!.Value.Item2, t.Item3.Item2!.Value.Item1, false, false))) + .Select(m => (new Mod(m.Value, m.Key), GetSettings(collection!.Value.Id, m.Key, m.Value, out _))) .OrderByDescending(p => p.Item2.Enabled) .ThenBy(p => p.Item1.Name) .ThenBy(p => p.Item1.DirectoryName) @@ -455,7 +486,14 @@ public class PenumbraService : IDisposable _removeAllTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) + { _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); + if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) + { + _getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface); + _getAllSettings = new global::Penumbra.Api.IpcSubscribers.GetAllModSettings(_pluginInterface); + } + } } Available = true; @@ -488,6 +526,8 @@ public class PenumbraService : IDisposable _getMods = null; _currentCollection = null; _getCurrentSettings = null; + _getCurrentSettingsWithTemp = null; + _getAllSettings = null; _inheritMod = null; _setMod = null; _setModPriority = null; diff --git a/Penumbra.Api b/Penumbra.Api index b4e716f..35b25be 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit b4e716f86d94cd4d98d8f58e580ed5f619ea87ae +Subproject commit 35b25bef92e9b0be96c44c150a3df89d848d2658 From 87016419c5cc5c33bb2ef03d3b553d0397984b96 Mon Sep 17 00:00:00 2001 From: Diorik Date: Tue, 4 Feb 2025 00:46:12 -0600 Subject: [PATCH 207/401] Add "Reset Design" command A new command to reapply automation while resetting the random design regardless of settings. --- Glamourer/Api/StateApi.cs | 2 +- Glamourer/Automation/AutoDesignApplier.cs | 4 ++-- Glamourer/Gui/DesignQuickBar.cs | 4 ++-- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 4 ++-- Glamourer/Services/CommandService.cs | 11 +++++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index eaf9d01..b2fdc9b 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -301,7 +301,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void RevertToAutomation(Actor actor, ActorState state, uint key, ApplyFlag flags) { var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; - _autoDesigns.ReapplyAutomation(actor, state.Identifier, state, true, out var forcedRedraw); + _autoDesigns.ReapplyAutomation(actor, state.Identifier, state, true, false, out var forcedRedraw); _stateManager.ReapplyAutomationState(actor, state, forcedRedraw, true, source); ApiHelpers.Lock(state, key, flags); } diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 1655c15..7f75674 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -225,7 +225,7 @@ public sealed class AutoDesignApplier : IDisposable _state.ReapplyState(actor, forcedRedraw, StateSource.Fixed); } - public void ReapplyAutomation(Actor actor, ActorIdentifier identifier, ActorState state, bool reset, out bool forcedRedraw) + public void ReapplyAutomation(Actor actor, ActorIdentifier identifier, ActorState state, bool reset, bool forcedNew, out bool forcedRedraw) { forcedRedraw = false; if (!_config.EnableAutoDesigns) @@ -235,7 +235,7 @@ public sealed class AutoDesignApplier : IDisposable _state.ResetState(state, StateSource.Game); if (GetPlayerSet(identifier, out var set)) - Reduce(actor, state, set, false, false, false, out forcedRedraw); + Reduce(actor, state, set, false, false, forcedNew, out forcedRedraw); } public bool Reduce(Actor actor, ActorIdentifier identifier, [NotNullWhen(true)] out ActorState? state) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index 50f86fd..b58643c 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -251,7 +251,7 @@ public sealed class DesignQuickBar : Window, IDisposable foreach (var actor in data.Objects) { - _autoDesignApplier.ReapplyAutomation(actor, id, state!, true, out var forcedRedraw); + _autoDesignApplier.ReapplyAutomation(actor, id, state!, true, false, out var forcedRedraw); _stateManager.ReapplyAutomationState(actor, forcedRedraw, true, StateSource.Manual); } } @@ -291,7 +291,7 @@ public sealed class DesignQuickBar : Window, IDisposable foreach (var actor in data.Objects) { - _autoDesignApplier.ReapplyAutomation(actor, id, state!, false, out var forcedRedraw); + _autoDesignApplier.ReapplyAutomation(actor, id, state!, false, false, out var forcedRedraw); _stateManager.ReapplyAutomationState(actor, forcedRedraw, false, StateSource.Manual); } } diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index d8f3cd1..9c8f3cf 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -393,7 +393,7 @@ public class ActorPanel "Reapply the current automation state for the character on top of its current state..", !_config.EnableAutoDesigns || _state!.IsLocked)) { - _autoDesignApplier.ReapplyAutomation(_actor, _identifier, _state!, false, out var forcedRedraw); + _autoDesignApplier.ReapplyAutomation(_actor, _identifier, _state!, false, false, out var forcedRedraw); _stateManager.ReapplyAutomationState(_actor, forcedRedraw, false, StateSource.Manual); } @@ -402,7 +402,7 @@ public class ActorPanel "Try to revert the character to the state it would have using automated designs.", !_config.EnableAutoDesigns || _state!.IsLocked)) { - _autoDesignApplier.ReapplyAutomation(_actor, _identifier, _state!, true, out var forcedRedraw); + _autoDesignApplier.ReapplyAutomation(_actor, _identifier, _state!, true, false, out var forcedRedraw); _stateManager.ReapplyAutomationState(_actor, forcedRedraw, true, StateSource.Manual); } diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 98dfa19..bffc072 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -121,8 +121,9 @@ public class CommandService : IDisposable, IApiService "apply" => Apply(argument), "reapply" => ReapplyState(argument), "revert" => Revert(argument), - "reapplyautomation" => ReapplyAutomation(argument, "reapplyautomation", false), - "reverttoautomation" => ReapplyAutomation(argument, "reverttoautomation", true), + "reapplyautomation" => ReapplyAutomation(argument, "reapplyautomation", false, false), + "reverttoautomation" => ReapplyAutomation(argument, "reverttoautomation", true, false), + "resetdesign" => ReapplyAutomation(argument, "resetdesign", false, true), "automation" => SetAutomation(argument), "copy" => CopyState(argument), "save" => SaveState(argument), @@ -151,6 +152,8 @@ public class CommandService : IDisposable, IApiService "Reapplies the current automation state on top of the characters current state.. Use without arguments for help.").BuiltString); _chat.Print(new SeStringBuilder().AddCommand("reverttoautomation", "Reverts a given character to its supposed state using automated designs. Use without arguments for help.").BuiltString); + _chat.Print(new SeStringBuilder().AddCommand("resetdesign", + "Reapplies the current automation and resets the random design. Use without arguments for help.").BuiltString); _chat.Print(new SeStringBuilder() .AddCommand("copy", "Copy the current state of a character to clipboard. Use without arguments for help.").BuiltString); _chat.Print(new SeStringBuilder() @@ -306,7 +309,7 @@ public class CommandService : IDisposable, IApiService return true; } - private bool ReapplyAutomation(string argument, string command, bool revert) + private bool ReapplyAutomation(string argument, string command, bool revert, bool forcedNew) { if (argument.Length == 0) { @@ -328,7 +331,7 @@ public class CommandService : IDisposable, IApiService { if (_stateManager.GetOrCreate(identifier, actor, out var state)) { - _autoDesignApplier.ReapplyAutomation(actor, identifier, state, revert, out var forcedRedraw); + _autoDesignApplier.ReapplyAutomation(actor, identifier, state, revert, forcedNew, out var forcedRedraw); _stateManager.ReapplyAutomationState(actor, forcedRedraw, revert, StateSource.Manual); } } From cf308fc118fbcc3fd83c7ad8bb10d71bb712068d Mon Sep 17 00:00:00 2001 From: Diorik Date: Tue, 4 Feb 2025 01:54:34 -0600 Subject: [PATCH 208/401] Prevent repeating random design Cache the last selected random design and prevent it from being chosen again. --- Glamourer/Designs/Special/RandomDesignGenerator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Glamourer/Designs/Special/RandomDesignGenerator.cs b/Glamourer/Designs/Special/RandomDesignGenerator.cs index 7ed4452..1bee8ad 100644 --- a/Glamourer/Designs/Special/RandomDesignGenerator.cs +++ b/Glamourer/Designs/Special/RandomDesignGenerator.cs @@ -5,15 +5,20 @@ namespace Glamourer.Designs.Special; public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileSystem) : IService { private readonly Random _rng = new(); + private Design? _lastDesign = null; public Design? Design(IReadOnlyList localDesigns) { if (localDesigns.Count == 0) return null; + if (_lastDesign != null && localDesigns.Count > 1) + localDesigns = localDesigns.Where(d => d != _lastDesign).ToList(); + var idx = _rng.Next(0, localDesigns.Count); Glamourer.Log.Verbose($"[Random Design] Chose design {idx + 1} out of {localDesigns.Count}: {localDesigns[idx].Incognito}."); - return localDesigns[idx]; + _lastDesign = localDesigns[idx]; + return _lastDesign; } public Design? Design() From 5d1c65cce7ef82acdace9743a288ce3d6d44594d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 6 Feb 2025 16:27:10 +0100 Subject: [PATCH 209/401] Fix overwriting with current state keeping old advanced dyes. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index dbe106b..dd198ae 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -636,6 +636,7 @@ public class DesignPanel var design = panel._converter.Convert(state, ApplicationRules.FromModifiers(state)) ?? throw new Exception("The clipboard did not contain valid data."); + panel._selector.Selected!.GetMaterialDataRef().Clear(); panel._manager.ApplyDesign(panel._selector.Selected!, design); } catch (Exception ex) From d849506ecd1d9e6c76dde4c145f3eca03ee3c10d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 6 Feb 2025 16:52:59 +0100 Subject: [PATCH 210/401] 1.3.6.0 --- Glamourer/Gui/GlamourerChangelog.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 0c9d99b..4c8b365 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -39,6 +39,7 @@ public class GlamourerChangelog Add1_3_3_0(Changelog); Add1_3_4_0(Changelog); Add1_3_5_0(Changelog); + Add1_3_6_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -59,6 +60,22 @@ public class GlamourerChangelog } } + private static void Add1_3_6_0(Changelog log) + => log.NextVersion("Version 1.3.6.0") + .RegisterHighlight("Added some new multi design selection functionality to change design settings of many designs at once.") + .RegisterEntry("Also added the number of selected designs and folders to the multi design selection display.", 1) + .RegisterEntry("Glamourer will now use temporary settings when saving mod associations, if they exist in Penumbra.") + .RegisterEntry("Actually added the checkbox to reset all temporary settings to Automation Sets (functionality was there, just not exposed to the UI...).") + .RegisterEntry("Adapted the behavior for identified copies of characters that have a different state than the character itself to deal with the associated Penumbra changes.") + .RegisterEntry("Added '/glamour resetdesign' as a command, that re-applies automation but resets randomly chosen designs (Thanks Diorik).") + .RegisterEntry("All existing facepaints should now be accepted in designs, including NPC facepaints.") + .RegisterEntry("Overwriting a design with your characters current state will now discard any prior advanced dyes and only add those from the current state.") + .RegisterEntry("Fixed an issue with racial mount and accessory scaling when changing zones on a changed race.") + .RegisterEntry("Fixed issues with the detection of gear set changes in certain circumstances (Thanks Cordelia).") + .RegisterEntry("Fixed an issue with the Force to Inherit checkbox in mod associations.") + .RegisterEntry("Added a new IPC event that fires only when Glamourer finalizes its current changes to a character (for/from Cordelia).") + .RegisterEntry("Added new IPC to set a meta flag on actors. (for/from Cordelia)."); + private static void Add1_3_5_0(Changelog log) => log.NextVersion("Version 1.3.5.0") .RegisterHighlight("Added the usage of the new Temporary Mod Setting functionality from Penumbra to apply mod associations. This is on by default but can be turned back to permanent changes in the settings.") From 2c7b7d59be3dab950eeca4d1684828bfea3dcd2a Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 6 Feb 2025 15:55:34 +0000 Subject: [PATCH 211/401] [CI] Updating repo.json for 1.3.6.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 6ee99a9..d506898 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.5.1", - "TestingAssemblyVersion": "1.3.5.5", + "AssemblyVersion": "1.3.6.0", + "TestingAssemblyVersion": "1.3.6.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.5.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.5.5/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 1df2a46884340c1710ff2e08d38d46e8d4047c6f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 6 Feb 2025 17:00:25 +0100 Subject: [PATCH 212/401] Update Submodule Versions. --- Glamourer.Api | 2 +- Penumbra.Api | 2 +- Penumbra.String | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 8de6fa7..9f9bdf0 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 8de6fa7246a403de50b3be4e17bb5f188717b279 +Subproject commit 9f9bdf0873899d2e45fabaca446bb1624303b418 diff --git a/Penumbra.Api b/Penumbra.Api index 35b25be..c678090 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 35b25bef92e9b0be96c44c150a3df89d848d2658 +Subproject commit c67809057fac73a0fd407e3ad567f0aa6bc0bc37 diff --git a/Penumbra.String b/Penumbra.String index 0bc2b0f..4eb7c11 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 0bc2b0f66eee1a02c9575b2bb30f27ce166f8632 +Subproject commit 4eb7c118cdac5873afb97cb04719602f061f03b7 From 67fd65d366133ba0569ce9a3a70760e8f43fec5a Mon Sep 17 00:00:00 2001 From: Diorik Date: Thu, 6 Feb 2025 12:49:23 -0600 Subject: [PATCH 213/401] Make PreventRandomc figurable, clean up logic Will no longer hold design reference or make redundant copy of list --- Glamourer/Configuration.cs | 1 + .../Designs/Special/RandomDesignGenerator.cs | 17 +++++++++-------- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 3 +++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 4b59191..5f838a8 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -67,6 +67,7 @@ public class Configuration : IPluginConfiguration, ISavable public bool UseTemporarySettings { get; set; } = true; public bool AllowDoubleClickToApply { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false; + public bool PreventRandomRepeats { get; set; } = false; public DefaultDesignSettings DefaultDesignSettings { get; set; } = new(); diff --git a/Glamourer/Designs/Special/RandomDesignGenerator.cs b/Glamourer/Designs/Special/RandomDesignGenerator.cs index 1bee8ad..3ff353b 100644 --- a/Glamourer/Designs/Special/RandomDesignGenerator.cs +++ b/Glamourer/Designs/Special/RandomDesignGenerator.cs @@ -1,24 +1,25 @@ -using OtterGui.Services; +using OtterGui; +using OtterGui.Services; namespace Glamourer.Designs.Special; -public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileSystem) : IService +public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileSystem, Configuration config) : IService { private readonly Random _rng = new(); - private Design? _lastDesign = null; + private Guid? _lastDesignID = null; - public Design? Design(IReadOnlyList localDesigns) + public Design? Design(IList localDesigns) { if (localDesigns.Count == 0) return null; - if (_lastDesign != null && localDesigns.Count > 1) - localDesigns = localDesigns.Where(d => d != _lastDesign).ToList(); + if (config.PreventRandomRepeats && _lastDesignID != null && localDesigns.Count > 1 && localDesigns.FindFirst(d => d.Identifier == _lastDesignID, out var found)) + localDesigns.Remove(found); var idx = _rng.Next(0, localDesigns.Count); Glamourer.Log.Verbose($"[Random Design] Chose design {idx + 1} out of {localDesigns.Count}: {localDesigns[idx].Incognito}."); - _lastDesign = localDesigns[idx]; - return _lastDesign; + _lastDesignID = localDesigns[idx].Identifier; + return localDesigns[idx]; } public Design? Design() diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index ab40a48..2b9548f 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -109,6 +109,9 @@ public class SettingsTab( Checkbox("Use Temporary Mod Settings", "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down.", config.UseTemporarySettings, v => config.UseTemporarySettings = v); + Checkbox("Prevent Random Design Repeats", + "When using random designs, prevent the same design from being chosen twice in a row.", + config.PreventRandomRepeats, v => config.PreventRandomRepeats = v); ImGui.NewLine(); } From 5ca151b675e3f9484dac8ff06236a48f045895db Mon Sep 17 00:00:00 2001 From: Diorik Date: Thu, 6 Feb 2025 13:29:47 -0600 Subject: [PATCH 214/401] PreventRandom use WeakReference, reroll rand instead of changing list --- .../Designs/Special/RandomDesignGenerator.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Glamourer/Designs/Special/RandomDesignGenerator.cs b/Glamourer/Designs/Special/RandomDesignGenerator.cs index 3ff353b..b34a8ba 100644 --- a/Glamourer/Designs/Special/RandomDesignGenerator.cs +++ b/Glamourer/Designs/Special/RandomDesignGenerator.cs @@ -6,19 +6,20 @@ namespace Glamourer.Designs.Special; public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileSystem, Configuration config) : IService { private readonly Random _rng = new(); - private Guid? _lastDesignID = null; + private WeakReference _lastDesign = new(null, false); - public Design? Design(IList localDesigns) + public Design? Design(IReadOnlyList localDesigns) { if (localDesigns.Count == 0) return null; - if (config.PreventRandomRepeats && _lastDesignID != null && localDesigns.Count > 1 && localDesigns.FindFirst(d => d.Identifier == _lastDesignID, out var found)) - localDesigns.Remove(found); - - var idx = _rng.Next(0, localDesigns.Count); + int idx; + do + idx = _rng.Next(0, localDesigns.Count); + while (config.PreventRandomRepeats && localDesigns.Count > 1 && _lastDesign.TryGetTarget(out var lastDesign) && lastDesign == localDesigns[idx]); + Glamourer.Log.Verbose($"[Random Design] Chose design {idx + 1} out of {localDesigns.Count}: {localDesigns[idx].Incognito}."); - _lastDesignID = localDesigns[idx].Identifier; + _lastDesign.SetTarget(localDesigns[idx]); return localDesigns[idx]; } From 4748d1e211731abf01ce3ca5b369065d854a2b67 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 13 Feb 2025 16:30:24 +0100 Subject: [PATCH 215/401] Allow filtered item names. --- Glamourer/Designs/DesignBase.cs | 3 ++ Glamourer/Designs/DesignData.cs | 66 ++++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 30d4ddd..b21c433 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -195,6 +195,9 @@ public class DesignBase return true; } + public IEnumerable FilteredItemNames + => _designData.FilteredItemNames(Application.Equip, Application.BonusItem); + internal FlagRestrictionResetter TemporarilyRestrictApplication(ApplicationCollection restrictions) => new(this, restrictions); diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index 4205996..bba0ccb 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -46,20 +46,9 @@ public unsafe struct DesignData public DesignData() { } + [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] public readonly bool ContainsName(LowerString name) - => name.IsContained(_nameHead) - || name.IsContained(_nameBody) - || name.IsContained(_nameHands) - || name.IsContained(_nameLegs) - || name.IsContained(_nameFeet) - || name.IsContained(_nameEars) - || name.IsContained(_nameNeck) - || name.IsContained(_nameWrists) - || name.IsContained(_nameRFinger) - || name.IsContained(_nameLFinger) - || name.IsContained(_nameMainhand) - || name.IsContained(_nameOffhand) - || name.IsContained(_nameGlasses); + => ItemNames.Any(name.IsContained); public readonly StainIds Stain(EquipSlot slot) { @@ -76,6 +65,57 @@ public unsafe struct DesignData public readonly bool Crest(CrestFlag slot) => CrestVisibility.HasFlag(slot); + public readonly IEnumerable ItemNames + { + [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] + get + { + yield return _nameHead; + yield return _nameBody; + yield return _nameHands; + yield return _nameLegs; + yield return _nameFeet; + yield return _nameEars; + yield return _nameNeck; + yield return _nameWrists; + yield return _nameRFinger; + yield return _nameLFinger; + yield return _nameMainhand; + yield return _nameOffhand; + yield return _nameGlasses; + } + } + + [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] + public readonly IEnumerable FilteredItemNames(EquipFlag item, BonusItemFlag bonusItem) + { + if (item.HasFlag(EquipFlag.Head)) + yield return _nameHead; + if (item.HasFlag(EquipFlag.Body)) + yield return _nameBody; + if (item.HasFlag(EquipFlag.Hands)) + yield return _nameHands; + if (item.HasFlag(EquipFlag.Legs)) + yield return _nameLegs; + if (item.HasFlag(EquipFlag.Feet)) + yield return _nameFeet; + if (item.HasFlag(EquipFlag.Ears)) + yield return _nameEars; + if (item.HasFlag(EquipFlag.Neck)) + yield return _nameNeck; + if (item.HasFlag(EquipFlag.Wrist)) + yield return _nameWrists; + if (item.HasFlag(EquipFlag.RFinger)) + yield return _nameRFinger; + if (item.HasFlag(EquipFlag.LFinger)) + yield return _nameLFinger; + if (item.HasFlag(EquipFlag.Mainhand)) + yield return _nameMainhand; + if (item.HasFlag(EquipFlag.Offhand)) + yield return _nameOffhand; + if (bonusItem.HasFlag(BonusItemFlag.Glasses)) + yield return _nameGlasses; + } public readonly FullEquipType MainhandType => _typeMainhand; From ab2a3f5bd9790e29d653bb20d4ae4b9a4208cb08 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 13 Feb 2025 16:30:35 +0100 Subject: [PATCH 216/401] Add new colors. --- Glamourer/Gui/Colors.cs | 58 +++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/Glamourer/Gui/Colors.cs b/Glamourer/Gui/Colors.cs index b7f9737..e19639c 100644 --- a/Glamourer/Gui/Colors.cs +++ b/Glamourer/Gui/Colors.cs @@ -29,6 +29,9 @@ public enum ColorId TriStateNeutral, BattleNpc, EventNpc, + ModdedItemMarker, + ContainsItemsEnabled, + ContainsItemsDisabled, } public static class Colors @@ -39,32 +42,35 @@ public static class Colors => color switch { // @formatter:off - ColorId.NormalDesign => (0xFFFFFFFF, "Normal Design", "A design with no specific traits." ), - ColorId.CustomizationDesign => (0xFFC000C0, "Customization Design", "A design that only changes customizations on a character." ), - ColorId.StateDesign => (0xFF00C0C0, "State Design", "A design that does not change equipment or customizations on a character." ), - ColorId.EquipmentDesign => (0xFF00C000, "Equipment Design", "A design that only changes equipment on a character." ), - ColorId.ActorAvailable => (0xFF18C018, "Actor Available", "The header in the Actor tab panel if the currently selected actor exists in the game world at least once." ), - ColorId.ActorUnavailable => (0xFF1818C0, "Actor Unavailable", "The Header in the Actor tab panel if the currently selected actor does not exist in the game world." ), - ColorId.FolderExpanded => (0xFFFFF0C0, "Expanded Design Folder", "A design folder that is currently expanded." ), - ColorId.FolderCollapsed => (0xFFFFF0C0, "Collapsed Design Folder", "A design folder that is currently collapsed." ), - ColorId.FolderLine => (0xFFFFF0C0, "Expanded Design Folder Line", "The line signifying which descendants belong to an expanded design folder." ), - ColorId.EnabledAutoSet => (0xFFA0F0A0, "Enabled Automation Set", "An automation set that is currently enabled. Only one set can be enabled for each identifier at once." ), - ColorId.DisabledAutoSet => (0xFF808080, "Disabled Automation Set", "An automation set that is currently disabled." ), - ColorId.AutomationActorAvailable => (0xFFFFFFFF, "Automation Actor Available", "A character associated with the given automated design set is currently visible." ), - ColorId.AutomationActorUnavailable => (0xFF808080, "Automation Actor Unavailable", "No character associated with the given automated design set is currently visible." ), - ColorId.HeaderButtons => (0xFFFFF0C0, "Header Buttons", "The text and border color of buttons in the header, like the Incognito toggle." ), - ColorId.FavoriteStarOn => (0xFF40D0D0, "Favored Item", "The color of the star for favored items and of the border in the unlock overview tab." ), - ColorId.FavoriteStarHovered => (0xFFD040D0, "Favorite Star Hovered", "The color of the star for favored items when it is hovered." ), - ColorId.FavoriteStarOff => (0x20808080, "Favorite Star Outline", "The color of the star for items that are not favored when it is not hovered." ), - ColorId.QuickDesignButton => (0x900A0A0A, "Quick Design Bar Button Background", "The color of button frames in the quick design bar." ), - ColorId.QuickDesignFrame => (0x90383838, "Quick Design Bar Combo Background", "The color of the combo background in the quick design bar." ), - ColorId.QuickDesignBg => (0x00F0F0F0, "Quick Design Bar Window Background", "The color of the window background in the quick design bar." ), - ColorId.TriStateCheck => (0xFF00D000, "Checkmark in Tri-State Checkboxes", "The color of the checkmark indicating positive change in tri-state checkboxes." ), - ColorId.TriStateCross => (0xFF0000D0, "Cross in Tri-State Checkboxes", "The color of the cross indicating negative change in tri-state checkboxes." ), - ColorId.TriStateNeutral => (0xFFD0D0D0, "Dot in Tri-State Checkboxes", "The color of the dot indicating no change in tri-state checkboxes." ), - ColorId.BattleNpc => (0xFFFFFFFF, "Battle NPC in NPC Tab", "The color of the names of battle NPCs in the NPC tab that do not have a more specific color assigned." ), - ColorId.EventNpc => (0xFFFFFFFF, "Event NPC in NPC Tab", "The color of the names of event NPCs in the NPC tab that do not have a more specific color assigned." ), - _ => (0x00000000, string.Empty, string.Empty ), + ColorId.NormalDesign => (0xFFFFFFFF, "Normal Design", "A design with no specific traits." ), + ColorId.CustomizationDesign => (0xFFC000C0, "Customization Design", "A design that only changes customizations on a character." ), + ColorId.StateDesign => (0xFF00C0C0, "State Design", "A design that does not change equipment or customizations on a character." ), + ColorId.EquipmentDesign => (0xFF00C000, "Equipment Design", "A design that only changes equipment on a character." ), + ColorId.ActorAvailable => (0xFF18C018, "Actor Available", "The header in the Actor tab panel if the currently selected actor exists in the game world at least once." ), + ColorId.ActorUnavailable => (0xFF1818C0, "Actor Unavailable", "The Header in the Actor tab panel if the currently selected actor does not exist in the game world." ), + ColorId.FolderExpanded => (0xFFFFF0C0, "Expanded Design Folder", "A design folder that is currently expanded." ), + ColorId.FolderCollapsed => (0xFFFFF0C0, "Collapsed Design Folder", "A design folder that is currently collapsed." ), + ColorId.FolderLine => (0xFFFFF0C0, "Expanded Design Folder Line", "The line signifying which descendants belong to an expanded design folder." ), + ColorId.EnabledAutoSet => (0xFFA0F0A0, "Enabled Automation Set", "An automation set that is currently enabled. Only one set can be enabled for each identifier at once." ), + ColorId.DisabledAutoSet => (0xFF808080, "Disabled Automation Set", "An automation set that is currently disabled." ), + ColorId.AutomationActorAvailable => (0xFFFFFFFF, "Automation Actor Available", "A character associated with the given automated design set is currently visible." ), + ColorId.AutomationActorUnavailable => (0xFF808080, "Automation Actor Unavailable", "No character associated with the given automated design set is currently visible." ), + ColorId.HeaderButtons => (0xFFFFF0C0, "Header Buttons", "The text and border color of buttons in the header, like the Incognito toggle." ), + ColorId.FavoriteStarOn => (0xFF40D0D0, "Favored Item", "The color of the star for favored items and of the border in the unlock overview tab." ), + ColorId.FavoriteStarHovered => (0xFFD040D0, "Favorite Star Hovered", "The color of the star for favored items when it is hovered." ), + ColorId.FavoriteStarOff => (0x20808080, "Favorite Star Outline", "The color of the star for items that are not favored when it is not hovered." ), + ColorId.QuickDesignButton => (0x900A0A0A, "Quick Design Bar Button Background", "The color of button frames in the quick design bar." ), + ColorId.QuickDesignFrame => (0x90383838, "Quick Design Bar Combo Background", "The color of the combo background in the quick design bar." ), + ColorId.QuickDesignBg => (0x00F0F0F0, "Quick Design Bar Window Background", "The color of the window background in the quick design bar." ), + ColorId.TriStateCheck => (0xFF00D000, "Checkmark in Tri-State Checkboxes", "The color of the checkmark indicating positive change in tri-state checkboxes." ), + ColorId.TriStateCross => (0xFF0000D0, "Cross in Tri-State Checkboxes", "The color of the cross indicating negative change in tri-state checkboxes." ), + ColorId.TriStateNeutral => (0xFFD0D0D0, "Dot in Tri-State Checkboxes", "The color of the dot indicating no change in tri-state checkboxes." ), + ColorId.BattleNpc => (0xFFFFFFFF, "Battle NPC in NPC Tab", "The color of the names of battle NPCs in the NPC tab that do not have a more specific color assigned." ), + ColorId.EventNpc => (0xFFFFFFFF, "Event NPC in NPC Tab", "The color of the names of event NPCs in the NPC tab that do not have a more specific color assigned." ), + ColorId.ModdedItemMarker => (0xFFFF20FF, "Modded Item Marker", "The color of dot in the unlocks overview tab signaling that the item is modded in the currently selected Penumbra collection." ), + ColorId.ContainsItemsEnabled => (0xFFA0F0A0, "Enabled Mod Contains Design Items", "The color of enabled mods in the associated mod dropdown menu when they contain items used in this design." ), + ColorId.ContainsItemsDisabled => (0x80A0F0A0, "Disabled Mod Contains Design Items", "The color of disabled mods in the associated mod dropdown menu when they contain items used in this design." ), + _ => (0x00000000, string.Empty, string.Empty ), // @formatter:on }; From d56c2db547e64496e794e68ee1771c49096b0f58 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 13 Feb 2025 16:32:23 +0100 Subject: [PATCH 217/401] Add more mod association and modded utility. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 1 - .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/ModCombo.cs | 54 ++++---- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 16 ++- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 55 +++++++- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 105 ++++++++++++-- Glamourer/Interop/Penumbra/PenumbraService.cs | 130 +++++++++++------- OtterGui | 2 +- Penumbra.Api | 2 +- 9 files changed, 277 insertions(+), 90 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index dd198ae..748afea 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -17,7 +17,6 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; -using OtterGuiInternal.Structs; using Penumbra.GameData.Enums; using static Glamourer.Gui.Tabs.HeaderDrawer; diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 021a396..feff657 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -15,7 +15,7 @@ namespace Glamourer.Gui.Tabs.DesignTab; public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelector selector, DesignManager manager, Configuration config) { - private readonly ModCombo _modCombo = new(penumbra, Glamourer.Log); + private readonly ModCombo _modCombo = new(penumbra, Glamourer.Log, selector); private (Mod, ModSettings)[]? _copy; public void Draw() diff --git a/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs b/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs index 53501b0..6ec9a1c 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs @@ -4,19 +4,18 @@ using ImGuiNET; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.DesignTab; -public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings)> +public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings, int Count)> { - public ModCombo(PenumbraService penumbra, Logger log) - : base(penumbra.GetMods, MouseWheelType.None, log) - { - SearchByParts = false; - } + public ModCombo(PenumbraService penumbra, Logger log, DesignFileSystemSelector selector) + : base(() => penumbra.GetMods(selector.Selected?.FilteredItemNames.ToArray() ?? []), MouseWheelType.None, log) + => SearchByParts = false; - protected override string ToString((Mod Mod, ModSettings Settings) obj) + protected override string ToString((Mod Mod, ModSettings Settings, int Count) obj) => obj.Mod.Name; protected override bool IsVisible(int globalIndex, LowerString filter) @@ -24,36 +23,45 @@ public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings)> protected override bool DrawSelectable(int globalIdx, bool selected) { - using var id = ImRaii.PushId(globalIdx); - var (mod, settings) = Items[globalIdx]; + using var id = ImUtf8.PushId(globalIdx); + var (mod, settings, count) = Items[globalIdx]; bool ret; - using (var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled), !settings.Enabled)) + var color = settings.Enabled + ? count > 0 + ? ColorId.ContainsItemsEnabled.Value() + : ImGui.GetColorU32(ImGuiCol.Text) + : count > 0 + ? ColorId.ContainsItemsDisabled.Value() + : ImGui.GetColorU32(ImGuiCol.TextDisabled); + using (ImRaii.PushColor(ImGuiCol.Text, color)) { - ret = ImGui.Selectable(mod.Name, selected); + ret = ImUtf8.Selectable(mod.Name, selected); } if (ImGui.IsItemHovered()) { using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale); - using var tt = ImRaii.Tooltip(); + using var tt = ImUtf8.Tooltip(); var namesDifferent = mod.Name != mod.DirectoryName; ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0)); - using (var group = ImRaii.Group()) + using (ImUtf8.Group()) { if (namesDifferent) - ImGui.TextUnformatted("Directory Name"); - ImGui.TextUnformatted("Enabled"); - ImGui.TextUnformatted("Priority"); + ImUtf8.Text("Directory Name"u8); + ImUtf8.Text("Enabled"u8); + ImUtf8.Text("Priority"u8); + ImUtf8.Text("Affected Design Items"u8); DrawSettingsLeft(settings); } ImGui.SameLine(Math.Max(ImGui.GetItemRectSize().X + 3 * ImGui.GetStyle().ItemSpacing.X, 150 * ImGuiHelpers.GlobalScale)); - using (var group = ImRaii.Group()) + using (ImUtf8.Group()) { if (namesDifferent) - ImGui.TextUnformatted(mod.DirectoryName); - ImGui.TextUnformatted(settings.Enabled.ToString()); - ImGui.TextUnformatted(settings.Priority.ToString()); + ImUtf8.Text(mod.DirectoryName); + ImUtf8.Text($"{settings.Enabled}"); + ImUtf8.Text($"{settings.Priority}"); + ImUtf8.Text($"{count}"); DrawSettingsRight(settings); } } @@ -65,7 +73,7 @@ public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings)> { foreach (var setting in settings.Settings) { - ImGui.TextUnformatted(setting.Key); + ImUtf8.Text(setting.Key); for (var i = 1; i < setting.Value.Count; ++i) ImGui.NewLine(); } @@ -76,10 +84,10 @@ public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings)> foreach (var setting in settings.Settings) { if (setting.Value.Count == 0) - ImGui.TextUnformatted(""); + ImUtf8.Text(""u8); else foreach (var option in setting.Value) - ImGui.TextUnformatted(option); + ImUtf8.Text(option); } } } diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 9e894c4..a7afa21 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -5,11 +5,15 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Text; +using static Glamourer.Gui.Tabs.HeaderDrawer; namespace Glamourer.Gui.Tabs.DesignTab; -public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager editor, DesignColors colors) +public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager editor, DesignColors colors, Configuration config) { + private readonly Button[] _leftButtons = []; + private readonly Button[] _rightButtons = [new IncognitoButton(config.Ephemeral)]; + private readonly DesignColorCombo _colorCombo = new(colors, true); public void Draw() @@ -17,8 +21,12 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e if (selector.SelectedPaths.Count == 0) return; - var width = ImGuiHelpers.ScaledVector2(145, 0); - ImGui.NewLine(); + HeaderDrawer.Draw(string.Empty, 0, ImGui.GetColorU32(ImGuiCol.FrameBg), _leftButtons, _rightButtons); + using var child = ImUtf8.Child("##MultiPanel"u8, default, true); + if (!child) + return; + + var width = ImGuiHelpers.ScaledVector2(145, 0); var treeNodePos = ImGui.GetCursorPos(); _numDesigns = DrawDesignList(); DrawCounts(treeNodePos); @@ -135,7 +143,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e { ImUtf8.TextFrameAligned("Multi Tagger:"u8); ImGui.SameLine(); - var offset = ImGui.GetItemRectSize().X; + var offset = ImGui.GetItemRectSize().X + ImGui.GetStyle().WindowPadding.X; ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - 2 * (width.X + ImGui.GetStyle().ItemSpacing.X)); ImUtf8.InputText("##tag"u8, ref _tag, "Tag Name..."u8); diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index afc4f7b..903257b 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -1,8 +1,8 @@ using Dalamud.Game.Text.SeStringHandling; using Dalamud.Interface.Utility; -using Glamourer.Designs; using Glamourer.GameData; using Glamourer.Interop; +using Glamourer.Interop.Penumbra; using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; @@ -23,7 +23,8 @@ public class UnlockOverview( TextureService textures, CodeService codes, JobService jobs, - FavoriteManager favorites) + FavoriteManager favorites, + PenumbraService penumbra) { private static readonly Vector4 UnavailableTint = new(0.3f, 0.3f, 0.3f, 1.0f); @@ -32,6 +33,9 @@ public class UnlockOverview( private Gender _selected3 = Gender.Unknown; private BonusItemFlag _selected4 = BonusItemFlag.Unknown; + private uint _favoriteColor; + private uint _moddedColor; + private void DrawSelector() { using var child = ImRaii.Child("Selector", new Vector2(200 * ImGuiHelpers.GlobalScale, -1), true); @@ -90,6 +94,9 @@ public class UnlockOverview( if (!child) return; + _moddedColor = ColorId.ModdedItemMarker.Value(); + _favoriteColor = ColorId.FavoriteStarOn.Value(); + if (_selected1 is not FullEquipType.Unknown) DrawItems(); else if (_selected2 is not SubRace.Unknown && _selected3 is not Gender.Unknown) @@ -120,7 +127,7 @@ public class UnlockOverview( unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (favorites.Contains(_selected3, _selected2, customize.Index, customize.Value)) - ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), + ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), _favoriteColor, 12 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 6 * ImGuiHelpers.GlobalScale); if (hasIcon && ImGui.IsItemHovered()) @@ -192,9 +199,11 @@ public class UnlockOverview( ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (favorites.Contains(item)) - ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), + ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), _favoriteColor, 2 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * ImGuiHelpers.GlobalScale); + var mods = DrawModdedMarker(item, iconSize); + // TODO handle clicking if (ImGui.IsItemHovered()) { @@ -206,9 +215,10 @@ public class UnlockOverview( ImUtf8.Text($"{item.Id.Id}"); ImUtf8.Text($"{item.PrimaryId.Id}-{item.Variant.Id}"); // TODO - ImUtf8.Text("Always Unlocked"); // : $"Unlocked on {time:g}" : "Not Unlocked."); + ImUtf8.Text("Always Unlocked"u8); // : $"Unlocked on {time:g}" : "Not Unlocked."); // TODO //tooltip.CreateTooltip(item, string.Empty, false); + DrawModTooltip(mods); } } } @@ -263,6 +273,8 @@ public class UnlockOverview( ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), 2 * ImGuiHelpers.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * ImGuiHelpers.GlobalScale); + var mods = DrawModdedMarker(item, iconSize); + if (ImGui.IsItemClicked()) Glamourer.Messager.Chat.Print(new SeStringBuilder().AddItemLink(item.ItemId.Id, false).BuiltString); @@ -306,6 +318,7 @@ public class UnlockOverview( ImGui.TextUnformatted("Tradable"); if (item.Flags.HasFlag(ItemFlags.IsCrestWorthy)) ImGui.TextUnformatted("Can apply Crest"); + DrawModTooltip(mods); tooltip.CreateTooltip(item, string.Empty, false); } } @@ -316,4 +329,36 @@ public class UnlockOverview( private static int IconsPerRow(float iconWidth, float iconSpacing) => (int)(ImGui.GetContentRegionAvail().X / (iconWidth + iconSpacing)); + + [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] + private (string ModDirectory, string ModName)[] DrawModdedMarker(in EquipItem item, Vector2 iconSize) + { + var mods = penumbra.CheckCurrentChangedItem(item.Name); + if (mods.Length == 0) + return mods; + + var center = ImGui.GetItemRectMin() + new Vector2(iconSize.X * 0.85f, iconSize.Y * 0.15f); + ImGui.GetWindowDrawList().AddCircleFilled(center, iconSize.X * 0.1f, _moddedColor); + ImGui.GetWindowDrawList().AddCircle(center, iconSize.X * 0.1f, 0xFF000000); + return mods; + } + + [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] + private void DrawModTooltip((string ModDirectory, string ModName)[] mods) + { + switch (mods.Length) + { + case 0: return; + case 1: + ImUtf8.Text("Modded by: "u8, _moddedColor); + ImGui.SameLine(0, 0); + ImUtf8.Text(mods[0].ModName); + return; + default: + ImUtf8.Text("Modded by:"u8, _moddedColor); + foreach (var (_, mod) in mods) + ImUtf8.BulletText(mod); + return; + } + } } diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 9651e85..6d9ce51 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -3,6 +3,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using Glamourer.Events; using Glamourer.Interop; +using Glamourer.Interop.Penumbra; using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; @@ -17,12 +18,16 @@ namespace Glamourer.Gui.Tabs.UnlocksTab; public class UnlockTable : Table, IDisposable { - private readonly ObjectUnlocked _event; + private readonly ObjectUnlocked _event; + private readonly PenumbraService _penumbra; + + private Guid _lastCurrentCollection = Guid.Empty; public UnlockTable(ItemManager items, TextureService textures, ItemUnlockManager itemUnlocks, - PenumbraChangedItemTooltip tooltip, ObjectUnlocked @event, JobService jobs, FavoriteManager favorites) + PenumbraChangedItemTooltip tooltip, ObjectUnlocked @event, JobService jobs, FavoriteManager favorites, PenumbraService penumbra) : base("ItemUnlockTable", new ItemList(items), new FavoriteColumn(favorites, @event) { Label = "F" }, + new ModdedColumn(penumbra) { Label = "M" }, new NameColumn(textures, tooltip) { Label = "Item Name..." }, new SlotColumn { Label = "Equip Slot" }, new TypeColumn { Label = "Item Type..." }, @@ -36,14 +41,40 @@ public class UnlockTable : Table, IDisposable new TradableColumn { Label = "Trade" } ) { - _event = @event; - Sortable = true; - Flags |= ImGuiTableFlags.Hideable | ImGuiTableFlags.Reorderable | ImGuiTableFlags.Resizable; + _event = @event; + _penumbra = penumbra; + Sortable = true; + Flags |= ImGuiTableFlags.Hideable | ImGuiTableFlags.Reorderable | ImGuiTableFlags.Resizable; _event.Subscribe(OnObjectUnlock, ObjectUnlocked.Priority.UnlockTable); + _penumbra.ModSettingChanged += OnModSettingsChanged; + + } + + private void OnModSettingsChanged(Penumbra.Api.Enums.ModSettingChange type, Guid collection, string mod, bool inherited) + { + if (collection != _lastCurrentCollection) + return; + + FilterDirty = true; + SortDirty = true; + } + + protected override void PreDraw() + { + var lastCurrentCollection = _penumbra.CurrentCollection.Id; + if (_lastCurrentCollection != lastCurrentCollection) + { + _lastCurrentCollection = lastCurrentCollection; + FilterDirty = true; + SortDirty = true; + } } public void Dispose() - => _event.Unsubscribe(OnObjectUnlock); + { + _event.Unsubscribe(OnObjectUnlock); + _penumbra.ModSettingChanged -= OnModSettingsChanged; + } private sealed class FavoriteColumn : YesNoColumn { @@ -77,6 +108,66 @@ public class UnlockTable : Table, IDisposable => _favorites.Contains(rhs).CompareTo(_favorites.Contains(lhs)); } + private sealed class ModdedColumn : YesNoColumn + { + public override float Width + => ImGui.GetFrameHeightWithSpacing(); + + private readonly PenumbraService _penumbra; + private readonly Dictionary _compareCache = []; + + public ModdedColumn(PenumbraService penumbra) + { + _penumbra = penumbra; + Flags |= ImGuiTableColumnFlags.NoResize; + } + + public override void PostSort() + { + _compareCache.Clear(); + } + + public override void DrawColumn(EquipItem item, int idx) + { + var value = _penumbra.CheckCurrentChangedItem(item.Name); + if (value.Length == 0) + return; + + using (ImRaii.PushFont(UiBuilder.IconFont)) + { + using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.ModdedItemMarker.Value()); + ImGuiUtil.Center(FontAwesomeIcon.Circle.ToIconString()); + } + + if (ImGui.IsItemHovered()) + { + using var tt = ImUtf8.Tooltip(); + foreach (var (_, mod) in value) + ImUtf8.BulletText(mod); + } + } + + public override bool FilterFunc(EquipItem item) + => FilterValue.HasFlag(_penumbra.CheckCurrentChangedItem(item.Name).Length > 0 ? YesNoFlag.Yes : YesNoFlag.No); + + public override int Compare(EquipItem lhs, EquipItem rhs) + { + if (!_compareCache.TryGetValue(lhs.Id, out var lhsCount)) + { + lhsCount = _penumbra.CheckCurrentChangedItem(lhs.Name).Length; + _compareCache[lhs.Id] = lhsCount; + } + + if (!_compareCache.TryGetValue(rhs.Id, out var rhsCount)) + { + rhsCount = _penumbra.CheckCurrentChangedItem(rhs.Name).Length; + _compareCache[rhs.Id] = rhsCount; + } + + return lhsCount.CompareTo(rhsCount); + } + } + private sealed class NameColumn : ColumnString { private readonly TextureService _textures; @@ -317,7 +408,6 @@ public class UnlockTable : Table, IDisposable { } } - private sealed class JobColumn : ColumnFlags { public override float Width @@ -415,7 +505,6 @@ public class UnlockTable : Table, IDisposable } } - private sealed class DyableColumn : ColumnFlags { [Flags] diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 27446ea..e0c445b 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -38,6 +38,7 @@ public class PenumbraService : IDisposable public const int RequiredPenumbraFeatureVersionTemp = 4; public const int RequiredPenumbraFeatureVersionTemp2 = 5; public const int RequiredPenumbraFeatureVersionTemp3 = 6; + public const int RequiredPenumbraFeatureVersionTemp4 = 7; private const int Key = -1610; @@ -49,30 +50,33 @@ public class PenumbraService : IDisposable private readonly EventSubscriber _createdCharacterBase; private readonly EventSubscriber _modSettingChanged; - private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; - private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; - private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw; - private global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo? _drawObjectInfo; - private global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex? _cutsceneParent; - private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; - private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; - private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; - private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp? _getCurrentSettingsWithTemp; - private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings? _getCurrentSettings; - private global::Penumbra.Api.IpcSubscribers.GetAllModSettings? _getAllSettings; - private global::Penumbra.Api.IpcSubscribers.TryInheritMod? _inheritMod; - private global::Penumbra.Api.IpcSubscribers.TrySetMod? _setMod; - private global::Penumbra.Api.IpcSubscribers.TrySetModPriority? _setModPriority; - private global::Penumbra.Api.IpcSubscribers.TrySetModSetting? _setModSetting; - private global::Penumbra.Api.IpcSubscribers.TrySetModSettings? _setModSettings; - private global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings? _setTemporaryModSettings; - private global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer? _setTemporaryModSettingsPlayer; - private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings? _removeTemporaryModSettings; - private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer? _removeTemporaryModSettingsPlayer; - private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; - private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; - private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings? _queryTemporaryModSettings; - private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; + private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; + private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; + private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw; + private global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo? _drawObjectInfo; + private global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex? _cutsceneParent; + private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; + private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; + private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; + private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp? _getCurrentSettingsWithTemp; + private global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings? _getCurrentSettings; + private global::Penumbra.Api.IpcSubscribers.GetAllModSettings? _getAllSettings; + private global::Penumbra.Api.IpcSubscribers.TryInheritMod? _inheritMod; + private global::Penumbra.Api.IpcSubscribers.TrySetMod? _setMod; + private global::Penumbra.Api.IpcSubscribers.TrySetModPriority? _setModPriority; + private global::Penumbra.Api.IpcSubscribers.TrySetModSetting? _setModSetting; + private global::Penumbra.Api.IpcSubscribers.TrySetModSettings? _setModSettings; + private global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings? _setTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer? _setTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings? _removeTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer? _removeTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings? _queryTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; + private global::Penumbra.Api.IpcSubscribers.GetChangedItems? _getChangedItems; + private IReadOnlyList<(string ModDirectory, IReadOnlyDictionary ChangedItems)>? _changedItems; + private Func? _checkCurrentChangedItems; private readonly IDisposable _initializedEvent; private readonly IDisposable _disposedEvent; @@ -195,37 +199,58 @@ public class PenumbraService : IDisposable return ret[0]; } - public IReadOnlyList<(Mod Mod, ModSettings Settings)> GetMods() + public IReadOnlyList<(Mod Mod, ModSettings Settings, int Count)> GetMods(IReadOnlyList data) { if (!Available) return []; try { - var allMods = _getMods!.Invoke(); - var collection = _currentCollection!.Invoke(ApiCollectionType.Current); - if (_getAllSettings != null) + var allMods = _getMods!.Invoke(); + var currentCollection = _currentCollection!.Invoke(ApiCollectionType.Current); + var withSettings = WithSettings(allMods, currentCollection!.Value.Id); + var withCounts = WithCounts(withSettings, allMods.Count); + return OrderList(withCounts, allMods.Count); + + IEnumerable<(Mod Mod, ModSettings Settings)> WithSettings(Dictionary mods, Guid collection) { - var allSettings = _getAllSettings.Invoke(collection!.Value.Id, false, false, Key); - if (allSettings.Item1 is PenumbraApiEc.Success) - return allMods.Select(m => (new Mod(m.Value, m.Key), + if (_getAllSettings != null) + { + var allSettings = _getAllSettings.Invoke(collection, false, false, Key); + if (allSettings.Item1 is PenumbraApiEc.Success) + return mods.Select(m => (new Mod(m.Value, m.Key), allSettings.Item2!.TryGetValue(m.Key, out var s) - ? new ModSettings(s.Item3, s.Item2, s.Item1, s.Item4 && s.Item5, false) - : ModSettings.Empty)) - .OrderByDescending(p => p.Item2.Enabled) - .ThenBy(p => p.Item1.Name) - .ThenBy(p => p.Item1.DirectoryName) - .ThenByDescending(p => p.Item2.Priority) - .ToList(); + ? new ModSettings(s.Item3, s.Item2, s.Item1, s is { Item4: true, Item5: true }, false) + : ModSettings.Empty)); + } + + return mods.Select(m => (new Mod(m.Value, m.Key), GetSettings(collection, m.Key, m.Value, out _))); } - return allMods - .Select(m => (new Mod(m.Value, m.Key), GetSettings(collection!.Value.Id, m.Key, m.Value, out _))) - .OrderByDescending(p => p.Item2.Enabled) - .ThenBy(p => p.Item1.Name) - .ThenBy(p => p.Item1.DirectoryName) - .ThenByDescending(p => p.Item2.Priority) - .ToList(); + IEnumerable<(Mod Mod, ModSettings Settings, int Count)> WithCounts(IEnumerable<(Mod Mod, ModSettings Settings)> mods, int count) + { + if (_changedItems != null && _changedItems.Count == count) + return mods.Select((m, idx) => (m.Mod, m.Settings, CountItems(_changedItems[idx].ChangedItems, data))); + + return mods.Select(p => (p.Item1, p.Item2, CountItems(_getChangedItems!.Invoke(p.Item1.DirectoryName, p.Item1.Name), data))); + + static int CountItems(IReadOnlyDictionary dict, IReadOnlyList data) + => data.Count(dict.ContainsKey); + } + + static IReadOnlyList<(Mod Mod, ModSettings Settings, int Count)> OrderList( + IEnumerable<(Mod Mod, ModSettings Settings, int Count)> enumerable, int count) + { + var array = new (Mod Mod, ModSettings Settings, int Count)[count]; + var i = 0; + foreach (var t in enumerable.OrderByDescending(p => p.Item2.Enabled) + .ThenByDescending(p => p.Item3) + .ThenBy(p => p.Item1.Name) + .ThenBy(p => p.Item1.DirectoryName) + .ThenByDescending(p => p.Item2.Priority)) + array[i++] = t; + return array; + } } catch (Exception ex) { @@ -289,6 +314,9 @@ public class PenumbraService : IDisposable RemoveAllTemporarySettings(collection.Key); } + public (string ModDirectory, string ModName)[] CheckCurrentChangedItem(string changedItem) + => _checkCurrentChangedItems?.Invoke(changedItem) ?? []; + private void SetModTemporary(StringBuilder sb, Mod mod, ModSettings settings, Guid collection, ObjectIndex? index) { var ex = settings.Remove @@ -476,6 +504,7 @@ public class PenumbraService : IDisposable _setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface); _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); + _getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface); if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp) { _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); @@ -488,10 +517,16 @@ public class PenumbraService : IDisposable if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) { _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); - if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) + if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp3) { _getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface); _getAllSettings = new global::Penumbra.Api.IpcSubscribers.GetAllModSettings(_pluginInterface); + if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp4) + { + _changedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItemAdapterList(_pluginInterface).Invoke(); + _checkCurrentChangedItems = + new global::Penumbra.Api.IpcSubscribers.CheckCurrentChangedItemFunc(_pluginInterface).Invoke(); + } } } } @@ -541,6 +576,9 @@ public class PenumbraService : IDisposable _removeAllTemporaryModSettings = null; _removeAllTemporaryModSettingsPlayer = null; _queryTemporaryModSettings = null; + _getChangedItems = null; + _changedItems = null; + _checkCurrentChangedItems = null; Available = false; Glamourer.Log.Debug("Glamourer detached from Penumbra."); } diff --git a/OtterGui b/OtterGui index 3c1260c..0b6085c 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 3c1260c9833303c2d33d12d6f77dc2b1afea3f34 +Subproject commit 0b6085ce720ffb7c78cf42d4e51861f34db27744 diff --git a/Penumbra.Api b/Penumbra.Api index c678090..70f0468 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit c67809057fac73a0fd407e3ad567f0aa6bc0bc37 +Subproject commit 70f046830cc7cd35b3480b12b7efe94182477fbb From f7d6e75a9b9e3687958c590cb90f8a3993ff62b8 Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 13 Feb 2025 15:43:08 +0000 Subject: [PATCH 218/401] [CI] Updating repo.json for testing_1.3.6.1 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index d506898..76009f4 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.6.0", - "TestingAssemblyVersion": "1.3.6.0", + "TestingAssemblyVersion": "1.3.6.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 11684609427ecfc84dedc4c4d826a3e3bae39148 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 17 Feb 2025 17:40:49 +0100 Subject: [PATCH 219/401] Add button to reset glamourer temporary settings to qdb. --- Glamourer/Gui/DesignQuickBar.cs | 43 +++- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 238 +++++++++--------- Glamourer/State/StateEditor.cs | 3 +- OtterGui | 2 +- 4 files changed, 167 insertions(+), 119 deletions(-) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index b58643c..1e2904c 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -7,11 +7,13 @@ using Dalamud.Plugin.Services; using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Interop; +using Glamourer.Interop.Penumbra; using Glamourer.Interop.Structs; using Glamourer.State; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Text; using Penumbra.GameData.Actors; namespace Glamourer.Gui; @@ -26,6 +28,7 @@ public enum QdbButtons RevertEquip = 0x10, RevertCustomize = 0x20, ReapplyAutomation = 0x40, + ResetSettings = 0x80, } public sealed class DesignQuickBar : Window, IDisposable @@ -40,6 +43,7 @@ public sealed class DesignQuickBar : Window, IDisposable private readonly StateManager _stateManager; private readonly AutoDesignApplier _autoDesignApplier; private readonly ObjectManager _objects; + private readonly PenumbraService _penumbra; private readonly IKeyState _keyState; private readonly ImRaii.Style _windowPadding = new(); private readonly ImRaii.Color _windowColor = new(); @@ -47,7 +51,7 @@ public sealed class DesignQuickBar : Window, IDisposable private int _numButtons; public DesignQuickBar(Configuration config, QuickDesignCombo designCombo, StateManager stateManager, IKeyState keyState, - ObjectManager objects, AutoDesignApplier autoDesignApplier) + ObjectManager objects, AutoDesignApplier autoDesignApplier, PenumbraService penumbra) : base("Glamourer Quick Bar", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking) { _config = config; @@ -56,6 +60,7 @@ public sealed class DesignQuickBar : Window, IDisposable _keyState = keyState; _objects = objects; _autoDesignApplier = autoDesignApplier; + _penumbra = penumbra; IsOpen = _config.Ephemeral.ShowDesignQuickBar; DisableWindowSounds = true; Size = Vector2.Zero; @@ -122,6 +127,7 @@ public sealed class DesignQuickBar : Window, IDisposable DrawRevertAdvancedCustomization(buttonSize); DrawRevertAutomationButton(buttonSize); DrawReapplyAutomationButton(buttonSize); + DrawResetSettingsButton(buttonSize); } private ActorIdentifier _playerIdentifier; @@ -392,10 +398,41 @@ public sealed class DesignQuickBar : Window, IDisposable _stateManager.ResetEquip(state!, StateSource.Manual); } + private void DrawResetSettingsButton(Vector2 buttonSize) + { + if (!_config.QdbButtons.HasFlag(QdbButtons.ResetSettings)) + return; + + var available = 0; + var tooltip = string.Empty; + + if (_playerIdentifier.IsValid && _playerData.Valid) + { + available |= 1; + tooltip = $"Left-Click: Reset all temporary settings applied by Glamourer to the collection affecting {_playerIdentifier}."; + } + + if (_targetIdentifier.IsValid && _targetData.Valid) + { + if (available != 0) + tooltip += '\n'; + available |= 2; + tooltip += $"Right-Click: Reset all temporary settings applied by Glamourer to the collection affecting {_targetIdentifier}."; + } + + if (available == 0) + tooltip = "Neither player character nor target are available to identify their collections."; + + var (clicked, _, data, _) = ResolveTarget(FontAwesomeIcon.Cog, buttonSize, tooltip, available); + ImGui.SameLine(); + if (clicked) + _penumbra.RemoveAllTemporarySettings(data.Objects[0].Index); + } + private (bool, ActorIdentifier, ActorData, ActorState?) ResolveTarget(FontAwesomeIcon icon, Vector2 buttonSize, string tooltip, int available) { - ImGuiUtil.DrawDisabledButton(icon.ToIconString(), buttonSize, tooltip, available == 0, true); + ImUtf8.IconButton(icon, tooltip, buttonSize, available == 0); if ((available & 1) == 1 && ImGui.IsItemClicked(ImGuiMouseButton.Left)) return (true, _playerIdentifier, _playerData, _playerState); if ((available & 2) == 2 && ImGui.IsItemClicked(ImGuiMouseButton.Right)) @@ -441,6 +478,8 @@ public sealed class DesignQuickBar : Window, IDisposable ++_numButtons; if (_config.QdbButtons.HasFlag(QdbButtons.RevertEquip)) ++_numButtons; + if (_config.UseTemporarySettings && _config.QdbButtons.HasFlag(QdbButtons.ResetSettings)) + ++_numButtons; if (_config.QdbButtons.HasFlag(QdbButtons.ApplyDesign)) { ++_numButtons; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index ab40a48..4ee261b 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -9,7 +9,6 @@ using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; using Glamourer.Interop.PalettePlus; using ImGuiNET; -using OtterGui; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Widgets; @@ -39,12 +38,12 @@ public class SettingsTab( public void DrawContent() { - using var child = ImRaii.Child("MainWindowChild"); + using var child = ImUtf8.Child("MainWindowChild"u8, default); if (!child) return; - Checkbox("Enable Auto Designs", - "Enable the application of designs associated to characters in the Automation tab to be applied automatically.", + Checkbox("Enable Auto Designs"u8, + "Enable the application of designs associated to characters in the Automation tab to be applied automatically."u8, config.EnableAutoDesigns, v => { config.EnableAutoDesigns = v; @@ -55,7 +54,7 @@ public class SettingsTab( ImGui.NewLine(); ImGui.NewLine(); - using (ImRaii.Child("SettingsChild")) + using (ImUtf8.Child("SettingsChild"u8, default)) { DrawBehaviorSettings(); DrawDesignDefaultSettings(); @@ -70,44 +69,44 @@ public class SettingsTab( private void DrawBehaviorSettings() { - if (!ImGui.CollapsingHeader("Glamourer Behavior")) + if (!ImUtf8.CollapsingHeader("Glamourer Behavior"u8)) return; - Checkbox("Always Apply Entire Weapon for Mainhand", - "When manually applying a mainhand item, will also apply a corresponding offhand and potentially gauntlets for certain fist weapons.", + Checkbox("Always Apply Entire Weapon for Mainhand"u8, + "When manually applying a mainhand item, will also apply a corresponding offhand and potentially gauntlets for certain fist weapons."u8, config.ChangeEntireItem, v => config.ChangeEntireItem = v); - Checkbox("Use Replacement Gear for Gear Unavailable to Your Race or Gender", - "Use different gender- and race-appropriate models as a substitute when detecting certain items not available for a characters current gender and race.", + Checkbox("Use Replacement Gear for Gear Unavailable to Your Race or Gender"u8, + "Use different gender- and race-appropriate models as a substitute when detecting certain items not available for a characters current gender and race."u8, config.UseRestrictedGearProtection, v => config.UseRestrictedGearProtection = v); - Checkbox("Do Not Apply Unobtained Items in Automation", - "Enable this if you want automatically applied designs to only consider items and customizations you have actually unlocked once, and skip those you have not.", + Checkbox("Do Not Apply Unobtained Items in Automation"u8, + "Enable this if you want automatically applied designs to only consider items and customizations you have actually unlocked once, and skip those you have not."u8, config.UnlockedItemMode, v => config.UnlockedItemMode = v); - Checkbox("Respect Manual Changes When Editing Automation", - "Whether changing any currently active automation group will respect manual changes to the character before re-applying the changed automation or not.", + Checkbox("Respect Manual Changes When Editing Automation"u8, + "Whether changing any currently active automation group will respect manual changes to the character before re-applying the changed automation or not."u8, config.RespectManualOnAutomationUpdate, v => config.RespectManualOnAutomationUpdate = v); - Checkbox("Enable Festival Easter-Eggs", - "Glamourer may do some fun things on specific dates. Disable this if you do not want your experience disrupted by this.", + Checkbox("Enable Festival Easter-Eggs"u8, + "Glamourer may do some fun things on specific dates. Disable this if you do not want your experience disrupted by this."u8, config.DisableFestivals == 0, v => config.DisableFestivals = v ? (byte)0 : (byte)2); - Checkbox("Auto-Reload Gear", - "Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection.", + Checkbox("Auto-Reload Gear"u8, + "Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection."u8, config.AutoRedrawEquipOnChanges, v => config.AutoRedrawEquipOnChanges = v); - Checkbox("Revert Manual Changes on Zone Change", - "Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone.", + Checkbox("Revert Manual Changes on Zone Change"u8, + "Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone."u8, config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v); - Checkbox("Enable Advanced Customization Options", - "Enable the display and editing of advanced customization options like arbitrary colors.", + Checkbox("Enable Advanced Customization Options"u8, + "Enable the display and editing of advanced customization options like arbitrary colors."u8, config.UseAdvancedParameters, paletteChecker.SetAdvancedParameters); PaletteImportButton(); - Checkbox("Enable Advanced Dye Options", - "Enable the display and editing of advanced dyes (color sets) for all equipment", + Checkbox("Enable Advanced Dye Options"u8, + "Enable the display and editing of advanced dyes (color sets) for all equipment"u8, config.UseAdvancedDyes, v => config.UseAdvancedDyes = v); - Checkbox("Always Apply Associated Mods", - "Whenever a design is applied to a character (including via automation), Glamourer will try to apply its associated mod settings to the collection currently associated with that character, if it is available.\n\n" - + "Glamourer will NOT revert these applied settings automatically. This may mess up your collection and configuration.\n\n" - + "If you enable this setting, you are aware that any resulting misconfiguration is your own fault.", + Checkbox("Always Apply Associated Mods"u8, + "Whenever a design is applied to a character (including via automation), Glamourer will try to apply its associated mod settings to the collection currently associated with that character, if it is available.\n\n"u8 + + "Glamourer will NOT revert these applied settings automatically. This may mess up your collection and configuration.\n\n"u8 + + "If you enable this setting, you are aware that any resulting misconfiguration is your own fault."u8, config.AlwaysApplyAssociatedMods, v => config.AlwaysApplyAssociatedMods = v); - Checkbox("Use Temporary Mod Settings", - "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down.", config.UseTemporarySettings, + Checkbox("Use Temporary Mod Settings"u8, + "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down."u8, config.UseTemporarySettings, v => config.UseTemporarySettings = v); ImGui.NewLine(); } @@ -117,33 +116,34 @@ public class SettingsTab( if (!ImUtf8.CollapsingHeader("Design Defaults")) return; - Checkbox("Show in Quick Design Bar", "Newly created designs will be shown in the quick design bar by default.", + Checkbox("Show in Quick Design Bar"u8, "Newly created designs will be shown in the quick design bar by default."u8, config.DefaultDesignSettings.ShowQuickDesignBar, v => config.DefaultDesignSettings.ShowQuickDesignBar = v); - Checkbox("Reset Advanced Dyes", "Newly created designs will be configured to reset advanced dyes on application by default.", + Checkbox("Reset Advanced Dyes"u8, "Newly created designs will be configured to reset advanced dyes on application by default."u8, config.DefaultDesignSettings.ResetAdvancedDyes, v => config.DefaultDesignSettings.ResetAdvancedDyes = v); - Checkbox("Always Force Redraw", "Newly created designs will be configured to force character redraws on application by default.", + Checkbox("Always Force Redraw"u8, "Newly created designs will be configured to force character redraws on application by default."u8, config.DefaultDesignSettings.AlwaysForceRedrawing, v => config.DefaultDesignSettings.AlwaysForceRedrawing = v); - Checkbox("Reset Temporary Settings", "Newly created designs will be configured to clear all advanced settings applied by Glamourer to the collection by default.", + Checkbox("Reset Temporary Settings"u8, + "Newly created designs will be configured to clear all advanced settings applied by Glamourer to the collection by default."u8, config.DefaultDesignSettings.ResetTemporarySettings, v => config.DefaultDesignSettings.ResetTemporarySettings = v); } private void DrawInterfaceSettings() { - if (!ImGui.CollapsingHeader("Interface")) + if (!ImUtf8.CollapsingHeader("Interface"u8)) return; - EphemeralCheckbox("Show Quick Design Bar", - "Show a bar separate from the main window that allows you to quickly apply designs or revert your character and target.", + EphemeralCheckbox("Show Quick Design Bar"u8, + "Show a bar separate from the main window that allows you to quickly apply designs or revert your character and target."u8, config.Ephemeral.ShowDesignQuickBar, v => config.Ephemeral.ShowDesignQuickBar = v); - EphemeralCheckbox("Lock Quick Design Bar", "Prevent the quick design bar from being moved and lock it in place.", + EphemeralCheckbox("Lock Quick Design Bar"u8, "Prevent the quick design bar from being moved and lock it in place."u8, config.Ephemeral.LockDesignQuickBar, v => config.Ephemeral.LockDesignQuickBar = v); if (Widget.ModifiableKeySelector("Hotkey to Toggle Quick Design Bar", "Set a hotkey that opens or closes the quick design bar.", 100 * ImGuiHelpers.GlobalScale, config.ToggleQuickDesignBar, v => config.ToggleQuickDesignBar = v, _validKeys)) config.Save(); - Checkbox("Show Quick Design Bar in Main Window", - "Show the quick design bar in the tab selection part of the main window, too.", + Checkbox("Show Quick Design Bar in Main Window"u8, + "Show the quick design bar in the tab selection part of the main window, too."u8, config.ShowQuickBarInTabs, v => config.ShowQuickBarInTabs = v); DrawQuickDesignBoxes(); @@ -151,7 +151,7 @@ public class SettingsTab( ImGui.Separator(); ImGui.Dummy(Vector2.Zero); - Checkbox("Enable Game Context Menus", "Whether to show a Try On via Glamourer button on context menus for equippable items.", + Checkbox("Enable Game Context Menus"u8, "Whether to show a Try On via Glamourer button on context menus for equippable items."u8, config.EnableGameContextMenu, v => { config.EnableGameContextMenu = v; @@ -160,41 +160,41 @@ public class SettingsTab( else contextMenuService.Disable(); }); - Checkbox("Show Window when UI is Hidden", "Whether to show Glamourer windows even when the games UI is hidden.", + Checkbox("Show Window when UI is Hidden"u8, "Whether to show Glamourer windows even when the games UI is hidden."u8, config.ShowWindowWhenUiHidden, v => { config.ShowWindowWhenUiHidden = v; uiBuilder.DisableUserUiHide = v; }); - Checkbox("Hide Window in Cutscenes", "Whether the main Glamourer window should automatically be hidden when entering cutscenes or not.", + Checkbox("Hide Window in Cutscenes"u8, "Whether the main Glamourer window should automatically be hidden when entering cutscenes or not."u8, config.HideWindowInCutscene, v => { config.HideWindowInCutscene = v; uiBuilder.DisableCutsceneUiHide = !v; }); - EphemeralCheckbox("Lock Main Window", "Prevent the main window from being moved and lock it in place.", + EphemeralCheckbox("Lock Main Window"u8, "Prevent the main window from being moved and lock it in place."u8, config.Ephemeral.LockMainWindow, v => config.Ephemeral.LockMainWindow = v); - Checkbox("Open Main Window at Game Start", "Whether the main Glamourer window should be open or closed after launching the game.", + Checkbox("Open Main Window at Game Start"u8, "Whether the main Glamourer window should be open or closed after launching the game."u8, config.OpenWindowAtStart, v => config.OpenWindowAtStart = v); ImGui.Dummy(Vector2.Zero); ImGui.Separator(); ImGui.Dummy(Vector2.Zero); - Checkbox("Smaller Equip Display", "Use single-line display without icons and small dye buttons instead of double-line display.", + Checkbox("Smaller Equip Display"u8, "Use single-line display without icons and small dye buttons instead of double-line display."u8, config.SmallEquip, v => config.SmallEquip = v); DrawHeightUnitSettings(); - Checkbox("Show Application Checkboxes", - "Show the application checkboxes in the Customization and Equipment panels of the design tab, instead of only showing them under Application Rules.", + Checkbox("Show Application Checkboxes"u8, + "Show the application checkboxes in the Customization and Equipment panels of the design tab, instead of only showing them under Application Rules."u8, !config.HideApplyCheckmarks, v => config.HideApplyCheckmarks = !v); if (Widget.DoubleModifierSelector("Design Deletion Modifier", "A modifier you need to hold while clicking the Delete Design button for it to take effect.", 100 * ImGuiHelpers.GlobalScale, config.DeleteDesignModifier, v => config.DeleteDesignModifier = v)) config.Save(); DrawRenameSettings(); - Checkbox("Auto-Open Design Folders", - "Have design folders open or closed as their default state after launching.", config.OpenFoldersByDefault, + Checkbox("Auto-Open Design Folders"u8, + "Have design folders open or closed as their default state after launching."u8, config.OpenFoldersByDefault, v => config.OpenFoldersByDefault = v); DrawFolderSortType(); @@ -202,32 +202,32 @@ public class SettingsTab( ImGui.Separator(); ImGui.Dummy(Vector2.Zero); - Checkbox("Allow Double-Clicking Designs to Apply", - "Tries to apply a design to the current player character When double-clicking it in the design selector.", + Checkbox("Allow Double-Clicking Designs to Apply"u8, + "Tries to apply a design to the current player character When double-clicking it in the design selector."u8, config.AllowDoubleClickToApply, v => config.AllowDoubleClickToApply = v); - Checkbox("Show all Application Rule Checkboxes for Automation", - "Show multiple separate application rule checkboxes for automated designs, instead of a single box for enabling or disabling.", + Checkbox("Show all Application Rule Checkboxes for Automation"u8, + "Show multiple separate application rule checkboxes for automated designs, instead of a single box for enabling or disabling."u8, config.ShowAllAutomatedApplicationRules, v => config.ShowAllAutomatedApplicationRules = v); - Checkbox("Show Unobtained Item Warnings", - "Show information whether you have unlocked all items and customizations in your automated design or not.", + Checkbox("Show Unobtained Item Warnings"u8, + "Show information whether you have unlocked all items and customizations in your automated design or not."u8, config.ShowUnlockedItemWarnings, v => config.ShowUnlockedItemWarnings = v); if (config.UseAdvancedParameters) { - Checkbox("Show Color Display Config", "Show the Color Display configuration options in the Advanced Customization panels.", + Checkbox("Show Color Display Config"u8, "Show the Color Display configuration options in the Advanced Customization panels."u8, config.ShowColorConfig, v => config.ShowColorConfig = v); - Checkbox("Show Palette+ Import Button", - "Show the import button that allows you to import Palette+ palettes onto a design in the Advanced Customization options section for designs.", + Checkbox("Show Palette+ Import Button"u8, + "Show the import button that allows you to import Palette+ palettes onto a design in the Advanced Customization options section for designs."u8, config.ShowPalettePlusImport, v => config.ShowPalettePlusImport = v); using var id = ImRaii.PushId(1); PaletteImportButton(); } if (config.UseAdvancedDyes) - Checkbox("Keep Advanced Dye Window Attached", - "Keeps the advanced dye window expansion attached to the main window, or makes it freely movable.", + Checkbox("Keep Advanced Dye Window Attached"u8, + "Keeps the advanced dye window expansion attached to the main window, or makes it freely movable."u8, config.KeepAdvancedDyesAttached, v => config.KeepAdvancedDyesAttached = v); - Checkbox("Debug Mode", "Show the debug tab. Only useful for debugging or advanced use. Not recommended in general.", config.DebugMode, + Checkbox("Debug Mode"u8, "Show the debug tab. Only useful for debugging or advanced use. Not recommended in general."u8, config.DebugMode, v => config.DebugMode = v); ImGui.NewLine(); } @@ -236,40 +236,48 @@ public class SettingsTab( { var showAuto = config.EnableAutoDesigns; var showAdvanced = config.UseAdvancedParameters || config.UseAdvancedDyes; - var numColumns = 7 - (showAuto ? 0 : 2) - (showAdvanced ? 0 : 1); + var numColumns = 8 - (showAuto ? 0 : 2) - (showAdvanced ? 0 : 1) - (config.UseTemporarySettings ? 0 : 1); ImGui.NewLine(); - ImGui.TextUnformatted("Show the Following Buttons in the Quick Design Bar:"); + ImUtf8.Text("Show the Following Buttons in the Quick Design Bar:"u8); ImGui.Dummy(Vector2.Zero); - using var table = ImRaii.Table("##tableQdb", numColumns, + using var table = ImUtf8.Table("##tableQdb"u8, numColumns, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders | ImGuiTableFlags.NoHostExtendX); if (!table) return; - var columns = new[] - { - (" Apply Design ", true, QdbButtons.ApplyDesign), - (" Revert All ", true, QdbButtons.RevertAll), - (" Revert to Auto ", showAuto, QdbButtons.RevertAutomation), - (" Reapply Auto ", showAuto, QdbButtons.ReapplyAutomation), - (" Revert Equip ", true, QdbButtons.RevertEquip), - (" Revert Customize ", true, QdbButtons.RevertCustomize), - (" Revert Advanced ", showAdvanced, QdbButtons.RevertAdvanced), - }; + ReadOnlySpan<(string, bool, QdbButtons)> columns = + [ + ("Apply Design", true, QdbButtons.ApplyDesign), + ("Revert All", true, QdbButtons.RevertAll), + ("Revert to Auto", showAuto, QdbButtons.RevertAutomation), + ("Reapply Auto", showAuto, QdbButtons.ReapplyAutomation), + ("Revert Equip", true, QdbButtons.RevertEquip), + ("Revert Customize", true, QdbButtons.RevertCustomize), + ("Revert Advanced", showAdvanced, QdbButtons.RevertAdvanced), + ("Reset Settings", config.UseTemporarySettings, QdbButtons.ResetSettings), + ]; - foreach (var (label, _, _) in columns.Where(t => t.Item2)) + for(var i = 0; i < columns.Length; ++i) { + if (!columns[i].Item2) + continue; + ImGui.TableNextColumn(); - ImGui.TableHeader(label); + ImUtf8.TableHeader(columns[i].Item1); } - foreach (var (_, _, flag) in columns.Where(t => t.Item2)) + for (var i = 0; i < columns.Length; ++i) { - using var id = ImRaii.PushId((int)flag); + if (!columns[i].Item2) + continue; + + var flag = columns[i].Item3; + using var id = ImUtf8.PushId((int)flag); ImGui.TableNextColumn(); var offset = (ImGui.GetContentRegionAvail().X - ImGui.GetFrameHeight()) / 2; ImGui.SetCursorPosX(ImGui.GetCursorPosX() + offset); var value = config.QdbButtons.HasFlag(flag); - if (!ImGui.Checkbox(string.Empty, ref value)) + if (!ImUtf8.Checkbox(""u8, ref value)) continue; var buttons = value ? config.QdbButtons | flag : config.QdbButtons & ~flag; @@ -287,31 +295,31 @@ public class SettingsTab( return; ImGui.SameLine(); - if (ImGui.Button("Import Palette+ to Designs")) + if (ImUtf8.Button("Import Palette+ to Designs"u8)) paletteImport.ImportDesigns(); - ImGuiUtil.HoverTooltip( + ImUtf8.HoverTooltip( $"Import all existing Palettes from your Palette+ Config into Designs at PalettePlus/[Name] if these do not exist. Existing Palettes are:\n\n\t - {string.Join("\n\t - ", paletteImport.Data.Keys)}"); } /// Draw the entire Color subsection. private void DrawColorSettings() { - if (!ImGui.CollapsingHeader("Colors")) + if (!ImUtf8.CollapsingHeader("Colors"u8)) return; - using (var tree = ImRaii.TreeNode("Custom Design Colors")) + using (var tree = ImUtf8.TreeNode("Custom Design Colors"u8)) { if (tree) designColorUi.Draw(); } - using (var tree = ImRaii.TreeNode("Color Settings")) + using (var tree = ImUtf8.TreeNode("Color Settings"u8)) { if (tree) foreach (var color in Enum.GetValues()) { var (defaultColor, name, description) = color.Data(); - var currentColor = config.Colors.TryGetValue(color, out var current) ? current : defaultColor; + var currentColor = config.Colors.GetValueOrDefault(color, defaultColor); if (Widget.ColorPicker(name, description, currentColor, c => config.Colors[color] = c, defaultColor)) config.Save(); } @@ -321,33 +329,33 @@ public class SettingsTab( } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - private void Checkbox(string label, string tooltip, bool current, Action setter) + private void Checkbox(ReadOnlySpan label, ReadOnlySpan tooltip, bool current, Action setter) { - using var id = ImRaii.PushId(label); + using var id = ImUtf8.PushId(label); var tmp = current; - if (ImGui.Checkbox(string.Empty, ref tmp) && tmp != current) + if (ImUtf8.Checkbox(""u8, ref tmp) && tmp != current) { setter(tmp); config.Save(); } ImGui.SameLine(); - ImGuiUtil.LabeledHelpMarker(label, tooltip); + ImUtf8.LabeledHelpMarker(label, tooltip); } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - private void EphemeralCheckbox(string label, string tooltip, bool current, Action setter) + private void EphemeralCheckbox(ReadOnlySpan label, ReadOnlySpan tooltip, bool current, Action setter) { - using var id = ImRaii.PushId(label); + using var id = ImUtf8.PushId(label); var tmp = current; - if (ImGui.Checkbox(string.Empty, ref tmp) && tmp != current) + if (ImUtf8.Checkbox(""u8, ref tmp) && tmp != current) { setter(tmp); config.Ephemeral.Save(); } ImGui.SameLine(); - ImGuiUtil.LabeledHelpMarker(label, tooltip); + ImUtf8.LabeledHelpMarker(label, tooltip); } /// Different supported sort modes as a combo. @@ -355,29 +363,29 @@ public class SettingsTab( { var sortMode = config.SortMode; ImGui.SetNextItemWidth(300 * ImGuiHelpers.GlobalScale); - using (var combo = ImRaii.Combo("##sortMode", sortMode.Name)) + using (var combo = ImUtf8.Combo("##sortMode"u8, sortMode.Name)) { if (combo) foreach (var val in Configuration.Constants.ValidSortModes) { - if (ImGui.Selectable(val.Name, val.GetType() == sortMode.GetType()) && val.GetType() != sortMode.GetType()) + if (ImUtf8.Selectable(val.Name, val.GetType() == sortMode.GetType()) && val.GetType() != sortMode.GetType()) { config.SortMode = val; selector.SetFilterDirty(); config.Save(); } - ImGuiUtil.HoverTooltip(val.Description); + ImUtf8.HoverTooltip(val.Description); } } - ImGuiUtil.LabeledHelpMarker("Sort Mode", "Choose the sort mode for the mod selector in the designs tab."); + ImUtf8.LabeledHelpMarker("Sort Mode"u8, "Choose the sort mode for the mod selector in the designs tab."u8); } private void DrawRenameSettings() { ImGui.SetNextItemWidth(300 * ImGuiHelpers.GlobalScale); - using (var combo = ImRaii.Combo("##renameSettings", config.ShowRename.GetData().Name)) + using (var combo = ImUtf8.Combo("##renameSettings"u8, config.ShowRename.GetData().Name)) { if (combo) foreach (var value in Enum.GetValues()) @@ -390,7 +398,7 @@ public class SettingsTab( config.Save(); } - ImGuiUtil.HoverTooltip(desc); + ImUtf8.HoverTooltip(desc); } } @@ -399,19 +407,19 @@ public class SettingsTab( "Select which of the two renaming input fields are visible when opening the right-click context menu of a design in the design selector."; ImGuiComponents.HelpMarker(tt); ImGui.SameLine(); - ImGui.TextUnformatted("Rename Fields in Design Context Menu"); - ImGuiUtil.HoverTooltip(tt); + ImUtf8.Text("Rename Fields in Design Context Menu"u8); + ImUtf8.HoverTooltip(tt); } private void DrawHeightUnitSettings() { ImGui.SetNextItemWidth(300 * ImGuiHelpers.GlobalScale); - using (var combo = ImRaii.Combo("##heightUnit", HeightDisplayTypeName(config.HeightDisplayType))) + using (var combo = ImUtf8.Combo("##heightUnit"u8, HeightDisplayTypeName(config.HeightDisplayType))) { if (combo) foreach (var type in Enum.GetValues()) { - if (ImGui.Selectable(HeightDisplayTypeName(type), type == config.HeightDisplayType) && type != config.HeightDisplayType) + if (ImUtf8.Selectable(HeightDisplayTypeName(type), type == config.HeightDisplayType) && type != config.HeightDisplayType) { config.HeightDisplayType = type; config.Save(); @@ -423,20 +431,20 @@ public class SettingsTab( const string tt = "Select how to display the height of characters in real-world units, if at all."; ImGuiComponents.HelpMarker(tt); ImGui.SameLine(); - ImGui.TextUnformatted("Character Height Display Type"); - ImGuiUtil.HoverTooltip(tt); + ImUtf8.Text("Character Height Display Type"u8); + ImUtf8.HoverTooltip(tt); } - private static string HeightDisplayTypeName(HeightDisplayType type) + private static ReadOnlySpan HeightDisplayTypeName(HeightDisplayType type) => type switch { - HeightDisplayType.None => "Do Not Display", - HeightDisplayType.Centimetre => "Centimetres (000.0 cm)", - HeightDisplayType.Metre => "Metres (0.00 m)", - HeightDisplayType.Wrong => "Inches (00.0 in)", - HeightDisplayType.WrongFoot => "Feet (0'00'')", - HeightDisplayType.Corgi => "Corgis (0.0 Corgis)", - HeightDisplayType.OlympicPool => "Olympic-size swimming Pools (0.000 Pools)", - _ => string.Empty, + HeightDisplayType.None => "Do Not Display"u8, + HeightDisplayType.Centimetre => "Centimetres (000.0 cm)"u8, + HeightDisplayType.Metre => "Metres (0.00 m)"u8, + HeightDisplayType.Wrong => "Inches (00.0 in)"u8, + HeightDisplayType.WrongFoot => "Feet (0'00'')"u8, + HeightDisplayType.Corgi => "Corgis (0.0 Corgis)"u8, + HeightDisplayType.OlympicPool => "Olympic-size swimming Pools (0.000 Pools)"u8, + _ => ""u8, }; } diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 42058d2..fec5b13 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -407,7 +407,8 @@ public class StateEditor( } else if (!value.Revert) { - Editor.ChangeMaterialValue(state, idx, new MaterialValueState(ColorRow.Empty, value.Value, CharacterWeapon.Empty, source), + Editor.ChangeMaterialValue(state, idx, + new MaterialValueState(ColorRow.Empty, value.Value, CharacterWeapon.Empty, source), settings.Source, out _, settings.Key); } } diff --git a/OtterGui b/OtterGui index 0b6085c..332852f 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 0b6085ce720ffb7c78cf42d4e51861f34db27744 +Subproject commit 332852ffa81387b59f260781d7e5c967f24d8be2 From e5b2114ac250dec49e052ffc15ceae9955c0af4d Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 18 Feb 2025 14:13:13 +0000 Subject: [PATCH 220/401] [CI] Updating repo.json for testing_1.3.6.2 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 76009f4..992ca6a 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.6.0", - "TestingAssemblyVersion": "1.3.6.1", + "TestingAssemblyVersion": "1.3.6.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 9e7679e70fecce6aa8abdb1a7b9eb769bd7a58e7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 19 Feb 2025 23:36:52 +0100 Subject: [PATCH 221/401] Move check for valid model to actor display instead of identifier list. --- Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs | 7 ++++--- Glamourer/Interop/ObjectManager.cs | 2 +- OtterGui | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs index 76f0ba4..3269fd2 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs @@ -91,9 +91,10 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral objects.Update(); _world = new WorldId(objects.Player.Valid ? objects.Player.HomeWorld : (ushort)0); - using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); - var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight()); - var remainder = ImGuiClip.FilteredClippedDraw(objects.Identifiers, skips, CheckFilter, DrawSelectable); + using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); + var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight()); + var remainder = ImGuiClip.FilteredClippedDraw(objects.Identifiers.Where(p => p.Value.Objects.Any(a => a.Model)), skips, CheckFilter, + DrawSelectable); ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight()); } diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs index b185f4a..47f7ad5 100644 --- a/Glamourer/Interop/ObjectManager.cs +++ b/Glamourer/Interop/ObjectManager.cs @@ -83,7 +83,7 @@ public class ObjectManager( private void HandleIdentifier(ActorIdentifier identifier, Actor character) { - if (!character.Model || !identifier.IsValid) + if (!identifier.IsValid) return; if (!_identifiers.TryGetValue(identifier, out var data)) diff --git a/OtterGui b/OtterGui index 332852f..06422a8 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 332852ffa81387b59f260781d7e5c967f24d8be2 +Subproject commit 06422a893348a18a013e6dbc558370db8d21a446 From 5a9e9513f4cf62fff84237a6a68717e9d5857693 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 19 Feb 2025 23:42:05 +0100 Subject: [PATCH 222/401] Skip automatic updates from temporary settings when applied by design. --- .../Interop/Penumbra/ModSettingApplier.cs | 5 +++-- .../Interop/Penumbra/PenumbraAutoRedraw.cs | 21 +++++++++++-------- .../Penumbra/PenumbraAutoRedrawSkip.cs | 15 +++++++++++++ Glamourer/State/StateEditor.cs | 2 +- 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 Glamourer/Interop/Penumbra/PenumbraAutoRedrawSkip.cs diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index 5b27e6e..60f07e4 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -7,12 +7,12 @@ using Penumbra.GameData.Structs; namespace Glamourer.Interop.Penumbra; -public class ModSettingApplier(PenumbraService penumbra, Configuration config, ObjectManager objects, CollectionOverrideService overrides) +public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip autoRedrawSkip, Configuration config, ObjectManager objects, CollectionOverrideService overrides) : IService { private readonly HashSet _collectionTracker = []; - public void HandleStateApplication(ActorState state, MergedDesign design) + public void HandleStateApplication(ActorState state, MergedDesign design, bool skipAutoRedraw) { if (!config.AlwaysApplyAssociatedMods || (design.AssociatedMods.Count == 0 && !design.ResetTemporarySettings)) return; @@ -26,6 +26,7 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O } _collectionTracker.Clear(); + using var skip = autoRedrawSkip.SkipAutoUpdates(skipAutoRedraw); foreach (var actor in data.Objects) { var (collection, _, overridden) = overrides.GetCollection(actor, state.Identifier); diff --git a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs index 3e48fe9..93d23c2 100644 --- a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs +++ b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs @@ -12,16 +12,18 @@ namespace Glamourer.Interop.Penumbra; public class PenumbraAutoRedraw : IDisposable, IRequiredService { - private const int WaitFrames = 5; - private readonly Configuration _config; - private readonly PenumbraService _penumbra; - private readonly StateManager _state; - private readonly ObjectManager _objects; - private readonly IFramework _framework; - private readonly StateChanged _stateChanged; + private const int WaitFrames = 5; + private readonly Configuration _config; + private readonly PenumbraService _penumbra; + private readonly StateManager _state; + private readonly ObjectManager _objects; + private readonly IFramework _framework; + private readonly StateChanged _stateChanged; + private readonly PenumbraAutoRedrawSkip _skip; + public PenumbraAutoRedraw(PenumbraService penumbra, Configuration config, StateManager state, ObjectManager objects, IFramework framework, - StateChanged stateChanged) + StateChanged stateChanged, PenumbraAutoRedrawSkip skip) { _penumbra = penumbra; _config = config; @@ -29,6 +31,7 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService _objects = objects; _framework = framework; _stateChanged = stateChanged; + _skip = skip; _penumbra.ModSettingChanged += OnModSettingChange; _framework.Update += OnFramework; _stateChanged.Subscribe(OnStateChanged, StateChanged.Priority.PenumbraAutoRedraw); @@ -94,7 +97,7 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService } }); } - else if (_config.AutoRedrawEquipOnChanges) + else if (_config.AutoRedrawEquipOnChanges && !_skip.Skip) { // Only update once per frame. var playerName = _penumbra.GetCurrentPlayerCollection(); diff --git a/Glamourer/Interop/Penumbra/PenumbraAutoRedrawSkip.cs b/Glamourer/Interop/Penumbra/PenumbraAutoRedrawSkip.cs new file mode 100644 index 0000000..8ef522c --- /dev/null +++ b/Glamourer/Interop/Penumbra/PenumbraAutoRedrawSkip.cs @@ -0,0 +1,15 @@ +using OtterGui.Classes; +using OtterGui.Services; + +namespace Glamourer.Interop.Penumbra; + +public class PenumbraAutoRedrawSkip : IService +{ + private bool _skipAutoUpdates; + + public BoolSetter SkipAutoUpdates(bool skip) + => new(ref _skipAutoUpdates, skip); + + public bool Skip + => _skipAutoUpdates; +} diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index fec5b13..7eea607 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -262,7 +262,7 @@ public class StateEditor( public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings settings) { var state = (ActorState)data; - modApplier.HandleStateApplication(state, mergedDesign); + modApplier.HandleStateApplication(state, mergedDesign, true); if (!Editor.ChangeModelId(state, mergedDesign.Design.DesignData.ModelId, mergedDesign.Design.DesignData.Customize, mergedDesign.Design.GetDesignDataRef().GetEquipmentPtr(), settings.Source, out var oldModelId, settings.Key)) return; From c1f84b4303b76f935a1f6023f12308868dc4a00a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 20 Feb 2025 00:16:49 +0100 Subject: [PATCH 223/401] Differentiate between temporary settings through manual and automatic application. --- Glamourer/Automation/AutoDesignApplier.cs | 10 ++- Glamourer/Gui/DesignQuickBar.cs | 9 ++- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 77 +++++++++---------- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 5 +- Glamourer/Interop/ObjectManager.cs | 10 ++- .../Interop/Penumbra/ModSettingApplier.cs | 26 ++++--- Glamourer/Interop/Penumbra/PenumbraService.cs | 44 +++++++---- Glamourer/Services/CommandService.cs | 2 +- Glamourer/State/StateEditor.cs | 2 +- 9 files changed, 108 insertions(+), 77 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 7f75674..545dff7 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -293,8 +293,16 @@ public sealed class AutoDesignApplier : IDisposable set.Designs.Where(d => d.IsActive(actor)) .SelectMany(d => d.Design.AllLinks(newApplication).Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))), state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods); - if (set.ResetTemporarySettings) + + if (_objects.IsInGPose && actor.IsGPoseOrCutscene) + { + mergedDesign.ResetTemporarySettings = false; + mergedDesign.AssociatedMods.Clear(); + } + else if (set.ResetTemporarySettings) + { mergedDesign.ResetTemporarySettings = true; + } _state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false)); forcedRedraw = mergedDesign.ForcedRedraw; diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index 1e2904c..b125b37 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -409,7 +409,7 @@ public sealed class DesignQuickBar : Window, IDisposable if (_playerIdentifier.IsValid && _playerData.Valid) { available |= 1; - tooltip = $"Left-Click: Reset all temporary settings applied by Glamourer to the collection affecting {_playerIdentifier}."; + tooltip = $"Left-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting {_playerIdentifier}."; } if (_targetIdentifier.IsValid && _targetData.Valid) @@ -417,7 +417,7 @@ public sealed class DesignQuickBar : Window, IDisposable if (available != 0) tooltip += '\n'; available |= 2; - tooltip += $"Right-Click: Reset all temporary settings applied by Glamourer to the collection affecting {_targetIdentifier}."; + tooltip += $"Right-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting {_targetIdentifier}."; } if (available == 0) @@ -426,7 +426,10 @@ public sealed class DesignQuickBar : Window, IDisposable var (clicked, _, data, _) = ResolveTarget(FontAwesomeIcon.Cog, buttonSize, tooltip, available); ImGui.SameLine(); if (clicked) - _penumbra.RemoveAllTemporarySettings(data.Objects[0].Index); + { + _penumbra.RemoveAllTemporarySettings(data.Objects[0].Index, StateSource.Manual); + _penumbra.RemoveAllTemporarySettings(data.Objects[0].Index, StateSource.Fixed); + } } private (bool, ActorIdentifier, ActorData, ActorState?) ResolveTarget(FontAwesomeIcon icon, Vector2 buttonSize, string tooltip, diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index caa7d60..680e0e9 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -52,7 +52,7 @@ public class SetPanel( private void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); + using var child = ImUtf8.Child("##Panel"u8, -Vector2.One, true); if (!child || !_selector.HasSelection) return; @@ -63,20 +63,20 @@ public class SetPanel( using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) { var enabled = Selection.Enabled; - if (ImGui.Checkbox("##Enabled", ref enabled)) + if (ImUtf8.Checkbox("##Enabled"u8, ref enabled)) _manager.SetState(_selector.SelectionIndex, enabled); - ImGuiUtil.LabeledHelpMarker("Enabled", - "Whether the designs in this set should be applied at all. Only one set can be enabled for a character at the same time."); + ImUtf8.LabeledHelpMarker("Enabled"u8, + "Whether the designs in this set should be applied at all. Only one set can be enabled for a character at the same time."u8); } using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) { var useGame = _selector.Selection!.BaseState is AutoDesignSet.Base.Game; - if (ImGui.Checkbox("##gameState", ref useGame)) + if (ImUtf8.Checkbox("##gameState"u8, ref useGame)) _manager.ChangeBaseState(_selector.SelectionIndex, useGame ? AutoDesignSet.Base.Game : AutoDesignSet.Base.Current); - ImGuiUtil.LabeledHelpMarker("Use Game State as Base", - "When this is enabled, the designs matching conditions will be applied successively on top of what your character is supposed to look like for the game. " - + "Otherwise, they will be applied on top of the characters actual current look using Glamourer."); + ImUtf8.LabeledHelpMarker("Use Game State as Base"u8, + "When this is enabled, the designs matching conditions will be applied successively on top of what your character is supposed to look like for the game. "u8 + + "Otherwise, they will be applied on top of the characters actual current look using Glamourer."u8); } } @@ -86,14 +86,14 @@ public class SetPanel( using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) { var editing = _config.ShowAutomationSetEditing; - if (ImGui.Checkbox("##Show Editing", ref editing)) + if (ImUtf8.Checkbox("##Show Editing"u8, ref editing)) { _config.ShowAutomationSetEditing = editing; _config.Save(); } - ImGuiUtil.LabeledHelpMarker("Show Editing", - "Show options to change the name or the associated character or NPC of this design set."); + ImUtf8.LabeledHelpMarker("Show Editing"u8, + "Show options to change the name or the associated character or NPC of this design set."u8); } using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) @@ -102,8 +102,8 @@ public class SetPanel( if (ImGui.Checkbox("##resetSettings", ref resetSettings)) _manager.ChangeResetSettings(_selector.SelectionIndex, resetSettings); - ImGuiUtil.LabeledHelpMarker("Reset Temporary Settings", - "Always reset all temporary settings applied by Glamourer when this automation set is applied, regardless of active designs."); + ImUtf8.LabeledHelpMarker("Reset Temporary Settings"u8, + "Always reset all temporary settings applied by Glamourer when this automation set is applied, regardless of active designs."u8); } } @@ -160,42 +160,42 @@ public class SetPanel( (false, false) => 4, }; - using var table = ImRaii.Table("SetTable", numRows, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX | ImGuiTableFlags.ScrollY); + using var table = ImUtf8.Table("SetTable"u8, numRows, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX | ImGuiTableFlags.ScrollY); if (!table) return; - ImGui.TableSetupColumn("##del", ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight()); - ImGui.TableSetupColumn("##Index", ImGuiTableColumnFlags.WidthFixed, 30 * ImGuiHelpers.GlobalScale); + ImUtf8.TableSetupColumn("##del"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight()); + ImUtf8.TableSetupColumn("##Index"u8, ImGuiTableColumnFlags.WidthFixed, 30 * ImGuiHelpers.GlobalScale); if (singleRow) { - ImGui.TableSetupColumn("Design", ImGuiTableColumnFlags.WidthFixed, 220 * ImGuiHelpers.GlobalScale); + ImUtf8.TableSetupColumn("Design"u8, ImGuiTableColumnFlags.WidthFixed, 220 * ImGuiHelpers.GlobalScale); if (_config.ShowAllAutomatedApplicationRules) - ImGui.TableSetupColumn("Application", ImGuiTableColumnFlags.WidthFixed, + ImUtf8.TableSetupColumn("Application"u8, ImGuiTableColumnFlags.WidthFixed, 6 * ImGui.GetFrameHeight() + 10 * ImGuiHelpers.GlobalScale); else - ImGui.TableSetupColumn("Use", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); + ImUtf8.TableSetupColumn("Use"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); } else { - ImGui.TableSetupColumn("Design / Job Restrictions", ImGuiTableColumnFlags.WidthFixed, 250 * ImGuiHelpers.GlobalScale); + ImUtf8.TableSetupColumn("Design / Job Restrictions"u8, ImGuiTableColumnFlags.WidthFixed, 250 * ImGuiHelpers.GlobalScale); if (_config.ShowAllAutomatedApplicationRules) - ImGui.TableSetupColumn("Application", ImGuiTableColumnFlags.WidthFixed, + ImUtf8.TableSetupColumn("Application"u8, ImGuiTableColumnFlags.WidthFixed, 3 * ImGui.GetFrameHeight() + 4 * ImGuiHelpers.GlobalScale); else - ImGui.TableSetupColumn("Use", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); + ImUtf8.TableSetupColumn("Use"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); } if (singleRow) - ImGui.TableSetupColumn("Job Restrictions", ImGuiTableColumnFlags.WidthStretch); + ImUtf8.TableSetupColumn("Job Restrictions"u8, ImGuiTableColumnFlags.WidthStretch); if (_config.ShowUnlockedItemWarnings) - ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthFixed, 2 * ImGui.GetFrameHeight() + 4 * ImGuiHelpers.GlobalScale); + ImUtf8.TableSetupColumn(""u8, ImGuiTableColumnFlags.WidthFixed, 2 * ImGui.GetFrameHeight() + 4 * ImGuiHelpers.GlobalScale); ImGui.TableHeadersRow(); foreach (var (design, idx) in Selection.Designs.WithIndex()) { - using var id = ImRaii.PushId(idx); + using var id = ImUtf8.PushId(idx); ImGui.TableNextColumn(); var keyValid = _config.DeleteDesignModifier.IsActive(); var tt = keyValid @@ -205,7 +205,7 @@ public class SetPanel( if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), new Vector2(ImGui.GetFrameHeight()), tt, !keyValid, true)) _endAction = () => _manager.DeleteDesign(Selection, idx); ImGui.TableNextColumn(); - ImGui.Selectable($"#{idx + 1:D2}"); + ImUtf8.Selectable($"#{idx + 1:D2}"); DrawDragDrop(Selection, idx); ImGui.TableNextColumn(); DrawRandomEditing(Selection, design, idx); @@ -234,8 +234,7 @@ public class SetPanel( ImGui.TableNextColumn(); ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted("New"); + ImUtf8.TextFrameAligned("New"u8); ImGui.TableNextColumn(); _designCombo.Draw(Selection, null, -1); ImGui.TableNextRow(); @@ -250,20 +249,20 @@ public class SetPanel( private void DrawConditions(AutoDesign design, int idx) { var usingGearset = design.GearsetIndex >= 0; - if (ImGui.Button($"{(usingGearset ? "Gearset:" : "Jobs:")}##usingGearset")) + if (ImUtf8.Button($"{(usingGearset ? "Gearset:" : "Jobs:")}##usingGearset")) { usingGearset = !usingGearset; _manager.ChangeGearsetCondition(Selection, idx, (short)(usingGearset ? 0 : -1)); } - ImGuiUtil.HoverTooltip("Click to switch between Job and Gearset restrictions."); + ImUtf8.HoverTooltip("Click to switch between Job and Gearset restrictions."u8); ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); if (usingGearset) { var set = 1 + (_tmpGearset == int.MaxValue || _whichIndex != idx ? design.GearsetIndex : _tmpGearset); ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); - if (ImGui.InputInt("##whichGearset", ref set, 0, 0)) + if (ImUtf8.InputScalar("##whichGearset"u8, ref set)) { _whichIndex = idx; _tmpGearset = Math.Clamp(set, 1, 100); @@ -361,12 +360,12 @@ public class SetPanel( ImGuiUtil.DrawTextButton(FontAwesomeIcon.ExclamationCircle.ToIconString(), size, color); } - ImGuiUtil.HoverTooltip(sb.ToString()); + ImUtf8.HoverTooltip($"{sb}"); } else { ImGuiUtil.DrawTextButton(string.Empty, size, 0); - ImGuiUtil.HoverTooltip(good); + ImUtf8.HoverTooltip(good); } } } @@ -374,7 +373,7 @@ public class SetPanel( private void DrawDragDrop(AutoDesignSet set, int index) { const string dragDropLabel = "DesignDragDrop"; - using (var target = ImRaii.DragDropTarget()) + using (var target = ImUtf8.DragDropTarget()) { if (target.Success && ImGuiUtil.IsDropping(dragDropLabel)) { @@ -388,11 +387,11 @@ public class SetPanel( } } - using (var source = ImRaii.DragDropSource()) + using (var source = ImUtf8.DragDropSource()) { if (source) { - ImGui.TextUnformatted($"Moving design #{index + 1:D2}..."); + ImUtf8.Text($"Moving design #{index + 1:D2}..."); if (ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0)) { _dragIndex = index; @@ -415,16 +414,16 @@ public class SetPanel( } style.Pop(); - ImGuiUtil.HoverTooltip("Toggle all application modes at once."); + ImUtf8.HoverTooltip("Toggle all application modes at once."u8); if (_config.ShowAllAutomatedApplicationRules) { void Box(int idx) { var (type, description) = ApplicationTypeExtensions.Types[idx]; var value = design.Type.HasFlag(type); - if (ImGui.Checkbox($"##{(byte)type}", ref value)) + if (ImUtf8.Checkbox($"##{(byte)type}", ref value)) newType = value ? newType | type : newType & ~type; - ImGuiUtil.HoverTooltip(description); + ImUtf8.HoverTooltip(description); } ImGui.SameLine(); diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index feff657..5856fcc 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -4,6 +4,7 @@ using Dalamud.Interface.Utility; using Dalamud.Utility; using Glamourer.Designs; using Glamourer.Interop.Penumbra; +using Glamourer.State; using ImGuiNET; using OtterGui; using OtterGui.Classes; @@ -83,7 +84,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect public void ApplyAll() { foreach (var (mod, settings) in selector.Selected!.AssociatedMods) - penumbra.SetMod(mod, settings); + penumbra.SetMod(mod, settings, StateSource.Manual); } private void DrawTable() @@ -218,7 +219,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect if (ImGuiUtil.DrawDisabledButton("Apply", new Vector2(ImGui.GetContentRegionAvail().X, 0), string.Empty, !penumbra.Available)) { - var text = penumbra.SetMod(mod, settings); + var text = penumbra.SetMod(mod, settings, StateSource.Manual); if (text.Length > 0) Glamourer.Messager.NotificationMessage(text, NotificationType.Warning, false); } diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs index 47f7ad5..471a49b 100644 --- a/Glamourer/Interop/ObjectManager.cs +++ b/Glamourer/Interop/ObjectManager.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game.Control; +using Glamourer.Events; using Glamourer.Interop.Structs; using OtterGui.Log; using Penumbra.GameData.Actors; @@ -24,8 +25,11 @@ public class ObjectManager( => LastFrame; private DateTime _identifierUpdate; - public bool IsInGPose { get; private set; } - public ushort World { get; private set; } + + public bool IsInGPose + => clientState.IsGPosing; + + public ushort World { get; private set; } private readonly Dictionary _identifiers = new(200); private readonly Dictionary _allWorldIdentifiers = new(200); @@ -76,8 +80,6 @@ public class ObjectManager( HandleIdentifier(identifier, actor); } - var gPose = GPosePlayer; - IsInGPose = gPose.Utf8Name.Length > 0; return true; } diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index 60f07e4..82a840c 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -12,7 +12,7 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip { private readonly HashSet _collectionTracker = []; - public void HandleStateApplication(ActorState state, MergedDesign design, bool skipAutoRedraw) + public void HandleStateApplication(ActorState state, MergedDesign design, StateSource source, bool skipAutoRedraw, bool respectManual) { if (!config.AlwaysApplyAssociatedMods || (design.AssociatedMods.Count == 0 && !design.ResetTemporarySettings)) return; @@ -36,10 +36,10 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip if (!_collectionTracker.Add(collection)) continue; - var index = ResetOldSettings(collection, actor, design.ResetTemporarySettings); + var index = ResetOldSettings(collection, actor, source, design.ResetTemporarySettings, respectManual); foreach (var (mod, setting) in design.AssociatedMods) { - var message = penumbra.SetMod(mod, setting, collection, index); + var message = penumbra.SetMod(mod, setting, source, collection, index); if (message.Length > 0) Glamourer.Log.Verbose($"[Mod Applier] Error applying mod settings: {message}"); else @@ -50,7 +50,7 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip } public (List Messages, int Applied, Guid Collection, string Name, bool Overridden) ApplyModSettings( - IReadOnlyDictionary settings, Actor actor, bool resetOther) + IReadOnlyDictionary settings, Actor actor, StateSource source, bool resetOther) { var (collection, name, overridden) = overrides.GetCollection(actor); if (collection == Guid.Empty) @@ -59,10 +59,10 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip var messages = new List(); var appliedMods = 0; - var index = ResetOldSettings(collection, actor, resetOther); + var index = ResetOldSettings(collection, actor, source, resetOther, true); foreach (var (mod, setting) in settings) { - var message = penumbra.SetMod(mod, setting, collection, index); + var message = penumbra.SetMod(mod, setting, source, collection, index); if (message.Length > 0) messages.Add($"Error applying mod settings: {message}"); else @@ -73,16 +73,24 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ObjectIndex? ResetOldSettings(Guid collection, Actor actor, bool resetOther) + private ObjectIndex? ResetOldSettings(Guid collection, Actor actor, StateSource source, bool resetOther, bool respectManual) { ObjectIndex? index = actor.Valid ? actor.Index : null; if (!resetOther) return index; if (index == null) - penumbra.RemoveAllTemporarySettings(collection); + { + penumbra.RemoveAllTemporarySettings(collection, source); + if (!respectManual && source.IsFixed()) + penumbra.RemoveAllTemporarySettings(collection, StateSource.Manual); + } else - penumbra.RemoveAllTemporarySettings(index.Value); + { + penumbra.RemoveAllTemporarySettings(index.Value, source); + if (!respectManual && source.IsFixed()) + penumbra.RemoveAllTemporarySettings(index.Value, StateSource.Manual); + } return index; } } diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index e0c445b..d9b4d27 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -1,6 +1,7 @@ using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin; using Glamourer.Events; +using Glamourer.State; using OtterGui.Classes; using Penumbra.Api.Enums; using Penumbra.Api.Helpers; @@ -40,7 +41,10 @@ public class PenumbraService : IDisposable public const int RequiredPenumbraFeatureVersionTemp3 = 6; public const int RequiredPenumbraFeatureVersionTemp4 = 7; - private const int Key = -1610; + private const int KeyFixed = -1610; + private const string NameFixed = "Glamourer (Automation)"; + private const int KeyManual = -6160; + private const string NameManual = "Glamourer (Manually)"; private readonly IDalamudPluginInterface _pluginInterface; private readonly Configuration _config; @@ -160,7 +164,7 @@ public class PenumbraService : IDisposable if (_getCurrentSettingsWithTemp != null) { source = string.Empty; - var (ec, tuple) = _getCurrentSettingsWithTemp!.Invoke(collection, modDirectory, modName, false, false, Key); + var (ec, tuple) = _getCurrentSettingsWithTemp!.Invoke(collection, modDirectory, modName, false, false, KeyFixed); if (ec is not PenumbraApiEc.Success) return ModSettings.Empty; @@ -216,7 +220,7 @@ public class PenumbraService : IDisposable { if (_getAllSettings != null) { - var allSettings = _getAllSettings.Invoke(collection, false, false, Key); + var allSettings = _getAllSettings.Invoke(collection, false, false, KeyFixed); if (allSettings.Item1 is PenumbraApiEc.Success) return mods.Select(m => (new Mod(m.Value, m.Key), allSettings.Item2!.TryGetValue(m.Key, out var s) @@ -276,7 +280,7 @@ public class PenumbraService : IDisposable /// Try to set all mod settings as desired. Only sets when the mod should be enabled. /// If it is disabled, ignore all other settings. /// - public string SetMod(Mod mod, ModSettings settings, Guid? collectionInput = null, ObjectIndex? index = null) + public string SetMod(Mod mod, ModSettings settings, StateSource source, Guid? collectionInput = null, ObjectIndex? index = null) { if (!Available) return "Penumbra is not available."; @@ -286,7 +290,7 @@ public class PenumbraService : IDisposable { var collection = collectionInput ?? _currentCollection!.Invoke(ApiCollectionType.Current)!.Value.Id; if (_config.UseTemporarySettings && _setTemporaryModSettings != null) - SetModTemporary(sb, mod, settings, collection, index); + SetModTemporary(sb, mod, settings, collection, index, source); else SetModPermanent(sb, mod, settings, collection); @@ -298,37 +302,43 @@ public class PenumbraService : IDisposable } } - public void RemoveAllTemporarySettings(Guid collection) - => _removeAllTemporaryModSettings?.Invoke(collection, Key); + public void RemoveAllTemporarySettings(Guid collection, StateSource source) + => _removeAllTemporaryModSettings?.Invoke(collection, source.IsFixed() ? KeyFixed : KeyManual); - public void RemoveAllTemporarySettings(ObjectIndex index) - => _removeAllTemporaryModSettingsPlayer?.Invoke(index.Index, Key); + public void RemoveAllTemporarySettings(ObjectIndex index, StateSource source) + => _removeAllTemporaryModSettingsPlayer?.Invoke(index.Index, source.IsFixed() ? KeyFixed : KeyManual); - public void ClearAllTemporarySettings() + public void ClearAllTemporarySettings(bool fix, bool manual) { if (!Available || _removeAllTemporaryModSettings == null) return; var collections = _collections!.Invoke(); foreach (var collection in collections) - RemoveAllTemporarySettings(collection.Key); + { + if (fix) + RemoveAllTemporarySettings(collection.Key, StateSource.Fixed); + if (manual) + RemoveAllTemporarySettings(collection.Key, StateSource.Manual); + } } public (string ModDirectory, string ModName)[] CheckCurrentChangedItem(string changedItem) => _checkCurrentChangedItems?.Invoke(changedItem) ?? []; - private void SetModTemporary(StringBuilder sb, Mod mod, ModSettings settings, Guid collection, ObjectIndex? index) + private void SetModTemporary(StringBuilder sb, Mod mod, ModSettings settings, Guid collection, ObjectIndex? index, StateSource source) { + var (key, name) = source.IsFixed() ? (KeyFixed, NameFixed) : (KeyManual, NameManual); var ex = settings.Remove ? index.HasValue - ? _removeTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, Key) - : _removeTemporaryModSettings!.Invoke(collection, mod.DirectoryName, Key) + ? _removeTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, key) + : _removeTemporaryModSettings!.Invoke(collection, mod.DirectoryName, key) : index.HasValue ? _setTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, settings.ForceInherit, settings.Enabled, settings.Priority, - settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), "Glamourer", Key) + settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), name, key) : _setTemporaryModSettings!.Invoke(collection, mod.DirectoryName, settings.ForceInherit, settings.Enabled, settings.Priority, - settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), "Glamourer", Key); + settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), name, key); switch (ex) { case PenumbraApiEc.InvalidArgument: @@ -586,7 +596,7 @@ public class PenumbraService : IDisposable public void Dispose() { - ClearAllTemporarySettings(); + ClearAllTemporarySettings(true, true); Unattach(); _tooltipSubscriber.Dispose(); _clickSubscriber.Dispose(); diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index bffc072..4b8ea3d 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -694,7 +694,7 @@ public class CommandService : IDisposable, IApiService if (!applyMods || design is not Design d) return; - var (messages, appliedMods, _, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor, d.ResetTemporarySettings); + var (messages, appliedMods, _, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor, StateSource.Manual, d.ResetTemporarySettings); foreach (var message in messages) Glamourer.Messager.Chat.Print($"Error applying mod settings: {message}"); diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 7eea607..1fa1ffe 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -262,7 +262,7 @@ public class StateEditor( public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings settings) { var state = (ActorState)data; - modApplier.HandleStateApplication(state, mergedDesign, true); + modApplier.HandleStateApplication(state, mergedDesign, settings.Source, true, settings.RespectManual); if (!Editor.ChangeModelId(state, mergedDesign.Design.DesignData.ModelId, mergedDesign.Design.DesignData.Customize, mergedDesign.Design.GetDesignDataRef().GetEquipmentPtr(), settings.Source, out var oldModelId, settings.Key)) return; From 8a7ec45bbf215602b82b94970e9d8c5a80761e0a Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 19 Feb 2025 23:19:21 +0000 Subject: [PATCH 224/401] [CI] Updating repo.json for testing_1.3.6.3 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 992ca6a..31b5654 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.6.0", - "TestingAssemblyVersion": "1.3.6.2", + "TestingAssemblyVersion": "1.3.6.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 0c8110e15e0f2200c9d95a27485f3bf50a3e6df4 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 21 Feb 2025 00:10:30 +0100 Subject: [PATCH 225/401] Highlight existing advanced dyes in state and design. --- Glamourer/Gui/Colors.cs | 2 + Glamourer/Gui/Equipment/BonusDrawData.cs | 6 +- Glamourer/Gui/Equipment/EquipDrawData.cs | 14 +-- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 89 +++++++++++-------- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 35 ++++---- .../Interop/Material/MaterialValueManager.cs | 20 +++++ 6 files changed, 106 insertions(+), 60 deletions(-) diff --git a/Glamourer/Gui/Colors.cs b/Glamourer/Gui/Colors.cs index e19639c..98deace 100644 --- a/Glamourer/Gui/Colors.cs +++ b/Glamourer/Gui/Colors.cs @@ -32,6 +32,7 @@ public enum ColorId ModdedItemMarker, ContainsItemsEnabled, ContainsItemsDisabled, + AdvancedDyeActive, } public static class Colors @@ -70,6 +71,7 @@ public static class Colors ColorId.ModdedItemMarker => (0xFFFF20FF, "Modded Item Marker", "The color of dot in the unlocks overview tab signaling that the item is modded in the currently selected Penumbra collection." ), ColorId.ContainsItemsEnabled => (0xFFA0F0A0, "Enabled Mod Contains Design Items", "The color of enabled mods in the associated mod dropdown menu when they contain items used in this design." ), ColorId.ContainsItemsDisabled => (0x80A0F0A0, "Disabled Mod Contains Design Items", "The color of disabled mods in the associated mod dropdown menu when they contain items used in this design." ), + ColorId.AdvancedDyeActive => (0xFF58DDFF, "Advanced Dyes Active", "The highlight color for the advanced dye button and marker if any advanced dyes are active for this slot." ), _ => (0x00000000, string.Empty, string.Empty ), // @formatter:on }; diff --git a/Glamourer/Gui/Equipment/BonusDrawData.cs b/Glamourer/Gui/Equipment/BonusDrawData.cs index e19287a..c14de2a 100644 --- a/Glamourer/Gui/Equipment/BonusDrawData.cs +++ b/Glamourer/Gui/Equipment/BonusDrawData.cs @@ -1,4 +1,5 @@ using Glamourer.Designs; +using Glamourer.Interop.Material; using Glamourer.State; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -9,10 +10,11 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) { private IDesignEditor _editor = null!; private object _object = null!; - public readonly BonusItemFlag Slot = slot; + public readonly BonusItemFlag Slot = slot; public bool Locked; public bool DisplayApplication; public bool AllowRevert; + public bool HasAdvancedDyes; public readonly bool IsDesign => _object is Design; @@ -42,6 +44,7 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) CurrentApply = design.DoApplyBonusItem(slot), Locked = design.WriteProtected(), DisplayApplication = true, + HasAdvancedDyes = design.GetMaterialDataRef().CheckExistence(MaterialValueIndex.FromSlot(slot)), }; public static BonusDrawData FromState(StateManager manager, ActorState state, BonusItemFlag slot) @@ -53,5 +56,6 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) DisplayApplication = false, GameItem = state.BaseData.BonusItem(slot), AllowRevert = true, + HasAdvancedDyes = state.Materials.CheckExistence(MaterialValueIndex.FromSlot(slot)), }; } diff --git a/Glamourer/Gui/Equipment/EquipDrawData.cs b/Glamourer/Gui/Equipment/EquipDrawData.cs index b72e234..d13b9e4 100644 --- a/Glamourer/Gui/Equipment/EquipDrawData.cs +++ b/Glamourer/Gui/Equipment/EquipDrawData.cs @@ -1,4 +1,5 @@ using Glamourer.Designs; +using Glamourer.Interop.Material; using Glamourer.State; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -9,7 +10,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) { private IDesignEditor _editor = null!; private object _object = null!; - public readonly EquipSlot Slot = slot; + public readonly EquipSlot Slot = slot; public bool Locked; public bool DisplayApplication; public bool AllowRevert; @@ -29,15 +30,13 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) public readonly void SetApplyItem(bool value) { var manager = (DesignManager)_editor; - var design = (Design)_object; - manager.ChangeApplyItem(design, Slot, value); + manager.ChangeApplyItem((Design)_object, Slot, value); } public readonly void SetApplyStain(bool value) { var manager = (DesignManager)_editor; - var design = (Design)_object; - manager.ChangeApplyStains(design, Slot, value); + manager.ChangeApplyStains((Design)_object, Slot, value); } public EquipItem CurrentItem = designData.Item(slot); @@ -46,6 +45,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) public StainIds GameStains = default; public bool CurrentApply; public bool CurrentApplyStain; + public bool HasAdvancedDyes; public readonly Gender CurrentGender = designData.Customize.Gender; public readonly Race CurrentRace = designData.Customize.Race; @@ -58,6 +58,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) CurrentApply = design.DoApplyEquip(slot), CurrentApplyStain = design.DoApplyStain(slot), Locked = design.WriteProtected(), + HasAdvancedDyes = design.GetMaterialDataRef().CheckExistence(MaterialValueIndex.FromSlot(slot)), DisplayApplication = true, }; @@ -70,6 +71,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) DisplayApplication = false, GameItem = state.BaseData.Item(slot), GameStains = state.BaseData.Stain(slot), + HasAdvancedDyes = state.Materials.CheckExistence(MaterialValueIndex.FromSlot(slot)), AllowRevert = true, }; -} \ No newline at end of file +} diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index c8a4b11..2bd84e7 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -3,6 +3,7 @@ using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; using Glamourer.Events; using Glamourer.Gui.Materials; +using Glamourer.Interop.Material; using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; @@ -63,6 +64,7 @@ public class EquipmentDrawer private Vector2 _iconSize; private float _comboLength; + private uint _advancedMaterialColor; public void Prepare() { @@ -74,7 +76,8 @@ public class EquipmentDrawer .Max(i => ImGui.CalcTextSize($"{i.Item2.Name} ({i.Item2.ModelString})").X) / ImGuiHelpers.GlobalScale; - _requiredComboWidth = _requiredComboWidthUnscaled * ImGuiHelpers.GlobalScale; + _requiredComboWidth = _requiredComboWidthUnscaled * ImGuiHelpers.GlobalScale; + _advancedMaterialColor = ColorId.AdvancedDyeActive.Value(); } private bool VerifyRestrictedGear(EquipDrawData data) @@ -91,7 +94,7 @@ public class EquipmentDrawer if (_config.HideApplyCheckmarks) equipDrawData.DisplayApplication = false; - using var id = ImRaii.PushId((int)equipDrawData.Slot); + using var id = ImUtf8.PushId((int)equipDrawData.Slot); var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); @@ -106,7 +109,7 @@ public class EquipmentDrawer if (_config.HideApplyCheckmarks) bonusDrawData.DisplayApplication = false; - using var id = ImRaii.PushId(100 + (int)bonusDrawData.Slot); + using var id = ImUtf8.PushId(100 + (int)bonusDrawData.Slot); var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); @@ -127,7 +130,7 @@ public class EquipmentDrawer offhand.DisplayApplication = false; } - using var id = ImRaii.PushId("Weapons"); + using var id = ImUtf8.PushId("Weapons"u8); var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); @@ -174,7 +177,7 @@ public class EquipmentDrawer change = true; } - ImGuiUtil.HoverTooltip($"{_config.DeleteDesignModifier.ToString()} and Right-click to clear."); + ImUtf8.HoverTooltip($"{_config.DeleteDesignModifier.ToString()} and Right-click to clear."); } return change; @@ -196,14 +199,13 @@ public class EquipmentDrawer } else if (equipDrawData.IsState) { - _advancedDyes.DrawButton(equipDrawData.Slot); + _advancedDyes.DrawButton(equipDrawData.Slot, equipDrawData.HasAdvancedDyes ? _advancedMaterialColor : 0u); } if (VerifyRestrictedGear(equipDrawData)) label += " (Restricted)"; - ImGui.SameLine(); - ImGui.TextUnformatted(label); + DrawEquipLabel(equipDrawData is { IsDesign: true, HasAdvancedDyes: true }, label); } private void DrawBonusItemSmall(in BonusDrawData bonusDrawData) @@ -218,11 +220,10 @@ public class EquipmentDrawer } else if (bonusDrawData.IsState) { - _advancedDyes.DrawButton(bonusDrawData.Slot); + _advancedDyes.DrawButton(bonusDrawData.Slot, bonusDrawData.HasAdvancedDyes ? _advancedMaterialColor : 0u); } - ImGui.SameLine(); - ImGui.TextUnformatted(label); + DrawEquipLabel(bonusDrawData is { IsDesign: true, HasAdvancedDyes: true }, label); } private void DrawWeaponsSmall(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) @@ -239,12 +240,12 @@ public class EquipmentDrawer } else if (mainhand.IsState) { - _advancedDyes.DrawButton(EquipSlot.MainHand); + _advancedDyes.DrawButton(EquipSlot.MainHand, mainhand.HasAdvancedDyes ? _advancedMaterialColor : 0u); } if (allWeapons) mainhandLabel += $" ({mainhand.CurrentItem.Type.ToName()})"; - WeaponHelpMarker(mainhandLabel); + WeaponHelpMarker(mainhand is { IsDesign: true, HasAdvancedDyes: true }, mainhandLabel); if (offhand.CurrentItem.Type is FullEquipType.Unknown) return; @@ -261,10 +262,10 @@ public class EquipmentDrawer } else if (offhand.IsState) { - _advancedDyes.DrawButton(EquipSlot.OffHand); + _advancedDyes.DrawButton(EquipSlot.OffHand, offhand.HasAdvancedDyes ? _advancedMaterialColor : 0u); } - WeaponHelpMarker(offhandLabel); + WeaponHelpMarker(offhand is { IsDesign: true, HasAdvancedDyes: true }, offhandLabel); } #endregion @@ -285,8 +286,8 @@ public class EquipmentDrawer DrawApply(equipDrawData); } - ImGui.SameLine(); - ImGui.TextUnformatted(label); + DrawEquipLabel(equipDrawData is { IsDesign: true, HasAdvancedDyes: true }, label); + DrawStain(equipDrawData, false); if (equipDrawData.DisplayApplication) { @@ -295,13 +296,13 @@ public class EquipmentDrawer } else if (equipDrawData.IsState) { - _advancedDyes.DrawButton(equipDrawData.Slot); + _advancedDyes.DrawButton(equipDrawData.Slot, equipDrawData.HasAdvancedDyes ? _advancedMaterialColor : 0u); } if (VerifyRestrictedGear(equipDrawData)) { ImGui.SameLine(); - ImGui.TextUnformatted("(Restricted)"); + ImUtf8.Text("(Restricted)"u8); } } @@ -319,11 +320,10 @@ public class EquipmentDrawer } else if (bonusDrawData.IsState) { - _advancedDyes.DrawButton(bonusDrawData.Slot); + _advancedDyes.DrawButton(bonusDrawData.Slot, bonusDrawData.HasAdvancedDyes ? _advancedMaterialColor : 0u); } - ImGui.SameLine(); - ImGui.TextUnformatted(label); + DrawEquipLabel(bonusDrawData is { IsDesign: true, HasAdvancedDyes: true }, label); } private void DrawWeaponsNormal(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) @@ -334,7 +334,7 @@ public class EquipmentDrawer mainhand.CurrentItem.DrawIcon(_textures, _iconSize, EquipSlot.MainHand); var left = ImGui.IsItemClicked(ImGuiMouseButton.Left); ImGui.SameLine(); - using (ImRaii.Group()) + using (ImUtf8.Group()) { DrawMainhand(ref mainhand, ref offhand, out var mainhandLabel, allWeapons, false, left); if (mainhand.DisplayApplication) @@ -343,7 +343,8 @@ public class EquipmentDrawer DrawApply(mainhand); } - WeaponHelpMarker(mainhandLabel, allWeapons ? mainhand.CurrentItem.Type.ToName() : null); + WeaponHelpMarker(mainhand is { IsDesign: true, HasAdvancedDyes: true }, mainhandLabel, + allWeapons ? mainhand.CurrentItem.Type.ToName() : null); DrawStain(mainhand, false); if (mainhand.DisplayApplication) @@ -353,7 +354,7 @@ public class EquipmentDrawer } else if (mainhand.IsState) { - _advancedDyes.DrawButton(EquipSlot.MainHand); + _advancedDyes.DrawButton(EquipSlot.MainHand, mainhand.HasAdvancedDyes ? _advancedMaterialColor : 0u); } } @@ -364,7 +365,7 @@ public class EquipmentDrawer var right = ImGui.IsItemClicked(ImGuiMouseButton.Right); left = ImGui.IsItemClicked(ImGuiMouseButton.Left); ImGui.SameLine(); - using (ImRaii.Group()) + using (ImUtf8.Group()) { DrawOffhand(mainhand, offhand, out var offhandLabel, false, right, left); if (offhand.DisplayApplication) @@ -373,7 +374,7 @@ public class EquipmentDrawer DrawApply(offhand); } - WeaponHelpMarker(offhandLabel); + WeaponHelpMarker(offhand is { IsDesign: true, HasAdvancedDyes: true }, offhandLabel); DrawStain(offhand, false); if (offhand.DisplayApplication) @@ -381,9 +382,9 @@ public class EquipmentDrawer ImGui.SameLine(); DrawApplyStain(offhand); } - else if (mainhand.IsState) + else if (offhand.IsState) { - _advancedDyes.DrawButton(EquipSlot.OffHand); + _advancedDyes.DrawButton(EquipSlot.OffHand, offhand.HasAdvancedDyes ? _advancedMaterialColor : 0u); } } } @@ -468,14 +469,16 @@ public class EquipmentDrawer UiHelpers.OpenCombo($"##{combo.Label}"); using var disabled = ImRaii.Disabled(data.Locked); - var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id.BonusItem, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, + var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id.BonusItem, + small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth); if (change) data.SetItem(combo.CurrentSelection); else if (combo.CustomVariant.Id > 0) data.SetItem(_items.Identify(data.Slot, combo.CustomSetId, combo.CustomVariant)); - if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, EquipItem.BonusItemNothing(data.Slot), out var item)) + if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, EquipItem.BonusItemNothing(data.Slot), + out var item)) data.SetItem(item); } @@ -502,7 +505,7 @@ public class EquipmentDrawer (false, true, _) => ("Right-click to clear.\nControl and mouse wheel to scroll.", clearItem, true), (false, false, _) => ("Control and mouse wheel to scroll.", default, false), }; - ImGuiUtil.HoverTooltip(tt); + ImUtf8.HoverTooltip(tt); return clicked && valid; } @@ -544,8 +547,8 @@ public class EquipmentDrawer } } - if (unknown && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) - ImGui.SetTooltip("The weapon type could not be identified, thus changing it to other weapons of that type is not possible."); + if (unknown) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "The weapon type could not be identified, thus changing it to other weapons of that type is not possible."u8); } private void DrawOffhand(in EquipDrawData mainhand, in EquipDrawData offhand, out string label, bool small, bool clear, bool open) @@ -595,14 +598,14 @@ public class EquipmentDrawer #endregion - private static void WeaponHelpMarker(string label, string? type = null) + private void WeaponHelpMarker(bool hasAdvancedDyes, string label, string? type = null) { ImGui.SameLine(); ImGuiComponents.HelpMarker( "Changing weapons to weapons of different types can cause crashes, freezes, soft- and hard locks and cheating, " + "thus it is only allowed to change weapons to other weapons of the same type."); - ImGui.SameLine(); - ImGui.TextUnformatted(label); + DrawEquipLabel(hasAdvancedDyes, label); + if (type == null) return; @@ -610,4 +613,16 @@ public class EquipmentDrawer pos.Y += ImGui.GetFrameHeightWithSpacing(); ImGui.GetWindowDrawList().AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), $"({type})"); } + + [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] + private void DrawEquipLabel(bool hasAdvancedDyes, string label) + { + ImGui.SameLine(); + using (ImRaii.PushColor(ImGuiCol.Text, _advancedMaterialColor, hasAdvancedDyes)) + { + ImUtf8.Text(label); + } + if (hasAdvancedDyes) + ImUtf8.HoverTooltip("This design has advanced dyes setup for this slot."u8); + } } diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index b842d7f..4fa93c1 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -51,28 +51,29 @@ public sealed unsafe class AdvancedDyePopup( return true; } - public void DrawButton(EquipSlot slot) - => DrawButton(MaterialValueIndex.FromSlot(slot)); + public void DrawButton(EquipSlot slot, uint color) + => DrawButton(MaterialValueIndex.FromSlot(slot), color); - public void DrawButton(BonusItemFlag slot) - => DrawButton(MaterialValueIndex.FromSlot(slot)); + public void DrawButton(BonusItemFlag slot, uint color) + => DrawButton(MaterialValueIndex.FromSlot(slot), color); - private void DrawButton(MaterialValueIndex index) + private void DrawButton(MaterialValueIndex index, uint color) { if (!config.UseAdvancedDyes) return; ImGui.SameLine(); - using var id = ImRaii.PushId(index.SlotIndex | ((int)index.DrawObject << 8)); + using var id = ImUtf8.PushId(index.SlotIndex | ((int)index.DrawObject << 8)); var isOpen = index == _drawIndex; - using (ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(ImGuiCol.ButtonActive), isOpen) - .Push(ImGuiCol.Text, ColorId.HeaderButtons.Value(), isOpen) - .Push(ImGuiCol.Border, ColorId.HeaderButtons.Value(), isOpen)) + var (textColor, buttonColor) = isOpen + ? (ColorId.HeaderButtons.Value(), ImGui.GetColorU32(ImGuiCol.ButtonActive)) + : (color, 0u); + + using (ImRaii.PushColor(ImGuiCol.Border, textColor, isOpen)) { using var frame = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * ImGuiHelpers.GlobalScale, isOpen); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Palette.ToIconString(), new Vector2(ImGui.GetFrameHeight()), - string.Empty, false, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Palette, ""u8, default, false, textColor, buttonColor)) { _forceFocus = true; _selectedMaterial = byte.MaxValue; @@ -80,7 +81,7 @@ public sealed unsafe class AdvancedDyePopup( } } - ImGuiUtil.HoverTooltip("Open advanced dyes for this slot."); + ImUtf8.HoverTooltip("Open advanced dyes for this slot."u8); } private (string Path, string GamePath) ResourceName(MaterialValueIndex index) @@ -197,7 +198,7 @@ public sealed unsafe class AdvancedDyePopup( var width = 7 * ImGui.GetFrameHeight() // Buttons + 3 * ImGui.GetStyle().ItemSpacing.X // around text + 7 * ImGui.GetStyle().ItemInnerSpacing.X - + 200 * ImGuiHelpers.GlobalScale // Drags + + 200 * ImGuiHelpers.GlobalScale // Drags + 7 * UiBuilder.MonoFont.GetCharAdvance(' ') * ImGuiHelpers.GlobalScale // Row + 2 * ImGui.GetStyle().WindowPadding.X; var height = 19 * ImGui.GetFrameHeightWithSpacing() + ImGui.GetStyle().WindowPadding.Y + 3 * ImGui.GetStyle().ItemSpacing.Y; @@ -305,8 +306,9 @@ public sealed unsafe class AdvancedDyePopup( { EquipSlot.MainHand => _state.ModelData.Weapon(EquipSlot.MainHand), EquipSlot.OffHand => _state.ModelData.Weapon(EquipSlot.OffHand), - EquipSlot.Unknown => _state.ModelData.BonusItem((index.SlotIndex - 16u).ToBonusSlot()).Armor().ToWeapon(0), // TODO: Handle better - _ => _state.ModelData.Armor(slot).ToWeapon(0), + EquipSlot.Unknown => + _state.ModelData.BonusItem((index.SlotIndex - 16u).ToBonusSlot()).Armor().ToWeapon(0), // TODO: Handle better + _ => _state.ModelData.Armor(slot).ToWeapon(0), }; value = new MaterialValueState(internalRow, internalRow, weapon, StateSource.Manual); } @@ -392,7 +394,8 @@ public sealed unsafe class AdvancedDyePopup( { var tmp = value; var minValue = ImGui.GetIO().KeyCtrl ? 0f : (float)Half.Epsilon; - if (!ImUtf8.DragScalar("##Gloss"u8, ref tmp, "%.1f G"u8, 0.001f, minValue, Math.Max(0.01f, 0.005f * value), ImGuiSliderFlags.AlwaysClamp)) + if (!ImUtf8.DragScalar("##Gloss"u8, ref tmp, "%.1f G"u8, 0.001f, minValue, Math.Max(0.01f, 0.005f * value), + ImGuiSliderFlags.AlwaysClamp)) return false; var tmp2 = Math.Clamp(tmp, minValue, (float)Half.MaxValue); diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index f1ec440..be52b9c 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -6,6 +6,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Structs; +using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; +using static Penumbra.GameData.Files.ShpkFile; namespace Glamourer.Interop.Material; @@ -280,6 +282,24 @@ public readonly struct MaterialValueManager return true; } + public bool CheckExistence(MaterialValueIndex index) + { + if (_values.Count == 0) + return false; + + var key = index.Key; + var idx = Search(key); + if (idx >= 0) + return true; + + idx = ~idx; + if (idx >= _values.Count) + return false; + + var nextItem = MaterialValueIndex.FromKey(_values[idx].Key); + return nextItem.DrawObject == index.DrawObject && nextItem.SlotIndex == index.SlotIndex; + } + public bool RemoveValue(MaterialValueIndex index) => RemoveValue(index.Key); From 425c9471fbaa422d1185dbde7d6eff91133bdb09 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 23 Feb 2025 23:19:24 +0100 Subject: [PATCH 226/401] Highlight materials with advanced dyes even if inactive, allow removing inactive. --- Glamourer/Gui/Equipment/BonusDrawData.cs | 4 +- Glamourer/Gui/Equipment/EquipDrawData.cs | 4 +- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 75 ++++++++++--------- .../Interop/Material/MaterialValueManager.cs | 24 ++++-- 4 files changed, 63 insertions(+), 44 deletions(-) diff --git a/Glamourer/Gui/Equipment/BonusDrawData.cs b/Glamourer/Gui/Equipment/BonusDrawData.cs index c14de2a..067c0c6 100644 --- a/Glamourer/Gui/Equipment/BonusDrawData.cs +++ b/Glamourer/Gui/Equipment/BonusDrawData.cs @@ -44,7 +44,7 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) CurrentApply = design.DoApplyBonusItem(slot), Locked = design.WriteProtected(), DisplayApplication = true, - HasAdvancedDyes = design.GetMaterialDataRef().CheckExistence(MaterialValueIndex.FromSlot(slot)), + HasAdvancedDyes = design.GetMaterialDataRef().CheckExistenceSlot(MaterialValueIndex.FromSlot(slot)), }; public static BonusDrawData FromState(StateManager manager, ActorState state, BonusItemFlag slot) @@ -56,6 +56,6 @@ public struct BonusDrawData(BonusItemFlag slot, in DesignData designData) DisplayApplication = false, GameItem = state.BaseData.BonusItem(slot), AllowRevert = true, - HasAdvancedDyes = state.Materials.CheckExistence(MaterialValueIndex.FromSlot(slot)), + HasAdvancedDyes = state.Materials.CheckExistenceSlot(MaterialValueIndex.FromSlot(slot)), }; } diff --git a/Glamourer/Gui/Equipment/EquipDrawData.cs b/Glamourer/Gui/Equipment/EquipDrawData.cs index d13b9e4..77f4533 100644 --- a/Glamourer/Gui/Equipment/EquipDrawData.cs +++ b/Glamourer/Gui/Equipment/EquipDrawData.cs @@ -58,7 +58,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) CurrentApply = design.DoApplyEquip(slot), CurrentApplyStain = design.DoApplyStain(slot), Locked = design.WriteProtected(), - HasAdvancedDyes = design.GetMaterialDataRef().CheckExistence(MaterialValueIndex.FromSlot(slot)), + HasAdvancedDyes = design.GetMaterialDataRef().CheckExistenceSlot(MaterialValueIndex.FromSlot(slot)), DisplayApplication = true, }; @@ -71,7 +71,7 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) DisplayApplication = false, GameItem = state.BaseData.Item(slot), GameStains = state.BaseData.Stain(slot), - HasAdvancedDyes = state.Materials.CheckExistence(MaterialValueIndex.FromSlot(slot)), + HasAdvancedDyes = state.Materials.CheckExistenceSlot(MaterialValueIndex.FromSlot(slot)), AllowRevert = true, }; } diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 4fa93c1..d6d7420 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -8,7 +8,6 @@ using Glamourer.Designs; using Glamourer.Interop.Material; using Glamourer.State; using ImGuiNET; -using OtterGui; using OtterGui.Raii; using OtterGui.Services; using OtterGui.Text; @@ -102,11 +101,12 @@ public sealed unsafe class AdvancedDyePopup( private void DrawTabBar(ReadOnlySpan> textures, ReadOnlySpan> materials, ref bool firstAvailable) { - using var bar = ImRaii.TabBar("tabs"); + using var bar = ImUtf8.TabBar("tabs"u8); if (!bar) return; - var table = new ColorTable.Table(); + var table = new ColorTable.Table(); + var highLightColor = ColorId.AdvancedDyeActive.Value(); for (byte i = 0; i < MaterialService.MaterialsPerModel; ++i) { var index = _drawIndex!.Value with { MaterialIndex = i }; @@ -125,17 +125,30 @@ public sealed unsafe class AdvancedDyePopup( if (available) firstAvailable = false; - using var tab = _label.TabItem(i, select); + var hasAdvancedDyes = _state.Materials.CheckExistenceMaterial(index); + using var c = ImRaii.PushColor(ImGuiCol.Text, highLightColor, hasAdvancedDyes); + using var tab = _label.TabItem(i, select); + c.Pop(); if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) { using var enabled = ImRaii.Enabled(); var (path, gamePath) = ResourceName(index); + using var tt = ImUtf8.Tooltip(); + if (gamePath.Length == 0 || path.Length == 0) - ImGui.SetTooltip("This material does not exist."); + ImUtf8.Text("This material does not exist."u8); else if (!available) - ImGui.SetTooltip($"This material does not have an associated color set.\n\n{gamePath}\n{path}"); + ImUtf8.Text($"This material does not have an associated color set.\n\n{gamePath}\n{path}"); else - ImGui.SetTooltip($"{gamePath}\n{path}"); + ImUtf8.Text($"{gamePath}\n{path}"); + + if (hasAdvancedDyes && !available) + { + ImUtf8.Text("\nRight-Click to remove ineffective advanced dyes."u8); + if (ImGui.IsMouseClicked(ImGuiMouseButton.Right)) + for (byte row = 0; row < ColorTable.NumRows; ++row) + stateManager.ResetMaterialValue(_state, index with { RowIndex = row }, ApplySettings.Game); + } } if ((tab.Success || select is ImGuiTabItemFlags.SetSelected) && available) @@ -174,7 +187,7 @@ public sealed unsafe class AdvancedDyePopup( DrawTabBar(textures, materials, ref firstAvailable); if (firstAvailable) - ImGui.TextUnformatted("No Editable Materials available."); + ImUtf8.Text("No Editable Materials available."u8); } private void DrawWindow(ReadOnlySpan> textures, ReadOnlySpan> materials) @@ -256,25 +269,23 @@ public sealed unsafe class AdvancedDyePopup( { using var id = ImRaii.PushId(100); var buttonSize = new Vector2(ImGui.GetFrameHeight()); - ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Crosshairs.ToIconString(), buttonSize, "Highlight all affected colors on the character.", - false, true); + ImUtf8.IconButton(FontAwesomeIcon.Crosshairs, "Highlight all affected colors on the character."u8, buttonSize); if (ImGui.IsItemHovered()) preview.OnHover(materialIndex with { RowIndex = byte.MaxValue }, _actor.Index, table); ImGui.SameLine(); ImGui.AlignTextToFramePadding(); using (ImRaii.PushFont(UiBuilder.MonoFont)) { - ImGui.TextUnformatted("All Color Row Pairs (1-16)"); + ImUtf8.Text("All Color Row Pairs (1-16)"u8); } var spacing = ImGui.GetStyle().ItemInnerSpacing.X; ImGui.SameLine(ImGui.GetWindowSize().X - 3 * buttonSize.X - 2 * spacing - ImGui.GetStyle().WindowPadding.X); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), buttonSize, "Export this table to your clipboard.", false, - true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this table to your clipboard."u8, buttonSize)) ColorRowClipboard.Table = table; ImGui.SameLine(0, spacing); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), buttonSize, - "Import an exported table from your clipboard onto this table.", !ColorRowClipboard.IsTableSet, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported table from your clipboard onto this table."u8, buttonSize, + !ColorRowClipboard.IsTableSet)) for (var idx = 0; idx < ColorTable.NumRows; ++idx) { var row = ColorRowClipboard.Table[idx]; @@ -288,15 +299,14 @@ public sealed unsafe class AdvancedDyePopup( } ImGui.SameLine(0, spacing); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.UndoAlt.ToIconString(), buttonSize, "Reset this table to game state.", !_anyChanged, - true)) + if (ImUtf8.IconButton(FontAwesomeIcon.UndoAlt, "Reset this table to game state."u8, buttonSize, !_anyChanged)) for (byte i = 0; i < ColorTable.NumRows; ++i) stateManager.ResetMaterialValue(_state, materialIndex with { RowIndex = i }, ApplySettings.Game); } private void DrawRow(ref ColorTableRow row, MaterialValueIndex index, in ColorTable.Table table) { - using var id = ImRaii.PushId(index.RowIndex); + using var id = ImUtf8.PushId(index.RowIndex); var changed = _state.Materials.TryGetValue(index, out var value); if (!changed) { @@ -319,8 +329,7 @@ public sealed unsafe class AdvancedDyePopup( } var buttonSize = new Vector2(ImGui.GetFrameHeight()); - ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Crosshairs.ToIconString(), buttonSize, "Highlight the affected colors on the character.", - false, true); + ImUtf8.IconButton(FontAwesomeIcon.Crosshairs, "Highlight the affected colors on the character."u8, buttonSize); if (ImGui.IsItemHovered()) preview.OnHover(index, _actor.Index, table); @@ -330,28 +339,28 @@ public sealed unsafe class AdvancedDyePopup( { var rowIndex = index.RowIndex / 2 + 1; var rowSuffix = (index.RowIndex & 1) == 0 ? 'A' : 'B'; - ImGui.TextUnformatted($"Row {rowIndex,2}{rowSuffix}"); + ImUtf8.Text($"Row {rowIndex,2}{rowSuffix}"); } ImGui.SameLine(0, ImGui.GetStyle().ItemSpacing.X * 2); - var applied = ImGuiUtil.ColorPicker("##diffuse", "Change the diffuse value for this row.", value.Model.Diffuse, - v => value.Model.Diffuse = v, "D"); + var applied = ImUtf8.ColorPicker("##diffuse"u8, "Change the diffuse value for this row."u8, value.Model.Diffuse, + v => value.Model.Diffuse = v, "D"u8); var spacing = ImGui.GetStyle().ItemInnerSpacing; ImGui.SameLine(0, spacing.X); - applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", value.Model.Specular, - v => value.Model.Specular = v, "S"); + applied |= ImUtf8.ColorPicker("##specular"u8, "Change the specular value for this row."u8, value.Model.Specular, + v => value.Model.Specular = v, "S"u8); ImGui.SameLine(0, spacing.X); - applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", value.Model.Emissive, - v => value.Model.Emissive = v, "E"); + applied |= ImUtf8.ColorPicker("##emissive"u8, "Change the emissive value for this row."u8, value.Model.Emissive, + v => value.Model.Emissive = v, "E"u8); ImGui.SameLine(0, spacing.X); if (_mode is not ColorRow.Mode.Dawntrail) { ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); applied |= DragGloss(ref value.Model.GlossStrength); - ImGuiUtil.HoverTooltip("Change the gloss strength for this row."); + ImUtf8.HoverTooltip("Change the gloss strength for this row."u8); } else { @@ -363,7 +372,7 @@ public sealed unsafe class AdvancedDyePopup( { ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); applied |= DragSpecularStrength(ref value.Model.SpecularStrength); - ImGuiUtil.HoverTooltip("Change the specular strength for this row."); + ImUtf8.HoverTooltip("Change the specular strength for this row."u8); } else { @@ -371,19 +380,17 @@ public sealed unsafe class AdvancedDyePopup( } ImGui.SameLine(0, spacing.X); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), buttonSize, "Export this row to your clipboard.", false, - true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this row to your clipboard."u8, buttonSize)) ColorRowClipboard.Row = value.Model; ImGui.SameLine(0, spacing.X); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), buttonSize, - "Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8, buttonSize, !ColorRowClipboard.IsSet)) { value.Model = ColorRowClipboard.Row; applied = true; } ImGui.SameLine(0, spacing.X); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.UndoAlt.ToIconString(), buttonSize, "Reset this row to game state.", !changed, true)) + if (ImUtf8.IconButton(FontAwesomeIcon.UndoAlt, "Reset this row to game state."u8, buttonSize, !changed)) stateManager.ResetMaterialValue(_state, index, ApplySettings.Game); if (applied) diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index be52b9c..520dacf 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -282,22 +282,34 @@ public readonly struct MaterialValueManager return true; } - public bool CheckExistence(MaterialValueIndex index) + public bool CheckExistenceSlot(MaterialValueIndex index) + { + var key = CheckExistence(index); + return key.Valid && key.DrawObject == index.DrawObject && key.SlotIndex == index.SlotIndex; + } + + public bool CheckExistenceMaterial(MaterialValueIndex index) + { + var key = CheckExistence(index); + return key.Valid && key.DrawObject == index.DrawObject && key.SlotIndex == index.SlotIndex && key.MaterialIndex == index.MaterialIndex; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private MaterialValueIndex CheckExistence(MaterialValueIndex index) { if (_values.Count == 0) - return false; + return MaterialValueIndex.Invalid; var key = index.Key; var idx = Search(key); if (idx >= 0) - return true; + return index; idx = ~idx; if (idx >= _values.Count) - return false; + return MaterialValueIndex.Invalid; - var nextItem = MaterialValueIndex.FromKey(_values[idx].Key); - return nextItem.DrawObject == index.DrawObject && nextItem.SlotIndex == index.SlotIndex; + return MaterialValueIndex.FromKey(_values[idx].Key); } public bool RemoveValue(MaterialValueIndex index) From 528aae7eeeeb49639e0470bd869ce1de205fcf73 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 2 Mar 2025 13:24:51 +0100 Subject: [PATCH 227/401] Remove PalettePlusChecker and config options to disable Advanced Customization and Advanced Dyes. --- Glamourer/Api/StateApi.cs | 2 +- Glamourer/Configuration.cs | 2 - Glamourer/Designs/ApplicationRules.cs | 3 - Glamourer/Glamourer.cs | 2 - Glamourer/Gui/DesignQuickBar.cs | 6 +- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 6 -- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 3 - Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 64 +++++++------------ Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 53 +++++++-------- Glamourer/Interop/Material/MaterialManager.cs | 3 - .../Interop/PalettePlus/PalettePlusChecker.cs | 49 -------------- Glamourer/State/StateApplier.cs | 26 +++----- Glamourer/State/StateListener.cs | 17 ++--- Glamourer/State/StateManager.cs | 2 +- 14 files changed, 66 insertions(+), 172 deletions(-) delete mode 100644 Glamourer/Interop/PalettePlus/PalettePlusChecker.cs diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index b2fdc9b..c27abb7 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -314,7 +314,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable if (!state.CanUnlock(key)) return (GlamourerApiEc.InvalidKey, null); - return (GlamourerApiEc.Success, _converter.ShareJObject(state, ApplicationRules.AllWithConfig(_config))); + return (GlamourerApiEc.Success, _converter.ShareJObject(state, ApplicationRules.All)); } private (GlamourerApiEc, string?) ConvertBase64(ActorState? state, uint key) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 4b59191..019bb2b 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -55,8 +55,6 @@ public class Configuration : IPluginConfiguration, ISavable public bool ShowQuickBarInTabs { get; set; } = true; public bool OpenWindowAtStart { get; set; } = false; public bool ShowWindowWhenUiHidden { get; set; } = false; - public bool UseAdvancedParameters { get; set; } = true; - public bool UseAdvancedDyes { get; set; } = true; public bool KeepAdvancedDyesAttached { get; set; } = true; public bool ShowPalettePlusImport { get; set; } = true; public bool UseFloatForColors { get; set; } = true; diff --git a/Glamourer/Designs/ApplicationRules.cs b/Glamourer/Designs/ApplicationRules.cs index 703a3ae..0df4feb 100644 --- a/Glamourer/Designs/ApplicationRules.cs +++ b/Glamourer/Designs/ApplicationRules.cs @@ -19,9 +19,6 @@ public readonly struct ApplicationRules(ApplicationCollection application, bool public static ApplicationRules AllButParameters(ActorState state) => new(ApplicationCollection.All with { Parameters = ComputeParameters(state.ModelData, state.BaseData, All.Parameters) }, true); - public static ApplicationRules AllWithConfig(Configuration config) - => new(ApplicationCollection.All with { Parameters = config.UseAdvancedParameters ? All.Parameters : 0 }, config.UseAdvancedDyes); - public static ApplicationRules NpcFromModifiers(bool ctrl, bool shift) { var equip = ctrl || !shift ? EquipFlagExtensions.All : 0; diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index cf0b278..5d38e3a 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -69,8 +69,6 @@ public class Glamourer : IDalamudPlugin sb.Append($"> **`Auto-Reload Gear: `** {config.AutoRedrawEquipOnChanges}\n"); sb.Append($"> **`Revert on Zone Change:`** {config.RevertManualChangesOnZoneChange}\n"); sb.Append($"> **`Festival Easter-Eggs: `** {config.DisableFestivals}\n"); - sb.Append($"> **`Advanced Customize: `** {config.UseAdvancedParameters}\n"); - sb.Append($"> **`Advanced Dye: `** {config.UseAdvancedDyes}\n"); sb.Append($"> **`Apply Entire Weapon: `** {config.ChangeEntireItem}\n"); sb.Append($"> **`Apply Associated Mods:`** {config.AlwaysApplyAssociatedMods}\n"); sb.Append($"> **`Show QDB: `** {config.Ephemeral.ShowDesignQuickBar}\n"); diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index b125b37..cabd888 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -11,7 +11,6 @@ using Glamourer.Interop.Penumbra; using Glamourer.Interop.Structs; using Glamourer.State; using ImGuiNET; -using OtterGui; using OtterGui.Classes; using OtterGui.Text; using Penumbra.GameData.Actors; @@ -304,9 +303,6 @@ public sealed class DesignQuickBar : Window, IDisposable private void DrawRevertAdvancedCustomization(Vector2 buttonSize) { - if (!_config.UseAdvancedParameters) - return; - if (!_config.QdbButtons.HasFlag(QdbButtons.RevertAdvanced)) return; @@ -475,7 +471,7 @@ public sealed class DesignQuickBar : Window, IDisposable ++_numButtons; } - if ((_config.UseAdvancedParameters || _config.UseAdvancedDyes) && _config.QdbButtons.HasFlag(QdbButtons.RevertAdvanced)) + if (_config.QdbButtons.HasFlag(QdbButtons.RevertAdvanced)) ++_numButtons; if (_config.QdbButtons.HasFlag(QdbButtons.RevertCustomize)) ++_numButtons; diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index d6d7420..6d0bb70 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -38,9 +38,6 @@ public sealed unsafe class AdvancedDyePopup( private bool ShouldBeDrawn() { - if (!config.UseAdvancedDyes) - return false; - if (_drawIndex is not { Valid: true }) return false; @@ -58,9 +55,6 @@ public sealed unsafe class AdvancedDyePopup( private void DrawButton(MaterialValueIndex index, uint color) { - if (!config.UseAdvancedDyes) - return; - ImGui.SameLine(); using var id = ImUtf8.PushId(index.SlotIndex | ((int)index.DrawObject << 8)); var isOpen = index == _drawIndex; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 9c8f3cf..e56266d 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -239,9 +239,6 @@ public class ActorPanel private void DrawParameterHeader() { - if (!_config.UseAdvancedParameters) - return; - using var h = ImUtf8.CollapsingHeaderId("Advanced Customizations"u8); if (!h) return; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 748afea..554e671 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -180,10 +180,7 @@ public class DesignPanel private void DrawCustomizeParameters() { - if (!_config.UseAdvancedParameters) - return; - - using var h = ImRaii.CollapsingHeader("Advanced Customizations"); + using var h = ImUtf8.CollapsingHeaderId("Advanced Customizations"u8); if (!h) return; @@ -192,10 +189,7 @@ public class DesignPanel private void DrawMaterialValues() { - if (!_config.UseAdvancedDyes) - return; - - using var h = ImRaii.CollapsingHeader("Advanced Dyes"); + using var h = ImUtf8.CollapsingHeaderId("Advanced Dyes"u8); if (!h) return; @@ -204,7 +198,7 @@ public class DesignPanel private void DrawCustomizeApplication() { - using var id = ImRaii.PushId("Customizations"); + using var id = ImUtf8.PushId("Customizations"u8); var set = _selector.Selected!.CustomizeSet; var available = set.SettingAvailable | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.BodyType; var flags = _selector.Selected!.ApplyCustomizeExcludingBodyType == 0 ? 0 : @@ -219,55 +213,52 @@ public class DesignPanel } var applyClan = _selector.Selected!.DoApplyCustomize(CustomizeIndex.Clan); - if (ImGui.Checkbox($"Apply {CustomizeIndex.Clan.ToDefaultName()}", ref applyClan)) + if (ImUtf8.Checkbox($"Apply {CustomizeIndex.Clan.ToDefaultName()}", ref applyClan)) _manager.ChangeApplyCustomize(_selector.Selected!, CustomizeIndex.Clan, applyClan); var applyGender = _selector.Selected!.DoApplyCustomize(CustomizeIndex.Gender); - if (ImGui.Checkbox($"Apply {CustomizeIndex.Gender.ToDefaultName()}", ref applyGender)) + if (ImUtf8.Checkbox($"Apply {CustomizeIndex.Gender.ToDefaultName()}", ref applyGender)) _manager.ChangeApplyCustomize(_selector.Selected!, CustomizeIndex.Gender, applyGender); foreach (var index in CustomizationExtensions.All.Where(set.IsAvailable)) { var apply = _selector.Selected!.DoApplyCustomize(index); - if (ImGui.Checkbox($"Apply {set.Option(index)}", ref apply)) + if (ImUtf8.Checkbox($"Apply {set.Option(index)}", ref apply)) _manager.ChangeApplyCustomize(_selector.Selected!, index, apply); } } private void DrawCrestApplication() { - using var id = ImRaii.PushId("Crests"); + using var id = ImUtf8.PushId("Crests"u8); var flags = (uint)_selector.Selected!.Application.Crest; var bigChange = ImGui.CheckboxFlags("Apply All Crests", ref flags, (uint)CrestExtensions.AllRelevant); foreach (var flag in CrestExtensions.AllRelevantSet) { var apply = bigChange ? ((CrestFlag)flags & flag) == flag : _selector.Selected!.DoApplyCrest(flag); - if (ImGui.Checkbox($"Apply {flag.ToLabel()} Crest", ref apply) || bigChange) + if (ImUtf8.Checkbox($"Apply {flag.ToLabel()} Crest", ref apply) || bigChange) _manager.ChangeApplyCrest(_selector.Selected!, flag, apply); } } private void DrawApplicationRules() { - using var h = ImRaii.CollapsingHeader("Application Rules"); + using var h = ImUtf8.CollapsingHeaderId("Application Rules"u8); if (!h) return; using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected()); - using (var _ = ImRaii.Group()) + using (var _ = ImUtf8.Group()) { DrawCustomizeApplication(); ImUtf8.IconDummy(); DrawCrestApplication(); ImUtf8.IconDummy(); - if (_config.UseAdvancedParameters) - { - DrawMetaApplication(); - ImUtf8.IconDummy(); - DrawBonusSlotApplication(); - } + DrawMetaApplication(); + ImUtf8.IconDummy(); + DrawBonusSlotApplication(); } ImGui.SameLine(ImGui.GetContentRegionAvail().X / 2); @@ -276,20 +267,20 @@ public class DesignPanel void ApplyEquip(string label, EquipFlag allFlags, bool stain, IEnumerable slots) { var flags = (uint)(allFlags & _selector.Selected!.Application.Equip); - using var id = ImRaii.PushId(label); + using var id = ImUtf8.PushId(label); var bigChange = ImGui.CheckboxFlags($"Apply All {label}", ref flags, (uint)allFlags); if (stain) foreach (var slot in slots) { var apply = bigChange ? ((EquipFlag)flags).HasFlag(slot.ToStainFlag()) : _selector.Selected!.DoApplyStain(slot); - if (ImGui.Checkbox($"Apply {slot.ToName()} Dye", ref apply) || bigChange) + if (ImUtf8.Checkbox($"Apply {slot.ToName()} Dye", ref apply) || bigChange) _manager.ChangeApplyStains(_selector.Selected!, slot, apply); } else foreach (var slot in slots) { var apply = bigChange ? ((EquipFlag)flags).HasFlag(slot.ToFlag()) : _selector.Selected!.DoApplyEquip(slot); - if (ImGui.Checkbox($"Apply {slot.ToName()}", ref apply) || bigChange) + if (ImUtf8.Checkbox($"Apply {slot.ToName()}", ref apply) || bigChange) _manager.ChangeApplyItem(_selector.Selected!, slot, apply); } } @@ -311,16 +302,7 @@ public class DesignPanel EquipSlotExtensions.FullSlots); ImUtf8.IconDummy(); - if (_config.UseAdvancedParameters) - { - DrawParameterApplication(); - } - else - { - DrawMetaApplication(); - ImUtf8.IconDummy(); - DrawBonusSlotApplication(); - } + DrawParameterApplication(); } } @@ -334,7 +316,7 @@ public class DesignPanel private void DrawMetaApplication() { - using var id = ImRaii.PushId("Meta"); + using var id = ImUtf8.PushId("Meta"); const uint all = (uint)MetaExtensions.All; var flags = (uint)_selector.Selected!.Application.Meta; var bigChange = ImGui.CheckboxFlags("Apply All Meta Changes", ref flags, all); @@ -342,7 +324,7 @@ public class DesignPanel foreach (var (index, label) in MetaExtensions.AllRelevant.Zip(MetaLabels)) { var apply = bigChange ? ((MetaFlag)flags).HasFlag(index.ToFlag()) : _selector.Selected!.DoApplyMeta(index); - if (ImGui.Checkbox(label, ref apply) || bigChange) + if (ImUtf8.Checkbox(label, ref apply) || bigChange) _manager.ChangeApplyMeta(_selector.Selected!, index, apply); } } @@ -368,20 +350,20 @@ public class DesignPanel private void DrawParameterApplication() { - using var id = ImRaii.PushId("Parameter"); + using var id = ImUtf8.PushId("Parameter"); var flags = (uint)_selector.Selected!.Application.Parameters; var bigChange = ImGui.CheckboxFlags("Apply All Customize Parameters", ref flags, (uint)CustomizeParameterExtensions.All); foreach (var flag in CustomizeParameterExtensions.AllFlags) { var apply = bigChange ? ((CustomizeParameterFlag)flags).HasFlag(flag) : _selector.Selected!.DoApplyParameter(flag); - if (ImGui.Checkbox($"Apply {flag.ToName()}", ref apply) || bigChange) + if (ImUtf8.Checkbox($"Apply {flag.ToName()}", ref apply) || bigChange) _manager.ChangeApplyParameter(_selector.Selected!, flag, apply); } } public void Draw() { - using var group = ImRaii.Group(); + using var group = ImUtf8.Group(); if (_selector.SelectedPaths.Count > 1) { _multiDesignPanel.Draw(); @@ -419,10 +401,12 @@ public class DesignPanel using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); if (!table || _selector.Selected == null) return; + ImGui.TableSetupScrollFreeze(0, 1); ImGui.TableNextColumn(); if (_selector.Selected == null) return; + ImGui.Dummy(Vector2.Zero); DrawButtonRow(); ImGui.TableNextColumn(); diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 4ee261b..fd4f3f5 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -24,7 +24,6 @@ public class SettingsTab( IKeyState keys, DesignColorUi designColorUi, PaletteImport paletteImport, - PalettePlusChecker paletteChecker, CollectionOverrideDrawer overrides, CodeDrawer codeDrawer, Glamourer glamourer, @@ -93,20 +92,15 @@ public class SettingsTab( Checkbox("Revert Manual Changes on Zone Change"u8, "Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone."u8, config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v); - Checkbox("Enable Advanced Customization Options"u8, - "Enable the display and editing of advanced customization options like arbitrary colors."u8, - config.UseAdvancedParameters, paletteChecker.SetAdvancedParameters); PaletteImportButton(); - Checkbox("Enable Advanced Dye Options"u8, - "Enable the display and editing of advanced dyes (color sets) for all equipment"u8, - config.UseAdvancedDyes, v => config.UseAdvancedDyes = v); Checkbox("Always Apply Associated Mods"u8, "Whenever a design is applied to a character (including via automation), Glamourer will try to apply its associated mod settings to the collection currently associated with that character, if it is available.\n\n"u8 + "Glamourer will NOT revert these applied settings automatically. This may mess up your collection and configuration.\n\n"u8 + "If you enable this setting, you are aware that any resulting misconfiguration is your own fault."u8, config.AlwaysApplyAssociatedMods, v => config.AlwaysApplyAssociatedMods = v); Checkbox("Use Temporary Mod Settings"u8, - "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down."u8, config.UseTemporarySettings, + "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down."u8, + config.UseTemporarySettings, v => config.UseTemporarySettings = v); ImGui.NewLine(); } @@ -152,7 +146,7 @@ public class SettingsTab( ImGui.Dummy(Vector2.Zero); Checkbox("Enable Game Context Menus"u8, "Whether to show a Try On via Glamourer button on context menus for equippable items."u8, - config.EnableGameContextMenu, v => + config.EnableGameContextMenu, v => { config.EnableGameContextMenu = v; if (v) @@ -161,12 +155,13 @@ public class SettingsTab( contextMenuService.Disable(); }); Checkbox("Show Window when UI is Hidden"u8, "Whether to show Glamourer windows even when the games UI is hidden."u8, - config.ShowWindowWhenUiHidden, v => + config.ShowWindowWhenUiHidden, v => { config.ShowWindowWhenUiHidden = v; uiBuilder.DisableUserUiHide = v; }); - Checkbox("Hide Window in Cutscenes"u8, "Whether the main Glamourer window should automatically be hidden when entering cutscenes or not."u8, + Checkbox("Hide Window in Cutscenes"u8, + "Whether the main Glamourer window should automatically be hidden when entering cutscenes or not."u8, config.HideWindowInCutscene, v => { @@ -177,13 +172,13 @@ public class SettingsTab( config.Ephemeral.LockMainWindow, v => config.Ephemeral.LockMainWindow = v); Checkbox("Open Main Window at Game Start"u8, "Whether the main Glamourer window should be open or closed after launching the game."u8, - config.OpenWindowAtStart, v => config.OpenWindowAtStart = v); + config.OpenWindowAtStart, v => config.OpenWindowAtStart = v); ImGui.Dummy(Vector2.Zero); ImGui.Separator(); ImGui.Dummy(Vector2.Zero); Checkbox("Smaller Equip Display"u8, "Use single-line display without icons and small dye buttons instead of double-line display."u8, - config.SmallEquip, v => config.SmallEquip = v); + config.SmallEquip, v => config.SmallEquip = v); DrawHeightUnitSettings(); Checkbox("Show Application Checkboxes"u8, "Show the application checkboxes in the Customization and Equipment panels of the design tab, instead of only showing them under Application Rules."u8, @@ -211,23 +206,22 @@ public class SettingsTab( Checkbox("Show Unobtained Item Warnings"u8, "Show information whether you have unlocked all items and customizations in your automated design or not."u8, config.ShowUnlockedItemWarnings, v => config.ShowUnlockedItemWarnings = v); - if (config.UseAdvancedParameters) + Checkbox("Show Color Display Config"u8, "Show the Color Display configuration options in the Advanced Customization panels."u8, + config.ShowColorConfig, v => config.ShowColorConfig = v); + Checkbox("Show Palette+ Import Button"u8, + "Show the import button that allows you to import Palette+ palettes onto a design in the Advanced Customization options section for designs."u8, + config.ShowPalettePlusImport, v => config.ShowPalettePlusImport = v); + using (ImRaii.PushId(1)) { - Checkbox("Show Color Display Config"u8, "Show the Color Display configuration options in the Advanced Customization panels."u8, - config.ShowColorConfig, v => config.ShowColorConfig = v); - Checkbox("Show Palette+ Import Button"u8, - "Show the import button that allows you to import Palette+ palettes onto a design in the Advanced Customization options section for designs."u8, - config.ShowPalettePlusImport, v => config.ShowPalettePlusImport = v); - using var id = ImRaii.PushId(1); PaletteImportButton(); } - if (config.UseAdvancedDyes) - Checkbox("Keep Advanced Dye Window Attached"u8, - "Keeps the advanced dye window expansion attached to the main window, or makes it freely movable."u8, - config.KeepAdvancedDyesAttached, v => config.KeepAdvancedDyesAttached = v); + Checkbox("Keep Advanced Dye Window Attached"u8, + "Keeps the advanced dye window expansion attached to the main window, or makes it freely movable."u8, + config.KeepAdvancedDyesAttached, v => config.KeepAdvancedDyesAttached = v); - Checkbox("Debug Mode"u8, "Show the debug tab. Only useful for debugging or advanced use. Not recommended in general."u8, config.DebugMode, + Checkbox("Debug Mode"u8, "Show the debug tab. Only useful for debugging or advanced use. Not recommended in general."u8, + config.DebugMode, v => config.DebugMode = v); ImGui.NewLine(); } @@ -235,8 +229,7 @@ public class SettingsTab( private void DrawQuickDesignBoxes() { var showAuto = config.EnableAutoDesigns; - var showAdvanced = config.UseAdvancedParameters || config.UseAdvancedDyes; - var numColumns = 8 - (showAuto ? 0 : 2) - (showAdvanced ? 0 : 1) - (config.UseTemporarySettings ? 0 : 1); + var numColumns = 8 - (showAuto ? 0 : 2) - (config.UseTemporarySettings ? 0 : 1); ImGui.NewLine(); ImUtf8.Text("Show the Following Buttons in the Quick Design Bar:"u8); ImGui.Dummy(Vector2.Zero); @@ -253,11 +246,11 @@ public class SettingsTab( ("Reapply Auto", showAuto, QdbButtons.ReapplyAutomation), ("Revert Equip", true, QdbButtons.RevertEquip), ("Revert Customize", true, QdbButtons.RevertCustomize), - ("Revert Advanced", showAdvanced, QdbButtons.RevertAdvanced), + ("Revert Advanced", true, QdbButtons.RevertAdvanced), ("Reset Settings", config.UseTemporarySettings, QdbButtons.ResetSettings), ]; - for(var i = 0; i < columns.Length; ++i) + for (var i = 0; i < columns.Length; ++i) { if (!columns[i].Item2) continue; @@ -291,7 +284,7 @@ public class SettingsTab( private void PaletteImportButton() { - if (!config.UseAdvancedParameters || !config.ShowPalettePlusImport) + if (!config.ShowPalettePlusImport) return; ImGui.SameLine(); diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index f3c1875..81373c5 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -41,9 +41,6 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable private void OnPrepareColorSet(CharacterBase* characterBase, MaterialResourceHandle* material, ref StainIds stain, ref nint ret) { - if (!_config.UseAdvancedDyes) - return; - var actor = _penumbra.GameObjectFromDrawObject(characterBase); var validType = FindType(characterBase, actor, out var type); var (slotId, materialId) = FindMaterial(characterBase, material); diff --git a/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs b/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs deleted file mode 100644 index a5a5ed9..0000000 --- a/Glamourer/Interop/PalettePlus/PalettePlusChecker.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Dalamud.Interface.ImGuiNotification; -using Dalamud.Plugin; -using OtterGui.Services; -using Notification = OtterGui.Classes.Notification; - -namespace Glamourer.Interop.PalettePlus; - -public sealed class PalettePlusChecker : IRequiredService, IDisposable -{ - private readonly Timer _paletteTimer; - private readonly Configuration _config; - private readonly IDalamudPluginInterface _pluginInterface; - - public PalettePlusChecker(Configuration config, IDalamudPluginInterface pluginInterface) - { - _config = config; - _pluginInterface = pluginInterface; - _paletteTimer = new Timer(_ => PalettePlusCheck(), null, TimeSpan.FromSeconds(30), Timeout.InfiniteTimeSpan); - } - - public void Dispose() - => _paletteTimer.Dispose(); - - public void SetAdvancedParameters(bool value) - { - _config.UseAdvancedParameters = value; - PalettePlusCheck(); - } - - private void PalettePlusCheck() - { - if (!_config.UseAdvancedParameters) - return; - - try - { - var subscriber = _pluginInterface.GetIpcSubscriber("PalettePlus.ApiVersion"); - subscriber.InvokeFunc(); - Glamourer.Messager.AddMessage(new Notification( - "You currently have Palette+ installed. This conflicts with Glamourers advanced options and will cause invalid state.\n\n" - + "Please uninstall Palette+ and restart your game. Palette+ is deprecated and no longer supported by Mare Synchronos.", - NotificationType.Warning, 10000)); - } - catch - { - // ignored - } - } -} diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 2e086d6..be85580 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -25,7 +25,6 @@ public class StateApplier( MetaService _metaService, ObjectManager _objects, CrestService _crests, - Configuration _config, DirectXService _directX) { /// Simply force a redraw regardless of conditions. @@ -291,30 +290,26 @@ public class StateApplier( } /// Change the customize parameters on models. Can change multiple at once. - public void ChangeParameters(ActorData data, CustomizeParameterFlag flags, in CustomizeParameterData values, bool force) + public void ChangeParameters(ActorData data, CustomizeParameterFlag flags, in CustomizeParameterData values) { - if (!force && !_config.UseAdvancedParameters || flags == 0) + if (flags == 0) return; foreach (var actor in data.Objects.Where(a => a is { IsCharacter: true, Model.IsHuman: true })) actor.Model.ApplyParameterData(flags, values); } - /// + /// public ActorData ChangeParameters(ActorState state, CustomizeParameterFlag flags, bool apply) { var data = GetData(state); if (apply) - ChangeParameters(data, flags, state.ModelData.Parameters, state.IsLocked); + ChangeParameters(data, flags, state.ModelData.Parameters); return data; } - public unsafe void ChangeMaterialValue(ActorState state, ActorData data, MaterialValueIndex changedIndex, ColorRow? changedValue, - bool force) + public unsafe void ChangeMaterialValue(ActorState state, ActorData data, MaterialValueIndex changedIndex, ColorRow? changedValue) { - if (!force && !_config.UseAdvancedDyes) - return; - foreach (var actor in data.Objects.Where(a => a is { IsCharacter: true, Model.IsHuman: true })) { if (!changedIndex.TryGetTexture(actor, out var texture)) @@ -341,16 +336,13 @@ public class StateApplier( { var data = GetData(state); if (apply) - ChangeMaterialValue(state, data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null, state.IsLocked); + ChangeMaterialValue(state, data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null); return data; } - public unsafe void ChangeMaterialValues(ActorData data, in StateMaterialManager materials, bool force) + public unsafe void ChangeMaterialValues(ActorData data, in StateMaterialManager materials) { - if (!force && !_config.UseAdvancedDyes) - return; - var groupedMaterialValues = materials.Values.Select(p => (MaterialValueIndex.FromKey(p.Key), p.Value)) .GroupBy(p => (p.Item1.DrawObject, p.Item1.SlotIndex, p.Item1.MaterialIndex)); @@ -410,8 +402,8 @@ public class StateApplier( ChangeMetaState(actors, MetaIndex.WeaponState, state.ModelData.IsWeaponVisible()); ChangeMetaState(actors, MetaIndex.VisorState, state.ModelData.IsVisorToggled()); ChangeCrests(actors, state.ModelData.CrestVisibility); - ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters, state.IsLocked); - ChangeMaterialValues(actors, state.Materials, state.IsLocked); + ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters); + ChangeMaterialValues(actors, state.Materials); } } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 3a6d6ef..88ec0b5 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -41,7 +41,7 @@ public class StateListener : IDisposable private readonly HeadGearVisibilityChanged _headGearVisibility; private readonly VisorStateChanged _visorState; private readonly WeaponVisibilityChanged _weaponVisibility; - private readonly StateFinalized _stateFinalized; + private readonly StateFinalized _stateFinalized; private readonly AutoDesignApplier _autoDesignApplier; private readonly FunModule _funModule; private readonly HumanModelList _humans; @@ -88,7 +88,7 @@ public class StateListener : IDisposable _condition = condition; _crestService = crestService; _bonusSlotUpdating = bonusSlotUpdating; - _stateFinalized = stateFinalized; + _stateFinalized = stateFinalized; Subscribe(); } @@ -225,7 +225,7 @@ public class StateListener : IDisposable // then we do not want to use our restricted gear protection // since we assume the player has that gear modded to availability. var locked = false; - if (actor.Identifier(_actors, out var identifier) + if (actor.Identifier(_actors, out var identifier) && _manager.TryGetValue(identifier, out var state)) { HandleEquipSlot(actor, state, slot, ref armor); @@ -889,7 +889,7 @@ public class StateListener : IDisposable case StateSource.Manual: if (state.BaseData.Parameters.Set(flag, newValue)) _manager.ChangeCustomizeParameter(state, flag, newValue, ApplySettings.Game); - else if (_config.UseAdvancedParameters) + else model.ApplySingleParameterData(flag, state.ModelData.Parameters); break; case StateSource.IpcManual: @@ -900,8 +900,7 @@ public class StateListener : IDisposable break; case StateSource.Fixed: state.BaseData.Parameters.Set(flag, newValue); - if (_config.UseAdvancedParameters) - model.ApplySingleParameterData(flag, state.ModelData.Parameters); + model.ApplySingleParameterData(flag, state.ModelData.Parameters); break; case StateSource.IpcFixed: state.BaseData.Parameters.Set(flag, newValue); @@ -910,14 +909,12 @@ public class StateListener : IDisposable case StateSource.Pending: state.BaseData.Parameters.Set(flag, newValue); state.Sources[flag] = StateSource.Manual; - if (_config.UseAdvancedParameters) - model.ApplySingleParameterData(flag, state.ModelData.Parameters); + model.ApplySingleParameterData(flag, state.ModelData.Parameters); break; case StateSource.IpcPending: state.BaseData.Parameters.Set(flag, newValue); state.Sources[flag] = StateSource.IpcManual; - if (_config.UseAdvancedParameters) - model.ApplySingleParameterData(flag, state.ModelData.Parameters); + model.ApplySingleParameterData(flag, state.ModelData.Parameters); break; } } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 9b71586..2dda310 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -297,7 +297,7 @@ public sealed class StateManager( { actors = Applier.ChangeParameters(state, CustomizeParameterExtensions.All, true); foreach (var (idx, mat) in state.Materials.Values) - Applier.ChangeMaterialValue(state, actors, MaterialValueIndex.FromKey(idx), mat.Game, true); + Applier.ChangeMaterialValue(state, actors, MaterialValueIndex.FromKey(idx), mat.Game); } state.Materials.Clear(); From 94f6e870e6c96e21bc06221dc8249aa94311e261 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 2 Mar 2025 13:33:41 +0100 Subject: [PATCH 228/401] Update Submodules. --- OtterGui | 2 +- Penumbra.GameData | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OtterGui b/OtterGui index 06422a8..c347d29 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 06422a893348a18a013e6dbc558370db8d21a446 +Subproject commit c347d29d980b0191d1d071170cf2ec229e3efdcf diff --git a/Penumbra.GameData b/Penumbra.GameData index 33fea10..a21c146 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 33fea10e18ec9f8a5b309890de557fcb25780086 +Subproject commit a21c146790b370bd58b0f752385ae153f7e769c0 From 7015737d887a9918f0d5f5175d98df9e6a81ee73 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 2 Mar 2025 13:38:58 +0100 Subject: [PATCH 229/401] Meh. --- Glamourer/GameData/NpcCustomizeSet.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/GameData/NpcCustomizeSet.cs b/Glamourer/GameData/NpcCustomizeSet.cs index 3cc19cd..725f80f 100644 --- a/Glamourer/GameData/NpcCustomizeSet.cs +++ b/Glamourer/GameData/NpcCustomizeSet.cs @@ -330,9 +330,9 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList /// Check decal files for existence. private static void CheckFacepaintFiles(IDataManager data, BitArray facepaints) { - for (var i = 0; i < 128; ++i) + for (byte i = 0; i < 128; ++i) { - var path = GamePaths.Character.Tex.DecalPath("face", (PrimaryId)i); + var path = GamePaths.Tex.FaceDecal(i); if (data.FileExists(path)) facepaints[i] = true; } From 311207977623c800449299fc6f243a1f246e4a19 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 2 Mar 2025 12:40:58 +0000 Subject: [PATCH 230/401] [CI] Updating repo.json for testing_1.3.6.5 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 31b5654..fe2a7c2 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.6.0", - "TestingAssemblyVersion": "1.3.6.3", + "TestingAssemblyVersion": "1.3.6.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.5/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c96f009fb431f0093015e8c9a0bec42df3f466f6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 2 Mar 2025 16:02:02 +0100 Subject: [PATCH 231/401] Slightly speed up QDB drawing. --- Glamourer/Gui/DesignQuickBar.cs | 130 +++++++++++++++++++------------- 1 file changed, 77 insertions(+), 53 deletions(-) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index cabd888..d2dba01 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -48,6 +48,7 @@ public sealed class DesignQuickBar : Window, IDisposable private readonly ImRaii.Color _windowColor = new(); private DateTime _keyboardToggle = DateTime.UnixEpoch; private int _numButtons; + private readonly StringBuilder _tooltipBuilder = new(512); public DesignQuickBar(Configuration config, QuickDesignCombo designCombo, StateManager stateManager, IKeyState keyState, ObjectManager objects, AutoDesignApplier autoDesignApplier, PenumbraService penumbra) @@ -107,7 +108,7 @@ public sealed class DesignQuickBar : Window, IDisposable private void Draw(float width) { - using var group = ImRaii.Group(); + using var group = ImUtf8.Group(); var spacing = ImGui.GetStyle().ItemInnerSpacing; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); var buttonSize = new Vector2(ImGui.GetFrameHeight()); @@ -149,33 +150,38 @@ public sealed class DesignQuickBar : Window, IDisposable { var design = _designCombo.Design as Design; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); + if (design == null) { - tooltip = "No design selected."; + _tooltipBuilder.Append("No design selected."); } else { if (_playerIdentifier.IsValid && _playerData.Valid) { available |= 1; - tooltip = $"Left-Click: Apply {design.ResolveName(_config.Ephemeral.IncognitoMode)} to yourself."; + _tooltipBuilder.Append("Left-Click: Apply ") + .Append(design.ResolveName(_config.Ephemeral.IncognitoMode)) + .Append(" to yourself."); } if (_targetIdentifier.IsValid && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Apply {design.ResolveName(_config.Ephemeral.IncognitoMode)} to {_targetIdentifier}."; + _tooltipBuilder.Append("Right-Click: Apply ") + .Append(design.ResolveName(_config.Ephemeral.IncognitoMode)) + .Append(" to {_targetIdentifier}."); } if (available == 0) - tooltip = "Neither player character nor target available."; + _tooltipBuilder.Append("Neither player character nor target available."); } - var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.PlayCircle, size, tooltip, available); + var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.PlayCircle, size, available); ImGui.SameLine(); if (!clicked) return; @@ -197,25 +203,28 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); + if (_playerIdentifier.IsValid && _playerState is { IsLocked: false }) { available |= 1; - tooltip = "Left-Click: Revert the player character to their game state."; + _tooltipBuilder.Append("Left-Click: Revert the player character to their game state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false }) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Revert {_targetIdentifier} to their game state."; + _tooltipBuilder.Append("Right-Click: Revert ") + .Append(_targetIdentifier) + .Append(" to their game state."); } if (available == 0) - tooltip = "Neither player character nor target are available, have state modified by Glamourer, or their state is locked."; + _tooltipBuilder.Append("Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); - var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, tooltip, available); + var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, available); ImGui.SameLine(); if (clicked) _stateManager.ResetState(state!, StateSource.Manual, isFinal: true); @@ -230,26 +239,28 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) { available |= 1; - tooltip = "Left-Click: Revert the player character to their automation state."; + _tooltipBuilder.Append("Left-Click: Revert the player character to their automation state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Revert {_targetIdentifier} to their automation state."; + _tooltipBuilder.Append("Right-Click: Revert ") + .Append(_targetIdentifier) + .Append(" to their automation state."); } if (available == 0) - tooltip = "Neither player character nor target are available, have state modified by Glamourer, or their state is locked."; + _tooltipBuilder.Append("Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); - var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.SyncAlt, buttonSize, tooltip, available); + var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.SyncAlt, buttonSize, available); ImGui.SameLine(); if (!clicked) return; @@ -270,26 +281,28 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) { available |= 1; - tooltip = "Left-Click: Reapply the player character's current automation on top of their current state."; + _tooltipBuilder.Append("Left-Click: Reapply the player character's current automation on top of their current state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Reapply {_targetIdentifier}'s current automation on top of their current state."; + _tooltipBuilder.Append("Right-Click: Reapply ") + .Append(_targetIdentifier) + .Append("'s current automation on top of their current state."); } if (available == 0) - tooltip = "Neither player character nor target are available, have state modified by Glamourer, or their state is locked."; + _tooltipBuilder.Append("Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); - var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.Repeat, buttonSize, tooltip, available); + var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.Repeat, buttonSize, available); ImGui.SameLine(); if (!clicked) return; @@ -307,26 +320,28 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) { available |= 1; - tooltip = "Left-Click: Revert the advanced customizations and dyes of the player character to their game state."; + _tooltipBuilder.Append("Left-Click: Revert the advanced customizations and dyes of the player character to their game state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Revert the advanced customizations and dyes of {_targetIdentifier} to their game state."; + _tooltipBuilder.Append("Right-Click: Revert the advanced customizations and dyes of ") + .Append(_targetIdentifier) + .Append(" to their game state."); } if (available == 0) - tooltip = "Neither player character nor target are available or their state is locked."; + _tooltipBuilder.Append("Neither player character nor target are available or their state is locked."); - var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.Palette, buttonSize, tooltip, available); + var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.Palette, buttonSize, available); ImGui.SameLine(); if (clicked) _stateManager.ResetAdvancedState(state!, StateSource.Manual); @@ -338,26 +353,28 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) { available |= 1; - tooltip = "Left-Click: Revert the customizations of the player character to their game state."; + _tooltipBuilder.Append("Left-Click: Revert the customizations of the player character to their game state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Revert the customizations of {_targetIdentifier} to their game state."; + _tooltipBuilder.Append("Right-Click: Revert the customizations of ") + .Append(_targetIdentifier) + .Append(" to their game state."); } if (available == 0) - tooltip = "Neither player character nor target are available or their state is locked."; + _tooltipBuilder.Append("Neither player character nor target are available or their state is locked."); - var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.User, buttonSize, tooltip, available); + var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.User, buttonSize, available); ImGui.SameLine(); if (clicked) _stateManager.ResetCustomize(state!, StateSource.Manual); @@ -369,26 +386,28 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) { available |= 1; - tooltip = "Left-Click: Revert the equipment of the player character to its game state."; + _tooltipBuilder.Append("Left-Click: Revert the equipment of the player character to its game state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Revert the equipment of {_targetIdentifier} to its game state."; + _tooltipBuilder.Append("Right-Click: Revert the equipment of ") + .Append(_targetIdentifier) + .Append(" to its game state."); } if (available == 0) - tooltip = "Neither player character nor target are available or their state is locked."; + _tooltipBuilder.Append("Neither player character nor target are available or their state is locked."); - var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.Vest, buttonSize, tooltip, available); + var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.Vest, buttonSize, available); ImGui.SameLine(); if (clicked) _stateManager.ResetEquip(state!, StateSource.Manual); @@ -400,26 +419,30 @@ public sealed class DesignQuickBar : Window, IDisposable return; var available = 0; - var tooltip = string.Empty; + _tooltipBuilder.Clear(); if (_playerIdentifier.IsValid && _playerData.Valid) { available |= 1; - tooltip = $"Left-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting {_playerIdentifier}."; + _tooltipBuilder.Append("Left-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting ") + .Append(_playerIdentifier) + .Append('.'); } if (_targetIdentifier.IsValid && _targetData.Valid) { if (available != 0) - tooltip += '\n'; + _tooltipBuilder.Append('\n'); available |= 2; - tooltip += $"Right-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting {_targetIdentifier}."; + _tooltipBuilder.Append("Right-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting ") + .Append(_targetIdentifier) + .Append('.'); } if (available == 0) - tooltip = "Neither player character nor target are available to identify their collections."; + _tooltipBuilder.Append("Neither player character nor target are available to identify their collections."); - var (clicked, _, data, _) = ResolveTarget(FontAwesomeIcon.Cog, buttonSize, tooltip, available); + var (clicked, _, data, _) = ResolveTarget(FontAwesomeIcon.Cog, buttonSize, available); ImGui.SameLine(); if (clicked) { @@ -428,10 +451,11 @@ public sealed class DesignQuickBar : Window, IDisposable } } - private (bool, ActorIdentifier, ActorData, ActorState?) ResolveTarget(FontAwesomeIcon icon, Vector2 buttonSize, string tooltip, - int available) + private (bool, ActorIdentifier, ActorData, ActorState?) ResolveTarget(FontAwesomeIcon icon, Vector2 buttonSize, int available) { - ImUtf8.IconButton(icon, tooltip, buttonSize, available == 0); + var enumerator = _tooltipBuilder.GetChunks(); + var span = enumerator.MoveNext() ? enumerator.Current.Span : []; + ImUtf8.IconButton(icon, span, buttonSize, available == 0); if ((available & 1) == 1 && ImGui.IsItemClicked(ImGuiMouseButton.Left)) return (true, _playerIdentifier, _playerData, _playerState); if ((available & 2) == 2 && ImGui.IsItemClicked(ImGuiMouseButton.Right)) From 6e685b96d11da86fbb19037da075763183f41da3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 3 Mar 2025 16:31:09 +0100 Subject: [PATCH 232/401] Make all panels configurable. --- Glamourer/Configuration.cs | 3 + Glamourer/DesignPanelFlag.cs | 96 +++++++++++++++++++ Glamourer/Glamourer.cs | 1 + Glamourer/Gui/Materials/AdvancedDyePopup.cs | 3 + Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 15 ++- .../Gui/Tabs/DesignTab/DesignDetailTab.cs | 9 +- .../Gui/Tabs/DesignTab/DesignLinkDrawer.cs | 14 ++- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 14 ++- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 7 +- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 24 +++-- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 15 +++ 11 files changed, 176 insertions(+), 25 deletions(-) create mode 100644 Glamourer/DesignPanelFlag.cs diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 019bb2b..ef51544 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -66,6 +66,9 @@ public class Configuration : IPluginConfiguration, ISavable public bool AllowDoubleClickToApply { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false; + public DesignPanelFlag HideDesignPanel { get; set; } = 0; + public DesignPanelFlag AutoExpandDesignPanel { get; set; } = 0; + public DefaultDesignSettings DefaultDesignSettings { get; set; } = new(); public HeightDisplayType HeightDisplayType { get; set; } = HeightDisplayType.Centimetre; diff --git a/Glamourer/DesignPanelFlag.cs b/Glamourer/DesignPanelFlag.cs new file mode 100644 index 0000000..db84173 --- /dev/null +++ b/Glamourer/DesignPanelFlag.cs @@ -0,0 +1,96 @@ +using Glamourer.Designs; +using ImGuiNET; +using OtterGui.Text; +using OtterGui.Text.EndObjects; + +namespace Glamourer; + +[Flags] +public enum DesignPanelFlag : uint +{ + Customization = 0x0001, + Equipment = 0x0002, + AdvancedCustomizations = 0x0004, + AdvancedDyes = 0x0008, + AppearanceDetails = 0x0010, + DesignDetails = 0x0020, + ModAssociations = 0x0040, + DesignLinks = 0x0080, + ApplicationRules = 0x0100, + DebugData = 0x0200, +} + +public static class DesignPanelFlagExtensions +{ + public static ReadOnlySpan ToName(this DesignPanelFlag flag) + => flag switch + { + DesignPanelFlag.Customization => "Customization"u8, + DesignPanelFlag.Equipment => "Equipment"u8, + DesignPanelFlag.AdvancedCustomizations => "Advanced Customization"u8, + DesignPanelFlag.AdvancedDyes => "Advanced Dyes"u8, + DesignPanelFlag.DesignDetails => "Design Details"u8, + DesignPanelFlag.ApplicationRules => "Application Rules"u8, + DesignPanelFlag.ModAssociations => "Mod Associations"u8, + DesignPanelFlag.DesignLinks => "Design Links"u8, + DesignPanelFlag.DebugData => "Debug Data"u8, + DesignPanelFlag.AppearanceDetails => "Appearance Details"u8, + _ => ""u8, + }; + + public static CollapsingHeader Header(this DesignPanelFlag flag, Configuration config) + { + if (config.HideDesignPanel.HasFlag(flag)) + return new CollapsingHeader() + { + Disposed = true, + }; + + var expand = config.AutoExpandDesignPanel.HasFlag(flag); + return ImUtf8.CollapsingHeaderId(flag.ToName(), expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); + } + + public static void DrawTable(ReadOnlySpan label, DesignPanelFlag hidden, DesignPanelFlag expanded, Action setterHide, + Action setterExpand) + { + var checkBoxWidth = Math.Max(ImGui.GetFrameHeight(), ImUtf8.CalcTextSize("Expand"u8).X); + var textWidth = ImUtf8.CalcTextSize(DesignPanelFlag.AdvancedCustomizations.ToName()).X; + var tableSize = 2 * (textWidth + 2 * checkBoxWidth) + 10 * ImGui.GetStyle().CellPadding.X + 2 * ImGui.GetStyle().WindowPadding.X + 2 * ImGui.GetStyle().FrameBorderSize; + using var table = ImUtf8.Table(label, 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders, new Vector2(tableSize, 6 * ImGui.GetFrameHeight())); + if (!table) + return; + + var headerColor = ImGui.GetColorU32(ImGuiCol.TableHeaderBg); + var checkBoxOffset = (checkBoxWidth - ImGui.GetFrameHeight()) / 2; + ImUtf8.TableSetupColumn("Panel##1"u8, ImGuiTableColumnFlags.WidthFixed, textWidth); + ImUtf8.TableSetupColumn("Show##1"u8, ImGuiTableColumnFlags.WidthFixed, checkBoxWidth); + ImUtf8.TableSetupColumn("Expand##1"u8, ImGuiTableColumnFlags.WidthFixed, checkBoxWidth); + ImUtf8.TableSetupColumn("Panel##2"u8, ImGuiTableColumnFlags.WidthFixed, textWidth); + ImUtf8.TableSetupColumn("Show##2"u8, ImGuiTableColumnFlags.WidthFixed, checkBoxWidth); + ImUtf8.TableSetupColumn("Expand##2"u8, ImGuiTableColumnFlags.WidthFixed, checkBoxWidth); + + ImGui.TableHeadersRow(); + foreach (var panel in Enum.GetValues()) + { + using var id = ImUtf8.PushId((int)panel); + ImGui.TableNextColumn(); + ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, headerColor); + ImUtf8.TextFrameAligned(panel.ToName()); + var isShown = !hidden.HasFlag(panel); + var isExpanded = expanded.HasFlag(panel); + + ImGui.TableNextColumn(); + ImGui.SetCursorPosX(ImGui.GetCursorPosX() + checkBoxOffset); + if (ImUtf8.Checkbox("##show"u8, ref isShown)) + setterHide.Invoke(isShown ? hidden & ~panel : hidden | panel); + ImUtf8.HoverTooltip( + "Show this panel and associated functionality in all relevant tabs.\n\nToggling this off does NOT disable any functionality, just the display of it, so hide panels at your own risk."u8); + + ImGui.TableNextColumn(); + ImGui.SetCursorPosX(ImGui.GetCursorPosX() + checkBoxOffset); + if (ImUtf8.Checkbox("##expand"u8, ref isExpanded)) + setterExpand.Invoke(isExpanded ? expanded | panel : expanded & ~panel); + ImUtf8.HoverTooltip("Expand this panel by default in all relevant tabs."u8); + } + } +} diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 5d38e3a..9191c4f 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -71,6 +71,7 @@ public class Glamourer : IDalamudPlugin sb.Append($"> **`Festival Easter-Eggs: `** {config.DisableFestivals}\n"); sb.Append($"> **`Apply Entire Weapon: `** {config.ChangeEntireItem}\n"); sb.Append($"> **`Apply Associated Mods:`** {config.AlwaysApplyAssociatedMods}\n"); + sb.Append($"> **`Hidden Panels: `** {config.HideDesignPanel}\n"); sb.Append($"> **`Show QDB: `** {config.Ephemeral.ShowDesignQuickBar}\n"); sb.Append($"> **`QDB Hotkey: `** {config.ToggleQuickDesignBar}\n"); sb.Append($"> **`Smaller Equip Display:`** {config.SmallEquip}\n"); diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 6d0bb70..21e5ef9 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -55,6 +55,9 @@ public sealed unsafe class AdvancedDyePopup( private void DrawButton(MaterialValueIndex index, uint color) { + if (config.HideDesignPanel.HasFlag(DesignPanelFlag.AdvancedDyes)) + return; + ImGui.SameLine(); using var id = ImUtf8.PushId(index.SlotIndex | ((int)index.DrawObject << 8)); var isOpen = index == _drawIndex; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index e56266d..0071b1f 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -59,7 +59,7 @@ public class ActorPanel ICondition conditions, DictModelChara modelChara, CustomizeParameterDrawer parameterDrawer, - AdvancedDyePopup advancedDyes, + AdvancedDyePopup advancedDyes, EditorHistory editorHistory) { _selector = selector; @@ -157,6 +157,7 @@ public class ActorPanel using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); if (!table || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) return; + ImGui.TableSetupScrollFreeze(0, 1); ImGui.TableNextColumn(); ImGui.Dummy(Vector2.Zero); @@ -191,10 +192,14 @@ public class ActorPanel private void DrawCustomizationsHeader() { + if (_config.HideDesignPanel.HasFlag(DesignPanelFlag.Customization)) + return; + var header = _state!.ModelData.ModelId == 0 ? "Customization" : $"Customization (Model Id #{_state.ModelData.ModelId})###Customization"; - using var h = ImUtf8.CollapsingHeaderId(header); + var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); + using var h = ImUtf8.CollapsingHeaderId(header, expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); if (!h) return; @@ -207,7 +212,7 @@ public class ActorPanel private void DrawEquipmentHeader() { - using var h = ImUtf8.CollapsingHeaderId("Equipment"u8); + using var h = DesignPanelFlag.Equipment.Header(_config); if (!h) return; @@ -239,7 +244,7 @@ public class ActorPanel private void DrawParameterHeader() { - using var h = ImUtf8.CollapsingHeaderId("Advanced Customizations"u8); + using var h = DesignPanelFlag.AdvancedCustomizations.Header(_config); if (!h) return; @@ -251,7 +256,7 @@ public class ActorPanel if (!_config.DebugMode) return; - using var h = ImUtf8.CollapsingHeaderId("Debug Data"u8); + using var h = DesignPanelFlag.DebugData.Header(_config); if (!h) return; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index 1469deb..cbf7acd 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -14,6 +14,7 @@ namespace Glamourer.Gui.Tabs.DesignTab; public class DesignDetailTab { private readonly SaveService _saveService; + private readonly Configuration _config; private readonly DesignFileSystemSelector _selector; private readonly DesignFileSystem _fileSystem; private readonly DesignManager _manager; @@ -30,19 +31,20 @@ public class DesignDetailTab private DesignFileSystem.Leaf? _changeLeaf; public DesignDetailTab(SaveService saveService, DesignFileSystemSelector selector, DesignManager manager, DesignFileSystem fileSystem, - DesignColors colors) + DesignColors colors, Configuration config) { _saveService = saveService; _selector = selector; _manager = manager; _fileSystem = fileSystem; _colors = colors; + _config = config; _colorCombo = new DesignColorCombo(_colors, false); } public void Draw() { - using var h = ImUtf8.CollapsingHeaderId("Design Details"u8); + using var h = DesignPanelFlag.DesignDetails.Header(_config); if (!h) return; @@ -159,7 +161,8 @@ public class DesignDetailTab ImGui.TableNextColumn(); if (ImUtf8.Checkbox("##ResetTemporarySettings"u8, ref resetTemporarySettings)) _manager.ChangeResetTemporarySettings(_selector.Selected!, resetTemporarySettings); - ImUtf8.HoverTooltip("Set this design to reset any temporary settings previously applied to the associated collection when it is applied through any means."u8); + ImUtf8.HoverTooltip( + "Set this design to reset any temporary settings previously applied to the associated collection when it is applied through any means."u8); ImUtf8.DrawFrameColumn("Color"u8); var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs index 5a8c41c..b81ffdf 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs @@ -10,7 +10,12 @@ using OtterGui.Services; namespace Glamourer.Gui.Tabs.DesignTab; -public class DesignLinkDrawer(DesignLinkManager _linkManager, DesignFileSystemSelector _selector, LinkDesignCombo _combo, DesignColors _colorManager) : IUiService +public class DesignLinkDrawer( + DesignLinkManager _linkManager, + DesignFileSystemSelector _selector, + LinkDesignCombo _combo, + DesignColors _colorManager, + Configuration config) : IUiService { private int _dragDropIndex = -1; private LinkOrder _dragDropOrder = LinkOrder.None; @@ -19,12 +24,15 @@ public class DesignLinkDrawer(DesignLinkManager _linkManager, DesignFileSystemSe public void Draw() { - using var header = ImRaii.CollapsingHeader("Design Links"); + using var h = DesignPanelFlag.DesignLinks.Header(config); + if (h.Disposed) + return; + ImGuiUtil.HoverTooltip( "Design links are links to other designs that will be applied to characters or during automation according to the rules set.\n" + "They apply from top to bottom just like automated design sets, so anything set by an earlier design will not not be set again by later designs, and order is important.\n" + "If a linked design links to other designs, they will also be applied, so circular links are prohibited. "); - if (!header) + if (!h) return; DrawList(); diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 554e671..f576223 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -101,7 +101,7 @@ public class DesignPanel private void DrawEquipment() { - using var h = ImRaii.CollapsingHeader("Equipment"); + using var h = DesignPanelFlag.Equipment.Header(_config); if (!h) return; @@ -156,10 +156,14 @@ public class DesignPanel private void DrawCustomize() { + if (_config.HideDesignPanel.HasFlag(DesignPanelFlag.Customization)) + return; + var header = _selector.Selected!.DesignData.ModelId == 0 ? "Customization" : $"Customization (Model Id #{_selector.Selected!.DesignData.ModelId})###Customization"; - using var h = ImRaii.CollapsingHeader(header); + var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); + using var h = ImUtf8.CollapsingHeaderId(header, expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); if (!h) return; @@ -180,7 +184,7 @@ public class DesignPanel private void DrawCustomizeParameters() { - using var h = ImUtf8.CollapsingHeaderId("Advanced Customizations"u8); + using var h = DesignPanelFlag.AdvancedCustomizations.Header(_config); if (!h) return; @@ -189,7 +193,7 @@ public class DesignPanel private void DrawMaterialValues() { - using var h = ImUtf8.CollapsingHeaderId("Advanced Dyes"u8); + using var h = DesignPanelFlag.AdvancedDyes.Header(_config); if (!h) return; @@ -244,7 +248,7 @@ public class DesignPanel private void DrawApplicationRules() { - using var h = ImUtf8.CollapsingHeaderId("Application Rules"u8); + using var h = DesignPanelFlag.ApplicationRules.Header(_config); if (!h) return; diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 5856fcc..f172735 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -21,7 +21,10 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect public void Draw() { - using var h = ImRaii.CollapsingHeader("Mod Associations"); + using var h = DesignPanelFlag.ModAssociations.Header(config); + if (h.Disposed) + return; + ImGuiUtil.HoverTooltip( "This tab can store information about specific mods associated with this design.\n\n" + "It does NOT change any mod settings automatically, though there is functionality to apply desired mod settings manually.\n" @@ -98,7 +101,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect ImUtf8.TableSetupColumn("Mod Name"u8, ImGuiTableColumnFlags.WidthStretch); if (config.UseTemporarySettings) ImUtf8.TableSetupColumn("Remove"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Remove"u8).X); - ImUtf8.TableSetupColumn("Inherit"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); + ImUtf8.TableSetupColumn("Inherit"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); ImUtf8.TableSetupColumn("State"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("State"u8).X); ImUtf8.TableSetupColumn("Priority"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Priority"u8).X); ImUtf8.TableSetupColumn("##Options"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Applym"u8).X); diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index aeb96f6..1151e86 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -19,6 +19,7 @@ namespace Glamourer.Gui.Tabs.NpcTab; public class NpcPanel { + private readonly Configuration _config; private readonly DesignColorCombo _colorCombo; private string _newName = string.Empty; private DesignBase? _newDesign; @@ -42,7 +43,8 @@ public class NpcPanel DesignManager designManager, StateManager state, ObjectManager objects, - DesignColors colors) + DesignColors colors, + Configuration config) { _selector = selector; _favorites = favorites; @@ -53,6 +55,7 @@ public class NpcPanel _state = state; _objects = objects; _colors = colors; + _config = config; _colorCombo = new DesignColorCombo(colors, true); _leftButtons = [ @@ -139,9 +142,14 @@ public class NpcPanel private void DrawCustomization() { - using var h = _selector.Selection.ModelId == 0 - ? ImUtf8.CollapsingHeaderId("Customization"u8) - : ImUtf8.CollapsingHeaderId($"Customization (Model Id #{_selector.Selection.ModelId})###Customization"); + if (_config.HideDesignPanel.HasFlag(DesignPanelFlag.Customization)) + return; + + var header = _selector.Selection.ModelId == 0 + ? "Customization" + : $"Customization (Model Id #{_selector.Selection.ModelId})###Customization"; + var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); + using var h = ImUtf8.CollapsingHeaderId(header, expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); if (!h) return; @@ -151,7 +159,7 @@ public class NpcPanel private void DrawEquipment() { - using var h = ImUtf8.CollapsingHeaderId("Equipment"u8); + using var h = DesignPanelFlag.Equipment.Header(_config); if (!h) return; @@ -190,7 +198,9 @@ public class NpcPanel private void DrawApplyToSelf() { var (id, data) = _objects.PlayerData; - if (!ImUtf8.ButtonEx("Apply to Yourself"u8, "Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations."u8, Vector2.Zero, !data.Valid)) + if (!ImUtf8.ButtonEx("Apply to Yourself"u8, + "Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations."u8, + Vector2.Zero, !data.Valid)) return; if (_state.GetOrCreate(id, data.Objects[0], out var state)) @@ -221,7 +231,7 @@ public class NpcPanel private void DrawAppearanceInfo() { - using var h = ImUtf8.CollapsingHeaderId("Appearance Details"u8); + using var h = DesignPanelFlag.AppearanceDetails.Header(_config); if (!h) return; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index fd4f3f5..d6d2c15 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -136,6 +136,7 @@ public class SettingsTab( 100 * ImGuiHelpers.GlobalScale, config.ToggleQuickDesignBar, v => config.ToggleQuickDesignBar = v, _validKeys)) config.Save(); + Checkbox("Show Quick Design Bar in Main Window"u8, "Show the quick design bar in the tab selection part of the main window, too."u8, config.ShowQuickBarInTabs, v => config.ShowQuickBarInTabs = v); @@ -193,6 +194,20 @@ public class SettingsTab( v => config.OpenFoldersByDefault = v); DrawFolderSortType(); + ImGui.NewLine(); + ImUtf8.Text("Show the following panels in their respective tabs:"u8); + ImGui.Dummy(Vector2.Zero); + DesignPanelFlagExtensions.DrawTable("##panelTable"u8, config.HideDesignPanel, config.AutoExpandDesignPanel, v => + { + config.HideDesignPanel = v; + config.Save(); + }, v => + { + config.AutoExpandDesignPanel = v; + config.Save(); + }); + + ImGui.Dummy(Vector2.Zero); ImGui.Separator(); ImGui.Dummy(Vector2.Zero); From b9e4c144c20f560d7ddc0f0aafb1124bdd3faacf Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 3 Mar 2025 17:55:38 +0100 Subject: [PATCH 233/401] Add some buttons to set design application rules to some presets. --- Glamourer/Designs/DesignManager.cs | 34 +++++++++ Glamourer/Gui/Materials/MaterialDrawer.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 84 +++++++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index f931489..f9429ad 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -3,6 +3,7 @@ using Glamourer.Designs.History; using Glamourer.Designs.Links; using Glamourer.Events; using Glamourer.GameData; +using Glamourer.Interop.Material; using Glamourer.Interop.Penumbra; using Glamourer.Services; using Newtonsoft.Json; @@ -448,6 +449,39 @@ public sealed class DesignManager : DesignEditor DesignChanged.Invoke(DesignChanged.Type.ApplyParameter, design, new ApplicationTransaction(flag, !value, value)); } + /// Change multiple application values at once. + public void ChangeApplyMulti(Design design, bool? equipment, bool? customization, bool? bonus, bool? parameters, bool? meta, bool? stains, + bool? materials, bool? crest) + { + if (equipment is { } e) + foreach (var f in EquipSlotExtensions.FullSlots) + ChangeApplyItem(design, f, e); + if (stains is { } s) + foreach (var f in EquipSlotExtensions.FullSlots) + ChangeApplyStains(design, f, s); + if (customization is { } c) + foreach (var f in CustomizationExtensions.All.Where(design.CustomizeSet.IsAvailable).Prepend(CustomizeIndex.Clan) + .Prepend(CustomizeIndex.Gender)) + ChangeApplyCustomize(design, f, c); + if (bonus is { } b) + foreach (var f in BonusExtensions.AllFlags) + ChangeApplyBonusItem(design, f, b); + if (meta is { } m) + foreach (var f in MetaExtensions.AllRelevant) + ChangeApplyMeta(design, f, m); + if (crest is { } cr) + foreach (var f in CrestExtensions.AllRelevantSet) + ChangeApplyCrest(design, f, cr); + + if (parameters is { } p) + foreach (var f in CustomizeParameterExtensions.AllFlags) + ChangeApplyParameter(design, f, p); + + if (materials is { } ma) + foreach (var (key, _) in design.GetMaterialData()) + ChangeApplyMaterialValue(design, MaterialValueIndex.FromKey(key), ma); + } + #endregion public void UndoDesignChange(Design design) diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 1b5e65a..5b3af31 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -44,7 +44,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) private void DrawName(MaterialValueIndex index) { - using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); + using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0.05f, 0.5f)); ImUtf8.TextFramed(index.ToString(), 0, new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0), borderColor: ImGui.GetColorU32(ImGuiCol.Text)); } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index f576223..caea8fe 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -254,6 +254,8 @@ public class DesignPanel using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected()); + DrawAllButtons(); + using (var _ = ImUtf8.Group()) { DrawCustomizeApplication(); @@ -310,6 +312,88 @@ public class DesignPanel } } + private void DrawAllButtons() + { + var enabled = _config.DeleteDesignModifier.IsActive(); + bool? equip = null; + bool? customize = null; + var size = new Vector2(200 * ImUtf8.GlobalScale, 0); + if (ImUtf8.ButtonEx("Disable Everything"u8, + "Disable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness."u8, size, + !enabled)) + { + equip = false; + customize = false; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); + + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Enable Everything"u8, + "Enable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness."u8, size, + !enabled)) + { + equip = true; + customize = true; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); + + if (ImUtf8.ButtonEx("Equipment Only"u8, + "Enable application of anything related to gear, disable anything that is not related to gear."u8, size, + !enabled)) + { + equip = true; + customize = false; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); + + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Customization Only"u8, + "Enable application of anything related to customization, disable anything that is not related to customization."u8, size, + !enabled)) + { + equip = false; + customize = true; + } + + if (ImUtf8.ButtonEx("Default Application"u8, + "Set the application rules to the default values as if the design was newly created, without any advanced features or wetness."u8, + size, + !enabled)) + { + _manager.ChangeApplyMulti(_selector.Selected!, true, true, true, false, true, true, false, true); + _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.Wetness, false); + } + + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Disable Advanced"u8, "Disable all advanced dyes and customizations but keep everything else as is."u8, + size, + !enabled)) + _manager.ChangeApplyMulti(_selector.Selected!, null, null, null, false, null, null, false, null); + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); + + if (equip is null && customize is null) + return; + + _manager.ChangeApplyMulti(_selector.Selected!, equip, customize, equip, customize, null, equip, equip, equip); + if (equip.HasValue) + { + _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.HatState, equip.Value); + _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.VisorState, equip.Value); + _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.WeaponState, equip.Value); + } + + if (customize.HasValue) + _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.Wetness, customize.Value); + } + private static readonly IReadOnlyList MetaLabels = [ "Apply Wetness", From 3fd6108fa1749c4e65958b8b3a4d2f5b4f437c9b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 3 Mar 2025 18:12:42 +0100 Subject: [PATCH 234/401] Add buttons to remove, enable and disable multiple advanced dyes at once in a design. --- Glamourer/Designs/DesignManager.cs | 2 +- Glamourer/Gui/Materials/MaterialDrawer.cs | 48 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index f9429ad..ef01e98 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -478,7 +478,7 @@ public sealed class DesignManager : DesignEditor ChangeApplyParameter(design, f, p); if (materials is { } ma) - foreach (var (key, _) in design.GetMaterialData()) + foreach (var (key, _) in design.GetMaterialData().ToArray()) ChangeApplyMaterialValue(design, MaterialValueIndex.FromKey(key), ma); } diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 5b3af31..0c4433d 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -35,6 +35,10 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) + (GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + 6 * _spacing + ImUtf8.CalcTextSize("Revert"u8).X; + DrawMultiButtons(design); + ImUtf8.Dummy(0); + ImGui.Separator(); + ImUtf8.Dummy(0); if (available > 1.95 * colorWidth) DrawSingleRow(design); else @@ -42,6 +46,39 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) DrawNew(design); } + private void DrawMultiButtons(Design design) + { + var any = design.Materials.Count > 0; + var disabled = !_config.DeleteDesignModifier.IsActive(); + var size = new Vector2(200 * ImUtf8.GlobalScale, 0); + if (ImUtf8.ButtonEx("Enable All Advanced Dyes"u8, + any + ? "Enable the application of all contained advanced dyes without deleting them."u8 + : "This design does not contain any advanced dyes."u8, size, + !any || disabled)) + _designManager.ChangeApplyMulti(design, null, null, null, null, null, null, true, null); + ; + if (disabled && any) + ImUtf8.HoverTooltip($"Hold {_config.DeleteDesignModifier} while clicking to enable."); + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Disable All Advanced Dyes"u8, + any + ? "Disable the application of all contained advanced dyes without deleting them."u8 + : "This design does not contain any advanced dyes."u8, size, + !any || disabled)) + _designManager.ChangeApplyMulti(design, null, null, null, null, null, null, false, null); + if (disabled && any) + ImUtf8.HoverTooltip($"Hold {_config.DeleteDesignModifier} while clicking to disable."); + + if (ImUtf8.ButtonEx("Delete All Advanced Dyes"u8, any ? ""u8 : "This design does not contain any advanced dyes."u8, size, + !any || disabled)) + while (design.Materials.Count > 0) + _designManager.ChangeMaterialValue(design, MaterialValueIndex.FromKey(design.Materials[0].Item1), null); + + if (disabled && any) + ImUtf8.HoverTooltip($"Hold {_config.DeleteDesignModifier} while clicking to delete."); + } + private void DrawName(MaterialValueIndex index) { using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0.05f, 0.5f)); @@ -139,7 +176,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) "If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."u8); } - public sealed class MaterialSlotCombo; + public sealed class MaterialSlotCombo; public void DrawNew(Design design) { @@ -165,22 +202,27 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) { ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Material AA"u8).X); var format = $"Material {(char)('A' + _newMaterialIdx)}"; - if (ImUtf8.DragScalar("##Material"u8, ref _newMaterialIdx, format, 0, MaterialService.MaterialsPerModel - 1, 0.01f)) + if (ImUtf8.DragScalar("##Material"u8, ref _newMaterialIdx, format, 0, MaterialService.MaterialsPerModel - 1, 0.01f, + ImGuiSliderFlags.NoInput)) { _newMaterialIdx = Math.Clamp(_newMaterialIdx, 0, MaterialService.MaterialsPerModel - 1); _newKey = _newKey with { MaterialIndex = (byte)_newMaterialIdx }; } + + ImUtf8.HoverTooltip("Drag this to the left or right to change its value."u8); } private void DrawRowIdxDrag() { ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Row 0000"u8).X); var format = $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}"; - if (ImUtf8.DragScalar("##Row"u8, ref _newRowIdx, format, 0, ColorTable.NumRows - 1, 0.01f)) + if (ImUtf8.DragScalar("##Row"u8, ref _newRowIdx, format, 0, ColorTable.NumRows - 1, 0.01f, ImGuiSliderFlags.NoInput)) { _newRowIdx = Math.Clamp(_newRowIdx, 0, ColorTable.NumRows - 1); _newKey = _newKey with { RowIndex = (byte)_newRowIdx }; } + + ImUtf8.HoverTooltip("Drag this to the left or right to change its value."u8); } private void DrawRow(Design design, MaterialValueIndex index, in ColorRow row, bool disabled) From 71e15474b2822a9403701458889a93a8f60397c9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 3 Mar 2025 18:32:52 +0100 Subject: [PATCH 235/401] Add deletion of advanced dyes to multi design selection. --- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index a7afa21..1e52fb5 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using Glamourer.Designs; +using Glamourer.Interop.Material; using ImGuiNET; using OtterGui; using OtterGui.Raii; @@ -37,6 +38,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e DrawMultiResetSettings(offset); DrawMultiResetDyes(offset); DrawMultiForceRedraw(offset); + DrawAdvancedButtons(offset); } private void DrawCounts(Vector2 treeNodePos) @@ -57,11 +59,13 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e private void ResetCounts() { - _numQuickDesignEnabled = 0; - _numDesignsLocked = 0; - _numDesignsForcedRedraw = 0; - _numDesignsResetSettings = 0; - _numDesignsResetDyes = 0; + _numQuickDesignEnabled = 0; + _numDesignsLocked = 0; + _numDesignsForcedRedraw = 0; + _numDesignsResetSettings = 0; + _numDesignsResetDyes = 0; + _numDesignsWithAdvancedDyes = 0; + _numAdvancedDyes = 0; } private bool CountLeaves(DesignFileSystem.IPath path) @@ -79,6 +83,12 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ++_numDesignsForcedRedraw; if (l.Value.ResetAdvancedDyes) ++_numDesignsResetDyes; + if (l.Value.Materials.Count > 0) + { + ++_numDesignsWithAdvancedDyes; + _numAdvancedDyes += l.Value.Materials.Count; + } + return true; } @@ -135,6 +145,8 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e private int _numDesignsForcedRedraw; private int _numDesignsResetSettings; private int _numDesignsResetDyes; + private int _numAdvancedDyes; + private int _numDesignsWithAdvancedDyes; private int _numDesigns; private readonly List _addDesigns = []; private readonly List<(Design, int)> _removeDesigns = []; @@ -294,7 +306,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e private void DrawMultiColor(Vector2 width, float offset) { - ImUtf8.TextFrameAligned("Multi Colors:"); + ImUtf8.TextFrameAligned("Multi Colors:"u8); ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); _colorCombo.Draw("##color", _colorCombo.CurrentSelection ?? string.Empty, "Select a design color.", ImGui.GetContentRegionAvail().X - 2 * (width.X + ImGui.GetStyle().ItemSpacing.X), ImGui.GetTextLineHeight()); @@ -330,6 +342,31 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ImGui.Separator(); } + private void DrawAdvancedButtons(float offset) + { + ImUtf8.TextFrameAligned("Delete Adv."u8); + ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); + var enabled = config.DeleteDesignModifier.IsActive(); + var tt = _numDesignsWithAdvancedDyes is 0 + ? "No selected designs contain any advanced dyes." + : $"Delete {_numAdvancedDyes} advanced dyes from {_numDesignsWithAdvancedDyes} of the selected designs."; + if (ImUtf8.ButtonEx("Delete All Advanced Dyes"u8, tt, new Vector2(ImGui.GetContentRegionAvail().X, 0), + !enabled || _numDesignsWithAdvancedDyes is 0)) + + foreach (var design in selector.SelectedPaths.OfType()) + { + while (design.Value.Materials.Count > 0) + editor.ChangeMaterialValue(design.Value, MaterialValueIndex.FromKey(design.Value.Materials[0].Item1), null); + } + + if (!enabled && _numDesignsWithAdvancedDyes is not 0) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking to delete."); + ImGui.Separator(); + } + + private void DrawApplicationButtons(Vector2 width, float offset) + { } + private void UpdateTagCache() { _addDesigns.Clear(); From 87f1b613f969f5c558acc51220f6d878cd638127 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 4 Mar 2025 00:18:41 +0100 Subject: [PATCH 236/401] Add application shortcuts to multi design panel. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 4 + .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 104 +++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index caea8fe..9fed566 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -360,6 +360,8 @@ public class DesignPanel equip = false; customize = true; } + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); if (ImUtf8.ButtonEx("Default Application"u8, "Set the application rules to the default values as if the design was newly created, without any advanced features or wetness."u8, @@ -369,6 +371,8 @@ public class DesignPanel _manager.ChangeApplyMulti(_selector.Selected!, true, true, true, false, true, true, false, true); _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.Wetness, false); } + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); ImGui.SameLine(); if (ImUtf8.ButtonEx("Disable Advanced"u8, "Disable all advanced dyes and customizations but keep everything else as is."u8, diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 1e52fb5..e0523f7 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -39,6 +39,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e DrawMultiResetDyes(offset); DrawMultiForceRedraw(offset); DrawAdvancedButtons(offset); + DrawApplicationButtons(offset); } private void DrawCounts(Vector2 treeNodePos) @@ -364,8 +365,107 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ImGui.Separator(); } - private void DrawApplicationButtons(Vector2 width, float offset) - { } + private void DrawApplicationButtons(float offset) + { + ImUtf8.TextFrameAligned("Application"u8); + ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X); + var width = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); + var enabled = config.DeleteDesignModifier.IsActive(); + bool? equip = null; + bool? customize = null; + var group = ImUtf8.Group(); + if (ImUtf8.ButtonEx("Disable Everything"u8, + _numDesigns > 0 + ? $"Disable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness for all {_numDesigns} designs." + : "No designs selected.", width, !enabled)) + { + equip = false; + customize = false; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); + + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Enable Everything"u8, + _numDesigns > 0 + ? $"Enable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness for all {_numDesigns} designs." + : "No designs selected.", width, !enabled)) + { + equip = true; + customize = true; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); + + if (ImUtf8.ButtonEx("Equipment Only"u8, + _numDesigns > 0 + ? $"Enable application of anything related to gear, disable anything that is not related to gear for all {_numDesigns} designs." + : "No designs selected.", width, !enabled)) + { + equip = true; + customize = false; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); + + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Customization Only"u8, + _numDesigns > 0 + ? $"Enable application of anything related to customization, disable anything that is not related to customization for all {_numDesigns} designs." + : "No designs selected.", width, !enabled)) + { + equip = false; + customize = true; + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); + + if (ImUtf8.ButtonEx("Default Application"u8, + _numDesigns > 0 + ? $"Set the application rules to the default values as if the {_numDesigns} were newly created,without any advanced features or wetness." + : "No designs selected.", width, !enabled)) + foreach (var design in selector.SelectedPaths.OfType().Select(l => l.Value)) + { + editor.ChangeApplyMulti(design, true, true, true, false, true, true, false, true); + editor.ChangeApplyMeta(design, MetaIndex.Wetness, false); + } + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); + + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Disable Advanced"u8, _numDesigns > 0 + ? $"Disable all advanced dyes and customizations but keep everything else as is for all {_numDesigns} designs." + : "No designs selected.", width, !enabled)) + foreach (var design in selector.SelectedPaths.OfType().Select(l => l.Value)) + editor.ChangeApplyMulti(design, null, null, null, false, null, null, false, null); + + if (!enabled) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); + + group.Dispose(); + ImGui.Separator(); + if (equip is null && customize is null) + return; + + foreach (var design in selector.SelectedPaths.OfType().Select(l => l.Value)) + { + editor.ChangeApplyMulti(design, equip, customize, equip, customize, null, equip, equip, equip); + if (equip.HasValue) + { + editor.ChangeApplyMeta(design, MetaIndex.HatState, equip.Value); + editor.ChangeApplyMeta(design, MetaIndex.VisorState, equip.Value); + editor.ChangeApplyMeta(design, MetaIndex.WeaponState, equip.Value); + } + + if (customize.HasValue) + editor.ChangeApplyMeta(design, MetaIndex.Wetness, customize.Value); + } + } private void UpdateTagCache() { From ae093506c19b4a0ad3bc994db86e3fb03b651888 Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 3 Mar 2025 23:21:09 +0000 Subject: [PATCH 237/401] [CI] Updating repo.json for testing_1.3.6.6 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index fe2a7c2..18c30c3 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.3.6.0", - "TestingAssemblyVersion": "1.3.6.5", + "TestingAssemblyVersion": "1.3.6.6", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.5/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.6/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 2026069ed35f38dd38b12ca703c9d1784219abce Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 4 Mar 2025 15:34:39 +0100 Subject: [PATCH 238/401] Make Glamourer able to export and import color sets to and from Penumbra, maybe. --- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 72 +++++++++++++++++-- .../Interop/Material/MaterialValueManager.cs | 2 - 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 21e5ef9..e15872b 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -1,4 +1,5 @@ using Dalamud.Interface; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.Graphics.Render; @@ -16,6 +17,7 @@ using Penumbra.GameData.Enums; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Interop; using Penumbra.String; +using Notification = OtterGui.Classes.Notification; namespace Glamourer.Gui.Materials; @@ -262,6 +264,61 @@ public sealed unsafe class AdvancedDyePopup( DrawAllRow(materialIndex, table); } + private static void CopyToClipboard(in ColorTable.Table table) + { + try + { + fixed (ColorTable.Table* ptr = &table) + { + var data = new ReadOnlySpan(ptr, sizeof(ColorTable.Table)); + var base64 = Convert.ToBase64String(data); + ImGui.SetClipboardText(base64); + } + } + catch (Exception ex) + { + Glamourer.Log.Error($"Could not copy color table to clipboard:\n{ex}"); + } + } + + private static bool ImportFromClipboard(out ColorTable.Table table) + { + try + { + var base64 = ImGui.GetClipboardText(); + if (base64.Length > 0) + { + var data = Convert.FromBase64String(base64); + if (sizeof(ColorTable.Table) <= data.Length) + { + table = new ColorTable.Table(); + fixed (ColorTable.Table* tPtr = &table) + { + fixed (byte* ptr = data) + { + new ReadOnlySpan(ptr, sizeof(ColorTable.Table)).CopyTo(new Span(tPtr, sizeof(ColorTable.Table))); + return true; + } + } + } + } + + if (ColorRowClipboard.IsTableSet) + { + table = ColorRowClipboard.Table; + return true; + } + } + catch (Exception ex) + { + Glamourer.Messager.AddMessage(new Notification(ex, "Could not paste color table from clipboard.", + "Could not paste color table from clipboard.", NotificationType.Error)); + } + + table = default; + return false; + } + private void DrawAllRow(MaterialValueIndex materialIndex, in ColorTable.Table table) { using var id = ImRaii.PushId(100); @@ -279,13 +336,17 @@ public sealed unsafe class AdvancedDyePopup( var spacing = ImGui.GetStyle().ItemInnerSpacing.X; ImGui.SameLine(ImGui.GetWindowSize().X - 3 * buttonSize.X - 2 * spacing - ImGui.GetStyle().WindowPadding.X); if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this table to your clipboard."u8, buttonSize)) + { ColorRowClipboard.Table = table; + CopyToClipboard(table); + } + ImGui.SameLine(0, spacing); - if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported table from your clipboard onto this table."u8, buttonSize, - !ColorRowClipboard.IsTableSet)) + if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported table from your clipboard onto this table."u8, buttonSize) + && ImportFromClipboard(out var newTable)) for (var idx = 0; idx < ColorTable.NumRows; ++idx) { - var row = ColorRowClipboard.Table[idx]; + var row = newTable[idx]; var internalRow = new ColorRow(row); var slot = materialIndex.ToEquipSlot(); var weapon = slot is EquipSlot.MainHand or EquipSlot.OffHand @@ -336,7 +397,7 @@ public sealed unsafe class AdvancedDyePopup( { var rowIndex = index.RowIndex / 2 + 1; var rowSuffix = (index.RowIndex & 1) == 0 ? 'A' : 'B'; - ImUtf8.Text($"Row {rowIndex,2}{rowSuffix}"); + ImUtf8.Text($"Row {rowIndex,2}{rowSuffix}"); } ImGui.SameLine(0, ImGui.GetStyle().ItemSpacing.X * 2); @@ -380,7 +441,8 @@ public sealed unsafe class AdvancedDyePopup( if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this row to your clipboard."u8, buttonSize)) ColorRowClipboard.Row = value.Model; ImGui.SameLine(0, spacing.X); - if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8, buttonSize, !ColorRowClipboard.IsSet)) + if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8, buttonSize, + !ColorRowClipboard.IsSet)) { value.Model = ColorRowClipboard.Row; applied = true; diff --git a/Glamourer/Interop/Material/MaterialValueManager.cs b/Glamourer/Interop/Material/MaterialValueManager.cs index 520dacf..01cb479 100644 --- a/Glamourer/Interop/Material/MaterialValueManager.cs +++ b/Glamourer/Interop/Material/MaterialValueManager.cs @@ -6,8 +6,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Structs; -using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; -using static Penumbra.GameData.Files.ShpkFile; namespace Glamourer.Interop.Material; From c9f00c636996c18c384ae47520682fcf1f5a4b61 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 4 Mar 2025 16:28:48 +0100 Subject: [PATCH 239/401] Mark designs containing advanced dyes, mod associations or links in automation. --- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 51 +++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 680e0e9..94329e5 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -30,10 +30,10 @@ public class SetPanel( Configuration _config, RandomRestrictionDrawer _randomDrawer) { - private readonly JobGroupCombo _jobGroupCombo = new(_manager, _jobs, Glamourer.Log); + private readonly JobGroupCombo _jobGroupCombo = new(_manager, _jobs, Glamourer.Log); private readonly HeaderDrawer.Button[] _rightButtons = [new HeaderDrawer.IncognitoButton(_config.Ephemeral)]; - private string? _tempName; - private int _dragIndex = -1; + private string? _tempName; + private int _dragIndex = -1; private Action? _endAction; @@ -178,7 +178,8 @@ public class SetPanel( } else { - ImUtf8.TableSetupColumn("Design / Job Restrictions"u8, ImGuiTableColumnFlags.WidthFixed, 250 * ImGuiHelpers.GlobalScale); + ImUtf8.TableSetupColumn("Design / Job Restrictions"u8, ImGuiTableColumnFlags.WidthFixed, + 250 * ImGuiHelpers.GlobalScale - (ImGui.GetScrollMaxY() > 0 ? ImGui.GetStyle().ScrollbarSize : 0)); if (_config.ShowAllAutomatedApplicationRules) ImUtf8.TableSetupColumn("Application"u8, ImGuiTableColumnFlags.WidthFixed, 3 * ImGui.GetFrameHeight() + 4 * ImGuiHelpers.GlobalScale); @@ -205,8 +206,8 @@ public class SetPanel( if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), new Vector2(ImGui.GetFrameHeight()), tt, !keyValid, true)) _endAction = () => _manager.DeleteDesign(Selection, idx); ImGui.TableNextColumn(); - ImUtf8.Selectable($"#{idx + 1:D2}"); - DrawDragDrop(Selection, idx); + DrawSelectable(idx, design.Design); + ImGui.TableNextColumn(); DrawRandomEditing(Selection, design, idx); _designCombo.Draw(Selection, design, idx); @@ -243,6 +244,44 @@ public class SetPanel( _endAction = null; } + private void DrawSelectable(int idx, IDesignStandIn design) + { + var highlight = 0u; + var sb = new StringBuilder(); + if (design is Design d) + { + var count = design.AllLinks(true).Count(); + if (count > 1) + { + sb.AppendLine($"This design contains {count - 1} links to other designs."); + highlight = ColorId.HeaderButtons.Value(); + } + + count = d.AssociatedMods.Count; + if (count > 0) + { + sb.AppendLine($"This design contains {count} mod associations."); + highlight = ColorId.ModdedItemMarker.Value(); + } + + count = design.GetMaterialData().Count(p => p.Item2.Enabled); + if (count > 0) + { + sb.AppendLine($"This design contains {count} enabled advanced dyes."); + highlight = ColorId.AdvancedDyeActive.Value(); + } + } + + using (ImRaii.PushColor(ImGuiCol.Text, highlight, highlight != 0)) + { + ImUtf8.Selectable($"#{idx + 1:D2}"); + } + + ImUtf8.HoverTooltip($"{sb}"); + + DrawDragDrop(Selection, idx); + } + private int _tmpGearset = int.MaxValue; private int _whichIndex = -1; From 773682838e553e966d0dd75e0294113c8e54f305 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 9 Mar 2025 13:37:27 +0100 Subject: [PATCH 240/401] Make customize buttons not change advanced customization to On by default. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 9fed566..04e51ce 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -386,7 +386,7 @@ public class DesignPanel if (equip is null && customize is null) return; - _manager.ChangeApplyMulti(_selector.Selected!, equip, customize, equip, customize, null, equip, equip, equip); + _manager.ChangeApplyMulti(_selector.Selected!, equip, customize, equip, customize.HasValue && !customize.Value ? false : null, null, equip, equip, equip); if (equip.HasValue) { _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.HatState, equip.Value); diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index e0523f7..2235160 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -454,7 +454,7 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e foreach (var design in selector.SelectedPaths.OfType().Select(l => l.Value)) { - editor.ChangeApplyMulti(design, equip, customize, equip, customize, null, equip, equip, equip); + editor.ChangeApplyMulti(design, equip, customize, equip, customize.HasValue && !customize.Value ? false : null, null, equip, equip, equip); if (equip.HasValue) { editor.ChangeApplyMeta(design, MetaIndex.HatState, equip.Value); From e93c3b7bb8872d73a68362190112789dde0825c1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 9 Mar 2025 23:12:21 +0100 Subject: [PATCH 241/401] Update submodules. --- OtterGui | 2 +- Penumbra.GameData | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OtterGui b/OtterGui index c347d29..13f1a90 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit c347d29d980b0191d1d071170cf2ec229e3efdcf +Subproject commit 13f1a90b88d2b8572480748a209f957b70d6a46f diff --git a/Penumbra.GameData b/Penumbra.GameData index a21c146..96163f7 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit a21c146790b370bd58b0f752385ae153f7e769c0 +Subproject commit 96163f79e13c7d52cc36cdd82ab4e823763f4f31 From 3dee511b9adb9a1da98442619d9e8093dab0caa5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 9 Mar 2025 23:13:33 +0100 Subject: [PATCH 242/401] Update some obsoletes. --- Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs | 2 +- Glamourer/Interop/InventoryService.cs | 2 +- Glamourer/Unlocks/ItemUnlockManager.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs index b021656..f57a57e 100644 --- a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs @@ -23,7 +23,7 @@ public unsafe class InventoryPanel : IGameDataDrawer ImGuiUtil.CopyOnClickSelectable($"0x{(ulong)inventory:X}"); var equip = inventory->GetInventoryContainer(InventoryType.EquippedItems); - if (equip == null || equip->Loaded == 0) + if (equip == null || equip->IsLoaded) return; ImGuiUtil.CopyOnClickSelectable($"0x{(ulong)equip:X}"); diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 4b98d46..c30ae06 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -182,7 +182,7 @@ public sealed unsafe class InventoryService : IDisposable, IRequiredService // Invoked after calling Original, so the item is already moved. var inventory = manager->GetInventoryContainer(targetContainer); - if (inventory == null || inventory->Loaded == 0 || inventory->Size <= targetSlot) + if (inventory == null || inventory->IsLoaded || inventory->Size <= targetSlot) return false; var item = inventory->GetInventorySlot((int)targetSlot); diff --git a/Glamourer/Unlocks/ItemUnlockManager.cs b/Glamourer/Unlocks/ItemUnlockManager.cs index 0fc1675..6708267 100644 --- a/Glamourer/Unlocks/ItemUnlockManager.cs +++ b/Glamourer/Unlocks/ItemUnlockManager.cs @@ -168,7 +168,7 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionaryGetInventoryContainer(type); - if (container != null && container->Loaded != 0 && _currentInventoryIndex < container->Size) + if (container != null && container->IsLoaded && _currentInventoryIndex < container->Size) { Glamourer.Log.Excessive($"[UnlockScanner] Scanning {_currentInventory} {type} {_currentInventoryIndex}/{container->Size}."); var item = container->GetInventorySlot(_currentInventoryIndex++); From 381b2a1b8b198f1569b23139e225f738842f2731 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 9 Mar 2025 23:14:19 +0100 Subject: [PATCH 243/401] 1.3.7.0 --- Glamourer/Gui/GlamourerChangelog.cs | 63 +++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 4c8b365..7033fdd 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -40,6 +40,7 @@ public class GlamourerChangelog Add1_3_4_0(Changelog); Add1_3_5_0(Changelog); Add1_3_6_0(Changelog); + Add1_3_7_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -60,32 +61,67 @@ public class GlamourerChangelog } } + private static void Add1_3_7_0(Changelog log) + => log.NextVersion("Version 1.3.7.0") + .RegisterImportant( + "The option to disable advanced customizations or advanced dyes has been removed. The functionality can no longer be disabled entirely, you can just decide not to use it, and to hide it.") + .RegisterHighlight( + "You can now configure which panels (like Customization, Equipment, Advanced Customization etc.) are displayed at all, and which are expanded by default. This does not disable any functionality.") + .RegisterHighlight( + "The Unlocks tab now shows whether items are modded in the currently selected collection in Penumbra in Overview mode and shows and can filter and sort for it in Detailed mode.") + .RegisterEntry("Added an optional button to the Quick Design Bar to reset all temporary settings applied by Glamourer.") + .RegisterHighlight( + "Any existing advanced dyes will now be highlighted on the corresponding Advanced Dye buttons in the actors panel and on the corresponding equip slot name in the design panel.") + .RegisterEntry("This also affects currently inactive advanced dyes, which can now be manually removed on the inactive materials.", + 1) + .RegisterHighlight( + "In the design list of an automation set, the design indices are now highlighted if a design contains advanced dyes, mod associations, or links to other designs.") + .RegisterHighlight("Some quality of life improvements:") + .RegisterEntry("Added some buttons for some application rule presets to the Application Rules panel.", 1) + .RegisterEntry("Added some buttons to enable, disable or delete all advanced dyes in a design.", 1) + .RegisterEntry("Some of those buttons are also available in multi-design selection to apply to all selected designs at once.", 1) + .RegisterEntry( + "A copied material color set from Penumbra should now be able to be imported into a advanced dye color set, as well as the other way around.") + .RegisterEntry( + "Automatically applied character updates when applying a design with mod associations and temporary settings are now skipped to prevent some issues with GPose. This should not affect anything else.") + .RegisterEntry("Glamourer now differentiates between temporary settings applied through manual or automatic application."); + + private static void Add1_3_6_0(Changelog log) => log.NextVersion("Version 1.3.6.0") .RegisterHighlight("Added some new multi design selection functionality to change design settings of many designs at once.") .RegisterEntry("Also added the number of selected designs and folders to the multi design selection display.", 1) .RegisterEntry("Glamourer will now use temporary settings when saving mod associations, if they exist in Penumbra.") - .RegisterEntry("Actually added the checkbox to reset all temporary settings to Automation Sets (functionality was there, just not exposed to the UI...).") - .RegisterEntry("Adapted the behavior for identified copies of characters that have a different state than the character itself to deal with the associated Penumbra changes.") - .RegisterEntry("Added '/glamour resetdesign' as a command, that re-applies automation but resets randomly chosen designs (Thanks Diorik).") + .RegisterEntry( + "Actually added the checkbox to reset all temporary settings to Automation Sets (functionality was there, just not exposed to the UI...).") + .RegisterEntry( + "Adapted the behavior for identified copies of characters that have a different state than the character itself to deal with the associated Penumbra changes.") + .RegisterEntry( + "Added '/glamour resetdesign' as a command, that re-applies automation but resets randomly chosen designs (Thanks Diorik).") .RegisterEntry("All existing facepaints should now be accepted in designs, including NPC facepaints.") - .RegisterEntry("Overwriting a design with your characters current state will now discard any prior advanced dyes and only add those from the current state.") + .RegisterEntry( + "Overwriting a design with your characters current state will now discard any prior advanced dyes and only add those from the current state.") .RegisterEntry("Fixed an issue with racial mount and accessory scaling when changing zones on a changed race.") .RegisterEntry("Fixed issues with the detection of gear set changes in certain circumstances (Thanks Cordelia).") .RegisterEntry("Fixed an issue with the Force to Inherit checkbox in mod associations.") - .RegisterEntry("Added a new IPC event that fires only when Glamourer finalizes its current changes to a character (for/from Cordelia).") + .RegisterEntry( + "Added a new IPC event that fires only when Glamourer finalizes its current changes to a character (for/from Cordelia).") .RegisterEntry("Added new IPC to set a meta flag on actors. (for/from Cordelia)."); private static void Add1_3_5_0(Changelog log) => log.NextVersion("Version 1.3.5.0") - .RegisterHighlight("Added the usage of the new Temporary Mod Setting functionality from Penumbra to apply mod associations. This is on by default but can be turned back to permanent changes in the settings.") + .RegisterHighlight( + "Added the usage of the new Temporary Mod Setting functionality from Penumbra to apply mod associations. This is on by default but can be turned back to permanent changes in the settings.") .RegisterEntry("Designs now have a setting to always reset all prior temporary settings made by Glamourer on application.", 1) - .RegisterEntry("Automation Sets also have a setting to do this, independently of the designs contained in them.", 1) + .RegisterEntry("Automation Sets also have a setting to do this, independently of the designs contained in them.", 1) .RegisterHighlight("More NPC customization options should now be accepted as valid for designs, regardless of clan/gender.") .RegisterHighlight("The 'Apply' chat command had the currently selected design and the current quick bar design added as choices.") - .RegisterEntry("The application buttons for designs, NPCs or actors should now stick at the top of their respective panels even when scrolling down.") + .RegisterEntry( + "The application buttons for designs, NPCs or actors should now stick at the top of their respective panels even when scrolling down.") .RegisterHighlight("Randomly chosen designs should now stay across loading screens or redrawing. (1.3.4.3)") - .RegisterEntry("In automation, Random designs now have an option to always choose another design, including during loading screens or redrawing.", 1) + .RegisterEntry( + "In automation, Random designs now have an option to always choose another design, including during loading screens or redrawing.", + 1) .RegisterEntry("Fixed an issue where disabling auto designs did not work as expected.") .RegisterEntry("Fixed the inversion of application flags in IPC calls.") .RegisterEntry("Fixed an issue with the scaling of the Advanced Dye popup with increased font sizes.") @@ -110,15 +146,18 @@ public class GlamourerChangelog => log.NextVersion("Version 1.3.2.0") .RegisterEntry("Fixed an issue with weapon hiding when leaving GPose or changing zones.") .RegisterEntry("Added support for unnamed items to be previewed from Penumbra.") - .RegisterEntry("Item combos filters now check if the model string starts with the current filter, instead of checking if the primary ID contains the current filter.") + .RegisterEntry( + "Item combos filters now check if the model string starts with the current filter, instead of checking if the primary ID contains the current filter.") .RegisterEntry("Improved the handling of bonus items (glasses) in designs.") .RegisterEntry("Imported .chara files now import bonus items.") - .RegisterEntry("Added a Debug Data rider in the Actors tab that is visible if Debug Mode is enabled and (currently) contains some IDs.") + .RegisterEntry( + "Added a Debug Data rider in the Actors tab that is visible if Debug Mode is enabled and (currently) contains some IDs.") .RegisterEntry("Fixed bonus items not reverting correctly in some cases.") .RegisterEntry("Fixed an issue with the RNG in cheat codes and events skipping some possible entries.") .RegisterEntry("Fixed the chat log context menu for glamourer Try-On.") .RegisterEntry("Fixed some issues with cheat code sets.") - .RegisterEntry("Made the popped out Advanced Dye Window and Unlocks Window non-docking as that caused issues when docked to the main Glamourer window.") + .RegisterEntry( + "Made the popped out Advanced Dye Window and Unlocks Window non-docking as that caused issues when docked to the main Glamourer window.") .RegisterEntry("Refreshed NPC name associations.") .RegisterEntry("Removed a now useless cheat code.") .RegisterEntry("Added API for Bonus Items. (1.3.1.1)"); From 99a8e1e8c5613bafb1ce9cf6f04d7dfe575b6d7b Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 9 Mar 2025 22:17:20 +0000 Subject: [PATCH 244/401] [CI] Updating repo.json for 1.3.7.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 18c30c3..cc9fb7a 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.6.0", - "TestingAssemblyVersion": "1.3.6.6", + "AssemblyVersion": "1.3.7.0", + "TestingAssemblyVersion": "1.3.7.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.6.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.3.6.6/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 25517525c90a8a16992577f6a150231357506db6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 10 Mar 2025 23:55:24 +0100 Subject: [PATCH 245/401] Keep temporary mod settings manually applied by Glamourer when redrawing with automation changes. --- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 4 +- .../Interop/Penumbra/ModSettingApplier.cs | 4 +- Glamourer/Interop/Penumbra/PenumbraService.cs | 41 +++++++++++++++---- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index f172735..80000d9 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -87,7 +87,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect public void ApplyAll() { foreach (var (mod, settings) in selector.Selected!.AssociatedMods) - penumbra.SetMod(mod, settings, StateSource.Manual); + penumbra.SetMod(mod, settings, StateSource.Manual, false); } private void DrawTable() @@ -222,7 +222,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect if (ImGuiUtil.DrawDisabledButton("Apply", new Vector2(ImGui.GetContentRegionAvail().X, 0), string.Empty, !penumbra.Available)) { - var text = penumbra.SetMod(mod, settings, StateSource.Manual); + var text = penumbra.SetMod(mod, settings, StateSource.Manual, false); if (text.Length > 0) Glamourer.Messager.NotificationMessage(text, NotificationType.Warning, false); } diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index 82a840c..1d39f79 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -39,7 +39,7 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip var index = ResetOldSettings(collection, actor, source, design.ResetTemporarySettings, respectManual); foreach (var (mod, setting) in design.AssociatedMods) { - var message = penumbra.SetMod(mod, setting, source, collection, index); + var message = penumbra.SetMod(mod, setting, source, respectManual, collection, index); if (message.Length > 0) Glamourer.Log.Verbose($"[Mod Applier] Error applying mod settings: {message}"); else @@ -62,7 +62,7 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip var index = ResetOldSettings(collection, actor, source, resetOther, true); foreach (var (mod, setting) in settings) { - var message = penumbra.SetMod(mod, setting, source, collection, index); + var message = penumbra.SetMod(mod, setting, source, false, collection, index); if (message.Length > 0) messages.Add($"Error applying mod settings: {message}"); else diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index d9b4d27..e04af7c 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -41,9 +41,9 @@ public class PenumbraService : IDisposable public const int RequiredPenumbraFeatureVersionTemp3 = 6; public const int RequiredPenumbraFeatureVersionTemp4 = 7; - private const int KeyFixed = -1610; - private const string NameFixed = "Glamourer (Automation)"; - private const int KeyManual = -6160; + private const int KeyFixed = -1610; + private const string NameFixed = "Glamourer (Automation)"; + private const int KeyManual = -6160; private const string NameManual = "Glamourer (Manually)"; private readonly IDalamudPluginInterface _pluginInterface; @@ -77,6 +77,7 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings? _queryTemporaryModSettings; + private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer? _queryTemporaryModSettingsPlayer; private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; private global::Penumbra.Api.IpcSubscribers.GetChangedItems? _getChangedItems; private IReadOnlyList<(string ModDirectory, IReadOnlyDictionary ChangedItems)>? _changedItems; @@ -280,7 +281,8 @@ public class PenumbraService : IDisposable /// Try to set all mod settings as desired. Only sets when the mod should be enabled. /// If it is disabled, ignore all other settings. /// - public string SetMod(Mod mod, ModSettings settings, StateSource source, Guid? collectionInput = null, ObjectIndex? index = null) + public string SetMod(Mod mod, ModSettings settings, StateSource source, bool respectManual, Guid? collectionInput = null, + ObjectIndex? index = null) { if (!Available) return "Penumbra is not available."; @@ -290,7 +292,7 @@ public class PenumbraService : IDisposable { var collection = collectionInput ?? _currentCollection!.Invoke(ApiCollectionType.Current)!.Value.Id; if (_config.UseTemporarySettings && _setTemporaryModSettings != null) - SetModTemporary(sb, mod, settings, collection, index, source); + SetModTemporary(sb, mod, settings, collection, respectManual, index, source); else SetModPermanent(sb, mod, settings, collection); @@ -326,9 +328,29 @@ public class PenumbraService : IDisposable public (string ModDirectory, string ModName)[] CheckCurrentChangedItem(string changedItem) => _checkCurrentChangedItems?.Invoke(changedItem) ?? []; - private void SetModTemporary(StringBuilder sb, Mod mod, ModSettings settings, Guid collection, ObjectIndex? index, StateSource source) + private void SetModTemporary(StringBuilder sb, Mod mod, ModSettings settings, Guid collection, bool respectManual, ObjectIndex? index, + StateSource source) { var (key, name) = source.IsFixed() ? (KeyFixed, NameFixed) : (KeyManual, NameManual); + // Check for existing manual settings and do not apply fixed on top of them if respecting manual changes. + if (key is KeyFixed && respectManual) + { + var existingSource = string.Empty; + var ec = index.HasValue + ? _queryTemporaryModSettingsPlayer?.Invoke(index.Value.Index, mod.DirectoryName, out _, + out existingSource, key, mod.Name) + ?? PenumbraApiEc.InvalidArgument + : _queryTemporaryModSettings?.Invoke(collection, mod.DirectoryName, out _, + out existingSource, key, mod.Name) + ?? PenumbraApiEc.InvalidArgument; + if (ec is PenumbraApiEc.Success && existingSource is NameManual) + { + Glamourer.Log.Debug( + $"Skipped applying mod settings for [{mod.Name}] through automation because manual settings from Glamourer existed."); + return; + } + } + var ex = settings.Remove ? index.HasValue ? _removeTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, key) @@ -391,9 +413,7 @@ public class PenumbraService : IDisposable : _setModSettings!.Invoke(collection, mod.DirectoryName, setting, list); switch (ec) { - case PenumbraApiEc.OptionGroupMissing: - sb.AppendLine($"Could not find the option group {setting} in mod {mod.Name}."); - break; + case PenumbraApiEc.OptionGroupMissing: sb.AppendLine($"Could not find the option group {setting} in mod {mod.Name}."); break; case PenumbraApiEc.OptionMissing: sb.AppendLine($"Could not find all desired options in the option group {setting} in mod {mod.Name}."); break; @@ -527,6 +547,8 @@ public class PenumbraService : IDisposable if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) { _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); + _queryTemporaryModSettingsPlayer = + new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer(_pluginInterface); if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp3) { _getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface); @@ -586,6 +608,7 @@ public class PenumbraService : IDisposable _removeAllTemporaryModSettings = null; _removeAllTemporaryModSettingsPlayer = null; _queryTemporaryModSettings = null; + _queryTemporaryModSettingsPlayer = null; _getChangedItems = null; _changedItems = null; _checkCurrentChangedItems = null; From 750d4f9eca78f1dae713065d099780a1bade9789 Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 10 Mar 2025 22:59:41 +0000 Subject: [PATCH 246/401] [CI] Updating repo.json for 1.3.7.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index cc9fb7a..f2b213e 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.7.0", - "TestingAssemblyVersion": "1.3.7.0", + "AssemblyVersion": "1.3.7.1", + "TestingAssemblyVersion": "1.3.7.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From fd0d761b9270698557e13cda343015fa8e30016f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 11 Mar 2025 00:58:00 +0100 Subject: [PATCH 247/401] Fix small issue with invisible customizations applying. --- Glamourer/Automation/ApplicationType.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Glamourer/Automation/ApplicationType.cs b/Glamourer/Automation/ApplicationType.cs index 8871a0e..58f296e 100644 --- a/Glamourer/Automation/ApplicationType.cs +++ b/Glamourer/Automation/ApplicationType.cs @@ -47,7 +47,13 @@ public static class ApplicationTypeExtensions } public static ApplicationCollection ApplyWhat(this ApplicationType type, IDesignStandIn designStandIn) - => designStandIn is not DesignBase design ? type.Collection() : type.Collection().Restrict(design.Application); + { + if(designStandIn is not DesignBase design) + return type.Collection(); + var ret = type.Collection().Restrict(design.Application); + ret.CustomizeRaw = ret.CustomizeRaw.FixApplication(design.CustomizeSet); + return ret; + } public const EquipFlag WeaponFlags = EquipFlag.Mainhand | EquipFlag.Offhand; public const EquipFlag ArmorFlags = EquipFlag.Head | EquipFlag.Body | EquipFlag.Hands | EquipFlag.Legs | EquipFlag.Feet; From 18ff905746225c81f42ae4d021a7db45d884f1de Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 11 Mar 2025 18:06:22 +0100 Subject: [PATCH 248/401] Add a chat command to clear temporary settings made by Glamourer. --- Glamourer/Services/CommandService.cs | 90 ++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 4b8ea3d..fa6e63f 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -41,12 +41,13 @@ public class CommandService : IDisposable, IApiService private readonly DesignManager _designManager; private readonly DesignConverter _converter; private readonly DesignResolver _resolver; + private readonly PenumbraService _penumbra; public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorManager actors, ObjectManager objects, AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter, DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager, Configuration config, ModSettingApplier modApplier, ItemManager items, RandomDesignGenerator randomDesign, CustomizeService customizeService, DesignFileSystemSelector designSelector, - QuickDesignCombo quickDesignCombo, DesignResolver resolver) + QuickDesignCombo quickDesignCombo, DesignResolver resolver, PenumbraService penumbra) { _commands = commands; _mainWindow = mainWindow; @@ -63,6 +64,7 @@ public class CommandService : IDisposable, IApiService _items = items; _customizeService = customizeService; _resolver = resolver; + _penumbra = penumbra; _commands.AddHandler(MainCommandString, new CommandInfo(OnGlamourer) { HelpMessage = "Open or close the Glamourer window." }); _commands.AddHandler(ApplyCommandString, @@ -122,8 +124,9 @@ public class CommandService : IDisposable, IApiService "reapply" => ReapplyState(argument), "revert" => Revert(argument), "reapplyautomation" => ReapplyAutomation(argument, "reapplyautomation", false, false), - "reverttoautomation" => ReapplyAutomation(argument, "reverttoautomation", true, false), - "resetdesign" => ReapplyAutomation(argument, "resetdesign", false, true), + "reverttoautomation" => ReapplyAutomation(argument, "reverttoautomation", true, false), + "resetdesign" => ReapplyAutomation(argument, "resetdesign", false, true), + "clearsettings" => ClearSettings(argument), "automation" => SetAutomation(argument), "copy" => CopyState(argument), "save" => SaveState(argument), @@ -154,6 +157,8 @@ public class CommandService : IDisposable, IApiService "Reverts a given character to its supposed state using automated designs. Use without arguments for help.").BuiltString); _chat.Print(new SeStringBuilder().AddCommand("resetdesign", "Reapplies the current automation and resets the random design. Use without arguments for help.").BuiltString); + _chat.Print(new SeStringBuilder() + .AddCommand("clearsettings", "Clears all temporary settings applied by Glamourer. Use without arguments for help.").BuiltString); _chat.Print(new SeStringBuilder() .AddCommand("copy", "Copy the current state of a character to clipboard. Use without arguments for help.").BuiltString); _chat.Print(new SeStringBuilder() @@ -168,6 +173,62 @@ public class CommandService : IDisposable, IApiService return true; } + private bool ClearSettings(string argument) + { + var argumentList = argument.Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + if (argumentList.Length < 1) + { + _chat.Print(new SeStringBuilder().AddText("Use with /glamour clearsettings ").AddGreen("[Character Identifier]").AddText(" | ") + .AddPurple("").AddText(" | ").AddBlue("").BuiltString); + PlayerIdentifierHelp(false, true); + _chat.Print(new SeStringBuilder().AddText(" 》 The character identifier specifies the collection to clear settings from. It also accepts '").AddGreen("all").AddText("' to clear all collections.").BuiltString); + _chat.Print(new SeStringBuilder().AddText(" 》 The booleans are optional and default to 'true', the ").AddPurple("first") + .AddText(" determines whether ").AddPurple("manually").AddText(" applied settings are cleared, the ").AddBlue("second") + .AddText(" determines whether ").AddBlue("automatically").AddText(" applied settings are cleared.").BuiltString); + return false; + } + + var clearManual = true; + var clearAutomatic = true; + if (argumentList.Length > 1 && bool.TryParse(argumentList[1], out var m)) + clearManual = m; + if (argumentList.Length > 2 && bool.TryParse(argumentList[2], out var a)) + clearAutomatic = a; + + if (!clearManual && !clearAutomatic) + return true; + + if (argumentList[0].ToLowerInvariant() is "all") + { + _penumbra.ClearAllTemporarySettings(clearAutomatic, clearManual); + return true; + } + + if (!IdentifierHandling(argumentList[0], out var identifiers, false, true)) + return false; + + var set = new HashSet(); + foreach (var id in identifiers) + { + if (!_objects.TryGetValue(id, out var data) || !data.Valid) + continue; + + foreach (var obj in data.Objects) + { + var guid = _penumbra.GetActorCollection(obj, out _); + if (!set.Add(guid)) + continue; + + if (clearManual) + _penumbra.RemoveAllTemporarySettings(guid, StateSource.Manual); + if (clearAutomatic) + _penumbra.RemoveAllTemporarySettings(guid, StateSource.Fixed); + } + } + + return true; + } + private bool SetAutomation(string arguments) { var argumentList = arguments.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); @@ -283,21 +344,11 @@ public class CommandService : IDisposable, IApiService { switch (char.ToLowerInvariant(character)) { - case 'c': - applicationFlags |= ApplicationType.Customizations; - break; - case 'e': - applicationFlags |= ApplicationType.Armor; - break; - case 'a': - applicationFlags |= ApplicationType.Accessories; - break; - case 'd': - applicationFlags |= ApplicationType.GearCustomization; - break; - case 'w': - applicationFlags |= ApplicationType.Weapons; - break; + case 'c': applicationFlags |= ApplicationType.Customizations; break; + case 'e': applicationFlags |= ApplicationType.Armor; break; + case 'a': applicationFlags |= ApplicationType.Accessories; break; + case 'd': applicationFlags |= ApplicationType.GearCustomization; break; + case 'w': applicationFlags |= ApplicationType.Weapons; break; default: _chat.Print(new SeStringBuilder().AddText("The value ").AddPurple(split2[1], true) .AddText(" is not a valid set of application flags.").BuiltString); @@ -694,7 +745,8 @@ public class CommandService : IDisposable, IApiService if (!applyMods || design is not Design d) return; - var (messages, appliedMods, _, name, overridden) = _modApplier.ApplyModSettings(d.AssociatedMods, actor, StateSource.Manual, d.ResetTemporarySettings); + var (messages, appliedMods, _, name, overridden) = + _modApplier.ApplyModSettings(d.AssociatedMods, actor, StateSource.Manual, d.ResetTemporarySettings); foreach (var message in messages) Glamourer.Messager.Chat.Print($"Error applying mod settings: {message}"); From 22babad7896ac3ae227087e8dbafce45a0420a28 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 27 Mar 2025 18:11:08 +0100 Subject: [PATCH 249/401] Update. --- .github/workflows/release.yml | 2 +- .github/workflows/test_release.yml | 2 +- Glamourer.Api | 2 +- Glamourer.sln | 48 ++++---- Glamourer/Glamourer.csproj | 64 +---------- Glamourer/Glamourer.json | 2 +- Glamourer/Gui/DesignQuickBar.cs | 2 +- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 2 +- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 2 +- Glamourer/Interop/Material/DirectXService.cs | 11 +- Glamourer/Interop/Material/MaterialService.cs | 12 +- Glamourer/Interop/Material/PrepareColorSet.cs | 2 +- Glamourer/Unlocks/CustomizeUnlockManager.cs | 4 +- Glamourer/packages.lock.json | 108 ++++++++++++++++++ OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- 18 files changed, 160 insertions(+), 111 deletions(-) create mode 100644 Glamourer/packages.lock.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bac600a..18435ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '8.x.x' + dotnet-version: '9.x.x' - name: Restore dependencies run: dotnet restore - name: Download Dalamud diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml index b9d3672..6316776 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '8.x.x' + dotnet-version: '9.x.x' - name: Restore dependencies run: dotnet restore - name: Download Dalamud diff --git a/Glamourer.Api b/Glamourer.Api index 9f9bdf0..5e5c867 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 9f9bdf0873899d2e45fabaca446bb1624303b418 +Subproject commit 5e5c867a095eecac0dd494b30a33298a65e46426 diff --git a/Glamourer.sln b/Glamourer.sln index 4ac3356..78c32ec 100644 --- a/Glamourer.sln +++ b/Glamourer.sln @@ -29,30 +29,30 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {01EB903D-871F-4285-A8CF-6486561D5B5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01EB903D-871F-4285-A8CF-6486561D5B5B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01EB903D-871F-4285-A8CF-6486561D5B5B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01EB903D-871F-4285-A8CF-6486561D5B5B}.Release|Any CPU.Build.0 = Release|Any CPU - {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Release|Any CPU.Build.0 = Release|Any CPU - {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Release|Any CPU.Build.0 = Release|Any CPU - {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Release|Any CPU.Build.0 = Release|Any CPU - {EF233CE2-F243-449E-BE05-72B9D110E419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EF233CE2-F243-449E-BE05-72B9D110E419}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EF233CE2-F243-449E-BE05-72B9D110E419}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EF233CE2-F243-449E-BE05-72B9D110E419}.Release|Any CPU.Build.0 = Release|Any CPU - {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Release|Any CPU.Build.0 = Release|Any CPU + {01EB903D-871F-4285-A8CF-6486561D5B5B}.Debug|Any CPU.ActiveCfg = Debug|x64 + {01EB903D-871F-4285-A8CF-6486561D5B5B}.Debug|Any CPU.Build.0 = Debug|x64 + {01EB903D-871F-4285-A8CF-6486561D5B5B}.Release|Any CPU.ActiveCfg = Release|x64 + {01EB903D-871F-4285-A8CF-6486561D5B5B}.Release|Any CPU.Build.0 = Release|x64 + {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Debug|Any CPU.ActiveCfg = Debug|x64 + {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Debug|Any CPU.Build.0 = Debug|x64 + {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Release|Any CPU.ActiveCfg = Release|x64 + {29C589ED-7AF1-4DE9-82EF-33EBEF19AAFA}.Release|Any CPU.Build.0 = Release|x64 + {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Debug|Any CPU.ActiveCfg = Debug|x64 + {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Debug|Any CPU.Build.0 = Debug|x64 + {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Release|Any CPU.ActiveCfg = Release|x64 + {C0A2FAF8-C3AE-4B7B-ADDB-4AAC1A855428}.Release|Any CPU.Build.0 = Release|x64 + {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Debug|Any CPU.ActiveCfg = Debug|x64 + {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Debug|Any CPU.Build.0 = Debug|x64 + {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Release|Any CPU.ActiveCfg = Release|x64 + {AAFE22E7-0F9B-462A-AAA3-6EE3B268F3F8}.Release|Any CPU.Build.0 = Release|x64 + {EF233CE2-F243-449E-BE05-72B9D110E419}.Debug|Any CPU.ActiveCfg = Debug|x64 + {EF233CE2-F243-449E-BE05-72B9D110E419}.Debug|Any CPU.Build.0 = Debug|x64 + {EF233CE2-F243-449E-BE05-72B9D110E419}.Release|Any CPU.ActiveCfg = Release|x64 + {EF233CE2-F243-449E-BE05-72B9D110E419}.Release|Any CPU.Build.0 = Release|x64 + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Debug|Any CPU.ActiveCfg = Debug|x64 + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Debug|Any CPU.Build.0 = Debug|x64 + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Release|Any CPU.ActiveCfg = Release|x64 + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Release|Any CPU.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 9a1b95b..5fa2c5d 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -1,38 +1,13 @@ - + - net8.0-windows - preview - x64 Glamourer Glamourer 9.0.0.1 9.0.0.1 - SoftOtter Glamourer - Copyright © 2023 - true - Library + Copyright © 2025 4 - true - enable bin\$(Configuration)\ - $(MSBuildWarningsAsMessages);MSB3277 - true - false - false - - - - true - full - false - DEBUG;TRACE - - - - pdbonly - true - TRACE @@ -47,41 +22,6 @@
- - $(AppData)\XIVLauncher\addon\Hooks\dev\ - - - - - $(DalamudLibPath)Dalamud.dll - False - - - $(DalamudLibPath)FFXIVClientStructs.dll - False - - - $(DalamudLibPath)ImGui.NET.dll - False - - - $(DalamudLibPath)ImGuiScene.dll - False - - - $(DalamudLibPath)Lumina.dll - False - - - $(DalamudLibPath)Lumina.Excel.dll - False - - - $(DalamudLibPath)Newtonsoft.Json.dll - False - - - diff --git a/Glamourer/Glamourer.json b/Glamourer/Glamourer.json index 1e9edf7..3127d7d 100644 --- a/Glamourer/Glamourer.json +++ b/Glamourer/Glamourer.json @@ -8,7 +8,7 @@ "AssemblyVersion": "9.0.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 11, + "DalamudApiLevel": 12, "ImageUrls": null, "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/master/images/icon.png" } \ No newline at end of file diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index d2dba01..c9ace0c 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -173,7 +173,7 @@ public sealed class DesignQuickBar : Window, IDisposable available |= 2; _tooltipBuilder.Append("Right-Click: Apply ") .Append(design.ResolveName(_config.Ephemeral.IncognitoMode)) - .Append(" to {_targetIdentifier}."); + .Append(" to ").Append(_config.Ephemeral.IncognitoMode ? _targetIdentifier.Incognito(null) : _targetIdentifier.ToName()); } if (available == 0) diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index e15872b..ec25378 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -94,7 +94,7 @@ public sealed unsafe class AdvancedDyePopup( : ByteString.FromSpanUnsafe(materialHandle->ResourceHandle.FileName.AsSpan(), true).ToString(); var gamePath = modelHandle == null ? string.Empty - : modelHandle->GetMaterialFileNameBySlotAsString(index.MaterialIndex); + : modelHandle->GetMaterialFileNameBySlot(index.MaterialIndex).ToString(); return (path, gamePath); } diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index 68ba18e..cf7e1f3 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -29,7 +29,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable .Select(p => new KeyValuePair(p.First, p.Second)); public ChangedItemType LastType { get; private set; } = ChangedItemType.None; - public uint LastId { get; private set; } = 0; + public uint LastId { get; private set; } public DateTime LastTooltip { get; private set; } = DateTime.MinValue; public DateTime LastClick { get; private set; } = DateTime.MinValue; diff --git a/Glamourer/Interop/Material/DirectXService.cs b/Glamourer/Interop/Material/DirectXService.cs index a809a34..8006a2f 100644 --- a/Glamourer/Interop/Material/DirectXService.cs +++ b/Glamourer/Interop/Material/DirectXService.cs @@ -1,12 +1,9 @@ using Dalamud.Plugin.Services; -using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; -using Lumina.Data.Files; using OtterGui.Services; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.String.Functions; using SharpGen.Runtime; using Vortice.Direct3D11; -using Vortice.DXGI; using MapFlags = Vortice.Direct3D11.MapFlags; using Texture = FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.Texture; @@ -14,7 +11,7 @@ namespace Glamourer.Interop.Material; public unsafe class DirectXService(IFramework framework) : IService { - private readonly object _lock = new(); + private readonly object _lock = new(); private readonly ConcurrentDictionary _textures = []; /// Generate a color table the way the game does inside the original texture, and release the original. @@ -32,9 +29,7 @@ public unsafe class DirectXService(IFramework framework) : IService lock (_lock) { - using var texture = new SafeTextureHandle(Device.Instance()->CreateTexture2D(textureSize, 1, - (uint)TexFile.TextureFormat.R16G16B16A16F, - (uint)(TexFile.Attribute.TextureType2D | TexFile.Attribute.Managed | TexFile.Attribute.Immutable), 7), false); + using var texture = new SafeTextureHandle(MaterialService.CreateColorTableTexture(), false); if (texture.IsInvalid) return false; @@ -119,7 +114,7 @@ public unsafe class DirectXService(IFramework framework) : IService { var desc = resource.Description1; - if (desc.Format is not Format.R16G16B16A16_Float + if (desc.Format is not Vortice.DXGI.Format.R16G16B16A16_Float || desc.Width != MaterialService.TextureWidth || desc.Height != MaterialService.TextureHeight || map.DepthPitch != map.RowPitch * desc.Height) diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index f7ffe0f..a5f2b36 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -9,18 +9,24 @@ namespace Glamourer.Interop.Material; public static unsafe class MaterialService { + private const TextureFormat Format = TextureFormat.R16G16B16A16_FLOAT; + private const TextureFlags Flags = TextureFlags.TextureType2D | TextureFlags.Managed | TextureFlags.Immutable; + public const int TextureWidth = 8; public const int TextureHeight = ColorTable.NumRows; public const int MaterialsPerModel = 10; - public static bool GenerateNewColorTable(in ColorTable.Table colorTable, out Texture* texture) + public static Texture* CreateColorTableTexture() { var textureSize = stackalloc int[2]; textureSize[0] = TextureWidth; textureSize[1] = TextureHeight; + return Device.Instance()->CreateTexture2D(textureSize, 1, Format, Flags, 7); + } - texture = Device.Instance()->CreateTexture2D(textureSize, 1, (uint)TexFile.TextureFormat.R16G16B16A16F, - (uint)(TexFile.Attribute.TextureType2D | TexFile.Attribute.Managed | TexFile.Attribute.Immutable), 7); + public static bool GenerateNewColorTable(in ColorTable.Table colorTable, out Texture* texture) + { + texture = CreateColorTableTexture(); if (texture == null) return false; diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index b44246b..4d1feef 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -133,7 +133,7 @@ public sealed unsafe class PrepareColorSet public static ColorRow.Mode GetMode(MaterialResourceHandle* handle) => handle == null ? ColorRow.Mode.Dawntrail - : handle->ShpkNameSpan.SequenceEqual("characterlegacy.shpk"u8) + : handle->ShpkName.AsSpan().SequenceEqual("characterlegacy.shpk"u8) ? ColorRow.Mode.Legacy : ColorRow.Mode.Dawntrail; diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index 18f3cac..b58385e 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -190,7 +190,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable ? "Eternal Bond" : x.Value.HintItem.ValueNullable?.Name.ExtractText().Replace("Modern Aesthetics - ", string.Empty) ?? string.Empty; - ret.TryAdd(hair, (x.Value.Data, name)); + ret.TryAdd(hair, (x.Value.UnlockLink, name)); } } @@ -201,7 +201,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable { var name = x.Value.HintItem.ValueNullable?.Name.ExtractText().Replace("Modern Cosmetics - ", string.Empty) ?? string.Empty; - ret.TryAdd(paint, (x.Value.Data, name)); + ret.TryAdd(paint, (x.Value.UnlockLink, name)); } } } diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json new file mode 100644 index 0000000..e6f2fe5 --- /dev/null +++ b/Glamourer/packages.lock.json @@ -0,0 +1,108 @@ +{ + "version": 1, + "dependencies": { + "net9.0-windows7.0": { + "DalamudPackager": { + "type": "Direct", + "requested": "[12.0.0, )", + "resolved": "12.0.0", + "contentHash": "J5TJLV3f16T/E2H2P17ClWjtfEBPpq3yxvqW46eN36JCm6wR+EaoaYkqG9Rm5sHqs3/nK/vKjWWyvEs/jhKoXw==" + }, + "DotNet.ReproducibleBuilds": { + "type": "Direct", + "requested": "[1.2.25, )", + "resolved": "1.2.25", + "contentHash": "xCXiw7BCxHJ8pF6wPepRUddlh2dlQlbr81gXA72hdk4FLHkKXas7EH/n+fk5UCA/YfMqG1Z6XaPiUjDbUNBUzg==" + }, + "Vortice.Direct3D11": { + "type": "Direct", + "requested": "[3.4.2-beta, )", + "resolved": "3.4.2-beta", + "contentHash": "CWVMTF7ebylzzXbQXVp5C9UpBB/L+EpX2OxSdb2wlzcsdEmrev/Ith8wVs0WjZ6DbA0WiiybnYAWqB5v0nOO/A==", + "dependencies": { + "SharpGen.Runtime": "2.1.2-beta", + "Vortice.DXGI": "3.4.2-beta" + } + }, + "JetBrains.Annotations": { + "type": "Transitive", + "resolved": "2024.3.0", + "contentHash": "ox5pkeLQXjvJdyAB4b2sBYAlqZGLh3PjSnP1bQNVx72ONuTJ9+34/+Rq91Fc0dG29XG9RgZur9+NcP4riihTug==" + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "9.0.2", + "contentHash": "ZffbJrskOZ40JTzcTyKwFHS5eACSWp2bUQBBApIgGV+es8RaTD4OxUG7XxFr3RIPLXtYQ1jQzF2DjKB5fZn7Qg==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.2" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "9.0.2", + "contentHash": "MNe7GSTBf3jQx5vYrXF0NZvn6l7hUKF6J54ENfAgCO8y6xjN1XUmKKWG464LP2ye6QqDiA1dkaWEZBYnhoZzjg==" + }, + "SharpGen.Runtime": { + "type": "Transitive", + "resolved": "2.1.2-beta", + "contentHash": "nqZAjfEG1jX1ivvdZLsi6Pkt0DiOJyuOgRgldNFsmjXFPhxUbXQibofLSwuDZidL2kkmtTF8qLoRIeqeVdXgYw==" + }, + "SharpGen.Runtime.COM": { + "type": "Transitive", + "resolved": "2.1.2-beta", + "contentHash": "HBCrb6HfnUWx9v5/GjJeBr5DuodZLnHlFQQYXPrQs1Hbe1c6Wd0uCXf+SJp4hW8fQNxjXEu0FgiyHGlA/SRzRw==", + "dependencies": { + "SharpGen.Runtime": "2.1.2-beta" + } + }, + "Vortice.DirectX": { + "type": "Transitive", + "resolved": "3.4.2-beta", + "contentHash": "EwDbemXkmEiDGZVDem25uiEcZBYOMb+wzePuta+M/k2LXrQVGPknZhZUK56+QlHhI+Ducf/d+J75wgBzEjKi2g==", + "dependencies": { + "SharpGen.Runtime": "2.1.2-beta", + "SharpGen.Runtime.COM": "2.1.2-beta", + "Vortice.Mathematics": "1.7.6" + } + }, + "Vortice.DXGI": { + "type": "Transitive", + "resolved": "3.4.2-beta", + "contentHash": "T4S3pp6l/SGJ6SH3ebCbodN/bimGOkIBiIYKeBpVEis7+/ac1XIjyzgSTJ5XsH3o3hSH7DqSbP6Yo6mL9nyFQA==", + "dependencies": { + "SharpGen.Runtime": "2.1.2-beta", + "Vortice.DirectX": "3.4.2-beta" + } + }, + "Vortice.Mathematics": { + "type": "Transitive", + "resolved": "1.7.6", + "contentHash": "W8FNv850lPGxmHphwLyi1qnUlQHZBxh/62EenFJTaY6acPP29Fk0xMQJI60G+YNlsVJb3fSoriuW+ong5sM5UQ==" + }, + "glamourer.api": { + "type": "Project" + }, + "ottergui": { + "type": "Project", + "dependencies": { + "JetBrains.Annotations": "[2024.3.0, )", + "Microsoft.Extensions.DependencyInjection": "[9.0.2, )" + } + }, + "penumbra.api": { + "type": "Project" + }, + "penumbra.gamedata": { + "type": "Project", + "dependencies": { + "OtterGui": "[1.0.0, )", + "Penumbra.Api": "[5.6.1, )", + "Penumbra.String": "[1.0.6, )" + } + }, + "penumbra.string": { + "type": "Project" + } + } + } +} \ No newline at end of file diff --git a/OtterGui b/OtterGui index 13f1a90..3396ee1 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 13f1a90b88d2b8572480748a209f957b70d6a46f +Subproject commit 3396ee176fa72ad2dfb2de3294f7125ebce4dae5 diff --git a/Penumbra.Api b/Penumbra.Api index 70f0468..2cbf4ba 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 70f046830cc7cd35b3480b12b7efe94182477fbb +Subproject commit 2cbf4bace53a5749d3eab1ff03025a6e6bd9fc37 diff --git a/Penumbra.GameData b/Penumbra.GameData index 96163f7..9ae4a97 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 96163f79e13c7d52cc36cdd82ab4e823763f4f31 +Subproject commit 9ae4a97110fff005a54213815086ce950d4d8b2d diff --git a/Penumbra.String b/Penumbra.String index 4eb7c11..2896c05 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 4eb7c118cdac5873afb97cb04719602f061f03b7 +Subproject commit 2896c0561f60827f97408650d52a15c38f4d9d10 From 00cb1b6643615fa360a5d4c11a44e0481f0820d9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 13:52:15 +0100 Subject: [PATCH 250/401] Use CS sig. --- Glamourer/Interop/ScalingService.cs | 5 +++-- Penumbra.GameData | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index 68dc2e8..2a89a25 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -27,6 +27,9 @@ public unsafe class ScalingService : IDisposable interop.HookFromAddress((nint)MountContainer.MemberFunctionPointers.SetupMount, SetupMountDetour); _calculateHeightHook = interop.HookFromAddress((nint)ModelContainer.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); + _placeMinionHook = interop.HookFromAddress((nint)Companion.MemberFunctionPointers.PlaceCompanion, PlaceMinionDetour); + //_updateOrnamentHook = + // interop.HookFromAddress((nint)Ornament.MemberFunctionPointers.UpdateOrnament, UpdateOrnamentDetour); _setupMountHook.Enable(); _updateOrnamentHook.Enable(); @@ -55,8 +58,6 @@ public unsafe class ScalingService : IDisposable private readonly Hook _calculateHeightHook; - // TODO: Use client structs sig. - [Signature(Sigs.PlaceMinion, DetourName = nameof(PlaceMinionDetour))] private readonly Hook _placeMinionHook = null!; private void SetupMountDetour(MountContainer* container, short mountId, uint unk1, uint unk2, uint unk3, byte unk4) diff --git a/Penumbra.GameData b/Penumbra.GameData index 9ae4a97..8ec54ed 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 9ae4a97110fff005a54213815086ce950d4d8b2d +Subproject commit 8ec54ed4b114e2ffb1d46596785fd5ec382d7ebd From d6d592f099a8a51065465f95c1a7dcd216b06026 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 13:58:19 +0100 Subject: [PATCH 251/401] 1.3.8.0 --- Glamourer.sln | 1 + Glamourer/Gui/GlamourerChangelog.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Glamourer.sln b/Glamourer.sln index 78c32ec..e2915d5 100644 --- a/Glamourer.sln +++ b/Glamourer.sln @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .github\workflows\release.yml = .github\workflows\release.yml + Glamourer\Glamourer.json = Glamourer\Glamourer.json repo.json = repo.json .github\workflows\test_release.yml = .github\workflows\test_release.yml EndProjectSection diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 7033fdd..e12b32e 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -41,6 +41,7 @@ public class GlamourerChangelog Add1_3_5_0(Changelog); Add1_3_6_0(Changelog); Add1_3_7_0(Changelog); + Add1_3_8_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -61,6 +62,18 @@ public class GlamourerChangelog } } + private static void Add1_3_8_0(Changelog log) + => log.NextVersion("Version 1.3.8.0") + .RegisterImportant("Updated Glamourer for update 7.20 and Dalamud API 12.") + .RegisterEntry( + "This is not thoroughly tested, but I decided to push to stable instead of testing because otherwise a lot of people would just go to testing just for early access again despite having no business doing so.", + 1) + .RegisterEntry( + "I also do not use most of the functionality of Glamourer myself, so I am unable to even encounter most issues myself.", 1) + .RegisterEntry("If you encounter any issues, please report them quickly on the discord.", 1) + .RegisterEntry("Added a chat command to clear temporary settings applied by Glamourer to Penumbra.") + .RegisterEntry("Fixed small issues with customizations not applicable to your race still applying."); + private static void Add1_3_7_0(Changelog log) => log.NextVersion("Version 1.3.7.0") .RegisterImportant( From 9d3dfbbece555b3505b86e63a1ac68d5700ad283 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 14:05:53 +0100 Subject: [PATCH 252/401] use staging build for release for now. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18435ae..327b75b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: dotnet restore - name: Download Dalamud run: | - Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip + Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev" - name: Build run: | From 296f1e90b5c0c3b18b3f79ba68a5bd5fd338a089 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 14:13:34 +0100 Subject: [PATCH 253/401] :shrug: --- Glamourer/Glamourer.csproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 5fa2c5d..a4325fb 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -10,10 +10,6 @@ bin\$(Configuration)\ - - OnOutputUpdated - - @@ -62,8 +58,4 @@ PreserveNewest - - - - \ No newline at end of file From d75d70bee577680da38b95dad877b1da92838c1e Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 28 Mar 2025 13:16:18 +0000 Subject: [PATCH 254/401] [CI] Updating repo.json for 1.3.8.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index f2b213e..2eabfd0 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.7.1", - "TestingAssemblyVersion": "1.3.7.1", + "AssemblyVersion": "1.3.8.0", + "TestingAssemblyVersion": "1.3.8.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 11, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.7.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From d398381b52f1d22625adfce15e0ad044c7146e95 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 14:17:16 +0100 Subject: [PATCH 255/401] Revert Dalamud staging on release, and update api level. --- .github/workflows/release.yml | 2 +- repo.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 327b75b..18435ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: dotnet restore - name: Download Dalamud run: | - Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip + Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev" - name: Build run: | diff --git a/repo.json b/repo.json index 2eabfd0..fd45265 100644 --- a/repo.json +++ b/repo.json @@ -21,8 +21,8 @@ "TestingAssemblyVersion": "1.3.8.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 11, - "TestingDalamudApiLevel": 11, + "DalamudApiLevel": 12, + "TestingDalamudApiLevel": 12, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From b0abf865cb2e189f3864295a7d875f6e4b2e4f55 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 15:54:10 +0100 Subject: [PATCH 256/401] Change build step. --- Glamourer/Glamourer.csproj | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index a4325fb..c3e46ab 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -12,6 +12,10 @@ + + + PreserveNewest + @@ -52,10 +56,4 @@ $(GitCommitHash) - - - - PreserveNewest - - \ No newline at end of file From b1d00e981240221fb3a98f7c3f545c7c6f2fb1e1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 15:54:26 +0100 Subject: [PATCH 257/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 8ec54ed..8592159 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 8ec54ed4b114e2ffb1d46596785fd5ec382d7ebd +Subproject commit 859215989da41a4ccb59a5ce390223570a69c94e From 361ed536a3056bbd7705cb6dcd16e5c1589bfa1b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 17:22:57 +0100 Subject: [PATCH 258/401] Fix issue with NPC automation due to missing job detection. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 8592159..ff9b731 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 859215989da41a4ccb59a5ce390223570a69c94e +Subproject commit ff9b731c39494851cfde3d580cd99364b6c04d7c From 76eaa75d04e7cf4373476e8a2dacaf6266e460ba Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 17:23:25 +0100 Subject: [PATCH 259/401] Update Penumbra.Api. --- Penumbra.Api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.Api b/Penumbra.Api index 2cbf4ba..bd56d82 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 2cbf4bace53a5749d3eab1ff03025a6e6bd9fc37 +Subproject commit bd56d82816b8366e19dddfb2dc7fd7f167e264ee From 782c4446b2ae78602c90331c6ee1bf8f9af24897 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 17:25:34 +0100 Subject: [PATCH 260/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index ff9b731..e717a66 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit ff9b731c39494851cfde3d580cd99364b6c04d7c +Subproject commit e717a66f33b0656a7c5c971ffa2f63fd96477d94 From 381b23fe0cbb9d8ed21c129c35f84113687ac21f Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 28 Mar 2025 16:29:25 +0000 Subject: [PATCH 261/401] [CI] Updating repo.json for 1.3.8.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index fd45265..d29a69f 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.0", - "TestingAssemblyVersion": "1.3.8.0", + "AssemblyVersion": "1.3.8.1", + "TestingAssemblyVersion": "1.3.8.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From b1e65e6f9d509c84454c0657da8f3936e9ca9f2d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 29 Mar 2025 18:04:13 +0100 Subject: [PATCH 262/401] Fix some offsets. --- Glamourer/Interop/Material/MaterialManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 81373c5..e065e91 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -197,12 +197,11 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// private static CharacterWeapon GetTempSlot(Weapon* weapon) { - // TODO: Use ClientStructs - var changedData = *(void**)((byte*)weapon + 0xA40); + var changedData = weapon->ChangedData; if (changedData == null) return new CharacterWeapon(weapon->ModelSetId, weapon->SecondaryId, (Variant)weapon->Variant, StainIds.FromWeapon(*weapon)); - return new CharacterWeapon(weapon->ModelSetId, *(SecondaryId*)changedData, ((Variant*)changedData)[2], - new StainIds(((StainId*)changedData)[3], ((StainId*)changedData)[4])); + return new CharacterWeapon(weapon->ModelSetId, changedData->SecondaryId, changedData->Variant, + new StainIds(changedData->Stain0, changedData->Stain1)); } } From 4fca1600cab8c954789171eb81feeecf5968c5dc Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 29 Mar 2025 17:06:25 +0000 Subject: [PATCH 263/401] [CI] Updating repo.json for 1.3.8.2 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index d29a69f..bba0aa8 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.1", - "TestingAssemblyVersion": "1.3.8.1", + "AssemblyVersion": "1.3.8.2", + "TestingAssemblyVersion": "1.3.8.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.2/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 6b3a64ce14ad1f033c23afe17b641021eaffdd73 Mon Sep 17 00:00:00 2001 From: keifufu Date: Mon, 31 Mar 2025 13:00:51 +0200 Subject: [PATCH 264/401] fix linux build --- Glamourer/Glamourer.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index c3e46ab..90c743e 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -26,7 +26,7 @@ - + @@ -56,4 +56,4 @@ $(GitCommitHash) - \ No newline at end of file + From a40a6905bec869940c371cc4adeac096ddc4de62 Mon Sep 17 00:00:00 2001 From: keifufu Date: Mon, 31 Mar 2025 13:02:19 +0200 Subject: [PATCH 265/401] newline be gone --- Glamourer/Glamourer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 90c743e..9dabbb2 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -56,4 +56,4 @@ $(GitCommitHash) - + \ No newline at end of file From 95bc52b2bc14758a547d8405a57d31917a42b5c0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 2 Apr 2025 23:45:02 +0200 Subject: [PATCH 266/401] Check for valid humanity. --- Glamourer/Interop/Material/MaterialManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index e065e91..ff30483 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -157,7 +157,11 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// Find the type of the given draw object by checking the actors pointers. private static bool FindType(CharacterBase* characterBase, Actor actor, out MaterialValueIndex.DrawObjectType type) { - type = MaterialValueIndex.DrawObjectType.Human; + type = MaterialValueIndex.DrawObjectType.Invalid; + if (!((Model)characterBase).IsHuman) + return false; + + type = type = MaterialValueIndex.DrawObjectType.Human; if (!actor.Valid) return false; From 90813ce0300751749a2bba70001be03a4ba338b1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 2 Apr 2025 23:45:28 +0200 Subject: [PATCH 267/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index e717a66..ab63da8 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit e717a66f33b0656a7c5c971ffa2f63fd96477d94 +Subproject commit ab63da8047f3d99240159bb1b17dbcb61d77326a From b98cb31fd2b03819c283d95ef674ecb7d7f7973c Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 2 Apr 2025 21:47:24 +0000 Subject: [PATCH 268/401] [CI] Updating repo.json for 1.3.8.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index bba0aa8..fae7a8f 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.2", - "TestingAssemblyVersion": "1.3.8.2", + "AssemblyVersion": "1.3.8.3", + "TestingAssemblyVersion": "1.3.8.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.2/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.2/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.3/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 096d82741d16e9e88e626c950b83c5a07f94f20c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 3 Apr 2025 01:04:58 +0200 Subject: [PATCH 269/401] Fix previous fix for weapons. --- Glamourer/Interop/Material/MaterialManager.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index ff30483..9eccb29 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -157,19 +157,23 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable /// Find the type of the given draw object by checking the actors pointers. private static bool FindType(CharacterBase* characterBase, Actor actor, out MaterialValueIndex.DrawObjectType type) { - type = MaterialValueIndex.DrawObjectType.Invalid; - if (!((Model)characterBase).IsHuman) - return false; - - type = type = MaterialValueIndex.DrawObjectType.Human; if (!actor.Valid) + { + type = MaterialValueIndex.DrawObjectType.Invalid; return false; + } - if (actor.Model.AsCharacterBase == characterBase) + if (actor.Model.AsCharacterBase == characterBase && ((Model)characterBase).IsHuman) + { + type = MaterialValueIndex.DrawObjectType.Human; return true; + } if (!actor.AsObject->IsCharacter()) + { + type = MaterialValueIndex.DrawObjectType.Invalid; return false; + } if (actor.AsCharacter->DrawData.WeaponData[0].DrawObject == characterBase) { @@ -183,6 +187,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable return true; } + type = MaterialValueIndex.DrawObjectType.Invalid; return false; } From 118f51cc647e82ec2910a3678d856e95fba457b3 Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 2 Apr 2025 23:07:10 +0000 Subject: [PATCH 270/401] [CI] Updating repo.json for 1.3.8.4 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index fae7a8f..b00ebe5 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.3", - "TestingAssemblyVersion": "1.3.8.3", + "AssemblyVersion": "1.3.8.4", + "TestingAssemblyVersion": "1.3.8.4", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.3/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.3/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.4/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.4/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.4/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 46f8818cee7cae30c5ac2d444290b389c85350a9 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 4 Apr 2025 22:35:42 +0200 Subject: [PATCH 271/401] Add Incognito Modifier. --- Glamourer/Configuration.cs | 1 + Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 2 +- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 2 +- Glamourer/Gui/Tabs/HeaderDrawer.cs | 28 ++++++++++++++----- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 4 +++ 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index ef51544..b1b9ec2 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -75,6 +75,7 @@ public class Configuration : IPluginConfiguration, ISavable public RenameField ShowRename { get; set; } = RenameField.BothDataPrio; public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY); public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift); + public DoubleModifier IncognitoModifier { get; set; } = new(ModifierHotkey.Control); public ChangeLogDisplayType ChangeLogDisplayType { get; set; } = ChangeLogDisplayType.New; public QdbButtons QdbButtons { get; set; } = diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 0071b1f..0381a17 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -87,7 +87,7 @@ public class ActorPanel _rightButtons = [ new LockedButton(this), - new HeaderDrawer.IncognitoButton(_config.Ephemeral), + new HeaderDrawer.IncognitoButton(_config), ]; } diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 94329e5..badeaeb 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -31,7 +31,7 @@ public class SetPanel( RandomRestrictionDrawer _randomDrawer) { private readonly JobGroupCombo _jobGroupCombo = new(_manager, _jobs, Glamourer.Log); - private readonly HeaderDrawer.Button[] _rightButtons = [new HeaderDrawer.IncognitoButton(_config.Ephemeral)]; + private readonly HeaderDrawer.Button[] _rightButtons = [new HeaderDrawer.IncognitoButton(_config)]; private string? _tempName; private int _dragIndex = -1; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 04e51ce..3543b68 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -89,7 +89,7 @@ public class DesignPanel _rightButtons = [ new LockButton(this), - new IncognitoButton(_config.Ephemeral), + new IncognitoButton(_config), ]; } diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 2235160..2a5b3e1 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -13,7 +13,7 @@ namespace Glamourer.Gui.Tabs.DesignTab; public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager editor, DesignColors colors, Configuration config) { private readonly Button[] _leftButtons = []; - private readonly Button[] _rightButtons = [new IncognitoButton(config.Ephemeral)]; + private readonly Button[] _rightButtons = [new IncognitoButton(config)]; private readonly DesignColorCombo _colorCombo = new(colors, true); diff --git a/Glamourer/Gui/Tabs/HeaderDrawer.cs b/Glamourer/Gui/Tabs/HeaderDrawer.cs index 0e9237d..d6baeb9 100644 --- a/Glamourer/Gui/Tabs/HeaderDrawer.cs +++ b/Glamourer/Gui/Tabs/HeaderDrawer.cs @@ -44,22 +44,36 @@ public static class HeaderDrawer } } - public sealed class IncognitoButton(EphemeralConfig config) : Button + public sealed class IncognitoButton(Configuration config) : Button { protected override string Description - => config.IncognitoMode - ? "Toggle incognito mode off." - : "Toggle incognito mode on."; + { + get + { + var hold = config.IncognitoModifier.IsActive(); + return (config.Ephemeral.IncognitoMode, hold) + switch + { + (true, true) => "Toggle incognito mode off.", + (false, true) => "Toggle incognito mode on.", + (true, false) => $"Toggle incognito mode off.\n\nHold {config.IncognitoModifier} while clicking to toggle.", + (false, false) => $"Toggle incognito mode on.\n\nHold {config.IncognitoModifier} while clicking to toggle.", + }; + } + } protected override FontAwesomeIcon Icon - => config.IncognitoMode + => config.Ephemeral.IncognitoMode ? FontAwesomeIcon.EyeSlash : FontAwesomeIcon.Eye; protected override void OnClick() { - config.IncognitoMode = !config.IncognitoMode; - config.Save(); + if (!config.IncognitoModifier.IsActive()) + return; + + config.Ephemeral.IncognitoMode = !config.Ephemeral.IncognitoMode; + config.Ephemeral.Save(); } } diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index d6d2c15..11af9b9 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -188,6 +188,10 @@ public class SettingsTab( "A modifier you need to hold while clicking the Delete Design button for it to take effect.", 100 * ImGuiHelpers.GlobalScale, config.DeleteDesignModifier, v => config.DeleteDesignModifier = v)) config.Save(); + if (Widget.DoubleModifierSelector("Incognito Modifier", + "A modifier you need to hold while clicking the Incognito button for it to take effect.", 100 * ImGuiHelpers.GlobalScale, + config.IncognitoModifier, v => config.IncognitoModifier = v)) + config.Save(); DrawRenameSettings(); Checkbox("Auto-Open Design Folders"u8, "Have design folders open or closed as their default state after launching."u8, config.OpenFoldersByDefault, From 8fe0ac81952b5650f80207270ec1610e74062333 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 5 Apr 2025 15:12:27 +0200 Subject: [PATCH 272/401] Fix weapon color set issue. --- Glamourer/Interop/Material/PrepareColorSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 4d1feef..bd60a60 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -119,7 +119,7 @@ public sealed unsafe class PrepareColorSet case MaterialValueIndex.DrawObjectType.Human: return index.SlotIndex < 10 ? actor.Model.GetArmor(((uint)index.SlotIndex).ToEquipSlot()).Stains : StainIds.None; case MaterialValueIndex.DrawObjectType.Mainhand: - var mainhand = (Model)actor.AsCharacter->DrawData.WeaponData[1].DrawObject; + var mainhand = (Model)actor.AsCharacter->DrawData.WeaponData[0].DrawObject; return mainhand.IsWeapon ? StainIds.FromWeapon(*mainhand.AsWeapon) : StainIds.None; case MaterialValueIndex.DrawObjectType.Offhand: var offhand = (Model)actor.AsCharacter->DrawData.WeaponData[1].DrawObject; From c0ad4aab510689f01ab07028a87b468003e68baa Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 5 Apr 2025 18:48:39 +0200 Subject: [PATCH 273/401] Update for new ActorObjectManager. --- Glamourer/Api/ApiHelpers.cs | 12 +- Glamourer/Api/StateApi.cs | 37 ++-- Glamourer/Automation/AutoDesignApplier.cs | 28 ++- Glamourer/Designs/History/EditorHistory.cs | 2 +- Glamourer/Events/StateChanged.cs | 1 + Glamourer/Events/StateFinalized.cs | 1 + Glamourer/Glamourer.cs | 6 +- Glamourer/Gui/DesignQuickBar.cs | 48 ++-- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 16 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 8 +- Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs | 11 +- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 2 +- .../Gui/Tabs/AutomationTab/SetSelector.cs | 26 +-- .../Gui/Tabs/DebugTab/ActiveStatePanel.cs | 14 +- .../DebugTab/AdvancedCustomizationDrawer.cs | 8 +- .../Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 44 ++-- .../Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 5 +- .../Gui/Tabs/DebugTab/NpcAppearancePanel.cs | 62 +++--- .../Gui/Tabs/DebugTab/ObjectManagerPanel.cs | 61 ++--- .../Gui/Tabs/DebugTab/RetainedStatePanel.cs | 3 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 10 +- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 6 +- .../SettingsTab/CollectionOverrideDrawer.cs | 13 +- Glamourer/Interop/ContextMenuService.cs | 15 +- Glamourer/Interop/ObjectManager.cs | 209 ------------------ .../Interop/Penumbra/ModSettingApplier.cs | 3 +- .../Interop/Penumbra/PenumbraAutoRedraw.cs | 8 +- Glamourer/Interop/Structs/ActorData.cs | 47 ---- Glamourer/Services/CommandService.cs | 46 ++-- Glamourer/Services/DesignApplier.cs | 15 +- Glamourer/Services/ServiceManager.cs | 2 + Glamourer/State/FunModule.cs | 39 ++-- Glamourer/State/StateApplier.cs | 8 +- Glamourer/State/StateEditor.cs | 1 + Glamourer/State/StateListener.cs | 21 +- Glamourer/Unlocks/CustomizeUnlockManager.cs | 9 +- OtterGui | 2 +- Penumbra.GameData | 2 +- 38 files changed, 273 insertions(+), 578 deletions(-) delete mode 100644 Glamourer/Interop/ObjectManager.cs delete mode 100644 Glamourer/Interop/Structs/ActorData.cs diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index ed58500..238d349 100644 --- a/Glamourer/Api/ApiHelpers.cs +++ b/Glamourer/Api/ApiHelpers.cs @@ -6,12 +6,12 @@ using OtterGui.Log; using OtterGui.Services; using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using Penumbra.String; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.Api; -public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorManager actors) : IApiService +public class ApiHelpers(ActorObjectManager objects, StateManager stateManager, ActorManager actors) : IApiService { [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] internal IEnumerable FindExistingStates(string actorName) @@ -27,7 +27,7 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] internal GlamourerApiEc FindExistingState(int objectIndex, out ActorState? state) { - var actor = objects[objectIndex]; + var actor = objects.Objects[objectIndex]; var identifier = actor.GetIdentifier(actors); if (!identifier.IsValid) { @@ -42,7 +42,7 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] internal ActorState? FindState(int objectIndex) { - var actor = objects[objectIndex]; + var actor = objects.Objects[objectIndex]; var identifier = actor.GetIdentifier(actors); if (identifier.IsValid && stateManager.GetOrCreate(identifier, actor, out var state)) return state; @@ -73,10 +73,8 @@ public class ApiHelpers(ObjectManager objects, StateManager stateManager, ActorM if (objectName.Length == 0 || !ByteString.FromString(objectName, out var byteString)) return []; - objects.Update(); - return stateManager.Values.Where(state => state.Identifier.Type is IdentifierType.Player && state.Identifier.PlayerName == byteString) - .Concat(objects.Identifiers + .Concat(objects .Where(kvp => kvp.Key is { IsValid: true, Type: IdentifierType.Player } && kvp.Key.PlayerName == byteString) .SelectWhere(kvp => { diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index c27abb7..43dc453 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -4,34 +4,32 @@ using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Designs.History; using Glamourer.Events; -using Glamourer.Interop.Structs; using Glamourer.State; using Newtonsoft.Json.Linq; using OtterGui.Services; using Penumbra.GameData.Interop; -using ObjectManager = Glamourer.Interop.ObjectManager; using StateChanged = Glamourer.Events.StateChanged; namespace Glamourer.Api; public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable { - private readonly ApiHelpers _helpers; - private readonly StateManager _stateManager; - private readonly DesignConverter _converter; - private readonly Configuration _config; - private readonly AutoDesignApplier _autoDesigns; - private readonly ObjectManager _objects; - private readonly StateChanged _stateChanged; - private readonly StateFinalized _stateFinalized; - private readonly GPoseService _gPose; + private readonly ApiHelpers _helpers; + private readonly StateManager _stateManager; + private readonly DesignConverter _converter; + private readonly Configuration _config; + private readonly AutoDesignApplier _autoDesigns; + private readonly ActorObjectManager _objects; + private readonly StateChanged _stateChanged; + private readonly StateFinalized _stateFinalized; + private readonly GPoseService _gPose; public StateApi(ApiHelpers helpers, StateManager stateManager, DesignConverter converter, Configuration config, AutoDesignApplier autoDesigns, - ObjectManager objects, + ActorObjectManager objects, StateChanged stateChanged, StateFinalized stateFinalized, GPoseService gPose) @@ -219,7 +217,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable if (!state.CanUnlock(key)) return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); - RevertToAutomation(_objects[objectIndex], state, key, flags); + RevertToAutomation(_objects.Objects[objectIndex], state, key, flags); return ApiHelpers.Return(GlamourerApiEc.Success, args); } @@ -272,15 +270,9 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; switch (flags & (ApplyFlag.Equipment | ApplyFlag.Customization)) { - case ApplyFlag.Equipment: - _stateManager.ResetEquip(state, source, key); - break; - case ApplyFlag.Customization: - _stateManager.ResetCustomize(state, source, key); - break; - case ApplyFlag.Equipment | ApplyFlag.Customization: - _stateManager.ResetState(state, source, key); - break; + case ApplyFlag.Equipment: _stateManager.ResetEquip(state, source, key); break; + case ApplyFlag.Customization: _stateManager.ResetCustomize(state, source, key); break; + case ApplyFlag.Equipment | ApplyFlag.Customization: _stateManager.ResetState(state, source, key); break; } ApiHelpers.Lock(state, key, flags); @@ -288,7 +280,6 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private GlamourerApiEc RevertToAutomation(ActorState state, uint key, ApplyFlag flags) { - _objects.Update(); if (!_objects.TryGetValue(state.Identifier, out var actors) || !actors.Valid) return GlamourerApiEc.ActorNotFound; diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 545dff7..a61a004 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -11,29 +11,28 @@ using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.Automation; public sealed class AutoDesignApplier : IDisposable { - private readonly Configuration _config; - private readonly AutoDesignManager _manager; - private readonly StateManager _state; - private readonly JobService _jobs; - private readonly EquippedGearset _equippedGearset; - private readonly ActorManager _actors; - private readonly AutomationChanged _event; - private readonly ObjectManager _objects; - private readonly WeaponLoading _weapons; - private readonly HumanModelList _humans; - private readonly DesignMerger _designMerger; - private readonly IClientState _clientState; + private readonly Configuration _config; + private readonly AutoDesignManager _manager; + private readonly StateManager _state; + private readonly JobService _jobs; + private readonly EquippedGearset _equippedGearset; + private readonly ActorManager _actors; + private readonly AutomationChanged _event; + private readonly ActorObjectManager _objects; + private readonly WeaponLoading _weapons; + private readonly HumanModelList _humans; + private readonly DesignMerger _designMerger; + private readonly IClientState _clientState; private readonly JobChangeState _jobChangeState; public AutoDesignApplier(Configuration config, AutoDesignManager manager, StateManager state, JobService jobs, ActorManager actors, - AutomationChanged @event, ObjectManager objects, WeaponLoading weapons, HumanModelList humans, IClientState clientState, + AutomationChanged @event, ActorObjectManager objects, WeaponLoading weapons, HumanModelList humans, IClientState clientState, EquippedGearset equippedGearset, DesignMerger designMerger, JobChangeState jobChangeState) { _config = config; @@ -154,7 +153,6 @@ public sealed class AutoDesignApplier : IDisposable if (newSet is not { Enabled: true }) return; - _objects.Update(); foreach (var id in newSet.Identifiers) { if (_objects.TryGetValue(id, out var data)) diff --git a/Glamourer/Designs/History/EditorHistory.cs b/Glamourer/Designs/History/EditorHistory.cs index 6382b94..58bce3d 100644 --- a/Glamourer/Designs/History/EditorHistory.cs +++ b/Glamourer/Designs/History/EditorHistory.cs @@ -1,8 +1,8 @@ using Glamourer.Api.Enums; using Glamourer.Events; -using Glamourer.Interop.Structs; using Glamourer.State; using OtterGui.Services; +using Penumbra.GameData.Interop; namespace Glamourer.Designs.History; diff --git a/Glamourer/Events/StateChanged.cs b/Glamourer/Events/StateChanged.cs index c704195..2bcc6fe 100644 --- a/Glamourer/Events/StateChanged.cs +++ b/Glamourer/Events/StateChanged.cs @@ -3,6 +3,7 @@ using Glamourer.Designs.History; using Glamourer.Interop.Structs; using Glamourer.State; using OtterGui.Classes; +using Penumbra.GameData.Interop; namespace Glamourer.Events; diff --git a/Glamourer/Events/StateFinalized.cs b/Glamourer/Events/StateFinalized.cs index e8548e9..0ccaa8b 100644 --- a/Glamourer/Events/StateFinalized.cs +++ b/Glamourer/Events/StateFinalized.cs @@ -2,6 +2,7 @@ using Glamourer.Api; using Glamourer.Api.Enums; using Glamourer.Interop.Structs; using OtterGui.Classes; +using Penumbra.GameData.Interop; namespace Glamourer.Events; diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 9191c4f..1e2a62d 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -6,12 +6,10 @@ using Glamourer.Gui; using Glamourer.Interop; using Glamourer.Services; using Glamourer.State; -using OtterGui; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Services; -using Penumbra.GameData.Enums; -using Penumbra.GameData.Files; +using Penumbra.GameData.Interop; namespace Glamourer; @@ -82,7 +80,7 @@ public class Glamourer : IDalamudPlugin var designManager = _services.GetService(); var autoManager = _services.GetService(); var stateManager = _services.GetService(); - var objectManager = _services.GetService(); + var objectManager = _services.GetService(); var currentPlayer = objectManager.PlayerData.Identifier; var states = stateManager.Where(kvp => objectManager.ContainsKey(kvp.Key)).ToList(); diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index c9ace0c..5112d97 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -6,14 +6,13 @@ using Dalamud.Interface.Windowing; using Dalamud.Plugin.Services; using Glamourer.Automation; using Glamourer.Designs; -using Glamourer.Interop; using Glamourer.Interop.Penumbra; -using Glamourer.Interop.Structs; using Glamourer.State; using ImGuiNET; using OtterGui.Classes; using OtterGui.Text; using Penumbra.GameData.Actors; +using Penumbra.GameData.Interop; namespace Glamourer.Gui; @@ -37,21 +36,21 @@ public sealed class DesignQuickBar : Window, IDisposable ? ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoMove : ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoFocusOnAppearing; - private readonly Configuration _config; - private readonly QuickDesignCombo _designCombo; - private readonly StateManager _stateManager; - private readonly AutoDesignApplier _autoDesignApplier; - private readonly ObjectManager _objects; - private readonly PenumbraService _penumbra; - private readonly IKeyState _keyState; - private readonly ImRaii.Style _windowPadding = new(); - private readonly ImRaii.Color _windowColor = new(); - private DateTime _keyboardToggle = DateTime.UnixEpoch; - private int _numButtons; - private readonly StringBuilder _tooltipBuilder = new(512); + private readonly Configuration _config; + private readonly QuickDesignCombo _designCombo; + private readonly StateManager _stateManager; + private readonly AutoDesignApplier _autoDesignApplier; + private readonly ActorObjectManager _objects; + private readonly PenumbraService _penumbra; + private readonly IKeyState _keyState; + private readonly ImRaii.Style _windowPadding = new(); + private readonly ImRaii.Color _windowColor = new(); + private DateTime _keyboardToggle = DateTime.UnixEpoch; + private int _numButtons; + private readonly StringBuilder _tooltipBuilder = new(512); public DesignQuickBar(Configuration config, QuickDesignCombo designCombo, StateManager stateManager, IKeyState keyState, - ObjectManager objects, AutoDesignApplier autoDesignApplier, PenumbraService penumbra) + ActorObjectManager objects, AutoDesignApplier autoDesignApplier, PenumbraService penumbra) : base("Glamourer Quick Bar", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking) { _config = config; @@ -222,7 +221,8 @@ public sealed class DesignQuickBar : Window, IDisposable } if (available == 0) - _tooltipBuilder.Append("Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); + _tooltipBuilder.Append( + "Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, available); ImGui.SameLine(); @@ -258,9 +258,10 @@ public sealed class DesignQuickBar : Window, IDisposable } if (available == 0) - _tooltipBuilder.Append("Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); + _tooltipBuilder.Append( + "Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); - var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.SyncAlt, buttonSize, available); + var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.SyncAlt, buttonSize, available); ImGui.SameLine(); if (!clicked) return; @@ -300,7 +301,8 @@ public sealed class DesignQuickBar : Window, IDisposable } if (available == 0) - _tooltipBuilder.Append("Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); + _tooltipBuilder.Append( + "Neither player character nor target are available, have state modified by Glamourer, or their state is locked."); var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.Repeat, buttonSize, available); ImGui.SameLine(); @@ -424,7 +426,9 @@ public sealed class DesignQuickBar : Window, IDisposable if (_playerIdentifier.IsValid && _playerData.Valid) { available |= 1; - _tooltipBuilder.Append("Left-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting ") + _tooltipBuilder + .Append( + "Left-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting ") .Append(_playerIdentifier) .Append('.'); } @@ -434,7 +438,9 @@ public sealed class DesignQuickBar : Window, IDisposable if (available != 0) _tooltipBuilder.Append('\n'); available |= 2; - _tooltipBuilder.Append("Right-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting ") + _tooltipBuilder + .Append( + "Right-Click: Reset all temporary settings applied by Glamourer (manually or through automation) to the collection affecting ") .Append(_targetIdentifier) .Append('.'); } diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index cf7e1f3..1723333 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -1,6 +1,5 @@ using Glamourer.Designs; using Glamourer.Events; -using Glamourer.Interop; using Glamourer.Interop.Penumbra; using Glamourer.Services; using Glamourer.State; @@ -9,18 +8,19 @@ using OtterGui.Raii; using Penumbra.Api.Enums; using Penumbra.GameData.Data; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.Gui; public sealed class PenumbraChangedItemTooltip : IDisposable { - private readonly PenumbraService _penumbra; - private readonly StateManager _stateManager; - private readonly ItemManager _items; - private readonly ObjectManager _objects; - private readonly CustomizeService _customize; - private readonly GPoseService _gpose; + private readonly PenumbraService _penumbra; + private readonly StateManager _stateManager; + private readonly ItemManager _items; + private readonly ActorObjectManager _objects; + private readonly CustomizeService _customize; + private readonly GPoseService _gpose; private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2]; @@ -33,7 +33,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable public DateTime LastTooltip { get; private set; } = DateTime.MinValue; public DateTime LastClick { get; private set; } = DateTime.MinValue; - public PenumbraChangedItemTooltip(PenumbraService penumbra, StateManager stateManager, ItemManager items, ObjectManager objects, + public PenumbraChangedItemTooltip(PenumbraService penumbra, StateManager stateManager, ItemManager items, ActorObjectManager objects, CustomizeService customize, GPoseService gpose) { _penumbra = penumbra; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 0381a17..5419f23 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -10,7 +10,6 @@ using Glamourer.Gui.Customization; using Glamourer.Gui.Equipment; using Glamourer.Gui.Materials; using Glamourer.Interop; -using Glamourer.Interop.Structs; using Glamourer.State; using ImGuiNET; using OtterGui; @@ -22,7 +21,6 @@ using Penumbra.GameData.Actors; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.Gui.Tabs.ActorTab; @@ -35,7 +33,7 @@ public class ActorPanel private readonly AutoDesignApplier _autoDesignApplier; private readonly Configuration _config; private readonly DesignConverter _converter; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly DesignManager _designManager; private readonly ImportService _importService; private readonly ICondition _conditions; @@ -53,7 +51,7 @@ public class ActorPanel AutoDesignApplier autoDesignApplier, Configuration config, DesignConverter converter, - ObjectManager objects, + ActorObjectManager objects, DesignManager designManager, ImportService importService, ICondition conditions, @@ -106,7 +104,7 @@ public class ActorPanel { using var group = ImRaii.Group(); (_identifier, _data) = _selector.Selection; - _lockedRedraw = _identifier.Type is IdentifierType.Special + _lockedRedraw = _identifier.Type is IdentifierType.Special || _objects.IsInLobby || _conditions[ConditionFlag.OccupiedInCutSceneEvent]; (_actorName, _actor) = GetHeaderName(); DrawHeader(); diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs index 3269fd2..e46d651 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs @@ -1,7 +1,4 @@ -using System.Security.AccessControl; -using Dalamud.Interface; -using Glamourer.Interop; -using Glamourer.Interop.Structs; +using Dalamud.Interface; using ImGuiNET; using OtterGui; using OtterGui.Classes; @@ -9,11 +6,12 @@ using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.ActorTab; -public class ActorSelector(ObjectManager objects, ActorManager actors, EphemeralConfig config) +public class ActorSelector(ActorObjectManager objects, ActorManager actors, EphemeralConfig config) { private ActorIdentifier _identifier = ActorIdentifier.Invalid; @@ -89,11 +87,10 @@ public class ActorSelector(ObjectManager objects, ActorManager actors, Ephemeral if (!child) return; - objects.Update(); _world = new WorldId(objects.Player.Valid ? objects.Player.HomeWorld : (ushort)0); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight()); - var remainder = ImGuiClip.FilteredClippedDraw(objects.Identifiers.Where(p => p.Value.Objects.Any(a => a.Model)), skips, CheckFilter, + var remainder = ImGuiClip.FilteredClippedDraw(objects.Where(p => p.Value.Objects.Any(a => a.Model)), skips, CheckFilter, DrawSelectable); ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight()); } diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index badeaeb..7f576b3 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -434,7 +434,7 @@ public class SetPanel( if (ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0)) { _dragIndex = index; - _selector._dragDesignIndex = index; + _selector.DragDesignIndex = index; } } } diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs index 950b735..09ee6aa 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs @@ -2,12 +2,11 @@ using Dalamud.Interface.Utility; using Glamourer.Automation; using Glamourer.Events; -using Glamourer.Interop; using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; -using Penumbra.GameData.Actors; +using Penumbra.GameData.Interop; using Penumbra.String; using ImGuiClip = OtterGui.ImGuiClip; @@ -18,8 +17,7 @@ public class SetSelector : IDisposable private readonly Configuration _config; private readonly AutoDesignManager _manager; private readonly AutomationChanged _event; - private readonly ActorManager _actors; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly List<(AutoDesignSet, int)> _list = []; public AutoDesignSet? Selection { get; private set; } @@ -38,14 +36,13 @@ public class SetSelector : IDisposable private int _dragIndex = -1; private Action? _endAction; - internal int _dragDesignIndex = -1; + internal int DragDesignIndex = -1; - public SetSelector(AutoDesignManager manager, AutomationChanged @event, Configuration config, ActorManager actors, ObjectManager objects) + public SetSelector(AutoDesignManager manager, AutomationChanged @event, Configuration config, ActorObjectManager objects) { _manager = manager; _event = @event; _config = config; - _actors = actors; _objects = objects; _event.Subscribe(OnAutomationChange, AutomationChanged.Priority.SetSelector); } @@ -94,7 +91,7 @@ public class SetSelector : IDisposable } private LowerString _filter = LowerString.Empty; - private uint _enabledFilter = 0; + private uint _enabledFilter; private float _width; private Vector2 _defaultItemSpacing; private Vector2 _selectableSize; @@ -177,7 +174,6 @@ public class SetSelector : IDisposable UpdateList(); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); _selectableSize = new Vector2(0, 2 * ImGui.GetTextLineHeight() + ImGui.GetStyle().ItemSpacing.Y); - _objects.Update(); ImGuiClip.ClippedDraw(_list, DrawSetSelectable, _selectableSize.Y + 2 * ImGui.GetStyle().ItemSpacing.Y); _endAction?.Invoke(); _endAction = null; @@ -186,7 +182,7 @@ public class SetSelector : IDisposable private void DrawSetSelectable((AutoDesignSet Set, int Index) pair) { using var id = ImRaii.PushId(pair.Index); - using (var color = ImRaii.PushColor(ImGuiCol.Text, pair.Set.Enabled ? ColorId.EnabledAutoSet.Value() : ColorId.DisabledAutoSet.Value())) + using (ImRaii.PushColor(ImGuiCol.Text, pair.Set.Enabled ? ColorId.EnabledAutoSet.Value() : ColorId.DisabledAutoSet.Value())) { if (ImGui.Selectable(GetSetName(pair.Set, pair.Index), pair.Set == Selection, ImGuiSelectableFlags.None, _selectableSize)) { @@ -285,9 +281,9 @@ public class SetSelector : IDisposable private void NewSetButton(Vector2 size) { - var id = _actors.GetCurrentPlayer(); + var id = _objects.Actors.GetCurrentPlayer(); if (!id.IsValid) - id = _actors.CreatePlayer(ByteString.FromSpanUnsafe("New Design"u8, true, false, true), ushort.MaxValue); + id = _objects.Actors.CreatePlayer(ByteString.FromSpanUnsafe("New Design"u8, true, false, true), ushort.MaxValue); if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Plus.ToIconString(), size, $"Create a new Automatic Design Set for {id}. The associated player can be changed later.", !id.IsValid, true)) _manager.AddDesignSet("New Automation Set", id); @@ -332,15 +328,15 @@ public class SetSelector : IDisposable } else if (ImGuiUtil.IsDropping("DesignDragDrop")) { - if (_dragDesignIndex >= 0) + if (DragDesignIndex >= 0) { - var idx = _dragDesignIndex; + var idx = DragDesignIndex; var setTo = set; var setFrom = Selection!; _endAction = () => _manager.MoveDesignToSet(setFrom, idx, setTo); } - _dragDesignIndex = -1; + DragDesignIndex = -1; } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index f5fe088..b4bdc2a 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -1,18 +1,17 @@ using Dalamud.Interface; using Glamourer.GameData; using Glamourer.Designs; -using Glamourer.Interop; -using Glamourer.Interop.Structs; using Glamourer.State; using ImGuiNET; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Interop; namespace Glamourer.Gui.Tabs.DebugTab; -public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectManager) : IGameDataDrawer +public class ActiveStatePanel(StateManager _stateManager, ActorObjectManager _objectManager) : IGameDataDrawer { public string Label => $"Active Actors ({_stateManager.Count})###Active Actors"; @@ -22,8 +21,7 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM public void Draw() { - _objectManager.Update(); - foreach (var (identifier, actors) in _objectManager.Identifiers) + foreach (var (identifier, actors) in _objectManager) { if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.Trash.ToIconString()}##{actors.Label}", new Vector2(ImGui.GetFrameHeight()), string.Empty, !_stateManager.ContainsKey(identifier), true)) @@ -66,13 +64,15 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM static string ItemString(in DesignData data, EquipSlot slot) { var item = data.Item(slot); - return $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; + return + $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; } static string BonusItemString(in DesignData data, BonusItemFlag slot) { var item = data.BonusItem(slot); - return $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; + return + $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; } PrintRow("Model ID", state.BaseData.ModelId, state.ModelData.ModelId, state.Sources[MetaIndex.ModelId]); diff --git a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs index 6f6d27a..5a02621 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs @@ -1,13 +1,13 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; -using Glamourer.Interop; using ImGuiNET; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Interop; namespace Glamourer.Gui.Tabs.DebugTab; -public unsafe class AdvancedCustomizationDrawer(ObjectManager objects) : IGameDataDrawer +public unsafe class AdvancedCustomizationDrawer(ActorObjectManager objects) : IGameDataDrawer { public string Label => "Advanced Customizations"; @@ -31,8 +31,8 @@ public unsafe class AdvancedCustomizationDrawer(ObjectManager objects) : IGameDa return; } - DrawCBuffer("Customize"u8, model.AsHuman->CustomizeParameterCBuffer, 0); - DrawCBuffer("Decal"u8, model.AsHuman->DecalColorCBuffer, 1); + DrawCBuffer("Customize"u8, model.AsHuman->CustomizeParameterCBuffer, 0); + DrawCBuffer("Decal"u8, model.AsHuman->DecalColorCBuffer, 1); DrawCBuffer("Unk1"u8, *(ConstantBuffer**)((byte*)model.AsHuman + 0xBA0), 2); DrawCBuffer("Unk2"u8, *(ConstantBuffer**)((byte*)model.AsHuman + 0xBA8), 3); } diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index 62f93e9..100cc9c 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -3,24 +3,25 @@ using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game; using Glamourer.Designs; -using Glamourer.Interop; using Glamourer.Services; using Glamourer.State; using ImGuiNET; using OtterGui; +using OtterGui.Text; using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.DebugTab; public unsafe class GlamourPlatePanel : IGameDataDrawer { - private readonly DesignManager _design; - private readonly ItemManager _items; - private readonly StateManager _state; - private readonly ObjectManager _objects; + private readonly DesignManager _design; + private readonly ItemManager _items; + private readonly StateManager _state; + private readonly ActorObjectManager _objects; public string Label => "Glamour Plates"; @@ -28,7 +29,8 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer public bool Disabled => false; - public GlamourPlatePanel(IGameInteropProvider interop, ItemManager items, DesignManager design, StateManager state, ObjectManager objects) + public GlamourPlatePanel(IGameInteropProvider interop, ItemManager items, DesignManager design, StateManager state, + ActorObjectManager objects) { _items = items; _design = design; @@ -42,24 +44,24 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer var manager = MirageManager.Instance(); using (ImRaii.Group()) { - ImGui.TextUnformatted("Address:"); - ImGui.TextUnformatted("Number of Glamour Plates:"); - ImGui.TextUnformatted("Glamour Plates Requested:"); - ImGui.TextUnformatted("Glamour Plates Loaded:"); - ImGui.TextUnformatted("Is Applying Glamour Plates:"); + ImUtf8.Text("Address:"u8); + ImUtf8.Text("Number of Glamour Plates:"u8); + ImUtf8.Text("Glamour Plates Requested:"u8); + ImUtf8.Text("Glamour Plates Loaded:"u8); + ImUtf8.Text("Is Applying Glamour Plates:"u8); } ImGui.SameLine(); using (ImRaii.Group()) { - ImGuiUtil.CopyOnClickSelectable($"0x{(ulong)manager:X}"); - ImGui.TextUnformatted(manager == null ? "-" : manager->GlamourPlates.Length.ToString()); - ImGui.TextUnformatted(manager == null ? "-" : manager->GlamourPlatesRequested.ToString()); + ImUtf8.CopyOnClickSelectable($"0x{(ulong)manager:X}"); + ImUtf8.Text(manager == null ? "-" : manager->GlamourPlates.Length.ToString()); + ImUtf8.Text(manager == null ? "-" : manager->GlamourPlatesRequested.ToString()); ImGui.SameLine(); - if (ImGui.SmallButton("Request Update")) + if (ImUtf8.SmallButton("Request Update"u8)) RequestGlamour(); - ImGui.TextUnformatted(manager == null ? "-" : manager->GlamourPlatesLoaded.ToString()); - ImGui.TextUnformatted(manager == null ? "-" : manager->IsApplyingGlamourPlate.ToString()); + ImUtf8.Text(manager == null ? "-" : manager->GlamourPlatesLoaded.ToString()); + ImUtf8.Text(manager == null ? "-" : manager->IsApplyingGlamourPlate.ToString()); } if (manager == null) @@ -71,12 +73,12 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer for (var i = 0; i < manager->GlamourPlates.Length; ++i) { - using var tree = ImRaii.TreeNode($"Plate #{i + 1:D2}"); + using var tree = ImUtf8.TreeNode($"Plate #{i + 1:D2}"); if (!tree) continue; ref var plate = ref manager->GlamourPlates[i]; - if (ImGuiUtil.DrawDisabledButton("Apply to Player", Vector2.Zero, string.Empty, !enabled)) + if (ImUtf8.ButtonEx("Apply to Player"u8, ""u8, Vector2.Zero, !enabled)) { var design = CreateDesign(plate); _state.ApplyDesign(state!, design, ApplySettings.Manual with { IsFinal = true }); @@ -85,14 +87,14 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer using (ImRaii.Group()) { foreach (var slot in EquipSlotExtensions.FullSlots) - ImGui.TextUnformatted(slot.ToName()); + ImUtf8.Text(slot.ToName()); } ImGui.SameLine(); using (ImRaii.Group()) { foreach (var (_, index) in EquipSlotExtensions.FullSlots.WithIndex()) - ImGui.TextUnformatted($"{plate.ItemIds[index]:D6}, {StainIds.FromGlamourPlate(plate, index)}"); + ImUtf8.Text($"{plate.ItemIds[index]:D6}, {StainIds.FromGlamourPlate(plate, index)}"); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index c1b5847..fc4799f 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -11,12 +11,11 @@ using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.Gui.Tabs.DebugTab; public unsafe class ModelEvaluationPanel( - ObjectManager _objectManager, + ActorObjectManager _objectManager, VisorService _visorService, UpdateSlotService _updateSlotService, ChangeCustomizeService _changeCustomizeService, @@ -34,7 +33,7 @@ public unsafe class ModelEvaluationPanel( public void Draw() { ImGui.InputInt("Game Object Index", ref _gameObjectIndex, 0, 0); - var actor = _objectManager[_gameObjectIndex]; + var actor = _objectManager.Objects[_gameObjectIndex]; var model = actor.Model; using var table = ImRaii.Table("##evaluationTable", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); ImGui.TableNextColumn(); diff --git a/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs b/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs index 04537b5..966bc6f 100644 --- a/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs @@ -3,18 +3,18 @@ using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.Designs; using Glamourer.GameData; -using Glamourer.Interop; using Glamourer.State; using ImGuiNET; -using OtterGui; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Interop; using ImGuiClip = OtterGui.ImGuiClip; namespace Glamourer.Gui.Tabs.DebugTab; -public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectManager _objectManager, DesignConverter _designConverter) +public class NpcAppearancePanel(NpcCombo npcCombo, StateManager stateManager, ActorObjectManager objectManager, DesignConverter designConverter) : IGameDataDrawer { public string Label @@ -28,9 +28,9 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM public void Draw() { - ImGui.Checkbox("Compare Customize (or Gear)", ref _customizeOrGear); + ImUtf8.Checkbox("Compare Customize (or Gear)"u8, ref _customizeOrGear); ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); - var resetScroll = ImGui.InputTextWithHint("##npcFilter", "Filter...", ref _npcFilter, 64); + var resetScroll = ImUtf8.InputText("##npcFilter"u8, ref _npcFilter, "Filter..."u8); using var table = ImRaii.Table("npcs", 7, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit, new Vector2(-1, 400 * ImGuiHelpers.GlobalScale)); @@ -40,19 +40,19 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM if (resetScroll) ImGui.SetScrollY(0); - ImGui.TableSetupColumn("Button", ImGuiTableColumnFlags.WidthFixed); - ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, ImGuiHelpers.GlobalScale * 300); - ImGui.TableSetupColumn("Kind", ImGuiTableColumnFlags.WidthFixed); - ImGui.TableSetupColumn("Id", ImGuiTableColumnFlags.WidthFixed); - ImGui.TableSetupColumn("Model", ImGuiTableColumnFlags.WidthFixed); - ImGui.TableSetupColumn("Visor", ImGuiTableColumnFlags.WidthFixed); - ImGui.TableSetupColumn("Compare", ImGuiTableColumnFlags.WidthStretch); + ImUtf8.TableSetupColumn("Button"u8, ImGuiTableColumnFlags.WidthFixed); + ImUtf8.TableSetupColumn("Name"u8, ImGuiTableColumnFlags.WidthFixed, ImGuiHelpers.GlobalScale * 300); + ImUtf8.TableSetupColumn("Kind"u8, ImGuiTableColumnFlags.WidthFixed); + ImUtf8.TableSetupColumn("Id"u8, ImGuiTableColumnFlags.WidthFixed); + ImUtf8.TableSetupColumn("Model"u8, ImGuiTableColumnFlags.WidthFixed); + ImUtf8.TableSetupColumn("Visor"u8, ImGuiTableColumnFlags.WidthFixed); + ImUtf8.TableSetupColumn("Compare"u8, ImGuiTableColumnFlags.WidthStretch); ImGui.TableNextColumn(); var skips = ImGuiClip.GetNecessarySkips(ImGui.GetFrameHeightWithSpacing()); ImGui.TableNextRow(); var idx = 0; - var remainder = ImGuiClip.FilteredClippedDraw(_npcCombo.Items, skips, + var remainder = ImGuiClip.FilteredClippedDraw(npcCombo.Items, skips, d => d.Name.Contains(_npcFilter, StringComparison.OrdinalIgnoreCase), DrawData); ImGui.TableNextColumn(); ImGuiClip.DrawEndDummy(remainder, ImGui.GetFrameHeightWithSpacing()); @@ -61,43 +61,31 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM void DrawData(NpcData data) { using var id = ImRaii.PushId(idx++); - var disabled = !_state.GetOrCreate(_objectManager.Player, out var state); + var disabled = !stateManager.GetOrCreate(objectManager.Player, out var state); ImGui.TableNextColumn(); - if (ImGuiUtil.DrawDisabledButton("Apply", Vector2.Zero, string.Empty, disabled)) + if (ImUtf8.ButtonEx("Apply"u8, ""u8, Vector2.Zero, disabled)) { - foreach (var (slot, item, stain) in _designConverter.FromDrawData(data.Equip.ToArray(), data.Mainhand, data.Offhand, true)) - _state.ChangeEquip(state!, slot, item, stain, ApplySettings.Manual); - _state.ChangeMetaState(state!, MetaIndex.VisorState, data.VisorToggled, ApplySettings.Manual); - _state.ChangeEntireCustomize(state!, data.Customize, CustomizeFlagExtensions.All, ApplySettings.Manual); + foreach (var (slot, item, stain) in designConverter.FromDrawData(data.Equip.ToArray(), data.Mainhand, data.Offhand, true)) + stateManager.ChangeEquip(state!, slot, item, stain, ApplySettings.Manual); + stateManager.ChangeMetaState(state!, MetaIndex.VisorState, data.VisorToggled, ApplySettings.Manual); + stateManager.ChangeEntireCustomize(state!, data.Customize, CustomizeFlagExtensions.All, ApplySettings.Manual); } - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(data.Name); + ImUtf8.DrawFrameColumn(data.Name); - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(data.Kind is ObjectKind.BattleNpc ? "B" : "E"); + ImUtf8.DrawFrameColumn(data.Kind is ObjectKind.BattleNpc ? "B" : "E"); - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(data.Id.Id.ToString()); + ImUtf8.DrawFrameColumn(data.Id.Id.ToString()); - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(data.ModelId.ToString()); + ImUtf8.DrawFrameColumn(data.ModelId.ToString()); using (_ = ImRaii.PushFont(UiBuilder.IconFont)) { - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(data.VisorToggled ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); + ImUtf8.DrawFrameColumn(data.VisorToggled ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); } using var mono = ImRaii.PushFont(UiBuilder.MonoFont); - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(_customizeOrGear ? data.Customize.ToString() : data.WriteGear()); + ImUtf8.DrawFrameColumn(_customizeOrGear ? data.Customize.ToString() : data.WriteGear()); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs index e519ea5..a4d1224 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs @@ -1,13 +1,13 @@ -using Glamourer.Interop; -using ImGuiNET; +using ImGuiNET; using OtterGui; -using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Actors; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Interop; namespace Glamourer.Gui.Tabs.DebugTab; -public class ObjectManagerPanel(ObjectManager _objectManager, ActorManager _actors) : IGameDataDrawer +public class ObjectManagerPanel(ActorObjectManager _objectManager, ActorManager _actors) : IGameDataDrawer { public string Label => "Object Manager"; @@ -19,44 +19,45 @@ public class ObjectManagerPanel(ObjectManager _objectManager, ActorManager _acto public void Draw() { - _objectManager.Update(); - using (var table = ImRaii.Table("##data", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit)) + _objectManager.Objects.DrawDebug(); + + using (var table = ImUtf8.Table("##data"u8, 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit)) { if (!table) return; - ImGuiUtil.DrawTableColumn("Last Update"); - ImGuiUtil.DrawTableColumn(_objectManager.LastUpdate.ToString(CultureInfo.InvariantCulture)); + ImUtf8.DrawTableColumn("World"u8); + ImUtf8.DrawTableColumn(_actors.Finished ? _actors.Data.ToWorldName(_objectManager.World) : "Service Missing"); + ImUtf8.DrawTableColumn(_objectManager.World.ToString()); + + ImUtf8.DrawTableColumn("Player Character"u8); + ImUtf8.DrawTableColumn($"{_objectManager.Player.Utf8Name} ({_objectManager.Player.Index})"); + ImGui.TableNextColumn(); + ImUtf8.CopyOnClickSelectable(_objectManager.Player.ToString()); + + ImUtf8.DrawTableColumn("In GPose"u8); + ImUtf8.DrawTableColumn(_objectManager.IsInGPose.ToString()); ImGui.TableNextColumn(); - ImGuiUtil.DrawTableColumn("World"); - ImGuiUtil.DrawTableColumn(_actors.Finished ? _actors.Data.ToWorldName(_objectManager.World) : "Service Missing"); - ImGuiUtil.DrawTableColumn(_objectManager.World.ToString()); - - ImGuiUtil.DrawTableColumn("Player Character"); - ImGuiUtil.DrawTableColumn($"{_objectManager.Player.Utf8Name} ({_objectManager.Player.Index})"); - ImGui.TableNextColumn(); - ImGuiUtil.CopyOnClickSelectable(_objectManager.Player.ToString()); - - ImGuiUtil.DrawTableColumn("In GPose"); - ImGuiUtil.DrawTableColumn(_objectManager.IsInGPose.ToString()); + ImUtf8.DrawTableColumn("In Lobby"u8); + ImUtf8.DrawTableColumn(_objectManager.IsInLobby.ToString()); ImGui.TableNextColumn(); if (_objectManager.IsInGPose) { - ImGuiUtil.DrawTableColumn("GPose Player"); - ImGuiUtil.DrawTableColumn($"{_objectManager.GPosePlayer.Utf8Name} ({_objectManager.GPosePlayer.Index})"); + ImUtf8.DrawTableColumn("GPose Player"u8); + ImUtf8.DrawTableColumn($"{_objectManager.GPosePlayer.Utf8Name} ({_objectManager.GPosePlayer.Index})"); ImGui.TableNextColumn(); - ImGuiUtil.CopyOnClickSelectable(_objectManager.GPosePlayer.ToString()); + ImUtf8.CopyOnClickSelectable(_objectManager.GPosePlayer.ToString()); } - ImGuiUtil.DrawTableColumn("Number of Players"); - ImGuiUtil.DrawTableColumn(_objectManager.Count.ToString()); + ImUtf8.DrawTableColumn("Number of Players"u8); + ImUtf8.DrawTableColumn(_objectManager.Count.ToString()); ImGui.TableNextColumn(); } - var filterChanged = ImGui.InputTextWithHint("##Filter", "Filter...", ref _objectFilter, 64); - using var table2 = ImRaii.Table("##data2", 3, + var filterChanged = ImUtf8.InputText("##Filter"u8, ref _objectFilter, "Filter..."u8); + using var table2 = ImUtf8.Table("##data2"u8, 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, new Vector2(-1, 20 * ImGui.GetTextLineHeightWithSpacing())); if (!table2) @@ -69,13 +70,13 @@ public class ObjectManagerPanel(ObjectManager _objectManager, ActorManager _acto var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeightWithSpacing()); ImGui.TableNextRow(); - var remainder = ImGuiClip.FilteredClippedDraw(_objectManager.Identifiers, skips, + var remainder = ImGuiClip.FilteredClippedDraw(_objectManager, skips, p => p.Value.Label.Contains(_objectFilter, StringComparison.OrdinalIgnoreCase), p => { - ImGuiUtil.DrawTableColumn(p.Key.ToString()); - ImGuiUtil.DrawTableColumn(p.Value.Label); - ImGuiUtil.DrawTableColumn(string.Join(", ", p.Value.Objects.OrderBy(a => a.Index).Select(a => a.Index.ToString()))); + ImUtf8.DrawTableColumn(p.Key.ToString()); + ImUtf8.DrawTableColumn(p.Value.Label); + ImUtf8.DrawTableColumn(string.Join(", ", p.Value.Objects.OrderBy(a => a.Index).Select(a => a.Index.ToString()))); }); ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeightWithSpacing()); } diff --git a/Glamourer/Gui/Tabs/DebugTab/RetainedStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/RetainedStatePanel.cs index 2abc1db..21f0c50 100644 --- a/Glamourer/Gui/Tabs/DebugTab/RetainedStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/RetainedStatePanel.cs @@ -3,10 +3,11 @@ using Glamourer.Interop.Structs; using Glamourer.State; using OtterGui.Raii; using Penumbra.GameData.Gui.Debug; +using Penumbra.GameData.Interop; namespace Glamourer.Gui.Tabs.DebugTab; -public class RetainedStatePanel(StateManager _stateManager, ObjectManager _objectManager) : IGameDataDrawer +public class RetainedStatePanel(StateManager _stateManager, ActorObjectManager _objectManager) : IGameDataDrawer { public string Label => "Retained States (Inactive Actors)"; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 3543b68..65014a4 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -18,6 +18,7 @@ using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using static Glamourer.Gui.Tabs.HeaderDrawer; namespace Glamourer.Gui.Tabs.DesignTab; @@ -28,7 +29,7 @@ public class DesignPanel private readonly DesignFileSystemSelector _selector; private readonly CustomizationDrawer _customizationDrawer; private readonly DesignManager _manager; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly StateManager _state; private readonly EquipmentDrawer _equipmentDrawer; private readonly ModAssociationsTab _modAssociations; @@ -48,7 +49,7 @@ public class DesignPanel public DesignPanel(DesignFileSystemSelector selector, CustomizationDrawer customizationDrawer, DesignManager manager, - ObjectManager objects, + ActorObjectManager objects, StateManager state, EquipmentDrawer equipmentDrawer, ModAssociationsTab modAssociations, @@ -360,6 +361,7 @@ public class DesignPanel equip = false; customize = true; } + if (!enabled) ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); @@ -371,6 +373,7 @@ public class DesignPanel _manager.ChangeApplyMulti(_selector.Selected!, true, true, true, false, true, true, false, true); _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.Wetness, false); } + if (!enabled) ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking."); @@ -386,7 +389,8 @@ public class DesignPanel if (equip is null && customize is null) return; - _manager.ChangeApplyMulti(_selector.Selected!, equip, customize, equip, customize.HasValue && !customize.Value ? false : null, null, equip, equip, equip); + _manager.ChangeApplyMulti(_selector.Selected!, equip, customize, equip, customize.HasValue && !customize.Value ? false : null, null, + equip, equip, equip); if (equip.HasValue) { _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.HatState, equip.Value); diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index 1151e86..c6166a3 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -5,7 +5,6 @@ using Glamourer.Designs; using Glamourer.Gui.Customization; using Glamourer.Gui.Equipment; using Glamourer.Gui.Tabs.DesignTab; -using Glamourer.Interop; using Glamourer.State; using ImGuiNET; using OtterGui; @@ -13,6 +12,7 @@ using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using static Glamourer.Gui.Tabs.HeaderDrawer; namespace Glamourer.Gui.Tabs.NpcTab; @@ -30,7 +30,7 @@ public class NpcPanel private readonly DesignConverter _converter; private readonly DesignManager _designManager; private readonly StateManager _state; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly DesignColors _colors; private readonly Button[] _leftButtons; private readonly Button[] _rightButtons; @@ -42,7 +42,7 @@ public class NpcPanel DesignConverter converter, DesignManager designManager, StateManager state, - ObjectManager objects, + ActorObjectManager objects, DesignColors colors, Configuration config) { diff --git a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs index d976d28..87490db 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs @@ -6,14 +6,14 @@ using OtterGui; using OtterGui.Raii; using OtterGui.Services; using Penumbra.GameData.Actors; -using ObjectManager = Glamourer.Interop.ObjectManager; +using Penumbra.GameData.Interop; namespace Glamourer.Gui.Tabs.SettingsTab; public class CollectionOverrideDrawer( CollectionOverrideService collectionOverrides, Configuration config, - ObjectManager objects, + ActorObjectManager objects, ActorManager actors, PenumbraService penumbra, CollectionCombo combo) : IService @@ -61,7 +61,8 @@ public class CollectionOverrideDrawer( DrawActorIdentifier(idx, actor); ImGui.TableNextColumn(); - if (combo.Draw("##collection", name, $"Select the overriding collection. Current GUID:", ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight())) + if (combo.Draw("##collection", name, $"Select the overriding collection. Current GUID:", ImGui.GetContentRegionAvail().X, + ImGui.GetTextLineHeight())) { var (guid, _, newName) = combo.CurrentSelection; collectionOverrides.ChangeOverride(idx, guid, newName); @@ -69,7 +70,7 @@ public class CollectionOverrideDrawer( if (ImGui.IsItemHovered()) { - using var tt = ImRaii.Tooltip(); + using var tt = ImRaii.Tooltip(); using var font = ImRaii.PushFont(UiBuilder.MonoFont); ImGui.TextUnformatted($" {collection}"); } @@ -102,7 +103,7 @@ public class CollectionOverrideDrawer( return; using var tt2 = ImRaii.Tooltip(); - using var f = ImRaii.PushFont(UiBuilder.MonoFont); + using var f = ImRaii.PushFont(UiBuilder.MonoFont); ImGui.TextUnformatted(collection.ToString()); } @@ -146,7 +147,7 @@ public class CollectionOverrideDrawer( } catch (ActorIdentifierFactory.IdentifierParseError e) { - _exception = e; + _exception = e; _identifiers = []; } diff --git a/Glamourer/Interop/ContextMenuService.cs b/Glamourer/Interop/ContextMenuService.cs index 71a9280..1f85612 100644 --- a/Glamourer/Interop/ContextMenuService.cs +++ b/Glamourer/Interop/ContextMenuService.cs @@ -5,6 +5,7 @@ using Glamourer.Designs; using Glamourer.Services; using Glamourer.State; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.Interop; @@ -13,16 +14,16 @@ public class ContextMenuService : IDisposable { public const int ChatLogContextItemId = 0x958; - private readonly ItemManager _items; - private readonly IContextMenu _contextMenu; - private readonly StateManager _state; - private readonly ObjectManager _objects; - private EquipItem _lastItem; - private readonly StainId[] _lastStains = new StainId[StainId.NumStains]; + private readonly ItemManager _items; + private readonly IContextMenu _contextMenu; + private readonly StateManager _state; + private readonly ActorObjectManager _objects; + private EquipItem _lastItem; + private readonly StainId[] _lastStains = new StainId[StainId.NumStains]; private readonly MenuItem _inventoryItem; - public ContextMenuService(ItemManager items, StateManager state, ObjectManager objects, Configuration config, + public ContextMenuService(ItemManager items, StateManager state, ActorObjectManager objects, Configuration config, IContextMenu context) { _contextMenu = context; diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs deleted file mode 100644 index 471a49b..0000000 --- a/Glamourer/Interop/ObjectManager.cs +++ /dev/null @@ -1,209 +0,0 @@ -using Dalamud.Game.ClientState.Objects; -using Dalamud.Plugin; -using Dalamud.Plugin.Services; -using FFXIVClientStructs.FFXIV.Client.Game.Control; -using Glamourer.Events; -using Glamourer.Interop.Structs; -using OtterGui.Log; -using Penumbra.GameData.Actors; -using Penumbra.GameData.Enums; -using Penumbra.GameData.Interop; - -namespace Glamourer.Interop; - -public class ObjectManager( - IFramework framework, - IClientState clientState, - IObjectTable objects, - IDalamudPluginInterface pi, - Logger log, - ActorManager actors, - ITargetManager targets) - : global::Penumbra.GameData.Interop.ObjectManager(pi, log, framework, objects) -{ - public DateTime LastUpdate - => LastFrame; - - private DateTime _identifierUpdate; - - public bool IsInGPose - => clientState.IsGPosing; - - public ushort World { get; private set; } - - private readonly Dictionary _identifiers = new(200); - private readonly Dictionary _allWorldIdentifiers = new(200); - private readonly Dictionary _nonOwnedIdentifiers = new(200); - - public IReadOnlyDictionary Identifiers - => _identifiers; - - public override bool Update() - { - if (!base.Update() && _identifierUpdate >= LastUpdate) - return false; - - _identifierUpdate = LastUpdate; - World = (ushort)(Player.Valid ? Player.HomeWorld : 0); - _identifiers.Clear(); - _allWorldIdentifiers.Clear(); - _nonOwnedIdentifiers.Clear(); - - foreach (var actor in BattleNpcs.Concat(CutsceneCharacters)) - { - if (actor.Identifier(actors, out var identifier)) - HandleIdentifier(identifier, actor); - } - - void AddSpecial(ScreenActor idx, string label) - { - var actor = this[(int)idx]; - if (actor.Identifier(actors, out var ident)) - { - var data = new ActorData(actor, label); - _identifiers.Add(ident, data); - } - } - - AddSpecial(ScreenActor.CharacterScreen, "Character Screen Actor"); - AddSpecial(ScreenActor.ExamineScreen, "Examine Screen Actor"); - AddSpecial(ScreenActor.FittingRoom, "Fitting Room Actor"); - AddSpecial(ScreenActor.DyePreview, "Dye Preview Actor"); - AddSpecial(ScreenActor.Portrait, "Portrait Actor"); - AddSpecial(ScreenActor.Card6, "Card Actor 6"); - AddSpecial(ScreenActor.Card7, "Card Actor 7"); - AddSpecial(ScreenActor.Card8, "Card Actor 8"); - - foreach (var actor in EventNpcs) - { - if (actor.Identifier(actors, out var identifier)) - HandleIdentifier(identifier, actor); - } - - return true; - } - - private void HandleIdentifier(ActorIdentifier identifier, Actor character) - { - if (!identifier.IsValid) - return; - - if (!_identifiers.TryGetValue(identifier, out var data)) - { - data = new ActorData(character, identifier.ToString()); - _identifiers[identifier] = data; - } - else - { - data.Objects.Add(character); - } - - if (identifier.Type is IdentifierType.Player or IdentifierType.Owned) - { - var allWorld = actors.CreateIndividualUnchecked(identifier.Type, identifier.PlayerName, ushort.MaxValue, - identifier.Kind, - identifier.DataId); - - if (!_allWorldIdentifiers.TryGetValue(allWorld, out var allWorldData)) - { - allWorldData = new ActorData(character, allWorld.ToString()); - _allWorldIdentifiers[allWorld] = allWorldData; - } - else - { - allWorldData.Objects.Add(character); - } - } - - if (identifier.Type is IdentifierType.Owned) - { - var nonOwned = actors.CreateNpc(identifier.Kind, identifier.DataId); - if (!_nonOwnedIdentifiers.TryGetValue(nonOwned, out var nonOwnedData)) - { - nonOwnedData = new ActorData(character, nonOwned.ToString()); - _nonOwnedIdentifiers[nonOwned] = nonOwnedData; - } - else - { - nonOwnedData.Objects.Add(character); - } - } - } - - public Actor GPosePlayer - => this[(int)ScreenActor.GPosePlayer]; - - public Actor Player - => this[0]; - - public unsafe Actor Target - => clientState.IsGPosing ? TargetSystem.Instance()->GPoseTarget : TargetSystem.Instance()->Target; - - public Actor Focus - => targets.FocusTarget?.Address ?? nint.Zero; - - public Actor MouseOver - => targets.MouseOverTarget?.Address ?? nint.Zero; - - public (ActorIdentifier Identifier, ActorData Data) PlayerData - { - get - { - Update(); - return Player.Identifier(actors, out var ident) && _identifiers.TryGetValue(ident, out var data) - ? (ident, data) - : (ident, ActorData.Invalid); - } - } - - public (ActorIdentifier Identifier, ActorData Data) TargetData - { - get - { - Update(); - return Target.Identifier(actors, out var ident) && _identifiers.TryGetValue(ident, out var data) - ? (ident, data) - : (ident, ActorData.Invalid); - } - } - - /// Also handles All Worlds players and non-owned NPCs. - public bool ContainsKey(ActorIdentifier key) - => Identifiers.ContainsKey(key) || _allWorldIdentifiers.ContainsKey(key) || _nonOwnedIdentifiers.ContainsKey(key); - - public bool TryGetValue(ActorIdentifier key, out ActorData value) - => Identifiers.TryGetValue(key, out value); - - public bool TryGetValueAllWorld(ActorIdentifier key, out ActorData value) - => _allWorldIdentifiers.TryGetValue(key, out value); - - public bool TryGetValueNonOwned(ActorIdentifier key, out ActorData value) - => _nonOwnedIdentifiers.TryGetValue(key, out value); - - public ActorData this[ActorIdentifier key] - => Identifiers[key]; - - public IEnumerable Keys - => Identifiers.Keys; - - public IEnumerable Values - => Identifiers.Values; - - public bool GetName(string lowerName, out Actor actor) - { - (actor, var ret) = lowerName switch - { - "" => (Actor.Null, true), - "" => (Player, true), - "self" => (Player, true), - "" => (Target, true), - "target" => (Target, true), - "" => (Focus, true), - "focus" => (Focus, true), - "" => (MouseOver, true), - "mouseover" => (MouseOver, true), - _ => (Actor.Null, false), - }; - return ret; - } -} diff --git a/Glamourer/Interop/Penumbra/ModSettingApplier.cs b/Glamourer/Interop/Penumbra/ModSettingApplier.cs index 1d39f79..b94be09 100644 --- a/Glamourer/Interop/Penumbra/ModSettingApplier.cs +++ b/Glamourer/Interop/Penumbra/ModSettingApplier.cs @@ -7,7 +7,7 @@ using Penumbra.GameData.Structs; namespace Glamourer.Interop.Penumbra; -public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip autoRedrawSkip, Configuration config, ObjectManager objects, CollectionOverrideService overrides) +public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip autoRedrawSkip, Configuration config, ActorObjectManager objects, CollectionOverrideService overrides) : IService { private readonly HashSet _collectionTracker = []; @@ -17,7 +17,6 @@ public class ModSettingApplier(PenumbraService penumbra, PenumbraAutoRedrawSkip if (!config.AlwaysApplyAssociatedMods || (design.AssociatedMods.Count == 0 && !design.ResetTemporarySettings)) return; - objects.Update(); if (!objects.TryGetValue(state.Identifier, out var data)) { Glamourer.Log.Verbose( diff --git a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs index 93d23c2..4e3c8e3 100644 --- a/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs +++ b/Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs @@ -2,11 +2,11 @@ using Glamourer.Api.Enums; using Glamourer.Designs.History; using Glamourer.Events; -using Glamourer.Interop.Structs; using Glamourer.State; using OtterGui.Classes; using OtterGui.Services; using Penumbra.Api.Enums; +using Penumbra.GameData.Interop; namespace Glamourer.Interop.Penumbra; @@ -16,13 +16,14 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService private readonly Configuration _config; private readonly PenumbraService _penumbra; private readonly StateManager _state; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly IFramework _framework; private readonly StateChanged _stateChanged; private readonly PenumbraAutoRedrawSkip _skip; - public PenumbraAutoRedraw(PenumbraService penumbra, Configuration config, StateManager state, ObjectManager objects, IFramework framework, + public PenumbraAutoRedraw(PenumbraService penumbra, Configuration config, StateManager state, ActorObjectManager objects, + IFramework framework, StateChanged stateChanged, PenumbraAutoRedrawSkip skip) { _penumbra = penumbra; @@ -78,7 +79,6 @@ public class PenumbraAutoRedraw : IDisposable, IRequiredService { _framework.RunOnFrameworkThread(() => { - _objects.Update(); foreach (var (id, state) in _state) { if (!_objects.TryGetValue(id, out var actors) || !actors.Valid) diff --git a/Glamourer/Interop/Structs/ActorData.cs b/Glamourer/Interop/Structs/ActorData.cs deleted file mode 100644 index 5cfbcbe..0000000 --- a/Glamourer/Interop/Structs/ActorData.cs +++ /dev/null @@ -1,47 +0,0 @@ -using OtterGui.Log; -using Penumbra.GameData.Interop; - -namespace Glamourer.Interop.Structs; - -/// -/// A single actor with its label and the list of associated game objects. -/// -public readonly struct ActorData -{ - public readonly List Objects; - public readonly string Label; - - public bool Valid - => Objects.Count > 0; - - public ActorData(Actor actor, string label) - { - Objects = [actor]; - Label = label; - } - - public static readonly ActorData Invalid = new(false); - - private ActorData(bool _) - { - Objects = []; - Label = string.Empty; - } - - public LazyString ToLazyString(string invalid) - { - var objects = Objects; - return Valid - ? new LazyString(() => string.Join(", ", objects.Select(o => o.ToString()))) - : new LazyString(() => invalid); - } - - private ActorData(List objects, string label) - { - Objects = objects; - Label = label; - } - - public ActorData OnlyGPose() - => new(Objects.Where(o => o.IsGPoseOrCutscene).ToList(), Label); -} diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index fa6e63f..ed51a06 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -17,7 +17,6 @@ using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.Services; @@ -26,24 +25,24 @@ public class CommandService : IDisposable, IApiService private const string MainCommandString = "/glamourer"; private const string ApplyCommandString = "/glamour"; - private readonly ICommandManager _commands; - private readonly MainWindow _mainWindow; - private readonly IChatGui _chat; - private readonly ActorManager _actors; - private readonly ObjectManager _objects; - private readonly StateManager _stateManager; - private readonly AutoDesignApplier _autoDesignApplier; - private readonly AutoDesignManager _autoDesignManager; - private readonly Configuration _config; - private readonly ModSettingApplier _modApplier; - private readonly ItemManager _items; - private readonly CustomizeService _customizeService; - private readonly DesignManager _designManager; - private readonly DesignConverter _converter; - private readonly DesignResolver _resolver; - private readonly PenumbraService _penumbra; + private readonly ICommandManager _commands; + private readonly MainWindow _mainWindow; + private readonly IChatGui _chat; + private readonly ActorManager _actors; + private readonly ActorObjectManager _objects; + private readonly StateManager _stateManager; + private readonly AutoDesignApplier _autoDesignApplier; + private readonly AutoDesignManager _autoDesignManager; + private readonly Configuration _config; + private readonly ModSettingApplier _modApplier; + private readonly ItemManager _items; + private readonly CustomizeService _customizeService; + private readonly DesignManager _designManager; + private readonly DesignConverter _converter; + private readonly DesignResolver _resolver; + private readonly PenumbraService _penumbra; - public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorManager actors, ObjectManager objects, + public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorManager actors, ActorObjectManager objects, AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter, DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager, Configuration config, ModSettingApplier modApplier, ItemManager items, RandomDesignGenerator randomDesign, CustomizeService customizeService, DesignFileSystemSelector designSelector, @@ -181,7 +180,9 @@ public class CommandService : IDisposable, IApiService _chat.Print(new SeStringBuilder().AddText("Use with /glamour clearsettings ").AddGreen("[Character Identifier]").AddText(" | ") .AddPurple("").AddText(" | ").AddBlue("").BuiltString); PlayerIdentifierHelp(false, true); - _chat.Print(new SeStringBuilder().AddText(" 》 The character identifier specifies the collection to clear settings from. It also accepts '").AddGreen("all").AddText("' to clear all collections.").BuiltString); + _chat.Print(new SeStringBuilder() + .AddText(" 》 The character identifier specifies the collection to clear settings from. It also accepts '").AddGreen("all") + .AddText("' to clear all collections.").BuiltString); _chat.Print(new SeStringBuilder().AddText(" 》 The booleans are optional and default to 'true', the ").AddPurple("first") .AddText(" determines whether ").AddPurple("manually").AddText(" applied settings are cleared, the ").AddBlue("second") .AddText(" determines whether ").AddBlue("automatically").AddText(" applied settings are cleared.").BuiltString); @@ -372,7 +373,6 @@ public class CommandService : IDisposable, IApiService if (!IdentifierHandling(argument, out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_objects.TryGetValue(identifier, out var data)) @@ -425,7 +425,6 @@ public class CommandService : IDisposable, IApiService if (!IdentifierHandling(argument, out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_objects.TryGetValue(identifier, out var data)) @@ -485,7 +484,6 @@ public class CommandService : IDisposable, IApiService if (!IdentifierHandling(split[1], out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_objects.TryGetValue(identifier, out var actors)) @@ -568,7 +566,6 @@ public class CommandService : IDisposable, IApiService if (!IdentifierHandling(split[1], out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_objects.TryGetValue(identifier, out var actors)) @@ -716,7 +713,6 @@ public class CommandService : IDisposable, IApiService if (!_resolver.GetDesign(split[0], out var design, true) || !IdentifierHandling(split2[0], out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_objects.TryGetValue(identifier, out var actors)) @@ -794,7 +790,6 @@ public class CommandService : IDisposable, IApiService if (!IdentifierHandling(argument, out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_stateManager.TryGetValue(identifier, out var state) @@ -835,7 +830,6 @@ public class CommandService : IDisposable, IApiService if (!IdentifierHandling(split[1], out var identifiers, false, true)) return false; - _objects.Update(); foreach (var identifier in identifiers) { if (!_stateManager.TryGetValue(identifier, out var state) diff --git a/Glamourer/Services/DesignApplier.cs b/Glamourer/Services/DesignApplier.cs index e0134d4..f0a9ba4 100644 --- a/Glamourer/Services/DesignApplier.cs +++ b/Glamourer/Services/DesignApplier.cs @@ -1,13 +1,12 @@ using Glamourer.Designs; -using Glamourer.Interop; -using Glamourer.Interop.Structs; using Glamourer.State; using OtterGui.Services; using Penumbra.GameData.Actors; +using Penumbra.GameData.Interop; namespace Glamourer.Services; -public sealed class DesignApplier(StateManager stateManager, ObjectManager objects) : IService +public sealed class DesignApplier(StateManager stateManager, ActorObjectManager objects) : IService { public void ApplyToPlayer(DesignBase design) { @@ -34,16 +33,10 @@ public sealed class DesignApplier(StateManager stateManager, ObjectManager objec } public void Apply(ActorIdentifier actor, DesignBase design) - { - objects.Update(); - Apply(actor, objects.TryGetValue(actor, out var d) ? d : ActorData.Invalid, design, ApplySettings.ManualWithLinks); - } + => Apply(actor, objects.TryGetValue(actor, out var d) ? d : ActorData.Invalid, design, ApplySettings.ManualWithLinks); public void Apply(ActorIdentifier actor, DesignBase design, ApplySettings settings) - { - objects.Update(); - Apply(actor, objects.TryGetValue(actor, out var d) ? d : ActorData.Invalid, design, settings); - } + => Apply(actor, objects.TryGetValue(actor, out var d) ? d : ActorData.Invalid, design, settings); public void Apply(ActorIdentifier actor, ActorData data, DesignBase design) => Apply(actor, data, design, ApplySettings.ManualWithLinks); diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index baae507..78a0bf0 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -27,6 +27,7 @@ using OtterGui.Services; using Penumbra.GameData.Actors; using Penumbra.GameData.Data; using Penumbra.GameData.DataContainers; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.Services; @@ -102,6 +103,7 @@ public static class StaticServiceManager .AddSingleton() .AddSingleton(p => new CutsceneResolver(p.GetRequiredService().CutsceneParent)) .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index 1ca5c48..52394a2 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -11,7 +11,6 @@ using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; using CustomizeIndex = Penumbra.GameData.Enums.CustomizeIndex; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.State; @@ -35,7 +34,7 @@ public unsafe class FunModule : IDisposable private readonly StateManager _stateManager; private readonly DesignConverter _designConverter; private readonly DesignManager _designManager; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly NpcCustomizeSet _npcs; private readonly StainId[] _stains; @@ -69,7 +68,7 @@ public unsafe class FunModule : IDisposable => OnDayChange(DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year); public FunModule(CodeService codes, CustomizeService customizations, ItemManager items, Configuration config, - GenericPopupWindow popupWindow, StateManager stateManager, ObjectManager objects, DesignConverter designConverter, + GenericPopupWindow popupWindow, StateManager stateManager, ActorObjectManager objects, DesignConverter designConverter, DesignManager designManager, NpcCustomizeSet npcs) { _codes = codes; @@ -125,9 +124,7 @@ public unsafe class FunModule : IDisposable switch (_codes.Masked(CodeService.GearCodes)) { - case CodeService.CodeFlag.Emperor: - SetRandomItem(slot, ref armor); - break; + case CodeService.CodeFlag.Emperor: SetRandomItem(slot, ref armor); break; case CodeService.CodeFlag.Elephants: case CodeService.CodeFlag.Dolphins: case CodeService.CodeFlag.World when actor.Index != 0: @@ -137,9 +134,7 @@ public unsafe class FunModule : IDisposable switch (_codes.Masked(CodeService.DyeCodes)) { - case CodeService.CodeFlag.Clown: - SetRandomDye(ref armor); - break; + case CodeService.CodeFlag.Clown: SetRandomDye(ref armor); break; } } @@ -306,9 +301,7 @@ public unsafe class FunModule : IDisposable SetDolphin(EquipSlot.Body, ref armor[1]); SetDolphin(EquipSlot.Head, ref armor[0]); break; - case CodeService.CodeFlag.World when actor.Index != 0: - _worldSets.Apply(actor, _rng, armor); - break; + case CodeService.CodeFlag.World when actor.Index != 0: _worldSets.Apply(actor, _rng, armor); break; } switch (_codes.Masked(CodeService.DyeCodes)) @@ -368,17 +361,17 @@ public unsafe class FunModule : IDisposable private static IReadOnlyList DolphinBodies => [ - new CharacterArmor(6089, 1, new StainIds(4)), // Toad - new CharacterArmor(6089, 1, new StainIds(4)), // Toad - new CharacterArmor(6089, 1, new StainIds(4)), // Toad - new CharacterArmor(6023, 1, new StainIds(4)), // Swine - new CharacterArmor(6023, 1, new StainIds(4)), // Swine - new CharacterArmor(6023, 1, new StainIds(4)), // Swine - new CharacterArmor(6133, 1, new StainIds(4)), // Gaja - new CharacterArmor(6182, 1, new StainIds(3)), // Imp - new CharacterArmor(6182, 1, new StainIds(3)), // Imp - new CharacterArmor(6182, 1, new StainIds(4)), // Imp - new CharacterArmor(6182, 1, new StainIds(4)), // Imp + new(6089, 1, new StainIds(4)), // Toad + new(6089, 1, new StainIds(4)), // Toad + new(6089, 1, new StainIds(4)), // Toad + new(6023, 1, new StainIds(4)), // Swine + new(6023, 1, new StainIds(4)), // Swine + new(6023, 1, new StainIds(4)), // Swine + new(6133, 1, new StainIds(4)), // Gaja + new(6182, 1, new StainIds(3)), // Imp + new(6182, 1, new StainIds(3)), // Imp + new(6182, 1, new StainIds(4)), // Imp + new(6182, 1, new StainIds(4)), // Imp ]; private void SetDolphin(EquipSlot slot, ref CharacterArmor armor) diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index be85580..698151f 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -7,6 +7,7 @@ using Glamourer.Interop.Structs; using Glamourer.Services; using Penumbra.Api.Enums; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.State; @@ -23,7 +24,7 @@ public class StateApplier( ItemManager _items, PenumbraService _penumbra, MetaService _metaService, - ObjectManager _objects, + ActorObjectManager _objects, CrestService _crests, DirectXService _directX) { @@ -411,8 +412,5 @@ public class StateApplier( } private ActorData GetData(ActorState state) - { - _objects.Update(); - return _objects.TryGetValue(state.Identifier, out var data) ? data : ActorData.Invalid; - } + => _objects.TryGetValue(state.Identifier, out var data) ? data : ActorData.Invalid; } diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 1fa1ffe..986bdc2 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -9,6 +9,7 @@ using Glamourer.Interop.Penumbra; using Glamourer.Interop.Structs; using Glamourer.Services; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; namespace Glamourer.State; diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 88ec0b5..24f641c 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -15,7 +15,6 @@ using Penumbra.GameData.DataContainers; using Glamourer.Designs; using Penumbra.GameData.Interop; using Glamourer.Api.Enums; -using ObjectManager = Glamourer.Interop.ObjectManager; namespace Glamourer.State; @@ -28,7 +27,7 @@ public class StateListener : IDisposable { private readonly Configuration _config; private readonly ActorManager _actors; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly StateManager _manager; private readonly StateApplier _applier; private readonly ItemManager _items; @@ -61,7 +60,7 @@ public class StateListener : IDisposable public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorManager actors, Configuration config, EquipSlotUpdating equipSlotUpdating, GearsetDataLoaded gearsetDataLoaded, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, - FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, + FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ActorObjectManager objects, GPoseService gPose, ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, CrestService crestService, BonusSlotUpdating bonusSlotUpdating, StateFinalized stateFinalized) { @@ -205,9 +204,7 @@ public class StateListener : IDisposable } break; - case UpdateState.NoChange: - customize = state.ModelData.Customize; - break; + case UpdateState.NoChange: customize = state.ModelData.Customize; break; } } @@ -262,9 +259,7 @@ public class StateListener : IDisposable item = state.ModelData.BonusItem(slot).Armor(); break; // Use current model data. - case UpdateState.NoChange: - item = state.ModelData.BonusItem(slot).Armor(); - break; + case UpdateState.NoChange: item = state.ModelData.BonusItem(slot).Armor(); break; case UpdateState.Transformed: break; } } @@ -279,7 +274,6 @@ public class StateListener : IDisposable if (!actor.Identifier(_actors, out var identifier)) return; - _objects.Update(); if (_objects.TryGetValue(identifier, out var actors) && actors.Valid) _stateFinalized.Invoke(StateFinalizationType.Gearset, actors); } @@ -287,7 +281,6 @@ public class StateListener : IDisposable private void OnMovedEquipment((EquipSlot, uint, StainIds)[] items) { - _objects.Update(); var (identifier, objects) = _objects.PlayerData; if (!identifier.IsValid || !_manager.TryGetValue(identifier, out var state)) return; @@ -310,7 +303,7 @@ public class StateListener : IDisposable var stainChanged = current.Stains == changed.Stains && !state.Sources[slot, true].IsFixed(); - switch ((itemChanged, stainChanged)) + switch (itemChanged, stainChanged) { case (true, true): _manager.ChangeEquip(state, slot, currentItem, current.Stains, ApplySettings.Game); @@ -376,9 +369,7 @@ public class StateListener : IDisposable else apply = true; break; - case UpdateState.NoChange: - apply = true; - break; + case UpdateState.NoChange: apply = true; break; } var baseType = slot is EquipSlot.OffHand ? state.BaseData.MainhandType.Offhand() : state.BaseData.MainhandType; diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index b58385e..bd13f99 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -1,16 +1,15 @@ using Dalamud.Game; using Dalamud.Hooking; using Dalamud.Plugin.Services; -using Dalamud.Utility; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.UI; using Glamourer.GameData; using Glamourer.Events; -using Glamourer.Interop; using Glamourer.Services; using Lumina.Excel.Sheets; using Penumbra.GameData; using Penumbra.GameData.Enums; +using Penumbra.GameData.Interop; namespace Glamourer.Unlocks; @@ -19,7 +18,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable private readonly SaveService _saveService; private readonly IClientState _clientState; private readonly ObjectUnlocked _event; - private readonly ObjectManager _objects; + private readonly ActorObjectManager _objects; private readonly Dictionary _unlocked = new(); public readonly IReadOnlyDictionary Unlockable; @@ -28,7 +27,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable => _unlocked; public CustomizeUnlockManager(SaveService saveService, CustomizeService customizations, IDataManager gameData, - IClientState clientState, ObjectUnlocked @event, IGameInteropProvider interop, ObjectManager objects) + IClientState clientState, ObjectUnlocked @event, IGameInteropProvider interop, ActorObjectManager objects) { interop.InitializeFromAttributes(this); _saveService = saveService; @@ -177,7 +176,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable IDataManager gameData) { var ret = new Dictionary(); - var sheet = gameData.GetExcelSheet(ClientLanguage.English)!; + var sheet = gameData.GetExcelSheet(ClientLanguage.English); foreach (var (clan, gender) in CustomizeManager.AllSets()) { var list = customizations.Manager.GetSet(clan, gender); diff --git a/OtterGui b/OtterGui index 3396ee1..f53fd22 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 3396ee176fa72ad2dfb2de3294f7125ebce4dae5 +Subproject commit f53fd227a242435ce44a9fe9c5e847d0ca788869 diff --git a/Penumbra.GameData b/Penumbra.GameData index ab63da8..801e98a 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit ab63da8047f3d99240159bb1b17dbcb61d77326a +Subproject commit 801e98a2956d707a25fd19bdfa46dc674c95365d From aad978f5f68bb36eb43f78f18c45ce7160c993e3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 8 Apr 2025 22:53:59 +0200 Subject: [PATCH 274/401] Pass actor in GearsetDataLoaded instead of looking it up. --- Glamourer/Events/GearsetDataLoaded.cs | 2 +- Glamourer/Interop/UpdateSlotService.cs | 2 +- Glamourer/State/StateListener.cs | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Glamourer/Events/GearsetDataLoaded.cs b/Glamourer/Events/GearsetDataLoaded.cs index 4750939..620bdab 100644 --- a/Glamourer/Events/GearsetDataLoaded.cs +++ b/Glamourer/Events/GearsetDataLoaded.cs @@ -11,7 +11,7 @@ namespace Glamourer.Events; /// /// public sealed class GearsetDataLoaded() - : EventWrapper(nameof(GearsetDataLoaded)) + : EventWrapper(nameof(GearsetDataLoaded)) { public enum Priority { diff --git a/Glamourer/Interop/UpdateSlotService.cs b/Glamourer/Interop/UpdateSlotService.cs index ffa6581..3ef99d9 100644 --- a/Glamourer/Interop/UpdateSlotService.cs +++ b/Glamourer/Interop/UpdateSlotService.cs @@ -120,7 +120,7 @@ public unsafe class UpdateSlotService : IDisposable { var ret = _loadGearsetDataHook.Original(drawDataContainer, gearsetData); var drawObject = drawDataContainer->OwnerObject->DrawObject; - GearsetDataLoadedEvent.Invoke(drawObject); + GearsetDataLoadedEvent.Invoke(drawDataContainer->OwnerObject, drawObject); Glamourer.Log.Excessive($"[LoadAllEquipmentDetour] GearsetItemData: {FormatGearsetItemDataStruct(*gearsetData)}"); return ret; } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 24f641c..90520b2 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -264,10 +264,9 @@ public class StateListener : IDisposable } } - private void OnGearsetDataLoaded(Model model) + private void OnGearsetDataLoaded(Actor actor, Model model) { - var actor = _penumbra.GameObjectFromDrawObject(model); - if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) + if (!actor.Valid || (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)) return; // ensure actor and state are valid. From 7ed42005dd8e8a2563a6fcaf4820a6a325a7943f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 9 Apr 2025 15:11:04 +0200 Subject: [PATCH 275/401] Force higher Penumbra API version and use better IPC for cutscene parents and game objects. --- Glamourer/Interop/Penumbra/PenumbraService.cs | 94 ++++++++----------- Penumbra.Api | 2 +- 2 files changed, 40 insertions(+), 56 deletions(-) diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index e04af7c..3f93551 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -34,12 +34,8 @@ public readonly record struct ModSettings(Dictionary> Setti public class PenumbraService : IDisposable { - public const int RequiredPenumbraBreakingVersion = 5; - public const int RequiredPenumbraFeatureVersion = 3; - public const int RequiredPenumbraFeatureVersionTemp = 4; - public const int RequiredPenumbraFeatureVersionTemp2 = 5; - public const int RequiredPenumbraFeatureVersionTemp3 = 6; - public const int RequiredPenumbraFeatureVersionTemp4 = 7; + public const int RequiredPenumbraBreakingVersion = 5; + public const int RequiredPenumbraFeatureVersion = 8; private const int KeyFixed = -1610; private const string NameFixed = "Glamourer (Automation)"; @@ -57,8 +53,6 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw; - private global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo? _drawObjectInfo; - private global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex? _cutsceneParent; private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; @@ -82,6 +76,8 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.GetChangedItems? _getChangedItems; private IReadOnlyList<(string ModDirectory, IReadOnlyDictionary ChangedItems)>? _changedItems; private Func? _checkCurrentChangedItems; + private Func? _checkCutsceneParent; + private Func? _getGameObject; private readonly IDisposable _initializedEvent; private readonly IDisposable _disposedEvent; @@ -453,11 +449,11 @@ public class PenumbraService : IDisposable /// Obtain the game object corresponding to a draw object. public Actor GameObjectFromDrawObject(Model drawObject) - => Available ? _drawObjectInfo!.Invoke(drawObject.Address).Item1 : Actor.Null; + => _getGameObject?.Invoke(drawObject.Address) ?? Actor.Null; /// Obtain the parent of a cutscene actor if it is known. public short CutsceneParent(ushort idx) - => (short)(Available ? _cutsceneParent!.Invoke(idx) : -1); + => (short)(_checkCutsceneParent?.Invoke(idx) ?? -1); /// Try to redraw the given actor. public void RedrawObject(Actor actor, RedrawType settings) @@ -519,49 +515,37 @@ public class PenumbraService : IDisposable _creatingCharacterBase.Enable(); _createdCharacterBase.Enable(); _modSettingChanged.Enable(); - _collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface); - _collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface); - _redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface); - _drawObjectInfo = new global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo(_pluginInterface); - _cutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex(_pluginInterface); - _objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface); - _getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface); - _currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface); - _getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface); - _inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface); - _setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface); - _setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface); - _setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface); - _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); - _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); - _getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface); - if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp) - { - _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); - _setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface); - _removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface); - _removeTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer(_pluginInterface); - _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); - _removeAllTemporaryModSettingsPlayer = - new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); - if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) - { - _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); - _queryTemporaryModSettingsPlayer = - new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer(_pluginInterface); - if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp3) - { - _getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface); - _getAllSettings = new global::Penumbra.Api.IpcSubscribers.GetAllModSettings(_pluginInterface); - if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp4) - { - _changedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItemAdapterList(_pluginInterface).Invoke(); - _checkCurrentChangedItems = - new global::Penumbra.Api.IpcSubscribers.CheckCurrentChangedItemFunc(_pluginInterface).Invoke(); - } - } - } - } + _collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface); + _collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface); + _redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface); + _checkCutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndexFunc(_pluginInterface).Invoke(); + _getGameObject = new global::Penumbra.Api.IpcSubscribers.GetGameObjectFromDrawObjectFunc(_pluginInterface).Invoke(); + _objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface); + _getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface); + _currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface); + _getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface); + _inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface); + _setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface); + _setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface); + _setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface); + _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); + _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); + _getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface); + _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); + _setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface); + _removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface); + _removeTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer(_pluginInterface); + _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); + _removeAllTemporaryModSettingsPlayer = + new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); + _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); + _queryTemporaryModSettingsPlayer = + new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer(_pluginInterface); + _getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface); + _getAllSettings = new global::Penumbra.Api.IpcSubscribers.GetAllModSettings(_pluginInterface); + _changedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItemAdapterList(_pluginInterface).Invoke(); + _checkCurrentChangedItems = + new global::Penumbra.Api.IpcSubscribers.CheckCurrentChangedItemFunc(_pluginInterface).Invoke(); Available = true; _penumbraReloaded.Invoke(); @@ -587,8 +571,8 @@ public class PenumbraService : IDisposable _collectionByIdentifier = null; _collections = null; _redraw = null; - _drawObjectInfo = null; - _cutsceneParent = null; + _getGameObject = null; + _checkCutsceneParent = null; _objectCollection = null; _getMods = null; _currentCollection = null; diff --git a/Penumbra.Api b/Penumbra.Api index bd56d82..47bd542 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit bd56d82816b8366e19dddfb2dc7fd7f167e264ee +Subproject commit 47bd5424d04c667d0df1ac1dd1eeb3e50b476c2c From 6c556d6a610e05d3900b4202c8e733d92a25747c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 10 Apr 2025 16:20:15 +0200 Subject: [PATCH 276/401] Update API. --- Penumbra.Api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.Api b/Penumbra.Api index 47bd542..f578091 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 47bd5424d04c667d0df1ac1dd1eeb3e50b476c2c +Subproject commit f578091fa579fb098c21036b492ff6e6088184c9 From bfce99859ff7540ddd52d00723015645534f6660 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 10 Apr 2025 16:39:04 +0200 Subject: [PATCH 277/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 801e98a..e10d8f3 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 801e98a2956d707a25fd19bdfa46dc674c95365d +Subproject commit e10d8f33a676ff4544d7ca05a93d555416f41222 From 4f6fb44f79ef88b2cedffada8a0cf6231e52bbb3 Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 10 Apr 2025 14:42:24 +0000 Subject: [PATCH 278/401] [CI] Updating repo.json for 1.3.8.5 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index b00ebe5..3e8e6dc 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.4", - "TestingAssemblyVersion": "1.3.8.4", + "AssemblyVersion": "1.3.8.5", + "TestingAssemblyVersion": "1.3.8.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.4/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.4/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.4/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.5/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.5/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.5/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 155a9d62660f57a6c7b7156199be4c055976df49 Mon Sep 17 00:00:00 2001 From: Caraxi Date: Tue, 15 Apr 2025 14:26:30 +0930 Subject: [PATCH 279/401] Fix `SetMetaState` and `SetMetaStateName` not being registered --- Glamourer/Api/IpcProviders.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 704f008..bd4da53 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -36,6 +36,8 @@ public sealed class IpcProviders : IDisposable, IApiService (a, b, c, d, e, f) => (int)api.Items.SetItemName(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)), IpcSubscribers.SetBonusItem.Provider(pi, api.Items), IpcSubscribers.SetBonusItemName.Provider(pi, api.Items), + IpcSubscribers.SetMetaState.Provider(pi, api.Items), + IpcSubscribers.SetMetaStateName.Provider(pi, api.Items), IpcSubscribers.GetState.Provider(pi, api.State), IpcSubscribers.GetStateName.Provider(pi, api.State), IpcSubscribers.GetStateBase64.Provider(pi, api.State), From 325b54031c431616dcadb09969b8fa39e6043dfc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 19 Apr 2025 22:28:00 +0200 Subject: [PATCH 280/401] Update libraries. --- Glamourer/Api/ApiHelpers.cs | 1 + Glamourer/Automation/AutoDesignManager.cs | 1 + Glamourer/Configuration.cs | 1 + Glamourer/Designs/DesignBase64Migration.cs | 1 + Glamourer/Designs/DesignColors.cs | 1 + Glamourer/Designs/DesignManager.cs | 2 +- Glamourer/Designs/Links/DesignLinkLoader.cs | 2 +- Glamourer/GameData/CustomizeSet.cs | 1 + Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs | 1 + Glamourer/Gui/DesignCombo.cs | 1 + Glamourer/Gui/Equipment/BonusItemCombo.cs | 1 + Glamourer/Gui/Equipment/EquipmentDrawer.cs | 1 + Glamourer/Gui/Equipment/ItemCombo.cs | 2 +- Glamourer/Gui/Equipment/WeaponCombo.cs | 1 + Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs | 1 + Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 1 + Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs | 1 + Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs | 1 + Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs | 1 + Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs | 1 + Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 1 + Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs | 1 + Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs | 1 + Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs | 1 + Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs | 1 + Glamourer/Interop/Material/UpdateColorSets.cs | 4 ++-- Glamourer/Services/CollectionOverrideService.cs | 1 + Glamourer/Services/CommandService.cs | 1 + Glamourer/State/FunModule.cs | 1 + OtterGui | 2 +- Penumbra.GameData | 2 +- 31 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index 238d349..45d84b9 100644 --- a/Glamourer/Api/ApiHelpers.cs +++ b/Glamourer/Api/ApiHelpers.cs @@ -2,6 +2,7 @@ using Glamourer.Designs; using Glamourer.State; using OtterGui; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Services; using Penumbra.GameData.Actors; diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index 6635a89..7a4511b 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Filesystem; using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index b1b9ec2..4339186 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -8,6 +8,7 @@ using Glamourer.Services; using Newtonsoft.Json; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Filesystem; using OtterGui.Widgets; using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; diff --git a/Glamourer/Designs/DesignBase64Migration.cs b/Glamourer/Designs/DesignBase64Migration.cs index cab9e27..8cd137f 100644 --- a/Glamourer/Designs/DesignBase64Migration.cs +++ b/Glamourer/Designs/DesignBase64Migration.cs @@ -1,6 +1,7 @@ using Glamourer.Api.Enums; using Glamourer.Services; using OtterGui; +using OtterGui.Extensions; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; diff --git a/Glamourer/Designs/DesignColors.cs b/Glamourer/Designs/DesignColors.cs index 96592bf..172e10f 100644 --- a/Glamourer/Designs/DesignColors.cs +++ b/Glamourer/Designs/DesignColors.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; namespace Glamourer.Designs; diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index ef01e98..fff9565 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -8,7 +8,7 @@ using Glamourer.Interop.Penumbra; using Glamourer.Services; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using OtterGui; +using OtterGui.Extensions; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; diff --git a/Glamourer/Designs/Links/DesignLinkLoader.cs b/Glamourer/Designs/Links/DesignLinkLoader.cs index fc7a26d..24138a8 100644 --- a/Glamourer/Designs/Links/DesignLinkLoader.cs +++ b/Glamourer/Designs/Links/DesignLinkLoader.cs @@ -1,6 +1,6 @@ using Dalamud.Interface.ImGuiNotification; -using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Services; using Notification = OtterGui.Classes.Notification; diff --git a/Glamourer/GameData/CustomizeSet.cs b/Glamourer/GameData/CustomizeSet.cs index d0193aa..8795c19 100644 --- a/Glamourer/GameData/CustomizeSet.cs +++ b/Glamourer/GameData/CustomizeSet.cs @@ -1,4 +1,5 @@ using OtterGui; +using OtterGui.Extensions; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using Race = Penumbra.GameData.Enums.Race; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index 486fdb4..eabb6f0 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -3,6 +3,7 @@ using Glamourer.GameData; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index dccfa44..a871cf1 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -8,6 +8,7 @@ using Glamourer.Events; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Equipment/BonusItemCombo.cs b/Glamourer/Gui/Equipment/BonusItemCombo.cs index c333a87..892d9f1 100644 --- a/Glamourer/Gui/Equipment/BonusItemCombo.cs +++ b/Glamourer/Gui/Equipment/BonusItemCombo.cs @@ -5,6 +5,7 @@ using ImGuiNET; using Lumina.Excel.Sheets; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Raii; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 2bd84e7..0d2e8dc 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -8,6 +8,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Text.EndObjects; diff --git a/Glamourer/Gui/Equipment/ItemCombo.cs b/Glamourer/Gui/Equipment/ItemCombo.cs index f7c75e1..14f2e8a 100644 --- a/Glamourer/Gui/Equipment/ItemCombo.cs +++ b/Glamourer/Gui/Equipment/ItemCombo.cs @@ -3,8 +3,8 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using Lumina.Excel.Sheets; -using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Equipment/WeaponCombo.cs b/Glamourer/Gui/Equipment/WeaponCombo.cs index 37d9d3c..e96f721 100644 --- a/Glamourer/Gui/Equipment/WeaponCombo.cs +++ b/Glamourer/Gui/Equipment/WeaponCombo.cs @@ -3,6 +3,7 @@ using Glamourer.Unlocks; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs index 530e04a..8a08437 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs @@ -3,6 +3,7 @@ using Dalamud.Utility; using ImGuiNET; using OtterGui; using OtterGui.Custom; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Widgets; using Penumbra.GameData.DataContainers; diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 7f576b3..1600837 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -8,6 +8,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs index 09ee6aa..96730e8 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs @@ -5,6 +5,7 @@ using Glamourer.Events; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Raii; using Penumbra.GameData.Interop; using Penumbra.String; diff --git a/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs b/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs index 98b7d9e..df39f45 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs @@ -1,6 +1,7 @@ using Glamourer.Automation; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using Penumbra.GameData.Gui.Debug; diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs index b562ecf..ede3e9e 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs @@ -2,6 +2,7 @@ using Glamourer.Designs; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs index c893f4c..26be8ce 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs @@ -3,6 +3,7 @@ using Glamourer.Designs; using Glamourer.Services; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index 100cc9c..aafc21a 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -7,6 +7,7 @@ using Glamourer.Services; using Glamourer.State; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Text; using Penumbra.GameData; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs b/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs index e59be09..9444ff7 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs @@ -1,6 +1,7 @@ using Glamourer.Designs; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 80000d9..bab25f0 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -8,6 +8,7 @@ using Glamourer.State; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Text.Widget; diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 2a5b3e1..3567fb6 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -4,6 +4,7 @@ using Glamourer.Designs; using Glamourer.Interop.Material; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; using static Glamourer.Gui.Tabs.HeaderDrawer; diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs b/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs index b3f0cef..847b65e 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs @@ -1,6 +1,7 @@ using Glamourer.GameData; using ImGuiNET; using OtterGui; +using OtterGui.Extensions; using OtterGui.Raii; using ImGuiClip = OtterGui.ImGuiClip; diff --git a/Glamourer/Interop/Material/UpdateColorSets.cs b/Glamourer/Interop/Material/UpdateColorSets.cs index a96c60f..e503bc6 100644 --- a/Glamourer/Interop/Material/UpdateColorSets.cs +++ b/Glamourer/Interop/Material/UpdateColorSets.cs @@ -8,7 +8,7 @@ public sealed class UpdateColorSets : FastHook { public delegate void Delegate(Model model, uint unk); - private readonly ThreadLocal _updatingModel = new(); + private readonly ThreadLocal _updatingModel = new(() => Model.Null); public UpdateColorSets(HookManager hooks) => Task = hooks.CreateHook("Update Color Sets", Sigs.UpdateColorSets, Detour, true); @@ -17,7 +17,7 @@ public sealed class UpdateColorSets : FastHook { _updatingModel.Value = model; Task.Result.Original(model, unk); - _updatingModel.Value = nint.Zero; + _updatingModel.Value = Model.Null; } public Model Get() diff --git a/Glamourer/Services/CollectionOverrideService.cs b/Glamourer/Services/CollectionOverrideService.cs index fcc9998..99635d8 100644 --- a/Glamourer/Services/CollectionOverrideService.cs +++ b/Glamourer/Services/CollectionOverrideService.cs @@ -3,6 +3,7 @@ using Glamourer.Interop.Penumbra; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; +using OtterGui.Extensions; using OtterGui.Filesystem; using OtterGui.Services; using Penumbra.GameData.Actors; diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index ed51a06..3d40fa9 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -12,6 +12,7 @@ using Glamourer.State; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using OtterGui.Services; using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index 52394a2..ae7160c 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -7,6 +7,7 @@ using Glamourer.Services; using ImGuiNET; using OtterGui; using OtterGui.Classes; +using OtterGui.Extensions; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; diff --git a/OtterGui b/OtterGui index f53fd22..d13d700 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit f53fd227a242435ce44a9fe9c5e847d0ca788869 +Subproject commit d13d700796648f2a9279250052c4aa8ebeca221f diff --git a/Penumbra.GameData b/Penumbra.GameData index e10d8f3..62bbce5 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit e10d8f33a676ff4544d7ca05a93d555416f41222 +Subproject commit 62bbce5981e961a91322ca1a7d3bb5be25f67185 From c7d1620c1e2f3024c5bb80330ca4681da255c4f6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 19 Apr 2025 23:09:48 +0200 Subject: [PATCH 281/401] Update GameData. --- Glamourer/Services/DalamudServices.cs | 3 +++ Penumbra.GameData | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Glamourer/Services/DalamudServices.cs b/Glamourer/Services/DalamudServices.cs index 02df634..85783b9 100644 --- a/Glamourer/Services/DalamudServices.cs +++ b/Glamourer/Services/DalamudServices.cs @@ -6,6 +6,8 @@ using OtterGui.Services; namespace Glamourer.Services; +#pragma warning disable SeStringEvaluator + public class DalamudServices { public static void AddServices(ServiceManager services, IDalamudPluginInterface pi) @@ -28,5 +30,6 @@ public class DalamudServices services.AddDalamudService(pi); services.AddDalamudService(pi); services.AddDalamudService(pi); + services.AddDalamudService(pi); } } diff --git a/Penumbra.GameData b/Penumbra.GameData index 62bbce5..002260d 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 62bbce5981e961a91322ca1a7d3bb5be25f67185 +Subproject commit 002260d9815e571f1496c50374f5b712818e9880 From 9a684c9ff5a89e339b529d704be8ed0c2a2351c2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 29 Apr 2025 23:50:29 +0200 Subject: [PATCH 282/401] Implement GetDesignListExtended. --- Glamourer.Api | 2 +- Glamourer/Api/DesignsApi.cs | 7 ++++++- Glamourer/Api/GlamourerApi.cs | 2 +- Glamourer/Api/IpcProviders.cs | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 5e5c867..2158bd4 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 5e5c867a095eecac0dd494b30a33298a65e46426 +Subproject commit 2158bd4bbcb6cefe3ce48e6d8b32e134cbee9a91 diff --git a/Glamourer/Api/DesignsApi.cs b/Glamourer/Api/DesignsApi.cs index 08f5ddc..0ee0b64 100644 --- a/Glamourer/Api/DesignsApi.cs +++ b/Glamourer/Api/DesignsApi.cs @@ -6,11 +6,16 @@ using OtterGui.Services; namespace Glamourer.Api; -public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager stateManager) : IGlamourerApiDesigns, IApiService +public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager stateManager, DesignFileSystem fileSystem, DesignColors color) + : IGlamourerApiDesigns, IApiService { public Dictionary GetDesignList() => designs.Designs.ToDictionary(d => d.Identifier, d => d.Name.Text); + public Dictionary GetDesignListExtended() + => designs.Designs.ToDictionary(d => d.Identifier, + d => (d.Name.Text, fileSystem.FindLeaf(d, out var leaf) ? leaf.FullName() : d.Name.Text, color.GetColor(d), d.QuickDesign)); + public GlamourerApiEc ApplyDesign(Guid designId, int objectIndex, uint key, ApplyFlag flags) { var args = ApiHelpers.Args("Design", designId, "Index", objectIndex, "Key", key, "Flags", flags); diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 62107a9..9aaf72f 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -6,7 +6,7 @@ namespace Glamourer.Api; public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; - public const int CurrentApiVersionMinor = 4; + public const int CurrentApiVersionMinor = 5; public (int Major, int Minor) ApiVersion => (CurrentApiVersionMajor, CurrentApiVersionMinor); diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 704f008..70ba47f 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -24,6 +24,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.ApiVersion.Provider(pi, api), IpcSubscribers.GetDesignList.Provider(pi, api.Designs), + IpcSubscribers.GetDesignListExtended.Provider(pi, api.Designs), IpcSubscribers.ApplyDesign.Provider(pi, api.Designs), IpcSubscribers.ApplyDesignName.Provider(pi, api.Designs), From b53124e7084c1036675c87ab0c922fdba4a63bb7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 1 May 2025 23:02:08 +0200 Subject: [PATCH 283/401] Temporarily use custom address for ReadStainingTemplate. --- Glamourer/Interop/Material/PrepareColorSet.cs | 14 +++++++++----- OtterGui | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index bd60a60..dfa6811 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -1,4 +1,5 @@ using Dalamud.Hooking; +using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; @@ -27,7 +28,8 @@ public sealed unsafe class PrepareColorSet : base("Prepare Color Set ") { _updateColorSets = updateColorSets; - _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, true); + hooks.Provider.InitializeFromAttributes(this); + _task = hooks.CreateHook(Name, Sigs.PrepareColorSet, Detour, true); } private readonly Task> _task; @@ -49,6 +51,10 @@ public sealed unsafe class PrepareColorSet private delegate Texture* Delegate(MaterialResourceHandle* material, StainId stainId1, StainId stainId2); + // TODO use CS when stabilized in Dalamud. + [Signature("E8 ?? ?? ?? ?? 48 8B FB EB 07")] + private static delegate* unmanaged _readStainingTemplate = null; + private Texture* Detour(MaterialResourceHandle* material, StainId stainId1, StainId stainId2) { Glamourer.Log.Excessive($"[{Name}] Triggered with 0x{(nint)material:X} {stainId1.Id} {stainId2.Id}."); @@ -78,12 +84,10 @@ public sealed unsafe class PrepareColorSet if (GetDyeTable(material, out var dyeTable)) { if (stainIds.Stain1.Id != 0) - ((delegate* unmanaged)MaterialResourceHandle.MemberFunctionPointers - .ReadStainingTemplate)(material, dyeTable, stainIds.Stain1.Id, (Half*)(&newTable), 0); + _readStainingTemplate(material, dyeTable, stainIds.Stain1.Id, (Half*)(&newTable), 0); if (stainIds.Stain2.Id != 0) - ((delegate* unmanaged)MaterialResourceHandle.MemberFunctionPointers - .ReadStainingTemplate)(material, dyeTable, stainIds.Stain2.Id, (Half*)(&newTable), 1); + _readStainingTemplate(material, dyeTable, stainIds.Stain2.Id, (Half*)(&newTable), 1); } table = newTable; diff --git a/OtterGui b/OtterGui index d13d700..abfce28 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit d13d700796648f2a9279250052c4aa8ebeca221f +Subproject commit abfce28e0bacdea841f029f59bc19971c43814d8 From 39636f5293d76d42c6b3b84b82bbb73a08826ec4 Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 1 May 2025 21:04:23 +0000 Subject: [PATCH 284/401] [CI] Updating repo.json for 1.3.8.6 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 3e8e6dc..3f1f29b 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.5", - "TestingAssemblyVersion": "1.3.8.5", + "AssemblyVersion": "1.3.8.6", + "TestingAssemblyVersion": "1.3.8.6", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.5/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.5/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.5/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.6/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.6/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.6/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From a6073e2a4214cac6142b0e794a8cb6966120bb90 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 3 May 2025 23:36:03 +0200 Subject: [PATCH 285/401] Update old PR slightly. --- .../Designs/Special/RandomDesignGenerator.cs | 41 +++++++++++-------- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 8 ++-- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Glamourer/Designs/Special/RandomDesignGenerator.cs b/Glamourer/Designs/Special/RandomDesignGenerator.cs index b34a8ba..b1e1e7c 100644 --- a/Glamourer/Designs/Special/RandomDesignGenerator.cs +++ b/Glamourer/Designs/Special/RandomDesignGenerator.cs @@ -5,22 +5,29 @@ namespace Glamourer.Designs.Special; public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileSystem, Configuration config) : IService { - private readonly Random _rng = new(); - private WeakReference _lastDesign = new(null, false); + private readonly Random _rng = new(); + private readonly WeakReference _lastDesign = new(null!, false); public Design? Design(IReadOnlyList localDesigns) { - if (localDesigns.Count == 0) + if (localDesigns.Count is 0) return null; - int idx; - do - idx = _rng.Next(0, localDesigns.Count); - while (config.PreventRandomRepeats && localDesigns.Count > 1 && _lastDesign.TryGetTarget(out var lastDesign) && lastDesign == localDesigns[idx]); - - Glamourer.Log.Verbose($"[Random Design] Chose design {idx + 1} out of {localDesigns.Count}: {localDesigns[idx].Incognito}."); - _lastDesign.SetTarget(localDesigns[idx]); - return localDesigns[idx]; + var idx = _rng.Next(0, localDesigns.Count); + if (localDesigns.Count is 1) + { + _lastDesign.SetTarget(localDesigns[idx]); + return localDesigns[idx]; + } + + if (config.PreventRandomRepeats && _lastDesign.TryGetTarget(out var lastDesign)) + while (lastDesign == localDesigns[idx]) + idx = _rng.Next(0, localDesigns.Count); + + var design = localDesigns[idx]; + Glamourer.Log.Verbose($"[Random Design] Chose design {idx + 1} out of {localDesigns.Count}: {design.Incognito}."); + _lastDesign.SetTarget(design); + return design; } public Design? Design() @@ -31,12 +38,12 @@ public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileS public Design? Design(IReadOnlyList predicates) { - if (predicates.Count == 0) - return Design(); - if (predicates.Count == 1) - return Design(predicates[0]); - - return Design(IDesignPredicate.Get(predicates, designs, fileSystem).ToList()); + return predicates.Count switch + { + 0 => Design(), + 1 => Design(predicates[0]), + _ => Design(IDesignPredicate.Get(predicates, designs, fileSystem).ToList()), + }; } public Design? Design(string restrictions) diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index a16c29e..746bb47 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -102,8 +102,8 @@ public class SettingsTab( "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down."u8, config.UseTemporarySettings, v => config.UseTemporarySettings = v); - Checkbox("Prevent Random Design Repeats", - "When using random designs, prevent the same design from being chosen twice in a row.", + Checkbox("Prevent Random Design Repeats"u8, + "When using random designs, prevent the same design from being chosen twice in a row."u8, config.PreventRandomRepeats, v => config.PreventRandomRepeats = v); ImGui.NewLine(); } @@ -250,8 +250,8 @@ public class SettingsTab( private void DrawQuickDesignBoxes() { - var showAuto = config.EnableAutoDesigns; - var numColumns = 8 - (showAuto ? 0 : 2) - (config.UseTemporarySettings ? 0 : 1); + var showAuto = config.EnableAutoDesigns; + var numColumns = 8 - (showAuto ? 0 : 2) - (config.UseTemporarySettings ? 0 : 1); ImGui.NewLine(); ImUtf8.Text("Show the Following Buttons in the Quick Design Bar:"u8); ImGui.Dummy(Vector2.Zero); From fcb0660deffa383d040567350bbab87aad777cf6 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 May 2025 00:36:39 +0200 Subject: [PATCH 286/401] Implement new IPC methods and API 1.6 --- Glamourer.Api | 2 +- Glamourer/Api/DesignsApi.cs | 66 ++++++++++++++++++- Glamourer/Api/GlamourerApi.cs | 2 +- Glamourer/Api/IpcProviders.cs | 5 ++ .../DebugTab/IpcTester/DesignIpcTester.cs | 45 +++++++++++++ OtterGui | 2 +- 6 files changed, 118 insertions(+), 4 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 2158bd4..9c86a9d 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 2158bd4bbcb6cefe3ce48e6d8b32e134cbee9a91 +Subproject commit 9c86a9d6847f68e75679fe57d34f53f680d949c6 diff --git a/Glamourer/Api/DesignsApi.cs b/Glamourer/Api/DesignsApi.cs index 0ee0b64..e21e6cb 100644 --- a/Glamourer/Api/DesignsApi.cs +++ b/Glamourer/Api/DesignsApi.cs @@ -2,11 +2,18 @@ using Glamourer.Api.Enums; using Glamourer.Designs; using Glamourer.State; +using Newtonsoft.Json.Linq; using OtterGui.Services; namespace Glamourer.Api; -public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager stateManager, DesignFileSystem fileSystem, DesignColors color) +public class DesignsApi( + ApiHelpers helpers, + DesignManager designs, + StateManager stateManager, + DesignFileSystem fileSystem, + DesignColors color, + DesignConverter converter) : IGlamourerApiDesigns, IApiService { public Dictionary GetDesignList() @@ -16,6 +23,11 @@ public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager => designs.Designs.ToDictionary(d => d.Identifier, d => (d.Name.Text, fileSystem.FindLeaf(d, out var leaf) ? leaf.FullName() : d.Name.Text, color.GetColor(d), d.QuickDesign)); + public (string DisplayName, string FullPath, uint DisplayColor, bool ShowInQdb) GetExtendedDesignData(Guid designId) + => designs.Designs.ByIdentifier(designId) is { } d + ? (d.Name.Text, fileSystem.FindLeaf(d, out var leaf) ? leaf.FullName() : d.Name.Text, color.GetColor(d), d.QuickDesign) + : (string.Empty, string.Empty, 0, false); + public GlamourerApiEc ApplyDesign(Guid designId, int objectIndex, uint key, ApplyFlag flags) { var args = ApiHelpers.Args("Design", designId, "Index", objectIndex, "Key", key, "Flags", flags); @@ -71,4 +83,56 @@ public class DesignsApi(ApiHelpers helpers, DesignManager designs, StateManager return ApiHelpers.Return(GlamourerApiEc.Success, args); } + + public (GlamourerApiEc, Guid) AddDesign(string designInput, string name) + { + var args = ApiHelpers.Args("DesignData", designInput, "Name", name); + + if (converter.FromBase64(designInput, true, true, out _) is not { } designBase) + try + { + var jObj = JObject.Parse(designInput); + designBase = converter.FromJObject(jObj, true, true); + if (designBase is null) + return (ApiHelpers.Return(GlamourerApiEc.CouldNotParse, args), Guid.Empty); + } + catch (Exception ex) + { + Glamourer.Log.Error($"Failure parsing data for AddDesign due to\n{ex}"); + return (ApiHelpers.Return(GlamourerApiEc.CouldNotParse, args), Guid.Empty); + } + + try + { + var design = designBase is Design d + ? designs.CreateClone(d, name, true) + : designs.CreateClone(designBase, name, true); + return (ApiHelpers.Return(GlamourerApiEc.Success, args), design.Identifier); + } + catch (Exception ex) + { + Glamourer.Log.Error($"Unknown error creating design via IPC:\n{ex}"); + return (ApiHelpers.Return(GlamourerApiEc.UnknownError, args), Guid.Empty); + } + } + + public GlamourerApiEc DeleteDesign(Guid designId) + { + var args = ApiHelpers.Args("DesignId", designId); + if (designs.Designs.ByIdentifier(designId) is not { } design) + return ApiHelpers.Return(GlamourerApiEc.NothingDone, args); + + designs.Delete(design); + return ApiHelpers.Return(GlamourerApiEc.Success, args); + } + + public string? GetDesignBase64(Guid designId) + => designs.Designs.ByIdentifier(designId) is { } design + ? converter.ShareBase64(design) + : null; + + public JObject? GetDesignJObject(Guid designId) + => designs.Designs.ByIdentifier(designId) is { } design + ? converter.ShareJObject(design) + : null; } diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 9aaf72f..14c0512 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -6,7 +6,7 @@ namespace Glamourer.Api; public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; - public const int CurrentApiVersionMinor = 5; + public const int CurrentApiVersionMinor = 6; public (int Major, int Minor) ApiVersion => (CurrentApiVersionMajor, CurrentApiVersionMinor); diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 8058818..2701f18 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -25,8 +25,13 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.GetDesignList.Provider(pi, api.Designs), IpcSubscribers.GetDesignListExtended.Provider(pi, api.Designs), + IpcSubscribers.GetExtendedDesignData.Provider(pi, api.Designs), IpcSubscribers.ApplyDesign.Provider(pi, api.Designs), IpcSubscribers.ApplyDesignName.Provider(pi, api.Designs), + IpcSubscribers.AddDesign.Provider(pi, api.Designs), + IpcSubscribers.DeleteDesign.Provider(pi, api.Designs), + IpcSubscribers.GetDesignBase64.Provider(pi, api.Designs), + IpcSubscribers.GetDesignJObject.Provider(pi, api.Designs), IpcSubscribers.SetItem.Provider(pi, api.Items), IpcSubscribers.SetItemName.Provider(pi, api.Items), diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs index 918c7ad..9e11b99 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs @@ -7,6 +7,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Services; +using OtterGui.Text; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; @@ -15,6 +16,7 @@ public class DesignIpcTester(IDalamudPluginInterface pluginInterface) : IUiServi private Dictionary _designs = []; private int _gameObjectIndex; private string _gameObjectName = string.Empty; + private string _designName = string.Empty; private uint _key; private ApplyFlag _flags = ApplyFlagEx.DesignDefault; private Guid? _design; @@ -30,6 +32,7 @@ public class DesignIpcTester(IDalamudPluginInterface pluginInterface) : IUiServi IpcTesterHelpers.IndexInput(ref _gameObjectIndex); IpcTesterHelpers.KeyInput(ref _key); IpcTesterHelpers.NameInput(ref _gameObjectName); + ImUtf8.InputText("##designName"u8, ref _designName, "Design Name..."u8); ImGuiUtil.GuidInput("##identifier", "Design Identifier...", string.Empty, ref _design, ref _designText, ImGui.GetContentRegionAvail().X); IpcTesterHelpers.DrawFlagInput(ref _flags); @@ -54,6 +57,48 @@ public class DesignIpcTester(IDalamudPluginInterface pluginInterface) : IUiServi IpcTesterHelpers.DrawIntro(ApplyDesignName.Label); if (ImGuiUtil.DrawDisabledButton("Apply##Name", Vector2.Zero, string.Empty, !_design.HasValue)) _lastError = new ApplyDesignName(pluginInterface).Invoke(_design!.Value, _gameObjectName, _key, _flags); + + IpcTesterHelpers.DrawIntro(GetExtendedDesignData.Label); + if (_design.HasValue) + { + var (display, path, color, draw) = new GetExtendedDesignData(pluginInterface).Invoke(_design.Value); + if (path.Length > 0) + ImUtf8.Text($"{display} ({path}){(draw ? " in QDB"u8 : ""u8)}", color); + else + ImUtf8.Text("No Data"u8); + } + else + { + ImUtf8.Text("No Data"u8); + } + + IpcTesterHelpers.DrawIntro(GetDesignBase64.Label); + if (ImUtf8.Button("To Clipboard##Base64"u8) && _design.HasValue) + { + var data = new GetDesignBase64(pluginInterface).Invoke(_design.Value); + ImUtf8.SetClipboardText(data); + } + + IpcTesterHelpers.DrawIntro(AddDesign.Label); + if (ImUtf8.Button("Add from Clipboard"u8)) + try + { + var data = ImUtf8.GetClipboardText(); + _lastError = new AddDesign(pluginInterface).Invoke(data, _designName, out var newDesign); + if (_lastError is GlamourerApiEc.Success) + { + _design = newDesign; + _designText = newDesign.ToString(); + } + } + catch + { + _lastError = GlamourerApiEc.UnknownError; + } + + IpcTesterHelpers.DrawIntro(DeleteDesign.Label); + if (ImUtf8.Button("Delete##Design"u8) && _design.HasValue) + _lastError = new DeleteDesign(pluginInterface).Invoke(_design.Value); } private void DrawDesignsPopup() diff --git a/OtterGui b/OtterGui index abfce28..d1ba194 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit abfce28e0bacdea841f029f59bc19971c43814d8 +Subproject commit d1ba1942efaae219b06ebc27d43de6d1889af97d From b1abbb8e77b0987c0432cc6eac9e5490d9c2b666 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 6 May 2025 00:30:27 +0200 Subject: [PATCH 287/401] Support model id input in weapon combo, support middle-mouse pipette. --- Glamourer/Gui/Equipment/EquipDrawData.cs | 3 + Glamourer/Gui/Equipment/EquipmentDrawer.cs | 33 +++++++-- Glamourer/Gui/Equipment/ItemCopyService.cs | 78 ++++++++++++++++++++++ Glamourer/Gui/Equipment/WeaponCombo.cs | 28 +++++++- Penumbra.GameData | 2 +- 5 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 Glamourer/Gui/Equipment/ItemCopyService.cs diff --git a/Glamourer/Gui/Equipment/EquipDrawData.cs b/Glamourer/Gui/Equipment/EquipDrawData.cs index 77f4533..f32e22b 100644 --- a/Glamourer/Gui/Equipment/EquipDrawData.cs +++ b/Glamourer/Gui/Equipment/EquipDrawData.cs @@ -27,6 +27,9 @@ public struct EquipDrawData(EquipSlot slot, in DesignData designData) public readonly void SetStains(StainIds stains) => _editor.ChangeStains(_object, Slot, stains, ApplySettings.Manual); + public readonly void SetStain(int which, StainId stain) + => _editor.ChangeStains(_object, Slot, CurrentStains.With(which, stain), ApplySettings.Manual); + public readonly void SetApplyItem(bool value) { var manager = (DesignManager)_editor; diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 0d2e8dc..f2ecc08 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -3,16 +3,15 @@ using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; using Glamourer.Events; using Glamourer.Gui.Materials; -using Glamourer.Interop.Material; using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; -using OtterGui; using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Text.EndObjects; using OtterGui.Widgets; +using Penumbra.GameData.Data; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -33,6 +32,7 @@ public class EquipmentDrawer private readonly Configuration _config; private readonly GPoseService _gPose; private readonly AdvancedDyePopup _advancedDyes; + private readonly ItemCopyService _itemCopy; private float _requiredComboWidthUnscaled; private float _requiredComboWidth; @@ -40,13 +40,14 @@ public class EquipmentDrawer private Stain? _draggedStain; public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, TextureService textures, - Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes) + Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes, ItemCopyService itemCopy) { _items = items; _textures = textures; _config = config; _gPose = gPose; _advancedDyes = advancedDyes; + _itemCopy = itemCopy; _stainData = items.Stains; _stainCombo = new GlamourerColorCombo(DefaultWidth - 20, _stainData, favorites); _itemCombo = EquipSlotExtensions.EqdpSlots.Select(e => new ItemCombo(gameData, items, e, Glamourer.Log, favorites)).ToArray(); @@ -184,6 +185,7 @@ public class EquipmentDrawer return change; } + #region Small private void DrawEquipSmall(in EquipDrawData equipDrawData) @@ -402,6 +404,7 @@ public class EquipmentDrawer ? _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss) : _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss, width); + _itemCopy.HandleCopyPaste(data, index); if (!change) DrawStainDragDrop(data, index, stain, found); @@ -456,6 +459,7 @@ public class EquipmentDrawer data.SetItem(combo.CurrentSelection); else if (combo.CustomVariant.Id > 0) data.SetItem(_items.Identify(data.Slot, combo.CustomSetId, combo.CustomVariant)); + _itemCopy.HandleCopyPaste(data); if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, ItemManager.NothingItem(data.Slot), out var item)) @@ -473,6 +477,14 @@ public class EquipmentDrawer var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id.BonusItem, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth); + if (ImGui.IsItemHovered() && ImGui.GetIO().KeyCtrl) + { + if (ImGui.IsKeyPressed(ImGuiKey.C)) + _itemCopy.Copy(combo.CurrentSelection); + else if (ImGui.IsKeyPressed(ImGuiKey.V)) + _itemCopy.Paste(data.Slot.ToEquipType(), data.SetItem); + } + if (change) data.SetItem(combo.CurrentSelection); else if (combo.CustomVariant.Id > 0) @@ -531,8 +543,12 @@ public class EquipmentDrawer if (combo.Draw(mainhand.CurrentItem.Name, mainhand.CurrentItem.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth)) changedItem = combo.CurrentSelection; - else if (ResetOrClear(mainhand.Locked || unknown, open, mainhand.AllowRevert, false, mainhand.CurrentItem, mainhand.GameItem, - default, out var c)) + else if (combo.CustomVariant.Id > 0 && (drawAll || ItemData.ConvertWeaponId(combo.CustomSetId) == mainhand.CurrentItem.Type)) + changedItem = _items.Identify(mainhand.Slot, combo.CustomSetId, combo.CustomWeaponId, combo.CustomVariant); + _itemCopy.HandleCopyPaste(mainhand); + + if (ResetOrClear(mainhand.Locked || unknown, open, mainhand.AllowRevert, false, mainhand.CurrentItem, mainhand.GameItem, + default, out var c)) changedItem = c; if (changedItem != null) @@ -549,7 +565,8 @@ public class EquipmentDrawer } if (unknown) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "The weapon type could not be identified, thus changing it to other weapons of that type is not possible."u8); + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, + "The weapon type could not be identified, thus changing it to other weapons of that type is not possible."u8); } private void DrawOffhand(in EquipDrawData mainhand, in EquipDrawData offhand, out string label, bool small, bool clear, bool open) @@ -569,6 +586,9 @@ public class EquipmentDrawer if (combo.Draw(offhand.CurrentItem.Name, offhand.CurrentItem.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth)) offhand.SetItem(combo.CurrentSelection); + else if (combo.CustomVariant.Id > 0 && ItemData.ConvertWeaponId(combo.CustomSetId) == offhand.CurrentItem.Type) + offhand.SetItem(_items.Identify(mainhand.Slot, combo.CustomSetId, combo.CustomWeaponId, combo.CustomVariant)); + _itemCopy.HandleCopyPaste(offhand); var defaultOffhand = _items.GetDefaultOffhand(mainhand.CurrentItem); if (ResetOrClear(locked, clear, offhand.AllowRevert, true, offhand.CurrentItem, offhand.GameItem, defaultOffhand, out var item)) @@ -623,6 +643,7 @@ public class EquipmentDrawer { ImUtf8.Text(label); } + if (hasAdvancedDyes) ImUtf8.HoverTooltip("This design has advanced dyes setup for this slot."u8); } diff --git a/Glamourer/Gui/Equipment/ItemCopyService.cs b/Glamourer/Gui/Equipment/ItemCopyService.cs new file mode 100644 index 0000000..e72a54b --- /dev/null +++ b/Glamourer/Gui/Equipment/ItemCopyService.cs @@ -0,0 +1,78 @@ +using Dalamud.Game.ClientState.Keys; +using Dalamud.Plugin.Services; +using Glamourer.Services; +using ImGuiNET; +using OtterGui.OtterGuiInternal.Enums; +using OtterGui.Services; +using OtterGuiInternal; +using Penumbra.GameData.Data; +using Penumbra.GameData.DataContainers; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; + +namespace Glamourer.Gui.Equipment; + +public class ItemCopyService(ItemManager items, IKeyState keyState, DictStain stainData) : IUiService +{ + public EquipItem? Item { get; private set; } + public Stain? Stain { get; private set; } + + public void Copy(in EquipItem item) + => Item = item; + + public void Copy(in Stain stain) + => Stain = stain; + + public void Paste(int which, Action setter) + { + if (Stain is { } stain) + setter(which, stain.RowIndex); + } + + public void Paste(FullEquipType type, Action setter) + { + if (Item is not { } item) + return; + + if (type != item.Type) + { + if (type.IsBonus()) + item = items.Identify(type.ToBonus(), item.PrimaryId, item.Variant); + else if (type.IsEquipment() || type.IsAccessory()) + item = items.Identify(type.ToSlot(), item.PrimaryId, item.Variant); + else + item = items.Identify(type.ToSlot(), item.PrimaryId, item.SecondaryId, item.Variant); + } + + if (item.Valid && item.Type == type) + setter(item); + } + + public void HandleCopyPaste(in EquipDrawData data) + { + if (ImGui.GetIO().KeyCtrl) + { + if (ImGui.IsItemHovered() && ImGui.IsMouseClicked(ImGuiMouseButton.Middle)) + Paste(data.CurrentItem.Type, data.SetItem); + } + else if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) && ImGui.IsMouseClicked(ImGuiMouseButton.Middle)) + { + Copy(data.CurrentItem); + } + } + + public void HandleCopyPaste(in EquipDrawData data, int which) + { + if (ImGui.GetIO().KeyCtrl) + { + if (ImGui.IsItemHovered() && ImGui.IsMouseClicked(ImGuiMouseButton.Middle)) + Paste(which, data.SetStain); + } + else if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) + && ImGui.IsMouseClicked(ImGuiMouseButton.Middle) + && stainData.TryGetValue(data.CurrentStains[which].Id, out var stain)) + { + Copy(stain); + } + } +} diff --git a/Glamourer/Gui/Equipment/WeaponCombo.cs b/Glamourer/Gui/Equipment/WeaponCombo.cs index e96f721..6e38e7c 100644 --- a/Glamourer/Gui/Equipment/WeaponCombo.cs +++ b/Glamourer/Gui/Equipment/WeaponCombo.cs @@ -1,7 +1,6 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; -using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; using OtterGui.Log; @@ -20,6 +19,10 @@ public sealed class WeaponCombo : FilterComboCache private ItemId _currentItem; private float _innerWidth; + public PrimaryId CustomSetId { get; private set; } + public SecondaryId CustomWeaponId { get; private set; } + public Variant CustomVariant { get; private set; } + public WeaponCombo(ItemManager items, FullEquipType type, Logger log, FavoriteManager favorites) : base(() => GetWeapons(favorites, items, type), MouseWheelType.Control, log) { @@ -47,8 +50,9 @@ public sealed class WeaponCombo : FilterComboCache public bool Draw(string previewName, ItemId previewIdx, float width, float innerWidth) { - _innerWidth = innerWidth; - _currentItem = previewIdx; + _innerWidth = innerWidth; + _currentItem = previewIdx; + CustomVariant = 0; return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()); } @@ -75,6 +79,24 @@ public sealed class WeaponCombo : FilterComboCache return ret; } + protected override void OnClosePopup() + { + // If holding control while the popup closes, try to parse the input as a full tuple of set id, weapon id and variant, and set a custom item for that. + if (!ImGui.GetIO().KeyCtrl) + return; + + var split = Filter.Text.Split('-', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + if (split.Length != 3 + || !ushort.TryParse(split[0], out var setId) + || !ushort.TryParse(split[1], out var weaponId) + || !byte.TryParse(split[2], out var variant)) + return; + + CustomSetId = setId; + CustomWeaponId = weaponId; + CustomVariant = variant; + } + protected override bool IsVisible(int globalIndex, LowerString filter) => base.IsVisible(globalIndex, filter) || Items[globalIndex].ModelString.StartsWith(filter.Lower); diff --git a/Penumbra.GameData b/Penumbra.GameData index 002260d..1019b56 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 002260d9815e571f1496c50374f5b712818e9880 +Subproject commit 1019b56de3b7ab2a6a1aefd699f9a507323e92fc From c1e1476fa647cdf50a36757bd63b4ca5becc29f2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 6 May 2025 00:30:47 +0200 Subject: [PATCH 288/401] Fix some issues with glamourer not searching mods by name. --- Glamourer/Interop/Penumbra/PenumbraService.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 3f93551..d66ddc4 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -172,14 +172,14 @@ public class PenumbraService : IDisposable if (_queryTemporaryModSettings != null) { - var tempEc = _queryTemporaryModSettings.Invoke(collection, modDirectory, out var tempTuple, out source); + var tempEc = _queryTemporaryModSettings.Invoke(collection, modDirectory, out var tempTuple, out source, 0, modName); if (tempEc is PenumbraApiEc.Success && tempTuple != null) return new ModSettings(tempTuple.Value.Settings, tempTuple.Value.Priority, tempTuple.Value.Enabled, tempTuple.Value.ForceInherit, false); } source = string.Empty; - var (ec2, tuple2) = _getCurrentSettings!.Invoke(collection, modDirectory); + var (ec2, tuple2) = _getCurrentSettings!.Invoke(collection, modDirectory, modName); if (ec2 is not PenumbraApiEc.Success) return ModSettings.Empty; @@ -265,7 +265,7 @@ public class PenumbraService : IDisposable if (!Available) return; - if (_openModPage!.Invoke(TabType.Mods, mod.DirectoryName) == PenumbraApiEc.ModMissing) + if (_openModPage!.Invoke(TabType.Mods, mod.DirectoryName, mod.Name) == PenumbraApiEc.ModMissing) Glamourer.Messager.NotificationMessage($"Could not open the mod {mod.Name}, no fitting mod was found in your Penumbra install.", NotificationType.Info, false); } @@ -349,14 +349,14 @@ public class PenumbraService : IDisposable var ex = settings.Remove ? index.HasValue - ? _removeTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, key) - : _removeTemporaryModSettings!.Invoke(collection, mod.DirectoryName, key) + ? _removeTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, key, mod.Name) + : _removeTemporaryModSettings!.Invoke(collection, mod.DirectoryName, key, mod.Name) : index.HasValue ? _setTemporaryModSettingsPlayer!.Invoke(index.Value.Index, mod.DirectoryName, settings.ForceInherit, settings.Enabled, settings.Priority, - settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), name, key) + settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), name, key, mod.Name) : _setTemporaryModSettings!.Invoke(collection, mod.DirectoryName, settings.ForceInherit, settings.Enabled, settings.Priority, - settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), name, key); + settings.Settings.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList)kvp.Value), name, key, mod.Name); switch (ex) { case PenumbraApiEc.InvalidArgument: @@ -384,8 +384,8 @@ public class PenumbraService : IDisposable private void SetModPermanent(StringBuilder sb, Mod mod, ModSettings settings, Guid collection) { var ec = settings.ForceInherit - ? _inheritMod!.Invoke(collection, mod.DirectoryName, true) - : _setMod!.Invoke(collection, mod.DirectoryName, settings.Enabled); + ? _inheritMod!.Invoke(collection, mod.DirectoryName, true, mod.Name) + : _setMod!.Invoke(collection, mod.DirectoryName, settings.Enabled, mod.Name); switch (ec) { case PenumbraApiEc.ModMissing: @@ -399,14 +399,14 @@ public class PenumbraService : IDisposable if (settings.ForceInherit || !settings.Enabled) return; - ec = _setModPriority!.Invoke(collection, mod.DirectoryName, settings.Priority); + ec = _setModPriority!.Invoke(collection, mod.DirectoryName, settings.Priority, mod.Name); Debug.Assert(ec is PenumbraApiEc.Success or PenumbraApiEc.NothingChanged, "Setting Priority should not be able to fail."); foreach (var (setting, list) in settings.Settings) { ec = list.Count == 1 - ? _setModSetting!.Invoke(collection, mod.DirectoryName, setting, list[0]) - : _setModSettings!.Invoke(collection, mod.DirectoryName, setting, list); + ? _setModSetting!.Invoke(collection, mod.DirectoryName, setting, list[0], mod.Name) + : _setModSettings!.Invoke(collection, mod.DirectoryName, setting, list, mod.Name); switch (ec) { case PenumbraApiEc.OptionGroupMissing: sb.AppendLine($"Could not find the option group {setting} in mod {mod.Name}."); break; From 8a9877bb014eb6493b6c3b21157e036cc1fa2c9e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 6 May 2025 00:31:26 +0200 Subject: [PATCH 289/401] Add testing Dynamis IPC for debugging. --- Glamourer/Glamourer.cs | 2 ++ Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 5 +++-- Glamourer/Services/ServiceManager.cs | 3 ++- OtterGui | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 1e2a62d..f62085a 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -26,6 +26,7 @@ public class Glamourer : IDalamudPlugin public static readonly Logger Log = new(); public static MessageService Messager { get; private set; } = null!; + public static DynamisIpc Dynamis { get; private set; } = null!; private readonly ServiceManager _services; @@ -35,6 +36,7 @@ public class Glamourer : IDalamudPlugin { _services = StaticServiceManager.CreateProvider(pluginInterface, Log, this); Messager = _services.GetService(); + Dynamis = _services.GetService(); _services.EnsureRequiredServices(); _services.GetService(); diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index fc4799f..a0f2491 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -45,9 +45,10 @@ public unsafe class ModelEvaluationPanel( ImGuiUtil.DrawTableColumn("Address"); ImGui.TableNextColumn(); - ImGuiUtil.CopyOnClickSelectable(actor.ToString()); + + Glamourer.Dynamis.DrawPointer(actor); ImGui.TableNextColumn(); - ImGuiUtil.CopyOnClickSelectable(model.ToString()); + Glamourer.Dynamis.DrawPointer(model); ImGui.TableNextColumn(); if (actor.IsCharacter) { diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 78a0bf0..0754313 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -112,7 +112,8 @@ public static class StaticServiceManager .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton(); + .AddSingleton() + .AddSingleton(); private static ServiceManager AddDesigns(this ServiceManager services) => services.AddSingleton() diff --git a/OtterGui b/OtterGui index d1ba194..9235599 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit d1ba1942efaae219b06ebc27d43de6d1889af97d +Subproject commit 9235599dd6efd17067a06ad98066a6c0d5b625e0 From 9abd7f27671b44a039ea34b9f007f28209ad0d9f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 8 May 2025 23:44:16 +0200 Subject: [PATCH 290/401] Make Dynamis IPC working. --- Glamourer/Gui/Equipment/ItemCopyService.cs | 9 ++------- Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/DynamisPanel.cs | 16 ++++++++++++++++ Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs | 6 ++++-- OtterGui | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 Glamourer/Gui/Tabs/DebugTab/DynamisPanel.cs diff --git a/Glamourer/Gui/Equipment/ItemCopyService.cs b/Glamourer/Gui/Equipment/ItemCopyService.cs index e72a54b..ea37963 100644 --- a/Glamourer/Gui/Equipment/ItemCopyService.cs +++ b/Glamourer/Gui/Equipment/ItemCopyService.cs @@ -1,18 +1,13 @@ -using Dalamud.Game.ClientState.Keys; -using Dalamud.Plugin.Services; -using Glamourer.Services; +using Glamourer.Services; using ImGuiNET; -using OtterGui.OtterGuiInternal.Enums; using OtterGui.Services; -using OtterGuiInternal; -using Penumbra.GameData.Data; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; namespace Glamourer.Gui.Equipment; -public class ItemCopyService(ItemManager items, IKeyState keyState, DictStain stainData) : IUiService +public class ItemCopyService(ItemManager items, DictStain stainData) : IUiService { public EquipItem? Item { get; private set; } public Stain? Stain { get; private set; } diff --git a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs index 90282e8..3df425f 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs @@ -1,5 +1,4 @@ using Glamourer.Gui.Tabs.DebugTab.IpcTester; -using ImGuiNET; using Microsoft.Extensions.DependencyInjection; using OtterGui.Raii; using Penumbra.GameData.Gui.Debug; @@ -36,6 +35,7 @@ public class DebugTabHeader(string label, params IGameDataDrawer[] subTrees) provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), + provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), diff --git a/Glamourer/Gui/Tabs/DebugTab/DynamisPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DynamisPanel.cs new file mode 100644 index 0000000..92cd777 --- /dev/null +++ b/Glamourer/Gui/Tabs/DebugTab/DynamisPanel.cs @@ -0,0 +1,16 @@ +using OtterGui.Services; +using Penumbra.GameData.Gui.Debug; + +namespace Glamourer.Gui.Tabs.DebugTab; + +public class DynamisPanel(DynamisIpc dynamis) : IGameDataDrawer +{ + public string Label + => "Dynamis Interop"; + + public void Draw() + => dynamis.DrawDebugInfo(); + + public bool Disabled + => false; +} diff --git a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index 3714c82..012e5ba 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -61,7 +61,7 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale); ImGui.InputInt("##CutsceneIndex", ref _gameObjectIndex, 0, 0); ImGuiUtil.DrawTableColumn(_penumbra.Available - ? _penumbra.CutsceneParent((ushort) _gameObjectIndex).ToString() + ? _penumbra.CutsceneParent((ushort)_gameObjectIndex).ToString() : "Penumbra Unavailable"); ImGuiUtil.DrawTableColumn("Redraw Object"); @@ -76,7 +76,9 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem } ImGuiUtil.DrawTableColumn("Last Tooltip Date"); - ImGuiUtil.DrawTableColumn(_penumbraTooltip.LastTooltip > DateTime.MinValue ? $"{_penumbraTooltip.LastTooltip.ToLongTimeString()} ({_penumbraTooltip.LastType} {_penumbraTooltip.LastId})" : "Never"); + ImGuiUtil.DrawTableColumn(_penumbraTooltip.LastTooltip > DateTime.MinValue + ? $"{_penumbraTooltip.LastTooltip.ToLongTimeString()} ({_penumbraTooltip.LastType} {_penumbraTooltip.LastId})" + : "Never"); ImGui.TableNextColumn(); ImGuiUtil.DrawTableColumn("Last Click Date"); diff --git a/OtterGui b/OtterGui index 9235599..ce8f88e 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 9235599dd6efd17067a06ad98066a6c0d5b625e0 +Subproject commit ce8f88ee892536016756769e86bdf48132351d80 From c93370ec920f03d3fb32154cfdcf730ba6129abd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 9 May 2025 00:06:19 +0200 Subject: [PATCH 291/401] Again. --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index ce8f88e..77485cd 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit ce8f88ee892536016756769e86bdf48132351d80 +Subproject commit 77485cdd92ffcadb58e183ea9147d4ba37a2b93b From e4b32343aeb4d515ee35b2b492d6e442abf4dc57 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 21 May 2025 17:08:17 +0200 Subject: [PATCH 292/401] Update libraries. --- OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OtterGui b/OtterGui index 77485cd..9aeda9a 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 77485cdd92ffcadb58e183ea9147d4ba37a2b93b +Subproject commit 9aeda9a892d9b971e32b10db21a8daf9c0b9ee53 diff --git a/Penumbra.Api b/Penumbra.Api index f578091..574ef3a 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit f578091fa579fb098c21036b492ff6e6088184c9 +Subproject commit 574ef3a8afd42b949e713e247a0b812886f088bb diff --git a/Penumbra.GameData b/Penumbra.GameData index 1019b56..bb3b462 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 1019b56de3b7ab2a6a1aefd699f9a507323e92fc +Subproject commit bb3b462bbc5bc2a598c1ad8c372b0cb255551fe1 From 081ac6bf8b3489aae69a3d80fafe0e0a9db63584 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 21 May 2025 17:09:41 +0200 Subject: [PATCH 293/401] Split ResetAdvanced into two parts. --- Glamourer/Configuration.cs | 4 +- Glamourer/Gui/DesignQuickBar.cs | 61 +++++++++++++++---- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 5 +- Glamourer/Services/ConfigMigrationService.cs | 13 +++- Glamourer/State/StateApplier.cs | 2 +- Glamourer/State/StateManager.cs | 61 ++++++++++++++++--- 6 files changed, 120 insertions(+), 26 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 1d3689d..c9ff0e6 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -81,7 +81,7 @@ public class Configuration : IPluginConfiguration, ISavable public ChangeLogDisplayType ChangeLogDisplayType { get; set; } = ChangeLogDisplayType.New; public QdbButtons QdbButtons { get; set; } = - QdbButtons.ApplyDesign | QdbButtons.RevertAll | QdbButtons.RevertAutomation | QdbButtons.RevertAdvanced; + QdbButtons.ApplyDesign | QdbButtons.RevertAll | QdbButtons.RevertAutomation | QdbButtons.RevertAdvancedDyes; [JsonConverter(typeof(SortModeConverter))] [JsonProperty(Order = int.MaxValue)] @@ -158,7 +158,7 @@ public class Configuration : IPluginConfiguration, ISavable public static class Constants { - public const int CurrentVersion = 7; + public const int CurrentVersion = 8; public static readonly ISortMode[] ValidSortModes = [ diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index 5112d97..b64a5f2 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -19,14 +19,15 @@ namespace Glamourer.Gui; [Flags] public enum QdbButtons { - ApplyDesign = 0x01, - RevertAll = 0x02, - RevertAutomation = 0x04, - RevertAdvanced = 0x08, - RevertEquip = 0x10, - RevertCustomize = 0x20, - ReapplyAutomation = 0x40, - ResetSettings = 0x80, + ApplyDesign = 0x01, + RevertAll = 0x02, + RevertAutomation = 0x04, + RevertAdvancedDyes = 0x08, + RevertEquip = 0x10, + RevertCustomize = 0x20, + ReapplyAutomation = 0x40, + ResetSettings = 0x80, + RevertAdvancedCustomization = 0x100, } public sealed class DesignQuickBar : Window, IDisposable @@ -124,6 +125,7 @@ public sealed class DesignQuickBar : Window, IDisposable DrawRevertEquipButton(buttonSize); DrawRevertCustomizeButton(buttonSize); DrawRevertAdvancedCustomization(buttonSize); + DrawRevertAdvancedDyes(buttonSize); DrawRevertAutomationButton(buttonSize); DrawReapplyAutomationButton(buttonSize); DrawResetSettingsButton(buttonSize); @@ -318,7 +320,7 @@ public sealed class DesignQuickBar : Window, IDisposable private void DrawRevertAdvancedCustomization(Vector2 buttonSize) { - if (!_config.QdbButtons.HasFlag(QdbButtons.RevertAdvanced)) + if (!_config.QdbButtons.HasFlag(QdbButtons.RevertAdvancedCustomization)) return; var available = 0; @@ -327,7 +329,7 @@ public sealed class DesignQuickBar : Window, IDisposable if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) { available |= 1; - _tooltipBuilder.Append("Left-Click: Revert the advanced customizations and dyes of the player character to their game state."); + _tooltipBuilder.Append("Left-Click: Revert the advanced customizations of the player character to their game state."); } if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) @@ -335,7 +337,40 @@ public sealed class DesignQuickBar : Window, IDisposable if (available != 0) _tooltipBuilder.Append('\n'); available |= 2; - _tooltipBuilder.Append("Right-Click: Revert the advanced customizations and dyes of ") + _tooltipBuilder.Append("Right-Click: Revert the advanced customizations of ") + .Append(_targetIdentifier) + .Append(" to their game state."); + } + + if (available == 0) + _tooltipBuilder.Append("Neither player character nor target are available or their state is locked."); + + var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.PaintBrush, buttonSize, available); + ImGui.SameLine(); + if (clicked) + _stateManager.ResetAdvancedCustomizations(state!, StateSource.Manual); + } + + private void DrawRevertAdvancedDyes(Vector2 buttonSize) + { + if (!_config.QdbButtons.HasFlag(QdbButtons.RevertAdvancedDyes)) + return; + + var available = 0; + _tooltipBuilder.Clear(); + + if (_playerIdentifier.IsValid && _playerState is { IsLocked: false } && _playerData.Valid) + { + available |= 1; + _tooltipBuilder.Append("Left-Click: Revert the advanced dyes of the player character to their game state."); + } + + if (_targetIdentifier.IsValid && _targetState is { IsLocked: false } && _targetData.Valid) + { + if (available != 0) + _tooltipBuilder.Append('\n'); + available |= 2; + _tooltipBuilder.Append("Right-Click: Revert the advanced dyes of ") .Append(_targetIdentifier) .Append(" to their game state."); } @@ -346,7 +381,7 @@ public sealed class DesignQuickBar : Window, IDisposable var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.Palette, buttonSize, available); ImGui.SameLine(); if (clicked) - _stateManager.ResetAdvancedState(state!, StateSource.Manual); + _stateManager.ResetAdvancedDyes(state!, StateSource.Manual); } private void DrawRevertCustomizeButton(Vector2 buttonSize) @@ -501,7 +536,7 @@ public sealed class DesignQuickBar : Window, IDisposable ++_numButtons; } - if (_config.QdbButtons.HasFlag(QdbButtons.RevertAdvanced)) + if (_config.QdbButtons.HasFlag(QdbButtons.RevertAdvancedCustomization)) ++_numButtons; if (_config.QdbButtons.HasFlag(QdbButtons.RevertCustomize)) ++_numButtons; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 746bb47..cf57824 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -251,7 +251,7 @@ public class SettingsTab( private void DrawQuickDesignBoxes() { var showAuto = config.EnableAutoDesigns; - var numColumns = 8 - (showAuto ? 0 : 2) - (config.UseTemporarySettings ? 0 : 1); + var numColumns = 9 - (showAuto ? 0 : 2) - (config.UseTemporarySettings ? 0 : 1); ImGui.NewLine(); ImUtf8.Text("Show the Following Buttons in the Quick Design Bar:"u8); ImGui.Dummy(Vector2.Zero); @@ -268,7 +268,8 @@ public class SettingsTab( ("Reapply Auto", showAuto, QdbButtons.ReapplyAutomation), ("Revert Equip", true, QdbButtons.RevertEquip), ("Revert Customize", true, QdbButtons.RevertCustomize), - ("Revert Advanced", true, QdbButtons.RevertAdvanced), + ("Revert Advanced Customization", true, QdbButtons.RevertAdvancedCustomization), + ("Revert Advanced Dyes", true, QdbButtons.RevertAdvancedDyes), ("Reset Settings", config.UseTemporarySettings, QdbButtons.ResetSettings), ]; diff --git a/Glamourer/Services/ConfigMigrationService.cs b/Glamourer/Services/ConfigMigrationService.cs index 3f997c9..ef39f1a 100644 --- a/Glamourer/Services/ConfigMigrationService.cs +++ b/Glamourer/Services/ConfigMigrationService.cs @@ -24,9 +24,20 @@ public class ConfigMigrationService(SaveService saveService, FixedDesignMigrator MigrateV4To5(); MigrateV5To6(); MigrateV6To7(); + MigrateV7To8(); AddColors(config, true); } + private void MigrateV7To8() + { + if (_config.Version > 7) + return; + + if (_config.QdbButtons.HasFlag(QdbButtons.RevertAdvancedDyes)) + _config.QdbButtons |= QdbButtons.RevertAdvancedCustomization; + _config.Version = 8; + } + private void MigrateV6To7() { if (_config.Version > 6) @@ -43,7 +54,7 @@ public class ConfigMigrationService(SaveService saveService, FixedDesignMigrator return; if (_data["ShowRevertAdvancedParametersButton"]?.ToObject() ?? true) - _config.QdbButtons |= QdbButtons.RevertAdvanced; + _config.QdbButtons |= QdbButtons.RevertAdvancedCustomization; _config.Version = 6; } diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 698151f..93a3450 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -411,6 +411,6 @@ public class StateApplier( return actors; } - private ActorData GetData(ActorState state) + public ActorData GetData(ActorState state) => _objects.TryGetValue(state.Identifier, out var data) ? data : ActorData.Invalid; } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 2dda310..98b12aa 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -270,16 +270,63 @@ public sealed class StateManager( state.Materials.Clear(); - var actors = ActorData.Invalid; + var objects = ActorData.Invalid; if (source is not StateSource.Game) - actors = Applier.ApplyAll(state, redraw, true); + objects = Applier.ApplyAll(state, redraw, true); Glamourer.Log.Verbose( - $"Reset entire state of {state.Identifier.Incognito(null)} to game base. [Affecting {actors.ToLazyString("nothing")}.]"); - StateChanged.Invoke(StateChangeType.Reset, source, state, actors, null); + $"Reset entire state of {state.Identifier.Incognito(null)} to game base. [Affecting {objects.ToLazyString("nothing")}.]"); + StateChanged.Invoke(StateChangeType.Reset, source, state, objects, null); // only invoke if we define this reset call as the final call in our state update. - if(isFinal) - StateFinalized.Invoke(StateFinalizationType.Revert, actors); + if (isFinal) + StateFinalized.Invoke(StateFinalizationType.Revert, objects); + } + + public void ResetAdvancedDyes(ActorState state, StateSource source, uint key = 0) + { + if (!state.Unlock(key) || !state.ModelData.IsHuman) + return; + + state.ModelData.Parameters = state.BaseData.Parameters; + + foreach (var flag in CustomizeParameterExtensions.AllFlags) + state.Sources[flag] = StateSource.Game; + + var objects = Applier.GetData(state); + if (source is not StateSource.Game) + foreach (var (idx, mat) in state.Materials.Values) + Applier.ChangeMaterialValue(state, objects, MaterialValueIndex.FromKey(idx), mat.Game); + + state.Materials.Clear(); + + Glamourer.Log.Verbose( + $"Reset advanced dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {objects.ToLazyString("nothing")}.]"); + StateChanged.Invoke(StateChangeType.Reset, source, state, objects, null); + // Update that we have completed a full operation. (We can do this directly as nothing else is linked) + StateFinalized.Invoke(StateFinalizationType.RevertAdvanced, objects); + } + + public void ResetAdvancedCustomizations(ActorState state, StateSource source, uint key = 0) + { + if (!state.Unlock(key) || !state.ModelData.IsHuman) + return; + + state.ModelData.Parameters = state.BaseData.Parameters; + + foreach (var flag in CustomizeParameterExtensions.AllFlags) + state.Sources[flag] = StateSource.Game; + + var objects = ActorData.Invalid; + if (source is not StateSource.Game) + objects = Applier.ChangeParameters(state, CustomizeParameterExtensions.All, true); + + state.Materials.Clear(); + + Glamourer.Log.Verbose( + $"Reset advanced customization and dye state of {state.Identifier.Incognito(null)} to game base. [Affecting {objects.ToLazyString("nothing")}.]"); + StateChanged.Invoke(StateChangeType.Reset, source, state, objects, null); + // Update that we have completed a full operation. (We can do this directly as nothing else is linked) + StateFinalized.Invoke(StateFinalizationType.RevertAdvanced, objects); } public void ResetAdvancedState(ActorState state, StateSource source, uint key = 0) @@ -468,7 +515,7 @@ public sealed class StateManager( || !actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false); StateChanged.Invoke(StateChangeType.Reapply, source, state, data, null); - if(isFinal) + if (isFinal) StateFinalized.Invoke(StateFinalizationType.Reapply, data); } From aa1ac291829f7f9948b8b10bcc8744f8fe4b7a04 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 21 May 2025 17:16:55 +0200 Subject: [PATCH 294/401] Make design selector resizable. --- Glamourer/EphemeralConfig.cs | 4 ++++ .../DesignTab/DesignFileSystemSelector.cs | 24 +++++++++++++++++++ Glamourer/Gui/Tabs/DesignTab/DesignTab.cs | 5 +--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Glamourer/EphemeralConfig.cs b/Glamourer/EphemeralConfig.cs index 3e13dc4..98dabec 100644 --- a/Glamourer/EphemeralConfig.cs +++ b/Glamourer/EphemeralConfig.cs @@ -20,6 +20,10 @@ public class EphemeralConfig : ISavable public Guid SelectedQuickDesign { get; set; } = Guid.Empty; public int LastSeenVersion { get; set; } = GlamourerChangelog.LastChangelogVersion; + public float CurrentDesignSelectorWidth { get; set; } = 200f; + public float DesignSelectorMinimumScale { get; set; } = 0.1f; + public float DesignSelectorMaximumScale { get; set; } = 0.5f; + [JsonIgnore] private readonly SaveService _saveService; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index ea117c5..11e803b 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -12,6 +12,7 @@ using OtterGui.Filesystem; using OtterGui.FileSystem.Selector; using OtterGui.Log; using OtterGui.Raii; +using OtterGui.Text; namespace Glamourer.Gui.Tabs.DesignTab; @@ -45,6 +46,29 @@ public sealed class DesignFileSystemSelector : FileSystemSelector _config.Ephemeral.CurrentDesignSelectorWidth * ImUtf8.GlobalScale; + + protected override float MinimumAbsoluteRemainder + => 470 * ImUtf8.GlobalScale; + + protected override float MinimumScaling + => _config.Ephemeral.DesignSelectorMinimumScale; + + protected override float MaximumScaling + => _config.Ephemeral.DesignSelectorMaximumScale; + + protected override void SetSize(Vector2 size) + { + base.SetSize(size); + var adaptedSize = MathF.Round(size.X / ImUtf8.GlobalScale); + if (adaptedSize == _config.Ephemeral.CurrentDesignSelectorWidth) + return; + + _config.Ephemeral.CurrentDesignSelectorWidth = adaptedSize; + _config.Ephemeral.Save(); + } + public DesignFileSystemSelector(DesignManager designManager, DesignFileSystem fileSystem, IKeyState keyState, DesignChanged @event, Configuration config, DesignConverter converter, TabSelected selectionEvent, Logger log, DesignColors designColors, DesignApplier designApplier) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs index 9832451..afb5900 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs @@ -16,7 +16,7 @@ public class DesignTab(DesignFileSystemSelector _selector, DesignPanel _panel, I public void DrawContent() { - _selector.Draw(GetDesignSelectorSize()); + _selector.Draw(); if (_importService.CreateCharaTarget(out var designBase, out var name)) { var newDesign = _manager.CreateClone(designBase, name, true); @@ -27,7 +27,4 @@ public class DesignTab(DesignFileSystemSelector _selector, DesignPanel _panel, I _panel.Draw(); _importService.CreateCharaSource(); } - - public float GetDesignSelectorSize() - => 200f * ImGuiHelpers.GlobalScale; } From f192c17c9bcb99b720b413b4aad16a095dafd8de Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 21 May 2025 17:46:56 +0200 Subject: [PATCH 295/401] Allow drag & drop for color buttons. --- .../CustomizationDrawer.Color.cs | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs index 4d34a05..4cc6ac3 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs @@ -4,13 +4,80 @@ using Glamourer.GameData; using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; +using OtterGui.Text.EndObjects; using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; +using System; namespace Glamourer.Gui.Customization; public partial class CustomizationDrawer { - private const string ColorPickerPopupName = "ColorPicker"; + private const string ColorPickerPopupName = "ColorPicker"; + private CustomizeValue _draggedColorValue; + private CustomizeIndex _draggedColorType; + + + private void DrawDragDropSource(CustomizeIndex index, CustomizeData custom) + { + using var dragDropSource = ImUtf8.DragDropSource(); + if (!dragDropSource) + return; + + if (!DragDropSource.SetPayload("##colorDragDrop"u8)) + _draggedColorValue = _customize[index]; + ImUtf8.Text( + $"Dragging {(custom.Color == 0 ? $"{_currentOption} (NPC)" : _currentOption)} #{_draggedColorValue.Value}..."); + _draggedColorType = index; + } + + private void DrawDragDropTarget(CustomizeIndex index) + { + using var dragDropTarget = ImUtf8.DragDropTarget(); + if (!dragDropTarget.Success || !dragDropTarget.IsDropping("##colorDragDrop"u8)) + return; + + var idx = _set.DataByValue(_draggedColorType, _draggedColorValue, out var draggedData, _customize.Face); + var bestMatch = _draggedColorValue; + if (draggedData.HasValue) + { + var draggedColor = draggedData.Value.Color; + var targetData = _set.Data(index, idx); + if (targetData.Color != draggedColor) + { + var bestDiff = Diff(targetData.Color, draggedColor); + var count = _set.Count(index); + for (var i = 0; i < count; ++i) + { + targetData = _set.Data(index, i); + if (targetData.Color == draggedColor) + { + UpdateValue(_draggedColorValue); + return; + } + + var diff = Diff(targetData.Color, draggedColor); + if (diff >= bestDiff) + continue; + + bestDiff = diff; + bestMatch = (CustomizeValue)i; + } + } + } + + UpdateValue(bestMatch); + return; + + static uint Diff(uint color1, uint color2) + { + var r = (color1 & 0xFF) - (color2 & 0xFF); + var g = ((color1 >> 8) & 0xFF) - ((color2 >> 8) & 0xFF); + var b = ((color1 >> 16) & 0xFF) - ((color2 >> 16) & 0xFF); + return 30 * r * r + 59 * g * g + 11 * b * b; + } + } private void DrawColorPicker(CustomizeIndex index) { @@ -21,7 +88,7 @@ public partial class CustomizationDrawer using (_ = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * ImGuiHelpers.GlobalScale, current < 0)) { - if (ImGui.ColorButton($"{_customize[index].Value}##color", color, ImGuiColorEditFlags.None, _framedIconSize)) + if (ImGui.ColorButton($"{_customize[index].Value}##color", color, ImGuiColorEditFlags.NoDragDrop, _framedIconSize)) { ImGui.OpenPopup(ColorPickerPopupName); } @@ -30,6 +97,9 @@ public partial class CustomizationDrawer var data = _set.Data(_currentIndex, current, _customize.Face); UpdateValue(data.Value); } + + DrawDragDropSource(index, custom); + DrawDragDropTarget(index); } var npc = false; From 74674cfa0c52d6e24dd63276a35e274c7ebdf29b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 23 May 2025 10:47:47 +0200 Subject: [PATCH 296/401] Make combos start from preview selection if possible. --- Glamourer/Gui/Customization/CustomizationDrawer.Color.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs | 8 -------- OtterGui | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs index 4cc6ac3..8db07ff 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs @@ -37,7 +37,7 @@ public partial class CustomizationDrawer using var dragDropTarget = ImUtf8.DragDropTarget(); if (!dragDropTarget.Success || !dragDropTarget.IsDropping("##colorDragDrop"u8)) return; - + var idx = _set.DataByValue(_draggedColorType, _draggedColorValue, out var draggedData, _customize.Face); var bestMatch = _draggedColorValue; if (draggedData.HasValue) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs b/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs index 9444ff7..0efa358 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs @@ -1,7 +1,6 @@ using Glamourer.Designs; using ImGuiNET; using OtterGui; -using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Widgets; @@ -13,13 +12,6 @@ public sealed class DesignColorCombo(DesignColors _designColors, bool _skipAutom : _designColors.Keys.OrderBy(k => k).Prepend(DesignColors.AutomaticName), MouseWheelType.Control, Glamourer.Log) { - protected override void OnMouseWheel(string preview, ref int current, int steps) - { - if (CurrentSelectionIdx < 0) - CurrentSelectionIdx = Items.IndexOf(preview); - base.OnMouseWheel(preview, ref current, steps); - } - protected override bool DrawSelectable(int globalIdx, bool selected) { var isAutomatic = !_skipAutomatic && globalIdx == 0; diff --git a/OtterGui b/OtterGui index 9aeda9a..421874a 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 9aeda9a892d9b971e32b10db21a8daf9c0b9ee53 +Subproject commit 421874a12540b7f8c1279dcc6a92e895a94d2fbc From b4485f028d29e0e2a99e20a348f819066224cc83 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 23 May 2025 15:21:14 +0200 Subject: [PATCH 297/401] Batch some multi-design changes to skip unnecessary computations. --- Glamourer/Designs/History/EditorHistory.cs | 4 +- Glamourer/Gui/DesignCombo.cs | 50 ++++++++++++++++++- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 24 +++++++-- Glamourer/Services/ServiceManager.cs | 3 +- OtterGui | 2 +- 5 files changed, 75 insertions(+), 8 deletions(-) diff --git a/Glamourer/Designs/History/EditorHistory.cs b/Glamourer/Designs/History/EditorHistory.cs index 58bce3d..caec151 100644 --- a/Glamourer/Designs/History/EditorHistory.cs +++ b/Glamourer/Designs/History/EditorHistory.cs @@ -152,7 +152,7 @@ public class EditorHistory : IDisposable, IService { if (!_stateEntries.TryGetValue(state, out var list)) { - list = new Queue(); + list = []; _stateEntries.Add(state, list); } @@ -163,7 +163,7 @@ public class EditorHistory : IDisposable, IService { if (!_designEntries.TryGetValue(design, out var list)) { - list = new Queue(); + list = []; _designEntries.Add(design, list); } diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index a871cf1..c1e474d 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -10,6 +10,7 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; using OtterGui.Log; +using OtterGui.Services; using OtterGui.Widgets; namespace Glamourer.Gui; @@ -21,6 +22,7 @@ public abstract class DesignComboBase : FilterComboCache>> generator, Logger log, DesignChanged designChanged, @@ -32,6 +34,7 @@ public abstract class DesignComboBase : FilterComboCache Combos = services.GetServicesImplementing().ToArray(); + + internal DesignComboListener StopListening() + { + var list = new List(Combos.Count); + foreach (var combo in Combos.Where(c => c.IsListening)) + { + combo.StopListening(); + list.Add(combo); + } + + return new DesignComboListener(list); + } + + internal readonly struct DesignComboListener(List combos) : IDisposable + { + public void Dispose() + { + foreach (var combo in combos) + combo.StartListening(); + } + } +} diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 3567fb6..ec8b465 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -3,7 +3,6 @@ using Dalamud.Interface.Utility; using Glamourer.Designs; using Glamourer.Interop.Material; using ImGuiNET; -using OtterGui; using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; @@ -11,7 +10,12 @@ using static Glamourer.Gui.Tabs.HeaderDrawer; namespace Glamourer.Gui.Tabs.DesignTab; -public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager editor, DesignColors colors, Configuration config) +public class MultiDesignPanel( + DesignFileSystemSelector selector, + DesignManager editor, + DesignColors colors, + Configuration config, + DesignComboWrapper combos) { private readonly Button[] _leftButtons = []; private readonly Button[] _rightButtons = [new IncognitoButton(config)]; @@ -201,16 +205,23 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e ? $"All {_numDesigns} selected designs are already displayed in the quick design bar." : $"Display all {_numDesigns} selected designs in the quick design bar. Changes {diff} designs."; if (ImUtf8.ButtonEx("Display Selected Designs in QDB"u8, tt, buttonWidth, diff == 0)) + { + using var disableListener = combos.StopListening(); foreach (var design in selector.SelectedPaths.OfType()) editor.SetQuickDesign(design.Value, true); + } ImGui.SameLine(); tt = _numQuickDesignEnabled == 0 ? $"All {_numDesigns} selected designs are already hidden in the quick design bar." : $"Hide all {_numDesigns} selected designs in the quick design bar. Changes {_numQuickDesignEnabled} designs."; if (ImUtf8.ButtonEx("Hide Selected Designs in QDB"u8, tt, buttonWidth, _numQuickDesignEnabled == 0)) + { + using var disableListener = combos.StopListening(); foreach (var design in selector.SelectedPaths.OfType()) editor.SetQuickDesign(design.Value, false); + } + ImGui.Separator(); } @@ -327,8 +338,11 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e : $"Set the color of {_addDesigns.Count} designs to \"{_colorCombo.CurrentSelection}\"\n\n\t{string.Join("\n\t", _addDesigns.Select(m => m.Name.Text))}"; ImGui.SameLine(); if (ImUtf8.ButtonEx(label, tooltip, width, _addDesigns.Count == 0)) + { + using var disableListener = combos.StopListening(); foreach (var design in _addDesigns) editor.ChangeColor(design, _colorCombo.CurrentSelection!); + } label = _removeDesigns.Count > 0 ? $"Unset {_removeDesigns.Count} Designs" @@ -338,8 +352,11 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e : $"Set {_removeDesigns.Count} designs to use automatic color again:\n\n\t{string.Join("\n\t", _removeDesigns.Select(m => m.Item1.Name.Text))}"; ImGui.SameLine(); if (ImUtf8.ButtonEx(label, tooltip, width, _removeDesigns.Count == 0)) + { + using var disableListener = combos.StopListening(); foreach (var (design, _) in _removeDesigns) editor.ChangeColor(design, string.Empty); + } ImGui.Separator(); } @@ -455,7 +472,8 @@ public class MultiDesignPanel(DesignFileSystemSelector selector, DesignManager e foreach (var design in selector.SelectedPaths.OfType().Select(l => l.Value)) { - editor.ChangeApplyMulti(design, equip, customize, equip, customize.HasValue && !customize.Value ? false : null, null, equip, equip, equip); + editor.ChangeApplyMulti(design, equip, customize, equip, customize.HasValue && !customize.Value ? false : null, null, equip, equip, + equip); if (equip.HasValue) { editor.ChangeApplyMeta(design, MetaIndex.HatState, equip.Value); diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 0754313..6c30d68 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -169,5 +169,6 @@ public static class StaticServiceManager .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton(); + .AddSingleton() + .AddSingleton(); } diff --git a/OtterGui b/OtterGui index 421874a..cee50c3 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 421874a12540b7f8c1279dcc6a92e895a94d2fbc +Subproject commit cee50c3fe97a03ca7445c81de651b609620da526 From 5b59e74417e0fc3d90ea4b7a66be4972bc2cadd3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 27 May 2025 12:06:29 +0200 Subject: [PATCH 298/401] Use CS ReadStainingTemplate again. --- Glamourer/Interop/Material/PrepareColorSet.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index dfa6811..cf9be19 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -1,5 +1,4 @@ using Dalamud.Hooking; -using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; @@ -51,10 +50,6 @@ public sealed unsafe class PrepareColorSet private delegate Texture* Delegate(MaterialResourceHandle* material, StainId stainId1, StainId stainId2); - // TODO use CS when stabilized in Dalamud. - [Signature("E8 ?? ?? ?? ?? 48 8B FB EB 07")] - private static delegate* unmanaged _readStainingTemplate = null; - private Texture* Detour(MaterialResourceHandle* material, StainId stainId1, StainId stainId2) { Glamourer.Log.Excessive($"[{Name}] Triggered with 0x{(nint)material:X} {stainId1.Id} {stainId2.Id}."); @@ -84,10 +79,10 @@ public sealed unsafe class PrepareColorSet if (GetDyeTable(material, out var dyeTable)) { if (stainIds.Stain1.Id != 0) - _readStainingTemplate(material, dyeTable, stainIds.Stain1.Id, (Half*)(&newTable), 0); + MaterialResourceHandle.MemberFunctionPointers.ReadStainingTemplate(material, dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 0); if (stainIds.Stain2.Id != 0) - _readStainingTemplate(material, dyeTable, stainIds.Stain2.Id, (Half*)(&newTable), 1); + MaterialResourceHandle.MemberFunctionPointers.ReadStainingTemplate(material, dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 1); } table = newTable; From 07df3186c28e4e549075cb0ba3c73826a4e5e97b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 27 May 2025 14:38:04 +0200 Subject: [PATCH 299/401] Better. --- Glamourer/Interop/Material/PrepareColorSet.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index cf9be19..342bb74 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -79,10 +79,10 @@ public sealed unsafe class PrepareColorSet if (GetDyeTable(material, out var dyeTable)) { if (stainIds.Stain1.Id != 0) - MaterialResourceHandle.MemberFunctionPointers.ReadStainingTemplate(material, dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 0); + material->ReadStainingTemplate(dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 0); if (stainIds.Stain2.Id != 0) - MaterialResourceHandle.MemberFunctionPointers.ReadStainingTemplate(material, dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 1); + material->ReadStainingTemplate(dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 1); } table = newTable; From a0d2c39f45ba17e12c931c64c3d717018177e089 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 28 May 2025 13:56:06 +0200 Subject: [PATCH 300/401] 1.4.0.0 --- Glamourer.Api | 2 +- Glamourer/Gui/GlamourerChangelog.cs | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Glamourer.Api b/Glamourer.Api index 9c86a9d..64897c0 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 9c86a9d6847f68e75679fe57d34f53f680d949c6 +Subproject commit 64897c069d3b6c3fe027b3ae0e832828728b9108 diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index e12b32e..a62743c 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -42,6 +42,7 @@ public class GlamourerChangelog Add1_3_6_0(Changelog); Add1_3_7_0(Changelog); Add1_3_8_0(Changelog); + Add1_4_0_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -62,6 +63,31 @@ public class GlamourerChangelog } } + private static void Add1_4_0_0(Changelog log) + => log.NextVersion("Version 1.4.0.0") + .RegisterHighlight("The design selector width is now draggable within certain restrictions that depend on the total window width.") + .RegisterEntry("The current behavior may not be final, let me know if you have any comments.", 1) + .RegisterEntry("Regular customization colors can now be dragged & dropped onto other customizations.") + .RegisterEntry( + "If no identical color is available in the target slot, the most similar color available (for certain values of similar) will be chosen instead.", + 1) + .RegisterEntry("Resetting advanced dyes and customizations has been split into two buttons for the quick design bar.") + .RegisterEntry("Weapons now also support custom ID input in the combo search box.") + .RegisterEntry("Added new IPC methods GetExtendedDesignData, AddDesign, DeleteDesign, GetDesignBase64, GetDesignJObject.") + .RegisterEntry("Added the option to prevent immediate repeats for random design selection (Thanks Diorik!).") + .RegisterEntry("Optimized some multi-design changes when selecting many designs and changing them at once.") + .RegisterEntry("Fixed item combos not starting from the currently selected item when scrolling them via mouse wheel.") + .RegisterEntry("Fixed some issue with Glamourer not searching mods by name for mod associations in some cases.") + .RegisterEntry("Fixed the IPC methods SetMetaState and SetMetaStateName not working (Thanks Caraxi!).") + .RegisterEntry("Added new IPC method GetDesignListExtended. (1.3.8.6)") + .RegisterEntry( + "Improved the naming of NPCs for identifiers by using Haselnussbombers new naming functionality (Thanks Hasel!). (1.3.8.6)") + .RegisterEntry( + "Added a modifier key separate from the delete modifier key that is used for less important key-checks, specifically toggling incognito mode. (1.3.8.5)") + .RegisterEntry("Used better Penumbra IPC for some things. (1.3.8.5)") + .RegisterEntry("Fixed an issue with advanced dyes for weapons. (1.3.8.5)") + .RegisterEntry("Fixed an issue with NPC automation due to missing job detection. (1.3.8.1)"); + private static void Add1_3_8_0(Changelog log) => log.NextVersion("Version 1.3.8.0") .RegisterImportant("Updated Glamourer for update 7.20 and Dalamud API 12.") From b8e1e7c3842ec602997b4ef2f724f030093d7858 Mon Sep 17 00:00:00 2001 From: Actions User Date: Wed, 28 May 2025 11:58:09 +0000 Subject: [PATCH 301/401] [CI] Updating repo.json for 1.4.0.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 3f1f29b..2ac55a2 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.3.8.6", - "TestingAssemblyVersion": "1.3.8.6", + "AssemblyVersion": "1.4.0.0", + "TestingAssemblyVersion": "1.4.0.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.6/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.6/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.3.8.6/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 56bbf6593af82af67008177bcac08ab96c8721b0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 29 May 2025 02:55:11 +0200 Subject: [PATCH 302/401] Fix button counting. --- Glamourer/Gui/DesignQuickBar.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index b64a5f2..d83fce9 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -538,6 +538,8 @@ public sealed class DesignQuickBar : Window, IDisposable if (_config.QdbButtons.HasFlag(QdbButtons.RevertAdvancedCustomization)) ++_numButtons; + if (_config.QdbButtons.HasFlag(QdbButtons.RevertAdvancedDyes)) + ++_numButtons; if (_config.QdbButtons.HasFlag(QdbButtons.RevertCustomize)) ++_numButtons; if (_config.QdbButtons.HasFlag(QdbButtons.RevertEquip)) From 66bed4217f01fb85bbee7024a50afaf0412f4d85 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 29 May 2025 02:55:20 +0200 Subject: [PATCH 303/401] Fix staining template reading. --- Glamourer/Interop/Material/PrepareColorSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 342bb74..f52bb68 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -82,7 +82,7 @@ public sealed unsafe class PrepareColorSet material->ReadStainingTemplate(dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 0); if (stainIds.Stain2.Id != 0) - material->ReadStainingTemplate(dyeTable, stainIds.Stain1.Id, (Half*)&newTable, 1); + material->ReadStainingTemplate(dyeTable, stainIds.Stain2.Id, (Half*)&newTable, 1); } table = newTable; From d7b189b7148ec92052b16119afaadea93cc86acb Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 29 May 2025 00:57:24 +0000 Subject: [PATCH 304/401] [CI] Updating repo.json for 1.4.0.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 2ac55a2..47bc610 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.4.0.0", - "TestingAssemblyVersion": "1.4.0.0", + "AssemblyVersion": "1.4.0.1", + "TestingAssemblyVersion": "1.4.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 282935c6d677417ff371b075e9541bfb4b17b001 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 3 Jun 2025 18:40:41 +0200 Subject: [PATCH 305/401] Allow drag & drop of equipment pieces. --- Glamourer/Gui/Equipment/EquipItemSlotCache.cs | 83 +++++++++++++++++++ Glamourer/Gui/Equipment/EquipmentDrawer.cs | 56 ++++++++++++- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 1 + Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 1 + Glamourer/Services/ItemManager.cs | 30 +++++++ Penumbra.Api | 2 +- 6 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 Glamourer/Gui/Equipment/EquipItemSlotCache.cs diff --git a/Glamourer/Gui/Equipment/EquipItemSlotCache.cs b/Glamourer/Gui/Equipment/EquipItemSlotCache.cs new file mode 100644 index 0000000..20aaf11 --- /dev/null +++ b/Glamourer/Gui/Equipment/EquipItemSlotCache.cs @@ -0,0 +1,83 @@ +using Glamourer.Services; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; + +namespace Glamourer.Gui.Equipment; + +[InlineArray(13)] +public struct EquipItemSlotCache +{ + private EquipItem _element; + + public EquipItem Dragged + { + get => this[^1]; + set => this[^1] = value; + } + + public void Clear() + => ((Span)this).Clear(); + + public EquipItem this[EquipSlot slot] + { + get => this[(int)slot.ToIndex()]; + set => this[(int)slot.ToIndex()] = value; + } + + public void Update(ItemManager items, in EquipItem item, EquipSlot startSlot) + { + if (item.Id == Dragged.Id && item.Type == Dragged.Type) + return; + + switch (startSlot) + { + case EquipSlot.MainHand: + { + Clear(); + this[EquipSlot.MainHand] = item; + if (item.Type is FullEquipType.Sword) + this[EquipSlot.OffHand] = items.FindClosestShield(item.ItemId, out var shield) ? shield : default; + else + this[EquipSlot.OffHand] = items.ItemData.Secondary.GetValueOrDefault(item.ItemId); + break; + } + case EquipSlot.OffHand: + { + Clear(); + if (item.Type is FullEquipType.Shield) + this[EquipSlot.MainHand] = items.FindClosestSword(item.ItemId, out var sword) ? sword : default; + else + this[EquipSlot.MainHand] = items.ItemData.Primary.GetValueOrDefault(item.ItemId); + this[EquipSlot.OffHand] = item; + break; + } + default: + { + this[EquipSlot.MainHand] = default; + this[EquipSlot.OffHand] = default; + foreach (var slot in EquipSlotExtensions.EqdpSlots) + { + if (startSlot == slot) + { + this[slot] = item; + continue; + } + + var slotItem = items.Identify(slot, item.PrimaryId, item.Variant); + if (!slotItem.Valid || slotItem.ItemId.Id is not 0 != item.ItemId.Id is not 0) + { + slotItem = items.Identify(EquipSlot.OffHand, item.PrimaryId, item.SecondaryId, 1, item.Type); + if (slotItem.ItemId.Id is not 0 != item.ItemId.Id is not 0) + slotItem = default; + } + + this[slot] = slotItem; + } + + break; + } + } + + Dragged = item; + } +} diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index f2ecc08..43fda84 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -37,7 +37,9 @@ public class EquipmentDrawer private float _requiredComboWidthUnscaled; private float _requiredComboWidth; - private Stain? _draggedStain; + private Stain? _draggedStain; + private EquipItemSlotCache _draggedItem; + private EquipSlot _dragTarget; public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, TextureService textures, Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes, ItemCopyService itemCopy) @@ -80,6 +82,7 @@ public class EquipmentDrawer _requiredComboWidth = _requiredComboWidthUnscaled * ImGuiHelpers.GlobalScale; _advancedMaterialColor = ColorId.AdvancedDyeActive.Value(); + _dragTarget = EquipSlot.Unknown; } private bool VerifyRestrictedGear(EquipDrawData data) @@ -429,8 +432,8 @@ public class EquipmentDrawer using var dragSource = ImUtf8.DragDropSource(); if (dragSource.Success) { - if (DragDropSource.SetPayload("stainDragDrop"u8)) - _draggedStain = stain; + DragDropSource.SetPayload("stainDragDrop"u8); + _draggedStain = stain; ImUtf8.Text($"Dragging {stain.Name}..."); } } @@ -455,6 +458,7 @@ public class EquipmentDrawer using var disabled = ImRaii.Disabled(data.Locked); var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth); + DrawGearDragDrop(data); if (change) data.SetItem(combo.CurrentSelection); else if (combo.CustomVariant.Id > 0) @@ -495,6 +499,50 @@ public class EquipmentDrawer data.SetItem(item); } + private void DrawGearDragDrop(in EquipDrawData data) + { + if (data.CurrentItem.Valid) + { + using var dragSource = ImUtf8.DragDropSource(); + if (dragSource.Success) + { + DragDropSource.SetPayload("equipDragDrop"u8); + _draggedItem.Update(_items, data.CurrentItem, data.Slot); + } + } + + using var dragTarget = ImUtf8.DragDropTarget(); + if (!dragTarget) + return; + + var item = _draggedItem[data.Slot]; + if (!item.Valid) + return; + + _dragTarget = data.Slot; + if (!dragTarget.IsDropping("equipDragDrop"u8)) + return; + + data.SetItem(item); + _draggedItem.Clear(); + } + + public unsafe void DrawDragDropTooltip() + { + var payload = ImGui.GetDragDropPayload().NativePtr; + if (payload is null) + return; + + if (!MemoryMarshal.CreateReadOnlySpanFromNullTerminated(payload->DataType).SequenceEqual("equipDragDrop"u8)) + return; + + using var tt = ImUtf8.Tooltip(); + if (_dragTarget is EquipSlot.Unknown) + ImUtf8.Text($"Dragging {_draggedItem.Dragged.Name}..."); + else + ImUtf8.Text($"Converting to {_draggedItem[_dragTarget].Name}..."); + } + private static bool ResetOrClear(bool locked, bool clicked, bool allowRevert, bool allowClear, in T currentItem, in T revertItem, in T clearItem, out T? item) where T : IEquatable { @@ -546,6 +594,7 @@ public class EquipmentDrawer else if (combo.CustomVariant.Id > 0 && (drawAll || ItemData.ConvertWeaponId(combo.CustomSetId) == mainhand.CurrentItem.Type)) changedItem = _items.Identify(mainhand.Slot, combo.CustomSetId, combo.CustomWeaponId, combo.CustomVariant); _itemCopy.HandleCopyPaste(mainhand); + DrawGearDragDrop(mainhand); if (ResetOrClear(mainhand.Locked || unknown, open, mainhand.AllowRevert, false, mainhand.CurrentItem, mainhand.GameItem, default, out var c)) @@ -589,6 +638,7 @@ public class EquipmentDrawer else if (combo.CustomVariant.Id > 0 && ItemData.ConvertWeaponId(combo.CustomSetId) == offhand.CurrentItem.Type) offhand.SetItem(_items.Identify(mainhand.Slot, combo.CustomSetId, combo.CustomWeaponId, combo.CustomVariant)); _itemCopy.HandleCopyPaste(offhand); + DrawGearDragDrop(offhand); var defaultOffhand = _items.GetDefaultOffhand(mainhand.CurrentItem); if (ResetOrClear(locked, clear, offhand.AllowRevert, true, offhand.CurrentItem, offhand.GameItem, defaultOffhand, out var item)) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 5419f23..98d9157 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -238,6 +238,7 @@ public class ActorPanel ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); DrawEquipmentMetaToggles(); ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + _equipmentDrawer.DrawDragDropTooltip(); } private void DrawParameterHeader() diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 65014a4..d2b98b2 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -130,6 +130,7 @@ public class DesignPanel ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); DrawEquipmentMetaToggles(); ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + _equipmentDrawer.DrawDragDropTooltip(); } private void DrawEquipmentMetaToggles() diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 5d6f074..2cc6461 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -174,6 +174,36 @@ public class ItemManager return NothingItem(offhandType); } + public bool FindClosestShield(ItemId id, out EquipItem item) + { + var list = ItemData.ByType[FullEquipType.Shield]; + try + { + item = list.Where(i => i.ItemId.Id > id.Id && i.ItemId.Id - id.Id < 50).MinBy(i => i.ItemId.Id); + return true; + } + catch + { + item = default; + return false; + } + } + + public bool FindClosestSword(ItemId id, out EquipItem item) + { + var list = ItemData.ByType[FullEquipType.Sword]; + try + { + item = list.Where(i => i.ItemId.Id < id.Id && id.Id - i.ItemId.Id < 50).MaxBy(i => i.ItemId.Id); + return true; + } + catch + { + item = default; + return false; + } + } + public EquipItem Identify(EquipSlot slot, PrimaryId id, SecondaryId type, Variant variant, FullEquipType mainhandType = FullEquipType.Unknown) { diff --git a/Penumbra.Api b/Penumbra.Api index 574ef3a..ff7b3b4 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 574ef3a8afd42b949e713e247a0b812886f088bb +Subproject commit ff7b3b4014a97455f823380c78b8a7c5107f8e2f From 75c76a92b9aa08d351f0979a2daa816c37fbe5d5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 13 Jun 2025 17:17:58 +0200 Subject: [PATCH 306/401] Optimize design combos and file system. --- Glamourer/Api/DesignsApi.cs | 6 +- Glamourer/Designs/DesignFileSystem.cs | 13 +- Glamourer/Designs/Special/RandomPredicate.cs | 2 +- Glamourer/Gui/DesignCombo.cs | 153 +++++++----------- .../AutomationTab/RandomRestrictionDrawer.cs | 2 +- .../Gui/Tabs/DebugTab/DesignManagerPanel.cs | 28 +++- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 7 +- Glamourer/Services/ServiceManager.cs | 3 +- OtterGui | 2 +- 9 files changed, 92 insertions(+), 124 deletions(-) diff --git a/Glamourer/Api/DesignsApi.cs b/Glamourer/Api/DesignsApi.cs index e21e6cb..9b48ade 100644 --- a/Glamourer/Api/DesignsApi.cs +++ b/Glamourer/Api/DesignsApi.cs @@ -20,12 +20,12 @@ public class DesignsApi( => designs.Designs.ToDictionary(d => d.Identifier, d => d.Name.Text); public Dictionary GetDesignListExtended() - => designs.Designs.ToDictionary(d => d.Identifier, - d => (d.Name.Text, fileSystem.FindLeaf(d, out var leaf) ? leaf.FullName() : d.Name.Text, color.GetColor(d), d.QuickDesign)); + => fileSystem.ToDictionary(kvp => kvp.Key.Identifier, + kvp => (kvp.Key.Name.Text, kvp.Value.FullName(), color.GetColor(kvp.Key), kvp.Key.QuickDesign)); public (string DisplayName, string FullPath, uint DisplayColor, bool ShowInQdb) GetExtendedDesignData(Guid designId) => designs.Designs.ByIdentifier(designId) is { } d - ? (d.Name.Text, fileSystem.FindLeaf(d, out var leaf) ? leaf.FullName() : d.Name.Text, color.GetColor(d), d.QuickDesign) + ? (d.Name.Text, fileSystem.TryGetValue(d, out var leaf) ? leaf.FullName() : d.Name.Text, color.GetColor(d), d.QuickDesign) : (string.Empty, string.Empty, 0, false); public GlamourerApiEc ApplyDesign(Guid designId, int objectIndex, uint key, ApplyFlag flags) diff --git a/Glamourer/Designs/DesignFileSystem.cs b/Glamourer/Designs/DesignFileSystem.cs index e985e32..4a1cb3d 100644 --- a/Glamourer/Designs/DesignFileSystem.cs +++ b/Glamourer/Designs/DesignFileSystem.cs @@ -114,14 +114,14 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable return; case DesignChanged.Type.Deleted: - if (FindLeaf(design, out var leaf1)) + if (TryGetValue(design, out var leaf1)) Delete(leaf1); return; case DesignChanged.Type.ReloadedAll: Reload(); return; case DesignChanged.Type.Renamed when (data as RenameTransaction?)?.Old is { } oldName: - if (!FindLeaf(design, out var leaf2)) + if (!TryGetValue(design, out var leaf2)) return; var old = oldName.FixName(); @@ -150,15 +150,6 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable ? (string.Empty, false) : (DesignToIdentifier(design), true); - // Search the entire filesystem for the leaf corresponding to a design. - public bool FindLeaf(Design design, [NotNullWhen(true)] out Leaf? leaf) - { - leaf = Root.GetAllDescendants(ISortMode.Lexicographical) - .OfType() - .FirstOrDefault(l => l.Value == design); - return leaf != null; - } - internal static void MigrateOldPaths(SaveService saveService, Dictionary oldPaths) { if (oldPaths.Count == 0) diff --git a/Glamourer/Designs/Special/RandomPredicate.cs b/Glamourer/Designs/Special/RandomPredicate.cs index efb3233..ae05f8f 100644 --- a/Glamourer/Designs/Special/RandomPredicate.cs +++ b/Glamourer/Designs/Special/RandomPredicate.cs @@ -22,7 +22,7 @@ public interface IDesignPredicate : designs; private static (Design Design, string LowerName, string Identifier, string LowerPath) Transform(Design d, DesignFileSystem fs) - => (d, d.Name.Lower, d.Identifier.ToString(), fs.FindLeaf(d, out var l) ? l.FullName().ToLowerInvariant() : string.Empty); + => (d, d.Name.Lower, d.Identifier.ToString(), fs.TryGetValue(d, out var l) ? l.FullName().ToLowerInvariant() : string.Empty); } public static class RandomPredicate diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index c1e474d..e5f3785 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -10,7 +10,6 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; using OtterGui.Log; -using OtterGui.Services; using OtterGui.Widgets; namespace Glamourer.Gui; @@ -22,8 +21,8 @@ public abstract class DesignComboBase : FilterComboCache>> generator, Logger log, DesignChanged designChanged, TabSelected tabSelected, EphemeralConfig config, DesignColors designColors) @@ -34,7 +33,6 @@ public abstract class DesignComboBase : FilterComboCache _currentDesign == p.Item1); - UpdateSelection(CurrentSelectionIdx >= 0 ? Items[CurrentSelectionIdx] : null); - return CurrentSelectionIdx; - } - protected bool Draw(IDesignStandIn? currentDesign, string? label, float width) { _currentDesign = currentDesign; - InnerWidth = 400 * ImGuiHelpers.GlobalScale; + UpdateCurrentSelection(); + InnerWidth = 400 * ImGuiHelpers.GlobalScale; var name = label ?? "Select Design Here..."; bool ret; using (_ = currentDesign != null ? ImRaii.PushColor(ImGuiCol.Text, DesignColors.GetColor(currentDesign as Design)) : null) @@ -150,37 +123,52 @@ public abstract class DesignComboBase : FilterComboCache ReferenceEquals(s.Item1, CurrentSelection?.Item1)); + if (CurrentSelectionIdx >= 0) + { + UpdateSelection(Items[CurrentSelectionIdx]); + } + else if (Items.Count > 0) + { + CurrentSelectionIdx = 0; + UpdateSelection(Items[0]); + } + else + { + UpdateSelection(null); + } + + if (!priorState) + Cleanup(); + _isCurrentSelectionDirty = false; + } + + protected override int UpdateCurrentSelected(int currentSelected) + { + CurrentSelectionIdx = Items.IndexOf(p => _currentDesign == p.Item1); + UpdateSelection(CurrentSelectionIdx >= 0 ? Items[CurrentSelectionIdx] : null); + return CurrentSelectionIdx; + } + private void OnDesignChanged(DesignChanged.Type type, Design? _1, ITransaction? _2 = null) { - switch (type) + _isCurrentSelectionDirty = type switch { - case DesignChanged.Type.Created: - case DesignChanged.Type.Renamed: - case DesignChanged.Type.ChangedColor: - case DesignChanged.Type.Deleted: - case DesignChanged.Type.QuickDesignBar: - var priorState = IsInitialized; - if (priorState) - Cleanup(); - CurrentSelectionIdx = Items.IndexOf(s => ReferenceEquals(s.Item1, CurrentSelection?.Item1)); - if (CurrentSelectionIdx >= 0) - { - UpdateSelection(Items[CurrentSelectionIdx]); - } - else if (Items.Count > 0) - { - CurrentSelectionIdx = 0; - UpdateSelection(Items[0]); - } - else - { - UpdateSelection(null); - } - - if (!priorState) - Cleanup(); - break; - } + DesignChanged.Type.Created => true, + DesignChanged.Type.Renamed => true, + DesignChanged.Type.ChangedColor => true, + DesignChanged.Type.Deleted => true, + DesignChanged.Type.QuickDesignBar => true, + _ => _isCurrentSelectionDirty, + }; } private void QuickSelectedDesignTooltip(IDesignStandIn? design) @@ -248,8 +236,7 @@ public abstract class DesignCombo : DesignComboBase public sealed class QuickDesignCombo : DesignCombo { - public QuickDesignCombo(DesignManager designs, - DesignFileSystem fileSystem, + public QuickDesignCombo(DesignFileSystem fileSystem, Logger log, DesignChanged designChanged, TabSelected tabSelected, @@ -257,9 +244,9 @@ public sealed class QuickDesignCombo : DesignCombo DesignColors designColors) : base(log, designChanged, tabSelected, config, designColors, () => [ - .. designs.Designs - .Where(d => d.QuickDesign) - .Select(d => new Tuple(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty)) + .. fileSystem + .Where(kvp => kvp.Key.QuickDesign) + .Select(kvp => new Tuple(kvp.Key, kvp.Value.FullName())) .OrderBy(d => d.Item2), ]) { @@ -300,7 +287,6 @@ public sealed class QuickDesignCombo : DesignCombo } public sealed class LinkDesignCombo( - DesignManager designs, DesignFileSystem fileSystem, Logger log, DesignChanged designChanged, @@ -309,8 +295,8 @@ public sealed class LinkDesignCombo( DesignColors designColors) : DesignCombo(log, designChanged, tabSelected, config, designColors, () => [ - .. designs.Designs - .Select(d => new Tuple(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty)) + .. fileSystem + .Select(kvp => new Tuple(kvp.Key, kvp.Value.FullName())) .OrderBy(d => d.Item2), ]); @@ -324,8 +310,8 @@ public sealed class RandomDesignCombo( DesignColors designColors) : DesignCombo(log, designChanged, tabSelected, config, designColors, () => [ - .. designs.Designs - .Select(d => new Tuple(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty)) + .. fileSystem + .Select(kvp => new Tuple(kvp.Key, kvp.Value.FullName())) .OrderBy(d => d.Item2), ]) { @@ -351,7 +337,6 @@ public sealed class RandomDesignCombo( } public sealed class SpecialDesignCombo( - DesignManager designs, DesignFileSystem fileSystem, TabSelected tabSelected, DesignColors designColors, @@ -361,8 +346,8 @@ public sealed class SpecialDesignCombo( EphemeralConfig config, RandomDesignGenerator rng, QuickSelectedDesign quickSelectedDesign) - : DesignComboBase(() => designs.Designs - .Select(d => new Tuple(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty)) + : DesignComboBase(() => fileSystem + .Select(kvp => new Tuple(kvp.Key, kvp.Value.FullName())) .OrderBy(d => d.Item2) .Prepend(new Tuple(new RandomDesign(rng), string.Empty)) .Prepend(new Tuple(quickSelectedDesign, string.Empty)) @@ -380,29 +365,3 @@ public sealed class SpecialDesignCombo( autoDesignManager.AddDesign(set, CurrentSelection!.Item1); } } - -public class DesignComboWrapper(ServiceManager services) -{ - public readonly IReadOnlyList Combos = services.GetServicesImplementing().ToArray(); - - internal DesignComboListener StopListening() - { - var list = new List(Combos.Count); - foreach (var combo in Combos.Where(c => c.IsListening)) - { - combo.StopListening(); - list.Add(combo); - } - - return new DesignComboListener(list); - } - - internal readonly struct DesignComboListener(List combos) : IDisposable - { - public void Dispose() - { - foreach (var combo in combos) - combo.StartListening(); - } - } -} diff --git a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs index e7efc09..ae3be7e 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs @@ -278,7 +278,7 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void LookupTooltip(IEnumerable designs) { using var _ = ImRaii.Tooltip(); - var tt = string.Join('\n', designs.Select(d => _designFileSystem.FindLeaf(d, out var l) ? l.FullName() : d.Name.Text).OrderBy(t => t)); + var tt = string.Join('\n', designs.Select(d => _designFileSystem.TryGetValue(d, out var l) ? l.FullName() : d.Name.Text).OrderBy(t => t)); ImGui.TextUnformatted(tt.Length == 0 ? "Matches no currently existing designs." : "Matches the following designs:"); diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs index ede3e9e..342bc41 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs @@ -3,7 +3,9 @@ using Glamourer.Designs; using ImGuiNET; using OtterGui; using OtterGui.Extensions; +using OtterGui.Filesystem; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; @@ -19,6 +21,7 @@ public class DesignManagerPanel(DesignManager _designManager, DesignFileSystem _ public void Draw() { + DrawButtons(); foreach (var (design, idx) in _designManager.Designs.WithIndex()) { using var t = ImRaii.TreeNode($"{design.Name}##{idx}"); @@ -26,7 +29,8 @@ public class DesignManagerPanel(DesignManager _designManager, DesignFileSystem _ continue; DrawDesign(design, _designFileSystem); - var base64 = DesignBase64Migration.CreateOldBase64(design.DesignData, design.Application.Equip, design.Application.Customize, design.Application.Meta, + var base64 = DesignBase64Migration.CreateOldBase64(design.DesignData, design.Application.Equip, design.Application.Customize, + design.Application.Meta, design.WriteProtected()); using var font = ImRaii.PushFont(UiBuilder.MonoFont); ImGuiUtil.TextWrapped(base64); @@ -35,6 +39,26 @@ public class DesignManagerPanel(DesignManager _designManager, DesignFileSystem _ } } + private void DrawButtons() + { + if (ImUtf8.Button("Generate 500 Test Designs"u8)) + for (var i = 0; i < 500; ++i) + { + var design = _designManager.CreateEmpty($"Test Designs/Test Design {i}", true); + _designManager.AddTag(design, "_DebugTest"); + } + + ImUtf8.SameLineInner(); + if (ImUtf8.Button("Remove All Test Designs"u8)) + { + var designs = _designManager.Designs.Where(d => d.Tags.Contains("_DebugTest")).ToArray(); + foreach (var design in designs) + _designManager.Delete(design); + if (_designFileSystem.Find("Test Designs", out var path) && path is DesignFileSystem.Folder { TotalChildren: 0 }) + _designFileSystem.Delete(path); + } + } + public static void DrawDesign(DesignBase design, DesignFileSystem? fileSystem) { using var table = ImRaii.Table("##equip", 8, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit); @@ -53,7 +77,7 @@ public class DesignManagerPanel(DesignManager _designManager, DesignFileSystem _ ImGui.TableNextRow(); ImGuiUtil.DrawTableColumn("Design File System Path"); if (fileSystem != null) - ImGuiUtil.DrawTableColumn(fileSystem.FindLeaf(d, out var leaf) ? leaf.FullName() : "No Path Known"); + ImGuiUtil.DrawTableColumn(fileSystem.TryGetValue(d, out var leaf) ? leaf.FullName() : "No Path Known"); ImGui.TableNextRow(); ImGuiUtil.DrawTableColumn("Creation"); diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index ec8b465..1ecda0b 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -14,8 +14,7 @@ public class MultiDesignPanel( DesignFileSystemSelector selector, DesignManager editor, DesignColors colors, - Configuration config, - DesignComboWrapper combos) + Configuration config) { private readonly Button[] _leftButtons = []; private readonly Button[] _rightButtons = [new IncognitoButton(config)]; @@ -206,7 +205,6 @@ public class MultiDesignPanel( : $"Display all {_numDesigns} selected designs in the quick design bar. Changes {diff} designs."; if (ImUtf8.ButtonEx("Display Selected Designs in QDB"u8, tt, buttonWidth, diff == 0)) { - using var disableListener = combos.StopListening(); foreach (var design in selector.SelectedPaths.OfType()) editor.SetQuickDesign(design.Value, true); } @@ -217,7 +215,6 @@ public class MultiDesignPanel( : $"Hide all {_numDesigns} selected designs in the quick design bar. Changes {_numQuickDesignEnabled} designs."; if (ImUtf8.ButtonEx("Hide Selected Designs in QDB"u8, tt, buttonWidth, _numQuickDesignEnabled == 0)) { - using var disableListener = combos.StopListening(); foreach (var design in selector.SelectedPaths.OfType()) editor.SetQuickDesign(design.Value, false); } @@ -339,7 +336,6 @@ public class MultiDesignPanel( ImGui.SameLine(); if (ImUtf8.ButtonEx(label, tooltip, width, _addDesigns.Count == 0)) { - using var disableListener = combos.StopListening(); foreach (var design in _addDesigns) editor.ChangeColor(design, _colorCombo.CurrentSelection!); } @@ -353,7 +349,6 @@ public class MultiDesignPanel( ImGui.SameLine(); if (ImUtf8.ButtonEx(label, tooltip, width, _removeDesigns.Count == 0)) { - using var disableListener = combos.StopListening(); foreach (var (design, _) in _removeDesigns) editor.ChangeColor(design, string.Empty); } diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 6c30d68..0754313 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -169,6 +169,5 @@ public static class StaticServiceManager .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() - .AddSingleton(); + .AddSingleton(); } diff --git a/OtterGui b/OtterGui index cee50c3..78528f9 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit cee50c3fe97a03ca7445c81de651b609620da526 +Subproject commit 78528f93ac253db0061d9a8244cfa0cee5c2f873 From 2e9a7004c696940085bf65bac506348927d0391b Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 13 Jun 2025 15:21:04 +0000 Subject: [PATCH 307/401] [CI] Updating repo.json for 1.4.0.2 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 47bc610..8b0be29 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.4.0.1", - "TestingAssemblyVersion": "1.4.0.1", + "AssemblyVersion": "1.4.0.2", + "TestingAssemblyVersion": "1.4.0.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.2/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c0a278ca2cc0d53cca1349b289bc94112a8b782f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 15 Jun 2025 23:33:54 +0200 Subject: [PATCH 308/401] Make designs update on mousewheel. --- Glamourer/Gui/DesignCombo.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index e5f3785..e35ad5e 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -123,6 +123,14 @@ public abstract class DesignComboBase : FilterComboCache Date: Mon, 14 Jul 2025 17:09:42 +0200 Subject: [PATCH 309/401] Fix issue with invalid bonus items. --- Glamourer/Services/ItemManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 2cc6461..a885b54 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -145,8 +145,10 @@ public class ItemManager // Only from early designs as migration. if (!id.IsBonusItem || id.Id == 0) { - IsBonusItemValid(slot, (BonusItemId)id.Id, out var item); - return item; + if (IsBonusItemValid(slot, (BonusItemId)id.Id, out var item)) + return item; + + return EquipItem.BonusItemNothing(slot); } if (!id.IsCustom) From 8a1f03c27254f7f9f01c7ae237b39bce79931d6e Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 14 Jul 2025 15:12:49 +0000 Subject: [PATCH 310/401] [CI] Updating repo.json for 1.4.0.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 8b0be29..0c6e22f 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.4.0.2", - "TestingAssemblyVersion": "1.4.0.2", + "AssemblyVersion": "1.4.0.3", + "TestingAssemblyVersion": "1.4.0.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.2/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.2/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.3/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 40b4a8fd7a87bb7c80654f0ed75085da027d8fa1 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Mon, 28 Jul 2025 08:37:57 -0700 Subject: [PATCH 311/401] Ensure Revert via Command invokes a StateFinalization type for Reset --- Glamourer/Services/CommandService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 3d40fa9..1b88a00 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -407,7 +407,7 @@ public class CommandService : IDisposable, IApiService foreach (var identifier in identifiers) { if (_stateManager.TryGetValue(identifier, out var state)) - _stateManager.ResetState(state, StateSource.Manual); + _stateManager.ResetState(state, StateSource.Manual, isFinal: true); } From 4ef4e65d46bb15581a25b4983988534e353ec660 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Mon, 28 Jul 2025 08:43:13 -0700 Subject: [PATCH 312/401] Ensure that reverts called by API invoke their StateFinalizationType upon completing a reset state. --- Glamourer/Api/StateApi.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 43dc453..68c593b 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -272,7 +272,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable { case ApplyFlag.Equipment: _stateManager.ResetEquip(state, source, key); break; case ApplyFlag.Customization: _stateManager.ResetCustomize(state, source, key); break; - case ApplyFlag.Equipment | ApplyFlag.Customization: _stateManager.ResetState(state, source, key); break; + case ApplyFlag.Equipment | ApplyFlag.Customization: _stateManager.ResetState(state, source, key, true); break; } ApiHelpers.Lock(state, key, flags); From d6df9885dcc15940e1263d50533b1afd3d6c05a8 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 2 Aug 2025 00:07:27 +0200 Subject: [PATCH 313/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index bb3b462..82b4467 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit bb3b462bbc5bc2a598c1ad8c372b0cb255551fe1 +Subproject commit 82b446721a9b9c99d2470c54ad49fe19ff4987e3 From 2c3bed6ba5964456e51b75f82bfe6f552517e833 Mon Sep 17 00:00:00 2001 From: Karou Date: Thu, 7 Aug 2025 21:50:23 -0400 Subject: [PATCH 314/401] Api 13 grunt work --- Glamourer.Api | 2 +- Glamourer/DesignPanelFlag.cs | 2 +- Glamourer/Designs/ApplicationCollection.cs | 2 +- Glamourer/Designs/ApplicationRules.cs | 2 +- Glamourer/Designs/DesignColors.cs | 2 +- Glamourer/Glamourer.csproj | 3 ++- Glamourer/Gui/Colors.cs | 2 +- Glamourer/Gui/Customization/CustomizationDrawer.Color.cs | 2 +- .../Gui/Customization/CustomizationDrawer.GenderRace.cs | 2 +- Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs | 8 ++++---- Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs | 2 +- Glamourer/Gui/Customization/CustomizationDrawer.cs | 2 +- Glamourer/Gui/Customization/CustomizeParameterDrawer.cs | 2 +- Glamourer/Gui/DesignCombo.cs | 2 +- Glamourer/Gui/DesignQuickBar.cs | 2 +- Glamourer/Gui/Equipment/BonusItemCombo.cs | 2 +- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 2 +- Glamourer/Gui/Equipment/GlamourerColorCombo.cs | 2 +- Glamourer/Gui/Equipment/ItemCombo.cs | 2 +- Glamourer/Gui/Equipment/ItemCopyService.cs | 2 +- Glamourer/Gui/Equipment/WeaponCombo.cs | 2 +- Glamourer/Gui/GenericPopupWindow.cs | 2 +- Glamourer/Gui/MainWindow.cs | 2 +- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 2 +- Glamourer/Gui/Materials/MaterialDrawer.cs | 2 +- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 2 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 2 +- Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs | 2 +- Glamourer/Gui/Tabs/ActorTab/ActorTab.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/AutomationTab.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs | 2 +- .../Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs | 2 +- .../Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/DebugTab.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/FunPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs | 2 +- Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignTab.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/ModCombo.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs | 2 +- Glamourer/Gui/Tabs/HeaderDrawer.cs | 2 +- Glamourer/Gui/Tabs/NpcTab/LocalNpcAppearanceData.cs | 2 +- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 2 +- Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs | 2 +- Glamourer/Gui/Tabs/NpcTab/NpcTab.cs | 2 +- Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs | 2 +- Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs | 2 +- .../Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs | 2 +- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 2 +- Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs | 2 +- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 2 +- Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs | 2 +- Glamourer/Gui/UiHelpers.cs | 2 +- Glamourer/Interop/CrestService.cs | 4 ++-- Glamourer/Interop/ImportService.cs | 2 +- Glamourer/Interop/Material/LiveColorTablePreviewer.cs | 5 +++-- Glamourer/Services/CommandService.cs | 2 +- Glamourer/Services/DesignResolver.cs | 2 +- Glamourer/State/FunModule.cs | 2 +- Glamourer/packages.lock.json | 8 ++++---- OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- 92 files changed, 102 insertions(+), 100 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 64897c0..6589ecd 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 64897c069d3b6c3fe027b3ae0e832828728b9108 +Subproject commit 6589ecdde5dac55730797fcc594be301e820bfcc diff --git a/Glamourer/DesignPanelFlag.cs b/Glamourer/DesignPanelFlag.cs index db84173..f9465d9 100644 --- a/Glamourer/DesignPanelFlag.cs +++ b/Glamourer/DesignPanelFlag.cs @@ -1,5 +1,5 @@ using Glamourer.Designs; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Text; using OtterGui.Text.EndObjects; diff --git a/Glamourer/Designs/ApplicationCollection.cs b/Glamourer/Designs/ApplicationCollection.cs index 13813a3..8beeb78 100644 --- a/Glamourer/Designs/ApplicationCollection.cs +++ b/Glamourer/Designs/ApplicationCollection.cs @@ -1,6 +1,6 @@ using Glamourer.Api.Enums; using Glamourer.GameData; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Penumbra.GameData.Enums; namespace Glamourer.Designs; diff --git a/Glamourer/Designs/ApplicationRules.cs b/Glamourer/Designs/ApplicationRules.cs index 0df4feb..281a940 100644 --- a/Glamourer/Designs/ApplicationRules.cs +++ b/Glamourer/Designs/ApplicationRules.cs @@ -1,7 +1,7 @@ using Glamourer.Api.Enums; using Glamourer.GameData; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Penumbra.GameData.Enums; namespace Glamourer.Designs; diff --git a/Glamourer/Designs/DesignColors.cs b/Glamourer/Designs/DesignColors.cs index 172e10f..a8f3178 100644 --- a/Glamourer/Designs/DesignColors.cs +++ b/Glamourer/Designs/DesignColors.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility.Raii; using Glamourer.Gui; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 9dabbb2..40b1218 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -1,4 +1,4 @@ - + Glamourer Glamourer @@ -29,6 +29,7 @@ + diff --git a/Glamourer/Gui/Colors.cs b/Glamourer/Gui/Colors.cs index 98deace..b2713eb 100644 --- a/Glamourer/Gui/Colors.cs +++ b/Glamourer/Gui/Colors.cs @@ -1,4 +1,4 @@ -using ImGuiNET; +using Dalamud.Bindings.ImGui; namespace Glamourer.Gui; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs index 8db07ff..4f463d6 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Color.cs @@ -1,7 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using Glamourer.GameData; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs index 2f67012..26e9002 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index eabb6f0..8599f8c 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -1,7 +1,7 @@ using Dalamud.Interface.Textures.TextureWraps; using Glamourer.GameData; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Raii; @@ -35,7 +35,7 @@ public partial class CustomizationDrawer var hasIcon = icon.TryGetWrap(out var wrap, out _); using (_ = ImRaii.Disabled(_locked || _currentIndex is CustomizeIndex.Face && _lockedRedraw)) { - if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize)) + if (ImGui.ImageButton(wrap?.Handle ?? icon.GetWrapOrEmpty().Handle, _iconSize)) { ImGui.OpenPopup(IconSelectorPopup); } @@ -89,7 +89,7 @@ public partial class CustomizationDrawer : ImRaii.PushColor(ImGuiCol.Button, ColorId.FavoriteStarOn.Value(), isFavorite); var hasIcon = icon.TryGetWrap(out var wrap, out var _); - if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize)) + if (ImGui.ImageButton(wrap?.Handle ?? icon.GetWrapOrEmpty().Handle, _iconSize)) { UpdateValue(custom.Value); ImGui.CloseCurrentPopup(); @@ -215,7 +215,7 @@ public partial class CustomizationDrawer hasIcon = icon.TryGetWrap(out wrap, out _); } - if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize, Vector2.Zero, Vector2.One, + if (ImGui.ImageButton(wrap?.Handle ?? icon.GetWrapOrEmpty().Handle, _iconSize, Vector2.Zero, Vector2.One, (int)ImGui.GetStyle().FramePadding.X, Vector4.Zero, enabled ? Vector4.One : _redTint)) { _customize.Set(featureIdx, enabled ? CustomizeValue.Zero : CustomizeValue.Max); diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index 2c797b8..ec5523f 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -1,4 +1,4 @@ -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGuiInternal; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 4ec6146..349891c 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -4,7 +4,7 @@ using Dalamud.Plugin.Services; using Glamourer.GameData; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs index 9bfb2f8..18a9d1a 100644 --- a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs @@ -3,7 +3,7 @@ using Glamourer.Designs; using Glamourer.GameData; using Glamourer.Interop.PalettePlus; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index e35ad5e..6dfffef 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -5,7 +5,7 @@ using Glamourer.Designs; using Glamourer.Designs.History; using Glamourer.Designs.Special; using Glamourer.Events; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index d83fce9..2dee0e4 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -8,7 +8,7 @@ using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Interop.Penumbra; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Classes; using OtterGui.Text; using Penumbra.GameData.Actors; diff --git a/Glamourer/Gui/Equipment/BonusItemCombo.cs b/Glamourer/Gui/Equipment/BonusItemCombo.cs index 892d9f1..aa43da7 100644 --- a/Glamourer/Gui/Equipment/BonusItemCombo.cs +++ b/Glamourer/Gui/Equipment/BonusItemCombo.cs @@ -1,7 +1,7 @@ using Dalamud.Plugin.Services; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Lumina.Excel.Sheets; using OtterGui; using OtterGui.Classes; diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 43fda84..91187a8 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -5,7 +5,7 @@ using Glamourer.Events; using Glamourer.Gui.Materials; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Equipment/GlamourerColorCombo.cs b/Glamourer/Gui/Equipment/GlamourerColorCombo.cs index 527dbb5..3149e67 100644 --- a/Glamourer/Gui/Equipment/GlamourerColorCombo.cs +++ b/Glamourer/Gui/Equipment/GlamourerColorCombo.cs @@ -2,7 +2,7 @@ using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Widgets; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Structs; diff --git a/Glamourer/Gui/Equipment/ItemCombo.cs b/Glamourer/Gui/Equipment/ItemCombo.cs index 14f2e8a..7c0c3bc 100644 --- a/Glamourer/Gui/Equipment/ItemCombo.cs +++ b/Glamourer/Gui/Equipment/ItemCombo.cs @@ -1,7 +1,7 @@ using Dalamud.Plugin.Services; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Lumina.Excel.Sheets; using OtterGui.Classes; using OtterGui.Extensions; diff --git a/Glamourer/Gui/Equipment/ItemCopyService.cs b/Glamourer/Gui/Equipment/ItemCopyService.cs index ea37963..6912f1f 100644 --- a/Glamourer/Gui/Equipment/ItemCopyService.cs +++ b/Glamourer/Gui/Equipment/ItemCopyService.cs @@ -1,5 +1,5 @@ using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Services; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Equipment/WeaponCombo.cs b/Glamourer/Gui/Equipment/WeaponCombo.cs index 6e38e7c..3029db7 100644 --- a/Glamourer/Gui/Equipment/WeaponCombo.cs +++ b/Glamourer/Gui/Equipment/WeaponCombo.cs @@ -1,6 +1,6 @@ using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Classes; using OtterGui.Extensions; using OtterGui.Log; diff --git a/Glamourer/Gui/GenericPopupWindow.cs b/Glamourer/Gui/GenericPopupWindow.cs index 502af14..5061862 100644 --- a/Glamourer/Gui/GenericPopupWindow.cs +++ b/Glamourer/Gui/GenericPopupWindow.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Plugin.Services; using Glamourer.Gui.Materials; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs index f21a2b7..a39db2e 100644 --- a/Glamourer/Gui/MainWindow.cs +++ b/Glamourer/Gui/MainWindow.cs @@ -12,7 +12,7 @@ using Glamourer.Gui.Tabs.NpcTab; using Glamourer.Gui.Tabs.SettingsTab; using Glamourer.Gui.Tabs.UnlocksTab; using Glamourer.Interop.Penumbra; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Custom; diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index ec25378..8cf81ff 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -8,7 +8,7 @@ using FFXIVClientStructs.Interop; using Glamourer.Designs; using Glamourer.Interop.Material; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Services; using OtterGui.Text; diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 0c4433d..ce50ff2 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Glamourer.Designs; using Glamourer.Interop.Material; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Services; using OtterGui.Text; diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index 1723333..ed6018e 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -3,7 +3,7 @@ using Glamourer.Events; using Glamourer.Interop.Penumbra; using Glamourer.Services; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using Penumbra.Api.Enums; using Penumbra.GameData.Data; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 98d9157..dcd3a12 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -11,7 +11,7 @@ using Glamourer.Gui.Equipment; using Glamourer.Gui.Materials; using Glamourer.Interop; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs index e46d651..7d132a1 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs @@ -1,5 +1,5 @@ using Dalamud.Interface; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorTab.cs b/Glamourer/Gui/Tabs/ActorTab/ActorTab.cs index 4e5e15c..9751a71 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorTab.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorTab.cs @@ -1,5 +1,5 @@ using Dalamud.Interface.Utility; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.ActorTab; diff --git a/Glamourer/Gui/Tabs/AutomationTab/AutomationTab.cs b/Glamourer/Gui/Tabs/AutomationTab/AutomationTab.cs index 831ee7c..da3b636 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/AutomationTab.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/AutomationTab.cs @@ -1,5 +1,5 @@ using Dalamud.Interface.Utility; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.AutomationTab; diff --git a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs index 8a08437..ce843c4 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs @@ -1,6 +1,6 @@ using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Utility; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Custom; using OtterGui.Extensions; diff --git a/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs b/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs index b197a1a..ba2e424 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/IdentifierDrawer.cs @@ -1,5 +1,5 @@ using Dalamud.Game.ClientState.Objects.Enums; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Penumbra.GameData.Actors; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Gui; diff --git a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs index ae3be7e..8eba59b 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs @@ -4,7 +4,7 @@ using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Designs.Special; using Glamourer.Events; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 1600837..4b05e35 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -6,7 +6,7 @@ using Glamourer.Designs.Special; using Glamourer.Interop; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Log; diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs index 96730e8..dca0ce5 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs @@ -2,7 +2,7 @@ using Dalamud.Interface.Utility; using Glamourer.Automation; using Glamourer.Events; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index b4bdc2a..e0ec4bd 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -2,7 +2,7 @@ using Glamourer.GameData; using Glamourer.Designs; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs index 5a02621..2202ceb 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs @@ -1,5 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Gui.Debug; diff --git a/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs b/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs index df39f45..aee59b6 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs @@ -1,5 +1,5 @@ using Glamourer.Automation; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs index 565b6ba..6c0995c 100644 --- a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs @@ -1,7 +1,7 @@ using Dalamud.Interface; using Glamourer.GameData; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs b/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs index a53a677..4bf7d7b 100644 --- a/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs @@ -1,5 +1,5 @@ using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs b/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs index 11f27fd..7c61392 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs @@ -1,5 +1,5 @@ using Glamourer.Interop; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using Penumbra.GameData.Files; using Penumbra.GameData.Gui.Debug; diff --git a/Glamourer/Gui/Tabs/DebugTab/DebugTab.cs b/Glamourer/Gui/Tabs/DebugTab/DebugTab.cs index cd89aec..b760221 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DebugTab.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DebugTab.cs @@ -1,4 +1,4 @@ -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Services; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs index 2345abc..287d373 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs @@ -1,7 +1,7 @@ using Dalamud.Interface; using Glamourer.Designs; using Glamourer.Utility; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Newtonsoft.Json.Linq; using OtterGui; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs index 342bc41..38f0077 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs @@ -1,6 +1,6 @@ using Dalamud.Interface; using Glamourer.Designs; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Filesystem; diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs index 26be8ce..cf45077 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs @@ -1,7 +1,7 @@ using Dalamud.Interface; using Glamourer.Designs; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/DebugTab/FunPanel.cs b/Glamourer/Gui/Tabs/DebugTab/FunPanel.cs index c517070..370c4e5 100644 --- a/Glamourer/Gui/Tabs/DebugTab/FunPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/FunPanel.cs @@ -1,5 +1,5 @@ using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Penumbra.GameData.Gui.Debug; namespace Glamourer.Gui.Tabs.DebugTab; diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index aafc21a..f480f6d 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -5,7 +5,7 @@ using FFXIVClientStructs.FFXIV.Client.Game; using Glamourer.Designs; using Glamourer.Services; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Text; diff --git a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs index f57a57e..ca9ff7b 100644 --- a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs @@ -1,5 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Game; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Gui.Debug; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs index 9e11b99..8cbf57a 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.Utility; using Dalamud.Plugin; using Glamourer.Api.Enums; using Glamourer.Api.IpcSubscribers; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs index 500fddd..dbcb30c 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs @@ -1,6 +1,6 @@ using Glamourer.Api.Enums; using Glamourer.Designs; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using static Penumbra.GameData.Files.ShpkFile; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs index 1a78b24..f4e6925 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs @@ -1,7 +1,7 @@ using Dalamud.Plugin; using Dalamud.Plugin.Services; using Glamourer.Api.IpcSubscribers; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Penumbra.GameData.Gui.Debug; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs index 1499fcb..ea95a9d 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs @@ -1,7 +1,7 @@ using Dalamud.Plugin; using Glamourer.Api.Enums; using Glamourer.Api.IpcSubscribers; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index 638bffc..e97d337 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -5,7 +5,7 @@ using Glamourer.Api.Enums; using Glamourer.Api.Helpers; using Glamourer.Api.IpcSubscribers; using Glamourer.Designs; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; diff --git a/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs index afbb86b..f82bfb3 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs @@ -1,7 +1,7 @@ using Dalamud.Interface.Utility; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index a0f2491..d1b42e8 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -2,7 +2,7 @@ using Glamourer.GameData; using Glamourer.Interop; using Glamourer.Interop.Structs; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs b/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs index 966bc6f..0d93bb8 100644 --- a/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs @@ -4,7 +4,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.Designs; using Glamourer.GameData; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs index a4d1224..97847ae 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs @@ -1,4 +1,4 @@ -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Text; using Penumbra.GameData.Actors; diff --git a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index 012e5ba..9992bc3 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -1,6 +1,6 @@ using Dalamud.Interface.Utility; using Glamourer.Interop.Penumbra; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.Api.Enums; diff --git a/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs b/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs index 99c79ed..b22008d 100644 --- a/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs @@ -1,7 +1,7 @@ using Dalamud.Interface.Utility; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs b/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs index 0efa358..e9fe775 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignColorCombo.cs @@ -1,5 +1,5 @@ using Glamourer.Designs; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index cbf7acd..042f2a2 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -2,7 +2,7 @@ using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index 11e803b..7341d31 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -5,7 +5,7 @@ using Glamourer.Designs; using Glamourer.Designs.History; using Glamourer.Events; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Filesystem; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs index b81ffdf..7e5807e 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.Utility; using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Designs.Links; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index d2b98b2..5bb3d77 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -12,7 +12,7 @@ using Glamourer.Gui.Equipment; using Glamourer.Gui.Materials; using Glamourer.Interop; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs index afb5900..1b92291 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignTab.cs @@ -2,7 +2,7 @@ using Dalamud.Interface.Utility; using Glamourer.Designs; using Glamourer.Interop; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Classes; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index bab25f0..02f00db 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -5,7 +5,7 @@ using Dalamud.Utility; using Glamourer.Designs; using Glamourer.Interop.Penumbra; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; diff --git a/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs b/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs index 6ec9a1c..76579c2 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs @@ -1,6 +1,6 @@ using Dalamud.Interface.Utility; using Glamourer.Interop.Penumbra; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 1ecda0b..1cdb171 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -2,7 +2,7 @@ using Dalamud.Interface.Utility; using Glamourer.Designs; using Glamourer.Interop.Material; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; diff --git a/Glamourer/Gui/Tabs/HeaderDrawer.cs b/Glamourer/Gui/Tabs/HeaderDrawer.cs index d6baeb9..cb169ba 100644 --- a/Glamourer/Gui/Tabs/HeaderDrawer.cs +++ b/Glamourer/Gui/Tabs/HeaderDrawer.cs @@ -1,6 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/NpcTab/LocalNpcAppearanceData.cs b/Glamourer/Gui/Tabs/NpcTab/LocalNpcAppearanceData.cs index 7941c13..1b70e27 100644 --- a/Glamourer/Gui/Tabs/NpcTab/LocalNpcAppearanceData.cs +++ b/Glamourer/Gui/Tabs/NpcTab/LocalNpcAppearanceData.cs @@ -2,7 +2,7 @@ using Glamourer.Designs; using Glamourer.GameData; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index c6166a3..29fe7ef 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -6,7 +6,7 @@ using Glamourer.Gui.Customization; using Glamourer.Gui.Equipment; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs b/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs index 847b65e..8497ab4 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs @@ -1,5 +1,5 @@ using Glamourer.GameData; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Extensions; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcTab.cs b/Glamourer/Gui/Tabs/NpcTab/NpcTab.cs index 4efa4c3..318e017 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcTab.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcTab.cs @@ -1,5 +1,5 @@ using Dalamud.Interface.Utility; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.NpcTab; diff --git a/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs index b4d3740..1dc9331 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs @@ -1,7 +1,7 @@ using Dalamud.Interface; using Glamourer.Services; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Filesystem; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs b/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs index 98ba870..7080b4d 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs @@ -1,6 +1,6 @@ using Dalamud.Interface; using Glamourer.Interop.Penumbra; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Log; using OtterGui.Raii; diff --git a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs index 87490db..76435ec 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs @@ -1,7 +1,7 @@ using Dalamud.Interface; using Glamourer.Interop.Penumbra; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Services; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index cf57824..311cf85 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -8,7 +8,7 @@ using Glamourer.Designs; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; using Glamourer.Interop.PalettePlus; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Widgets; diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index 903257b..947f0c6 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -5,7 +5,7 @@ using Glamourer.Interop; using Glamourer.Interop.Penumbra; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 6d9ce51..d75f2dc 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -6,7 +6,7 @@ using Glamourer.Interop; using Glamourer.Interop.Penumbra; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Raii; using OtterGui.Table; diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs index c2e06e5..661b2a4 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlocksTab.cs @@ -1,6 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Windowing; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui; using OtterGui.Widgets; diff --git a/Glamourer/Gui/UiHelpers.cs b/Glamourer/Gui/UiHelpers.cs index 1ec79d7..94ddb06 100644 --- a/Glamourer/Gui/UiHelpers.cs +++ b/Glamourer/Gui/UiHelpers.cs @@ -2,7 +2,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; using Glamourer.Services; using Glamourer.Unlocks; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using Lumina.Misc; using OtterGui; using OtterGui.Raii; diff --git a/Glamourer/Interop/CrestService.cs b/Glamourer/Interop/CrestService.cs index 95b3587..74b7800 100644 --- a/Glamourer/Interop/CrestService.cs +++ b/Glamourer/Interop/CrestService.cs @@ -122,7 +122,7 @@ public sealed unsafe class CrestService : EventWrapperRef3IsFreeCompanyCrestVisibleOnSlot(index) != 0; + return model.AsHuman->IsFreeCompanyCrestVisibleOnSlot(index); } case CrestType.Offhand: { @@ -130,7 +130,7 @@ public sealed unsafe class CrestService : EventWrapperRef3IsFreeCompanyCrestVisibleOnSlot(index) != 0; + return model.AsWeapon->IsFreeCompanyCrestVisibleOnSlot(index); } } diff --git a/Glamourer/Interop/ImportService.cs b/Glamourer/Interop/ImportService.cs index b9dfbe1..c6e90fd 100644 --- a/Glamourer/Interop/ImportService.cs +++ b/Glamourer/Interop/ImportService.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.ImGuiNotification; using Glamourer.Designs; using Glamourer.Interop.CharaFile; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Classes; using Penumbra.GameData.Enums; using Penumbra.GameData.Files; diff --git a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs index 94cb9ca..4190746 100644 --- a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs +++ b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs @@ -1,5 +1,5 @@ using Dalamud.Plugin.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Services; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Structs; @@ -114,7 +114,8 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable var frame = DateTimeOffset.UtcNow.UtcTicks; var hueByte = frame % (steps * frameLength) / frameLength; var hue = (float)hueByte / steps; - ImGui.ColorConvertHSVtoRGB(hue, 1, 1, out var r, out var g, out var b); + float r, g, b = 0; + ImGui.ColorConvertHSVtoRGB(hue, 1, 1, &r, &g, &b); return new Vector3(r, g, b); } diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 1b88a00..d47f26f 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -9,7 +9,7 @@ using Glamourer.Gui; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop.Penumbra; using Glamourer.State; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; diff --git a/Glamourer/Services/DesignResolver.cs b/Glamourer/Services/DesignResolver.cs index 68b54bb..8bb5cd2 100644 --- a/Glamourer/Services/DesignResolver.cs +++ b/Glamourer/Services/DesignResolver.cs @@ -4,7 +4,7 @@ using Glamourer.Designs; using Glamourer.Designs.Special; using Glamourer.Gui; using Glamourer.Gui.Tabs.DesignTab; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui.Services; using OtterGui.Classes; diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index ae7160c..6abb03a 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -4,7 +4,7 @@ using Glamourer.Designs; using Glamourer.GameData; using Glamourer.Gui; using Glamourer.Services; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using OtterGui; using OtterGui.Classes; using OtterGui.Extensions; diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json index e6f2fe5..f66e6e4 100644 --- a/Glamourer/packages.lock.json +++ b/Glamourer/packages.lock.json @@ -4,9 +4,9 @@ "net9.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[12.0.0, )", - "resolved": "12.0.0", - "contentHash": "J5TJLV3f16T/E2H2P17ClWjtfEBPpq3yxvqW46eN36JCm6wR+EaoaYkqG9Rm5sHqs3/nK/vKjWWyvEs/jhKoXw==" + "requested": "[13.0.0, )", + "resolved": "13.0.0", + "contentHash": "Mb3cUDSK/vDPQ8gQIeuCw03EMYrej1B4J44a1AvIJ9C759p9XeqdU9Hg4WgOmlnlPe0G7ILTD32PKSUpkQNa8w==" }, "DotNet.ReproducibleBuilds": { "type": "Direct", @@ -96,7 +96,7 @@ "type": "Project", "dependencies": { "OtterGui": "[1.0.0, )", - "Penumbra.Api": "[5.6.1, )", + "Penumbra.Api": "[5.10.0, )", "Penumbra.String": "[1.0.6, )" } }, diff --git a/OtterGui b/OtterGui index 78528f9..9523b7a 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 78528f93ac253db0061d9a8244cfa0cee5c2f873 +Subproject commit 9523b7ac725656b21fa98faef96962652e86e64f diff --git a/Penumbra.Api b/Penumbra.Api index ff7b3b4..c27a060 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit ff7b3b4014a97455f823380c78b8a7c5107f8e2f +Subproject commit c27a06004138f2ec80ccdb494bb6ddf6d39d2165 diff --git a/Penumbra.GameData b/Penumbra.GameData index 82b4467..65c5bf3 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 82b446721a9b9c99d2470c54ad49fe19ff4987e3 +Subproject commit 65c5bf3f46569a54b0057c9015ab839b4e2a4350 diff --git a/Penumbra.String b/Penumbra.String index 2896c05..878acce 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 2896c0561f60827f97408650d52a15c38f4d9d10 +Subproject commit 878acce46e286867d6ef1f8ecedb390f7bac34fd From 72e05e23bc77c877f29c039e6901117e3a973ed5 Mon Sep 17 00:00:00 2001 From: Karou Date: Thu, 7 Aug 2025 21:53:01 -0400 Subject: [PATCH 315/401] stupid detached head.... --- Glamourer.Api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer.Api b/Glamourer.Api index 6589ecd..1c51730 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 6589ecdde5dac55730797fcc594be301e820bfcc +Subproject commit 1c517301c9fd0818e2c02e72304d6de121b9d703 From c25f0f72db033fcc264ef3ee2c9f24c735bd288f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:36:14 +0200 Subject: [PATCH 316/401] Update for ottergui. --- Glamourer/Designs/DesignFileSystem.cs | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Glamourer/Designs/DesignFileSystem.cs b/Glamourer/Designs/DesignFileSystem.cs index 4a1cb3d..fd47793 100644 --- a/Glamourer/Designs/DesignFileSystem.cs +++ b/Glamourer/Designs/DesignFileSystem.cs @@ -41,11 +41,11 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable public struct CreationDate : ISortMode { - public string Name - => "Creation Date (Older First)"; + public ReadOnlySpan Name + => "Creation Date (Older First)"u8; - public string Description - => "In each folder, sort all subfolders lexicographically, then sort all leaves using their creation date."; + public ReadOnlySpan Description + => "In each folder, sort all subfolders lexicographically, then sort all leaves using their creation date."u8; public IEnumerable GetChildren(Folder f) => f.GetSubFolders().Cast().Concat(f.GetLeaves().OrderBy(l => l.Value.CreationDate)); @@ -53,11 +53,11 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable public struct UpdateDate : ISortMode { - public string Name - => "Update Date (Older First)"; + public ReadOnlySpan Name + => "Update Date (Older First)"u8; - public string Description - => "In each folder, sort all subfolders lexicographically, then sort all leaves using their last update date."; + public ReadOnlySpan Description + => "In each folder, sort all subfolders lexicographically, then sort all leaves using their last update date."u8; public IEnumerable GetChildren(Folder f) => f.GetSubFolders().Cast().Concat(f.GetLeaves().OrderBy(l => l.Value.LastEdit)); @@ -65,11 +65,11 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable public struct InverseCreationDate : ISortMode { - public string Name - => "Creation Date (Newer First)"; + public ReadOnlySpan Name + => "Creation Date (Newer First)"u8; - public string Description - => "In each folder, sort all subfolders lexicographically, then sort all leaves using their inverse creation date."; + public ReadOnlySpan Description + => "In each folder, sort all subfolders lexicographically, then sort all leaves using their inverse creation date."u8; public IEnumerable GetChildren(Folder f) => f.GetSubFolders().Cast().Concat(f.GetLeaves().OrderByDescending(l => l.Value.CreationDate)); @@ -77,11 +77,11 @@ public sealed class DesignFileSystem : FileSystem, IDisposable, ISavable public struct InverseUpdateDate : ISortMode { - public string Name - => "Update Date (Newer First)"; + public ReadOnlySpan Name + => "Update Date (Newer First)"u8; - public string Description - => "In each folder, sort all subfolders lexicographically, then sort all leaves using their inverse last update date."; + public ReadOnlySpan Description + => "In each folder, sort all subfolders lexicographically, then sort all leaves using their inverse last update date."u8; public IEnumerable GetChildren(Folder f) => f.GetSubFolders().Cast().Concat(f.GetLeaves().OrderByDescending(l => l.Value.LastEdit)); From 0f98fac157bdf693d186984e915cca9c36a98356 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:36:47 +0200 Subject: [PATCH 317/401] Add auto-locking to design defaults. --- Glamourer/Configuration.cs | 1 + Glamourer/Designs/DesignManager.cs | 3 +++ Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index c9ff0e6..f128bdd 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -32,6 +32,7 @@ public class DefaultDesignSettings public bool ResetAdvancedDyes = false; public bool ShowQuickDesignBar = true; public bool ResetTemporarySettings = false; + public bool Locked = false; } public class Configuration : IPluginConfiguration, ISavable diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index fff9565..3ddfefd 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -110,6 +110,7 @@ public sealed class DesignManager : DesignEditor QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, ResetTemporarySettings = Config.DefaultDesignSettings.ResetTemporarySettings, }; + design.SetWriteProtected(Config.DefaultDesignSettings.Locked); Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier}."); SaveService.ImmediateSave(design); @@ -134,6 +135,7 @@ public sealed class DesignManager : DesignEditor ResetTemporarySettings = Config.DefaultDesignSettings.ResetTemporarySettings, }; + design.SetWriteProtected(Config.DefaultDesignSettings.Locked); Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier} by cloning Temporary Design."); SaveService.ImmediateSave(design); @@ -153,6 +155,7 @@ public sealed class DesignManager : DesignEditor Name = actualName, Index = Designs.Count, }; + design.SetWriteProtected(Config.DefaultDesignSettings.Locked); Designs.Add(design); Glamourer.Log.Debug( $"Added new design {design.Identifier} by cloning {clone.Identifier.ToString()}."); diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 311cf85..1ccb079 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -113,6 +113,8 @@ public class SettingsTab( if (!ImUtf8.CollapsingHeader("Design Defaults")) return; + Checkbox("Locked Designs"u8, "Newly created designs will be locked to prevent unintended changes."u8, + config.DefaultDesignSettings.Locked, v => config.DefaultDesignSettings.Locked = v); Checkbox("Show in Quick Design Bar"u8, "Newly created designs will be shown in the quick design bar by default."u8, config.DefaultDesignSettings.ShowQuickDesignBar, v => config.DefaultDesignSettings.ShowQuickDesignBar = v); Checkbox("Reset Advanced Dyes"u8, "Newly created designs will be configured to reset advanced dyes on application by default."u8, From 00d550f4feb344342bb5f3962d205c23feedc821 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:38:51 +0200 Subject: [PATCH 318/401] Add viera ear flags --- Glamourer.Api | 2 +- Glamourer/Automation/ApplicationType.cs | 2 +- Glamourer/Designs/ApplicationCollection.cs | 6 +- Glamourer/Designs/DesignBase.cs | 14 +++- Glamourer/Designs/DesignData.cs | 15 ++++ Glamourer/Designs/MetaIndex.cs | 13 ++- Glamourer/Events/PenumbraReloaded.cs | 3 + Glamourer/Events/VieraEarStateChanged.cs | 22 +++++ Glamourer/Events/VisorStateChanged.cs | 2 +- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 6 ++ .../Gui/Tabs/DebugTab/ActiveStatePanel.cs | 3 + .../Gui/Tabs/DebugTab/DesignManagerPanel.cs | 1 + .../Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 22 +++++ Glamourer/Interop/VieraEarService.cs | 82 +++++++++++++++++++ Glamourer/Interop/VisorService.cs | 6 +- Glamourer/Services/ServiceManager.cs | 2 + Glamourer/State/StateApplier.cs | 9 ++ Glamourer/State/StateIndex.cs | 4 +- Glamourer/State/StateListener.cs | 47 ++++++++++- Glamourer/State/StateManager.cs | 3 +- Penumbra.GameData | 2 +- 21 files changed, 245 insertions(+), 21 deletions(-) create mode 100644 Glamourer/Events/VieraEarStateChanged.cs create mode 100644 Glamourer/Interop/VieraEarService.cs diff --git a/Glamourer.Api b/Glamourer.Api index 1c51730..54c1944 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 1c517301c9fd0818e2c02e72304d6de121b9d703 +Subproject commit 54c1944dc7db704733b4788520e494761bb0b58e diff --git a/Glamourer/Automation/ApplicationType.cs b/Glamourer/Automation/ApplicationType.cs index 58f296e..f72c93f 100644 --- a/Glamourer/Automation/ApplicationType.cs +++ b/Glamourer/Automation/ApplicationType.cs @@ -38,7 +38,7 @@ public static class ApplicationTypeExtensions var customizeFlags = type.HasFlag(ApplicationType.Customizations) ? CustomizeFlagExtensions.All : 0; var parameterFlags = type.HasFlag(ApplicationType.Customizations) ? CustomizeParameterExtensions.All : 0; var crestFlags = type.HasFlag(ApplicationType.GearCustomization) ? CrestExtensions.AllRelevant : 0; - var metaFlags = (type.HasFlag(ApplicationType.Armor) ? MetaFlag.HatState | MetaFlag.VisorState : 0) + var metaFlags = (type.HasFlag(ApplicationType.Armor) ? MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.EarState : 0) | (type.HasFlag(ApplicationType.Weapons) ? MetaFlag.WeaponState : 0) | (type.HasFlag(ApplicationType.Customizations) ? MetaFlag.Wetness : 0); var bonusFlags = type.HasFlag(ApplicationType.Armor) ? BonusExtensions.All : 0; diff --git a/Glamourer/Designs/ApplicationCollection.cs b/Glamourer/Designs/ApplicationCollection.cs index 8beeb78..c03d4b4 100644 --- a/Glamourer/Designs/ApplicationCollection.cs +++ b/Glamourer/Designs/ApplicationCollection.cs @@ -19,13 +19,13 @@ public record struct ApplicationCollection( public static readonly ApplicationCollection None = new(0, 0, CustomizeFlag.BodyType, 0, 0, 0); public static readonly ApplicationCollection Equipment = new(EquipFlagExtensions.All, BonusExtensions.All, - CustomizeFlag.BodyType, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState); + CustomizeFlag.BodyType, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.WeaponState | MetaFlag.VisorState | MetaFlag.EarState); public static readonly ApplicationCollection Customizations = new(0, 0, CustomizeFlagExtensions.AllRelevant, 0, CustomizeParameterExtensions.All, MetaFlag.Wetness); public static readonly ApplicationCollection Default = new(EquipFlagExtensions.All, BonusExtensions.All, - CustomizeFlagExtensions.AllRelevant, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState); + CustomizeFlagExtensions.AllRelevant, CrestExtensions.AllRelevant, 0, MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState | MetaFlag.EarState); public static ApplicationCollection FromKeys() => (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch @@ -47,7 +47,7 @@ public record struct ApplicationCollection( Equip = 0; BonusItem = 0; Crest = 0; - Meta &= ~(MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState); + Meta &= ~(MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState | MetaFlag.EarState); } public void RemoveCustomize() diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index b21c433..f87d75a 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -40,7 +40,8 @@ public class DesignBase } /// Used when importing .cma or .chara files. - internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags, BonusItemFlag bonusFlags) + internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags, + BonusItemFlag bonusFlags) { _designData = designData; ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant; @@ -254,9 +255,10 @@ public class DesignBase ret[slot.ToString()] = Serialize(item.Id, stains, crest, DoApplyEquip(slot), DoApplyStain(slot), DoApplyCrest(crestSlot)); } - ret["Hat"] = new QuadBool(_designData.IsHatVisible(), DoApplyMeta(MetaIndex.HatState)).ToJObject("Show", "Apply"); - ret["Visor"] = new QuadBool(_designData.IsVisorToggled(), DoApplyMeta(MetaIndex.VisorState)).ToJObject("IsToggled", "Apply"); - ret["Weapon"] = new QuadBool(_designData.IsWeaponVisible(), DoApplyMeta(MetaIndex.WeaponState)).ToJObject("Show", "Apply"); + ret["Hat"] = new QuadBool(_designData.IsHatVisible(), DoApplyMeta(MetaIndex.HatState)).ToJObject("Show", "Apply"); + ret["VieraEars"] = new QuadBool(_designData.AreEarsVisible(), DoApplyMeta(MetaIndex.EarState)).ToJObject("Show", "Apply"); + ret["Visor"] = new QuadBool(_designData.IsVisorToggled(), DoApplyMeta(MetaIndex.VisorState)).ToJObject("IsToggled", "Apply"); + ret["Weapon"] = new QuadBool(_designData.IsWeaponVisible(), DoApplyMeta(MetaIndex.WeaponState)).ToJObject("Show", "Apply"); } else { @@ -603,6 +605,10 @@ public class DesignBase metaValue = QuadBool.FromJObject(equip["Visor"], "IsToggled", "Apply", QuadBool.NullFalse); design.SetApplyMeta(MetaIndex.VisorState, metaValue.Enabled); design._designData.SetVisor(metaValue.ForcedValue); + + metaValue = QuadBool.FromJObject(equip["VieraEars"], "Show", "Apply", QuadBool.NullTrue); + design.SetApplyMeta(MetaIndex.EarState, metaValue.Enabled); + design._designData.SetEarsVisible(metaValue.ForcedValue); return; void PrintWarning(string msg) diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index bba0ccb..c7ca8e5 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -287,6 +287,7 @@ public unsafe struct DesignData MetaIndex.HatState => IsHatVisible(), MetaIndex.VisorState => IsVisorToggled(), MetaIndex.WeaponState => IsWeaponVisible(), + MetaIndex.EarState => AreEarsVisible(), _ => false, }; @@ -297,6 +298,7 @@ public unsafe struct DesignData MetaIndex.HatState => SetHatVisible(value), MetaIndex.VisorState => SetVisor(value), MetaIndex.WeaponState => SetWeaponVisible(value), + MetaIndex.EarState => SetEarsVisible(value), _ => false, }; @@ -340,6 +342,9 @@ public unsafe struct DesignData public readonly bool IsWeaponVisible() => (_states & 0x08) == 0x08; + public readonly bool AreEarsVisible() + => (_states & 0x10) == 0x00; + public bool SetWeaponVisible(bool value) { if (value == IsWeaponVisible()) @@ -349,6 +354,15 @@ public unsafe struct DesignData return true; } + public bool SetEarsVisible(bool value) + { + if (value == AreEarsVisible()) + return false; + + _states = (byte)(value ? _states & ~0x10 : _states | 0x10); + return true; + } + public void SetDefaultEquipment(ItemManager items) { foreach (var slot in EquipSlotExtensions.EqdpSlots) @@ -386,6 +400,7 @@ public unsafe struct DesignData SetHatVisible(true); SetWeaponVisible(true); + SetEarsVisible(true); SetVisor(false); fixed (uint* ptr = _itemIds) { diff --git a/Glamourer/Designs/MetaIndex.cs b/Glamourer/Designs/MetaIndex.cs index 3fc4655..1842ae3 100644 --- a/Glamourer/Designs/MetaIndex.cs +++ b/Glamourer/Designs/MetaIndex.cs @@ -10,14 +10,15 @@ public enum MetaIndex VisorState = StateIndex.MetaVisorState, WeaponState = StateIndex.MetaWeaponState, ModelId = StateIndex.MetaModelId, + EarState = StateIndex.MetaEarState, } public static class MetaExtensions { public static readonly IReadOnlyList AllRelevant = - [MetaIndex.Wetness, MetaIndex.HatState, MetaIndex.VisorState, MetaIndex.WeaponState]; + [MetaIndex.Wetness, MetaIndex.HatState, MetaIndex.VisorState, MetaIndex.WeaponState, MetaIndex.EarState]; - public const MetaFlag All = MetaFlag.Wetness | MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState; + public const MetaFlag All = MetaFlag.Wetness | MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState | MetaFlag.EarState; public static MetaFlag ToFlag(this MetaIndex index) => index switch @@ -26,6 +27,7 @@ public static class MetaExtensions MetaIndex.HatState => MetaFlag.HatState, MetaIndex.VisorState => MetaFlag.VisorState, MetaIndex.WeaponState => MetaFlag.WeaponState, + MetaIndex.EarState => MetaFlag.EarState, _ => (MetaFlag)byte.MaxValue, }; @@ -36,7 +38,8 @@ public static class MetaExtensions MetaFlag.HatState => MetaIndex.HatState, MetaFlag.VisorState => MetaIndex.VisorState, MetaFlag.WeaponState => MetaIndex.WeaponState, - _ => (MetaIndex)byte.MaxValue, + MetaFlag.EarState => MetaIndex.EarState, + _ => (MetaIndex)byte.MaxValue, }; public static IEnumerable ToIndices(this MetaFlag index) @@ -49,6 +52,8 @@ public static class MetaExtensions yield return MetaIndex.VisorState; if (index.HasFlag(MetaFlag.WeaponState)) yield return MetaIndex.WeaponState; + if (index.HasFlag(MetaFlag.EarState)) + yield return MetaIndex.EarState; } public static string ToName(this MetaIndex index) @@ -58,6 +63,7 @@ public static class MetaExtensions MetaIndex.VisorState => "Visor Toggled", MetaIndex.WeaponState => "Weapon Visible", MetaIndex.Wetness => "Force Wetness", + MetaIndex.EarState => "Ears Visible", _ => "Unknown Meta", }; @@ -68,6 +74,7 @@ public static class MetaExtensions MetaIndex.VisorState => "Toggle the visor state of the characters head gear.", MetaIndex.WeaponState => "Hide or show the characters weapons when not drawn.", MetaIndex.Wetness => "Force the character to be wet or not.", + MetaIndex.EarState => "Hide or show the characters ears through the head gear. (Viera only)", _ => string.Empty, }; } diff --git a/Glamourer/Events/PenumbraReloaded.cs b/Glamourer/Events/PenumbraReloaded.cs index 20b58f9..0975670 100644 --- a/Glamourer/Events/PenumbraReloaded.cs +++ b/Glamourer/Events/PenumbraReloaded.cs @@ -15,5 +15,8 @@ public sealed class PenumbraReloaded() /// VisorService = 0, + + /// + VieraEarService = 0, } } diff --git a/Glamourer/Events/VieraEarStateChanged.cs b/Glamourer/Events/VieraEarStateChanged.cs new file mode 100644 index 0000000..65730b8 --- /dev/null +++ b/Glamourer/Events/VieraEarStateChanged.cs @@ -0,0 +1,22 @@ +using OtterGui.Classes; +using Penumbra.GameData.Interop; + +namespace Glamourer.Events; + +/// +/// Triggered when the state of viera ear visibility for any draw object is changed. +/// +/// Parameter is the model with a changed viera ear visibility state. +/// Parameter is the new state. +/// Parameter is whether to call the original function. +/// +/// +public sealed class VieraEarStateChanged() + : EventWrapperRef2(nameof(VieraEarStateChanged)) +{ + public enum Priority + { + /// + StateListener = 0, + } +} diff --git a/Glamourer/Events/VisorStateChanged.cs b/Glamourer/Events/VisorStateChanged.cs index d2d3a6c..03b7336 100644 --- a/Glamourer/Events/VisorStateChanged.cs +++ b/Glamourer/Events/VisorStateChanged.cs @@ -19,4 +19,4 @@ public sealed class VisorStateChanged() /// StateListener = 0, } -} +} \ No newline at end of file diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index dcd3a12..224154b 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -305,6 +305,12 @@ public class ActorPanel EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(MetaIndex.WeaponState, _stateManager, _state!)); EquipmentDrawer.DrawMetaToggle(ToggleDrawData.CrestFromState(CrestFlag.OffHand, _stateManager, _state!)); } + + ImGui.SameLine(); + using (_ = ImRaii.Group()) + { + EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(MetaIndex.EarState, _stateManager, _state!)); + } } private void DrawMonsterPanel() diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index e0ec4bd..35642a7 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -87,6 +87,9 @@ public class ActiveStatePanel(StateManager _stateManager, ActorObjectManager _ob PrintRow("Visor Toggled", state.BaseData.IsVisorToggled(), state.ModelData.IsVisorToggled(), state.Sources[MetaIndex.VisorState]); ImGui.TableNextRow(); + PrintRow("Viera Ears Visible", state.BaseData.AreEarsVisible(), state.ModelData.AreEarsVisible(), + state.Sources[MetaIndex.EarState]); + ImGui.TableNextRow(); PrintRow("Weapon Visible", state.BaseData.IsWeaponVisible(), state.ModelData.IsWeaponVisible(), state.Sources[MetaIndex.WeaponState]); ImGui.TableNextRow(); diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs index 38f0077..7c60dda 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs @@ -114,6 +114,7 @@ public class DesignManagerPanel(DesignManager _designManager, DesignFileSystem _ ImGuiUtil.DrawTableColumn(index.ToName()); ImGuiUtil.DrawTableColumn(design.DesignData.GetMeta(index).ToString()); ImGuiUtil.DrawTableColumn(design.DoApplyMeta(index) ? "Apply" : "Keep"); + ImGui.TableNextRow(); } ImGuiUtil.DrawTableColumn("Model ID"); diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index d1b42e8..185e19b 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -17,6 +17,7 @@ namespace Glamourer.Gui.Tabs.DebugTab; public unsafe class ModelEvaluationPanel( ActorObjectManager _objectManager, VisorService _visorService, + VieraEarService _vieraEarService, UpdateSlotService _updateSlotService, ChangeCustomizeService _changeCustomizeService, CrestService _crestService, @@ -84,6 +85,7 @@ public unsafe class ModelEvaluationPanel( ImGuiUtil.CopyOnClickSelectable(offhand.ToString()); DrawVisor(actor, model); + DrawVieraEars(actor, model); DrawHatState(actor, model); DrawWeaponState(actor, model); DrawWetness(actor, model); @@ -135,6 +137,26 @@ public unsafe class ModelEvaluationPanel( _visorService.SetVisorState(model, !VisorService.GetVisorState(model)); } + private void DrawVieraEars(Actor actor, Model model) + { + using var id = ImRaii.PushId("Viera Ears"); + ImGuiUtil.DrawTableColumn("Viera Ears"); + ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.ShowVieraEars.ToString() : "No Character"); + ImGuiUtil.DrawTableColumn(model.IsHuman ? model.VieraEarsVisible.ToString() : "No Human"); + ImGui.TableNextColumn(); + if (!model.IsHuman) + return; + + if (ImGui.SmallButton("Set True")) + _vieraEarService.SetVieraEarState(model, true); + ImGui.SameLine(); + if (ImGui.SmallButton("Set False")) + _vieraEarService.SetVieraEarState(model, false); + ImGui.SameLine(); + if (ImGui.SmallButton("Toggle")) + _vieraEarService.SetVieraEarState(model, !model.VieraEarsVisible); + } + private void DrawHatState(Actor actor, Model model) { using var id = ImRaii.PushId("HatState"); diff --git a/Glamourer/Interop/VieraEarService.cs b/Glamourer/Interop/VieraEarService.cs new file mode 100644 index 0000000..1e5c4eb --- /dev/null +++ b/Glamourer/Interop/VieraEarService.cs @@ -0,0 +1,82 @@ +using Dalamud.Hooking; +using Dalamud.Plugin.Services; +using FFXIVClientStructs.FFXIV.Client.Game.Character; +using Glamourer.Events; +using Penumbra.GameData.Interop; + +namespace Glamourer.Interop; + +public unsafe class VieraEarService : IDisposable +{ + private readonly PenumbraReloaded _penumbra; + private readonly IGameInteropProvider _interop; + public readonly VieraEarStateChanged Event; + + public VieraEarService(VieraEarStateChanged visorStateChanged, IGameInteropProvider interop, PenumbraReloaded penumbra) + { + _interop = interop; + _penumbra = penumbra; + Event = visorStateChanged; + _setupVieraEarHook = Create(); + _penumbra.Subscribe(Restore, PenumbraReloaded.Priority.VieraEarService); + } + + public void Dispose() + { + _setupVieraEarHook.Dispose(); + _penumbra.Unsubscribe(Restore); + } + + /// Obtain the current state of viera ears for the given draw object (true: toggled). + public static unsafe bool GetVieraEarState(Model characterBase) + => characterBase is { IsCharacterBase: true, VieraEarsVisible: true }; + + /// Manually set the state of the Visor for the given draw object. + /// The draw object. + /// The desired state (true: toggled). + /// Whether the state was changed. + public bool SetVieraEarState(Model human, bool on) + { + if (!human.IsHuman) + return false; + + var oldState = GetVieraEarState(human); + Glamourer.Log.Verbose($"[SetVieraEarState] Invoked manually on 0x{human.Address:X} switching from {oldState} to {on}."); + if (oldState == on) + return false; + + human.VieraEarsVisible = on; + return true; + } + + private delegate void UpdateVieraEarDelegateInternal(DrawDataContainer* drawData, byte on); + + private Hook _setupVieraEarHook; + + private void SetupVieraEarDetour(DrawDataContainer* drawData, byte value) + { + Actor actor = drawData->OwnerObject; + var originalOn = value != 0; + var on = originalOn; + // Invoke an event that can change the requested value + Event.Invoke(actor, ref on); + + Glamourer.Log.Verbose( + $"[SetVieraEarState] Invoked from game on 0x{actor.Address:X} switching to {on} (original {originalOn} from {value})."); + + _setupVieraEarHook.Original(drawData, on ? (byte)1 : (byte)0); + } + + private unsafe Hook Create() + { + var hook = _interop.HookFromSignature("E8 ?? ?? ?? ?? 48 8D 8F ?? ?? ?? ?? 4C 8D 4C 24", SetupVieraEarDetour); + hook.Enable(); + return hook; + } + + private void Restore() + { + _setupVieraEarHook.Dispose(); + _setupVieraEarHook = Create(); + } +} diff --git a/Glamourer/Interop/VisorService.cs b/Glamourer/Interop/VisorService.cs index 9763682..25823b6 100644 --- a/Glamourer/Interop/VisorService.cs +++ b/Glamourer/Interop/VisorService.cs @@ -9,9 +9,9 @@ namespace Glamourer.Interop; public class VisorService : IDisposable { - private readonly PenumbraReloaded _penumbra; - private readonly IGameInteropProvider _interop; - public readonly VisorStateChanged Event; + private readonly PenumbraReloaded _penumbra; + private readonly IGameInteropProvider _interop; + public readonly VisorStateChanged Event; public VisorService(VisorStateChanged visorStateChanged, IGameInteropProvider interop, PenumbraReloaded penumbra) { diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 0754313..6cfb4b6 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -71,6 +71,7 @@ public static class StaticServiceManager private static ServiceManager AddEvents(this ServiceManager services) => services.AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() @@ -96,6 +97,7 @@ public static class StaticServiceManager private static ServiceManager AddInterop(this ServiceManager services) => services.AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 93a3450..c346ab1 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -262,6 +262,14 @@ public class StateApplier( _visor.SetVisorState(actor.Model, value); return; } + case MetaIndex.EarState: + foreach (var actor in data.Objects.Where(a => a.Model.IsHuman)) + { + var model = actor.Model; + model.VieraEarsVisible = value; + } + + return; } } @@ -402,6 +410,7 @@ public class StateApplier( ChangeMetaState(actors, MetaIndex.HatState, state.ModelData.IsHatVisible()); ChangeMetaState(actors, MetaIndex.WeaponState, state.ModelData.IsWeaponVisible()); ChangeMetaState(actors, MetaIndex.VisorState, state.ModelData.IsVisorToggled()); + ChangeMetaState(actors, MetaIndex.EarState, state.ModelData.AreEarsVisible()); ChangeCrests(actors, state.ModelData.CrestVisibility); ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters); ChangeMaterialValues(actors, state.Materials); diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index e3f1863..dff05a3 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -189,8 +189,9 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators MetaFlag.HatState, MetaVisorState => MetaFlag.VisorState, MetaWeaponState => MetaFlag.WeaponState, + MetaEarState => MetaFlag.EarState, MetaModelId => true, CrestHead => CrestFlag.Head, diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 90520b2..4b70718 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -9,6 +9,7 @@ using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using Dalamud.Game.ClientState.Conditions; using Dalamud.Plugin.Services; +using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.GameData; using Penumbra.GameData.DataContainers; @@ -39,6 +40,7 @@ public class StateListener : IDisposable private readonly WeaponLoading _weaponLoading; private readonly HeadGearVisibilityChanged _headGearVisibility; private readonly VisorStateChanged _visorState; + private readonly VieraEarStateChanged _vieraEarState; private readonly WeaponVisibilityChanged _weaponVisibility; private readonly StateFinalized _stateFinalized; private readonly AutoDesignApplier _autoDesignApplier; @@ -62,7 +64,7 @@ public class StateListener : IDisposable WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, StateApplier applier, MovedEquipment movedEquipment, ActorObjectManager objects, GPoseService gPose, ChangeCustomizeService changeCustomizeService, CustomizeService customizations, ICondition condition, - CrestService crestService, BonusSlotUpdating bonusSlotUpdating, StateFinalized stateFinalized) + CrestService crestService, BonusSlotUpdating bonusSlotUpdating, StateFinalized stateFinalized, VieraEarStateChanged vieraEarState) { _manager = manager; _items = items; @@ -88,6 +90,7 @@ public class StateListener : IDisposable _crestService = crestService; _bonusSlotUpdating = bonusSlotUpdating; _stateFinalized = stateFinalized; + _vieraEarState = vieraEarState; Subscribe(); } @@ -266,7 +269,7 @@ public class StateListener : IDisposable private void OnGearsetDataLoaded(Actor actor, Model model) { - if (!actor.Valid || (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)) + if (!actor.Valid || _condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) return; // ensure actor and state are valid. @@ -710,6 +713,44 @@ public class StateListener : IDisposable } } + /// Handle visor state changes made by the game. + private void OnVieraEarChange(Actor actor, ref bool value) + { + // Value is inverted compared to our own handling. + + // Skip updates when in customize update. + if (ChangeCustomizeService.InUpdate.InMethod) + return; + + if (!actor.IsCharacter) + return; + + if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) + return; + + if (!actor.Identifier(_actors, out var identifier)) + return; + + if (!_manager.TryGetValue(identifier, out var state)) + return; + + // Update visor base state. + if (state.BaseData.SetEarsVisible(!value)) + { + // if base state changed, either overwrite the actual value if we have fixed values, + // or overwrite the stored model state with the new one. + if (state.Sources[MetaIndex.EarState].IsFixed()) + value = !state.ModelData.AreEarsVisible(); + else + _manager.ChangeMetaState(state, MetaIndex.EarState, !value, ApplySettings.Game); + } + else + { + // if base state did not change, overwrite the value with the model state one. + value = !state.ModelData.AreEarsVisible(); + } + } + /// Handle Hat Visibility changes. These act on the game object. private void OnHeadGearVisibilityChange(Actor actor, ref bool value) { @@ -802,6 +843,7 @@ public class StateListener : IDisposable _movedEquipment.Subscribe(OnMovedEquipment, MovedEquipment.Priority.StateListener); _weaponLoading.Subscribe(OnWeaponLoading, WeaponLoading.Priority.StateListener); _visorState.Subscribe(OnVisorChange, VisorStateChanged.Priority.StateListener); + _vieraEarState.Subscribe(OnVieraEarChange, VieraEarStateChanged.Priority.StateListener); _headGearVisibility.Subscribe(OnHeadGearVisibilityChange, HeadGearVisibilityChanged.Priority.StateListener); _weaponVisibility.Subscribe(OnWeaponVisibilityChange, WeaponVisibilityChanged.Priority.StateListener); _changeCustomizeService.Subscribe(OnCustomizeChange, ChangeCustomizeService.Priority.StateListener); @@ -820,6 +862,7 @@ public class StateListener : IDisposable _movedEquipment.Unsubscribe(OnMovedEquipment); _weaponLoading.Unsubscribe(OnWeaponLoading); _visorState.Unsubscribe(OnVisorChange); + _vieraEarState.Unsubscribe(OnVieraEarChange); _headGearVisibility.Unsubscribe(OnHeadGearVisibilityChange); _weaponVisibility.Unsubscribe(OnWeaponVisibilityChange); _changeCustomizeService.Unsubscribe(OnCustomizeChange); diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 98b12aa..e8926d6 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -158,6 +158,7 @@ public sealed class StateManager( // Visor state is a flag on the game object, but we can see the actual state on the draw object. ret.SetVisor(VisorService.GetVisorState(model)); + ret.SetEarsVisible(model.VieraEarsVisible); foreach (var slot in CrestExtensions.AllRelevantSet) ret.SetCrest(slot, CrestService.GetModelCrest(actor, slot)); @@ -186,7 +187,7 @@ public sealed class StateManager( off = actor.GetOffhand(); FistWeaponHack(ref ret, ref main, ref off); ret.SetVisor(actor.AsCharacter->DrawData.IsVisorToggled); - + ret.SetEarsVisible(actor.ShowVieraEars); foreach (var slot in CrestExtensions.AllRelevantSet) ret.SetCrest(slot, actor.GetCrest(slot)); diff --git a/Penumbra.GameData b/Penumbra.GameData index 65c5bf3..17f2f49 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 65c5bf3f46569a54b0057c9015ab839b4e2a4350 +Subproject commit 17f2f496664b0d69ebd7fcdabe7bc8e3e20b6463 From ac6a726f57a2eefda348425ed6da5aec25bc58cd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:39:05 +0200 Subject: [PATCH 319/401] Remaining API13 updates. --- Glamourer/Glamourer.csproj | 1 - Glamourer/Glamourer.json | 2 +- .../Customization/CustomizeParameterDrawer.cs | 4 ++-- Glamourer/Gui/DesignCombo.cs | 2 +- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 4 ++-- Glamourer/Gui/Materials/AdvancedDyePopup.cs | 2 +- Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 2 +- .../Gui/Tabs/AutomationTab/SetSelector.cs | 4 ++-- Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs | 2 +- .../Gui/Tabs/DesignTab/DesignLinkDrawer.cs | 2 +- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 5 +++++ .../SettingsTab/CollectionOverrideDrawer.cs | 2 +- .../Gui/Tabs/UnlocksTab/UnlockOverview.cs | 8 ++++---- Glamourer/Interop/CrestService.cs | 2 +- .../Material/LiveColorTablePreviewer.cs | 6 +++--- Glamourer/Services/TextureService.cs | 19 ++++++++++--------- 16 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 40b1218..86ae713 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -29,7 +29,6 @@ - diff --git a/Glamourer/Glamourer.json b/Glamourer/Glamourer.json index 3127d7d..2daff91 100644 --- a/Glamourer/Glamourer.json +++ b/Glamourer/Glamourer.json @@ -8,7 +8,7 @@ "AssemblyVersion": "9.0.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 12, + "DalamudApiLevel": 13, "ImageUrls": null, "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/master/images/icon.png" } \ No newline at end of file diff --git a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs index 18a9d1a..4db6b14 100644 --- a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs @@ -287,13 +287,13 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import } private ImGuiColorEditFlags GetFlags() - => Format | Display | ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.NoOptions; + => Format | Display | ImGuiColorEditFlags.Hdr | ImGuiColorEditFlags.NoOptions; private ImGuiColorEditFlags Format => config.UseFloatForColors ? ImGuiColorEditFlags.Float : ImGuiColorEditFlags.Uint8; private ImGuiColorEditFlags Display - => config.UseRgbForColors ? ImGuiColorEditFlags.DisplayRGB : ImGuiColorEditFlags.DisplayHSV; + => config.UseRgbForColors ? ImGuiColorEditFlags.DisplayRgb : ImGuiColorEditFlags.DisplayHsv; private ImRaii.IEndObject EnsureSize() { diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index 6dfffef..2d8880e 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -194,7 +194,7 @@ public abstract class DesignComboBase : FilterComboCacheDataType).SequenceEqual("equipDragDrop"u8)) + if (!MemoryMarshal.CreateReadOnlySpanFromNullTerminated((byte*)Unsafe.AsPointer(ref payload->DataType_0)).SequenceEqual("equipDragDrop"u8)) return; using var tt = ImUtf8.Tooltip(); diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 8cf81ff..4499107 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -91,7 +91,7 @@ public sealed unsafe class AdvancedDyePopup( var modelHandle = model == null ? null : model->ModelResourceHandle; var path = materialHandle == null ? string.Empty - : ByteString.FromSpanUnsafe(materialHandle->ResourceHandle.FileName.AsSpan(), true).ToString(); + : ByteString.FromSpanUnsafe(materialHandle->FileName.AsSpan(), true).ToString(); var gamePath = modelHandle == null ? string.Empty : modelHandle->GetMaterialFileNameBySlot(index.MaterialIndex).ToString(); diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 4b05e35..8a85a45 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -432,7 +432,7 @@ public class SetPanel( if (source) { ImUtf8.Text($"Moving design #{index + 1:D2}..."); - if (ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0)) + if (ImGui.SetDragDropPayload(dragDropLabel, null, 0)) { _dragIndex = index; _selector.DragDesignIndex = index; diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs index dca0ce5..8a235ae 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs @@ -144,7 +144,7 @@ public class SetSelector : IDisposable ImGui.SameLine(); var f = _enabledFilter; - if (ImGui.CheckboxFlags("##enabledFilter", ref f, 3)) + if (ImGui.CheckboxFlags("##enabledFilter", ref f, 3u)) { _enabledFilter = _enabledFilter switch { @@ -347,7 +347,7 @@ public class SetSelector : IDisposable if (source) { ImGui.TextUnformatted($"Moving design set {GetSetName(set, index)} from position {index + 1}..."); - if (ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0)) + if (ImGui.SetDragDropPayload(dragDropLabel, null, 0)) _dragIndex = index; } } diff --git a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index 9992bc3..aa94a23 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -49,7 +49,7 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem ImGui.TableNextColumn(); var address = _drawObject.Address; ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale); - if (ImGui.InputScalar("##drawObjectPtr", ImGuiDataType.U64, (nint)(&address), nint.Zero, nint.Zero, "%llx", + if (ImGui.InputScalar("##drawObjectPtr", ImGuiDataType.U64, ref address, nint.Zero, nint.Zero, "%llx", ImGuiInputTextFlags.CharsHexadecimal)) _drawObject = address; ImGuiUtil.DrawTableColumn(_penumbra.Available diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs index 7e5807e..d9517c8 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs @@ -195,7 +195,7 @@ public class DesignLinkDrawer( { if (source) { - ImGui.SetDragDropPayload("DraggingLink", IntPtr.Zero, 0); + ImGui.SetDragDropPayload("DraggingLink", null, 0); ImGui.TextUnformatted($"Reordering {design.Name}..."); _dragDropIndex = index; _dragDropOrder = order; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 5bb3d77..84aaac0 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -154,6 +154,11 @@ public class DesignPanel EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(MetaIndex.WeaponState, _manager, _selector.Selected!)); EquipmentDrawer.DrawMetaToggle(ToggleDrawData.CrestFromDesign(CrestFlag.OffHand, _manager, _selector.Selected!)); } + ImGui.SameLine(); + using (var _ = ImRaii.Group()) + { + EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(MetaIndex.EarState, _manager, _selector.Selected!)); + } } private void DrawCustomize() diff --git a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs index 76435ec..5c4fec3 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs @@ -123,7 +123,7 @@ public class CollectionOverrideDrawer( { if (source) { - ImGui.SetDragDropPayload("DraggingOverride", nint.Zero, 0); + ImGui.SetDragDropPayload("DraggingOverride", null, 0); ImGui.TextUnformatted($"Reordering Override #{idx + 1}..."); _dragDropIndex = idx; } diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index 947f0c6..8644aeb 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -123,7 +123,7 @@ public class UnlockOverview( var unlocked = customizeUnlocks.IsUnlocked(customize, out var time); var icon = customizations.Manager.GetIcon(customize.IconId); var hasIcon = icon.TryGetWrap(out var wrap, out _); - ImGui.Image(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, iconSize, Vector2.Zero, Vector2.One, + ImGui.Image(wrap?.Handle ?? icon.GetWrapOrEmpty().Handle, iconSize, Vector2.Zero, Vector2.One, unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (favorites.Contains(_selected3, _selected2, customize.Index, customize.Value)) @@ -135,7 +135,7 @@ public class UnlockOverview( using var tt = ImRaii.Tooltip(); var size = new Vector2(wrap!.Width, wrap.Height); if (size.X >= iconSize.X && size.Y >= iconSize.Y) - ImGui.Image(wrap.ImGuiHandle, size); + ImGui.Image(wrap.Handle, size); ImGui.TextUnformatted(unlockData.Name); ImGui.TextUnformatted($"{customize.Index.ToDefaultName()} {customize.Value.Value}"); ImGui.TextUnformatted(unlocked ? $"Unlocked on {time:g}" : "Not unlocked."); @@ -194,7 +194,7 @@ public class UnlockOverview( if (!textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) return; - var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); + var (icon, size) = (iconHandle.Handle, new Vector2(iconHandle.Width, iconHandle.Height)); ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); @@ -265,7 +265,7 @@ public class UnlockOverview( if (!textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) return; - var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); + var (icon, size) = (iconHandle.Handle, new Vector2(iconHandle.Width, iconHandle.Height)); ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); diff --git a/Glamourer/Interop/CrestService.cs b/Glamourer/Interop/CrestService.cs index 74b7800..2b55f94 100644 --- a/Glamourer/Interop/CrestService.cs +++ b/Glamourer/Interop/CrestService.cs @@ -67,7 +67,7 @@ public sealed unsafe class CrestService : EventWrapperRef3 _crestChangeHook = null!; private void CrestChangeDetour(DrawDataContainer* container, byte crestFlags) diff --git a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs index 4190746..3b9edb7 100644 --- a/Glamourer/Interop/Material/LiveColorTablePreviewer.cs +++ b/Glamourer/Interop/Material/LiveColorTablePreviewer.cs @@ -114,9 +114,9 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable var frame = DateTimeOffset.UtcNow.UtcTicks; var hueByte = frame % (steps * frameLength) / frameLength; var hue = (float)hueByte / steps; - float r, g, b = 0; - ImGui.ColorConvertHSVtoRGB(hue, 1, 1, &r, &g, &b); - return new Vector3(r, g, b); + Vector3 ret; + ImGui.ColorConvertHSVtoRGB(hue, 1, 1, &ret.X, &ret.Y, &ret.Z); + return ret; } public void Dispose() diff --git a/Glamourer/Services/TextureService.cs b/Glamourer/Services/TextureService.cs index 29c2343..a0ec443 100644 --- a/Glamourer/Services/TextureService.cs +++ b/Glamourer/Services/TextureService.cs @@ -1,3 +1,4 @@ +using Dalamud.Bindings.ImGui; using Dalamud.Interface; using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Plugin.Services; @@ -12,30 +13,30 @@ public sealed class TextureService(IUiBuilder uiBuilder, IDataManager dataManage { private readonly IDalamudTextureWrap?[] _slotIcons = CreateSlotIcons(uiBuilder); - public (nint, Vector2, bool) GetIcon(EquipItem item, EquipSlot slot) + public (ImTextureID, Vector2, bool) GetIcon(EquipItem item, EquipSlot slot) { if (item.IconId.Id != 0 && TryLoadIcon(item.IconId.Id, out var ret)) - return (ret.ImGuiHandle, new Vector2(ret.Width, ret.Height), false); + return (ret.Handle, new Vector2(ret.Width, ret.Height), false); var idx = slot.ToIndex(); return idx < 12 && _slotIcons[idx] != null - ? (_slotIcons[idx]!.ImGuiHandle, new Vector2(_slotIcons[idx]!.Width, _slotIcons[idx]!.Height), true) - : (nint.Zero, Vector2.Zero, true); + ? (_slotIcons[idx]!.Handle, new Vector2(_slotIcons[idx]!.Width, _slotIcons[idx]!.Height), true) + : (default, Vector2.Zero, true); } - public (nint, Vector2, bool) GetIcon(EquipItem item, BonusItemFlag slot) + public (ImTextureID, Vector2, bool) GetIcon(EquipItem item, BonusItemFlag slot) { if (item.IconId.Id != 0 && TryLoadIcon(item.IconId.Id, out var ret)) - return (ret.ImGuiHandle, new Vector2(ret.Width, ret.Height), false); + return (ret.Handle, new Vector2(ret.Width, ret.Height), false); var idx = slot.ToIndex(); if (idx == uint.MaxValue) - return (nint.Zero, Vector2.Zero, true); + return (default, Vector2.Zero, true); idx += 12; return idx < 13 && _slotIcons[idx] != null - ? (_slotIcons[idx]!.ImGuiHandle, new Vector2(_slotIcons[idx]!.Width, _slotIcons[idx]!.Height), true) - : (nint.Zero, Vector2.Zero, true); + ? (_slotIcons[idx]!.Handle, new Vector2(_slotIcons[idx]!.Width, _slotIcons[idx]!.Height), true) + : (default, Vector2.Zero, true); } public void Dispose() From 44729205368908f17e3d0660fe7779741122e0a4 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:46:24 +0200 Subject: [PATCH 320/401] Move Viera Ears sig to gamedata. --- Glamourer/Interop/VieraEarService.cs | 3 ++- Penumbra.GameData | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Glamourer/Interop/VieraEarService.cs b/Glamourer/Interop/VieraEarService.cs index 1e5c4eb..a6afd1d 100644 --- a/Glamourer/Interop/VieraEarService.cs +++ b/Glamourer/Interop/VieraEarService.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game.Character; using Glamourer.Events; +using Penumbra.GameData; using Penumbra.GameData.Interop; namespace Glamourer.Interop; @@ -69,7 +70,7 @@ public unsafe class VieraEarService : IDisposable private unsafe Hook Create() { - var hook = _interop.HookFromSignature("E8 ?? ?? ?? ?? 48 8D 8F ?? ?? ?? ?? 4C 8D 4C 24", SetupVieraEarDetour); + var hook = _interop.HookFromSignature(Sigs.SetupVieraEars, SetupVieraEarDetour); hook.Enable(); return hook; } diff --git a/Penumbra.GameData b/Penumbra.GameData index 17f2f49..7981d20 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 17f2f496664b0d69ebd7fcdabe7bc8e3e20b6463 +Subproject commit 7981d2041bc49096101ab128682155dbe1fbc468 From 97e32a3cb7a953eba65bcbca0ee4040d76a0f1da Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:48:19 +0200 Subject: [PATCH 321/401] Update GameData. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 7981d20..ea49bc0 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 7981d2041bc49096101ab128682155dbe1fbc468 +Subproject commit ea49bc099e783ecafdf78f0bd0bc41fb8c60ad19 From be78f1447bd20c1c273a55ce4823780437f7e748 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 15:56:08 +0200 Subject: [PATCH 322/401] 1.5.0.0 --- Glamourer/Gui/GlamourerChangelog.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index a62743c..31d1ce3 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -43,6 +43,7 @@ public class GlamourerChangelog Add1_3_7_0(Changelog); Add1_3_8_0(Changelog); Add1_4_0_0(Changelog); + Add1_5_0_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -63,6 +64,19 @@ public class GlamourerChangelog } } + private static void Add1_5_0_0(Changelog log) + => log.NextVersion("Version 1.5.0.0") + .RegisterImportant("Updated for game version 7.30 and Dalamud API13, which uses a new GUI backend. Some things may not work as expected. Please let me know any issues you encounter.") + .RegisterHighlight("Added the new Viera Ears state to designs. Old designs will not apply the state.") + .RegisterHighlight("Added the option to make newly created designs write-protected by default to the design defaults.") + .RegisterEntry("Fixed issues with reverting state and IPC.") + .RegisterEntry("Fixed an issue when using the mousewheel to scroll through designs (1.4.0.3).") + .RegisterEntry("Fixed an issue with invalid bonus items (1.4.0.3).") + .RegisterHighlight("Added drag & drop of equipment pieces which will try to match the corresponding model IDs in other slots if possible (1.4.0.2).") + .RegisterEntry("Heavily optimized some issues when having many designs and creating new ones or updating them (1.4.0.2)") + .RegisterEntry("Fixed an issue with staining templates (1.4.0.1).") + .RegisterEntry("Fixed an issue with the QDB buttons not counting correctly (1.4.0.1)."); + private static void Add1_4_0_0(Changelog log) => log.NextVersion("Version 1.4.0.0") .RegisterHighlight("The design selector width is now draggable within certain restrictions that depend on the total window width.") From b66df624f77b7a765f6c4739627d1645422e74a5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 23:01:54 +0200 Subject: [PATCH 323/401] Update Gamedata. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index ea49bc0..fd875c4 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit ea49bc099e783ecafdf78f0bd0bc41fb8c60ad19 +Subproject commit fd875c43ee910350107b2609809335285bd4ac0f From 56753ae7bab53ce93ea9e150d569f7b46e8c1e99 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 23:03:58 +0200 Subject: [PATCH 324/401] Use staging for release. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18435ae..327b75b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: dotnet restore - name: Download Dalamud run: | - Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip + Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev" - name: Build run: | From 557cbf23ce7cf431f87643738092bb1b9d334b98 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 8 Aug 2025 21:06:10 +0000 Subject: [PATCH 325/401] [CI] Updating repo.json for 1.5.0.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 0c6e22f..3f9f19c 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.4.0.3", - "TestingAssemblyVersion": "1.4.0.3", + "AssemblyVersion": "1.5.0.0", + "TestingAssemblyVersion": "1.5.0.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 12, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.3/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.4.0.3/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 98574558e5b3fdbbebc9368c6f2033543956294a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Aug 2025 23:07:08 +0200 Subject: [PATCH 326/401] Set Repo API level to 13 and remove stg from future releases. --- .github/workflows/release.yml | 2 +- repo.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 327b75b..18435ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: dotnet restore - name: Download Dalamud run: | - Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip + Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev" - name: Build run: | diff --git a/repo.json b/repo.json index 3f9f19c..40cbed2 100644 --- a/repo.json +++ b/repo.json @@ -21,8 +21,8 @@ "TestingAssemblyVersion": "1.5.0.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 12, - "TestingDalamudApiLevel": 12, + "DalamudApiLevel": 13, + "TestingDalamudApiLevel": 13, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From a8b79993df3200c196e53ea92177558b1e9ef56f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 11:47:11 +0200 Subject: [PATCH 327/401] Make QDB ignore close hotkey. --- Glamourer/Gui/DesignQuickBar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index 2dee0e4..6425c5c 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -52,7 +52,6 @@ public sealed class DesignQuickBar : Window, IDisposable public DesignQuickBar(Configuration config, QuickDesignCombo designCombo, StateManager stateManager, IKeyState keyState, ActorObjectManager objects, AutoDesignApplier autoDesignApplier, PenumbraService penumbra) - : base("Glamourer Quick Bar", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking) { _config = config; _designCombo = designCombo; @@ -64,6 +63,7 @@ public sealed class DesignQuickBar : Window, IDisposable IsOpen = _config.Ephemeral.ShowDesignQuickBar; DisableWindowSounds = true; Size = Vector2.Zero; + RespectCloseHotkey = false; } public void Dispose() From 52fd29c4787255067aa118fa9fbe1a8080e8ab82 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 11:52:17 +0200 Subject: [PATCH 328/401] Woops --- Glamourer/Gui/DesignQuickBar.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index 6425c5c..e8c0ce3 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -52,6 +52,7 @@ public sealed class DesignQuickBar : Window, IDisposable public DesignQuickBar(Configuration config, QuickDesignCombo designCombo, StateManager stateManager, IKeyState keyState, ActorObjectManager objects, AutoDesignApplier autoDesignApplier, PenumbraService penumbra) + : base("Glamourer Quick Bar", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking) { _config = config; _designCombo = designCombo; From e83f328cdcc306d2b2ef0af7332629bc75c33a39 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 11:58:52 +0200 Subject: [PATCH 329/401] Fix resizable child. --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index 9523b7a..539ce9e 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 9523b7ac725656b21fa98faef96962652e86e64f +Subproject commit 539ce9e504fdc8bb0c2ca229905f4d236c376f6a From 0d94aae7322b5baf2a0f50b03cc561b52f60e4ac Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 12:11:42 +0200 Subject: [PATCH 330/401] Fix popups not working early. --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index 539ce9e..5224ac5 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 539ce9e504fdc8bb0c2ca229905f4d236c376f6a +Subproject commit 5224ac538b1a7c0e86e7d2ceaf652d8d807888ae From 4761b8f5847ddd246703437f821886007cae476e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 13:01:48 +0200 Subject: [PATCH 331/401] Need staging again... --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18435ae..327b75b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: dotnet restore - name: Download Dalamud run: | - Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip + Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev" - name: Build run: | From 34bf95dddb739d10741122bbe76d01e178bcc957 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 9 Aug 2025 11:03:48 +0000 Subject: [PATCH 332/401] [CI] Updating repo.json for 1.5.0.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 40cbed2..ffa61be 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.0", - "TestingAssemblyVersion": "1.5.0.0", + "AssemblyVersion": "1.5.0.1", + "TestingAssemblyVersion": "1.5.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From a9caddafd50c0e223fd191f4decdc6352aa8aad1 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 18:39:07 +0200 Subject: [PATCH 333/401] Maybe fix design crashes. --- Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index 7341d31..e0e4543 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -175,7 +175,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector Date: Sat, 9 Aug 2025 16:41:32 +0000 Subject: [PATCH 334/401] [CI] Updating repo.json for 1.5.0.2 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index ffa61be..56d0c96 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.1", - "TestingAssemblyVersion": "1.5.0.1", + "AssemblyVersion": "1.5.0.2", + "TestingAssemblyVersion": "1.5.0.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.2/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 8f34f197d0aa70693c8ccf98911778b397cc2729 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 18:53:22 +0200 Subject: [PATCH 335/401] Another try. --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index 5224ac5..5e32bb2 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 5224ac538b1a7c0e86e7d2ceaf652d8d807888ae +Subproject commit 5e32bb225e5fbb60ed8426ed887fd7e8a831ebae From 304b362002cafbaf97689d51105644ced66157a8 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 9 Aug 2025 16:55:27 +0000 Subject: [PATCH 336/401] [CI] Updating repo.json for 1.5.0.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 56d0c96..e117eee 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.2", - "TestingAssemblyVersion": "1.5.0.2", + "AssemblyVersion": "1.5.0.3", + "TestingAssemblyVersion": "1.5.0.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.2/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.2/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.3/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 612cd31c3e86eafa8d81077cb20882ce5e709523 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 19:02:26 +0200 Subject: [PATCH 337/401] Fix some caravans. --- Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index 042f2a2..8a3dd06 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -189,10 +189,7 @@ public class DesignDetailTab else if (_selector.Selected!.Color.Length != 0) { ImGui.SameLine(); - var size = new Vector2(ImGui.GetFrameHeight()); - using var font = ImRaii.PushFont(UiBuilder.IconFont); - ImGuiUtil.DrawTextButton(FontAwesomeIcon.ExclamationCircle.ToIconString(), size, 0, _colors.MissingColor); - ImUtf8.HoverTooltip("The color associated with this design does not exist."u8); + ImUtf8.Icon(FontAwesomeIcon.ExclamationCircle, "The color associated with this design does not exist."u8, _colors.MissingColor); } ImUtf8.DrawFrameColumn("Creation Date"u8); From 240c889fff459afd0769a92123e93c815f386df2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Aug 2025 20:48:46 +0200 Subject: [PATCH 338/401] Fix changed equipment access to use new size. --- Glamourer/Interop/Material/MaterialManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 9eccb29..1ffd820 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -197,7 +197,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable if (human->ChangedEquipData == null) return ((Model)human).GetArmor(((uint)slotId).ToEquipSlot()).ToWeapon(0); - return ((CharacterArmor*)human->ChangedEquipData + slotId * 3)->ToWeapon(0); + return ((CharacterArmor*)human->ChangedEquipData + slotId * 4)->ToWeapon(0); } /// From e4374337f2ea3099da8fc06d84b0f02a5ad524ff Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 9 Aug 2025 18:50:50 +0000 Subject: [PATCH 339/401] [CI] Updating repo.json for 1.5.0.4 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index e117eee..447bda2 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.3", - "TestingAssemblyVersion": "1.5.0.3", + "AssemblyVersion": "1.5.0.4", + "TestingAssemblyVersion": "1.5.0.4", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.3/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.3/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.4/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.4/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.4/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 26862ba78f46e69d7d3e1ab48c795e60c1ef7b0b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 11 Aug 2025 19:58:36 +0200 Subject: [PATCH 340/401] Update ChangedEquipData. --- Glamourer/Interop/Material/MaterialManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 1ffd820..5b731b0 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -197,7 +197,8 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable if (human->ChangedEquipData == null) return ((Model)human).GetArmor(((uint)slotId).ToEquipSlot()).ToWeapon(0); - return ((CharacterArmor*)human->ChangedEquipData + slotId * 4)->ToWeapon(0); + var item = (ChangedEquipData*)human->ChangedEquipData + slotId; + return ((CharacterArmor*)item)->ToWeapon(0); } /// From dc431c10a55f32894af23aff9650ae94d0c81631 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 11 Aug 2025 19:59:20 +0200 Subject: [PATCH 341/401] Add chat command to toggle automation. --- Glamourer/Services/CommandService.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index d47f26f..d2feac0 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -96,6 +96,12 @@ public class CommandService : IDisposable, IApiService _config.Ephemeral.LockMainWindow = !_config.Ephemeral.LockMainWindow; _config.Ephemeral.Save(); return; + case "automation": + var newValue = !_config.EnableAutoDesigns; + _config.EnableAutoDesigns = newValue; + _autoDesignApplier.OnEnableAutoDesignsChanged(newValue); + _config.Save(); + return; default: _chat.Print("Use without argument to toggle the main window."); _chat.Print(new SeStringBuilder().AddText("Use ").AddPurple("/glamour").AddText(" instead of ").AddRed("/glamourer") From 4cc191cb25308629225847a3d27732e69eb34999 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 11 Aug 2025 20:53:44 +0200 Subject: [PATCH 342/401] Add viera ear visibility to application rules. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 84aaac0..381d342 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -270,11 +270,9 @@ public class DesignPanel DrawCrestApplication(); ImUtf8.IconDummy(); DrawMetaApplication(); - ImUtf8.IconDummy(); - DrawBonusSlotApplication(); } - ImGui.SameLine(ImGui.GetContentRegionAvail().X / 2); + ImGui.SameLine(210 * ImUtf8.GlobalScale + ImGui.GetStyle().ItemSpacing.X); using (var _ = ImRaii.Group()) { void ApplyEquip(string label, EquipFlag allFlags, bool stain, IEnumerable slots) @@ -316,6 +314,9 @@ public class DesignPanel ImUtf8.IconDummy(); DrawParameterApplication(); + + ImUtf8.IconDummy(); + DrawBonusSlotApplication(); } } @@ -324,7 +325,7 @@ public class DesignPanel var enabled = _config.DeleteDesignModifier.IsActive(); bool? equip = null; bool? customize = null; - var size = new Vector2(200 * ImUtf8.GlobalScale, 0); + var size = new Vector2(210 * ImUtf8.GlobalScale, 0); if (ImUtf8.ButtonEx("Disable Everything"u8, "Disable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness."u8, size, !enabled)) @@ -414,6 +415,7 @@ public class DesignPanel "Apply Hat Visibility", "Apply Visor State", "Apply Weapon Visibility", + "Apply Viera Ear Visibility", ]; private void DrawMetaApplication() From abf998a7273c7bcc9ff2ec262b6bc5954f660f50 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 12 Aug 2025 12:29:55 +0200 Subject: [PATCH 343/401] Update GameData --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index fd875c4..2f5e901 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit fd875c43ee910350107b2609809335285bd4ac0f +Subproject commit 2f5e901314444238ab3aa6c5043368622bca815a From 65f789880d06d94879a78d33ab39241362b8ed95 Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 12 Aug 2025 10:32:03 +0000 Subject: [PATCH 344/401] [CI] Updating repo.json for 1.5.0.5 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 447bda2..513dd43 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.4", - "TestingAssemblyVersion": "1.5.0.4", + "AssemblyVersion": "1.5.0.5", + "TestingAssemblyVersion": "1.5.0.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.4/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.4/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.4/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.5/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.5/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.5/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c9b291c2f313a199766a410ee4711cd893907ffe Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 12 Aug 2025 14:46:56 +0200 Subject: [PATCH 345/401] Add new parameter to LoadWeapon hook. --- Glamourer/Interop/WeaponService.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Glamourer/Interop/WeaponService.cs b/Glamourer/Interop/WeaponService.cs index b0bdd19..54f318b 100644 --- a/Glamourer/Interop/WeaponService.cs +++ b/Glamourer/Interop/WeaponService.cs @@ -13,7 +13,7 @@ public unsafe class WeaponService : IDisposable private readonly WeaponLoading _event; private readonly ThreadLocal _inUpdate = new(() => false); - private readonly delegate* unmanaged[Stdcall] + private readonly delegate* unmanaged[Stdcall] _original; public WeaponService(WeaponLoading @event, IGameInteropProvider interop) @@ -22,7 +22,7 @@ public unsafe class WeaponService : IDisposable _loadWeaponHook = interop.HookFromAddress((nint)DrawDataContainer.MemberFunctionPointers.LoadWeapon, LoadWeaponDetour); _original = - (delegate* unmanaged[Stdcall] < DrawDataContainer*, uint, ulong, byte, byte, byte, byte, void >) + (delegate* unmanaged[Stdcall] < DrawDataContainer*, uint, ulong, byte, byte, byte, byte, int, void >) DrawDataContainer.MemberFunctionPointers.LoadWeapon; _loadWeaponHook.Enable(); } @@ -36,13 +36,14 @@ public unsafe class WeaponService : IDisposable // redrawOnEquality controls whether the game does anything if the new weapon is identical to the old one. // skipGameObject seems to control whether the new weapons are written to the game object or just influence the draw object. (1 = skip, 0 = change) // unk4 seemed to be the same as unk1. + // unk5 is new in 7.30 and is checked at the beginning of the function to call some timeline related function. private delegate void LoadWeaponDelegate(DrawDataContainer* drawData, uint slot, ulong weapon, byte redrawOnEquality, byte unk2, - byte skipGameObject, byte unk4); + byte skipGameObject, byte unk4, byte unk5); private readonly Hook _loadWeaponHook; private void LoadWeaponDetour(DrawDataContainer* drawData, uint slot, ulong weaponValue, byte redrawOnEquality, byte unk2, - byte skipGameObject, byte unk4) + byte skipGameObject, byte unk4, byte unk5) { if (!_inUpdate.Value) { @@ -64,21 +65,21 @@ public unsafe class WeaponService : IDisposable else if (weaponValue == actor.GetMainhand().Value && weaponValue != 0) _event.Invoke(actor, EquipSlot.MainHand, ref tmpWeapon); - _loadWeaponHook.Original(drawData, slot, weapon.Value, redrawOnEquality, unk2, skipGameObject, unk4); + _loadWeaponHook.Original(drawData, slot, weapon.Value, redrawOnEquality, unk2, skipGameObject, unk4, unk5); if (tmpWeapon.Value != weapon.Value) { if (tmpWeapon.Skeleton.Id == 0) tmpWeapon.Stains = StainIds.None; - _loadWeaponHook.Original(drawData, slot, tmpWeapon.Value, 1, unk2, 1, unk4); + _loadWeaponHook.Original(drawData, slot, tmpWeapon.Value, 1, unk2, 1, unk4, unk5); } Glamourer.Log.Excessive( - $"Weapon reloaded for 0x{actor.Address:X} ({actor.Utf8Name}) with attributes {slot} {weapon.Value:X14}, {redrawOnEquality}, {unk2}, {skipGameObject}, {unk4}"); + $"Weapon reloaded for 0x{actor.Address:X} ({actor.Utf8Name}) with attributes {slot} {weapon.Value:X14}, {redrawOnEquality}, {unk2}, {skipGameObject}, {unk4}, {unk5}"); } else { - _loadWeaponHook.Original(drawData, slot, weaponValue, redrawOnEquality, unk2, skipGameObject, unk4); + _loadWeaponHook.Original(drawData, slot, weaponValue, redrawOnEquality, unk2, skipGameObject, unk4, unk5); } } @@ -89,18 +90,18 @@ public unsafe class WeaponService : IDisposable { case EquipSlot.MainHand: _inUpdate.Value = true; - _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0); + _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0, 0); _inUpdate.Value = false; return; case EquipSlot.OffHand: _inUpdate.Value = true; - _original(&character.AsCharacter->DrawData, 1, weapon.Value, 1, 0, 1, 0); + _original(&character.AsCharacter->DrawData, 1, weapon.Value, 1, 0, 1, 0, 0); _inUpdate.Value = false; return; case EquipSlot.BothHand: _inUpdate.Value = true; - _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0); - _original(&character.AsCharacter->DrawData, 1, CharacterWeapon.Empty.Value, 1, 0, 1, 0); + _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0, 0); + _original(&character.AsCharacter->DrawData, 1, CharacterWeapon.Empty.Value, 1, 0, 1, 0, 0); _inUpdate.Value = false; return; } From 49d24df2e7e8812ce1a3b960ce355f06260b56a3 Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 12 Aug 2025 12:53:44 +0000 Subject: [PATCH 346/401] [CI] Updating repo.json for 1.5.0.6 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 513dd43..eec3de8 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.5", - "TestingAssemblyVersion": "1.5.0.5", + "AssemblyVersion": "1.5.0.6", + "TestingAssemblyVersion": "1.5.0.6", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.5/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.5/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.5/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.6/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.6/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.6/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From e854386b2384c2f20cba1d1c149f3a70a81779f3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 16 Aug 2025 11:58:04 +0200 Subject: [PATCH 347/401] Update OtterGui --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index 5e32bb2..4a9b71a 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 5e32bb225e5fbb60ed8426ed887fd7e8a831ebae +Subproject commit 4a9b71a93e76aa5eed818542288329e34ec0dd89 From bb2ba0cf113fa6b0b60ef2571829dccfc9c21cfc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 16 Aug 2025 11:58:41 +0200 Subject: [PATCH 348/401] Add glasses to advanced dye slot combo. --- Glamourer/Gui/Materials/MaterialDrawer.cs | 41 +++++++++++++++---- .../Gui/Tabs/AutomationTab/HumanNpcCombo.cs | 2 +- .../Interop/Material/MaterialValueIndex.cs | 19 +++++++++ 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index ce50ff2..7c16372 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -18,7 +18,6 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) public const float GlossWidth = 100; public const float SpecularStrengthWidth = 125; - private EquipSlot _newSlot = EquipSlot.Head; private int _newMaterialIdx; private int _newRowIdx; private MaterialValueIndex _newKey = MaterialValueIndex.FromSlot(EquipSlot.Head); @@ -178,14 +177,42 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config) public sealed class MaterialSlotCombo; + private void DrawSlotCombo() + { + var width = ImUtf8.CalcTextSize(EquipSlot.OffHand.ToName()).X + ImGui.GetFrameHeightWithSpacing(); + ImGui.SetNextItemWidth(width); + using var combo = ImUtf8.Combo("##slot"u8, _newKey.SlotName()); + if (combo) + { + var currentSlot = _newKey.ToEquipSlot(); + foreach (var tmpSlot in EquipSlotExtensions.FullSlots) + { + if (ImUtf8.Selectable(tmpSlot.ToName(), tmpSlot == currentSlot) && currentSlot != tmpSlot) + _newKey = MaterialValueIndex.FromSlot(tmpSlot) with + { + MaterialIndex = (byte)_newMaterialIdx, + RowIndex = (byte)_newRowIdx, + }; + } + + var currentBonus = _newKey.ToBonusSlot(); + foreach (var bonusSlot in BonusExtensions.AllFlags) + { + if (ImUtf8.Selectable(bonusSlot.ToName(), bonusSlot == currentBonus) && bonusSlot != currentBonus) + _newKey = MaterialValueIndex.FromSlot(bonusSlot) with + { + MaterialIndex = (byte)_newMaterialIdx, + RowIndex = (byte)_newRowIdx, + }; + } + } + + ImUtf8.HoverTooltip("Choose a slot for an advanced dye row."u8); + } + public void DrawNew(Design design) { - if (EquipSlotCombo.Draw("##slot", "Choose a slot for an advanced dye row.", ref _newSlot)) - _newKey = MaterialValueIndex.FromSlot(_newSlot) with - { - MaterialIndex = (byte)_newMaterialIdx, - RowIndex = (byte)_newRowIdx, - }; + DrawSlotCombo(); ImUtf8.SameLineInner(); DrawMaterialIdxDrag(); ImUtf8.SameLineInner(); diff --git a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs index ce843c4..1d3e711 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs @@ -2,11 +2,11 @@ using Dalamud.Utility; using Dalamud.Bindings.ImGui; using OtterGui; -using OtterGui.Custom; using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Widgets; using Penumbra.GameData.DataContainers; +using OtterGui.Custom; namespace Glamourer.Gui.Tabs.AutomationTab; diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index 712b0d5..eb3f71f 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -50,6 +50,18 @@ public readonly record struct MaterialValueIndex( return idx > 2 ? Invalid : new MaterialValueIndex(DrawObjectType.Human, (byte)(idx + 16), 0, 0); } + public string SlotName() + { + var slot = ToEquipSlot(); + if (slot is not EquipSlot.Unknown) + return slot.ToName(); + + if (DrawObject is DrawObjectType.Human && SlotIndex is 16) + return BonusItemFlag.Glasses.ToString(); + + return EquipSlot.Unknown.ToName(); + } + public EquipSlot ToEquipSlot() => DrawObject switch { @@ -59,6 +71,13 @@ public readonly record struct MaterialValueIndex( _ => EquipSlot.Unknown, }; + public BonusItemFlag ToBonusSlot() + => DrawObject switch + { + DrawObjectType.Human when SlotIndex > 15 => ((uint)SlotIndex - 16).ToBonusSlot(), + _ => BonusItemFlag.Unknown, + }; + public unsafe bool TryGetModel(Actor actor, out Model model) { if (!actor.Valid) From 22e6c0655bcb67e0ee8a6c1a6b03fbdef5729815 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 16 Aug 2025 11:59:03 +0200 Subject: [PATCH 349/401] Add ear state when toggling meta application via button. --- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 381d342..e3c965c 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -154,6 +154,7 @@ public class DesignPanel EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(MetaIndex.WeaponState, _manager, _selector.Selected!)); EquipmentDrawer.DrawMetaToggle(ToggleDrawData.CrestFromDesign(CrestFlag.OffHand, _manager, _selector.Selected!)); } + ImGui.SameLine(); using (var _ = ImRaii.Group()) { @@ -403,6 +404,7 @@ public class DesignPanel _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.HatState, equip.Value); _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.VisorState, equip.Value); _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.WeaponState, equip.Value); + _manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.EarState, equip.Value); } if (customize.HasValue) From b2b8f2b6ebc5fa54b4051c204ae11a05aa6e716a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 17 Aug 2025 10:43:26 +0200 Subject: [PATCH 350/401] Make glamourers visor toggle trigger static visors. (?!?) --- Glamourer/Interop/VisorService.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/VisorService.cs b/Glamourer/Interop/VisorService.cs index 25823b6..83262e4 100644 --- a/Glamourer/Interop/VisorService.cs +++ b/Glamourer/Interop/VisorService.cs @@ -9,9 +9,9 @@ namespace Glamourer.Interop; public class VisorService : IDisposable { - private readonly PenumbraReloaded _penumbra; - private readonly IGameInteropProvider _interop; - public readonly VisorStateChanged Event; + private readonly PenumbraReloaded _penumbra; + private readonly IGameInteropProvider _interop; + public readonly VisorStateChanged Event; public VisorService(VisorStateChanged visorStateChanged, IGameInteropProvider interop, PenumbraReloaded penumbra) { @@ -36,7 +36,7 @@ public class VisorService : IDisposable /// The draw object. /// The desired state (true: toggled). /// Whether the state was changed. - public bool SetVisorState(Model human, bool on) + public unsafe bool SetVisorState(Model human, bool on) { if (!human.IsHuman) return false; @@ -46,6 +46,8 @@ public class VisorService : IDisposable if (oldState == on) return false; + // No clue what this flag does, but it's necessary for toggling static visors on or off, e.g. Alternate Cap (6229-1). + human.AsHuman->StateFlags |= (CharacterBase.StateFlag)0x40000000; SetupVisorDetour(human, human.GetArmor(EquipSlot.Head).Set.Id, on); return true; } From 3704051b0fc9f367c750ee9b636e937ddeaa3c9e Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 17 Aug 2025 08:45:55 +0000 Subject: [PATCH 351/401] [CI] Updating repo.json for 1.5.0.7 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index eec3de8..849d380 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.6", - "TestingAssemblyVersion": "1.5.0.6", + "AssemblyVersion": "1.5.0.7", + "TestingAssemblyVersion": "1.5.0.7", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.6/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.6/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.6/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 2c34154915a242694ffca33f7684c1e349044f71 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 22 Aug 2025 18:08:53 +0200 Subject: [PATCH 352/401] Update API. --- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Penumbra.Api b/Penumbra.Api index c27a060..0a97029 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit c27a06004138f2ec80ccdb494bb6ddf6d39d2165 +Subproject commit 0a970295b2398683b1e49c46fd613541e2486210 diff --git a/Penumbra.GameData b/Penumbra.GameData index 2f5e901..15e7c8e 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 2f5e901314444238ab3aa6c5043368622bca815a +Subproject commit 15e7c8eb41867e6bbd3fe6a8885404df087bc7e7 From fb065549e9ea65ca817b41e7cfc0e6df0aec2180 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 22 Aug 2025 20:32:27 +0200 Subject: [PATCH 353/401] Add PCP Service. --- Glamourer/Configuration.cs | 59 ++++----- Glamourer/Glamourer.cs | 1 + Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 40 +++++- Glamourer/Interop/Penumbra/PenumbraService.cs | 63 +++++++--- Glamourer/Services/PcpService.cs | 119 ++++++++++++++++++ Glamourer/packages.lock.json | 20 +++ 6 files changed, 251 insertions(+), 51 deletions(-) create mode 100644 Glamourer/Services/PcpService.cs diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index f128bdd..d266a55 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -40,34 +40,37 @@ public class Configuration : IPluginConfiguration, ISavable [JsonIgnore] public readonly EphemeralConfig Ephemeral; - public bool UseRestrictedGearProtection { get; set; } = false; - public bool OpenFoldersByDefault { get; set; } = false; - public bool AutoRedrawEquipOnChanges { get; set; } = false; - public bool EnableAutoDesigns { get; set; } = true; - public bool HideApplyCheckmarks { get; set; } = false; - public bool SmallEquip { get; set; } = false; - public bool UnlockedItemMode { get; set; } = false; - public byte DisableFestivals { get; set; } = 1; - public bool EnableGameContextMenu { get; set; } = true; - public bool HideWindowInCutscene { get; set; } = false; - public bool ShowAutomationSetEditing { get; set; } = true; - public bool ShowAllAutomatedApplicationRules { get; set; } = true; - public bool ShowUnlockedItemWarnings { get; set; } = true; - public bool RevertManualChangesOnZoneChange { get; set; } = false; - public bool ShowQuickBarInTabs { get; set; } = true; - public bool OpenWindowAtStart { get; set; } = false; - public bool ShowWindowWhenUiHidden { get; set; } = false; - public bool KeepAdvancedDyesAttached { get; set; } = true; - public bool ShowPalettePlusImport { get; set; } = true; - public bool UseFloatForColors { get; set; } = true; - public bool UseRgbForColors { get; set; } = true; - public bool ShowColorConfig { get; set; } = true; - public bool ChangeEntireItem { get; set; } = false; - public bool AlwaysApplyAssociatedMods { get; set; } = false; - public bool UseTemporarySettings { get; set; } = true; - public bool AllowDoubleClickToApply { get; set; } = false; - public bool RespectManualOnAutomationUpdate { get; set; } = false; - public bool PreventRandomRepeats { get; set; } = false; + public bool AttachToPcp { get; set; } = true; + public bool UseRestrictedGearProtection { get; set; } = false; + public bool OpenFoldersByDefault { get; set; } = false; + public bool AutoRedrawEquipOnChanges { get; set; } = false; + public bool EnableAutoDesigns { get; set; } = true; + public bool HideApplyCheckmarks { get; set; } = false; + public bool SmallEquip { get; set; } = false; + public bool UnlockedItemMode { get; set; } = false; + public byte DisableFestivals { get; set; } = 1; + public bool EnableGameContextMenu { get; set; } = true; + public bool HideWindowInCutscene { get; set; } = false; + public bool ShowAutomationSetEditing { get; set; } = true; + public bool ShowAllAutomatedApplicationRules { get; set; } = true; + public bool ShowUnlockedItemWarnings { get; set; } = true; + public bool RevertManualChangesOnZoneChange { get; set; } = false; + public bool ShowQuickBarInTabs { get; set; } = true; + public bool OpenWindowAtStart { get; set; } = false; + public bool ShowWindowWhenUiHidden { get; set; } = false; + public bool KeepAdvancedDyesAttached { get; set; } = true; + public bool ShowPalettePlusImport { get; set; } = true; + public bool UseFloatForColors { get; set; } = true; + public bool UseRgbForColors { get; set; } = true; + public bool ShowColorConfig { get; set; } = true; + public bool ChangeEntireItem { get; set; } = false; + public bool AlwaysApplyAssociatedMods { get; set; } = true; + public bool UseTemporarySettings { get; set; } = true; + public bool AllowDoubleClickToApply { get; set; } = false; + public bool RespectManualOnAutomationUpdate { get; set; } = false; + public bool PreventRandomRepeats { get; set; } = false; + public string PcpFolder { get; set; } = "PCP"; + public string PcpColor { get; set; } = ""; public DesignPanelFlag HideDesignPanel { get; set; } = 0; public DesignPanelFlag AutoExpandDesignPanel { get; set; } = 0; diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index f62085a..33c67d5 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -71,6 +71,7 @@ public class Glamourer : IDalamudPlugin sb.Append($"> **`Festival Easter-Eggs: `** {config.DisableFestivals}\n"); sb.Append($"> **`Apply Entire Weapon: `** {config.ChangeEntireItem}\n"); sb.Append($"> **`Apply Associated Mods:`** {config.AlwaysApplyAssociatedMods}\n"); + sb.Append($"> **`Attach to PCP: `** {config.AttachToPcp}\n"); sb.Append($"> **`Hidden Panels: `** {config.HideDesignPanel}\n"); sb.Append($"> **`Show QDB: `** {config.Ephemeral.ShowDesignQuickBar}\n"); sb.Append($"> **`QDB Hotkey: `** {config.ToggleQuickDesignBar}\n"); diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 1ccb079..0a84adc 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -1,4 +1,5 @@ -using Dalamud.Game.ClientState.Keys; +using Dalamud.Bindings.ImGui; +using Dalamud.Game.ClientState.Keys; using Dalamud.Interface; using Dalamud.Interface.Components; using Dalamud.Interface.Utility; @@ -8,7 +9,8 @@ using Glamourer.Designs; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; using Glamourer.Interop.PalettePlus; -using Dalamud.Bindings.ImGui; +using Glamourer.Services; +using OtterGui; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Widgets; @@ -27,7 +29,8 @@ public class SettingsTab( CollectionOverrideDrawer overrides, CodeDrawer codeDrawer, Glamourer glamourer, - AutoDesignApplier autoDesignApplier) + AutoDesignApplier autoDesignApplier, + PcpService pcpService) : ITab { private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray(); @@ -89,6 +92,15 @@ public class SettingsTab( Checkbox("Auto-Reload Gear"u8, "Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection."u8, config.AutoRedrawEquipOnChanges, v => config.AutoRedrawEquipOnChanges = v); + Checkbox("Attach to PCP-Handling"u8, + "Add the actor's glamourer state when a PCP is created by Penumbra, and create a design and apply it if possible when a PCP is installed by Penumbra."u8, + config.AttachToPcp, pcpService.Set); + var active = config.DeleteDesignModifier.IsActive(); + ImGui.SameLine(); + if (ImUtf8.ButtonEx("Delete all PCP Designs"u8, "Deletes all designs tagged with 'PCP' from the design list."u8, disabled: !active)) + pcpService.CleanPcpDesigns(); + if (!active) + ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"\nHold {config.DeleteDesignModifier} while clicking."); Checkbox("Revert Manual Changes on Zone Change"u8, "Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone."u8, config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v); @@ -124,6 +136,28 @@ public class SettingsTab( Checkbox("Reset Temporary Settings"u8, "Newly created designs will be configured to clear all advanced settings applied by Glamourer to the collection by default."u8, config.DefaultDesignSettings.ResetTemporarySettings, v => config.DefaultDesignSettings.ResetTemporarySettings = v); + + var tmp = config.PcpFolder; + ImGui.SetNextItemWidth(0.4f * ImGui.GetContentRegionAvail().X); + if (ImUtf8.InputText("##pcpFolder"u8, ref tmp)) + config.PcpFolder = tmp; + + if (ImGui.IsItemDeactivatedAfterEdit()) + config.Save(); + + ImGuiUtil.LabeledHelpMarker("Default PCP Organizational Folder", + "The folder any designs created due to penumbra character packs are moved to on creation.\nLeave blank to import into Root."); + + tmp = config.PcpColor; + ImGui.SetNextItemWidth(0.4f * ImGui.GetContentRegionAvail().X); + if (ImUtf8.InputText("##pcpColor"u8, ref tmp)) + config.PcpColor = tmp; + + if (ImGui.IsItemDeactivatedAfterEdit()) + config.Save(); + + ImGuiUtil.LabeledHelpMarker("Default PCP Design Color", + "The name of the color group any designs created due to penumbra character packs are assigned.\nLeave blank for no specific color assignment."); } private void DrawInterfaceSettings() diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index d66ddc4..123e989 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin; using Glamourer.Events; using Glamourer.State; +using Newtonsoft.Json.Linq; using OtterGui.Classes; using Penumbra.Api.Enums; using Penumbra.Api.Helpers; @@ -49,6 +50,8 @@ public class PenumbraService : IDisposable private readonly EventSubscriber _creatingCharacterBase; private readonly EventSubscriber _createdCharacterBase; private readonly EventSubscriber _modSettingChanged; + private readonly EventSubscriber _pcpParsed; + private readonly EventSubscriber _pcpCreated; private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; @@ -101,6 +104,8 @@ public class PenumbraService : IDisposable _createdCharacterBase = global::Penumbra.Api.IpcSubscribers.CreatedCharacterBase.Subscriber(pi); _creatingCharacterBase = global::Penumbra.Api.IpcSubscribers.CreatingCharacterBase.Subscriber(pi); _modSettingChanged = global::Penumbra.Api.IpcSubscribers.ModSettingChanged.Subscriber(pi); + _pcpCreated = global::Penumbra.Api.IpcSubscribers.CreatingPcp.Subscriber(pi); + _pcpParsed = global::Penumbra.Api.IpcSubscribers.ParsingPcp.Subscriber(pi); Reattach(); } @@ -135,6 +140,18 @@ public class PenumbraService : IDisposable remove => _modSettingChanged.Event -= value; } + public event Action PcpCreated + { + add => _pcpCreated.Event += value; + remove => _pcpCreated.Event -= value; + } + + public event Action PcpParsed + { + add => _pcpParsed.Event += value; + remove => _pcpParsed.Event -= value; + } + public Dictionary GetCollections() => Available ? _collections!.Invoke() : []; @@ -514,28 +531,30 @@ public class PenumbraService : IDisposable _clickSubscriber.Enable(); _creatingCharacterBase.Enable(); _createdCharacterBase.Enable(); + _pcpCreated.Enable(); + _pcpParsed.Enable(); _modSettingChanged.Enable(); - _collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface); - _collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface); - _redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface); - _checkCutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndexFunc(_pluginInterface).Invoke(); - _getGameObject = new global::Penumbra.Api.IpcSubscribers.GetGameObjectFromDrawObjectFunc(_pluginInterface).Invoke(); - _objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface); - _getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface); - _currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface); - _getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface); - _inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface); - _setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface); - _setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface); - _setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface); - _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); - _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); - _getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface); - _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); - _setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface); - _removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface); + _collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface); + _collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface); + _redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface); + _checkCutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndexFunc(_pluginInterface).Invoke(); + _getGameObject = new global::Penumbra.Api.IpcSubscribers.GetGameObjectFromDrawObjectFunc(_pluginInterface).Invoke(); + _objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface); + _getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface); + _currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface); + _getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface); + _inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface); + _setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface); + _setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface); + _setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface); + _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); + _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); + _getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface); + _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); + _setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface); + _removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface); _removeTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer(_pluginInterface); - _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); + _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); _removeAllTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); @@ -566,6 +585,8 @@ public class PenumbraService : IDisposable _creatingCharacterBase.Disable(); _createdCharacterBase.Disable(); _modSettingChanged.Disable(); + _pcpCreated.Disable(); + _pcpParsed.Disable(); if (Available) { _collectionByIdentifier = null; @@ -612,5 +633,7 @@ public class PenumbraService : IDisposable _initializedEvent.Dispose(); _disposedEvent.Dispose(); _modSettingChanged.Dispose(); + _pcpCreated.Dispose(); + _pcpParsed.Dispose(); } } diff --git a/Glamourer/Services/PcpService.cs b/Glamourer/Services/PcpService.cs new file mode 100644 index 0000000..3894981 --- /dev/null +++ b/Glamourer/Services/PcpService.cs @@ -0,0 +1,119 @@ +using Glamourer.Designs; +using Glamourer.Interop.Penumbra; +using Glamourer.State; +using Newtonsoft.Json.Linq; +using OtterGui.Services; +using Penumbra.GameData.Actors; +using Penumbra.GameData.Interop; + +namespace Glamourer.Services; + +public class PcpService : IRequiredService +{ + private readonly Configuration _config; + private readonly PenumbraService _penumbra; + private readonly ActorObjectManager _objects; + private readonly StateManager _state; + private readonly DesignConverter _designConverter; + private readonly DesignManager _designManager; + + public PcpService(Configuration config, PenumbraService penumbra, ActorObjectManager objects, StateManager state, + DesignConverter designConverter, DesignManager designManager) + { + _config = config; + _penumbra = penumbra; + _objects = objects; + _state = state; + _designConverter = designConverter; + _designManager = designManager; + + _config.AttachToPcp = !_config.AttachToPcp; + Set(!_config.AttachToPcp); + } + + public void CleanPcpDesigns() + { + var designs = _designManager.Designs.Where(d => d.Tags.Contains("PCP")).ToList(); + Glamourer.Log.Information($"[PCPService] Deleting {designs.Count} designs containing the tag PCP."); + foreach (var design in designs) + _designManager.Delete(design); + } + + public void Set(bool value) + { + if (value == _config.AttachToPcp) + return; + + _config.AttachToPcp = value; + _config.Save(); + if (value) + { + Glamourer.Log.Information("[PCPService] Attached to PCP handling."); + _penumbra.PcpCreated += OnPcpCreation; + _penumbra.PcpParsed += OnPcpParse; + } + else + { + Glamourer.Log.Information("[PCPService] Detached from PCP handling."); + _penumbra.PcpCreated -= OnPcpCreation; + _penumbra.PcpParsed -= OnPcpParse; + } + } + + private void OnPcpParse(JObject jObj, string modDirectory, Guid collection) + { + Glamourer.Log.Debug("[PCPService] Parsing PCP file."); + if (jObj["Glamourer"] is not JObject glamourer) + return; + + if (glamourer["Version"]!.ToObject() is not 1) + return; + + if (_designConverter.FromJObject(glamourer["Design"] as JObject, true, true) is not { } designBase) + return; + + var actorIdentifier = _objects.Actors.FromJson(jObj["Actor"] as JObject); + if (!actorIdentifier.IsValid) + return; + + var time = new DateTimeOffset(jObj["Time"]?.ToObject() ?? DateTime.UtcNow); + var design = _designManager.CreateClone(designBase, + $"{_config.PcpFolder}/{actorIdentifier} - {jObj["Note"]?.ToObject() ?? string.Empty}", true); + _designManager.AddTag(design, "PCP"); + _designManager.SetWriteProtection(design, true); + _designManager.AddMod(design, new Mod(modDirectory, modDirectory), new ModSettings([], 0, true, false, false)); + _designManager.ChangeDescription(design, $"PCP design created for {actorIdentifier} on {time}."); + _designManager.ChangeResetAdvancedDyes(design, true); + _designManager.SetQuickDesign(design, false); + _designManager.ChangeColor(design, _config.PcpColor); + + Glamourer.Log.Debug("[PCPService] Created PCP design."); + if (_state.GetOrCreate(actorIdentifier, _objects.TryGetValue(actorIdentifier, out var data) ? data.Objects[0] : Actor.Null, + out var state)) + { + _state.ApplyDesign(state!, design, ApplySettings.Manual); + Glamourer.Log.Debug($"[PCPService] Applied PCP design to {actorIdentifier.Incognito(null)}"); + } + } + + private void OnPcpCreation(JObject jObj, ushort index) + { + Glamourer.Log.Debug("[PCPService] Adding Glamourer data to PCP file."); + var actorIdentifier = _objects.Actors.FromJson(jObj["Actor"] as JObject); + if (!actorIdentifier.IsValid) + return; + + if (!_state.GetOrCreate(actorIdentifier, _objects.Objects[(int)index], out var state)) + { + Glamourer.Log.Debug($"[PCPService] Could not get or create state for actor {index}."); + return; + } + + var design = _designConverter.Convert(state, ApplicationRules.All); + jObj["Glamourer"] = new JObject() + { + ["Version"] = 1, + ["Design"] = design.JsonSerialize(), + }; + } +} diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json index f66e6e4..9e36276 100644 --- a/Glamourer/packages.lock.json +++ b/Glamourer/packages.lock.json @@ -24,6 +24,19 @@ "Vortice.DXGI": "3.4.2-beta" } }, + "FlatSharp.Compiler": { + "type": "Transitive", + "resolved": "7.9.0", + "contentHash": "MU6808xvdbWJ3Ev+5PKalqQuzvVbn1DzzQH8txRDHGFUNDvHjd+ejqpvnYc9BSJ8Qp8VjkkpJD8OzRYilbPp3A==" + }, + "FlatSharp.Runtime": { + "type": "Transitive", + "resolved": "7.9.0", + "contentHash": "Bm8+WqzEsWNpxqrD5x4x+zQ8dyINlToCreM5FI2oNSfUVc9U9ZB+qztX/jd8rlJb3r0vBSlPwVLpw0xBtPa3Vw==", + "dependencies": { + "System.Memory": "4.5.5" + } + }, "JetBrains.Annotations": { "type": "Transitive", "resolved": "2024.3.0", @@ -55,6 +68,11 @@ "SharpGen.Runtime": "2.1.2-beta" } }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==" + }, "Vortice.DirectX": { "type": "Transitive", "resolved": "3.4.2-beta", @@ -95,6 +113,8 @@ "penumbra.gamedata": { "type": "Project", "dependencies": { + "FlatSharp.Compiler": "[7.9.0, )", + "FlatSharp.Runtime": "[7.9.0, )", "OtterGui": "[1.0.0, )", "Penumbra.Api": "[5.10.0, )", "Penumbra.String": "[1.0.6, )" From 4d4e4669dd30ca0e5029972bb70f7da6a13d4f6a Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 22 Aug 2025 18:34:49 +0000 Subject: [PATCH 354/401] [CI] Updating repo.json for testing_1.5.0.8 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 849d380..a40f1ff 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.5.0.7", - "TestingAssemblyVersion": "1.5.0.7", + "TestingAssemblyVersion": "1.5.0.8", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.5.0.8/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 487d3b9399f3065239bf89ffaaca396c418d87d2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 24 Aug 2025 15:49:24 +0200 Subject: [PATCH 355/401] Update PCP Service. --- Glamourer/Interop/Penumbra/PenumbraService.cs | 4 ++-- Glamourer/Services/PcpService.cs | 4 ++-- Penumbra.Api | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 123e989..4d70a3f 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -51,7 +51,7 @@ public class PenumbraService : IDisposable private readonly EventSubscriber _createdCharacterBase; private readonly EventSubscriber _modSettingChanged; private readonly EventSubscriber _pcpParsed; - private readonly EventSubscriber _pcpCreated; + private readonly EventSubscriber _pcpCreated; private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; @@ -140,7 +140,7 @@ public class PenumbraService : IDisposable remove => _modSettingChanged.Event -= value; } - public event Action PcpCreated + public event Action PcpCreated { add => _pcpCreated.Event += value; remove => _pcpCreated.Event -= value; diff --git a/Glamourer/Services/PcpService.cs b/Glamourer/Services/PcpService.cs index 3894981..3363172 100644 --- a/Glamourer/Services/PcpService.cs +++ b/Glamourer/Services/PcpService.cs @@ -96,7 +96,7 @@ public class PcpService : IRequiredService } } - private void OnPcpCreation(JObject jObj, ushort index) + private void OnPcpCreation(JObject jObj, ushort index, string path) { Glamourer.Log.Debug("[PCPService] Adding Glamourer data to PCP file."); var actorIdentifier = _objects.Actors.FromJson(jObj["Actor"] as JObject); @@ -110,7 +110,7 @@ public class PcpService : IRequiredService } var design = _designConverter.Convert(state, ApplicationRules.All); - jObj["Glamourer"] = new JObject() + jObj["Glamourer"] = new JObject { ["Version"] = 1, ["Design"] = design.JsonSerialize(), diff --git a/Penumbra.Api b/Penumbra.Api index 0a97029..297941b 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 0a970295b2398683b1e49c46fd613541e2486210 +Subproject commit 297941bc22300f4a8368f4d0177f62943eb69727 From 3eabe591dfb3e46b02e699f6e6381936961f3fb3 Mon Sep 17 00:00:00 2001 From: Actions User Date: Sun, 24 Aug 2025 13:59:02 +0000 Subject: [PATCH 356/401] [CI] Updating repo.json for testing_1.5.0.9 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index a40f1ff..02c85f5 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.5.0.7", - "TestingAssemblyVersion": "1.5.0.8", + "TestingAssemblyVersion": "1.5.0.9", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.5.0.8/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.5.0.9/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 389a8781d6007865891c548db2184aa157ee2b18 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 25 Aug 2025 10:39:32 +0200 Subject: [PATCH 357/401] Update library. --- Penumbra.Api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.Api b/Penumbra.Api index 297941b..af41b17 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 297941bc22300f4a8368f4d0177f62943eb69727 +Subproject commit af41b1787acef9df7dc83619fe81e63a36443ee5 From 835ba23935e9a785076bc98a8514776cc8eada5a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 25 Aug 2025 10:43:14 +0200 Subject: [PATCH 358/401] 1.5.1.0 --- Glamourer/Gui/GlamourerChangelog.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Glamourer/Gui/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 31d1ce3..686d4a1 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -44,6 +44,7 @@ public class GlamourerChangelog Add1_3_8_0(Changelog); Add1_4_0_0(Changelog); Add1_5_0_0(Changelog); + Add1_5_1_0(Changelog); } private (int, ChangeLogDisplayType) ConfigData() @@ -64,6 +65,16 @@ public class GlamourerChangelog } } + private static void Add1_5_1_0(Changelog log) + => log.NextVersion("Version 1.5.1.0") + .RegisterHighlight("Added support for Penumbras PCP functionality to add the current state of the character as a design.") + .RegisterEntry("On import, a design for the PCP is created and, if possible, applied to the character.", 1) + .RegisterEntry("No automation is assigned.", 1) + .RegisterEntry("Finer control about this can be found in the settings.", 1) + .RegisterEntry("Fixed an issue with static visors not toggling through Glamourer (1.5.0.7).") + .RegisterEntry("The advanced dye slot combo now contains glasses (1.5.0.7).") + .RegisterEntry("Several fixes for patch-related issues (1.5.0.1 - 1.5.0.6"); + private static void Add1_5_0_0(Changelog log) => log.NextVersion("Version 1.5.0.0") .RegisterImportant("Updated for game version 7.30 and Dalamud API13, which uses a new GUI backend. Some things may not work as expected. Please let me know any issues you encounter.") From 654787fa0d536ec3d69114bd697cb6fe496ce060 Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 25 Aug 2025 08:45:28 +0000 Subject: [PATCH 359/401] [CI] Updating repo.json for 1.5.1.0 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 02c85f5..ab6a415 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.0.7", - "TestingAssemblyVersion": "1.5.0.9", + "AssemblyVersion": "1.5.1.0", + "TestingAssemblyVersion": "1.5.1.0", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.5.0.9/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.0/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.0/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.0/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 6e62905fa70ef5851fb01859b887310c318ef269 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 26 Aug 2025 11:54:00 +0200 Subject: [PATCH 360/401] Fix staging incompatibility with CS. --- Glamourer/Interop/Material/MaterialService.cs | 4 ++-- Glamourer/Interop/Material/PrepareColorSet.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index a5f2b36..e232798 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -69,9 +69,9 @@ public static unsafe class MaterialService return null; var material = (MaterialResourceHandle*) model.AsCharacterBase->MaterialsSpan[index].Value; - if (material == null || material->ColorTable == null) + if (material == null || material->DataSet == null) return null; - return (ColorTable.Table*)material->ColorTable; + return (ColorTable.Table*)material->DataSet; } } diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index f52bb68..21a731b 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -69,13 +69,13 @@ public sealed unsafe class PrepareColorSet public static bool TryGetColorTable(MaterialResourceHandle* material, StainIds stainIds, out ColorTable.Table table) { - if (material->ColorTable == null) + if (material->DataSet == null) { table = default; return false; } - var newTable = *(ColorTable.Table*)material->ColorTable; + var newTable = *(ColorTable.Table*)material->DataSet; if (GetDyeTable(material, out var dyeTable)) { if (stainIds.Stain1.Id != 0) From 889f01a7243b0c6af7b3483947ea2cea8b01add4 Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 26 Aug 2025 09:58:08 +0000 Subject: [PATCH 361/401] [CI] Updating repo.json for 1.5.1.1 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index ab6a415..78132bf 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.0", - "TestingAssemblyVersion": "1.5.1.0", + "AssemblyVersion": "1.5.1.1", + "TestingAssemblyVersion": "1.5.1.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.0/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.0/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.0/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.1/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.1/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.1/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 8e1745d67aa87a80a5491be8477a3ea26308d985 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 28 Aug 2025 18:47:51 +0200 Subject: [PATCH 362/401] Once more with feeling --- Glamourer/Interop/Material/MaterialService.cs | 3 +-- Glamourer/Interop/Material/PrepareColorSet.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index e232798..4893e14 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -1,6 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; -using Lumina.Data.Files; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Interop; using Texture = FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.Texture; @@ -69,7 +68,7 @@ public static unsafe class MaterialService return null; var material = (MaterialResourceHandle*) model.AsCharacterBase->MaterialsSpan[index].Value; - if (material == null || material->DataSet == null) + if (material == null || material->DataSet == null || material->DataSetSize < sizeof(ColorTable.Table) || !material->HasColorTable) return null; return (ColorTable.Table*)material->DataSet; diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 21a731b..821a152 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -69,7 +69,7 @@ public sealed unsafe class PrepareColorSet public static bool TryGetColorTable(MaterialResourceHandle* material, StainIds stainIds, out ColorTable.Table table) { - if (material->DataSet == null) + if (material->DataSet == null || material->DataSetSize < sizeof(ColorTable.Table) || !material->HasColorTable) { table = default; return false; From 414bd8bee7d1d738290014d726b730baae0f8385 Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 28 Aug 2025 16:52:43 +0000 Subject: [PATCH 363/401] [CI] Updating repo.json for 1.5.1.2 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 78132bf..9f7e922 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.1", - "TestingAssemblyVersion": "1.5.1.1", + "AssemblyVersion": "1.5.1.2", + "TestingAssemblyVersion": "1.5.1.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.1/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.1/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.1/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.2/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.2/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.2/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From c420b1f18062ce5d0c41c06126b107a576dc94ab Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Sun, 31 Aug 2025 23:04:41 +0100 Subject: [PATCH 364/401] Update .gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 137c8ba..26b4730 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,5 +16,5 @@ branch = main [submodule "Glamourer.Api"] path = Glamourer.Api - url = https://github.com/Ottermandias/Glamourer.Api.git + url = https://github.com/Bracket416/Glamourer.Api branch = main From da1db70635787c00818c3468094cb02ed9f52a82 Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Sun, 31 Aug 2025 23:06:23 +0100 Subject: [PATCH 365/401] Update IpcProviders.cs --- Glamourer/Api/IpcProviders.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 2701f18..1dc1cc8 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -53,6 +53,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.RevertState.Provider(pi, api.State), IpcSubscribers.RevertStateName.Provider(pi, api.State), IpcSubscribers.UnlockState.Provider(pi, api.State), + IpcSubscribers.IsUnlocked.Provider(pi, api.State), IpcSubscribers.UnlockStateName.Provider(pi, api.State), IpcSubscribers.UnlockAll.Provider(pi, api.State), IpcSubscribers.RevertToAutomation.Provider(pi, api.State), @@ -75,3 +76,4 @@ public sealed class IpcProviders : IDisposable, IApiService _disposedProvider.Dispose(); } } + From c31f6c19a604e40f178ba20985333982f3637faa Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Sun, 31 Aug 2025 23:06:54 +0100 Subject: [PATCH 366/401] Update StateApi.cs --- Glamourer/Api/StateApi.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 68c593b..f7e2de1 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -180,6 +180,16 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } + public (GlamourerApiEc, bool?) IsUnlocked(int objectIndex, uint key) + { + var args = ApiHelpers.Args("Index", objectIndex, "Key", key); + if (_helpers.FindExistingState(objectIndex, out var state) != GlamourerApiEc.Success) + return (ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args), null); + if (state == null) + return (ApiHelpers.Return(GlamourerApiEc.InvalidState, args), null); // Possibly, the error type could be changed. I just looked at what was available. + return (ApiHelpers.Return(GlamourerApiEc.Success, args), state.CanUnlock(key)); + } + public GlamourerApiEc UnlockStateName(string playerName, uint key) { var args = ApiHelpers.Args("Name", playerName, "Key", key); From 6a34d41f6ad37a33c10340be6ca92d5ed894d4fb Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:27:11 +0100 Subject: [PATCH 367/401] Update .gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 26b4730..49b25bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,5 +16,5 @@ branch = main [submodule "Glamourer.Api"] path = Glamourer.Api - url = https://github.com/Bracket416/Glamourer.Api + url = https://github.com/Ottermandias/Glamourer.Api branch = main From c62c3c4eea6d1ddee5f908ef0444ceffddfbafaf Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:27:35 +0100 Subject: [PATCH 368/401] Update .gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 49b25bb..137c8ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,5 +16,5 @@ branch = main [submodule "Glamourer.Api"] path = Glamourer.Api - url = https://github.com/Ottermandias/Glamourer.Api + url = https://github.com/Ottermandias/Glamourer.Api.git branch = main From 0442fb7b607287abc39fbf5510dcead05e85aa29 Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Tue, 2 Sep 2025 02:02:08 +0100 Subject: [PATCH 369/401] Update IpcProviders.cs --- Glamourer/Api/IpcProviders.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 1dc1cc8..9be723c 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -53,7 +53,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.RevertState.Provider(pi, api.State), IpcSubscribers.RevertStateName.Provider(pi, api.State), IpcSubscribers.UnlockState.Provider(pi, api.State), - IpcSubscribers.IsUnlocked.Provider(pi, api.State), + IpcSubscribers.CanUnlock.Provider(pi, api.State), IpcSubscribers.UnlockStateName.Provider(pi, api.State), IpcSubscribers.UnlockAll.Provider(pi, api.State), IpcSubscribers.RevertToAutomation.Provider(pi, api.State), @@ -77,3 +77,4 @@ public sealed class IpcProviders : IDisposable, IApiService } } + From 8f362c5121f645cd5120e8e3c5a40787b99730ed Mon Sep 17 00:00:00 2001 From: Bracket <31086695+Bracket416@users.noreply.github.com> Date: Tue, 2 Sep 2025 02:02:52 +0100 Subject: [PATCH 370/401] Update StateApi.cs --- Glamourer/Api/StateApi.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index f7e2de1..97d7fcc 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -180,14 +180,18 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } - public (GlamourerApiEc, bool?) IsUnlocked(int objectIndex, uint key) + public GlamourerApiEc CanUnlock(int objectIndex, uint key, out bool isLocked, out bool canUnlock) { var args = ApiHelpers.Args("Index", objectIndex, "Key", key); + isLocked = false; // These seem like reasonable defaults. + canUnlock = false; if (_helpers.FindExistingState(objectIndex, out var state) != GlamourerApiEc.Success) - return (ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args), null); + return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); if (state == null) - return (ApiHelpers.Return(GlamourerApiEc.InvalidState, args), null); // Possibly, the error type could be changed. I just looked at what was available. - return (ApiHelpers.Return(GlamourerApiEc.Success, args), state.CanUnlock(key)); + return ApiHelpers.Return(GlamourerApiEc.InvalidState, args); // Possibly, the error type could be changed. I just looked at what was available. + isLocked = state.IsLocked; + canUnlock = state.CanUnlock(key); + return ApiHelpers.Return(GlamourerApiEc.Success, args); } public GlamourerApiEc UnlockStateName(string playerName, uint key) From 0a9693daea99f79c44b2a69e1bfb006573a721a0 Mon Sep 17 00:00:00 2001 From: Ottermandias <70807659+Ottermandias@users.noreply.github.com> Date: Mon, 15 Sep 2025 20:29:13 +0200 Subject: [PATCH 371/401] Update CodeService.cs --- Glamourer/Services/CodeService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index af2e88b..4a82f0e 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -50,7 +50,8 @@ public class CodeService | CodeFlag.OopsMiqote | CodeFlag.OopsRoegadyn | CodeFlag.OopsAuRa - | CodeFlag.OopsHrothgar; + | CodeFlag.OopsHrothgar + | CodeFlag.OopsViera; public const CodeFlag FullCodes = CodeFlag.Face | CodeFlag.Manderville | CodeFlag.Smiles; @@ -250,3 +251,4 @@ public class CodeService _ => (false, 0, string.Empty, string.Empty, string.Empty), }; } + From 20914bc064ba9f1e90ccbec2c1525c6672af6c15 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 26 Sep 2025 19:11:07 -0700 Subject: [PATCH 372/401] Add ReapplyState & ReapplyStateName with Helpers. --- Glamourer/Api/StateApi.cs | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 68c593b..73e9540 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -123,6 +123,48 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } + public GlamourerApiEc ReapplyState(int objectIndex, uint key, ApplyFlag flags) + { + var args = ApiHelpers.Args("Index", objectIndex, "Key", key, "Flags", flags); + if (_helpers.FindExistingState(objectIndex, out var state) != GlamourerApiEc.Success) + return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); + + if (state == null) + return ApiHelpers.Return(GlamourerApiEc.NothingDone, args); + + if (!state.CanUnlock(key)) + return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); + + Reapply(_objects.Objects[objectIndex], state, key, flags); + return ApiHelpers.Return(GlamourerApiEc.Success, args); + } + + public GlamourerApiEc ReapplyStateName(string playerName, uint key, ApplyFlag flags) + { + var args = ApiHelpers.Args("Name", playerName, "Key", key, "Flags", flags); + var states = _helpers.FindExistingStates(playerName); + + var any = false; + var anyReapplied = false; + foreach (var state in states) + { + any = true; + if (!state.CanUnlock(key)) + continue; + + anyReapplied = true; + anyReapplied |= Reapply(state, key, flags) is GlamourerApiEc.Success; + } + + if (any) + ApiHelpers.Return(GlamourerApiEc.NothingDone, args); + + if (!anyReapplied) + return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args); + + return ApiHelpers.Return(GlamourerApiEc.Success, args); + } + public GlamourerApiEc RevertState(int objectIndex, uint key, ApplyFlag flags) { var args = ApiHelpers.Args("Index", objectIndex, "Key", key, "Flags", flags); @@ -265,6 +307,24 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable ApiHelpers.Lock(state, key, flags); } + private GlamourerApiEc Reapply(ActorState state, uint key, ApplyFlag flags) + { + if (!_objects.TryGetValue(state.Identifier, out var actors) || !actors.Valid) + return GlamourerApiEc.ActorNotFound; + + foreach (var actor in actors.Objects) + Reapply(actor, state, key, flags); + + return GlamourerApiEc.Success; + } + + private void Reapply(Actor actor, ActorState state, uint key, ApplyFlag flags) + { + var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; + _stateManager.ReapplyState(actor, state, false, source, true); + ApiHelpers.Lock(state, key, flags); + } + private void Revert(ActorState state, uint key, ApplyFlag flags) { var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; From 44345b942910b54c62df0a6702a703400c2060bf Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 26 Sep 2025 19:11:39 -0700 Subject: [PATCH 373/401] Init providers from API --- Glamourer/Api/IpcProviders.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 2701f18..6d4b5eb 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -50,6 +50,8 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.GetStateBase64Name.Provider(pi, api.State), IpcSubscribers.ApplyState.Provider(pi, api.State), IpcSubscribers.ApplyStateName.Provider(pi, api.State), + IpcSubscribers.ReapplyState.Provider(pi, api.State), + IpcSubscribers.ReapplyStateName.Provider(pi, api.State), IpcSubscribers.RevertState.Provider(pi, api.State), IpcSubscribers.RevertStateName.Provider(pi, api.State), IpcSubscribers.UnlockState.Provider(pi, api.State), From d6c36ca4f7ada7b801100f1477115f555f46cb3a Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Fri, 26 Sep 2025 19:12:02 -0700 Subject: [PATCH 374/401] Add IPC Calls to IPC Tester. --- Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index e97d337..232c48e 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -138,6 +138,14 @@ public class StateIpcTester : IUiService, IDisposable if (ImUtf8.Button("Apply Base64##Name"u8)) _lastError = new ApplyStateName(_pluginInterface).Invoke(_base64State, _gameObjectName, _key, _flags); + IpcTesterHelpers.DrawIntro(ReapplyState.Label); + if (ImUtf8.Button("Reapply##Idx"u8)) + _lastError = new ReapplyState(_pluginInterface).Invoke(_gameObjectIndex, _key, _flags); + + IpcTesterHelpers.DrawIntro(ReapplyStateName.Label); + if (ImUtf8.Button("Reapply##Name"u8)) + _lastError = new ReapplyStateName(_pluginInterface).Invoke(_gameObjectName, _key, _flags); + IpcTesterHelpers.DrawIntro(RevertState.Label); if (ImUtf8.Button("Revert##Idx"u8)) _lastError = new RevertState(_pluginInterface).Invoke(_gameObjectIndex, _key, _flags); From c3469a1687285f5278182600877201b76b9b3d97 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 28 Sep 2025 23:55:44 +0200 Subject: [PATCH 375/401] Fix facewear advanced dyes, fix backup service not running in task, update libraries. --- Glamourer.Api | 2 +- Glamourer/Designs/DesignManager.cs | 1 - Glamourer/Glamourer.csproj | 2 +- .../Gui/Tabs/DesignTab/MultiDesignPanel.cs | 1 - Glamourer/Interop/Material/MaterialManager.cs | 23 ++++++++++++++----- Glamourer/Services/BackupService.cs | 10 ++++++-- Glamourer/packages.lock.json | 6 ++--- OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- 11 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 54c1944..7e8505c 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 54c1944dc7db704733b4788520e494761bb0b58e +Subproject commit 7e8505cd6f8dbc5bcf41b72e16785d62b4d218f3 diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 3ddfefd..e3648a4 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -8,7 +8,6 @@ using Glamourer.Interop.Penumbra; using Glamourer.Services; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using OtterGui.Extensions; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 86ae713..d7e62a9 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -1,4 +1,4 @@ - + Glamourer Glamourer diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 1cdb171..4c7c103 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -3,7 +3,6 @@ using Dalamud.Interface.Utility; using Glamourer.Designs; using Glamourer.Interop.Material; using Dalamud.Bindings.ImGui; -using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; using static Glamourer.Gui.Tabs.HeaderDrawer; diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 5b731b0..43e500b 100644 --- a/Glamourer/Interop/Material/MaterialManager.cs +++ b/Glamourer/Interop/Material/MaterialManager.cs @@ -62,7 +62,7 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable var drawData = type switch { - MaterialValueIndex.DrawObjectType.Human => GetTempSlot((Human*)characterBase, slotId), + MaterialValueIndex.DrawObjectType.Human => GetTempSlot((Human*)characterBase, (HumanSlot)slotId), _ => GetTempSlot((Weapon*)characterBase), }; var mode = PrepareColorSet.GetMode(material); @@ -192,13 +192,24 @@ public sealed unsafe class MaterialManager : IRequiredService, IDisposable } /// We need to get the temporary set, variant and stain that is currently being set if it is available. - private static CharacterWeapon GetTempSlot(Human* human, byte slotId) + private static CharacterWeapon GetTempSlot(Human* human, HumanSlot slotId) { - if (human->ChangedEquipData == null) - return ((Model)human).GetArmor(((uint)slotId).ToEquipSlot()).ToWeapon(0); + if (human->ChangedEquipData is null) + return slotId.ToSpecificEnum() switch + { + EquipSlot slot => ((Model)human).GetArmor(slot).ToWeapon(0), + BonusItemFlag bonus => ((Model)human).GetBonus(bonus).ToWeapon(0), + _ => default, + }; - var item = (ChangedEquipData*)human->ChangedEquipData + slotId; - return ((CharacterArmor*)item)->ToWeapon(0); + if (!slotId.ToSlotIndex(out var index)) + return default; + + var item = (ChangedEquipData*)human->ChangedEquipData + index; + if (index < 10) + return ((CharacterArmor*)item)->ToWeapon(0); + + return new CharacterWeapon(item->BonusModel, 0, item->BonusVariant, StainIds.None); } /// diff --git a/Glamourer/Services/BackupService.cs b/Glamourer/Services/BackupService.cs index 3abf13a..511cca6 100644 --- a/Glamourer/Services/BackupService.cs +++ b/Glamourer/Services/BackupService.cs @@ -1,9 +1,10 @@ using OtterGui.Classes; using OtterGui.Log; +using OtterGui.Services; namespace Glamourer.Services; -public class BackupService +public class BackupService : IAsyncService { private readonly Logger _logger; private readonly DirectoryInfo _configDirectory; @@ -14,7 +15,7 @@ public class BackupService _logger = logger; _fileNames = GlamourerFiles(fileNames); _configDirectory = new DirectoryInfo(fileNames.ConfigDirectory); - Backup.CreateAutomaticBackup(logger, _configDirectory, _fileNames); + Awaiter = Task.Run(() => Backup.CreateAutomaticBackup(logger, new DirectoryInfo(fileNames.ConfigDirectory), _fileNames)); } /// Create a permanent backup with a given name for migrations. @@ -40,4 +41,9 @@ public class BackupService return list; } + + public Task Awaiter { get; } + + public bool Finished + => Awaiter.IsCompletedSuccessfully; } diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json index 9e36276..8ac1fe4 100644 --- a/Glamourer/packages.lock.json +++ b/Glamourer/packages.lock.json @@ -4,9 +4,9 @@ "net9.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[13.0.0, )", - "resolved": "13.0.0", - "contentHash": "Mb3cUDSK/vDPQ8gQIeuCw03EMYrej1B4J44a1AvIJ9C759p9XeqdU9Hg4WgOmlnlPe0G7ILTD32PKSUpkQNa8w==" + "requested": "[13.1.0, )", + "resolved": "13.1.0", + "contentHash": "XdoNhJGyFby5M/sdcRhnc5xTop9PHy+H50PTWpzLhJugjB19EDBiHD/AsiDF66RETM+0qKUdJBZrNuebn7qswQ==" }, "DotNet.ReproducibleBuilds": { "type": "Direct", diff --git a/OtterGui b/OtterGui index 4a9b71a..f354444 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 4a9b71a93e76aa5eed818542288329e34ec0dd89 +Subproject commit f354444776591ae423e2d8374aae346308d81424 diff --git a/Penumbra.Api b/Penumbra.Api index af41b17..648b6fc 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit af41b1787acef9df7dc83619fe81e63a36443ee5 +Subproject commit 648b6fc2ce600a95ab2b2ced27e1639af2b04502 diff --git a/Penumbra.GameData b/Penumbra.GameData index 15e7c8e..a34f314 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 15e7c8eb41867e6bbd3fe6a8885404df087bc7e7 +Subproject commit a34f314cbc1053a09923a0d64aa3173044d32101 diff --git a/Penumbra.String b/Penumbra.String index 878acce..c8611a0 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 878acce46e286867d6ef1f8ecedb390f7bac34fd +Subproject commit c8611a0c546b6b2ec29214ab319fc2c38fe74793 From 48bef12555b5d1d0ca6d6013f9192de963d565f0 Mon Sep 17 00:00:00 2001 From: Cordelia Mist Date: Sun, 5 Oct 2025 10:31:41 -0700 Subject: [PATCH 376/401] Optional Addition: Include IPC to get the current state of Auto-Reload Gear, and an IPC Event call for when the option changes. - Should help clear up ambiguity with any external plugins intending to call ReapplyState on a mod-change to themselves, to know if Glamourer has it handled for them. --- Glamourer/Api/GlamourerApi.cs | 5 +++- Glamourer/Api/IpcProviders.cs | 2 ++ Glamourer/Api/StateApi.cs | 13 +++++++-- Glamourer/Events/AutoRedrawChanged.cs | 16 +++++++++++ .../DebugTab/IpcTester/IpcTesterHelpers.cs | 3 --- .../Tabs/DebugTab/IpcTester/IpcTesterPanel.cs | 7 +++++ .../Tabs/DebugTab/IpcTester/StateIpcTester.cs | 27 ++++++++++++++----- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 8 +++++- 8 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 Glamourer/Events/AutoRedrawChanged.cs diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 14c0512..1942d65 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -3,7 +3,7 @@ using OtterGui.Services; namespace Glamourer.Api; -public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService +public class GlamourerApi(Configuration config, DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; public const int CurrentApiVersionMinor = 6; @@ -11,6 +11,9 @@ public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : public (int Major, int Minor) ApiVersion => (CurrentApiVersionMajor, CurrentApiVersionMinor); + public bool AutoReloadGearEnabled + => config.AutoRedrawEquipOnChanges; + public IGlamourerApiDesigns Designs => designs; diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 6d4b5eb..3b7fb08 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -22,6 +22,7 @@ public sealed class IpcProviders : IDisposable, IApiService new FuncProvider<(int Major, int Minor)>(pi, "Glamourer.ApiVersions", () => api.ApiVersion), // backward compatibility new FuncProvider(pi, "Glamourer.ApiVersion", () => api.ApiVersion.Major), // backward compatibility IpcSubscribers.ApiVersion.Provider(pi, api), + IpcSubscribers.AutoReloadGearEnabled.Provider(pi, api), IpcSubscribers.GetDesignList.Provider(pi, api.Designs), IpcSubscribers.GetDesignListExtended.Provider(pi, api.Designs), @@ -59,6 +60,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.UnlockAll.Provider(pi, api.State), IpcSubscribers.RevertToAutomation.Provider(pi, api.State), IpcSubscribers.RevertToAutomationName.Provider(pi, api.State), + IpcSubscribers.AutoReloadGearChanged.Provider(pi, api.State), IpcSubscribers.StateChanged.Provider(pi, api.State), IpcSubscribers.StateChangedWithType.Provider(pi, api.State), IpcSubscribers.StateFinalized.Provider(pi, api.State), diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 73e9540..4ed2d57 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -20,6 +20,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private readonly Configuration _config; private readonly AutoDesignApplier _autoDesigns; private readonly ActorObjectManager _objects; + private readonly AutoRedrawChanged _autoRedraw; private readonly StateChanged _stateChanged; private readonly StateFinalized _stateFinalized; private readonly GPoseService _gPose; @@ -30,6 +31,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable Configuration config, AutoDesignApplier autoDesigns, ActorObjectManager objects, + AutoRedrawChanged autoRedraw, StateChanged stateChanged, StateFinalized stateFinalized, GPoseService gPose) @@ -40,9 +42,11 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable _config = config; _autoDesigns = autoDesigns; _objects = objects; + _autoRedraw = autoRedraw; _stateChanged = stateChanged; _stateFinalized = stateFinalized; _gPose = gPose; + _autoRedraw.Subscribe(OnAutoRedrawChange, AutoRedrawChanged.Priority.StateApi); _stateChanged.Subscribe(OnStateChanged, Events.StateChanged.Priority.GlamourerIpc); _stateFinalized.Subscribe(OnStateFinalized, Events.StateFinalized.Priority.StateApi); _gPose.Subscribe(OnGPoseChange, GPoseService.Priority.StateApi); @@ -50,6 +54,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public void Dispose() { + _autoRedraw.Unsubscribe(OnAutoRedrawChange); _stateChanged.Unsubscribe(OnStateChanged); _stateFinalized.Unsubscribe(OnStateFinalized); _gPose.Unsubscribe(OnGPoseChange); @@ -293,6 +298,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } + public event Action? AutoReloadGearChanged; public event Action? StateChanged; public event Action? StateChangedWithType; public event Action? StateFinalized; @@ -385,8 +391,8 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable }; } - private void OnGPoseChange(bool gPose) - => GPoseChanged?.Invoke(gPose); + private void OnAutoRedrawChange(bool autoReload) + => AutoReloadGearChanged?.Invoke(autoReload); private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { @@ -407,4 +413,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable foreach (var actor in actors.Objects) StateFinalized.Invoke(actor.Address, type); } + + private void OnGPoseChange(bool gPose) + => GPoseChanged?.Invoke(gPose); } diff --git a/Glamourer/Events/AutoRedrawChanged.cs b/Glamourer/Events/AutoRedrawChanged.cs new file mode 100644 index 0000000..a8dd03a --- /dev/null +++ b/Glamourer/Events/AutoRedrawChanged.cs @@ -0,0 +1,16 @@ +using OtterGui.Classes; + +namespace Glamourer.Events; + +/// +/// Triggered when the auto-reload gear setting is changed in glamourer configuration. +/// +public sealed class AutoRedrawChanged() + : EventWrapper(nameof(AutoRedrawChanged)) +{ + public enum Priority + { + /// + StateApi = int.MinValue, + } +} \ No newline at end of file diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs index dbcb30c..61dad53 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs @@ -1,8 +1,5 @@ using Glamourer.Api.Enums; -using Glamourer.Designs; using Dalamud.Bindings.ImGui; -using OtterGui; -using static Penumbra.GameData.Files.ShpkFile; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs index f4e6925..22c7597 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs @@ -33,6 +33,11 @@ public class IpcTesterPanel( ImGui.SameLine(); ImGui.TextUnformatted($"({major}.{minor:D4})"); + ImGui.TextUnformatted(AutoReloadGearEnabled.Label); + var autoRedraw = new AutoReloadGearEnabled(pluginInterface).Invoke(); + ImGui.SameLine(); + ImGui.TextUnformatted(autoRedraw ? "Enabled" : "Disabled"); + designs.Draw(); items.Draw(); state.Draw(); @@ -49,6 +54,7 @@ public class IpcTesterPanel( return; Glamourer.Log.Debug("[IPCTester] Subscribed to IPC events for IPC tester."); + state.AutoRedrawChanged.Enable(); state.GPoseChanged.Enable(); state.StateChanged.Enable(); state.StateFinalized.Enable(); @@ -72,6 +78,7 @@ public class IpcTesterPanel( Glamourer.Log.Debug("[IPCTester] Unsubscribed from IPC events for IPC tester."); _subscribed = false; + state.AutoRedrawChanged.Disable(); state.GPoseChanged.Disable(); state.StateChanged.Disable(); state.StateFinalized.Disable(); diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index 232c48e..6fb9d68 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -1,11 +1,11 @@ -using Dalamud.Interface; +using Dalamud.Bindings.ImGui; +using Dalamud.Interface; using Dalamud.Interface.Utility; using Dalamud.Plugin; using Glamourer.Api.Enums; using Glamourer.Api.Helpers; using Glamourer.Api.IpcSubscribers; using Glamourer.Designs; -using Dalamud.Bindings.ImGui; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; @@ -31,6 +31,10 @@ public class StateIpcTester : IUiService, IDisposable private string _base64State = string.Empty; private string? _getStateString; + public readonly EventSubscriber AutoRedrawChanged; + private bool _lastAutoRedrawChangeValue; + private DateTime _lastAutoRedrawChangeTime; + public readonly EventSubscriber StateChanged; private nint _lastStateChangeActor; private ByteString _lastStateChangeName = ByteString.Empty; @@ -51,10 +55,12 @@ public class StateIpcTester : IUiService, IDisposable public StateIpcTester(IDalamudPluginInterface pluginInterface) { - _pluginInterface = pluginInterface; - StateChanged = StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged); - StateFinalized = Api.IpcSubscribers.StateFinalized.Subscriber(_pluginInterface, OnStateFinalized); - GPoseChanged = Api.IpcSubscribers.GPoseChanged.Subscriber(_pluginInterface, OnGPoseChange); + _pluginInterface = pluginInterface; + AutoRedrawChanged = AutoReloadGearChanged.Subscriber(_pluginInterface, OnAutoRedrawChanged); + StateChanged = StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged); + StateFinalized = Api.IpcSubscribers.StateFinalized.Subscriber(_pluginInterface, OnStateFinalized); + GPoseChanged = Api.IpcSubscribers.GPoseChanged.Subscriber(_pluginInterface, OnGPoseChange); + AutoRedrawChanged.Disable(); StateChanged.Disable(); StateFinalized.Disable(); GPoseChanged.Disable(); @@ -62,6 +68,7 @@ public class StateIpcTester : IUiService, IDisposable public void Dispose() { + AutoRedrawChanged.Dispose(); StateChanged.Dispose(); StateFinalized.Dispose(); GPoseChanged.Dispose(); @@ -83,6 +90,8 @@ public class StateIpcTester : IUiService, IDisposable IpcTesterHelpers.DrawIntro("Last Error"); ImGui.TextUnformatted(_lastError.ToString()); + IpcTesterHelpers.DrawIntro("Last Auto Redraw Change"); + ImGui.TextUnformatted($"{_lastAutoRedrawChangeValue} at {_lastAutoRedrawChangeTime.ToLocalTime().TimeOfDay}"); IpcTesterHelpers.DrawIntro("Last State Change"); PrintChangeName(); IpcTesterHelpers.DrawIntro("Last State Finalization"); @@ -233,6 +242,12 @@ public class StateIpcTester : IUiService, IDisposable ImUtf8.Text($"at {_lastStateFinalizeTime.ToLocalTime().TimeOfDay}"); } + private void OnAutoRedrawChanged(bool value) + { + _lastAutoRedrawChangeValue = value; + _lastAutoRedrawChangeTime = DateTime.UtcNow; + } + private void OnStateChanged(nint actor, StateChangeType type) { _lastStateChangeActor = actor; diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 0a84adc..82bdd54 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -6,6 +6,7 @@ using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; using Glamourer.Automation; using Glamourer.Designs; +using Glamourer.Events; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; using Glamourer.Interop.PalettePlus; @@ -30,6 +31,7 @@ public class SettingsTab( CodeDrawer codeDrawer, Glamourer glamourer, AutoDesignApplier autoDesignApplier, + AutoRedrawChanged autoRedraw, PcpService pcpService) : ITab { @@ -91,7 +93,11 @@ public class SettingsTab( config.DisableFestivals == 0, v => config.DisableFestivals = v ? (byte)0 : (byte)2); Checkbox("Auto-Reload Gear"u8, "Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection."u8, - config.AutoRedrawEquipOnChanges, v => config.AutoRedrawEquipOnChanges = v); + config.AutoRedrawEquipOnChanges, v => + { + config.AutoRedrawEquipOnChanges = v; + autoRedraw.Invoke(v); + }); Checkbox("Attach to PCP-Handling"u8, "Add the actor's glamourer state when a PCP is created by Penumbra, and create a design and apply it if possible when a PCP is installed by Penumbra."u8, config.AttachToPcp, pcpService.Set); From 76ed347cbfbe9db2a314e9d42a24f9a3917a613a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 7 Oct 2025 12:28:18 +0200 Subject: [PATCH 377/401] Update signatures. --- Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs | 2 ++ Penumbra.GameData | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 02f00db..587fe65 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -71,6 +71,8 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect private void DrawApplyAllButton() { var (id, name) = penumbra.CurrentCollection; + if (config.Ephemeral.IncognitoMode) + name = id.ShortGuid(); if (ImGuiUtil.DrawDisabledButton($"Try Applying All Associated Mods to {name}##applyAll", new Vector2(ImGui.GetContentRegionAvail().X, 0), string.Empty, id == Guid.Empty)) ApplyAll(); diff --git a/Penumbra.GameData b/Penumbra.GameData index a34f314..7e7d510 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit a34f314cbc1053a09923a0d64aa3173044d32101 +Subproject commit 7e7d510a2ce78e2af78312a8b2215c23bf43a56f From ace3a8f755f61c71c67df5f3718c6d39d2d8bb22 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 7 Oct 2025 12:43:40 +0200 Subject: [PATCH 378/401] Again. --- Penumbra.GameData | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.GameData b/Penumbra.GameData index 7e7d510..3baace7 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 7e7d510a2ce78e2af78312a8b2215c23bf43a56f +Subproject commit 3baace73c828271dcb71a8156e3e7b91e1dd12ae From e644b8da289002dd26b51bd638c70f856e7b031b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 7 Oct 2025 12:53:55 +0200 Subject: [PATCH 379/401] Fix span issue. --- Glamourer/Designs/DesignManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index e3648a4..e568218 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -6,11 +6,13 @@ using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Interop.Penumbra; using Glamourer.Services; +using OtterGui.Extensions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; + namespace Glamourer.Designs; public sealed class DesignManager : DesignEditor @@ -227,7 +229,7 @@ public sealed class DesignManager : DesignEditor design.Tags = design.Tags.Append(tag).OrderBy(t => t).ToArray(); design.LastEdit = DateTimeOffset.UtcNow; - var idx = design.Tags.IndexOf(tag); + var idx = design.Tags.AsEnumerable().IndexOf(tag); SaveService.QueueSave(design); Glamourer.Log.Debug($"Added tag {tag} at {idx} to design {design.Identifier}."); DesignChanged.Invoke(DesignChanged.Type.AddedTag, design, new TagAddedTransaction(tag, idx)); @@ -260,7 +262,7 @@ public sealed class DesignManager : DesignEditor SaveService.QueueSave(design); Glamourer.Log.Debug($"Renamed tag {oldTag} at {tagIdx} to {newTag} in design {design.Identifier} and reordered tags."); DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design, - new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag))); + new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.AsEnumerable().IndexOf(newTag))); } /// Add an associated mod to a design. From 4228fc1b896a5bd4421f7327047bdb65365ce703 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 7 Oct 2025 12:59:39 +0200 Subject: [PATCH 380/401] fu --- Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 4c7c103..a68c191 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -3,6 +3,7 @@ using Dalamud.Interface.Utility; using Glamourer.Designs; using Glamourer.Interop.Material; using Dalamud.Bindings.ImGui; +using OtterGui.Extensions; using OtterGui.Raii; using OtterGui.Text; using static Glamourer.Gui.Tabs.HeaderDrawer; @@ -489,7 +490,7 @@ public class MultiDesignPanel( foreach (var leaf in selector.SelectedPaths.OfType()) { - var index = leaf.Value.Tags.IndexOf(_tag); + var index = leaf.Value.Tags.AsEnumerable().IndexOf(_tag); if (index >= 0) _removeDesigns.Add((leaf.Value, index)); else From a56852f918b718a1b1643dc130ae6ac94e111b87 Mon Sep 17 00:00:00 2001 From: Actions User Date: Tue, 7 Oct 2025 11:02:02 +0000 Subject: [PATCH 381/401] [CI] Updating repo.json for 1.5.1.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 9f7e922..55e372c 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.2", - "TestingAssemblyVersion": "1.5.1.2", + "AssemblyVersion": "1.5.1.3", + "TestingAssemblyVersion": "1.5.1.3", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.2/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.2/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.2/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From a0d912a395f31eab5923815bd7bcca5e0774d8dd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 23 Oct 2025 17:23:43 +0200 Subject: [PATCH 382/401] Fix issue with reverting state of unavailable actors. --- Glamourer/State/StateApplier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index c346ab1..9800445 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -385,7 +385,7 @@ public class StateApplier( var actors = ChangeMetaState(state, MetaIndex.Wetness, true); if (redraw) { - if (withLock) + if (withLock && actors.Valid) state.TempLock(); ForceRedraw(actors); } From c604d5dbe50174da8a22d5c660c777c645b0efe0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 23 Oct 2025 17:25:54 +0200 Subject: [PATCH 383/401] Add DeletePlayerState. --- Glamourer.Api | 2 +- Glamourer/Api/ApiHelpers.cs | 19 ++++++++++++++----- Glamourer/Api/GlamourerApi.cs | 2 +- Glamourer/Api/IpcProviders.cs | 1 + Glamourer/Api/StateApi.cs | 25 ++++++++++++++++++++++--- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 7e8505c..59a7ab5 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 7e8505cd6f8dbc5bcf41b72e16785d62b4d218f3 +Subproject commit 59a7ab5fa9941eb754757b62e4cb189e455e9514 diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index 45d84b9..14cff3b 100644 --- a/Glamourer/Api/ApiHelpers.cs +++ b/Glamourer/Api/ApiHelpers.cs @@ -1,13 +1,13 @@ using Glamourer.Api.Enums; using Glamourer.Designs; using Glamourer.State; -using OtterGui; using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Services; using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; +using Penumbra.GameData.Structs; using Penumbra.String; namespace Glamourer.Api; @@ -15,14 +15,23 @@ namespace Glamourer.Api; public class ApiHelpers(ActorObjectManager objects, StateManager stateManager, ActorManager actors) : IApiService { [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - internal IEnumerable FindExistingStates(string actorName) + internal IEnumerable FindExistingStates(string actorName, ushort worldId = ushort.MaxValue) { if (actorName.Length == 0 || !ByteString.FromString(actorName, out var byteString)) yield break; - foreach (var state in stateManager.Values.Where(state - => state.Identifier.Type is IdentifierType.Player && state.Identifier.PlayerName == byteString)) - yield return state; + if (worldId == WorldId.AnyWorld.Id) + { + foreach (var state in stateManager.Values.Where(state + => state.Identifier.Type is IdentifierType.Player && state.Identifier.PlayerName == byteString)) + yield return state; + } + else + { + var identifier = actors.CreatePlayer(byteString, worldId); + if (stateManager.TryGetValue(identifier, out var state)) + yield return state; + } } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 14c0512..4bad983 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -6,7 +6,7 @@ namespace Glamourer.Api; public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; - public const int CurrentApiVersionMinor = 6; + public const int CurrentApiVersionMinor = 7; public (int Major, int Minor) ApiVersion => (CurrentApiVersionMajor, CurrentApiVersionMinor); diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 2701f18..6019e68 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -54,6 +54,7 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.RevertStateName.Provider(pi, api.State), IpcSubscribers.UnlockState.Provider(pi, api.State), IpcSubscribers.UnlockStateName.Provider(pi, api.State), + IpcSubscribers.DeletePlayerState.Provider(pi, api.State), IpcSubscribers.UnlockAll.Provider(pi, api.State), IpcSubscribers.RevertToAutomation.Provider(pi, api.State), IpcSubscribers.RevertToAutomationName.Provider(pi, api.State), diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 68c593b..3b0c2c5 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -8,6 +8,7 @@ using Glamourer.State; using Newtonsoft.Json.Linq; using OtterGui.Services; using Penumbra.GameData.Interop; +using Penumbra.GameData.Structs; using StateChanged = Glamourer.Events.StateChanged; namespace Glamourer.Api; @@ -17,7 +18,6 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private readonly ApiHelpers _helpers; private readonly StateManager _stateManager; private readonly DesignConverter _converter; - private readonly Configuration _config; private readonly AutoDesignApplier _autoDesigns; private readonly ActorObjectManager _objects; private readonly StateChanged _stateChanged; @@ -27,7 +27,6 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public StateApi(ApiHelpers helpers, StateManager stateManager, DesignConverter converter, - Configuration config, AutoDesignApplier autoDesigns, ActorObjectManager objects, StateChanged stateChanged, @@ -37,7 +36,6 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable _helpers = helpers; _stateManager = stateManager; _converter = converter; - _config = config; _autoDesigns = autoDesigns; _objects = objects; _stateChanged = stateChanged; @@ -202,6 +200,27 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } + public GlamourerApiEc DeletePlayerState(string playerName, ushort worldId, uint key) + { + var args = ApiHelpers.Args("Name", playerName, "World", worldId, "Key", key); + var states = _helpers.FindExistingStates(playerName).ToList(); + if (states.Count is 0) + return ApiHelpers.Return(GlamourerApiEc.NothingDone, args); + + var anyLocked = false; + foreach (var state in states) + { + if (state.CanUnlock(key)) + _stateManager.DeleteState(state.Identifier); + else + anyLocked = true; + } + + return ApiHelpers.Return(anyLocked + ? GlamourerApiEc.InvalidKey + : GlamourerApiEc.Success, args); + } + public int UnlockAll(uint key) => _stateManager.Values.Count(state => state.Unlock(key)); From bef1e39ac34c5b08bb17c0b2075234d3ee282f55 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 23 Oct 2025 17:36:03 +0200 Subject: [PATCH 384/401] Update Libraries. --- OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OtterGui b/OtterGui index f354444..a63f673 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit f354444776591ae423e2d8374aae346308d81424 +Subproject commit a63f6735cf4bed4f7502a022a10378607082b770 diff --git a/Penumbra.Api b/Penumbra.Api index 648b6fc..c23ee05 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 648b6fc2ce600a95ab2b2ced27e1639af2b04502 +Subproject commit c23ee05c1e9fa103eaa52e6aa7e855ef568ee669 diff --git a/Penumbra.GameData b/Penumbra.GameData index 3baace7..d889f9e 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 3baace73c828271dcb71a8156e3e7b91e1dd12ae +Subproject commit d889f9ef918514a46049725052d378b441915b00 From 88fe25f69e86906bd18ccd4ee4e552bdda1c4428 Mon Sep 17 00:00:00 2001 From: Actions User Date: Thu, 23 Oct 2025 15:40:25 +0000 Subject: [PATCH 385/401] [CI] Updating repo.json for testing_1.5.1.4 --- repo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo.json b/repo.json index 55e372c..ab87553 100644 --- a/repo.json +++ b/repo.json @@ -18,7 +18,7 @@ ], "InternalName": "Glamourer", "AssemblyVersion": "1.5.1.3", - "TestingAssemblyVersion": "1.5.1.3", + "TestingAssemblyVersion": "1.5.1.4", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -29,7 +29,7 @@ "LastUpdate": 1618608322, "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.5.1.4/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 434a5a809e6ea4efbec7482dec17e6fbda500f11 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 7 Nov 2025 23:29:41 +0100 Subject: [PATCH 386/401] Make old backup files overwrite instead of throwing. --- Glamourer/Designs/DesignManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index e568218..92f8398 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -557,7 +557,7 @@ public sealed class DesignManager : DesignEditor try { File.Move(SaveService.FileNames.MigrationDesignFile, - Path.ChangeExtension(SaveService.FileNames.MigrationDesignFile, ".json.bak")); + Path.ChangeExtension(SaveService.FileNames.MigrationDesignFile, ".json.bak"), true); Glamourer.Log.Information($"Moved migrated design file {SaveService.FileNames.MigrationDesignFile} to backup file."); } catch (Exception ex) From 76b214c643a9bf4b3a4d1e0f2bb50c81a461123a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 7 Nov 2025 23:29:59 +0100 Subject: [PATCH 387/401] Fix try-on interaction with Penumbra for facewear. --- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 62 ++++++++++++++++++-- Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs | 8 ++- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index ed6018e..dff9a6e 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -22,11 +22,12 @@ public sealed class PenumbraChangedItemTooltip : IDisposable private readonly CustomizeService _customize; private readonly GPoseService _gpose; - private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2]; + private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2 + BonusExtensions.AllFlags.Count]; - public IEnumerable> LastItems - => EquipSlotExtensions.EqdpSlots.Append(EquipSlot.MainHand).Append(EquipSlot.OffHand).Zip(_lastItems) - .Select(p => new KeyValuePair(p.First, p.Second)); + public IEnumerable> LastItems + => EquipSlotExtensions.EqdpSlots.Cast().Append(EquipSlot.MainHand).Append(EquipSlot.OffHand) + .Concat(BonusExtensions.AllFlags.Cast()).Zip(_lastItems) + .Select(p => new KeyValuePair(p.First, p.Second)); public ChangedItemType LastType { get; private set; } = ChangedItemType.None; public uint LastId { get; private set; } @@ -72,6 +73,21 @@ public sealed class PenumbraChangedItemTooltip : IDisposable if (!Player()) return; + var bonusSlot = item.Type.ToBonus(); + if (bonusSlot is not BonusItemFlag.Unknown) + { + // + 2 due to weapons. + var glasses = _lastItems[bonusSlot.ToSlot() + 2]; + using (_ = !openTooltip ? null : ImRaii.Tooltip()) + { + ImGui.TextUnformatted($"{prefix}Right-Click to apply to current actor."); + if (glasses.Valid) + ImGui.TextUnformatted($"{prefix}Control + Right-Click to re-apply {glasses.Name} to current actor."); + } + + return; + } + var slot = item.Type.ToSlot(); var last = _lastItems[slot.ToIndex()]; switch (slot) @@ -109,6 +125,27 @@ public sealed class PenumbraChangedItemTooltip : IDisposable public void ApplyItem(ActorState state, EquipItem item) { + var bonusSlot = item.Type.ToBonus(); + if (bonusSlot is not BonusItemFlag.Unknown) + { + // + 2 due to weapons. + var glasses = _lastItems[bonusSlot.ToSlot() + 2]; + if (ImGui.GetIO().KeyCtrl && glasses.Valid) + { + Glamourer.Log.Debug($"Re-Applying {glasses.Name} to {bonusSlot.ToName()}."); + SetLastItem(bonusSlot, default, state); + _stateManager.ChangeBonusItem(state, bonusSlot, glasses, ApplySettings.Manual); + } + else + { + Glamourer.Log.Debug($"Applying {item.Name} to {bonusSlot.ToName()}."); + SetLastItem(bonusSlot, item, state); + _stateManager.ChangeBonusItem(state, bonusSlot, item, ApplySettings.Manual); + } + + return; + } + var slot = item.Type.ToSlot(); var last = _lastItems[slot.ToIndex()]; switch (slot) @@ -265,7 +302,22 @@ public sealed class PenumbraChangedItemTooltip : IDisposable { var oldItem = state.ModelData.Item(slot); if (oldItem.Id != item.Id) - _lastItems[slot.ToIndex()] = oldItem; + last = oldItem; + } + } + + private void SetLastItem(BonusItemFlag slot, EquipItem item, ActorState state) + { + ref var last = ref _lastItems[slot.ToSlot() + 2]; + if (!item.Valid) + { + last = default; + } + else + { + var oldItem = state.ModelData.BonusItem(slot); + if (oldItem.Id != item.Id) + last = oldItem; } } diff --git a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index aa94a23..833ebe4 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -89,7 +89,13 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem ImGui.Separator(); foreach (var (slot, item) in _penumbraTooltip.LastItems) { - ImGuiUtil.DrawTableColumn($"{slot.ToName()} Revert-Item"); + switch (slot) + { + case EquipSlot e: ImGuiUtil.DrawTableColumn($"{e.ToName()} Revert-Item"); break; + case BonusItemFlag f: ImGuiUtil.DrawTableColumn($"{f.ToName()} Revert-Item"); break; + default: ImGuiUtil.DrawTableColumn("Unk Revert-Item"); break; + } + ImGuiUtil.DrawTableColumn(item.Valid ? item.Name : "None"); ImGui.TableNextColumn(); } From bf4673a1d950a78bc40928388402b6a3e658c594 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 7 Nov 2025 23:30:11 +0100 Subject: [PATCH 388/401] Save Remove and Inherit for mod associations. --- Glamourer/Designs/Design.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index 35ee3aa..848e7d6 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -100,7 +100,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn public new JObject JsonSerialize() { - var ret = new JObject() + var ret = new JObject { ["FileVersion"] = FileVersion, ["Identifier"] = Identifier, @@ -131,12 +131,17 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn var ret = new JArray(); foreach (var (mod, settings) in AssociatedMods) { - var obj = new JObject() + var obj = new JObject { ["Name"] = mod.Name, ["Directory"] = mod.DirectoryName, - ["Enabled"] = settings.Enabled, }; + if (settings.Remove) + obj["Remove"] = true; + else if (settings.ForceInherit) + obj["Inherit"] = true; + else + obj["Enabled"] = settings.Enabled; if (settings.Enabled) { obj["Priority"] = settings.Priority; From 04fb37d6618c27fae86299fa1fc69efe8a269dca Mon Sep 17 00:00:00 2001 From: Exter-N Date: Thu, 13 Nov 2025 20:09:26 +0100 Subject: [PATCH 389/401] Display relevant settings in Penumbra --- Glamourer/Gui/MainWindow.cs | 7 +++- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 33 ++++++++++++++----- Glamourer/Interop/Penumbra/PenumbraService.cs | 25 +++++++++++++- Penumbra.Api | 2 +- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs index a39db2e..abde603 100644 --- a/Glamourer/Gui/MainWindow.cs +++ b/Glamourer/Gui/MainWindow.cs @@ -102,6 +102,8 @@ public class MainWindow : Window, IDisposable SelectTab = _config.Ephemeral.SelectedTab; _event.Subscribe(OnTabSelected, TabSelected.Priority.MainWindow); IsOpen = _config.OpenWindowAtStart; + + _penumbra.DrawSettingsSection += Settings.DrawPenumbraIntegrationSettings; } public void OpenSettings() @@ -120,7 +122,10 @@ public class MainWindow : Window, IDisposable } public void Dispose() - => _event.Unsubscribe(OnTabSelected); + { + _event.Unsubscribe(OnTabSelected); + _penumbra.DrawSettingsSection -= Settings.DrawPenumbraIntegrationSettings; + } public override void Draw() { diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 0a84adc..fda9a7c 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -9,6 +9,7 @@ using Glamourer.Designs; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; using Glamourer.Interop.PalettePlus; +using Glamourer.Interop.Penumbra; using Glamourer.Services; using OtterGui; using OtterGui.Raii; @@ -69,6 +70,12 @@ public class SettingsTab( MainWindow.DrawSupportButtons(glamourer, changelog.Changelog); } + public void DrawPenumbraIntegrationSettings() + { + DrawPenumbraIntegrationSettings1(); + DrawPenumbraIntegrationSettings2(); + } + private void DrawBehaviorSettings() { if (!ImUtf8.CollapsingHeader("Glamourer Behavior"u8)) @@ -89,6 +96,20 @@ public class SettingsTab( Checkbox("Enable Festival Easter-Eggs"u8, "Glamourer may do some fun things on specific dates. Disable this if you do not want your experience disrupted by this."u8, config.DisableFestivals == 0, v => config.DisableFestivals = v ? (byte)0 : (byte)2); + DrawPenumbraIntegrationSettings1(); + Checkbox("Revert Manual Changes on Zone Change"u8, + "Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone."u8, + config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v); + PaletteImportButton(); + DrawPenumbraIntegrationSettings2(); + Checkbox("Prevent Random Design Repeats"u8, + "When using random designs, prevent the same design from being chosen twice in a row."u8, + config.PreventRandomRepeats, v => config.PreventRandomRepeats = v); + ImGui.NewLine(); + } + + private void DrawPenumbraIntegrationSettings1() + { Checkbox("Auto-Reload Gear"u8, "Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection."u8, config.AutoRedrawEquipOnChanges, v => config.AutoRedrawEquipOnChanges = v); @@ -101,10 +122,10 @@ public class SettingsTab( pcpService.CleanPcpDesigns(); if (!active) ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"\nHold {config.DeleteDesignModifier} while clicking."); - Checkbox("Revert Manual Changes on Zone Change"u8, - "Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone."u8, - config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v); - PaletteImportButton(); + } + + private void DrawPenumbraIntegrationSettings2() + { Checkbox("Always Apply Associated Mods"u8, "Whenever a design is applied to a character (including via automation), Glamourer will try to apply its associated mod settings to the collection currently associated with that character, if it is available.\n\n"u8 + "Glamourer will NOT revert these applied settings automatically. This may mess up your collection and configuration.\n\n"u8 @@ -114,10 +135,6 @@ public class SettingsTab( "Apply all settings as temporary settings so they will be reset when Glamourer or the game shut down."u8, config.UseTemporarySettings, v => config.UseTemporarySettings = v); - Checkbox("Prevent Random Design Repeats"u8, - "When using random designs, prevent the same design from being chosen twice in a row."u8, - config.PreventRandomRepeats, v => config.PreventRandomRepeats = v); - ImGui.NewLine(); } private void DrawDesignDefaultSettings() diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 4d70a3f..b2813cd 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin; +using Dalamud.Plugin.Ipc.Exceptions; using Glamourer.Events; using Glamourer.State; using Newtonsoft.Json.Linq; @@ -36,7 +37,7 @@ public readonly record struct ModSettings(Dictionary> Setti public class PenumbraService : IDisposable { public const int RequiredPenumbraBreakingVersion = 5; - public const int RequiredPenumbraFeatureVersion = 8; + public const int RequiredPenumbraFeatureVersion = 13; private const int KeyFixed = -1610; private const string NameFixed = "Glamourer (Automation)"; @@ -77,6 +78,8 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer? _queryTemporaryModSettingsPlayer; private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; private global::Penumbra.Api.IpcSubscribers.GetChangedItems? _getChangedItems; + private global::Penumbra.Api.IpcSubscribers.RegisterSettingsSection? _registerSettingsSection; + private global::Penumbra.Api.IpcSubscribers.UnregisterSettingsSection? _unregisterSettingsSection; private IReadOnlyList<(string ModDirectory, IReadOnlyDictionary ChangedItems)>? _changedItems; private Func? _checkCurrentChangedItems; private Func? _checkCutsceneParent; @@ -152,6 +155,11 @@ public class PenumbraService : IDisposable remove => _pcpParsed.Event -= value; } + public event Action? DrawSettingsSection; + + private void InvokeDrawSettingsSection() + => DrawSettingsSection?.Invoke(); + public Dictionary GetCollections() => Available ? _collections!.Invoke() : []; @@ -565,6 +573,10 @@ public class PenumbraService : IDisposable _changedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItemAdapterList(_pluginInterface).Invoke(); _checkCurrentChangedItems = new global::Penumbra.Api.IpcSubscribers.CheckCurrentChangedItemFunc(_pluginInterface).Invoke(); + _registerSettingsSection = new global::Penumbra.Api.IpcSubscribers.RegisterSettingsSection(_pluginInterface); + _unregisterSettingsSection = new global::Penumbra.Api.IpcSubscribers.UnregisterSettingsSection(_pluginInterface); + + _registerSettingsSection.Invoke(InvokeDrawSettingsSection); Available = true; _penumbraReloaded.Invoke(); @@ -587,6 +599,15 @@ public class PenumbraService : IDisposable _modSettingChanged.Disable(); _pcpCreated.Disable(); _pcpParsed.Disable(); + try + { + _unregisterSettingsSection?.Invoke(InvokeDrawSettingsSection); + } + catch (IpcNotReadyError) + { + // Ignore. + } + if (Available) { _collectionByIdentifier = null; @@ -617,6 +638,8 @@ public class PenumbraService : IDisposable _getChangedItems = null; _changedItems = null; _checkCurrentChangedItems = null; + _registerSettingsSection = null; + _unregisterSettingsSection = null; Available = false; Glamourer.Log.Debug("Glamourer detached from Penumbra."); } diff --git a/Penumbra.Api b/Penumbra.Api index c23ee05..b97784b 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit c23ee05c1e9fa103eaa52e6aa7e855ef568ee669 +Subproject commit b97784bd7cd911bd0a323cd8e717714de1875469 From aadcf771e71115cf9d93da6b275c5da341d52dcf Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Nov 2025 23:06:53 +0100 Subject: [PATCH 390/401] 1.5.1.5 --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index a63f673..1459e2b 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit a63f6735cf4bed4f7502a022a10378607082b770 +Subproject commit 1459e2b8f5e1687f659836709e23571235d4206c From 5b6517aae8259031c8bc9f600f5bdd431a1af3ae Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 28 Nov 2025 22:09:08 +0000 Subject: [PATCH 391/401] [CI] Updating repo.json for 1.5.1.5 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index ab87553..fd4c07f 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.3", - "TestingAssemblyVersion": "1.5.1.4", + "AssemblyVersion": "1.5.1.5", + "TestingAssemblyVersion": "1.5.1.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 13, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.3/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/testing_1.5.1.4/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.5/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.5/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.5/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 507e1268acb34141a8874e82830fe9b396cd67cf Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 17 Dec 2025 18:39:30 +0100 Subject: [PATCH 392/401] Update SDK. --- Glamourer.Api | 2 +- Glamourer/Glamourer.csproj | 2 +- Glamourer/packages.lock.json | 26 +++++++++----------------- OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- 7 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index 59a7ab5..3bfd1db 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 59a7ab5fa9941eb754757b62e4cb189e455e9514 +Subproject commit 3bfd1db3a471f6e808c4d981485a08f58a4bf6cd diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index d7e62a9..061e920 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -1,4 +1,4 @@ - + Glamourer Glamourer diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json index 8ac1fe4..30a6d00 100644 --- a/Glamourer/packages.lock.json +++ b/Glamourer/packages.lock.json @@ -1,18 +1,18 @@ { "version": 1, "dependencies": { - "net9.0-windows7.0": { + "net10.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[13.1.0, )", - "resolved": "13.1.0", - "contentHash": "XdoNhJGyFby5M/sdcRhnc5xTop9PHy+H50PTWpzLhJugjB19EDBiHD/AsiDF66RETM+0qKUdJBZrNuebn7qswQ==" + "requested": "[14.0.0, )", + "resolved": "14.0.0", + "contentHash": "9c1q/eAeAs82mkQWBOaCvbt3GIQxAIadz5b/7pCXDIy9nHPtnRc+tDXEvKR+M36Wvi7n+qBTevRupkLUQp6DFA==" }, "DotNet.ReproducibleBuilds": { "type": "Direct", - "requested": "[1.2.25, )", - "resolved": "1.2.25", - "contentHash": "xCXiw7BCxHJ8pF6wPepRUddlh2dlQlbr81gXA72hdk4FLHkKXas7EH/n+fk5UCA/YfMqG1Z6XaPiUjDbUNBUzg==" + "requested": "[1.2.39, )", + "resolved": "1.2.39", + "contentHash": "fcFN01tDTIQqDuTwr1jUQK/geofiwjG5DycJQOnC72i1SsLAk1ELe+apBOuZ11UMQG8YKFZG1FgvjZPbqHyatg==" }, "Vortice.Direct3D11": { "type": "Direct", @@ -32,10 +32,7 @@ "FlatSharp.Runtime": { "type": "Transitive", "resolved": "7.9.0", - "contentHash": "Bm8+WqzEsWNpxqrD5x4x+zQ8dyINlToCreM5FI2oNSfUVc9U9ZB+qztX/jd8rlJb3r0vBSlPwVLpw0xBtPa3Vw==", - "dependencies": { - "System.Memory": "4.5.5" - } + "contentHash": "Bm8+WqzEsWNpxqrD5x4x+zQ8dyINlToCreM5FI2oNSfUVc9U9ZB+qztX/jd8rlJb3r0vBSlPwVLpw0xBtPa3Vw==" }, "JetBrains.Annotations": { "type": "Transitive", @@ -68,11 +65,6 @@ "SharpGen.Runtime": "2.1.2-beta" } }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==" - }, "Vortice.DirectX": { "type": "Transitive", "resolved": "3.4.2-beta", @@ -116,7 +108,7 @@ "FlatSharp.Compiler": "[7.9.0, )", "FlatSharp.Runtime": "[7.9.0, )", "OtterGui": "[1.0.0, )", - "Penumbra.Api": "[5.10.0, )", + "Penumbra.Api": "[5.13.0, )", "Penumbra.String": "[1.0.6, )" } }, diff --git a/OtterGui b/OtterGui index 1459e2b..6f32364 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 1459e2b8f5e1687f659836709e23571235d4206c +Subproject commit 6f3236453b1edfaa25c8edcc8b39a9d9b2fc18ac diff --git a/Penumbra.Api b/Penumbra.Api index c23ee05..e4934cc 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit c23ee05c1e9fa103eaa52e6aa7e855ef568ee669 +Subproject commit e4934ccca0379f22dadf989ab2d34f30b3c5c7ea diff --git a/Penumbra.GameData b/Penumbra.GameData index d889f9e..2ff50e6 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit d889f9ef918514a46049725052d378b441915b00 +Subproject commit 2ff50e68f7c951f0f8b25957a400a2e32ed9d6dc diff --git a/Penumbra.String b/Penumbra.String index c8611a0..0315144 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit c8611a0c546b6b2ec29214ab319fc2c38fe74793 +Subproject commit 0315144ab5614c11911e2a4dddf436fb18c5d7e3 From cf87184c923e78b317683d6dada3831b48df49b2 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 19 Dec 2025 01:26:19 +0100 Subject: [PATCH 393/401] SDK update. --- .github/workflows/release.yml | 8 +++++--- .github/workflows/test_release.yml | 8 +++++--- Glamourer.Api | 2 +- Glamourer/Glamourer.csproj | 2 +- Glamourer/Glamourer.json | 2 +- Glamourer/Services/DalamudServices.cs | 2 +- Glamourer/packages.lock.json | 8 ++++---- OtterGui | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- Penumbra.String | 2 +- repo.json | 4 ++-- 12 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 327b75b..feecf19 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,13 +9,15 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 with: submodules: recursive - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v5 with: - dotnet-version: '9.x.x' + dotnet-version: | + 10.x.x + 9.x.x - name: Restore dependencies run: dotnet restore - name: Download Dalamud diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml index 6316776..5639c7b 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -9,13 +9,15 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 with: submodules: recursive - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v5 with: - dotnet-version: '9.x.x' + dotnet-version: | + 10.x.x + 9.x.x - name: Restore dependencies run: dotnet restore - name: Download Dalamud diff --git a/Glamourer.Api b/Glamourer.Api index 3bfd1db..5b6730d 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 3bfd1db3a471f6e808c4d981485a08f58a4bf6cd +Subproject commit 5b6730d46f17bdd02a441e23e2141576cf7acf53 diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index 061e920..560621d 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -1,4 +1,4 @@ - + Glamourer Glamourer diff --git a/Glamourer/Glamourer.json b/Glamourer/Glamourer.json index 2daff91..e2dbf8b 100644 --- a/Glamourer/Glamourer.json +++ b/Glamourer/Glamourer.json @@ -8,7 +8,7 @@ "AssemblyVersion": "9.0.0.1", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 13, + "DalamudApiLevel": 14, "ImageUrls": null, "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/master/images/icon.png" } \ No newline at end of file diff --git a/Glamourer/Services/DalamudServices.cs b/Glamourer/Services/DalamudServices.cs index 85783b9..e8a9f55 100644 --- a/Glamourer/Services/DalamudServices.cs +++ b/Glamourer/Services/DalamudServices.cs @@ -1,4 +1,3 @@ -using Dalamud.Game.ClientState.Objects; using Dalamud.Interface.DragDrop; using Dalamud.Plugin; using Dalamud.Plugin.Services; @@ -17,6 +16,7 @@ public class DalamudServices services.AddDalamudService(pi); services.AddDalamudService(pi); services.AddDalamudService(pi); + services.AddDalamudService(pi); services.AddDalamudService(pi); services.AddDalamudService(pi); services.AddDalamudService(pi); diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json index 30a6d00..b15c917 100644 --- a/Glamourer/packages.lock.json +++ b/Glamourer/packages.lock.json @@ -4,9 +4,9 @@ "net10.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[14.0.0, )", - "resolved": "14.0.0", - "contentHash": "9c1q/eAeAs82mkQWBOaCvbt3GIQxAIadz5b/7pCXDIy9nHPtnRc+tDXEvKR+M36Wvi7n+qBTevRupkLUQp6DFA==" + "requested": "[14.0.1, )", + "resolved": "14.0.1", + "contentHash": "y0WWyUE6dhpGdolK3iKgwys05/nZaVf4ZPtIjpLhJBZvHxkkiE23zYRo7K7uqAgoK/QvK5cqF6l3VG5AbgC6KA==" }, "DotNet.ReproducibleBuilds": { "type": "Direct", @@ -109,7 +109,7 @@ "FlatSharp.Runtime": "[7.9.0, )", "OtterGui": "[1.0.0, )", "Penumbra.Api": "[5.13.0, )", - "Penumbra.String": "[1.0.6, )" + "Penumbra.String": "[1.0.7, )" } }, "penumbra.string": { diff --git a/OtterGui b/OtterGui index 6f32364..ff1e654 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 6f3236453b1edfaa25c8edcc8b39a9d9b2fc18ac +Subproject commit ff1e6543845e3b8c53a5f8b240bc38faffb1b3bf diff --git a/Penumbra.Api b/Penumbra.Api index e4934cc..1750c41 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit e4934ccca0379f22dadf989ab2d34f30b3c5c7ea +Subproject commit 1750c41b53e1000c99a7fb9d8a0f082aef639a41 diff --git a/Penumbra.GameData b/Penumbra.GameData index 2ff50e6..0e973ed 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 2ff50e68f7c951f0f8b25957a400a2e32ed9d6dc +Subproject commit 0e973ed6eace6afd31cd298f8c58f76fa8d5ef60 diff --git a/Penumbra.String b/Penumbra.String index 0315144..9bd016f 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 0315144ab5614c11911e2a4dddf436fb18c5d7e3 +Subproject commit 9bd016fbef5fb2de467dd42165267fdd93cd9592 diff --git a/repo.json b/repo.json index fd4c07f..d2c030b 100644 --- a/repo.json +++ b/repo.json @@ -21,8 +21,8 @@ "TestingAssemblyVersion": "1.5.1.5", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 13, - "TestingDalamudApiLevel": 13, + "DalamudApiLevel": 14, + "TestingDalamudApiLevel": 14, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, From 643c83a6f3ceeab7416928b9e78ca6c71b8c07e4 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 19 Dec 2025 13:56:36 +0100 Subject: [PATCH 394/401] Touch up CanUnlock. --- Glamourer/Api/StateApi.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 8914dee..ffd541e 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -228,12 +228,12 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public GlamourerApiEc CanUnlock(int objectIndex, uint key, out bool isLocked, out bool canUnlock) { var args = ApiHelpers.Args("Index", objectIndex, "Key", key); - isLocked = false; // These seem like reasonable defaults. - canUnlock = false; - if (_helpers.FindExistingState(objectIndex, out var state) != GlamourerApiEc.Success) + isLocked = false; + canUnlock = true; + if (_helpers.FindExistingState(objectIndex, out var state) is not GlamourerApiEc.Success) return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); - if (state == null) - return ApiHelpers.Return(GlamourerApiEc.InvalidState, args); // Possibly, the error type could be changed. I just looked at what was available. + if (state is null) + return ApiHelpers.Return(GlamourerApiEc.Success, args); isLocked = state.IsLocked; canUnlock = state.CanUnlock(key); return ApiHelpers.Return(GlamourerApiEc.Success, args); From 77f3912bf2a5aee0b375e7ee1a4d6afdb38afbf5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 19 Dec 2025 14:01:51 +0100 Subject: [PATCH 395/401] Minor touch up ReapplyState. --- Glamourer/Api/StateApi.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index ffd541e..4ce9c01 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -129,10 +129,10 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public GlamourerApiEc ReapplyState(int objectIndex, uint key, ApplyFlag flags) { var args = ApiHelpers.Args("Index", objectIndex, "Key", key, "Flags", flags); - if (_helpers.FindExistingState(objectIndex, out var state) != GlamourerApiEc.Success) + if (_helpers.FindExistingState(objectIndex, out var state) is not GlamourerApiEc.Success) return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); - if (state == null) + if (state is null) return ApiHelpers.Return(GlamourerApiEc.NothingDone, args); if (!state.CanUnlock(key)) @@ -359,14 +359,14 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable private void Reapply(Actor actor, ActorState state, uint key, ApplyFlag flags) { - var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; + var source = flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcFixed : StateSource.IpcManual; _stateManager.ReapplyState(actor, state, false, source, true); ApiHelpers.Lock(state, key, flags); } private void Revert(ActorState state, uint key, ApplyFlag flags) { - var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; + var source = flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcFixed : StateSource.IpcManual; switch (flags & (ApplyFlag.Equipment | ApplyFlag.Customization)) { case ApplyFlag.Equipment: _stateManager.ResetEquip(state, source, key); break; From 3c68124b29e96d846a5b274344403eeaa47a6424 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 19 Dec 2025 14:15:14 +0100 Subject: [PATCH 396/401] Ny --- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 6432811..e559841 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -119,7 +119,7 @@ public class SettingsTab( config.AutoRedrawEquipOnChanges = v; autoRedraw.Invoke(v); }); - Checkbox("Attach to PCP-Handling"u8, + Checkbox("Attach to PCP Handling"u8, "Add the actor's glamourer state when a PCP is created by Penumbra, and create a design and apply it if possible when a PCP is installed by Penumbra."u8, config.AttachToPcp, pcpService.Set); var active = config.DeleteDesignModifier.IsActive(); From 98b702d6e663f4affe8df479683ed80f0bd65ab1 Mon Sep 17 00:00:00 2001 From: Actions User Date: Fri, 19 Dec 2025 13:16:42 +0000 Subject: [PATCH 397/401] [CI] Updating repo.json for 1.5.1.6 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index d2c030b..73f3e21 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.5", - "TestingAssemblyVersion": "1.5.1.5", + "AssemblyVersion": "1.5.1.6", + "TestingAssemblyVersion": "1.5.1.6", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 14, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.5/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.5/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.5/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.6/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.6/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.6/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 96f825e29851acab5374bf15c4ee877803111b93 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 20 Dec 2025 16:01:00 +0100 Subject: [PATCH 398/401] Update Penumbra API. --- Penumbra.Api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Penumbra.Api b/Penumbra.Api index 1750c41..52a3216 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 1750c41b53e1000c99a7fb9d8a0f082aef639a41 +Subproject commit 52a3216a525592205198303df2844435e382cf87 From 0d9a0d49aba6f04f3eb20f56037c46327614d57d Mon Sep 17 00:00:00 2001 From: Actions User Date: Sat, 20 Dec 2025 15:03:30 +0000 Subject: [PATCH 399/401] [CI] Updating repo.json for 1.5.1.7 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index 73f3e21..31b4c6e 100644 --- a/repo.json +++ b/repo.json @@ -17,8 +17,8 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.6", - "TestingAssemblyVersion": "1.5.1.6", + "AssemblyVersion": "1.5.1.7", + "TestingAssemblyVersion": "1.5.1.7", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", "DalamudApiLevel": 14, @@ -27,9 +27,9 @@ "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.6/Glamourer.zip", - "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.6/Glamourer.zip", - "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.6/Glamourer.zip", + "DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.7/Glamourer.zip", + "DownloadLinkUpdate": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.7/Glamourer.zip", + "DownloadLinkTesting": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.1.7/Glamourer.zip", "IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png" } ] From 59c9601a9bc8743eee7dd6ea0ad6080b611cc394 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 26 Dec 2025 18:20:44 +0100 Subject: [PATCH 400/401] Fix issue with material value in history. --- Glamourer/Designs/History/DesignTransaction.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Glamourer/Designs/History/DesignTransaction.cs b/Glamourer/Designs/History/DesignTransaction.cs index 98e3eec..65086db 100644 --- a/Glamourer/Designs/History/DesignTransaction.cs +++ b/Glamourer/Designs/History/DesignTransaction.cs @@ -1,6 +1,7 @@ using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Interop.Penumbra; +using Glamourer.State; using Penumbra.GameData.Enums; namespace Glamourer.Designs.History; @@ -125,7 +126,10 @@ public readonly record struct MaterialTransaction(MaterialValueIndex Index, Colo => older is MaterialTransaction other && Index == other.Index ? new MaterialTransaction(Index, other.Old, New) : null; public void Revert(IDesignEditor editor, object data) - => ((DesignManager)editor).ChangeMaterialValue((Design)data, Index, Old); + { + if (editor is DesignManager e) + e.ChangeMaterialValue((Design)data, Index, Old); + } } /// Only Designs. From f8ca572d380da3e71b761e6b955e106898109801 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 26 Dec 2025 18:21:47 +0100 Subject: [PATCH 401/401] Fix issue in unlocks tab. --- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index d75f2dc..2323ca2 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -194,7 +194,7 @@ public class UnlockTable : Table, IDisposable ImGui.Dummy(new Vector2(ImGui.GetFrameHeight())); ImGui.SameLine(); ImGui.AlignTextToFramePadding(); - if (ImGui.Selectable(item.Name)) + if (ImGui.Selectable(item.Name) && !item.Id.IsBonusItem) Glamourer.Messager.Chat.Print(new SeStringBuilder().AddItemLink(item.ItemId.Id, false).BuiltString); if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && _tooltip.Player(out var state))