diff --git a/Glamourer/GlamourerConfig.cs b/Glamourer/GlamourerConfig.cs index 14f2495..2fa5da4 100644 --- a/Glamourer/GlamourerConfig.cs +++ b/Glamourer/GlamourerConfig.cs @@ -10,9 +10,10 @@ namespace Glamourer public const uint DefaultStateColor = 0xFF00C0C0; public const uint DefaultEquipmentColor = 0xFF00C000; - public bool FoldersFirst { get; set; } = false; - public bool ColorDesigns { get; set; } = true; - public bool ShowLocks { get; set; } = true; + public bool FoldersFirst { get; set; } = false; + public bool ColorDesigns { get; set; } = true; + public bool ShowLocks { get; set; } = true; + public bool AttachToPenumbra { get; set; } = true; public uint CustomizationColor { get; set; } = DefaultCustomizationColor; public uint StateColor { get; set; } = DefaultStateColor; diff --git a/Glamourer/Gui/InterfaceConfig.cs b/Glamourer/Gui/InterfaceConfig.cs index a7de996..9e294a7 100644 --- a/Glamourer/Gui/InterfaceConfig.cs +++ b/Glamourer/Gui/InterfaceConfig.cs @@ -43,6 +43,27 @@ namespace Glamourer.Gui ImGui.SetTooltip(tooltip); } + private void DrawRestorePenumbraButton() + { + const string buttonLabel = "Re-Register Penumbra"; + if (!Glamourer.Config.AttachToPenumbra) + { + using var raii = new ImGuiRaii().PushStyle(ImGuiStyleVar.Alpha, 0.5f); + ImGui.Button(buttonLabel); + return; + } + + if (ImGui.Button(buttonLabel) && _plugin.GetPenumbra()) + { + _plugin.UnregisterFunctions(); + _plugin.RegisterFunctions(); + } + + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "If Penumbra did not register the functions for some reason, pressing this button might help restore functionality."); + } + private void DrawConfigTab() { using var raii = new ImGuiRaii(); @@ -59,6 +80,24 @@ namespace Glamourer.Gui v => cfg.ColorDesigns = v); DrawConfigCheckMark("Show Locks", "Write-protected Designs show a lock besides their name in the selector.", cfg.ShowLocks, v => cfg.ShowLocks = v); + DrawConfigCheckMark("Attach to Penumbra", + "Allows you to right-click items in the Changed Items tab of a mod in Penumbra to apply them to your player character.", + cfg.AttachToPenumbra, + v => + { + cfg.AttachToPenumbra = v; + if (v) + { + if (_plugin.GetPenumbra()) + _plugin.RegisterFunctions(); + } + else + { + _plugin.UnregisterFunctions(); + } + }); + ImGui.SameLine(); + DrawRestorePenumbraButton(); ImGui.Dummy(Vector2.UnitY * ImGui.GetTextLineHeightWithSpacing() / 2); diff --git a/Glamourer/Gui/InterfaceCustomization.cs b/Glamourer/Gui/InterfaceCustomization.cs index 2ce7660..0e56c22 100644 --- a/Glamourer/Gui/InterfaceCustomization.cs +++ b/Glamourer/Gui/InterfaceCustomization.cs @@ -98,7 +98,7 @@ namespace Glamourer.Gui if (InputInt($"##text_{id}", ref current, 1, count)) { customization[id] = set.Data(id, current - 1).Value; - ret = true; + ret = true; } @@ -111,7 +111,7 @@ namespace Glamourer.Gui return ret; customization[id] = newCustom.Value; - ret = true; + ret = true; return ret; } @@ -132,7 +132,7 @@ namespace Glamourer.Gui if (ImGui.Selectable($"{set.Option(id)} #{i + 1}##combo", i == current) && i != current) { customization[id] = (byte) i; - ret = true; + ret = true; } } @@ -143,7 +143,7 @@ namespace Glamourer.Gui if (InputInt($"##text_{id}", ref current, 1, count)) { customization[id] = set.Data(id, current).Value; - ret = true; + ret = true; } ImGui.SameLine(); @@ -198,7 +198,7 @@ namespace Glamourer.Gui if (InputInt($"##{CustomizationId.FacialFeaturesTattoos}", ref value, 1, 256)) { customization[CustomizationId.FacialFeaturesTattoos] = (byte) value; - ret = true; + ret = true; } ImGui.Text(set.Option(CustomizationId.FacialFeaturesTattoos)); @@ -273,13 +273,13 @@ namespace Glamourer.Gui if (InputInt($"##text_{id}", ref current, 1, count)) { customization[id] = set.Data(id, current).Value; - ret = true; + ret = true; } if (DrawIconPickerPopup(popupName, set, id, out var newCustom)) { customization[id] = newCustom.Value; - ret = true; + ret = true; } ImGui.Text(label); @@ -301,7 +301,7 @@ namespace Glamourer.Gui if (ImGui.SliderInt($"##slider_{id}", ref value, 0, count - 1, "") && value != customization[id]) { customization[id] = (byte) value; - ret = true; + ret = true; } ImGui.SameLine(); @@ -309,7 +309,7 @@ namespace Glamourer.Gui if (InputInt($"##input_{id}", ref value, 0, count - 1)) { customization[id] = (byte) (value + 1); - ret = true; + ret = true; } ImGui.SameLine(); @@ -323,15 +323,15 @@ namespace Glamourer.Gui private bool DrawRaceSelector(ref ActorCustomization customization) { using var group = ImGuiRaii.NewGroup(); - var ret = false; + var ret = false; ImGui.SetNextItemWidth(_raceSelectorWidth); if (ImGui.BeginCombo("##subRaceCombo", ClanName(customization.Clan, customization.Gender))) { - for (var i = 0; i < (int)SubRace.Veena; ++i) + for (var i = 0; i < (int) SubRace.Veena; ++i) { - if (ImGui.Selectable(ClanName((SubRace)i + 1, customization.Gender), (int)customization.Clan == i + 1)) + if (ImGui.Selectable(ClanName((SubRace) i + 1, customization.Gender), (int) customization.Clan == i + 1)) { - var race = (SubRace)i + 1; + var race = (SubRace) i + 1; ret |= ChangeRace(ref customization, race); } } @@ -349,18 +349,18 @@ namespace Glamourer.Gui { var ret = false; ImGui.PushFont(UiBuilder.IconFont); - var icon = customization.Gender == Gender.Male ? FontAwesomeIcon.Mars : FontAwesomeIcon.Venus; + var icon = customization.Gender == Gender.Male ? FontAwesomeIcon.Mars : FontAwesomeIcon.Venus; var restricted = false; if (customization.Race == Race.Viera) { ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f); - icon = FontAwesomeIcon.VenusDouble; + icon = FontAwesomeIcon.VenusDouble; restricted = true; } else if (customization.Race == Race.Hrothgar) { ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f); - icon = FontAwesomeIcon.MarsDouble; + icon = FontAwesomeIcon.MarsDouble; restricted = true; } @@ -383,17 +383,19 @@ namespace Glamourer.Gui switch (set.Type(id)) { - case CharaMakeParams.MenuType.ColorPicker: return DrawColorPicker(set.OptionName[(int)id], "", ref customization, id, set); - case CharaMakeParams.MenuType.ListSelector: return DrawListSelector(set.OptionName[(int)id], "", ref customization, id, set); - case CharaMakeParams.MenuType.IconSelector: return DrawIconSelector(set.OptionName[(int)id], "", ref customization, id, set); + case CharaMakeParams.MenuType.ColorPicker: return DrawColorPicker(set.OptionName[(int) id], "", ref customization, id, set); + case CharaMakeParams.MenuType.ListSelector: return DrawListSelector(set.OptionName[(int) id], "", ref customization, id, set); + case CharaMakeParams.MenuType.IconSelector: return DrawIconSelector(set.OptionName[(int) id], "", ref customization, id, set); case CharaMakeParams.MenuType.MultiIconSelector: return DrawMultiSelector(ref customization, set); - case CharaMakeParams.MenuType.Percentage: return DrawPercentageSelector(set.OptionName[(int)id], "", ref customization, id, set); + case CharaMakeParams.MenuType.Percentage: + return DrawPercentageSelector(set.OptionName[(int) id], "", ref customization, id, set); } return false; } - private static readonly CustomizationId[] AllCustomizations = (CustomizationId[])Enum.GetValues(typeof(CustomizationId)); + private static readonly CustomizationId[] AllCustomizations = (CustomizationId[]) Enum.GetValues(typeof(CustomizationId)); + private bool DrawCustomization(ref ActorCustomization custom) { if (!ImGui.CollapsingHeader("Character Customization")) @@ -441,7 +443,7 @@ namespace Glamourer.Gui if (ImGui.Checkbox(set.Option(CustomizationId.HighlightsOnFlag), ref tmp) && tmp != custom.HighlightsOn) { custom.HighlightsOn = tmp; - ret = true; + ret = true; } var xPos = _inputIntSize + _actualIconSize.X + 3 * ImGui.GetStyle().ItemSpacing.X; @@ -451,7 +453,7 @@ namespace Glamourer.Gui && tmp != custom.FacePaintReversed) { custom.FacePaintReversed = tmp; - ret = true; + ret = true; } tmp = custom.SmallIris; @@ -460,7 +462,7 @@ namespace Glamourer.Gui && tmp != custom.SmallIris) { custom.SmallIris = tmp; - ret = true; + ret = true; } if (custom.Race != Race.Hrothgar) @@ -470,7 +472,7 @@ namespace Glamourer.Gui if (ImGui.Checkbox(set.Option(CustomizationId.LipColor), ref tmp) && tmp != custom.Lipstick) { custom.Lipstick = tmp; - ret = true; + ret = true; } } diff --git a/Glamourer/Main.cs b/Glamourer/Main.cs index 8281164..3823fc8 100644 --- a/Glamourer/Main.cs +++ b/Glamourer/Main.cs @@ -75,7 +75,7 @@ namespace Glamourer } } - private void RegisterFunctions() + public void RegisterFunctions() { if (Penumbra == null || !Penumbra.Valid) return; @@ -84,7 +84,7 @@ namespace Glamourer Penumbra!.ChangedItemClicked += PenumbraRightClick; } - private void UnregisterFunctions() + public void UnregisterFunctions() { if (Penumbra == null || !Penumbra.Valid) return; @@ -111,7 +111,7 @@ namespace Glamourer _plugins = pluginsList ?? throw new Exception("Could not obtain Dalamud."); } - private bool GetPenumbra() + public bool GetPenumbra() { if (Penumbra?.Valid ?? false) return true; @@ -123,14 +123,9 @@ namespace Glamourer var penumbra = (IPenumbraApiBase?) plugin?.GetType().GetProperty("Api", BindingFlags.Instance | BindingFlags.Public) ?.GetValue(plugin); if (penumbra != null && penumbra.Valid && penumbra.ApiVersion >= RequiredPenumbraShareVersion) - { Penumbra = (IPenumbraApi) penumbra!; - RegisterFunctions(); - } else - { Penumbra = null; - } return Penumbra != null; } @@ -144,7 +139,8 @@ namespace Glamourer SetDalamud(PluginInterface); SetPlugins(PluginInterface); Designs = new DesignManager(PluginInterface); - GetPenumbra(); + if (GetPenumbra() && Config.AttachToPenumbra) + RegisterFunctions(); PlayerWatcher = PlayerWatchFactory.Create(PluginInterface); PluginInterface.CommandManager.AddHandler("/glamourer", new CommandInfo(OnGlamourer) @@ -181,7 +177,6 @@ namespace Glamourer }; } - public void CopyToClipboard(Actor actor) { var save = new CharacterSave(); @@ -193,7 +188,6 @@ namespace Glamourer { CharacterSave? save = null; if (target.ToLowerInvariant() == "clipboard") - { try { save = CharacterSave.FromString(Clipboard.GetText()); @@ -202,15 +196,10 @@ namespace Glamourer { PluginInterface.Framework.Gui.Chat.PrintError("Clipboard does not contain a valid customization string."); } - } else if (!Designs.FileSystem.Find(target, out var child) || child is not Design d) - { PluginInterface.Framework.Gui.Chat.PrintError("The given path to a saved design does not exist or does not point to a design."); - } else - { save = d.Data; - } save?.Apply(actor); UpdateActors(actor); @@ -280,8 +269,9 @@ namespace Glamourer PluginInterface.Framework.Gui.Chat.Print("Applying requires a name for the save to be applied or 'clipboard'."); return; } + ApplyCommand(actor, split[2]); - + return; } case "save": @@ -291,6 +281,7 @@ namespace Glamourer PluginInterface.Framework.Gui.Chat.Print("Saving requires a name for the save."); return; } + SaveCommand(actor, split[2]); return; }