feat: add config setting to toggle hiding

This commit is contained in:
goat 2020-08-14 03:01:58 +02:00
parent 5f9efaaea0
commit 196217f1d5
5 changed files with 18 additions and 14 deletions

View file

@ -42,6 +42,7 @@ namespace Dalamud
public bool DoDalamudTest { get; set; } = false; public bool DoDalamudTest { get; set; } = false;
public float GlobalUiScale { get; set; } = 1.0f; public float GlobalUiScale { get; set; } = 1.0f;
public bool ToggleUiHide { get; set; } = true;
[JsonIgnore] [JsonIgnore]
public string ConfigPath; public string ConfigPath;

View file

@ -374,6 +374,9 @@ namespace Dalamud {
ImGui.EndMenu(); ImGui.EndMenu();
} }
if (this.Framework.Gui.GameUiHidden)
ImGui.BeginMenu("UI is hidden...", false);
ImGui.EndMainMenuBar(); ImGui.EndMainMenuBar();
} }
} }

View file

@ -1,23 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq; using System.Linq;
using System.Net.Mime;
using System.Numerics; using System.Numerics;
using CheapLoc; using CheapLoc;
using Dalamud.Game.Chat; using Dalamud.Game.Chat;
using Dalamud.Game.ClientState.Actors.Types;
using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
using Dalamud.Plugin;
using ImGuiNET; using ImGuiNET;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Serilog;
using SharpDX.Direct3D11;
namespace Dalamud.Interface namespace Dalamud.Interface
{ {
class DalamudSettingsWindow { internal class DalamudSettingsWindow {
private readonly Dalamud dalamud; private readonly Dalamud dalamud;
public DalamudSettingsWindow(Dalamud dalamud) { public DalamudSettingsWindow(Dalamud dalamud) {
@ -30,6 +20,7 @@ namespace Dalamud.Interface
this.doCfChatMessage = this.dalamud.Configuration.DutyFinderChatMessage; this.doCfChatMessage = this.dalamud.Configuration.DutyFinderChatMessage;
this.globalUiScale = this.dalamud.Configuration.GlobalUiScale; this.globalUiScale = this.dalamud.Configuration.GlobalUiScale;
this.doToggleUiHide = this.dalamud.Configuration.ToggleUiHide;
this.doPluginTest = this.dalamud.Configuration.DoPluginTest; this.doPluginTest = this.dalamud.Configuration.DoPluginTest;
this.doDalamudTest = this.dalamud.Configuration.DoDalamudTest; this.doDalamudTest = this.dalamud.Configuration.DoDalamudTest;
@ -53,6 +44,7 @@ namespace Dalamud.Interface
private const float MinScale = 0.3f; private const float MinScale = 0.3f;
private const float MaxScale = 2.0f; private const float MaxScale = 2.0f;
private float globalUiScale; private float globalUiScale;
private bool doToggleUiHide;
#region Experimental #region Experimental
@ -105,6 +97,11 @@ namespace Dalamud.Interface
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale all XIVLauncher UI elements - useful for 4K displays.")); ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale all XIVLauncher UI elements - useful for 4K displays."));
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.EndTabItem(); ImGui.EndTabItem();
} }
@ -152,6 +149,7 @@ namespace Dalamud.Interface
this.dalamud.Configuration.DutyFinderChatMessage = this.doCfChatMessage; this.dalamud.Configuration.DutyFinderChatMessage = this.doCfChatMessage;
this.dalamud.Configuration.GlobalUiScale = this.globalUiScale; this.dalamud.Configuration.GlobalUiScale = this.globalUiScale;
this.dalamud.Configuration.ToggleUiHide = this.doToggleUiHide;
this.dalamud.Configuration.DoPluginTest = this.doPluginTest; this.dalamud.Configuration.DoPluginTest = this.doPluginTest;
this.dalamud.Configuration.DoDalamudTest = this.doDalamudTest; this.dalamud.Configuration.DoDalamudTest = this.doDalamudTest;

View file

@ -40,6 +40,7 @@ namespace Dalamud.Interface
private readonly InterfaceManager interfaceManager; private readonly InterfaceManager interfaceManager;
private readonly GameGui gameGui; 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
@ -55,11 +56,12 @@ 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, string namespaceName) { internal UiBuilder(InterfaceManager interfaceManager, GameGui gameGui, DalamudConfiguration config, string namespaceName) {
this.namespaceName = namespaceName; this.namespaceName = namespaceName;
this.interfaceManager = interfaceManager; this.interfaceManager = interfaceManager;
this.gameGui = gameGui; this.gameGui = gameGui;
this.config = config;
this.interfaceManager.OnDraw += OnDraw; this.interfaceManager.OnDraw += OnDraw;
this.stopwatch = new System.Diagnostics.Stopwatch(); this.stopwatch = new System.Diagnostics.Stopwatch();
} }
@ -128,7 +130,7 @@ namespace Dalamud.Interface
private void OnDraw() { private void OnDraw() {
if (this.gameGui.GameUiHidden && !DisableAutomaticUiHide) if (this.gameGui.GameUiHidden && this.config.ToggleUiHide && !DisableAutomaticUiHide)
return; return;
ImGui.PushID(this.namespaceName); ImGui.PushID(this.namespaceName);

View file

@ -75,7 +75,7 @@ namespace Dalamud.Plugin
this.CommandManager = dalamud.CommandManager; this.CommandManager = dalamud.CommandManager;
this.Framework = dalamud.Framework; this.Framework = dalamud.Framework;
this.ClientState = dalamud.ClientState; this.ClientState = dalamud.ClientState;
this.UiBuilder = new UiBuilder(dalamud.InterfaceManager, dalamud.Framework.Gui, pluginName); this.UiBuilder = new UiBuilder(dalamud.InterfaceManager, dalamud.Framework.Gui, dalamud.Configuration, pluginName);
this.TargetModuleScanner = dalamud.SigScanner; this.TargetModuleScanner = dalamud.SigScanner;
this.Data = dalamud.Data; this.Data = dalamud.Data;
this.SeStringManager = dalamud.SeStringManager; this.SeStringManager = dalamud.SeStringManager;