Mercurial > wow > turok
comparison Turok/Modules/Utilities/Raid.lua @ 6:a9b8b0866ece
clear out log jam
author | Nenue |
---|---|
date | Sun, 21 Feb 2016 08:32:53 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:8a9a6637f082 | 6:a9b8b0866ece |
---|---|
1 --- Turok Raid/Raid.lua | |
2 -- @file-author@ | |
3 -- @project-revision@ @project-hash@ | |
4 -- @file-revision@ @file-hash@ | |
5 --- Defines the interfaces for raid tools | |
6 local T = Turok | |
7 local mod = T:NewModule('RaidReady') | |
8 mod.OnInitialize = function(self) | |
9 self.db = TurokData.Lost | |
10 self.events = { | |
11 PARTY_MEMBERS_CHANGED = self.MembersChangedEvent, | |
12 PLAYER_SPECIALIZATION_CHANGED = self.SpecChangeEvent, | |
13 ENCOUNTER_START = self.EncounterStart, | |
14 UNIT_AURA = self.UnitAura | |
15 } | |
16 end | |
17 | |
18 T.defaults.Lost = { | |
19 parent = 'UIParent', | |
20 anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT', | |
21 x = -300, y = 300, | |
22 height = 24*9, width = 72, | |
23 width = 72, | |
24 height = 24, | |
25 size = 11, | |
26 font = "Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Bold.ttf", | |
27 | |
28 raidbuff = { | |
29 icon = {}, | |
30 status = {}, | |
31 }, | |
32 | |
33 durability = { | |
34 | |
35 }, | |
36 | |
37 toast = { | |
38 | |
39 }, | |
40 } | |
41 local _G = _G | |
42 local print = function(...) if Devian and DevianDB.workspace~= 1 then print('RaidInfo', ...) end end | |
43 local CreateFrame, floor, GetRaidBuffTrayAuraInfo, NUM_LE_RAID_BUFF_TYPES = CreateFrame, math.floor, GetRaidBuffTrayAuraInfo, NUM_LE_RAID_BUFF_TYPES | |
44 local GetSpecialization, GetSpecializationInfo, GetSpecializationInfoByID = GetSpecialization, GetSpecializationInfo, GetSpecializationInfoByID | |
45 local IsInRaid, IsInGroup, GetInspectSpecialization = IsInRaid, IsInGroup, GetInspectSpecialization | |
46 local find, match, sub = string.find, string.match, string.sub | |
47 local GetRealmName, GetRaidRosterInfo, UnitGUID = GetRealmName, GetRaidRosterInfo, UnitGUID | |
48 local db | |
49 | |
50 function mod:OnEnable() | |
51 db = self.db | |
52 | |
53 self.raidbuffs = {} -- active raid buffs | |
54 self.buffinfo = {} -- raid buff text | |
55 self.available = {} -- availability info | |
56 self.units_raid = {} | |
57 | |
58 self.raidbuffs_tray = _G.TurokRaidbuffsTray | |
59 | |
60 -- seed raid buff analyzer assets | |
61 self.num_raidbuff_columns = floor(db.raidbuff.width / db.raidbuff.icon.width) | |
62 for i = 1, 9 do | |
63 --print('TurokRaidbuffButton'..i, self.raidbuffs_tray, 'TurokRaidbuffButton') | |
64 local buff = CreateFrame('Button', 'TurokRaidbuffButton'..i, self.raidbuffs_tray, 'TurokRaidbuffButton') | |
65 | |
66 -- T.SetFrameLayout(buff, db.raidbuff) | |
67 end | |
68 | |
69 db.raidevent = {} | |
70 | |
71 | |
72 | |
73 | |
74 end | |
75 | |
76 function mod:PLAYER_SPECIALIZATION_CHANGED(e, unit) | |
77 local specID | |
78 --print(e, unit) | |
79 if unit == 'player' then | |
80 specID = GetSpecializationInfo(GetSpecialization()) | |
81 else | |
82 --NotifyInspect(unit) | |
83 specID = GetInspectSpecialization() | |
84 end | |
85 if specID then | |
86 --print(GetSpecializationInfoByID(specID)) | |
87 end | |
88 end | |
89 | |
90 function mod:PARTY_MEMBERS_CHANGED(e, ...) | |
91 if IsInRaid() or IsInGroup() then | |
92 self.raidbuffs_frame:Show() | |
93 self:RaidBuffScan() | |
94 else | |
95 end | |
96 end | |
97 | |
98 function mod:ENCOUNTER_START(e,...) | |
99 --print(e,...) | |
100 end | |
101 | |
102 -- Updates available raid/party buffs | |
103 function mod:RaidbuffsUpdate(unit) | |
104 if not (IsInGroup() or IsInRaid()) then | |
105 self.raidbuffs_tray:Hide() | |
106 return | |
107 end | |
108 | |
109 local c = db.raidbuff | |
110 local k = 0 | |
111 for i = 1, NUM_LE_RAID_BUFF_TYPES do | |
112 | |
113 local rb = self.raidbuffs[i] | |
114 local buff = {GetRaidBuffTrayAuraInfo(i) } | |
115 --name, rank, texture, duration, expiration, spellId, slot | |
116 local isShown = false | |
117 if buff[1] then | |
118 isShown = true | |
119 self.raidbuffs[i] = buff | |
120 else | |
121 self.raidbuffs[i] = nil | |
122 end | |
123 | |
124 if isShown then | |
125 rb:Show() | |
126 rb.bufftype:SetText(sub(_G['RAID_BUFF_'..i],0,2)) | |
127 rb.spellname:SetText(self.buffinfo[i]) | |
128 | |
129 local pn = k -- need (n-1) for lua grid math | |
130 local py = floor(pn / self.num_raidbuff_columns) * c.height | |
131 local px = (pn * c.width) % db.width -- x-offset | |
132 --print('buff slot '..i..' (draw position '..k..')', pn, py, px) | |
133 rb:SetPoint(c.anchor, self.raidbuffs_tray, c.anchor, px, py) | |
134 | |
135 k = k + 1 | |
136 end | |
137 end | |
138 if k == 0 and self.raidbuffs_tray:IsVisible() then | |
139 self.raidbuffs_tray:Hide() | |
140 elseif not self.raidbuffs_tray:IsVisible() then | |
141 self.raidbuffs_tray:Show() | |
142 end | |
143 end | |
144 | |
145 function mod:RosterScan() | |
146 local lim = 1 | |
147 if IsInRaid() then | |
148 lim = 40 | |
149 elseif IsInGroup() then | |
150 lim = 5 | |
151 end | |
152 end |