vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --Created by Tehu of Garona |
2 | -- |
||
3 | -- |
||
4 | --Credit goes out to the creators of AvgXP and AvgXPPlus for the AvgXP functions |
||
5 | --Credit goes out to the creator of TotalXP for the XP needed until 60 function |
||
6 | --Credit goes out the the creator of the original XPBar (non titan that is :P) for the sizing functions |
||
7 | |||
8 | TITAN_XPBAR_FREQUENCY=1 |
||
9 | local restxp=nil |
||
10 | PLAYER_ENTERING_WORLD=0 |
||
11 | TITAN_XPBAR_BUTTON_TEXT_XP="XP: %s" |
||
12 | TITAN_XPBAR_BUTTON_TEXT_NIL="%s" |
||
13 | TITAN_XPBAR_BUTTON_TEXT_NEEDED="%s XP" |
||
14 | TITAN_XPBAR_BUTTON_TEXT_NPCT="%s" |
||
15 | TITAN_XPBAR_MENU_TEXT="XPBar" |
||
16 | TITAN_XPBAR_MENU_SHOW_STATUS="Show XP Statusbar" |
||
17 | TITAN_XPBAR_MENU_HIDE_STATUS="Hide XP Statusbar" |
||
18 | TITAN_XPBAR_TOOLTIP_XP="Current XP:" |
||
19 | TITAN_XPBAR_TOOLTIP_LEV="Level XP:" |
||
20 | TITAN_XPBAR_TOOLTIP_REST="Rested XP:" |
||
21 | TITAN_XPBAR_TOOLTIP_NEED="XP Until Next Level:" |
||
22 | TITAN_XPBAR_TOOLTIP_PERCENT="" |
||
23 | TITAN_XPBAR_TOOLTIP="Experience Tooltip" |
||
24 | TITAN_XPBAR_TOOLTIP_CURRLEV="Currently Level:" |
||
25 | TITAN_XPBAR_TOOLTIP_XPTO60="XP Remaining Until 60" |
||
26 | TITAN_XPBAR_TOOLTIP_XPSOFAR="XP Gained Since Level 1" |
||
27 | TITAN_XPBAR_TOOLTIP_XPTO60PCT="" |
||
28 | TITAN_XPBAR_TOOLTIP_XPSOFARPCT="" |
||
29 | TITAN_XPBAR_TOTAL_TIME_PLAYED = "Total Time Played:" |
||
30 | TITAN_XPBAR_LEVEL_TIME_PLAYED = "Time Played This Level:" |
||
31 | TITAN_XPBAR_SESSION_TIME_PLAYED = "Time Played This Session:" |
||
32 | TITAN_XPBAR_SESSION_XP = "XP Gained This Session:" |
||
33 | TITAN_XPBAR_PER_HOUR_LEVEL = "XP Per Hour This Level:" |
||
34 | TITAN_XPBAR_PER_HOUR_SESSION = "XP Per Hour This Session:" |
||
35 | TITAN_XPBAR_EST_TIME_TO_LEVEL_LEVEL_RATE = "Time To Level At This Level's Rate:" |
||
36 | TITAN_XPBAR_EST_TIME_TO_LEVEL_SESSION_RATE = "Time To Level At This Session's Rate:" |
||
37 | |||
38 | TITAN_XPBAR_TOTAL_KILLS="Total Kills This Session:" |
||
39 | TITAN_XPBAR_TOTAL_NKILLS="Total Kills Needed To Level:" |
||
40 | TITAN_XPBAR_AVGXP="Average XP Gained Per Kill:" |
||
41 | TITAN_XPBAR_MENU_SHOW_TEXT="Show Average XP Text" |
||
42 | |||
43 | TITAN_XPBAR_NKILLS=" Needed: %s" |
||
44 | TITAN_XPBAR_KILLS=" Kills: %s" |
||
45 | TITAN_XPBAR_AVGXPTEXT="AVG XP: %s" |
||
46 | |||
47 | TITAN_XPBAR_MENU_SHOWCURR="Display Current Level Info" |
||
48 | TITAN_XPBAR_MENU_SHOWNEXT="Display XP Needed Until Next Level" |
||
49 | TITAN_XPBAR_MENU_CHAT="Enable Chat Output" |
||
50 | |||
51 | LBLUE_FONT_COLOR="|cff55A9FF" |
||
52 | |||
53 | TXP_pos = {}; |
||
54 | RegisterForSave("TXP_pos"); |
||
55 | AVG_pos = {}; |
||
56 | RegisterForSave("AVG_pos"); |
||
57 | |||
58 | function TitanPanelXPBarButton_OnLoad() |
||
59 | SlashCmdList["TXP"] = TXP_SlashHandler |
||
60 | SLASH_TXP1 = "/txp"; |
||
61 | |||
62 | SlashCmdList["TEST"] = TXP_TestHandler; |
||
63 | SLASH_TEST1 = "/test" |
||
64 | |||
65 | DEFAULT_CHAT_FRAME:AddMessage("TitanXPBar Loaded, /txp for options", 1, 1, 0) |
||
66 | |||
67 | this:RegisterEvent("VARIABLES_LOADED") |
||
68 | this:RegisterEvent("UPDATE_EXHAUSTION") |
||
69 | this:RegisterEvent("PLAYER_ENTERING_WORLD") |
||
70 | this:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); |
||
71 | this:RegisterEvent("UNIT_NAME_UPDATE"); |
||
72 | this:RegisterEvent("PLAYER_TARGET_CHANGED"); |
||
73 | this:RegisterEvent("PLAYER_LEVEL_UP") |
||
74 | this:RegisterEvent("PLAYER_XP_UPDATE"); |
||
75 | this.registry={ |
||
76 | id="XPBar", |
||
77 | menuText = TITAN_XPBAR_MENU_TEXT, |
||
78 | buttonTextFunction="TitanPanelXPBarButton_GetButtonText", |
||
79 | tooltipTitle = TITAN_XPBAR_TOOLTIP, |
||
80 | tooltipTextFunction = "TitanPanelXPBarButton_GetTooltipText", |
||
81 | } |
||
82 | |||
83 | totalkilled=0 |
||
84 | avgxp=0 |
||
85 | totalxpgained=0 |
||
86 | lastxpgained=0 |
||
87 | numleft=0 |
||
88 | bar = {255, 255, 255} |
||
89 | |||
90 | |||
91 | |||
92 | end |
||
93 | |||
94 | function TXP_TestHandler(msg) |
||
95 | RegisterForSave("test_Args"); |
||
96 | test_Args=tyn_Parser(msg); |
||
97 | end |
||
98 | |||
99 | function tyn_Parser(commandline) |
||
100 | local t = {}; |
||
101 | local k, v; |
||
102 | local msg=commandline; |
||
103 | for k, v in string.gfind(msg, "(%w+)=\"(.-)\"") do |
||
104 | t[k] = v |
||
105 | end |
||
106 | msg=string.gsub(msg, "(%w+)=\"(.-)\"", "") |
||
107 | for k, v in string.gfind(msg, "(%w+)=(%w+)") do |
||
108 | t[k] = v |
||
109 | end |
||
110 | msg=string.gsub(msg, "(%w+)=(%w+)", "") |
||
111 | for k in string.gfind(msg, "(%w+)") do |
||
112 | t[k] = true; |
||
113 | end |
||
114 | return t; |
||
115 | end |
||
116 | |||
117 | function TitanPanelXPBarButton_OnEvent(event) |
||
118 | local rxp,curr,max,needed,currpcent,needpcent,currlev,nextlev=TitanPanelXPBarButton_GetXPBarInfo() |
||
119 | TitanPanelButton_UpdateButton("XPBar") |
||
120 | Statusbar_Update() |
||
121 | |||
122 | if (TitanSettings.Chat == nil) then |
||
123 | if (event == "PLAYER_XP_UPDATE") then |
||
124 | DEFAULT_CHAT_FRAME:AddMessage(LBLUE_FONT_COLOR..curr.."/"..max.." XP ("..needpcent..") to go"..FONT_COLOR_CODE_CLOSE) |
||
125 | DEFAULT_CHAT_FRAME:AddMessage(LBLUE_FONT_COLOR..needed.." XP Until Level "..nextlev..FONT_COLOR_CODE_CLOSE) |
||
126 | end |
||
127 | end |
||
128 | |||
129 | if (event == "PLAYER_ENTERING_WORLD") then |
||
130 | if (PLAYER_ENTERING_WORLD == 0) then |
||
131 | this.initXP = UnitXP("player"); |
||
132 | this.accumXP = 0; |
||
133 | this.sessionXP = 0; |
||
134 | PLAYER_ENTERING_WORLD = 1 |
||
135 | end |
||
136 | elseif (event == "PLAYER_XP_UPDATE") then |
||
137 | if (not this.initXP) then |
||
138 | this.initXP = UnitXP("player"); |
||
139 | this.accumXP = 0; |
||
140 | this.sessionXP = 0; |
||
141 | end |
||
142 | this.sessionXP = UnitXP("player") - this.initXP + this.accumXP; |
||
143 | elseif (event == "PLAYER_LEVEL_UP") then |
||
144 | this.accumXP = this.accumXP + UnitXPMax("player") - this.initXP; |
||
145 | this.initXP = 0; |
||
146 | end |
||
147 | |||
148 | if(event=="CHAT_MSG_COMBAT_XP_GAIN") then |
||
149 | for mobile_name, xp in string.gfind(arg1, "(.+) dies, you gain (%d+) experience.") do |
||
150 | lastxpgained = tonumber(xp) |
||
151 | totalkilled = totalkilled + 1 |
||
152 | totalxpgained = totalxpgained + lastxpgained |
||
153 | end |
||
154 | end |
||
155 | |||
156 | |||
157 | |||
158 | |||
159 | if( (totalkilled > 0) and (totalkilled~=nil) ) then |
||
160 | avgxp = floor(totalxpgained / totalkilled * 100) / 100; |
||
161 | end |
||
162 | |||
163 | |||
164 | if( (avgxp > 0) and (avgxp~=nil) ) then |
||
165 | numleft = ( UnitXPMax("player") - UnitXP("player") ) / avgxp; |
||
166 | numleft = ceil(numleft); |
||
167 | end |
||
168 | |||
169 | if (event == "VARIABLES_LOADED") then |
||
170 | if (XPBar_Width) then |
||
171 | XPBG:SetWidth(XPBar_Width); |
||
172 | XPStatus:SetWidth(XPBar_Width); |
||
173 | end |
||
174 | |||
175 | if (XPBar_Height) then |
||
176 | XPBG:SetHeight(XPBar_Height); |
||
177 | XPStatus:SetHeight(XPBar_Height); |
||
178 | end |
||
179 | |||
180 | if (AVGXP_Locked) then |
||
181 | TXP_SlashHandler('lock'); |
||
182 | end |
||
183 | |||
184 | |||
185 | TXP() |
||
186 | AVG() |
||
187 | end |
||
188 | |||
189 | end |
||
190 | |||
191 | function TitanPanelXPBarButton_GetButtonText(id) |
||
192 | local rxp,curr,max,needed,currpcent,needpcent,currlev,nextlev=TitanPanelXPBarButton_GetXPBarInfo() |
||
193 | local button, id = TitanUtils_GetButton(id, true); |
||
194 | if (rxp == nil) then |
||
195 | rxp=0 |
||
196 | else |
||
197 | rxp=rxp |
||
198 | end |
||
199 | |||
200 | |||
201 | if (TitanSettings.Status == 1) then |
||
202 | XPStatus:Hide() |
||
203 | end |
||
204 | |||
205 | if (TitanSettings.Status == nil) then |
||
206 | XPStatus:Show() |
||
207 | end |
||
208 | |||
209 | |||
210 | if (TitanSettings.Showtext == nil) then |
||
211 | getglobal("AVGText"):SetText("AVG XP: "..TitanUtils_GetHighlightText(avgxp).." Kills: "..TitanUtils_GetHighlightText(totalkilled).." Needed: "..TitanUtils_GetHighlightText(numleft)) |
||
212 | AVGXPButton:Show() |
||
213 | end |
||
214 | |||
215 | if (TitanSettings.Showtext == 1) then |
||
216 | AVGXPButton:Hide() |
||
217 | end |
||
218 | |||
219 | if (TitanSettings.XPFormat == 1) then |
||
220 | return |
||
221 | format(TITAN_XPBAR_BUTTON_TEXT_XP,TitanUtils_GetHighlightText(curr)).."/".. |
||
222 | format(TITAN_XPBAR_BUTTON_TEXT_NIL,TitanUtils_GetHighlightText(max)).." + (".. |
||
223 | format(TITAN_XPBAR_BUTTON_TEXT_NIL,TitanUtils_GetHighlightText(rxp)).." Rested)" |
||
224 | end |
||
225 | |||
226 | |||
227 | if (TitanSettings.XPFormat == nil) then |
||
228 | return |
||
229 | format(TITAN_XPBAR_BUTTON_TEXT_NEEDED,TitanUtils_GetHighlightText(needed)).." (".. |
||
230 | format(TITAN_XPBAR_BUTTON_TEXT_NPCT,TitanUtils_GetHighlightText(needpcent))..") until ".. |
||
231 | format(TITAN_XPBAR_BUTTON_TEXT_NIL,TitanUtils_GetHighlightText(nextlev)).." (".. |
||
232 | format(TITAN_XPBAR_BUTTON_TEXT_NIL,TitanUtils_GetHighlightText(rxp)).." Rested)" |
||
233 | end |
||
234 | |||
235 | end |
||
236 | |||
237 | function TitanPanelXPBarButton_GetXPBarInfo() |
||
238 | local rxp=GetXPExhaustion("player") |
||
239 | local max=UnitXPMax("player") |
||
240 | local curr=UnitXP("player") |
||
241 | local needed=max - curr |
||
242 | local currpercent=string.format("%.2f", ( curr / max) * 100) |
||
243 | local needpcent=string.format("%.2f", ( needed / max) * 100) |
||
244 | local currlev=UnitLevel("player") |
||
245 | local nextlev=currlev + 1 |
||
246 | return rxp,curr,max,needed,currpercent.."%",needpcent.."%",currlev,nextlev |
||
247 | end |
||
248 | |||
249 | function TitanPanelXPBarButton_GetTooltipText() |
||
250 | local rxp,curr,max,needed,currpercent,needpcent,currlev=TitanPanelXPBarButton_GetXPBarInfo() |
||
251 | local totalxp,totalMaxXP,totalxppct,needxp,needxppct,totalgpct,totalnpct=totalxp(level) |
||
252 | local totalTime = TitanUtils_GetTotalTime(); |
||
253 | local sessionTime = TitanUtils_GetSessionTime(); |
||
254 | local levelTime = TitanUtils_GetLevelTime(); |
||
255 | local xpPerHourThisLevel = curr / levelTime * 3600; |
||
256 | local xpPerHourThisSession = this.sessionXP / sessionTime * 3600; |
||
257 | local estTimeToLevelThisLevel = TitanUtils_Ternary((curr == 0), -1, needed / curr * levelTime); |
||
258 | local estTimeToLevelThisSession = TitanUtils_Ternary((this.sessionXP == 0), -1, needed / this.sessionXP * sessionTime); |
||
259 | |||
260 | if (rxp == nil) then |
||
261 | rxp=0 |
||
262 | rxppcent=0 .."%" |
||
263 | else |
||
264 | rxppcent=floor(rxp*100/max) .."%" |
||
265 | end |
||
266 | |||
267 | return "".. |
||
268 | TITAN_XPBAR_TOOLTIP_CURRLEV.." "..GetBlueText(currlev).."\n".. |
||
269 | "\n".. |
||
270 | TITAN_XPBAR_TOOLTIP_XP.." "..TitanUtils_GetHighlightText(curr).." ".. |
||
271 | TITAN_XPBAR_TOOLTIP_PERCENT.." ("..TitanUtils_GetHighlightText(currpercent)..")".."\n".. |
||
272 | TITAN_XPBAR_TOOLTIP_LEV.." "..TitanUtils_GetHighlightText(max).."\n".. |
||
273 | TITAN_XPBAR_TOOLTIP_NEED.." "..TitanUtils_GetHighlightText(needed).." ".. |
||
274 | TITAN_XPBAR_TOOLTIP_PERCENT.." ("..TitanUtils_GetHighlightText(needpcent)..")".."\n".. |
||
275 | TITAN_XPBAR_TOOLTIP_REST.." "..TitanUtils_GetHighlightText(rxp).." ".. |
||
276 | TITAN_XPBAR_TOOLTIP_PERCENT.." ("..TitanUtils_GetHighlightText(rxppcent)..")".."\n".."\n".. |
||
277 | TITAN_XPBAR_TOOLTIP_XPSOFAR..": "..GetBlueText(totalxp).." (".. |
||
278 | TITAN_XPBAR_TOOLTIP_XPSOFARPCT..""..GetBlueText(totalgpct)..")".."\n".. |
||
279 | TITAN_XPBAR_TOOLTIP_XPTO60.." "..GetBlueText(needxp).." (".. |
||
280 | TITAN_XPBAR_TOOLTIP_XPTO60PCT..""..GetBlueText(totalnpct)..")".."\n".."\n".. |
||
281 | TITAN_XPBAR_SESSION_XP.." "..TitanUtils_GetGreenText(this.sessionXP).."\n".. |
||
282 | TITAN_XPBAR_AVGXP.." "..TitanUtils_GetGreenText(avgxp).."\n".."\n".. |
||
283 | TITAN_XPBAR_TOTAL_KILLS.." "..GetBlueText(totalkilled).."\n".. |
||
284 | TITAN_XPBAR_TOTAL_NKILLS.." "..GetBlueText(numleft).."\n".."\n".. |
||
285 | TITAN_XPBAR_PER_HOUR_LEVEL.." "..TitanUtils_GetHighlightText(floor((xpPerHourThisLevel / 100) *100)).."\n".. |
||
286 | TITAN_XPBAR_PER_HOUR_SESSION.." "..TitanUtils_GetHighlightText(floor((xpPerHourThisSession / 100)*100)).."\n".."\n".. |
||
287 | TITAN_XPBAR_TOTAL_TIME_PLAYED.." "..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(totalTime)).."\n".. |
||
288 | TITAN_XPBAR_EST_TIME_TO_LEVEL_LEVEL_RATE.." "..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisLevel)).."\n".. |
||
289 | TITAN_XPBAR_EST_TIME_TO_LEVEL_SESSION_RATE.." "..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisSession)) |
||
290 | |||
291 | |||
292 | end |
||
293 | |||
294 | function GetBlueText(text) |
||
295 | if (text) then |
||
296 | return LBLUE_FONT_COLOR..text..FONT_COLOR_CODE_CLOSE; |
||
297 | end |
||
298 | end |
||
299 | |||
300 | function Statusbar_Update() |
||
301 | local currValue = UnitXP("player"); |
||
302 | local maxValue = UnitXPMax("player"); |
||
303 | |||
304 | XPStatus:SetMinMaxValues(0, maxValue); |
||
305 | XPStatus:SetValue(currValue); |
||
306 | |||
307 | XPBG:SetMinMaxValues(0, maxValue); |
||
308 | XPBG:SetValue(maxValue) |
||
309 | |||
310 | XPStatus:ClearAllPoints(); |
||
311 | XPStatus:SetPoint("BOTTOM", "UIParent", "BOTTOM", TXP_pos["LOCATIONX"], TXP_pos["LOCATIONY"]); |
||
312 | |||
313 | AVGText:ClearAllPoints(); |
||
314 | AVGText:SetPoint("BOTTOM", "UIParent", "BOTTOM", AVG_pos["LOCX"], AVG_pos["LOCY"]); |
||
315 | end |
||
316 | |||
317 | function TitanPanelRightClickMenu_PrepareXPBarMenu() |
||
318 | local id = "XPBar"; |
||
319 | local info; |
||
320 | |||
321 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText); |
||
322 | |||
323 | info = {}; |
||
324 | info.text = TITAN_XPBAR_MENU_SHOWCURR |
||
325 | info.func = TitanPanelXPBarButton_ShowCurr |
||
326 | info.checked=TitanSettings.XPFormat |
||
327 | UIDropDownMenu_AddButton(info); |
||
328 | |||
329 | info = {}; |
||
330 | info.text = TITAN_XPBAR_MENU_SHOWNEXT |
||
331 | info.func = TitanPanelXPBarButton_ShowNext |
||
332 | info.checked=TitanUtils_Toggle(TitanSettings.XPFormat) |
||
333 | UIDropDownMenu_AddButton(info) |
||
334 | TitanPanelRightClickMenu_AddSpacer() |
||
335 | |||
336 | info = {}; |
||
337 | info.text = TITAN_XPBAR_MENU_SHOW_STATUS; |
||
338 | info.func = TitanPanelXPBarButton_ShowStatus; |
||
339 | info.checked = TitanUtils_Toggle(TitanSettings.Status); |
||
340 | UIDropDownMenu_AddButton(info); |
||
341 | |||
342 | info = {}; |
||
343 | info.disabled = nil |
||
344 | info.text = TITAN_XPBAR_MENU_SHOW_TEXT |
||
345 | info.func = TitanPanelXPBarButton_ShowText |
||
346 | info.checked = TitanUtils_Toggle(TitanSettings.Showtext) |
||
347 | UIDropDownMenu_AddButton(info) |
||
348 | |||
349 | info = {}; |
||
350 | info.text = TITAN_XPBAR_MENU_CHAT |
||
351 | info.func = TitanPanelXPBarButton_Chat |
||
352 | info.checked = TitanUtils_Toggle(TitanSettings.Chat) |
||
353 | UIDropDownMenu_AddButton(info) |
||
354 | |||
355 | info = {} |
||
356 | info.text = "Enable Shift+Click Output" |
||
357 | info.func = TitanPanelXPBarButton_Shift |
||
358 | info.checked = TitanUtils_Toggle(TitanSettings.Shift) |
||
359 | UIDropDownMenu_AddButton(info) |
||
360 | |||
361 | TitanPanelRightClickMenu_AddSpacer(); |
||
362 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, id, TITAN_PANEL_MENU_FUNC_HIDE); |
||
363 | end |
||
364 | |||
365 | function TitanPanelXPBarButton_ShowStatus() |
||
366 | TitanSettings.Status = TitanUtils_Toggle(TitanSettings.Status) |
||
367 | TitanPanelButton_UpdateButton("XPBar"); |
||
368 | end |
||
369 | |||
370 | |||
371 | function totalxp(level) |
||
372 | myLevel = UnitLevel("player"); |
||
373 | myCurrXP = UnitXP("player"); |
||
374 | myMaxXP = UnitXPMax("player"); |
||
375 | myTNLXP = myMaxXP - myCurrXP; |
||
376 | |||
377 | xpl = { 0, 400, 1300, 2700, 4800, 7600, 11200, 15700, 21100, 27600, |
||
378 | 35200, 44000, 54100, 65500, 78400, 92800, 108800, 126500, |
||
379 | 145900, 167200, 190400, 215600, 242900, 272300, 304000, |
||
380 | 338000, 374400, 413300, 454700, 499000, 546400, 597200, |
||
381 | 651900, 710500, 773300, 840300, 911900, 988000, 1068800, |
||
382 | 1154500, 1245200, 1341000, 1442000, 1548300, 1660100, |
||
383 | 1777500, 1900700, 2029800, 2164900, 2306100, 2453600, |
||
384 | 2607500, 2767900, 2935000, 3108900, 3289700, 3477600, |
||
385 | 3672600, 3874900, 4084700 } |
||
386 | |||
387 | local totalxp = xpl[myLevel] + myCurrXP; |
||
388 | local totalMaxXP = xpl[60]; |
||
389 | local totalxppct = totalxp / totalMaxXP; |
||
390 | |||
391 | local needxp = totalMaxXP - totalxp |
||
392 | local needxppct = (totalMaxXP - totalxp) / totalMaxXP |
||
393 | |||
394 | local totalgpct = floor(totalxppct * 10000) / 100 |
||
395 | local totalnpct = floor(needxppct * 10000) / 100 |
||
396 | |||
397 | return totalxp,totalMaxXP,totalxppct,needxp,needxppct,totalgpct.."%",totalnpct.."%" |
||
398 | end |
||
399 | |||
400 | function TitanPanelXPBarButton_ShowText() |
||
401 | TitanSettings.Showtext=TitanUtils_Toggle(TitanSettings.Showtext) |
||
402 | TitanPanelButton_UpdateButton("XPBar") |
||
403 | end |
||
404 | |||
405 | function TitanPanelXPBarButton_Chat() |
||
406 | TitanSettings.Chat=TitanUtils_Toggle(TitanSettings.Chat) |
||
407 | end |
||
408 | |||
409 | function TitanPanelXPBarButton_ShowCurr() |
||
410 | TitanSettings.XPFormat=1 |
||
411 | TitanPanelButton_UpdateButton("XPBar") |
||
412 | end |
||
413 | |||
414 | function TitanPanelXPBarButton_ShowNext() |
||
415 | TitanSettings.XPFormat=nil |
||
416 | TitanPanelButton_UpdateButton("XPBar") |
||
417 | end |
||
418 | |||
419 | function TitanPanelXPBarButton_Shift() |
||
420 | TitanSettings.Shift=TitanUtils_Toggle(TitanSettings.Shift) |
||
421 | TitanPanelButton_UpdateButton("XPBar") |
||
422 | end |
||
423 | |||
424 | function TitanPanelXPBarButton_OnClick() |
||
425 | local rxp,curr,max,needed,currpercent,needpcent,currlev,nextlev=TitanPanelXPBarButton_GetXPBarInfo() |
||
426 | |||
427 | |||
428 | if (IsShiftKeyDown()) then |
||
429 | if (not chatFrame) then |
||
430 | chatFrame = DEFAULT_CHAT_FRAME; |
||
431 | end |
||
432 | |||
433 | chatType = chatFrame.editBox.chatType; |
||
434 | |||
435 | if (TitanSettings.Shift == nil) then |
||
436 | if (ChatFrameEditBox:IsVisible()) then |
||
437 | ChatFrameEditBox:Insert("Currently "..curr.."/"..max.." XP with "..needed.." XP ("..needpcent..") until level "..nextlev); |
||
438 | else |
||
439 | SendChatMessage("Currently "..curr.."/"..max.." XP with "..needed.." XP ("..needpcent..") until level "..nextlev); |
||
440 | end |
||
441 | |||
442 | end |
||
443 | end |
||
444 | end |
||
445 | |||
446 | function TXP_SlashHandler(msg) |
||
447 | |||
448 | if (msg == 'help') then msg = nil end |
||
449 | --if (msg == '') then |
||
450 | -- DEFAULT_CHAT_FRAME:AddMessage("Usage: /txp height=## width=## x=## y=## avgx=## avgy=##", 1, 1, 0) |
||
451 | -- DEFAULT_CHAT_FRAME:AddMessage("Typing just '/txp x' (or y) will display the current x (or y) position", 1, 1, 0) |
||
452 | --end |
||
453 | |||
454 | if msg then |
||
455 | |||
456 | local LOCK = false; |
||
457 | local UNLOCK = false; |
||
458 | |||
459 | local param = TXP_Split(msg, " "); |
||
460 | |||
461 | |||
462 | |||
463 | |||
464 | local i = 1; |
||
465 | |||
466 | |||
467 | while ( param[i] ~= nil ) do |
||
468 | local current = string.lower(param[i]); |
||
469 | if (string.sub(current, 1, 7)=="height=") then |
||
470 | local height=tonumber(string.sub(current, 8)); |
||
471 | if (height) then |
||
472 | if (height<10) then |
||
473 | height=10; |
||
474 | end |
||
475 | XPBar_Height = height; |
||
476 | XPBG:SetHeight(XPBar_Height); |
||
477 | XPStatus:SetHeight(XPBar_Height); |
||
478 | end |
||
479 | end |
||
480 | if (string.sub(current, 1, 6)=="width=") then |
||
481 | local width=tonumber(string.sub(current, 7)); |
||
482 | if (width) then |
||
483 | if (width<50) then |
||
484 | width=50; |
||
485 | end |
||
486 | XPBar_Width = width; |
||
487 | XPBG:SetWidth(XPBar_Width); |
||
488 | XPStatus:SetWidth(XPBar_Width); |
||
489 | end |
||
490 | end |
||
491 | |||
492 | if (current == "x") then |
||
493 | DEFAULT_CHAT_FRAME:AddMessage("Current Statusbar X = " ..TXP_pos["LOCATIONX"], 1, 1, 0); |
||
494 | end |
||
495 | |||
496 | if (current == "") then |
||
497 | DEFAULT_CHAT_FRAME:AddMessage("Use: /txp height=## width=## x=## y=## avgx=## avgy=##", 1, 1, 0) |
||
498 | DEFAULT_CHAT_FRAME:AddMessage("Typing just '/txp x'(or y) will display the current x (or y) position", 1, 1, 0) |
||
499 | DEFAULT_CHAT_FRAME:AddMessage("The same works for avgx and avgy", 1, 1, 0) |
||
500 | end |
||
501 | |||
502 | if (string.sub(current, 1, 2)=="x=") then |
||
503 | local xpos=tonumber(string.sub(current,3)) |
||
504 | if (xpos) then |
||
505 | if (xpos==0) then |
||
506 | xpos=0 |
||
507 | end |
||
508 | TXP_pos["LOCATIONX"] = xpos |
||
509 | end |
||
510 | end |
||
511 | |||
512 | if (current == "y") then |
||
513 | DEFAULT_CHAT_FRAME:AddMessage("Current Statusbar Y = " ..TXP_pos["LOCATIONY"], 1, 1, 0); |
||
514 | end |
||
515 | |||
516 | if (current == "avgx") then |
||
517 | DEFAULT_CHAT_FRAME:AddMessage("Current AVGXP X = " ..AVG_pos["LOCX"], 1, 1, 0); |
||
518 | end |
||
519 | |||
520 | if (current == "avgy") then |
||
521 | DEFAULT_CHAT_FRAME:AddMessage("Current AVGXP Y = " ..AVG_pos["LOCY"], 1, 1, 0); |
||
522 | end |
||
523 | |||
524 | if (string.sub(current, 1, 2)=="y=") then |
||
525 | local ypos=tonumber(string.sub(current,3)) |
||
526 | if (ypos) then |
||
527 | if (ypos == 0) then |
||
528 | ypos=0 |
||
529 | end |
||
530 | TXP_pos["LOCATIONY"] = ypos |
||
531 | end |
||
532 | end |
||
533 | |||
534 | if (string.sub(current, 1, 5)=="avgx=") then |
||
535 | local avgxpos=tonumber(string.sub(current,6)) |
||
536 | if (avgxpos) then |
||
537 | if (avgxpos == 0) then |
||
538 | avgxpos=0 |
||
539 | end |
||
540 | AVG_pos["LOCX"] = avgxpos |
||
541 | end |
||
542 | end |
||
543 | |||
544 | if (string.sub(current, 1, 5)=="avgy=") then |
||
545 | local avgypos=tonumber(string.sub(current,6)) |
||
546 | if (avgypos) then |
||
547 | if (avgypos == 0) then |
||
548 | avgypos=0 |
||
549 | end |
||
550 | AVG_pos["LOCY"] = avgypos |
||
551 | end |
||
552 | end |
||
553 | |||
554 | i = i + 1; |
||
555 | |||
556 | end |
||
557 | |||
558 | |||
559 | |||
560 | Statusbar_Update(); |
||
561 | TXP() |
||
562 | AVG() |
||
563 | end |
||
564 | end |
||
565 | |||
566 | function TXP_Split(toCut, separator) |
||
567 | local splitted = {}; |
||
568 | local i = 0; |
||
569 | local regEx = "([^" .. separator .. "]*)" .. separator .. "?"; |
||
570 | |||
571 | for item in string.gfind(toCut .. separator, regEx) do |
||
572 | i = i + 1; |
||
573 | splitted[i] = TXP_Trim(item) or ''; |
||
574 | end |
||
575 | splitted[i] = nil; |
||
576 | return splitted; |
||
577 | end |
||
578 | |||
579 | function TXP_Trim (s) |
||
580 | return (string.gsub(s, "^%s*(.-)%s*$", "%1")); |
||
581 | end |
||
582 | |||
583 | function TXP() |
||
584 | if ( not TXP_pos["LOCATIONX"] ) then |
||
585 | TXP_pos["LOCATIONX"] = "0"; |
||
586 | end |
||
587 | |||
588 | if ( not TXP_pos["LOCATIONY"] ) then |
||
589 | TXP_pos["LOCATIONY"] = "90"; |
||
590 | end |
||
591 | end |
||
592 | |||
593 | function AVG() |
||
594 | if ( not AVG_pos["LOCX"] ) then |
||
595 | AVG_pos["LOCX"] = "0"; |
||
596 | end |
||
597 | |||
598 | if ( not AVG_pos["LOCY"] ) then |
||
599 | AVG_pos["LOCY"] = "90"; |
||
600 | end |
||
601 | end |