-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDevTools.lua
More file actions
103 lines (86 loc) · 2.74 KB
/
Copy pathDevTools.lua
File metadata and controls
103 lines (86 loc) · 2.74 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
-- recursive print a table
function pprint(tbl, level)
local newlevel = level or 0
newlevel = newlevel + 1
if type(tbl) ~= "table" then
print(tbl)
else
for k, v in pairs(tbl) do
if type(v) == "table" then
print(k)
pprint(v, newlevel)
else
print(string.rep(' ', newlevel), k, v)
end
end
end
end
-- convert arguments to EasyDestroy.Debug into concatenated strings
local function handler(...)
local ret = ""
for k, v in ipairs({...}) do
if tostring(v) then v = tostring(v) end
ret = ret .. v .. " "
end
return ret
end
-- send messages to the debug frame
function EasyDestroy.Debug(...)
if EasyDestroy.DebugActive then
if EasyDestroy.DebugFrame then
EasyDestroy.DebugFrame:AddMessage(date("[%H:%M:%S]") .. " " .. handler(...) .. "\n")
else
print(date(), ...)
end
end
end
-- create a frame for capturing debug messages
function EasyDestroy:CreateBG(frame, r, g, b)
local bg = frame:CreateTexture(nil, "BACKGROUND");
bg:SetAllPoints(true);
bg:SetColorTexture(r, g, b, 0.5);
end
-- My own personal hell, err, chat window for debug messages.
if EasyDestroy.DebugActive then
local f = CreateFrame("Frame", nil, UIParent, "UIPanelDialogTemplate")
f:SetPoint("CENTER")
f:SetHeight(300)
f:SetWidth(600)
f:SetMovable(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", f.StartMoving)
f:SetScript("OnDragStop", f.StopMovingOrSizing)
local c = CreateFrame("ScrollingMessageFrame", nil, f )
c:SetPoint("TOPLEFT", 10, -28)
c:SetPoint("BOTTOMRIGHT", -10, 8)
c:SetFontObject("GameFontNormal")
c:SetTextColor(1,1,1,1)
c:SetFading(false)
c:SetJustifyH("LEFT")
c:SetMaxLines(1000)
c:EnableMouseWheel(true)
c:SetScript("OnMouseWheel", FloatingChatFrame_OnMouseScroll)
c:Show()
c:AddMessage("TEST")
EasyDestroy.DebugFrame = c
function EasyDestroy.ShowDebugFrame()
f:Show()
end
local function DBG(e)
EasyDestroy.Debug(e)
end
-- Would probably be better if this went to a separate frame, but I
-- just want to see what events fire and when...
EasyDestroy.RegisterCallback(f, "ED_NEW_CRITERIA_AVAILABLE", DBG)
EasyDestroy.RegisterCallback(f, "ED_BLACKLIST_UPDATED", DBG)
EasyDestroy.RegisterCallback(f, "ED_INVENTORY_UPDATED", DBG)
EasyDestroy.RegisterCallback(f, "ED_INVENTORY_UPDATED_DELAYED", DBG)
EasyDestroy.RegisterCallback(f, "ED_FILTER_CRITERIA_CHANGED", DBG)
EasyDestroy.RegisterCallback(f, "ED_FILTER_LOADED", DBG)
EasyDestroy.RegisterCallback(f, "ED_FILTERS_AVAILABLE_CHANGED", DBG)
EasyDestroy.RegisterCallback(f, "ED_ADDON_LOADED", function ()
EasyDestroy:CreateBG(EasyDestroyFrameSearch, 1, 0, 0)
EasyDestroy:CreateBG(EasyDestroyConfiguration, 0, 1, 0)
end)
end