Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Infobox 3DS Homebrews: Difference between revisions

From GameBrew
No edit summary
No edit summary
 
(16 intermediate revisions by 2 users not shown)
Line 43: Line 43:
return table.concat( ret, ', ' )
return table.concat( ret, ', ' )
end
end
 
local function getType( type )
local function getType(typeVal)
if empty( type ) then return end
    if not typeVal then return end
 
local types = {
    local categories = {
-- Applications
        -- Applications
['media player']       = '[[List of 3DS homebrew applications#Media players|Media player]] [[Category:3DS Homebrew media players]]',
        ['Media Players']       = {'3DS homebrew applications', 'Media players on 3DS', '3DS homebrew applications'},
['utility']            = '[[List of 3DS homebrew applications#Utilities|Utility]] [[Category:3DS Homebrew utilities]]',
        ['File Browsers']       = {'3DS homebrew applications', 'Utility applications on 3DS', '3DS homebrew applications'},
['operating system']   = '[[List of 3DS homebrew applications#Operating systems|Operating system]] [[Category:3DS Homebrew operating systems]]',
        ['System Tools']         = {'3DS homebrew applications', 'System tools on 3DS', '3DS homebrew applications'},
['math']               = '[[List of 3DS homebrew applications#Math|Math application]] [[Category:3DS Homebrew math applications]]',
        ['Utilities']            = {'3DS homebrew applications', 'Utility applications on 3DS', '3DS homebrew applications'},
['other']             = '[[List of 3DS homebrew applications#Other applications|Other application]] [[Category:3DS Homebrew other applications]]',
        ['System Tools']        = {'3DS homebrew applications', 'System tools on 3DS', '3DS homebrew applications'},
-- Games
        ['Save Managers and Editors'] = {'3DS homebrew applications', 'Utility applications on 3DS', '3DS homebrew applications'},
['arcade game']       = '[[List of 3DS homebrew games#Arcade|Arcade game]] [[Category:3DS Homebrew arcade games]]',
        ['Operating Systems']   = {'3DS homebrew applications', 'Operating systems on 3DS', '3DS homebrew applications'},
['board game']         = '[[List of 3DS homebrew games#Board|Board game]] [[Category:3DS Homebrew board games]]',
        ['Math'] = {'3DS homebrew applications', 'Maths applications on 3DS', '3DS homebrew applications'},
['card game']         = '[[List of 3DS homebrew games#Card|Card game]] [[Category:3DS Homebrew card games]]',
        ['Music Apps']           = {'3DS homebrew applications', 'Music applications on 3DS', '3DS homebrew applications'},
['game engine']       = '[[List of 3DS homebrew games#Game engine|Game engine]] [[Category:3DS Homebrew game engines]]',
        ['Other Apps']           = {'3DS homebrew applications', 'Other applications on 3DS', '3DS homebrew applications'},
['music game']         = '[[List of 3DS homebrew games#Music|Music game]] [[Category:3DS Homebrew music games]]',
        -- Games
['platform game']     = '[[List of 3DS homebrew games#Platform|Platform game]] [[Category:3DS Homebrew platform games]]',
        ['Action']               = {'3DS homebrew games', 'Action games on 3DS', '3DS homebrew games'},
['puzzle game']       = '[[List of 3DS homebrew games#Puzzle|Puzzle game]] [[Category:3DS Homebrew puzzle games]]',
        ['Adventure']            = {'3DS homebrew games', 'Adventure games on 3DS', '3DS homebrew games'},
['racing game']       = '[[List of 3DS homebrew games#Racing|Racing game]] [[Category:3DS Homebrew racing games]]',
        ['Arcade Games']        = {'3DS homebrew games', 'Arcade games on 3DS', '3DS homebrew games'},
['role playing game'] = '[[List of 3DS homebrew games#Role playing|Role playing game]] [[Category:3DS Homebrew role playing games]]',
        ['Board']               = {'3DS homebrew games', 'Board games on 3DS', '3DS homebrew games'},
['shooting game']     = '[[List of 3DS homebrew games#Shooter|Shooting game]] [[Category:3DS Homebrew shooting games]]',
        ['Card']                 = {'3DS homebrew games', 'Card games on 3DS', '3DS homebrew games'},
['simulation game']   = '[[List of 3DS homebrew games#Simulation|Simulation game]] [[Category:3DS Homebrew simulation games]]',
        ['Game Engine']         = {'3DS homebrew games', 'Game engines on 3DS', '3DS homebrew games'},
['trivia game']       = '[[List of 3DS homebrew games#Trivia|Trivia game]] [[Category:3DS Homebrew trivia games]]',
        ['Music']               = {'3DS homebrew games', 'Music games on 3DS', '3DS homebrew games'},
['other game']         = '[[List of 3DS homebrew games#Other games|Other game]] [[Category:3DS Homebrew other games]]',
        ['Platform']             = {'3DS homebrew games', 'Platform games on 3DS', '3DS homebrew games'},
-- Emulators
        ['Puzzle']               = {'3DS homebrew games', 'Puzzle games on 3DS', '3DS homebrew games'},
['console emulator']   = '[[List of 3DS homebrew emulators#Console|Console emulator]] [[Category:3DS Homebrew console emulators]]',
        ['Racing']               = {'3DS homebrew games', 'Racing games on 3DS', '3DS homebrew games'},
['handheld emulator'] = '[[List of 3DS homebrew emulators#Handheld|Handheld emulator]] [[Category:3DS Homebrew portable emulators]]',
        ['Role Playing']         = {'3DS homebrew games', 'Role playing games on 3DS', '3DS homebrew games'},
['arcade emulator']   = '[[List of 3DS homebrew emulators#Arcade|Arcade emulator]] [[Category:3DS Homebrew arcade emulators]]',
        ['Shooter']             = {'3DS homebrew games', 'Shooter games on 3DS', '3DS homebrew games'},
['computer emulator'] = '[[List of 3DS homebrew emulators#Computer|Computer emulator]] [[Category:3DS Homebrew computer emulators]]',
        ['Simulation']           = {'3DS homebrew games', 'Simulation games on 3DS', '3DS homebrew games'},
-- Loaders
        ['Strategy']             = {'3DS homebrew games', 'Strategy games on 3DS', '3DS homebrew games'},
['loader']             = '[[List of 3DS homebrew loaders|Loader]] [[Category:3DS Homebrew loaders]]',
        ['Trivia']               = {'3DS homebrew games', 'Trivia games on 3DS', '3DS homebrew games'},
-- Exploits
        ['Other Games']         = {'3DS homebrew games', 'Other games on 3DS', '3DS homebrew games'},
['exploit']            = '[[List of 3DS homebrew exploits|Exploit]] [[Category:3DS Homebrew exploits]]',
        -- Emulators
-- System Tools
        ['Console']             = {'3DS homebrew emulators', 'Console emulators on 3DS', '3DS homebrew emulators'},
['system tool']       = '[[List of 3DS system tools|System tool]] [[Category:3DS homebrew system tools]]',
        ['Handheld']             = {'3DS homebrew emulators', 'Handheld emulators on 3DS', '3DS homebrew emulators'},
-- PC Utilities
        ['Arcade']               = {'3DS homebrew emulators', 'Arcade emulators on 3DS', '3DS homebrew emulators'},
['pc utility']        = '[[List of 3DS PC utilities|PC utility]] [[Category:3DS PC utilities]]',
        ['Computer']             = {'3DS homebrew emulators', 'Computer emulators on 3DS', '3DS homebrew emulators'},
-- Demos
        ['Other Emulators']     = {'3DS homebrew emulators', 'Other emulators on 3DS', '3DS homebrew emulators'},
['Demos']               = '[[List of 3DS homebrew demos|Demos]] [[Category:Demo Homebrews on 3DS]]',
-- Homebrew Loaders
}
        ['Custom Firmwares']     = {'3DS homebrew loaders', 'Custom firmwares on 3DS', '3DS homebrew loaders'},
        ['Title Launchers']      = {'3DS homebrew loaders', 'Title launchers on 3DS', '3DS homebrew loaders'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        -- PC (PC Utilities for 3DS)
        ['File Operation']            = {'3DS PC utilities', 'File operation for 3DS', 'PC utilities for 3DS'},
        ['Forwarders and Virtual Console Injectors'] = {'3DS PC utilities', 'Forwarding and injection tools for 3DS', 'PC utilities for 3DS'},
        ['3DS Streaming']             = {'3DS PC utilities', 'Wireless streaming for 3DS', 'PC utilities for 3DS'},
        ['Theme Tools']               = {'3DS PC utilities', 'Theme tools for 3DS', 'PC utilities for 3DS'},
        ['ROM Managers and Patchers'] = {'3DS PC utilities', 'Other PC utilities for 3DS', 'PC utilities for 3DS'},
        ['Save and Game Managers']    = {'3DS PC utilities', 'Other PC utilities for 3DS', 'PC utilities for 3DS'},
        ['Developments']             = {'3DS PC utilities', 'Development utilities for 3DS', 'PC utilities for 3DS'},
        ['PC Utilities']             = {'3DS PC utilities', 'Other PC utilities for 3DS', 'PC utilities for 3DS'},
        -- Demos
        ['Demos']               = {'3DS homebrew demos', 'Demo homebrews on 3DS', '3DS homebrew applications'},
        -- ROM Hack
        ['Plugins']             = {'all 3DS Rom Hacks', '3DS plugins', '3DS homebrew rom hacks'},
         ['Game Hacks']          = {'all 3DS Rom Hacks', '3DS game hacks', '3DS homebrew rom hacks'},
        ['Translations']        = {'all 3DS Rom Hacks', '3DS game translations', '3DS homebrew rom hacks'},
        ['Hack Utilities']      = {'all 3DS Rom Hacks', '3DS hack utilities', '3DS homebrew rom hacks'},
        ['Save Editors']         = {'all 3DS Rom Hacks', '3DS hack utilities', '3DS homebrew rom hacks'},
    }
 
    local category = categories[typeVal]
    if category then
            return string.format('[[List of %s#%s|%s]] [[Category:%s]] [[Category:%s]]', category[1], typeVal, typeVal, category[2], category[3])
    else
        return typeVal .. '[[Category:Infobox homebrew using invalid type parameter]]'
    end
end
end
 
 
local function getLicense( license )
local function getLicense( license )
if empty( license ) then return end
if empty( license ) then return end
Line 93: Line 118:
local licenses = {
local licenses = {
['Apache']      = '[https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0]',
['Apache']      = '[https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0]',
['GNU GPL']      = '[https://www.gnu.org/licenses/gpl.html GNU GPL] [[Category:Demo Homebrews on 3DS]]',
['GNU GPL']      = '[https://www.gnu.org/licenses/gpl.html GNU GPL]',
['GNU LGPL']    = '[https://www.gnu.org/licenses/lgpl.html GNU LGPL]',
['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 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]',
['BSD 3-Clause'] = '[http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause]',
['Mixed']        = 'Mixed [[Category:Demo Homebrews on 3DS]]',
['Mixed']        = 'Mixed',
['MIT']          = '[http://opensource.org/licenses/mit-license.html MIT License]',
['MIT']          = '[http://opensource.org/licenses/mit-license.html MIT License]',
}
}
Line 182: Line 207:
data5    = userList( a.portedby ),
data5    = userList( a.portedby ),
label6  = 'Type',
label6  = 'Type',
data6    = a.type,
data6    = getType( a['type'] ),
label7  = 'Version',
label7  = 'Version',
data7    = a.version,
data7    = a.version,

Latest revision as of 01:12, 27 July 2024

Documentation for this module may be created at Module:Infobox 3DS 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 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(typeVal)
    if not typeVal then return end

    local categories = {
        -- Applications
        ['Media Players']        = {'3DS homebrew applications', 'Media players on 3DS', '3DS homebrew applications'},
        ['File Browsers']        = {'3DS homebrew applications', 'Utility applications on 3DS', '3DS homebrew applications'},
        ['System Tools']         = {'3DS homebrew applications', 'System tools on 3DS', '3DS homebrew applications'},
        ['Utilities']            = {'3DS homebrew applications', 'Utility applications on 3DS', '3DS homebrew applications'},
        ['System Tools']         = {'3DS homebrew applications', 'System tools on 3DS', '3DS homebrew applications'},
        ['Save Managers and Editors'] = {'3DS homebrew applications', 'Utility applications on 3DS', '3DS homebrew applications'},
        ['Operating Systems']    = {'3DS homebrew applications', 'Operating systems on 3DS', '3DS homebrew applications'},
        ['Math'] = {'3DS homebrew applications', 'Maths applications on 3DS', '3DS homebrew applications'},
        ['Music Apps']           = {'3DS homebrew applications', 'Music applications on 3DS', '3DS homebrew applications'},
        ['Other Apps']           = {'3DS homebrew applications', 'Other applications on 3DS', '3DS homebrew applications'},
        -- Games
        ['Action']               = {'3DS homebrew games', 'Action games on 3DS', '3DS homebrew games'},
        ['Adventure']            = {'3DS homebrew games', 'Adventure games on 3DS', '3DS homebrew games'},
        ['Arcade Games']         = {'3DS homebrew games', 'Arcade games on 3DS', '3DS homebrew games'},
        ['Board']                = {'3DS homebrew games', 'Board games on 3DS', '3DS homebrew games'},		
        ['Card']                 = {'3DS homebrew games', 'Card games on 3DS', '3DS homebrew games'},	
        ['Game Engine']          = {'3DS homebrew games', 'Game engines on 3DS', '3DS homebrew games'},	
        ['Music']                = {'3DS homebrew games', 'Music games on 3DS', '3DS homebrew games'},	
        ['Platform']             = {'3DS homebrew games', 'Platform games on 3DS', '3DS homebrew games'},	
        ['Puzzle']               = {'3DS homebrew games', 'Puzzle games on 3DS', '3DS homebrew games'},	
        ['Racing']               = {'3DS homebrew games', 'Racing games on 3DS', '3DS homebrew games'},	
        ['Role Playing']         = {'3DS homebrew games', 'Role playing games on 3DS', '3DS homebrew games'},	
        ['Shooter']              = {'3DS homebrew games', 'Shooter games on 3DS', '3DS homebrew games'},	
        ['Simulation']           = {'3DS homebrew games', 'Simulation games on 3DS', '3DS homebrew games'},	
        ['Strategy']             = {'3DS homebrew games', 'Strategy games on 3DS', '3DS homebrew games'},	
        ['Trivia']               = {'3DS homebrew games', 'Trivia games on 3DS', '3DS homebrew games'},	
        ['Other Games']          = {'3DS homebrew games', 'Other games on 3DS', '3DS homebrew games'},	
        -- Emulators
        ['Console']              = {'3DS homebrew emulators', 'Console emulators on 3DS', '3DS homebrew emulators'},
        ['Handheld']             = {'3DS homebrew emulators', 'Handheld emulators on 3DS', '3DS homebrew emulators'},
        ['Arcade']               = {'3DS homebrew emulators', 'Arcade emulators on 3DS', '3DS homebrew emulators'},
        ['Computer']             = {'3DS homebrew emulators', 'Computer emulators on 3DS', '3DS homebrew emulators'},
        ['Other Emulators']      = {'3DS homebrew emulators', 'Other emulators on 3DS', '3DS homebrew emulators'},
		-- Homebrew Loaders
        ['Custom Firmwares']     = {'3DS homebrew loaders', 'Custom firmwares on 3DS', '3DS homebrew loaders'},
        ['Title Launchers']      = {'3DS homebrew loaders', 'Title launchers on 3DS', '3DS homebrew loaders'},
        -- PC (PC Utilities for 3DS)
        ['File Operation']            = {'3DS PC utilities', 'File operation for 3DS', 'PC utilities for 3DS'},
        ['Forwarders and Virtual Console Injectors'] = {'3DS PC utilities', 'Forwarding and injection tools for 3DS', 'PC utilities for 3DS'},
        ['3DS Streaming']             = {'3DS PC utilities', 'Wireless streaming for 3DS', 'PC utilities for 3DS'},
        ['Theme Tools']               = {'3DS PC utilities', 'Theme tools for 3DS', 'PC utilities for 3DS'},
        ['ROM Managers and Patchers'] = {'3DS PC utilities', 'Other PC utilities for 3DS', 'PC utilities for 3DS'},
        ['Save and Game Managers']    = {'3DS PC utilities', 'Other PC utilities for 3DS', 'PC utilities for 3DS'},
        ['Developments']              = {'3DS PC utilities', 'Development utilities for 3DS', 'PC utilities for 3DS'},
        ['PC Utilities']              = {'3DS PC utilities', 'Other PC utilities for 3DS', 'PC utilities for 3DS'},
        -- Demos
        ['Demos']                = {'3DS homebrew demos', 'Demo homebrews on 3DS', '3DS homebrew applications'},
        -- ROM Hack
        ['Plugins']              = {'all 3DS Rom Hacks', '3DS plugins', '3DS homebrew rom hacks'},
        ['Game Hacks']           = {'all 3DS Rom Hacks', '3DS game hacks', '3DS homebrew rom hacks'},
        ['Translations']         = {'all 3DS Rom Hacks', '3DS game translations', '3DS homebrew rom hacks'},
        ['Hack Utilities']       = {'all 3DS Rom Hacks', '3DS hack utilities', '3DS homebrew rom hacks'},
        ['Save Editors']         = {'all 3DS Rom Hacks', '3DS hack utilities', '3DS homebrew rom hacks'},
    }

    local category = categories[typeVal]
    if category then
            return string.format('[[List of %s#%s|%s]] [[Category:%s]] [[Category:%s]]', category[1], typeVal, typeVal, category[2], category[3])
    else
        return typeVal .. '[[Category:Infobox homebrew using invalid type parameter]]'
    end
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:3DS open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:3DS 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( 'Support Author', 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: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,
		header2  = 'General',
		label3   = 'Author',
		data3    = 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,
        header13 = div3(),
        header20 = div(),
        header1 = div2(),
		-- Links
		data15   = getLink( 'Download', a.download, a.downloadraw ),
		data16   = getLink( 'Website', a.website ),
		data17   = getSource( a.source ),
		data18   = getDonation( 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.header111 = 'CIA information'
		ibData.label112  = 'Title ID'
		ibData.data112   = a.titleID or 'Unknown[[Category:3DS Homebrew missing CIA titleID]]'
		ibData.label113  = 'Unique ID'
		ibData.data113   = a.uniqueID or 'Unknown[[Category:3DS Homebrew missing CIA uniqueID]]'
	end
 
	return infobox.infobox( ibData )
end
 
return p

Advertising: