-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathCustom.lua
More file actions
94 lines (82 loc) · 2.49 KB
/
Custom.lua
File metadata and controls
94 lines (82 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
-- @Liquipedia
-- page=Module:Infobox/Map/Custom
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--
local Lua = require('Module:Lua')
local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local Injector = Lua.import('Module:Widget/Injector')
local Map = Lua.import('Module:Infobox/Map')
local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local Image = Lua.import('Module:Widget/Image/Icon/Image')
local Widgets = Lua.import('Module:Widget/All')
local Cell = Widgets.Cell
local Center = Widgets.Center
local Title = Widgets.Title
local UniverseIcon = Lua.import('Module:Widget/UniverseIcon')
local WidgetUtil = Lua.import('Module:Widget/Util')
---@class HeroesMapInfobox: MapInfobox
local CustomMap = Class.new(Map)
---@class HeroesMapInfoboxWidgetInjector: WidgetInjector
---@field caller HeroesMapInfobox
local CustomInjector = Class.new(Injector)
---@param frame Frame
---@return Widget
function CustomMap.run(frame)
local map = CustomMap(frame)
map.args.informationType = 'Battleground'
map:setWidgetInjector(CustomInjector(map))
return map:createInfobox()
end
---@param id string
---@param widgets Widget[]
---@return Widget[]
function CustomInjector:parse(id, widgets)
local caller = self.caller
local args = caller.args
if id == 'custom' then
return WidgetUtil.collect(
Cell{name = 'Universe', children = {UniverseIcon{universe = args.universe}}},
caller:_objectives(),
Cell{name = 'Creatures', children = caller:getAllArgsForBase(args, 'creature')},
Title{children = {'Map Data'}},
Cell{name = 'Lanes', children = {args.lanes}},
Cell{name = 'Mercenary camps', children = {args.mercenarycamps}},
caller:_image2()
)
end
return widgets
end
---@param args table
---@return string[]
function CustomMap:getWikiCategories(args)
return {
'Battlegrounds',
args.universe and (args.universe .. ' Battlegrounds') or nil,
}
end
---@return Widget[]?
function CustomMap:_objectives()
local objectives = self:getAllArgsForBase(self.args, 'objective')
if Logic.isEmpty(objectives) then return end
return {
Title{children = {'Main Objectives'}},
Center{children = Array.interleave(objectives, ' ')}
}
end
---@return Widget?
function CustomMap:_image2()
if not self.args.image2 then return end
return HtmlWidgets.Div{
classes = {'infobox-image'},
children = {Image{
imageLight = self.args.image2,
size = '294px',
horizontalAlignment = 'center',
}}
}
end
return CustomMap