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

Module:Infobox GBA Homebrews: Difference between revisions

From GameBrew
(Created page with "local p = {} local function empty(param) return not param or param == '' end local function formatUser( user ) return '[[User:' .. user .. (user:find('|') and '' or ('|'...")
 
No edit summary
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
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)
local function empty(param)
Line 23: 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  GBA homebrew applications#Media players|Media player]] [[Category: GBA Homebrew media players]]',
        ['File Browsers']       = {'GBA homebrew applications', 'Utility applications on GBA', 'GBA homebrew applications'},
['utility']           = '[[List of  GBA homebrew applications#Utilities|Utility]] [[Category: GBA Homebrew utilities]]',
        ['Math']                = {'GBA homebrew applications', 'Maths applications on GBA', 'GBA homebrew applications'},
['operating system']   = '[[List of  GBA homebrew applications#Operating systems|Operating system]] [[Category: GBA Homebrew operating systems]]',
        ['Media Players']        = {'GBA homebrew applications', 'Media players on GBA', 'GBA homebrew applications'},
['math']               = '[[List of  GBA homebrew applications#Math|Math application]] [[Category: GBA Homebrew math applications]]',
        ['Music Apps']           = {'GBA homebrew applications', 'Music applications on GBA', 'GBA homebrew applications'},
['other']              = '[[List of  GBA homebrew applications#Other applications|Other application]] [[Category: GBA Homebrew other applications]]',
        ['Other Apps']           = {'GBA homebrew applications', 'Other applications on GBA', 'GBA homebrew applications'},
-- Games
        ['System Tools']         = {'GBA homebrew applications', 'System tools on GBA', 'GBA homebrew applications'},
['arcade game']       = '[[List of  GBA homebrew games#Arcade|Arcade game]] [[Category: GBA Homebrew arcade games]]',
        ['Utilities']           = {'GBA homebrew applications', 'Utility applications on GBA', 'GBA homebrew applications'},
['board game']         = '[[List of  GBA homebrew games#Board|Board game]] [[Category: GBA Homebrew board games]]',
['Plugins']              = {'GBA homebrew applications', 'GBA plugins for PogoShell', 'GBA homebrew applications'},
['card game']         = '[[List of  GBA homebrew games#Card|Card game]] [[Category: GBA Homebrew card games]]',
        -- Games
['game engine']       = '[[List of  GBA homebrew games#Game engine|Game engine]] [[Category: GBA Homebrew game engines]]',
        ['Action']               = {'GBA homebrew games', 'Action games on GBA', 'GBA homebrew games'},
['music game']         = '[[List of  GBA homebrew games#Music|Music game]] [[Category: GBA Homebrew music games]]',
        ['Adventure']            = {'GBA homebrew games', 'Adventure games on GBA', 'GBA homebrew games'},
['platform game']     = '[[List of  GBA homebrew games#Platform|Platform game]] [[Category: GBA Homebrew platform games]]',
        ['Arcade Games']        = {'GBA homebrew games', 'Arcade games on GBA', 'GBA homebrew games'},
['puzzle game']       = '[[List of  GBA homebrew games#Puzzle|Puzzle game]] [[Category: GBA Homebrew puzzle games]]',
        ['Board']               = {'GBA homebrew games', 'Board games on GBA', 'GBA homebrew games'},
['racing game']       = '[[List of  GBA homebrew games#Racing|Racing game]] [[Category: GBA Homebrew racing games]]',
        ['Card']                 = {'GBA homebrew games', 'Card games on GBA', 'GBA homebrew games'},
['role playing game'] = '[[List of  GBA homebrew games#Role playing|Role playing game]] [[Category: GBA Homebrew role playing games]]',
        ['Game Engine']         = {'GBA homebrew games', 'Game engines on GBA', 'GBA homebrew games'},
['shooting game']     = '[[List of  GBA homebrew games#Shooter|Shooting game]] [[Category: GBA Homebrew shooting games]]',
        ['Music']               = {'GBA homebrew games', 'Music games on GBA', 'GBA homebrew games'},
['simulation game']   = '[[List of  GBA homebrew games#Simulation|Simulation game]] [[Category: GBA Homebrew simulation games]]',
        ['Other Games']         = {'GBA homebrew games', 'Other games on GBA', 'GBA homebrew games'},
['trivia game']       = '[[List of  GBA homebrew games#Trivia|Trivia game]] [[Category: GBA Homebrew trivia games]]',
        ['Platform']             = {'GBA homebrew games', 'Platform games on GBA', 'GBA homebrew games'},
['other game']         = '[[List of  GBA homebrew games#Other games|Other game]] [[Category: GBA Homebrew other games]]',
        ['Puzzle']               = {'GBA homebrew games', 'Puzzle games on GBA', 'GBA homebrew games'},
-- Emulators
        ['Racing']               = {'GBA homebrew games', 'Racing games on GBA', 'GBA homebrew games'},
['console emulator']   = '[[List of  GBA homebrew emulators#Console|Console emulator]] [[Category: GBA Homebrew console emulators]]',
        ['Role Playing']         = {'GBA homebrew games', 'Role playing games on GBA', 'GBA homebrew games'},
