Nenue@1: -- User: Krakyn Nenue@1: -- Created: 12/14/2015 3:03 PM Nenue@1: local T = LibStub("AceAddon-3.0"):GetAddon("Turok") Nenue@1: local TL = 'Lost' Nenue@1: local print = function(...) _G.print(TL, ...) end Nenue@1: local LSM = LibStub("LibSharedMedia-3.0") Nenue@1: local mod = T:NewModule(TL, "AceTimer-3.0") Nenue@1: local time = _G.ct Nenue@1: local spell_trunc = {} Nenue@1: local inv = T.anchor_inverse Nenue@1: local d = T.direction_coord Nenue@1: local a = T.anchor_direction Nenue@1: Nenue@3: mod.encounter_start = { Nenue@3: ['Aspect'] = { Nenue@3: type = 'buff', Nenue@3: Nenue@3: Test = function() Nenue@3: local res = UnitBuff('player', 'Aspect of the Pack', nil, 'PLAYER') Nenue@3: return (res ~= nil) Nenue@3: end, Nenue@3: sound = LSM:Fetch('sound', 'Wilhelm Scream'), Nenue@3: }, Nenue@3: ['Rune'] = { Nenue@3: Test = function() Nenue@3: local res = UnitBuff('player', 'Hyper Augmentation', nil, 'PLAYER') Nenue@3: return (res ~= nil) Nenue@3: end Nenue@3: } Nenue@3: } Nenue@3: Nenue@1: function mod:OnEnable() Nenue@1: self.raidbuffs_active = {} -- active raid buffs Nenue@1: self.raidbuffs_text = {} -- raid buff text Nenue@1: self.raidbuffs_avail = {} -- availability info Nenue@1: self.raidbuffs_display = {} -- buff list ordering info Nenue@1: self.unit_cache = {} -- remember GUIDs we've seen before Nenue@3: self.raidbuffs_shown = NUM_LE_RAID_BUFF_TYPES Nenue@3: Nenue@1: Nenue@1: local db = _G.TurokData Nenue@1: db.raidbuff = { Nenue@1: parent = 'UIParent', Nenue@1: anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT', Nenue@1: posX = -300, posY = 300, Nenue@3: height = 24*9, width = 72, Nenue@3: raidbuff_width = 72, Nenue@3: raidbuff_height = 24, Nenue@1: label_size = 11, Nenue@1: label_font = 'ArchivoNarrow-Bold', Nenue@1: } Nenue@1: Nenue@3: Nenue@3: Nenue@1: local rw = CreateFrame('Frame', 'TkRaidWatch', UIParent) Nenue@1: local c = db.raidbuff Nenue@3: self.raidbuffs_frame = rw Nenue@1: rw:SetPoint(c.anchor, c.parent, c.anchorTo, c.posX, c.posY) Nenue@1: rw:SetSize(c.width, c.height) Nenue@1: rw:SetMovable(true) Nenue@1: local bd = rw:CreateTexture() Nenue@1: bd:SetTexture(1,1,1,1) Nenue@1: bd:SetGradient('VERTICAL', 0,0,0,1,1,1) Nenue@1: bd:SetBlendMode('MOD') Nenue@1: bd:SetPoint('TOPLEFT',rw,'TOPLEFT', -2, 2) Nenue@1: bd:SetPoint('BOTTOMRIGHT',rw,'BOTTOMRIGHT', 2, -2) Nenue@1: Nenue@3: -- seed raid buff analyzer assets Nenue@3: self.num_raidbuff_columns = math.floor(c.width / c.raidbuff_width) Nenue@1: for i = 1, 9 do Nenue@1: local icon = rw:CreateTexture('TkRaidWatchButton'..i, 'ARTWORK') Nenue@3: icon:SetSize(c.raidbuff_width,c.raidbuff_height) Nenue@1: icon:SetTexCoord(0.15, 0.85, 0.15, 0.85) Nenue@1: Nenue@1: Nenue@1: self.raidbuffs_active[i] = icon Nenue@1: rw:EnableMouse(true) Nenue@1: rw:SetScript('OnMouseDown', function(self) self:StartMoving() end) Nenue@1: rw:SetScript('OnMouseUp', function(self) self:StopMovingOrSizing() end) Nenue@1: Nenue@1: local text = rw:CreateFontString('TkRaidWatchText'.. i, 'OVERLAY') Nenue@1: text:SetPoint('CENTER', icon, 'CENTER') Nenue@1: text:SetFont(LSM:Fetch('font', c.label_font), c.label_size, 'OUTLINE') Nenue@1: text:SetText(i) Nenue@1: self.raidbuffs_text[i] = text Nenue@1: end Nenue@1: Nenue@1: db.raidevent = {} Nenue@1: Nenue@1: Nenue@1: self:RegisterEvent('PARTY_MEMBERS_CHANGED') Nenue@1: self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') Nenue@1: self:RegisterEvent('ENCOUNTER_START') Nenue@1: self:RegisterEvent('INSPECT_READY') Nenue@1: self:RegisterEvent('UNIT_AURA', 'RaidBuffScan') Nenue@1: Nenue@1: self:RaidBuffScan() Nenue@1: self:RosterScan() Nenue@1: end Nenue@1: function mod:PLAYER_REGEN_ENABLED(e,...) end Nenue@1: function mod:PLAYER_REGEN_DISABLED(e, ...) end Nenue@1: Nenue@1: function mod:INSPECT_READY() Nenue@1: end Nenue@1: function mod:PLAYER_SPECIALIZATION_CHANGED(e,unit) Nenue@1: local specID Nenue@1: print(e, unit) Nenue@1: if unit == 'player' then Nenue@1: specID = GetSpecializationInfo(GetSpecialization()) Nenue@1: else Nenue@1: --NotifyInspect(unit) Nenue@1: specID = GetInspectSpecialization() Nenue@1: end Nenue@1: Nenue@1: print(GetSpecializationInfoByID(specID)) Nenue@1: self:RosterScan() Nenue@1: end Nenue@1: Nenue@1: function mod:PARTY_MEMBERS_CHANGED(e, ...) Nenue@3: if IsInRaid() or IsInGroup() then Nenue@3: self.raidbuffs_frame:Show() Nenue@3: self:RaidBuffScan() Nenue@3: end Nenue@1: end Nenue@3: Nenue@1: function mod:ENCOUNTER_START(e,...) Nenue@3: for k, v in pairs(self.encounter_start) do Nenue@3: local test, info = v.Test() Nenue@3: if test == true then Nenue@3: print(v.type, k, 'doing a thing') Nenue@3: else Nenue@3: print(v.type, k, info) Nenue@3: end Nenue@3: end Nenue@1: end Nenue@1: Nenue@1: -- Updates available raid/party buffs Nenue@1: function mod:RaidBuffScan(unit) Nenue@3: if self.hiding then Nenue@3: return Nenue@3: end Nenue@3: local c = T.db.raidbuff Nenue@1: Nenue@1: -- search for unit data Nenue@3: -- update raidbuffs Nenue@1: Nenue@3: -- set our number of things to track Nenue@3: Nenue@1: local k = 1 Nenue@1: for i = 1, NUM_LE_RAID_BUFF_TYPES do Nenue@1: local rb = self.raidbuffs_active[i] Nenue@1: local rt = self.raidbuffs_text[i] Nenue@1: local name, rank, texture, duration, expiration, spellId, slot = GetRaidBuffTrayAuraInfo(i) Nenue@1: if name then Nenue@1: rb:Hide() Nenue@1: rt:Hide() Nenue@1: self.raidbuffs_display[i] = nil Nenue@1: else Nenue@1: rb:Show() Nenue@1: rt:Show() Nenue@1: if self.raidbuffs_avail[i] then Nenue@1: rb:SetTexture(0.5,0.5,0.5,0.1) Nenue@1: rb:SetBlendMode('MOD') Nenue@1: else Nenue@1: rb:SetTexture(1,0.2,0,0.5) Nenue@1: rb:SetBlendMode('ADD') Nenue@1: end Nenue@1: self.raidbuffs_text[i]:SetText(string.sub(_G['RAID_BUFF_'..i],0,2)) Nenue@1: Nenue@1: if not self.raidbuffs_display[i] or self.raidbuffs_display[i] ~= k then Nenue@1: self.raidbuffs_display[i] = k Nenue@3: local pn = k-1 -- need (n-1) for lua grid math Nenue@3: local py = math.floor(pn / self.num_raidbuff_columns) * c.raidbuff_height Nenue@3: local px = (pn * c.raidbuff_width) % c.width -- x-offset Nenue@3: print('buff slot '..i..' (draw slot '..k..')', pn, py, px) Nenue@3: rb:SetPoint('BOTTOMLEFT', TkRaidWatch, 'BOTTOMLEFT', px, py) Nenue@1: end Nenue@1: Nenue@1: k = k + 1 Nenue@1: end Nenue@1: end Nenue@1: end Nenue@1: Nenue@1: function mod:RosterScan() Nenue@1: local lim = 1 Nenue@1: if IsInRaid() then Nenue@1: lim = 40 Nenue@1: elseif IsInGroup() then Nenue@1: lim = 5 Nenue@1: end Nenue@1: Nenue@1: for i = 1, lim do Nenue@1: local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i) Nenue@3: local realm Nenue@1: if name then Nenue@1: if string.find(name,'-') then Nenue@1: name, realm = string.match(name, "(.+)-(.+)") Nenue@1: else Nenue@1: realm = GetRealmName() Nenue@1: end Nenue@1: Nenue@3: local GUID = UnitGUID('raid' .. i) Nenue@3: if not self.unit_cache[GUID] then Nenue@3: self.unit_cache[GUID] = { Nenue@3: name = name, Nenue@3: realm = realm, Nenue@3: } Nenue@3: end Nenue@3: Nenue@3: pl = self.unit_cache[GUID] Nenue@3: Nenue@3: Nenue@1: print(i, name, class, role) Nenue@1: end Nenue@1: Nenue@1: end Nenue@1: Nenue@1: end