@@ -131,101 +131,102 @@ end
131131--- TODO: right now we are using DB.statusbtn to assign settins ot the status buttons, but I think our indexes are bar specific
132132function STATUSBTN :xpstrings_Update () -- handles updating all the strings for the play XP watch bar
133133
134- local currXP , nextXP , restedXP , percentXP , bubbles , rank
134+ local currXP , nextXP , restedXP , percentXP , bubbles , rank , isRested
135135
136136 -- player xp option
137137 if self .elements .SB .curXPType == " player_xp" then
138138
139139 currXP , nextXP , restedXP = UnitXP (" player" ), UnitXPMax (" player" ), GetXPExhaustion ()
140-
141140 local playerLevel = UnitLevel (" player" )
142141
143142 if playerLevel == MAX_PLAYER_LEVEL then
144143 currXP = nextXP
145144 end
146145
147146 percentXP = (currXP / nextXP )* 100 ;
148-
149147 bubbles = tostring (math.floor (currXP / (nextXP / 20 ))).. " / 20 " .. L [" Bubbles" ]
150148 percentXP = string.format (" %.2f" , (percentXP )).. " %"
151149
152-
153- if restedXP then
150+ if restedXP > 0 then
154151 restedXP = string.format (" %.2f" , (tostring (restedXP / nextXP ))).. " " .. L [" Levels" ]
152+ isRested = true
155153 else
156154 restedXP = " 0" .. " " .. L [" Levels" ]
155+ isRested = false
157156 end
158157
159158 rank = L [" Level" ].. " " .. tostring (playerLevel )
160159
160+ -- covenant renown
161+ elseif self .elements .SB .curXPType == " covenant_renown" then
162+ if C_Covenants .GetActiveCovenantID () ~= 0 then
163+ local covenantLevel = C_CovenantSanctumUI .GetRenownLevel (C_Covenants .GetActiveCovenantID ())
164+ local covenantName = C_Covenants .GetCovenantData (C_Covenants .GetActiveCovenantID ()).name
165+ rank = covenantName .. " : " .. L [" Level" ].. " " .. covenantLevel
166+ end
167+
161168 -- heart of azeroth option
162169 elseif self .elements .SB .curXPType == " azerite_xp" then
163-
164170 local azeriteItemLocation = C_AzeriteItem .FindActiveAzeriteItem ()
165-
166171 if azeriteItemLocation then
167-
168172 currXP , nextXP = C_AzeriteItem .GetAzeriteItemXPInfo (azeriteItemLocation )
169-
170173 restedXP = " 0" .. " " .. L [" Levels" ]
171-
172- percentXP = (currXP / nextXP )* 100
174+ percentXP = string.format (" %.2f" , (currXP / nextXP )* 100 ).. " %" -- format
173175 bubbles = tostring (math.floor (percentXP / 5 )).. " / 20 " .. L [" Bubbles" ]
174- rank = L [" Level" ] .. " " .. tostring (C_AzeriteItem .GetPowerLevel (azeriteItemLocation ))
175- else
176- currXP = 0 ;
177- nextXP = 0 ;
178- percentXP = 0 ;
179- restedXP = " 0" .. " " .. L [" Levels" ]
180- bubbles = tostring (0 ).. " / 20 " .. L [" Bubbles" ]
181- rank = tostring (0 ).. " " .. L [" Points" ]
176+ rank = L [" Level" ].. " " .. tostring (C_AzeriteItem .GetPowerLevel (azeriteItemLocation ))
182177 end
183178
184- percentXP = string.format (" %.2f" , percentXP ).. " %" ; -- format
185-
186-
187179 -- honor points option
188180 elseif self .elements .SB .curXPType == " honor_points" then
189181 currXP = UnitHonor (" player" ); -- current value for level
190182 nextXP = UnitHonorMax (" player" ); -- max value for level
191- restedXP = tostring (0 ).. " " .. L [" Levels" ]
192183
193184 local level = UnitHonorLevel (" player" );
194-
195185 percentXP = (currXP / nextXP )* 100
196-
197-
198186 bubbles = tostring (math.floor (percentXP / 5 )).. " / 20 " .. L [" Bubbles" ];
199187 percentXP = string.format (" %.2f" , percentXP ).. " %" ; -- format
188+ rank = L [" Level" ].. " " .. tostring (level )
200189
190+ end
201191
202- rank = L [" Level" ] .. " " .. tostring (level )
192+ if not self .elements .SB .XPWatch then -- make sure we make the table for us to store our data so we aren't trying to index a non existent table
193+ self .elements .SB .XPWatch = {}
194+ end
203195
196+ if currXP and nextXP then
197+ self .elements .SB .XPWatch .current = BreakUpLargeNumbers (currXP ).. " / " .. BreakUpLargeNumbers (nextXP )
198+ else
199+ self .elements .SB .XPWatch .current = " "
204200 end
205201
206- if not self .elements .SB .XPWatch then -- make sure we make the table for us to store our data so we aren't trying to index a non existant table
207- self .elements .SB .XPWatch = {}
202+ if restedXP then
203+ self .elements .SB .XPWatch .rested = restedXP
204+ else
205+ self .elements .SB .XPWatch .rested = " "
208206 end
209207
210- self . elements . SB . XPWatch . current = BreakUpLargeNumbers ( currXP ) .. " / " .. BreakUpLargeNumbers ( nextXP )
211- self .elements .SB .XPWatch .rested = restedXP
212- self . elements . SB . XPWatch . percent = percentXP
213- self .elements .SB .XPWatch .bubbles = bubbles
214- self . elements . SB . XPWatch . rank = rank
208+ if percentXP then
209+ self .elements .SB .XPWatch .percent = percentXP
210+ else
211+ self .elements .SB .XPWatch .percent = " "
212+ end
215213
214+ if bubbles then
215+ self .elements .SB .XPWatch .bubbles = bubbles
216+ else
217+ self .elements .SB .XPWatch .bubbles = " "
218+ end
216219
217- local isRested
218- if restedXP ~= " 0" then
219- isRested = true
220+ if rank then
221+ self .elements .SB .XPWatch .rank = rank
220222 else
221- isRested = false
223+ self . elements . SB . XPWatch . rank = " "
222224 end
223225
224226 return currXP , nextXP , isRested
225227end
226228
227229
228-
229230function STATUSBTN :XPBar_OnEvent (event , ...)
230231
231232 if not self .DB .curXPType then
@@ -241,40 +242,41 @@ function STATUSBTN:XPBar_OnEvent(event, ...)
241242 if self .elements .SB .curXPType == " player_xp" and (event == " PLAYER_XP_UPDATE" or event == " PLAYER_ENTERING_WORLD" or event == " UPDATE_EXHAUSTION" or event == " changed_curXPType" ) then
242243
243244 currXP , nextXP , isRested = self :xpstrings_Update ()
244-
245- if isRested then
245+ if isRested or UnitLevel (" player" ) == MAX_PLAYER_LEVEL then -- don't show rested XP as exhausted if we are max level
246246 self .elements .SB :SetStatusBarColor (self .elements .SB .restColor [1 ], self .elements .SB .restColor [2 ], self .elements .SB .restColor [3 ], self .elements .SB .restColor [4 ])
247247 else
248248 self .elements .SB :SetStatusBarColor (self .elements .SB .norestColor [1 ], self .elements .SB .norestColor [2 ], self .elements .SB .norestColor [3 ], self .elements .SB .norestColor [4 ])
249249 end
250-
251250 hasChanged = true ;
252251 end
253252
253+ if self .elements .SB .curXPType == " covenant_renown" and (event == " COVENANT_SANCTUM_RENOWN_LEVEL_CHANGED" or event == " PLAYER_ENTERING_WORLD" or event == " changed_curXPType" ) then
254+ currXP , nextXP = self :xpstrings_Update ()
255+ local covenantData = C_Covenants .GetCovenantData (C_Covenants .GetActiveCovenantID ())
256+ local covenantColor = COVENANT_COLORS [covenantData .textureKit ]
257+ self .elements .SB :SetStatusBarColor (covenantColor :GetRGB ())
258+ hasChanged = true
259+ end
254260
255261 if self .elements .SB .curXPType == " azerite_xp" and (event == " AZERITE_ITEM_EXPERIENCE_CHANGED" or event == " PLAYER_ENTERING_WORLD" or event == " PLAYER_EQUIPMENT_CHANGED" or event == " changed_curXPType" ) then
256-
257262 currXP , nextXP = self :xpstrings_Update ()
258-
259- self .elements .SB :SetStatusBarColor (1 , 1 , 0 ); -- set to yellow?
260-
261- hasChanged = true ;
262-
263+ self .elements .SB :SetStatusBarColor (1 , 1 , 0 ) -- set to yellow
264+ hasChanged = true
263265 end
264266
265267 if self .elements .SB .curXPType == " honor_points" and (event == " HONOR_XP_UPDATE" or event == " PLAYER_ENTERING_WORLD" or event == " changed_curXPType" ) then
266-
267268 currXP , nextXP = self :xpstrings_Update ()
268-
269- self .elements .SB :SetStatusBarColor (1 , .4 , .4 );
270-
271- hasChanged = true ;
269+ self .elements .SB :SetStatusBarColor (1 , .4 , .4 ) -- set to red
270+ hasChanged = true
272271 end
273272
274273 if hasChanged == true then
275274 self .elements .SB :SetMinMaxValues (0 , 100 ) -- these are for the bar itself, the progress it has from left to right
276- self .elements .SB :SetValue ((currXP / nextXP )* 100 )
277-
275+ if currXP and nextXP then
276+ self .elements .SB :SetValue ((currXP / nextXP )* 100 )
277+ else
278+ self .elements .SB :SetValue (100 )
279+ end
278280 self .elements .SB .cText :SetText (self .elements .SB .cFunc (self .elements .SB ))
279281 self .elements .SB .lText :SetText (self .elements .SB .lFunc (self .elements .SB ))
280282 self .elements .SB .rText :SetText (self .elements .SB .rFunc (self .elements .SB ))
@@ -284,14 +286,12 @@ function STATUSBTN:XPBar_OnEvent(event, ...)
284286end
285287
286288
287-
288289function STATUSBTN :switchCurXPType (newXPType )
289290
290291 self .DB .curXPType = newXPType
291292 self :XPBar_OnEvent (" changed_curXPType" )
292293end
293294
294-
295295function STATUSBTN :xpDropDown_Initialize () -- initialize the dropdown menu for chosing to watch either XP, azerite XP, or Honor Points
296296
297297 -- this is the frame that will hold our dropdown menu
@@ -320,6 +320,16 @@ function STATUSBTN:xpDropDown_Initialize() -- initialize the dropdown menu for c
320320 -- wow classic doesn't have Honor points nor Azerite, carefull
321321 if not Neuron .isWoWClassic then
322322
323+ if C_Covenants .GetActiveCovenantID () ~= 0 then
324+ table.insert (menu , {
325+ arg1 = self ,
326+ arg2 = " covenant_renown" ,
327+ text = L [" Track Covenant Renown" ],
328+ func = function (dropdown , self , newXPType ) self :switchCurXPType (newXPType ) end ,
329+ checked = self .elements .SB .curXPType == " covenant_renown" ,
330+ })
331+ end
332+
323333 -- add Heart of Azeroth option
324334 local azeriteItem = C_AzeriteItem .FindActiveAzeriteItem ()
325335 if azeriteItem and azeriteItem :IsEquipmentSlot () and C_AzeriteItem .IsAzeriteItemEnabled (azeriteItem ) then -- only show this button if they player has the Heart of Azeroth
@@ -1908,6 +1918,7 @@ function STATUSBTN:SetType()
19081918
19091919 if not Neuron .isWoWClassic then
19101920 self :RegisterEvent (" HONOR_XP_UPDATE" , " XPBar_OnEvent" )
1921+ self :RegisterEvent (" COVENANT_SANCTUM_RENOWN_LEVEL_CHANGED" , " XPBar_OnEvent" )
19111922 self :RegisterEvent (" AZERITE_ITEM_EXPERIENCE_CHANGED" , " XPBar_OnEvent" )
19121923 end
19131924
0 commit comments