Skip to content

Commit a04b963

Browse files
committed
Remove nonblocking list gen
1 parent a1a8fe1 commit a04b963

1 file changed

Lines changed: 11 additions & 41 deletions

File tree

‎src/Modules/ConfigModBrowser.lua‎

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ local function addItemMod(seenGroups, set, mod, source)
8484
-- note that exactly 0.5 range is necessary as that is what the
8585
-- modcache uses
8686
local rangedLine = itemLib.applyRange(line, 0.5)
87-
addModLine(set, rangedLine, source)
87+
local modList, extra = modLib.parseMod(rangedLine)
88+
addModLine(set, rangedLine, source, (not not modList) and not extra)
8889
end
8990
else
9091
-- crafted mods have a different format
9192
for _, line in ipairs(mod) do
9293
local rangedLine = itemLib.applyRange(line, 0.5)
93-
addModLine(set, rangedLine, source)
94+
local modList, extra = modLib.parseMod(rangedLine)
95+
addModLine(set, rangedLine, source, (not not modList) and not extra)
9496
end
9597
end
9698
end
@@ -106,7 +108,7 @@ local function sortAlphabeticallyIgnoringValues(a, b)
106108
end
107109

108110
local NO_MATCH_TEXT = "No matching modifiers found"
109-
local function updateDisplayList(controls, displayList, modList, noReset)
111+
local function updateDisplayList(controls, displayList, modList)
110112
wipeTable(displayList)
111113
local searchStr = controls.search.buf:lower():gsub("^[%s]+", ""):gsub("[%s]+$", "")
112114

@@ -138,7 +140,7 @@ local function updateDisplayList(controls, displayList, modList, noReset)
138140
if #displayList == 0 then
139141
t_insert(displayList, { text = NO_MATCH_TEXT })
140142
end
141-
if controls.listControl and not noReset then
143+
if controls.listControl then
142144
controls.listControl.selIndex = 1
143145
controls.listControl.selValue = displayList[1]
144146
controls.listControl.controls.scrollBarV.offset = 0
@@ -161,7 +163,9 @@ function M.OpenAddModPopup(configTab, blockData)
161163
else
162164
for i, line in ipairs(node.stats) do
163165
local supported = node.mods[i].list and not node.mods[i].extra
164-
addModLine(modSet, line, string.format("%s Node", node.type), supported)
166+
local ascendancyPrefix = node.isBloodline and "Bloodline " or
167+
node.ascendancyName and "Ascendancy " or ""
168+
addModLine(modSet, line, string.format("%s%s Node", ascendancyPrefix, node.type), supported)
165169
end
166170
end
167171
end
@@ -192,7 +196,6 @@ function M.OpenAddModPopup(configTab, blockData)
192196
end
193197

194198
local supportedList = {}
195-
local pendingList = {}
196199
for template, mod in pairs(modSet) do
197200
mod.template = template
198201
-- a key which is based on the stripped line, but one that also tries to
@@ -201,52 +204,18 @@ function M.OpenAddModPopup(configTab, blockData)
201204
:gsub("[^%a]+", " ")
202205
-- strip left and right spaces
203206
:match("^%s*(.-)%s*$")
204-
if mod.supported == true then
207+
if mod.supported then
205208
table.insert(supportedList, mod)
206-
else
207-
table.insert(pendingList, mod)
208209
end
209210
end
210211

211212
local displayList = {}
212213
local controls = {}
213214

214215

215-
local originalPending = #pendingList
216-
controls.builderStatus = new("LabelControl", { "BOTTOMLEFT", nil, "BOTTOMLEFT" }, { 8, -10, 0, 16 }, function()
217-
local pendingCount = #pendingList
218-
if pendingCount == 0 or #displayList == 0 then
219-
return ""
220-
end
221-
local remaining = #pendingList - originalPending
222-
local donePercent = math.floor(-100 * remaining / originalPending)
223-
return string.format("^7Building list %d%%", donePercent)
224-
end)
225216
controls.listControl = new("ListControl", { "TOPLEFT", nil, "TOPLEFT" }, { 10, 20, 700, 454 }, 16, "VERTICAL", false, displayList)
226217
controls.listControl.forceTooltip = true
227218
controls.listControl.font = "VAR"
228-
controls.listControl.RealDraw = controls.listControl.Draw
229-
function controls.listControl:Draw(vp, noTT)
230-
local start = GetTime()
231-
-- parse mods without pausing the UI on open
232-
local modsAdded = false
233-
while #pendingList > 0 do
234-
local mod = table.remove(pendingList, #pendingList)
235-
local modList, extra = modLib.parseMod(mod.text)
236-
if modList and not extra then
237-
modsAdded = true
238-
table.insert(supportedList, mod)
239-
end
240-
local now = GetTime()
241-
if now - start > 40 then
242-
break
243-
end
244-
end
245-
if #displayList == 0 or modsAdded then
246-
updateDisplayList(controls, displayList, supportedList, modsAdded)
247-
end
248-
controls.listControl:RealDraw(vp, noTT)
249-
end
250219
controls.listControl.GetRowValue = function(self, column, index, value)
251220
if value and value.text then
252221
return (value.text == NO_MATCH_TEXT) and value.text or (colorCodes.MAGIC .. value.text)
@@ -278,6 +247,7 @@ function M.OpenAddModPopup(configTab, blockData)
278247
return #controls.search.buf > 0
279248
end
280249

250+
updateDisplayList(controls, displayList, supportedList)
281251
local helpSize = 24
282252
controls.whatDoesItDo = new("ButtonControl", { "BOTTOM", nil, "BOTTOM" }, { 0, -10, helpSize, helpSize }, "?", function() end)
283253
controls.whatDoesItDo.forceTooltip = true

0 commit comments

Comments
 (0)