Skip to content

Commit 9b7a967

Browse files
PeecheyLocalIdentityWires77
authored
Add support for Imbued Supports (#9670)
Co-authored-by: LocalIdentity <localidentity2@gmail.com> Co-authored-by: Wires77 <Wires77@users.noreply.github.com>
1 parent c2dcb87 commit 9b7a967

File tree

6 files changed

+226
-72
lines changed

6 files changed

+226
-72
lines changed

src/Classes/GemSelectControl.lua

Lines changed: 72 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ local m_max = math.max
1212
local m_floor = math.floor
1313

1414
local toolTipText = "Prefix tag searches with a colon and exclude tags with a dash. e.g. :fire:lightning:-cold:area"
15+
local imbuedTooltipText = "\"Socketed in\" item must be set in order to add an imbued support.\nOnly one imbued support is allowed per item."
1516

16-
local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip)
17+
local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip, imbued)
1718
self.EditControl(anchor, rect, nil, nil, "^ %a':-")
1819
self.controls.scrollBar = new("ScrollBarControl", { "TOPRIGHT", self, "TOPRIGHT" }, {-1, 0, 18, 0}, (self.height - 4) * 4)
1920
self.controls.scrollBar.y = function()
@@ -50,6 +51,7 @@ local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self
5051
lifeReservationFlat = "Life",
5152
lifeReservationPercent = "LifePercent",
5253
}
54+
self.imbuedSelect = imbued
5355
end)
5456

5557
function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS)
@@ -74,7 +76,7 @@ function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS)
7476

