Skip to content

Commit 44a5a2a

Browse files
committed
Also add tree view to compare tab compact mode
1 parent eaa4e7d commit 44a5a2a

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ local tradeHelpers = LoadModule("Classes/TradeHelpers")
1414
local buySimilar = LoadModule("Classes/CompareBuySimilar")
1515
local calcsHelpers = LoadModule("Classes/CompareCalcsHelpers")
1616
local buildListHelpers = LoadModule("Modules/BuildListHelpers")
17+
local itemSlotHelper = LoadModule("Modules/ItemSlotHelper")
1718

1819
-- Node IDs below this value are normal passive tree nodes; IDs at or above are cluster jewel nodes
1920
local CLUSTER_NODE_OFFSET = 65536
@@ -3797,13 +3798,33 @@ function CompareTabClass:DrawItems(vp, compareEntry, inputEvents)
37973798
drawY = drawY + maxH + 6
37983799
else
37993800
-- === COMPACT MODE ===
3801+
local slot = self.primaryBuild.itemsTab.slots[equipSlotName]
3802+
local nodeId = slot.nodeId
3803+
local shouldUnderline = not not nodeId
38003804
local pHover, cHover, b1Hover, b2Hover, b3Hover, b2X, b2Y, b2W, b2H,
38013805
rowHoverItem, rowHoverItemsTab, rowHoverX, rowHoverY, rowHoverW, rowHoverH =
38023806
tradeHelpers.drawCompactSlotRow(drawY, label, pItem, cItem,
38033807
colWidth, cursorX, cursorY, labelW,
38043808
self.primaryBuild.itemsTab, compareEntry.itemsTab, pWarn, cWarn, slotMissing,
3805-
LAYOUT.itemsCopyBtnW, LAYOUT.itemsCopyBtnH, LAYOUT.itemsBuyBtnW, LAYOUT.itemsEquipBtnW, scrollOffsetX)
3806-
3809+
LAYOUT.itemsCopyBtnW, LAYOUT.itemsCopyBtnH, LAYOUT.itemsBuyBtnW, LAYOUT.itemsEquipBtnW, scrollOffsetX,
3810+
shouldUnderline)
3811+
3812+
local labelX = (scrollOffsetX or 0) + 10
3813+
-- draw passive tree view when hovering over the label, if the slot is a jewel socket
3814+
if labelX <= cursorX and cursorX <= (labelX + labelW)
3815+
and drawY <= cursorY and cursorY <= (drawY + 20) then
3816+
if nodeId then
3817+
local boxSize = 250
3818+
-- anchor bottom left to label top left, keeping in mind what our viewport was
3819+
SetViewport()
3820+
local boxX = vp.x + labelX
3821+
local boxY = (vp.y + checkboxOffset) + drawY - boxSize
3822+
itemSlotHelper.DrawViewer(self.primaryBuild.itemsTab, nodeId, boxX, boxY, boxSize,
3823+
boxSize)
3824+
-- restore viewport
3825+
SetViewport(vp.x, vp.y + checkboxOffset, vp.width, scrollViewH)
3826+
end
3827+
end
38073828
if rowHoverItem then
38083829
hoverItem = rowHoverItem
38093830
hoverItemsTab = rowHoverItemsTab

src/Classes/TradeHelpers.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ local ITEM_BOX_H = 20
450450

451451
function M.drawCompactSlotRow(drawY, slotLabel, pItem, cItem,
452452
colWidth, cursorX, cursorY, maxLabelW, primaryItemsTab, compareItemsTab, pWarn, cWarn, slotMissing,
453-
copyBtnW, copyBtnH, buyBtnW, equipBtnW, xOffset)
453+
copyBtnW, copyBtnH, buyBtnW, equipBtnW, xOffset, shouldUnderlineLabel)
454454

455455
xOffset = xOffset or 0
456456
local pName = pItem and pItem.name or "(empty)"
@@ -480,7 +480,13 @@ function M.drawCompactSlotRow(drawY, slotLabel, pItem, cItem,
480480

481481
-- Draw slot label
482482
SetDrawColor(1, 1, 1)
483-
DrawString(labelX, drawY + 2, "LEFT", 16, "VAR", "^7" .. slotLabel .. ":")
483+
local labelText = "^7" .. slotLabel .. ":"
484+
DrawString(labelX, drawY + 2, "LEFT", 16, "VAR", labelText)
485+
486+
if shouldUnderlineLabel then
487+
local labelW = DrawStringWidth(16, "VAR", labelText)
488+
DrawImage(nil, labelX, drawY + 2 + 16, labelW, 1)
489+
end
484490

485491
-- Draw primary item box
486492
local pBorderGray = pHover and 0.5 or 0.33

src/Modules/ItemSlotHelper.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local M = {}
22

3-
-- draws a small display window of a jewel socket's position
3+
-- Draws a small display window of a jewel socket's position. Note that this will reset the
4+
-- viewport and the draw layer.
45
---@param nodeId integer
56
---@param x integer
67
---@param y integer

0 commit comments

Comments
 (0)