vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | TODO; |
||
3 | Get options load probs localized |
||
4 | allow reset of session data |
||
5 | HonorBar at lvl 60. |
||
6 | Experience from mob text. |
||
7 | Add second tier text vars |
||
8 | Figure out profile deletion |
||
9 | Element offsets |
||
10 | Start hooking |
||
11 | Vertical bars. |
||
12 | Circular bars. |
||
13 | More time to.... text... |
||
14 | More text bars. |
||
15 | DAB optional dependencies for frame attachment. |
||
16 | Help tooltips for config |
||
17 | Identify and fix position label wierdness |
||
18 | Custom texture addons |
||
19 | Element defaults |
||
20 | OnMousover for bar/elements |
||
21 | ]] |
||
22 | BEB.CurrentVersion = 0.87 |
||
23 | BEB.textevents = {} |
||
24 | BEB.TimeThisSession = 1 |
||
25 | local VARIABLES_LOADED |
||
26 | local ENTERING_WORLD |
||
27 | BEB.XpThisSession = 0 |
||
28 | BEB.RateThisSession = 0 |
||
29 | BEB.RestState = -1 |
||
30 | BEB.XpMobsTS = 0 |
||
31 | BEB.MobsTS = 0 |
||
32 | BEB.Flashers = {} |
||
33 | BEB.Flashframes = {} |
||
34 | local UpdateFrequency = 5 |
||
35 | local TimeFromLastUpdate = 0 |
||
36 | local StringOnUpdate = 0 |
||
37 | BEB.LOG_10 = math.log(10) |
||
38 | BEB.Elements ={ "BEBBackground", "BEBBarText", "BEBMarkers", "BEBRestedXpBar", "BEBRestedXpTick", |
||
39 | "BEBRestedXpTickGlow", "BEBXpBar", "BEBXpTick"} |
||
40 | BEB.XpPerLvl = {400,900,1400,2100,2800,3600,4400,5400,6500,7600,8800,10100,11400,12900,14400,16000,17700,19400,21300,23200, |
||
41 | 25200,27300,29400,31700,34000,36400,38900,41400,44300,47400,50800,54500,58600,62800,67100,71600,76100,80800,85700,90700, |
||
42 | 95800,101000,106300,111800,117500,123200,129100,135100,141200,147500,153900,160400,167100,173900,180800,187900,195000, |
||
43 | 202300,209800,217400} |
||
44 | |||
45 | function BEB.OnLoad() |
||
46 | SlashCmdList["BEB"] = BEB.Slash_Handler |
||
47 | SLASH_BEB1 = "/beb" |
||
48 | SLASH_BEB2 = "/basicexperiencebar" |
||
49 | this:RegisterEvent("PLAYER_ENTERING_WORLD") |
||
50 | this:RegisterEvent("VARIABLES_LOADED") |
||
51 | end |
||
52 | |||
53 | function BEB.OnEvent(event) |
||
54 | if (event == "VARIABLES_LOADED") then |
||
55 | VARIABLES_LOADED = true |
||
56 | if ( ENTERING_WORLD ) then |
||
57 | BEB.Initialize() |
||
58 | end |
||
59 | elseif (event == "PLAYER_ENTERING_WORLD") then |
||
60 | ENTERING_WORLD = true |
||
61 | if ( VARIABLES_LOADED ) then |
||
62 | BEB.Initialize() |
||
63 | end |
||
64 | elseif (event == "PLAYER_LEVEL_UP") then |
||
65 | BEB.XpThisSession = BEB.XpThisSession + (UnitXPMax("player") - BEB.OldXp) |
||
66 | BEB.OldXp = 0 |
||
67 | elseif (event == "PLAYER_UPDATE_RESTING") then |
||
68 | BEB.UpdateFlashers() |
||
69 | -- BEB.SetColors("force") |
||
70 | BEB.UpdateElement("BEBRestedXpTickGlow") |
||
71 | elseif (event == "PLAYER_XP_UPDATE") then |
||
72 | BEB.XpThisSession = BEB.XpThisSession + (UnitXP("player") - BEB.OldXp) |
||
73 | BEB.OldXp = UnitXP("player") |
||
74 | BEB.UpdateElement("BEBXpBar") |
||
75 | BEB.UpdateElement("BEBRestedXpBar") |
||
76 | BEB.UpdateElement("BEBRestedXpTick") |
||
77 | elseif (event == "CHAT_MSG_COMBAT_XP_GAIN") then |
||
78 | local _,_,xp,_ = string.find(arg1, BEB.LOCALIZED.XpSearchString) |
||
79 | if (xp) then |
||
80 | local _,_,rxp = string.find(arg1, BEB.LOCALIZED.RestedSearchString) |
||
81 | BEB.XpMobsTS = BEB.XpMobsTS + tonumber(xp) - (tonumber(rxp) or 0) |
||
82 | BEB.MobsTS = BEB.MobsTS + 1; |
||
83 | end |
||
84 | elseif (event == "UPDATE_EXHAUSTION") then |
||
85 | BEB.UpdateElement("BEBRestedXpBar") |
||
86 | BEB.UpdateElement("BEBRestedXpTick") |
||
87 | BEB.UpdateElement("BEBRestedXpTickGlow") |
||
88 | BEB.SetColors() |
||
89 | elseif (event == "PLAYER_LOGOUT") then |
||
90 | if (BEBCharSettings.BEBProfile) then |
||
91 | BEB.SaveProfile(BEBCharSettings.BEBProfile) |
||
92 | end |
||
93 | end |
||
94 | end |
||
95 | |||
96 | function BEB.Initialize() |
||
97 | local INDEX = UnitName("player").." of "..GetCVar("realmName") |
||
98 | if (BEBCharSettings) then |
||
99 | if (BEBCharSettings.BEBMain.BEBProfile) then |
||
100 | BEB.LoadProfile(BEBCharSettings.BEBProfile) |
||
101 | end |
||
102 | end |
||
103 | if BEBINITIALIZED then |
||
104 | return |
||
105 | end |
||
106 | BEBMain:RegisterEvent("PLAYER_LOGOUT") |
||
107 | BEBMain:RegisterEvent("PLAYER_LEVEL_UP") |
||
108 | BEBMain:RegisterEvent("PLAYER_UPDATE_RESTING") |
||
109 | BEBMain:RegisterEvent("PLAYER_XP_UPDATE") |
||
110 | BEBMain:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN") |
||
111 | BEBMain:RegisterEvent("UPDATE_EXHAUSTION") |
||
112 | BEBMain:RegisterForClicks("LeftButtonUp","RightButtonUp") |
||
113 | -- Set default local vals |
||
114 | BEB.StartTime = GetTime() - 1 |
||
115 | BEB.OldXp = UnitXP("player") or 0 |
||
116 | -- Setup default settings and saved variables |
||
117 | if (not BEBGlobal) then |
||
118 | BEBGlobal = {} |
||
119 | BEBGlobal.profiles = {} |
||
120 | BEBGlobal.Chars = {} |
||
121 | BEB.DefaultSettings() |
||
122 | elseif (not BEBCharSettings) then |
||
123 | BEB.DefaultSettings() |
||
124 | elseif (BEBCharSettings.Version < BEB.CurrentVersion) then |
||
125 | BEB.DefaultSettings() |
||
126 | end |
||
127 | if (BEBCharSettings.BEBProfile) then |
||
128 | BEB.SaveProfile(BEBCharSettings.BEBProfile) |
||
129 | end |
||
130 | BEBGlobal.Chars[INDEX] = {Profile = BEBCharSettings.BEBProfile, Version = BEBCharSettings.Version} |
||
131 | --count profiles for the dropdown menu... move to BEBOptions? |
||
132 | local numprofiles = 0 |
||
133 | for _,_ in BEBGlobal.profiles do |
||
134 | numprofiles = numprofiles + 1 |
||
135 | end |
||
136 | table.setn(BEBGlobal.profiles,numprofiles) |
||
137 | |||
138 | BEB.SetupBars() |
||
139 | BEBINITIALIZED = true |
||
140 | BEB.OnEvent("PLAYER_UPDATE_RESTING") |
||
141 | end |
||
142 | |||
143 | function BEB.Slash_Handler(msg) |
||
144 | local command, param |
||
145 | local index = string.find(msg, " ") |
||
146 | if(index) then |
||
147 | command = string.sub(msg, 1, (index - 1)) |
||
148 | param = string.sub(msg, (index + 1) ) |
||
149 | else |
||
150 | command = msg |
||
151 | end |
||
152 | if (command == "") then |
||
153 | if (not IsAddOnLoaded("BEBOptions")) then |
||
154 | local loaded,reason = LoadAddOn("BEBOptions") |
||
155 | if (not loaded) then |
||
156 | if (reason == "DISABLED") then |
||
157 | BEB.Feedback(BEB.TEXT.optionsdisabled) |
||
158 | elseif (reason == "MISSING") then |
||
159 | BEB.Feedback(BEB.TEXT.optionsmissing) |
||
160 | elseif (reason == "CORRUPT") then |
||
161 | BEB.Feedback(BEB.TEXT.optionscorrupt) |
||
162 | elseif (reason == "INTERFACE_VERSION") then |
||
163 | BEB.Feedback(BEB.TEXT.optionsversion) |
||
164 | else |
||
165 | BEB.Feedback(BEB.TEXT.optionsnoload1..reason..BEB.TEXT.optionsnoload2) |
||
166 | end |
||
167 | return |
||
168 | end |
||
169 | end |
||
170 | if (BEBConfigFrame:IsVisible()) then |
||
171 | BEBConfigFrame:Hide() |
||
172 | else |
||
173 | BEBConfigFrame:Show() |
||
174 | end |
||
175 | else |
||
176 | if (command == "help") then |
||
177 | BEB.Feedback(BEB.TEXT.validcommands) |
||
178 | elseif (command == "defaults") then |
||
179 | BEB.LoadDefaults() |
||
180 | else |
||
181 | BEB.Feedback(BEB.TEXT.invalidcommand) |
||
182 | end |
||
183 | end |
||
184 | end |
||
185 | function BEB.DefaultSettings() |
||
186 | if (not BEBCharSettings) then |
||
187 | BEBCharSettings = {} |
||
188 | BEBCharSettings.Version = 0 |
||
189 | end |
||
190 | if (BEBCharSettings.Version < 0.7) then |
||
191 | BEBCharSettings = { |
||
192 | BEBBackground = { |
||
193 | maxrestcolor = {0, 0, 0, .25}, |
||
194 | restcolor = {0, 0, 0, .25}, |
||
195 | shown = true, |
||
196 | texture = "PlainBackdrop", |
||
197 | unrestcolor = {0, 0, 0, .25} |
||
198 | }, |
||
199 | BEBBarText = { |
||
200 | clicktext = true, |
||
201 | location = { |
||
202 | point = "CENTER", |
||
203 | relpoint = "CENTER", |
||
204 | x = 0, |
||
205 | y = 0 |
||
206 | }, |
||
207 | maxrestcolor = {1, 1, 1, 1}, |
||
208 | mouseover = false, |
||
209 | restcolor = {1, 1, 1, 1}, |
||
210 | shown = true, |
||
211 | size = {y=10}, |
||
212 | text = {string = "Lvl $plv, XP $cxp/$mxp, $pdl% , $rxp Rested Xp."}, |
||
213 | unrestcolor = {1, 1, 1, 1} |
||
214 | }, |
||
215 | BEBMain = { |
||
216 | dragable = true, |
||
217 | enabled = true, |
||
218 | location = { |
||
219 | point = "CENTER", |
||
220 | relpoint = "CENTER", |
||
221 | relto = "UIParent", |
||
222 | x = 0, |
||
223 | y = -337 |
||
224 | }, |
||
225 | size = {x=1024,y=12} |
||
226 | }, |
||
227 | BEBMarkers = { |
||
228 | maxrestcolor = {1, 1, 1, 1}, |
||
229 | restcolor = {1, 1, 1, 1}, |
||
230 | shown = true, |
||
231 | texture = "BEB-ExperienceBarMarkers", |
||
232 | unrestcolor = {1, 1, 1, 1} |
||
233 | }, |
||
234 | BEBProfile = false, |
||
235 | BEBRestedXpBar = { |
||
236 | maxrestcolor = {0.2, 0.3, 0.65, 1}, |
||
237 | restcolor = {0.2, 0.3, 0.65, 1}, |
||
238 | shown = true, |
||
239 | texture = "BEB-BarFill-RoundedLight" |
||
240 | }, |
||
241 | BEBRestedXpTick = { |
||
242 | location = {x=0,y=0}, |
||
243 | maxrestcolor = {1, 0, 0, 1}, |
||
244 | restcolor = {1, 1, 1, 1}, |
||
245 | shown = true, |
||
246 | size = {x=27,y=26}, |
||
247 | texture = "BEB-ExhaustionTicks" |
||
248 | }, |
||
249 | BEBRestedXpTickGlow = { |
||
250 | flashing = true, |
||
251 | maxrestcolor = {1, 0.8, 0.8, 1}, |
||
252 | restcolor = {1, 1, 1, 1}, |
||
253 | shown = true, |
||
254 | texture = "BEB-ExhaustionTicksGlow" |
||
255 | }, |
||
256 | BEBXpBar = { |
||
257 | maxrestcolor = {0.4, 0, 0.7, 1}, |
||
258 | restcolor = {0.4, 0, 0.7, 1}, |
||
259 | texture = "BEB-BarFill-RoundedLight", |
||
260 | unrestcolor = {0.6, 0, 0.5, 1} |
||
261 | }, |
||
262 | BEBXpTick = { |
||
263 | location = {x=0,y=0}, |
||
264 | maxrestcolor = {1, 1, 1, 1}, |
||
265 | restcolor = {1, 1, 1, 1}, |
||
266 | shown = true, |
||
267 | size = {x=27,y=26}, |
||
268 | texture = "BEB-ExhaustionTicks", |
||
269 | unrestcolor = {1, 1, 1, 1} |
||
270 | }, |
||
271 | Version = 0.7, |
||
272 | } |
||
273 | end |
||
274 | if (BEBCharSettings.Version < 0.71) then |
||
275 | BEBCharSettings.BEBBackground.flashing = false |
||
276 | BEBCharSettings.BEBXpBar.flashing = false |
||
277 | BEBCharSettings.BEBRestedXpBar.flashing = false |
||
278 | BEBCharSettings.BEBMarkers.flashing = false |
||
279 | BEBCharSettings.BEBXpTick.flashing = false |
||
280 | BEBCharSettings.BEBRestedXpTick.flashing = false |
||
281 | BEBCharSettings.BEBBarText.flashing = false |
||
282 | BEBCharSettings.Version = 0.71 |
||
283 | end |
||
284 | if (BEBCharSettings.Version < 0.82) then |
||
285 | BEBCharSettings.BEBMain.level = 5 |
||
286 | BEBCharSettings.BEBBackground.level = 6 |
||
287 | BEBCharSettings.BEBXpBar.level = 7 |
||
288 | BEBCharSettings.BEBRestedXpBar.level = 7 |
||
289 | BEBCharSettings.BEBMarkers.level = 8 |
||
290 | BEBCharSettings.BEBXpTick.level = 9 |
||
291 | BEBCharSettings.BEBRestedXpTick.level = 9 |
||
292 | BEBCharSettings.BEBRestedXpTickGlow.level = 10 |
||
293 | BEBCharSettings.BEBBarText.level = 10 |
||
294 | BEBCharSettings.Version = 0.82 |
||
295 | end |
||
296 | if (BEBCharSettings.Version < 0.84) then |
||
297 | BEBCharSettings.BEBMain.strata = "HIGH" |
||
298 | BEBCharSettings.BEBBackground.strata = "HIGH" |
||
299 | BEBCharSettings.BEBXpBar.strata = "HIGH" |
||
300 | BEBCharSettings.BEBRestedXpBar.strata = "HIGH" |
||
301 | BEBCharSettings.BEBMarkers.strata = "HIGH" |
||
302 | BEBCharSettings.BEBXpTick.strata = "HIGH" |
||
303 | BEBCharSettings.BEBRestedXpTick.strata = "HIGH" |
||
304 | BEBCharSettings.BEBRestedXpTickGlow.strata = "HIGH" |
||
305 | BEBCharSettings.BEBBarText.strata = "HIGH" |
||
306 | BEBCharSettings.Version = 0.84 |
||
307 | end |
||
308 | if (BEBCharSettings.Version < 0.86) then |
||
309 | BEBCharSettings.BEBMain.enabled = nil |
||
310 | BEBCharSettings.Version = 0.86 |
||
311 | end |
||
312 | if (BEBCharSettings.Version < BEB.CurrentVersion) then |
||
313 | BEBCharSettings.Version = BEB.CurrentVersion |
||
314 | end |
||
315 | end |
||
316 | |||
317 | |||
318 | |||
319 | function BEB.OnDragStart() |
||
320 | if(not BEBCharSettings.BEBMain.dragable) then |
||
321 | BEB.Feedback(BEB.TEXT.framelocked) |
||
322 | else |
||
323 | BEBMain:StartMoving() |
||
324 | end |
||
325 | end |
||
326 | |||
327 | function BEB.OnDragStop() |
||
328 | BEBMain:StopMovingOrSizing() |
||
329 | BEB.GetPosition() |
||
330 | BEBMain:SetUserPlaced(false) |
||
331 | end |
||
332 | |||
333 | function BEB.OnClick(arg1) |
||
334 | if (arg1 == "RightButton") then |
||
335 | BEB.Slash_Handler("") |
||
336 | elseif (arg1 == "LeftButton") then |
||
337 | if (BEBCharSettings.BEBBarText.shown and BEBCharSettings.BEBBarText.clicktext) then |
||
338 | ChatFrameEditBox:Insert(BEBBarText.textframe:GetText()) |
||
339 | end |
||
340 | end |
||
341 | end |
||
342 | |||
343 | function BEB.OnEnter() |
||
344 | if (BEBCharSettings.BEBBarText.shown and BEBCharSettings.BEBBarText.mouseover) then |
||
345 | BEBBarText:Show() |
||
346 | end |
||
347 | end |
||
348 | function BEB.OnLeave() |
||
349 | if (BEBCharSettings.BEBBarText.shown and BEBCharSettings.BEBBarText.mouseover) then |
||
350 | BEBBarText:Hide() |
||
351 | end |
||
352 | end |
||
353 | |||
354 | function BEB.GetPosition() |
||
355 | local BEBPoint = {} |
||
356 | local BEBRelPoint = {} |
||
357 | local point = BEBCharSettings.BEBMain.location.point |
||
358 | local relpoint = BEBCharSettings.BEBMain.location.relpoint |
||
359 | local relto = getglobal(BEBCharSettings.BEBMain.location.relto) |
||
360 | if (point == "CENTER") then |
||
361 | BEBPoint.x, BEBPoint.y = BEBMain:GetCenter() |
||
362 | elseif (point == "TOPRIGHT") then |
||
363 | BEBPoint.x, BEBPoint.y = BEBMain:GetRight(), BEBMain:GetTop() |
||
364 | elseif (point == "TOPLEFT") then |
||
365 | BEBPoint.x, BEBPoint.y = BEBMain:GetLeft(), BEBMain:GetTop() |
||
366 | elseif (point == "BOTTOMRIGHT") then |
||
367 | BEBPoint.x, BEBPoint.y = BEBMain:GetRight(), BEBMain:GetBottom() |
||
368 | elseif (point == "BOTTOMLEFT") then |
||
369 | BEBPoint.x, BEBPoint.y = BEBMain:GetLeft(), BEBMain:GetBottom() |
||
370 | elseif (point == "TOP") then |
||
371 | BEBPoint.x, _, BEBPoint.y = BEBMain:GetCenter(), BEBMain:GetTop() |
||
372 | elseif (point == "BOTTOM") then |
||
373 | BEBPoint.x, _, BEBPoint.y = BEBMain:GetCenter(), BEBMain:GetBottom() |
||
374 | elseif (point == "LEFT") then |
||
375 | BEBPoint.x, _, BEBPoint.y = BEBMain:GetLeft(), BEBMain:GetCenter() |
||
376 | elseif (point == "RIGHT") then |
||
377 | BEBPoint.x, _, BEBPoint.y = BEBMain:GetRight(), BEBMain:GetCenter() |
||
378 | end |
||
379 | if (relpoint == "CENTER") then |
||
380 | BEBRelPoint.x, BEBRelPoint.y = relto:GetCenter() |
||
381 | elseif (relpoint == "TOPRIGHT") then |
||
382 | BEBRelPoint.x, BEBRelPoint.y = relto:GetRight(), relto:GetTop() |
||
383 | elseif (relpoint == "TOPLEFT") then |
||
384 | BEBRelPoint.x, BEBRelPoint.y = relto:GetLeft(), relto:GetTop() |
||
385 | elseif (relpoint == "BOTTOMRIGHT") then |
||
386 | BEBRelPoint.x, BEBRelPoint.y = relto:GetRight(), relto:GetBottom() |
||
387 | elseif (relpoint == "BOTTOMLEFT") then |
||
388 | BEBRelPoint.x, BEBRelPoint.y = relto:GetLeft(), relto:GetBottom() |
||
389 | elseif (relpoint == "TOP") then |
||
390 | BEBRelPoint.x, _, BEBRelPoint.y = relto:GetCenter(), relto:GetTop() |
||
391 | elseif (relpoint == "BOTTOM") then |
||
392 | BEBRelPoint.x, _, BEBRelPoint.y = relto:GetCenter(), relto:GetBottom() |
||
393 | elseif (relpoint == "LEFT") then |
||
394 | BEBRelPoint.x, _, BEBRelPoint.y = relto:GetLeft(), relto:GetCenter() |
||
395 | elseif (relpoint == "RIGHT") then |
||
396 | BEBRelPoint.x, _, BEBRelPoint.y = relto:GetRight(), relto:GetCenter() |
||
397 | end |
||
398 | BEBCharSettings.BEBMain.location.x, BEBCharSettings.BEBMain.location.y = BEBPoint.x - BEBRelPoint.x, BEBPoint.y - BEBRelPoint.y |
||
399 | end |
||
400 | |||
401 | function BEB.IsFrame(frameName) |
||
402 | if (getglobal(frameName)) then |
||
403 | local var = getglobal(frameName) |
||
404 | return ((type(var) == "table") and (type(var[0]) == "userdata") and (type(var.GetName) == "function") and (var:GetName() == frameName)) |
||
405 | else |
||
406 | return false |
||
407 | end |
||
408 | end |
||
409 | |||
410 | function BEB.CompileString(instring, Frame) |
||
411 | for k,_ in BEB.textevents do |
||
412 | BEBTextEventFrame:UnregisterEvent(k) |
||
413 | end |
||
414 | local frame = Frame:GetName() |
||
415 | local outstring = {} |
||
416 | local i = 1 |
||
417 | local length = string.len(instring) |
||
418 | local count = 0 |
||
419 | while (i<=length) do |
||
420 | count = count +1 |
||
421 | outstring[count] = {} |
||
422 | local start,_ = string.find(instring,"%$",i) |
||
423 | if (start == i) then |
||
424 | local substring = string.sub(instring, i, i+3) |
||
425 | outstring[count].string = substring |
||
426 | if (BEB.VARIABLE_FUNCTIONS[substring]) then |
||
427 | outstring[count].func = BEB.VARIABLE_FUNCTIONS[substring].func |
||
428 | outstring[count].text = outstring[count].func() |
||
429 | for _,event in BEB.VARIABLE_FUNCTIONS[substring].events do |
||
430 | if (BEB.textevents[event]) then |
||
431 | if (BEB.textevents[event][frame]) then |
||
432 | table.insert(BEB.textevents[event][frame],count) |
||
433 | else |
||
434 | BEB.textevents[event][frame] = {count} |
||
435 | end |
||
436 | else |
||
437 | BEB.textevents[event] = {[frame] = {count}} |
||
438 | end |
||
439 | end |
||
440 | end |
||
441 | i = i+4 |
||
442 | elseif (not start) then |
||
443 | outstring[count].string = string.sub(instring, i, length) |
||
444 | outstring[count].text = outstring[count].string |
||
445 | i = length +1 |
||
446 | else |
||
447 | outstring[count].string = string.sub(instring, i, start-1) |
||
448 | outstring[count].text = outstring[count].string |
||
449 | i = start |
||
450 | end |
||
451 | end |
||
452 | outstring.count = count |
||
453 | Frame.texttable = outstring |
||
454 | for k,_ in BEB.textevents do |
||
455 | BEBTextEventFrame:RegisterEvent(k) |
||
456 | end |
||
457 | end |
||
458 | |||
459 | function BEB.TexturePath(var) |
||
460 | if (string.find(var, "Interface\\")) then |
||
461 | return var |
||
462 | else |
||
463 | return "Interface\\AddOns\\BEB\\Textures\\"..var |
||
464 | end |
||
465 | end |
||
466 | |||
467 | function BEB.LoadProfile(bebprofile) |
||
468 | if (BEBGlobal.profiles[bebprofile]) then |
||
469 | if (BEBCharSettings.BEBProfile == bebprofile) then |
||
470 | BEBCharSettings = BEB.TableCopy(BEBGlobal.profiles[bebprofile]) |
||
471 | BEBCharSettings.BEBProfile = bebprofile |
||
472 | else |
||
473 | BEBCharSettings = BEB.TableCopy(BEBGlobal.profiles[bebprofile]) |
||
474 | end |
||
475 | else |
||
476 | BEB.FeedBack(BEB.TEXT.profilemissing) |
||
477 | BEBCharSettings.BEBProfile = false |
||
478 | end |
||
479 | end |
||
480 | |||
481 | function BEB.SaveProfile(bebprofile) |
||
482 | BEBGlobal.profiles[bebprofile] = BEB.TableCopy(BEBCharSettings) |
||
483 | BEBGlobal.profiles[bebprofile].BEBProfile = false |
||
484 | end |
||
485 | |||
486 | function BEB.TableCopy(a) |
||
487 | local b={} |
||
488 | for k,v in a do |
||
489 | if type(v) == "table" then |
||
490 | b[k] = BEB.TableCopy(v) |
||
491 | else |
||
492 | b[k]=v |
||
493 | end |
||
494 | end |
||
495 | return b |
||
496 | end |
||
497 | |||
498 | function BEB.SetupBars() |
||
499 | local elements = {"BEBMain","BEBBackground","BEBXpBar","BEBRestedXpBar","BEBMarkers","BEBXpTick","BEBRestedXpTick","BEBRestedXpTickGlow","BEBBarText"} |
||
500 | for _,v in ipairs(elements) do |
||
501 | BEB.SetupElement(v) |
||
502 | end |
||
503 | BEB.SetColors(nil, true) |
||
504 | end |
||
505 | function BEB.SetupElement(element) |
||
506 | if (element == "BEBProfile") then |
||
507 | return |
||
508 | end |
||
509 | local Element = getglobal(element) |
||
510 | if (BEBCharSettings[element].flashing) then |
||
511 | BEB.Flashframes[element] = true |
||
512 | if ((IsResting() == 1) and (not Element.flashing)) then |
||
513 | BEB.StartFlashing(element,0.7,0.2,1) |
||
514 | end |
||
515 | else |
||
516 | BEB.Flashframes[element] = nil |
||
517 | if ((IsResting() == 1) and Element.flashing) then |
||
518 | BEB.StopFlashing(element) |
||
519 | end |
||
520 | end |
||
521 | Element:SetFrameLevel(BEBCharSettings[element].level) |
||
522 | Element:SetFrameStrata(BEBCharSettings[element].strata) |
||
523 | if (element == "BEBMain") then |
||
524 | if (BEB.IsFrame(BEBCharSettings.BEBMain.location.relto)) then |
||
525 | BEBMain:ClearAllPoints() |
||
526 | local Location = BEBCharSettings.BEBMain.location |
||
527 | BEBMain:SetPoint(Location.point, Location.relto, Location.relpoint, Location.x, Location.y) |
||
528 | else |
||
529 | BEB.Feedback(BEB.TEXT.framewasinvalid) |
||
530 | BEBMain:SetPoint("CENTER","UIParent","CENTER",0,0) |
||
531 | end |
||
532 | BEBMain:SetWidth(BEBCharSettings.BEBMain.size.x) |
||
533 | BEBMain:SetHeight(BEBCharSettings.BEBMain.size.y) |
||
534 | if (BEBCharSettings.BEBMain.dragable == true) then |
||
535 | BEBMain:RegisterForDrag("LeftButton") |
||
536 | else |
||
537 | BEBMain:RegisterForDrag() |
||
538 | end |
||
539 | BEBBarText:SetHeight(BEBCharSettings.BEBMain.size.y) |
||
540 | BEBXpBar:SetHeight(BEBCharSettings.BEBMain.size.y) |
||
541 | BEBRestedXpBar:SetHeight(BEBCharSettings.BEBMain.size.y) |
||
542 | BEB.BEBMainWidth = BEBMain:GetWidth() |
||
543 | elseif (element == "BEBBackground") then |
||
544 | if (BEBCharSettings.BEBBackground.shown) then |
||
545 | BEBBackground:ClearAllPoints() |
||
546 | BEBBackground:SetPoint("TOPLEFT", BEBMain, "TOPLEFT", 0, 0) |
||
547 | BEBBackground:SetPoint("BOTTOMRIGHT", BEBMain, "BOTTOMRIGHT", 0, 0) |
||
548 | BEBBackground.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBBackground.texture)) |
||
549 | BEBBackground:Show() |
||
550 | else |
||
551 | BEBBackground:Hide() |
||
552 | end |
||
553 | elseif (element == "BEBXpBar") then |
||
554 | BEBXpBar:ClearAllPoints() |
||
555 | BEBXpBar:SetPoint("LEFT", BEBMain, "LEFT", 0, 0) |
||
556 | BEBXpBar.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBXpBar.texture)) |
||
557 | elseif (element == "BEBRestedXpBar") then |
||
558 | if (BEBCharSettings.BEBRestedXpBar.shown) then |
||
559 | BEBRestedXpBar:ClearAllPoints() |
||
560 | BEBRestedXpBar:SetPoint("LEFT", BEBXpBar, "RIGHT", 0, 0) |
||
561 | BEBRestedXpBar.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBRestedXpBar.texture)) |
||
562 | BEBRestedXpBar:Show() |
||
563 | else |
||
564 | BEBRestedXpBar:Hide() |
||
565 | end |
||
566 | elseif (element == "BEBMarkers") then |
||
567 | if (BEBCharSettings.BEBMarkers.shown) then |
||
568 | BEBMarkers:ClearAllPoints() |
||
569 | BEBMarkers:SetPoint("TOPLEFT", BEBMain, "TOPLEFT", 0, 0) |
||
570 | BEBMarkers:SetPoint("BOTTOMRIGHT", BEBMain, "BOTTOMRIGHT", 0, 0) |
||
571 | BEBMarkers.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBMarkers.texture)) |
||
572 | BEBMarkers:Show() |
||
573 | else |
||
574 | BEBMarkers:Hide() |
||
575 | end |
||
576 | elseif (element == "BEBXpTick") then |
||
577 | if (BEBCharSettings.BEBXpTick.shown) then |
||
578 | BEBXpTick:ClearAllPoints() |
||
579 | BEBXpTick:SetPoint("CENTER", "BEBXpBar", "RIGHT", BEBCharSettings.BEBXpTick.location.x, BEBCharSettings.BEBXpTick.location.y) |
||
580 | BEBXpTick.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBXpTick.texture)) |
||
581 | BEBXpTick.texture:SetTexCoord(0,0.5,0,0.5) |
||
582 | BEBXpTick:Show() |
||
583 | else |
||
584 | BEBXpTick:Hide() |
||
585 | end |
||
586 | BEBXpTick:SetWidth(BEBCharSettings.BEBXpTick.size.x) |
||
587 | BEBXpTick:SetHeight(BEBCharSettings.BEBXpTick.size.y) |
||
588 | elseif (element == "BEBRestedXpTick") then |
||
589 | if (BEBCharSettings.BEBRestedXpTick.shown) then |
||
590 | BEBRestedXpTick.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBRestedXpTick.texture)) |
||
591 | BEBRestedXpTick:SetWidth(BEBCharSettings.BEBRestedXpTick.size.x) |
||
592 | BEBRestedXpTick:SetHeight(BEBCharSettings.BEBRestedXpTick.size.y) |
||
593 | BEBRestedXpTick:Show() |
||
594 | else |
||
595 | BEBRestedXpTick:Hide() |
||
596 | end |
||
597 | elseif (element == "BEBRestedXpTickGlow") then |
||
598 | if (BEBCharSettings.BEBRestedXpTickGlow.shown) then |
||
599 | BEBRestedXpTickGlow.texture:SetTexture(BEB.TexturePath(BEBCharSettings.BEBRestedXpTickGlow.texture)) |
||
600 | BEBRestedXpTickGlow:ClearAllPoints() |
||
601 | BEBRestedXpTickGlow:SetPoint("TOPLEFT", "BEBRestedXpTick", "TOPLEFT", 0, 0) |
||
602 | BEBRestedXpTickGlow:SetPoint("BOTTOMRIGHT", "BEBRestedXpTick", "BOTTOMRIGHT", 0, 0) |
||
603 | end |
||
604 | elseif (element == "BEBBarText") then |
||
605 | if (BEBCharSettings.BEBBarText.shown) then |
||
606 | BEB.CompileString(BEBCharSettings.BEBBarText.text.string, BEBBarText) |
||
607 | BEBBarText:ClearAllPoints() |
||
608 | BEBBarText:SetPoint(BEBCharSettings.BEBBarText.location.point, "BEBMain", BEBCharSettings.BEBBarText.location.relpoint, BEBCharSettings.BEBBarText.location.x, BEBCharSettings.BEBBarText.location.y) |
||
609 | BEB.StringEvent("WRITE_ALL", element) |
||
610 | if (BEBCharSettings.BEBBarText.mouseover) then |
||
611 | BEBBarText:Hide() |
||
612 | else |
||
613 | BEBBarText:Show() |
||
614 | end |
||
615 | else |
||
616 | BEBBarText:Hide() |
||
617 | end |
||
618 | BEBBarText.textframe:SetTextHeight(BEBCharSettings.BEBBarText.size.y) |
||
619 | local scale = BEBMain:GetScale() |
||
620 | BEBMain:SetScale(scale + 0.1) |
||
621 | BEBMain:SetScale(scale) |
||
622 | end |
||
623 | BEB.UpdateElement(element) |
||
624 | end |
||
625 | |||
626 | function BEB.SetColors(element, force) -- do not use the numbers 0, 1 or 2 for force |
||
627 | BEB.OldRestState = force or BEB.RestState |
||
628 | if (GetRestState() == 1) then |
||
629 | if (GetXPExhaustion() == (UnitXPMax("player")*1.5)) then |
||
630 | BEB.RestState = 2 |
||
631 | else |
||
632 | BEB.RestState = 1 |
||
633 | end |
||
634 | else |
||
635 | BEB.RestState = 0 |
||
636 | end |
||
637 | if (BEB.RestState ~= BEB.OldRestState) then |
||
638 | if (element) then |
||
639 | BEB.SetElementColor(element) |
||
640 | else |
||
641 | for _,v in BEB.Elements do |
||
642 | BEB.SetElementColor(v) |
||
643 | end |
||
644 | end |
||
645 | end |
||
646 | end |
||
647 | |||
648 | function BEB.SetElementColor(element) |
||
649 | local Element = getglobal(element) |
||
650 | if ((BEB.RestState == 0) and BEBCharSettings[element].unrestcolor) then |
||
651 | (Element.texture or Element.textframe):SetVertexColor(unpack(BEBCharSettings[element].unrestcolor)) |
||
652 | elseif ((BEB.RestState == 1) and BEBCharSettings[element].restcolor) then |
||
653 | (Element.texture or Element.textframe):SetVertexColor(unpack(BEBCharSettings[element].restcolor)) |
||
654 | elseif ((BEB.RestState == 2) and BEBCharSettings[element].maxrestcolor) then |
||
655 | (Element.texture or Element.textframe):SetVertexColor(unpack(BEBCharSettings[element].maxrestcolor)) |
||
656 | end |
||
657 | end |
||
658 | |||
659 | function BEB.UpdateElement(element) |
||
660 | if (element == "BEBXpBar") then |
||
661 | BEB.BEBScale = BEB.BEBMainWidth / UnitXPMax("player") |
||
662 | if ((not UnitXP("player")) or (UnitXP("player") == 0)) then |
||
663 | BEB.BEBXpWidth = 1 |
||
664 | else |
||
665 | BEB.BEBXpWidth = BEB.BEBScale * UnitXP("player") |
||
666 | end |
||
667 | BEBXpBar:SetWidth(BEB.BEBXpWidth) |
||
668 | BEBXpBar.texture:SetTexCoord(0,(BEB.BEBXpWidth/BEB.BEBMainWidth),0,1) |
||
669 | elseif (element == "BEBRestedXpBar") then |
||
670 | if ((GetRestState() == 1) and BEBCharSettings.BEBRestedXpBar.shown) then |
||
671 | if ((UnitXP("player")+GetXPExhaustion()) > UnitXPMax("player")) then |
||
672 | BEBRestedXpBar:SetWidth(BEB.BEBMainWidth - BEB.BEBXpWidth) |
||
673 | BEBRestedXpBar.texture:SetTexCoord((BEB.BEBXpWidth/BEB.BEBMainWidth),1,0,1) |
||
674 | else |
||
675 | local BEBRestedXpWidth = (UnitXP("player")+GetXPExhaustion())*BEB.BEBScale |
||
676 | BEBRestedXpBar:SetWidth(BEBRestedXpWidth - BEB.BEBXpWidth) |
||
677 | BEBRestedXpBar.texture:SetTexCoord((BEB.BEBXpWidth/BEB.BEBMainWidth),(BEBRestedXpWidth/BEB.BEBMainWidth),0,1) |
||
678 | end |
||
679 | else |
||
680 | BEBRestedXpBar:Hide() |
||
681 | end |
||
682 | elseif (element == "BEBRestedXpTick") then |
||
683 | if ((GetRestState() == 1) and BEBCharSettings.BEBRestedXpTick.shown) then |
||
684 | local position |
||
685 | local xp, rest, xpmax, level = UnitXP("player"), GetXPExhaustion(), UnitXPMax("player"), UnitLevel("player") |
||
686 | if (level < 59) then |
||
687 | if ((xp + rest - xpmax) > BEB.XpPerLvl[level+1]) then |
||
688 | position = ((xp + rest - xpmax - BEB.XpPerLvl[level+1])/BEB.XpPerLvl[level+2]) * BEB.BEBMainWidth |
||
689 | BEBRestedXpTick.texture:SetTexCoord(0, 0.5, 0.5, 1) |
||
690 | BEB.BEBRestState = 3 |
||
691 | elseif ((xp + rest) > xpmax) then |
||
692 | position = ((xp + rest - xpmax)/BEB.XpPerLvl[level+1]) * BEB.BEBMainWidth |
||
693 | BEBRestedXpTick.texture:SetTexCoord(0.5, 1, 0, 0.5) |
||
694 | BEB.BEBRestState = 2 |
||
695 | else |
||
696 | position = (xp + rest)*BEB.BEBScale |
||
697 | BEBRestedXpTick.texture:SetTexCoord(0, 0.5, 0, 0.5) |
||
698 | BEB.BEBRestState = 1 |
||
699 | end |
||
700 | elseif (level == 59) then |
||
701 | if ((xp + rest - xpmax) > BEB.XpPerLvl[level+1]) then |
||
702 | position = BEB.BEBMainWidth |
||
703 | BEBRestedXpTick.texture:SetTexCoord(0, 0.5, 0.5, 1) |
||
704 | BEB.BEBRestState = 3 |
||
705 | elseif ((xp + rest) > xpmax) then |
||
706 | position = ((xp + rest - xpmax)/BEB.XpPerLvl[level+1]) * BEB.BEBMainWidth |
||
707 | BEBRestedXpTick.texture:SetTexCoord(0.5, 1, 0, 0.5) |
||
708 | BEB.BEBRestState = 2 |
||
709 | else |
||
710 | position = (xp + rest)*BEB.BEBScale |
||
711 | BEBRestedXpTick.texture:SetTexCoord(0, 0.5, 0, 0.5) |
||
712 | BEB.BEBRestState = 1 |
||
713 | end |
||
714 | elseif (level == 60) then |
||
715 | if ((xp + rest) > xpmax) then |
||
716 | position = BEB.BEBMainWidth |
||
717 | BEBRestedXpTick.texture:SetTexCoord(0.5, 1, 0, 0.5) |
||
718 | BEB.BEBRestState = 2 |
||
719 | else |
||
720 | position = (xp + rest)*BEB.BEBScale |
||
721 | BEBRestedXpTick.texture:SetTexCoord(0, 0.5, 0, 0.5) |
||
722 | BEB.BEBRestState = 1 |
||
723 | end |
||
724 | end |
||
725 | local offsets = BEBCharSettings.BEBRestedXpTick.location |
||
726 | BEBRestedXpTick:SetPoint("CENTER" ,"BEBMain" ,"LEFT", (position + offsets.x), offsets.y) |
||
727 | BEBRestedXpTick:Show() |
||
728 | else |
||
729 | BEBRestedXpTick:Hide() |
||
730 | BEB.BEBRestState = 0 |
||
731 | end |
||
732 | elseif (element == "BEBRestedXpTickGlow") then |
||
733 | if (BEBCharSettings.BEBRestedXpTickGlow.shown and (BEB.BEBRestState ~= 0) and (IsResting() == 1)) then |
||
734 | if (BEB.BEBRestState == 1) then |
||
735 | BEBRestedXpTickGlow.texture:SetTexCoord(0, 0.5, 0, 0.5) |
||
736 | BEBRestedXpTickGlow:Show() |
||
737 | elseif (BEB.BEBRestState == 2) then |
||
738 | BEBRestedXpTickGlow.texture:SetTexCoord(0.5, 1, 0, 0.5) |
||
739 | BEBRestedXpTickGlow:Show() |
||
740 | elseif (BEB.BEBRestState == 3) then |
||
741 | BEBRestedXpTickGlow.texture:SetTexCoord(0, 0.5, 0.5, 1) |
||
742 | BEBRestedXpTickGlow:Show() |
||
743 | end |
||
744 | else |
||
745 | BEBRestedXpTickGlow:Hide() |
||
746 | end |
||
747 | end |
||
748 | end |
||
749 | |||
750 | function BEB.OnUpdate(elapsed) |
||
751 | if (BEBINITIALIZED) then |
||
752 | if (BEB.TextTimeToHide) then |
||
753 | if (BEB.TextTimeToHide > 0) then |
||
754 | BEB.TextTimeToHide = BEB.TextTimeToHide - elapsed |
||
755 | else |
||
756 | BEB.TextTimeToHide = nil |
||
757 | BEBBarText:Hide() |
||
758 | end |
||
759 | end |
||
760 | BEB.TimeThisSession = GetTime() - BEB.StartTime |
||
761 | BEB.RateThisSession = BEB.XpThisSession/BEB.TimeThisSession |
||
762 | TimeFromLastUpdate = TimeFromLastUpdate + elapsed |
||
763 | if (TimeFromLastUpdate > UpdateFrequency) then |
||
764 | BEB.UpdateElement("BEBXpBar") |
||
765 | BEB.UpdateElement("BEBRestedXpBar") |
||
766 | BEB.UpdateElement("BEBRestedXpTick") |
||
767 | BEB.UpdateElement("BEBRestedXpTickGlow") |
||
768 | BEB.SetColors() |
||
769 | TimeFromLastUpdate = 0 |
||
770 | end |
||
771 | if (BEB.textevents["ON_UPDATE"]) then |
||
772 | StringOnUpdate = StringOnUpdate +elapsed |
||
773 | if (StringOnUpdate > 0.5) then |
||
774 | BEB.StringEvent("ON_UPDATE") |
||
775 | StringOnUpdate = 0 |
||
776 | end |
||
777 | end |
||
778 | BEB.Flashing(elapsed) |
||
779 | end |
||
780 | end |
||
781 | |||
782 | function BEB.StringEvent(event,writeframe) |
||
783 | if (BEB.textevents[event]) then |
||
784 | for frame,table in BEB.textevents[event] do |
||
785 | local Frame = getglobal(frame) |
||
786 | local text = "" |
||
787 | for _,n in table do |
||
788 | Frame.texttable[n].text = Frame.texttable[n].func() |
||
789 | end |
||
790 | for i=1,Frame.texttable.count do |
||
791 | text = text..Frame.texttable[i].text |
||
792 | end |
||
793 | if (Frame.textframe) then |
||
794 | Frame.textframe:SetText(text) |
||
795 | Frame:SetWidth(Frame.textframe:GetWidth()) |
||
796 | else |
||
797 | Frame.text = text |
||
798 | end |
||
799 | end |
||
800 | elseif (event == "WRITE_ALL") then |
||
801 | local Frame = getglobal(writeframe) |
||
802 | local text = "" |
||
803 | for i=1,Frame.texttable.count do |
||
804 | text = text..Frame.texttable[i].text |
||
805 | end |
||
806 | if (Frame.textframe) then |
||
807 | Frame.textframe:SetText(text) |
||
808 | Frame:SetWidth(Frame.textframe:GetWidth()) |
||
809 | else |
||
810 | Frame.text = text |
||
811 | end |
||
812 | end |
||
813 | end |
||
814 | |||
815 | function BEB.Feedback(msg) |
||
816 | DEFAULT_CHAT_FRAME:AddMessage( msg, 1.0, 1.0, 0.0 ); |
||
817 | end |
||
818 | |||
819 | function BEB.StartFlashing(element,rate,min,max) |
||
820 | local Element = getglobal(element) |
||
821 | if (not BEB.Flashers[element]) then |
||
822 | BEB.Flashers[element] = Element |
||
823 | Element.rate = rate |
||
824 | Element.min = min |
||
825 | Element.max = max |
||
826 | Element.scale = (max-min)/rate |
||
827 | Element.time = rate |
||
828 | if (Element.textframe) then |
||
829 | Element.textframe:SetAlpha(max) |
||
830 | elseif (Element.texture) then |
||
831 | Element.texture:SetAlpha(max) |
||
832 | end |
||
833 | end |
||
834 | end |
||
835 | |||
836 | function BEB.StopFlashing(element) |
||
837 | local Element = getglobal(element) |
||
838 | BEB.Flashers[element] = nil |
||
839 | Element.rate = nil |
||
840 | Element.min = nil |
||
841 | Element.max = nil |
||
842 | Element.scale = nil |
||
843 | Element.time = nil |
||
844 | -- SetElementAlpha(element) |
||
845 | end |
||
846 | |||
847 | function BEB.Flashing(elapsed) |
||
848 | for k,v in BEB.Flashers do |
||
849 | BEB.doFlash(k,v,elapsed) |
||
850 | end |
||
851 | end |
||
852 | function BEB.doFlash(element,Element,elapsed) |
||
853 | if (Element.shown) then |
||
854 | Element.time = Element.time - elapsed |
||
855 | while (Element.time < 0) do |
||
856 | Element.time = Element.rate + Element.time |
||
857 | Element.reversed = not Element.reversed |
||
858 | -- if (Element.cycles) then |
||
859 | -- Element.cycles = Element.cycles - 0.5 |
||
860 | -- if (Element.cycles == 0) then |
||
861 | -- BEB.StopFlashing(element) |
||
862 | -- Element.cycles = nil |
||
863 | -- return |
||
864 | -- end |
||
865 | -- end |
||
866 | end |
||
867 | if (Element.reversed) then |
||
868 | if (Element.textframe) then |
||
869 | Element.textframe:SetAlpha(Element.max-(Element.scale*Element.time)) |
||
870 | elseif (Element.texture) then |
||
871 | Element.texture:SetAlpha(Element.max-(Element.scale*Element.time)) |
||
872 | end |
||
873 | else |
||
874 | if (Element.textframe) then |
||
875 | Element.textframe:SetAlpha(Element.min+(Element.scale*Element.time)) |
||
876 | elseif (Element.texture) then |
||
877 | Element.texture:SetAlpha(Element.min+(Element.scale*Element.time)) |
||
878 | end |
||
879 | end |
||
880 | end |
||
881 | end |
||
882 | |||
883 | function BEB.UpdateFlashers() |
||
884 | if (IsResting() == 1) then |
||
885 | for v,_ in BEB.Flashframes do |
||
886 | BEB.StartFlashing(v,0.7,0.2,1) |
||
887 | end |
||
888 | else |
||
889 | for v,_ in BEB.Flashframes do |
||
890 | BEB.StopFlashing(v) |
||
891 | BEB.SetColors(v, true) |
||
892 | end |
||
893 | end |
||
894 | end |
||
895 | |||
896 | function BEB.SecondsToTime(seconds) |
||
897 | if (seconds < 60) then |
||
898 | return math.floor(seconds).."s" |
||
899 | elseif (seconds < 3600) then |
||
900 | return math.floor(seconds/60).."m"..math.floor(math.mod(seconds,60)).."s" |
||
901 | elseif (seconds < 86400) then |
||
902 | return math.floor(seconds/3600).."h"..math.floor(math.mod(seconds,3600)/60).."m" |
||
903 | else |
||
904 | return math.floor(seconds/86400).."d"..math.floor(math.mod(seconds,86400)/3600).."h" |
||
905 | end |
||
906 | end |
||
907 | |||
908 | function BEB.round(num, idp) |
||
909 | local mult = 10^(idp or 0) |
||
910 | return math.ceil((num*mult)-0.5) / mult |
||
911 | end |
||
912 | |||
913 | function BEB.sigfigs(num, figs) |
||
914 | if (num == 0) then |
||
915 | return 0 |
||
916 | else |
||
917 | local expo = math.floor(math.log(math.abs(num))/BEB.LOG_10) |
||
918 | return BEB.round(num, (figs-expo)-1) |
||
919 | end |
||
920 | end |
||
921 | |||
922 | function BEB.LoadDefaults() |
||
923 | if ( not BEBINITIALIZED ) then |
||
924 | BEBConfigFrame:Hide() |
||
925 | return |
||
926 | end |
||
927 | BEBCharSettings = nil |
||
928 | BEB.DefaultSettings() |
||
929 | BEB.SetupBars() |
||
930 | BEB.Feedback(BEB.TEXT.defaultsloaded) |
||
931 | BEBOPTIONS.OnShow() |
||
932 | end |