Bureaucrats, Check users, emailconfirmed, Interface administrators, staff, Administrators, translation-admin, Widget editors
1,651
edits
(Add support for default sprites with custom lore or name) |
mNo edit summary |
||
(66 intermediate revisions by 3 users not shown) | |||
Line 85: | Line 85: | ||
local name = args['name'] or args['Name'] or args['title'] or args['Title'] | local name = args['name'] or args['Name'] or args['title'] or args['Title'] | ||
if name then | if name and #name ~= 0 then | ||
sprite:SetTitle(name) | sprite:SetTitle(name) | ||
end | end | ||
local lore = args['lore'] or args['Lore'] or args['text'] or args['Text'] | local lore = args['lore'] or args['Lore'] or args['text'] or args['Text'] | ||
if lore then | if lore and #lore ~= 0 then | ||
sprite:SetLore(lore) | sprite:SetLore(lore) | ||
end | end | ||
local hideTooltip = args['hideToolTip'] or args['hideTooltip'] or args['HideToolTip'] or args['HideTooltip'] | |||
if hideTooltip then | |||
sprite:HideTooltip() | |||
end | |||
local inline = args['inline'] or args['Inline'] | local inline = args['inline'] or args['Inline'] | ||
local spriteDiv | local spriteDiv | ||
if inline then | local parentDiv = mw.html.create("span"):css("position","relative") | ||
if inline ~= 'false' then | |||
spriteDiv = sprite:GenerateHTML("span") | spriteDiv = sprite:GenerateHTML("span") | ||
spriteDiv:css("display","inline-block") | spriteDiv:css("display","inline-block") | ||
Line 104: | Line 110: | ||
end | end | ||
local count = tonumber(args['count']) or tonumber(args['Count']) or string.match(tostring(args['count']),'%?') or string.match(tostring(args['Count']),'%?') or 1 | |||
if count ~= 1 then | |||
local countSpan = parentDiv:tag("span"):wikitext(count) | |||
countSpan:addClass("invslot-stacksize") | |||
end | |||
local | local enchanted = args['enchanted'] or args['Enchanted'] | ||
if | if enchanted == 'true' then | ||
spriteDiv:addClass("enchanted") | |||
end | |||
local link = args['link'] or args['Link'] | |||
if link and #link ~= 0 then | |||
if link:sub( 1,2 ) == '[[' then | |||
parentDiv:wikitext(link:sub( 1,#link-2 ) .. '|') | |||
elseif link:sub ( 1,1 ) == '[' then | |||
parentDiv:wikitext(link:sub( 1,#link-1 ) .. '|') | |||
end | |||
end | |||
parentDiv:node(spriteDiv) | |||
if link and #link ~= 0 then | |||
if link:sub( 1,2 ) == '[[' then | |||
parentDiv:wikitext(']]') | |||
elseif link:sub ( 1,1 ) == '[' then | |||
parentDiv:wikitext(']') | |||
end | |||
end | end | ||
return | return parentDiv | ||
end | end | ||
Line 148: | Line 177: | ||
else | else | ||
sprite:SetSize(args['size'] or args['Size'] or 32) | sprite:SetSize(args['size'] or args['Size'] or 32) | ||
end | |||
local name = args['name'] or args['Name'] or args['title'] or args['Title'] | |||
if name and #name ~= 0 then | |||
sprite:SetTitle(name) | |||
end | |||
local lore = args['lore'] or args['Lore'] or args['text'] or args['Text'] | |||
if lore and #lore ~= 0 then | |||
sprite:SetLore(lore) | |||
end | |||
local hideTooltip = args['hideToolTip'] or args['hideTooltip'] or args['HideToolTip'] or args['HideTooltip'] | |||
if hideTooltip then | |||
sprite:HideTooltip() | |||
end | end | ||
Line 157: | Line 202: | ||
spriteDiv:css("border-width","3px") | spriteDiv:css("border-width","3px") | ||
spriteDiv:css("border-style","solid") | spriteDiv:css("border-style","solid") | ||
spriteDiv:css("box-sizing","border-box") | |||
if args['standard'] or args['Standard'] then | if args['standard'] or args['Standard'] then | ||
Line 164: | Line 210: | ||
spriteDiv:css("background-color","#67AFD0") | spriteDiv:css("background-color","#67AFD0") | ||
spriteDiv:css("border-color","#1A536E #C0DEEB #C0DEEB #1A536E") | spriteDiv:css("border-color","#1A536E #C0DEEB #C0DEEB #1A536E") | ||
end | |||
local count = tonumber(args['count']) or tonumber(args['Count']) or 1 or "?" | |||
if count ~= 1 then | |||
local countSpan = spriteDiv:tag("span"):wikitext(count) | |||
countSpan:addClass("invslot-stacksize") | |||
end | end | ||
edits