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