17,101
edits
Falterfire (talk | contribs) (added Cyclops and Wizard to the list of ambiguous overrides) |
(Icon: Implement noicon option for obtaining only link; Link: Implement shortcut for Icon() with noicon = true) |
||
Line 49: | Line 49: | ||
["Thiever's Cape"] = 'png', | ["Thiever's Cape"] = 'png', | ||
["Thief's Moneysack"] = 'png', | ["Thief's Moneysack"] = 'png', | ||
["Swordfish (Perfect)"] = ' | ["Swordfish (Perfect)"] = 'mpng', | ||
["Strawberry Cupcake (Perfect)"] = 'png', | ["Strawberry Cupcake (Perfect)"] = 'png', | ||
["Strawberry Cupcake"] = 'png', | ["Strawberry Cupcake"] = 'png', | ||
Line 195: | Line 195: | ||
local notext = args.notext ~= nil and args.notext ~= '' | local notext = args.notext ~= nil and args.notext ~= '' | ||
local nolink = args.nolink ~= nil and args.nolink ~= '' | local nolink = args.nolink ~= nil and args.nolink ~= '' | ||
local noicon = args.noicon ~= nil and args.noicon ~= '' | |||
local menu = args.menu ~= nil and args.menu ~= '' | local menu = args.menu ~= nil and args.menu ~= '' | ||
local imgSize = args.size ~= nil and args.size or 25 | local imgSize = args.size ~= nil and args.size or 25 | ||
Line 239: | Line 240: | ||
if Shared.contains(ambiguousOverrides, link) then | if Shared.contains(ambiguousOverrides, link) then | ||
if text == nil then text = link end | if text == nil then text = link end | ||
link = link..' ('..iconType..')' | link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')' | ||
end | end | ||
--Creating the image... | local result = '' | ||
if not noicon then | |||
--Creating the image... | |||
result = '[[File:'..img | |||
--Add in type if one is set | |||
if iconType ~= nil and iconType ~= '' then result = result..'_('..iconType..')' end | |||
--Add in extension and image size | |||
result = result..'.'..ext..'|'..tostring(imgSize)..'x'..tostring(imgSize)..'px' | |||
--Include a link unless no link -and- no text was requested | |||
if not (nolink and notext) then result = result..'|link='..link end | |||
result = result..']]' | |||
end | |||
--Add Quantity to the front if requested | --Add Quantity to the front if requested | ||
if qty ~= nil and qty ~= '' then result = Shared.formatnum(qty)..' '..result end | if qty ~= nil and qty ~= '' then result = Shared.formatnum(qty)..' '..result end | ||
if not notext then | if not notext then | ||
-- If the result is currently empty then there's no need to pad with whitespace | |||
local padStr = (string.len(result) > 0 and ' ' or '') | |||
if nolink then | if nolink then | ||
if text ~= nil and text ~= '' then | if text ~= nil and text ~= '' then | ||
result = result.. | result = result..padStr..text | ||
else | else | ||
result = result.. | result = result..padStr..link | ||
end | end | ||
else | else | ||
result = result..' [['..link | result = result..padStr..'[['..link | ||
if text ~= nil and text ~= '' and text ~= link then | if text ~= nil and text ~= '' and text ~= link then | ||
result = result..'|'..text | result = result..'|'..text | ||
Line 270: | Line 276: | ||
end | end | ||
end | end | ||
result = '<span style="display:inline-block">'..result..'</span>' | if not noicon then | ||
result = '<span style="display:inline-block">'..result..'</span>' | |||
end | |||
if menu then | if menu then | ||
Line 279: | Line 287: | ||
return result | return result | ||
end | |||
-- Wrapper for p.Icon(), uses the same parameters but forces noicon = true | |||
function p.Link(frame) | |||
local args = frame.args ~= nil and frame.args or frame | |||
args.noicon = true | |||
return p.Icon({['args'] = args}) | |||
end | end | ||