From b358dff0aab4f2a3e4b61ebf80768b6b8d12d72d Mon Sep 17 00:00:00 2001 From: azuraji <72912613+azuraji@users.noreply.github.com> Date: Sun, 27 Nov 2022 08:45:52 +0100 Subject: [PATCH] Fix a bug that would occur when not tracking any faction --- FuBar_FuXPFu/FuBar_FuXPFu.lua | 38 ++++++++++++++++++----------------- FuBar_FuXPFu/FuBar_FuXPFu.toc | 4 +--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/FuBar_FuXPFu/FuBar_FuXPFu.lua b/FuBar_FuXPFu/FuBar_FuXPFu.lua index c77734f..60bad54 100644 --- a/FuBar_FuXPFu/FuBar_FuXPFu.lua +++ b/FuBar_FuXPFu/FuBar_FuXPFu.lua @@ -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 @@ -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() diff --git a/FuBar_FuXPFu/FuBar_FuXPFu.toc b/FuBar_FuXPFu/FuBar_FuXPFu.toc index 3946ad5..13c521a 100644 --- a/FuBar_FuXPFu/FuBar_FuXPFu.toc +++ b/FuBar_FuXPFu/FuBar_FuXPFu.toc @@ -4,13 +4,11 @@ ## Notes: Lightweight XP Bar ## Notes-zhCN: 迷你经验条 ## Notes-zhTW: 輕量級的經驗值條模組。 -## Version: 3 +## Version: 10.0.2.3 ## Author: Wobin ## eMail: wobster@gmail.com ## 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