Skip to content

Commit ebeed3a

Browse files
committed
handle Ring 3 slot
1 parent 527b4ee commit ebeed3a

1 file changed

Lines changed: 43 additions & 14 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,9 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
21492149
end
21502150
if categories.items then
21512151
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
2152+
if self:ShouldShowRing3(compareEntry) then
2153+
t_insert(baseSlots, 10, "Ring 3")
2154+
end
21522155
for _, slotName in ipairs(baseSlots) do
21532156
local cSlot = compareEntry.itemsTab and compareEntry.itemsTab.slots[slotName]
21542157
local cItem = cSlot and compareEntry.itemsTab.items[cSlot.selItemId]
@@ -2282,6 +2285,9 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
22822285
-- ==========================================
22832286
if categories.items then
22842287
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
2288+
if self:ShouldShowRing3(compareEntry) then
2289+
t_insert(baseSlots, 10, "Ring 3")
2290+
end
22852291
for _, slotName in ipairs(baseSlots) do
22862292
local cSlot = compareEntry.itemsTab and compareEntry.itemsTab.slots[slotName]
22872293
local cItem = cSlot and compareEntry.itemsTab.items[cSlot.selItemId]
@@ -3097,7 +3103,7 @@ end
30973103
-- Helper: draw Copy, Copy+Use, and Buy buttons at the given position.
30983104
-- btnStartX is the left edge where the first button (Buy) should appear.
30993105
-- Returns copyHovered, copyUseHovered, buyHovered booleans.
3100-
local function drawCopyButtons(cursorX, cursorY, btnStartX, btnY)
3106+
local function drawCopyButtons(cursorX, cursorY, btnStartX, btnY, slotMissing)
31013107
local btnW = LAYOUT.itemsCopyBtnW
31023108
local btnH = LAYOUT.itemsCopyBtnH
31033109
local buyW = LAYOUT.itemsBuyBtnW
@@ -3125,15 +3131,23 @@ local function drawCopyButtons(cursorX, cursorY, btnStartX, btnY)
31253131
SetDrawColor(1, 1, 1)
31263132
DrawString(btn1X + btnW / 2, btnY + 1, "CENTER_X", 14, "VAR", "^7Copy")
31273133

3128-
-- "Copy+Use" button
3129-
local b2Hover = cursorX >= btn2X and cursorX < btn2X + btnW
3130-
and cursorY >= btnY and cursorY < btnY + btnH
3131-
SetDrawColor(b2Hover and 0.5 or 0.35, b2Hover and 0.5 or 0.35, b2Hover and 0.5 or 0.35)
3132-
DrawImage(nil, btn2X, btnY, btnW, btnH)
3133-
SetDrawColor(0.1, 0.1, 0.1)
3134-
DrawImage(nil, btn2X + 1, btnY + 1, btnW - 2, btnH - 2)
3135-
SetDrawColor(1, 1, 1)
3136-
DrawString(btn2X + btnW / 2, btnY + 1, "CENTER_X", 14, "VAR", "^7Copy+Use")
3134+
local b2Hover
3135+
if slotMissing then
3136+
-- Show "Missing slot" label instead of Copy+Use button
3137+
SetDrawColor(1, 1, 1)
3138+
DrawString(btn2X + btnW / 2, btnY + 1, "CENTER_X", 14, "VAR", "^xBBBBBBMissing slot")
3139+
b2Hover = false
3140+
else
3141+
-- "Copy+Use" button
3142+
b2Hover = cursorX >= btn2X and cursorX < btn2X + btnW
3143+
and cursorY >= btnY and cursorY < btnY + btnH
3144+
SetDrawColor(b2Hover and 0.5 or 0.35, b2Hover and 0.5 or 0.35, b2Hover and 0.5 or 0.35)
3145+
DrawImage(nil, btn2X, btnY, btnW, btnH)
3146+
SetDrawColor(0.1, 0.1, 0.1)
3147+
DrawImage(nil, btn2X + 1, btnY + 1, btnW - 2, btnH - 2)
3148+
SetDrawColor(1, 1, 1)
3149+
DrawString(btn2X + btnW / 2, btnY + 1, "CENTER_X", 14, "VAR", "^7Copy+Use")
3150+
end
31373151

