vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | aUF = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceHook-2.0", "AceDB-2.0", "AceConsole-2.0") |
2 | aUF.Layouts = {} |
||
3 | |||
4 | local L = AceLibrary("AceLocale-2.0"):new("ag_UnitFrames") |
||
5 | local AceOO = AceLibrary("AceOO-2.0") |
||
6 | |||
7 | local print = function(msg) if msg then DEFAULT_CHAT_FRAME:AddMessage(msg) end end |
||
8 | |||
9 | -- SYSTEM |
||
10 | |||
11 | function aUF:OnInitialize() |
||
12 | self:RegisterDB("aUFDB") |
||
13 | self:RegisterDefaults('profile', aUF_DEFAULT_OPTIONS) |
||
14 | |||
15 | self:SetupVariables() |
||
16 | self:UpdateBlizzVisibility() |
||
17 | self:InitMenu() |
||
18 | self:RegisterEvents() |
||
19 | self:LoadStringFormats() |
||
20 | if UnitInRaid("player") == 1 then |
||
21 | self:RAID_ROSTER_UPDATE() |
||
22 | end |
||
23 | aUF:ScheduleRepeatingEvent("agUF_auraPoolSchedule",self.AuraPool, 0.3, self) |
||
24 | end |
||
25 | |||
26 | function aUF:AuraPool() |
||
27 | local n = 0 |
||
28 | for k,v in pairs(self.auraUpdatePool) do |
||
29 | if v == true and self.auraUpdates + n < 5 then |
||
30 | self.units[k]:UpdateAuras(true) |
||
31 | n = n + 1 |
||
32 | else |
||
33 | break |
||
34 | end |
||
35 | end |
||
36 | aUF.auraUpdates = 0 |
||
37 | end |
||
38 | |||
39 | function aUF:Reset() |
||
40 | self:ResetDB("profile") |
||
41 | self:LoadStringFormats() |
||
42 | self:CallUnitMethods("Reset") |
||
43 | self:CallUnitMethods("Reset",nil,nil,nil,"subgroups") |
||
44 | end |
||
45 | |||
46 | function aUF:OnProfileEnable() |
||
47 | self:CallUnitMethods("Reset") |
||
48 | end |
||
49 | |||
50 | -- EVENT REGISTERING |
||
51 | |||
52 | function aUF:RegisterEvents() |
||
53 | self:RegisterEvent("PLAYER_LOGIN") |
||
54 | self:RegisterEvent("PARTY_MEMBERS_CHANGED") |
||
55 | self:RegisterEvent("RAID_ROSTER_UPDATE") |
||
56 | self:RegisterEvent("UNIT_PET","PARTY_MEMBERS_CHANGED") |
||
57 | self:RegisterEvent("PLAYER_TARGET_CHANGED") |
||
58 | |||
59 | self:RegisterEvent("agUF_UpdateGroups") |
||
60 | end |
||
61 | |||
62 | function aUF:SetupVariables() |
||
63 | self.auraUpdates = 0 |
||
64 | self.auraUpdatePool = {} |
||
65 | |||
66 | self.feedback = {} |
||
67 | |||
68 | self.imagePath = "Interface\\AddOns\\ag_UnitFrames\\images\\" |
||
69 | self.fontPath = "Interface\\AddOns\\ag_UnitFrames\\fonts\\" |
||
70 | |||
71 | self.wowClasses = {"player","pet","party","partypet","target","targettarget","raid","raidpet"} |
||
72 | |||
73 | -- Which auras can the player see? |
||
74 | self.CanDispel = { |
||
75 | ["PRIEST"] = { |
||
76 | ["Magic"] = true, |
||
77 | ["Disease"] = true, |
||
78 | }, |
||
79 | ["SHAMAN"] = { |
||
80 | ["Poison"] = true, |
||
81 | ["Disease"] = true, |
||
82 | }, |
||
83 | ["PALADIN"] = { |
||
84 | ["Magic"] = true, |
||
85 | ["Poison"] = true, |
||
86 | ["Disease"] = true, |
||
87 | }, |
||
88 | ["MAGE"] = { |
||
89 | ["Curse"] = true, |
||
90 | }, |
||
91 | ["DRUID"] = { |
||
92 | ["Curse"] = true, |
||
93 | ["Poison"] = true, |
||
94 | } |
||
95 | } |
||
96 | |||
97 | -- Various constants like colors, textures... |
||
98 | |||
99 | self.DebuffColor = { |
||
100 | ["Magic"] = { |
||
101 | r = 1, |
||
102 | g = 0, |
||
103 | b = 0, |
||
104 | }, |
||
105 | ["Disease"] = { |
||
106 | r = 0.25, |
||
107 | g = 1, |
||
108 | b = 0, |
||
109 | }, |
||
110 | ["Poison"] = { |
||
111 | r = 0, |
||
112 | g = 0.25, |
||
113 | b = 1, |
||
114 | }, |
||
115 | ["Curse"] = { |
||
116 | r = 0.75, |
||
117 | g = 0, |
||
118 | b = 0.75, |
||
119 | } |
||
120 | } |
||
121 | |||
122 | self.RepColor = { |
||
123 | [1] = {r = 226/255, g = 45/255, b = 75/255}, |
||
124 | [2] = {r = 226/255, g = 45/255, b = 75/255}, |
||
125 | [3] = {r = 0.75, g = 0.27, b = 0}, |
||
126 | [4] = {r = 1, g = 1, b = 34/255}, |
||
127 | [5] = {r = 0.2, g = 0.8, b = 0.15}, |
||
128 | [6] = {r = 0.2, g = 0.8, b = 0.15}, |
||
129 | [7] = {r = 0.2, g = 0.8, b = 0.15}, |
||
130 | [8] = {r = 0.2, g = 0.8, b = 0.15}, |
||
131 | } |
||
132 | |||
133 | self.HealthColor = { |
||
134 | r = 0.11, |
||
135 | g = 0.84, |
||
136 | b = 0.3, |
||
137 | } |
||
138 | |||
139 | self.ManaColor = { |
||
140 | [0] = { r = 48/255, g = 113/255, b = 191/255}, -- Mana |
||
141 | [1] = { r = 226/255, g = 45/255, b = 75/255}, -- Rage |
||
142 | [2] = { r = 255/255, g = 210/255, b = 0}, -- Focus |
||
143 | [3] = { r = 255, g = 220/255, b = 25/255}, -- Energy |
||
144 | [4] = { r = 0.00, g = 1.00, b = 1.00} -- Happiness |
||
145 | } |
||
146 | |||
147 | self.Borders = { |
||
148 | ["Classic"] = {["texture"] = "Interface\\Tooltips\\UI-Tooltip-Border",["size"] = 16,["insets"] = 5}, |
||
149 | ["Nurfed"] = {["texture"] = "Interface\\DialogFrame\\UI-DialogBox-Border",["size"] = 16,["insets"] = 5}, |
||
150 | ["Hidden"] = {["texture"] = "",["size"] = 0,["insets"] = 3}, |
||
151 | } |
||
152 | self.Bars = { |
||
153 | ["Default"] = self.imagePath.."AceBarFrames.tga", |
||
154 | ["Classic"] = "Interface\\TargetingFrame\\UI-StatusBar", |
||
155 | ["Smooth"] = self.imagePath.."smooth.tga", |
||
156 | ["Bumps"] = self.imagePath.."Bumps.tga", |
||
157 | ["Perl"] = self.imagePath.."Perl.tga", |
||
158 | ["Gloss"] = self.imagePath.."Gloss.tga", |
||
159 | ["Wisps"] = self.imagePath.."Wisps.tga", |
||
160 | ["Bars"] = self.imagePath.."Bars.tga", |
||
161 | ["Smudge"] = self.imagePath.."Smudge.tga", |
||
162 | ["Dabs"] = self.imagePath.."Dabs.tga", |
||
163 | ["Rain"] = self.imagePath.."Rain.tga", |
||
164 | ["Hatched"] = self.imagePath.."Hatched.tga", |
||
165 | ["Cracked"] = self.imagePath.."Cracked.tga", |
||
166 | ["Grid"] = self.imagePath.."Grid.tga", |
||
167 | ["Button"] = self.imagePath.."Button.tga", |
||
168 | ["Skewed"] = self.imagePath.."Skewed.tga", |
||
169 | ["Diagonal"] = self.imagePath.."Diagonal.tga", |
||
170 | ["Cloud"] = self.imagePath.."Cloud.tga", |
||
171 | ["Water"] = self.imagePath.."Water.tga", |
||
172 | ["Charcoal"] = self.imagePath.."Charcoal.tga", |
||
173 | ["BantoBar"] = self.imagePath.."BantoBar.tga", |
||
174 | } |
||
175 | |||
176 | self.RaidColors = { |
||
177 | ["DRUID"] = "|cffff7c0a", |
||
178 | ["HUNTER"] = "|cffaad372", |
||
179 | ["MAGE"] = "|cff68ccef", |
||
180 | ["PALADIN"] = "|cfff48cba", |
||
181 | ["PRIEST"] = "|cffffffff", |
||
182 | ["ROGUE"] = "|cfffff468", |
||
183 | ["SHAMAN"] = "|cfff48cba", |
||
184 | ["WARLOCK"] = "|cff9382C9", |
||
185 | ["WARRIOR"] = "|cffc69b6d", |
||
186 | } |
||
187 | |||
188 | self.RaidRole = { |
||
189 | ["DRUID"] = "healer", |
||
190 | ["HUNTER"] = "dps", |
||
191 | ["MAGE"] = "dps", |
||
192 | ["PALADIN"] = "healer", |
||
193 | ["PRIEST"] = "healer", |
||
194 | ["ROGUE"] = "dps", |
||
195 | ["SHAMAN"] = "healer", |
||
196 | ["WARLOCK"] = "dps", |
||
197 | ["WARRIOR"] = "tank", |
||
198 | } |
||
199 | |||
200 | self.UnitInformation = { |
||
201 | ["name"] = function(u) local type = string.gsub(u, "%d", "") if self.db.profile[type].RaidColorName and UnitIsPlayer(u) then local _,x=UnitClass(u) return string.format("%s%s%s",aUF.RaidColors[x] or "",UnitName(u) or "","|cFFFFFFFF") else return UnitName(u) or "" end end, |
||
202 | |||
203 | ["status"] = function (u) if UnitIsDead(u) then return "Dead" elseif UnitIsGhost(u) then return "Ghost" elseif (not UnitIsConnected(u)) then return "Offline" elseif (UnitAffectingCombat(u)) then return "Combat" elseif (u== "player" and IsResting()) then return "Resting" else return "" end end, |
||
204 | ["statuscolor"] = function (u) if UnitIsDead(u) then return "|cffff0000" elseif UnitIsGhost(u) then return "|cff9d9d9d" elseif (not UnitIsConnected(u)) then return "|cffff8000" elseif (UnitAffectingCombat(u)) then return "|cffFF0000" elseif (u== "player" and IsResting()) then return WatchDog:GetHex(UnitReactionColor[4]) else return "" end end, |
||
205 | ["happycolor"] = function (u) local x=GetPetHappiness() return ( (x==2) and "|cffFFFF00" or (x==1) and "|cffFF0000" or "" ) end, |
||
206 | |||
207 | ["aghp"] = function(u) return self:Tag_aghp(u) or "" end, |
||
208 | ["agpercenthp"] = function(u) return self:Tag_aghp(u,1) or "" end, |
||
209 | ["agmissinghp"] = function(u) return self:Tag_aghp(u,2) or "" end, |
||
210 | ["agsmarthp"] = function(u) return self:Tag_aghp(u,3) or "" end, |
||
211 | |||
212 | ["agmana"] = function(u) return self:Tag_agmana(u) or "" end, |
||
213 | ["agpercentmana"] = function(u) return self:Tag_agmana(u,1) or "" end, |
||
214 | ["agmissingmana"] = function(u) return self:Tag_agmana(u,2) or "" end, |
||
215 | ["agsmartmana"] = function(u) return self:Tag_agmana(u,3) or "" end, |
||
216 | |||
217 | ["agclass"] = function (u) if UnitIsPlayer(u) then return (UnitClass(u) or "Unknown") else return (UnitCreatureFamily(u) or UnitCreatureType(u) or "") end end, |
||
218 | ["agrace"] = function (u) if string.find(u,"target") then return UnitRace(u) or "" else return "" end end, |
||
219 | ["agtype"] = function (u) if (UnitIsPlusMob(u)) then return aUF:TargetGetMobType(u) or "" else return "" end end, |
||
220 | |||
221 | ["curhp"] = function (u) return UnitHealth(u) or 0 end, |
||
222 | ["maxhp"] = function (u) return UnitHealthMax(u) or 1 end, |
||
223 | ["percenthp"] = function (u) local hpmax = UnitHealthMax(u) return (hpmax ~= 0) and floor((UnitHealth(u) / hpmax) * 100) or 0 end, |
||
224 | ["missinghp"] = function (u) return UnitHealthMax(u) - UnitHealth(u) or 0 end, |
||
225 | |||
226 | ["curmana"] = function (u) return UnitMana(u) or 1 end, |
||
227 | ["maxmana"] = function (u) return UnitManaMax(u) or 0 end, |
||
228 | ["percentmana"] = function (u) local mpmax = UnitManaMax(u) return (mpmax ~= 0) and floor((UnitMana(u) / mpmax) * 100) or 0 end, |
||
229 | ["missingmana"] = function (u) return UnitHealthMax(u) - UnitHealth(u) or 0 end, |
||
230 | |||
231 | ["typemana"] = function (u) local p=UnitPowerType(u) return ( (p==1) and "Rage" or (p==2) and "Focus" or (p==3) and "Energy" or "Mana" ) end, |
||
232 | ["level"] = function (u) local x = UnitLevel(u) return ((x>0) and x or "??") end, |
||
233 | ["class"] = function (u) return (UnitClass(u) or "Unknown") end, |
||
234 | ["creature"] = function (u) return (UnitCreatureFamily(u) or UnitCreatureType(u) or "Unknown") end, |
||
235 | ["smartclass"] = function (u) if UnitIsPlayer(u) then return self.UnitInformation["class"](u) else return self.UnitInformation["creature"](u) end end, |
||
236 | ["combos"] = function (u) return (GetComboPoints() or 0) end, |
||
237 | ["combos2"] = function (u) return string.rep("@", GetComboPoints()) end, |
||
238 | ["classification"] = function (u) if UnitClassification(u) == "rare" then return "Rare " elseif UnitClassification(u) == "eliterare" then return "Rare Elite " elseif UnitClassification(u) == "elite" then return "Elite " elseif UnitClassification(u) == "worldboss" then return "Boss " else return "" end end, |
||
239 | ["faction"] = function (u) return (UnitFactionGroup(u) or "") end, |
||
240 | ["connect"] = function (u) return ( (UnitIsConnected(u)) and "" or "Offline" ) end, |
||
241 | ["race"] = function (u) return ( UnitRace(u) or "") end, |
||
242 | ["pvp"] = function (u) return ( UnitIsPVP(u) and "PvP" or "" ) end, |
||
243 | ["plus"] = function (u) return ( UnitIsPlusMob(u) and "+" or "" ) end, |
||
244 | ["sex"] = function (u) local x = UnitSex(u) return ( (x==0) and "Male" or (x==1) and "Female" or "" ) end, |
||
245 | ["rested"] = function (u) return (GetRestState()==1 and "Rested" or "") end, |
||
246 | ["leader"] = function (u) return (UnitIsPartyLeader(u) and "(L)" or "") end, |
||
247 | ["leaderlong"] = function (u) return (UnitIsPartyLeader(u) and "(Leader)" or "") end, |
||
248 | |||
249 | ["happynum"] = function (u) return (GetPetHappiness() or 0) end, |
||
250 | ["happytext"] = function (u) return ( getglobal("PET_HAPPINESS"..(GetPetHappiness() or 0)) or "" ) end, |
||
251 | ["happyicon"] = function (u) local x=GetPetHappiness() return ( (x==3) and ":)" or (x==2) and ":|" or (x==1) and ":(" or "" ) end, |
||
252 | |||
253 | ["curxp"] = function (u) return (UnitXP(u) or "") end, |
||
254 | ["maxxp"] = function (u) return (UnitXPMax(u) or "") end, |
||
255 | ["percentxp"] = function (u) local x=UnitXPMax(u) if (x>0) then return floor( UnitXP(u)/x*100+0.5) else return 0 end end, |
||
256 | ["missingxp"] = function (u) return (UnitXPMax(u) - UnitXP(u)) end, |
||
257 | ["restedxp"] = function (u) return (GetXPExhaustion() or "") end, |
||
258 | |||
259 | ["tappedbyme"] = function (u) if UnitIsTappedByPlayer("target") then return "*" else return "" end end, |
||
260 | ["istapped"] = function (u) if UnitIsTapped(u) and (not UnitIsTappedByPlayer("target")) then return "*" else return "" end end, |
||
261 | ["pvpranknum"] = function (u) if (UnitPVPRank(u) >= 1) then return ((UnitPVPRank(u)-4) or "") else return "" end end, |
||
262 | ["pvprank"] = function (u) if (UnitPVPRank(u) >= 1) then return (GetPVPRankInfo(UnitPVPRank(u), u) or "" ) else return "" end end, |
||
263 | ["fkey"] = function (u) |
||
264 | local _,_,fkey = string.find(u, "^party(%d)$") |
||
265 | if u == "player" then |
||
266 | fkey = 0 |
||
267 | end |
||
268 | if not fkey then |
||
269 | return "" |
||
270 | else |
||
271 | return "F"..(fkey+1) |
||
272 | end |
||
273 | end, |
||
274 | ["white"] = function (u) return "|cFFFFFFFF" end, |
||
275 | ["aggro"] = function (u) |
||
276 | local x = (UnitReaction("player",u) or 5) |
||
277 | return self:GiveHex(UnitReactionColor[x].r, UnitReactionColor[x].g, UnitReactionColor[x].b) |
||
278 | end, |
||
279 | ["difficulty"] = function (u) if UnitCanAttack("player",u) then local x = (UnitLevel(u)>0) and UnitLevel(u) or 99 local color = GetDifficultyColor(x) return aUF:GiveHex(color.r,color.g,color.b) else return "" end end, |
||
280 | ["colormp"] = function (u) local x = ManaBarColor[UnitPowerType(u)] return self:GiveHex(x.r, x.g, x.b) end, |
||
281 | ["inmelee"] = function (u) if PlayerFrame.inCombat then return "|cffFF0000" else return "" end end, |
||
282 | ["incombat"] = function (u) if UnitAffectingCombat(u) then return "|cffFF0000" else return "" end end, |
||
283 | ["raidcolor"] = function (u) local _,x=UnitClass(u) if x and UnitIsPlayer(u) then return (self.RaidColors[x] or "") else return "" end end, |
||
284 | } |
||
285 | |||
286 | self.formats = { |
||
287 | ["Health"] = { |
||
288 | ["Absolute"] = "[aghp]", |
||
289 | ["Difference"] = "[agmissinghp]", |
||
290 | ["Percent"] = "[agpercenthp]", |
||
291 | ["Smart"] = "[agsmarthp]", |
||
292 | ["Hide"] = "", |
||
293 | }, |
||
294 | ["Mana"] = { |
||
295 | ["Absolute"] = "[agmana]", |
||
296 | ["Difference"] = "[agmissingmana]", |
||
297 | ["Percent"] = "[agpercentmana]", |
||
298 | ["Smart"] = "[agsmartmana]", |
||
299 | ["Hide"] = "", |
||
300 | }, |
||
301 | ["Name"] = { |
||
302 | ["Default"] = "[name]", |
||
303 | ["Hide"] = "", |
||
304 | }, |
||
305 | ["Class"] = { |
||
306 | ["Default"] = "[agtype][difficulty][level][white] [raidcolor][agclass][white] [agrace]", |
||
307 | ["Hide"] = "", |
||
308 | } |
||
309 | } |
||
310 | |||
311 | |||
312 | self.HelperFunctions = {} |
||
313 | self.units = {} |
||
314 | self.subgroups = {} |
||
315 | self.changedSubgroups = {} |
||
316 | end |
||
317 | |||
318 | -- EVENTS |
||
319 | |||
320 | function aUF:PLAYER_LOGIN() |
||
321 | aUF:CreateObject("player","player","XP") |
||
322 | aUF:CreateObject("pet","pet","XP") |
||
323 | aUF:CreateObject("target","target","Combo") |
||
324 | aUF:CreateObject("targettarget","targettarget","Metro") |
||
325 | |||
326 | self:PARTY_MEMBERS_CHANGED() |
||
327 | end |
||
328 | |||
329 | function aUF:PLAYER_TARGET_CHANGED() |
||
330 | if self.units.target then |
||
331 | self.units.target:UpdateAll() |
||
332 | end |
||
333 | if self.units.targettarget then |
||
334 | if UnitExists("target") then |
||
335 | self.units.targettarget:Start() |
||
336 | else |
||
337 | self.units.targettarget:Stop() |
||
338 | end |
||
339 | end |
||
340 | end |
||
341 | |||
342 | function aUF:PARTY_MEMBERS_CHANGED() |
||
343 | for i = 1,4 do |
||
344 | if aUF:CheckVisibility("party"..i) == true then |
||
345 | aUF:CreateObject("party"..i) |
||
346 | end |
||
347 | if aUF:CheckVisibility("partypet"..i) == true then |
||
348 | aUF:CreateObject("partypet"..i) |
||
349 | end |
||
350 | end |
||
351 | end |
||
352 | |||
353 | function aUF:RAID_ROSTER_UPDATE() |
||
354 | for i = 1,40 do |
||
355 | if aUF:CheckVisibility("raid"..i) == true then |
||
356 | aUF:CreateObject("raid"..i,"raid"..i,"Raid") |
||
357 | end |
||
358 | end |
||
359 | self:PARTY_MEMBERS_CHANGED() |
||
360 | end |
||
361 | |||
362 | function aUF:agUF_UpdateGroups() |
||
363 | for name in self.changedSubgroups do |
||
364 | if string.find(name,"party") then |
||
365 | self.subgroups[name].raid = false |
||
366 | end |
||
367 | self.subgroups[name]:Update() |
||
368 | end |
||
369 | self.changedSubgroups = {} |
||
370 | end |
||
371 | |||
372 | -- UTILITY FUNCTIONS |
||
373 | |||
374 | function aUF:CreateObject(name,unit,type,db) |
||
375 | if not self.units[name] then |
||
376 | if not unit then |
||
377 | unit = name |
||
378 | end |
||
379 | if not type then |
||
380 | self.units[name] = self.classes.aUFunit:new(name,unit,db) |
||
381 | else |
||
382 | self.units[name] = self.classes["aUFunit"..type]:new(name,unit,db) |
||
383 | end |
||
384 | end |
||
385 | end |
||
386 | |||
387 | function aUF:FindObjects(sortBy,object) |
||
388 | local table = {} |
||
389 | if not object then object = "units" end |
||
390 | if self[object] then |
||
391 | for _,v in self[object] do |
||
392 | if v[sortBy] then |
||
393 | if not table[v[sortBy]] then |
||
394 | table[v[sortBy]] = {} |
||
395 | end |
||
396 | tinsert(table[v[sortBy]],v) |
||
397 | end |
||
398 | end |
||
399 | end |
||
400 | return table |
||
401 | end |
||
402 | |||
403 | function aUF:CallUnitMethods(func,arg,find,type,object) |
||
404 | if not func then return end |
||
405 | if find and type then |
||
406 | if aUF:FindObjects(type)[find] then |
||
407 | for _,unitObject in aUF:FindObjects(type,object)[find] do |
||
408 | if unitObject[func] then |
||
409 | unitObject[func](unitObject,arg) |
||
410 | end |
||
411 | end |
||
412 | end |
||
413 | else |
||
414 | if not object then object = "units" end |
||
415 | if self[object] then |
||
416 | for _,unitObject in self[object] do |
||
417 | unitObject[func](unitObject,arg) |
||
418 | end |
||
419 | end |
||
420 | end |
||
421 | end |
||
422 | |||
423 | function aUF:CheckVisibility(unit) |
||
424 | local _,_,type = string.find(unit, "(%a+)") |
||
425 | |||
426 | -- if self.db.profile[type].AlwaysShow == true then |
||
427 | -- return true |
||
428 | -- end |
||
429 | -- Special cases |
||
430 | -- Hide targettarget if player is targetting self |
||
431 | if unit == "targettarget" then |
||
432 | if UnitName("player") == UnitName("target") then |
||
433 | return false |
||
434 | end |
||
435 | -- Hide partyframes in raid |
||
436 | elseif type == "party" then |
||
437 | if self.db.profile.RaidHideParty == true and UnitInRaid("player") == 1 then |
||
438 | return false |
||
439 | end |
||
440 | elseif type == "partypet" then |
||
441 | if self.db.profile.RaidHideParty == true and UnitInRaid("player") == 1 then |
||
442 | return false |
||
443 | end |
||
444 | local parent = string.gsub(unit,"pet","") |
||
445 | if aUF:CheckVisibility(parent) == false then |
||
446 | return false |
||
447 | end |
||
448 | elseif type == "raidpet" then |
||
449 | local parent = string.gsub(unit,"pet","") |
||
450 | if not aUF:CheckVisibility(parent) then |
||
451 | return false |
||
452 | end |
||
453 | end |
||
454 | |||
455 | if (UnitExists(unit) and not self.db.profile[type].HideFrame == true) then |
||
456 | return true |
||
457 | end |
||
458 | end |
||
459 | |||
460 | function aUF:UtilFactionColors(unit) |
||
461 | local r, g, b = 0,0,0 |
||
462 | local a = 0.5 |
||
463 | if ( UnitPlayerControlled(unit) ) then |
||
464 | if ( UnitCanAttack(unit, "player") ) then |
||
465 | if ( not UnitCanAttack("player", unit) ) then |
||
466 | r = self.ManaColor[0].r |
||
467 | g = self.ManaColor[0].g |
||
468 | b = self.ManaColor[0].b |
||
469 | else |
||
470 | r = self.ManaColor[1].r |
||
471 | g = self.ManaColor[1].g |
||
472 | b = self.ManaColor[1].b |
||
473 | end |
||
474 | elseif ( UnitCanAttack("player", unit) ) then |
||
475 | r = self.ManaColor[3].r |
||
476 | g = self.ManaColor[3].g |
||
477 | b = self.ManaColor[3].b |
||
478 | elseif ( UnitIsPVP(unit) ) then |
||
479 | r = self.HealthColor.r |
||
480 | g = self.HealthColor.g |
||
481 | b = self.HealthColor.b |
||
482 | else |
||
483 | r = self.ManaColor[0].r |
||
484 | g = self.ManaColor[0].g |
||
485 | b = self.ManaColor[0].b |
||
486 | end |
||
487 | elseif ( UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) ) or UnitIsDead(unit) then |
||
488 | r = 0.5 |
||
489 | g = 0.5 |
||
490 | b = 0.5 |
||
491 | else |
||
492 | local reaction = UnitReaction(unit, "player") |
||
493 | if ( reaction ) then |
||
494 | if reaction == 5 or reaction == 6 or reaction == 7 then |
||
495 | r = self.HealthColor.r |
||
496 | g = self.HealthColor.g |
||
497 | b = self.HealthColor.b |
||
498 | elseif reaction == 4 then |
||
499 | r = self.ManaColor[3].r |
||
500 | g = self.ManaColor[3].g |
||
501 | b = self.ManaColor[3].b |
||
502 | elseif reaction == 1 or reaction == 2 or reaction == 3 then |
||
503 | r = self.ManaColor[1].r |
||
504 | g = self.ManaColor[1].g |
||
505 | b = self.ManaColor[1].b |
||
506 | else |
||
507 | r = UnitReactionColor[reaction].r |
||
508 | g = UnitReactionColor[reaction].g |
||
509 | b = UnitReactionColor[reaction].b |
||
510 | end |
||
511 | end |
||
512 | end |
||
513 | return {r = r,g = g,b = b} |
||
514 | end |
||
515 | |||
516 | function aUF:GiveHex(r,g,b) |
||
517 | r=r*255 |
||
518 | g=g*255 |
||
519 | b=b*255 |
||
520 | return string.format("|cff%2x%2x%2x", r, g, b) or "" |
||
521 | end |
||
522 | |||
523 | function aUF:GetRaidColors(class) |
||
524 | if self.RaidColors[class] then |
||
525 | return self.RaidColors[class] |
||
526 | else |
||
527 | return "|r" |
||
528 | end |
||
529 | end |
||
530 | |||
531 | function aUF:TargetGetMobType(unit) |
||
532 | local classification = UnitClassification(unit) |
||
533 | if ( classification == "worldboss" ) then |
||
534 | return "Boss " |
||
535 | elseif ( classification == "rareelite" ) then |
||
536 | return "Rare-Elite " |
||
537 | elseif ( classification == "elite" ) then |
||
538 | return "Elite " |
||
539 | elseif ( classification == "rare" ) then |
||
540 | return "Rare " |
||
541 | else |
||
542 | return nil; |
||
543 | end |
||
544 | end |
||
545 | |||
546 | function aUF:UnitDebuff(unit,id,filter) |
||
547 | local aura, count, t = UnitDebuff(unit,id) |
||
548 | local _, eClass = UnitClass("player") |
||
549 | |||
550 | if filter == 1 then |
||
551 | if ( self.CanDispel[eClass] and self.CanDispel[eClass][t] == true or ( eClass == "PRIEST" and aura == "Interface\\Icons\\Spell_Holy_AshesToAshes") ) then |
||
552 | return aura, count or 0, t |
||
553 | end |
||
554 | else |
||
555 | return aura, count or 0, t |
||
556 | end |
||
557 | end |
||
558 | |||
559 | function aUF:FeedbackUpdate() |
||
560 | local maxalpha = 0.6 |
||
561 | local found |
||
562 | for objectName,v in self.feedback do |
||
563 | found = true |
||
564 | local unitOjbect = aUF.units[objectName] |
||
565 | local elapsedTime = GetTime() - unitOjbect.feedbackStartTime |
||
566 | if ( elapsedTime < COMBATFEEDBACK_FADEINTIME ) then |
||
567 | local alpha = maxalpha*(elapsedTime / COMBATFEEDBACK_FADEINTIME) |
||
568 | unitOjbect.HitIndicator:SetAlpha(alpha) |
||
569 | elseif ( elapsedTime < (COMBATFEEDBACK_FADEINTIME + COMBATFEEDBACK_HOLDTIME) ) then |
||
570 | unitOjbect.HitIndicator:SetAlpha(maxalpha) |
||
571 | elseif ( elapsedTime < (COMBATFEEDBACK_FADEINTIME + COMBATFEEDBACK_HOLDTIME + COMBATFEEDBACK_FADEOUTTIME) ) then |
||
572 | local alpha = maxalpha - maxalpha*((elapsedTime - COMBATFEEDBACK_HOLDTIME - COMBATFEEDBACK_FADEINTIME) / COMBATFEEDBACK_FADEOUTTIME) |
||
573 | unitOjbect.HitIndicator:SetAlpha(alpha) |
||
574 | else |
||
575 | unitOjbect.HitIndicator:Hide() |
||
576 | aUF.feedback[objectName] = nil |
||
577 | end |
||
578 | end |
||
579 | if not found then |
||
580 | self:CancelScheduledEvent("agUF_CombatSchedule") |
||
581 | end |
||
582 | end |
||
583 | |||
584 | -- Dewdrop stuff |
||
585 | |||
586 | function aUF:CreateMenu() |
||
587 | self.dewdrop = AceLibrary("Dewdrop-2.0") |
||
588 | |||
589 | local unitTable = {} |
||
590 | unitTable.UnitHeader = { |
||
591 | name = L"unitsettings", |
||
592 | type = 'header', |
||
593 | desc = "desc", |
||
594 | order = 1, |
||
595 | } |
||
596 | for order,unit in ipairs(self.wowClasses) do |
||
597 | unitTable[unit] = aUF:CreateDewdrop(unit,(order + 1),true) |
||
598 | end |
||
599 | |||
600 | local agDewdropMenu = { |
||
601 | type= 'group', |
||
602 | args = { |
||
603 | AddonHeader = { |
||
604 | name = L"addonname", |
||
605 | type = 'header', |
||
606 | desc = "desc", |
||
607 | order = 1, |
||
608 | }, |
||
609 | Units = { |
||
610 | name = L"units", |
||
611 | type = 'group', |
||
612 | desc = L"UnitDesc", |
||
613 | args = unitTable, |
||
614 | order = 2, |
||
615 | }, |
||
616 | Borders = { |
||
617 | name = L"borders", |
||
618 | type = 'text', |
||
619 | desc = L"BordersDesc", |
||
620 | get = function() |
||
621 | return self.db.profile.BorderStyle |
||
622 | end, |
||
623 | set = function(option) |
||
624 | self.db.profile.BorderStyle = option |
||
625 | self:CallUnitMethods("BorderBackground") |
||
626 | self:CallUnitMethods("BorderBackground",nil,nil,nil,"subgroups") |
||
627 | end, |
||
628 | validate = {"Classic", "Nurfed", "Hidden"}, |
||
629 | order = 3, |
||
630 | }, |
||
631 | FrameColors = { |
||
632 | type= 'group', |
||
633 | name = L"framecolors", |
||
634 | desc = L"framecolorsdesc", |
||
635 | args = { |
||
636 | partybg = { |
||
637 | name = L"partybg", |
||
638 | type = 'color', |
||
639 | desc = L"partybgdesc", |
||
640 | hasAlpha = true, |
||
641 | get = function() |
||
642 | return self.db.profile.PartyFrameColors.r, self.db.profile.PartyFrameColors.g, self.db.profile.PartyFrameColors.b, self.db.profile.PartyFrameColors.a |
||
643 | end, |
||
644 | set = function(r, g, b, a) |
||
645 | self.db.profile.PartyFrameColors.r, self.db.profile.PartyFrameColors.g, self.db.profile.PartyFrameColors.b, self.db.profile.PartyFrameColors.a = r, g, b, a |
||
646 | self:CallUnitMethods("BorderBackground") |
||
647 | self:CallUnitMethods("BorderBackground",nil,nil,nil,"subgroups") |
||
648 | end, |
||
649 | order = 1, |
||
650 | }, |
||
651 | targetbg = { |
||
652 | name = L"targetbg", |
||
653 | type = 'color', |
||
654 | desc = L"targetbgdesc", |
||
655 | hasAlpha = true, |
||
656 | get = function() |
||
657 | return self.db.profile.TargetFrameColors.r, self.db.profile.TargetFrameColors.g, self.db.profile.TargetFrameColors.b, self.db.profile.TargetFrameColors.a |
||
658 | end, |
||
659 | set = function(r, g, b, a) |
||
660 | self.db.profile.TargetFrameColors.r, self.db.profile.TargetFrameColors.g, self.db.profile.TargetFrameColors.b, self.db.profile.TargetFrameColors.a = r, g, b, a |
||
661 | self:CallUnitMethods("BorderBackground") |
||
662 | self:CallUnitMethods("BorderBackground",nil,nil,nil,"subgroups") |
||
663 | end, |
||
664 | order = 2, |
||
665 | }, |
||
666 | border = { |
||
667 | name = L"bordercolor", |
||
668 | type = 'color', |
||
669 | desc = L"bordercolordesc", |
||
670 | hasAlpha = true, |
||
671 | get = function() |
||
672 | return self.db.profile.FrameBorderColors.r, self.db.profile.FrameBorderColors.g, self.db.profile.FrameBorderColors.b, self.db.profile.FrameBorderColors.a |
||
673 | end, |
||
674 | set = function(r, g, b, a) |
||
675 | self.db.profile.FrameBorderColors.r, self.db.profile.FrameBorderColors.g, self.db.profile.FrameBorderColors.b, self.db.profile.FrameBorderColors.a = r, g, b, a |
||
676 | self:CallUnitMethods("BorderBackground") |
||
677 | self:CallUnitMethods("BorderBackground",nil,nil,nil,"subgroups") |
||
678 | end, |
||
679 | order = 3, |
||
680 | }, |
||
681 | }, |
||
682 | order = 4, |
||
683 | }, |
||
684 | BarColors = { |
||
685 | type= 'group', |
||
686 | args = { |
||
687 | Health = { |
||
688 | name = L"health", |
||
689 | type = 'color', |
||
690 | desc = L"healthDesc", |
||
691 | get = function() |
||
692 | return self.db.profile.HealthColor.r, self.db.profile.HealthColor.g, self.db.profile.HealthColor.b |
||
693 | end, |
||
694 | set = function(r, g, b) |
||
695 | self.db.profile.HealthColor.r, self.db.profile.HealthColor.g, self.db.profile.HealthColor.b = r, g, b |
||
696 | self:CallUnitMethods("StatusBarsColor") |
||
697 | end, |
||
698 | order = 1, |
||
699 | }, |
||
700 | Mana = { |
||
701 | name = L"mana", |
||
702 | type = 'color', |
||
703 | desc = L"manaDesc", |
||
704 | get = function() |
||
705 | return self.db.profile.ManaColor[0].r, self.db.profile.ManaColor[0].g, self.db.profile.ManaColor[0].b |
||
706 | end, |
||
707 | set = function(r, g, b) |
||
708 | self.db.profile.ManaColor[0].r, self.db.profile.ManaColor[0].g, self.db.profile.ManaColor[0].b = r, g, b |
||
709 | self:CallUnitMethods("StatusBarsColor") |
||
710 | end, |
||
711 | order = 2, |
||
712 | }, |
||
713 | Rage = { |
||
714 | name = L"rage", |
||
715 | type = 'color', |
||
716 | desc = L"rageDesc", |
||
717 | get = function() |
||
718 | return self.db.profile.ManaColor[1].r, self.db.profile.ManaColor[1].g, self.db.profile.ManaColor[1].b |
||
719 | end, |
||
720 | set = function(r, g, b) |
||
721 | self.db.profile.ManaColor[1].r, self.db.profile.ManaColor[1].g, self.db.profile.ManaColor[1].b = r, g, b |
||
722 | self:CallUnitMethods("StatusBarsColor") |
||
723 | end, |
||
724 | order = 3, |
||
725 | }, |
||
726 | Energy = { |
||
727 | name = L"energy", |
||
728 | type = 'color', |
||
729 | desc = L"energyDesc", |
||
730 | get = function() |
||
731 | return self.db.profile.ManaColor[3].r, self.db.profile.ManaColor[3].g, self.db.profile.ManaColor[3].b |
||
732 | end, |
||
733 | set = function(r, g, b) |
||
734 | self.db.profile.ManaColor[3].r, self.db.profile.ManaColor[3].g, self.db.profile.ManaColor[3].b = r, g, b |
||
735 | self:CallUnitMethods("StatusBarsColor") |
||
736 | end, |
||
737 | order = 4, |
||
738 | }, |
||
739 | PetFocus = { |
||
740 | name = L"petfocus", |
||
741 | type = 'color', |
||
742 | desc = L"petfocusDesc", |
||
743 | get = function() |
||
744 | return self.db.profile.ManaColor[2].r, self.db.profile.ManaColor[2].g, self.db.profile.ManaColor[2].b |
||
745 | end, |
||
746 | set = function(r, g, b) |
||
747 | self.db.profile.ManaColor[2].r, self.db.profile.ManaColor[2].g, self.db.profile.ManaColor[2].b = r, g, b |
||
748 | self:CallUnitMethods("StatusBarsColor") |
||
749 | end, |
||
750 | order = 5, |
||
751 | }, |
||
752 | }, |
||
753 | order = 5, |
||
754 | name = L"barcolors", |
||
755 | desc = L"barcolorsDesc", |
||
756 | }, |
||
757 | BarStyle = { |
||
758 | name = L"barstyle", |
||
759 | type = 'text', |
||
760 | desc = L"BarStyleDesc", |
||
761 | get = function() |
||
762 | return self.db.profile.BarStyle |
||
763 | end, |
||
764 | set = function(option) |
||
765 | self.db.profile.BarStyle = option |
||
766 | self:CallUnitMethods("BarTexture") |
||
767 | end, |
||
768 | validate = {"Classic", "Default","Smooth", "Bars", "Bumps", "Button", "Cloud", "Cracked", "Dabs", "Diagonal", "Gloss", "Grid", "Hatched", "Perl", "Rain", "Skewed", "Smudge", "Water", "Wisps","Charcoal","BantoBar"}, |
||
769 | order = 6, |
||
770 | }, |
||
771 | ShowPvPIcon = { |
||
772 | name = L"pvpicon", |
||
773 | type = 'toggle', |
||
774 | desc = L"ShowPVPIconDesc", |
||
775 | get = function() |
||
776 | return self.db.profile.ShowPvPIcon |
||
777 | end, |
||
778 | set = function(option) |
||
779 | self.db.profile.ShowPvPIcon = option |
||
780 | self:CallUnitMethods("UpdatePvP",true) |
||
781 | end, |
||
782 | order = 7, |
||
783 | }, |
||
784 | ShowGroupIcons = { |
||
785 | name = L"groupicon", |
||
786 | type = 'toggle', |
||
787 | desc = L"ShowGroupIconsDesc", |
||
788 | get = function() |
||
789 | return self.db.profile.ShowGroupIcons |
||
790 | end, |
||
791 | set = function(option) |
||
792 | self.db.profile.ShowGroupIcons = option |
||
793 | self:CallUnitMethods("LabelsCheckLeader") |
||
794 | end, |
||
795 | order = 8, |
||
796 | }, |
||
797 | HighlightSelected = { |
||
798 | name = L"highlightselected", |
||
799 | type = 'toggle', |
||
800 | desc = L"HighlightSelectedDesc", |
||
801 | get = function() |
||
802 | return self.db.profile.HighlightSelected |
||
803 | end, |
||
804 | set = function(option) |
||
805 | self.db.profile.HighlightSelected = option |
||
806 | end, |
||
807 | order = 9, |
||
808 | }, |
||
809 | Locked = { |
||
810 | name = L"lock", |
||
811 | type = 'toggle', |
||
812 | desc = L"LockedDesc", |
||
813 | get = function() |
||
814 | return self.db.profile.Locked |
||
815 | end, |
||
816 | set = function(option) |
||
817 | self.db.profile.Locked = option |
||
818 | end, |
||
819 | order = 12, |
||
820 | }, |
||
821 | } |
||
822 | } |
||
823 | self.dewdrop:InjectAceOptionsTable(self, agDewdropMenu) |
||
824 | return agDewdropMenu |
||
825 | end |
||
826 | |||
827 | function aUF:InitMenu() |
||
828 | if not self.menu then |
||
829 | self.menu = aUF:CreateMenu() |
||
830 | end |
||
831 | |||
832 | local agSlashMenu = { |
||
833 | type = "group", |
||
834 | args = { |
||
835 | config = { |
||
836 | name = L('config'), |
||
837 | desc = L('configdesc'), |
||
838 | type = 'execute', |
||
839 | func = function() |
||
840 | self.dewdrop:Open(UIParent, 'children', function() self.dewdrop:FeedAceOptionsTable(self.menu) end,'cursorX', true, 'cursorY', true) |
||
841 | end, |
||
842 | }, |
||
843 | reset = { |
||
844 | name = L('reset'), |
||
845 | desc = L('resetdesc'), |
||
846 | type = 'execute', |
||
847 | func = function() |
||
848 | self:Reset() |
||
849 | end, |
||
850 | } |
||
851 | } |
||
852 | } |
||
853 | |||
854 | self:RegisterChatCommand({ "/aguf", "/ag_unitframes" }, agSlashMenu ) |
||
855 | end |
||
856 | |||
857 | function aUF:CreateDewdrop(type,order,mainmenu) |
||
858 | local class = type |
||
859 | local prettyname = L(class) |
||
860 | |||
861 | local strings = {"Health","Mana","Name","Class"} |
||
862 | -- local strings = {"Health","Mana"} |
||
863 | |||
864 | local stringArgs = {} |
||
865 | |||
866 | for k,v in strings do |
||
867 | local name = v |
||
868 | local order = k |
||
869 | local validate |
||
870 | if v == "Health" or v == "Mana" then |
||
871 | validate = {"Absolute", "Difference", "Percent", "Smart","Custom", "Hide"} |
||
872 | else |
||
873 | validate = {"Default","Custom", "Hide"} |
||
874 | end |
||
875 | stringArgs[v] = { |
||
876 | name = name.." Text", |
||
877 | type = 'group', |
||
878 | desc = L"UnitDesc", |
||
879 | order = order, |
||
880 | args = { |
||
881 | StatusTextStyle = { |
||
882 | name = "Style", |
||
883 | type = 'text', |
||
884 | desc = L"StatusTextDesc", |
||
885 | get = function() |
||
886 | return self.db.profile[class][name.."Style"] |
||
887 | end, |
||
888 | set = function(option) |
||
889 | self.db.profile[class][name.."Style"] = option |
||
890 | |||
891 | self:SetStringFormats(class) |
||
892 | self:CallUnitMethods("UpdateTextStrings",nil,class,"type") |
||
893 | end, |
||
894 | validate = validate, |
||
895 | order = 1, |
||
896 | }, |
||
897 | HealthCustom = { |
||
898 | name = "Custom", |
||
899 | type = 'text', |
||
900 | desc = L"StatusTextDesc", |
||
901 | get = function() |
||
902 | return self.db.profile[class][name.."Format"] |
||
903 | end, |
||
904 | set = function(option) |
||
905 | self.db.profile[class][name.."Format"] = option |
||
906 | |||
907 | self:SetStringFormats(class) |
||
908 | self:CallUnitMethods("UpdateTextStrings",nil,class,"type") |
||
909 | end, |
||
910 | usage = "", |
||
911 | order = 2, |
||
912 | } |
||
913 | } |
||
914 | } |
||
915 | end |
||
916 | |||
917 | |||
918 | |||
919 | local table = { |
||
920 | name = prettyname, |
||
921 | type = 'group', |
||
922 | desc = prettyname.." Settings", |
||
923 | order = order, |
||
924 | args = { |
||
925 | UnitHeader = { |
||
926 | name = prettyname.." "..L"layoutsettings", |
||
927 | type = 'header', |
||
928 | desc = "desc", |
||
929 | order = 1, |
||
930 | }, |
||
931 | FrameStyle = { |
||
932 | name = L"framestyle", |
||
933 | type = 'text', |
||
934 | desc = L"FrameStyleDesc", |
||
935 | validate = {}, |
||
936 | get = function() |
||
937 | return self.db.profile[class].FrameStyle |
||
938 | end, |
||
939 | set = function(option) |
||
940 | self.db.profile[class].FrameStyle = option |
||
941 | self:CallUnitMethods("ApplyTheme",nil,class,"type") |
||
942 | self:CallUnitMethods("UpdateName",true,class,"type") |
||
943 | end, |
||
944 | order = 2, |
||
945 | }, |
||
946 | |||
947 | Width = { |
||
948 | name = L"widthadjust", |
||
949 | type = 'range', |
||
950 | desc = L"widthadjustDesc", |
||
951 | min = 50, |
||
952 | max = 400, |
||
953 | step = 1, |
||
954 | get = function() |
||
955 | return self.db.profile[class].Width |
||
956 | end, |
||
957 | set = function(option) |
||
958 | self.db.profile[class].Width = option |
||
959 | self:CallUnitMethods("SetWidth",nil,class,"type") |
||
960 | end, |
||
961 | order = 3, |
||
962 | }, |
||
963 | |||
964 | StatusTextStyle = { |
||
965 | name = "Status Text", |
||
966 | type = 'group', |
||
967 | desc = L"UnitDesc", |
||
968 | order = 5, |
||
969 | args = stringArgs, |
||
970 | }, |
||
971 | Scale = { |
||
972 | name = L"scale", |
||
973 | type = 'range', |
||
974 | desc = L"ScaleDesc", |
||
975 | min = 0.5, |
||
976 | max = 2, |
||
977 | step = 0.01, |
||
978 | isPercent = true, |
||
979 | get = function() |
||
980 | return self.db.profile[class].Scale |
||
981 | end, |
||
982 | set = function(option) |
||
983 | self.db.profile[class].Scale = option |
||
984 | self:CallUnitMethods("LoadScale",nil,class,"type") |
||
985 | self:CallUnitMethods("LoadPosition",nil,class,"type") |
||
986 | end, |
||
987 | order = 7, |
||
988 | }, |
||
989 | ClassColorBars = { |
||
990 | name = L"classcolorbar", |
||
991 | type = 'toggle', |
||
992 | desc = L"ClassColorBarsDesc", |
||
993 | get = function() |
||
994 | return self.db.profile[class].ClassColorBars |
||
995 | end, |
||
996 | set = function(option) |
||
997 | self.db.profile[class].ClassColorBars = option |
||
998 | self:CallUnitMethods("StatusBarsColor",nil,class,"type") |
||
999 | end, |
||
1000 | order = 20, |
||
1001 | }, |
||
1002 | RaidColorName = { |
||
1003 | name = L"raidcolorname", |
||
1004 | type = 'toggle', |
||
1005 | desc = L"RaidColorNameDesc", |
||
1006 | get = function() |
||
1007 | return self.db.profile[class].RaidColorName |
||
1008 | end, |
||
1009 | set = function(option) |
||
1010 | self.db.profile[class].RaidColorName = option |
||
1011 | self:CallUnitMethods("UpdateTextStrings",nil,class,"type") |
||
1012 | end, |
||
1013 | order = 21, |
||
1014 | }, |
||
1015 | ShowCombat = { |
||
1016 | name = L"showcombat", |
||
1017 | type = 'toggle', |
||
1018 | desc = L"ShowCombatDesc", |
||
1019 | get = function() |
||
1020 | return self.db.profile[class].ShowCombat |
||
1021 | end, |
||
1022 | set = function(option) |
||
1023 | self.db.profile[class].ShowCombat = option |
||
1024 | end, |
||
1025 | order = 23, |
||
1026 | }, |
||
1027 | ShowInCombatIcon = { |
||
1028 | name = L"showincombat", |
||
1029 | type = 'toggle', |
||
1030 | desc = L"ShowInCombatDesc", |
||
1031 | get = function () |
||
1032 | return self.db.profile[class].ShowInCombatIcon |
||
1033 | end, |
||
1034 | set = function(option) |
||
1035 | self.db.profile[class].ShowInCombatIcon = option |
||
1036 | end, |
||
1037 | order = 24, |
||
1038 | }, |
||
1039 | ShowRaidTargetIcon = { |
||
1040 | name = L"showraidicon", |
||
1041 | type = 'toggle', |
||
1042 | desc = L"ShowRaidIconDesc", |
||
1043 | get = function () |
||
1044 | return self.db.profile[class].ShowRaidTargetIcon |
||
1045 | end, |
||
1046 | set = function(option) |
||
1047 | self.db.profile[class].ShowRaidTargetIcon = option |
||
1048 | self:CallUnitMethods("UpdateRaidTargetIcon",true,class,"type") |
||
1049 | end, |
||
1050 | order = 25, |
||
1051 | }, |
||
1052 | LongStatusbars = { |
||
1053 | name = L"longbars", |
||
1054 | type = 'toggle', |
||
1055 | desc = L"LongBarsDesc", |
||
1056 | get = function() |
||
1057 | return self.db.profile[class].LongStatusbars |
||
1058 | end, |
||
1059 | set = function(option) |
||
1060 | self.db.profile[class].LongStatusbars = option |
||
1061 | self:CallUnitMethods("ApplyTheme",nil,class,"type") |
||
1062 | end, |
||
1063 | order = 26, |
||
1064 | }, |
||
1065 | HideMana = { |
||
1066 | name = L"hidemana", |
||
1067 | type = 'toggle', |
||
1068 | desc = L"HideManaDesc", |
||
1069 | get = function() |
||
1070 | return self.db.profile[class].HideMana |
||
1071 | end, |
||
1072 | set = function(option) |
||
1073 | self.db.profile[class].HideMana = option |
||
1074 | self:CallUnitMethods("ApplyTheme",nil,class,"type") |
||
1075 | self:CallUnitMethods("UpdateName",true,class,"type") |
||
1076 | end, |
||
1077 | order = 27, |
||
1078 | }, |
||
1079 | HideFrame = { |
||
1080 | name = L"hideframe", |
||
1081 | type = 'toggle', |
||
1082 | desc = L"HideFrameDesc", |
||
1083 | get = function() |
||
1084 | return self.db.profile[class].HideFrame |
||
1085 | end, |
||
1086 | set = function(option) |
||
1087 | self.db.profile[class].HideFrame = option |
||
1088 | self:RAID_ROSTER_UPDATE() |
||
1089 | self:CallUnitMethods("UpdateAll",nil,class,"type") |
||
1090 | end, |
||
1091 | order = 29, |
||
1092 | }, |
||
1093 | Spacing1 = { |
||
1094 | name = " ", |
||
1095 | type = 'header', |
||
1096 | order = 35, |
||
1097 | }, |
||
1098 | AuraHeader = { |
||
1099 | name = L"aurasettings", |
||
1100 | type = 'header', |
||
1101 | order = 39, |
||
1102 | }, |
||
1103 | AuraStyle = { |
||
1104 | name = L"aurastyle", |
||
1105 | type = 'text', |
||
1106 | desc = L"AuraStyleDesc", |
||
1107 | get = function() |
||
1108 | return self.db.profile[class].AuraStyle |
||
1109 | end, |
||
1110 | set = function(option) |
||
1111 | self.db.profile[class].AuraStyle = option |
||
1112 | self:CallUnitMethods("UpdateAuras",true,class,"type") |
||
1113 | self:CallUnitMethods("AuraPosition",true,class,"type") |
||
1114 | end, |
||
1115 | validate = {OneLine = L"oneline", TwoLines = L"twolines", Hide = L"hide"}, |
||
1116 | order = 40, |
||
1117 | }, |
||
1118 | AuraPos = { |
||
1119 | name = L"aurapos", |
||
1120 | type = 'text', |
||
1121 | desc = L"AuraPosDesc", |
||
1122 | get = function() |
||
1123 | return self.db.profile[class].AuraPos |
||
1124 | end, |
||
1125 | set = function(option) |
||
1126 | self.db.profile[class].AuraPos = option |
||
1127 | self:CallUnitMethods("UpdateAuras",true,class,"type") |
||
1128 | self:CallUnitMethods("AuraPosition",true,class,"type") |
||
1129 | end, |
||
1130 | validate = {"Right", "Left", "Above", "Below"}, |
||
1131 | order = 41, |
||
1132 | }, |
||
1133 | DebuffColoring = { |
||
1134 | name = L"debuffcoloring", |
||
1135 | type = 'toggle', |
||
1136 | desc = L"DebuffColoringDesc", |
||
1137 | get = function() |
||
1138 | return self.db.profile[class].AuraDebuffC |
||
1139 | end, |
||
1140 | set = function(option) |
||
1141 | self.db.profile[class].AuraDebuffC = option |
||
1142 | self:CallUnitMethods("UpdateAuras",true,class,"type") |
||
1143 | end, |
||
1144 | order = 42, |
||
1145 | }, |
||
1146 | AuraFilter = { |
||
1147 | name = L"aurafilter", |
||
1148 | type = 'toggle', |
||
1149 | desc = L"AuraFilterDesc", |
||
1150 | get = function() |
||
1151 | if self.db.profile[class].AuraFilter == 1 then |
||
1152 | return true |
||
1153 | else |
||
1154 | return false |
||
1155 | end |
||
1156 | end, |
||
1157 | set = function(option) |
||
1158 | if option == true then |
||
1159 | self.db.profile[class].AuraFilter = 1 |
||
1160 | else |
||
1161 | self.db.profile[class].AuraFilter = 0 |
||
1162 | end |
||
1163 | self:CallUnitMethods("UpdateAuras",true,class,"type") |
||
1164 | end, |
||
1165 | order = 43, |
||
1166 | } |
||
1167 | } |
||
1168 | } |
||
1169 | -- Inject themes from the theme table |
||
1170 | local themetable = {} |
||
1171 | for k, v in self.Layouts do |
||
1172 | tinsert(themetable,k) |
||
1173 | end |
||
1174 | table.args.FrameStyle.validate = themetable |
||
1175 | |||
1176 | -- PLAYER/PET |
||
1177 | --[[ |
||
1178 | if class == "player" then |
||
1179 | local ShowRestingIcon = { |
||
1180 | name = L"showresting", |
||
1181 | type = 'toggle', |
||
1182 | desc = L"ShowRestingDesc", |
||
1183 | get = function() |
||
1184 | return self.db.profile[class].ShowRestingIcon |
||
1185 | end, |
||
1186 | set = function(option) |
||
1187 | self.db.profile[class].ShowRestingIcon = option |
||
1188 | self:CallUnitMethods("UpdateResting",nil,class,"type") |
||
1189 | end, |
||
1190 | order = 26, |
||
1191 | } |
||
1192 | table.args.ShowRestingIcon = ShowRestingIcon |
||
1193 | end |
||
1194 | ]] |
||
1195 | if class == "player" or class == "pet" then |
||
1196 | local ShowXP = { |
||
1197 | name = L"showxp", |
||
1198 | type = 'toggle', |
||
1199 | desc = L"ShowXPDesc", |
||
1200 | get = function() |
||
1201 | return self.db.profile[class].ShowXP |
||
1202 | end, |
||
1203 | set = function(option) |
||
1204 | self.db.profile[class].ShowXP = option |
||
1205 | self:CallUnitMethods("ApplyTheme",nil,class,"type") |
||
1206 | end, |
||
1207 | order = 26, |
||
1208 | } |
||
1209 | table.args.ShowXP = ShowXP |
||
1210 | end |
||
1211 | |||
1212 | if class == "pet" then |
||
1213 | local PetGrouping = { |
||
1214 | name = L"petgrouping", |
||
1215 | type = 'text', |
||
1216 | desc = L"PetGroupingDesc", |
||
1217 | get = function() |
||
1218 | return self.db.profile.PetGrouping |
||
1219 | end, |
||
1220 | set = function(option) |
||
1221 | self.db.profile.PetGrouping = option |
||
1222 | self:CallUnitMethods("UpdateAll") |
||
1223 | end, |
||
1224 | validate = {["withplayer"] = L"withplayer", ["nogroup"] = L"nogroup"}, |
||
1225 | order = 6, |
||
1226 | } |
||
1227 | table.args.PetGrouping = PetGrouping |
||
1228 | end |
||
1229 | |||
1230 | if class == "pet" or class == "partypet" or class == "raidpet" then |
||
1231 | table.args.RaidColorName = nil |
||
1232 | table.args.ClassColorBars = nil |
||
1233 | end |
||
1234 | |||
1235 | -- TARGET |
||
1236 | if string.find(class,"target") then |
||
1237 | local TargetShowHostile = { |
||
1238 | name = L"targetshowhostile", |
||
1239 | type = 'toggle', |
||
1240 | desc = L"TargetHostileDesc", |
||
1241 | get = function() |
||
1242 | return self.db.profile.TargetShowHostile |
||
1243 | end, |
||
1244 | set = function(option) |
||
1245 | self.db.profile.TargetShowHostile = option |
||
1246 | self:CallUnitMethods("StatusBarsColor",nil,class,"type") |
||
1247 | end, |
||
1248 | order = 22, |
||
1249 | } |
||
1250 | table.args.TargetShowHostile = TargetShowHostile |
||
1251 | end |
||
1252 | |||
1253 | -- PARTY |
||
1254 | if class == "party" then |
||
1255 | local RaidHideParty = { |
||
1256 | name = L"raidhideparty", |
||
1257 | type = 'toggle', |
||
1258 | desc = L"RaidHidePartyDesc", |
||
1259 | get = function() |
||
1260 | return self.db.profile.RaidHideParty |
||
1261 | end, |
||
1262 | set = function(option) |
||
1263 | self.db.profile.RaidHideParty = option |
||
1264 | self:CallUnitMethods("UpdateAll",nil,"party","type") |
||
1265 | self:CallUnitMethods("UpdateAll",nil,"partypet","type") |
||
1266 | end, |
||
1267 | order = 28, |
||
1268 | } |
||
1269 | table.args.RaidHideParty = RaidHideParty |
||
1270 | |||
1271 | local PartyGrouping = { |
||
1272 | name = L"partygrouping", |
||
1273 | type = 'text', |
||
1274 | desc = L"PartyGroupingDesc", |
||
1275 | get = function() |
||
1276 | return self.db.profile.PartyGrouping |
||
1277 | end, |
||
1278 | set = function(option) |
||
1279 | self.db.profile.PartyGrouping = option |
||
1280 | self:PARTY_MEMBERS_CHANGED() |
||
1281 | self:CallUnitMethods("UpdateAll") |
||
1282 | end, |
||
1283 | validate = {["withplayer"] = L"withplayer", ["withoutplayer"] = L"withoutplayer", ["nogroup"] = L"nogroup"}, |
||
1284 | order = 6, |
||
1285 | } |
||
1286 | table.args.PartyGrouping = PartyGrouping |
||
1287 | end |
||
1288 | |||
1289 | -- RAID |
||
1290 | if class == "raid" then |
||
1291 | local RaidGrouping = { |
||
1292 | name = L"raidgrouping", |
||
1293 | type = 'text', |
||
1294 | desc = L"RaidGroupingDesc", |
||
1295 | get = function() |
||
1296 | return self.db.profile.RaidGrouping |
||
1297 | end, |
||
1298 | set = function(option) |
||
1299 | self.db.profile.RaidGrouping = option |
||
1300 | self:CallUnitMethods("UpdateAll") |
||
1301 | end, |
||
1302 | validate = {["bysubgroup"] = L"bysubgroup", ["byclass"] = L"byclass", ["byrole"] = L"byrole", ["nogroup"] = L"nogroup", ["onebiggroup"] = L"onebiggroup"}, |
||
1303 | order = 6, |
||
1304 | } |
||
1305 | table.args.RaidGrouping = RaidGrouping |
||
1306 | end |
||
1307 | |||
1308 | if not mainmenu then |
||
1309 | table.args.UnitHeader.name = L(class).." "..L"frame" |
||
1310 | local EndSpacing = { |
||
1311 | name = " ", |
||
1312 | type = 'header', |
||
1313 | order = 51, |
||
1314 | } |
||
1315 | table.args.EndSpacing = EndSpacing |
||
1316 | end |
||
1317 | |||
1318 | return table |
||
1319 | end |
||
1320 | |||
1321 | function aUF:LoadStringFormats() |
||
1322 | for order,unit in ipairs(self.wowClasses) do |
||
1323 | self:SetStringFormats(unit) |
||
1324 | end |
||
1325 | end |
||
1326 | |||
1327 | function aUF:SetStringFormats(type) |
||
1328 | local db = self.db.profile[type] |
||
1329 | local strings = {"Health","Mana","Name","Class"} |
||
1330 | if not aUF.HelperFunctions[type] then |
||
1331 | aUF.HelperFunctions[type] = {} |
||
1332 | end |
||
1333 | |||
1334 | for k,v in strings do |
||
1335 | local format |
||
1336 | if db[v.."Style"] == "Custom" then |
||
1337 | format = db[v.."Format"] |
||
1338 | else |
||
1339 | format = self.formats[v][db[v.."Style"]] |
||
1340 | end |
||
1341 | aUF.HelperFunctions[type][v.."Text"] = self:Parse(format) |
||
1342 | end |
||
1343 | end |
||
1344 | |||
1345 | |||
1346 | -- Clads code-- Clads code-- Clads code-- Clads code |
||
1347 | -- Clads code-- Clads code-- Clads code-- Clads code |
||
1348 | |||
1349 | -- Code Begins here |
||
1350 | local work = {} |
||
1351 | local strgsub, strsub, strgfind, strformat, strfind = string.gsub, string.sub, string.gfind, string.format, string.find |
||
1352 | |||
1353 | function aUF:Parse(format) |
||
1354 | if not format then |
||
1355 | return nil |
||
1356 | end |
||
1357 | |||
1358 | local formatArgs, formatString = {} |
||
1359 | |||
1360 | for s,data,e in strgfind(format, "()(%b[])()") do |
||
1361 | local tag = strsub(data, 2, -2) |
||
1362 | local func = aUF:GetTagFunction(tag) |
||
1363 | if func then |
||
1364 | table.insert(formatArgs, func) |
||
1365 | else |
||
1366 | error(strformat("\"%s\" is not a valid format tag.", data)) |
||
1367 | end |
||
1368 | end |
||
1369 | |||
1370 | formatString = strgsub(format, "%%", "%%%%") |
||
1371 | formatString = strgsub(formatString, "%b[]", "%%s") |
||
1372 | |||
1373 | -- Lets avoid unpacking extra results |
||
1374 | local num = table.getn(formatArgs) |
||
1375 | local tmp = work[num] |
||
1376 | if not tmp then |
||
1377 | tmp = {} |
||
1378 | work[num] = tmp |
||
1379 | end |
||
1380 | |||
1381 | if num == 0 then |
||
1382 | return function(unit, fontstring) |
||
1383 | fontstring:SetText(formatString) |
||
1384 | end |
||
1385 | else |
||
1386 | return function(unit, fontstring) |
||
1387 | for i,func in ipairs(formatArgs) do |
||
1388 | work[i] = func(unit) |
||
1389 | end |
||
1390 | fontstring:SetText(strformat(formatString, unpack(work))) |
||
1391 | end |
||
1392 | end |
||
1393 | end |
||
1394 | |||
1395 | local helpers = {} |
||
1396 | |||
1397 | function aUF:GetTagFunction(tag) |
||
1398 | -- Check if this is just a unit tag |
||
1399 | if aUF.UnitInformation[tag] then return aUF.UnitInformation[tag] end |
||
1400 | |||
1401 | local s,e,tag,args = strfind(tag, "^(%a+)%s+(.*)$") |
||
1402 | if not tag then |
||
1403 | -- Not a pattern we can recognize |
||
1404 | return nil |
||
1405 | end |
||
1406 | |||
1407 | -- Bind the unit function to a local for closure purposes |
||
1408 | local func = aUF.UnitInformation[tag] |
||
1409 | if not func then |
||
1410 | -- Not a tag we support |
||
1411 | return nil |
||
1412 | end |
||
1413 | local _,_,width = strfind(args, "^(%d+)$") |
||
1414 | if width then |
||
1415 | local id = strformat("%s-%d", tag, width) |
||
1416 | local hFunc = helpers[id] |
||
1417 | if not hFunc then |
||
1418 | hFunc = function(unit) |
||
1419 | return strsub(func(unit), 1, width) |
||
1420 | end |
||
1421 | |||
1422 | helpers[id] = hFunc |
||
1423 | end |
||
1424 | return hFunc |
||
1425 | end |
||
1426 | |||
1427 | local _,_,oc,ec = strfind(args, "^(.)(.)$") |
||
1428 | if oc then |
||
1429 | local id = strformat("%s-%s%s", tag, oc, ec) |
||
1430 | local hFunc = helpers[id] |
||
1431 | if not hFunc then |
||
1432 | hFunc = function(unit) |
||
1433 | local t = func(unit) |
||
1434 | if t ~= "" then return |
||
1435 | strformat("%s%s%s",oc,t,ec) |
||
1436 | else |
||
1437 | return t |
||
1438 | end |
||
1439 | end |
||
1440 | |||
1441 | helpers[id] = hFunc |
||
1442 | end |
||
1443 | return hFunc |
||
1444 | end |
||
1445 | end |
||
1446 | |||
1447 | function aUF:Tag_agmana(unit,flag) |
||
1448 | local currValue,maxValue = UnitMana(unit),UnitManaMax(unit) |
||
1449 | local perc = currValue/maxValue * 100 |
||
1450 | local manaDiff = maxValue - currValue |
||
1451 | local text = "" |
||
1452 | |||
1453 | if ( not UnitExists(unit) or UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit) ) then |
||
1454 | return "" |
||
1455 | end |
||
1456 | if currValue > maxValue then |
||
1457 | maxValue = currValue |
||
1458 | end |
||
1459 | if currValue > 9999 then |
||
1460 | currValue = string.format("%.1fk", currValue / 1000) |
||
1461 | end |
||
1462 | if maxValue > 9999 then |
||
1463 | maxValue = string.format("%.1fk", maxValue / 1000) |
||
1464 | end |
||
1465 | |||
1466 | if flag == 1 then |
||
1467 | return string.format("%.0f%%", perc) |
||
1468 | elseif flag == 2 then |
||
1469 | if manaDiff > 9999 then |
||
1470 | manaDiff = string.format("%.1fk", manaDiff / 1000) |
||
1471 | end |
||
1472 | return (currValue.."|cffff7f7f-"..manaDiff.."|r") |
||
1473 | elseif flag == 3 then |
||
1474 | return currValue |
||
1475 | else |
||
1476 | return (currValue.."/"..maxValue) |
||
1477 | end |
||
1478 | |||
1479 | return text |
||
1480 | end |
||
1481 | |||
1482 | function aUF:Tag_aghp(unit,flag) |
||
1483 | local currValue,maxValue = UnitHealth(unit),UnitHealthMax(unit) |
||
1484 | local perc = currValue/maxValue * 100 |
||
1485 | local text = "" |
||
1486 | local MHfound = false |
||
1487 | if ( UnitIsDead(unit) ) then |
||
1488 | return L("dead") |
||
1489 | elseif ( UnitIsGhost(unit) ) then |
||
1490 | return L("ghost") |
||
1491 | elseif ( not UnitIsConnected(unit) or maxValue == 1 ) then |
||
1492 | return L("disc") |
||
1493 | end |
||
1494 | if (MobHealth3 and not UnitIsFriend("player", unit) ) then |
||
1495 | currValue,maxValue,MHfound = MobHealth3:GetUnitHealth(unit, currValue,maxValue) |
||
1496 | end |
||
1497 | if currValue > maxValue then |
||
1498 | maxValue = currValue |
||
1499 | end |
||
1500 | local hpDiff = maxValue - currValue |
||
1501 | if currValue > 9999 then |
||
1502 | currValue = string.format("%.1fk", currValue / 1000) |
||
1503 | end |
||
1504 | if maxValue > 9999 then |
||
1505 | maxValue = string.format("%.1fk", maxValue / 1000) |
||
1506 | end |
||
1507 | |||
1508 | if not flag and MHfound and not UnitIsFriend("player", unit) then |
||
1509 | return currValue .." (".. perc .."%)" |
||
1510 | end |
||
1511 | |||
1512 | if not (flag == 1) and (MHfound or unit == "pet" or unit == "player" or UnitInParty(unit) or UnitInRaid(unit)) then |
||
1513 | if flag == 2 then |
||
1514 | if hpDiff > 0 then |
||
1515 | if hpDiff > 9999 then |
||
1516 | hpDiff = string.format("%.1fk", hpDiff / 1000) |
||
1517 | end |
||
1518 | return (currValue.."|cffff7f7f-"..hpDiff.."|r") |
||
1519 | else |
||
1520 | return currValue |
||
1521 | end |
||
1522 | elseif flag == 3 and hpDiff > 0 then |
||
1523 | if hpDiff > 9999 then |
||
1524 | hpDiff = string.format("%.1fk", hpDiff / 1000) |
||
1525 | end |
||
1526 | return "|cffff7f7f-"..hpDiff.."|r" |
||
1527 | elseif flag == 3 then |
||
1528 | return "" |
||
1529 | else |
||
1530 | return (currValue.."/"..maxValue) |
||
1531 | end |
||
1532 | else |
||
1533 | return string.format("%.0f%%", perc) |
||
1534 | end |
||
1535 | return text |
||
1536 | end |
||
1537 | |||
1538 | |||
1539 | |||
1540 | |||
1541 | |||
1542 | |||
1543 | -- Blizzard hide and show |
||
1544 | |||
1545 | function aUF:UpdateBlizzVisibility() |
||
1546 | if aUF.db.profile.BlizFramesVisibility.HidePlayerFrame == true then |
||
1547 | aUF:HideBlizzPlayer() |
||
1548 | else |
||
1549 | aUF:ShowBlizzPlayer() |
||
1550 | end |
||
1551 | if aUF.db.profile.BlizFramesVisibility.HidePartyFrame == true then |
||
1552 | aUF:HideBlizzParty() |
||
1553 | else |
||
1554 | aUF:ShowBlizzParty() |
||
1555 | end |
||
1556 | if aUF.db.profile.BlizFramesVisibility.HideTargetFrame == true then |
||
1557 | aUF:HideBlizzTarget() |
||
1558 | else |
||
1559 | aUF:ShowBlizzTarget() |
||
1560 | end |
||
1561 | end |
||
1562 | |||
1563 | function aUF:HideBlizzPlayer() |
||
1564 | PlayerFrame:UnregisterEvent("UNIT_LEVEL") |
||
1565 | PlayerFrame:UnregisterEvent("UNIT_COMBAT") |
||
1566 | PlayerFrame:UnregisterEvent("UNIT_SPELLMISS") |
||
1567 | PlayerFrame:UnregisterEvent("UNIT_PVP_UPDATE") |
||
1568 | PlayerFrame:UnregisterEvent("UNIT_MAXMANA") |
||
1569 | PlayerFrame:UnregisterEvent("PLAYER_ENTER_COMBAT") |
||
1570 | PlayerFrame:UnregisterEvent("PLAYER_LEAVE_COMBAT") |
||
1571 | PlayerFrame:UnregisterEvent("PLAYER_UPDATE_RESTING") |
||
1572 | PlayerFrame:UnregisterEvent("PARTY_MEMBERS_CHANGED") |
||
1573 | PlayerFrame:UnregisterEvent("PARTY_LEADER_CHANGED") |
||
1574 | PlayerFrame:UnregisterEvent("PARTY_LOOT_METHOD_CHANGED") |
||
1575 | PlayerFrame:UnregisterEvent("PLAYER_ENTERING_WORLD") |
||
1576 | PlayerFrame:UnregisterEvent("PLAYER_REGEN_DISABLED") |
||
1577 | PlayerFrame:UnregisterEvent("PLAYER_REGEN_ENABLED") |
||
1578 | PlayerFrameHealthBar:UnregisterEvent("UNIT_HEALTH") |
||
1579 | PlayerFrameHealthBar:UnregisterEvent("UNIT_MAXHEALTH") |
||
1580 | PlayerFrameManaBar:UnregisterEvent("UNIT_MANA") |
||
1581 | PlayerFrameManaBar:UnregisterEvent("UNIT_RAGE") |
||
1582 | PlayerFrameManaBar:UnregisterEvent("UNIT_FOCUS") |
||
1583 | PlayerFrameManaBar:UnregisterEvent("UNIT_ENERGY") |
||
1584 | PlayerFrameManaBar:UnregisterEvent("UNIT_HAPPINESS") |
||
1585 | PlayerFrameManaBar:UnregisterEvent("UNIT_MAXMANA") |
||
1586 | PlayerFrameManaBar:UnregisterEvent("UNIT_MAXRAGE") |
||
1587 | PlayerFrameManaBar:UnregisterEvent("UNIT_MAXFOCUS") |
||
1588 | PlayerFrameManaBar:UnregisterEvent("UNIT_MAXENERGY") |
||
1589 | PlayerFrameManaBar:UnregisterEvent("UNIT_MAXHAPPINESS") |
||
1590 | PlayerFrameManaBar:UnregisterEvent("UNIT_DISPLAYPOWER") |
||
1591 | PlayerFrame:UnregisterEvent("UNIT_NAME_UPDATE") |
||
1592 | PlayerFrame:UnregisterEvent("UNIT_PORTRAIT_UPDATE") |
||
1593 | PlayerFrame:UnregisterEvent("UNIT_DISPLAYPOWER") |
||
1594 | PlayerFrame:Hide() |
||
1595 | end |
||
1596 | |||
1597 | function aUF:ShowBlizzPlayer() |
||
1598 | PlayerFrame:RegisterEvent("UNIT_LEVEL") |
||
1599 | PlayerFrame:RegisterEvent("UNIT_COMBAT") |
||
1600 | PlayerFrame:RegisterEvent("UNIT_SPELLMISS") |
||
1601 | PlayerFrame:RegisterEvent("UNIT_PVP_UPDATE") |
||
1602 | PlayerFrame:RegisterEvent("UNIT_MAXMANA") |
||
1603 | PlayerFrame:RegisterEvent("PLAYER_ENTER_COMBAT") |
||
1604 | PlayerFrame:RegisterEvent("PLAYER_LEAVE_COMBAT") |
||
1605 | PlayerFrame:RegisterEvent("PLAYER_UPDATE_RESTING") |
||
1606 | PlayerFrame:RegisterEvent("PARTY_MEMBERS_CHANGED") |
||
1607 | PlayerFrame:RegisterEvent("PARTY_LEADER_CHANGED") |
||
1608 | PlayerFrame:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") |
||
1609 | PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD") |
||
1610 | PlayerFrame:RegisterEvent("PLAYER_REGEN_DISABLED") |
||
1611 | PlayerFrame:RegisterEvent("PLAYER_REGEN_ENABLED") |
||
1612 | PlayerFrameHealthBar:RegisterEvent("UNIT_HEALTH") |
||
1613 | PlayerFrameHealthBar:RegisterEvent("UNIT_MAXHEALTH") |
||
1614 | PlayerFrameManaBar:RegisterEvent("UNIT_MANA") |
||
1615 | PlayerFrameManaBar:RegisterEvent("UNIT_RAGE") |
||
1616 | PlayerFrameManaBar:RegisterEvent("UNIT_FOCUS") |
||
1617 | PlayerFrameManaBar:RegisterEvent("UNIT_ENERGY") |
||
1618 | PlayerFrameManaBar:RegisterEvent("UNIT_HAPPINESS") |
||
1619 | PlayerFrameManaBar:RegisterEvent("UNIT_MAXMANA") |
||
1620 | PlayerFrameManaBar:RegisterEvent("UNIT_MAXRAGE") |
||
1621 | PlayerFrameManaBar:RegisterEvent("UNIT_MAXFOCUS") |
||
1622 | PlayerFrameManaBar:RegisterEvent("UNIT_MAXENERGY") |
||
1623 | PlayerFrameManaBar:RegisterEvent("UNIT_MAXHAPPINESS") |
||
1624 | PlayerFrameManaBar:RegisterEvent("UNIT_DISPLAYPOWER") |
||
1625 | PlayerFrame:RegisterEvent("UNIT_NAME_UPDATE") |
||
1626 | PlayerFrame:RegisterEvent("UNIT_PORTRAIT_UPDATE") |
||
1627 | PlayerFrame:RegisterEvent("UNIT_DISPLAYPOWER") |
||
1628 | PlayerFrame:Show() |
||
1629 | end |
||
1630 | |||
1631 | function aUF:HideBlizzParty() |
||
1632 | self:Hook("RaidOptionsFrame_UpdatePartyFrames", function() end) |
||
1633 | for i=1,4 do |
||
1634 | local frame = getglobal("PartyMemberFrame"..i) |
||
1635 | frame:UnregisterAllEvents() |
||
1636 | frame:Hide() |
||
1637 | end |
||
1638 | end |
||
1639 | |||
1640 | function aUF:ShowBlizzParty() |
||
1641 | self:Unhook("RaidOptionsFrame_UpdatePartyFrames") |
||
1642 | for i=1,4 do |
||
1643 | local frame = getglobal("PartyMemberFrame"..i) |
||
1644 | frame:RegisterEvent("PARTY_MEMBERS_CHANGED") |
||
1645 | frame:RegisterEvent("PARTY_LEADER_CHANGED") |
||
1646 | frame:RegisterEvent("PARTY_MEMBER_ENABLE") |
||
1647 | frame:RegisterEvent("PARTY_MEMBER_DISABLE") |
||
1648 | frame:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") |
||
1649 | frame:RegisterEvent("UNIT_PVP_UPDATE") |
||
1650 | frame:RegisterEvent("UNIT_AURA") |
||
1651 | frame:RegisterEvent("UNIT_PET") |
||
1652 | frame:RegisterEvent("VARIABLES_LOADED") |
||
1653 | frame:RegisterEvent("UNIT_NAME_UPDATE") |
||
1654 | frame:RegisterEvent("UNIT_PORTRAIT_UPDATE") |
||
1655 | frame:RegisterEvent("UNIT_DISPLAYPOWER") |
||
1656 | |||
1657 | UnitFrame_OnEvent("PARTY_MEMBERS_CHANGED") |
||
1658 | |||
1659 | PartyMemberFrame_UpdateMember() |
||
1660 | end |
||
1661 | end |
||
1662 | |||
1663 | function aUF:HideBlizzTarget() |
||
1664 | TargetFrame:UnregisterEvent("PLAYER_TARGET_CHANGED") |
||
1665 | TargetFrame:UnregisterEvent("UNIT_HEALTH") |
||
1666 | TargetFrame:UnregisterEvent("UNIT_LEVEL") |
||
1667 | TargetFrame:UnregisterEvent("UNIT_FACTION") |
||
1668 | TargetFrame:UnregisterEvent("UNIT_CLASSIFICATION_CHANGED") |
||
1669 | TargetFrame:UnregisterEvent("UNIT_AURA") |
||
1670 | TargetFrame:UnregisterEvent("PLAYER_FLAGS_CHANGED") |
||
1671 | TargetFrame:UnregisterEvent("PARTY_MEMBERS_CHANGED") |
||
1672 | TargetFrame:Hide() |
||
1673 | |||
1674 | ComboFrame:UnregisterEvent("PLAYER_TARGET_CHANGED") |
||
1675 | ComboFrame:UnregisterEvent("PLAYER_COMBO_POINTS") |
||
1676 | end |
||
1677 | |||
1678 | function aUF:ShowBlizzTarget() |
||
1679 | TargetFrame:RegisterEvent("PLAYER_TARGET_CHANGED") |
||
1680 | TargetFrame:RegisterEvent("UNIT_HEALTH") |
||
1681 | TargetFrame:RegisterEvent("UNIT_LEVEL") |
||
1682 | TargetFrame:RegisterEvent("UNIT_FACTION") |
||
1683 | TargetFrame:RegisterEvent("UNIT_CLASSIFICATION_CHANGED") |
||
1684 | TargetFrame:RegisterEvent("UNIT_AURA") |
||
1685 | TargetFrame:RegisterEvent("PLAYER_FLAGS_CHANGED") |
||
1686 | TargetFrame:RegisterEvent("PARTY_MEMBERS_CHANGED") |
||
1687 | TargetFrame:Show() |
||
1688 | |||
1689 | ComboFrame:RegisterEvent("PLAYER_TARGET_CHANGED") |
||
1690 | ComboFrame:RegisterEvent("PLAYER_COMBO_POINTS") |
||
1691 | end |
||
1692 | |||
1693 | |||
1694 | function aUF:tonum(val, base) |
||
1695 | return tonumber((val or 0), base) or 0 |
||
1696 | end |
||
1697 | |||
1698 | function aUF:round(num) |
||
1699 | return floor(aUF:tonum(num)+.5) |
||
1700 | end |