Skip to content

Commit

Permalink
Fix Commify option on Classic
Browse files Browse the repository at this point in the history
Apparently BreakUpLargeNumbers is a noop in Classic
  • Loading branch information
phyber committed Sep 15, 2019
1 parent 466f0f7 commit 9073a12
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .luacheckrc
Expand Up @@ -15,6 +15,7 @@ max_line_length = false

-- We don't want to check externals Libs or this config file
exclude_files = {
".release/",
"Libs/",
".luacheckrc",
}
Expand Down Expand Up @@ -104,9 +105,10 @@ read_globals = {
"FACTION_BAR_COLORS",
"FACTION_HORDE",
"GUILD",
"MAX_PLAYER_LEVEL_TABLE",
"LE_ITEM_QUALITY_ARTIFACT",
"ITEM_QUALITY_COLORS",
"LARGE_NUMBER_SEPERATOR",
"LE_ITEM_QUALITY_ARTIFACT",
"MAX_PLAYER_LEVEL_TABLE",

-- Frames
"GameTooltip",
Expand Down
21 changes: 20 additions & 1 deletion Core.lua
Expand Up @@ -36,7 +36,6 @@ do
end

-- WoW Functions
local BreakUpLargeNumbers = BreakUpLargeNumbers
local CollapseFactionHeader = CollapseFactionHeader
local ExpandFactionHeader = ExpandFactionHeader
local GetContainerItemInfo = GetContainerItemInfo
Expand All @@ -60,6 +59,7 @@ local UnitXPMax = UnitXPMax

-- Some functions don't exist in Classic. We set these conditionally depending
-- on which client we're running on.
local BreakUpLargeNumbers
local GetFactionParagonInfo
local GetFriendshipReputation
local HasActiveAzeriteItem
Expand All @@ -70,6 +70,24 @@ local GetAzeriteItemXPInfo
local GetPowerLevel
do
if IsClassic() then
-- BreakUpLargeNumbers in Classic doesn't do anything. Implement it
-- ourselves.
local LARGE_NUMBER_SEPERATOR = LARGE_NUMBER_SEPERATOR

BreakUpLargeNumbers = function(num)
local str = ""
local count = 0
for d in tostring(num):reverse():gmatch("%d") do
if count ~= 0 and count % 3 == 0 then
str = str .. LARGE_NUMBER_SEPERATOR .. d
else
str = str .. d
end
count = count + 1
end
return str:reverse()
end

-- Easier to stub these than add conditionals to the callers of this
-- function.
-- Friendship reputations don't exist in Classic
Expand Down Expand Up @@ -99,6 +117,7 @@ do
return false
end
else
BreakUpLargeNumbers = _G.BreakUpLargeNumbers
FindActiveAzeriteItem = C_AzeriteItem.FindActiveAzeriteItem
GetAzeriteItemXPInfo = C_AzeriteItem.GetAzeriteItemXPInfo
GetFactionParagonInfo = C_Reputation.GetFactionParagonInfo
Expand Down

0 comments on commit 9073a12

Please sign in to comment.