-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOutfitterUITools.lua
572 lines (439 loc) · 21.1 KB
/
OutfitterUITools.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
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
----------------------------------------
Outfitter._ButtonBar = {}
----------------------------------------
function Outfitter._ButtonBar:Construct(pName, pNumColumns, pNumRows, pButtonMethods, pButtonTemplate)
self.Name = pName
self.NumColumns = 0
self.NumRows = 0
self.Buttons = {}
self.BackgroundTextures = {}
self.ButtonMethods = pButtonMethods
self.ButtonTemplate = pButtonTemplate or "ItemButtonTemplate"
self:SetFrameStrata("DIALOG")
Outfitter.SetFrameLevel(self, 1)
self:EnableMouse(true)
self:SetDimensions(pNumColumns, pNumRows)
self:SetParent(UIParent)
end
function Outfitter._ButtonBar:SetDimensions(pNumColumns, pNumRows)
self.NumColumns = pNumColumns
self.NumRows = pNumRows
-- Allocate additional buttons if needed
local vTotalButtons = pNumColumns * pNumRows
for vIndex = #self.Buttons, vTotalButtons do
local vButtonName = self.Name.."Button"..vIndex
local vButton = CreateFrame("CheckButton", vButtonName, self, self.ButtonTemplate)
Outfitter.InitializeFrame(vButton, self.ButtonMethods)
vButton:Construct()
--Outfitter.SetFrameLevel(vButton, self:GetFrameLevel() + 1)
table.insert(self.Buttons, vButton)
end
-- Allocate additional textures if needed
local vNumTexRows = self.NumRows + 1
local vNumTexColumns = self.NumColumns + 1
local vTotalTextures = vNumTexRows * vNumTexColumns
for vIndex = #self.BackgroundTextures, vTotalTextures do
local vTexture = self:CreateTexture(nil, "BACKGROUND")
vTexture:SetTexture("Interface\\Addons\\Outfitter\\Textures\\QuickSlotsBackground")
vTexture:SetHeight(Outfitter.Style.ButtonBar.BackgroundHeight)
vTexture:Hide()
table.insert(self.BackgroundTextures, vTexture)
end
self.NumTextures = vTotalTextures
-- Link the buttons together
local vButtonFrameLevel = self:GetFrameLevel() + 1
local vButtonIndex = 1
local vPrevRowFirstButton
local vRowFirstButton
for vRow = 1, self.NumRows do
local vPrevButton
local vRowFirstButton = self.Buttons[vButtonIndex]
for vColumn = 1, self.NumColumns do
local vButton = self.Buttons[vButtonIndex]
vButton:ClearAllPoints()
if vPrevButton then
vButton:SetPoint("LEFT", vPrevButton, "LEFT", Outfitter.Style.ButtonBar.BackgroundWidth, 0)
elseif vPrevRowFirstButton then
vButton:SetPoint("TOP", vPrevRowFirstButton, "TOP", 0, -Outfitter.Style.ButtonBar.BackgroundHeight)
else
vButton:SetPoint("TOPLEFT", self, "TOPLEFT", 7, -6)
end
vButton:EnableMouse(true)
--vButton:SetFrameLevel(vButtonFrameLevel)
vButton:Enable()
vButton:Show()
vPrevButton = vButton
vButtonIndex = vButtonIndex + 1
end
vPrevRowFirstButton = vRowFirstButton
end
-- Hide unused buttons
for vIndex = vButtonIndex, #self.Buttons do
local vButton = self.Buttons[vIndex]
vButton.Outfit = nil
vButton:EnableMouse(false)
vButton:Disable()
vButton:Hide()
end
-- Set the textures and link them together
local vTextureIndex = 1
local vPrevRowFirstTexture
local vRowFirstTexture
local vTexVertCoord1 = Outfitter.Style.ButtonBar.BackgroundHeight0 / Outfitter.Style.ButtonBar.BackgroundTextureHeight
local vTexVertCoord2 = (Outfitter.Style.ButtonBar.BackgroundHeight0 + Outfitter.Style.ButtonBar.BackgroundHeight) / Outfitter.Style.ButtonBar.BackgroundTextureHeight
local vTexVertCoord3 = (Outfitter.Style.ButtonBar.BackgroundHeight0 + Outfitter.Style.ButtonBar.BackgroundHeight + Outfitter.Style.ButtonBar.BackgroundHeightN) / Outfitter.Style.ButtonBar.BackgroundTextureHeight
local vTexHorizCoord1 = Outfitter.Style.ButtonBar.BackgroundWidth0 / Outfitter.Style.ButtonBar.BackgroundTextureWidth
local vTexHorizCoord2 = (Outfitter.Style.ButtonBar.BackgroundWidth0 + Outfitter.Style.ButtonBar.BackgroundWidth) / Outfitter.Style.ButtonBar.BackgroundTextureWidth
local vTexHorizCoord3 = (Outfitter.Style.ButtonBar.BackgroundWidth0 + Outfitter.Style.ButtonBar.BackgroundWidth + Outfitter.Style.ButtonBar.BackgroundWidthN) / Outfitter.Style.ButtonBar.BackgroundTextureWidth
for vRow = 1, vNumTexRows do
local vPrevTexture
local vRowFirstTexture = self.BackgroundTextures[vTextureIndex]
local vHeight, vTexTop, vTexBottom
if vRow == 1 then
vHeight = Outfitter.Style.ButtonBar.BackgroundHeight0
vTexTop = 0
vTexBottom = vTexVertCoord1
elseif vRow == vNumTexRows then
vHeight = Outfitter.Style.ButtonBar.BackgroundHeightN
vTexTop = vTexVertCoord2
vTexBottom = vTexVertCoord3
else
vHeight = Outfitter.Style.ButtonBar.BackgroundHeight
vTexTop = vTexVertCoord1
vTexBottom = vTexVertCoord2
end
for vColumn = 1, vNumTexColumns do
local vTexture = self.BackgroundTextures[vTextureIndex]
local vWidth, vTexLeft, vTexRight
if vColumn == 1 then
vWidth = Outfitter.Style.ButtonBar.BackgroundWidth0
vTexLeft = 0
vTexRight = vTexHorizCoord1
elseif vColumn == vNumTexColumns then
vWidth = Outfitter.Style.ButtonBar.BackgroundWidthN
vTexLeft = vTexHorizCoord2
vTexRight = vTexHorizCoord3
else
vWidth = Outfitter.Style.ButtonBar.BackgroundWidth
vTexLeft = vTexHorizCoord1
vTexRight = vTexHorizCoord2
end
vTexture:SetTexCoord(vTexLeft, vTexRight, vTexTop, vTexBottom)
vTexture:SetHeight(vHeight)
vTexture:SetWidth(vWidth)
vTexture:ClearAllPoints()
if vPrevTexture then
vTexture:SetPoint("LEFT", vPrevTexture, "RIGHT")
elseif vPrevRowFirstTexture then
vTexture:SetPoint("TOP", vPrevRowFirstTexture, "BOTTOM")
else
vTexture:SetPoint("TOPLEFT", self, "TOPLEFT")
end
if not self.HideBackground then
vTexture:Show()
end
vPrevTexture = vTexture
vTextureIndex = vTextureIndex + 1
end
vPrevRowFirstTexture = vRowFirstTexture
end
-- Hide unused textures
for vIndex = vTextureIndex, #self.BackgroundTextures do
local vTexture = self.BackgroundTextures[vIndex]
vTexture:ClearAllPoints()
vTexture:Hide()
end
-- Resize the bar
self:SetWidth(Outfitter.Style.ButtonBar.BackgroundWidth * (pNumColumns - 1) + Outfitter.Style.ButtonBar.BackgroundWidth0 + Outfitter.Style.ButtonBar.BackgroundWidthN)
self:SetHeight(Outfitter.Style.ButtonBar.BackgroundHeight * (pNumRows - 1) + Outfitter.Style.ButtonBar.BackgroundHeight0 + Outfitter.Style.ButtonBar.BackgroundHeightN)
end
function Outfitter._ButtonBar:GetIndexedButton(pButtonIndex)
local vNumButtons = self.NumColumns * self.NumRows
if not pButtonIndex or pButtonIndex < 1 or pButtonIndex > vNumButtons then
return
end
return self.Buttons[pButtonIndex]
end
function Outfitter._ButtonBar:ShowBackground(pShow)
self.HideBackground = not pShow
if self.HideBackground then
for vIndex, vTexture in ipairs(self.BackgroundTextures) do
if vIndex > self.NumTextures then
break
end
vTexture:Hide()
end
else
for vIndex, vTexture in ipairs(self.BackgroundTextures) do
if vIndex > self.NumTextures then
break
end
vTexture:Show()
end
end
end
----------------------------------------
Outfitter._SidebarWindowFrame = {}
----------------------------------------
function Outfitter._SidebarWindowFrame:Construct()
-- Create the textures
self.TopHeight = 80
self.LeftWidth = 80
self.BottomHeight = 183
self.RightWidth = 94
self.TopMargin = 13
self.LeftMargin = 0
self.BottomMargin = 3
self.RightMargin = 1
self.TextureWidth1 = 256
self.TextureWidth2 = 128
self.TextureUsedWidth2 = 94
self.TextureHeight1 = 256
self.TextureHeight2 = 256
self.TextureUsedHeight2 = 183
self.MiddleWidth1 = self.TextureWidth1 - self.LeftWidth
self.MiddleWidth2 = 60
self.TexCoordX1 = self.LeftWidth / self.TextureWidth1
self.TexCoordX2 = (self.TextureUsedWidth2 - self.RightWidth) / self.TextureWidth2
self.TexCoordX3 = self.TextureUsedWidth2 / self.TextureWidth2
self.TexCoordY1 = self.TopHeight / self.TextureHeight1
self.TexCoordY2 = (self.TextureUsedHeight2 - self.BottomHeight) / self.TextureHeight2
self.TexCoordY3 = self.TextureUsedHeight2 / self.TextureHeight2
self.Background = {}
self.Background.TopRight = self:CreateTexture(nil, "BORDER")
self.Background.TopRight:SetWidth(self.RightWidth)
self.Background.TopRight:SetHeight(self.TopHeight)
self.Background.TopRight:SetPoint("TOPRIGHT", self, "TOPRIGHT", self.RightMargin, self.TopMargin)
self.Background.TopRight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopRight")
self.Background.TopRight:SetTexCoord(self.TexCoordX2, self.TexCoordX3, 0, self.TexCoordY1)
self.Background.TopLeft = self:CreateTexture(nil, "BORDER")
self.Background.TopLeft:SetHeight(self.TopHeight)
self.Background.TopLeft:SetPoint("TOPLEFT", self, "TOPLEFT", -self.LeftMargin, self.TopMargin)
self.Background.TopLeft:SetPoint("TOPRIGHT", self.Background.TopRight, "TOPLEFT")
self.Background.TopLeft:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft")
self.Background.TopLeft:SetTexCoord(self.TexCoordX1, 1, 0, self.TexCoordY1)
self.Background.BottomRight = self:CreateTexture(nil, "BORDER")
self.Background.BottomRight:SetWidth(self.RightWidth)
self.Background.BottomRight:SetHeight(self.BottomHeight)
self.Background.BottomRight:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", self.RightMargin, -self.BottomMargin)
self.Background.BottomRight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomRight")
self.Background.BottomRight:SetTexCoord(self.TexCoordX2, self.TexCoordX3, self.TexCoordY2, self.TexCoordY3)
self.Background.BottomLeft = self:CreateTexture(nil, "BORDER")
self.Background.BottomLeft:SetHeight(self.BottomHeight)
self.Background.BottomLeft:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", -self.LeftMargin, -self.BottomMargin)
self.Background.BottomLeft:SetPoint("BOTTOMRIGHT", self.Background.BottomRight, "BOTTOMLEFT")
self.Background.BottomLeft:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomLeft")
self.Background.BottomLeft:SetTexCoord(self.TexCoordX1, 1, self.TexCoordY2, self.TexCoordY3)
self.Background.RightMiddle = self:CreateTexture(nil, "BORDER")
self.Background.RightMiddle:SetWidth(self.RightWidth)
self.Background.RightMiddle:SetPoint("TOPRIGHT", self.Background.TopRight, "BOTTOMRIGHT")
self.Background.RightMiddle:SetPoint("BOTTOMRIGHT", self.Background.BottomRight, "TOPRIGHT")
self.Background.RightMiddle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopRight")
self.Background.RightMiddle:SetTexCoord(self.TexCoordX2, self.TexCoordX3, self.TexCoordY1, 1)
self.Background.LeftMiddle = self:CreateTexture(nil, "BORDER")
self.Background.LeftMiddle:SetPoint("TOPLEFT", self.Background.TopLeft, "BOTTOMLEFT")
self.Background.LeftMiddle:SetPoint("BOTTOMLEFT", self.Background.BottomLeft, "TOPLEFT")
self.Background.LeftMiddle:SetPoint("TOPRIGHT", self.Background.TopRight, "BOTTOMLEFT")
self.Background.LeftMiddle:SetPoint("BOTTOMRIGHT", self.Background.BottomRight, "TOPLEFT")
self.Background.LeftMiddle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft")
self.Background.LeftMiddle:SetTexCoord(self.TexCoordX1, 1, self.TexCoordY1, 1)
self.Background.ShadowFrame = CreateFrame("Frame", nil, self)
self.Background.ShadowFrame:SetWidth(16)
self.Background.ShadowFrame:SetPoint("TOPLEFT", self, "TOPLEFT")
self.Background.ShadowFrame:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT")
self.Background.ShadowFrame:SetFrameLevel(self:GetFrameLevel() + 20)
self.Background.Shadow = self.Background.ShadowFrame:CreateTexture(nil, "OVERLAY")
self.Background.Shadow:SetAllPoints()
self.Background.Shadow:SetTexture(0, 0, 0, 1)
self.Background.Shadow:SetGradient(
"HORIZONTAL",
CreateColor(1, 1, 1, 1),
CreateColor(1, 1, 1, 0))
end
----------------------------------------
Outfitter._PortraitWindowFrame = {}
----------------------------------------
function Outfitter._PortraitWindowFrame:Construct()
-- Create the textures
self.TopHeight = 80
self.LeftWidth = 80
self.BottomHeight = 183
self.RightWidth = 94
self.TopMargin = 13
self.LeftMargin = 12
self.BottomMargin = 3
self.RightMargin = 1
self.TextureWidth1 = 256
self.TextureWidth2 = 128
self.TextureUsedWidth2 = 94
self.TextureHeight1 = 256
self.TextureHeight2 = 256
self.TextureUsedHeight2 = 183
self.MiddleWidth1 = self.TextureWidth1 - self.LeftWidth
self.MiddleWidth2 = 60
self.TexCoordX1 = self.LeftWidth / self.TextureWidth1
self.TexCoordX2 = (self.TextureUsedWidth2 - self.RightWidth) / self.TextureWidth2
self.TexCoordX3 = self.TextureUsedWidth2 / self.TextureWidth2
self.TexCoordY1 = self.TopHeight / self.TextureHeight1
self.TexCoordY2 = (self.TextureUsedHeight2 - self.BottomHeight) / self.TextureHeight2
self.TexCoordY3 = self.TextureUsedHeight2 / self.TextureHeight2
self.Background = {}
-- Create the four corners first
self.Background.TopLeft = self:CreateTexture(nil, "BORDER")
self.Background.TopLeft:SetWidth(self.LeftWidth)
self.Background.TopLeft:SetHeight(self.TopHeight)
self.Background.TopLeft:SetPoint("TOPLEFT", self, "TOPLEFT", -self.LeftMargin, self.TopMargin)
self.Background.TopLeft:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft")
self.Background.TopLeft:SetTexCoord(0, self.TexCoordX1, 0, self.TexCoordY1)
self.Background.TopRight = self:CreateTexture(nil, "BORDER")
self.Background.TopRight:SetWidth(self.RightWidth)
self.Background.TopRight:SetHeight(self.TopHeight)
self.Background.TopRight:SetPoint("TOPRIGHT", self, "TOPRIGHT", self.RightMargin, self.TopMargin)
self.Background.TopRight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopRight")
self.Background.TopRight:SetTexCoord(self.TexCoordX2, self.TexCoordX3, 0, self.TexCoordY1)
self.Background.BottomLeft = self:CreateTexture(nil, "BORDER")
self.Background.BottomLeft:SetWidth(self.LeftWidth)
self.Background.BottomLeft:SetHeight(self.BottomHeight)
self.Background.BottomLeft:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", -self.LeftMargin, -self.BottomMargin)
self.Background.BottomLeft:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomLeft")
self.Background.BottomLeft:SetTexCoord(0, self.TexCoordX1, self.TexCoordY2, self.TexCoordY3)
self.Background.BottomRight = self:CreateTexture(nil, "BORDER")
self.Background.BottomRight:SetWidth(self.RightWidth)
self.Background.BottomRight:SetHeight(self.BottomHeight)
self.Background.BottomRight:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", self.RightMargin, -self.BottomMargin)
self.Background.BottomRight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomRight")
self.Background.BottomRight:SetTexCoord(self.TexCoordX2, self.TexCoordX3, self.TexCoordY2, self.TexCoordY3)
self.Background.TopMiddle = self:CreateTexture(nil, "BORDER")
self.Background.TopMiddle:SetHeight(self.TopHeight)
self.Background.TopMiddle:SetPoint("TOPLEFT", self.Background.TopLeft, "TOPRIGHT")
self.Background.TopMiddle:SetPoint("TOPRIGHT", self.Background.TopRight, "TOPLEFT")
self.Background.TopMiddle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft")
self.Background.TopMiddle:SetTexCoord(self.TexCoordX1, 1, 0, self.TexCoordY1)
self.Background.BottomMiddle = self:CreateTexture(nil, "BORDER")
self.Background.BottomMiddle:SetHeight(self.BottomHeight)
self.Background.BottomMiddle:SetPoint("TOPLEFT", self.Background.BottomLeft, "TOPRIGHT")
self.Background.BottomMiddle:SetPoint("TOPRIGHT", self.Background.BottomRight, "TOPLEFT")
self.Background.BottomMiddle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomLeft")
self.Background.BottomMiddle:SetTexCoord(self.TexCoordX1, 1, self.TexCoordY2, self.TexCoordY3)
self.Background.LeftMiddle = self:CreateTexture(nil, "BORDER")
self.Background.LeftMiddle:SetWidth(self.LeftWidth)
self.Background.LeftMiddle:SetPoint("TOPLEFT", self.Background.TopLeft, "BOTTOMLEFT")
self.Background.LeftMiddle:SetPoint("BOTTOMLEFT", self.Background.BottomLeft, "TOPLEFT")
self.Background.LeftMiddle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft")
self.Background.LeftMiddle:SetTexCoord(0, self.TexCoordX1, self.TexCoordY1, 1)
self.Background.RightMiddle = self:CreateTexture(nil, "BORDER")
self.Background.RightMiddle:SetWidth(self.RightWidth)
self.Background.RightMiddle:SetPoint("TOPRIGHT", self.Background.TopRight, "BOTTOMRIGHT")
self.Background.RightMiddle:SetPoint("BOTTOMRIGHT", self.Background.BottomRight, "TOPRIGHT")
self.Background.RightMiddle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopRight")
self.Background.RightMiddle:SetTexCoord(self.TexCoordX2, self.TexCoordX3, self.TexCoordY1, 1)
self.Background.Middle = self:CreateTexture(nil, "BORDER")
self.Background.Middle:SetPoint("TOPLEFT", self.Background.TopLeft, "BOTTOMRIGHT")
self.Background.Middle:SetPoint("TOPRIGHT", self.Background.TopRight, "BOTTOMLEFT")
self.Background.Middle:SetPoint("BOTTOMLEFT", self.Background.BottomLeft, "TOPRIGHT")
self.Background.Middle:SetPoint("BOTTOMRIGHT", self.Background.BottomRight, "TOPLEFT")
self.Background.Middle:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft")
self.Background.Middle:SetTexCoord(self.TexCoordX1, 1, self.TexCoordY1, 1)
self.CloseButton = Outfitter:NewCloseButton(self)
self.CloseButton:SetPoint("TOPRIGHT", self, "TOPRIGHT", -3, -3)
end
function Outfitter:NewCloseButton(pParent)
local vButton = CreateFrame("Button", nil, pParent)
local vTexture
vButton:SetWidth(17)
vButton:SetHeight(17)
local vTexture
vButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up")
vTexture = vButton:GetNormalTexture()
vTexture:SetTexCoord(0.1875, 0.78125, 0.21875, 0.78125)
vButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down")
vTexture = vButton:GetPushedTexture()
vTexture:SetTexCoord(0.1875, 0.78125, 0.21875, 0.78125)
vButton:SetHighlightTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight")
vTexture = vButton:GetHighlightTexture()
vTexture:SetTexCoord(0.1875, 0.78125, 0.21875, 0.78125)
vTexture:SetBlendMode("ADD")
return vButton
end
function Outfitter.CursorInFrame(pFrame)
local vCursorX, vCursorY = GetCursorPosition()
return Outfitter.PointInFrame(pFrame, vCursorX, vCursorY)
end
function Outfitter.PointInFrame(pFrame, pPointX, pPointY)
local vLeft, vRight, vTop, vBottom = Outfitter.GetFrameEffectiveBounds(pFrame)
return pPointX >= vLeft
and pPointX < vRight
and pPointY <= vTop
and pPointY > vBottom
end
function Outfitter.GetFrameEffectiveBounds(pFrame)
local vEffectiveScale = pFrame:GetEffectiveScale()
return pFrame:GetLeft() * vEffectiveScale,
pFrame:GetRight() * vEffectiveScale,
pFrame:GetTop() * vEffectiveScale,
pFrame:GetBottom() * vEffectiveScale
end
function Outfitter:BeginMenu(pMenu)
table.insert(UIMenus, pMenu:GetName())
end
function Outfitter:EndMenu(pMenu)
local vName = pMenu:GetName()
for vIndex = #UIMenus, 1, -1 do
if vName == UIMenus[vIndex] then
table.remove(UIMenus, vIndex)
break
end
end
end
function Outfitter:FrameMouseDown(pFrame)
-- Note the position in case the user decides to drag
if not pFrame.DraggingInfo then
pFrame.DraggingInfo = {}
end
pFrame.DraggingInfo.CursorStartX, pFrame.DraggingInfo.CursorStartY = GetCursorPosition()
end
function Outfitter:StartMovingFrame(pFrame)
if not pFrame.DraggingInfo then
return
end
pFrame.DraggingInfo.StartX = pFrame:GetLeft() * pFrame:GetEffectiveScale()
pFrame.DraggingInfo.StartY = pFrame:GetTop() * pFrame:GetEffectiveScale() - UIParent:GetTop() * UIParent:GetEffectiveScale()
Outfitter.SchedulerLib:ScheduleRepeatingTask(0, self.UpdateMovingFrame, pFrame)
end
function Outfitter.UpdateMovingFrame(pFrame) -- Note this is not a method, just a function
if not pFrame.DraggingInfo then
Outfitter:FrameStopDragging(pFrame)
return
end
-- Move the frame being dragged
local vCursorX, vCursorY = GetCursorPosition()
local vCursorDeltaX = vCursorX - pFrame.DraggingInfo.CursorStartX
local vCursorDeltaY = vCursorY - pFrame.DraggingInfo.CursorStartY
--
local vPositionX = pFrame.DraggingInfo.StartX + vCursorDeltaX
local vPositionY = pFrame.DraggingInfo.StartY + vCursorDeltaY
if pFrame.DraggingInfo.PositionX ~= vPositionX
or pFrame.DraggingInfo.PositionY ~= vPositionY then
pFrame.DraggingInfo.PositionX = vPositionX
pFrame.DraggingInfo.PositionY = vPositionY
pFrame:ClearAllPoints()
pFrame:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", vPositionX / pFrame:GetEffectiveScale(), vPositionY / pFrame:GetEffectiveScale())
end
end
function Outfitter:StopMovingFrame(pFrame)
Outfitter.SchedulerLib:UnscheduleTask(self.UpdateMovingFrame, pFrame)
end
function Outfitter.SetFrameLevel(pFrame, pLevel)
pFrame:SetFrameLevel(pLevel)
local vChildren = {pFrame:GetChildren()}
for _, vChildFrame in pairs(vChildren) do
Outfitter.SetFrameLevel(vChildFrame, pLevel + 1)
end
end
function Outfitter.SetFrameStrata(pFrame, pStrata)
pFrame:SetFrameStrata(pStrata)
local vChildren = {pFrame:GetChildren()}
for _, vChildFrame in pairs(vChildren) do
Outfitter.SetFrameStrata(vChildFrame, pStrata)
end
end