Nenue@1
|
1 -- User: Krakyn
|
Nenue@1
|
2 -- Created: 12/14/2015 3:03 PM
|
Nenue@1
|
3 local T = LibStub("AceAddon-3.0"):GetAddon("Turok")
|
Nenue@1
|
4 local TL = 'Lost'
|
Nenue@1
|
5 local print = function(...) _G.print(TL, ...) end
|
Nenue@1
|
6 local LSM = LibStub("LibSharedMedia-3.0")
|
Nenue@1
|
7 local mod = T:NewModule(TL, "AceTimer-3.0")
|
Nenue@1
|
8 local time = _G.ct
|
Nenue@1
|
9 local spell_trunc = {}
|
Nenue@1
|
10 local inv = T.anchor_inverse
|
Nenue@1
|
11 local d = T.direction_coord
|
Nenue@1
|
12 local a = T.anchor_direction
|
Nenue@1
|
13
|
Nenue@3
|
14 mod.encounter_start = {
|
Nenue@3
|
15 ['Aspect'] = {
|
Nenue@3
|
16 type = 'buff',
|
Nenue@3
|
17
|
Nenue@3
|
18 Test = function()
|
Nenue@3
|
19 local res = UnitBuff('player', 'Aspect of the Pack', nil, 'PLAYER')
|
Nenue@3
|
20 return (res ~= nil)
|
Nenue@3
|
21 end,
|
Nenue@3
|
22 sound = LSM:Fetch('sound', 'Wilhelm Scream'),
|
Nenue@3
|
23 },
|
Nenue@3
|
24 ['Rune'] = {
|
Nenue@3
|
25 Test = function()
|
Nenue@3
|
26 local res = UnitBuff('player', 'Hyper Augmentation', nil, 'PLAYER')
|
Nenue@3
|
27 return (res ~= nil)
|
Nenue@3
|
28 end
|
Nenue@3
|
29 }
|
Nenue@3
|
30 }
|
Nenue@3
|
31
|
Nenue@1
|
32 function mod:OnEnable()
|
Nenue@1
|
33 self.raidbuffs_active = {} -- active raid buffs
|
Nenue@1
|
34 self.raidbuffs_text = {} -- raid buff text
|
Nenue@1
|
35 self.raidbuffs_avail = {} -- availability info
|
Nenue@1
|
36 self.raidbuffs_display = {} -- buff list ordering info
|
Nenue@1
|
37 self.unit_cache = {} -- remember GUIDs we've seen before
|
Nenue@3
|
38 self.raidbuffs_shown = NUM_LE_RAID_BUFF_TYPES
|
Nenue@3
|
39
|
Nenue@1
|
40
|
Nenue@1
|
41 local db = _G.TurokData
|
Nenue@1
|
42 db.raidbuff = {
|
Nenue@1
|
43 parent = 'UIParent',
|
Nenue@1
|
44 anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT',
|
Nenue@1
|
45 posX = -300, posY = 300,
|
Nenue@3
|
46 height = 24*9, width = 72,
|
Nenue@3
|
47 raidbuff_width = 72,
|
Nenue@3
|
48 raidbuff_height = 24,
|
Nenue@1
|
49 label_size = 11,
|
Nenue@1
|
50 label_font = 'ArchivoNarrow-Bold',
|
Nenue@1
|
51 }
|
Nenue@1
|
52
|
Nenue@3
|
53
|
Nenue@3
|
54
|
Nenue@1
|
55 local rw = CreateFrame('Frame', 'TkRaidWatch', UIParent)
|
Nenue@1
|
56 local c = db.raidbuff
|
Nenue@3
|
57 self.raidbuffs_frame = rw
|
Nenue@1
|
58 rw:SetPoint(c.anchor, c.parent, c.anchorTo, c.posX, c.posY)
|
Nenue@1
|
59 rw:SetSize(c.width, c.height)
|
Nenue@1
|
60 rw:SetMovable(true)
|
Nenue@1
|
61 local bd = rw:CreateTexture()
|
Nenue@1
|
62 bd:SetTexture(1,1,1,1)
|
Nenue@1
|
63 bd:SetGradient('VERTICAL', 0,0,0,1,1,1)
|
Nenue@1
|
64 bd:SetBlendMode('MOD')
|
Nenue@1
|
65 bd:SetPoint('TOPLEFT',rw,'TOPLEFT', -2, 2)
|
Nenue@1
|
66 bd:SetPoint('BOTTOMRIGHT',rw,'BOTTOMRIGHT', 2, -2)
|
Nenue@1
|
67
|
Nenue@3
|
68 -- seed raid buff analyzer assets
|
Nenue@3
|
69 self.num_raidbuff_columns = math.floor(c.width / c.raidbuff_width)
|
Nenue@1
|
70 for i = 1, 9 do
|
Nenue@1
|
71 local icon = rw:CreateTexture('TkRaidWatchButton'..i, 'ARTWORK')
|
Nenue@3
|
72 icon:SetSize(c.raidbuff_width,c.raidbuff_height)
|
Nenue@1
|
73 icon:SetTexCoord(0.15, 0.85, 0.15, 0.85)
|
Nenue@1
|
74
|
Nenue@1
|
75
|
Nenue@1
|
76 self.raidbuffs_active[i] = icon
|
Nenue@1
|
77 rw:EnableMouse(true)
|
Nenue@1
|
78 rw:SetScript('OnMouseDown', function(self) self:StartMoving() end)
|
Nenue@1
|
79 rw:SetScript('OnMouseUp', function(self) self:StopMovingOrSizing() end)
|
Nenue@1
|
80
|
Nenue@1
|
81 local text = rw:CreateFontString('TkRaidWatchText'.. i, 'OVERLAY')
|
Nenue@1
|
82 text:SetPoint('CENTER', icon, 'CENTER')
|
Nenue@1
|
83 text:SetFont(LSM:Fetch('font', c.label_font), c.label_size, 'OUTLINE')
|
Nenue@1
|
84 text:SetText(i)
|
Nenue@1
|
85 self.raidbuffs_text[i] = text
|
Nenue@1
|
86 end
|
Nenue@1
|
87
|
Nenue@1
|
88 db.raidevent = {}
|
Nenue@1
|
89
|
Nenue@1
|
90
|
Nenue@1
|
91 self:RegisterEvent('PARTY_MEMBERS_CHANGED')
|
Nenue@1
|
92 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
|
Nenue@1
|
93 self:RegisterEvent('ENCOUNTER_START')
|
Nenue@1
|
94 self:RegisterEvent('INSPECT_READY')
|
Nenue@1
|
95 self:RegisterEvent('UNIT_AURA', 'RaidBuffScan')
|
Nenue@1
|
96
|
Nenue@1
|
97 self:RaidBuffScan()
|
Nenue@1
|
98 self:RosterScan()
|
Nenue@1
|
99 end
|
Nenue@1
|
100 function mod:PLAYER_REGEN_ENABLED(e,...) end
|
Nenue@1
|
101 function mod:PLAYER_REGEN_DISABLED(e, ...) end
|
Nenue@1
|
102
|
Nenue@1
|
103 function mod:INSPECT_READY()
|
Nenue@1
|
104 end
|
Nenue@1
|
105 function mod:PLAYER_SPECIALIZATION_CHANGED(e,unit)
|
Nenue@1
|
106 local specID
|
Nenue@1
|
107 print(e, unit)
|
Nenue@1
|
108 if unit == 'player' then
|
Nenue@1
|
109 specID = GetSpecializationInfo(GetSpecialization())
|
Nenue@1
|
110 else
|
Nenue@1
|
111 --NotifyInspect(unit)
|
Nenue@1
|
112 specID = GetInspectSpecialization()
|
Nenue@1
|
113 end
|
Nenue@1
|
114
|
Nenue@1
|
115 print(GetSpecializationInfoByID(specID))
|
Nenue@1
|
116 self:RosterScan()
|
Nenue@1
|
117 end
|
Nenue@1
|
118
|
Nenue@1
|
119 function mod:PARTY_MEMBERS_CHANGED(e, ...)
|
Nenue@3
|
120 if IsInRaid() or IsInGroup() then
|
Nenue@3
|
121 self.raidbuffs_frame:Show()
|
Nenue@3
|
122 self:RaidBuffScan()
|
Nenue@3
|
123 end
|
Nenue@1
|
124 end
|
Nenue@3
|
125
|
Nenue@1
|
126 function mod:ENCOUNTER_START(e,...)
|
Nenue@3
|
127 for k, v in pairs(self.encounter_start) do
|
Nenue@3
|
128 local test, info = v.Test()
|
Nenue@3
|
129 if test == true then
|
Nenue@3
|
130 print(v.type, k, 'doing a thing')
|
Nenue@3
|
131 else
|
Nenue@3
|
132 print(v.type, k, info)
|
Nenue@3
|
133 end
|
Nenue@3
|
134 end
|
Nenue@1
|
135 end
|
Nenue@1
|
136
|
Nenue@1
|
137 -- Updates available raid/party buffs
|
Nenue@1
|
138 function mod:RaidBuffScan(unit)
|
Nenue@3
|
139 if self.hiding then
|
Nenue@3
|
140 return
|
Nenue@3
|
141 end
|
Nenue@3
|
142 local c = T.db.raidbuff
|
Nenue@1
|
143
|
Nenue@1
|
144 -- search for unit data
|
Nenue@3
|
145 -- update raidbuffs
|
Nenue@1
|
146
|
Nenue@3
|
147 -- set our number of things to track
|
Nenue@3
|
148
|
Nenue@1
|
149 local k = 1
|
Nenue@1
|
150 for i = 1, NUM_LE_RAID_BUFF_TYPES do
|
Nenue@1
|
151 local rb = self.raidbuffs_active[i]
|
Nenue@1
|
152 local rt = self.raidbuffs_text[i]
|
Nenue@1
|
153 local name, rank, texture, duration, expiration, spellId, slot = GetRaidBuffTrayAuraInfo(i)
|
Nenue@1
|
154 if name then
|
Nenue@1
|
155 rb:Hide()
|
Nenue@1
|
156 rt:Hide()
|
Nenue@1
|
157 self.raidbuffs_display[i] = nil
|
Nenue@1
|
158 else
|
Nenue@1
|
159 rb:Show()
|
Nenue@1
|
160 rt:Show()
|
Nenue@1
|
161 if self.raidbuffs_avail[i] then
|
Nenue@1
|
162 rb:SetTexture(0.5,0.5,0.5,0.1)
|
Nenue@1
|
163 rb:SetBlendMode('MOD')
|
Nenue@1
|
164 else
|
Nenue@1
|
165 rb:SetTexture(1,0.2,0,0.5)
|
Nenue@1
|
166 rb:SetBlendMode('ADD')
|
Nenue@1
|
167 end
|
Nenue@1
|
168 self.raidbuffs_text[i]:SetText(string.sub(_G['RAID_BUFF_'..i],0,2))
|
Nenue@1
|
169
|
Nenue@1
|
170 if not self.raidbuffs_display[i] or self.raidbuffs_display[i] ~= k then
|
Nenue@1
|
171 self.raidbuffs_display[i] = k
|
Nenue@3
|
172 local pn = k-1 -- need (n-1) for lua grid math
|
Nenue@3
|
173 local py = math.floor(pn / self.num_raidbuff_columns) * c.raidbuff_height
|
Nenue@3
|
174 local px = (pn * c.raidbuff_width) % c.width -- x-offset
|
Nenue@3
|
175 print('buff slot '..i..' (draw slot '..k..')', pn, py, px)
|
Nenue@3
|
176 rb:SetPoint('BOTTOMLEFT', TkRaidWatch, 'BOTTOMLEFT', px, py)
|
Nenue@1
|
177 end
|
Nenue@1
|
178
|
Nenue@1
|
179 k = k + 1
|
Nenue@1
|
180 end
|
Nenue@1
|
181 end
|
Nenue@1
|
182 end
|
Nenue@1
|
183
|
Nenue@1
|
184 function mod:RosterScan()
|
Nenue@1
|
185 local lim = 1
|
Nenue@1
|
186 if IsInRaid() then
|
Nenue@1
|
187 lim = 40
|
Nenue@1
|
188 elseif IsInGroup() then
|
Nenue@1
|
189 lim = 5
|
Nenue@1
|
190 end
|
Nenue@1
|
191
|
Nenue@1
|
192 for i = 1, lim do
|
Nenue@1
|
193 local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
|
Nenue@3
|
194 local realm
|
Nenue@1
|
195 if name then
|
Nenue@1
|
196 if string.find(name,'-') then
|
Nenue@1
|
197 name, realm = string.match(name, "(.+)-(.+)")
|
Nenue@1
|
198 else
|
Nenue@1
|
199 realm = GetRealmName()
|
Nenue@1
|
200 end
|
Nenue@1
|
201
|
Nenue@3
|
202 local GUID = UnitGUID('raid' .. i)
|
Nenue@3
|
203 if not self.unit_cache[GUID] then
|
Nenue@3
|
204 self.unit_cache[GUID] = {
|
Nenue@3
|
205 name = name,
|
Nenue@3
|
206 realm = realm,
|
Nenue@3
|
207 }
|
Nenue@3
|
208 end
|
Nenue@3
|
209
|
Nenue@3
|
210 pl = self.unit_cache[GUID]
|
Nenue@3
|
211
|
Nenue@3
|
212
|
Nenue@1
|
213 print(i, name, class, role)
|
Nenue@1
|
214 end
|
Nenue@1
|
215
|
Nenue@1
|
216 end
|
Nenue@1
|
217
|
Nenue@1
|
218 end |