Module:Icons: Difference between revisions

Use class in place of inline styles
(Undo revision 61545 by Auron956 (talk) Reinstated to allow linking to items with hashes in their names)
(Use class in place of inline styles)
(16 intermediate revisions by 4 users not shown)
Line 45: Line 45:
["Hardcore Adventure Speedrun"] = "svg",
["Hardcore Adventure Speedrun"] = "svg",
["Mastery Tokens"] = "gif",
["Mastery Tokens"] = "gif",
["Lesser Relics"] = "gif",
["Prat, the Serpent of Fire"] = "svg",
["Prat, the Serpent of Fire"] = "svg",
["Unholy Prayers"] = "svg",
["Unholy Prayers"] = "svg",
Line 102: Line 103:
["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 189: Line 186:
["Aranite Sieve"] = "png",
["Aranite Sieve"] = "png",
["Aranite Trowel"] = "png",
["Aranite Trowel"] = "png",
["Travel Token"] = "png",
["Dig Site Token"] = "png",
["Summoner's Pack I"] = "png",
["Summoners' Pack II"] = "png",
["Summoners' Pack III"] = "png",
-- Marks (Summoning), included to override the type level override above
-- Marks (Summoning), included to override the type level override above
["Eagle"] = "png",
["Eagle"] = "png",
Line 202: Line 204:
["Cult Grounds"] = "png",
["Cult Grounds"] = "png",
["Trickery Temple"] = "png",
["Trickery Temple"] = "png",
["Underwater City"] = "png"
["Underwater City"] = "png",
["Underwater Ruins"] = "png",
["Eye-conic Cave"] = "png",
["Mucky Cave"] = "png",
["Lost Temple"] = "png",
["Ritual Site"] = "png",
["Shipwreck Cove"] = "png",
}
}
}
}
Line 277: Line 285:
["Winter"] = "png",
["Winter"] = "png",
["Nightfall"] = "png",
["Nightfall"] = "png",
["Solar Eclipse"] = "png",
["Solar Eclipse"] = "png"
["Lemon Season"] = "png"
}
}
}
}
Line 327: Line 334:
["Cartographer's Enhancement"] = {'Cartography', 'skill'},
["Cartographer's Enhancement"] = {'Cartography', 'skill'},
["Cartographer's Knowledge"] = {'Cartography', 'skill'},
["Cartographer's Knowledge"] = {'Cartography', 'skill'},
["Combat Supply I"] = {'Adamant Javelin', 'item'},
["Combat Supply II"] = {'Rune Javelin', 'item'},
["Combat Supply III"] = {'Dragon Javelin', 'item'},
-- Golbin Raid shop items
-- Golbin Raid shop items
["Reduce Wave Skip Cost"] = {'Melvor Logo', ''},
["Reduce Wave Skip Cost"] = {'Melvor Logo', ''},
Line 415: Line 425:
-- Township generic statue building
-- Township generic statue building
['Statue of Worship'] = 'Statue of Nothing',
['Statue of Worship'] = 'Statue of Nothing',
-- Township seasons
["Lemon Season"] = 'Spring',
-- Easter egg stuff
-- Easter egg stuff
["Lemonade (Empty)"] = "Lemonade",
["Lemonade (Empty)"] = "Lemonade",
Line 447: Line 459:
["Lemonade (Full)"] = "Lemonade",
["Lemonade (Full)"] = "Lemonade",
["Birthday Present (Artisan)"] = "Christmas Present (Yellow)",
["Birthday Present (Artisan)"] = "Christmas Present (Yellow)",
["Birthday Present (Utiliy)"] = "Christmas Present (Blue)",
["Birthday Present (Utility)"] = "Christmas Present (Blue)",
["Birthday Present (Gathering)"] = "Christmas Present (Green)",
["Birthday Present (Gathering)"] = "Christmas Present (Green)",
["Birthday Present (Combat)"] = "Christmas Present (White)"
["Birthday Present (Combat)"] = "Christmas Present (White)",
["Clue Scroll 1"] = "Event Clue 1",
["Clue Scroll 2"] = "Event Clue 1",
["Clue Scroll 3"] = "Event Clue 1",
["Clue Scroll 4"] = "Event Clue 1",
["Clue Scroll 5"] = "Event Clue 1",
["Clue Scroll 6"] = "Event Clue 1"
}
}
--When calling for an icon for Key + Type, replace with image Value, and optionally override type also
--When calling for an icon for Key + Type, replace with image Value, and optionally override type also
Line 546: Line 564:
}
}


