@@ -4152,7 +4152,104 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
41524152 end
41534153 end
41544154
4155- -- Draw matched pairs
4155+ -- Helper: check if gemA supports gemB (mirrors GemSelectControl:CheckSupporting)
4156+ local function checkSupporting (gemA , gemB )
4157+ if not gemA .gemData or not gemB .gemData then return false end
4158+ return (gemA .gemData .grantedEffect and gemA .gemData .grantedEffect .support
4159+ and gemB .gemData .grantedEffect and not gemB .gemData .grantedEffect .support
4160+ and gemA .supportEffect and gemA .supportEffect .isSupporting
4161+ and gemA .supportEffect .isSupporting [gemB ])
4162+ or (gemA .gemData .secondaryGrantedEffect
4163+ and gemA .gemData .secondaryGrantedEffect .support
4164+ and gemB .gemData .grantedEffect and not gemB .gemData .grantedEffect .support
4165+ and gemA .supportEffect and gemA .supportEffect .isSupporting
4166+ and gemA .supportEffect .isSupporting [gemB ])
4167+ end
4168+
4169+ local gemFontSize = 16
4170+ local gemLineHeight = 18
4171+ local gemTextWidth = colWidth - 30
4172+
4173+ -- Position pre-pass: compute gem positions without drawing to enable hover hit-testing
4174+ local gemEntries = {} -- { gem, x, y, group }
4175+ local preY = 4 - self .scrollY + 24 -- after headers
4176+ for _ , pair in ipairs (renderPairs ) do
4177+ preY = preY + 2 -- separator
4178+ local pSet = pair .pIdx and pSets [pair .pIdx ] or {}
4179+ local cSet = pair .cIdx and cSets [pair .cIdx ] or {}
4180+ local pGemY = preY + lineHeight
4181+ local cGemY = preY + lineHeight
4182+
4183+ -- Primary group gems
4184+ local pGroup = pair .pIdx and pGroups [pair .pIdx ]
4185+ if pGroup then
4186+ for _ , gem in ipairs (pGroup .gemList or {}) do
4187+ t_insert (gemEntries , { gem = gem , x = 20 , y = pGemY , group = pGroup })
4188+ pGemY = pGemY + gemLineHeight
4189+ end
4190+ if pair .cIdx then
4191+ for name in pairs (cSet ) do
4192+ if not pSet [name ] then
4193+ pGemY = pGemY + gemLineHeight -- missing gem placeholder
4194+ end
4195+ end
4196+ end
4197+ end
4198+
4199+ -- Compare group gems
4200+ local cGroup = pair .cIdx and cGroups [pair .cIdx ]
4201+ if cGroup then
4202+ for _ , gem in ipairs (cGroup .gemList or {}) do
4203+ t_insert (gemEntries , { gem = gem , x = colWidth + 20 , y = cGemY , group = cGroup })
4204+ cGemY = cGemY + gemLineHeight
4205+ end
4206+ if pair .pIdx then
4207+ for name in pairs (pSet ) do
4208+ if not cSet [name ] then
4209+ cGemY = cGemY + gemLineHeight
4210+ end
4211+ end
4212+ end
4213+ end
4214+
4215+ preY = preY + m_max (pGemY - preY , cGemY - preY ) + 6
4216+ end
4217+
4218+ -- Hit-test: find hovered gem
4219+ local cursorX , cursorY = GetCursorPos ()
4220+ local localCursorX = cursorX - vp .x
4221+ local localCursorY = cursorY - vp .y
4222+ local hoveredEntry = nil
4223+ if localCursorX >= 0 and localCursorX < vp .width and localCursorY >= 0 and localCursorY < vp .height then
4224+ for _ , entry in ipairs (gemEntries ) do
4225+ if localCursorX >= entry .x and localCursorX < entry .x + gemTextWidth
4226+ and localCursorY >= entry .y and localCursorY < entry .y + gemLineHeight then
4227+ hoveredEntry = entry
4228+ break
4229+ end
4230+ end
4231+ end
4232+
4233+ -- Build set of highlighted gems based on hover
4234+ local highlightSet = {}
4235+ if hoveredEntry then
4236+ highlightSet [hoveredEntry .gem ] = true
4237+ for _ , entry in ipairs (gemEntries ) do
4238+ if entry .group == hoveredEntry .group and entry .gem ~= hoveredEntry .gem then
4239+ if checkSupporting (hoveredEntry .gem , entry .gem ) or checkSupporting (entry .gem , hoveredEntry .gem ) then
4240+ highlightSet [entry .gem ] = true
4241+ end
4242+ end
4243+ end
4244+ -- Only keep highlights if there's at least one linked gem (not just the hovered one)
4245+ local count = 0
4246+ for _ in pairs (highlightSet ) do count = count + 1 end
4247+ if count <= 1 then
4248+ highlightSet = {}
4249+ end
4250+ end
4251+
4252+ -- Draw pass
41564253 for _ , pair in ipairs (renderPairs ) do
41574254 SetDrawColor (0.3 , 0.3 , 0.3 )
41584255 DrawImage (nil , 4 , drawY , vp .width - 8 , 1 )
@@ -4173,6 +4270,10 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
41734270 DrawString (10 , drawY , " LEFT" , 16 , " VAR" , " ^7" .. groupLabel )
41744271 local gemY = drawY + lineHeight
41754272 for _ , gem in ipairs (pGroup .gemList or {}) do
4273+ if highlightSet [gem ] then
4274+ SetDrawColor (0.33 , 1 , 0.33 , 0.25 )
4275+ DrawImage (nil , 20 , gemY , gemTextWidth , gemLineHeight )
4276+ end
41764277 local gemName = gem .grantedEffect and gem .grantedEffect .name or gem .nameSpec or " ?"
41774278 local gemColor = gem .color or colorCodes .GEM
41784279 local levelStr = gem .level and (" Lv" .. gem .level ) or " "
@@ -4181,8 +4282,8 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
41814282 if pair .cIdx and not cSet [gemName ] then
41824283 prefix = colorCodes .POSITIVE .. " + "
41834284 end
4184- DrawString (20 , gemY , " LEFT" , 14 , " VAR" , prefix .. gemColor .. gemName .. " ^7" .. levelStr .. qualStr )
4185- gemY = gemY + 16
4285+ DrawString (20 , gemY , " LEFT" , gemFontSize , " VAR" , prefix .. gemColor .. gemName .. " ^7" .. levelStr .. qualStr )
4286+ gemY = gemY + gemLineHeight
41864287 end
41874288 -- Show gems missing from primary but present in compare
41884289 if pair .cIdx then
@@ -4194,8 +4295,8 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
41944295 end
41954296 table.sort (missing )
41964297 for _ , name in ipairs (missing ) do
4197- DrawString (20 , gemY , " LEFT" , 14 , " VAR" , colorCodes .NEGATIVE .. " - " .. name .. " ^7" )
4198- gemY = gemY + 16
4298+ DrawString (20 , gemY , " LEFT" , gemFontSize , " VAR" , colorCodes .NEGATIVE .. " - " .. name .. " ^7" )
4299+ gemY = gemY + gemLineHeight
41994300 end
42004301 end
42014302 pFinalGemY = gemY
@@ -4211,6 +4312,10 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
42114312 DrawString (colWidth + 10 , drawY , " LEFT" , 16 , " VAR" , " ^7" .. groupLabel )
42124313 local gemY = drawY + lineHeight
42134314 for _ , gem in ipairs (cGroup .gemList or {}) do
4315+ if highlightSet [gem ] then
4316+ SetDrawColor (0.33 , 1 , 0.33 , 0.25 )
4317+ DrawImage (nil , colWidth + 20 , gemY , gemTextWidth , gemLineHeight )
4318+ end
42144319 local gemName = gem .grantedEffect and gem .grantedEffect .name or gem .nameSpec or " ?"
42154320 local gemColor = gem .color or colorCodes .GEM
42164321 local levelStr = gem .level and (" Lv" .. gem .level ) or " "
@@ -4219,8 +4324,8 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
42194324 if pair .pIdx and not pSet [gemName ] then
42204325 prefix = colorCodes .POSITIVE .. " + "
42214326 end
4222- DrawString (colWidth + 20 , gemY , " LEFT" , 14 , " VAR" , prefix .. gemColor .. gemName .. " ^7" .. levelStr .. qualStr )
4223- gemY = gemY + 16
4327+ DrawString (colWidth + 20 , gemY , " LEFT" , gemFontSize , " VAR" , prefix .. gemColor .. gemName .. " ^7" .. levelStr .. qualStr )
4328+ gemY = gemY + gemLineHeight
42244329 end
42254330 -- Show gems missing from compare but present in primary
42264331 if pair .pIdx then
@@ -4232,8 +4337,8 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
42324337 end
42334338 table.sort (missing )
42344339 for _ , name in ipairs (missing ) do
4235- DrawString (colWidth + 20 , gemY , " LEFT" , 14 , " VAR" , colorCodes .NEGATIVE .. " - " .. name .. " ^7" )
4236- gemY = gemY + 16
4340+ DrawString (colWidth + 20 , gemY , " LEFT" , gemFontSize , " VAR" , colorCodes .NEGATIVE .. " - " .. name .. " ^7" )
4341+ gemY = gemY + gemLineHeight
42374342 end
42384343 end
42394344 cFinalGemY = gemY
0 commit comments