Module:Item Navbox: Difference between revisionsGive feedback
Tag: Undo |
No edit summary |
||
| Line 129: | Line 129: | ||
return table.concat(items, sep) | return table.concat(items, sep) | ||
end | |||
-- Generates the full HTML item navbox recursively and efficiently | |||
function p.generate_full_navbox(frame) | |||
local debug_mode | |||
if type(frame) == "table" and frame.args then | |||
debug_mode = frame.args["debug_mode"] | |||
end | |||
local html = {} | |||
table.insert(html, '<div class="itemnav-container"><templatestyles src="User:Kai/mp/itemnavbox/styles.css"/>\n') | |||
-- Maps Headers to Slots and distinct CSS Classes | |||
local categories = { | |||
{ header = "Weapon", slot = "Weapon", css = "itemnav-weapon" }, | |||
{ header = "Vitality", slot = "Armor", css = "itemnav-vitality" }, | |||
{ header = "Spirit", slot = "Tech", css = "itemnav-tech" } | |||
} | |||
-- Maps tier boundaries and formatting | |||
local tiers = { | |||
{ label = "{{Souls|800}}", min = 0, max = 801 }, | |||
{ label = "{{Souls|1600}}", min = 801, max = 1601 }, | |||
{ label = "{{Souls|3200}}", min = 1601, max = 3201 }, | |||
{ label = "{{Souls|6400}}", min = 3201, max = 6401 }, | |||
{ label = "[[Street Brawl|{{Legendary|{{#invoke:Lang|get_string|Citadel_ItemDraft_Legendary}}}}]]", min = 6401, max = 99999, extra_css = "itemnav-legendary " } | |||
} | |||
for _, cat in ipairs(categories) do | |||
table.insert(html, '\n<div class="itemnav-type-header">\'\'\'' .. cat.header .. '\'\'\'</div>\n') | |||
table.insert(html, '<div class="itemnav-type-container">\n') | |||
for _, tier in ipairs(tiers) do | |||
local css_class = "itemnav-soul " .. (tier.extra_css or "") .. cat.css | |||
-- Fetch items purely in lua without invoking preprocessing mid-loop | |||
local items_wikitext = write_wrapped_item_list(cat.slot, tier.min, tier.max, "ItemIcon", '', nil) | |||
table.insert(html, '\n<div class="imsodonenamingclasses">\n') | |||
table.insert(html, '<div class="' .. css_class .. '">' .. tier.label .. '</div><div class="itemnav-cost-type-container">' .. items_wikitext .. '</div>\n') | |||
table.insert(html, '</div>\n') | |||
end | |||
table.insert(html, '\n</div>\n') | |||
end | |||
table.insert(html, '\n</div>') | |||
-- Only ONE preprocess call for the entire structure! | |||
local final_wikitext = table.concat(html) | |||
return process_debug_mode(final_wikitext, debug_mode) | |||
end | end | ||