feat(window): restore hide-chat-window + Enter-to-restore (1.5.6)

The eye/hide button now hides the HellionChat window (runtime-only, via a new
DrawConditions gate) instead of toggling native-chat suppression, matching 1.5.6.
The chat-activation keybind (Enter / "/"), whose dispatch was a dead stub in the
KeybindManager since the v1.6.0 rewrite, is re-wired to MainWindow.ActivateChat:
it un-hides, opens if closed, brings the window to front and focuses the input --
so the chat reacts to Enter again from any state. /hellion is a reliable one-press
recovery (Toggle now clears the hide), and the window always shows on login
(start state no longer read from the persisted flag). Adds HideRestoreSelfTestStep.
This commit is contained in:
2026-06-15 20:49:14 +02:00
parent b397591ba4
commit a73f4d0d0c
7 changed files with 124 additions and 19 deletions
+12 -10
View File
@@ -45,6 +45,9 @@ internal sealed class InputBar
// pop-out would be confusing). The main window's InputBar gets the instance.
private readonly ThemeQuickPicker? _themeQuickPicker;
// Null in pop-outs (those have their own close button). Hides the main window.
private readonly Action? _onHideWindow;
private string _pendingMessage = string.Empty;
private bool _isFocused;
private bool _wasInputTextHovered;
@@ -81,7 +84,8 @@ internal sealed class InputBar
ILogger<InputBar> logger,
Action onOpenSettings,
CommandHelpWindow commandHelpWindow,
ThemeQuickPicker? themeQuickPicker = null
ThemeQuickPicker? themeQuickPicker = null,
Action? onHideWindow = null
)
{
_symbolPicker = symbolPicker;
@@ -92,6 +96,7 @@ internal sealed class InputBar
_onOpenSettings = onOpenSettings;
_commandHelpWindow = commandHelpWindow;
_themeQuickPicker = themeQuickPicker;
_onHideWindow = onHideWindow;
}
public string PendingMessage => _pendingMessage;
@@ -540,20 +545,17 @@ internal sealed class InputBar
ImGui.SetTooltip("Settings");
}
// Hide button gated on ShowHideButton (1.5.6 parity). It is the last
// button in the row, so skipping it (with its leading SameLine) leaves
// no dangling SameLine. Shared by main + pop-out InputBars.
if (Plugin.Config.ShowHideButton)
// Hides the window (1.5.6 UserHide). One-way — Enter brings it back.
// Main window only (pop-outs have their own close); last in the row.
if (Plugin.Config.ShowHideButton && _onHideWindow is not null)
{
ImGui.SameLine();
var hidden = Plugin.Config.HideChat;
var visIcon = hidden ? FontAwesomeIcon.EyeSlash : FontAwesomeIcon.Eye;
if (ImGui.Button(visIcon.ToIconString()))
Plugin.Config.HideChat = !hidden;
if (ImGui.Button(FontAwesomeIcon.EyeSlash.ToIconString()))
_onHideWindow();
if (ImGui.IsItemHovered())
{
using (ImRaii.DefaultFont())
ImGui.SetTooltip(hidden ? "Unhide chat" : "Hide chat");
ImGui.SetTooltip("Hide chat (Enter to bring back)");
}
}
}
+32 -4
View File
@@ -33,6 +33,10 @@ internal sealed class MainWindow : Window
private Tab? _activeTab;
// Runtime-only hide: window stays IsOpen but DrawConditions skips it, so the
// chat-activation key can restore it (1.5.6 HideState.User parity).
private bool _userHidden;
public Vector2 LastWindowPos { get; private set; } = Vector2.Zero;
public Vector2 LastWindowSize { get; private set; } = Vector2.Zero;
internal unsafe ImGuiViewport* LastViewport;
@@ -66,7 +70,9 @@ internal sealed class MainWindow : Window
MinimumSize = new Vector2(MinWidth, MinHeight),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue),
};
IsOpen = Plugin.Config.MainWindowOpen;
// 1.5.6 parity: the chat always shows on login. The window stays closeable
// and hideable within a session, but that state is not carried across starts.
IsOpen = true;
RespectCloseHotkey = false;
}
@@ -162,11 +168,33 @@ internal sealed class MainWindow : Window
internal Components.MessageList GetMessageListForSelfTest() => _messages;
// new-shadow on Window.Toggle so the open path also writes Config —
// OnClose already covers the close path through the base behaviour.
public override bool DrawConditions() => !_userHidden;
internal void UserHide() => _userHidden = true;
// Chat-activation keybind (Enter) entry point. Field writes only, so it is safe
// from the framework thread; the draw path applies focus next frame.
internal void ActivateChat()
{
_userHidden = false;
if (!IsOpen)
{
IsOpen = true;
Plugin.Config.MainWindowOpen = true;
}
BringToFront();
_input.Activate = true;
}
// new-shadow on Window.Toggle so the open path also writes Config. A user-hide
// counts as "not visible", so /hellion is a reliable one-press recovery even when
// the Enter keybind can't fire (DirectChat / a focused game text field).
public new void Toggle()
{
IsOpen = !IsOpen;
var visible = IsOpen && !_userHidden;
IsOpen = !visible;
if (IsOpen)
_userHidden = false;
Plugin.Config.MainWindowOpen = IsOpen;
}