Module:Gallery

From Kairosoft Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Gallery/doc

local getArgs = require('Module:Arguments').getArgs
 
local p = {}

-- Invoked by: Template:Game platform list
function p.gamePlatformList(frame)
    local args = getArgs(frame)
    
    local title = args['title']
    local googleplay = args['googleplay']
    local ios = args['ios']
    local switch = args['switch']
    local playstation = args['playstation']
    local steam = args['steam']
    local xbox = args['xbox']
    local arcade = args['arcade']
    
    -- Data
    local links = {}
    if googleplay then
    	links[#links+1] = {
    		link = 'https://play.google.com/store/apps/details?id='..googleplay,
    		icon = "Android 2023 logo.png",
    		text = "Google Play"
    	}
    end
    if ios then
    	links[#links+1] = {
    		link = 'https://itunes.apple.com/app/'..ios,
    		icon = "Apple logo.svg",
    		text = "iOS App Store"
    	}
    end
    if switch then
    	links[#links+1] = {
    		link = 'https://www.nintendo.com/store/products/'..switch,
    		icon = "Switch logo.svg",
    		text = "Nintendo Switch"
    	}
    end
    if playstation then
    	links[#links+1] = {
    		link = 'https://store.playstation.com/en-us/product/'..playstation,
    		icon = "PlayStation logo.svg",
    		text = "PlayStation"
    	}
    end
    if steam then
    	links[#links+1] = {
    		link = 'https://store.steampowered.com/app/'..steam,
    		icon = "Steam icon logo.svg",
    		text = "Steam"
    	}
    end
    if xbox then
    	links[#links+1] = {
    		link = 'https://www.microsoft.com/store/productid/'..xbox,
    		icon = "Xbox logo.png",
    		text = "Xbox"
    	}
    end
    if arcade then
    	links[#links+1] = {
    		link = 'https://apps.apple.com/us/app/'..arcade,
    		icon = "Apple arcade logo.svg",
    		text = "Apple Arcade"
    	}
    end
    
    -- Render
    local t = {}
    t[#t+1] = '<div style="overflow-x:hidden;">'
    if title then
    	t[#t+1] = '<center style="margin-top:4px"><b>'..title..'</b></center>'
    end
    t[#t+1] = '<div class="game-platform-links" style="table-layout:fixed;" border="1" cellpadding="5"><center>'
    
	for _,data in pairs(links) do
		t[#t+1] = table.concat{
			'<div class="game-platform-links-item">',
				'[', data.link, ' ', 
					'[[File:', data.icon, '|center|25px|link=]]',
					data.text,
				']',
			'</div>'
		}
	end
	
    t[#t+1] = "</center></div>"
    t[#t+1] = "</div>"
    
    return table.concat(t, '\n')
end
 
return p