Move to externals' version of GSC

This commit is contained in:
tekkub ʕ ´ᴥ` ʔ 2016-09-11 22:16:44 -06:00
parent 36c5228bac
commit f320154440
4 changed files with 66 additions and 20 deletions

View File

@ -10,13 +10,13 @@
## X-LoadOn-Merchant: true
externals\events.lua
externals\gsc.lua
externals\itemid.lua
externals\size_to_fit.lua
externals\tooltip_scanner.lua
externals\ui-scrollbar.lua
externals\ui-textinput.lua
tekFunks\gsc.lua
LibItemSearch-1.0.lua
frames\AltCurrency.lua

View File

@ -1,4 +1,5 @@
events.lua
gsc.lua
itemid.lua
size_to_fit.lua
tooltip_scanner.lua

64
externals/gsc.lua vendored Normal file
View File

@ -0,0 +1,64 @@
local myname, ns = ...
local G, S, C = "|cffffd700", "|cffc7c7cf", "|cffeda55f"
local GOLD, SILVER, COPPER = G.."%s", S.."%s", C.."%s"
local SILVER00, COPPER00 = S.."%02d", C.."%02d"
local GSC = string.join('.', GOLD, SILVER00, COPPER00)
local GS = string.join('.', GOLD, SILVER00)
local SC = string.join('.', SILVER, COPPER00)
-- Converts an integer into a colored gold.silver.copper string
--
-- cash - an integer representing a price in copper
-- colorblind - force the use of colorblind mode, always printing out
-- zero-value silver and copper
--
-- Returns a colored string
function ns.GSC(cash, colorblind)
if not cash then return end
local g, s, c = floor(cash/10000), floor((cash/100)%100), cash%100
local g2 = BreakUpLargeNumbers(g)
if colorblind or GetCVarBool("colorblindMode") then
if g > 0 then return string.format(GSC, g2, s, c)
elseif s > 0 then return string.format(SC, s, c)
else return string.format(COPPER, c) end
else
if g > 0 and s == 0 and c == 0 then return string.format(GOLD, g2)
elseif g > 99999 then return string.format(GOLD, g2)
elseif g > 0 and c == 0 then return string.format(GS, g2, s)
elseif g > 0 then return string.format(GSC, g2, s, c)
elseif s > 0 and c == 0 then return string.format(GS, 0, s)
elseif s > 0 then return string.format(SC, s, c)
else return string.format(COPPER, c) end
end
end
-- Converts an integer into a colored gold.silver string
--
-- cash - an integer representing a price in copper
--
-- Returns a colored string
function ns.GS(cash)
if not cash then return end
if cash > 999999 then return ns.GSC(floor(cash/10000)*10000)
else return ns.GSC(floor(cash/100)*100) end
end
-- Converts an integer into a colored gold string
--
-- cash - an integer representing a price in copper
--
-- Returns a colored string
function ns.G(cash)
if not cash then return end
return ns.GSC(floor(cash/10000)*10000)
end

View File

@ -1,19 +0,0 @@
local myname, ns = ...
function ns.GSC(cash, colorblind)
if not cash then return end
local g, s, c = floor(cash/10000), floor((cash/100)%100), cash%100
if colorblind or GetCVarBool("colorblindMode") then
if g > 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d.|cffeda55f%02d", g, s, c)
elseif s > 0 then return string.format(" |cffc7c7cf%d.|cffeda55f%02d", s, c)
else return string.format(" |cffeda55f%d", c) end
else
if g > 0 and s == 0 and c == 0 then return string.format(" |cffffd700%d", g)
elseif g > 0 and c == 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d", g, s)
elseif g > 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d.|cffeda55f%02d", g, s, c)
elseif s > 0 and c == 0 then return string.format(" |cffc7c7cf%d", s)
elseif s > 0 then return string.format(" |cffc7c7cf%d.|cffeda55f%02d", s, c)
else return string.format(" |cffeda55f%d", c) end
end
end