annotate Turok/Modules/Utilities/Raid.lua @ 6:a9b8b0866ece

clear out log jam
author Nenue
date Sun, 21 Feb 2016 08:32:53 -0500
parents
children
rev   line source
Nenue@6 1 --- Turok Raid/Raid.lua
Nenue@6 2 -- @file-author@
Nenue@6 3 -- @project-revision@ @project-hash@
Nenue@6 4 -- @file-revision@ @file-hash@
Nenue@6 5 --- Defines the interfaces for raid tools
Nenue@6 6 local T = Turok
Nenue@6 7 local mod = T:NewModule('RaidReady')
Nenue@6 8 mod.OnInitialize = function(self)
Nenue@6 9 self.db = TurokData.Lost
Nenue@6 10 self.events = {
Nenue@6 11 PARTY_MEMBERS_CHANGED = self.MembersChangedEvent,
Nenue@6 12 PLAYER_SPECIALIZATION_CHANGED = self.SpecChangeEvent,
Nenue@6 13 ENCOUNTER_START = self.EncounterStart,
Nenue@6 14 UNIT_AURA = self.UnitAura
Nenue@6 15 }
Nenue@6 16 end
Nenue@6 17
Nenue@6 18 T.defaults.Lost = {
Nenue@6 19 parent = 'UIParent',
Nenue@6 20 anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT',
Nenue@6 21 x = -300, y = 300,
Nenue@6 22 height = 24*9, width = 72,
Nenue@6 23 width = 72,
Nenue@6 24 height = 24,
Nenue@6 25 size = 11,
Nenue@6 26 font = "Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Bold.ttf",
Nenue@6 27
Nenue@6 28 raidbuff = {
Nenue@6 29 icon = {},
Nenue@6 30 status = {},
Nenue@6 31 },
Nenue@6 32
Nenue@6 33 durability = {
Nenue@6 34
Nenue@6 35 },
Nenue@6 36
Nenue@6 37 toast = {
Nenue@6 38
Nenue@6 39 },
Nenue@6 40 }
Nenue@6 41 local _G = _G
Nenue@6 42 local print = function(...) if Devian and DevianDB.workspace~= 1 then print('RaidInfo', ...) end end
Nenue@6 43 local CreateFrame, floor, GetRaidBuffTrayAuraInfo, NUM_LE_RAID_BUFF_TYPES = CreateFrame, math.floor, GetRaidBuffTrayAuraInfo, NUM_LE_RAID_BUFF_TYPES
Nenue@6 44 local GetSpecialization, GetSpecializationInfo, GetSpecializationInfoByID = GetSpecialization, GetSpecializationInfo, GetSpecializationInfoByID
Nenue@6 45 local IsInRaid, IsInGroup, GetInspectSpecialization = IsInRaid, IsInGroup, GetInspectSpecialization
Nenue@6 46 local find, match, sub = string.find, string.match, string.sub
Nenue@6 47 local GetRealmName, GetRaidRosterInfo, UnitGUID = GetRealmName, GetRaidRosterInfo, UnitGUID
Nenue@6 48 local db
Nenue@6 49
Nenue@6 50 function mod:OnEnable()
Nenue@6 51 db = self.db
Nenue@6 52
Nenue@6 53 self.raidbuffs = {} -- active raid buffs
Nenue@6 54 self.buffinfo = {} -- raid buff text
Nenue@6 55 self.available = {} -- availability info
Nenue@6 56 self.units_raid = {}
Nenue@6 57
Nenue@6 58 self.raidbuffs_tray = _G.TurokRaidbuffsTray
Nenue@6 59
Nenue@6 60 -- seed raid buff analyzer assets
Nenue@6 61 self.num_raidbuff_columns = floor(db.raidbuff.width / db.raidbuff.icon.width)
Nenue@6 62 for i = 1, 9 do
Nenue@6 63 --print('TurokRaidbuffButton'..i, self.raidbuffs_tray, 'TurokRaidbuffButton')
Nenue@6 64 local buff = CreateFrame('Button', 'TurokRaidbuffButton'..i, self.raidbuffs_tray, 'TurokRaidbuffButton')
Nenue@6 65
Nenue@6 66 -- T.SetFrameLayout(buff, db.raidbuff)
Nenue@6 67 end
Nenue@6 68
Nenue@6 69 db.raidevent = {}
Nenue@6 70
Nenue@6 71
Nenue@6 72
Nenue@6 73
Nenue@6 74 end
Nenue@6 75
Nenue@6 76 function mod:PLAYER_SPECIALIZATION_CHANGED(e, unit)
Nenue@6 77 local specID
Nenue@6 78 --print(e, unit)
Nenue@6 79 if unit == 'player' then
Nenue@6 80 specID = GetSpecializationInfo(GetSpecialization())
Nenue@6 81 else
Nenue@6 82 --NotifyInspect(unit)
Nenue@6 83 specID = GetInspectSpecialization()
Nenue@6 84 end
Nenue@6 85 if specID then
Nenue@6 86 --print(GetSpecializationInfoByID(specID))
Nenue@6 87 end
Nenue@6 88 end
Nenue@6 89
Nenue@6 90 function mod:PARTY_MEMBERS_CHANGED(e, ...)
Nenue@6 91 if IsInRaid() or IsInGroup() then
Nenue@6 92 self.raidbuffs_frame:Show()
Nenue@6 93 self:RaidBuffScan()
Nenue@6 94 else
Nenue@6 95 end
Nenue@6 96 end
Nenue@6 97
Nenue@6 98 function mod:ENCOUNTER_START(e,...)
Nenue@6 99 --print(e,...)
Nenue@6 100 end
Nenue@6 101
Nenue@6 102 -- Updates available raid/party buffs
Nenue@6 103 function mod:RaidbuffsUpdate(unit)
Nenue@6 104 if not (IsInGroup() or IsInRaid()) then
Nenue@6 105 self.raidbuffs_tray:Hide()
Nenue@6 106 return
Nenue@6 107 end
Nenue@6 108
Nenue@6 109 local c = db.raidbuff
Nenue@6 110 local k = 0
Nenue@6 111 for i = 1, NUM_LE_RAID_BUFF_TYPES do
Nenue@6 112
Nenue@6 113 local rb = self.raidbuffs[i]
Nenue@6 114 local buff = {GetRaidBuffTrayAuraInfo(i) }
Nenue@6 115 --name, rank, texture, duration, expiration, spellId, slot
Nenue@6 116 local isShown = false
Nenue@6 117 if buff[1] then
Nenue@6 118 isShown = true
Nenue@6 119 self.raidbuffs[i] = buff
Nenue@6 120 else
Nenue@6 121 self.raidbuffs[i] = nil
Nenue@6 122 end
Nenue@6 123
Nenue@6 124 if isShown then
Nenue@6 125 rb:Show()
Nenue@6 126 rb.bufftype:SetText(sub(_G['RAID_BUFF_'..i],0,2))
Nenue@6 127 rb.spellname:SetText(self.buffinfo[i])
Nenue@6 128
Nenue@6 129 local pn = k -- need (n-1) for lua grid math
Nenue@6 130 local py = floor(pn / self.num_raidbuff_columns) * c.height
Nenue@6 131 local px = (pn * c.width) % db.width -- x-offset
Nenue@6 132 --print('buff slot '..i..' (draw position '..k..')', pn, py, px)
Nenue@6 133 rb:SetPoint(c.anchor, self.raidbuffs_tray, c.anchor, px, py)
Nenue@6 134
Nenue@6 135 k = k + 1
Nenue@6 136 end
Nenue@6 137 end
Nenue@6 138 if k == 0 and self.raidbuffs_tray:IsVisible() then
Nenue@6 139 self.raidbuffs_tray:Hide()
Nenue@6 140 elseif not self.raidbuffs_tray:IsVisible() then
Nenue@6 141 self.raidbuffs_tray:Show()
Nenue@6 142 end
Nenue@6 143 end
Nenue@6 144
Nenue@6 145 function mod:RosterScan()
Nenue@6 146 local lim = 1
Nenue@6 147 if IsInRaid() then
Nenue@6 148 lim = 40
Nenue@6 149 elseif IsInGroup() then
Nenue@6 150 lim = 5
Nenue@6 151 end
Nenue@6 152 end