Combo highlight config, tooltips, nameplates, hotbars fixes
- Combo highlight: configurable color, glow, line style (solid/dashed/dotted), thickness - Tooltips: font selection, scaling slider, improved wrap/cramping handling - Nameplates: custom quest icons with config, position smoothing fix for jitter - Hotbars: hide keybinds on empty slots, combo highlight within icon bounds - HudHelper: restore default nameplates on plugin disable Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -176,6 +176,57 @@ namespace HSUI.Helpers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Draw a rect outline with optional glow and line style (solid, dashed, dotted).</summary>
|
||||
public static void DrawComboHighlightRect(ImDrawListPtr drawList, Vector2 min, Vector2 max, uint color, float thickness, bool showGlow, int lineStyle)
|
||||
{
|
||||
const float inset = 2f;
|
||||
Vector2 innerMin = min + new Vector2(inset, inset);
|
||||
Vector2 innerMax = max - new Vector2(inset, inset);
|
||||
if (innerMax.X <= innerMin.X || innerMax.Y <= innerMin.Y) return;
|
||||
|
||||
if (showGlow)
|
||||
{
|
||||
for (int g = 5; g >= 1; g--)
|
||||
{
|
||||
float o = g;
|
||||
uint alpha = (uint)(byte)(70 * (6 - g)) << 24;
|
||||
drawList.AddRect(innerMin - new Vector2(o, o), innerMax + new Vector2(o, o),
|
||||
alpha | (color & 0x00FFFFFF), 0, ImDrawFlags.None, 2f);
|
||||
}
|
||||
}
|
||||
|
||||
if (lineStyle == 0) // Solid
|
||||
{
|
||||
drawList.AddRect(innerMin, innerMax, color, 0, ImDrawFlags.None, thickness);
|
||||
return;
|
||||
}
|
||||
|
||||
// Dashed or Dotted: draw each side as segments
|
||||
float dashLen = lineStyle == 1 ? 4f : 2f;
|
||||
float gapLen = lineStyle == 1 ? 3f : 3f;
|
||||
float step = dashLen + gapLen;
|
||||
|
||||
void DrawSegmentedLine(Vector2 a, Vector2 b)
|
||||
{
|
||||
Vector2 d = b - a;
|
||||
float len = d.Length();
|
||||
if (len < 0.001f) return;
|
||||
Vector2 u = d / len;
|
||||
float t = 0;
|
||||
while (t < len)
|
||||
{
|
||||
float tEnd = Math.Min(t + dashLen, len);
|
||||
drawList.AddLine(a + u * t, a + u * tEnd, color, thickness);
|
||||
t += step;
|
||||
}
|
||||
}
|
||||
|
||||
DrawSegmentedLine(innerMin, new Vector2(innerMax.X, innerMin.Y)); // top
|
||||
DrawSegmentedLine(new Vector2(innerMax.X, innerMin.Y), innerMax); // right
|
||||
DrawSegmentedLine(innerMax, new Vector2(innerMin.X, innerMax.Y)); // bottom
|
||||
DrawSegmentedLine(new Vector2(innerMin.X, innerMax.Y), innerMin); // left
|
||||
}
|
||||
|
||||
public static void DrawIcon(uint iconId, Vector2 position, Vector2 size, bool drawBorder, uint color, ImDrawListPtr drawList)
|
||||
{
|
||||
IDalamudTextureWrap? texture = TexturesHelper.GetTextureFromIconId(iconId);
|
||||
|
||||
+23
-11
@@ -42,8 +42,8 @@ namespace HSUI.Helpers
|
||||
}
|
||||
#endregion
|
||||
|
||||
private float MaxWidth => 340 * ImGuiHelpers.GlobalScale;
|
||||
private float Margin => 5 * ImGuiHelpers.GlobalScale;
|
||||
private float MaxWidth => Math.Max(160, 340 * ImGuiHelpers.GlobalScale * _config.TooltipScale);
|
||||
private float Margin => Math.Max(4, 5 * ImGuiHelpers.GlobalScale * _config.TooltipScale);
|
||||
|
||||
private TooltipsConfig _config => ConfigurationManager.Instance.GetConfigObject<TooltipsConfig>();
|
||||
|
||||
@@ -95,7 +95,8 @@ namespace HSUI.Helpers
|
||||
_currentTooltipTitle += " (ID: " + id + ")";
|
||||
}
|
||||
|
||||
using (FontsManager.Instance.PushFont(FontsConfig.DefaultSmallFontKey))
|
||||
string fontId = _config.FontID ?? FontsConfig.DefaultSmallFontKey;
|
||||
using (FontsManager.Instance.PushFont(fontId))
|
||||
{
|
||||
_titleSize = ImGui.CalcTextSize(_currentTooltipTitle, false, MaxWidth);
|
||||
_titleSize.Y += Margin;
|
||||
@@ -103,7 +104,8 @@ namespace HSUI.Helpers
|
||||
}
|
||||
|
||||
// calculate text size
|
||||
using (FontsManager.Instance.PushFont(FontsConfig.DefaultSmallFontKey))
|
||||
string fontIdForText = _config.FontID ?? FontsConfig.DefaultSmallFontKey;
|
||||
using (FontsManager.Instance.PushFont(fontIdForText))
|
||||
{
|
||||
_textSize = ImGui.CalcTextSize(_currentTooltipText, false, MaxWidth);
|
||||
}
|
||||
@@ -170,25 +172,27 @@ namespace HSUI.Helpers
|
||||
// no idea why i have to do this
|
||||
float globalScaleCorrection = -15 + 15 * ImGuiHelpers.GlobalScale;
|
||||
|
||||
string fontId = _config.FontID ?? FontsConfig.DefaultSmallFontKey;
|
||||
float wrapWidth = Math.Max(_titleSize.X, _textSize.X) + Margin;
|
||||
if (_currentTooltipTitle != null)
|
||||
{
|
||||
// title
|
||||
Vector2 cursorPos;
|
||||
using (FontsManager.Instance.PushFont(FontsConfig.DefaultSmallFontKey))
|
||||
using (FontsManager.Instance.PushFont(fontId))
|
||||
{
|
||||
cursorPos = new Vector2(windowMargin.X + _size.X / 2f - _titleSize.X / 2f, Margin);
|
||||
ImGui.SetCursorPos(cursorPos);
|
||||
ImGui.PushTextWrapPos(cursorPos.X + _titleSize.X + globalScaleCorrection + Margin);
|
||||
ImGui.PushTextWrapPos(cursorPos.X + wrapWidth + globalScaleCorrection);
|
||||
ImGui.TextColored(_config.TitleColor.Vector, _currentTooltipTitle);
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
|
||||
// text
|
||||
using (FontsManager.Instance.PushFont(FontsConfig.DefaultSmallFontKey))
|
||||
using (FontsManager.Instance.PushFont(fontId))
|
||||
{
|
||||
cursorPos = new Vector2(windowMargin.X + _size.X / 2f - _textSize.X / 2f, Margin + _titleSize.Y);
|
||||
ImGui.SetCursorPos(cursorPos);
|
||||
ImGui.PushTextWrapPos(cursorPos.X + _textSize.X + globalScaleCorrection + Margin);
|
||||
ImGui.PushTextWrapPos(cursorPos.X + wrapWidth + globalScaleCorrection);
|
||||
ImGui.TextColored(_config.TextColor.Vector, _currentTooltipText);
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
@@ -196,13 +200,13 @@ namespace HSUI.Helpers
|
||||
else
|
||||
{
|
||||
// text
|
||||
using (FontsManager.Instance.PushFont(FontsConfig.DefaultSmallFontKey))
|
||||
using (FontsManager.Instance.PushFont(fontId))
|
||||
{
|
||||
var cursorPos = windowMargin + new Vector2(Margin, Margin);
|
||||
var textWidth = _size.X - Margin * 2;
|
||||
|
||||
ImGui.SetCursorPos(cursorPos);
|
||||
ImGui.PushTextWrapPos(cursorPos.X + textWidth + globalScaleCorrection + Margin);
|
||||
ImGui.PushTextWrapPos(cursorPos.X + textWidth + globalScaleCorrection);
|
||||
ImGui.TextColored(_config.TextColor.Vector, _currentTooltipText);
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
@@ -248,8 +252,16 @@ namespace HSUI.Helpers
|
||||
[Order(3)]
|
||||
public bool DebugTooltips = false;
|
||||
|
||||
[Font]
|
||||
[Order(4)]
|
||||
public string? FontID = null;
|
||||
|
||||
[DragFloat("Tooltip Scale", min = 0.5f, max = 2f, help = "Scale the tooltip window size. Useful for large resolutions.")]
|
||||
[Order(6)]
|
||||
public float TooltipScale = 1f;
|
||||
|
||||
[Checkbox("Show Status Effects IDs")]
|
||||
[Order(5)]
|
||||
[Order(7)]
|
||||
public bool ShowStatusIDs = false;
|
||||
|
||||
[Checkbox("Show Source Name")]
|
||||
|
||||
Reference in New Issue
Block a user