--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 588:
['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 664:
-- 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 752:
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


Line 727: Line 789:


if menu then
if menu then
return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. expIcon .. resultText .. '\r\n|}'
return '{| class="articletable img-text" style="vertical-align:middle;"\r\n|-\r\n|' .. expIcon .. resultText .. '\r\n|}'
elseif not noicon and not nospan then
elseif not noicon and not nospan then
return '<span style="display:inline-block">' .. expIcon .. resultText .. '</span>'
return '<span class="img-text">' .. expIcon .. resultText .. '</span>'
else
else
return resultText
return resultText
Line 748: Line 810:
result = result.." Level "..level
result = result.." Level "..level


result = '<span style="display:inline-block">'..result..'</span>'
result = '<span class="img-text">'..result..'</span>'
return result
return result
end
end
Line 775: Line 837:
result = result..p.Icon({linkname, img=iconname, type='item', notext=true, nospan=true, alt=altTextItem})..p.Icon({'Mastery', notext=true, nospan=true, alt=altTextMastery})
result = result..p.Icon({linkname, img=iconname, type='item', notext=true, nospan=true, alt=altTextItem})..p.Icon({'Mastery', notext=true, nospan=true, alt=altTextMastery})
if showText then result = result..'[['..linkname..']] [[Mastery]]' end
if showText then result = result..'[['..linkname..']] [[Mastery]]' end
result = '<span style="display:inline-block">'..result..'</span>'
result = '<span class="img-text">'..result..'</span>'
return result
return result
end
end
Line 787: Line 849:
end
end


function p._Currency(fileName, link, altText, amt, maxAmt)
function p._Currency(fileName, link, altText, amount, maxAmount)
local amtText = nil
local ret = {}
if tonumber(amt) ~= nil then
table.insert(ret, '<span class="img-text">')
amtText = formatnum(amt)
local sep = ''
if maxAmt ~= nil and maxAmt >= amt then
-- Currency amounts
amtText = amtText .. ' - ' .. formatnum(maxAmt)
if tonumber(amount) ~= nil then
sep = '&nbsp;'
local function numColour(amount)
if tonumber(amount) < 0 then
return '<span style="color:red;">' .. formatnum(amount) .. '</span>'
else
return formatnum(amount)
end
end
table.insert(ret, numColour(amount))
if (tonumber(maxAmount) ~= nil and maxAmount > amount) then
table.insert(ret, ' - ' .. numColour(maxAmount))
end
end
end
end
 
-- Currency icon
local fileText = ''
if fileName ~= nil then
if fileName ~= nil then
fileText = '[[File:' .. fileName .. '|25px'
table.insert(ret, sep .. '[[File:' .. fileName .. '|25px')
if link ~= nil then
if link ~= nil then
fileText = fileText .. '|link=' .. link
table.insert(ret, '|link=' .. link)
end
end
fileText = fileText .. '|alt=' .. ((altText == nil and '') or altText) .. ']]'
table.insert(ret, '|alt=' .. ((altText == nil and '') or altText) .. ']]')
end
end
 
table.insert(ret, '</span>')
return '<span style="display:inline-block">' .. fileText .. (amtText ~= nil and '&nbsp;' .. amtText or '') .. '</span>'
return table.concat(ret)
end
end


Line 827: Line 900:
function p.AoD()
function p.AoD()
return p.Icon({'Atlas of Discovery Expansion', notext=true, img='AoD', alt=''})
return p.Icon({'Atlas of Discovery Expansion', notext=true, img='AoD', alt=''})
end
-- Prework to have function call available for when DLC releases.
-- Remove comments and uncomment line below when the image is available.
function p.ItA()
--return p.Icon({'Into the Abyss Expansion', notext=true, img='ItA', alt=''})
return nil
end
end