Module:Item Navbox: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary Tag: Manual revert |
||
| Line 29: | Line 29: | ||
end | end | ||
-- Directly fetches and formats | -- Directly fetches and formats ItemIcons for the navbox | ||
local function | local function get_item_icons(slot, min_souls, max_souls, filter_mode) | ||
if slot ~= 'Weapon' and slot ~= 'Armor' and slot ~= 'Tech' then return '' end | if slot ~= 'Weapon' and slot ~= 'Armor' and slot ~= 'Tech' then return '' end | ||
| Line 57: | Line 57: | ||
local item_template | local item_template | ||
if lang_code == "en" then | if lang_code == "en" then | ||
item_template = " | item_template = "{{ItemIcon|" .. item_name_english .. "|size=26px}}" | ||
else | else | ||
item_template = " | item_template = "{{ItemIcon|" .. item_name_english .. "|lang=" .. lang_code .. "|l1=" .. item_name_local .. "|size=26px}}" | ||
end | end | ||
| Line 90: | Line 89: | ||
end | end | ||
-- Generates the | -- Generates the full HTML item navbox recursively and efficiently | ||
function p.generate_full_navbox(frame) | function p.generate_full_navbox(frame) | ||
local debug_mode = type(frame) == "table" and frame.args and frame.args["debug_mode"] or nil | local debug_mode = type(frame) == "table" and frame.args and frame.args["debug_mode"] or nil | ||
local | local html = {} | ||
table.insert(html, '<div class="itemnav-header"> [[Items]] <div class="item-nav-search-container"></div></div>\n') | |||
table.insert(html, '<div class="itemnav-container"><templatestyles src="User:Kai/mp/itemnavbox/styles.css"/>\n') | |||
-- Maps Headers to Slots and distinct CSS Classes | |||
table.insert( | |||
local categories = { | local categories = { | ||
{ header = "Weapon", slot = "Weapon" }, | { header = "Weapon", slot = "Weapon", css = "itemnav-weapon" }, | ||
{ header = "Vitality", slot = "Armor" }, | { header = "Vitality", slot = "Armor", css = "itemnav-vitality" }, | ||
{ header = "Spirit", slot = "Tech" } | { header = "Spirit", slot = "Tech", css = "itemnav-tech" } | ||
} | } | ||
-- Maps tier boundaries and formatting | |||
local tiers = { | local tiers = { | ||
{ label = "{{Souls|800}}", min = 0, max = 801 }, | { label = "{{Souls|800}}", min = 0, max = 801 }, | ||
| Line 120: | Line 110: | ||
{ label = "{{Souls|3200}}", min = 1601, max = 3201 }, | { label = "{{Souls|3200}}", min = 1601, max = 3201 }, | ||
{ label = "{{Souls|6400}}", min = 3201, max = 6401 }, | { label = "{{Souls|6400}}", min = 3201, max = 6401 }, | ||
{ label | { 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 | |||
for | table.insert(html, '\n<div class="itemnav-type-header">\'\'\'' .. cat.header .. '\'\'\'</div>\n') | ||
table.insert(html, '<div class="itemnav-type-container">\n') | |||
table.insert( | |||
for _, tier in ipairs(tiers) do | |||
local css_class = "itemnav-soul " .. (tier.extra_css or "") .. cat.css | |||
local items_wikitext = get_item_icons(cat.slot, tier.min, tier.max, nil) | |||
table.insert( | |||
table.insert(html, '\n<div class="imsodonenamingclasses">\n') | |||
for | table.insert(html, '<div class="' .. css_class .. '">' .. tier.label .. '</div><!--\n') | ||
table.insert(html, '--><div class="itemnav-cost-type-container">' .. items_wikitext .. '</div>\n') | |||
table.insert(html, '</div>\n') | |||
local | |||
table.insert( | |||
end | end | ||
table.insert( | table.insert(html, '\n</div>\n') | ||
end | end | ||
table.insert( | table.insert(html, '\n</div>') | ||
-- Only ONE preprocess call for the entire structure | -- Only ONE preprocess call for the entire structure | ||
return process_debug_mode(table.concat( | return process_debug_mode(table.concat(html), debug_mode) | ||
end | end | ||
return p | return p | ||