Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
The main server is currently down. We are running on a backup server, so editing and search functionality are temporarily disabled. Please check back in a few hours.

Module:Infobox Switch Homebrews: Difference between revisions

From GameBrew
No edit summary
No edit summary
Line 12: Line 12:
div
div
:attr( 'id', 'largemobilebanner' )
:attr( 'id', 'largemobilebanner' )
return tostring( div )
end
local function div3()
local div = mw.html.create( 'div' )
div
:attr( 'id', 'Ads-Infobox1' )
return tostring( div )
end
local function div4()
local div = mw.html.create( 'div' )
div
:attr( 'id', 'Ads-Infobox3' )
return tostring( div )
return tostring( div )
end
end
Line 42: Line 56:
local types = {
local types = {
-- Applications
-- Applications
['media player']      = '[[List of 3DS homebrew applications#Media players|Media player]] [[Category:3DS Homebrew media players]]',
['media player']      = '[[List of Switch homebrew applications#Media players|Media player]] [[Category:Switch Homebrew media players]]',
['utility']            = '[[List of 3DS homebrew applications#Utilities|Utility]] [[Category:3DS Homebrew utilities]]',
['utility']            = '[[List of Switch homebrew applications#Utilities|Utility]] [[Category:Switch Homebrew utilities]]',
['operating system']  = '[[List of 3DS homebrew applications#Operating systems|Operating system]] [[Category:3DS Homebrew operating systems]]',
['operating system']  = '[[List of Switch homebrew applications#Operating systems|Operating system]] [[Category:Switch Homebrew operating systems]]',
['math']              = '[[List of 3DS homebrew applications#Math|Math application]] [[Category:3DS Homebrew math applications]]',
['math']              = '[[List of Switch homebrew applications#Math|Math application]] [[Category:Switch Homebrew math applications]]',
['other']              = '[[List of 3DS homebrew applications#Other applications|Other application]] [[Category:3DS Homebrew other applications]]',
['other']              = '[[List of Switch homebrew applications#Other applications|Other application]] [[Category:Switch Homebrew other applications]]',
-- Games
-- Games
['arcade game']        = '[[List of 3DS homebrew games#Arcade|Arcade game]] [[Category:3DS Homebrew arcade games]]',
['arcade game']        = '[[List of Switch homebrew games#Arcade|Arcade game]] [[Category:Switch Homebrew arcade games]]',
['board game']        = '[[List of 3DS homebrew games#Board|Board game]] [[Category:3DS Homebrew board games]]',
['board game']        = '[[List of Switch homebrew games#Board|Board game]] [[Category:Switch Homebrew board games]]',
['card game']          = '[[List of 3DS homebrew games#Card|Card game]] [[Category:3DS Homebrew card games]]',
['card game']          = '[[List of Switch homebrew games#Card|Card game]] [[Category:Switch Homebrew card games]]',
['game engine']        = '[[List of 3DS homebrew games#Game engine|Game engine]] [[Category:3DS Homebrew game engines]]',
['game engine']        = '[[List of Switch homebrew games#Game engine|Game engine]] [[Category:Switch Homebrew game engines]]',
['music game']        = '[[List of 3DS homebrew games#Music|Music game]] [[Category:3DS Homebrew music games]]',
['music game']        = '[[List of Switch homebrew games#Music|Music game]] [[Category:Switch Homebrew music games]]',
['platform game']      = '[[List of 3DS homebrew games#Platform|Platform game]] [[Category:3DS Homebrew platform games]]',
['platform game']      = '[[List of Switch homebrew games#Platform|Platform game]] [[Category:Switch Homebrew platform games]]',
['puzzle game']        = '[[List of 3DS homebrew games#Puzzle|Puzzle game]] [[Category:3DS Homebrew puzzle games]]',
['puzzle game']        = '[[List of Switch homebrew games#Puzzle|Puzzle game]] [[Category:Switch Homebrew puzzle games]]',
['racing game']        = '[[List of 3DS homebrew games#Racing|Racing game]] [[Category:3DS Homebrew racing games]]',
['racing game']        = '[[List of Switch homebrew games#Racing|Racing game]] [[Category:Switch Homebrew racing games]]',
['role playing game']  = '[[List of 3DS homebrew games#Role playing|Role playing game]] [[Category:3DS Homebrew role playing games]]',
['role playing game']  = '[[List of Switch homebrew games#Role playing|Role playing game]] [[Category:Switch Homebrew role playing games]]',
['shooting game']      = '[[List of 3DS homebrew games#Shooter|Shooting game]] [[Category:3DS Homebrew shooting games]]',
['shooting game']      = '[[List of Switch homebrew games#Shooter|Shooting game]] [[Category:Switch Homebrew shooting games]]',
['simulation game']    = '[[List of 3DS homebrew games#Simulation|Simulation game]] [[Category:3DS Homebrew simulation games]]',
['simulation game']    = '[[List of Switch homebrew games#Simulation|Simulation game]] [[Category:Switch Homebrew simulation games]]',
['trivia game']        = '[[List of 3DS homebrew games#Trivia|Trivia game]] [[Category:3DS Homebrew trivia games]]',
['trivia game']        = '[[List of Switch homebrew games#Trivia|Trivia game]] [[Category:Switch Homebrew trivia games]]',
['other game']        = '[[List of 3DS homebrew games#Other games|Other game]] [[Category:3DS Homebrew other games]]',
['other game']        = '[[List of Switch homebrew games#Other games|Other game]] [[Category:Switch Homebrew other games]]',
-- Emulators
-- Emulators
['console emulator']  = '[[List of 3DS homebrew emulators#Console|Console emulator]] [[Category:3DS Homebrew console emulators]]',
['console emulator']  = '[[List of Switch homebrew emulators#Console|Console emulator]] [[Category:Switch Homebrew console emulators]]',
['handheld emulator']  = '[[List of 3DS homebrew emulators#Handheld|Handheld emulator]] [[Category:3DS Homebrew portable emulators]]',
['handheld emulator']  = '[[List of Switch homebrew emulators#Handheld|Handheld emulator]] [[Category:Switch Homebrew portable emulators]]',
['arcade emulator']    = '[[List of 3DS homebrew emulators#Arcade|Arcade emulator]] [[Category:3DS Homebrew arcade emulators]]',
['arcade emulator']    = '[[List of Switch homebrew emulators#Arcade|Arcade emulator]] [[Category:Switch Homebrew arcade emulators]]',
['computer emulator']  = '[[List of 3DS homebrew emulators#Computer|Computer emulator]] [[Category:3DS Homebrew computer emulators]]',
['computer emulator']  = '[[List of Switch homebrew emulators#Computer|Computer emulator]] [[Category:Switch Homebrew computer emulators]]',
-- Loaders
-- Loaders
['loader']            = '[[List of 3DS homebrew loaders|Loader]] [[Category:3DS Homebrew loaders]]',
['loader']            = '[[List of Switch homebrew loaders|Loader]] [[Category:Switch Homebrew loaders]]',
-- Exploits
-- Exploits
['exploit']            = '[[List of 3DS homebrew exploits|Exploit]] [[Category:3DS Homebrew exploits]]',
['exploit']            = '[[List of Switch homebrew exploits|Exploit]] [[Category:Switch Homebrew exploits]]',
-- System Tools
-- System Tools
['system tool']        = '[[List of 3DS system tools|System tool]] [[Category:3DS homebrew system tools]]',
['system tool']        = '[[List of Switch system tools|System tool]] [[Category:Switch homebrew system tools]]',
-- PC Utilities
-- PC Utilities
['pc utility']        = '[[List of 3DS PC utilities|PC utility]] [[Category:3DS PC utilities]]',
['pc utility']        = '[[List of Switch PC utilities|PC utility]] [[Category:Switch PC utilities]]',
-- Demos
-- Demos
['demo']              = '[[List of 3DS homebrew demos|Demo]] [[Category:3DS homebrew demos]]',
['demo']              = '[[List of Switch homebrew demos|Demo]] [[Category:Switch homebrew demos]]',
}
}
   
   
Line 98: Line 112:
   
   
local function getFormats( a )
local function getFormats( a )
local formats = { '3dsx', '3ds', 'cia', 'bin', 'dat', 'cxi' }
local formats = { 'Switchx', 'Switch', 'cia', 'bin', 'dat', 'cxi' }
local ret = {}
local ret = {}
   
   
Line 135: Line 149:
   
   
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
end
local function getDonation( donation )
if empty( donation ) then return end
if donation == 'included' then return 'donation included[[Category:Support the author]]' end
return getLink( 'donation', donation ) .. '[[Category:Support the author]]'
end
end
   
   
Line 141: Line 162:
   
   
if empty(dmversion) or dmversion == version then
if empty(dmversion) or dmversion == version then
return 'Downloadable via [[DownloadMii]] [[Category:3DS Homebrew in DownloadMii]]'
return 'Downloadable via [[DownloadMii]] [[Category:Switch Homebrew in DownloadMii]]'
else
else
return "Version '''" .. dmversion .. "''' downloadable via [[DownloadMii]] [[Category:3DS Homebrew in DownloadMii]]"
return "Version '''" .. dmversion .. "''' downloadable via [[DownloadMii]] [[Category:Switch Homebrew in DownloadMii]]"
end
end
end
end
Line 156: Line 177:
   
   
local ibData = {
local ibData = {
    header1 = div3(),
title    = a.title,
title    = a.title,
image    = a.image,
image    = a.image,
imagesize    = a.imagesize or '48px',
imagesize    = a.imagesize or '48px',
imagecaption = a.imagecaption,
imagecaption = a.imagecaption,
         header1 = div2(),
         header2 = div2(),
header2 = 'General',
header3 = 'General',
label3   = 'Author',
label4   = 'Author',
data3   = a.author,
data4   = a.author,
label4   = 'Contributor',
label5   = 'Contributor',
data4   = userList( a.contributor ),
data5   = userList( a.contributor ),
label5   = 'Ported by',
label6   = 'Ported by',
data5   = userList( a.portedby ),
data6   = userList( a.portedby ),
label6   = 'Type',
label7   = 'Type',
data6   = getType( a['type'] ),
data7   = getType( a['type'] ),
label7   = 'Version',
label8   = 'Version',
data7   = a.version,
data8   = a.version,
label8   = 'License',
label9   = 'License',
data8   = getLicense( a.license ),
data9   = getLicense( a.license ),
label9   = 'Language',
label10   = 'Language',
data9   = a.language,
data10   = a.language,
label10 = 'Format',
label11 = 'Format',
data10   = getFormats( a ),
data11   = getFormats( a ),
label11   = 'Last Updated',
label12   = 'Last Updated',
data11   = a.lastupdated,
data12   = a.lastupdated,
         header20 = div(),
         header20 = div(),
header13 = div4(),
-- Links
-- Links
data15  = getLink( 'Download', a.download, a.downloadraw ),
data15  = getLink( 'Download', a.download, a.downloadraw ),
data16  = getLink( 'Website', a.website ),
data16  = getLink( 'Website', a.website ),
data17  = getSource( a.source ),
data17  = getSource( a.source ),
data18  = getLink( 'Support Author', a.discussion ),
data18  = getDonation( 'Support Author', a.donation),
data19  = getDownloadMii( a.dm, a.dmversion, a.version ),
data19  = getDownloadMii( a.dm, a.dmversion, a.version ),
below    = a.below
below    = a.below
Line 194: Line 217:
if a.cia == 'yes' then
if a.cia == 'yes' then
ibData.header11 = 'CIA information'
ibData.header11 = 'CIA information'
ibData.label12 = 'Title ID'
ibData.label112 = 'Title ID'
ibData.data12   = a.titleID or 'Unknown[[Category:3DS Homebrew missing CIA titleID]]'
ibData.data112   = a.titleID or 'Unknown[[Category:Switch Homebrew missing CIA titleID]]'
ibData.label13 = 'Unique ID'
ibData.label113 = 'Unique ID'
ibData.data13   = a.uniqueID or 'Unknown[[Category:3DS Homebrew missing CIA uniqueID]]'
ibData.data113   = a.uniqueID or 'Unknown[[Category:Switch Homebrew missing CIA uniqueID]]'
end
end
   
   

Revision as of 23:26, 28 March 2023

Documentation for this module may be created at Module:Infobox Switch Homebrews/doc

local p = {}

local function div()
local div = mw.html.create( 'div' )
div
	:attr( 'id', 'Ads-Infobox' )
return tostring( div )
end

local function div2()
local div = mw.html.create( 'div' )
div
	:attr( 'id', 'largemobilebanner' )
return tostring( div )
end

local function div3()
local div = mw.html.create( 'div' )
div
	:attr( 'id', 'Ads-Infobox1' )
return tostring( div )
end

local function div4()
local div = mw.html.create( 'div' )
div
	:attr( 'id', 'Ads-Infobox3' )
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 Switch homebrew applications#Media players|Media player]] [[Category:Switch Homebrew media players]]',
		['utility']            = '[[List of Switch homebrew applications#Utilities|Utility]] [[Category:Switch Homebrew utilities]]',
		['operating system']   = '[[List of Switch homebrew applications#Operating systems|Operating system]] [[Category:Switch Homebrew operating systems]]',
		['math']               = '[[List of Switch homebrew applications#Math|Math application]] [[Category:Switch Homebrew math applications]]',
		['other']              = '[[List of Switch homebrew applications#Other applications|Other application]] [[Category:Switch Homebrew other applications]]',
		-- Games
		['arcade game']        = '[[List of Switch homebrew games#Arcade|Arcade game]] [[Category:Switch Homebrew arcade games]]',
		['board game']         = '[[List of Switch homebrew games#Board|Board game]] [[Category:Switch Homebrew board games]]',
		['card game']          = '[[List of Switch homebrew games#Card|Card game]] [[Category:Switch Homebrew card games]]',
		['game engine']        = '[[List of Switch homebrew games#Game engine|Game engine]] [[Category:Switch Homebrew game engines]]',
		['music game']         = '[[List of Switch homebrew games#Music|Music game]] [[Category:Switch Homebrew music games]]',
		['platform game']      = '[[List of Switch homebrew games#Platform|Platform game]] [[Category:Switch Homebrew platform games]]',
		['puzzle game']        = '[[List of Switch homebrew games#Puzzle|Puzzle game]] [[Category:Switch Homebrew puzzle games]]',
		['racing game']        = '[[List of Switch homebrew games#Racing|Racing game]] [[Category:Switch Homebrew racing games]]',
		['role playing game']  = '[[List of Switch homebrew games#Role playing|Role playing game]] [[Category:Switch Homebrew role playing games]]',
		['shooting game']      = '[[List of Switch homebrew games#Shooter|Shooting game]] [[Category:Switch Homebrew shooting games]]',
		['simulation game']    = '[[List of Switch homebrew games#Simulation|Simulation game]] [[Category:Switch Homebrew simulation games]]',
		['trivia game']        = '[[List of Switch homebrew games#Trivia|Trivia game]] [[Category:Switch Homebrew trivia games]]',
		['other game']         = '[[List of Switch homebrew games#Other games|Other game]] [[Category:Switch Homebrew other games]]',
		-- Emulators
		['console emulator']   = '[[List of Switch homebrew emulators#Console|Console emulator]] [[Category:Switch Homebrew console emulators]]',
		['handheld emulator']  = '[[List of Switch homebrew emulators#Handheld|Handheld emulator]] [[Category:Switch Homebrew portable emulators]]',
		['arcade emulator']    = '[[List of Switch homebrew emulators#Arcade|Arcade emulator]] [[Category:Switch Homebrew arcade emulators]]',
		['computer emulator']  = '[[List of Switch homebrew emulators#Computer|Computer emulator]] [[Category:Switch Homebrew computer emulators]]',
		-- Loaders
		['loader']             = '[[List of Switch homebrew loaders|Loader]] [[Category:Switch Homebrew loaders]]',
		-- Exploits
		['exploit']            = '[[List of Switch homebrew exploits|Exploit]] [[Category:Switch Homebrew exploits]]',
		-- System Tools
		['system tool']        = '[[List of Switch system tools|System tool]] [[Category:Switch homebrew system tools]]',
		-- PC Utilities
		['pc utility']         = '[[List of Switch PC utilities|PC utility]] [[Category:Switch PC utilities]]',
		-- Demos
		['demo']               = '[[List of Switch homebrew demos|Demo]] [[Category:Switch 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 = { 'Switchx', 'Switch', '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 getDonation( donation )
	if empty( donation ) then return end
	if donation == 'included' then return 'donation included[[Category:Support the author]]' end
 
	return getLink( 'donation', donation ) .. '[[Category:Support the author]]'
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:Switch Homebrew in DownloadMii]]'
	else
		return "Version '''" .. dmversion .. "''' downloadable via [[DownloadMii]] [[Category:Switch 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 = {
	    header1 = div3(),
		title    = a.title,
		image    = a.image,
		imagesize    = a.imagesize or '48px',
		imagecaption = a.imagecaption,
        header2 = div2(),
		header3  = 'General',
		label4   = 'Author',
		data4    = a.author,
		label5   = 'Contributor',
		data5    = userList( a.contributor ),
		label6   = 'Ported by',
		data6    = userList( a.portedby ),
		label7   = 'Type',
		data7    = getType( a['type'] ),
		label8   = 'Version',
		data8    = a.version,
		label9   = 'License',
		data9    = getLicense( a.license ),
		label10   = 'Language',
		data10    = a.language,
		label11  = 'Format',
		data11   = getFormats( a ),
		label12   = 'Last Updated',
		data12    = a.lastupdated,
        header20 = div(),
		header13 = div4(),
		-- Links
		data15   = getLink( 'Download', a.download, a.downloadraw ),
		data16   = getLink( 'Website', a.website ),
		data17   = getSource( a.source ),
		data18   = getDonation( 'Support Author', a.donation),
		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.label112  = 'Title ID'
		ibData.data112   = a.titleID or 'Unknown[[Category:Switch Homebrew missing CIA titleID]]'
		ibData.label113  = 'Unique ID'
		ibData.data113   = a.uniqueID or 'Unknown[[Category:Switch Homebrew missing CIA uniqueID]]'
	end
 
	return infobox.infobox( ibData )
end
 
return p

Advertising: