Skip to content

Commit

Permalink
Fix a bug that would occur when not tracking any faction
Browse files Browse the repository at this point in the history
  • Loading branch information
azuraji committed Nov 28, 2022
1 parent 72c2358 commit b358dff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 20 additions & 18 deletions FuBar_FuXPFu/FuBar_FuXPFu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,12 @@ end
function FuXP:OnTextUpdate()
FuXP:OnDataUpdate()
-- Setup watched factions
if self.db.profile.ShowText == "Rep" and self.db.profile.Faction ~= 0 then
if self.db.profile.ShowText == "Rep" and self.db.profile.Faction ~= 0 then
local name, standing, minRep, maxRep, currentRep, factionID = GetWatchedFactionInfo()
if standing <= 0 then return end -- 'Unknown' usually means that the player just started their character and aren't tracking any faction

local max, xp = UnitXPMax("player"), UnitXP("player")
local toGo = max - xp
local name, standing, minRep, maxRep, currentRep, factionID = GetWatchedFactionInfo()

-- Paragon Reputation introduced in Legion:
-- https://wow.gamepedia.com/Reputation#Paragon
Expand Down Expand Up @@ -742,22 +744,22 @@ function FuXP:OnTextUpdate()
self:SetText(string.format(L["%s: %3.0f%% (%s/%s) (%s) // XP: %s%%/%s to go"], name, ((currentRep-minRep)/(maxRep-minRep))*100 , currentRep-minRep, maxRep-minRep, factionStandingLabel.."|r", math.floor(xp/max * 100), toGo))
end
end
elseif self.db.profile.ShowText == "XP" then
local max, xp = UnitXPMax("player"), UnitXP("player")
local toGo = max - xp
local percentToGo = math.floor(toGo / max * 100)
if crayon then
toGo = "|cff"..crayon:GetThresholdHexColor(toGo, 0) .. toGo .. "|r"
percentToGo = "|cff"..crayon:GetThresholdHexColor(percentToGo) .. percentToGo .. "|r"
end
if self.db.profile.ToGo then
self:SetText(string.format("%s (%s%%)", toGo, percentToGo))
else
self:SetText(string.format("%s/%s (%s%%)", xp, max, math.floor(xp/max * 100)))
end
else
self:SetText("FuXPFu")
end
elseif self.db.profile.ShowText == "XP" then
local max, xp = UnitXPMax("player"), UnitXP("player")
local toGo = max - xp
local percentToGo = math.floor(toGo / max * 100)
if crayon then
toGo = "|cff"..crayon:GetThresholdHexColor(toGo, 0) .. toGo .. "|r"
percentToGo = "|cff"..crayon:GetThresholdHexColor(percentToGo) .. percentToGo .. "|r"
end
if self.db.profile.ToGo then
self:SetText(string.format("%s (%s%%)", toGo, percentToGo))
else
self:SetText(string.format("%s/%s (%s%%)", xp, max, math.floor(xp/max * 100)))
end
else
self:SetText("FuXPFu")
end
end

function FuXP:OnTooltipUpdate()
Expand Down
4 changes: 1 addition & 3 deletions FuBar_FuXPFu/FuBar_FuXPFu.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
## Notes: Lightweight XP Bar
## Notes-zhCN: 迷你经验条
## Notes-zhTW: 輕量級的經驗值條模組。
## Version: 3
## Version: 10.0.2.3
## Author: Wobin
## eMail: [email protected]
## X-Credits: Bant (For the design)
## X-Category: Interface Enhancements
## X-RelSite-WoWI: 5097
## X-AceForum: 1569
## X-WoWIPortal: wobin
## Dependencies: FuBar
## OptionalDeps: Ace2, DewdropLib, TabletLib, FuBarPlugin-2.0, JostleLib, CrayonLib, FuBar, FuBar_Factions, tekAutoRep
Expand Down

0 comments on commit b358dff

Please sign in to comment.