Nenue@6: --- Turok Raid/Raid.lua Nenue@6: -- @file-author@ Nenue@6: -- @project-revision@ @project-hash@ Nenue@6: -- @file-revision@ @file-hash@ Nenue@6: --- Defines the interfaces for raid tools Nenue@6: local T = Turok Nenue@6: local mod = T:NewModule('RaidReady') Nenue@6: mod.OnInitialize = function(self) Nenue@6: self.db = TurokData.Lost Nenue@6: self.events = { Nenue@6: PARTY_MEMBERS_CHANGED = self.MembersChangedEvent, Nenue@6: PLAYER_SPECIALIZATION_CHANGED = self.SpecChangeEvent, Nenue@6: ENCOUNTER_START = self.EncounterStart, Nenue@6: UNIT_AURA = self.UnitAura Nenue@6: } Nenue@6: end Nenue@6: Nenue@6: T.defaults.Lost = { Nenue@6: parent = 'UIParent', Nenue@6: anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT', Nenue@6: x = -300, y = 300, Nenue@6: height = 24*9, width = 72, Nenue@6: width = 72, Nenue@6: height = 24, Nenue@6: size = 11, Nenue@6: font = "Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Bold.ttf", Nenue@6: Nenue@6: raidbuff = { Nenue@6: icon = {}, Nenue@6: status = {}, Nenue@6: }, Nenue@6: Nenue@6: durability = { Nenue@6: Nenue@6: }, Nenue@6: Nenue@6: toast = { Nenue@6: Nenue@6: }, Nenue@6: } Nenue@6: local _G = _G Nenue@6: local print = function(...) if Devian and DevianDB.workspace~= 1 then print('RaidInfo', ...) end end Nenue@6: local CreateFrame, floor, GetRaidBuffTrayAuraInfo, NUM_LE_RAID_BUFF_TYPES = CreateFrame, math.floor, GetRaidBuffTrayAuraInfo, NUM_LE_RAID_BUFF_TYPES Nenue@6: local GetSpecialization, GetSpecializationInfo, GetSpecializationInfoByID = GetSpecialization, GetSpecializationInfo, GetSpecializationInfoByID Nenue@6: local IsInRaid, IsInGroup, GetInspectSpecialization = IsInRaid, IsInGroup, GetInspectSpecialization Nenue@6: local find, match, sub = string.find, string.match, string.sub Nenue@6: local GetRealmName, GetRaidRosterInfo, UnitGUID = GetRealmName, GetRaidRosterInfo, UnitGUID Nenue@6: local db Nenue@6: Nenue@6: function mod:OnEnable() Nenue@6: db = self.db Nenue@6: Nenue@6: self.raidbuffs = {} -- active raid buffs Nenue@6: self.buffinfo = {} -- raid buff text Nenue@6: self.available = {} -- availability info Nenue@6: self.units_raid = {} Nenue@6: Nenue@6: self.raidbuffs_tray = _G.TurokRaidbuffsTray Nenue@6: Nenue@6: -- seed raid buff analyzer assets Nenue@6: self.num_raidbuff_columns = floor(db.raidbuff.width / db.raidbuff.icon.width) Nenue@6: for i = 1, 9 do Nenue@6: --print('TurokRaidbuffButton'..i, self.raidbuffs_tray, 'TurokRaidbuffButton') Nenue@6: local buff = CreateFrame('Button', 'TurokRaidbuffButton'..i, self.raidbuffs_tray, 'TurokRaidbuffButton') Nenue@6: Nenue@6: -- T.SetFrameLayout(buff, db.raidbuff) Nenue@6: end Nenue@6: Nenue@6: db.raidevent = {} Nenue@6: Nenue@6: Nenue@6: Nenue@6: Nenue@6: end Nenue@6: Nenue@6: function mod:PLAYER_SPECIALIZATION_CHANGED(e, unit) Nenue@6: local specID Nenue@6: --print(e, unit) Nenue@6: if unit == 'player' then Nenue@6: specID = GetSpecializationInfo(GetSpecialization()) Nenue@6: else Nenue@6: --NotifyInspect(unit) Nenue@6: specID = GetInspectSpecialization() Nenue@6: end Nenue@6: if specID then Nenue@6: --print(GetSpecializationInfoByID(specID)) Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: function mod:PARTY_MEMBERS_CHANGED(e, ...) Nenue@6: if IsInRaid() or IsInGroup() then Nenue@6: self.raidbuffs_frame:Show() Nenue@6: self:RaidBuffScan() Nenue@6: else Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: function mod:ENCOUNTER_START(e,...) Nenue@6: --print(e,...) Nenue@6: end Nenue@6: Nenue@6: -- Updates available raid/party buffs Nenue@6: function mod:RaidbuffsUpdate(unit) Nenue@6: if not (IsInGroup() or IsInRaid()) then Nenue@6: self.raidbuffs_tray:Hide() Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: local c = db.raidbuff Nenue@6: local k = 0 Nenue@6: for i = 1, NUM_LE_RAID_BUFF_TYPES do Nenue@6: Nenue@6: local rb = self.raidbuffs[i] Nenue@6: local buff = {GetRaidBuffTrayAuraInfo(i) } Nenue@6: --name, rank, texture, duration, expiration, spellId, slot Nenue@6: local isShown = false Nenue@6: if buff[1] then Nenue@6: isShown = true Nenue@6: self.raidbuffs[i] = buff Nenue@6: else Nenue@6: self.raidbuffs[i] = nil Nenue@6: end Nenue@6: Nenue@6: if isShown then Nenue@6: rb:Show() Nenue@6: rb.bufftype:SetText(sub(_G['RAID_BUFF_'..i],0,2)) Nenue@6: rb.spellname:SetText(self.buffinfo[i]) Nenue@6: Nenue@6: local pn = k -- need (n-1) for lua grid math Nenue@6: local py = floor(pn / self.num_raidbuff_columns) * c.height Nenue@6: local px = (pn * c.width) % db.width -- x-offset Nenue@6: --print('buff slot '..i..' (draw position '..k..')', pn, py, px) Nenue@6: rb:SetPoint(c.anchor, self.raidbuffs_tray, c.anchor, px, py) Nenue@6: Nenue@6: k = k + 1 Nenue@6: end Nenue@6: end Nenue@6: if k == 0 and self.raidbuffs_tray:IsVisible() then Nenue@6: self.raidbuffs_tray:Hide() Nenue@6: elseif not self.raidbuffs_tray:IsVisible() then Nenue@6: self.raidbuffs_tray:Show() Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: function mod:RosterScan() Nenue@6: local lim = 1 Nenue@6: if IsInRaid() then Nenue@6: lim = 40 Nenue@6: elseif IsInGroup() then Nenue@6: lim = 5 Nenue@6: end Nenue@6: end