Skip to content

Commit

Permalink
Add buttons to filter Active and Support gems in Skills tab (#7442)
Browse files Browse the repository at this point in the history
* Add filter buttons as overlay to gem select widget

* Cleanup

* Improve layout

* Cleaner look

* Add tooltips

* Cleanup
  • Loading branch information
ryuukk authored Mar 24, 2024
1 parent 790881d commit b27f505
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self
self.gemChangeFunc = changeFunc
self.forceTooltip = forceTooltip
self.list = { }
self.mode = ""
self.changeFunc = function()
if not self.dropped then
self.dropped = true
Expand Down Expand Up @@ -146,7 +147,8 @@ function GemSelectClass:BuildList(buf)

self.controls.scrollBar.offset = 0
wipeTable(self.list)
self.searchStr = buf
self.searchStr = buf .. self.mode
self.mode = ""
if #self.searchStr > 0 then
local added = { }

Expand Down Expand Up @@ -341,6 +343,7 @@ function GemSelectClass:UpdateSortCache()
sortCache.dpsColor[gemId] = "^xFFFF66"
end
end

--ConPrintf("Gem Selector time: %d ms", GetTime() - start)
end

Expand Down Expand Up @@ -496,7 +499,7 @@ function GemSelectClass:Draw(viewPort, noTooltip)
end
if mOver and (not self.skillsTab.selControl or self.skillsTab.selControl._className ~= "GemSelectControl" or not self.skillsTab.selControl.dropped) and (not noTooltip or self.forceTooltip) then
local gemInstance = self.skillsTab.displayGroup.gemList[self.index]
SetDrawLayer(nil, 10)
local cursorX, cursorY = GetCursorPos()
self.tooltip:Clear()
if gemInstance and gemInstance.gemData then
-- Check valid qualityId, set to 'Default' if missing
Expand All @@ -507,6 +510,39 @@ function GemSelectClass:Draw(viewPort, noTooltip)
else
self.tooltip:AddLine(16, toolTipText)
end

colorS = 0.5
colorA = 0.5
if cursorX > (x + width - 18) then
colorS = 1
self.tooltip:Clear()
self.tooltip:AddLine(16, "Only show Support gems")
elseif (cursorX > (x + width - 40) and cursorX < (cursorX + width - 20)) then
colorA = 1
self.tooltip:Clear()
self.tooltip:AddLine(16, "Only show Active gems")
end

-- support shortcut
sx = x + width - 16 - 2
SetDrawColor(colorS,colorS,colorS)
DrawImage(nil, sx, y, 16, height)
SetDrawColor(0,0,0)
DrawImage(nil, sx+1, y+2, 16-2, height-4)
SetDrawColor(colorS,colorS,colorS)
DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "S")

-- active shortcut
sx = x + width - (16*2) - (2*2)
SetDrawColor(colorA,colorA,colorA)
DrawImage(nil, sx, y, 16, height)
SetDrawColor(0,0,0)
DrawImage(nil, sx+1, y+2, 16-2, height-4)
SetDrawColor(colorA,colorA,colorA)
DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "A")


SetDrawLayer(nil, 10)
self.tooltip:Draw(x, y, width, height, viewPort)
SetDrawLayer(nil, 0)
end
Expand Down Expand Up @@ -713,6 +749,17 @@ function GemSelectClass:OnKeyDown(key, doubleClick)
if not self:IsShown() or not self:IsEnabled() then
return
end

-- for filter overlay buttons
local x, y = self:GetPos()
local width, height = self:GetSize()
local cursorX, cursorY = GetCursorPos()
if cursorX > (x + width - 18) then
self.mode = ":support:"
elseif (cursorX > (x + width - 40) and cursorX < (cursorX + width - 20)) then
self.mode = ":active:"
end

local mOverControl = self:GetMouseOverControl()
if mOverControl and mOverControl.OnKeyDown then
self.selControl = mOverControl
Expand Down Expand Up @@ -814,4 +861,4 @@ function GemSelectClass:OnKeyUp(key)
end
local newSel = self.EditControl:OnKeyUp(key)
return newSel == self.EditControl and self or newSel
end
end

0 comments on commit b27f505

Please sign in to comment.