vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local dewdrop = AceLibrary("Dewdrop-2.0") |
2 | local tablet = AceLibrary("Tablet-2.0") |
||
3 | local metro = AceLibrary("Metrognome-2.0") |
||
4 | |||
5 | FuXP = AceLibrary("AceAddon-2.0"):new("FuBarPlugin-2.0", "AceDB-2.0", "AceEvent-2.0", "AceConsole-2.0") |
||
6 | |||
7 | local defaults = { |
||
8 | Shadow = true, |
||
9 | ShowRemaining = false, |
||
10 | Thickness = 2, |
||
11 | Spark = 1, |
||
12 | Spark2 = 1, |
||
13 | XP = {0, 0.4,.9,1}, |
||
14 | Rest = {1, 0.2, 1, 1}, |
||
15 | None = {0.3,0.3,0.3,1}, |
||
16 | } |
||
17 | |||
18 | FuXP:RegisterDB("FuXPDB") |
||
19 | FuXP:RegisterDefaults('profile', defaults); |
||
20 | |||
21 | local L = AceLibrary("AceLocale-2.0"):new("FuXP") |
||
22 | |||
23 | function FuXP:GetXPColor() |
||
24 | return self.db.profile.XP[1], self.db.profile.XP[2], self.db.profile.XP[3] |
||
25 | end |
||
26 | |||
27 | function FuXP:SetXPColor(r, g, b) |
||
28 | self.db.profile.XP[1] = r |
||
29 | self.db.profile.XP[2] = g |
||
30 | self.db.profile.XP[3] = b |
||
31 | self.XPBarTex:SetVertexColor(r, g, b, 1) |
||
32 | self.Spark:SetVertexColor(r, g, b, 1) |
||
33 | end |
||
34 | |||
35 | function FuXP:GetRestColor() |
||
36 | return self.db.profile.Rest[1], self.db.profile.Rest[2], self.db.profile.Rest[3] |
||
37 | end |
||
38 | |||
39 | function FuXP:SetRestColor(r, g, b) |
||
40 | self.db.profile.Rest[1] = r |
||
41 | self.db.profile.Rest[2] = g |
||
42 | self.db.profile.Rest[3] = b |
||
43 | self.RestedXPTex:SetVertexColor(r, g, b, 1) |
||
44 | end |
||
45 | |||
46 | function FuXP:GetNoXPColor() |
||
47 | return self.db.profile.None[1], self.db.profile.None[2], self.db.profile.None[3] |
||
48 | end |
||
49 | |||
50 | function FuXP:SetNoXPColor(r, g, b) |
||
51 | self.db.profile.None[1] = r |
||
52 | self.db.profile.None[2] = g |
||
53 | self.db.profile.None[3] = b |
||
54 | self.NoXPTex:SetVertexColor(r, g, b, 1) |
||
55 | end |
||
56 | |||
57 | local optionsTable = { |
||
58 | type = 'group', |
||
59 | args = { |
||
60 | currentXP = { |
||
61 | type = "color", |
||
62 | name = L["Current XP"], |
||
63 | desc = L["Sets the color of the XP Bar"], |
||
64 | get = "GetXPColor", |
||
65 | set = "SetXPColor", |
||
66 | order = 110, |
||
67 | }, |
||
68 | restedXP = { |
||
69 | type = 'color', |
||
70 | name = L["Rested XP"], |
||
71 | desc = L["Sets the color of the Rested Bar"], |
||
72 | get = "GetRestColor", |
||
73 | set = "SetRestColor", |
||
74 | order = 111, |
||
75 | }, |
||
76 | color = { |
||
77 | type = 'color', |
||
78 | name = L["No XP"], |
||
79 | desc = L["Sets the empty color of the XP Bar"], |
||
80 | get = "GetNoXPColor", |
||
81 | set = "SetNoXPColor", |
||
82 | order = 112, |
||
83 | }, |
||
84 | spark = { |
||
85 | type = 'range', |
||
86 | name = L["Spark intensity"], |
||
87 | desc = L["Brightness level of Spark"], |
||
88 | get = function() return FuXP.db.profile.Spark end, |
||
89 | set = function(v) |
||
90 | FuXP.db.profile.Spark = v |
||
91 | FuXP.Spark:SetAlpha(v) |
||
92 | FuXP.Spark2:SetAlpha(v) |
||
93 | end, |
||
94 | min = 0, |
||
95 | max = 1, |
||
96 | step = 0.05, |
||
97 | order = 113 |
||
98 | }, |
||
99 | thickness = { |
||
100 | type = 'range', |
||
101 | name = L["Thickness"], |
||
102 | desc = L["Sets thickness of XP Bar"], |
||
103 | get = function() return FuXP.db.profile.Thickness end, |
||
104 | set = function(v) |
||
105 | FuXP:SetThickness(v) |
||
106 | end, |
||
107 | min = 1.5, |
||
108 | max = 8, |
||
109 | step = 0.1, |
||
110 | order = 114 |
||
111 | }, |
||
112 | shadow = { |
||
113 | type = 'toggle', |
||
114 | name = L["Shadow"], |
||
115 | desc = L["Toggles Shadow under XP Bar"], |
||
116 | get = function() return FuXP.db.profile.Shadow end, |
||
117 | set = function() |
||
118 | FuXP.db.profile.Shadow = not FuXP.db.profile.Shadow |
||
119 | if FuXP.db.profile.Shadow then FuXP.Border:Show() else FuXP.Border:Hide() end |
||
120 | end, |
||
121 | order = 115 |
||
122 | }, |
||
123 | remaining = { |
||
124 | type = 'toggle', |
||
125 | name = L["Remaining"], |
||
126 | desc = L["Show Remaining in Bar"], |
||
127 | get = function() return FuXP.db.profile.ShowRemaining end, |
||
128 | set = function() |
||
129 | FuXP.db.profile.ShowRemaining = not FuXP.db.profile.ShowRemaining |
||
130 | end, |
||
131 | order = 116 |
||
132 | }, |
||
133 | } |
||
134 | } |
||
135 | |||
136 | FuXP.version = "2.0." .. string.sub("$Revision: 7495 $", 12, -3) |
||
137 | FuXP.hasIcon = true |
||
138 | FuXP.cannotDetachTooltip = true |
||
139 | FuXP.defaultPosition = "LEFT" |
||
140 | FuXP.hideWithoutStandby = true |
||
141 | FuXP.cannotAttachToMinimap = true |
||
142 | FuXP:RegisterChatCommand(L:GetTable("AceConsole-commands"), optionsTable) |
||
143 | FuXP.OnMenuRequest = optionsTable |
||
144 | |||
145 | function FuXP:OnInitialize() |
||
146 | local XPBar = CreateFrame("Frame", "FuXPBar", UIParent) |
||
147 | local tex = XPBar:CreateTexture("XPBarTex") |
||
148 | XPBar:SetFrameStrata("HIGH") |
||
149 | tex:SetTexture("Interface\\AddOns\\FuBar_FuXPFu\\Textures\\texture.tga") |
||
150 | tex:SetVertexColor(self.db.profile.XP[1], self.db.profile.XP[2], self.db.profile.XP[3], self.db.profile.XP[4]) |
||
151 | tex:ClearAllPoints() |
||
152 | tex:SetAllPoints(XPBar) |
||
153 | tex:Show() |
||
154 | XPBar:SetHeight(self.db.profile.Thickness) |
||
155 | |||
156 | local spark = XPBar:CreateTexture("XPSpark", "OVERLAY") |
||
157 | spark:SetTexture("Interface\\AddOns\\FuBar_FuXPFu\\Textures\\glow.tga") |
||
158 | spark:SetWidth(128) |
||
159 | spark:SetHeight((self.db.profile.Thickness) * 8) |
||
160 | spark:SetVertexColor(self.db.profile.XP[1], self.db.profile.XP[2], self.db.profile.XP[3], self.db.profile.Spark or 1) |
||
161 | spark:SetBlendMode("ADD") |
||
162 | |||
163 | local spark2 = XPBar:CreateTexture("XPSpark2", "OVERLAY") |
||
164 | spark2:SetTexture("Interface\\AddOns\\FuBar_FuXPFu\\Textures\\glow2.tga") |
||
165 | spark2:SetWidth(128) |
||
166 | spark2:SetAlpha(self.db.profile.Spark or 1) |
||
167 | spark2:SetHeight((self.db.profile.Thickness) * 8) |
||
168 | spark2:SetBlendMode("ADD") |
||
169 | |||
170 | local RestedXP = CreateFrame("Frame", "FuRestXPBar", UIParent) |
||
171 | local restex = RestedXP:CreateTexture("RestedXPTex") |
||
172 | restex:SetTexture("Interface\\AddOns\\FuBar_FuXPFu\\Textures\\texture.tga") |
||
173 | restex:SetVertexColor(self.db.profile.Rest[1], self.db.profile.Rest[2], self.db.profile.Rest[3], self.db.profile.Rest[4]) |
||
174 | restex:ClearAllPoints() |
||
175 | restex:Show() |
||
176 | restex:SetAllPoints(RestedXP) |
||
177 | RestedXP:SetHeight(self.db.profile.Thickness) |
||
178 | |||
179 | local NoXP = CreateFrame("Frame", "FuNoXPBar", UIParent) |
||
180 | local notex = NoXP:CreateTexture("NoXPTex") |
||
181 | notex:SetTexture("Interface\\AddOns\\FuBar_FuXPFu\\Textures\\texture.tga") |
||
182 | notex:SetVertexColor(self.db.profile.None[1], self.db.profile.None[2], self.db.profile.None[3], self.db.profile.None[4]) |
||
183 | notex:ClearAllPoints() |
||
184 | notex:Show() |
||
185 | notex:SetAllPoints(NoXP) |
||
186 | NoXP:SetHeight(self.db.profile.Thickness) |
||
187 | |||
188 | local Border = CreateFrame("Frame", "BottomBorder", UIParent) |
||
189 | local bordtex = Border:CreateTexture("BottomBorderTex") |
||
190 | bordtex:SetTexture("Interface\\AddOns\\FuBar_FuXPFu\\Textures\\border.tga") |
||
191 | bordtex:SetVertexColor(0, 0, 0, 1) |
||
192 | bordtex:ClearAllPoints() |
||
193 | bordtex:SetAllPoints(Border) |
||
194 | Border:SetHeight(5) |
||
195 | if not self.db.profile.Shadow then |
||
196 | Border:Hide() |
||
197 | end |
||
198 | |||
199 | |||
200 | self.XPBar = XPBar |
||
201 | self.XPBarTex = tex |
||
202 | self.Spark = spark |
||
203 | self.Spark2 = spark2 |
||
204 | self.NoXP = NoXP |
||
205 | self.NoXPTex = notex |
||
206 | self.RestedXP = RestedXP |
||
207 | self.RestedXPTex = restex |
||
208 | self.Border = Border |
||
209 | self.BorderTex = bordtex |
||
210 | self.Spark:SetParent(self.XPBar) |
||
211 | self.Spark2:SetParent(self.XPBar) |
||
212 | self.RestedXP:SetParent(self.XPBar) |
||
213 | self.NoXP:SetParent(self.XPBar) |
||
214 | self.Border:SetParent(self.XPBar) |
||
215 | metro:Register("XPFuBar", self.Reanchor, 3, self) |
||
216 | metro:Register(self.name, self.Update, 1, self) |
||
217 | end |
||
218 | |||
219 | function FuXP:OnEnable() |
||
220 | self:RegisterEvent("UPDATE_EXHAUSTION", "UpdateBars") |
||
221 | self:RegisterEvent("PLAYER_XP_UPDATE", "UpdateBars") |
||
222 | self:RegisterEvent("UPDATE_FACTION", "UpdateBars") |
||
223 | self:RegisterEvent("FuBar_ChangedPanels") |
||
224 | metro:Start("XPFuBar") |
||
225 | metro:Start(self.name) |
||
226 | MainMenuExpBar:Hide() |
||
227 | ReputationWatchBar:Hide() |
||
228 | ExhaustionTick:Hide() |
||
229 | end |
||
230 | |||
231 | function FuXP:OnDisable() |
||
232 | -- you do not need to unregister the event here, all events/hooks are unregistered on disable implicitly. |
||
233 | self:Print("Disabling") |
||
234 | self:HideBar() |
||
235 | MainMenuExpBar:Show() |
||
236 | ReputationWatchBar:Show() |
||
237 | ExhaustionTick:Show() |
||
238 | end |
||
239 | |||
240 | function FuXP:FuBar_ChangedPanels() |
||
241 | if(self.Loaded) then |
||
242 | self:Reanchor() |
||
243 | end |
||
244 | end |
||
245 | |||
246 | function FuXP:Reanchor() |
||
247 | local point, relpoint, y |
||
248 | |||
249 | if(self.panel) then |
||
250 | metro:Stop("XPFuBar") |
||
251 | else |
||
252 | return |
||
253 | end |
||
254 | |||
255 | self.Loaded = true |
||
256 | self.Panel = self.panel |
||
257 | |||
258 | if(self.Panel:GetAttachPoint() == "BOTTOM") then |
||
259 | self.Side = "BOTTOM" |
||
260 | self.FuPanel = FuBar:GetTopmostBottomPanel() |
||
261 | point = "BOTTOMLEFT" |
||
262 | relpoint = "TOPLEFT" |
||
263 | self.BorderTex:SetTexCoord(1,0,1,0) |
||
264 | else |
||
265 | self.Side = "TOP" |
||
266 | self.FuPanel = FuBar:GetBottommostTopPanel() |
||
267 | point = "TOPLEFT" |
||
268 | relpoint = "BOTTOMLEFT" |
||
269 | self.BorderTex:SetTexCoord(1,0,0,1) |
||
270 | end |
||
271 | if(not self.FuPanel) then |
||
272 | self.FuPanel = self.panel |
||
273 | end |
||
274 | self.XPBar:ClearAllPoints() |
||
275 | self.Spark:ClearAllPoints() |
||
276 | self.Spark2:ClearAllPoints() |
||
277 | self.RestedXP:ClearAllPoints() |
||
278 | self.NoXP:ClearAllPoints() |
||
279 | self.Border:ClearAllPoints() |
||
280 | self.XPBar:SetParent(self.FuPanel.frame) |
||
281 | self.XPBar:SetPoint(point, self.FuPanel.frame, relpoint, 0, y or 0) |
||
282 | self.Spark:SetPoint("RIGHT", self.XPBar, "RIGHT",11,0 ) |
||
283 | self.Spark2:SetPoint("RIGHT", self.XPBar, "RIGHT",11,0 ) |
||
284 | self.RestedXP:SetPoint("LEFT", self.XPBar, "RIGHT") |
||
285 | self.NoXP:SetPoint("LEFT", self.RestedXP, "RIGHT") |
||
286 | self.Border:SetPoint(point, self.XPBar, relpoint) |
||
287 | self:ShowBar() |
||
288 | self:UpdateBars() |
||
289 | end |
||
290 | |||
291 | function FuXP:ShowBar() |
||
292 | self.XPBar:Show() |
||
293 | self.Spark:Show() |
||
294 | self.Spark2:Show() |
||
295 | self.RestedXP:Show() |
||
296 | self.NoXP:Show() |
||
297 | end |
||
298 | |||
299 | function FuXP:HideBar() |
||
300 | self.XPBar:Hide() |
||
301 | self.Spark:Hide() |
||
302 | self.Spark2:Hide() |
||
303 | self.RestedXP:Hide() |
||
304 | self.NoXP:Hide() |
||
305 | end |
||
306 | |||
307 | function FuXP:SetThickness(thickness) |
||
308 | self.XPBar:SetHeight(thickness) |
||
309 | self.Spark:SetHeight((thickness) * 8) |
||
310 | self.Spark2:SetHeight((thickness) * 8) |
||
311 | self.RestedXP:SetHeight(thickness) |
||
312 | self.NoXP:SetHeight(thickness) |
||
313 | self.db.profile.Thickness = thickness |
||
314 | end |
||
315 | |||
316 | function FuXP:UpdateBars() |
||
317 | if(not self.Loaded) then return end |
||
318 | |||
319 | local name, standing, minRep, maxRep, currentRep = GetWatchedFactionInfo() |
||
320 | local total = self.Panel.frame:GetWidth() |
||
321 | |||
322 | self.XPBar:SetWidth(0.001) |
||
323 | self.RestedXP:SetWidth(0.001) |
||
324 | self.NoXP:SetWidth(0.001) |
||
325 | self.Border:SetWidth(total) |
||
326 | |||
327 | if(not name) then |
||
328 | if(UnitLevel("player") == 60) then |
||
329 | self.NoXP:SetWidth(total) |
||
330 | return |
||
331 | end |
||
332 | local currentXP = UnitXP("player") |
||
333 | local maxXP = UnitXPMax("player") |
||
334 | local restXP = GetXPExhaustion() or 0 |
||
335 | local remainXP = maxXP - (currentXP + restXP) |
||
336 | |||
337 | if(remainXP <= 0) then remainXP = 0 end |
||
338 | |||
339 | self.XPBar:SetWidth((currentXP/maxXP)*total) |
||
340 | if(((restXP + currentXP)/maxXP) > 1) then |
||
341 | self.RestedXP:SetWidth(total - self.XPBar:GetWidth()) |
||
342 | else |
||
343 | self.RestedXP:SetWidth((restXP/maxXP)*total + 0.001) |
||
344 | end |
||
345 | self.NoXP:SetWidth((remainXP/maxXP)*total) |
||
346 | else |
||
347 | self.XPBar:SetWidth(((currentRep - minRep)/(maxRep-minRep))*total) |
||
348 | self.RestedXP:SetWidth(0.0001) |
||
349 | self.NoXP:SetWidth(((maxRep - currentRep)/(maxRep - minRep))*total) |
||
350 | end |
||
351 | end |
||
352 | |||
353 | function FuXP:UpdateText() |
||
354 | if(not self.Loaded) then return end |
||
355 | if(GetWatchedFactionInfo()) then |
||
356 | local name, standing, minRep, maxRep, currentRep = GetWatchedFactionInfo() |
||
357 | if(self.Type == "XP") then |
||
358 | self:UpdateBars() |
||
359 | end |
||
360 | if(self.db.profile.ShowRemaining) then |
||
361 | self:SetText(string.format(L["%s:%s %3.0f%% left (%s/%s)"], name, maxRep - currentRep, ((currentRep-minRep)/(maxRep-minRep))*100 , currentRep-minRep, maxRep-minRep)) |
||
362 | else |
||
363 | self:SetText("FuRepFu") |
||
364 | end |
||
365 | self.Type = "Rep" |
||
366 | else |
||
367 | if(self.Type == "Rep") then |
||
368 | self:UpdateBars() |
||
369 | end |
||
370 | if(self.db.profile.ShowRemaining) then |
||
371 | self:SetText(string.format(L["%s to go (%3.0f%%)"], UnitXPMax("player") - UnitXP("player"), ((UnitXPMax("player") - UnitXP("player"))/UnitXPMax("player"))*100 )) |
||
372 | else |
||
373 | self:SetText("FuXPFu") |
||
374 | end |
||
375 | self.Type = "XP" |
||
376 | end |
||
377 | end |
||
378 | |||
379 | function FuXP:OnTooltipUpdate() |
||
380 | if(not self.Loaded) then return end |
||
381 | |||
382 | local totalXP = UnitXPMax("player") |
||
383 | local currentXP = UnitXP("player") |
||
384 | local toLevelXP = totalXP - currentXP |
||
385 | local xp = tablet:AddCategory( |
||
386 | 'columns', 2 |
||
387 | ) |
||
388 | local name, standing, minRep, maxRep, currentRep = GetWatchedFactionInfo() |
||
389 | |||
390 | self:UpdateBars() |
||
391 | |||
392 | if(self.panel:GetAttachPoint() ~= self.Side) then |
||
393 | self:Reanchor() |
||
394 | end |
||
395 | |||
396 | if(not name) then |
||
397 | xp:AddLine( |
||
398 | 'text', L["Current XP"], |
||
399 | 'text2', string.format("%s/%s (%3.0f%%)", currentXP,totalXP, (currentXP/totalXP)*100) |
||
400 | ) |
||
401 | xp:AddLine( |
||
402 | 'text', L["To Level"], |
||
403 | 'text2', toLevelXP |
||
404 | ) |
||
405 | if(GetXPExhaustion()) then |
||
406 | xp:AddLine( |
||
407 | 'text', L["Rested XP"], |
||
408 | 'text2', string.format("%d (%2.f%%)", GetXPExhaustion(), (GetXPExhaustion()/totalXP)*100) |
||
409 | ) |
||
410 | end |
||
411 | tablet:SetHint(L["Click to send your current xp to an open editbox."]) |
||
412 | else |
||
413 | xp:AddLine( |
||
414 | 'text', L["Faction"], |
||
415 | 'text2', name |
||
416 | ) |
||
417 | xp:AddLine( |
||
418 | 'text', L["Rep to next standing"], |
||
419 | 'text2', maxRep - currentRep |
||
420 | ) |
||
421 | xp:AddLine( |
||
422 | 'text', L["Current rep"], |
||
423 | 'text2', getglobal("FACTION_STANDING_LABEL"..standing) |
||
424 | ) |
||
425 | tablet:SetHint(L["Click to send your current rep to an open editbox."]) |
||
426 | end |
||
427 | end |
||
428 | |||
429 | function FuXP:OnClick() |
||
430 | local totalXP = UnitXPMax("player") |
||
431 | local currentXP = UnitXP("player") |
||
432 | local toLevelXP = totalXP - currentXP |
||
433 | local name, standing, minRep, maxRep, currentRep = GetWatchedFactionInfo() |
||
434 | |||
435 | if(not name) then |
||
436 | DEFAULT_CHAT_FRAME.editBox:SetText(string.format(L["%s/%s (%3.0f%%) %d to go"], currentXP,totalXP, (currentXP/totalXP)*100, totalXP - currentXP)) |
||
437 | else |
||
438 | DEFAULT_CHAT_FRAME.editBox:SetText(string.format(L["%s:%s/%s (%3.2f%%) Currently %s with %d to go"], |
||
439 | name, |
||
440 | currentRep - minRep, |
||
441 | maxRep - minRep, |
||
442 | (currentRep-minRep)/(maxRep-minRep)*100, |
||
443 | getglobal("FACTION_STANDING_LABEL"..standing), |
||
444 | maxRep - currentRep)) |
||
445 | end |
||
446 | end |