-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.lua
More file actions
158 lines (126 loc) · 3.82 KB
/
Copy pathlibrary.lua
File metadata and controls
158 lines (126 loc) · 3.82 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
--[[
Scroll Bar Function
Id: Nome que irá ficar salvo no storage, usado para salvar os valores.
Title: Titulo principal.
Min: Valor minimo.
Max: Valor máximo.
Default Value: Valor definido no começo.
Dest: Tab que irá ficar a scrollbar.
Tooltip: Tooltip que irá ficar no widget
]]--
local scrollBarLayout = [[
Panel
height: 28
margin-top: 0
UIWidget
id: text
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
text-align: center
HorizontalScrollBar
id: scroll
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 3
minimum: 0
maximum: 10
step: 1
]]
storage.scrollBarValues = storage.scrollBarValues or {}
addScrollBar = function(id, title, min, max, defaultValue, dest, tooltip)
local widget = setupUI(scrollBarLayout, dest)
widget.text:setTooltip(tooltip)
local value = math.min(math.max(storage.scrollBarValues[id] or defaultValue, min), max)
widget.scroll.onValueChange = function(scroll, value)
widget.text:setText(title .. ": " .. value)
storage.scrollBarValues[id] = value
end
widget.scroll:setMinimum(min)
widget.scroll:setMaximum(max)
widget.scroll:setValue(value)
widget.scroll.onValueChange(widget.scroll, value)
end
--[[
Switch Bar Function
Id: Nome que irá ficar salvo no storage, usado para salvar os valrores.
Title: Titulo principal.
Default Value: Valor definido no começo(boolean).
Dest: Tab que irá ficar a scrollbar.
Tooltip: Tooltip que irá ficar no widget
]]--
local switchBarLayout = [[
BotSwitch
height: 20
margin-top: 7
]]
storage.switchStatus = storage.switchStatus or {}
addSwitchBar = function(id, title, defaultValue, dest, tooltip)
local widget = setupUI(switchBarLayout, dest)
widget.onClick = function()
widget:setOn(not widget:isOn())
storage.switchStatus[id] = widget:isOn()
end
widget:setText(title)
widget:setTooltip(tooltip)
widget:setOn(storage.switchStatus[id] or defaultValue)
end
--[[
Item Widget Function
Id: Nome que irá ficar salvo no storage, usado para salvar os valrores.
Title: Titulo principal.
Default Item: Valor definido no começo(id).
Dest: Tab que irá ficar a scrollbar.
Tooltip: Tooltip que irá ficar no widget
]]--
itemWidget = [[
Panel
height: 34
margin-top: 7
margin-left: 25
margin-right: 25
UIWidget
id: text
anchors.left: parent.left
anchors.verticalCenter: next.verticalCenter
BotItem
id: item
anchors.top: parent.top
anchors.right: parent.right
]]
storage.itemValues = storage.itemValues or {};
addItem = function(id, title, defaultItem, dest, tooltip)
local widget = setupUI(itemWidget, dest)
widget.text:setText(title)
widget.text:setTooltip(tooltip)
widget.item:setTooltip(tooltip)
widget.item:setItemId(storage.itemValues[id] or defaultItem)
widget.item.onItemChange = function(widget)
storage.itemValues[id] = widget:getItemId()
end
storage.itemValues[id] = storage.itemValues[id] or defaultItem
end
--[[
CheckBox Widget Function
Id: Nome que irá ficar salvo no storage, usado para salvar os valrores.
Title: Titulo principal.
Default Item: Valor definido no começo(boolean).
Dest: Tab que irá ficar a scrollbar.
Tooltip: Tooltip que irá ficar no widget
]]--
checkBoxWidget = [[
CheckBox
width: 30
]]
storage.checkBoxStatus = storage.checkBoxStatus or {}
addCheckBox = function(id, title, defaultBoolean, dest, tooltip)
local widget = setupUI(checkBoxWidget, dest)
widget:setText(title)
widget:setTooltip(tooltip)
widget.onCheckChange = function(widget, checked)
widget:setChecked(checked)
storage.checkBoxStatus[id] = checked;
end
widget:setChecked(storage.checkBoxStatus[id] or defaultBoolean)
end