Skip to content

Commit ad2c0b6

Browse files
committed
Right click to pin stats to sidebar
Allows user to right click any item in the calcs tab to pin that item to the sidebar display.
1 parent 9c2bf03 commit ad2c0b6

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

src/Classes/CalcSectionControl.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function CalcSectionClass:IsMouseOver()
7474
return mOver, colData
7575
end
7676
elseif cursorX >= colData.x and cursorY >= colData.y and cursorX < colData.x + colData.width and cursorY < colData.y + colData.height then
77+
colData.pinnedLabel = data.label
7778
return mOver, colData
7879
end
7980
end
@@ -330,11 +331,19 @@ function CalcSectionClass:OnKeyDown(key, doubleClick)
330331
return
331332
end
332333
if mOverComp then
334+
--Add the stat to siderbar under "Pinned:"
335+
if key == "RIGHTBUTTON" then
336+
self.calcsTab:AddSidebarPinnedStat(mOverComp)
337+
return
338+
end
333339
-- Pin the stat breakdown
334-
self.calcsTab:SetDisplayStat(mOverComp, true)
335-
return self.calcsTab.controls.breakdown
340+
if key == "LEFTBUTTON" then
341+
self.calcsTab:SetDisplayStat(mOverComp, true)
342+
return self.calcsTab.controls.breakdown
343+
end
336344
end
337345
end
346+
338347
return
339348
end
340349

src/Classes/CalcsTab.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,31 @@ function CalcsTabClass:SetDisplayStat(displayData, pin)
411411
self.controls.breakdown:SetBreakdownData(displayData, pin)
412412
end
413413

414+
function CalcsTabClass:AddSidebarPinnedStat(displayData)
415+
if not displayData or not displayData.format then
416+
return
417+
end
418+
419+
self.sidebarPinnedStats = self.sidebarPinnedStats or { }
420+
421+
local displayLabel = displayData.pinnedLabel or ""
422+
local displayFormat = displayData.format or ""
423+
424+
for index, pinned in ipairs(self.sidebarPinnedStats) do
425+
local pinnedLabel = pinned.pinnedLabel or ""
426+
local pinnedFormat = pinned.format or ""
427+
428+
if pinnedLabel == displayLabel and pinnedFormat == displayFormat then
429+
table.remove(self.sidebarPinnedStats, index)
430+
self.build:RefreshStatList()
431+
return
432+
end
433+
end
434+
435+
table.insert(self.sidebarPinnedStats, displayData)
436+
437+
self.build:RefreshStatList()
438+
end
414439
function CalcsTabClass:CheckFlag(obj)
415440
local actor = self.input.showMinion and self.calcsEnv.minion or self.calcsEnv.player
416441
local skillFlags = actor.mainSkill.activeEffect.statSetCalcs.skillFlags

src/Modules/Build.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,16 @@ function buildMode:RefreshStatList()
22572257
t_insert(statBoxList, { height = 14, align = "CENTER_X", x = 140, self.calcsTab.mainEnv.player.mainSkill.disableReason })
22582258
end
22592259
self:AddDisplayStatList(self.displayStats, self.calcsTab.mainEnv.player)
2260+
if self.calcsTab.sidebarPinnedStats and #self.calcsTab.sidebarPinnedStats > 0 then
2261+
local actor = self.calcsTab.mainEnv.player
2262+
t_insert(statBoxList, { height = 10 })
2263+
t_insert(statBoxList, { height = 18, "^7Pinned:" })
2264+
for i, pinned in ipairs(self.calcsTab.sidebarPinnedStats) do
2265+
local label = pinned.pinnedLabel or ("Pinned " .. tostring(i))
2266+
local value = formatCalcStr(pinned.format, actor, pinned)
2267+
t_insert(statBoxList, { height = 16, "^7" .. label, "^7" .. tostring(value) })
2268+
end
2269+
end
22602270
self:InsertItemWarnings()
22612271
self:EstimatePlayerProgress()
22622272
end

0 commit comments

Comments
 (0)