['handheld emulator'] = '[[List of  GBA homebrew emulators#Handheld|Handheld emulator]] [[Category: GBA Homebrew portable emulators]]',
        ['Shooter']             = {'GBA homebrew games', 'Shooter games on GBA', 'GBA homebrew games'},
['arcade emulator']   = '[[List of  GBA homebrew emulators#Arcade|Arcade emulator]] [[Category: GBA Homebrew arcade emulators]]',
        ['Simulation']           = {'GBA homebrew games', 'Simulation games on GBA', 'GBA homebrew games'},
['computer emulator'] = '[[List of  GBA homebrew emulators#Computer|Computer emulator]] [[Category: GBA Homebrew computer emulators]]',
        ['Strategy']             = {'GBA homebrew games', 'Strategy games on GBA', 'GBA homebrew games'},
-- Loaders
        ['Trivia']               = {'GBA homebrew games', 'Trivia games on GBA', 'GBA homebrew games'},
['loader']             = '[[List of  GBA homebrew loaders|Loader]] [[Category: GBA Homebrew loaders]]',
        -- Emulators
-- Exploits
        ['Arcade']               = {'GBA homebrew emulators', 'Arcade emulators on GBA', 'GBA homebrew emulators'},
['exploit']           = '[[List of  GBA homebrew exploits|Exploit]] [[Category: GBA Homebrew exploits]]',
        ['Computer']             = {'GBA homebrew emulators', 'Computer emulators on GBA', 'GBA homebrew emulators'},
-- System Tools
        ['Console']             = {'GBA homebrew emulators', 'Console emulators on GBA', 'GBA homebrew emulators'},
['system tool']       = '[[List of  GBA system tools|System tool]] [[Category: GBA homebrew system tools]]',
        ['Handheld']             = {'GBA homebrew emulators', 'Handheld emulators on GBA', 'GBA homebrew emulators'},
-- PC Utilities
        ['Other Emulators']     = {'GBA homebrew emulators', 'Other emulators on GBA', 'GBA homebrew emulators'},
['pc utility']        = '[[List of  GBA PC utilities|PC utility]] [[Category: GBA PC utilities]]',
        -- PC (PC Utilities for GBA)
-- Demos
        ['Builder Tools']         = {'GBA PC utilities', 'Rom builders for GBA', 'PC utilities for GBA'},
['demo']               = '[[List of GBA homebrew demos|Demo]] [[Category: GBA homebrew demos]]',
        ['Development']           = {'GBA PC utilities', 'Development utilities for GBA', 'PC utilities for GBA'},
}
        ['File Operation']        = {'GBA PC utilities', 'File management utilities for GBA', 'PC utilities for GBA'},
        ['Other PC Utilities']    = {'GBA PC utilities', 'Other PC utilities for GBA', 'PC utilities for GBA'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        -- Demos
        ['Demos']               = {'GBA homebrew demos', 'Demo homebrews on GBA', 'GBA homebrew applications'},
        -- ROM Hack
        ['Game Hacks']          = {'all GBA Rom Hacks', 'GBA game hacks', 'GBA rom hacks'},
        ['Translations']        = {'all GBA Rom Hacks', 'GBA game translations', 'GBA rom hacks'},
        ['Hack Utilities']       = {'all GBA Rom Hacks', 'GBA hack utilities', 'GBA 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 110: Line 144:
   
   
if link:find( '://' ) then
if link:find( '://' ) then
return '[' .. link .. ' ' .. label .. ']'
return '[' .. link .. ' ' .. label .. ']'
end
end
   
   
Line 118: Line 152:
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:GBA open source homebrew]]' end
   
   
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
return getLink( 'Source', source ) .. '[[Category:GBA 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 146: Line 187:
imagesize    = a.imagesize or '48px',
imagesize    = a.imagesize or '48px',
imagecaption = a.imagecaption,
imagecaption = a.imagecaption,
header1 = 'General',
header2 = 'General',
label2   = 'Author',
label3   = 'Author',
data2   = a.author,
data3   = a.author,
label3  = 'Last Updated',
data3    = a.lastupdated,
label4  = 'Contributor',
label4  = 'Contributor',
data4    = userList( a.contributor ),
data4    = userList( a.contributor ),
Line 165: Line 204:
label10  = 'Format',
label10  = 'Format',
data10  = getFormats( a ),
data10  = getFormats( a ),
label11  = 'Last Updated',
data11    = a.lastupdated,
        header13 = div3(),
        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( 'Discussion', 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 177: Line 221:
   
   
if a.cia == 'yes' then
if a.cia == 'yes' then
ibData.header11 = 'CIA information'
ibData.header111 = 'CIA information'
ibData.label12 = 'Title ID'
ibData.label112 = 'Title ID'
ibData.data12   = a.titleID or 'Unknown[[Category:3 GBA Homebrew missing CIA titleID]]'
ibData.data112   = a.titleID or 'Unknown[[Category:3 GBA Homebrew missing CIA titleID]]'
ibData.label13 = 'Unique ID'
ibData.label113 = 'Unique ID'
ibData.data13   = a.uniqueID or 'Unknown[[Category:3 GBA Homebrew missing CIA uniqueID]]'
ibData.data113   = a.uniqueID or 'Unknown[[Category:3 GBA Homebrew missing CIA uniqueID]]'
end
end
   
   

Latest revision as of 03:04, 25 October 2024

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

Advertising: