diff --git a/Glamaholic/Plugin.cs b/Glamaholic/Plugin.cs index 7f1bfd7..c79de19 100755 --- a/Glamaholic/Plugin.cs +++ b/Glamaholic/Plugin.cs @@ -8,7 +8,8 @@ using Dalamud.Plugin; namespace Glamaholic { // ReSharper disable once ClassNeverInstantiated.Global public class Plugin : IDalamudPlugin { - public string Name => "Glamaholic"; + internal const string PluginName = "Glamaholic"; + public string Name => PluginName; [PluginService] internal DalamudPluginInterface Interface { get; init; } diff --git a/Glamaholic/Ui/Helpers/EditorHelper.cs b/Glamaholic/Ui/Helpers/EditorHelper.cs index 510cdb8..f91071c 100755 --- a/Glamaholic/Ui/Helpers/EditorHelper.cs +++ b/Glamaholic/Ui/Helpers/EditorHelper.cs @@ -1,5 +1,4 @@ -using Dalamud.Interface; -using FFXIVClientStructs.FFXIV.Component.GUI; +using FFXIVClientStructs.FFXIV.Component.GUI; using ImGuiNET; namespace Glamaholic.Ui.Helpers { @@ -28,13 +27,15 @@ namespace Glamaholic.Ui.Helpers { return; } - ImGui.SetNextWindowPos(drawPos.Value); - if (!ImGui.Begin("##glamaholic-helper-open", HelperUtil.HelperWindowFlags)) { - ImGui.End(); - return; + using (new HelperUtil.HelperStyles()) { + ImGui.SetNextWindowPos(drawPos.Value, ImGuiCond.Appearing); + if (!ImGui.Begin("##glamaholic-helper-open", HelperUtil.HelperWindowFlags)) { + ImGui.End(); + return; + } } - ImGui.SetNextItemWidth(ImGui.CalcTextSize(this.Ui.Plugin.Name).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + 32 * ImGuiHelpers.GlobalScale); + ImGui.SetNextItemWidth(HelperUtil.DropdownWidth()); if (ImGui.BeginCombo("##glamaholic-helper-examine-combo", this.Ui.Plugin.Name)) { if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) { this.Ui.OpenMainInterface(); @@ -42,6 +43,8 @@ namespace Glamaholic.Ui.Helpers { ImGui.EndCombo(); } + + ImGui.SetNextWindowPos(drawPos.Value); ImGui.End(); } diff --git a/Glamaholic/Ui/Helpers/ExamineHelper.cs b/Glamaholic/Ui/Helpers/ExamineHelper.cs index b84be66..76a4e4d 100755 --- a/Glamaholic/Ui/Helpers/ExamineHelper.cs +++ b/Glamaholic/Ui/Helpers/ExamineHelper.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Dalamud.Interface; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Component.GUI; using ImGuiNET; @@ -30,13 +29,16 @@ namespace Glamaholic.Ui.Helpers { return; } - ImGui.SetNextWindowPos(drawPos.Value); - if (!ImGui.Begin("##glamaholic-helper-examine", HelperUtil.HelperWindowFlags)) { - ImGui.End(); - return; + using (new HelperUtil.HelperStyles()) { + // get first frame + ImGui.SetNextWindowPos(drawPos.Value, ImGuiCond.Appearing); + if (!ImGui.Begin("##glamaholic-helper-examine", HelperUtil.HelperWindowFlags)) { + ImGui.End(); + return; + } } - ImGui.SetNextItemWidth(ImGui.CalcTextSize(this.Ui.Plugin.Name).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + 32 * ImGuiHelpers.GlobalScale); + ImGui.SetNextItemWidth(HelperUtil.DropdownWidth()); if (ImGui.BeginCombo("##glamaholic-helper-examine-combo", this.Ui.Plugin.Name)) { if (ImGui.Selectable("Create glamour plate")) { this.CopyToGlamourPlate(); @@ -52,6 +54,8 @@ namespace Glamaholic.Ui.Helpers { ImGui.EndCombo(); } + ImGui.SetWindowPos(drawPos.Value); + ImGui.End(); } diff --git a/Glamaholic/Ui/Helpers/HelperUtil.cs b/Glamaholic/Ui/Helpers/HelperUtil.cs index 7063fdb..264234d 100755 --- a/Glamaholic/Ui/Helpers/HelperUtil.cs +++ b/Glamaholic/Ui/Helpers/HelperUtil.cs @@ -1,4 +1,6 @@ -using System.Numerics; +using System; +using System.Numerics; +using Dalamud.Interface; using FFXIVClientStructs.FFXIV.Component.GUI; using ImGuiNET; @@ -15,9 +17,10 @@ namespace Glamaholic.Ui.Helpers { | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoFocusOnAppearing - | ImGuiWindowFlags.AlwaysAutoResize; + | ImGuiWindowFlags.AlwaysAutoResize + | ImGuiWindowFlags.NoDocking; - internal static unsafe Vector2? DrawPosForAddon(AtkUnitBase* addon) { + internal static unsafe Vector2? DrawPosForAddon(AtkUnitBase* addon, bool right = false) { if (addon == null) { return null; } @@ -27,10 +30,32 @@ namespace Glamaholic.Ui.Helpers { return null; } - return new Vector2(addon->X, addon->Y) - - new Vector2(0, ImGui.CalcTextSize("A").Y) - - new Vector2(0, ImGui.GetStyle().ItemInnerSpacing.Y * 2) - - new Vector2(0, ImGui.GetStyle().CellPadding.Y * 2); + var xModifier = right + ? root->Width - DropdownWidth() + : 0; + + return ImGuiHelpers.MainViewport.Pos + + new Vector2(addon->X, addon->Y) + + Vector2.UnitX * xModifier + - Vector2.UnitY * ImGui.CalcTextSize("A") + - Vector2.UnitY * (ImGui.GetStyle().FramePadding.Y + ImGui.GetStyle().FrameBorderSize); + } + + internal static float DropdownWidth() { + // arrow size is GetFrameHeight + return (ImGui.CalcTextSize(Plugin.PluginName).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + ImGui.GetFrameHeight()) * ImGuiHelpers.GlobalScale; + } + + internal class HelperStyles : IDisposable { + internal HelperStyles() { + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); + ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0); + ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, Vector2.Zero); + } + + public void Dispose() { + ImGui.PopStyleVar(3); + } } } }