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

Module:Infobox PSP Homebrews: Difference between revisions

From GameBrew
No edit summary
No edit summary
Tag: Manual revert
 
(20 intermediate revisions by 2 users not shown)
Line 5: Line 5:
div
div
:attr( 'id', 'Ads-Infobox' )
: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 )
return tostring( div )
end
end
Line 30: Line 44:
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 PSP homebrew applications#Media players|Media player]] [[Category:PSP Homebrew media players]]',
        ['Custom Firmwares']     = {'PSP homebrew applications', 'Custom firmwares on PSP', 'PSP homebrew applications'},
['utility']           = '[[List of PSP homebrew applications#Utilities|Utility]] [[Category:PSP Homebrew utilities]]',
        ['File Browsers']        = {'PSP homebrew applications', 'Utility applications on PSP', 'PSP homebrew applications'},
['operating system']   = '[[List of PSP homebrew applications#Operating systems|Operating system]] [[Category:PSP Homebrew operating systems]]',
        ['Math']                = {'PSP homebrew applications', 'Maths applications on PSP', 'PSP homebrew applications'},
['math']               = '[[List of PSP homebrew applications#Math|Math application]] [[Category:PSP Homebrew math applications]]',
        ['Media Players']       = {'PSP homebrew applications', 'Media players on PSP', 'PSP homebrew applications'},
['other']              = '[[List of PSP homebrew applications#Other applications|Other application]] [[Category:PSP Homebrew other applications]]',
        ['Music']               = {'PSP homebrew applications', 'Music applications on PSP', 'PSP homebrew applications'},
-- Games
        ['Operating Systems']   = {'PSP homebrew applications', 'Operating systems on PSP', 'PSP homebrew applications'},
['arcade game']       = '[[List of PSP homebrew games#Arcade|Arcade game]] [[Category:PSP Homebrew arcade games]]',
        ['Other']               = {'PSP homebrew applications', 'Other applications on PSP', 'PSP homebrew applications'},
['board game']         = '[[List of PSP homebrew games#Board|Board game]] [[Category:PSP Homebrew board games]]',
        ['System Tools']         = {'PSP homebrew applications', 'System tools on PSP', 'PSP homebrew applications'},
['card game']         = '[[List of PSP homebrew games#Card|Card game]] [[Category:PSP Homebrew card games]]',
        ['Utilities']           = {'PSP homebrew applications', 'Utility applications on PSP', 'PSP homebrew applications'},
['game engine']       = '[[List of PSP homebrew games#Game engine|Game engine]] [[Category:PSP Homebrew game engines]]',
        ['Plugins']              = {'PSP homebrew applications', 'PSP plugins', 'PSP homebrew applications'},
['music game']         = '[[List of PSP homebrew games#Music|Music game]] [[Category:PSP Homebrew music games]]',
        -- Games
['platform game']     = '[[List of PSP homebrew games#Platform|Platform game]] [[Category:PSP Homebrew platform games]]',
        ['Action']               = {'PSP homebrew games', 'Action games on PSP', 'PSP homebrew games'},
['puzzle game']       = '[[List of PSP homebrew games#Puzzle|Puzzle game]] [[Category:PSP Homebrew puzzle games]]',
        ['Adventure']            = {'PSP homebrew games', 'Adventure games on PSP', 'PSP homebrew games'},
['racing game']       = '[[List of PSP homebrew games#Racing|Racing game]] [[Category:PSP Homebrew racing games]]',
        ['Arcade Games']        = {'PSP homebrew games', 'Arcade games on PSP', 'PSP homebrew games'},
['role playing game'] = '[[List of PSP homebrew games#Role playing|Role playing game]] [[Category:PSP Homebrew role playing games]]',
        ['Board']               = {'PSP homebrew games', 'Board games on PSP', 'PSP homebrew games'},
['shooting game']     = '[[List of PSP homebrew games#Shooter|Shooting game]] [[Category:PSP Homebrew shooting games]]',
        ['Card']                 = {'PSP homebrew games', 'Card games on PSP', 'PSP homebrew games'},
