From 9073a126fca6c96d9a77ed8dd3eef10d669d3a9f Mon Sep 17 00:00:00 2001 From: phyber Date: Sun, 15 Sep 2019 19:15:50 +0100 Subject: [PATCH] Fix Commify option on Classic Apparently BreakUpLargeNumbers is a noop in Classic --- .luacheckrc | 6 ++++-- Core.lua | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index f94e4f5..fefe414 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -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", } @@ -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", diff --git a/Core.lua b/Core.lua index 040412b..00bbc4f 100644 --- a/Core.lua +++ b/Core.lua @@ -36,7 +36,6 @@ do end -- WoW Functions -local BreakUpLargeNumbers = BreakUpLargeNumbers local CollapseFactionHeader = CollapseFactionHeader local ExpandFactionHeader = ExpandFactionHeader local GetContainerItemInfo = GetContainerItemInfo @@ -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 @@ -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 @@ -99,6 +117,7 @@ do return false end else + BreakUpLargeNumbers = _G.BreakUpLargeNumbers FindActiveAzeriteItem = C_AzeriteItem.FindActiveAzeriteItem GetAzeriteItemXPInfo = C_AzeriteItem.GetAzeriteItemXPInfo GetFactionParagonInfo = C_Reputation.GetFactionParagonInfo