Module:Infobox XBOX 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 ('|'...")
 
(adding them back..)
 
(95 intermediate revisions by 2 users 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 XBOX homebrew applications#Media players|Media player]] [[Category:XBOX Homebrew media players]]',
        ['Media players'] = {'Applications', 'XBOX Homebrew Media players', 'Xbox Homebrew Applications'},
['utility']           = '[[List of XBOX homebrew applications#Utilities|Utility]] [[Category:XBOX Homebrew utilities]]',
        ['File Browsers'] = {'Applications', 'Utility Homebrews on Xbox', 'Xbox Homebrew Applications'},
['operating system']   = '[[List of XBOX homebrew applications#Operating systems|Operating system]] [[Category:XBOX Homebrew operating systems]]',
        -- Games
['math']               = '[[List of XBOX homebrew applications#Math|Math application]] [[Category:XBOX Homebrew math applications]]',
        ['Action'] = {'homebrew games', 'Action Games on Xbox', 'Xbox Homebrew Games'},
['other']              = '[[List of XBOX homebrew applications#Other applications|Other application]] [[Category:XBOX Homebrew other applications]]',
        ['Adventure'] = {'homebrew games', 'Adventure Games on Xbox', 'Xbox Homebrew Games'},
-- Games
        ['Arcade Games'] = {'homebrew games', 'Arcade Games on Xbox', 'Xbox Homebrew Games'},
['arcade game']       = '[[List of XBOX homebrew games#Arcade|Arcade game]] [[Category:XBOX Homebrew arcade games]]',
        ['Board'] = {'homebrew games', 'Board Games on Xbox', 'Xbox Homebrew Games'},
['board game']         = '[[List of XBOX homebrew games#Board|Board game]] [[Category:XBOX Homebrew board games]]',
        ['Card'] = {'homebrew games', 'Card Games on Xbox', 'Xbox Homebrew Games'},
['card game']         = '[[List of XBOX homebrew games#Card|Card game]] [[Category:XBOX Homebrew card games]]',
        ['Game Engine'] = {'homebrew games', 'Game Engine on Xbox', 'Xbox Homebrew Games'},
['game engine']       = '[[List of XBOX homebrew games#Game engine|Game engine]] [[Category:XBOX Homebrew game engines]]',
        ['Music'] = {'homebrew games', 'Music Games on Xbox', 'Xbox Homebrew Games'},
['music game']         = '[[List of XBOX homebrew games#Music|Music game]] [[Category:XBOX Homebrew music games]]',
        ['Platform'] = {'homebrew games', 'Platform Games on Xbox', 'Xbox Homebrew Games'},
['platform game']     = '[[List of XBOX homebrew games#Platform|Platform game]] [[Category:XBOX Homebrew platform games]]',
        ['Puzzle'] = {'homebrew games', 'Puzzle Games on Xbox', 'Xbox Homebrew Games'},
['puzzle game']       = '[[List of XBOX homebrew games#Puzzle|Puzzle game]] [[Category:XBOX Homebrew puzzle games]]',
        ['Racing'] = {'homebrew games', 'Racing Games on Xbox', 'Xbox Homebrew Games'},
['racing game']       = '[[List of XBOX homebrew games#Racing|Racing game]] [[Category:XBOX Homebrew racing games]]',
        ['Role Playing'] = {'homebrew games', 'Role Playing Games on Xbox', 'Xbox Homebrew Games'},
['role playing game'] = '[[List of XBOX homebrew games#Role playing|Role playing game]] [[Category:XBOX Homebrew role playing games]]',
        ['Shooter'] = {'homebrew games', 'Shooter Games on Xbox', 'Xbox Homebrew Games'},
['shooting game']     = '[[List of XBOX homebrew games#Shooter|Shooting game]] [[Category:XBOX Homebrew shooting games]]',
        ['Simulation'] = {'homebrew games', 'Simulation Games on Xbox', 'Xbox Homebrew Games'},
['simulation game']   = '[[List of XBOX homebrew games#Simulation|Simulation game]] [[Category:XBOX Homebrew simulation games]]',
        ['Strategy'] = {'homebrew games', 'Strategy Games on Xbox', 'Xbox Homebrew Games'},
['trivia game']       = '[[List of XBOX homebrew games#Trivia|Trivia game]] [[Category:XBOX Homebrew trivia games]]',
        ['Trivia'] = {'homebrew games', 'Trivia Games on Xbox', 'Xbox Homebrew Games'},
['other game']         = '[[List of XBOX homebrew games#Other games|Other game]] [[Category:XBOX Homebrew other games]]',
        ['Other Games'] = {'homebrew games', 'Other Games on Xbox', 'Xbox Homebrew Games'},
-- Emulators
        -- Emulators
['console emulator']   = '[[List of XBOX homebrew emulators#Console|Console emulator]] [[Category:XBOX Homebrew console emulators]]',
        ['Console'] = {'homebrew emulators', 'Console Emulators on Xbox', 'Xbox Homebrew Emulators'},
['handheld emulator'] = '[[List of XBOX homebrew emulators#Handheld|Handheld emulator]] [[Category:XBOX Homebrew portable emulators]]',
        ['Handheld'] = {'homebrew emulators', 'Handheld Emulators on Xbox', 'Xbox Homebrew Emulators'},
['arcade emulator']   = '[[List of XBOX homebrew emulators#Arcade|Arcade emulator]] [[Category:XBOX Homebrew arcade emulators]]',
        ['Arcade'] = {'homebrew emulators', 'Arcade Emulators on Xbox', 'Xbox Homebrew Emulators'},
['computer emulator'] = '[[List of XBOX homebrew emulators#Computer|Computer emulator]] [[Category:XBOX Homebrew computer emulators]]',
        ['Computer'] = {'homebrew emulators', 'Computer Emulators on Xbox', 'Xbox Homebrew Emulators'},
-- Loaders
 
['loader']            = '[[List of XBOX homebrew loaders|Loader]] [[Category:XBOX Homebrew loaders]]',
    }
-- Exploits
 
['exploit']            = '[[List of XBOX homebrew exploits|Exploit]] [[Category:XBOX Homebrew exploits]]',
    local category = categories[typeVal]
-- System Tools
    if category then
['system tool']        = '[[List of XBOX system tools|System tool]] [[Category:XBOX homebrew system tools]]',
            return string.format('[[List of XBOX %s#%s|%s]] [[Category:%s]] [[Category:%s]]', category[1], typeVal, typeVal, category[2], category[3])
-- PC Utilities
    else
['pc utility']        = '[[List of XBOX PC utilities|PC utility]] [[Category:XBOX PC utilities]]',
        return typeVal .. '[[Category:Infobox homebrew using invalid type parameter]]'
-- Demos
    end
['demo']               = '[[List of XBOX homebrew demos|Demo]] [[Category:XBOX homebrew demos]]',
}
return types[type] or type .. '[[Category:Infobox homebrew using invalid type parameter]]'
end
end
   
   
Line 115: Line 132:
return '[[' .. link .. '|' .. label .. ']]'
return '[[' .. link .. '|' .. label .. ']]'
end
end
local function getLink2( label, link, altlink )
    local lastModified = os.date("?!%Y-%m-%d_%H:%M:%S", os.time())
