Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGUI.lua
More file actions
Latest commit
696 lines (610 loc) · 21.8 KB
/
Copy pathGUI.lua
File metadata and controls
696 lines (610 loc) · 21.8 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
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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
--[[
AdiDebug - Adirelle's debug self.
Copyright 2010 Adirelle (adirelle@tagada-team.net)
All rights reserved.
--]]
localaddonName=...
localAdiDebugGUI=CreateFrame("Frame", "AdiDebugGUI", UIParent)
AdiDebugGUI:Hide()
localAdiDebug=AdiDebug
localALPHA_DELAY=0.25
-- ----------------------------------------------------------------------------
-- Scroll bar and message handling
-- ----------------------------------------------------------------------------
functionAdiDebugGUI:UpdateScrollBar()
ifself.safetyLockthenreturnend
localnumMessages, displayed=self.Messages:GetNumMessages(), self.Messages:GetNumVisibleLines()
localnewMax=max(0, numMessages-displayed)
localscrollBar=self.ScrollBar
ifnewMax>0then
self.safetyLock=true
ifnewMax~=select(2, scrollBar:GetMinMaxValues()) then
scrollBar:SetMinMaxValues(0, newMax)
end
localoffset=max(0, newMax-self.Messages:GetScrollOffset())
ifoffset~=scrollBar:GetValue() then
scrollBar:SetValue(offset)
end
self.safetyLock=false
ifnotscrollBar:IsShown() then
scrollBar:Show()
end
elseifscrollBar:IsShown() then
scrollBar:Hide()
end
end
localid=0
localcategoryIds=setmetatable({}, {__index=function(t,k)
id=id+1
t[k] =id
returnid
end})
functionAdiDebugGUI:GetCategoryId(streamId, category)
returncategoryIds[strjoin('/', streamId, category)]
end
functionAdiDebugGUI:AddMessage(category, timestamp, text)
ifnotself.db.profile.categories[self.currentStreamId][category] then
return
elseifself.searchText~=nilandnotstrmatch(text, self.searchText) then
return
end
iftimestamp~=self.currentTimestampthen
self.Messages:AddMessage(strjoin("", "----- ", date("%X", timestamp), strsub(format("%.3f", timestamp%1), 2)), 0.6, 0.6, 0.6)
self.currentTimestamp=timestamp
end
localr, g, b=unpack(self.db.profile.categoryColors[self.currentStreamId][category])
self.Messages:AddMessage(text, r, g, b, self:GetCategoryId(self.currentStreamId, category))
end
functionAdiDebugGUI:RefreshMessages()
self.Messages:Clear()
self.currentTimestamp=nil
ifself.currentStreamIdthen
fori, category, now, textinAdiDebug:IterateMessages(self.currentStreamId) do
self:AddMessage(category, now, text)
end
end
self:UpdateScrollBar()
end
functionAdiDebugGUI:SelectStream(streamId)
ifnotAdiDebug:HasStream(streamId) thenreturnend
self.db.profile.streamId=streamId
self.Selector.Text:SetText(streamIdor"")
ifstreamId==self.currentStreamIdthenreturnend
self.currentStreamId=streamId
self:RefreshMessages()
returntrue
end
-- ----------------------------------------------------------------------------
-- Selector menu handling
-- ----------------------------------------------------------------------------
localfunctionCategoryEntry_IsChecked(button)
returnAdiDebugGUI.db.profile.categories[button.arg1][button.value]
end
localfunctionCategoryEntry_OnClick(button, streamId, _, checked)
AdiDebugGUI.db.profile.categories[streamId][button.value] =checked
ifstreamId==AdiDebugGUI.currentStreamIdthen
AdiDebugGUI:RefreshMessages()
end
end
localfunctionCategoryEntry_SetColor(streamId, category, r, g, b)
ifnotAdiDebug:HasStream(streamId) thenreturnend
localc=AdiDebugGUI.db.profile.categoryColors[streamId][category]
c[1], c[2], c[3] =r, g, b
ifstreamId==AdiDebugGUI.currentStreamIdthen
localcategoryId=AdiDebugGUI:GetCategoryId(streamId, category)
AdiDebugGUI.Messages:AdjustMessageColors(function (_, _, _, _, messageId)
ifmessageId==categoryIdthen
returntrue, r, g, b
end
end)
end
end
localfunctionStreamEntry_IsChecked(button)
returnbutton.value==AdiDebugGUI.currentStreamId
end
localfunctionStreamEntry_OnClick(button)
returnAdiDebugGUI:SelectStream(button.value)
end
localfunctionStreamEntry_SetAllSelected(button, shown)
localstreamId=button.value
localdb=AdiDebugGUI.db.profile.categories[streamId]
db[streamId] =shown
forcategoryinAdiDebug:IterateCategories(streamId) do
db[category] =shown
end
ifstreamId==AdiDebugGUI.currentStreamIdthen
AdiDebugGUI:RefreshMessages()
end
end
localinfo
localentries= {}
localfunctionBuildCategoryButtons(streamId)
wipe(entries)
forcategoryinAdiDebug:IterateCategories(streamId) do
tinsert(entries, category)
end
table.sort(entries)
tinsert(entries, 1, streamId)
return#entries
end
localfunctionAddPartitionButtons(streamId, numParts, partitionSize, count)
info.hasArrow=true
info.notCheckable=true
fori=1, numPartsdo
localfirstIndex=1+ (i-1) *partitionSize
locallastIndex=math.min(count, i*partitionSize)
info.text=entries[firstIndex].." .. "..entries[lastIndex]
info.value= { streamId, firstIndex, lastIndex }
UIDropDownMenu_AddButton(info, 2)
end
end
localfunctionAddCategoryButtons(level, streamId, firstIndex, lastIndex)
info.func=CategoryEntry_OnClick
info.checked=CategoryEntry_IsChecked
info.keepShownOnClick=true
info.hasColorSwatch=true
info.isNotRadio=true
info.arg1=streamId
fori=firstIndex, lastIndexdo
localcategory=entries[i]
info.text=category
info.r, info.g, info.b=unpack(AdiDebugGUI.db.profile.categoryColors[streamId][category])
info.swatchFunc=function()
CategoryEntry_SetColor(streamId, category, ColorPickerFrame:GetColorRGB())
end
info.cancelFunc=function(values)
CategoryEntry_SetColor(streamId, category, values.r, values.g, values.b)
end
UIDropDownMenu_AddButton(info, level)
end
end
localfunctionAddSelectAllEntries(streamId)
wipe(info)
info.text="Select all"
info.value=streamId
info.notCheckable=true
info.arg1=true
info.func=StreamEntry_SetAllSelected
UIDropDownMenu_AddButton(info, 2)
info.text="Unselect all"
info.arg1=false
UIDropDownMenu_AddButton(info, 2)
end
localfunctionAddStreamButtons()
wipe(entries)
forstreamIdinAdiDebug:IterateStreams() do
tinsert(entries, streamId)
end
table.sort(entries)
info.checked=StreamEntry_IsChecked
info.func=StreamEntry_OnClick
info.hasArrow=true
fori, streamIdinipairs(entries) do
info.text=streamId
UIDropDownMenu_AddButton(info, 1)
end
end
localfunctionAddFirstLevelCategories(streamId)
localcount=BuildCategoryButtons(streamId)
localnumParts=1+math.floor(count/15)
ifnumParts>1then
localpartitionSize=math.ceil(count/numParts)
AddPartitionButtons(streamId, numParts, partitionSize, count)
else
AddCategoryButtons(2, streamId, 1, count)
end
ifcount>1then
AddSelectAllEntries(streamId)
end
end
localfunctionInitializeStreamDropdown(frame, level)
ifnotAdiDebugGUI.dbthenreturnend
info=UIDropDownMenu_CreateInfo()
iflevel==1then
AddStreamButtons()
elseiflevel==2then
AddFirstLevelCategories(UIDROPDOWNMENU_MENU_VALUE)
elseiflevel==3then
AddCategoryButtons(level, unpack(UIDROPDOWNMENU_MENU_VALUE))
end
wipe(info)
info.text="Close Menu"
info.notCheckable=true
UIDropDownMenu_AddButton(info, level)
end
-- ----------------------------------------------------------------------------
-- AdiDebug callback handlers
-- ----------------------------------------------------------------------------
functionAdiDebugGUI:AdiDebug_NewStream(event, streamId)
ifnotself.currentStreamIdandstreamId==self.db.profile.streamIdthen
self:SelectStream(streamId)
end
end
functionAdiDebugGUI:AdiDebug_NewMessage(event, streamId, category, now, text)
ifstreamId==self.currentStreamIdthen
self:AddMessage(category, now, text)
self:UpdateScrollBar()
end
end
-- ----------------------------------------------------------------------------
-- Script handlers
-- ----------------------------------------------------------------------------
functionAdiDebugGUI:OnMoverMouseDown()
ifnotself.movingOrSizingthen
localx, y=GetCursorPosition()
localscale=self:GetEffectiveScale()
localleft, bottom, width, height=self:GetRect()
x, y= (x/scale) -left, (y/scale) -bottom
localhoriz= (x<24) and"LEFT" or (x>width-24) and"RIGHT"
localvert= (y<24) and"BOTTOM" or (y>height-24) and"TOP"
ifhorizorvertthen
self:StartSizing(strjoin("", vertor"", horizor""))
else
self:StartMoving()
end
self.movingOrSizing=true
end
end
functionAdiDebugGUI:OnMoverMouseUp()
ifself.movingOrSizingthen
self.movingOrSizing=nil
self:StopMovingOrSizing()
localprofile=self.db.profile
profile.width, profile.height=self:GetSize()
local_
_, _, profile.point, profile.xOffset, profile.yOffset=self:GetPoint()
end
end
functionAdiDebugGUI:OnShow()
self:UpdateScrollBar()
end
-- ----------------------------------------------------------------------------
-- Frame/table tooltips
-- ----------------------------------------------------------------------------
localgetters= {
-- UIObject
"GetObjectType",
-- Region
"GetParent", "IsProtected", "GetRect",
-- VisibleRegion
"GetAlpha", "IsShown", "IsVisible",
-- Frame
"GetFrameStrata", "GetFrameLevel", "GetScale", "GetID", "GetNumChildren", "GetNumRegions",
"GetPropagateKeyboardInput", "IsClampedToScreen", "IsJoystickEnabled", "IsKeyboardEnabled", "IsMouseEnabled",
"IsMouseWheelEnabled", "IsMovable", "IsResizable", "IsToplevel", "IsUserPlaced",
"GetBackdrop", "GetBackdropBorderColor", "GetBackdropColor",
-- Button
"GetButtonState", "GetMotionScriptsWhileDisabled", "GetTextHeight", "GetTextWidth", "IsEnabled",
"GetDisabledTexture", "GetDisabledFontObject", "GetFontString", "GetHighlightFontObject", "GetHighlightTexture",
"GetNormalFontObject", "GetNormalTexture", "GetPushedTextOffset", "GetPushedTexture",
-- CheckButton
"GetChecked",
-- ScrollFrame
"GetHorizontalScroll", "GetHorizontalScrollRange","GetVerticalScroll", "GetVerticalScrollRange", "GetScrollChild",
-- Slider
"GetMinMaxValues", "GetOrientation", "GetThumbTexture", "GetValue", "GetValueStep",
-- StatusBar
"GetRotatesTexture", "GetStatusBarColor", "GetStatusBarTexture",
-- FontInstance
"GetFontObject", "GetJustifyH", "GetJustifyV", "GetShadowColor", "GetShadowOffset", "GetSpacing", "GetTextColor",
-- FontString
"GetFieldSize", "GetIndentedWordWrap", "GetText", "GetStringWidth", "GetStringHeight", "IsTruncated",
"CanNonSpaceWrap", "CanWordWrap",
-- Texture
"GetBlendMode", "GetNonBlocking", "GetTexture", "GetHorizTile", "GetVertTile", "IsDesaturated", "GetTexCoord", "GetVertexColor",
-- GameTooltip
"GetOwner", "GetUnit", "GetSpell", "GetItem", "IsEquippedItem",
}
localt= {}
localfunctionFormat(...)
localn=max(1, select('#', ...))
fori=1, ndo
t[i] =AdiDebug:PrettyFormat(select(i, ...), true, 30)
end
returntable.concat(t, ", ", 1, n)
end
localbools= {}
localfunctionShowUIObjectTooltip(obj)
-- We're doing duck typing there
localhaveBools=false
fori, getterinipairs(getters) do
iftype(obj[getter]) =="function" then
locallabel=strmatch(getter, "^Is(%w+)$") orstrmatch(getter, "^(Can%w+)$")
iflabelthen
haveBools=true
ifobj[getter](obj) then
tinsert(bools, label)
end
else
GameTooltip:AddDoubleLine(strmatch(getter, "^Get(%w+)$") orgetter, Format(obj[getter](obj)), nil, nil, nil, 1, 1, 1)
end
end
end
ifhaveBoolsthen
if#bools>0then
GameTooltip:AddDoubleLine("Flags", table.concat(bools, ", "), nil, nil, nil, 1, 1, 1)
wipe(bools)
else
GameTooltip:AddDoubleLine("Flags", "-", nil, nil, nil, 1, 1, 1)
end
end
end
localfunctionShowTableTooltip(value)
localmt=getmetatable(value)
setmetatable(value, nil)
GameTooltip:AddDoubleLine("Metatable", AdiDebug:PrettyFormat(mt, true), nil, nil, nil, 1, 1, 1)
localn=0
fork, vinpairs(value) do
ifn==0then
GameTooltip:AddLine("Content:")
end
ifn<10then
GameTooltip:AddDoubleLine(AdiDebug:PrettyFormat(k, true, 30), AdiDebug:PrettyFormat(v, true, 30), 1, 1, 1, 1, 1, 1)
end
n=n+1
end
ifn>10then
GameTooltip:AddLine(format("|cffaaaaaa%d more entries...|r", n-10))
end
setmetatable(value, mt)
end
-- ----------------------------------------------------------------------------
-- Widget script handlers
-- ----------------------------------------------------------------------------
localfunctionMessages_OnHyperlinkClick(self, data, link)
GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
GameTooltip:ClearLines()
localt, tableType=AdiDebug:GetTableHyperlinkTable(link)
iftthen
GameTooltip:AddDoubleLine(link, tableType)
iftableType=="table" then
ShowTableTooltip(t)
else
ShowUIObjectTooltip(t)
end
else
GameTooltip:SetHyperlink(link)
end
GameTooltip:Show()
end
localfunctionMessages_OnHyperlinkEnter(self, data, link)
GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
GameTooltip:ClearLines()
GameTooltip:AddLine(link)
local_, tableType=AdiDebug:GetTableHyperlinkTable(link)
locallinkType, linkData=strsplit(':', data, 2)
GameTooltip:AddDoubleLine("Link type", tableTypeorlinkType)
GameTooltip:AddDoubleLine("Link data", linkData)
GameTooltip:AddLine("|cffaaaaaaClick for more details.|r")
GameTooltip:Show()
end
localfunctionMessages_OnMouseWheel(self, delta)
localnum, displayed=self:GetNumMessages(), self:GetNumVisibleLines()
localstep=IsShiftKeyDown() andnumorIsControlKeyDown() anddisplayedor1
localcurrent=self:GetScrollOffset()
localnewOffset=min(max(0, current+step*delta), num-displayed)
ifnewOffset~=currentthen
self:SetScrollOffset(newOffset)
AdiDebugGUI:UpdateScrollBar()
end
end
localfunctionBackground_GetSettings()
localsettings=AdiDebugGUI.db.profile
ifsettings.autoFadeOutthen
returnAdiDebugGUI.movingOrSizingorAdiDebugGUI:IsMouseOver(), settings.opacity, 0.95
else
returntrue, 0.1, settings.opacity
end
end
localfunctionBackground_OnUpdate(self, elapsed)
localalpha, newAlpha=self:GetAlpha()
localgoMax, minAlpha, maxAlpha=Background_GetSettings()
ifgoMaxthen
newAlpha=min(maxAlpha, alpha+ (maxAlpha-minAlpha) *elapsed/ALPHA_DELAY)
else
newAlpha=max(minAlpha, alpha- (maxAlpha-minAlpha) *elapsed/ALPHA_DELAY)
end
ifnewAlpha~=alphathen
self:SetAlpha(newAlpha)
end
end
localfunctionBackground_OnShow(self)
localgoMax, minAlpha, maxAlpha=Background_GetSettings()
self:SetAlpha(goMaxandmaxAlphaorminAlpha)
end
localfunctionShowTooltipText(self)
GameTooltip:ClearLines()
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(self.tooltipText)
GameTooltip:Show()
end
-- ----------------------------------------------------------------------------
-- GUI initialization
-- ----------------------------------------------------------------------------
AdiDebugGUI:SetScript('OnShow', function(self)
self:SetSize(self.db.profile.width, self.db.profile.height)
self:SetPoint(self.db.profile.point, self.db.profile.xOffset, self.db.profile.yOffset)
self:SetClampedToScreen(true)
self:SetClampRectInsets(4,-4,-4,4)
self:SetMovable(true)
self:SetResizable(true)
self:SetFrameStrata("FULLSCREEN_DIALOG")
self:SetToplevel(true)
self:SetResizeBounds(300, 120)
self:EnableMouse(true)
self:SetScript('OnShow', self.OnShow)
----- Background -----
localbackground=CreateFrame("Frame", nil, self, 'BackdropTemplate')
background:SetAllPoints(self)
background:SetBackdrop({
bgFile=[[Interface\Addons\AdiDebug\media\white16x16]], tile=true, tileSize=16,
edgeFile=[[Interface\Tooltips\UI-Tooltip-Border]], edgeSize=16,
insets= { left=4, right=4, top=4, bottom=4 },
})
background:SetBackdropColor(0,0,0,0.9)
background:SetBackdropBorderColor(1,1,1,1)
background:SetScript('OnUpdate', Background_OnUpdate)
background:SetScript('OnShow', Background_OnShow)
Background_OnShow(background)
localfunctionAttachTooltip(target, text)
target.tooltipText=text
target:SetScript('OnEnter', ShowTooltipText)
target:SetScript('OnLeave', GameTooltip_Hide)
end
----- Moving helper -----
localmover=CreateFrame("Frame", nil, self)
mover:SetFrameLevel(200)
mover:SetAllPoints(self)
mover.Update=function()
localenable=IsModifierKeyDown()
mover:EnableMouse(enable)
mover:SetShown(enable)
end
mover:RegisterEvent('MODIFIER_STATE_CHANGED')
mover:SetScript('OnEvent', mover.Update)
mover:SetScript('OnShow', mover.Update)
mover:SetScript('OnMouseDown', function(_, ...) returnself:OnMoverMouseDown(...) end)
mover:SetScript('OnMouseUp', function(_, ...) returnself:OnMoverMouseUp(...) end)
AttachTooltip(mover, "Drag the borders and corners to resize the frame.\nDrag the center to move the frame.")
mover.Update()
----- Close button -----
localcloseButton=CreateFrame("Button", nil, background, "UIPanelCloseButton")
closeButton:SetPoint("TOPRIGHT")
closeButton:SetScript('OnClick', function() self:Hide() end)
AttachTooltip(closeButton, "Hide")
----- Stream selector -----
localselector=CreateFrame("Button", "AdiDebugDropdown", background, "UIDropDownMenuTemplate")
selector:SetPoint("TOPLEFT", -12, -4)
selector:SetWidth(145)
selector.Text=_G["AdiDebugDropdownText"]
AttachTooltip(selector, "Debugging stream\nSelect the debugging stream to watch.")
self.Selector=selector
localmenuFrame=CreateFrame("Frame", "AdiDebugDropdownMenu", nil, "UIDropDownMenuTemplate")
UIDropDownMenu_Initialize(menuFrame, InitializeStreamDropdown, "MENU")
_G["AdiDebugDropdownButton"]:SetScript('OnClick', function()
returnToggleDropDownMenu(1, nil, menuFrame, "AdiDebugDropdown", 16, 8)
end)
----- Message area -----
localmessages=CreateFrame("ScrollingMessageFrame", nil, self)
messages:SetPoint("TOPLEFT", self, "TOPLEFT", 8, -28)
messages:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -24, 8)
messages:SetFading(false)
messages:SetJustifyH("LEFT")
messages:SetMaxLines(550)
messages:SetFontObject(ChatFontNormal)
messages:SetShadowOffset(1, -1)
messages:SetShadowColor(0, 0, 0, 1)
messages:Raise()
messages:SetIndentedWordWrap(true)
messages:SetHyperlinksEnabled(true)
messages:EnableMouseWheel(true)
messages:SetScript('OnSizeChanged', UpdateScrollBar)
messages:SetScript('OnHyperlinkClick', Messages_OnHyperlinkClick)
messages:SetScript('OnHyperlinkEnter', Messages_OnHyperlinkEnter)
messages:SetScript('OnHyperlinkLeave', GameTooltip_Hide)
messages:SetScript('OnLeave', GameTooltip_Hide)
messages:SetScript('OnMouseWheel', Messages_OnMouseWheel)
self.Messages=messages
----- Scroll bar -----
localscrollBar=CreateFrame("Slider", nil, background, "UIPanelScrollBarTemplate")
scrollBar:Hide()
scrollBar:SetPoint("TOPRIGHT", self, "TOPRIGHT", -8, -44)
scrollBar:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -8, 24)
scrollBar:SetValueStep(1)
scrollBar:SetObeyStepOnDrag(true)
scrollBar.scrollStep=3
scrollBar:SetScript('OnValueChanged', function (_, value)
local_, maxValue=scrollBar:GetMinMaxValues()
messages:SetScrollOffset(maxValue-value)
end)
self.ScrollBar=scrollBar
----- Auto fade button -----
localautoFadeButton=CreateFrame("CheckButton", nil, background, "UICheckButtonTemplate")
autoFadeButton:RegisterForClicks("anyup")
autoFadeButton:SetSize(24, 24)
autoFadeButton:SetPoint("TOPRIGHT", -32, -4)
autoFadeButton:SetScript('OnClick', function(button) self.db.profile.autoFadeOut=notnotbutton:GetChecked() end)
autoFadeButton:SetChecked(self.db.profile.autoFadeOut)
AttachTooltip(autoFadeButton, "Auto fade out\nAutomatically fade out the self when the mouse cursor is not hovering it.")
----- Opacity slider -----
localopacitySlider=CreateFrame("Slider", nil, self, 'UISliderTemplate')
opacitySlider:SetSize(80, 16)
opacitySlider:SetPoint("TOPRIGHT", -64, -8)
opacitySlider:SetValueStep(0.05)
opacitySlider:SetMinMaxValues(0.1, 0.95)
opacitySlider:SetValue(self.db.profile.opacity)
opacitySlider:SetScript('OnValueChanged', function(_, value) self.db.profile.opacity=valueend)
AttachTooltip(opacitySlider, "Frame opacity\nAdjust the self opacity.\nThis is the lowest opacity if auto fading is enabled else it is the self opacity.")
----- Text search -----
localsearchBox=CreateFrame("EditBox", nil, self, "SearchBoxTemplate")
searchBox:SetSize(130, 20)
searchBox:SetPoint("TOPRIGHT", opacitySlider, "TOPLEFT", -10, 4)
searchBox:SetScript('OnTextChanged', function()
SearchBoxTemplate_OnTextChanged(searchBox)
localtext=strtrim(searchBox:GetText())
iftext=="" ortext==SEARCHthen
text=nil
end
iftext~=self.searchTextthen
self.searchText=text
self:RefreshMessages()
end
end)
AttachTooltip(searchBox, "Enter text to search in the logs.")
-- Register callbacks
AdiDebug.RegisterCallback(self, "AdiDebug_NewStream")
AdiDebug.RegisterCallback(self, "AdiDebug_NewMessage")
end)
-- ----------------------------------------------------------------------------
-- Addon initialization
-- ----------------------------------------------------------------------------
AdiDebugGUI:SetScript('OnEvent', function(self, event, name)
ifevent=='ADDON_LOADED' andname==addonNamethen
self:UnregisterEvent('ADDON_LOADED')
self:SetScript('OnEvent', nil)
self.db=AdiDebug.db:RegisterNamespace("GUI", {
profile= {
point="TOPLEFT",
xOffset=16,
yOffset=-200,
width=640,
height=400,
categories= { ['*'] = { ['*'] =true } },
categoryColors= { ['*'] = { ['*'] = { 1, 1, 1 } } },
autoFadeOut=false,
opacity=0.95,
shown=false,
}
}, true)
self.db:RegisterCallback('OnDatabaseShutdown', function()
self.db.profile.shown=self:IsShown()
end)
ifself.db.profile.shownthen
self:Show()
end
end
end)
AdiDebugGUI:RegisterEvent('ADDON_LOADED')
-- ----------------------------------------------------------------------------
-- Chat Command
-- ----------------------------------------------------------------------------
SLASH_ADIDEBUG1="/ad"
SLASH_ADIDEBUG2="/adidebug"
functionSlashCmdList.ADIDEBUG(arg)
ifstrtrim(arg) =="" then
arg=nil
end
ifnotargandAdiDebugGUI:IsShown() then
AdiDebugGUI:Hide()
return
end
AdiDebugGUI:Show()
ifargthen
arg=strlower(arg)
forstreamIdinAdiDebug:IterateStreams() do
ifstrlower(streamId) ==argthen
AdiDebugGUI:SelectStream(streamId)
end
end
end
end