Line 1: |
Line 1: |
| local getArgs = require("Module:GetArgs") | | local getArgs = require("Module:GetArgs") |
− | local U = require("Module:Utils") | + | local U = require("Module:Core") |
| local F = require("Module:Formatting") | | local F = require("Module:Formatting") |
| local Equipment = require("Module:Equipment") | | local Equipment = require("Module:Equipment") |
| local EquipmentCardKai = require("Module:EquipmentCardKai") | | local EquipmentCardKai = require("Module:EquipmentCardKai") |
| + | local EquipmentGraphicKai = require("Module:EquipmentGraphicKai") |
| | | |
| local EquipmentLink = {} | | local EquipmentLink = {} |
Line 9: |
Line 10: |
| function EquipmentLink.format(frame, args) | | function EquipmentLink.format(frame, args) |
| | | |
− | args = args or getArgs{ frame = frame:getParent() } | + | args = args |
| + | or U.getTemplateArgs(frame).implicit[1] and U.getTemplateArgs(frame).implicit |
| + | or U.getTemplateArgs(frame).explicit |
| | | |
| local name = args[1] or "??" | | local name = args[1] or "??" |
Line 16: |
Line 19: |
| local image = args.image | | local image = args.image |
| local icon = args.icon | | local icon = args.icon |
| + | |
| + | local size = args.size or (args[2] and "160px" or "260px") |
| | | |
| local cards = {} | | local cards = {} |
| for _, arg in ipairs(args) do | | for _, arg in ipairs(args) do |
− | table.insert(cards, arg == "-" and "<br />" or EquipmentCardKai:Asset({ arg, size = args.size })) | + | local equip = arg ~= "-" and Equipment(arg) |
| + | table.insert( |
| + | cards, |
| + | arg == "-" and |
| + | "<br />" or |
| + | equip._is_enemy and |
| + | EquipmentGraphicKai:get{ equip = equip, size = size } or |
| + | EquipmentCardKai:get{ equip = equip, size = size } |
| + | ) |
| end | | end |
| | | |
| local formatted_image | | local formatted_image |
| = image | | = image |
− | and EquipmentCardKai:Asset({ name, size = image, link = link or name }) | + | and EquipmentCardKai:Asset({ name, size = image == "true" and "50px" or image, link = link or name }) |
| or "" | | or "" |
| | | |
Line 45: |
Line 58: |
| formatted_text = "" | | formatted_text = "" |
| else | | else |
− | formatted_text = F:format_link(link or name, text or name) | + | formatted_text = F:format_link(link or name, name) |
| end | | end |
| end | | end |
| | | |
− | local tooltip_content = F:class_div("tooltip-contents", nil, #cards > 0 and table.concat(cards, "") or "??") | + | local tooltip_content = F:class_span("tooltiptext", nil, #cards > 0 and table.concat(cards, "") or "??") |
| | | |
− | return F:class_span("advanced-tooltip", nil, formatted_icon .. formatted_image .. formatted_text .. tooltip_content) | + | return F:class_span("tooltip", nil, formatted_icon .. formatted_image .. formatted_text .. tooltip_content) |
| | | |
| end | | end |
| | | |
− | --[[
| |
| U.registerFormatTests(EquipmentLink, { | | U.registerFormatTests(EquipmentLink, { |
| { "Prototype 51cm Twin Gun Mount" }, | | { "Prototype 51cm Twin Gun Mount" }, |
Line 62: |
Line 74: |
| { "Prototype 51cm Twin Gun Mount", image = "50px" }, | | { "Prototype 51cm Twin Gun Mount", image = "50px" }, |
| { "Prototype 51cm Twin Gun Mount", icon = "x" }, | | { "Prototype 51cm Twin Gun Mount", icon = "x" }, |
| + | { "Prototype 51cm Twin Gun Mount", "Prototype 51cm Twin Gun Mount" }, |
| { }, | | { }, |
| { icon = "x" }, | | { icon = "x" }, |
| }) | | }) |
| -- p.run_format_tests() | | -- p.run_format_tests() |
− | ]]--
| |
| | | |
| return EquipmentLink | | return EquipmentLink |