['simulation game']   = '[[List of PSP homebrew games#Simulation|Simulation game]] [[Category:PSP Homebrew simulation games]]',
        ['Game Engine']         = {'PSP homebrew games', 'Game engines on PSP', 'PSP homebrew games'},
['trivia game']       = '[[List of PSP homebrew games#Trivia|Trivia game]] [[Category:PSP Homebrew trivia games]]',
        ['Music Games']         = {'PSP homebrew games', 'Music games on PSP', 'PSP homebrew games'},
['other game']         = '[[List of PSP homebrew games#Other games|Other game]] [[Category:PSP Homebrew other games]]',
        ['Other Games']         = {'PSP homebrew games', 'Other games on PSP', 'PSP homebrew games'},
-- Emulators
        ['Platform']             = {'PSP homebrew games', 'Platform games on PSP', 'PSP homebrew games'},
['console emulator']   = '[[List of PSP homebrew emulators#Console|Console emulator]] [[Category:PSP Homebrew console emulators]]',
        ['Puzzle']               = {'PSP homebrew games', 'Puzzle games on PSP', 'PSP homebrew games'},
['handheld emulator'] = '[[List of PSP homebrew emulators#Handheld|Handheld emulator]] [[Category:PSP Homebrew portable emulators]]',
        ['Racing']               = {'PSP homebrew games', 'Racing games on PSP', 'PSP homebrew games'},
['arcade emulator']   = '[[List of PSP homebrew emulators#Arcade|Arcade emulator]] [[Category:PSP Homebrew arcade emulators]]',
        ['Role Playing']         = {'PSP homebrew games', 'Role playing games on PSP', 'PSP homebrew games'},
['computer emulator'] = '[[List of PSP homebrew emulators#Computer|Computer emulator]] [[Category:PSP Homebrew computer emulators]]',
        ['Shooter']             = {'PSP homebrew games', 'Shooter games on PSP', 'PSP homebrew games'},
-- Loaders
        ['Simulation']           = {'PSP homebrew games', 'Simulation games on PSP', 'PSP homebrew games'},
['loader']             = '[[List of PSP homebrew loaders|Loader]] [[Category:PSP Homebrew loaders]]',
        ['Strategy']             = {'PSP homebrew games', 'Strategy games on PSP', 'PSP homebrew games'},
-- Exploits
        ['Trivia']               = {'PSP homebrew games', 'Trivia games on PSP', 'PSP homebrew games'},
['exploit']            = '[[List of PSP homebrew exploits|Exploit]] [[Category:PSP Homebrew exploits]]',
        ['OpenBOR Games']       = {'PSP homebrew games', 'OpenBOR games on PSP', 'PSP homebrew games'},
-- System Tools
        -- Emulators
['system tool']       = '[[List of PSP system tools|System tool]] [[Category:PSP homebrew system tools]]',
        ['Arcade']               = {'PSP homebrew emulators', 'Arcade emulators on PSP', 'PSP homebrew emulators'},
-- PC Utilities
        ['Computer']            = {'PSP homebrew emulators', 'Computer emulators on PSP', 'PSP homebrew emulators'},
['pc utility']        = '[[List of PSP PC utilities|PC utility]] [[Category:PSP PC utilities]]',
        ['Console']             = {'PSP homebrew emulators', 'Console emulators on PSP', 'PSP homebrew emulators'},
-- Demos
        ['Handheld']             = {'PSP homebrew emulators', 'Handheld emulators on PSP', 'PSP homebrew emulators'},
