vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local dewdrop = DewdropLib:GetInstance('1.0') |
2 | local tablet = TabletLib:GetInstance('1.0') |
||
3 | local metro = Metrognome:GetInstance('1') |
||
4 | |||
5 | FuBar_Experienced = FuBarPlugin:GetInstance("1.2"):new({ |
||
6 | name = FuBar_ExperiencedLocals.NAME, |
||
7 | description = FuBar_ExperiencedLocals.DESCRIPTION, |
||
8 | version = "0.3.0", |
||
9 | releaseDate = "05-18-2006", |
||
10 | aceCompatible = 103, |
||
11 | author = "Tain", |
||
12 | email = "tain.dev@gmail.com", |
||
13 | website = "http://tain.wowinterface.com/", |
||
14 | category = "others", |
||
15 | db = AceDatabase:new("FuBar_ExperiencedDB"), |
||
16 | defaults = { |
||
17 | levelExp = TRUE, |
||
18 | levelExpPercent = TRUE, |
||
19 | restedExp = TRUE |
||
20 | }, |
||
21 | cmd = AceChatCmd:new(FuBar_ExperiencedLocals.CHATCMD, FuBar_ExperiencedLocals.CHATOPT), |
||
22 | locals = FuBar_ExperiencedLocals, |
||
23 | |||
24 | -- Methods |
||
25 | GetVar = function(self,var) |
||
26 | return self.data[var] and TRUE |
||
27 | end, |
||
28 | |||
29 | ToggleShowLevelExp = function(self, silent) |
||
30 | self.data.levelExp = not self.data.levelExp |
||
31 | if silent ~= TRUE then |
||
32 | self.cmd:status(self.locals.MENU_SHOW_LEVEL_XP, self:GetVar("levelExp"), FuBarUtils.MAP_ONOFF) |
||
33 | end |
||
34 | self:Update() |
||
35 | return self.data.levelExp |
||
36 | end, |
||
37 | |||
38 | ToggleShowToLevelExp = function(self, silent) |
||
39 | self.data.toLevelExp = not self.data.toLevelExp |
||
40 | if silent ~= TRUE then |
||
41 | self.cmd:status(self.locals.MENU_SHOW_TOLEVEL_XP, self:GetVar("toLevelExp"), FuBarUtils.MAP_ONOFF) |
||
42 | end |
||
43 | self:Update() |
||
44 | return self.data.toLevelExp |
||
45 | end, |
||
46 | |||
47 | ToggleShowLevelExpPercent = function(self, silent) |
||
48 | self.data.levelExpPercent = not self.data.levelExpPercent |
||
49 | if silent ~= TRUE then |
||
50 | self.cmd:status(self.locals.MENU_SHOW_LEVEL_XP_PERCENT, self:GetVar("levelExpPercent"), FuBarUtils.MAP_ONOFF) |
||
51 | end |
||
52 | self:Update() |
||
53 | return self.data.showExpPercent |
||
54 | end, |
||
55 | |||
56 | ToggleShowRestedExp = function(self, silent) |
||
57 | self.data.restedExp = not self.data.restedExp |
||
58 | if silent ~= TRUE then |
||
59 | self.cmd:status(self.locals.MENU_SHOW_RESTED_XP, self:GetVar("restedExp"), FuBarUtils.MAP_ONOFF) |
||
60 | end |
||
61 | self:Update() |
||
62 | return self.data.restedExp |
||
63 | end, |
||
64 | |||
65 | ToggleShowRestedExpPercent = function(self, silent) |
||
66 | self.data.restedExpPercent = not self.data.restedExpPercent |
||
67 | if silent ~= TRUE then |
||
68 | self.cmd:status(self.locals.MENU_SHOW_RESTED_XP_PERCENT, self:GetVar("restedExpPercent"), FuBarUtils.MAP_ONOFF) |
||
69 | end |
||
70 | self:Update() |
||
71 | return self.data.restedExpPercent |
||
72 | end, |
||
73 | |||
74 | ToggleShowAverageExp = function(self, silent) |
||
75 | self.data.averageExp = not self.data.averageExp |
||
76 | if silent ~= TRUE then |
||
77 | self.cmd:status(self.locals.MENU_SHOW_AVERAGE_XP_GAIN, self:GetVar("averageExp"), FuBarUtils.MAP_ONOFF) |
||
78 | end |
||
79 | self:Update() |
||
80 | return self.data.averageExp |
||
81 | end, |
||
82 | |||
83 | ToggleShowByLevel = function(self, silent) |
||
84 | self.data.byLevel = not self.data.byLevel |
||
85 | if silent ~= TRUE then |
||
86 | self.cmd:status(self.locals.MENU_SHOW_AVERAGE_XP_GAIN_BY_LEVEL, self:GetVar("byLevel"), FuBarUtils.MAP_ONOFF) |
||
87 | end |
||
88 | self:Update() |
||
89 | return self.data.byLevel |
||
90 | end, |
||
91 | |||
92 | Initialize = function(self) |
||
93 | self.initialXP = UnitXP("player") |
||
94 | end, |
||
95 | |||
96 | Enable = function(self) |
||
97 | self.timeSinceLastUpdate = 0 |
||
98 | self:RegisterEvent("PLAYER_XP_UPDATE", "OnPlayerXpUpdate") |
||
99 | self:RegisterEvent("PLAYER_LEVEL_UP", "OnPlayerLevelUp") |
||
100 | self:RegisterEvent("TIME_PLAYED_MSG", "OnTimePlayedMsg") |
||
101 | -- RequestTimePlayed() |
||
102 | metro:Register(self.name, self.Update, 2, self) |
||
103 | metro:Start(self.name) |
||
104 | end, |
||
105 | |||
106 | Disable = function(self) |
||
107 | end, |
||
108 | |||
109 | Report = function(self) |
||
110 | self.cmd:report({ |
||
111 | { |
||
112 | text=self.locals.MENU_SHOW_LEVEL_XP, |
||
113 | val=self:GetVar("levelExp"), |
||
114 | map=FuBarLocals.MAP_ONOFF |
||
115 | }, |
||
116 | { |
||
117 | text=self.locals.MENU_SHOW_TOLEVEL_XP, |
||
118 | val=self:GetVar("toLevelExp"), |
||
119 | map=FuBarLocals.MAP_ONOFF |
||
120 | }, |
||
121 | { |
||
122 | text=self.locals.MENU_SHOW_LEVEL_XP_PERCENT, |
||
123 | val=self:GetVar("levelExpPercent"), |
||
124 | map=FuBarLocals.MAP_ONOFF |
||
125 | }, |
||
126 | { |
||
127 | text=self.locals.MENU_SHOW_RESTED_XP, |
||
128 | val=self:GetVar("restedExp"), |
||
129 | map=FuBarLocals.MAP_ONOFF |
||
130 | }, |
||
131 | { |
||
132 | text=self.locals.MENU_SHOW_RESTED_XP_PERCENT, |
||
133 | val=self:GetVar("restedExpPercent"), |
||
134 | map=FuBarLocals.MAP_ONOFF |
||
135 | }, |
||
136 | }) |
||
137 | end, |
||
138 | |||
139 | MenuSettings = function(self, level, value) |
||
140 | |||
141 | dewdrop:AddLine( |
||
142 | 'text', self.locals.MENU_SHOW_LEVEL_XP, |
||
143 | 'arg1', self, |
||
144 | 'func', function() |
||
145 | self:ToggleShowLevelExp(TRUE) |
||
146 | end, |
||
147 | 'checked', self:GetVar("levelExp") |
||
148 | ) |
||
149 | |||
150 | dewdrop:AddLine( |
||
151 | 'text', self.locals.MENU_SHOW_TOLEVEL_XP, |
||
152 | 'arg1', self, |
||
153 | 'func', function() |
||
154 | self:ToggleShowToLevelExp(TRUE) |
||
155 | end, |
||
156 | 'checked', self:GetVar("toLevelExp") |
||
157 | ) |
||
158 | |||
159 | dewdrop:AddLine( |
||
160 | 'text', self.locals.MENU_SHOW_LEVEL_XP_PERCENT, |
||
161 | 'arg1', self, |
||
162 | 'func', function() |
||
163 | self:ToggleShowLevelExpPercent(TRUE) |
||
164 | end, |
||
165 | 'checked', self:GetVar("levelExpPercent") |
||
166 | ) |
||
167 | |||
168 | dewdrop:AddLine( |
||
169 | 'text', self.locals.MENU_SHOW_RESTED_XP, |
||
170 | 'arg1', self, |
||
171 | 'func', function() |
||
172 | self:ToggleShowRestedExp(TRUE) |
||
173 | end, |
||
174 | 'checked', self:GetVar("restedExp") |
||
175 | ) |
||
176 | |||
177 | dewdrop:AddLine( |
||
178 | 'text', self.locals.MENU_SHOW_RESTED_XP_PERCENT, |
||
179 | 'arg1', self, |
||
180 | 'func', function() |
||
181 | self:ToggleShowRestedExpPercent(TRUE) |
||
182 | end, |
||
183 | 'checked', self:GetVar("restedExpPercent") |
||
184 | ) |
||
185 | |||
186 | end, |
||
187 | |||
188 | OnUpdate = function(self, difference) |
||
189 | self.timeSinceLastUpdate = self.timeSinceLastUpdate + difference |
||
190 | if self.timeSinceLastUpdate >= 1 then |
||
191 | self.timeSinceLastUpdate = 0 |
||
192 | self:Update() |
||
193 | end |
||
194 | end, |
||
195 | |||
196 | UpdateText = function(self) |
||
197 | local totalXP = UnitXPMax("player") |
||
198 | local currentXP = UnitXP("player") |
||
199 | local toLevelXP = totalXP - currentXP |
||
200 | local sessionXP = self.sessionXP |
||
201 | local xps |
||
202 | |||
203 | local restedXP |
||
204 | if self.data.toLevelExp then |
||
205 | xps = "XPLvl: |cffffffff%d|r" |
||
206 | xps = string.format(xps, toLevelXP) |
||
207 | elseif self.data.levelExp then |
||
208 | xps = "XP/T: |cffffffff%d|r/|cffffffff%d|r" |
||
209 | xps = string.format(xps, currentXP, totalXP) |
||
210 | else |
||
211 | xps = "XP: |cffffffff%d|r" |
||
212 | xps = string.format(xps, currentXP) |
||
213 | end |
||
214 | if self.data.levelExpPercent then |
||
215 | local xpp = " (|cffffffff%.1f%%|r)" |
||
216 | if self.data.toLevelExp then |
||
217 | xpp = string.format(xpp, toLevelXP / totalXP * 100) |
||
218 | else |
||
219 | xpp = string.format(xpp, currentXP / totalXP * 100) |
||
220 | end |
||
221 | xps = xps..xpp |
||
222 | end |
||
223 | |||
224 | if self.data.restedExp then |
||
225 | restedXP = GetXPExhaustion() |
||
226 | restedXP = restedXP or 0 |
||
227 | if self.data.restedExpPercent then |
||
228 | restedXP = format("R: |cffffffff%.1f%%|r", floor((restedXP*100)/totalXP)) |
||
229 | else |
||
230 | restedXP = format("R: |cffffffff%d|r", restedXP) |
||
231 | end |
||
232 | else |
||
233 | restedXP = nil |
||
234 | end |
||
235 | xps = xps..((restedXP and " "..restedXP) or "") |
||
236 | |||
237 | xps = xps or "" |
||
238 | self:SetText(xps) |
||
239 | end, |
||
240 | |||
241 | UpdateTooltip = function(self) |
||
242 | local totalXP = UnitXPMax("player") |
||
243 | local currentXP = UnitXP("player") |
||
244 | local restedXP = GetXPExhaustion() |
||
245 | local toLevelXP = totalXP - currentXP |
||
246 | |||
247 | local cat = tablet:AddCategory( |
||
248 | 'columns', 2, |
||
249 | 'child_textR', 1, |
||
250 | 'child_textG', 1, |
||
251 | 'child_textB', 0, |
||
252 | 'child_text2R', 1, |
||
253 | 'child_text2G', 1, |
||
254 | 'child_text2B', 1 |
||
255 | ) |
||
256 | |||
257 | cat:AddLine( |
||
258 | 'text', self.locals.TEXT_LEVEL .. ":", |
||
259 | 'text2', UnitLevel("player") |
||
260 | ) |
||
261 | |||
262 | cat:AddLine( |
||
263 | 'text', self.locals.TEXT_TOTAL_LEVEL_XP .. ":", |
||
264 | 'text2', totalXP |
||
265 | ) |
||
266 | |||
267 | cat:AddLine( |
||
268 | 'text', self.locals.TEXT_XP_GAINED .. ":", |
||
269 | 'text2', format("%d (%.1f%%)", currentXP, currentXP / totalXP * 100) |
||
270 | ) |
||
271 | |||
272 | cat:AddLine( |
||
273 | 'text', self.locals.TEXT_XP_REMAINING .. ":", |
||
274 | 'text2', format("%d (%.1f%%)", toLevelXP, toLevelXP / totalXP * 100) |
||
275 | ) |
||
276 | |||
277 | cat:AddLine( |
||
278 | 'text', self.locals.TEXT_RESTED_XP .. ":", |
||
279 | 'text2', restedXP |
||
280 | ) |
||
281 | end, |
||
282 | }) |
||
283 | FuBar_Experienced:RegisterForLoad() |