Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,22 @@ function GemSelectClass:SortGemList(gemList)
end)
end

function GemSelectClass:UpdateGem(setText, addUndo)
function GemSelectClass:UpdateGem(setText, addUndo, focusLost)
local gemId = self.list[m_max(self.selIndex, 1)]
-- don't process unless the buffer equals an actual gem, whether typed, clicked, or navigated with arrows
-- we don't nil the gemId here if it doesn't match because the imbuedGemSelect and slotGemSelect have different paths
local bufMatchesGem = (self.gems[gemId] and self.buf:lower() == self.gems[gemId].name:lower())

if self.buf:match("%S") and self.gems[gemId] then
self.gemId = gemId
else
self.gemId = nil
end
self.gemName = self.gemId and self.gems[self.gemId].name or ""
self.gemName = bufMatchesGem and (self.gemId and self.gems[self.gemId].name) or ""
if setText then
self:SetText(self.gemName)
end
self.gemChangeFunc(self.gemId and self.gemId:gsub("%w+:", ""), addUndo and self.gemName ~= self.initialBuf)
self.gemChangeFunc(self.gemId and self.gemId:gsub("%w+:", ""), addUndo and self.gemName ~= self.initialBuf, focusLost, bufMatchesGem)
end

function GemSelectClass:ScrollSelIntoView()
Expand Down Expand Up @@ -787,7 +791,7 @@ function GemSelectClass:OnFocusLost()
if self.noMatches then
self:SetText("")
end
self:UpdateGem(true,true)
self:UpdateGem(true,true, true)
end
end

