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

Module:Infobox Vita Homebrews: Difference between revisions

From GameBrew
No edit summary
(..)
 
(31 intermediate revisions by the same user not shown)
Line 44: 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 (Exploits)
['media player']       = '[[List of Vita homebrew applications#Media players|Media player]] [[Category:Vita Homebrew media players]]',
        ['File Browsers']     = {'Vita homebrew applications', 'File browsers on Vita', 'Vita homebrew applications'},
['utility']           = '[[List of Vita homebrew applications#Utilities|Utility]] [[Category:Vita Homebrew utilities]]',
        ['Custom Firmwares']  = {'Vita homebrew applications', 'Custom firmwares on Vita', 'Vita homebrew applications'},
['operating system']  = '[[List of Vita homebrew applications#Operating systems|Operating system]] [[Category:Vita Homebrew operating systems]]',
        ['Math']              = {'Vita homebrew applications', 'Maths applications on Vita', 'Vita homebrew applications'},
['math']               = '[[List of Vita homebrew applications#Math|Math application]] [[Category:Vita Homebrew math applications]]',
        ['Media Players']     = {'Vita homebrew applications', 'Media players on Vita', 'Vita homebrew applications'},
['other']             = '[[List of Vita homebrew applications#Other applications|Other application]] [[Category:Vita Homebrew other applications]]',
        ['Music Apps']       = {'Vita homebrew applications', 'Music applications on Vita', 'Vita homebrew applications'},
-- Games
        ['Other Apps']       = {'Vita homebrew applications', 'Other applications on Vita', 'Vita homebrew applications'},
['arcade game']       = '[[List of Vita homebrew games#Arcade|Arcade game]] [[Category:Vita Homebrew arcade games]]',
        ['System Tools']     = {'Vita homebrew applications', 'System tools on Vita', 'Vita homebrew applications'},
['board game']         = '[[List of Vita homebrew games#Board|Board game]] [[Category:Vita Homebrew board games]]',
        ['Title Launchers']  = {'Vita homebrew applications', 'Title launchers on Vita', 'Vita homebrew applications'},
['card game']         = '[[List of Vita homebrew games#Card|Card game]] [[Category:Vita Homebrew card games]]',
        ['Utilities']         = {'Vita homebrew applications', 'Utility applications on Vita', 'Vita homebrew applications'},
['game engine']       = '[[List of Vita homebrew games#Game engine|Game engine]] [[Category:Vita Homebrew game engines]]',
        ['Plugins']           = {'Vita homebrew applications', 'Vita plugins', 'Vita homebrew applications'},
['music game']         = '[[List of Vita homebrew games#Music|Music game]] [[Category:Vita Homebrew music games]]',
        -- Games
['platform game']     = '[[List of Vita homebrew games#Platform|Platform game]] [[Category:Vita Homebrew platform games]]',
        ['Action']               = {'Vita homebrew games', 'Action games on Vita', 'Vita homebrew games'},
['puzzle game']       = '[[List of Vita homebrew games#Puzzle|Puzzle game]] [[Category:Vita Homebrew puzzle games]]',
        ['Adventure']            = {'Vita homebrew games', 'Adventure games on Vita', 'Vita homebrew games'},
['racing game']       = '[[List of Vita homebrew games#Racing|Racing game]] [[Category:Vita Homebrew racing games]]',
        ['Arcade Games']        = {'Vita homebrew games', 'Arcade games on Vita', 'Vita homebrew games'},
['role playing game'] = '[[List of Vita homebrew games#Role playing|Role playing game]] [[Category:Vita Homebrew role playing games]]',
        ['Board']               = {'Vita homebrew games', 'Board games on Vita', 'Vita homebrew games'},
['shooting game']     = '[[List of Vita homebrew games#Shooter|Shooting game]] [[Category:Vita Homebrew shooting games]]',
        ['Card']                 = {'Vita homebrew games', 'Card games on Vita', 'Vita homebrew games'},
['simulation game']   = '[[List of Vita homebrew games#Simulation|Simulation game]] [[Category:Vita Homebrew simulation games]]',
        ['Game Engine']         = {'Vita homebrew games', 'Game engines on Vita', 'Vita homebrew games'},
['trivia game']       = '[[List of Vita homebrew games#Trivia|Trivia game]] [[Category:Vita Homebrew trivia games]]',
        ['Music']               = {'Vita homebrew games', 'Music games on Vita', 'Vita homebrew games'},
['other game']         = '[[List of Vita homebrew games#Other games|Other game]] [[Category:Vita Homebrew other games]]',
        ['Other Games']         = {'Vita homebrew games', 'Other games on Vita', 'Vita homebrew games'},
-- Emulators
        ['Platform']             = {'Vita homebrew games', 'Platform games on Vita', 'Vita homebrew games'},
