Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunny67 committed Jan 7, 2018
1 parent 0ff560d commit 34d828b
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 251 deletions.
8 changes: 4 additions & 4 deletions ElvUI/Settings/Filters/UnitFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ G.unitframe.buffwatch = {
[61301] = ClassBuff(61301, "TOPLEFT", {0.7, 0.3, 0.7}), -- Riptide
},
ROGUE = {
[57933] = ClassBuff(57933, "TOPRIGHT", {227/255, 23/255, 13/255}), -- Tricks of the Trade
[57933] = ClassBuff(57933, "TOPRIGHT", {0.89, 0.09, 0.05}), -- Tricks of the Trade
},
MAGE = {
[54646] = ClassBuff(54646, "TOPRIGHT", {0.2, 0.2, 1}), -- Focus Magic
},
WARRIOR = {
[3411] = ClassBuff(3411, "TOPRIGHT", {227/255, 23/255, 13/255}), -- Intervene
[3411] = ClassBuff(3411, "TOPRIGHT", {0.89, 0.09, 0.05}), -- Intervene
[59665] = ClassBuff(59665, "TOPLEFT", {0.2, 0.2, 1}), -- Vigilance
},
DEATHKNIGHT = {
Expand Down Expand Up @@ -529,8 +529,8 @@ G.unitframe.ChannelTicks = {
}

G.unitframe.AuraBarColors = {
[SpellName(2825)] = {r = 250/255, g = 146/255, b = 27/255}, -- Bloodlust
[SpellName(32182)] = {r = 250/255, g = 146/255, b = 27/255}, -- Heroism
[SpellName(2825)] = {r = 0.98, g = 0.57, b = 0.10}, -- Bloodlust
[SpellName(32182)] = {r = 0.98, g = 0.57, b = 0.10}, -- Heroism
}

G.unitframe.InvalidSpells = {
Expand Down
2 changes: 2 additions & 0 deletions ElvUI/Settings/Profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ P["general"] = {
["watchFrameHeight"] = 480,
["afk"] = true,
["numberPrefixStyle"] = "ENGLISH",
["decimalLength"] = 1,

["fontSize"] = 12,
["font"] = "PT Sans Narrow",

Expand Down
120 changes: 72 additions & 48 deletions ElvUI/core/math.lua
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
local E, L, V, P, G = unpack(select(2, ...));

local select, unpack, assert, tonumber, type, pairs = select, unpack, assert, tonumber, type, pairs;
local tinsert, tremove = tinsert, tremove;
local tinsert, tremove = tinsert, tremove
local abs, ceil, floor, modf, mod = math.abs, math.ceil, math.floor, math.modf, mod;
local format, sub, upper, split, utf8sub = string.format, string.sub, string.upper, string.split, string.utf8sub;

local GetScreenWidth, GetScreenHeight = GetScreenWidth, GetScreenHeight;
local CreateFrame = CreateFrame;

--Return short value of a number
local shortValueDec
function E:ShortValue(v)
if(E.db.general.numberPrefixStyle == "METRIC") then
if(abs(v) >= 1e9) then
return format("%.1fG", v / 1e9);
elseif(abs(v) >= 1e6) then
return format("%.1fM", v / 1e6);
elseif(abs(v) >= 1e3) then
return format("%.1fk", v / 1e3);
shortValueDec = format("%%.%df", E.db.general.decimalLength or 1)
if E.db.general.numberPrefixStyle == "METRIC" then
if abs(v) >= 1e9 then
return format(shortValueDec.."G", v / 1e9)
elseif abs(v) >= 1e6 then
return format(shortValueDec.."M", v / 1e6)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."k", v / 1e3)
else
return format("%d", v);
return format("%s", v)
end
elseif(E.db.general.numberPrefixStyle == "CHINESE") then
if(abs(v) >= 1e8) then
return format("%.1fY", v / 1e8);
elseif(abs(v) >= 1e4) then
return format("%.1fW", v / 1e4);
elseif E.db.general.numberPrefixStyle == "CHINESE" then
if abs(v) >= 1e8 then
return format(shortValueDec.."Y", v / 1e8)
elseif abs(v) >= 1e4 then
return format(shortValueDec.."W", v / 1e4)
else
return format("%d", v);
return format("%s", v)
end
elseif E.db.general.numberPrefixStyle == "KOREAN" then
if abs(v) >= 1e8 then
return format(shortValueDec.."", v / 1e8)
elseif abs(v) >= 1e4 then
return format(shortValueDec.."", v / 1e4)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."", v / 1e3)
else
return format("%s", v)
end
elseif E.db.general.numberPrefixStyle == "GERMAN" then
if abs(v) >= 1e9 then
return format(shortValueDec.."Mrd", v / 1e9)
elseif abs(v) >= 1e6 then
return format(shortValueDec.."Mio", v / 1e6)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."Tsd", v / 1e3)
else
return format("%s", v)
end
else
if(abs(v) >= 1e9) then
return format("%.1fB", v / 1e9);
elseif(abs(v) >= 1e6) then
return format("%.1fM", v / 1e6);
elseif(abs(v) >= 1e3) then
return format("%.1fK", v / 1e3);
if abs(v) >= 1e9 then
return format(shortValueDec.."B", v / 1e9)
elseif abs(v) >= 1e6 then
return format(shortValueDec.."M", v / 1e6)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."K", v / 1e3)
else
return format("%d", v);
return format("%s", v)
end
end
end
Expand Down Expand Up @@ -165,43 +188,44 @@ function E:GetXYOffset(position, override)
end

