vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local module = ArcHUD:NewModule("DruidMana")
2 module.unit = "player"
3 module.defaults = {
4 Enabled = false,
5 Outline = true,
6 ShowText = true,
7 ShowPerc = true,
8 Side = 2,
9 Level = 1,
10 }
11 module.options = {
12 {name = "ShowText", text = "SHOWTEXT", tooltip = "SHOWTEXT"},
13 {name = "ShowPerc", text = "SHOWPERC", tooltip = "SHOWPERC"},
14 attach = true,
15 }
16 module.localized = true
17  
18 function module:Initialize()
19 -- Setup the frame we need
20 self.f = self:CreateRing(true, ArcHUDFrame)
21 self.f:SetAlpha(0)
22  
23 self.MPText = self:CreateFontString(self.f, "BACKGROUND", {150, 13}, 12, "LEFT", {0.0, 1.0, 1.0}, {"TOPLEFT", ArcHUDFrameCombo, "TOPRIGHT", 0, 14})
24 self.MPPerc = self:CreateFontString(self.f, "BACKGROUND", {70, 12}, 10, "LEFT", {1.0, 1.0, 1.0}, {"TOPLEFT", self.parent:GetModule("Mana").MPPerc, "TOPRIGHT", 0, -1})
25  
26 -- Override Update timer
27 self:RegisterMetro(self.name .. "Update", self.UpdateAlpha, 0.05, self)
28  
29 -- Add timer for DruidBar
30 self:RegisterMetro(self.name .. "DruidBarUpdate", self.DruidBarUpdate, 0.5, self)
31 end
32  
33 function module:Update()
34 if(self.db.profile.ShowText) then
35 self.MPText:Show()
36 else
37 self.MPText:Hide()
38 end
39  
40 if(self.db.profile.ShowPerc) then
41 self.MPPerc:Show()
42 else
43 self.MPPerc:Hide()
44 end
45  
46 if(self.db.profile.Outline) then
47 self.f.BG:Show()
48 else
49 self.f.BG:Hide()
50 end
51  
52 -- Clear all points for the ring
53 self.f:ClearAllPoints()
54 self.f:SetValue(0)
55 if(self.db.profile.Side == 1) then
56 -- Attach to left side
57 self.f:SetPoint("TOPLEFT", self.parent:GetModule("Anchors").Left, "TOPLEFT", self.db.profile.Level * -15, 0)
58 self.f.BG:SetReversed(false)
59 self.f:SetReversed(false)
60 else
61 -- Attach to right side
62 self.f:SetPoint("TOPRIGHT", self.parent:GetModule("Anchors").Right, "TOPRIGHT", self.db.profile.Level * 15, 0)
63 self.f.BG:SetReversed(true)
64 self.f:SetReversed(true)
65 end
66 self.f.BG:SetAngle(180)
67 end
68  
69 function module:Enable()
70 self.f:UpdateColor({r=0.0, g=0.0, b=1.0})
71  
72 -- Don't go further if player is not a druid
73 local _, class = UnitClass(self.unit)
74 if(class ~= "DRUID") then return end
75  
76 -- Register the events we will use
77 self:RegisterEvent("UNIT_DISPLAYPOWER")
78  
79 -- Activate the timers
80 self:StartMetro(self.name .. "Alpha")
81 self:StartMetro(self.name .. "Fade")
82 self:StartMetro(self.name .. "Update")
83  
84 -- Check if we have any druid mana addons loaded
85 if(DruidBarKey) then
86 -- We got DruidBar
87 self:StartMetro(self.name .. "DruidBarUpdate")
88  
89 self.gotAddon = true
90 elseif(SoleManax) then
91 -- We got SoleManax
92 SoleManax:AddUser(self.UpdateMana, true, self)
93 --self:UpdateMana(SoleManax:GetPlayerMana())
94  
95 self.gotAddon = true
96 end
97  
98 self.f:Show()
99 end
100  
101 function module:Disable()
102 if(SoleManax) then
103 SoleManax:DelUser(self.UpdateMana)
104 end
105 end
106  
107 function module:UpdateAlpha()
108 if(self.doUpdates) then
109 if(self.f.startValue < self.f.maxValue and ArcHUD.PlayerIsInCombat) then
110 self.f:SetRingAlpha(ArcHUD.db.profile.FadeIC)
111 elseif(self.f.startValue < self.f.maxValue and not ArcHUD.PlayerIsInCombat) then
112 self.f:SetRingAlpha(ArcHUD.db.profile.FadeOOC)
113 else
114 self.f:SetRingAlpha(0)
115 end
116 else
117 self.f:SetRingAlpha(0)
118 end
119 end
120  
121 function module:DruidBarUpdate()
122 self:UpdateMana(DruidBarKey.keepthemana, DruidBarKey.maxmana)
123 end
124  
125 function module:UpdateMana(curMana, maxMana)
126 if(self.doUpdates) then
127 self.MPText:SetText(floor(curMana).."/"..floor(maxMana))
128 self.MPPerc:SetText(floor((curMana/maxMana)*100).."%")
129 self.f:SetMax(maxMana)
130 self.f:SetValue(curMana)
131 end
132 end
133  
134 function module:UNIT_DISPLAYPOWER()
135 if(arg1 ~= self.unit) then return end
136 if(UnitPowerType(self.unit) == 1 or UnitPowerType(self.unit) == 3 and not self.doUpdates) then
137 --Bear or Cat form
138 self.doUpdates = true
139 elseif(UnitPowerType(self.unit) == 0 and self.doUpdates) then
140 --player/aqua/travel
141 self.doUpdates = false
142 end
143 end