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@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@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@1: height = 50, width = 150, Nenue@1: icon_size = 25, Nenue@1: label_size = 11, Nenue@1: label_font = 'ArchivoNarrow-Bold', Nenue@1: } Nenue@1: Nenue@1: local rw = CreateFrame('Frame', 'TkRaidWatch', UIParent) Nenue@1: local c = db.raidbuff Nenue@1: self.raid_watcher = 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@1: for i = 1, 9 do Nenue@1: local icon = rw:CreateTexture('TkRaidWatchButton'..i, 'ARTWORK') Nenue@1: icon:SetSize(c.icon_size,c.icon_size) 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: 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@1: end Nenue@1: function mod:ENCOUNTER_START(e,...) Nenue@1: end Nenue@1: Nenue@1: -- Updates available raid/party buffs Nenue@1: function mod:RaidBuffScan(unit) Nenue@1: Nenue@1: -- search for unit data Nenue@1: Nenue@1: local changed = false Nenue@1: local c = T.db.raidbuff Nenue@1: -- update raidbuffs 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@1: local axis_a, axis_b = c.icon_size, c.width Nenue@1: local w = axis_a * (k-1) % axis_b Nenue@1: local h = math.floor((k-1) / (axis_b / axis_a)) * axis_a Nenue@1: print(axis_a, axis_b, w, h) Nenue@1: rb:SetPoint('BOTTOMLEFT', TkRaidWatch, 'BOTTOMLEFT', w, h) 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@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@1: print(i, name, class, role) Nenue@1: end Nenue@1: Nenue@1: end Nenue@1: Nenue@1: end