['console emulator']   = '[[List of Vita homebrew emulators#Console|Console emulator]] [[Category:Vita Homebrew console emulators]]',
        ['Puzzle']               = {'Vita homebrew games', 'Puzzle games on Vita', 'Vita homebrew games'},
['handheld emulator'] = '[[List of Vita homebrew emulators#Handheld|Handheld emulator]] [[Category:Vita Homebrew portable emulators]]',
        ['Racing']               = {'Vita homebrew games', 'Racing games on Vita', 'Vita homebrew games'},
['arcade emulator']   = '[[List of Vita homebrew emulators#Arcade|Arcade emulator]] [[Category:Vita Homebrew arcade emulators]]',
        ['Role Playing']         = {'Vita homebrew games', 'Role playing games on Vita', 'Vita homebrew games'},
['computer emulator'] = '[[List of Vita homebrew emulators#Computer|Computer emulator]] [[Category:Vita Homebrew computer emulators]]',
        ['Shooter']             = {'Vita homebrew games', 'Shooter games on Vita', 'Vita homebrew games'},
-- Loaders
        ['Simulation']           = {'Vita homebrew games', 'Simulation games on Vita', 'Vita homebrew games'},
['loader']             = '[[List of Vita homebrew loaders|Loader]] [[Category:Vita Homebrew loaders]]',
        ['Strategy']             = {'Vita homebrew games', 'Strategy games on Vita', 'Vita homebrew games'},
-- Exploits
        ['Trivia']               = {'Vita homebrew games', 'Trivia games on Vita', 'Vita homebrew games'},
['exploit']           = '[[List of Vita homebrew exploits|Exploit]] [[Category:Vita Homebrew exploits]]',
        ['Horror']               = {'Vita homebrew games', 'Horror games on Vita', 'Vita homebrew games'},
-- System Tools
        -- Emulators
['system tool']       = '[[List of Vita system tools|System tool]] [[Category:Vita homebrew system tools]]',
        ['Arcade']               = {'Vita homebrew emulators', 'Arcade emulators on Vita', 'Vita homebrew emulators'},
-- PC Utilities
        ['Computer']             = {'Vita homebrew emulators', 'Computer emulators on Vita', 'Vita homebrew emulators'},
['pc utility']        = '[[List of Vita PC utilities|PC utility]] [[Category:Vita PC utilities]]',
        ['Console']             = {'Vita homebrew emulators', 'Console emulators on Vita', 'Vita homebrew emulators'},
-- Demos
        ['Handheld']             = {'Vita homebrew emulators', 'Handheld emulators on Vita', 'Vita homebrew emulators'},
['demo']               = '[[List of Vita homebrew demos|Demo]] [[Category:Vita homebrew demos]]',
        ['Other Emulators']     = {'Vita homebrew emulators', 'Other emulators on Vita', 'Vita homebrew emulators'},
}
        -- PC (PC Utilities for Vita)
        ['Bubble Makers']       = {'Vita PC utilities', 'Bubble makers for Vita', 'PC utilities for Vita'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        ['Developments']         = {'Vita PC utilities', 'Development utilities for Vita', 'PC utilities for Vita'},
        ['PC Utilities']        = {'Vita PC utilities', 'Other PC utilities for Vita', 'PC utilities for Vita'},
        -- Demos
        ['Demos']               = {'Vita homebrew demos', 'Demo homebrews on Vita', 'Vita homebrew applications'},
        -- ROM Hack
        ['Game Hacks']          = {'Vita Rom Hacks', 'Vita game hacks', 'Vita rom hacks'},
        ['Translations']        = {'Vita Rom Hacks', 'Vita game translations', 'Vita rom hacks'},
        ['Hack Utilities']       = {'Vita Rom Hacks', 'Vita hack utilities', 'Vita 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 131: Line 146:
   
   
if link:find( '://' ) then
if link:find( '://' ) then
return '[' .. link .. ' ' .. label .. ']'
return '[' .. link .. ' ' .. label .. ']'
end
return '[[' .. link .. '|' .. label .. ']]'
end
 
local function getLink2( label, link, altlink, version )
if empty( link ) then return altlink end
if link:find( '://' ) then
return '[' .. link .. ' ' .. label .. ']'
end
end
   
   
Line 139: Line 164:
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:Vita open source homebrew]]' end
   
   
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
return getLink( 'Source', source ) .. '[[Category:Vita 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 188: Line 220:
         header13 = div3(),
         header13 = div3(),
         header20 = div(),
         header20 = div(),
         header21 = div2(),
         header1 = div2(),
