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

Documentation for this module may be created at Module:Infobox PS3 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']        = {'PS3 homebrew applications', 'Media players on PS3', 'PS3 homebrew applications'},
        ['File Browsers']        = {'PS3 homebrew applications', 'Utility applications on PS3', 'PS3 homebrew applications'},
        ['System Tools']         = {'PS3 homebrew applications', 'System tools on PS3', 'PS3 homebrew applications'},
        ['Utilities']            = {'PS3 homebrew applications', 'Utility applications on PS3', 'PS3 homebrew applications'},
        ['System Tools']         = {'PS3 homebrew applications', 'System tools on PS3', 'PS3 homebrew applications'},
        ['Save Managers and Editors'] = {'PS3 homebrew applications', 'Utility applications on PS3', 'PS3 homebrew applications'},
        ['Operating Systems']    = {'PS3 homebrew applications', 'Operating systems on PS3', 'PS3 homebrew applications'},
        ['Math']                 = {'PS3 homebrew applications', 'Maths applications on PS3', 'PS3 homebrew applications'},
        ['Music Apps']           = {'PS3 homebrew applications', 'Music applications on PS3', 'PS3 homebrew applications'},
        ['Other Apps']           = {'PS3 homebrew applications', 'Other applications on PS3', 'PS3 homebrew applications'},
        -- Games
        ['Action']               = {'PS3 homebrew games', 'Action games on PS3', 'PS3 homebrew games'},
        ['Adventure']            = {'PS3 homebrew games', 'Adventure games on PS3', 'PS3 homebrew games'},
        ['Arcade Games']         = {'PS3 homebrew games', 'Arcade games on PS3', 'PS3 homebrew games'},
        ['Board']                = {'PS3 homebrew games', 'Board games on PS3', 'PS3 homebrew games'},		
        ['Card']                 = {'PS3 homebrew games', 'Card games on PS3', 'PS3 homebrew games'},	
        ['Game Engine']          = {'PS3 homebrew games', 'Game engines on PS3', 'PS3 homebrew games'},	
        ['Music']                = {'PS3 homebrew games', 'Music games on PS3', 'PS3 homebrew games'},	
        ['Platform']             = {'PS3 homebrew games', 'Platform games on PS3', 'PS3 homebrew games'},	
        ['Puzzle']               = {'PS3 homebrew games', 'Puzzle games on PS3', 'PS3 homebrew games'},	
        ['Racing']               = {'PS3 homebrew games', 'Racing games on PS3', 'PS3 homebrew games'},	
        ['Role Playing']         = {'PS3 homebrew games', 'Role playing games on PS3', 'PS3 homebrew games'},	
        ['Shooter']              = {'PS3 homebrew games', 'Shooter games on PS3', 'PS3 homebrew games'},	
        ['Simulation']           = {'PS3 homebrew games', 'Simulation games on PS3', 'PS3 homebrew games'},	
        ['Strategy']             = {'PS3 homebrew games', 'Strategy games on PS3', 'PS3 homebrew games'},	
        ['Trivia']               = {'PS3 homebrew games', 'Trivia games on PS3', 'PS3 homebrew games'},	
        ['Other Games']          = {'PS3 homebrew games', 'Other games on PS3', 'PS3 homebrew games'},	
        -- Emulators
        ['Console']              = {'PS3 homebrew emulators', 'Console emulators on PS3', 'PS3 homebrew emulators'},
        ['Handheld']             = {'PS3 homebrew emulators', 'Handheld emulators on PS3', 'PS3 homebrew emulators'},
        ['Arcade']               = {'PS3 homebrew emulators', 'Arcade emulators on PS3', 'PS3 homebrew emulators'},
        ['Computer']             = {'PS3 homebrew emulators', 'Computer emulators on PS3', 'PS3 homebrew emulators'},
        ['Other Emulators']      = {'PS3 homebrew emulators', 'Other emulators on PS3', 'PS3 homebrew emulators'},
        -- PC (PC Utilities for PS3)
        ['File Operation']            = {'PS3 PC utilities', 'File operation for PS3', 'PC utilities for PS3'},
        ['Theme Tools']               = {'PS3 PC utilities', 'Theme tools for PS3', 'PC utilities for PS3'},
        ['Save and Game Managers']    = {'PS3 PC utilities', 'Other PC utilities for PS3', 'PC utilities for PS3'},
        ['Developments']              = {'PS3 PC utilities', 'Development utilities for PS3', 'PC utilities for PS3'},
        ['PC Utilities']              = {'PS3 PC utilities', 'Other PC utilities for PS3', 'PC utilities for PS3'},
        -- Demos
        ['Demos']                = {'PS3 homebrew demos', 'Demo homebrews on PS3', 'PS3 homebrew applications'},
        -- ROM Hack
        ['Plugins']              = {'all PS3 Rom Hacks', 'PS3 plugins', 'PS3 homebrew rom hacks'},
        ['Game Hacks']           = {'all PS3 Rom Hacks', 'PS3 game hacks', 'PS3 homebrew rom hacks'},
        ['Translations']         = {'all PS3 Rom Hacks', 'PS3 game translations', 'PS3 homebrew rom hacks'},
        ['Hack Utilities']       = {'all PS3 Rom Hacks', 'PS3 hack utilities', 'PS3 homebrew rom hacks'},
        ['Save Editors']         = {'all PS3 Rom Hacks', 'PS3 hack utilities', 'PS3 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 = { 'PS3x', 'PS3', '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:PS3 open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:PS3 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:PS3 Homebrew in DownloadMii]]'
	else
		return "Version '''" .. dmversion .. "''' downloadable via [[DownloadMii]] [[Category:PS3 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:PS3 Homebrew missing CIA titleID]]'
		ibData.label113  = 'Unique ID'
		ibData.data113   = a.uniqueID or 'Unknown[[Category:PS3 Homebrew missing CIA uniqueID]]'
	end
 
	return infobox.infobox( ibData )
end
 
return p

Advertising: