Move tooltips if user has "Next to Cursor" option active
This commit is contained in:
@@ -3,13 +3,17 @@ using ChatTwo.Code;
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Ui;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.Config;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Action = System.Action;
|
||||
@@ -186,10 +190,13 @@ internal sealed class PayloadHandler {
|
||||
GameFunctions.GameFunctions.OpenItemTooltip(item.RawItemId);
|
||||
|
||||
_handleTooltips = true;
|
||||
if (_hoveredItem != item.RawItemId) {
|
||||
if (_hoveredItem != item.RawItemId)
|
||||
{
|
||||
_hoveredItem = item.RawItemId;
|
||||
_hoverCounter = _lastHoverCounter = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastHoverCounter = _hoverCounter;
|
||||
}
|
||||
|
||||
@@ -221,6 +228,34 @@ internal sealed class PayloadHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void MoveTooltip(AddonEvent type, AddonArgs args)
|
||||
{
|
||||
if (!_handleTooltips)
|
||||
return;
|
||||
|
||||
// Only move if user has "Next to Cursor" option selected
|
||||
if (!Plugin.GameConfig.TryGet(UiControlOption.DetailTrackingType, out uint selected) || selected != 0)
|
||||
return;
|
||||
|
||||
if (Log.LastViewport != ImGuiHelpers.MainViewport.NativePtr)
|
||||
return;
|
||||
|
||||
var atk = (AtkUnitBase*) args.Addon;
|
||||
if (atk == null)
|
||||
return;
|
||||
|
||||
var atkSize = (X: atk->GetScaledWidth(true), Y: atk->GetScaledHeight(true));
|
||||
var viewportSize = ImGuiHelpers.MainViewport.Size;
|
||||
var window = Log.LastWindowPos + Log.LastWindowSize;
|
||||
var isLeft = window.X < viewportSize.X / 2;
|
||||
var isTop = window.Y < viewportSize.Y / 2;
|
||||
|
||||
var x = isLeft ? window.X : Log.LastWindowPos.X - atkSize.X;
|
||||
var y = Math.Clamp(window.Y - atkSize.Y, 0, float.MaxValue);
|
||||
y -= isTop ? 0 : 10; // small offset to prevent cut-off on the bottom
|
||||
atk->SetPosition((short) x, (short) y);
|
||||
}
|
||||
|
||||
private static void InlineIcon(IDalamudTextureWrap icon) {
|
||||
var lineHeight = ImGui.CalcTextSize("A").Y;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Globalization;
|
||||
using ChatTwo.Ipc;
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
@@ -32,6 +33,7 @@ public sealed class Plugin : IDalamudPlugin {
|
||||
[PluginService] internal static IGameInteropProvider GameInteropProvider { get; private set; } = null!;
|
||||
[PluginService] internal static IGameConfig GameConfig { get; private set; } = null!;
|
||||
[PluginService] internal static INotificationManager Notification { get; private set; } = null!;
|
||||
[PluginService] internal static IAddonLifecycle AddonLifecycle { get; private set; } = null!;
|
||||
|
||||
internal Configuration Config { get; }
|
||||
internal Commands Commands { get; }
|
||||
@@ -81,10 +83,14 @@ public sealed class Plugin : IDalamudPlugin {
|
||||
Framework.Update += FrameworkUpdate;
|
||||
Interface.UiBuilder.Draw += Ui.Draw;
|
||||
Interface.LanguageChanged += LanguageChanged;
|
||||
|
||||
AddonLifecycle.RegisterListener(AddonEvent.PostRequestedUpdate, "ItemDetail", Ui.ChatLog.PayloadHandler.MoveTooltip);
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
|
||||
public void Dispose() {
|
||||
AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "ItemDetail", Ui.ChatLog.PayloadHandler.MoveTooltip);
|
||||
|
||||
Interface.LanguageChanged -= LanguageChanged;
|
||||
Interface.UiBuilder.Draw -= Ui.Draw;
|
||||
Framework.Update -= FrameworkUpdate;
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ internal sealed class PluginUi : IDisposable {
|
||||
|
||||
internal Tab? CurrentTab {
|
||||
get {
|
||||
var i = _chatLog.LastTab;
|
||||
var i = ChatLog.LastTab;
|
||||
if (i > -1 && i < Plugin.Config.Tabs.Count) {
|
||||
return Plugin.Config.Tabs[i];
|
||||
}
|
||||
@@ -44,16 +44,16 @@ internal sealed class PluginUi : IDisposable {
|
||||
private ushort[] _jpRange;
|
||||
private ushort[] _symRange = [0xE020, 0xE0DB, 0];
|
||||
|
||||
private readonly ChatLog _chatLog;
|
||||
public readonly ChatLog ChatLog;
|
||||
|
||||
internal PluginUi(Plugin plugin) {
|
||||
Plugin = plugin;
|
||||
Salt = new Random().Next().ToString();
|
||||
|
||||
_chatLog = new ChatLog(this);
|
||||
ChatLog = new ChatLog(this);
|
||||
Components = new List<IUiComponent> {
|
||||
new Settings(this),
|
||||
_chatLog,
|
||||
ChatLog,
|
||||
};
|
||||
|
||||
var gameSym = new HttpClient().GetAsync("https://img.finalfantasyxiv.com/lds/pc/global/fonts/FFXIV_Lodestone_SSF.ttf")
|
||||
|
||||
+278
-278
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user