2201478a54
- Configuration.cs: ShowTitleBar defaults to true so a fresh install shows the window header instead of leaving the user without a drag handle and hide button - Configuration.cs: MaxLinesToRender default drops from 10000 to 5000 to match the slider's intended ceiling and the previous user-tuned baseline - ChatLogWindow.cs: 24h-clock checkbox now actually flips the format. The Bestand path passed null culture which on a German system locale always rendered 24h regardless of the toggle - Appearance.cs + ChatLogWindow.cs + Popout.cs: when Hellion theme is enabled the global theme opacity drives the chat-window BgAlpha and the legacy WindowAlpha slider is disabled, so the two opacity controls no longer fight each other - Appearance.cs: ticking UseHellionFont now flips FontsEnabled off so the two mutually-exclusive font stacks no longer appear active at the same time
163 lines
5.5 KiB
C#
163 lines
5.5 KiB
C#
using System.Numerics;
|
|
using Dalamud.Interface.Style;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
using Dalamud.Interface.Windowing;
|
|
using Dalamud.Bindings.ImGui;
|
|
|
|
namespace ChatTwo.Ui;
|
|
|
|
internal class Popout : Window
|
|
{
|
|
private readonly ChatLogWindow ChatLogWindow;
|
|
private readonly Tab Tab;
|
|
private readonly int Idx;
|
|
|
|
private long FrameTime; // set every frame
|
|
private long LastActivityTime = Environment.TickCount64;
|
|
|
|
public Popout(ChatLogWindow chatLogWindow, Tab tab, int idx) : base($"{tab.Name}##popout")
|
|
{
|
|
ChatLogWindow = chatLogWindow;
|
|
Tab = tab;
|
|
Idx = idx;
|
|
|
|
Size = new Vector2(350, 350);
|
|
SizeCondition = ImGuiCond.FirstUseEver;
|
|
|
|
IsOpen = true;
|
|
RespectCloseHotkey = false;
|
|
DisableWindowSounds = true;
|
|
}
|
|
|
|
public override void PreOpenCheck()
|
|
{
|
|
if (!Tab.PopOut)
|
|
IsOpen = false;
|
|
}
|
|
|
|
public override bool DrawConditions()
|
|
{
|
|
FrameTime = Environment.TickCount64;
|
|
if (Tab.IndependentHide ? HideStateCheck() : ChatLogWindow.IsHidden)
|
|
return false;
|
|
|
|
if (!Plugin.Config.HideWhenInactive || (!Plugin.Config.InactivityHideActiveDuringBattle && Plugin.InBattle) || !Tab.UnhideOnActivity)
|
|
{
|
|
LastActivityTime = FrameTime;
|
|
return true;
|
|
}
|
|
|
|
// Activity in the tab, this popout window, or the main chat log window.
|
|
var lastActivityTime = Math.Max(Tab.LastActivity, LastActivityTime);
|
|
lastActivityTime = Math.Max(lastActivityTime, ChatLogWindow.LastActivityTime);
|
|
return FrameTime - lastActivityTime <= 1000 * Plugin.Config.InactivityHideTimeout;
|
|
}
|
|
|
|
public override void PreDraw()
|
|
{
|
|
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
|
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Push();
|
|
|
|
Flags = ImGuiWindowFlags.None;
|
|
if (!Plugin.Config.ShowPopOutTitleBar)
|
|
Flags |= ImGuiWindowFlags.NoTitleBar;
|
|
|
|
if (!Tab.CanMove)
|
|
Flags |= ImGuiWindowFlags.NoMove;
|
|
|
|
if (!Tab.CanResize)
|
|
Flags |= ImGuiWindowFlags.NoResize;
|
|
|
|
if (!ChatLogWindow.PopOutDocked[Idx])
|
|
{
|
|
if (Tab.IndependentOpacity)
|
|
{
|
|
BgAlpha = Tab.Opacity / 100f;
|
|
}
|
|
else
|
|
{
|
|
BgAlpha = Plugin.Config.HellionThemeEnabled
|
|
? Plugin.Config.HellionThemeWindowOpacity
|
|
: Plugin.Config.WindowAlpha / 100f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Draw()
|
|
{
|
|
using var id = ImRaii.PushId($"popout-{Tab.Identifier}");
|
|
|
|
if (!Plugin.Config.ShowPopOutTitleBar)
|
|
{
|
|
ImGui.TextUnformatted(Tab.Name);
|
|
ImGui.Separator();
|
|
}
|
|
|
|
var handler = ChatLogWindow.HandlerLender.Borrow();
|
|
ChatLogWindow.DrawMessageLog(Tab, handler, ImGui.GetContentRegionAvail().Y, false);
|
|
|
|
if (ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows))
|
|
LastActivityTime = FrameTime;
|
|
}
|
|
|
|
public override void PostDraw()
|
|
{
|
|
ChatLogWindow.PopOutDocked[Idx] = ImGui.IsWindowDocked();
|
|
|
|
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
|
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Pop();
|
|
}
|
|
|
|
public override void OnClose()
|
|
{
|
|
ChatLogWindow.PopOutWindows.Remove(Tab.Identifier);
|
|
ChatLogWindow.Plugin.WindowSystem.RemoveWindow(this);
|
|
|
|
Tab.PopOut = false;
|
|
ChatLogWindow.Plugin.SaveConfig();
|
|
}
|
|
|
|
private enum HideState
|
|
{
|
|
None,
|
|
Cutscene,
|
|
CutsceneOverride,
|
|
User,
|
|
Battle
|
|
}
|
|
|
|
private HideState CurrentHideState = HideState.None;
|
|
|
|
private bool HideStateCheck()
|
|
{
|
|
// if the chat has no hide state set, and the player has entered battle, we hide chat if they have configured it
|
|
if (Tab.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle)
|
|
CurrentHideState = HideState.Battle;
|
|
|
|
// If the chat is hidden because of battle, we reset it here
|
|
if (CurrentHideState is HideState.Battle && !Plugin.InBattle)
|
|
CurrentHideState = HideState.None;
|
|
|
|
// if the chat has no hide state and in a cutscene, set the hide state to cutscene
|
|
if (Tab.HideDuringCutscenes && CurrentHideState == HideState.None && (Plugin.CutsceneActive || Plugin.GposeActive))
|
|
{
|
|
if (ChatLogWindow.Plugin.Functions.Chat.CheckHideFlags())
|
|
CurrentHideState = HideState.Cutscene;
|
|
}
|
|
|
|
// if the chat is hidden because of a cutscene and no longer in a cutscene, set the hide state to none
|
|
if (CurrentHideState is HideState.Cutscene or HideState.CutsceneOverride && !Plugin.CutsceneActive && !Plugin.GposeActive)
|
|
CurrentHideState = HideState.None;
|
|
|
|
// if the chat is hidden because of a cutscene and the chat has been activated, show chat
|
|
if (CurrentHideState == HideState.Cutscene && ChatLogWindow.Activate)
|
|
CurrentHideState = HideState.CutsceneOverride;
|
|
|
|
// if the user hid the chat and is now activating chat, reset the hide state
|
|
if (CurrentHideState == HideState.User && ChatLogWindow.Activate)
|
|
CurrentHideState = HideState.None;
|
|
|
|
return CurrentHideState is HideState.Cutscene or HideState.User or HideState.Battle || (Tab.HideWhenNotLoggedIn && !Plugin.ClientState.IsLoggedIn);
|
|
}
|
|
}
|