7577
-- Create gemInstance to represent the hovered gem
7678
local gemInstance = gemList[self.index]
77-
gemInstance.level = self.skillsTab:ProcessGemLevel(gemData)
79+
gemInstance.level = self.skillsTab:ProcessGemLevel(gemData, self.imbuedSelect)
7880
gemInstance.gemData = gemData
7981
gemInstance.displayEffect = nil
8082
-- Calculate the impact of using this gem
@@ -105,12 +107,19 @@ function GemSelectClass:PopulateGemList()
105107
if (self.sortGemsBy and gemData.tags[self.sortGemsBy] == true or not self.sortGemsBy) then
106108
local levelRequirement = gemData.grantedEffect.levels[1].levelRequirement or 1
107109
if characterLevel >= levelRequirement or not matchLevel then
108-
if (showExceptional or showAll) and ((gemData.grantedEffect.legacy and gemData.grantedEffect.plusVersionOf) or gemData.tagString:match("Exceptional")) then
109-
if self.skillsTab.showLegacyGems or not gemData.grantedEffect.legacy then
110+
if self.imbuedSelect then
111+
-- Imbued dropdown only allows non-exceptional support gems.
112+
if gemData.grantedEffect.support and not gemData.tagString:match("Exceptional") and not gemData.grantedEffect.plusVersionOf then
113+
self.gems["Default:" .. gemId] = gemData
114+
end
115+
else
116+
if (showExceptional or showAll) and ((gemData.grantedEffect.legacy and gemData.grantedEffect.plusVersionOf) or gemData.tagString:match("Exceptional")) then
117+
if self.skillsTab.showLegacyGems or not gemData.grantedEffect.legacy then
118+
self.gems["Default:" .. gemId] = gemData
119+
end
120+
elseif showNormal or showAll then
110121
self.gems["Default:" .. gemId] = gemData
111122
end
112-
elseif showNormal or showAll then
113-
self.gems["Default:" .. gemId] = gemData
114123
end
115124
end
116125
end
@@ -123,6 +132,11 @@ function GemSelectClass:FilterSupport(gemId, gemData)
123132
if gemData.grantedEffect.legacy and not self.skillsTab.showLegacyGems then
124133
return false
125134
end
135+
136+
if self.imbuedSelect then
137+
return gemData.grantedEffect.support and not gemData.tagString:match("Exceptional") and self.sortCache.canSupport[gemId]
138+
end
139+
126140
return (not gemData.grantedEffect.support
127141
or showSupportTypes == "ALL"
128142
or (showSupportTypes == "NORMAL" and not (isLegacyAwakened or gemData.tagString:match("Exceptional")))
@@ -273,7 +287,7 @@ function GemSelectClass:UpdateSortCache()
273287
for gemId, gemData in pairs(self.gems) do
274288
if gemData.grantedEffect.support then
275289
for _, activeSkill in ipairs(self.skillsTab.displayGroup.displaySkillList) do
276-
if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill) then
290+
if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill, self.imbuedSelect) then
277291
sortCache.canSupport[gemId] = true
278292
break
279293
end
@@ -288,7 +302,7 @@ function GemSelectClass:UpdateSortCache()
288302
for gemId, gemData in pairs(self.gems) do
289303
if gemData.grantedEffect.support then
290304
for _, activeSkill in ipairs(group.displaySkillList) do
291-
if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill) then
305+
if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill, self.imbuedSelect) then
292306
sortCache.canSupport[gemId] = true
293307
break
294308
end
@@ -301,7 +315,7 @@ function GemSelectClass:UpdateSortCache()
301315
for gemId, gemData in pairs(self.gems) do
302316
if gemData.grantedEffect.support then
303317
for _, activeSkill in ipairs(group.displaySkillList) do
304-
if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill) then
318+
if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill, self.imbuedSelect) then
305319
sortCache.canSupport[gemId] = true
306320
break
307321
end
@@ -468,7 +482,7 @@ function GemSelectClass:Draw(viewPort, noTooltip)
468482
local gemData = self.gems[self.list[self.hoverSel]]
469483
local output= self:CalcOutputWithThisGem(calcFunc, gemData, self.skillsTab.sortGemsByDPSField == "FullDPS")
470484
local gemInstance = {
471-
level = self.skillsTab:ProcessGemLevel(gemData),
485+
level = self.skillsTab:ProcessGemLevel(gemData, self.imbuedSelect),
472486
quality = self.skillsTab.defaultGemQuality or 0,
473487
count = 1,
474488
enabled = true,
@@ -508,41 +522,55 @@ function GemSelectClass:Draw(viewPort, noTooltip)
508522
local gemInstance = self.skillsTab.displayGroup.gemList[self.index]
509523
local cursorX, cursorY = GetCursorPos()
510524
self.tooltip:Clear()
525+
526+
if hoverControl and hoverControl.imbuedSelect then -- tooltip for imbued
527+
gemInstance = { }
528+
if type(hoverControl.gemId) == "string" then -- on select
529+
gemInstance["gemData"] = hoverControl.gems[hoverControl.gemId]
530+
else -- on load
531+
gemInstance["gemData"] = hoverControl.gemId
532+
end
533+
gemInstance.level = 1
534+
gemInstance.quality = 0
535+
end
536+
511537
if gemInstance and gemInstance.gemData then
512538
self:AddGemTooltip(gemInstance)
513539
else
514-
self.tooltip:AddLine(16, toolTipText)
515-
end
540+
self.tooltip:AddLine(16, self.imbuedSelect and imbuedTooltipText or toolTipText)
541+
end
542+
543+
if not self.imbuedSelect then
544+
colorS = 0.5
545+
colorA = 0.5
546+
if cursorX > (x + width - 18) then
547+
colorS = 1
548+
self.tooltip:Clear()
549+
self.tooltip:AddLine(16, "Only show Support gems")
550+
elseif (cursorX > (x + width - 40) and cursorX < (cursorX + width - 20)) then
551+
colorA = 1
552+
self.tooltip:Clear()
553+
self.tooltip:AddLine(16, "Only show Active gems")
554+
end
516555

517-
colorS = 0.5
518-
colorA = 0.5
519-
if cursorX > (x + width - 18) then
520-
colorS = 1
521-
self.tooltip:Clear()
522-
self.tooltip:AddLine(16, "Only show Support gems")
523-
elseif (cursorX > (x + width - 40) and cursorX < (cursorX + width - 20)) then
524-
colorA = 1
525-
self.tooltip:Clear()
526-
self.tooltip:AddLine(16, "Only show Active gems")
527-
end
528-
529-
-- support shortcut
530-
sx = x + width - 16 - 2
531-
SetDrawColor(colorS,colorS,colorS)
532-
DrawImage(nil, sx, y+2, 16, height-4)
533-
SetDrawColor(0,0,0)
534-
DrawImage(nil, sx+1, y+2, 16-2, height-4)
535-
SetDrawColor(colorS,colorS,colorS)
536-
DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "S")
537-
538-
-- active shortcut
539-
sx = x + width - (16*2) - (2*2)
540-
SetDrawColor(colorA,colorA,colorA)
541-
DrawImage(nil, sx, y+2, 16, height-4)
542-
SetDrawColor(0,0,0)
543-
DrawImage(nil, sx+1, y+2, 16-2, height-4)
544-
SetDrawColor(colorA,colorA,colorA)
545-
DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "A")
556+
-- support shortcut
557+
sx = x + width - 16 - 2
558+
SetDrawColor(colorS,colorS,colorS)
559+
DrawImage(nil, sx, y+2, 16, height-4)
560+
SetDrawColor(0,0,0)
561+
DrawImage(nil, sx+1, y+2, 16-2, height-4)
562+
SetDrawColor(colorS,colorS,colorS)
563+
DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "S")
564+
565+
-- active shortcut
566+
sx = x + width - (16*2) - (2*2)
567+
SetDrawColor(colorA,colorA,colorA)
568+
DrawImage(nil, sx, y+2, 16, height-4)
569+
SetDrawColor(0,0,0)
570+
DrawImage(nil, sx+1, y+2, 16-2, height-4)
571+
SetDrawColor(colorA,colorA,colorA)
572+
DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "A")
573+
end
546574

