show focus target on visibility hover

This commit is contained in:
2025-12-03 13:59:30 +09:00
parent c335489cee
commit 1c36db97dc
4 changed files with 149 additions and 9 deletions

View File

@@ -56,6 +56,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private readonly TagHandler _tagHandler;
private readonly UiSharedService _uiSharedService;
private readonly LightFinderService _broadcastService;
private readonly DalamudUtilService _dalamudUtilService;
private List<IDrawFolder> _drawFolders;
private Pair? _lastAddedUser;
@@ -68,6 +69,9 @@ public class CompactUi : WindowMediatorSubscriberBase
private float _windowContentWidth;
private readonly SeluneBrush _seluneBrush = new();
private const float _connectButtonHighlightThickness = 14f;
private Pair? _focusedPair;
private Pair? _pendingFocusPair;
private int _pendingFocusFrame = -1;
public CompactUi(
ILogger<CompactUi> logger,
@@ -109,7 +113,9 @@ public class CompactUi : WindowMediatorSubscriberBase
_ipcManager = ipcManager;
_broadcastService = broadcastService;
_pairLedger = pairLedger;
_dalamudUtilService = dalamudUtilService;
_tabMenu = new TopTabMenu(Mediator, _apiController, _uiSharedService, pairRequestService, dalamudUtilService, lightlessNotificationService);
Mediator.Subscribe<PairFocusCharacterMessage>(this, msg => RegisterFocusCharacter(msg.Pair));
AllowPinning = true;
AllowClickthrough = false;
@@ -178,6 +184,12 @@ public class CompactUi : WindowMediatorSubscriberBase
_lightlessMediator = mediator;
}
public override void OnClose()
{
ForceReleaseFocus();
base.OnClose();
}
protected override void DrawInternal()
{
var drawList = ImGui.GetWindowDrawList();
@@ -268,6 +280,8 @@ public class CompactUi : WindowMediatorSubscriberBase
selune.Animate(ImGui.GetIO().DeltaTime);
}
ProcessFocusTracker();
var lastAddedPair = _pairUiService.GetLastAddedPair();
if (_configService.Current.OpenPopupOnAdd && lastAddedPair is not null)
{
@@ -1117,4 +1131,50 @@ public class CompactUi : WindowMediatorSubscriberBase
_wasOpen = IsOpen;
IsOpen = false;
}
private void RegisterFocusCharacter(Pair pair)
{
_pendingFocusPair = pair;
_pendingFocusFrame = ImGui.GetFrameCount();
}
private void ProcessFocusTracker()
{
var frame = ImGui.GetFrameCount();
Pair? character = _pendingFocusFrame == frame ? _pendingFocusPair : null;
if (!ReferenceEquals(character, _focusedPair))
{
if (character is null)
{
_dalamudUtilService.ReleaseVisiblePairFocus();
}
else
{
_dalamudUtilService.FocusVisiblePair(character);
}
_focusedPair = character;
}
if (_pendingFocusFrame == frame)
{
_pendingFocusPair = null;
_pendingFocusFrame = -1;
}
}
private void ForceReleaseFocus()
{
if (_focusedPair is null)
{
_pendingFocusPair = null;
_pendingFocusFrame = -1;
return;
}
_dalamudUtilService.ReleaseVisiblePairFocus();
_focusedPair = null;
_pendingFocusPair = null;
_pendingFocusFrame = -1;
}
}