['demo']               = '[[List of PSP homebrew demos|Demo]] [[Category:PSP homebrew demos]]',
        ['Other Emulators']     = {'PSP homebrew emulators', 'Other emulators on PSP', 'PSP homebrew emulators'},
}
        -- PC (PC Utilities for PSP)
        ['Development Libraries'] = {'PSP PC utilities', 'Development utilities for PSP', 'PC utilities for PSP'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        ['Development']            = {'PSP PC utilities', 'Development utilities for PSP', 'PC utilities for PSP'},
        ['File Operation']        = {'PSP PC utilities', 'File management utilities for PSP', 'PC utilities for PSP'},
        ['Save and Game Managers'] = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        ['PSP Streaming']         = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        ['Theme Tools']            = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        ['PC Utilities']          = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        -- Demos
        ['Demos']               = {'PSP homebrew demos', 'Demo homebrews on PSP', 'PSP homebrew applications'},
        -- ROM Hack
        ['Game Hacks']          = {'PSP Rom Hacks', 'PSP game hacks', 'PSP rom hacks'},
        ['Translations']        = {'PSP Rom Hacks', 'PSP game translations', 'PSP rom hacks'},
        ['Hack Utilities']      = {'PSP Rom Hacks', 'PSP hack utilities', 'PSP rom hacks'},
        ['Save Editors']         = {'PSP Rom Hacks', 'PSP hack utilities', 'PSP 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
   
   
Line 125: Line 159:
local function getSource( source )
local function getSource( source )
if empty( source ) then return end
if empty( source ) then return end
if source == 'included' then return 'Source included[[Category:Open source homebrew]]' end
if source == 'included' then return 'Source included[[Category:PSP open source homebrew]]' end
   
   
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
return getLink( 'Source', source ) .. '[[Category:PSP open source homebrew]]'
end
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 )
local function getDownloadMii( dm, dmversion, version )
if not dm or dm ~= 'yes' then return end
if not dm or dm ~= 'yes' then return end
Line 153: Line 194:
imagesize    = a.imagesize or '48px',
imagesize    = a.imagesize or '48px',
imagecaption = a.imagecaption,
imagecaption = a.imagecaption,
header1 = 'General',
header2 = 'General',
description = a.description,
description = a.description,
label2   = 'Author',
label3   = 'Author',
data2   = a.author,
data3   = a.author,
label4  = 'Contributor',
label4  = 'Contributor',
data4    = userList( a.contributor ),
data4    = userList( a.contributor ),
Line 173: Line 214:
label11  = 'Last Updated',
label11  = 'Last Updated',
data11    = a.lastupdated,
data11    = a.lastupdated,
        header13 = div3(),
         header20 = div(),
         header20 = div(),
        header1 = div2(),
-- 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( 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 187: Line 230:
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:3DS 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:3DS Homebrew missing CIA uniqueID]]'
end
end
   
   

Latest revision as of 04:59, 10 December 2024

