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 DS 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
 
(20 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)
return not param or param == ''
return not param or 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 DS homebrew applications#Media players|Media player]] [[Category:DS Homebrew media players]]',
        ['Math']                 = {'DS homebrew applications', 'Maths applications on DS', 'DS homebrew applications'},
['utility']           = '[[List of DS homebrew applications#Utilities|Utility]] [[Category:DS Homebrew utilities]]',
        ['Media Players']        = {'DS homebrew applications', 'Media players on DS', 'DS homebrew applications'},
['operating system']   = '[[List of DS homebrew applications#Operating systems|Operating system]] [[Category:DS Homebrew operating systems]]',
        ['Music Apps']           = {'DS homebrew applications', 'Music applications on DS', 'DS homebrew applications'},
['math']               = '[[List of DS homebrew applications#Math|Math application]] [[Category:DS Homebrew math applications]]',
        ['Operating Systems']   = {'DS homebrew applications', 'Operating systems on DS', 'DS homebrew applications'},
['other']             = '[[List of DS homebrew applications#Other applications|Other application]] [[Category:DS Homebrew other applications]]',
        ['Other Apps']           = {'DS homebrew applications', 'Other applications on DS', 'DS homebrew applications'},
-- Games
        ['System Tools']         = {'DS homebrew applications', 'System tools on DS', 'DS homebrew applications'},
['arcade game']       = '[[List of DS homebrew games#Arcade|Arcade game]] [[Category:DS Homebrew arcade games]]',
        ['File Browsers']        = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
['board game']         = '[[List of DS homebrew games#Board|Board game]] [[Category:DS Homebrew board games]]',
        ['Utilities']            = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
['card game']         = '[[List of DS homebrew games#Card|Card game]] [[Category:DS Homebrew card games]]',
        ['File Browsers']       = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
['game engine']       = '[[List of DS homebrew games#Game engine|Game engine]] [[Category:DS Homebrew game engines]]',
        ['Savegame Tools']       = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
['music game']         = '[[List of DS homebrew games#Music|Music game]] [[Category:DS Homebrew music games]]',
        -- Games
['platform game']     = '[[List of DS homebrew games#Platform|Platform game]] [[Category:DS Homebrew platform games]]',
        ['Action']               = {'DS homebrew games', 'Action games on DS', 'DS homebrew games'},
['puzzle game']       = '[[List of DS homebrew games#Puzzle|Puzzle game]] [[Category:DS Homebrew puzzle games]]',
        ['Adventure']            = {'DS homebrew games', 'Adventure games on DS', 'DS homebrew games'},
['racing game']       = '[[List of DS homebrew games#Racing|Racing game]] [[Category:DS Homebrew racing games]]',
        ['Arcade Games']        = {'DS homebrew games', 'Arcade games on DS', 'DS homebrew games'},
['role playing game'] = '[[List of DS homebrew games#Role playing|Role playing game]] [[Category:DS Homebrew role playing games]]',
        ['Board']               = {'DS homebrew games', 'Board games on DS', 'DS homebrew games'},
['shooting game']     = '[[List of DS homebrew games#Shooter|Shooting game]] [[Category:DS Homebrew shooting games]]',
        ['Card']                 = {'DS homebrew games', 'Card games on DS', 'DS homebrew games'},
['simulation game']   = '[[List of DS homebrew games#Simulation|Simulation game]] [[Category:DS Homebrew simulation games]]',
        ['Game Engine']         = {'DS homebrew games', 'Game engines on DS', 'DS homebrew games'},
['trivia game']       = '[[List of DS homebrew games#Trivia|Trivia game]] [[Category:DS Homebrew trivia games]]',
        ['Music']               = {'DS homebrew games', 'Music games on DS', 'DS homebrew games'},
['other game']         = '[[List of DS homebrew games#Other games|Other game]] [[Category:DS Homebrew other games]]',
        ['Other Games']         = {'DS homebrew games', 'Other games on DS', 'DS homebrew games'},
-- Emulators
        ['Platform']             = {'DS homebrew games', 'Platform games on DS', 'DS homebrew games'},
['console emulator']   = '[[List of DS homebrew emulators#Console|Console emulator]] [[Category:DS Homebrew console emulators]]',
        ['Puzzle']               = {'DS homebrew games', 'Puzzle games on DS', 'DS homebrew games'},
['handheld emulator'] = '[[List of DS homebrew emulators#Handheld|Handheld emulator]] [[Category:DS Homebrew portable emulators]]',
        ['Racing']               = {'DS homebrew games', 'Racing games on DS', 'DS homebrew games'},
