-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTemplates.lua
More file actions
239 lines (170 loc) · 6.11 KB
/
Copy pathTemplates.lua
File metadata and controls
239 lines (170 loc) · 6.11 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
EasyDestroyItemsMixin = {}
function EasyDestroyItemsMixin:UpdateItemFrame(item, onclick)
if self and item:GetStaticBackingItem() then
item:ContinueWithCancelOnItemLoad(function()
self.Icon:SetTexture(item:GetItemIcon())
self.Item:SetText(item:GetItemName())
end)
--self.Item.itemLink = link
if item.classID == Enum.ItemClass.Tradegoods and item.count and item.count > 1 then
self.Item:SetText(item:GetItemName() .. " (" .. item.count .. ")")
self.ItemLevel:SetText("")
elseif item.level and item.level ~= nil and item.level ~= 0 then
if item.level then
self.ItemLevel:SetText("(" .. item.level .. ")")
else
self.ItemLevel:SetText("")
end
end
local r,g,b = GetItemQualityColor(item.quality)
self:SetBackdrop({bgFile="Interface\\Tooltips\\UI-Tooltip-Background",})
self:SetBackdropColor(r,g,b, 0.5)
self:SetScript("OnClick", onclick)
end
end
function EasyDestroyItemsMixin:HideItemFrame()
self.item = nil
self:Hide()
self:SetScript("OnClick", nil)
end
--[[ So that you don't have to remember which keys/names are used ]]
EasyDestroyEditBoxMixin = {}
function EasyDestroyEditBoxMixin:SetText(text)
self.input:SetText(text)
end
function EasyDestroyEditBoxMixin:SetNumeric(bool)
self.input:SetNumeric(bool)
end
function EasyDestroyEditBoxMixin:GetText()
return self.input:GetText()
end
function EasyDestroyEditBoxMixin:GetNumber()
return self.input:GetNumber()
end
function EasyDestroyEditBoxMixin:SetLabel(text)
self.label:SetText(text)
end
EasyDestroyEditBoxRangeMixin = {}
function EasyDestroyEditBoxRangeMixin:SetFromText(text)
self.inputfrom:SetText(text)
end
function EasyDestroyEditBoxRangeMixin:SetToText(text)
self.inputto:SetText(text)
end
function EasyDestroyEditBoxRangeMixin:SetValues(textfrom, textto)
self:SetFromText(textfrom)
self:SetToText(textto)
end
function EasyDestroyEditBoxRangeMixin:GetFromText()
return self.inputfrom:GetText()
end
function EasyDestroyEditBoxRangeMixin:GetToText()
return self.inputto:GetText()
end
function EasyDestroyEditBoxRangeMixin:GetTextValues()
return self.inputfrom:GetText(), self.inputto:GetText()
end
function EasyDestroyEditBoxRangeMixin:SetNumeric(bool)
self.inputfrom:SetNumeric(bool)
self.inputto:SetNumeric(bool)
end
function EasyDestroyEditBoxRangeMixin:GetFromNumber()
return self.inputfrom:GetNumber()
end
function EasyDestroyEditBoxRangeMixin:GetToNumber()
return self.inputto:GetNumber()
end
function EasyDestroyEditBoxRangeMixin:GetNumberValues()
return self:GetFromNumber(), self:GetToNumber()
end
--[[
CHECKBUTTON MIXIN
]]
EasyDestroyCheckboxMixin = {}
function EasyDestroyCheckboxMixin:SetLabel(text)
self.label:SetText(text)
end
EasyDestroyFramedCheckboxMixin = {}
function EasyDestroyFramedCheckboxMixin:SetLabel(text)
self.Checkbutton.label:SetText(text)
end
function EasyDestroyFramedCheckboxMixin:GetChecked()
return self.Checkbutton:GetChecked()
end
function EasyDestroyFramedCheckboxMixin:SetChecked(bool)
self.Checkbutton:SetChecked(bool)
end
-- function EasyDestroyCheckboxMixin:SetScript(...)
-- -- pass SetScript to the actual checkbutton
-- self.Checkbutton:SetScript(...)
-- end
-- function EasyDestroyCheckboxMixin:HookScript(...)
-- -- pass HookScript to the actual checkbutton
-- self.Checkbutton:HookScript(...)
-- end
-- function EasyDestroyCheckboxMixin:HasScript(...)
-- -- pass HasScript to the actual checkbutton
-- return self.Checkbutton:HasScript(...)
-- end
EasyDestroyScrollMixin = {}
function EasyDestroyScrollMixin:Initialize(listfunc, displayed, height, childfunc)
if type(listfunc) == "function" then
self.ListFunction = listfunc
end
if type(displayed) == "number" then
self.MaxDisplayed = displayed
end
if type(height) == "number" then
self.ChildHeight = height
end
if type(childfunc) == "function" then
self.ChildOnClick = childfunc
end
self.UpdateItemList = true
self.ItemList = {}
self.ItemCount = 0
-- We can display up to 10 items, if we're doing <10 then hide the remaining
if self.MaxDisplayed < 10 then
for i=self.MaxDisplayed+1,10,1 do
local f = _G[self:GetName() .. "Item" .. i]
f:Hide()
f:Disable()
end
end
end
function EasyDestroyScrollMixin:ItemListUpdate(listFuncArg)
if not self.ListFunction then return end
self.ItemList = self.ListFunction(listFuncArg or self.lastFuncArg)
self.lastFuncArg = listFuncArg or self.lastFuncArg
end
function EasyDestroyScrollMixin:ScrollUpdate(callbackFunction)
local itemList = nil
if not self.ListFunction then return end
if not self and self.ScrollFrame then return end
if not self.ItemList then return end
FauxScrollFrame_Update(self.ScrollFrame, #self.ItemList, self.MaxDisplayed, self.ChildHeight)
local offset = FauxScrollFrame_GetOffset(self.ScrollFrame)
for i=1, self.MaxDisplayed, 1 do
local index = offset+i
local frame = _G[ self:GetName() .. "Item" .. i ]
if index <= #self.ItemList then
frame.item = self.ItemList[index]
frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
frame:UpdateItemFrame(frame.item, self.ChildOnClick or nil)
frame:Show()
else
frame:HideItemFrame()
end
end
if callbackFunction ~= nil and type(callbackFunction) == "function" then
callbackFunction()
end
if self.ItemList ~= nil then
self.ItemCount = #self.ItemList
else
self.ItemCount = 0
end
end
function EasyDestroyScrollMixin:OnVerticalScroll(offset)
FauxScrollFrame_OnVerticalScroll(self.ScrollFrame, offset, self.ChildHeight, function() self:ScrollUpdate() end)
end