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