if empty( link ) then return altlink end
   
   
if link:find( '://' ) then
return '[' .. link .. lastModified ..' ' .. label .. ']'
end
return '[[' .. link .. '|' .. label .. ']]'
end
local function getLink3(label, link, altlink)
    -- Get the current timestamp
    local lastModified = os.date("!%Y-%m-%d_%H:%M:%S", os.time())
    -- Check if link is empty or nil, return altlink if true
    if link == nil or link == "" then
        return altlink
    end
    -- Check if link contains a protocol (e.g., http:// or https://)
    if string.find(link, '://') then
        -- If it does, append the timestamp and return as a plain link
        return '[' .. link .. ' ' .. label .. ' (' .. lastModified .. ')]'
    end
    -- If the link doesn't contain a protocol, treat it as a wiki link
    return '[[' .. link .. '|' .. label .. ']]'
end
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:Xbox Open Source Homebrew]]' end
   
   
return getLink( 'Source', source ) .. '[[Category:Open source homebrew]]'
return getLink( 'Source', source ) .. '[[Category:Xbox 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 202:
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 219:
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  = 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( '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
}
}
 
if ibData.data15 or ibData.data16 or ibData.data17 or ibData.data18 or ibData.data19 then ibData.header14 = 'Links' end
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
if a.cia == 'yes' then
ibData.header11 = 'CIA information'
ibData.header111 = 'CIA information'
ibData.label12 = 'Title ID'
ibData.label121 = 'Title ID'
ibData.data12   = a.titleID or 'Unknown[[Category:3DS Homebrew missing CIA titleID]]'
ibData.data121   = a.titleID or 'Unknown[[Category:3DS Homebrew missing CIA titleID]]'
ibData.label13 = 'Unique ID'
ibData.label212 = 'Unique ID'
ibData.data13   = a.uniqueID or 'Unknown[[Category:3DS Homebrew missing CIA uniqueID]]'
ibData.data212   = a.uniqueID or 'Unknown[[Category:3DS Homebrew missing CIA uniqueID]]'
end
end
   
   

