mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Compare commits
3 commits
3704051b0f
...
4d4e4669dd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d4e4669dd | ||
|
|
fb065549e9 | ||
|
|
2c34154915 |
9 changed files with 255 additions and 55 deletions
|
|
@ -40,34 +40,37 @@ public class Configuration : IPluginConfiguration, ISavable
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public readonly EphemeralConfig Ephemeral;
|
public readonly EphemeralConfig Ephemeral;
|
||||||
|
|
||||||
public bool UseRestrictedGearProtection { get; set; } = false;
|
public bool AttachToPcp { get; set; } = true;
|
||||||
public bool OpenFoldersByDefault { get; set; } = false;
|
public bool UseRestrictedGearProtection { get; set; } = false;
|
||||||
public bool AutoRedrawEquipOnChanges { get; set; } = false;
|
public bool OpenFoldersByDefault { get; set; } = false;
|
||||||
public bool EnableAutoDesigns { get; set; } = true;
|
public bool AutoRedrawEquipOnChanges { get; set; } = false;
|
||||||
public bool HideApplyCheckmarks { get; set; } = false;
|
public bool EnableAutoDesigns { get; set; } = true;
|
||||||
public bool SmallEquip { get; set; } = false;
|
public bool HideApplyCheckmarks { get; set; } = false;
|
||||||
public bool UnlockedItemMode { get; set; } = false;
|
public bool SmallEquip { get; set; } = false;
|
||||||
public byte DisableFestivals { get; set; } = 1;
|
public bool UnlockedItemMode { get; set; } = false;
|
||||||
public bool EnableGameContextMenu { get; set; } = true;
|
public byte DisableFestivals { get; set; } = 1;
|
||||||
public bool HideWindowInCutscene { get; set; } = false;
|
public bool EnableGameContextMenu { get; set; } = true;
|
||||||
public bool ShowAutomationSetEditing { get; set; } = true;
|
public bool HideWindowInCutscene { get; set; } = false;
|
||||||
public bool ShowAllAutomatedApplicationRules { get; set; } = true;
|
public bool ShowAutomationSetEditing { get; set; } = true;
|
||||||
public bool ShowUnlockedItemWarnings { get; set; } = true;
|
public bool ShowAllAutomatedApplicationRules { get; set; } = true;
|
||||||
public bool RevertManualChangesOnZoneChange { get; set; } = false;
|
public bool ShowUnlockedItemWarnings { get; set; } = true;
|
||||||
public bool ShowQuickBarInTabs { get; set; } = true;
|
public bool RevertManualChangesOnZoneChange { get; set; } = false;
|
||||||
public bool OpenWindowAtStart { get; set; } = false;
|
public bool ShowQuickBarInTabs { get; set; } = true;
|
||||||
public bool ShowWindowWhenUiHidden { get; set; } = false;
|
public bool OpenWindowAtStart { get; set; } = false;
|
||||||
public bool KeepAdvancedDyesAttached { get; set; } = true;
|
public bool ShowWindowWhenUiHidden { get; set; } = false;
|
||||||
public bool ShowPalettePlusImport { get; set; } = true;
|
public bool KeepAdvancedDyesAttached { get; set; } = true;
|
||||||
public bool UseFloatForColors { get; set; } = true;
|
public bool ShowPalettePlusImport { get; set; } = true;
|
||||||
public bool UseRgbForColors { get; set; } = true;
|
public bool UseFloatForColors { get; set; } = true;
|
||||||
public bool ShowColorConfig { get; set; } = true;
|
public bool UseRgbForColors { get; set; } = true;
|
||||||
public bool ChangeEntireItem { get; set; } = false;
|
public bool ShowColorConfig { get; set; } = true;
|
||||||
public bool AlwaysApplyAssociatedMods { get; set; } = false;
|
public bool ChangeEntireItem { get; set; } = false;
|
||||||
public bool UseTemporarySettings { get; set; } = true;
|
public bool AlwaysApplyAssociatedMods { get; set; } = true;
|
||||||
public bool AllowDoubleClickToApply { get; set; } = false;
|
public bool UseTemporarySettings { get; set; } = true;
|
||||||
public bool RespectManualOnAutomationUpdate { get; set; } = false;
|
public bool AllowDoubleClickToApply { get; set; } = false;
|
||||||
public bool PreventRandomRepeats { 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 HideDesignPanel { get; set; } = 0;
|
||||||
public DesignPanelFlag AutoExpandDesignPanel { get; set; } = 0;
|
public DesignPanelFlag AutoExpandDesignPanel { get; set; } = 0;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public class Glamourer : IDalamudPlugin
|
||||||
sb.Append($"> **`Festival Easter-Eggs: `** {config.DisableFestivals}\n");
|
sb.Append($"> **`Festival Easter-Eggs: `** {config.DisableFestivals}\n");
|
||||||
sb.Append($"> **`Apply Entire Weapon: `** {config.ChangeEntireItem}\n");
|
sb.Append($"> **`Apply Entire Weapon: `** {config.ChangeEntireItem}\n");
|
||||||
sb.Append($"> **`Apply Associated Mods:`** {config.AlwaysApplyAssociatedMods}\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($"> **`Hidden Panels: `** {config.HideDesignPanel}\n");
|
||||||
sb.Append($"> **`Show QDB: `** {config.Ephemeral.ShowDesignQuickBar}\n");
|
sb.Append($"> **`Show QDB: `** {config.Ephemeral.ShowDesignQuickBar}\n");
|
||||||
sb.Append($"> **`QDB Hotkey: `** {config.ToggleQuickDesignBar}\n");
|
sb.Append($"> **`QDB Hotkey: `** {config.ToggleQuickDesignBar}\n");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Dalamud.Game.ClientState.Keys;
|
using Dalamud.Bindings.ImGui;
|
||||||
|
using Dalamud.Game.ClientState.Keys;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
|
|
@ -8,7 +9,8 @@ using Glamourer.Designs;
|
||||||
using Glamourer.Gui.Tabs.DesignTab;
|
using Glamourer.Gui.Tabs.DesignTab;
|
||||||
using Glamourer.Interop;
|
using Glamourer.Interop;
|
||||||
using Glamourer.Interop.PalettePlus;
|
using Glamourer.Interop.PalettePlus;
|
||||||
using Dalamud.Bindings.ImGui;
|
using Glamourer.Services;
|
||||||
|
using OtterGui;
|
||||||
using OtterGui.Raii;
|
using OtterGui.Raii;
|
||||||
using OtterGui.Text;
|
using OtterGui.Text;
|
||||||
using OtterGui.Widgets;
|
using OtterGui.Widgets;
|
||||||
|
|
@ -27,7 +29,8 @@ public class SettingsTab(
|
||||||
CollectionOverrideDrawer overrides,
|
CollectionOverrideDrawer overrides,
|
||||||
CodeDrawer codeDrawer,
|
CodeDrawer codeDrawer,
|
||||||
Glamourer glamourer,
|
Glamourer glamourer,
|
||||||
AutoDesignApplier autoDesignApplier)
|
AutoDesignApplier autoDesignApplier,
|
||||||
|
PcpService pcpService)
|
||||||
: ITab
|
: ITab
|
||||||
{
|
{
|
||||||
private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray();
|
private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray();
|
||||||
|
|
@ -89,6 +92,15 @@ public class SettingsTab(
|
||||||
Checkbox("Auto-Reload Gear"u8,
|
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,
|
"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);
|
||||||
|
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,
|
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,
|
"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);
|
config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v);
|
||||||
|
|
@ -124,6 +136,28 @@ public class SettingsTab(
|
||||||
Checkbox("Reset Temporary Settings"u8,
|
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,
|
"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);
|
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()
|
private void DrawInterfaceSettings()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Glamourer.Events;
|
using Glamourer.Events;
|
||||||
using Glamourer.State;
|
using Glamourer.State;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
using Penumbra.Api.Helpers;
|
using Penumbra.Api.Helpers;
|
||||||
|
|
@ -49,6 +50,8 @@ public class PenumbraService : IDisposable
|
||||||
private readonly EventSubscriber<nint, Guid, nint, nint, nint> _creatingCharacterBase;
|
private readonly EventSubscriber<nint, Guid, nint, nint, nint> _creatingCharacterBase;
|
||||||
private readonly EventSubscriber<nint, Guid, nint> _createdCharacterBase;
|
private readonly EventSubscriber<nint, Guid, nint> _createdCharacterBase;
|
||||||
private readonly EventSubscriber<ModSettingChange, Guid, string, bool> _modSettingChanged;
|
private readonly EventSubscriber<ModSettingChange, Guid, string, bool> _modSettingChanged;
|
||||||
|
private readonly EventSubscriber<JObject, string, Guid> _pcpParsed;
|
||||||
|
private readonly EventSubscriber<JObject, ushort> _pcpCreated;
|
||||||
|
|
||||||
private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier;
|
private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier;
|
||||||
private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections;
|
private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections;
|
||||||
|
|
@ -101,6 +104,8 @@ public class PenumbraService : IDisposable
|
||||||
_createdCharacterBase = global::Penumbra.Api.IpcSubscribers.CreatedCharacterBase.Subscriber(pi);
|
_createdCharacterBase = global::Penumbra.Api.IpcSubscribers.CreatedCharacterBase.Subscriber(pi);
|
||||||
_creatingCharacterBase = global::Penumbra.Api.IpcSubscribers.CreatingCharacterBase.Subscriber(pi);
|
_creatingCharacterBase = global::Penumbra.Api.IpcSubscribers.CreatingCharacterBase.Subscriber(pi);
|
||||||
_modSettingChanged = global::Penumbra.Api.IpcSubscribers.ModSettingChanged.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();
|
Reattach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,6 +140,18 @@ public class PenumbraService : IDisposable
|
||||||
remove => _modSettingChanged.Event -= value;
|
remove => _modSettingChanged.Event -= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event Action<JObject, ushort> PcpCreated
|
||||||
|
{
|
||||||
|
add => _pcpCreated.Event += value;
|
||||||
|
remove => _pcpCreated.Event -= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event Action<JObject, string, Guid> PcpParsed
|
||||||
|
{
|
||||||
|
add => _pcpParsed.Event += value;
|
||||||
|
remove => _pcpParsed.Event -= value;
|
||||||
|
}
|
||||||
|
|
||||||
public Dictionary<Guid, string> GetCollections()
|
public Dictionary<Guid, string> GetCollections()
|
||||||
=> Available ? _collections!.Invoke() : [];
|
=> Available ? _collections!.Invoke() : [];
|
||||||
|
|
||||||
|
|
@ -514,28 +531,30 @@ public class PenumbraService : IDisposable
|
||||||
_clickSubscriber.Enable();
|
_clickSubscriber.Enable();
|
||||||
_creatingCharacterBase.Enable();
|
_creatingCharacterBase.Enable();
|
||||||
_createdCharacterBase.Enable();
|
_createdCharacterBase.Enable();
|
||||||
|
_pcpCreated.Enable();
|
||||||
|
_pcpParsed.Enable();
|
||||||
_modSettingChanged.Enable();
|
_modSettingChanged.Enable();
|
||||||
_collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface);
|
_collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface);
|
||||||
_collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface);
|
_collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface);
|
||||||
_redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface);
|
_redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface);
|
||||||
_checkCutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndexFunc(_pluginInterface).Invoke();
|
_checkCutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndexFunc(_pluginInterface).Invoke();
|
||||||
_getGameObject = new global::Penumbra.Api.IpcSubscribers.GetGameObjectFromDrawObjectFunc(_pluginInterface).Invoke();
|
_getGameObject = new global::Penumbra.Api.IpcSubscribers.GetGameObjectFromDrawObjectFunc(_pluginInterface).Invoke();
|
||||||
_objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface);
|
_objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface);
|
||||||
_getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface);
|
_getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface);
|
||||||
_currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface);
|
_currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface);
|
||||||
_getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface);
|
_getCurrentSettings = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettings(_pluginInterface);
|
||||||
_inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface);
|
_inheritMod = new global::Penumbra.Api.IpcSubscribers.TryInheritMod(_pluginInterface);
|
||||||
_setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface);
|
_setMod = new global::Penumbra.Api.IpcSubscribers.TrySetMod(_pluginInterface);
|
||||||
_setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface);
|
_setModPriority = new global::Penumbra.Api.IpcSubscribers.TrySetModPriority(_pluginInterface);
|
||||||
_setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface);
|
_setModSetting = new global::Penumbra.Api.IpcSubscribers.TrySetModSetting(_pluginInterface);
|
||||||
_setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface);
|
_setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface);
|
||||||
_openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface);
|
_openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface);
|
||||||
_getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface);
|
_getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface);
|
||||||
_setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface);
|
_setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface);
|
||||||
_setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface);
|
_setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface);
|
||||||
_removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface);
|
_removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface);
|
||||||
_removeTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer(_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 =
|
_removeAllTemporaryModSettingsPlayer =
|
||||||
new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface);
|
new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface);
|
||||||
_queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface);
|
_queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface);
|
||||||
|
|
@ -566,6 +585,8 @@ public class PenumbraService : IDisposable
|
||||||
_creatingCharacterBase.Disable();
|
_creatingCharacterBase.Disable();
|
||||||
_createdCharacterBase.Disable();
|
_createdCharacterBase.Disable();
|
||||||
_modSettingChanged.Disable();
|
_modSettingChanged.Disable();
|
||||||
|
_pcpCreated.Disable();
|
||||||
|
_pcpParsed.Disable();
|
||||||
if (Available)
|
if (Available)
|
||||||
{
|
{
|
||||||
_collectionByIdentifier = null;
|
_collectionByIdentifier = null;
|
||||||
|
|
@ -612,5 +633,7 @@ public class PenumbraService : IDisposable
|
||||||
_initializedEvent.Dispose();
|
_initializedEvent.Dispose();
|
||||||
_disposedEvent.Dispose();
|
_disposedEvent.Dispose();
|
||||||
_modSettingChanged.Dispose();
|
_modSettingChanged.Dispose();
|
||||||
|
_pcpCreated.Dispose();
|
||||||
|
_pcpParsed.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
119
Glamourer/Services/PcpService.cs
Normal file
119
Glamourer/Services/PcpService.cs
Normal file
|
|
@ -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<int>() 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>() ?? DateTime.UtcNow);
|
||||||
|
var design = _designManager.CreateClone(designBase,
|
||||||
|
$"{_config.PcpFolder}/{actorIdentifier} - {jObj["Note"]?.ToObject<string>() ?? 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(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,19 @@
|
||||||
"Vortice.DXGI": "3.4.2-beta"
|
"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": {
|
"JetBrains.Annotations": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "2024.3.0",
|
"resolved": "2024.3.0",
|
||||||
|
|
@ -55,6 +68,11 @@
|
||||||
"SharpGen.Runtime": "2.1.2-beta"
|
"SharpGen.Runtime": "2.1.2-beta"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"System.Memory": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.5.5",
|
||||||
|
"contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw=="
|
||||||
|
},
|
||||||
"Vortice.DirectX": {
|
"Vortice.DirectX": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "3.4.2-beta",
|
"resolved": "3.4.2-beta",
|
||||||
|
|
@ -95,6 +113,8 @@
|
||||||
"penumbra.gamedata": {
|
"penumbra.gamedata": {
|
||||||
"type": "Project",
|
"type": "Project",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"FlatSharp.Compiler": "[7.9.0, )",
|
||||||
|
"FlatSharp.Runtime": "[7.9.0, )",
|
||||||
"OtterGui": "[1.0.0, )",
|
"OtterGui": "[1.0.0, )",
|
||||||
"Penumbra.Api": "[5.10.0, )",
|
"Penumbra.Api": "[5.10.0, )",
|
||||||
"Penumbra.String": "[1.0.6, )"
|
"Penumbra.String": "[1.0.6, )"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit c27a06004138f2ec80ccdb494bb6ddf6d39d2165
|
Subproject commit 0a970295b2398683b1e49c46fd613541e2486210
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2f5e901314444238ab3aa6c5043368622bca815a
|
Subproject commit 15e7c8eb41867e6bbd3fe6a8885404df087bc7e7
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
],
|
],
|
||||||
"InternalName": "Glamourer",
|
"InternalName": "Glamourer",
|
||||||
"AssemblyVersion": "1.5.0.7",
|
"AssemblyVersion": "1.5.0.7",
|
||||||
"TestingAssemblyVersion": "1.5.0.7",
|
"TestingAssemblyVersion": "1.5.0.8",
|
||||||
"RepoUrl": "https://github.com/Ottermandias/Glamourer",
|
"RepoUrl": "https://github.com/Ottermandias/Glamourer",
|
||||||
"ApplicableVersion": "any",
|
"ApplicableVersion": "any",
|
||||||
"DalamudApiLevel": 13,
|
"DalamudApiLevel": 13,
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
"LastUpdate": 1618608322,
|
"LastUpdate": 1618608322,
|
||||||
"DownloadLinkInstall": "https://github.com/Ottermandias/Glamourer/releases/download/1.5.0.7/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",
|
"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"
|
"IconUrl": "https://raw.githubusercontent.com/Ottermandias/Glamourer/main/images/icon.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue