Skip to content

Commit

Permalink
Add paragon support for major factions
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliote committed May 10, 2024
1 parent 9de4e07 commit 314ad3e
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions TitanReputations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,19 @@ local function GetBalanceForMajorFaction(factionId, currentXp, currentLvl)
return balance
end

-- @return current, maximun, color, standingText, hasRewardPending, session, texture
local function GetParagonValues(barValue, factionId, colors, texture)
local color = colors.paragon
local currentValue, threshold, _, hasRewardPending = C_Reputation.GetFactionParagonInfo(factionId);
local standingText = " (" .. GetFactionLabel("paragon") .. ")"
if hasRewardPending then
standingText = " (" .. GetFactionLabel("paragon") .. " |A:ParagonReputation_Bag:0:0|a" .. ")"
end
sessionStart[factionId] = sessionStart[factionId] or barValue
local session = barValue - sessionStart[factionId]
return mod(currentValue, threshold), threshold, color, standingText, hasRewardPending, session, texture
end

-- @return current, maximum, color, standingText, hasRewardPending, session, texture
local function GetValueAndMaximum(standingId, barValue, bottomValue, topValue, factionId, colors)
if (IsMajorFaction(factionId)) then
local data = GetMajorFactionData(factionId)
Expand All @@ -116,6 +128,9 @@ local function GetValueAndMaximum(standingId, barValue, bottomValue, topValue, f
local standingText = " (" .. (RENOWN_LEVEL_LABEL .. data.renownLevel) .. ")"
local session = GetBalanceForMajorFaction(factionId, current, data.renownLevel)
local texture = data.textureKit and ([[Interface\Icons\UI_MajorFaction_%s]]):format(data.textureKit)
if (C_Reputation.IsFactionParagon(factionId)) then
return GetParagonValues(barValue, factionId, colors, texture)
end
return current, data.renownLevelThreshold, colors.renown, standingText, nil, session, texture
end

Expand All @@ -124,37 +139,29 @@ local function GetValueAndMaximum(standingId, barValue, bottomValue, topValue, f
end

if (C_Reputation.IsFactionParagon(factionId)) then
local color = colors.paragon
local currentValue, threshold, _, hasRewardPending = C_Reputation.GetFactionParagonInfo(factionId);
local standingText = " (" .. GetFactionLabel("paragon") .. ")"
if hasRewardPending then
standingText = " (" .. GetFactionLabel("paragon") .. " |A:ParagonReputation_Bag:0:0|a" .. ")"
end
sessionStart[factionId] = sessionStart[factionId] or barValue
local session = barValue - sessionStart[factionId]
return mod(currentValue, threshold), threshold, color, standingText, hasRewardPending, session
return GetParagonValues(barValue, factionId, colors)
end

local friendID, friendRep, _, _, _, friendTexture, friendTextLevel, friendThreshold, nextFriendThreshold = GetFriendshipReputation(factionId)
if (friendID) then
local standingText = " (" .. friendTextLevel .. ")"
local color = colors[standingId] or colors[5]
local maximun, current = 1, 1
local maximum, current = 1, 1
if (nextFriendThreshold) then
maximun, current = nextFriendThreshold - friendThreshold, friendRep - friendThreshold
maximum, current = nextFriendThreshold - friendThreshold, friendRep - friendThreshold
end
sessionStart[factionId] = sessionStart[factionId] or friendRep
local session = friendRep - sessionStart[factionId]
return current, maximun, color, standingText, nil, session, friendTexture
return current, maximum, color, standingText, nil, session, friendTexture
end

local current = barValue - bottomValue
local maximun = topValue - bottomValue
local maximum = topValue - bottomValue
local color = colors[standingId] or colors[5]
local standingText = " (" .. GetFactionLabel(standingId) .. ")"
sessionStart[factionId] = sessionStart[factionId] or barValue
local session = barValue - sessionStart[factionId]
return current, maximun, color, standingText, nil, session
return current, maximum, color, standingText, nil, session
end

local function GetButtonMainRepInfo(self)
Expand Down

0 comments on commit 314ad3e

Please sign in to comment.