Mercurial > wow > turok
diff Lost.lua @ 1:766d8a40a1d6
first commit?
author | Nenue |
---|---|
date | Tue, 15 Dec 2015 08:07:21 -0500 |
parents | |
children | 9de4a810fda7 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lost.lua Tue Dec 15 08:07:21 2015 -0500 @@ -0,0 +1,165 @@ +-- 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 + +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 + + local db = _G.TurokData + db.raidbuff = { + parent = 'UIParent', + anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT', + posX = -300, posY = 300, + height = 50, width = 150, + icon_size = 25, + label_size = 11, + label_font = 'ArchivoNarrow-Bold', + } + + local rw = CreateFrame('Frame', 'TkRaidWatch', UIParent) + local c = db.raidbuff + self.raid_watcher = 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) + + for i = 1, 9 do + local icon = rw:CreateTexture('TkRaidWatchButton'..i, 'ARTWORK') + icon:SetSize(c.icon_size,c.icon_size) + 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, ...) +end +function mod:ENCOUNTER_START(e,...) +end + +-- Updates available raid/party buffs +function mod:RaidBuffScan(unit) + + -- search for unit data + + local changed = false + local c = T.db.raidbuff + -- update raidbuffs + 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 axis_a, axis_b = c.icon_size, c.width + local w = axis_a * (k-1) % axis_b + local h = math.floor((k-1) / (axis_b / axis_a)) * axis_a + print(axis_a, axis_b, w, h) + rb:SetPoint('BOTTOMLEFT', TkRaidWatch, 'BOTTOMLEFT', w, h) + 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) + if name then + if string.find(name,'-') then + name, realm = string.match(name, "(.+)-(.+)") + else + realm = GetRealmName() + end + + print(i, name, class, role) + end + + end + +end \ No newline at end of file