547575
SetDrawLayer(nil, 10)
548576
self.tooltip:Draw(x, y, width, height, viewPort)
@@ -738,7 +766,7 @@ function GemSelectClass:OnFocusGained()
738766
self:UpdateSortCache()
739767
self:BuildList("")
740768
for index, gemId in pairs(self.list) do
741-
if self.gems[gemId].name == self.buf then
769+
if self.gems[gemId] and self.gems[gemId].name == self.buf then
742770
self.selIndex = index
743771
self:ScrollSelIntoView()
744772
break
@@ -768,7 +796,7 @@ function GemSelectClass:OnKeyDown(key, doubleClick)
768796
local width, height = self:GetSize()
769797
local cursorX, cursorY = GetCursorPos()
770798
-- constrain cursor to the height of the control
771-
if key == "LEFTBUTTON" and (cursorY > y and cursorY < (y + height)) then
799+
if not self.imbuedSelect and key == "LEFTBUTTON" and (cursorY > y and cursorY < (y + height)) then
772800
-- no need to constrain right side of the S overlay as that's outside hover
773801
if cursorX > (x + width - 18) then
774802
self.sortGemsBy = "support" -- only need to change sortBy, code will continue to UpdateSortCache
@@ -880,4 +908,4 @@ function GemSelectClass:OnKeyUp(key)
880908
end
881909
local newSel = self.EditControl:OnKeyUp(key)
882910
return newSel == self.EditControl and self or newSel
883-
end
911+
end

src/Classes/ImportTab.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ function ImportTabClass:ImportItemsAndSkills(json)
758758
end
759759
end
760760
wipeTable(self.build.skillsTab.socketGroupList)
761+
self.build.skillsTab:RebuildImbuedSupportBySlot()
761762
end
762763
self.charImportStatus = colorCodes.POSITIVE.."Items and skills successfully imported."
763764
--ConPrintTable(charItemData)
@@ -1148,6 +1149,10 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
11481149
else
11491150
t_insert(socketGroup.gemList, gemInstance)
11501151
end
1152+
if socketedItem.builtInSupport then
1153+
socketGroup.imbuedSupport = socketedItem.builtInSupport:gsub("Supported by Level 1 ", "")
1154+
self.build.skillsTab.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, slotName)
1155+
end
11511156
end
11521157
end
11531158
end

src/Classes/SkillListControl.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ local SkillListClass = newClass("SkillListControl", "ListControl", function(self
3939
self.controls.deleteAll = new("ButtonControl", {"RIGHT",self.controls.delete,"LEFT"}, {-4, 0, 70, 18}, "Delete All", function()
4040
main:OpenConfirmPopup("Delete All", "Are you sure you want to delete all socket groups in this build?", "Delete", function()
4141
wipeTable(self.list)
42+
skillsTab:RebuildImbuedSupportBySlot()
4243
skillsTab:SetDisplayGroup()
4344
skillsTab:AddUndoState()
4445
skillsTab.build.buildFlag = true
@@ -165,6 +166,7 @@ function SkillListClass:OnSelDelete(index, socketGroup)
165166
main:OpenMessagePopup("Delete Socket Group", "This socket group cannot be deleted as it is created by an equipped item.")
166167
elseif not socketGroup.gemList[1] then
167168
t_remove(self.list, index)
169+
self.skillsTab:RebuildImbuedSupportBySlot()
168170
if self.skillsTab.displayGroup == socketGroup then
169171
self.skillsTab.displayGroup = nil
170172
end
@@ -175,6 +177,7 @@ function SkillListClass:OnSelDelete(index, socketGroup)
175177
else
176178
main:OpenConfirmPopup("Delete Socket Group", "Are you sure you want to delete '"..socketGroup.displayLabel.."'?", "Delete", function()
177179
t_remove(self.list, index)
180+
self.skillsTab:RebuildImbuedSupportBySlot()
178181
if self.skillsTab.displayGroup == socketGroup then
179182
self.skillsTab:SetDisplayGroup()
180183
end

0 commit comments

Comments
 (0)