diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index feecf19..327b75b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,15 +9,13 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v2 with: submodules: recursive - name: Setup .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@v1 with: - dotnet-version: | - 10.x.x - 9.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 5639c7b..6316776 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -9,15 +9,13 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v2 with: submodules: recursive - name: Setup .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@v1 with: - dotnet-version: | - 10.x.x - 9.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 5b6730d..54c1944 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 5b6730d46f17bdd02a441e23e2141576cf7acf53 +Subproject commit 54c1944dc7db704733b4788520e494761bb0b58e diff --git a/Glamourer/Api/ApiHelpers.cs b/Glamourer/Api/ApiHelpers.cs index 14cff3b..45d84b9 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,23 +15,14 @@ namespace Glamourer.Api; public class ApiHelpers(ActorObjectManager objects, StateManager stateManager, ActorManager actors) : IApiService { [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - internal IEnumerable FindExistingStates(string actorName, ushort worldId = ushort.MaxValue) + internal IEnumerable FindExistingStates(string actorName) { if (actorName.Length == 0 || !ByteString.FromString(actorName, out var byteString)) yield break; - 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; - } + foreach (var state in stateManager.Values.Where(state + => state.Identifier.Type is IdentifierType.Player && state.Identifier.PlayerName == byteString)) + yield return state; } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 85f873a..14c0512 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -3,17 +3,14 @@ using OtterGui.Services; namespace Glamourer.Api; -public class GlamourerApi(Configuration config, DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService +public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; - public const int CurrentApiVersionMinor = 7; + public const int CurrentApiVersionMinor = 6; 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 f120db3..2701f18 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -22,7 +22,6 @@ 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), @@ -51,18 +50,13 @@ 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), - IpcSubscribers.CanUnlock.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), - IpcSubscribers.AutoReloadGearChanged.Provider(pi, api.State), IpcSubscribers.StateChanged.Provider(pi, api.State), IpcSubscribers.StateChangedWithType.Provider(pi, api.State), IpcSubscribers.StateFinalized.Provider(pi, api.State), @@ -81,5 +75,3 @@ public sealed class IpcProviders : IDisposable, IApiService _disposedProvider.Dispose(); } } - - diff --git a/Glamourer/Api/StateApi.cs b/Glamourer/Api/StateApi.cs index 4ce9c01..68c593b 100644 --- a/Glamourer/Api/StateApi.cs +++ b/Glamourer/Api/StateApi.cs @@ -8,7 +8,6 @@ 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; @@ -18,9 +17,9 @@ 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 AutoRedrawChanged _autoRedraw; private readonly StateChanged _stateChanged; private readonly StateFinalized _stateFinalized; private readonly GPoseService _gPose; @@ -28,9 +27,9 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public StateApi(ApiHelpers helpers, StateManager stateManager, DesignConverter converter, + Configuration config, AutoDesignApplier autoDesigns, ActorObjectManager objects, - AutoRedrawChanged autoRedraw, StateChanged stateChanged, StateFinalized stateFinalized, GPoseService gPose) @@ -38,13 +37,12 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable _helpers = helpers; _stateManager = stateManager; _converter = converter; + _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); @@ -52,7 +50,6 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable public void Dispose() { - _autoRedraw.Unsubscribe(OnAutoRedrawChange); _stateChanged.Unsubscribe(OnStateChanged); _stateFinalized.Unsubscribe(OnStateFinalized); _gPose.Unsubscribe(OnGPoseChange); @@ -126,48 +123,6 @@ 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) is not GlamourerApiEc.Success) - return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); - - if (state is 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); @@ -225,20 +180,6 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable return ApiHelpers.Return(GlamourerApiEc.Success, args); } - public GlamourerApiEc CanUnlock(int objectIndex, uint key, out bool isLocked, out bool canUnlock) - { - var args = ApiHelpers.Args("Index", objectIndex, "Key", key); - isLocked = false; - canUnlock = true; - if (_helpers.FindExistingState(objectIndex, out var state) is not GlamourerApiEc.Success) - return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); - if (state is null) - return ApiHelpers.Return(GlamourerApiEc.Success, args); - isLocked = state.IsLocked; - canUnlock = state.CanUnlock(key); - return ApiHelpers.Return(GlamourerApiEc.Success, args); - } - public GlamourerApiEc UnlockStateName(string playerName, uint key) { var args = ApiHelpers.Args("Name", playerName, "Key", key); @@ -261,27 +202,6 @@ 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)); @@ -331,7 +251,6 @@ 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; @@ -346,27 +265,9 @@ 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.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.HasFlag(ApplyFlag.Once) ? StateSource.IpcFixed : StateSource.IpcManual; + 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; @@ -424,8 +325,8 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable }; } - private void OnAutoRedrawChange(bool autoReload) - => AutoReloadGearChanged?.Invoke(autoReload); + private void OnGPoseChange(bool gPose) + => GPoseChanged?.Invoke(gPose); private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5) { @@ -446,7 +347,4 @@ 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/Configuration.cs b/Glamourer/Configuration.cs index d266a55..f128bdd 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -40,37 +40,34 @@ public class Configuration : IPluginConfiguration, ISavable [JsonIgnore] public readonly EphemeralConfig Ephemeral; - 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 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 DesignPanelFlag HideDesignPanel { get; set; } = 0; public DesignPanelFlag AutoExpandDesignPanel { get; set; } = 0; diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index 848e7d6..35ee3aa 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,17 +131,12 @@ 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; diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 92f8398..3ddfefd 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -6,13 +6,12 @@ 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 OtterGui.Extensions; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; - namespace Glamourer.Designs; public sealed class DesignManager : DesignEditor @@ -229,7 +228,7 @@ public sealed class DesignManager : DesignEditor design.Tags = design.Tags.Append(tag).OrderBy(t => t).ToArray(); design.LastEdit = DateTimeOffset.UtcNow; - var idx = design.Tags.AsEnumerable().IndexOf(tag); + 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, new TagAddedTransaction(tag, idx)); @@ -262,7 +261,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.AsEnumerable().IndexOf(newTag))); + new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag))); } /// Add an associated mod to a design. @@ -557,7 +556,7 @@ public sealed class DesignManager : DesignEditor try { File.Move(SaveService.FileNames.MigrationDesignFile, - Path.ChangeExtension(SaveService.FileNames.MigrationDesignFile, ".json.bak"), true); + Path.ChangeExtension(SaveService.FileNames.MigrationDesignFile, ".json.bak")); Glamourer.Log.Information($"Moved migrated design file {SaveService.FileNames.MigrationDesignFile} to backup file."); } catch (Exception ex) diff --git a/Glamourer/Designs/History/DesignTransaction.cs b/Glamourer/Designs/History/DesignTransaction.cs index 65086db..98e3eec 100644 --- a/Glamourer/Designs/History/DesignTransaction.cs +++ b/Glamourer/Designs/History/DesignTransaction.cs @@ -1,7 +1,6 @@ using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Interop.Penumbra; -using Glamourer.State; using Penumbra.GameData.Enums; namespace Glamourer.Designs.History; @@ -126,10 +125,7 @@ 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) - { - if (editor is DesignManager e) - e.ChangeMaterialValue((Design)data, Index, Old); - } + => ((DesignManager)editor).ChangeMaterialValue((Design)data, Index, Old); } /// Only Designs. diff --git a/Glamourer/Events/AutoRedrawChanged.cs b/Glamourer/Events/AutoRedrawChanged.cs deleted file mode 100644 index a8dd03a..0000000 --- a/Glamourer/Events/AutoRedrawChanged.cs +++ /dev/null @@ -1,16 +0,0 @@ -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/Glamourer.cs b/Glamourer/Glamourer.cs index 33c67d5..f62085a 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -71,7 +71,6 @@ 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/Glamourer.csproj b/Glamourer/Glamourer.csproj index 560621d..86ae713 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 e2dbf8b..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": 14, + "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/GlamourerChangelog.cs b/Glamourer/Gui/GlamourerChangelog.cs index 686d4a1..31d1ce3 100644 --- a/Glamourer/Gui/GlamourerChangelog.cs +++ b/Glamourer/Gui/GlamourerChangelog.cs @@ -44,7 +44,6 @@ 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() @@ -65,16 +64,6 @@ 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.") diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs index abde603..a39db2e 100644 --- a/Glamourer/Gui/MainWindow.cs +++ b/Glamourer/Gui/MainWindow.cs @@ -102,8 +102,6 @@ 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() @@ -122,10 +120,7 @@ public class MainWindow : Window, IDisposable } public void Dispose() - { - _event.Unsubscribe(OnTabSelected); - _penumbra.DrawSettingsSection -= Settings.DrawPenumbraIntegrationSettings; - } + => _event.Unsubscribe(OnTabSelected); public override void Draw() { diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 7c16372..ce50ff2 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -18,6 +18,7 @@ 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); @@ -177,42 +178,14 @@ 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) { - DrawSlotCombo(); + 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, + }; ImUtf8.SameLineInner(); DrawMaterialIdxDrag(); ImUtf8.SameLineInner(); diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index dff9a6e..ed6018e 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -22,12 +22,11 @@ public sealed class PenumbraChangedItemTooltip : IDisposable private readonly CustomizeService _customize; private readonly GPoseService _gpose; - private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2 + BonusExtensions.AllFlags.Count]; + private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2]; - 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 IEnumerable> LastItems + => EquipSlotExtensions.EqdpSlots.Append(EquipSlot.MainHand).Append(EquipSlot.OffHand).Zip(_lastItems) + .Select(p => new KeyValuePair(p.First, p.Second)); public ChangedItemType LastType { get; private set; } = ChangedItemType.None; public uint LastId { get; private set; } @@ -73,21 +72,6 @@ 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) @@ -125,27 +109,6 @@ 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) @@ -302,22 +265,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable { var oldItem = state.ModelData.Item(slot); if (oldItem.Id != item.Id) - 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; + _lastItems[slot.ToIndex()] = oldItem; } } diff --git a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs index 1d3e711..ce843c4 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/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs index 61dad53..dbcb30c 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs @@ -1,5 +1,8 @@ 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 22c7597..f4e6925 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs @@ -33,11 +33,6 @@ 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(); @@ -54,7 +49,6 @@ 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(); @@ -78,7 +72,6 @@ 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 6fb9d68..e97d337 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -1,11 +1,11 @@ -using Dalamud.Bindings.ImGui; -using Dalamud.Interface; +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,10 +31,6 @@ 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; @@ -55,12 +51,10 @@ public class StateIpcTester : IUiService, IDisposable public StateIpcTester(IDalamudPluginInterface pluginInterface) { - _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(); + _pluginInterface = pluginInterface; + 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(); @@ -68,7 +62,6 @@ public class StateIpcTester : IUiService, IDisposable public void Dispose() { - AutoRedrawChanged.Dispose(); StateChanged.Dispose(); StateFinalized.Dispose(); GPoseChanged.Dispose(); @@ -90,8 +83,6 @@ 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"); @@ -147,14 +138,6 @@ 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); @@ -242,12 +225,6 @@ 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/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index 833ebe4..aa94a23 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -89,13 +89,7 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem ImGui.Separator(); foreach (var (slot, item) in _penumbraTooltip.LastItems) { - 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($"{slot.ToName()} Revert-Item"); ImGuiUtil.DrawTableColumn(item.Valid ? item.Name : "None"); ImGui.TableNextColumn(); } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index 8a3dd06..042f2a2 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -189,7 +189,10 @@ public class DesignDetailTab else if (_selector.Selected!.Color.Length != 0) { ImGui.SameLine(); - ImUtf8.Icon(FontAwesomeIcon.ExclamationCircle, "The color associated with this design does not exist."u8, _colors.MissingColor); + 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.DrawFrameColumn("Creation Date"u8); diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index e3c965c..84aaac0 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -154,7 +154,6 @@ 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()) { @@ -271,9 +270,11 @@ public class DesignPanel DrawCrestApplication(); ImUtf8.IconDummy(); DrawMetaApplication(); + ImUtf8.IconDummy(); + DrawBonusSlotApplication(); } - ImGui.SameLine(210 * ImUtf8.GlobalScale + ImGui.GetStyle().ItemSpacing.X); + ImGui.SameLine(ImGui.GetContentRegionAvail().X / 2); using (var _ = ImRaii.Group()) { void ApplyEquip(string label, EquipFlag allFlags, bool stain, IEnumerable slots) @@ -315,9 +316,6 @@ public class DesignPanel ImUtf8.IconDummy(); DrawParameterApplication(); - - ImUtf8.IconDummy(); - DrawBonusSlotApplication(); } } @@ -326,7 +324,7 @@ public class DesignPanel var enabled = _config.DeleteDesignModifier.IsActive(); bool? equip = null; bool? customize = null; - var size = new Vector2(210 * ImUtf8.GlobalScale, 0); + 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)) @@ -404,7 +402,6 @@ 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) @@ -417,7 +414,6 @@ public class DesignPanel "Apply Hat Visibility", "Apply Visor State", "Apply Weapon Visibility", - "Apply Viera Ear Visibility", ]; private void DrawMetaApplication() diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 587fe65..02f00db 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -71,8 +71,6 @@ 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/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index a68c191..1cdb171 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -490,7 +490,7 @@ public class MultiDesignPanel( foreach (var leaf in selector.SelectedPaths.OfType()) { - var index = leaf.Value.Tags.AsEnumerable().IndexOf(_tag); + var index = leaf.Value.Tags.IndexOf(_tag); if (index >= 0) _removeDesigns.Add((leaf.Value, index)); else diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index e559841..1ccb079 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -1,18 +1,14 @@ -using Dalamud.Bindings.ImGui; -using Dalamud.Game.ClientState.Keys; +using Dalamud.Game.ClientState.Keys; using Dalamud.Interface; using Dalamud.Interface.Components; 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; -using Glamourer.Interop.Penumbra; -using Glamourer.Services; -using OtterGui; +using Dalamud.Bindings.ImGui; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Widgets; @@ -31,9 +27,7 @@ public class SettingsTab( CollectionOverrideDrawer overrides, CodeDrawer codeDrawer, Glamourer glamourer, - AutoDesignApplier autoDesignApplier, - AutoRedrawChanged autoRedraw, - PcpService pcpService) + AutoDesignApplier autoDesignApplier) : ITab { private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray(); @@ -72,12 +66,6 @@ public class SettingsTab( MainWindow.DrawSupportButtons(glamourer, changelog.Changelog); } - public void DrawPenumbraIntegrationSettings() - { - DrawPenumbraIntegrationSettings1(); - DrawPenumbraIntegrationSettings2(); - } - private void DrawBehaviorSettings() { if (!ImUtf8.CollapsingHeader("Glamourer Behavior"u8)) @@ -98,40 +86,13 @@ 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("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"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; - 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); - 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."); - } - - 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 @@ -141,6 +102,10 @@ 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() @@ -159,28 +124,6 @@ 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/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 2323ca2..d75f2dc 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) && !item.Id.IsBonusItem) + if (ImGui.Selectable(item.Name)) Glamourer.Messager.Chat.Print(new SeStringBuilder().AddItemLink(item.ItemId.Id, false).BuiltString); if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && _tooltip.Player(out var state)) diff --git a/Glamourer/Interop/Material/MaterialManager.cs b/Glamourer/Interop/Material/MaterialManager.cs index 43e500b..9eccb29 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, (HumanSlot)slotId), + MaterialValueIndex.DrawObjectType.Human => GetTempSlot((Human*)characterBase, slotId), _ => GetTempSlot((Weapon*)characterBase), }; var mode = PrepareColorSet.GetMode(material); @@ -192,24 +192,12 @@ 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, HumanSlot slotId) + private static CharacterWeapon GetTempSlot(Human* human, byte slotId) { - 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, - }; + if (human->ChangedEquipData == null) + return ((Model)human).GetArmor(((uint)slotId).ToEquipSlot()).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); + return ((CharacterArmor*)human->ChangedEquipData + slotId * 3)->ToWeapon(0); } /// diff --git a/Glamourer/Interop/Material/MaterialService.cs b/Glamourer/Interop/Material/MaterialService.cs index 4893e14..a5f2b36 100644 --- a/Glamourer/Interop/Material/MaterialService.cs +++ b/Glamourer/Interop/Material/MaterialService.cs @@ -1,5 +1,6 @@ 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; @@ -68,9 +69,9 @@ public static unsafe class MaterialService return null; var material = (MaterialResourceHandle*) model.AsCharacterBase->MaterialsSpan[index].Value; - if (material == null || material->DataSet == null || material->DataSetSize < sizeof(ColorTable.Table) || !material->HasColorTable) + if (material == null || material->ColorTable == null) return null; - return (ColorTable.Table*)material->DataSet; + return (ColorTable.Table*)material->ColorTable; } } diff --git a/Glamourer/Interop/Material/MaterialValueIndex.cs b/Glamourer/Interop/Material/MaterialValueIndex.cs index eb3f71f..712b0d5 100644 --- a/Glamourer/Interop/Material/MaterialValueIndex.cs +++ b/Glamourer/Interop/Material/MaterialValueIndex.cs @@ -50,18 +50,6 @@ 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 { @@ -71,13 +59,6 @@ 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) diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 821a152..f52bb68 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->DataSet == null || material->DataSetSize < sizeof(ColorTable.Table) || !material->HasColorTable) + if (material->ColorTable == null) { table = default; return false; } - var newTable = *(ColorTable.Table*)material->DataSet; + var newTable = *(ColorTable.Table*)material->ColorTable; if (GetDyeTable(material, out var dyeTable)) { if (stainIds.Stain1.Id != 0) diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index b2813cd..d66ddc4 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -1,9 +1,7 @@ using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin; -using Dalamud.Plugin.Ipc.Exceptions; using Glamourer.Events; using Glamourer.State; -using Newtonsoft.Json.Linq; using OtterGui.Classes; using Penumbra.Api.Enums; using Penumbra.Api.Helpers; @@ -37,7 +35,7 @@ public readonly record struct ModSettings(Dictionary> Setti public class PenumbraService : IDisposable { public const int RequiredPenumbraBreakingVersion = 5; - public const int RequiredPenumbraFeatureVersion = 13; + public const int RequiredPenumbraFeatureVersion = 8; private const int KeyFixed = -1610; private const string NameFixed = "Glamourer (Automation)"; @@ -51,8 +49,6 @@ 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; @@ -78,8 +74,6 @@ 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; @@ -107,8 +101,6 @@ 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(); } @@ -143,23 +135,6 @@ 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 event Action? DrawSettingsSection; - - private void InvokeDrawSettingsSection() - => DrawSettingsSection?.Invoke(); - public Dictionary GetCollections() => Available ? _collections!.Invoke() : []; @@ -539,30 +514,28 @@ 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); @@ -573,10 +546,6 @@ 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(); @@ -597,17 +566,6 @@ public class PenumbraService : IDisposable _creatingCharacterBase.Disable(); _createdCharacterBase.Disable(); _modSettingChanged.Disable(); - _pcpCreated.Disable(); - _pcpParsed.Disable(); - try - { - _unregisterSettingsSection?.Invoke(InvokeDrawSettingsSection); - } - catch (IpcNotReadyError) - { - // Ignore. - } - if (Available) { _collectionByIdentifier = null; @@ -638,8 +596,6 @@ public class PenumbraService : IDisposable _getChangedItems = null; _changedItems = null; _checkCurrentChangedItems = null; - _registerSettingsSection = null; - _unregisterSettingsSection = null; Available = false; Glamourer.Log.Debug("Glamourer detached from Penumbra."); } @@ -656,7 +612,5 @@ public class PenumbraService : IDisposable _initializedEvent.Dispose(); _disposedEvent.Dispose(); _modSettingChanged.Dispose(); - _pcpCreated.Dispose(); - _pcpParsed.Dispose(); } } diff --git a/Glamourer/Interop/VisorService.cs b/Glamourer/Interop/VisorService.cs index 83262e4..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) { @@ -36,7 +36,7 @@ public class VisorService : IDisposable /// The draw object. /// The desired state (true: toggled). /// Whether the state was changed. - public unsafe bool SetVisorState(Model human, bool on) + public bool SetVisorState(Model human, bool on) { if (!human.IsHuman) return false; @@ -46,8 +46,6 @@ 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; } diff --git a/Glamourer/Interop/WeaponService.cs b/Glamourer/Interop/WeaponService.cs index 54f318b..b0bdd19 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, int, void >) + (delegate* unmanaged[Stdcall] < DrawDataContainer*, uint, ulong, byte, byte, byte, byte, void >) DrawDataContainer.MemberFunctionPointers.LoadWeapon; _loadWeaponHook.Enable(); } @@ -36,14 +36,13 @@ 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 unk5); + byte skipGameObject, byte unk4); private readonly Hook _loadWeaponHook; private void LoadWeaponDetour(DrawDataContainer* drawData, uint slot, ulong weaponValue, byte redrawOnEquality, byte unk2, - byte skipGameObject, byte unk4, byte unk5) + byte skipGameObject, byte unk4) { if (!_inUpdate.Value) { @@ -65,21 +64,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, unk5); + _loadWeaponHook.Original(drawData, slot, weapon.Value, redrawOnEquality, unk2, skipGameObject, unk4); if (tmpWeapon.Value != weapon.Value) { if (tmpWeapon.Skeleton.Id == 0) tmpWeapon.Stains = StainIds.None; - _loadWeaponHook.Original(drawData, slot, tmpWeapon.Value, 1, unk2, 1, unk4, unk5); + _loadWeaponHook.Original(drawData, slot, tmpWeapon.Value, 1, unk2, 1, unk4); } Glamourer.Log.Excessive( - $"Weapon reloaded for 0x{actor.Address:X} ({actor.Utf8Name}) with attributes {slot} {weapon.Value:X14}, {redrawOnEquality}, {unk2}, {skipGameObject}, {unk4}, {unk5}"); + $"Weapon reloaded for 0x{actor.Address:X} ({actor.Utf8Name}) with attributes {slot} {weapon.Value:X14}, {redrawOnEquality}, {unk2}, {skipGameObject}, {unk4}"); } else { - _loadWeaponHook.Original(drawData, slot, weaponValue, redrawOnEquality, unk2, skipGameObject, unk4, unk5); + _loadWeaponHook.Original(drawData, slot, weaponValue, redrawOnEquality, unk2, skipGameObject, unk4); } } @@ -90,18 +89,18 @@ public unsafe class WeaponService : IDisposable { case EquipSlot.MainHand: _inUpdate.Value = true; - _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0, 0); + _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0); _inUpdate.Value = false; return; case EquipSlot.OffHand: _inUpdate.Value = true; - _original(&character.AsCharacter->DrawData, 1, weapon.Value, 1, 0, 1, 0, 0); + _original(&character.AsCharacter->DrawData, 1, weapon.Value, 1, 0, 1, 0); _inUpdate.Value = false; return; case EquipSlot.BothHand: _inUpdate.Value = true; - _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); + _original(&character.AsCharacter->DrawData, 0, weapon.Value, 1, 0, 1, 0); + _original(&character.AsCharacter->DrawData, 1, CharacterWeapon.Empty.Value, 1, 0, 1, 0); _inUpdate.Value = false; return; } diff --git a/Glamourer/Services/BackupService.cs b/Glamourer/Services/BackupService.cs index 511cca6..3abf13a 100644 --- a/Glamourer/Services/BackupService.cs +++ b/Glamourer/Services/BackupService.cs @@ -1,10 +1,9 @@ using OtterGui.Classes; using OtterGui.Log; -using OtterGui.Services; namespace Glamourer.Services; -public class BackupService : IAsyncService +public class BackupService { private readonly Logger _logger; private readonly DirectoryInfo _configDirectory; @@ -15,7 +14,7 @@ public class BackupService : IAsyncService _logger = logger; _fileNames = GlamourerFiles(fileNames); _configDirectory = new DirectoryInfo(fileNames.ConfigDirectory); - Awaiter = Task.Run(() => Backup.CreateAutomaticBackup(logger, new DirectoryInfo(fileNames.ConfigDirectory), _fileNames)); + Backup.CreateAutomaticBackup(logger, _configDirectory, _fileNames); } /// Create a permanent backup with a given name for migrations. @@ -41,9 +40,4 @@ public class BackupService : IAsyncService return list; } - - public Task Awaiter { get; } - - public bool Finished - => Awaiter.IsCompletedSuccessfully; } diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index 4a82f0e..af2e88b 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -50,8 +50,7 @@ public class CodeService | CodeFlag.OopsMiqote | CodeFlag.OopsRoegadyn | CodeFlag.OopsAuRa - | CodeFlag.OopsHrothgar - | CodeFlag.OopsViera; + | CodeFlag.OopsHrothgar; public const CodeFlag FullCodes = CodeFlag.Face | CodeFlag.Manderville | CodeFlag.Smiles; @@ -251,4 +250,3 @@ public class CodeService _ => (false, 0, string.Empty, string.Empty, string.Empty), }; } - diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index d2feac0..d47f26f 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -96,12 +96,6 @@ 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") diff --git a/Glamourer/Services/DalamudServices.cs b/Glamourer/Services/DalamudServices.cs index e8a9f55..85783b9 100644 --- a/Glamourer/Services/DalamudServices.cs +++ b/Glamourer/Services/DalamudServices.cs @@ -1,3 +1,4 @@ +using Dalamud.Game.ClientState.Objects; using Dalamud.Interface.DragDrop; using Dalamud.Plugin; using Dalamud.Plugin.Services; @@ -16,7 +17,6 @@ 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/Services/PcpService.cs b/Glamourer/Services/PcpService.cs deleted file mode 100644 index 3363172..0000000 --- a/Glamourer/Services/PcpService.cs +++ /dev/null @@ -1,119 +0,0 @@ -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, string path) - { - 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/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 9800445..c346ab1 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 && actors.Valid) + if (withLock) state.TempLock(); ForceRedraw(actors); } diff --git a/Glamourer/packages.lock.json b/Glamourer/packages.lock.json index b15c917..f66e6e4 100644 --- a/Glamourer/packages.lock.json +++ b/Glamourer/packages.lock.json @@ -1,18 +1,18 @@ { "version": 1, "dependencies": { - "net10.0-windows7.0": { + "net9.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[14.0.1, )", - "resolved": "14.0.1", - "contentHash": "y0WWyUE6dhpGdolK3iKgwys05/nZaVf4ZPtIjpLhJBZvHxkkiE23zYRo7K7uqAgoK/QvK5cqF6l3VG5AbgC6KA==" + "requested": "[13.0.0, )", + "resolved": "13.0.0", + "contentHash": "Mb3cUDSK/vDPQ8gQIeuCw03EMYrej1B4J44a1AvIJ9C759p9XeqdU9Hg4WgOmlnlPe0G7ILTD32PKSUpkQNa8w==" }, "DotNet.ReproducibleBuilds": { "type": "Direct", - "requested": "[1.2.39, )", - "resolved": "1.2.39", - "contentHash": "fcFN01tDTIQqDuTwr1jUQK/geofiwjG5DycJQOnC72i1SsLAk1ELe+apBOuZ11UMQG8YKFZG1FgvjZPbqHyatg==" + "requested": "[1.2.25, )", + "resolved": "1.2.25", + "contentHash": "xCXiw7BCxHJ8pF6wPepRUddlh2dlQlbr81gXA72hdk4FLHkKXas7EH/n+fk5UCA/YfMqG1Z6XaPiUjDbUNBUzg==" }, "Vortice.Direct3D11": { "type": "Direct", @@ -24,16 +24,6 @@ "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==" - }, "JetBrains.Annotations": { "type": "Transitive", "resolved": "2024.3.0", @@ -105,11 +95,9 @@ "penumbra.gamedata": { "type": "Project", "dependencies": { - "FlatSharp.Compiler": "[7.9.0, )", - "FlatSharp.Runtime": "[7.9.0, )", "OtterGui": "[1.0.0, )", - "Penumbra.Api": "[5.13.0, )", - "Penumbra.String": "[1.0.7, )" + "Penumbra.Api": "[5.10.0, )", + "Penumbra.String": "[1.0.6, )" } }, "penumbra.string": { diff --git a/OtterGui b/OtterGui index ff1e654..5e32bb2 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit ff1e6543845e3b8c53a5f8b240bc38faffb1b3bf +Subproject commit 5e32bb225e5fbb60ed8426ed887fd7e8a831ebae diff --git a/Penumbra.Api b/Penumbra.Api index 52a3216..c27a060 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 52a3216a525592205198303df2844435e382cf87 +Subproject commit c27a06004138f2ec80ccdb494bb6ddf6d39d2165 diff --git a/Penumbra.GameData b/Penumbra.GameData index 0e973ed..fd875c4 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 0e973ed6eace6afd31cd298f8c58f76fa8d5ef60 +Subproject commit fd875c43ee910350107b2609809335285bd4ac0f diff --git a/Penumbra.String b/Penumbra.String index 9bd016f..878acce 160000 --- a/Penumbra.String +++ b/Penumbra.String @@ -1 +1 @@ -Subproject commit 9bd016fbef5fb2de467dd42165267fdd93cd9592 +Subproject commit 878acce46e286867d6ef1f8ecedb390f7bac34fd diff --git a/repo.json b/repo.json index 31b4c6e..56d0c96 100644 --- a/repo.json +++ b/repo.json @@ -17,19 +17,19 @@ "Character" ], "InternalName": "Glamourer", - "AssemblyVersion": "1.5.1.7", - "TestingAssemblyVersion": "1.5.1.7", + "AssemblyVersion": "1.5.0.2", + "TestingAssemblyVersion": "1.5.0.2", "RepoUrl": "https://github.com/Ottermandias/Glamourer", "ApplicableVersion": "any", - "DalamudApiLevel": 14, - "TestingDalamudApiLevel": 14, + "DalamudApiLevel": 13, + "TestingDalamudApiLevel": 13, "IsHide": "False", "IsTestingExclusive": "False", "DownloadCount": 1, "LastUpdate": 1618608322, - "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", + "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" } ]