Skip to content

Commit

Permalink
Fix a bug where the XP bar wouldn't properly hide on max level
Browse files Browse the repository at this point in the history
  • Loading branch information
azuraji committed Nov 28, 2022
1 parent b358dff commit 632b11d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
66 changes: 33 additions & 33 deletions FuBar_FuXPFu/FuBar_FuXPFu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FuBar_FuXPFu/FuBar_FuXPFu.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]
## X-Credits: Bant (For the design)
Expand Down

0 comments on commit 632b11d

Please sign in to comment.