Skip to content

Commit

Permalink
Update for reputation API changes in the xp/rep bar module
Browse files Browse the repository at this point in the history
Replaces PR #58
  • Loading branch information
Nevcairiel committed Aug 16, 2024
1 parent 3936d7f commit e6a045f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ read_globals = {
-- API functions
"C_AddOns",
"C_IncomingSummon",
"C_Reputation",
"C_Spell",
"C_Timer",
"C_UnitAuras",
Expand All @@ -68,7 +69,6 @@ read_globals = {
"GetTime",
"GetTotemInfo",
"GetUnitPowerBarInfoByID",
"GetWatchedFactionInfo",
"GetWeaponEnchantInfo",
"GetXPExhaustion",
"HasLFGRestrictions",
Expand Down
9 changes: 5 additions & 4 deletions modules/xp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,21 @@ end

function XP:UpdateRep(frame)
if( not frame.xpBar.rep ) then return end
local name, reaction, min, max, current = GetWatchedFactionInfo()
if( not name ) then
local factionData = C_Reputation.GetWatchedFactionData()
if( not factionData ) then
frame.xpBar.rep:Hide()
return
end

-- Blizzard stores faction info related to Exalted, not your current level, so get more mathier to find the current reputation using the current standing tier
local min, max, current = factionData.currentReactionThreshold, factionData.nextReactionThreshold, factionData.currentStanding
current = math.abs(min - current)
max = math.abs(min - max)

local color = FACTION_BAR_COLORS[reaction]
local color = FACTION_BAR_COLORS[factionData.reaction]
frame.xpBar.rep:SetMinMaxValues(0, max)
frame.xpBar.rep:SetValue(current)
frame.xpBar.rep.tooltip = string.format(L["%s (%s): %s/%s (%.2f%% done)"], name, GetText("FACTION_STANDING_LABEL" .. reaction, UnitSex("player")), formatNumber(current), formatNumber(max), (max > 0 and current / max or 0) * 100)
frame.xpBar.rep.tooltip = string.format(L["%s (%s): %s/%s (%.2f%% done)"], factionData.name, GetText("FACTION_STANDING_LABEL" .. tostring(factionData.reaction), UnitSex("player")), formatNumber(current), formatNumber(max), (max > 0 and current / max or 0) * 100)
frame.xpBar.rep:SetStatusBarColor(color.r, color.g, color.b, ShadowUF.db.profile.bars.alpha)
frame.xpBar.rep.background:SetVertexColor(color.r, color.g, color.b, ShadowUF.db.profile.bars.backgroundAlpha)
frame.xpBar.rep:Show()
Expand Down

0 comments on commit e6a045f

Please sign in to comment.