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