['arcade emulator']   = '[[List of DS homebrew emulators#Arcade|Arcade emulator]] [[Category:DS Homebrew arcade emulators]]',
        ['Role Playing']         = {'DS homebrew games', 'Role playing games on DS', 'DS homebrew games'},
['computer emulator'] = '[[List of DS homebrew emulators#Computer|Computer emulator]] [[Category:DS Homebrew computer emulators]]',
        ['Shooter']             = {'DS homebrew games', 'Shooter games on DS', 'DS homebrew games'},
-- Loaders
        ['Simulation']           = {'DS homebrew games', 'Simulation games on DS', 'DS homebrew games'},
['loader']             = '[[List of DS homebrew loaders|Loader]] [[Category:DS Homebrew loaders]]',
        ['Strategy']             = {'DS homebrew games', 'Strategy games on DS', 'DS homebrew games'},
-- Exploits
        ['Trivia']               = {'DS homebrew games', 'Trivia games on DS', 'DS homebrew games'},
['exploit']            = '[[List of DS homebrew exploits|Exploit]] [[Category:DS Homebrew exploits]]',
        -- Emulators
-- System Tools
        ['Arcade']               = {'DS homebrew emulators', 'Arcade emulators on DS', 'DS homebrew emulators'},
['system tool']        = '[[List of DS system tools|System tool]] [[Category:DS homebrew system tools]]',
        ['Computer']            = {'DS homebrew emulators', 'Computer emulators on DS', 'DS homebrew emulators'},
-- PC Utilities
        ['Console']             = {'DS homebrew emulators', 'Console emulators on DS', 'DS homebrew emulators'},
['pc utility']         = '[[List of DS PC utilities|PC utility]] [[Category:DS PC utilities]]',
        ['Handheld']             = {'DS homebrew emulators', 'Handheld emulators on DS', 'DS homebrew emulators'},
-- Demos
        ['Other Emulators']     = {'DS homebrew emulators', 'Other emulators on DS', 'DS homebrew emulators'},
