diff --git a/spec/System/TestSkills_spec.lua b/spec/System/TestSkills_spec.lua index 3afa41ce0..b1d1efbb2 100644 --- a/spec/System/TestSkills_spec.lua +++ b/spec/System/TestSkills_spec.lua @@ -245,4 +245,25 @@ describe("TestSkills", function() assert.True(build.calcsTab.calcsOutput.Cooldown == 10) end) -end) \ No newline at end of file + + it("Test active gem DPS sorting estimates replacement skills", function() + build.itemsTab:CreateDisplayItemFromRaw([[ + New Item + Bombard Crossbow + Quality: 0 + ]]) + build.itemsTab:AddDisplayItem() + runCallback("OnFrame") + + build.skillsTab:PasteSocketGroup("Oil Grenade 20/0 1") + runCallback("OnFrame") + + build.skillsTab.sortGemsByDPS = true + build.skillsTab.sortGemsByDPSField = "CombinedDPS" + local activeGemSelect = build.skillsTab.gemSlots[1].nameSpec + activeGemSelect:UpdateSortCache() + + local _, explosiveGrenade = build.skillsTab:FindSkillGem("Explosive Grenade") + assert.True(activeGemSelect.sortCache.dpsCalculated["Default:" .. explosiveGrenade.id]) + end) +end) diff --git a/src/Classes/GemSelectControl.lua b/src/Classes/GemSelectControl.lua index f3b9e11b6..d4ccca3ee 100644 --- a/src/Classes/GemSelectControl.lua +++ b/src/Classes/GemSelectControl.lua @@ -246,6 +246,7 @@ function GemSelectClass:UpdateSortCache() canSupport = { }, dps = { }, dpsColor = { }, + dpsCalculated = { }, sortType = self.skillsTab.sortGemsByDPSField } self.sortCache = sortCache @@ -300,14 +301,19 @@ function GemSelectClass:UpdateSortCache() local calcFunc, calcBase = self.skillsTab.build.calcsTab:GetMiscCalculator(self.build) -- Check for nil because some fields may not be populated, default to 0 local baseDPS = (dpsField == "FullDPS" and calcBase[dpsField] ~= nil and calcBase[dpsField]) or (calcBase.Minion and calcBase.Minion.CombinedDPS) or (calcBase[dpsField] ~= nil and calcBase[dpsField]) or 0 + sortCache.baseDPS = baseDPS for gemId, gemData in pairs(self.gems) do sortCache.dps[gemId] = baseDPS - -- Ignore gems that don't support the active skill - if sortCache.canSupport[gemId] or (gemData.grantedEffect.hasGlobalEffect and not gemData.grantedEffect.support) then + local canEstimateDPS = sortCache.canSupport[gemId] + or (gemData.grantedEffect.hasGlobalEffect and not gemData.grantedEffect.support) + or (self.index == 1 and not gemData.grantedEffect.support) + -- Ignore gems that cannot affect the active skill or replace the active gem + if canEstimateDPS then local output = self:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS, fastCalcOptions, calcBase) -- Check for nil because some fields may not be populated, default to 0 sortCache.dps[gemId] = (dpsField == "FullDPS" and output[dpsField] ~= nil and output[dpsField]) or (output.Minion and output.Minion.CombinedDPS) or (output[dpsField] ~= nil and output[dpsField]) or 0 + sortCache.dpsCalculated[gemId] = true end -- Color based on the DPS if sortCache.dps[gemId] > baseDPS then @@ -438,6 +444,9 @@ function GemSelectClass:Draw(viewPort, noTooltip) elseif gemData.grantedEffect.hasGlobalEffect then SetDrawColor(self.sortCache.dpsColor[gemId]) DrawString(width - 4 - height / 2 - (scrollBar.enabled and 18 or 0), y - 2, "CENTER_X", height, "VAR", "+") + elseif self.sortCache.dpsCalculated[gemId] and self.sortCache.dps[gemId] ~= self.sortCache.baseDPS then + SetDrawColor(self.sortCache.dpsColor[gemId]) + DrawString(width - 4 - height / 2 - (scrollBar.enabled and 18 or 0), y - 2, "CENTER_X", height, "VAR", "+") end end end @@ -907,4 +916,4 @@ function GemSelectClass:OnKeyUp(key) end local newSel = self.EditControl:OnKeyUp(key) return newSel == self.EditControl and self or newSel -end \ No newline at end of file +end