Module:Icons: Difference between revisions

Icon: Expand support for 'section links' to include POIs; remove duplicate extension overrides
m (Fix image override)
(Icon: Expand support for 'section links' to include POIs; remove duplicate extension overrides)
Line 102: Line 102:
["Mark"] = "svg",
["Mark"] = "svg",
["Astro"] = "svg",
["Astro"] = "svg",
-- Combat areas & dungeons
["Underwater Ruins"] = "png",
["Underwater City"] = "png",
["Cult Grounds"] = "png",
-- Curses & spells, included to override the type level override above
-- Curses & spells, included to override the type level override above
["Madness"] = "png",
["Madness"] = "png",
Line 546: Line 542:
}
}


--If no other text override was specified for the given link, use these
-- If no other text override was specified for the given link, use these
local txtOverrides = {
local txtOverrides = {
['Spider2'] = 'Brown Spider',
['Spider2'] = 'Brown Spider',
['Earth Golem (AoD)'] = 'Earth Golem'
['Earth Golem (AoD)'] = 'Earth Golem'
}
}
--Ambiguous overrides section
-- Ambiguous overrides section
local ambiguousOverrides = {
local ambiguousOverrides = {
['Golbin'] = true,
['Golbin'] = true,
Line 570: Line 566:
['Shipwreck Cove'] = true
['Shipwreck Cove'] = true
}
}
--When calling for an icon for Key, add a css class
 
-- For ambiguous overrides, determines the type text to be used in the page link
local ambiguousTypeMap = {
['mark'] = 'item',
['combatArea'] = 'Combat Area',
['poi'] = 'Dig Site'
}
 
-- Defines icon types for which a section or anchor on a static page should be linked to, rather
-- than the usual page linking
local sectionLinks = {
['agility'] = {
['link'] = 'Agility',
['img'] = {'Agility', 'skill'},
['exclude'] = {}
},
['poi'] = {
['link'] = 'Cartography',
['exclude'] = {
['Ancient Market'] = true,
['Ritual Site'] = true,
['Melantis'] = true,
['Cathedral'] = true,
['Monuments'] = true,
['Coral Wreckage'] = true,
['Shipwreck Cove'] = true,
['Watchtower'] = true,
['Sacrificial Site'] = true,
['Old Village'] = true,
['Bazaar'] = true,
['Glacia City Ruins'] = true,
['Castle Ruins'] = true,
['Ancient Forge'] = true,
['Quarry'] = true,
['Secret Mines'] = true,
['Lost Temple'] = true,
['Stoneworkers'] = true
}
}
}
 
-- When calling for an icon for Key, add a css class
local imgClassOverrides = {
local imgClassOverrides = {
-- Was previously used for Township stat icons prior to v1.1.2
-- Was previously used for Township stat icons prior to v1.1.2
Line 605: Line 642:
-- of a page should instead be performed using the 'section' parameter.
-- of a page should instead be performed using the 'section' parameter.
link = sgsub(link, '#', '')
link = sgsub(link, '#', '')
 
-- Special handling for links to Agility obstacles or pillars
-- Handle types for which links should be to a section of a static page
if iconType == 'agility' then
local sl = sectionLinks[iconType]
img = 'Agility'
if sl ~= nil and not sl.exclude[link] then
iconType = 'skill'
if text == nil or text == '' then
if text == nil or text == '' then
text = link
text = link
end
end
linkSection = string.gsub(link, ' ', '')
linkSection = string.gsub(link, ' ', '')
link = 'Agility'
-- Link overwriting must occur after text & linkSection have been set
link = sl.link
if sl.img ~= nil then
img = sl.img[1]
if sl.img[2] ~= nil then
iconType = sl.img[2]
end
end
end
end


Line 687: Line 730:
hasText = true
hasText = true
end
end
local lTypeStr = origType
if isAmbig then
if origType == 'mark' then
link = link .. ' (' .. (ambiguousTypeMap[origType] or origType) .. ')'
lTypeStr = 'item'
end
elseif origType == 'combatArea' then
if hasSection then
lTypeStr = 'Combat Area'
link = link .. '#' .. linkSection
elseif origType == 'poi' then
lTypeStr = 'Dig Site'
end
end
link = link .. (isAmbig and ' ('..lTypeStr..')' or '') .. (hasSection and '#' .. linkSection or '')
end
end