['demo']               = '[[List of DS homebrew demos|Demo]] [[Category:DS homebrew demos]]',
-- Homebrew Loaders
}
        ['HB Launchers']         = {'DS homebrew loaders', 'Homebrew loaders on DS', 'DS homebrew applications'},
        ['Kernels']              = {'DS homebrew loaders', 'Homebrew loaders on DS', 'DS homebrew applications'},
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
        ['Title Launchers']     = {'DS homebrew loaders', 'Homebrew loaders on DS', 'DS homebrew applications'},
        -- PC (PC Utilities for DS)
        ['Development']            = {'DS PC utilities', 'Development utilities for DS', 'PC utilities for DS'},
        ['File Operation']        = {'DS PC utilities', 'File management utilities for DS', 'PC utilities for DS'},
        ['ROM Patchers']          = {'DS PC utilities', 'ROM patchers', 'PC utilities for DS'},
        ['ROM Managers']           = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['Save Management']        = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['Other PC Utilities']    = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['PC Utilities']          = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['Network']               = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        -- Demos
        ['Demos']               = {'DS homebrew demos', 'Demo homebrews on DS', 'DS homebrew applications'},
        -- ROM Hack
        ['Game Hacks']           = {'all DS Rom Hacks', 'DS game hacks', 'DS homebrew rom hacks'},
        ['Translations']         = {'all DS Rom Hacks', 'DS game translations', 'DS homebrew rom hacks'},
        ['Hack Utilities']      = {'all DS Rom Hacks', 'DS hack utilities', 'DS homebrew rom hacks'},
        ['Save Editors']        = {'all DS Rom Hacks', 'DS hack utilities', 'DS 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
end
   
   
Line 118: Line 163:
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:DS open source homebrew]]' end
   
   
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
return getLink( 'Source', source ) .. '[[Category:DS 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 198:
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   = userList( 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 215:
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 232:
   
   
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: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 05:02, 24 August 2024

Documentation for this module may be created at Module:Infobox DS 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']                 = {'DS homebrew applications', 'Maths applications on DS', 'DS homebrew applications'},
        ['Media Players']        = {'DS homebrew applications', 'Media players on DS', 'DS homebrew applications'},
        ['Music Apps']           = {'DS homebrew applications', 'Music applications on DS', 'DS homebrew applications'},
        ['Operating Systems']    = {'DS homebrew applications', 'Operating systems on DS', 'DS homebrew applications'},
        ['Other Apps']           = {'DS homebrew applications', 'Other applications on DS', 'DS homebrew applications'},
        ['System Tools']         = {'DS homebrew applications', 'System tools on DS', 'DS homebrew applications'},
        ['File Browsers']        = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
        ['Utilities']            = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
        ['File Browsers']        = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
        ['Savegame Tools']       = {'DS homebrew applications', 'Utility applications on DS', 'DS homebrew applications'},
        -- Games
        ['Action']               = {'DS homebrew games', 'Action games on DS', 'DS homebrew games'},
        ['Adventure']            = {'DS homebrew games', 'Adventure games on DS', 'DS homebrew games'},
        ['Arcade Games']         = {'DS homebrew games', 'Arcade games on DS', 'DS homebrew games'},
        ['Board']                = {'DS homebrew games', 'Board games on DS', 'DS homebrew games'},		
        ['Card']                 = {'DS homebrew games', 'Card games on DS', 'DS homebrew games'},	
        ['Game Engine']          = {'DS homebrew games', 'Game engines on DS', 'DS homebrew games'},	
        ['Music']                = {'DS homebrew games', 'Music games on DS', 'DS homebrew games'},	
        ['Other Games']          = {'DS homebrew games', 'Other games on DS', 'DS homebrew games'},	
        ['Platform']             = {'DS homebrew games', 'Platform games on DS', 'DS homebrew games'},	
        ['Puzzle']               = {'DS homebrew games', 'Puzzle games on DS', 'DS homebrew games'},	
        ['Racing']               = {'DS homebrew games', 'Racing games on DS', 'DS homebrew games'},	
        ['Role Playing']         = {'DS homebrew games', 'Role playing games on DS', 'DS homebrew games'},	
        ['Shooter']              = {'DS homebrew games', 'Shooter games on DS', 'DS homebrew games'},	
        ['Simulation']           = {'DS homebrew games', 'Simulation games on DS', 'DS homebrew games'},	
        ['Strategy']             = {'DS homebrew games', 'Strategy games on DS', 'DS homebrew games'},	
        ['Trivia']               = {'DS homebrew games', 'Trivia games on DS', 'DS homebrew games'},	
        -- Emulators
        ['Arcade']               = {'DS homebrew emulators', 'Arcade emulators on DS', 'DS homebrew emulators'},
        ['Computer']             = {'DS homebrew emulators', 'Computer emulators on DS', 'DS homebrew emulators'},
        ['Console']              = {'DS homebrew emulators', 'Console emulators on DS', 'DS homebrew emulators'},
        ['Handheld']             = {'DS homebrew emulators', 'Handheld emulators on DS', 'DS homebrew emulators'},
        ['Other Emulators']      = {'DS homebrew emulators', 'Other emulators on DS', 'DS homebrew emulators'},
		-- Homebrew Loaders
        ['HB Launchers']         = {'DS homebrew loaders', 'Homebrew loaders on DS', 'DS homebrew applications'},
        ['Kernels']              = {'DS homebrew loaders', 'Homebrew loaders on DS', 'DS homebrew applications'},
        ['Title Launchers']      = {'DS homebrew loaders', 'Homebrew loaders on DS', 'DS homebrew applications'},
        -- PC (PC Utilities for DS)
        ['Development']            = {'DS PC utilities', 'Development utilities for DS', 'PC utilities for DS'},
        ['File Operation']         = {'DS PC utilities', 'File management utilities for DS', 'PC utilities for DS'},
        ['ROM Patchers']           = {'DS PC utilities', 'ROM patchers', 'PC utilities for DS'},
        ['ROM Managers']           = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['Save Management']        = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['Other PC Utilities']     = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['PC Utilities']           = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        ['Network']                = {'DS PC utilities', 'Other PC utilities for DS', 'PC utilities for DS'},
        -- Demos
        ['Demos']                = {'DS homebrew demos', 'Demo homebrews on DS', 'DS homebrew applications'},
        -- ROM Hack
        ['Game Hacks']           = {'all DS Rom Hacks', 'DS game hacks', 'DS homebrew rom hacks'},
        ['Translations']         = {'all DS Rom Hacks', 'DS game translations', 'DS homebrew rom hacks'},
        ['Hack Utilities']       = {'all DS Rom Hacks', 'DS hack utilities', 'DS homebrew rom hacks'},
        ['Save Editors']         = {'all DS Rom Hacks', 'DS hack utilities', 'DS 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 = { '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:DS open source homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:DS 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    = 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: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: