Skip to content
106 changes: 52 additions & 54 deletions src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ local m_max = math.max
local m_floor = math.floor

local toolTipText = "Prefix tag searches with a colon and exclude tags with a dash. e.g. :fire:lightning:-cold:area"
local imbuedTooltipText = "Socketed in must be set in order to add an imbued support. Only one imbued support is allowed per socketed in."
local altQualMap = {
["Default"] = "",
["Alternate1"] = "Anomalous ",
["Alternate2"] = "Divergent ",
["Alternate3"] = "Phantasmal ",
}

local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip)
local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip, imbued)
self.EditControl(anchor, rect, nil, nil, "^ %a':-")
self.controls.scrollBar = new("ScrollBarControl", { "TOPRIGHT", self, "TOPRIGHT" }, {-1, 0, 18, 0}, (self.height - 4) * 4)
self.controls.scrollBar.y = function()
Expand Down Expand Up @@ -56,6 +57,7 @@ local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self
lifeReservationFlat = "Life",
lifeReservationPercent = "LifePercent",
}
self.imbuedSelect = imbued
end)

function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, qualityId, useFullDPS)
Expand All @@ -81,7 +83,7 @@ function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, qualityId, useF

-- Create gemInstance to represent the hovered gem
local gemInstance = gemList[self.index]
gemInstance.level = self.skillsTab:ProcessGemLevel(gemData)
gemInstance.level = self.skillsTab:ProcessGemLevel(gemData, self.imbuedSelect)
gemInstance.gemData = gemData
gemInstance.displayEffect = nil
if gemInstance.qualityId == nil or gemInstance.qualityId == "" then
Expand Down Expand Up @@ -120,28 +122,27 @@ function GemSelectClass:PopulateGemList()
self.gems["Default:" .. gemId] = gemData
end
elseif showNormal or showAll then
if self.skillsTab.showAltQualityGems and (self.skillsTab.defaultGemQuality or 0) > 0 then
for _, altQual in ipairs(self.skillsTab:getGemAltQualityList(gemData)) do
self.gems[altQual.type .. ":" .. gemId] = gemData
end
else
self.gems["Default:" .. gemId] = gemData
end
self.gems["Default:" .. gemId] = gemData
end
end
end
end
end

function GemSelectClass:GetQualityType(gemId)
return gemId and gemId:gsub(":.+","") or "Default"
function GemSelectClass:GetQualityType() -- todo: whatever is using this adds the Default quality to gems, it seems, can't fully remove yet?
return "Default"
end

function GemSelectClass:FilterSupport(gemId, gemData)
local showSupportTypes = self.skillsTab.showSupportGemTypes
if gemData.grantedEffect.legacy and not self.skillsTab.showLegacyGems then
return false
end

if self.imbuedSelect then
return (gemData.grantedEffect.support and not (gemData.tagString:match("Exceptional")))
end

return (not gemData.grantedEffect.support
or showSupportTypes == "ALL"
or (showSupportTypes == "NORMAL" and not gemData.grantedEffect.plusVersionOf)
Expand Down Expand Up @@ -176,7 +177,7 @@ function GemSelectClass:BuildList(buf)
for i, pattern in ipairs(patternList) do
local matchList = { }
for gemId, gemData in pairs(self.gems) do
if self:FilterSupport(gemId, gemData) and not added[gemId] and ((" "..gemData.name:lower()):match(pattern) or altQualMap[self:GetQualityType(gemId)]:lower():match(pattern)) then
if self:FilterSupport(gemId, gemData) and not added[gemId] and ((" "..gemData.name:lower()):match(pattern)) then
addThisGem = true
if #tagsList > 0 then
for _, tag in ipairs(tagsList) do
Expand Down Expand Up @@ -258,12 +259,11 @@ function GemSelectClass:UpdateSortCache()
and sortCache.outputRevision == self.skillsTab.build.outputRevision and sortCache.defaultLevel == self.skillsTab.defaultGemLevel
and (sortCache.characterLevel == self.skillsTab.build.characterLevel or self.skillsTab.defaultGemLevel ~= "characterLevel")
and sortCache.defaultQuality == self.skillsTab.defaultGemQuality and sortCache.sortType == self.skillsTab.sortGemsByDPSField
and sortCache.considerAlternates == self.skillsTab.showAltQualityGems and sortCache.considerGemType == self.skillsTab.showSupportGemTypes
and sortCache.showLegacyGems == self.skillsTab.showLegacyGems then
and sortCache.considerGemType == self.skillsTab.showSupportGemTypes and sortCache.showLegacyGems == self.skillsTab.showLegacyGems then
return
end

if not sameSortBy or not sortCache or (sortCache.considerAlternates ~= self.skillsTab.showAltQualityGems or sortCache.considerGemType ~= self.skillsTab.showSupportGemTypes
if not sameSortBy or not sortCache or (sortCache.considerGemType ~= self.skillsTab.showSupportGemTypes
or sortCache.showLegacyGems ~= self.skillsTab.showLegacyGems
or sortCache.defaultQuality ~= self.skillsTab.defaultGemQuality
or sortCache.defaultLevel ~= self.skillsTab.defaultGemLevel
Expand All @@ -275,7 +275,6 @@ function GemSelectClass:UpdateSortCache()
-- Initialize a new sort cache
sortCache = {
considerGemType = self.skillsTab.showSupportGemTypes,
considerAlternates = self.skillsTab.showAltQualityGems,
showLegacyGems = self.skillsTab.showLegacyGems,
socketGroup = self.skillsTab.displayGroup,
gemInstance = self.skillsTab.displayGroup.gemList[self.index],
Expand Down Expand Up @@ -470,9 +469,6 @@ function GemSelectClass:Draw(viewPort, noTooltip)
end
end
local gemText = gemData and gemData.name or "<No matches>"
if gemId and gemId ~= "" then
gemText = altQualMap[self:GetQualityType(gemId)] .. gemText
end
DrawString(0, y, "LEFT", height - 4, "VAR", gemText)
if gemData then
if gemData.grantedEffect.support and self.sortCache.canSupport[gemId] then
Expand All @@ -494,7 +490,7 @@ function GemSelectClass:Draw(viewPort, noTooltip)
local qualityType = self:GetQualityType(self.list[self.hoverSel])
local output= self:CalcOutputWithThisGem(calcFunc, gemData, qualityType, self.skillsTab.sortGemsByDPSField == "FullDPS")
local gemInstance = {
level = self.skillsTab:ProcessGemLevel(gemData),
level = self.skillsTab:ProcessGemLevel(gemData, self.imbuedSelect),
qualityId = qualityType,
quality = self.skillsTab.defaultGemQuality or 0,
count = 1,
Expand Down Expand Up @@ -542,38 +538,40 @@ function GemSelectClass:Draw(viewPort, noTooltip)
end
self:AddGemTooltip(gemInstance)
else
self.tooltip:AddLine(16, toolTipText)
end
self.tooltip:AddLine(16, self.imbuedSelect and imbuedTooltipText or toolTipText)
end

if not self.imbuedSelect then
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

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+2, 16, height-4)
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+2, 16, height-4)
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")
-- support shortcut
sx = x + width - 16 - 2
SetDrawColor(colorS,colorS,colorS)
DrawImage(nil, sx, y+2, 16, height-4)
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+2, 16, height-4)
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")
end

SetDrawLayer(nil, 10)
self.tooltip:Draw(x, y, width, height, viewPort)
Expand All @@ -598,7 +596,7 @@ function GemSelectClass:AddGemTooltip(gemInstance)
if secondary and (not secondary.support or gemInstance.gemData.secondaryEffectName) then
local grantedEffect = gemInstance.gemData.VaalGem and secondary or primary
local grantedEffectSecondary = gemInstance.gemData.VaalGem and primary or secondary
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. altQualMap[gemInstance.qualityId]..grantedEffect.name, "FONTIN SC")
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM..grantedEffect.name, "FONTIN SC")
self.tooltip:AddSeparator(10)
self.tooltip:AddLine(fontSizeBig, "^x7F7F7F" .. gemInstance.gemData.tagString, "FONTIN SC")
self:AddCommonGemInfo(gemInstance, grantedEffect, true)
Expand All @@ -608,7 +606,7 @@ function GemSelectClass:AddGemTooltip(gemInstance)
self:AddCommonGemInfo(gemInstance, grantedEffectSecondary)
else
local grantedEffect = gemInstance.gemData.grantedEffect
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. altQualMap[gemInstance.qualityId]..grantedEffect.name, "FONTIN SC")
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM..grantedEffect.name, "FONTIN SC")
self.tooltip:AddSeparator(10)
if grantedEffect.legacy then
self.tooltip:AddLine(fontSizeTitle, colorCodes.WARNING .. "Legacy Gem", "FONTIN SC")
Expand Down Expand Up @@ -911,4 +909,4 @@ function GemSelectClass:OnKeyUp(key)
end
local newSel = self.EditControl:OnKeyUp(key)
return newSel == self.EditControl and self or newSel
end
end
8 changes: 6 additions & 2 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1116,11 +1116,11 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
self:ImportItem(socketedItem, slotName .. " Abyssal Socket "..abyssalSocketId)
abyssalSocketId = abyssalSocketId + 1
else
local normalizedBasename, qualityType = self.build.skillsTab:GetBaseNameAndQuality(socketedItem.typeLine, nil)
local normalizedBasename, qualityType = sanitiseText(socketedItem.typeLine)
local gemId = self.build.data.gemForBaseName[normalizedBasename:lower()]
if socketedItem.hybrid then
-- Used by transfigured gems and dual-skill gems (currently just Stormbind)
normalizedBasename, qualityType = self.build.skillsTab:GetBaseNameAndQuality(socketedItem.hybrid.baseTypeName, nil)
normalizedBasename, qualityType = sanitiseText(socketedItem.hybrid.baseTypeName)
gemId = self.build.data.gemForBaseName[normalizedBasename:lower()]
if gemId and socketedItem.hybrid.isVaalGem then
gemId = self.build.data.gemGrantedEffectIdForVaalGemId[self.build.data.gems[gemId].grantedEffectId]
Expand Down Expand Up @@ -1149,6 +1149,10 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
else
t_insert(socketGroup.gemList, gemInstance)
end
if socketedItem.builtInSupport then
socketGroup.imbuedSupport = socketedItem.builtInSupport:gsub("Supported by Level 1 ", "")
self.build.skillsTab.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, slotName)
end
end
end
end
Expand Down
Loading
Loading