|
|
(14 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| ------------------------------ Helper Functions -------------------------------
| | function Infobox(frame) |
| | | local ret = "" |
| -- Mapping of game codes to full game names
| | for k,v in frame:argumentPairs() do |
| local GAMES = {
| | ret = ret .. k .. " = " .. v .. "<br>" |
| S = "Splatoon",
| | end |
| S2 = "Splatoon 2"
| | return ret |
| }
| |
| | |
| -- Common infobox opener
| |
| function OpenInfobox(color, title) | |
| -- Outer container
| |
| local ret = "<div style=\"border: 1px solid rgb(" .. color ..
| |
| "); border-width: 8px 1px; border-radius: 8px; " ..
| |
| "background: #ffffff; display: inline-block; width: 300px;\">"
| |
| | |
| -- Inner client area
| |
| ret = ret .. "<div style=\"background: rgba(" .. color .. ", 0.25); " ..
| |
| "box-shadow: 0 0 16px #ffffff inset; padding: 8px;\">"
| |
| | |
| -- Title
| |
| ret = ret .. "<div style=\"border: 1px solid rgb(" .. color .. "); " ..
| |
| "border-width: 1px 4px; border-radius: 4px; " ..
| |
| "background: rgba(" .. color .. ", 0.25); text-align: center; " ..
| |
| "font-size: 20px; font-weight: bold; padding: 8px;\">" ..
| |
| title .. "</div>"
| |
| | |
| return ret
| |
| end
| |
| | |
| -- Common parameters opener
| |
| function OpenParams()
| |
| return "<div style=\"display: grid; " ..
| |
| "grid-template-columns: max-content auto; grid-gap: 4px; " ..
| |
| "align-items: center;\">"
| |
| end
| |
| | |
| -- Common infobox and parameters closer
| |
| function CloseAll()
| |
| return "</div></div></div>"
| |
| end
| |
| | |
| -- Produce a parameter row for an infobox
| |
| function ParamRow(color, label, content)
| |
| | |
| -- Outer label container, styles the left vertical edge
| |
| local ret = "<div style=\"border: 1px solid rgb(" .. color .. "); " ..
| |
| "border-width: 0 0 0 4px; border-radius: 4px;\">"
| |
| | |
| -- Inner label container, styles the horizontal edges and background
| |
| ret = ret .. "<div style=\"border: 1px solid red; " ..
| |
| "border-width: 1px 0 1px 0; font-weight: bold; " ..
| |
| "padding: 4px 8px 4px 4px; " ..
| |
| "background: linear-gradient(90deg, rgba(" .. color .. ", 0.5), " ..
| |
| "rgba(" .. color .. ", 0.5) 25%, rgba(" .. color .. ", 0)); " ..
| |
| "border-image: linear-gradient(90deg, rgb(" .. color .. "), " ..
| |
| "rgba(" .. color .. ", 0)) 1;\">"
| |
| | |
| -- Parameter contents
| |
| return ret .. label .. "</div></div><div>" .. content .. "</div>"
| |
| end
| |
| | |
| -- Produce an image and a link for a parameter row
| |
| function ParamImageLink(filename, link, opacity)
| |
| local img = "[[File:" .. filename .. "|x24px|link=" .. link .. "|" ..
| |
| link .. "]]"
| |
| if opacity then
| |
| img = "<span style=\"opacity: " .. opacity .. ";\">" .. img .. "</span>"
| |
| end
| |
| return img .. " [[" .. link .. "]]"
| |
| end
| |
| | |
| ---------------------------------- Infoboxes ----------------------------------
| |
| | |
| -- Gear
| |
| function Gear(frame)
| |
| local color = frame:expandTemplate
| |
| { title = "SiteColor", args = { GAMES[frame.args.game] } }
| |
| local ret = OpenInfobox(color, frame.args.name)
| |
| | |
| -- Image
| |
| ret = ret .. "<div style=\"display: flex; align-items: center; " ..
| |
| "justify-content: center;\">[[File:" .. frame.args.game ..
| |
| "_Gear_" .. frame.args.category .. "_" .. frame.args.name ..
| |
| ".png|128x128px]]</div>"
| |
| | |
| -- Parameters
| |
| ret = ret .. OpenParams()
| |
| | |
| -- Category row
| |
| if frame.args.category then
| |
| ret = ret .. ParamRow(color, "Category", ParamImageLink(
| |
| "S2_Icon_" .. frame.args.category .. ".png",
| |
| frame.args.category,
| |
| 0.5))
| |
| end
| |
| | |
| -- Brand row
| |
| if frame.args.brand then
| |
| ret = ret .. ParamRow(color, "Brand", ParamImageLink(
| |
| frame.args.game .. "_Brand_" .. frame.args.brand .. ".png",
| |
| frame.args.brand
| |
| ))
| |
| end
| |
| | |
| -- Ability row
| |
| if frame.args.ability then
| |
| ret = ret .. ParamRow(color, "Ability", ParamImageLink(
| |
| frame.args.game .. "_Ability_" .. frame.args.ability .. ".png",
| |
| frame.args.ability
| |
| ))
| |
| end
| |
| | |
| -- Cost row
| |
| if frame.args.cost then
| |
| ret = ret .. ParamRow(color, "Cost", frame:expandTemplate
| |
| { title = "Cost", args = {
| |
| frame.args.game, frame.args.cost, "cash", "link"
| |
| } }
| |
| )
| |
| end
| |
| | |
| -- SplatNet 2 row
| |
| if frame.args.splatnet2 then
| |
| ret = ret .. ParamRow(color, "SplatNet 2", frame:expandTemplate
| |
| { title = "Cost", args = {
| |
| frame.args.game, frame.args.splatnet2, "cash", "link"
| |
| } }
| |
| )
| |
| end
| |
| | |
| -- Rarity row
| |
| if frame.args.rarity then
| |
| ret = ret .. ParamRow(color, "Rarity", frame:expandTemplate
| |
| { title = "Rarity", args = { frame.args.rarity } }
| |
| )
| |
| end
| |
| | |
| ret = ret .. CloseAll()
| |
| if frame.args.nowiki ~= nil then
| |
| ret = ret:gsub("%<", "<"):gsub("%[", "…")
| |
| end
| |
| return ret
| |
| end | | end |
|
| |
|
| -- Module | | -- Module |
| return { | | return { |
| gear = Gear | | infobox = Infobox |
| } | | } |