缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!

该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!

全站通知:

模块:信息框/建筑

来自缺氧WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

用于模块:Module:建筑信息框



local infobox = require([[Module:信息框]])
local fstr = mw.ustring.format
local p = {}

local loadAndPower =
    '<abbr title="引擎功率/总舱块负担 = 火箭速度(格/周期)">%s</abbr>'
local innerNodes = {
    {
        tag = 'image',
        source = '图片',
        children = {{tag = 'caption', source = '图片说明'}}
    },
    {
        tag = 'data',
        source = '描述',
        label = nil
    },
    {
        tag = 'data',
        source = 'ID',
        label = 'ID'
    },
    {
        tag = 'data',
        source = '弃用',
        label = '弃用'
    },
    {
        tag = 'data',
        source = '尺寸',
        label = '[[File:图标_尺寸.png|16px|link=|class=dark-invert]] 尺寸'
    },
    {
        tag = 'data',
        source = '旋转',
        label = '[[File:图标_旋转.png|16px|link=|class=dark-invert]] 旋转'
    },
    {
        tag = 'data',
        source = '装饰',
        label = '[[File:图标_装饰.png|16px|link=]] 装饰'
    },
    {
        tag = 'data',
        source = '建筑血量',
        label = '建筑血量'
    },
    {
        tag = "group",
        header = "效果",
        attr = {collapse = 'open', layout = "open"},
        children = {
            {
                tag = 'data',
                source = '电力',
                label = '[[File:图标_电力.png|16px|link=]] 电力'
            },
            {
                tag = 'data',
                source = '产热',
                label = '[[File:图标_温度.png|16px|link=]] [[计量单位#热量(Q)|产热]]'
            },
            {
                tag = 'data',
                source = '电力容量',
                label = '[[File:图标_电力.png|16px|link=]] 电力容量'
            },
            {
                tag = 'data',
                source = '电力泄露',
                label = '[[File:图标_电力.png|16px|link=]] 电力泄露'
            },
            {
                tag = 'data',
                source = '配方',
                label = nil
            },
            {
                tag = 'data',
                source = '使用效果',
                label = nil
            },
        }
    },
    {
        tag = "group",
        header = "建造",
        attr = {collapse = 'open', layout = "open"},
        children = {
            {
                tag = 'data',
                source = '类别',
                label = '[[File:图标_工作_建造.png|16px|link=]] 类别'
            },
            {
                tag = 'data',
                source = '科技',
                label = '[[File:高级研究.png|16px|link=]] [[研究|科技]]'
            },
            {
                tag = 'data',
                source = '房间类型',
                label = '[[File:图标_房间需求类型.png|16px|link=]][[房间|房间类型]]'
            },
            {
                tag = 'data',
                source = '类型',
                label = '[[File:图标_工作_建造.png|16px|link=]] 类型'
            },
            {
                tag = 'data',
                source = '基础建造时间',
                label = '[[File:图标_时间.png|16px|link=|class=dark-invert]] 建造时间'
            },
            {
                tag = 'data',
                source = '建筑材料',
                label = '[[File:图标_材料.png|16px|link=]] 建筑材料'
            },
            {
                tag = 'data',
                source = '导热系数',
                label = '导热系数'
            },
        }
    },
    {
        tag = "group",
        header = "火箭舱块",
        attr = {collapse = 'open'},
        -- attr = {layout = "horizontal"},
        children = {
            {
                tag = 'data',
                source = '舱块负担',
                label = fstr(loadAndPower, '舱块负担')
            },
            {tag = 'data', source = '最大高度', label = '最大高度'},
            {
                tag = 'data',
                source = '引擎功率',
                label = fstr(loadAndPower, '引擎功率')
            },
            {tag = 'data', source = '燃料', label = '燃料'},
            {tag = 'data', source = '废气', label = '废气'},
            {
                tag = 'data',
                source = '需要氧化剂',
                label = '需要氧化剂'
            }
        }
    },
    {
        tag = 'group',
        header = '工作条件',
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '过热',
                label = '[[File:复制人_状态_升温.png|16px|link=]] 过热'
            },
            {
                tag = 'data',
                source = '过冷',
                label = '[[File:复制人_状态_降温.png|16px|link=]] 过冷'
            },
            {
                tag = 'data',
                source = '淹没',
                label = '[[File:图标_淹没.png|16px|link=|class=dark-invert]] <abbr title="淹没判定:元素默认质量(一般为满格质量)的 35%">淹没</abbr>'
            },
            {
                tag = 'data',
                source = '掩埋',
                label = '[[File:图标_掩埋.png|16px|link=|class=dark-invert]] 掩埋'
            },
            {
                tag = 'data',
                source = '操作',
                label = '[[File:复制人.png|16px|link=|class=dark-invert]] 复制人操作'
            },
            {
                tag = 'data',
                source = '可被蓄意破坏',
                label = '<abbr title = "决定复制人压力过大时是否会破坏该建筑">可被毁坏</abbr>'
            },
            {
                tag = 'data',
                source = '火箭限制',
                label = '[[File:自动化输入.png|16px|link=]] 火箭限制'
            }
        }
    },
    {
        tag = 'group',
        header = '物流',
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '水管',
                label = '[[File:图标_水管.png|16px|link=]] 水管'
            }, {
                tag = 'data',
                source = '通风',
                label = '[[File:图标_通风.png|16px|link=]] 通风'
            }, {
                tag = 'data',
                source = '运输',
                label = '[[File:图标_运输.png|16px|link=]] 运输'
            }
        }
    },
    {
        tag = "group",
        header = "自动化",
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '自动化输入',
                label = '[[File:自动化输入.png|16px|link=]] 自动化输入'
            },
            {
                tag = 'data',
                source = '自动化输出',
                label = '[[File:自动化输出.png|16px|link=]] 自动化输出'
            }
        }
    },
    {
        tag = "group",
        header = "库存",
        attr = {collapse = 'closed'},
        children = {
            {
                tag = 'data',
                source = '机械臂运送',
                label = '机械臂运送'
            },
            {
                tag = 'data',
                source = '允许清空库存',
                label = '允许清空库存'
            },
            {
                tag = 'data',
                source = '库存容量',
                label = '库存容量'
            },
            {
                tag = 'data',
                source = '存储物品',
                label = '存储物品'
            }
        }
    }
}

