vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local abacus = AbacusLib:GetInstance('1.0')
2 local babbleZone = BabbleLib:GetInstance('Zone 1.1')
3 local compost = CompostLib:GetInstance('compost-1')
4 local crayon = CrayonLib:GetInstance('1.0')
5 local dewdrop = DewdropLib:GetInstance('1.0')
6 local glory = GloryLib:GetInstance('1.0')
7 local metro = Metrognome:GetInstance('1')
8 local tablet = TabletLib:GetInstance('1.0')
9  
10 local bfNum, bfAlpha
11  
12 BattlegroundFu = FuBarPlugin:GetInstance("1.2"):new({
13 name = BattlegroundFuLocals.NAME,
14 description = BattlegroundFuLocals.DESCRIPTION,
15 version = "1.1.5",
16 releaseDate = "05-27-2006",
17 aceCompatible = 103,
18 author = "Mynithrosil of Feathermoon",
19 email = "hyperactiveChipmunk@gmail.com",
20 website = "http://hyperactiveChipmunk.wowinterface.com",
21 category = "others",
22 db = AceDatabase:new("BattlegroundFuDB"),
23 defaults = {
24 hideMinimapButton = false,
25 invertQueueProgress = false,
26 clickShowsScoreboard = false,
27 showTeamSizes = true,
28 showTeamScores = true,
29 showNumBases = true,
30 showResourceTTV = true,
31 showBattlefieldObjectiveStatus = true,
32 showUncontestedObjectives = true,
33 showCTFFlagCarriers = true,
34 showBattlefieldPlayerStatistics = true,
35 showBattlefieldQueues = true,
36 hideQueueText = {},
37 },
38 cmd = AceChatCmd:new(BattlegroundFuLocals.COMMANDS, BattlegroundFuLocals.CMD_OPTIONS),
39 hasIcon = true,
40 clickableTooltip = true,
41 loc = BattlegroundFuLocals,
42 updateTime = 1,
43 FACTION_ICON_PATH = "Interface\\GroupFrame\\UI-Group-PVP-",
44 })
45 --User Options Methods=========================================================
46 function BattlegroundFu:IsHidingMinimapButton()
47 return self.data.hideMinimapButton
48 end
49  
50 function BattlegroundFu:ToggleHidingMinimapButton(loud)
51 self.data.hideMinimapButton = not self.data.hideMinimapButton
52 if loud then
53 self.cmd:status(self.loc.ARGUMENT_HIDEMINIMAPBUTTON, self.data.hideMinimapButton and 1 or 0, FuBarLocals.MAP_ONOFF)
54 end
55 if self.data.hideMinimapButton then
56 MiniMapBattlefieldFrame:Hide()
57 else
58 MiniMapBattlefieldFrame:Show()
59 end
60 return self.data.hideMinimapButton
61 end
62  
63 function BattlegroundFu:IsInvertQueueProgress()
64 return self.data.invertQueueProgress
65 end
66  
67 function BattlegroundFu:ToggleInvertQueueProgress(loud)
68 self.data.invertQueueProgress = not self.data.invertQueueProgress
69 if loud then
70 self.cmd:status(self.loc.ARGUMENT_INVERTQUEUEPROGRESS, self.data.invertQueueProgress and 1 or 0, FuBarLocals.MAP_ONOFF)
71 end
72 self:UpdateDisplay()
73 return self.data.invertQueueProgress
74 end
75  
76 function BattlegroundFu:IsClickShowsScoreboard()
77 return self.data.clickShowsScoreboard
78 end
79  
80 function BattlegroundFu:ToggleClickShowsScoreboard(loud)
81 self.data.clickShowsScoreboard = not self.data.clickShowsScoreboard
82 if loud then
83 self.cmd:status(self.loc.ARGUMENT_CLICKSHOWSSCOREBOARD, self.data.clickShowsScoreboard and 1 or 0, FuBarLocals.MAP_ONOFF)
84 end
85 self:UpdateDisplay()
86 end
87  
88 function BattlegroundFu:IsShowingTeamSizes()
89 return self.data.showTeamSizes
90 end
91  
92 function BattlegroundFu:ToggleShowingTeamSizes(loud)
93 self.data.showTeamSizes = not self.data.showTeamSizes
94 if loud then
95 self.cmd:status(self.loc.ARGUMENT_SHOWTEAMSIZES, self.data.showTeamSizes and 1 or 0, FuBarLocals.MAP_ONOFF)
96 end
97 self:UpdateTooltip()
98 return self.data.showTeamSizes
99 end
100  
101 function BattlegroundFu:IsShowingTeamScores()
102 return self.data.showTeamScores
103 end
104  
105 function BattlegroundFu:ToggleShowingTeamScores(loud)
106 self.data.showTeamScores = not self.data.showTeamScores
107 if loud then
108 self.cmd:status(self.loc.ARGUMENT_SHOWTEAMSCORES, self.data.showTeamScores and 1 or 0, FuBarLocals.MAP_ONOFF)
109 end
110 self:UpdateTooltip()
111 return self.data.showTeamScores
112 end
113  
114 function BattlegroundFu:IsShowingNumBases()
115 return self.data.showNumBases
116 end
117  
118 function BattlegroundFu:ToggleShowingNumBases(loud)
119 self.data.showNumBases = not self.data.showNumBases
120 if loud then
121 self.cmd:status(self.loc.ARGUMENT_SHOWNUMBASES, self.data.showNumBases and 1 or 0, FuBarLocals.MAP_ONOFF)
122 end
123 self:UpdateTooltip()
124 return self.data.showNumBases
125 end
126  
127 function BattlegroundFu:IsShowingResourceTTV()
128 return self.data.showResourceTTV
129 end
130  
131 function BattlegroundFu:ToggleShowingResourceTTV(loud)
132 self.data.showResourceTTV = not self.data.showResourceTTV
133 if loud then
134 self.cmd:status(self.loc.ARGUMENT_SHOWRESOURCETTV, self.data.showResourceTTV and 1 or 0, FuBarLocals.MAP_ONOFF)
135 end
136 self:UpdateTooltip()
137 return self.data.showResourceTTV
138 end
139  
140 function BattlegroundFu:IsShowingBattlefieldPlayerStatistics()
141 return self.data.showBattlefieldPlayerStatistics
142 end
143  
144 function BattlegroundFu:ToggleShowingBattlefieldPlayerStatistics(loud)
145 self.data.showBattlefieldPlayerStatistics = not self.data.showBattlefieldPlayerStatistics
146 if loud then
147 self.cmd:status(self.loc.ARGUMENT_SHOWBATTLEFIELDSTATS, self.data.showBattlefieldPlayerStatistics and 1 or 0, FuBarLocals.MAP_ONOFF)
148 end
149 self:UpdateTooltip()
150 return self.data.showBattlefieldPlayerStatistics
151 end
152  
153 function BattlegroundFu:IsShowingBattlefieldObjectiveStatus()
154 return self.data.showBattlefieldObjectiveStatus
155 end
156  
157 function BattlegroundFu:ToggleShowingBattlefieldObjectiveStatus(loud)
158 self.data.showBattlefieldObjectiveStatus = not self.data.showBattlefieldObjectiveStatus
159 if loud then
160 self.cmd:status(self.loc.ARGUMENT_SHOWOBJECTIVESTATUS, self.data.showBattlefieldObjectiveStatus and 1 or 0, FuBarLocals.MAP_ONOFF)
161 end
162 self:UpdateTooltip()
163 return self.data.showBattlefieldObjectiveStatus
164 end
165  
166 function BattlegroundFu:IsShowingUncontestedObjectives()
167 return self.data.showUncontestedObjectives
168 end
169  
170 function BattlegroundFu:ToggleShowingUncontestedObjectives(loud)
171 self.data.showUncontestedObjectives = not self.data.showUncontestedObjectives
172 if loud then
173 self.cmd:status(self.loc.ARGUMENT_SHOWUNCONTESTED, self.data.showUncontestedObjectives and 1 or 0, FuBarLocals.MAP_ONOFF)
174 end
175 self:UpdateTooltip()
176 return self.data.showUncontestedObjectives
177 end
178  
179 function BattlegroundFu:IsShowingCTFFlagCarriers()
180 return self.data.showCTFFlagCarriers
181 end
182  
183 function BattlegroundFu:ToggleShowingCTFFlagCarriers(loud)
184 self.data.showCTFFlagCarriers = not self.data.showCTFFlagCarriers
185 if loud then
186 self.cmd:status(self.loc.ARGUMENT_SHOWCTFFLAGCARRIERS, self.data.showCTFFlagCarriers and 1 or 0, FuBarLocals.MAP_ONOFF)
187 end
188 self:UpdateTooltip()
189 return self.data.showCTFFlagCarriers
190 end
191  
192 function BattlegroundFu:IsShowingBattlefieldQueues()
193 return self.data.showBattlefieldQueues
194 end
195  
196 function BattlegroundFu:ToggleShowingBattlefieldQueues(loud)
197 self.data.showBattlefieldQueues = not self.data.showBattlefieldQueues
198 if loud then
199 self.cmd:status(self.loc.ARGUMENT_SHOWBATTLEFIELDQUEUES, self.data.showBattlefieldQueues and 1 or 0, FuBarLocals.MAP_ONOFF)
200 end
201 self:UpdateTooltip()
202 return self.data.showBattlefieldQueues
203 end
204  
205 function BattlegroundFu:IsHidingQueueText(q)
206 return self.data.hideQueueText[q]
207 end
208  
209 function BattlegroundFu:ToggleHidingQueueText(q)
210 self.data.hideQueueText[q] = not self.data.hideQueueText[q]
211 self:UpdateText()
212 return self.data.hideQueueText[q]
213 end
214 --End User Options Methods=====================================================
215 --FuBar Standard Methods=======================================================
216 function BattlegroundFu:Initialize()
217 local defaults = {}
218 for index,value in defaults do
219 if self.data[index] == nil then
220 self.data[index] = value
221 end
222 end
223 self.j = 1
224 self.numActiveBattlefields = {}
225 end
226  
227 function BattlegroundFu:Enable()
228 self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS", "OnUpdateBattlefieldStatus")
229 self:RegisterEvent("UPDATE_WORLD_STATES", "UpdateTooltip")
230  
231 self.playerFaction = UnitFactionGroup("player")
232  
233 metro:Register(self.name, self.Update, 1, self)
234 metro:Start(self.name)
235 -- metro:Register("BatFu_numActiveBattlefields", self.UpdateNumActiveBattlefields, 1, self)
236 end
237  
238 function BattlegroundFu:Disable()
239 glory:UnregisterAll(self)
240 metro:Unregister(self.name)
241 -- metro:Unregister("BatFu_numActiveBattlefields")
242 end
243  
244 function BattlegroundFu:Report()
245 local report = compost:Acquire(
246 compost:AcquireHash(
247 'text', self.loc.ARGUMENT_HIDEMINIMAPBUTTON,
248 'val', self:IsHidingMinimapButton() and 1 or 0,
249 'map', FuBarLocals.MAP_ONOFF
250 ),
251 compost:AcquireHash(
252 'text', self.loc.ARGUMENT_INVERTQUEUEPROGRESS,
253 'val', self:IsInvertQueueProgress() and 1 or 0,
254 'map', FuBarLocals.MAP_ONOFF
255 ),
256 compost:AcquireHash(
257 'text', self.loc.ARGUMENT_CLICKSHOWSSCOREBOARD,
258 'val', self:IsClickShowsScoreboard() and 1 or 0,
259 'map', FuBarLocals.MAP_ONOFF
260 ),
261 compost:AcquireHash(
262 'text', self.loc.ARGUMENT_SHOWTEAMSIZES,
263 'val', self:IsShowingTeamSizes() and 1 or 0,
264 'map', FuBarLocals.MAP_ONOFF
265 ),
266 compost:AcquireHash(
267 'text', self.loc.ARGUMENT_SHOWTEAMSCORES,
268 'val', self:IsShowingTeamScores() and 1 or 0,
269 'map', FuBarLocals.MAP_ONOFF
270 ),
271 compost:AcquireHash(
272 'text', self.loc.ARGUMENT_SHOWNUMBASES,
273 'val', self:IsShowingNumBases() and 1 or 0,
274 'map', FuBarLocals.MAP_ONOFF
275 ),
276 compost:AcquireHash(
277 'text', self.loc.ARGUMENT_SHOWRESOURCETTV,
278 'val', self:IsShowingResourceTTV() and 1 or 0,
279 'map', FuBarLocals.MAP_ONOFF
280 ),
281 compost:AcquireHash(
282 'text', self.loc.ARGUMENT_SHOWBATTLEFIELDSTATS,
283 'val', self:IsShowingBattlefieldPlayerStatistics() and 1 or 0,
284 'map', FuBarLocals.MAP_ONOFF
285 ),
286 compost:AcquireHash(
287 'text', self.loc.ARGUMENT_SHOWOBJECTIVESTATUS,
288 'val', self:IsShowingBattlefieldObjectiveStatus() and 1 or 0,
289 'map', FuBarLocals.MAP_ONOFF
290 ),
291 compost:AcquireHash(
292 'text', self.loc.ARGUMENT_SHOWUNCONTESTED,
293 'val', self:IsShowingUncontestedObjectives() and 1 or 0,
294 'map', FuBarLocals.MAP_ONOFF
295 ),
296 compost:AcquireHash(
297 'text', self.loc.ARGUMENT_SHOWCTFFLAGCARRIERS,
298 'val', self:IsShowingCTFFlagCarriers() and 1 or 0,
299 'map', FuBarLocals.MAP_ONOFF
300 ),
301 compost:AcquireHash(
302 'text', self.loc.ARGUMENT_SHOWBATTLEFIELDQUEUES,
303 'val', self:IsShowingBattlefieldQueues() and 1 or 0,
304 'map', FuBarLocals.MAP_ONOFF
305 )
306 )
307 self.cmd:report(report)
308 compost:Reclaim(report, 1)
309 end
310 ------MenuSettings=============================================================
311 function BattlegroundFu:MenuSettings(level, value, inTooltip)
312 if level == 1 then
313 self:MenuSettings_BattlefieldDropDown() --Rewrite of the Battlefield Minimap Button Dropdown; see below
314 dewdrop:AddLine()
315 if not inTooltip then
316 dewdrop:AddLine(
317 'text', self.loc.MENU_HIDE_MINIMAP_BUTTON,
318 'arg1', self,
319 'func', "ToggleHidingMinimapButton",
320 'checked', self:IsHidingMinimapButton()
321 )
322 dewdrop:AddLine(
323 'text', self.loc.MENU_INVERT_QUEUE_PROGRESS_TIMERS,
324 'arg1', self,
325 'func', "ToggleInvertQueueProgress",
326 'checked', self:IsInvertQueueProgress()
327 )
328 dewdrop:AddLine(
329 'text', self.loc.MENU_CLICK_SHOWS_SCOREBOARD,
330 'arg1', self,
331 'func', "ToggleClickShowsScoreboard",
332 'checked', self:IsClickShowsScoreboard()
333 )
334 dewdrop:AddLine()
335 dewdrop:AddLine(
336 'text', self.loc.MENU_TOOLTIP_DISPLAY,
337 'hasArrow', true,
338 'value', "ttdisplay"
339 )
340 else
341 self:MenuSettings_TooltipDisplay()
342 end
343 elseif level == 2 and not inTooltip then
344 if value == "ttdisplay" then
345 self:MenuSettings_TooltipDisplay()
346 end
347 end
348 end
349 ----------MenuSettings Component Methods=======================================
350 function BattlegroundFu:MenuSettings_BattlefieldDropDown()
351 local status, mapName
352 for i = 1, MAX_BATTLEFIELD_QUEUES do
353 local i = i
354 local mapName = mapName
355 status, mapName = GetBattlefieldStatus(i)
356 if status == "queued" or status == "confirm" then
357 dewdrop:AddLine()
358 dewdrop:AddLine(
359 'text', mapName,
360 'textR', 1,
361 'textG', 0.843,
362 'textB', 0,
363 'arg1', self,
364 'arg2', mapName,
365 'func', "ToggleHidingQueueText",
366 'checked', not self:IsHidingQueueText(mapName)
367 )
368 if status == "queued" then
369 dewdrop:AddLine(
370 'text', CHANGE_INSTANCE,
371 'func', function ()
372 ShowBattlefieldList(i)
373 end
374 )
375 elseif status == "confirm" then
376 dewdrop:AddLine(
377 'text', ENTER_BATTLE,
378 'func', function ()
379 AcceptBattlefieldPort(i, 1)
380 end
381 )
382 end
383 dewdrop:AddLine(
384 'text', LEAVE_QUEUE,
385 'func', function ()
386 AcceptBattlefieldPort(i)
387 if not IsShiftKeyDown() then
388 dewdrop:Close(1)
389 end
390 end
391 )
392 end
393 end
394 end
395  
396 function BattlegroundFu:MenuSettings_TooltipDisplay()
397 dewdrop:AddLine(
398 'text', self.loc.MENU_TEAM_SIZES,
399 'arg1', self,
400 'func', "ToggleShowingTeamSizes",
401 'checked', self:IsShowingTeamSizes()
402 )
403  
404 dewdrop:AddLine(
405 'text', self.loc.MENU_TEAM_SCORES,
406 'arg1', self,
407 'func', "ToggleShowingTeamScores",
408 'checked', self:IsShowingTeamScores()
409 )
410 dewdrop:AddLine(
411 'text', self.loc.MENU_NUM_BASES_HELD,
412 'arg1', self,
413 'func', "ToggleShowingNumBases",
414 'checked', self:IsShowingNumBases()
415 )
416 dewdrop:AddLine(
417 'text', self.loc.MENU_RESOURCE_TTV,
418 'arg1', self,
419 'func', "ToggleShowingResourceTTV",
420 'checked', self:IsShowingResourceTTV()
421 )
422 dewdrop:AddLine(
423 'text', self.loc.MENU_BATTLEFIELD_STATS,
424 'arg1', self,
425 'func', "ToggleShowingBattlefieldPlayerStatistics",
426 'checked', self:IsShowingBattlefieldPlayerStatistics()
427 )
428 dewdrop:AddLine(
429 'text', self.loc.MENU_OBJECTIVE_STATUS,
430 'arg1', self,
431 'func', "ToggleShowingBattlefieldObjectiveStatus",
432 'checked', self:IsShowingBattlefieldObjectiveStatus()
433 )
434 dewdrop:AddLine(
435 'text', self.loc.MENU_SHOW_UNCONTESTED,
436 'arg1', self,
437 'func', "ToggleShowingUncontestedObjectives",
438 'checked', self:IsShowingUncontestedObjectives(),
439 'disabled', not self:IsShowingBattlefieldObjectiveStatus()
440 )
441 dewdrop:AddLine(
442 'text', self.loc.MENU_CTF_FLAG_CARRIERS,
443 'arg1', self,
444 'func', "ToggleShowingCTFFlagCarriers",
445 'checked', self:IsShowingCTFFlagCarriers()
446 )
447 dewdrop:AddLine(
448 'text', self.loc.MENU_BATTLEFIELD_QUEUES,
449 'arg1', self,
450 'func', "ToggleShowingBattlefieldQueues",
451 'checked', self:IsShowingBattlefieldQueues()
452 )
453 end
454 ----------End MenuSettings Component Methods===================================
455 ------End MenuSettings=========================================================
456 function BattlegroundFu:OnClick()
457 if glory:IsInBattlegrounds() and self:IsClickShowsScoreboard() then
458 if WorldStateScoreFrame:IsVisible() then
459 HideUIPanel(WorldStateScoreFrame)
460 else
461 ShowUIPanel(WorldStateScoreFrame)
462 end
463 elseif GetBattlefieldStatus(self.j) == "active" then
464 ShowUIPanel(WorldStateScoreFrame)
465 self.j = self.j + 1
466 elseif GetBattlefieldStatus(self.j) == "queued" or GetBattlefieldStatus(self.j) == "confirm" then
467 HideUIPanel(WorldStateScoreFrame)
468 ShowBattlefieldList(self.j)
469 self.j = self.j + 1
470 else
471 HideUIPanel(WorldStateScoreFrame)
472 HideUIPanel(BattlefieldFrame)
473 self.j = 1
474 end
475 end
476 ------UpdateData===============================================================
477 function BattlegroundFu:UpdateData()
478 if glory:IsInBattlegrounds() then
479 RequestBattlefieldScoreData()
480 end
481 end
482 ------End UpdateData===========================================================
483 ------UpdateText===============================================================
484 function BattlegroundFu:UpdateText()
485 self:SetIcon(self.FACTION_ICON_PATH .. self.playerFaction)
486 if glory:IsInBattlegrounds() then
487 self:UpdateText_BattlefieldPlayerStatistics()
488 else
489 self:UpdateText_QueuedBattlefields()
490 end
491 end
492 ----------UpdateText Component Methods=========================================
493 function BattlegroundFu:UpdateText_BattlefieldPlayerStatistics()
494 local red, green, white = crayon.COLOR_HEX_RED, crayon.COLOR_HEX_GREEN, crayon.COLOR_HEX_WHITE
495 if glory:GetStanding() then
496 self:SetText(format("#: |cff%s%s|r KB: |cff%s%s|r K: |cff%s%s|r D: |cff%s%s|r H: |cff%s%s|r", white, glory:GetStanding(), green, glory:GetKillingBlows(), green, glory:GetHonorableKills(), red, glory:GetDeaths(), white, glory:GetBonusHonor()))
497 end
498 end
499  
500 function BattlegroundFu:UpdateText_QueuedBattlefields()
501 local status, mapName, progress, usingDefaultText, bgTimeQueued, bgEstimatedTime, timeColor
502 local queueText = self.loc.TEXT_NO_QUEUES
503 local numQueues = 0
504 for i = 1, MAX_BATTLEFIELD_QUEUES do
505 status, mapName = GetBattlefieldStatus(i)
506 if status == "queued" then
507 numQueues = numQueues + 1
508 if not self:IsHidingQueueText(mapName) then
509 bgTimeQueued = GetBattlefieldTimeWaited(i)/1000
510 bgEstimatedTime = GetBattlefieldEstimatedWaitTime(i)/1000
511 timeColor = crayon:GetThresholdHexColor(1-bgTimeQueued/bgEstimatedTime, -0.25, -0.1, 0.1, 0.5, 0.9)
512 if self:IsInvertQueueProgress() then
513 progress = format("|cff%s%s|r/%s", timeColor, abacus:FormatDurationFull(bgEstimatedTime - bgTimeQueued, nil, 1), abacus:FormatDurationFull(bgEstimatedTime, nil, 1))
514 else
515 progress = format("|cff%s%s|r/%s", timeColor, abacus:FormatDurationFull(bgTimeQueued, nil, 1), abacus:FormatDurationFull(bgEstimatedTime, nil, 1))
516 end
517 if usingDefaultText or queueText == self.loc.TEXT_NO_QUEUES then
518 queueText = glory:GetBGAcronym(mapName) .. ": " .. progress
519 else
520 queueText = queueText .. " || " .. glory:GetBGAcronym(mapName) .. ": " .. progress
521 end
522 usingDefaultText = nil
523 end
524 if usingDefaultText or queueText == self.loc.TEXT_NO_QUEUES then
525 queueText = format("%d %s", numQueues, self.loc.TEXT_QUEUES)
526 usingDefaultText = true
527 end
528 end
529 end
530 self:SetText(queueText)
531 end
532 ----------End UpdateText Component Methods=====================================
533 ------End UpdateText===========================================================
534  
535 ------UpdateTooltip============================================================
536 function BattlegroundFu:UpdateTooltip()
537 if glory:IsInBattlegrounds() and self:IsClickShowsScoreboard() then
538 tablet:SetHint(self.loc.TEXT_HINT_CLICKSHOWSSCOREBOARD)
539 else
540 tablet:SetHint(self.loc.TEXT_HINT_NORMAL)
541 end
542  
543 local status, mapName, instanceID
544  
545 if glory:IsInBattlegrounds() then
546 tablet:AddCategory():AddLine('text', glory:GetActiveBattlefieldUniqueID(), 'textR', 1, 'textG', 1, 'textB', 1)
547 if self:IsShowingTeamSizes() then
548 self:UpdateTooltip_BattlefieldMatchInfo(self.loc.TEXT_PLAYERS, glory:GetNumAlliancePlayers(), glory:GetNumHordePlayers())
549 end
550 if self:IsShowingTeamScores() and GetWorldStateUIInfo(1) then
551 self:UpdateTooltip_BattlefieldMatchInfo(self.loc.TEXT_SCORE, glory:GetAllianceScoreString(), glory:GetHordeScoreString())
552 end
553 if self:IsShowingNumBases() and GetWorldStateUIInfo(1) and string.find(GetWorldStateUIInfo(1), self.loc.TEXT_BASES) then
554 self:UpdateTooltip_BattlefieldMatchInfo(self.loc.TEXT_BASES, glory:GetNumAllianceBases(), glory:GetNumHordeBases())
555 end
556 if self:IsShowingResourceTTV() and GetWorldStateUIInfo(1) and string.find(GetWorldStateUIInfo(1), self.loc.TEXT_RESOURCES) then
557 self:UpdateTooltip_BattlefieldMatchInfo(self.loc.TEXT_TTV, abacus:FormatDurationCondensed(glory:GetAllianceTTV()), abacus:FormatDurationCondensed(glory:GetHordeTTV()))
558 end
559 if self:IsShowingBattlefieldPlayerStatistics() then
560 self:UpdateTooltip_BattlefieldPlayerStatistics()
561 end
562 if GetNumMapLandmarks() > 0 and self:IsShowingBattlefieldObjectiveStatus() then
563 self:UpdateTooltip_BattlefieldObjectiveTimers()
564 end
565 if self:IsShowingCTFFlagCarriers() and glory:GetActiveBattlefieldZone() == babbleZone:GetLocalized("WARSONG_GULCH") then
566 self:UpdateTooltip_CTFFlagCarriers()
567 end
568 end
569  
570 if self:IsShowingBattlefieldQueues() then
571 for i=1, MAX_BATTLEFIELD_QUEUES do
572 status = GetBattlefieldStatus(i)
573 if status == "queued" or status == "confirm" then
574 self:UpdateTooltip_BGQueues()
575 break
576 end
577 end
578 end
579 end
580 ----------UpdateTooltip ComponeMethods=========================================
581 function BattlegroundFu:UpdateTooltip_BattlefieldMatchInfo(label, textA, textH)
582 local aR, aG, aB = glory:GetFactionColor(FACTION_ALLIANCE)
583 local hR, hG, hB = glory:GetFactionColor(FACTION_HORDE)
584 local cat = tablet:AddCategory(
585 'hideBlankLine', true,
586 -- 'text', glory:GetActiveBattlefieldUniqueID(),
587 'columns', 3,
588 'child_textR', aR,
589 'child_textG', aG,
590 'child_textB', aB,
591 'child_text2R', 1,
592 'child_text2G', 1,
593 'child_text2B', 1,
594 'child_text3R', hR,
595 'child_text3G', hG,
596 'child_text3B', hB
597 )
598  
599 cat:AddLine(
600 'text', textA,
601 'text2', label,
602 'text3', textH
603 )
604 end
605  
606 function BattlegroundFu:UpdateTooltip_BattlefieldPlayerStatistics()
607 local cat = tablet:AddCategory(
608 'columns', 2,
609 'text', self.loc.TEXT_PLAYER_STATS,
610 'child_textR', 1,
611 'child_textG', 0.843,
612 'child_textB', 0
613 )
614  
615 cat:AddLine(
616 'text', self.loc.TEXT_STANDING,
617 'text2', glory:GetStanding(),
618 'text2R', 1,
619 'text2G', 1,
620 'text2B', 1
621 )
622 cat:AddLine(
623 'text', self.loc.TEXT_KILLING_BLOWS,
624 'text2', glory:GetKillingBlows(),
625 'text2R', 0,
626 'text2G', 1,
627 'text2B', 0
628 )
629 cat:AddLine(
630 'text', self.loc.TEXT_KILLS,
631 'text2', glory:GetHonorableKills(),
632 'text2R', 0,
633 'text2G', 1,
634 'text2B', 0
635 )
636 cat:AddLine(
637 'text', self.loc.TEXT_DEATHS,
638 'text2', glory:GetDeaths(),
639 'text2R', 1,
640 'text2G', 0,
641 'text2B', 0
642 )
643 cat:AddLine(
644 'text', self.loc.TEXT_BONUS_HONOR,
645 'text2', glory:GetBonusHonor(),
646 'text2R', 1,
647 'text2G', 1,
648 'text2B', 1
649 )
650 end
651  
652 function BattlegroundFu:UpdateTooltip_BattlefieldObjectiveTimers()
653 local node, status, lR, lG, lB, rR, rG, rB
654 if glory.battlefieldObjectiveStatus and next(glory.battlefieldObjectiveStatus) then
655 local cat = tablet:AddCategory(
656 'columns', 2,
657 'text', self.loc.TEXT_BASE,
658 'text2', self.loc.TEXT_STATUS
659 )
660 for _, poi in glory:IterateSortedObjectiveNodes() do
661 lR, lG, lB = glory:GetFactionColor(glory:GetDefender(poi))
662 rR, rG, rB = glory:GetFactionColor(glory:GetDefender(poi))
663 node = glory:GetName(poi)
664 if glory:IsInConflict(poi) then
665 rR, rG, rB = glory:GetFactionColor(glory:GetAttacker(poi))
666 if glory:GetTimeAttacked(poi) then
667 status = abacus:FormatDurationCondensed(glory:GetTimeToCapture(poi))
668 else --when joining a battlefield where the node is already under attack
669 status = self.loc.TEXT_BGOBJECTIVE_INCONFLICT
670 end
671 elseif glory:IsDestroyed(poi) then
672 status = self.loc.TEXT_BGOBJECTIVE_DESTROYED
673 else
674 status = glory:GetDefender(poi)
675 end
676 if self:IsShowingUncontestedObjectives() or glory:IsInConflict(poi) then
677 cat:AddLine(
678 'text', node,
679 'text2', status,
680 'textR', lR,
681 'textG', lG,
682 'textB', lB,
683 'text2R', rR,
684 'text2G', rG,
685 'text2B', rB
686 )
687 end
688 end
689 end
690 end
691  
692 function BattlegroundFu:UpdateTooltip_CTFFlagCarriers()
693 local aR, aG, aB = glory:GetFactionColor(FACTION_ALLIANCE)
694 local hR, hG, hB = glory:GetFactionColor(FACTION_HORDE)
695 local rR, rG, rB, carrier
696 local cat = tablet:AddCategory(
697 'columns', 2,
698 'text', self.loc.TEXT_FLAG,
699 'text2', self.loc.TEXT_CARRIER
700 )
701 carrier = glory:GetHordeFlagCarrier()
702 if carrier then
703 rR, rG, rB = glory:GetFactionColor(FACTION_HORDE)
704 else
705 rR, rG, rB = glory:GetFactionColor(FACTION_ALLIANCE)
706 end
707 cat:AddLine(
708 'text', FACTION_ALLIANCE,
709 'text2', carrier or self.loc.TEXT_NA,
710 'textR', aR,
711 'textG', aG,
712 'textB', aB,
713 'text2R', rR,
714 'text2G', rG,
715 'text2B', rB,
716 'func', function()
717 glory:TargetHordeFlagCarrier()
718 end
719 )
720  
721 carrier = glory:GetAllianceFlagCarrier()
722 if carrier then
723 rR, rG, rB = glory:GetFactionColor(FACTION_ALLIANCE)
724 else
725 rR, rG, rB = glory:GetFactionColor(FACTION_HORDE)
726 end
727 cat:AddLine(
728 'text', FACTION_HORDE,
729 'text2', carrier or self.loc.TEXT_NA,
730 'textR', hR,
731 'textG', hG,
732 'textB', hB,
733 'text2R', rR,
734 'text2G', rG,
735 'text2B', rB,
736 'func', function()
737 glory:TargetAllianceFlagCarrier()
738 end
739 )
740 end
741  
742 function BattlegroundFu:UpdateTooltip_BGQueues()
743 local status, mapName, progress, bgTimeQueued, bgEstimatedTime, timeR, timeG, timeB, bgPortExpiration
744 local cat = tablet:AddCategory(
745 'columns', 2,
746 'text', self.loc.TEXT_BGQUEUES,
747 'text2', self:IsInvertQueueProgress() and self.loc.TEXT_INVERT_QUEUE_PROGRESS or self.loc.TEXT_QUEUE_PROGRESS,
748 'child_textG', 0.843,
749 'child_teøt1B', 0
750 )
751 for i = 1, MAX_BATTLEFIELD_QUEUES do
752 local i = i
753 status, mapName = GetBattlefieldStatus(i)
754 if self.numActiveBattlefields[i] then
755 mapName = format("(%d) %s", self.numActiveBattlefields[i], mapName)
756 end
757 if status == "queued" then
758 bgTimeQueued = GetBattlefieldTimeWaited(i)/1000
759 bgEstimatedTime = GetBattlefieldEstimatedWaitTime(i)/1000
760 timeR, timeG, timeB = crayon:GetThresholdColor(1-bgTimeQueued/bgEstimatedTime, -0.25, -0.1, 0.1, 0.5, 0.9)
761 if self:IsInvertQueueProgress() then
762 progress = abacus:FormatDurationCondensed(bgEstimatedTime - bgTimeQueued) .. "|r|cffffd700/" .. abacus:FormatDurationCondensed(bgEstimatedTime)
763 else
764 progress = abacus:FormatDurationCondensed(bgTimeQueued) .. "|r|cffffd700/" .. abacus:FormatDurationCondensed(bgEstimatedTime)
765 end
766 cat:AddLine(
767 'text', mapName,
768 'text2', progress,
769 'text2R', timeR,
770 'text2G', timeG,
771 'text2B', timeB,
772 'func', function ()
773 if not BattlefieldFrame:IsVisible() or self.ttOpenBattlefieldFrame ~= i then
774 ShowBattlefieldList(i)
775 self.ttOpenBattlefieldFrame = i
776 else
777 HideUIPanel(BattlefieldFrame)
778 end
779 end
780 )
781 end
782 if status == "confirm" then
783 bgPortExpiration = GetBattlefieldPortExpiration(i)/1000
784 timeR, timeG, timeB = crayon:GetThresholdColor(bgPortExpiration/120)
785 progress = self.loc.TEXT_CONFIRM .. ": " .. abacus:FormatDurationCondensed(bgPortExpiration)
786 cat:AddLine(
787 'text', mapName,
788 'text2', progress,
789 'text2R', timeR,
790 'text2G', timeG,
791 'text2B', timeB,
792 'func', function ()
793 if not BattlefieldFrame:IsVisible() or self.ttOpenBattlefieldFrame ~= i then
794 ShowBattlefieldList(i)
795 self.ttOpenBattlefieldFrame = i
796 else
797 HideUIPanel(BattlefieldFrame)
798 end
799 end
800 )
801 end
802 end
803 end
804 ----------End UpdateTooltip Component Methods==================================
805 ------End UpdateTooltip========================================================
806 --End FuBar Standard Methods===================================================
807  
808 --Game Events==================================================================
809 function BattlegroundFu:OnUpdateBattlefieldStatus()
810 if self:IsHidingMinimapButton() and MiniMapBattlefieldFrame:IsVisible() then
811 MiniMapBattlefieldFrame:Hide()
812 end
813 self:UpdateDisplay()
814 if BattlefieldFrame:GetAlpha() ~= 1 and BattlefieldFrame:GetAlpha() ~= 0 then
815 bfAlpha = BattlefieldFrame:GetAlpha()
816 end
817 -- metro:Start("BatFu_numActiveBattlefields")
818 end
819  
820 --[[ function BattlegroundFu:UpdateNumActiveBattlefields()
821 if BattlefieldFrame:IsVisible() and BattlefieldFrame:GetAlpha() > 0 then return end
822 bfNum = bfNum or 1
823 if bfNum <= MAX_BATTLEFIELD_QUEUES + 1 then
824 if bfNum ~= 1 then
825 self.numActiveBattlefields[bfNum - 1] = GetNumBattlefields()
826 end
827 BattlefieldFrame:SetAlpha(0)
828 ShowBattlefieldList(bfNum)
829 bfNum = bfNum + 1
830 else
831 HideUIPanel(BattlefieldFrame)
832 BattlefieldFrame:SetAlpha(bfAlpha or 1)
833 metro:Stop("BatFu_numActiveBattlefields")
834 bfNum = 1
835 end
836 end]]--
837 --End Game Events==============================================================
838  
839 BattlegroundFu:RegisterForLoad()