From e6a045f165cc55c1ec6db1d82bc550f6dd2886d2 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Fri, 16 Aug 2024 10:25:58 +0200 Subject: [PATCH] Update for reputation API changes in the xp/rep bar module Replaces PR #58 --- .luacheckrc | 2 +- modules/xp.lua | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 6d9ed6fb..0263bfa6 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -43,6 +43,7 @@ read_globals = { -- API functions "C_AddOns", "C_IncomingSummon", + "C_Reputation", "C_Spell", "C_Timer", "C_UnitAuras", @@ -68,7 +69,6 @@ read_globals = { "GetTime", "GetTotemInfo", "GetUnitPowerBarInfoByID", - "GetWatchedFactionInfo", "GetWeaponEnchantInfo", "GetXPExhaustion", "HasLFGRestrictions", diff --git a/modules/xp.lua b/modules/xp.lua index 7c7f8ead..f7d569ae 100755 --- a/modules/xp.lua +++ b/modules/xp.lua @@ -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()