Documentation for this module may be created at Module:Infobox PSP 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
        ['Custom Firmwares']     = {'PSP homebrew applications', 'Custom firmwares on PSP', 'PSP homebrew applications'},
        ['File Browsers']        = {'PSP homebrew applications', 'Utility applications on PSP', 'PSP homebrew applications'},
        ['Math']                 = {'PSP homebrew applications', 'Maths applications on PSP', 'PSP homebrew applications'},
        ['Media Players']        = {'PSP homebrew applications', 'Media players on PSP', 'PSP homebrew applications'},
        ['Music']                = {'PSP homebrew applications', 'Music applications on PSP', 'PSP homebrew applications'},
        ['Operating Systems']    = {'PSP homebrew applications', 'Operating systems on PSP', 'PSP homebrew applications'},
        ['Other']                = {'PSP homebrew applications', 'Other applications on PSP', 'PSP homebrew applications'},
        ['System Tools']         = {'PSP homebrew applications', 'System tools on PSP', 'PSP homebrew applications'},
        ['Utilities']            = {'PSP homebrew applications', 'Utility applications on PSP', 'PSP homebrew applications'},
        ['Plugins']              = {'PSP homebrew applications', 'PSP plugins', 'PSP homebrew applications'},
        -- Games
        ['Action']               = {'PSP homebrew games', 'Action games on PSP', 'PSP homebrew games'},
        ['Adventure']            = {'PSP homebrew games', 'Adventure games on PSP', 'PSP homebrew games'},
        ['Arcade Games']         = {'PSP homebrew games', 'Arcade games on PSP', 'PSP homebrew games'},
        ['Board']                = {'PSP homebrew games', 'Board games on PSP', 'PSP homebrew games'},		
        ['Card']                 = {'PSP homebrew games', 'Card games on PSP', 'PSP homebrew games'},	
        ['Game Engine']          = {'PSP homebrew games', 'Game engines on PSP', 'PSP homebrew games'},	
        ['Music Games']          = {'PSP homebrew games', 'Music games on PSP', 'PSP homebrew games'},	
        ['Other Games']          = {'PSP homebrew games', 'Other games on PSP', 'PSP homebrew games'},	
        ['Platform']             = {'PSP homebrew games', 'Platform games on PSP', 'PSP homebrew games'},	
        ['Puzzle']               = {'PSP homebrew games', 'Puzzle games on PSP', 'PSP homebrew games'},	
        ['Racing']               = {'PSP homebrew games', 'Racing games on PSP', 'PSP homebrew games'},	
        ['Role Playing']         = {'PSP homebrew games', 'Role playing games on PSP', 'PSP homebrew games'},	
        ['Shooter']              = {'PSP homebrew games', 'Shooter games on PSP', 'PSP homebrew games'},	
        ['Simulation']           = {'PSP homebrew games', 'Simulation games on PSP', 'PSP homebrew games'},	
        ['Strategy']             = {'PSP homebrew games', 'Strategy games on PSP', 'PSP homebrew games'},	
        ['Trivia']               = {'PSP homebrew games', 'Trivia games on PSP', 'PSP homebrew games'},	
        ['OpenBOR Games']        = {'PSP homebrew games', 'OpenBOR games on PSP', 'PSP homebrew games'},	
        -- Emulators
        ['Arcade']               = {'PSP homebrew emulators', 'Arcade emulators on PSP', 'PSP homebrew emulators'},
        ['Computer']             = {'PSP homebrew emulators', 'Computer emulators on PSP', 'PSP homebrew emulators'},
        ['Console']              = {'PSP homebrew emulators', 'Console emulators on PSP', 'PSP homebrew emulators'},
        ['Handheld']             = {'PSP homebrew emulators', 'Handheld emulators on PSP', 'PSP homebrew emulators'},
        ['Other Emulators']      = {'PSP homebrew emulators', 'Other emulators on PSP', 'PSP homebrew emulators'},
        -- PC (PC Utilities for PSP)
        ['Development Libraries']  = {'PSP PC utilities', 'Development utilities for PSP', 'PC utilities for PSP'},
        ['Development']            = {'PSP PC utilities', 'Development utilities for PSP', 'PC utilities for PSP'},
        ['File Operation']         = {'PSP PC utilities', 'File management utilities for PSP', 'PC utilities for PSP'},
        ['Save and Game Managers'] = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        ['PSP Streaming']          = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        ['Theme Tools']            = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        ['PC Utilities']           = {'PSP PC utilities', 'Other PC utilities for PSP', 'PC utilities for PSP'},
        -- Demos
        ['Demos']                = {'PSP homebrew demos', 'Demo homebrews on PSP', 'PSP homebrew applications'},
        -- ROM Hack
        ['Game Hacks']           = {'PSP Rom Hacks', 'PSP game hacks', 'PSP rom hacks'},
        ['Translations']         = {'PSP Rom Hacks', 'PSP game translations', 'PSP rom hacks'},
        ['Hack Utilities']       = {'PSP Rom Hacks', 'PSP hack utilities', 'PSP rom hacks'},
        ['Save Editors']         = {'PSP Rom Hacks', 'PSP hack utilities', 'PSP 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:PSP open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:PSP 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',
		description = a.description,
		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.header11 = '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: