Skip to content

Commit 1bd28f0

Browse files
committed
Add saving and item set functionality to rune selectors
1 parent 96a8f01 commit 1bd28f0

4 files changed

Lines changed: 35 additions & 4 deletions

File tree

src/Classes/DropDownControl.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,22 @@ function DropDownClass:DrawSearchHighlights(label, searchInfo, x, y, width, heig
127127
end
128128

129129

130-
function DropDownClass:SelByValue(value, key)
130+
function DropDownClass:SelByValue(value, key, callSelFunc)
131131
for index, listVal in ipairs(self.list) do
132132
if type(listVal) == "table" then
133133
if listVal[key] == value then
134134
self.selIndex = index
135+
if callSelFunc and self.selFunc then
136+
self.selFunc(index, self.list[index])
137+
end
135138
return
136139
end
137140
else
138141
if listVal == value then
139142
self.selIndex = index
143+
if callSelFunc and self.selFunc then
144+
self.selFunc(index, self.list[index])
145+
end
140146
return
141147
end
142148
end

src/Classes/ImportTab.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ function ImportTabClass:ImportChakra(slotName, runeName)
10271027
local slot = self.build.itemsTab.runeSlots[slotName]
10281028
-- note that if the rune is not in ModRunes.lua, this will not select it
10291029
if slot then
1030-
slot:SelByValue(runeName, "name")
1030+
slot:SelByValue(runeName, "name", true)
10311031
end
10321032
end
10331033

src/Classes/ItemsTab.lua

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Contro
274274
local slotName = s_format("%s Rune #%d", slot.type, i)
275275
local label = slotName:gsub(" Armour", ""):gsub("#", "")
276276

277-
local runeSlot = new("DropDownControl", { "TOPLEFT", prevSlot, "BOTTOMLEFT" }, {0, 2, 310, 20}, runeList[slot.type:lower()], function ()
277+
local runeSlot = new("DropDownControl", { "TOPLEFT", prevSlot, "BOTTOMLEFT" }, {0, 2, 310, 20}, runeList[slot.type:lower()], function (_, value)
278+
self.activeItemSet[slotName] = { runeName = value.name }
278279
self.build.buildFlag = true
279280
end)
280281
runeSlot.anchor.collapse = true
@@ -1260,6 +1261,13 @@ function ItemsTabClass:Load(xml, dbFileName)
12601261
itemSet[slotName].active = child.attrib.active == "true"
12611262
itemSet[slotName].pbURL = child.attrib.itemPbURL or ""
12621263
end
1264+
elseif child.elem == "RuneSlot" then
1265+
local slotName = child.attrib.slotName or ""
1266+
local slot = itemSet[slotName]
1267+
if slot then
1268+
local runeName = child.attrib.runeName or "None"
1269+
slot.runeName = runeName
1270+
end
12631271
elseif child.elem == "SocketIdURL" then
12641272
local id = tonumber(child.attrib.nodeId)
12651273
itemSet[id] = { pbURL = child.attrib.itemPbURL or "" }
@@ -1352,6 +1360,11 @@ function ItemsTabClass:Save(xml)
13521360
end
13531361
end
13541362
end
1363+
for slotName, _ in pairs(self.runeSlots) do
1364+
local runeName = (itemSet[slotName] and itemSet[slotName].runeName) or "None"
1365+
local node = { elem = "RuneSlot", attrib = { slotName = slotName, runeName = runeName } }
1366+
t_insert(child, node)
1367+
end
13551368
t_insert(xml, child)
13561369
end
13571370
if self.tradeQuery.statSortSelectionList then
@@ -1525,6 +1538,9 @@ function ItemsTabClass:CreateItemSet(itemSetId, name)
15251538
itemSet[slotName] = { selItemId = 0 }
15261539
end
15271540
end
1541+
for slotName, _ in pairs(self.runeSlots) do
1542+
itemSet[slotName] = { runeName = "None" }
1543+
end
15281544
self.itemSets[itemSet.id] = itemSet
15291545
return itemSet
15301546
end
@@ -1592,6 +1608,15 @@ function ItemsTabClass:SetActiveItemSet(itemSetId, deferSync)
15921608
end
15931609
end
15941610
end
1611+
for slotName, slot in pairs(self.runeSlots) do
1612+
if prevSet then
1613+
-- Update the previous set
1614+
prevSet[slotName] = { runeName = slot:GetSelValue().name }
1615+
end
1616+
-- Equip incoming set's rune
1617+
local currentRune = curSet[slotName] and curSet[slotName].runeName or "None"
1618+
slot:SelByValue(currentRune, "name", true)
1619+
end
15951620
self.build.buildFlag = true
15961621
self:PopulateSlots()
15971622
if not deferSync then

src/Modules/CalcSetup.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ function calcs.initEnv(build, mode, override, specEnv)
13271327
end
13281328

13291329
for augmentName, count in pairs(augmentCounts) do
1330-
local dbAugment = data.itemMods.Runes[augmentName]
1330+
local dbAugment = data.itemMods.Runes[augmentName] or {}
13311331
local _, dbMod = next(dbAugment)
13321332
if dbMod and dbMod.limit and count > dbMod.limit then
13331333
-- warn for going over augment limits

0 commit comments

Comments
 (0)