-- test: = p.infoboxContent{['过冷'] = 5}
function p.infoboxContent(args)
    if args['过冷'] ~= nil then args['过冷'] = args['过冷'] .. "°C" end
    if args['各材料过热'] ~= nil then
        args['过热'] = tostring(infobox.collapsible {
            collapsed = true,
            expandText = '不同材料',
            showText = args['过热'],
            hideText = args['各材料过热']
        })
    elseif args['过热'] ~= nil then
        args['过热'] = args['过热'] 
    end
    if args['各材料装饰'] ~= nil then
        args['装饰'] = tostring(infobox.collapsible {
            collapsed = true,
            expandText = '不同材料',
            showText = args['装饰'],
            hideText = args['各材料装饰']
        })
    end
    if args['库存'] ~= nil and #args['库存'] > 0 then
        local allStorageItems = table.concat(args["库存"], "<br/>")
        if #args['库存'] > 3 then
            args['存储物品'] = tostring(infobox.collapsible {
                collapsed = true,
                expandText = '所有物品',
                showText = fstr("共%d种可存储物品", #args['库存']),
                hideText = allStorageItems
            })
        else
            args['存储物品'] = allStorageItems
        end
    end

    local generated = {}
    for _, n in ipairs(innerNodes) do
        local child = infobox.genNode(n, args)
        if child ~= nil then
            table.insert(generated, child)
        end
    end

    return generated
end

-- test: = p.main('testTitle', {{data={['过冷'] = 5}}}, true)
--[[ test: = p.main('testTitle', {
    {label = 'testlabel1', data = {['过冷'] = 5}},
    {label = 'testlabel2', data = {['过冷'] = 5}}
}, true)
]]
function p.main(title, data, raw)
    local contentNodes = nil
    if #data == 1 then
        contentNodes = p.infoboxContent(data[1].data)
    else
        local panelData = {}
        for _, pData in ipairs(data) do
            table.insert(panelData, {
                label = pData.label,
                content = p.infoboxContent(pData.data)
            })
        end
        contentNodes = {infobox.panel(panelData)}
    end
    return infobox.infobox(title, contentNodes, raw)
end

-- test: =p.demo{['过冷'] = 5, raw=true}
function p.demo(frame)
    local getArgs = require('Dev:Arguments').getArgs
    local args = getArgs(frame)
    return p.main(args['标题'], {{data = args}}, args.raw)
end

return p