mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-20 07:34:17 +01:00
fix: NullRef when ClientState is null
This commit is contained in:
parent
144cc2d356
commit
d4a669a33e
1 changed files with 16 additions and 20 deletions
|
|
@ -39,14 +39,12 @@ namespace Dalamud.Interface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool DisableAutomaticUiHide { get; set; } = false;
|
public bool DisableAutomaticUiHide { get; set; } = false;
|
||||||
|
|
||||||
private bool CutsceneOrGposeActive => this.clientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
|
private bool CutsceneOrGposeActive => this.dalamud.ClientState != null && this.dalamud.ClientState.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
|
||||||
this.clientState.Condition[ConditionFlag.WatchingCutscene] ||
|
this.dalamud.ClientState.Condition[ConditionFlag.WatchingCutscene] ||
|
||||||
this.clientState.Condition[ConditionFlag.WatchingCutscene78];
|
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
|
#if DEBUG
|
||||||
internal static bool DoStats { get; set; } = true;
|
internal static bool DoStats { get; set; } = true;
|
||||||
#else
|
#else
|
||||||
|
|
@ -62,13 +60,11 @@ namespace Dalamud.Interface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="interfaceManager">The interface manager to register on.</param>
|
/// <param name="interfaceManager">The interface manager to register on.</param>
|
||||||
/// <param name="namespaceName">The plugin namespace.</param>
|
/// <param name="namespaceName">The plugin namespace.</param>
|
||||||
internal UiBuilder(InterfaceManager interfaceManager, GameGui gameGui, DalamudConfiguration config, ClientState clientState, string namespaceName) {
|
internal UiBuilder(Dalamud dalamud, string namespaceName) {
|
||||||
this.namespaceName = namespaceName;
|
this.namespaceName = namespaceName;
|
||||||
|
|
||||||
this.interfaceManager = interfaceManager;
|
this.dalamud = dalamud;
|
||||||
this.gameGui = gameGui;
|
this.dalamud.InterfaceManager.OnDraw += OnDraw;
|
||||||
this.config = config;
|
|
||||||
this.interfaceManager.OnDraw += OnDraw;
|
|
||||||
this.stopwatch = new System.Diagnostics.Stopwatch();
|
this.stopwatch = new System.Diagnostics.Stopwatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +72,7 @@ namespace Dalamud.Interface
|
||||||
/// Unregister the UiBuilder. Do not call this in plugin code.
|
/// Unregister the UiBuilder. Do not call this in plugin code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.interfaceManager.OnDraw -= OnDraw;
|
this.dalamud.InterfaceManager.OnDraw -= OnDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -85,7 +81,7 @@ namespace Dalamud.Interface
|
||||||
/// <param name="filePath">The full filepath to the image.</param>
|
/// <param name="filePath">The full filepath to the image.</param>
|
||||||
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
||||||
public TextureWrap LoadImage(string filePath) =>
|
public TextureWrap LoadImage(string filePath) =>
|
||||||
this.interfaceManager.LoadImage(filePath);
|
this.dalamud.InterfaceManager.LoadImage(filePath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads an image from a byte stream, such as a png downloaded into memory.
|
/// Loads an image from a byte stream, such as a png downloaded into memory.
|
||||||
|
|
@ -93,7 +89,7 @@ namespace Dalamud.Interface
|
||||||
/// <param name="imageData">A byte array containing the raw image data.</param>
|
/// <param name="imageData">A byte array containing the raw image data.</param>
|
||||||
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
||||||
public TextureWrap LoadImage(byte[] imageData) =>
|
public TextureWrap LoadImage(byte[] imageData) =>
|
||||||
this.interfaceManager.LoadImage(imageData);
|
this.dalamud.InterfaceManager.LoadImage(imageData);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads an image from raw unformatted pixel data, with no type or header information. To load formatted data, use <see cref="LoadImage(byte[])"/>.
|
/// Loads an image from raw unformatted pixel data, with no type or header information. To load formatted data, use <see cref="LoadImage(byte[])"/>.
|
||||||
|
|
@ -104,7 +100,7 @@ namespace Dalamud.Interface
|
||||||
/// <param name="numChannels">The number of channels (bytes per pixel) of the image contained in <paramref name="imageData"/>. This should usually be 4.</param>
|
/// <param name="numChannels">The number of channels (bytes per pixel) of the image contained in <paramref name="imageData"/>. This should usually be 4.</param>
|
||||||
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
||||||
public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels) =>
|
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);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event that is called any time ImGui fonts need to be rebuilt.<br/>
|
/// An event that is called any time ImGui fonts need to be rebuilt.<br/>
|
||||||
|
|
@ -115,8 +111,8 @@ namespace Dalamud.Interface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action OnBuildFonts
|
public Action OnBuildFonts
|
||||||
{
|
{
|
||||||
get { return this.interfaceManager.OnBuildFonts; }
|
get { return this.dalamud.InterfaceManager.OnBuildFonts; }
|
||||||
set { this.interfaceManager.OnBuildFonts = value; }
|
set { this.dalamud.InterfaceManager.OnBuildFonts = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -125,7 +121,7 @@ namespace Dalamud.Interface
|
||||||
/// ready to be used on the next UI frame.
|
/// ready to be used on the next UI frame.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RebuildFonts() =>
|
public void RebuildFonts() =>
|
||||||
this.interfaceManager.RebuildFonts();
|
this.dalamud.InterfaceManager.RebuildFonts();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that is fired when the plugin should open its configuration interface.
|
/// Event that is fired when the plugin should open its configuration interface.
|
||||||
|
|
@ -136,7 +132,7 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
private void OnDraw() {
|
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;
|
return;
|
||||||
|
|
||||||
ImGui.PushID(this.namespaceName);
|
ImGui.PushID(this.namespaceName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue