annotate Lost.lua @ 1:766d8a40a1d6

first commit?
author Nenue
date Tue, 15 Dec 2015 08:07:21 -0500
parents
children 9de4a810fda7
rev   line source
Nenue@1 1 -- User: Krakyn
Nenue@1 2 -- Created: 12/14/2015 3:03 PM
Nenue@1 3 local T = LibStub("AceAddon-3.0"):GetAddon("Turok")
Nenue@1 4 local TL = 'Lost'
Nenue@1 5 local print = function(...) _G.print(TL, ...) end
Nenue@1 6 local LSM = LibStub("LibSharedMedia-3.0")
Nenue@1 7 local mod = T:NewModule(TL, "AceTimer-3.0")
Nenue@1 8 local time = _G.ct
Nenue@1 9 local spell_trunc = {}
Nenue@1 10 local inv = T.anchor_inverse
Nenue@1 11 local d = T.direction_coord
Nenue@1 12 local a = T.anchor_direction
Nenue@1 13
Nenue@1 14 function mod:OnEnable()
Nenue@1 15 self.raidbuffs_active = {} -- active raid buffs
Nenue@1 16 self.raidbuffs_text = {} -- raid buff text
Nenue@1 17 self.raidbuffs_avail = {} -- availability info
Nenue@1 18 self.raidbuffs_display = {} -- buff list ordering info
Nenue@1 19 self.unit_cache = {} -- remember GUIDs we've seen before
Nenue@1 20
Nenue@1 21 local db = _G.TurokData
Nenue@1 22 db.raidbuff = {
Nenue@1 23 parent = 'UIParent',
Nenue@1 24 anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT',
Nenue@1 25 posX = -300, posY = 300,
Nenue@1 26 height = 50, width = 150,
Nenue@1 27 icon_size = 25,
Nenue@1 28 label_size = 11,
Nenue@1 29 label_font = 'ArchivoNarrow-Bold',
Nenue@1 30 }
Nenue@1 31
Nenue@1 32 local rw = CreateFrame('Frame', 'TkRaidWatch', UIParent)
Nenue@1 33 local c = db.raidbuff
Nenue@1 34 self.raid_watcher = rw
Nenue@1 35 rw:SetPoint(c.anchor, c.parent, c.anchorTo, c.posX, c.posY)
Nenue@1 36 rw:SetSize(c.width, c.height)
Nenue@1 37 rw:SetMovable(true)
Nenue@1 38 local bd = rw:CreateTexture()
Nenue@1 39 bd:SetTexture(1,1,1,1)
Nenue@1 40 bd:SetGradient('VERTICAL', 0,0,0,1,1,1)
Nenue@1 41 bd:SetBlendMode('MOD')
Nenue@1 42 bd:SetPoint('TOPLEFT',rw,'TOPLEFT', -2, 2)
Nenue@1 43 bd:SetPoint('BOTTOMRIGHT',rw,'BOTTOMRIGHT', 2, -2)
Nenue@1 44
Nenue@1 45 for i = 1, 9 do
Nenue@1 46 local icon = rw:CreateTexture('TkRaidWatchButton'..i, 'ARTWORK')
Nenue@1 47 icon:SetSize(c.icon_size,c.icon_size)
Nenue@1 48 icon:SetTexCoord(0.15, 0.85, 0.15, 0.85)
Nenue@1 49
Nenue@1 50
Nenue@1 51 self.raidbuffs_active[i] = icon
Nenue@1 52 rw:EnableMouse(true)
Nenue@1 53 rw:SetScript('OnMouseDown', function(self) self:StartMoving() end)
Nenue@1 54 rw:SetScript('OnMouseUp', function(self) self:StopMovingOrSizing() end)
Nenue@1 55
Nenue@1 56 local text = rw:CreateFontString('TkRaidWatchText'.. i, 'OVERLAY')
Nenue@1 57 text:SetPoint('CENTER', icon, 'CENTER')
Nenue@1 58 text:SetFont(LSM:Fetch('font', c.label_font), c.label_size, 'OUTLINE')
Nenue@1 59 text:SetText(i)
Nenue@1 60 self.raidbuffs_text[i] = text
Nenue@1 61 end
Nenue@1 62
Nenue@1 63
Nenue@1 64 db.raidevent = {}
Nenue@1 65
Nenue@1 66
Nenue@1 67 self:RegisterEvent('PARTY_MEMBERS_CHANGED')
Nenue@1 68 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
Nenue@1 69 self:RegisterEvent('ENCOUNTER_START')
Nenue@1 70 self:RegisterEvent('INSPECT_READY')
Nenue@1 71 self:RegisterEvent('UNIT_AURA', 'RaidBuffScan')
Nenue@1 72
Nenue@1 73 self:RaidBuffScan()
Nenue@1 74 self:RosterScan()
Nenue@1 75 end
Nenue@1 76 function mod:PLAYER_REGEN_ENABLED(e,...) end
Nenue@1 77 function mod:PLAYER_REGEN_DISABLED(e, ...) end
Nenue@1 78
Nenue@1 79 function mod:INSPECT_READY()
Nenue@1 80 end
Nenue@1 81 function mod:PLAYER_SPECIALIZATION_CHANGED(e,unit)
Nenue@1 82 local specID
Nenue@1 83 print(e, unit)
Nenue@1 84 if unit == 'player' then
Nenue@1 85 specID = GetSpecializationInfo(GetSpecialization())
Nenue@1 86 else
Nenue@1 87 --NotifyInspect(unit)
Nenue@1 88 specID = GetInspectSpecialization()
Nenue@1 89 end
Nenue@1 90
Nenue@1 91 print(GetSpecializationInfoByID(specID))
Nenue@1 92 self:RosterScan()
Nenue@1 93 end
Nenue@1 94
Nenue@1 95 function mod:PARTY_MEMBERS_CHANGED(e, ...)
Nenue@1 96 end
Nenue@1 97 function mod:ENCOUNTER_START(e,...)
Nenue@1 98 end
Nenue@1 99
Nenue@1 100 -- Updates available raid/party buffs
Nenue@1 101 function mod:RaidBuffScan(unit)
Nenue@1 102
Nenue@1 103 -- search for unit data
Nenue@1 104
Nenue@1 105 local changed = false
Nenue@1 106 local c = T.db.raidbuff
Nenue@1 107 -- update raidbuffs
Nenue@1 108 local k = 1
Nenue@1 109 for i = 1, NUM_LE_RAID_BUFF_TYPES do
Nenue@1 110 local rb = self.raidbuffs_active[i]
Nenue@1 111 local rt = self.raidbuffs_text[i]
Nenue@1 112 local name, rank, texture, duration, expiration, spellId, slot = GetRaidBuffTrayAuraInfo(i)
Nenue@1 113 if name then
Nenue@1 114 rb:Hide()
Nenue@1 115 rt:Hide()
Nenue@1 116 self.raidbuffs_display[i] = nil
Nenue@1 117 else
Nenue@1 118 rb:Show()
Nenue@1 119 rt:Show()
Nenue@1 120 if self.raidbuffs_avail[i] then
Nenue@1 121 rb:SetTexture(0.5,0.5,0.5,0.1)
Nenue@1 122 rb:SetBlendMode('MOD')
Nenue@1 123 else
Nenue@1 124 rb:SetTexture(1,0.2,0,0.5)
Nenue@1 125 rb:SetBlendMode('ADD')
Nenue@1 126 end
Nenue@1 127 self.raidbuffs_text[i]:SetText(string.sub(_G['RAID_BUFF_'..i],0,2))
Nenue@1 128
Nenue@1 129 if not self.raidbuffs_display[i] or self.raidbuffs_display[i] ~= k then
Nenue@1 130 self.raidbuffs_display[i] = k
Nenue@1 131 local axis_a, axis_b = c.icon_size, c.width
Nenue@1 132 local w = axis_a * (k-1) % axis_b
Nenue@1 133 local h = math.floor((k-1) / (axis_b / axis_a)) * axis_a
Nenue@1 134 print(axis_a, axis_b, w, h)
Nenue@1 135 rb:SetPoint('BOTTOMLEFT', TkRaidWatch, 'BOTTOMLEFT', w, h)
Nenue@1 136 end
Nenue@1 137
Nenue@1 138 k = k + 1
Nenue@1 139 end
Nenue@1 140 end
Nenue@1 141 end
Nenue@1 142
Nenue@1 143 function mod:RosterScan()
Nenue@1 144 local lim = 1
Nenue@1 145 if IsInRaid() then
Nenue@1 146 lim = 40
Nenue@1 147 elseif IsInGroup() then
Nenue@1 148 lim = 5
Nenue@1 149 end
Nenue@1 150
Nenue@1 151 for i = 1, lim do
Nenue@1 152 local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
Nenue@1 153 if name then
Nenue@1 154 if string.find(name,'-') then
Nenue@1 155 name, realm = string.match(name, "(.+)-(.+)")
Nenue@1 156 else
Nenue@1 157 realm = GetRealmName()
Nenue@1 158 end
Nenue@1 159
Nenue@1 160 print(i, name, class, role)
Nenue@1 161 end
Nenue@1 162
Nenue@1 163 end
Nenue@1 164
Nenue@1 165 end