-- Links
-- Links
data15  = getLink( 'Download', a.download, a.downloadraw ),
data15  = getLink2( '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

Latest revision as of 14:01, 25 Haziran 2024

Documentation for this module may be created at Module:Infobox Vita 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 (Exploits)
        ['File Browsers']     = {'Vita homebrew applications', 'File browsers on Vita', 'Vita homebrew applications'},
        ['Custom Firmwares']  = {'Vita homebrew applications', 'Custom firmwares on Vita', 'Vita homebrew applications'},
        ['Math']              = {'Vita homebrew applications', 'Maths applications on Vita', 'Vita homebrew applications'},
        ['Media Players']     = {'Vita homebrew applications', 'Media players on Vita', 'Vita homebrew applications'},
        ['Music Apps']        = {'Vita homebrew applications', 'Music applications on Vita', 'Vita homebrew applications'},
        ['Other Apps']        = {'Vita homebrew applications', 'Other applications on Vita', 'Vita homebrew applications'},
        ['System Tools']      = {'Vita homebrew applications', 'System tools on Vita', 'Vita homebrew applications'},
        ['Title Launchers']   = {'Vita homebrew applications', 'Title launchers on Vita', 'Vita homebrew applications'},
        ['Utilities']         = {'Vita homebrew applications', 'Utility applications on Vita', 'Vita homebrew applications'},
        ['Plugins']           = {'Vita homebrew applications', 'Vita plugins', 'Vita homebrew applications'},
        -- Games
        ['Action']               = {'Vita homebrew games', 'Action games on Vita', 'Vita homebrew games'},
        ['Adventure']            = {'Vita homebrew games', 'Adventure games on Vita', 'Vita homebrew games'},
        ['Arcade Games']         = {'Vita homebrew games', 'Arcade games on Vita', 'Vita homebrew games'},
        ['Board']                = {'Vita homebrew games', 'Board games on Vita', 'Vita homebrew games'},		
        ['Card']                 = {'Vita homebrew games', 'Card games on Vita', 'Vita homebrew games'},	
        ['Game Engine']          = {'Vita homebrew games', 'Game engines on Vita', 'Vita homebrew games'},	
        ['Music']                = {'Vita homebrew games', 'Music games on Vita', 'Vita homebrew games'},	
        ['Other Games']          = {'Vita homebrew games', 'Other games on Vita', 'Vita homebrew games'},	
        ['Platform']             = {'Vita homebrew games', 'Platform games on Vita', 'Vita homebrew games'},	
        ['Puzzle']               = {'Vita homebrew games', 'Puzzle games on Vita', 'Vita homebrew games'},	
        ['Racing']               = {'Vita homebrew games', 'Racing games on Vita', 'Vita homebrew games'},	
        ['Role Playing']         = {'Vita homebrew games', 'Role playing games on Vita', 'Vita homebrew games'},	
        ['Shooter']              = {'Vita homebrew games', 'Shooter games on Vita', 'Vita homebrew games'},	
        ['Simulation']           = {'Vita homebrew games', 'Simulation games on Vita', 'Vita homebrew games'},	
        ['Strategy']             = {'Vita homebrew games', 'Strategy games on Vita', 'Vita homebrew games'},	
        ['Trivia']               = {'Vita homebrew games', 'Trivia games on Vita', 'Vita homebrew games'},	
        ['Horror']               = {'Vita homebrew games', 'Horror games on Vita', 'Vita homebrew games'},	
        -- Emulators
        ['Arcade']               = {'Vita homebrew emulators', 'Arcade emulators on Vita', 'Vita homebrew emulators'},
        ['Computer']             = {'Vita homebrew emulators', 'Computer emulators on Vita', 'Vita homebrew emulators'},
        ['Console']              = {'Vita homebrew emulators', 'Console emulators on Vita', 'Vita homebrew emulators'},
        ['Handheld']             = {'Vita homebrew emulators', 'Handheld emulators on Vita', 'Vita homebrew emulators'},
        ['Other Emulators']      = {'Vita homebrew emulators', 'Other emulators on Vita', 'Vita homebrew emulators'},
        -- PC (PC Utilities for Vita)
        ['Bubble Makers']        = {'Vita PC utilities', 'Bubble makers for Vita', 'PC utilities for Vita'},
        ['Developments']         = {'Vita PC utilities', 'Development utilities for Vita', 'PC utilities for Vita'},
        ['PC Utilities']         = {'Vita PC utilities', 'Other PC utilities for Vita', 'PC utilities for Vita'},
        -- Demos
        ['Demos']                = {'Vita homebrew demos', 'Demo homebrews on Vita', 'Vita homebrew applications'},
        -- ROM Hack
        ['Game Hacks']           = {'Vita Rom Hacks', 'Vita game hacks', 'Vita rom hacks'},
        ['Translations']         = {'Vita Rom Hacks', 'Vita game translations', 'Vita rom hacks'},
        ['Hack Utilities']       = {'Vita Rom Hacks', 'Vita hack utilities', 'Vita 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 getLink2( label, link, altlink, version )
	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:Vita open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:Vita 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    = userList( 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   = getLink2( '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: