fix: only allow pinning/clickthrough if the window is within the main viewport

This commit is contained in:
goat 2023-11-07 19:27:45 +01:00
parent f10a597566
commit c03d6ff048
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 30 additions and 6 deletions

View file

@ -25,6 +25,13 @@ public static class ImGuiHelpers
/// </summary> /// </summary>
public static float GlobalScale { get; private set; } public static float GlobalScale { get; private set; }
/// <summary>
/// Check if the current ImGui window is on the main viewport.
/// Only valid within a window.
/// </summary>
/// <returns>Whether the window is on the main viewport.</returns>
public static bool CheckIsWindowOnMainViewport() => MainViewport.ID == ImGui.GetWindowViewport().ID;
/// <summary> /// <summary>
/// Gets a <see cref="Vector2"/> that is pre-scaled with the <see cref="GlobalScale"/> multiplier. /// Gets a <see cref="Vector2"/> that is pre-scaled with the <see cref="GlobalScale"/> multiplier.
/// </summary> /// </summary>

View file

@ -362,6 +362,11 @@ public abstract class Window
if (ImGui.BeginPopup(additionsPopupName, ImGuiWindowFlags.NoMove)) if (ImGui.BeginPopup(additionsPopupName, ImGuiWindowFlags.NoMove))
{ {
var isAvailable = ImGuiHelpers.CheckIsWindowOnMainViewport();
if (!isAvailable)
ImGui.BeginDisabled();
if (this.internalIsClickthrough) if (this.internalIsClickthrough)
ImGui.BeginDisabled(); ImGui.BeginDisabled();
@ -391,13 +396,25 @@ public abstract class Window
this.internalAlpha = null; this.internalAlpha = null;
} }
ImGui.TextColored(ImGuiColors.DalamudGrey, if (isAvailable)
Loc.Localize("WindowSystemContextActionClickthroughDisclaimer", {
"Open this menu again to disable clickthrough.")); ImGui.TextColored(ImGuiColors.DalamudGrey,
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("WindowSystemContextActionClickthroughDisclaimer",
Loc.Localize("WindowSystemContextActionDisclaimer", "Open this menu again to disable clickthrough."));
"These options may not work for all plugins at the moment.")); ImGui.TextColored(ImGuiColors.DalamudGrey,
Loc.Localize("WindowSystemContextActionDisclaimer",
"These options may not work for all plugins at the moment."));
}
else
{
ImGui.TextColored(ImGuiColors.DalamudGrey,
Loc.Localize("WindowSystemContextActionViewportDisclaimer",
"These features are only available if this window is inside the game window."));
}
if (!isAvailable)
ImGui.EndDisabled();
ImGui.EndPopup(); ImGui.EndPopup();
} }