Latest revision as of 03:01, 7 May 2024

Documentation for this module may be created at Module:Infobox XBOX 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'] = {'Applications', 'XBOX Homebrew Media players', 'Xbox Homebrew Applications'},
        ['File Browsers'] = {'Applications', 'Utility Homebrews on Xbox', 'Xbox Homebrew Applications'},
        -- Games
        ['Action'] = {'homebrew games', 'Action Games on Xbox', 'Xbox Homebrew Games'},
        ['Adventure'] = {'homebrew games', 'Adventure Games on Xbox', 'Xbox Homebrew Games'},
        ['Arcade Games'] = {'homebrew games', 'Arcade Games on Xbox', 'Xbox Homebrew Games'},
        ['Board'] = {'homebrew games', 'Board Games on Xbox', 'Xbox Homebrew Games'},		
        ['Card'] = {'homebrew games', 'Card Games on Xbox', 'Xbox Homebrew Games'},	
        ['Game Engine'] = {'homebrew games', 'Game Engine on Xbox', 'Xbox Homebrew Games'},	
        ['Music'] = {'homebrew games', 'Music Games on Xbox', 'Xbox Homebrew Games'},	
        ['Platform'] = {'homebrew games', 'Platform Games on Xbox', 'Xbox Homebrew Games'},	
        ['Puzzle'] = {'homebrew games', 'Puzzle Games on Xbox', 'Xbox Homebrew Games'},	
        ['Racing'] = {'homebrew games', 'Racing Games on Xbox', 'Xbox Homebrew Games'},	
        ['Role Playing'] = {'homebrew games', 'Role Playing Games on Xbox', 'Xbox Homebrew Games'},	
        ['Shooter'] = {'homebrew games', 'Shooter Games on Xbox', 'Xbox Homebrew Games'},	
        ['Simulation'] = {'homebrew games', 'Simulation Games on Xbox', 'Xbox Homebrew Games'},	
        ['Strategy'] = {'homebrew games', 'Strategy Games on Xbox', 'Xbox Homebrew Games'},	
        ['Trivia'] = {'homebrew games', 'Trivia Games on Xbox', 'Xbox Homebrew Games'},	
        ['Other Games'] = {'homebrew games', 'Other Games on Xbox', 'Xbox Homebrew Games'},	
        -- Emulators
        ['Console'] = {'homebrew emulators', 'Console Emulators on Xbox', 'Xbox Homebrew Emulators'},
        ['Handheld'] = {'homebrew emulators', 'Handheld Emulators on Xbox', 'Xbox Homebrew Emulators'},
        ['Arcade'] = {'homebrew emulators', 'Arcade Emulators on Xbox', 'Xbox Homebrew Emulators'},
        ['Computer'] = {'homebrew emulators', 'Computer Emulators on Xbox', 'Xbox Homebrew Emulators'},

    }

    local category = categories[typeVal]
    if category then
            return string.format('[[List of XBOX %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 )

    local lastModified = os.date("?!%Y-%m-%d_%H:%M:%S", os.time())

	if empty( link ) then return altlink end
 
	if link:find( '://' ) then
		return '[' .. link .. lastModified ..' ' .. label .. ']'
	end
 
	return '[[' .. link .. '|' .. label .. ']]'
end

local function getLink3(label, link, altlink)
    -- Get the current timestamp
    local lastModified = os.date("!%Y-%m-%d_%H:%M:%S", os.time())

    -- Check if link is empty or nil, return altlink if true
    if link == nil or link == "" then
        return altlink
    end

    -- Check if link contains a protocol (e.g., http:// or https://)
    if string.find(link, '://') then
        -- If it does, append the timestamp and return as a plain link
        return '[' .. link .. ' ' .. label .. ' (' .. lastModified .. ')]'
    end

    -- If the link doesn't contain a protocol, treat it as a wiki link
    return '[[' .. link .. '|' .. label .. ']]'
end

local function getSource( source )
	if empty( source ) then return end
	if source == 'included' then return 'Source included[[Category:Xbox Open Source Homebrew]]' end
 
	return getLink( 'Source', source ) .. '[[Category:Xbox 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   = 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.header111 = 'CIA information'
		ibData.label121  = 'Title ID'
		ibData.data121   = a.titleID or 'Unknown[[Category:3DS Homebrew missing CIA titleID]]'
		ibData.label212  = 'Unique ID'
		ibData.data212   = a.uniqueID or 'Unknown[[Category:3DS Homebrew missing CIA uniqueID]]'
	end
 
	return infobox.infobox( ibData )
end
 
return p

Advertising: