65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System.Numerics;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface.Windowing;
|
|
using HellionChat.Ui.Components;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace HellionChat.Ui.Windows;
|
|
|
|
// One pre-allocated pop-out window bound to a single Tab. Pure DI-sink: the
|
|
// PayloadHandler arrives via AttachPayloadHandler (post-build setter), NEVER
|
|
// via ctor — see plan §B.2. The ###id carries the slot index so all N
|
|
// instances are unique for WindowSystem.AddWindow and ImGui state is stable
|
|
// per slot (not per bound tab).
|
|
internal sealed class ChannelPopoutWindow : Window
|
|
{
|
|
private readonly int _slotIndex;
|
|
private readonly MessageList _messages;
|
|
private readonly InputBar _input;
|
|
private readonly ILogger<ChannelPopoutWindow> _logger;
|
|
|
|
public ChannelPopoutWindow(
|
|
int slotIndex,
|
|
MessageList messages,
|
|
InputBar input,
|
|
ILogger<ChannelPopoutWindow> logger
|
|
)
|
|
: base($"{Plugin.PluginName}###hellion_popout_{slotIndex}")
|
|
{
|
|
_slotIndex = slotIndex;
|
|
_messages = messages;
|
|
_input = input;
|
|
_logger = logger;
|
|
IsOpen = false;
|
|
RespectCloseHotkey = false;
|
|
}
|
|
|
|
public int SlotIndex => _slotIndex;
|
|
|
|
public Tab? Bound { get; private set; }
|
|
|
|
// Post-build setter — see plan §B.2. Wired by ChannelPopoutInitHostedService.
|
|
public void AttachPayloadHandler(PayloadHandler handler) =>
|
|
_messages.AttachPayloadHandler(handler);
|
|
|
|
public void Bind(Tab tab)
|
|
{
|
|
// Filled in Phase B.
|
|
Bound = tab;
|
|
IsOpen = true;
|
|
}
|
|
|
|
public void Unbind()
|
|
{
|
|
Bound = null;
|
|
IsOpen = false;
|
|
}
|
|
|
|
public override void Draw()
|
|
{
|
|
// Filled in Phase B. Defensive guard so an unbound slot renders nothing.
|
|
if (Bound is null)
|
|
return;
|
|
}
|
|
}
|