31383152
return b1Hover, b2Hover, b3Hover, btn2X, btnY, btnW, btnH
31393153
end
@@ -3162,7 +3176,7 @@ local ITEM_BOX_W = 310
31623176
local ITEM_BOX_H = 20
31633177

31643178
local function drawCompactSlotRow(drawY, slotLabel, pItem, cItem,
3165-
colWidth, cursorX, cursorY, maxLabelW, primaryItemsTab, compareItemsTab, pWarn, cWarn)
3179+
colWidth, cursorX, cursorY, maxLabelW, primaryItemsTab, compareItemsTab, pWarn, cWarn, slotMissing)
31663180

31673181
local pName = pItem and pItem.name or "(empty)"
31683182
local cName = cItem and cItem.name or "(empty)"
@@ -3219,7 +3233,7 @@ local function drawCompactSlotRow(drawY, slotLabel, pItem, cItem,
32193233
if cItem then
32203234
local btnStartX = cBoxX + cBoxW + 6
32213235
b1Hover, b2Hover, b3Hover, b2X, b2Y, b2W, b2H =
3222-
drawCopyButtons(cursorX, cursorY, btnStartX, drawY + 1)
3236+
drawCopyButtons(cursorX, cursorY, btnStartX, drawY + 1, slotMissing)
32233237
end
32243238

32253239
-- Determine hovered item and tooltip anchor position
@@ -3405,8 +3419,21 @@ function CompareTabClass:DrawItemExpanded(item, x, startY, colWidth, otherModMap
34053419
return drawY - startY
34063420
end
34073421

3422+
function CompareTabClass:ShouldShowRing3(compareEntry)
3423+
local primaryEnv = self.primaryBuild.calcsTab and self.primaryBuild.calcsTab.mainEnv
3424+
local compareEnv = compareEntry.calcsTab and compareEntry.calcsTab.mainEnv
3425+
local primaryHas = primaryEnv and primaryEnv.modDB:Flag(nil, "AdditionalRingSlot")
3426+
local compareHas = compareEnv and compareEnv.modDB:Flag(nil, "AdditionalRingSlot")
3427+
return primaryHas or compareHas
3428+
end
3429+
34083430
function CompareTabClass:DrawItems(vp, compareEntry, inputEvents)
34093431
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
3432+
if self:ShouldShowRing3(compareEntry) then
3433+
t_insert(baseSlots, 10, "Ring 3")
3434+
end
3435+
local primaryEnv = self.primaryBuild.calcsTab and self.primaryBuild.calcsTab.mainEnv
3436+
local primaryHasRing3 = primaryEnv and primaryEnv.modDB:Flag(nil, "AdditionalRingSlot")
34103437
local lineHeight = 20
34113438
local colWidth = m_floor(vp.width / 2)
34123439

@@ -3470,7 +3497,8 @@ function CompareTabClass:DrawItems(vp, compareEntry, inputEvents)
34703497

34713498
-- Copy/Buy buttons for compare item
34723499
if cItem then
3473-
local b1Hover, b2Hover, b3Hover, b2X, b2Y, b2W, b2H = drawCopyButtons(cursorX, cursorY, vp.width - 196, drawY + 1)
3500+
local slotMissing = slotName == "Ring 3" and not primaryHasRing3
3501+
local b1Hover, b2Hover, b3Hover, b2X, b2Y, b2W, b2H = drawCopyButtons(cursorX, cursorY, vp.width - 196, drawY + 1, slotMissing)
34743502
if b2Hover then
34753503
hoverCopyUseItem = cItem
34763504
hoverCopyUseSlotName = slotName
@@ -3519,7 +3547,8 @@ function CompareTabClass:DrawItems(vp, compareEntry, inputEvents)
35193547
rowHoverItem, rowHoverItemsTab, rowHoverX, rowHoverY, rowHoverW, rowHoverH =
35203548
drawCompactSlotRow(drawY, slotName, pItem, cItem,
35213549
colWidth, cursorX, cursorY, maxLabelW,
3522-
self.primaryBuild.itemsTab, compareEntry.itemsTab)
3550+
self.primaryBuild.itemsTab, compareEntry.itemsTab, nil, nil,
3551+
slotName == "Ring 3" and not primaryHasRing3)
35233552

35243553
if rowHoverItem then
35253554
hoverItem = rowHoverItem

0 commit comments

Comments
 (0)