Module:Entry/metatable: Difference between revisions

no edit summary
(Change default icon size of GBA levels from 20px wide to 20px tall to maintain original Remix icon width)
No edit summary
Line 8: Line 8:
end
end


function entryMT.target(entry)
function entryMT._data(entry)
return titles[entry][1]
return titles[entry.console][entry.stage].entries[entry.number]
end
end


function entryMT.selfLink(entry)
function entryMT.target(entry)
return mw.title.getCurrentTitle().prefixedText == entry.target
return entry._data[1] or ""
end
end


function entryMT.title(entry)
function entryMT.title(entry)
if entry.selfLink then return entry.target end
return entry._data[2] or titles.target
return titles[entry][2] or entry.target
end
end


function entryMT.text(entry)
function entryMT.text(entry)
local t = titles[entry]
return entry._data[3] or titles.title
return t[3] or t[2] or t[1]
end
end


local function textWithTempoUp(entry, tempoUpSize)
local function _textWithTempoUp(entry, args)
if entry.target == "" then return "" end
local tempoUpSize = args.tempoUpSize
local t = entry.text
local t = entry.text
if (entry.console == "GBA" or entry.console == "Arcade")
if (entry.console == "GBA" or entry.console == "Arcade")
Line 39: Line 39:


function entryMT.textWithTempoUp()
function entryMT.textWithTempoUp()
return textWithTempoUp
return _textWithTempoUp
end
 
function entryMT.selfLink(entry)
return mw.title.getCurrentTitle().prefixedText == entry.target
end
end


local function _link(entry, tempoUpSize)
local function _link(entry, args)
local t = entry.text
if entry.target == "" then return "" end
t = mw.ustring.format("[[%s|%s]]", entry.title, t)
local title = entry.selfLink and entry.target or entry.title
local t = mw.ustring.format("[[%s|%s]]", title, entry.text)
if (entry.console == "GBA" or entry.console == "Arcade")
if (entry.console == "GBA" or entry.console == "Arcade")
and entry.stage == "EX"
and entry.stage == "EX"
then
then
tempoUpSize = tempoUpSize or "72px"
local tempoUpSize = args.tempoUpSize or "72px"
title = entry.selfLink and "" or entry.title
t = mw.ustring.format("%s [[File:TempoUpExtra%s.png|%s|link=%s]]",
t = mw.ustring.format("%s [[File:TempoUpExtra%s.png|%s|link=%s]]",
t, entry.number, tempoUpSize, entry.selfLink and "" or entry.title)
t, entry.number, tempoUpSize, title)
end
end
return t
return t
Line 75: Line 81:
end
end


function entryMT.iconName(entry)
function entryMT.iconVariants(entry)
local variants = {}
for _, v in ipairs(entry._data.variants) do variants[v] = true end
return variants
end
 
local function _iconName(entry, args)
local animateStages = {
local animateStages = {
GBA = {T = true},
GBA = {T = true},
Line 87: Line 99:
local console = entry.console
local console = entry.console
if console == "Arcade" then console = "GBA" end
if console == "Arcade" then console = "GBA" end
local entryCode = titles[entry].icon or (entry.stage .. "-" .. entry.number)
local entryCode = entry._data.icon or (entry.stage .. "-" .. entry.number)
return mw.ustring.format("Game %s %s.%s", console, entryCode, ext)
local var = args.variant
if entry.iconVariants[var] then var = " " .. var
else var = "" end
return mw.ustring.format("Game %s %s%s.%s", console, entryCode, var, ext)
end
 
function entryMT.iconName()
return _iconName
end
end


local function _icon(entry, iconSize)
local function _icon(entry, args)
iconSize = iconSize or entry.defaultIconSize
local iconSize = args.iconSize or entry.defaultIconSize
return mw.ustring.format("[[File:%s|%s|link=%s]]",
return mw.ustring.format("[[File:%s|%s|link=%s]]",
entry.iconName, iconSize, entry.selfLink and "" or entry.title)
entry:iconName(args), iconSize, entry.selfLink and "" or entry.title)
end
end


Line 101: Line 120:
end
end


local function _iconAndLink(entry, iconSize, tempoUpSize)
local function _iconAndLink(entry, args)
return tostring(mw.html.create("span")
local span = mw.html.create("span")
:css("white-space", "nowrap")
:css("white-space", "nowrap")
:wikitext(entry:icon(iconSize), " ", entry:link(tempoUpSize))
:wikitext(entry:icon(args))
)
if entry.stage ~= "?" then span:wikitext(" ", entry:link(args)) end
return tostring(span)
end
end


420

edits