More actions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local function div() | |||
local div = mw.html.create( 'div' ) | |||
div | |||
:attr( 'id', 'Ads-Infobox' ) | |||
return tostring( div ) | |||
end | |||
local function empty(param) | local function empty(param) | ||
return not param or param == '' | return not param or param == '' | ||
Line 165: | Line 172: | ||
label11 = 'Last Updated', | label11 = 'Last Updated', | ||
data11 = a.lastupdated, | data11 = a.lastupdated, | ||
header20 = div(), | |||
-- Links | -- Links | ||
data15 = getLink( 'Download', a.download, a.downloadraw ), | data15 = getLink( 'Download', a.download, a.downloadraw ), |
Revision as of 12:44, 4 February 2023
Documentation for this module may be created at Module:Infobox Wii Homebrews/doc
local p = {} local function div() local div = mw.html.create( 'div' ) div :attr( 'id', 'Ads-Infobox' ) return tostring( div ) end local function empty(param) return not param or param == '' end local function formatUser( user ) return '[[User:' .. user .. (user:find('|') and '' or ('|' .. user)) .. ']]' end local function userList( list ) if empty(list) then return end if not list:find(',') then return formatUser(list) end local ret = {} for user in mw.text.gsplit( list, '%s*,%s*' ) do ret[#ret+1] = formatUser(user) end return table.concat( ret, ', ' ) end local function getType( type ) if empty( type ) then return end local types = { -- Applications ['media player'] = '[[List of Wii homebrew applications#Media players|Media player]] [[Category:Wii Homebrew media players]]', ['utility'] = '[[List of Wii homebrew applications#Utilities|Utility]] [[Category:Wii Homebrew utilities]]', ['operating system'] = '[[List of Wii homebrew applications#Operating systems|Operating system]] [[Category:Wii Homebrew operating systems]]', ['math'] = '[[List of Wii homebrew applications#Math|Math application]] [[Category:Wii Homebrew math applications]]', ['other'] = '[[List of Wii homebrew applications#Other applications|Other application]] [[Category:Wii Homebrew other applications]]', -- Games ['arcade game'] = '[[List of Wii homebrew games#Arcade|Arcade game]] [[Category:Wii Homebrew arcade games]]', ['board game'] = '[[List of Wii homebrew games#Board|Board game]] [[Category:Wii Homebrew board games]]', ['card game'] = '[[List of Wii homebrew games#Card|Card game]] [[Category:Wii Homebrew card games]]', ['game engine'] = '[[List of Wii homebrew games#Game engine|Game engine]] [[Category:Wii Homebrew game engines]]', ['music game'] = '[[List of Wii homebrew games#Music|Music game]] [[Category:Wii Homebrew music games]]', ['platform game'] = '[[List of Wii homebrew games#Platform|Platform game]] [[Category:Wii Homebrew platform games]]', ['puzzle game'] = '[[List of Wii homebrew games#Puzzle|Puzzle game]] [[Category:Wii Homebrew puzzle games]]', ['racing game'] = '[[List of Wii homebrew games#Racing|Racing game]] [[Category:Wii Homebrew racing games]]', ['role playing game'] = '[[List of Wii homebrew games#Role playing|Role playing game]] [[Category:Wii Homebrew role playing games]]', ['shooting game'] = '[[List of Wii homebrew games#Shooter|Shooting game]] [[Category:Wii Homebrew shooting games]]', ['simulation game'] = '[[List of Wii homebrew games#Simulation|Simulation game]] [[Category:Wii Homebrew simulation games]]', ['trivia game'] = '[[List of Wii homebrew games#Trivia|Trivia game]] [[Category:Wii Homebrew trivia games]]', ['other game'] = '[[List of Wii homebrew games#Other games|Other game]] [[Category:Wii Homebrew other games]]', -- Emulators ['console emulator'] = '[[List of Wii homebrew emulators#Console|Console emulator]] [[Category:Wii Homebrew console emulators]]', ['handheld emulator'] = '[[List of Wii homebrew emulators#Handheld|Handheld emulator]] [[Category:Wii Homebrew portable emulators]]', ['arcade emulator'] = '[[List of Wii homebrew emulators#Arcade|Arcade emulator]] [[Category:Wii Homebrew arcade emulators]]', ['computer emulator'] = '[[List of Wii homebrew emulators#Computer|Computer emulator]] [[Category:Wii Homebrew computer emulators]]', -- Loaders ['loader'] = '[[List of Wii homebrew loaders|Loader]] [[Category:Wii Homebrew loaders]]', -- Exploits ['exploit'] = '[[List of Wii homebrew exploits|Exploit]] [[Category:Wii Homebrew exploits]]', -- System Tools ['system tool'] = '[[List of Wii system tools|System tool]] [[Category:Wii homebrew system tools]]', -- PC Utilities ['pc utility'] = '[[List of Wii PC utilities|PC utility]] [[Category:Wii PC utilities]]', -- Demos ['demo'] = '[[List of Wii homebrew demos|Demo]] [[Category:Wii homebrew demos]]', } return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]' end local function getLicense( license ) if empty( license ) then return end local licenses = { ['Apache'] = '[https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0]', ['GNU GPL'] = '[https://www.gnu.org/licenses/gpl.html GNU GPL]', ['GNU LGPL'] = '[https://www.gnu.org/licenses/lgpl.html GNU LGPL]', ['BSD 2-Clause'] = '[http://opensource.org/licenses/BSD-2-Clause BSD 2-Clause]', ['BSD 3-Clause'] = '[http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause]', ['Mixed'] = 'Mixed', ['MIT'] = '[http://opensource.org/licenses/mit-license.html MIT License]', } return licenses[license] or license end local function getFormats( a ) local formats = { '3dsx', '3ds', 'cia', 'bin', 'dat', 'cxi' } local ret = {} for i=1,#formats do local f = formats[i] local tmp = a[f] if not empty(tmp) then local label = f == 'bin' and 'bin/elf' or f if tmp == 'yes' then ret[#ret+1] = label .. ' <span style="color:#00B000">✔</span>' elseif tmp == 'no' then ret[#ret+1] = label .. ' <span style="color:red">✘</span>' else ret[#ret+1] = label .. ' <span style="color:orange">?</span>' end end end if next(ret) == nil then return end -- We got nothing... return table.concat(ret, '<br />') end local function getLink( label, link, altlink ) if empty( link ) then return altlink end if link:find( '://' ) then return '[' .. link .. ' ' .. label .. ']' end return '[[' .. link .. '|' .. label .. ']]' end local function getSource( source ) if empty( source ) then return end if source == 'included' then return 'Source included[[Category:Open source homebrew]]' end return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]' end local function getDownloadMii( dm, dmversion, version ) if not dm or dm ~= 'yes' then return end if empty(dmversion) or dmversion == version then return 'Downloadable via [[DownloadMii]] [[Category:3DS Homebrew in DownloadMii]]' else return "Version '''" .. dmversion .. "''' downloadable via [[DownloadMii]] [[Category:3DS Homebrew in DownloadMii]]" end end function p.main( frame ) local a = frame:getParent().args local infobox = require( 'Module:Infobox' ) if not empty( a.title ) then frame:callParserFunction( 'DISPLAYTITLE', a.title ) end local ibData = { title = a.title, image = a.image, imagesize = a.imagesize or '48px', imagecaption = a.imagecaption, header1 = 'General', label2 = 'Author', data2 = userList( a.author ), label4 = 'Contributor', data4 = userList( a.contributor ), label5 = 'Ported by', data5 = userList( a.portedby ), label6 = 'Type', data6 = getType( a['type'] ), label7 = 'Version', data7 = a.version, label8 = 'License', data8 = getLicense( a.license ), label9 = 'Language', data9 = a.language, label10 = 'Format', data10 = getFormats( a ), label11 = 'Last Updated', data11 = a.lastupdated, header20 = div(), -- Links data15 = getLink( 'Download', a.download, a.downloadraw ), data16 = getLink( 'Website', a.website ), data17 = getSource( a.source ), data18 = getLink( 'Discussion', a.discussion ), data19 = getDownloadMii( a.dm, a.dmversion, a.version ), below = a.below } if ibData.data15 or ibData.data16 or ibData.data17 or ibData.data18 or ibData.data19 then ibData.header14 = 'Links' end if a.cia == 'yes' then ibData.header11 = 'CIA information' ibData.label12 = 'Title ID' ibData.data12 = a.titleID or 'Unknown[[Category:3DS Homebrew missing CIA titleID]]' ibData.label13 = 'Unique ID' ibData.data13 = a.uniqueID or 'Unknown[[Category:3DS Homebrew missing CIA uniqueID]]' end return infobox.infobox( ibData ) end return p