From 4f7981deaaa948ce33f3432b8faf2290dddff351 Mon Sep 17 00:00:00 2001
From: karashiiro <49822414+karashiiro@users.noreply.github.com>
Date: Wed, 2 Sep 2020 14:05:10 -0700
Subject: [PATCH 1/3] Add cutscenes and gpose to UI hide conditions
---
Dalamud/Interface/DalamudSettingsWindow.cs | 4 ++--
Dalamud/Interface/UiBuilder.cs | 10 ++++++++--
Dalamud/Plugin/DalamudPluginInterface.cs | 2 +-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/Dalamud/Interface/DalamudSettingsWindow.cs b/Dalamud/Interface/DalamudSettingsWindow.cs
index 8876295af..dd13888ae 100644
--- a/Dalamud/Interface/DalamudSettingsWindow.cs
+++ b/Dalamud/Interface/DalamudSettingsWindow.cs
@@ -99,8 +99,8 @@ namespace Dalamud.Interface
ImGui.Dummy(new Vector2(10f, 10f));
- ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is hidden"), ref this.doToggleUiHide);
- ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideHint", "Check this box to hide any open windows by plugins when toggling the game overlay."));
+ ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is hidden and during cutscenes and gpose"), ref this.doToggleUiHide);
+ ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideHint", "Check this box to hide any open windows by plugins when toggling the game overlay, or upon entering gpose or a cutscene."));
ImGui.EndTabItem();
}
diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs
index 10c213bd6..4db7ad81b 100644
--- a/Dalamud/Interface/UiBuilder.cs
+++ b/Dalamud/Interface/UiBuilder.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Dalamud.Game.ClientState;
using Dalamud.Game.Internal.Gui;
using ImGuiNET;
using ImGuiScene;
@@ -38,6 +39,11 @@ namespace Dalamud.Interface
///
public bool DisableAutomaticUiHide { get; set; } = false;
+ private bool CutsceneActive => this.clientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
+ this.clientState.Condition[ConditionFlag.WatchingCutscene] ||
+ this.clientState.Condition[ConditionFlag.WatchingCutscene78];
+
+ private readonly ClientState clientState;
private readonly InterfaceManager interfaceManager;
private readonly GameGui gameGui;
private readonly DalamudConfiguration config;
@@ -56,7 +62,7 @@ namespace Dalamud.Interface
///
/// The interface manager to register on.
/// The plugin namespace.
- internal UiBuilder(InterfaceManager interfaceManager, GameGui gameGui, DalamudConfiguration config, string namespaceName) {
+ internal UiBuilder(InterfaceManager interfaceManager, GameGui gameGui, DalamudConfiguration config, ClientState clientState, string namespaceName) {
this.namespaceName = namespaceName;
this.interfaceManager = interfaceManager;
@@ -130,7 +136,7 @@ namespace Dalamud.Interface
private void OnDraw() {
- if (this.gameGui.GameUiHidden && this.config.ToggleUiHide && !DisableAutomaticUiHide)
+ if ((this.gameGui.GameUiHidden || CutsceneActive) && this.config.ToggleUiHide && !DisableAutomaticUiHide)
return;
ImGui.PushID(this.namespaceName);
diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs
index 6f39c2d2b..71e720c2b 100644
--- a/Dalamud/Plugin/DalamudPluginInterface.cs
+++ b/Dalamud/Plugin/DalamudPluginInterface.cs
@@ -75,7 +75,7 @@ namespace Dalamud.Plugin
this.CommandManager = dalamud.CommandManager;
this.Framework = dalamud.Framework;
this.ClientState = dalamud.ClientState;
- this.UiBuilder = new UiBuilder(dalamud.InterfaceManager, dalamud.Framework.Gui, dalamud.Configuration, pluginName);
+ this.UiBuilder = new UiBuilder(dalamud.InterfaceManager, dalamud.Framework.Gui, dalamud.Configuration, dalamud.ClientState, pluginName);
this.TargetModuleScanner = dalamud.SigScanner;
this.Data = dalamud.Data;
this.SeStringManager = dalamud.SeStringManager;
From ef7570542178d91c249a237e271870932f9cb1af Mon Sep 17 00:00:00 2001
From: karashiiro <49822414+karashiiro@users.noreply.github.com>
Date: Wed, 2 Sep 2020 14:07:34 -0700
Subject: [PATCH 2/3] Rename variable
---
Dalamud/Interface/UiBuilder.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs
index 4db7ad81b..1857bf91d 100644
--- a/Dalamud/Interface/UiBuilder.cs
+++ b/Dalamud/Interface/UiBuilder.cs
@@ -39,9 +39,9 @@ namespace Dalamud.Interface
///
public bool DisableAutomaticUiHide { get; set; } = false;
- private bool CutsceneActive => this.clientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
- this.clientState.Condition[ConditionFlag.WatchingCutscene] ||
- this.clientState.Condition[ConditionFlag.WatchingCutscene78];
+ private bool CutsceneOrGposeActive => this.clientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
+ this.clientState.Condition[ConditionFlag.WatchingCutscene] ||
+ this.clientState.Condition[ConditionFlag.WatchingCutscene78];
private readonly ClientState clientState;
private readonly InterfaceManager interfaceManager;
@@ -136,7 +136,7 @@ namespace Dalamud.Interface
private void OnDraw() {
- if ((this.gameGui.GameUiHidden || CutsceneActive) && this.config.ToggleUiHide && !DisableAutomaticUiHide)
+ if ((this.gameGui.GameUiHidden || CutsceneOrGposeActive) && this.config.ToggleUiHide && !DisableAutomaticUiHide)
return;
ImGui.PushID(this.namespaceName);
From d4a669a33e121bebb14e3321c85759d8f971188d Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Mon, 7 Sep 2020 15:35:28 +0200
Subject: [PATCH 3/3] fix: NullRef when ClientState is null
---
Dalamud/Interface/UiBuilder.cs | 36 +++++++++++++++-------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs
index 1857bf91d..5cb58dc64 100644
--- a/Dalamud/Interface/UiBuilder.cs
+++ b/Dalamud/Interface/UiBuilder.cs
@@ -39,14 +39,12 @@ namespace Dalamud.Interface
///
public bool DisableAutomaticUiHide { get; set; } = false;
- private bool CutsceneOrGposeActive => this.clientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
- this.clientState.Condition[ConditionFlag.WatchingCutscene] ||
- this.clientState.Condition[ConditionFlag.WatchingCutscene78];
+ private bool CutsceneOrGposeActive => this.dalamud.ClientState != null && this.dalamud.ClientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
+ this.dalamud.ClientState.Condition[ConditionFlag.WatchingCutscene] ||
+ this.dalamud.ClientState.Condition[ConditionFlag.WatchingCutscene78];
+
+ private Dalamud dalamud;
- private readonly ClientState clientState;
- private readonly InterfaceManager interfaceManager;
- private readonly GameGui gameGui;
- private readonly DalamudConfiguration config;
#if DEBUG
internal static bool DoStats { get; set; } = true;
#else
@@ -62,13 +60,11 @@ namespace Dalamud.Interface
///
/// The interface manager to register on.
/// The plugin namespace.
- internal UiBuilder(InterfaceManager interfaceManager, GameGui gameGui, DalamudConfiguration config, ClientState clientState, string namespaceName) {
+ internal UiBuilder(Dalamud dalamud, string namespaceName) {
this.namespaceName = namespaceName;
- this.interfaceManager = interfaceManager;
- this.gameGui = gameGui;
- this.config = config;
- this.interfaceManager.OnDraw += OnDraw;
+ this.dalamud = dalamud;
+ this.dalamud.InterfaceManager.OnDraw += OnDraw;
this.stopwatch = new System.Diagnostics.Stopwatch();
}
@@ -76,7 +72,7 @@ namespace Dalamud.Interface
/// Unregister the UiBuilder. Do not call this in plugin code.
///
public void Dispose() {
- this.interfaceManager.OnDraw -= OnDraw;
+ this.dalamud.InterfaceManager.OnDraw -= OnDraw;
}
///
@@ -85,7 +81,7 @@ namespace Dalamud.Interface
/// The full filepath to the image.
/// A object wrapping the created image. Use inside ImGui.Image()
public TextureWrap LoadImage(string filePath) =>
- this.interfaceManager.LoadImage(filePath);
+ this.dalamud.InterfaceManager.LoadImage(filePath);
///
/// Loads an image from a byte stream, such as a png downloaded into memory.
@@ -93,7 +89,7 @@ namespace Dalamud.Interface
/// A byte array containing the raw image data.
/// A object wrapping the created image. Use inside ImGui.Image()
public TextureWrap LoadImage(byte[] imageData) =>
- this.interfaceManager.LoadImage(imageData);
+ this.dalamud.InterfaceManager.LoadImage(imageData);
///
/// Loads an image from raw unformatted pixel data, with no type or header information. To load formatted data, use .
@@ -104,7 +100,7 @@ namespace Dalamud.Interface
/// The number of channels (bytes per pixel) of the image contained in . This should usually be 4.
/// A object wrapping the created image. Use inside ImGui.Image()
public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels) =>
- this.interfaceManager.LoadImageRaw(imageData, width, height, numChannels);
+ this.dalamud.InterfaceManager.LoadImageRaw(imageData, width, height, numChannels);
///
/// An event that is called any time ImGui fonts need to be rebuilt.
@@ -115,8 +111,8 @@ namespace Dalamud.Interface
///
public Action OnBuildFonts
{
- get { return this.interfaceManager.OnBuildFonts; }
- set { this.interfaceManager.OnBuildFonts = value; }
+ get { return this.dalamud.InterfaceManager.OnBuildFonts; }
+ set { this.dalamud.InterfaceManager.OnBuildFonts = value; }
}
///
@@ -125,7 +121,7 @@ namespace Dalamud.Interface
/// ready to be used on the next UI frame.
///
public void RebuildFonts() =>
- this.interfaceManager.RebuildFonts();
+ this.dalamud.InterfaceManager.RebuildFonts();
///
/// Event that is fired when the plugin should open its configuration interface.
@@ -136,7 +132,7 @@ namespace Dalamud.Interface
private void OnDraw() {
- if ((this.gameGui.GameUiHidden || CutsceneOrGposeActive) && this.config.ToggleUiHide && !DisableAutomaticUiHide)
+ if ((this.dalamud.Framework.Gui.GameUiHidden || CutsceneOrGposeActive) && this.dalamud.Configuration.ToggleUiHide && !DisableAutomaticUiHide)
return;
ImGui.PushID(this.namespaceName);