local styles = {
-- keep percents in this table with `PERCENT` in the key, and `%.1f%%` in the value somewhere.
-- we use these two things to follow our setting for decimal length. they need to be EXACT.
["CURRENT"] = "%s",
["CURRENT_MAX"] = "%s - %s",
["CURRENT_PERCENT"] = "%s - %.1f%%",
["CURRENT_MAX_PERCENT"] = "%s - %s | %.1f%%",
["PERCENT"] = "%.1f%%",
["DEFICIT"] = "-%s"
};
}

local gftDec, gftUseStyle, gftDeficit
function E:GetFormattedText(style, min, max)
assert(styles[style], "Invalid format style: "..style);
assert(min, "You need to provide a current value. Usage: E:GetFormattedText(style, min, max)");
assert(max, "You need to provide a maximum value. Usage: E:GetFormattedText(style, min, max)");
assert(styles[style], "Invalid format style: "..style)
assert(min, "You need to provide a current value. Usage: E:GetFormattedText(style, min, max)")
assert(max, "You need to provide a maximum value. Usage: E:GetFormattedText(style, min, max)")

if(max == 0) then max = 1; end
if max == 0 then max = 1 end

local useStyle = styles[style];
gftDec = (E.db.general.decimalLength or 1)
if (gftDec ~= 1) and style:find("PERCENT") then
gftUseStyle = styles[style]:gsub("%%%.1f%%%%", "%%."..gftDec.."f%%%%")
else
gftUseStyle = styles[style]
end

if(style == "DEFICIT") then
local deficit = max - min;
if(deficit <= 0) then
return "";
else
return format(useStyle, E:ShortValue(deficit));
end
elseif(style == "PERCENT") then
local s = format(useStyle, min / max * 100);
return s;
elseif(style == "CURRENT" or ((style == "CURRENT_MAX" or style == "CURRENT_MAX_PERCENT" or style == "CURRENT_PERCENT") and min == max)) then
return format(styles["CURRENT"], E:ShortValue(min));
elseif(style == "CURRENT_MAX") then
return format(useStyle, E:ShortValue(min), E:ShortValue(max));
elseif(style == "CURRENT_PERCENT") then
local s = format(useStyle, E:ShortValue(min), min / max * 100);
return s;
elseif(style == "CURRENT_MAX_PERCENT") then
local s = format(useStyle, E:ShortValue(min), E:ShortValue(max), min / max * 100);
return s;
if style == "DEFICIT" then
gftDeficit = max - min
return ((gftDeficit > 0) and format(gftUseStyle, E:ShortValue(gftDeficit))) or ""
elseif style == "PERCENT" then
return format(gftUseStyle, min / max * 100)
elseif style == "CURRENT" or ((style == "CURRENT_MAX" or style == "CURRENT_MAX_PERCENT" or style == "CURRENT_PERCENT") and min == max) then
return format(styles["CURRENT"], E:ShortValue(min))
elseif style == "CURRENT_MAX" then
return format(gftUseStyle, E:ShortValue(min), E:ShortValue(max))
elseif style == "CURRENT_PERCENT" then
return format(gftUseStyle, E:ShortValue(min), min / max * 100)
elseif style == "CURRENT_MAX_PERCENT" then
return format(gftUseStyle, E:ShortValue(min), E:ShortValue(max), min / max * 100)
end
end

Expand Down
17 changes: 14 additions & 3 deletions ElvUI_Config/General.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,21 @@ E.Options.args.general = {
get = function(info) return E.db.general.numberPrefixStyle; end,
set = function(info, value) E.db.general.numberPrefixStyle = value; E:StaticPopup_Show("CONFIG_RL"); end,
values = {
["METRIC"] = "k, M, G",
["ENGLISH"] = "K, M, B",
["CHINESE"] = "W, Y"
["METRIC"] = "Metric (k, M, G)",
["ENGLISH"] = "English (K, M, B)",
["CHINESE"] = "Chinese (W, Y)",
["KOREAN"] = "Korean (천, 만, 억)",
["GERMAN"] = "German (Tsd, Mio, Mrd)"
}
},
decimalLength = {
order = 21,
type = "range",
name = L["Decimal Length"],
desc = L["Controls the amount of decimals used in values displayed on elements like NamePlates and UnitFrames."],
min = 0, max = 4, step = 1,
get = function(info) return E.db.general.decimalLength end,
set = function(info, value) E.db.general.decimalLength = value; E:StaticPopup_Show("GLOBAL_RL") end
}
}
},
Expand Down
Loading

0 comments on commit 34d828b

Please sign in to comment.