Mercurial > wow > devian
comparison Devent.lua @ 107:8dc0c1917890
- Test fix for frames getting stuck in hidden state when zoning on the move
author | Nenue |
---|---|
date | Tue, 17 Oct 2017 16:57:38 -0400 |
parents | |
children | 7a36f5a92f0a |
comparison
equal
deleted
inserted
replaced
106:f8ed212558c1 | 107:8dc0c1917890 |
---|---|
1 -- | |
2 -- Created by IntelliJ IDEA. | |
3 -- User: Nick | |
4 -- Date: 4/12/2017 | |
5 -- Time: 5:07 PM | |
6 -- To change this template use File | Settings | File Templates. | |
7 -- | |
8 local tooltip = GameTooltip | |
9 local traces = {} -- frames | |
10 local eventLog = {} -- events received | |
11 local selectedEvents = {} -- events selected | |
12 local print = function(...) print('Devent', ...) end | |
13 | |
14 --print('Devent script') | |
15 --print('Devent:OnLoad()') | |
16 SLASH_DTRACE1 = "/dtrace" | |
17 | |
18 SlashCmdList.DTRACE = function(args) | |
19 if #traces == 0 then | |
20 local trace = CreateFrame('Frame', 'DevianTraceLog'.. (#traces+1), UIParent, 'DevianEventTraceTemplate') | |
21 tinsert(traces, trace) | |
22 trace:Setup() | |
23 end | |
24 | |
25 traces[1]:Show() | |
26 end | |
27 DevianEventTraceMixin = { | |
28 events = {}, | |
29 selected = {}, | |
30 } | |
31 local tracer = DevianEventTraceMixin | |
32 | |
33 function tracer:OnLoad() | |
34 self:SetMaxResize(GetScreenWidth(), GetScreenHeight()) | |
35 self:SetMinResize(100, 24) | |
36 self:EnableMouse(true) | |
37 self:RegisterForDrag('LeftButton') | |
38 self:SetMovable(true) | |
39 self:SetResizable(true) | |
40 self:SetClampedToScreen(true) | |
41 self:SetFont("Interface\\Addons\\Devian\\font\\SourceCodePro-Regular.ttf", 13, 'NORMAL') | |
42 self:SetJustifyH('LEFT') | |
43 self:SetHyperlinksEnabled(true) | |
44 self:SetPoint('CENTER') | |
45 self:SetSize(400,400) | |
46 end | |
47 | |
48 function tracer:Setup(info) | |
49 if not info then | |
50 self:RegisterAllEvents() | |
51 return | |
52 end | |
53 | |
54 for _, event in ipairs(self.events) do | |
55 self:UnregisterEvent(event) | |
56 end | |
57 | |
58 for _, event in ipairs(info.events) do | |
59 self:RegisterEvent(event) | |
60 end | |
61 end | |
62 | |
63 function tracer:OnHyperlinkEnter(linkdata, link) | |
64 local messageID = tonumber(linkdata:match('%d+')) | |
65 if messageID and self.events[messageID] then | |
66 local data = self.events[messageID] | |
67 tooltip:SetOwner(self, 'ANCHOR_RIGHT') | |
68 tooltip:AddLine(data.event) | |
69 for i, arg in ipairs(data.args) do | |
70 local argtype = data.argtypes[i] | |
71 tooltip:AddLine('|cFFAAAAAA'..tostring(argtype)..'|r ' .. tostring(arg)) | |
72 end | |
73 tooltip:Show() | |
74 end | |
75 | |
76 end | |
77 | |
78 function tracer:OnHyperlinkLeave(linkdata, link) | |
79 end | |
80 | |
81 function tracer:OnHyperlinkClick(linkdata, link) | |
82 | |
83 local messageID = tonumber(linkdata:match('%d+')) | |
84 if messageID and self.events[messageID] then | |
85 local data = self.events[messageID] | |
86 | |
87 if self.selected[data.event] then | |
88 self.selected[data.event] = nil | |
89 else | |
90 self.selected[data.event] = true | |
91 end | |
92 end | |
93 self:Update() | |
94 end | |
95 | |
96 function tracer:OnLeave() | |
97 if tooltip:IsOwned(self) then | |
98 tooltip:Hide() | |
99 end | |
100 end | |
101 | |
102 function tracer:OnEvent(event, ...) | |
103 local entry = { | |
104 index = #self.events + 1, | |
105 ts = time(), | |
106 event = event, | |
107 args = {}, | |
108 argtypes = {} | |
109 } | |
110 for i = 1, select('#', ...) do | |
111 local arg = select(i,...) | |
112 entry.argtypes[i] = type(arg) | |
113 entry.args[i] = tostring(arg) | |
114 end | |
115 self.events[entry.index] = entry | |
116 self:Update() | |
117 end | |
118 | |
119 function tracer:Update() | |
120 local startingLine = self.CurrentLine or #self.events | |
121 local prevLine | |
122 for i = 0, 20 do | |
123 local index = startingLine - i | |
124 local line = self.lines[i] | |
125 if not line then | |
126 line = self:CreateFontString('EventLine'..i) | |
127 line:SetFont([[Fonts\ARIALN__.TTF]], 14, 'THIN') | |
128 line:SetTextColor(1,1,1) | |
129 self.lines[i] = line | |
130 end | |
131 local entry = self.events[index] | |
132 | |
133 if entry then | |
134 line:SetText('|Hdevent:'..entry.index..'|h'..entry.event..'|h') | |
135 line:ClearAllPoints() | |
136 if prevLine then | |
137 line:SetPoint('BOTTOMLEFT', prevLine, 'TOPLEFT', 0, 0) | |
138 else | |
139 line:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT') | |
140 end | |
141 line:Show() | |
142 prevLine = line | |
143 else | |
144 line:Hide() | |
145 end | |
146 end | |
147 | |
148 end |