Expand Down Expand Up @@ -837,14 +841,14 @@ function GemSelectClass:OnKeyDown(key, doubleClick)
self:SetText("")
end
self.selIndex = m_max(self.selIndex, 1)
self:UpdateGem(true, true)
self:UpdateGem(true, true, true)
return
elseif key == "ESCAPE" then
self.dropped = false
self:BuildList("")
self.buf = self.initialBuf
self.selIndex = self.initialIndex
self:UpdateGem(false,true)
self:UpdateGem(false,true, true)
return
elseif self.controls.scrollBar:IsScrollUpKey(key) then
self.controls.scrollBar:Scroll(-1)
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
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)
self.build.skillsTab.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, true, slotName)
end
end
end
Expand Down
31 changes: 23 additions & 8 deletions src/Classes/SkillsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,15 @@ local SkillsTabClass = newClass("SkillsTab", "UndoHandler", "ControlHost", "Cont
-- the last var in the GemSelectControl init, the true, sets imbuedSelect to true which sets the level to 1 and support filtering
self.imbuedSupportBySlot = { }
self.controls.imbuedSupportLabel = new("LabelControl", { "LEFT", self.controls.groupSlotLabel, "LEFT" }, { 86, 28, 0, 16 }, colorCodes.CRAFTED.."Imbued Support:")
self.controls.imbuedSupport = new("GemSelectControl", { "LEFT", self.controls.imbuedSupportLabel, "RIGHT" }, { 8, 0, 250, 20 }, self, 1, function(gemData, _, _, slotName) -- slotName used on Import
self.controls.imbuedSupport = new("GemSelectControl", { "LEFT", self.controls.imbuedSupportLabel, "RIGHT" }, { 8, 0, 250, 20 }, self, 1, function(gemData, _, _, gemMatch, slotName)
local targetSlot = slotName or (self.displayGroup and self.displayGroup.slot)
if not targetSlot then
return
end
local updateDisplayGroup = self.displayGroup and targetSlot == self.displayGroup.slot
if not gemMatch then
gemData = nil
end
if gemData and (type(gemData) == "string" or gemData.id) then
local gem = data.gems[gemData.id or gemData]
self.imbuedSupportBySlot[targetSlot] = gem.grantedEffect
Expand All @@ -233,10 +236,14 @@ local SkillsTabClass = newClass("SkillsTab", "UndoHandler", "ControlHost", "Cont
self.controls.imbuedSupport.inactiveCol = data.skillColorMap[gem.grantedEffect.color]
self.build.buildFlag = true
else
local cleanUp = self.imbuedSupportBySlot[targetSlot]
self.imbuedSupportBySlot[targetSlot] = nil
if updateDisplayGroup then
self.displayGroup.imbuedSupport = nil
end
if cleanUp then -- an imbued existed before clearing it, so reprocess
self.build.buildFlag = true
end
end
end, true, true)
local function isImbuedEnabled() -- socketedIn must be set and the displayGroup must have an imbued, otherwise disable the imbued dropdown
Expand All @@ -251,9 +258,7 @@ local SkillsTabClass = newClass("SkillsTab", "UndoHandler", "ControlHost", "Cont
self.controls.imbuedSupportClear = new("ButtonControl", { "LEFT", self.controls.imbuedSupportLabel, "RIGHT" }, { 260, 0, 20, 20}, "x", function()
self.controls.imbuedSupport.gemId = nil
self.controls.imbuedSupport:SetText("")
self.displayGroup.imbuedSupport = nil
self.imbuedSupportBySlot[self.displayGroup.slot] = nil
self.build.buildFlag = true
self.controls.imbuedSupport:gemChangeFunc(nil)
end)
self.controls.imbuedSupportClear.enabled = function()
return isImbuedEnabled()
Expand Down Expand Up @@ -635,8 +640,7 @@ function SkillsTabClass:CreateGemSlot(index)
local slot = { }
self.gemSlots[index] = slot

-- Delete gem
slot.delete = new("ButtonControl", nil, {0, 0, 20, 20}, "x", function()
local function deleteGem()
t_remove(self.displayGroup.gemList, index)
for index2 = index, #self.displayGroup.gemList do
-- Update the other gem slot controls
Expand All @@ -651,6 +655,10 @@ function SkillsTabClass:CreateGemSlot(index)
end
self:AddUndoState()
self.build.buildFlag = true
end
-- Delete gem
slot.delete = new("ButtonControl", nil, {0, 0, 20, 20}, "x", function()
return deleteGem()
end)
if index == 1 then
slot.delete:SetAnchor("TOPLEFT", self.anchorGemSlots, "TOPLEFT", 0, 0)
Expand All @@ -670,7 +678,7 @@ function SkillsTabClass:CreateGemSlot(index)
self.controls["gemSlot"..index.."Delete"] = slot.delete

-- Gem name specification
slot.nameSpec = new("GemSelectControl", { "LEFT", slot.delete, "RIGHT" }, { 2, 0, 300, 20 }, self, index, function(gemId, addUndo)
slot.nameSpec = new("GemSelectControl", { "LEFT", slot.delete, "RIGHT" }, { 2, 0, 300, 20 }, self, index, function(gemId, addUndo, focusLost, bufMatchesGem)
if not self.displayGroup then
return
end
Expand All @@ -696,10 +704,15 @@ function SkillsTabClass:CreateGemSlot(index)
slot.enableGlobal1.state = true
slot.enableGlobal2.state = true
slot.count:SetText(gemInstance.count)
elseif focusLost and not bufMatchesGem then
return deleteGem()
elseif gemId == gemInstance.gemId then
if addUndo then
self:AddUndoState()
end
if bufMatchesGem then
self.build.buildFlag = true
end
return
end
gemInstance.gemId = gemId
Expand All @@ -713,7 +726,9 @@ function SkillsTabClass:CreateGemSlot(index)
if addUndo then
self:AddUndoState()
end
self.build.buildFlag = true
if bufMatchesGem then
self.build.buildFlag = true
end
end, true)
slot.nameSpec:AddToTabGroup(self.controls.groupLabel)
self.controls["gemSlot"..index.."Name"] = slot.nameSpec
Expand Down
Loading