mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-24 01:19:18 +01:00
feat: add MainViewport to ImGuiHelpers instead
This commit is contained in:
parent
c21e7efab7
commit
303ddf8d27
2 changed files with 7 additions and 17 deletions
|
|
@ -9,7 +9,10 @@ namespace Dalamud.Interface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ImGuiHelpers
|
public static class ImGuiHelpers
|
||||||
{
|
{
|
||||||
private static uint mainViewportId;
|
/// <summary>
|
||||||
|
/// Gets the main viewport.
|
||||||
|
/// </summary>
|
||||||
|
public static ImGuiViewportPtr MainViewport { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the global Dalamud scale.
|
/// Gets the global Dalamud scale.
|
||||||
|
|
@ -19,21 +22,7 @@ namespace Dalamud.Interface
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Force this ImGui window to stay inside the main game window.
|
/// Force this ImGui window to stay inside the main game window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ForceMainWindow() => ImGui.SetNextWindowViewport(GetMainViewportId());
|
public static void ForceMainWindow() => ImGui.SetNextWindowViewport(MainViewport.ID);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the ID of the main game window viewport.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The ID of the main game window viewport.</returns>
|
|
||||||
public static uint GetMainViewportId()
|
|
||||||
{
|
|
||||||
if (mainViewportId == 0)
|
|
||||||
mainViewportId = ImGui.GetMainViewport().ID;
|
|
||||||
|
|
||||||
return mainViewportId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector2 MainWindowPos { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a dummy scaled by the global Dalamud scale.
|
/// Create a dummy scaled by the global Dalamud scale.
|
||||||
|
|
@ -55,7 +44,6 @@ namespace Dalamud.Interface
|
||||||
internal static void NewFrame()
|
internal static void NewFrame()
|
||||||
{
|
{
|
||||||
GlobalScale = ImGui.GetIO().FontGlobalScale;
|
GlobalScale = ImGui.GetIO().FontGlobalScale;
|
||||||
MainWindowPos = ImGui.GetMainViewport().Pos;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,8 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale;
|
ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale;
|
||||||
ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.DockingEnable;
|
ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.DockingEnable;
|
||||||
|
|
||||||
|
ImGuiHelpers.MainViewport = ImGui.GetMainViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process information needed by ImGuiHelpers each frame.
|
// Process information needed by ImGuiHelpers each frame.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue