Skip to content

Commit

Permalink
item compare now takes itemicons into account
Browse files Browse the repository at this point in the history
  • Loading branch information
NoBetaBoredom committed Feb 9, 2022
1 parent 703faa0 commit a10f5b4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
30 changes: 28 additions & 2 deletions TipTac/ttCore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ local TT_DefaultConfig = {
if_iconSize = 42,
if_iconAnchor = "BOTTOMLEFT",
if_iconTooltipAnchor = "TOPLEFT",
if_iconOffsetX = 2.5,
if_iconOffsetY = -2.5,
if_iconOffsetX = 0,
if_iconOffsetY = 0,
if_copyParentBorder = false,
};

Expand Down Expand Up @@ -944,6 +944,31 @@ function tt:ReApplyAnchorTypeForMouse(frame, noUpdateAnchorPosition, ignoreWorld
end
end

-- anchors the comparing items tooltip with an appropriate offset to account for the item icon
function tt:anchorShoppingTooltips(frame)
if (frame:GetName() == "ShoppingTooltip1" or frame:GetName() == "ShoppingTooltip2") then
-- calculate offset if the icon is to the left or right of the tooltip
local iconDistance = 0;
if (cfg.if_showIcon) then
local leftDistance = gtt:GetLeft() - gtt.ttIcon:GetLeft();
local rightDistance = gtt.ttIcon:GetRight() - gtt:GetRight();
if (leftDistance > 0) then
iconDistance = leftDistance;
elseif (rightDistance > 0) then
iconDistance = rightDistance
end
end

local anchor, aFrame, anchorTo, x, y = frame:GetPoint();
local gapOffset = tt:GetNearestPixelSize(5);
local toTheLeft = (anchor == "TOPRIGHT");
local xOffset = (toTheLeft and -(gapOffset + iconDistance) or (gapOffset + iconDistance));

frame:ClearAllPoints();
frame:SetPoint(anchor, aFrame, anchorTo, xOffset, 0);
end
end

-- Removes lines from the tooltip which are unwanted, such as "PvP", "Alliance", "Horde"
-- Also removes the coalesced realm line(s), which I am unsure is still in BfA?
function tt:RemoveUnwantedLines(tip)
Expand Down Expand Up @@ -1297,6 +1322,7 @@ end
-- EventHook: OnTooltipSetItem
function gttScriptHooks:OnTooltipSetItem()
tt:ReApplyAnchorTypeForMouse(self);
tt:anchorShoppingTooltips(self, "ontooltipsetitem");
end

-- OnHide Script -- Used to default the background and border color -- Az: May cause issues with embedded tooltips, see GameTooltip.lua:396
Expand Down
4 changes: 2 additions & 2 deletions TipTacOptions/ttOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ if (TipTacItemRef) then
{ type = "Slider", var = "if_iconSize", label = "Icon Size", min = 16, max = 128, step = 1 },
{ type = "DropDown", var = "if_iconAnchor", label = "Icon Anchor", tip = "The anchor of the icon", list = DROPDOWN_ANCHORPOS },
{ type = "DropDown", var = "if_iconTooltipAnchor", label = "Icon Tooltip Anchor", tip = "The anchor of the tooltip that the icon should anchor to.", list = DROPDOWN_ANCHORPOS },
{ type = "Slider", var = "if_iconOffsetX", label = "Icon X Offset", min = -200, max = 200, step = 0.5 },
{ type = "Slider", var = "if_iconOffsetY", label = "Icon Y Offset", min = -200, max = 200, step = 0.5 },
{ type = "Slider", var = "if_iconOffsetX", label = "Icon X Offset", min = -200, max = 200, step = 1 }, -- only whole numbers or we get jitters
{ type = "Slider", var = "if_iconOffsetY", label = "Icon Y Offset", min = -200, max = 200, step = 1 }, -- only whole numbers or we get jitters
};
end

Expand Down

0 comments on commit a10f5b4

Please sign in to comment.