Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
The main server is currently down. We are running on a backup server, so editing and search functionality are temporarily disabled. Please check back in a few hours.

Module:Infobox GB Homebrews: Difference between revisions

From GameBrew
No edit summary
Tag: Reverted
No edit summary
 
(8 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
['media player']       = '[[List of GB homebrew applications#Media players|Media player]] [[Category:GB Homebrew media players]]',
        ['Math']                 = {'GB homebrew applications', 'Maths applications on GB', 'GB homebrew applications'},
['utility']           = '[[List of GB homebrew applications#Utilities|Utility]] [[Category:GB Homebrew utilities]]',
        ['Music Apps']          = {'GB homebrew applications', 'Music applications on GB', 'GB homebrew applications'},
['operating system']   = '[[List of GB homebrew applications#Operating systems|Operating system]] [[Category:GB Homebrew operating systems]]',
        ['Music Disks']         = {'GB homebrew applications', 'Music disks on GB', 'GB homebrew applications'},
['math']               = '[[List of GB homebrew applications#Math|Math application]] [[Category:GB Homebrew math applications]]',
        ['Other Apps']           = {'GB homebrew applications', 'Other applications on GB', 'GB homebrew applications'},
['other']             = '[[List of GB homebrew applications#Other applications|Other application]] [[Category:GB Homebrew other applications]]',
        ['Test Roms']           = {'GB homebrew applications', 'Test roms on GB', 'GB homebrew applications'},
-- Games
        ['Utilities']           = {'GB homebrew applications', 'Utility applications on GB', 'GB homebrew applications'},
['arcade game']       = '[[List of GB homebrew games#Arcade|Arcade game]] [[Category:GB Homebrew arcade games]]',
        -- Games
['board game']         = '[[List of GB homebrew games#Board|Board game]] [[Category:GB Homebrew board games]]',
        ['Action']               = {'GB homebrew games', 'Action games on GB', 'GB homebrew games'},
['card game']         = '[[List of GB homebrew games#Card|Card game]] [[Category:GB Homebrew card games]]',
        ['Adventure']            = {'GB homebrew games', 'Adventure games on GB', 'GB homebrew games'},
['game engine']       = '[[List of GB homebrew games#Game engine|Game engine]] [[Category:GB Homebrew game engines]]',
        ['Arcade Games']        = {'GB homebrew games', 'Arcade games on GB', 'GB homebrew games'},
['music game']         = '[[List of GB homebrew games#Music|Music game]] [[Category:GB Homebrew music games]]',
        ['Board']               = {'GB homebrew games', 'Board games on GB', 'GB homebrew games'},
['platform game']     = '[[List of GB homebrew games#Platform|Platform game]] [[Category:GB Homebrew platform games]]',
        ['Card']                 = {'GB homebrew games', 'Card games on GB', 'GB homebrew games'},
['Puzzle']       = 'Puzzle [[Category:GB homebrew puzzle games]]',
        ['Music']               = {'GB homebrew games', 'Music games on GB', 'GB homebrew games'},
['racing game']       = '[[List of GB homebrew games#Racing|Racing game]] [[Category:GB Homebrew racing games]]',
        ['Other Games']         = {'GB homebrew games', 'Other games on GB', 'GB homebrew games'},
['role playing game'] = '[[List of GB homebrew games#Role playing|Role playing game]] [[Category:GB Homebrew role playing games]]',
        ['Platform']             = {'GB homebrew games', 'Platform games on GB', 'GB homebrew games'},
['shooting game']     = '[[List of GB homebrew games#Shooter|Shooting game]] [[Category:GB Homebrew shooting games]]',
        ['Puzzle']               = {'GB homebrew games', 'Puzzle games on GB', 'GB homebrew games'},
['simulation game']   = '[[List of GB homebrew games#Simulation|Simulation game]] [[Category:GB Homebrew simulation games]]',
        ['Racing']               = {'GB homebrew games', 'Racing games on GB', 'GB homebrew games'},
['trivia game']       = '[[List of GB homebrew games#Trivia|Trivia game]] [[Category:GB Homebrew trivia games]]',
        ['Role Playing']         = {'GB homebrew games', 'Role playing games on GB', 'GB homebrew games'},
['other game']         = '[[List of GB homebrew games#Other games|Other game]] [[Category:GB Homebrew other games]]',
        ['Shooter']             = {'GB homebrew games', 'Shooter games on GB', 'GB homebrew games'},
-- Emulators
        ['Simulation']           = {'GB homebrew games', 'Simulation games on GB', 'GB homebrew games'},
['console emulator']   = '[[List of GB homebrew emulators#Console|Console emulator]] [[Category:GB Homebrew console emulators]]',
        ['Strategy']             = {'GB homebrew games', 'Strategy games on GB', 'GB homebrew games'},
['handheld emulator'] = '[[List of GB homebrew emulators#Handheld|Handheld emulator]] [[Category:GB Homebrew portable emulators]]',
        ['Trivia']               = {'GB homebrew games', 'Trivia games on GB', 'GB homebrew games'},
['arcade emulator']   = '[[List of GB homebrew emulators#Arcade|Arcade emulator]] [[Category:GB Homebrew arcade emulators]]',
        -- Emulators
['computer emulator'] = '[[List of GB homebrew emulators#Computer|Computer emulator]] [[Category:GB Homebrew computer emulators]]',
        ['Computer']             = {'GB homebrew emulators', 'Computer emulators on GB', 'GB homebrew emulators'},
-- Loaders
        ['Console']             = {'GB homebrew emulators', 'Console emulators on GB', 'GB homebrew emulators'},
['loader']             = '[[List of GB homebrew loaders|Loader]] [[Category:GB Homebrew loaders]]',
        ['Other Emulators']     = {'GB homebrew emulators', 'Other emulators on GB', 'GB homebrew emulators'},
-- Exploits
        -- PC (PC Utilities for GB)
['exploit']           = '[[List of GB homebrew exploits|Exploit]] [[Category:GB Homebrew exploits]]',
        ['Development']           = {'GB PC utilities', 'Development utilities for GB', 'PC utilities for GB'},
-- System Tools
        ['PC Utilities']         = {'GB PC utilities', 'Other PC utilities for GB', 'PC utilities for GB'},
['system tool']       = '[[List of GB system tools|System tool]] [[Category:GB homebrew system tools]]',
        -- Demos
-- PC Utilities
        ['Demos']               = {'GB homebrew demos', 'Demo applications on GB', 'GB homebrew demos'},
['pc utility']        = '[[List of GB PC utilities|PC utility]] [[Category:GB PC utilities]]',
        ['Game Demos']          = {'GB homebrew demos', 'Demo games on GB', 'GB homebrew demos'},
-- Demos
        ['Samples']             = {'GB homebrew demos', 'Code samples for GB', 'GB homebrew demos'},
['demo']               = '[[List of GB homebrew demos|Demo]] [[Category:GB homebrew demos]]',
        -- ROM Hack
}
        ['Game Hacks']           = {'all GB Rom Hacks', 'GB game hacks', 'GB rom hacks'},
        ['Translations']        = {'all GB Rom Hacks', 'GB game translations', 'GB rom hacks'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        ['Hack Utilities']      = {'all GB Rom Hacks', 'GB hack utilities', 'GB 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 178: Line 186:
data3    = a.author,
data3    = a.author,
label4  = 'Contributor',
label4  = 'Contributor',
data4    = userList( a.contributor ),
data4    = '',
label5  = 'Ported by',
label5  = 'Ported by',
data5    = '',
data5    = '',

Latest revision as of 08:16, 22 June 2024

Documentation for this module may be created at Module:Infobox GB 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
        ['Math']                 = {'GB homebrew applications', 'Maths applications on GB', 'GB homebrew applications'},
        ['Music Apps']           = {'GB homebrew applications', 'Music applications on GB', 'GB homebrew applications'},
        ['Music Disks']          = {'GB homebrew applications', 'Music disks on GB', 'GB homebrew applications'},
        ['Other Apps']           = {'GB homebrew applications', 'Other applications on GB', 'GB homebrew applications'},
        ['Test Roms']            = {'GB homebrew applications', 'Test roms on GB', 'GB homebrew applications'},
        ['Utilities']            = {'GB homebrew applications', 'Utility applications on GB', 'GB homebrew applications'},
        -- Games
        ['Action']               = {'GB homebrew games', 'Action games on GB', 'GB homebrew games'},
        ['Adventure']            = {'GB homebrew games', 'Adventure games on GB', 'GB homebrew games'},
        ['Arcade Games']         = {'GB homebrew games', 'Arcade games on GB', 'GB homebrew games'},
        ['Board']                = {'GB homebrew games', 'Board games on GB', 'GB homebrew games'},		
        ['Card']                 = {'GB homebrew games', 'Card games on GB', 'GB homebrew games'},	
        ['Music']                = {'GB homebrew games', 'Music games on GB', 'GB homebrew games'},	
        ['Other Games']          = {'GB homebrew games', 'Other games on GB', 'GB homebrew games'},	
        ['Platform']             = {'GB homebrew games', 'Platform games on GB', 'GB homebrew games'},	
        ['Puzzle']               = {'GB homebrew games', 'Puzzle games on GB', 'GB homebrew games'},	
        ['Racing']               = {'GB homebrew games', 'Racing games on GB', 'GB homebrew games'},	
        ['Role Playing']         = {'GB homebrew games', 'Role playing games on GB', 'GB homebrew games'},	
        ['Shooter']              = {'GB homebrew games', 'Shooter games on GB', 'GB homebrew games'},	
        ['Simulation']           = {'GB homebrew games', 'Simulation games on GB', 'GB homebrew games'},	
        ['Strategy']             = {'GB homebrew games', 'Strategy games on GB', 'GB homebrew games'},	
        ['Trivia']               = {'GB homebrew games', 'Trivia games on GB', 'GB homebrew games'},	
        -- Emulators
        ['Computer']             = {'GB homebrew emulators', 'Computer emulators on GB', 'GB homebrew emulators'},
        ['Console']              = {'GB homebrew emulators', 'Console emulators on GB', 'GB homebrew emulators'},
        ['Other Emulators']      = {'GB homebrew emulators', 'Other emulators on GB', 'GB homebrew emulators'},
        -- PC (PC Utilities for GB)
        ['Development']           = {'GB PC utilities', 'Development utilities for GB', 'PC utilities for GB'},
        ['PC Utilities']          = {'GB PC utilities', 'Other PC utilities for GB', 'PC utilities for GB'},
        -- Demos
        ['Demos']               = {'GB homebrew demos', 'Demo applications on GB', 'GB homebrew demos'},
        ['Game Demos']          = {'GB homebrew demos', 'Demo games on GB', 'GB homebrew demos'},
        ['Samples']             = {'GB homebrew demos', 'Code samples for GB', 'GB homebrew demos'},
        -- ROM Hack
        ['Game Hacks']           = {'all GB Rom Hacks', 'GB game hacks', 'GB rom hacks'},
        ['Translations']         = {'all GB Rom Hacks', 'GB game translations', 'GB rom hacks'},
        ['Hack Utilities']       = {'all GB Rom Hacks', 'GB hack utilities', 'GB 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:GB open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:GB 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    = a.author,
		label4   = 'Contributor',
		data4    = '',
		label5   = 'Ported by',
		data5    = '',
		label6   = 'Type',
		data6    = getType( a['type'] ),
		label7   = 'Version',
		data7    = a.version,
		label8   = 'License',
		data8    = getLicense( a.license ),
		label9   = 'Language',
		data9    = a.language,
		label10  = 'System',
		data10   = a.format,
		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: