From 632b11d6288cacd8da4385eb866564237f335517 Mon Sep 17 00:00:00 2001 From: azuraji <72912613+azuraji@users.noreply.github.com> Date: Mon, 28 Nov 2022 19:35:29 +0100 Subject: [PATCH] Fix a bug where the XP bar wouldn't properly hide on max level --- FuBar_FuXPFu/FuBar_FuXPFu.lua | 66 +++++++++++++++++------------------ FuBar_FuXPFu/FuBar_FuXPFu.toc | 2 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/FuBar_FuXPFu/FuBar_FuXPFu.lua b/FuBar_FuXPFu/FuBar_FuXPFu.lua index 60bad54..c8996f1 100644 --- a/FuBar_FuXPFu/FuBar_FuXPFu.lua +++ b/FuBar_FuXPFu/FuBar_FuXPFu.lua @@ -254,7 +254,7 @@ function FuXP:SetupMenu() get = function() return FuXP.db.profile.ShowText end, set = function(show) FuXP.db.profile.ShowText = show; - FuXP:OnTextUpdate(); + FuXP:OnTextUpdate(); end, validate = { ["XP"] = L["XP"], ["Rep"] = L["Rep"], ["None"] = L["None"] }, order = 122 @@ -276,7 +276,7 @@ end FuXP.hasIcon = true FuXP.cannotDetachTooltip = true - FuXP.defaultPosition = "LEFT" + FuXP.defaultPosition = "CENTER" FuXP.hideWithoutStandby = true FuXP.cannotAttachToMinimap = true FuXP.independentProfile = true @@ -412,23 +412,15 @@ end function FuXP:OnEnable() self:RegisterBucketEvent("UPDATE_EXHAUSTION", 60, "Update") self:RegisterEvent("PLAYER_UPDATE_RESTING", "CheckIcon") - self:RegisterEvent("PLAYER_LEVEL_UP", "OnLevelUp") + -- self:RegisterEvent("PLAYER_LEVEL_UP", "OnLevelUp") self:RegisterEvent("PLAYER_XP_UPDATE", "OnTextUpdate") - --self:RegisterBucketEvent("UPDATE_FACTION", 5, "Update") - --self:RegisterEvent("UPDATE_FACTION", "OnTextUpdate") - - -- self:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE", "OnTextUpdate") self:RegisterEvent("UPDATE_FACTION", "OnTextUpdate") - -- self:RegisterEvent("FuBar_ChangedPanels") - -- self:RegisterEvent("tekAutoRep_NewFaction", "UpdateInABit") self:SecureHook("SetWatchedFactionIndex", "UpdateInABit"); self:ScheduleRepeatingEvent("XPFuBar", self.Reanchor, 1, self) self:ScheduleRepeatingEvent("XPFuRep", self.GetRep, 3, self) + self:SetupMenu() - -- MainMenuExpBar:Hide() - -- ReputationWatchBar:Hide() - -- ExhaustionTick:Hide() end function FuXP:GetRep() if not self.FactionTable or #self.FactionTable == 0 then @@ -556,7 +548,12 @@ function FuXP:Reanchor() if self.db.profile.ShowRep then if self.db.profile.ShowXP then self.RepBar:SetParent(self.FuPanel.frame) - self.RepBar:SetPoint(point, self.FuPanel.frame, relpoint, 0, y * self.XPBar:GetHeight()) + + if UnitLevel("player") ~= MAX_PLAYER_LEVEL then + self.RepBar:SetPoint(point, self.FuPanel.frame, relpoint, 0, y * self.XPBar:GetHeight()) + else + self.RepBar:SetPoint(point, self.FuPanel.frame, relpoint, 0, y * self.XPBar:GetHeight() - 2) + end else self.RepBar:SetParent(self.FuPanel.frame) self.RepBar:SetPoint(point, self.FuPanel.frame, relpoint, 0, 0) @@ -651,14 +648,12 @@ function FuXP:OnDataUpdate() self.NoRep:SetWidth(((maxRep - currentRep)/(maxRep - minRep))*total) end - self.XPBar:SetWidth(0) - self.RestedXP:SetWidth(0) - self.NoXP:SetWidth(0) - self.Border:SetWidth(0) + self.XPBar:Hide() + self.RestedXP:Hide() + self.NoXP:Hide() + self.Border:Hide() + if self.db.profile.ShowXP == true and UnitLevel("player") ~= MAX_PLAYER_LEVEL then - --if UnitLevel("player") == MAX_PLAYER_LEVEL then - --self.NoXP:SetWidth(total) - --end local currentXP = UnitXP("player") local maxXP = UnitXPMax("player") local restXP = GetXPExhaustion() or 0 @@ -668,26 +663,31 @@ function FuXP:OnDataUpdate() remainXP = 0 end - self.XPBar:SetWidth((currentXP/maxXP)*total) - if (restXP + currentXP)/maxXP > 1 then + self.XPBar:SetWidth((currentXP / maxXP) * total) + if (restXP + currentXP) / maxXP > 1 then self.RestedXP:SetWidth(total - self.XPBar:GetWidth()) else - self.RestedXP:SetWidth((restXP/maxXP)*total + 0.001) + self.RestedXP:SetWidth((restXP / maxXP) * total + 0.001) end - self.NoXP:SetWidth((remainXP/maxXP)*total) - end -end + self.NoXP:SetWidth((remainXP / maxXP) * total) -function FuXP:OnLevelUp(newLevel) - if self.db.profile.ShowXP == true and newLevel == MAX_PLAYER_LEVEL then - self.XPBar:Hide() - self.Spark:Hide() - self.Spark2:Hide() - self.RestedXP:Hide() - self.NoXP:Hide() + self.XPBar:Show() + self.RestedXP:Show() + self.NoXP:Show() + self.Border:Show() end end +-- function FuXP:OnLevelUp(newLevel) +-- if self.db.profile.ShowXP == true and newLevel == MAX_PLAYER_LEVEL then +-- self.XPBar:Hide() +-- self.Spark:Hide() +-- self.Spark2:Hide() +-- self.RestedXP:Hide() +-- self.NoXP:Hide() +-- end +-- end + function FuXP:OnTextUpdate() FuXP:OnDataUpdate() -- Setup watched factions diff --git a/FuBar_FuXPFu/FuBar_FuXPFu.toc b/FuBar_FuXPFu/FuBar_FuXPFu.toc index 13c521a..4334aa9 100644 --- a/FuBar_FuXPFu/FuBar_FuXPFu.toc +++ b/FuBar_FuXPFu/FuBar_FuXPFu.toc @@ -4,7 +4,7 @@ ## Notes: Lightweight XP Bar ## Notes-zhCN: 迷你经验条 ## Notes-zhTW: 輕量級的經驗值條模組。 -## Version: 10.0.2.3 +## Version: 10.0.2.4 ## Author: Wobin ## eMail: wobster@gmail.com ## X-Credits: Bant (For the design)