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

Module:Infobox Switch Homebrews: Difference between revisions

From GameBrew
No edit summary
No edit summary
 
(17 intermediate revisions by 2 users not shown)
Line 51: Line 51:
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 players']       = '[[List of Switch Homebrew Applications#Media players|Media players]] [[Category:Switch Homebrew Media players]]',
        ['Media Players']             = {'Switch homebrew applications', 'Media players on Switch', 'Switch homebrew applications'},
['utility']           = '[[List of Switch homebrew applications#Utilities|Utility]] [[Category:Switch Homebrew utilities]]',
        ['File Browsers']             = {'Switch homebrew applications', 'File browsers on Switch', 'Switch homebrew applications'},
['operating system']   = '[[List of Switch homebrew applications#Operating systems|Operating system]] [[Category:Switch Homebrew operating systems]]',
        ['Save Managers and Editors'] = {'Switch homebrew applications', 'Savegame tools on Switch', 'Switch homebrew applications'},
['math']               = '[[List of Switch homebrew applications#Math|Math application]] [[Category:Switch Homebrew math applications]]',
        ['Title Launchers']          = {'Switch homebrew applications', 'Title launchers on Switch', 'Switch homebrew applications'},
['other']             = '[[List of Switch homebrew applications#Other applications|Other application]] [[Category:Switch Homebrew other applications]]',
        ['Utilities']                 = {'Switch homebrew applications', 'Utility applications on Switch', 'Switch homebrew applications'},
-- Games
        ['System Tools']             = {'Switch homebrew applications', 'System tools on Switch', 'Switch homebrew applications'},
['arcade game']       = '[[List of Switch homebrew games#Arcade|Arcade game]] [[Category:Switch Homebrew arcade games]]',
        ['Custom Firmwares']         = {'Switch homebrew applications', 'Custom firmwares on Switch', 'Switch homebrew applications'},
['board game']         = '[[List of Switch homebrew games#Board|Board game]] [[Category:Switch Homebrew board games]]',
        ['Operating Systems']         = {'Switch homebrew applications', 'Operating systems on Switch', 'Switch homebrew applications'},
['card game']         = '[[List of Switch homebrew games#Card|Card game]] [[Category:Switch Homebrew card games]]',
        ['Math']                     = {'Switch homebrew applications', 'Maths applications on Switch', 'Switch homebrew applications'},
['game engine']       = '[[List of Switch homebrew games#Game engine|Game engine]] [[Category:Switch Homebrew game engines]]',
        ['Music Apps']               = {'Switch homebrew applications', 'Music applications on Switch', 'Switch homebrew applications'},
['music game']         = '[[List of Switch homebrew games#Music|Music game]] [[Category:Switch Homebrew music games]]',
        ['Other Apps']               = {'Switch homebrew applications', 'Other applications on Switch', 'Switch homebrew applications'},
['platform game']     = '[[List of Switch homebrew games#Platform|Platform game]] [[Category:Switch Homebrew platform games]]',
        -- Games
['puzzle game']       = '[[List of Switch homebrew games#Puzzle|Puzzle game]] [[Category:Switch Homebrew puzzle games]]',
        ['Action']                   = {'Switch homebrew games', 'Action games on Switch', 'Switch homebrew games'},
['racing game']       = '[[List of Switch homebrew games#Racing|Racing game]] [[Category:Switch Homebrew racing games]]',
        ['Adventure']                = {'Switch homebrew games', 'Adventure games on Switch', 'Switch homebrew games'},
['role playing game'] = '[[List of Switch homebrew games#Role playing|Role playing game]] [[Category:Switch Homebrew role playing games]]',
        ['Arcade Games']              = {'Switch homebrew games', 'Arcade games on Switch', 'Switch homebrew games'},
['shooting game']     = '[[List of Switch homebrew games#Shooter|Shooting game]] [[Category:Switch Homebrew shooting games]]',
        ['Board']                     = {'Switch homebrew games', 'Board games on Switch', 'Switch homebrew games'},
['simulation game']   = '[[List of Switch homebrew games#Simulation|Simulation game]] [[Category:Switch Homebrew simulation games]]',
        ['Card']                     = {'Switch homebrew games', 'Card games on Switch', 'Switch homebrew games'},
['trivia game']       = '[[List of Switch homebrew games#Trivia|Trivia game]] [[Category:Switch Homebrew trivia games]]',
        ['Game Engine']               = {'Switch homebrew games', 'Game engines on Switch', 'Switch homebrew games'},
['other game']         = '[[List of Switch homebrew games#Other games|Other game]] [[Category:Switch Homebrew other games]]',
        ['Music']                     = {'Switch homebrew games', 'Music games on Switch', 'Switch homebrew games'},
-- Emulators
        ['Other Games']               = {'Switch homebrew games', 'Other games on Switch', 'Switch homebrew games'},
['console emulator']   = '[[List of Switch homebrew emulators#Console|Console emulator]] [[Category:Switch Homebrew console emulators]]',
        ['Platform']                 = {'Switch homebrew games', 'Platform games on Switch', 'Switch homebrew games'},
['handheld emulator'] = '[[List of Switch homebrew emulators#Handheld|Handheld emulator]] [[Category:Switch Homebrew portable emulators]]',
        ['Puzzle']                   = {'Switch homebrew games', 'Puzzle games on Switch', 'Switch homebrew games'},
['arcade emulator']   = '[[List of Switch homebrew emulators#Arcade|Arcade emulator]] [[Category:Switch Homebrew arcade emulators]]',
        ['Racing']                   = {'Switch homebrew games', 'Racing games on Switch', 'Switch homebrew games'},
['computer emulator'] = '[[List of Switch homebrew emulators#Computer|Computer emulator]] [[Category:Switch Homebrew computer emulators]]',
        ['Role Playing']             = {'Switch homebrew games', 'Role playing games on Switch', 'Switch homebrew games'},
-- Loaders
        ['Shooter']                   = {'Switch homebrew games', 'Shooter games on Switch', 'Switch homebrew games'},
['loader']             = '[[List of Switch homebrew loaders|Loader]] [[Category:Switch Homebrew loaders]]',
        ['Simulation']               = {'Switch homebrew games', 'Simulation games on Switch', 'Switch homebrew games'},
-- Exploits
        ['Strategy']                 = {'Switch homebrew games', 'Strategy games on Switch', 'Switch homebrew games'},
['exploit']           = '[[List of Switch homebrew exploits|Exploit]] [[Category:Switch Homebrew exploits]]',
        ['Trivia']                   = {'Switch homebrew games', 'Trivia games on Switch', 'Switch homebrew games'},
-- System Tools
        -- Emulators
['system tool']       = '[[List of Switch system tools|System tool]] [[Category:Switch homebrew system tools]]',
        ['Arcade']                   = {'Switch homebrew emulators', 'Arcade emulators on Switch', 'Switch homebrew emulators'},
-- PC Utilities
        ['Computer']                  = {'Switch homebrew emulators', 'Computer emulators on Switch', 'Switch homebrew emulators'},
['pc utility']        = '[[List of Switch PC utilities|PC utility]] [[Category:Switch PC utilities]]',
        ['Console']                  = {'Switch homebrew emulators', 'Console emulators on Switch', 'Switch homebrew emulators'},
-- Demos
        ['Handheld']                 = {'Switch homebrew emulators', 'Handheld emulators on Switch', 'Switch homebrew emulators'},
['demo']               = '[[List of Switch homebrew demos|Demo]] [[Category:Switch homebrew demos]]',
        ['Other Emulators']           = {'Switch homebrew emulators', 'Other emulators on Switch', 'Switch homebrew emulators'},
}
        -- Plugins
        ['Overlays']                 = {'Switch homebrew plugins', 'Overlays on Switch', 'Switch addons'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        ['Sysmodules']               = {'Switch homebrew plugins', 'Sysmodules on Switch', 'Switch addons'},
        ['Plugins']                   = {'Switch homebrew plugins', 'Plugins on Switch', 'Switch addons'},
        -- PC (PC Utilities)
        ['PC Utilities']             = {'Switch PC utilities', 'Other PC utilities for Switch', 'PC utilities for Switch'},
        ['Theme Tools']              = {'Switch PC utilities', 'Theme tools for Switch', 'PC utilities for Switch'},
        ['Game Management']          = {'Switch PC utilities', 'Game library managers for Switch', 'PC utilities for Switch'},
        ['Emulation and Forwarders'] = {'Switch PC utilities', 'Emulation and forwarder tools for Switch', 'PC utilities for Switch'},
        ['Game Installer Companion'] = {'Switch PC utilities', 'Game installer companions for Switch', 'PC utilities for Switch'},
        ['Network']                  = {'Switch PC utilities', 'Network utilities for Switch', 'PC utilities for Switch'},
        ['Remote Play and Streaming'] = {'Switch PC utilities', 'Remote play and streaming programs for Switch', 'PC utilities for Switch'},
        ['Developments']             = {'Switch PC utilities', 'Development utilities for Switch', 'PC utilities for Switch'},
        -- Payloads
        ['Payload (Binaries)']         = {'Switch payloads', 'Payloads for Switch', 'Switch homebrew applications'},
        ['Payload Senders (Software)']  = {'Switch payloads', 'Payload Senders for Switch', 'Switch homebrew applications'},
        ['Payload Senders (Hardware)'] = {'Switch payloads', 'Payload Senders for Switch', 'Switch homebrew applications'},
        -- Demos
        ['Demos']                       = {'Switch homebrew demos', 'Demo homebrews on Switch', 'Switch homebrew applications'},
        -- ROM Hack
        ['Game Hacks']                 = {'Switch rom hacks', 'Switch game hacks', 'Switch rom hacks'},
         ['Translations']                = {'Switch rom hacks', 'Switch game translations', 'Switch rom hacks'},
        ['Hack Utilities']              = {'Switch rom hacks', 'Switch hack utilities', 'Switch rom hacks'},
        ['Save Editors and Converters'] = {'Switch rom hacks', 'Switch hack utilities', 'Switch 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
   
   

Latest revision as of 14:47, 22 Haziran 2024

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(typeVal)
    if not typeVal then return end

    local categories = {
        -- Applications
        ['Media Players']             = {'Switch homebrew applications', 'Media players on Switch', 'Switch homebrew applications'},
        ['File Browsers']             = {'Switch homebrew applications', 'File browsers on Switch', 'Switch homebrew applications'},
        ['Save Managers and Editors'] = {'Switch homebrew applications', 'Savegame tools on Switch', 'Switch homebrew applications'},
        ['Title Launchers']           = {'Switch homebrew applications', 'Title launchers on Switch', 'Switch homebrew applications'},
        ['Utilities']                 = {'Switch homebrew applications', 'Utility applications on Switch', 'Switch homebrew applications'},
        ['System Tools']              = {'Switch homebrew applications', 'System tools on Switch', 'Switch homebrew applications'},
        ['Custom Firmwares']          = {'Switch homebrew applications', 'Custom firmwares on Switch', 'Switch homebrew applications'},
        ['Operating Systems']         = {'Switch homebrew applications', 'Operating systems on Switch', 'Switch homebrew applications'},
        ['Math']                      = {'Switch homebrew applications', 'Maths applications on Switch', 'Switch homebrew applications'},
        ['Music Apps']                = {'Switch homebrew applications', 'Music applications on Switch', 'Switch homebrew applications'},
        ['Other Apps']                = {'Switch homebrew applications', 'Other applications on Switch', 'Switch homebrew applications'},
        -- Games
        ['Action']                    = {'Switch homebrew games', 'Action games on Switch', 'Switch homebrew games'},
        ['Adventure']                 = {'Switch homebrew games', 'Adventure games on Switch', 'Switch homebrew games'},
        ['Arcade Games']              = {'Switch homebrew games', 'Arcade games on Switch', 'Switch homebrew games'},
        ['Board']                     = {'Switch homebrew games', 'Board games on Switch', 'Switch homebrew games'},		
        ['Card']                      = {'Switch homebrew games', 'Card games on Switch', 'Switch homebrew games'},	
        ['Game Engine']               = {'Switch homebrew games', 'Game engines on Switch', 'Switch homebrew games'},	
        ['Music']                     = {'Switch homebrew games', 'Music games on Switch', 'Switch homebrew games'},	
        ['Other Games']               = {'Switch homebrew games', 'Other games on Switch', 'Switch homebrew games'},	
        ['Platform']                  = {'Switch homebrew games', 'Platform games on Switch', 'Switch homebrew games'},	
        ['Puzzle']                    = {'Switch homebrew games', 'Puzzle games on Switch', 'Switch homebrew games'},	
        ['Racing']                    = {'Switch homebrew games', 'Racing games on Switch', 'Switch homebrew games'},	
        ['Role Playing']              = {'Switch homebrew games', 'Role playing games on Switch', 'Switch homebrew games'},	
        ['Shooter']                   = {'Switch homebrew games', 'Shooter games on Switch', 'Switch homebrew games'},	
        ['Simulation']                = {'Switch homebrew games', 'Simulation games on Switch', 'Switch homebrew games'},	
        ['Strategy']                  = {'Switch homebrew games', 'Strategy games on Switch', 'Switch homebrew games'},	
        ['Trivia']                    = {'Switch homebrew games', 'Trivia games on Switch', 'Switch homebrew games'},	
        -- Emulators
        ['Arcade']                    = {'Switch homebrew emulators', 'Arcade emulators on Switch', 'Switch homebrew emulators'},
        ['Computer']                  = {'Switch homebrew emulators', 'Computer emulators on Switch', 'Switch homebrew emulators'},
        ['Console']                   = {'Switch homebrew emulators', 'Console emulators on Switch', 'Switch homebrew emulators'},
        ['Handheld']                  = {'Switch homebrew emulators', 'Handheld emulators on Switch', 'Switch homebrew emulators'},
        ['Other Emulators']           = {'Switch homebrew emulators', 'Other emulators on Switch', 'Switch homebrew emulators'},
        -- Plugins
        ['Overlays']                  = {'Switch homebrew plugins', 'Overlays on Switch', 'Switch addons'},
        ['Sysmodules']                = {'Switch homebrew plugins', 'Sysmodules on Switch', 'Switch addons'},
        ['Plugins']                   = {'Switch homebrew plugins', 'Plugins on Switch', 'Switch addons'},
        -- PC (PC Utilities)
        ['PC Utilities']              = {'Switch PC utilities', 'Other PC utilities for Switch', 'PC utilities for Switch'},
        ['Theme Tools']               = {'Switch PC utilities', 'Theme tools for Switch', 'PC utilities for Switch'},
        ['Game Management']           = {'Switch PC utilities', 'Game library managers for Switch', 'PC utilities for Switch'},
        ['Emulation and Forwarders']  = {'Switch PC utilities', 'Emulation and forwarder tools for Switch', 'PC utilities for Switch'},
        ['Game Installer Companion']  = {'Switch PC utilities', 'Game installer companions for Switch', 'PC utilities for Switch'},
        ['Network']                   = {'Switch PC utilities', 'Network utilities for Switch', 'PC utilities for Switch'},
        ['Remote Play and Streaming'] = {'Switch PC utilities', 'Remote play and streaming programs for Switch', 'PC utilities for Switch'},
        ['Developments']              = {'Switch PC utilities', 'Development utilities for Switch', 'PC utilities for Switch'},
        -- Payloads
        ['Payload (Binaries)']          = {'Switch payloads', 'Payloads for Switch', 'Switch homebrew applications'},
        ['Payload Senders (Software)']  = {'Switch payloads', 'Payload Senders for Switch', 'Switch homebrew applications'},
        ['Payload Senders (Hardware)']  = {'Switch payloads', 'Payload Senders for Switch', 'Switch homebrew applications'},
        -- Demos
        ['Demos']                       = {'Switch homebrew demos', 'Demo homebrews on Switch', 'Switch homebrew applications'},
        -- ROM Hack
        ['Game Hacks']                  = {'Switch rom hacks', 'Switch game hacks', 'Switch rom hacks'},
        ['Translations']                = {'Switch rom hacks', 'Switch game translations', 'Switch rom hacks'},
        ['Hack Utilities']              = {'Switch rom hacks', 'Switch hack utilities', 'Switch rom hacks'},
        ['Save Editors and Converters'] = {'Switch rom hacks', 'Switch hack utilities', 'Switch 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 = { '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:Switch open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:Switch 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: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 = {
		title    = a.title,
		image    = a.image,
		imagesize    = a.imagesize or '48px',
		imagecaption = a.imagecaption,
		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,
        header13 = div3(),
        header20 = div(),
        header2 = 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: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: