feat: allow hiding

This commit is contained in:
Anna 2022-02-01 00:20:20 -05:00
parent 326ef5430c
commit 60e22f58ee
5 changed files with 81 additions and 4 deletions

View File

@ -8,6 +8,7 @@ internal class Configuration : IPluginConfiguration {
public int Version { get; set; } = 1;
public bool HideChat = true;
public bool HideDuringCutscenes = true;
public bool NativeItemTooltips = true;
public bool PrettierTimestamps = true;
public bool MoreCompactPretty;

View File

@ -1,6 +1,7 @@
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Party;
@ -28,6 +29,9 @@ public sealed class Plugin : IDalamudPlugin {
[PluginService]
internal CommandManager CommandManager { get; init; }
[PluginService]
internal Condition Condition { get; init; }
[PluginService]
internal DataManager DataManager { get; init; }

View File

@ -88,10 +88,16 @@ internal sealed class PluginUi : IDisposable {
gameSym.Length
);
this.Plugin.Interface.UiBuilder.BuildFonts += this.BuildFonts;
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
var uiBuilder = this.Plugin.Interface.UiBuilder;
uiBuilder.DisableAutomaticUiHide = true;
uiBuilder.DisableCutsceneUiHide = true;
uiBuilder.DisableGposeUiHide = true;
uiBuilder.DisableUserUiHide = true;
this.Plugin.Interface.UiBuilder.RebuildFonts();
uiBuilder.BuildFonts += this.BuildFonts;
uiBuilder.Draw += this.Draw;
uiBuilder.RebuildFonts();
}
public void Dispose() {

View File

@ -3,6 +3,7 @@ using System.Numerics;
using ChatTwo.Code;
using ChatTwo.GameFunctions.Types;
using ChatTwo.Util;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Command;
using Dalamud.Game.Text.SeStringHandling;
@ -237,7 +238,55 @@ internal sealed class ChatLog : IUiComponent {
}
}
private bool CutsceneActive {
get {
var condition = this.Ui.Plugin.Condition;
return condition[ConditionFlag.OccupiedInCutSceneEvent]
|| condition[ConditionFlag.WatchingCutscene78];
}
}
private bool GposeActive {
get {
var condition = this.Ui.Plugin.Condition;
return condition[ConditionFlag.WatchingCutscene];
}
}
private enum HideState {
None,
Cutscene,
CutsceneOverride,
User,
}
private HideState _hideState = HideState.None;
public unsafe void Draw() {
// if the chat has no hide state and in a cutscene, set the hide state to cutscene
if (this.Ui.Plugin.Config.HideDuringCutscenes && this._hideState == HideState.None && (this.CutsceneActive || this.GposeActive)) {
this._hideState = HideState.Cutscene;
}
// if the chat is hidden because of a cutscene and no longer in a cutscene, set the hide state to none
if (this._hideState is HideState.Cutscene or HideState.CutsceneOverride && !this.CutsceneActive && !this.GposeActive) {
this._hideState = HideState.None;
}
// if the chat is hidden because of a cutscene and the chat has been activated, show chat
if (this._hideState == HideState.Cutscene && this.Activate) {
this._hideState = HideState.CutsceneOverride;
}
// if the user hid the chat and is now activating chat, reset the hide state
if (this._hideState == HideState.User && this.Activate) {
this._hideState = HideState.None;
}
if (this._hideState is HideState.Cutscene or HideState.User) {
return;
}
var flags = ImGuiWindowFlags.None;
if (!this.Ui.Plugin.Config.CanMove) {
flags |= ImGuiWindowFlags.NoMove;
@ -360,6 +409,8 @@ internal sealed class ChatLog : IUiComponent {
}
}
var normalColour = *ImGui.GetStyleColorVec4(ImGuiCol.Text);
var inputColour = this.Ui.Plugin.Config.ChatColours.TryGetValue(inputType, out var inputCol)
? inputCol
: inputType.DefaultColour();
@ -422,6 +473,20 @@ internal sealed class ChatLog : IUiComponent {
this._tempChannel = null;
}
if (ImGui.BeginPopupContextItem()) {
ImGui.PushStyleColor(ImGuiCol.Text, normalColour);
try {
if (ImGui.Selectable("Hide chat")) {
this._hideState = HideState.User;
}
} finally {
ImGui.PopStyleColor();
}
ImGui.EndPopup();
}
if (inputColour != null) {
ImGui.PopStyleColor();
}

View File

@ -12,7 +12,8 @@ internal sealed class Display : ISettingsTab {
}
public void Draw() {
ImGui.Checkbox("Hide chat", ref this.Mutable.HideChat);
ImGui.Checkbox("Hide vanilla chat", ref this.Mutable.HideChat);
ImGui.Checkbox("Hide chat during cutscenes", ref this.Mutable.HideDuringCutscenes);
ImGui.Checkbox("Show native item tooltips", ref this.Mutable.NativeItemTooltips);
ImGui.Checkbox("Show tabs in a sidebar", ref this.Mutable.SidebarTabView);
ImGui.Checkbox("Use modern timestamp layout", ref this.Mutable.PrettierTimestamps);