-
Notifications
You must be signed in to change notification settings - Fork 1
/
AssetsWidget.lua
92 lines (84 loc) · 2.33 KB
/
AssetsWidget.lua
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
--[[--
Assets widget
@classmod UI.AssetsWidget
--]]
local Roact = require(script.Parent.Parent.Parent.lib.Roact)
local Dropdown = require(script.Parent.Dropdown)
local AssetItem = require(script.Parent.AssetItem)
local c = Roact.createElement
local AssetsWidget = Roact.Component:extend("AssetsWidget")
function AssetsWidget:init(props)
assert(props)
self.state = {
Plugin = props.Plugin,
CurrentCategory = nil,
Assets = {
NPC = {
-- Frog
1667638075
},
Tools = {
-- Hammer
1637181997,
-- Nommy Gun
1673945800
},
Utilities = {
-- Waypoints
1667667072,
-- Area
1667505353,
}
}
}
end
function AssetsWidget:render()
local items = {}
local propsType = "Model"
if self.state.CurrentCategory == "Tools" then
propsType = "Tool"
end
-- Only add try to add asset items if a category is chosen
if self.state.CurrentCategory then
for _, v in pairs(self.state.Assets[self.state.CurrentCategory]) do
table.insert(items, c(AssetItem, {
ID = v,
Plugin = self.Plugin,
Type = propsType,
}))
end
end
return c("Frame", {
Position = UDim2.new(0, 0, 0, 0),
Size = UDim2.new(1.0, 0, 1.0, 0),
BackgroundTransparency = 1,
}, {
TypeFrame = c("Frame", {
Position = UDim2.new(0, 0, 0, 0),
Size = UDim2.new(1.0, 0, 0, 32),
BackgroundTransparency = 1,
},{
TypeChosen = c(Dropdown, {
Items = {
"NPC",
"Utilities",
"Tools",
},
ChangeFn = function(item)
self:setState({
CurrentCategory = item,
})
end
})
}),
AssetList = c("ScrollingFrame", {
Position = UDim2.new(0, 0, 0, 32),
Size = UDim2.new(1.0, 0, 1.0, -32),
BackgroundTransparency = 1,
}, {
c("UIListLayout"),
unpack(items),
})
})
end
return AssetsWidget