Skip to content

Commit

Permalink
add CastbarFont tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunny67 committed Nov 22, 2017
1 parent 5ebd8ff commit 2a58aee
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 0 deletions.
257 changes: 257 additions & 0 deletions ElvUI_CustomTweaks/Categories/unitframes/CastbarFont.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
local E, L, V, P, G = unpack(ElvUI)
local CT = E:GetModule("CustomTweaks")
local isEnabled = E.private["unitframe"].enable and E.private["CustomTweaks"] and E.private["CustomTweaks"]["CastbarFont"]and true or false
local UF = E:GetModule("UnitFrames")
local LSM = LibStub("LibSharedMedia-3.0")

--Cache global variables
local _G = _G
local pairs = pairs

P["CustomTweaks"]["CastbarFont"] = {
["Player"] = {
["duration"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
["text"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
},
["Pet"] = {
["duration"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
["text"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
},
["Target"] = {
["duration"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
["text"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
},
["Focus"] = {
["duration"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
["text"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
},
["Arena"] = {
["duration"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
["text"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
},
["Boss"] = {
["duration"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
["text"] = {
["font"] = "Homespun",
["fontSize"] = 10,
["fontOutline"] = "MONOCHROMEOUTLINE",
},
},
}

local units = {"Player", "Pet", "Target", "Focus", "Arena", "Boss"}
local UpdateCastbarFont
local MAX_BOSS_FRAMES = MAX_BOSS_FRAMES

local function ConfigTable()
E.Options.args.CustomTweaks.args.Unitframe.args.options.args.CastbarFont = {
type = "group",
name = "CastbarFont",
get = function(info) return E.db.CustomTweaks.CastbarFont[info[#info]] end,
set = function(info, value) E.db.CustomTweaks.CastbarFont[info[#info]] = value; end,
childGroups = "tab",
args = {},
}

local function CreateOptionsGroup(order, name, unit)
local group = {
order = order,
type = "group",
name = name,
args = {
text = {
order = 2,
type = "group",
name = L["Text"],
guiInline = true,
get = function(info) return E.db.CustomTweaks.CastbarFont[unit].text[info[#info]] end,
set = function(info, value) E.db.CustomTweaks.CastbarFont[unit].text[info[#info]] = value; UpdateCastbarFont(unit) end,
disabled = function() return not isEnabled end,
args = {
font = {
order = 1,
type = "select",
dialogControl = "LSM30_Font",
name = L["Font"],
values = AceGUIWidgetLSMlists.font,
},
fontSize = {
order = 2,
type = "range",
name = L["Font Size"],
min = 4, max = 22, step = 1,
},
fontOutline = {
order = 3,
type = "select",
name = L["Font Outline"],
values = {
["NONE"] = L["None"],
["OUTLINE"] = "OUTLINE",
["MONOCHROMEOUTLINE"] = "MONOCROMEOUTLINE",
["THICKOUTLINE"] = "THICKOUTLINE",
},
},
},
},

duration = {
order = 1,
type = "group",
name = L["Duration"],
guiInline = true,
get = function(info) return E.db.CustomTweaks.CastbarFont[unit].duration[info[#info]] end,
set = function(info, value) E.db.CustomTweaks.CastbarFont[unit].duration[info[#info]] = value; UpdateCastbarFont(unit) end,
disabled = function() return not isEnabled end,
args = {
font = {
order = 1,
type = "select",
dialogControl = "LSM30_Font",
name = L["Font"],
values = AceGUIWidgetLSMlists.font,
},
fontSize = {
order = 2,
type = "range",
name = L["Font Size"],
min = 4, max = 22, step = 1,
},
fontOutline = {
order = 3,
type = "select",
name = L["Font Outline"],
values = {
["NONE"] = L["None"],
["OUTLINE"] = "OUTLINE",
["MONOCHROMEOUTLINE"] = "MONOCROMEOUTLINE",
["THICKOUTLINE"] = "THICKOUTLINE",
},
},
},
},
},
}

return group
end

local options = E.Options.args.CustomTweaks.args.Unitframe.args.options.args.CastbarFont.args
options.player = CreateOptionsGroup(1, L["Player"], "Player")
options.pet = CreateOptionsGroup(2, L["Pet"], "Pet")
options.target = CreateOptionsGroup(3, L["Target"], "Target")
options.focus = CreateOptionsGroup(4, L["Focus"], "Focus")
options.arena = CreateOptionsGroup(5, L["Arena"], "Arena")
options.boss = CreateOptionsGroup(6, L["Boss"], "Boss")
end
CT.Configs["CastbarFont"] = ConfigTable
if not isEnabled then return; end

function UpdateCastbarFont(unit)
local font = E.db.CustomTweaks.CastbarFont[unit].text.font
local fontSize = E.db.CustomTweaks.CastbarFont[unit].text.fontSize
local fontOutline = E.db.CustomTweaks.CastbarFont[unit].text.fontOutline

local font2 = E.db.CustomTweaks.CastbarFont[unit].duration.font
local fontSize2 = E.db.CustomTweaks.CastbarFont[unit].duration.fontSize
local fontOutline2 = E.db.CustomTweaks.CastbarFont[unit].duration.fontOutline

if unit == "Arena" then
for i = 1, 5 do
local unitframe = _G["ElvUF_Arena"..i]
local castbar = unitframe and unitframe.Castbar

if castbar then
castbar.Text:FontTemplate(LSM:Fetch("font", font), fontSize, fontOutline)
castbar.Time:FontTemplate(LSM:Fetch("font", font2), fontSize2, fontOutline2)

if onLoad then
UF["fontstrings"][castbar.Time] = nil
UF["fontstrings"][castbar.Text] = nil
end
end
end
elseif unit == "Boss" then
for i = 1, MAX_BOSS_FRAMES do
local unitframe = _G["ElvUF_Boss"..i]
local castbar = unitframe and unitframe.Castbar

if castbar then
castbar.Text:FontTemplate(LSM:Fetch("font", font), fontSize, fontOutline)
castbar.Time:FontTemplate(LSM:Fetch("font", font2), fontSize2, fontOutline2)

if onLoad then
UF["fontstrings"][castbar.Time] = nil
UF["fontstrings"][castbar.Text] = nil
end
end
end
else
local unitframe = _G["ElvUF_"..unit]
local castbar = unitframe and unitframe.Castbar

if castbar then
castbar.Text:FontTemplate(LSM:Fetch("font", font), fontSize, fontOutline)
castbar.Time:FontTemplate(LSM:Fetch("font", font2), fontSize2, fontOutline2)

if onLoad then
UF["fontstrings"][castbar.Time] = nil
UF["fontstrings"][castbar.Text] = nil
end
end
end
end

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(self)
self:UnregisterEvent("PLAYER_ENTERING_WORLD")

for _, unit in pairs(units) do
UpdateCastbarFont(unit, true)
end
end)
1 change: 1 addition & 0 deletions ElvUI_CustomTweaks/Categories/unitframes/load_tweaks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<Script file='CastbarText.lua'/>
<Script file='PowerBarTexture.lua'/>
<Script file='UnitframeSpacingLimits.lua'/>
<Script file='CastbarFont.lua'/>
</Ui>
2 changes: 2 additions & 0 deletions ElvUI_CustomTweaks/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ local Tweaks = {
{"CastbarText", L["Allows you to position and change color and alpha of castbar text."]},
{"PowerBarTexture", L["Allows you to use a separate texture for unitframe power bars."]},
{"UnitFrameSpacingLimits", L["Increases the maximum allowed vertical and horizontal spacing for party and raid frames."]},
{"CastbarFont", L["Allows you to change the text and duration font for the castbar."]},
},
}

Expand All @@ -64,6 +65,7 @@ local Authors = {
"PushedColor",
"RaidControl",
"UnitFrameSpacingLimits",
"CastbarFont",
}},
}

Expand Down
2 changes: 2 additions & 0 deletions ElvUI_CustomTweaks/locales.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ L["Add 'Stack' Button"] = true;
L["AddOn Description / Download"] = true;
L["Allows you to change bag buttons to use the classic texture style and allows you to add a 'Stack' button."] = true;
L["Allows you to change template of the Raid Control button or hide it altogether."] = true;
L["Allows you to change the text and duration font for the castbar."] = true;
L["Allows you to choose the color of the actionbar button when it is pushed down."] = true;
L["Allows you to choose which text format the Bags datatext uses."] = true;
L["Allows you to make actionbars clickthrough."] = true;
Expand Down Expand Up @@ -148,6 +149,7 @@ if L then
L["AddOn Description / Download"] = "Описание / Скачать:";
L["Allows you to change bag buttons to use the classic texture style and allows you to add a 'Stack' button."] = "Позволяет изменять кнопки сумок на текстурные полосы, а так же добавляет кнопку 'Собрать'.";
L["Allows you to change template of the Raid Control button or hide it altogether."] = "Позволяет изменять вид кнопки управления рейдом или полностью скрыть её.";
L["Allows you to change the text and duration font for the castbar."] = "Позволяет изменять шрифт текста и длительности для полосы заклинания";
L["Allows you to choose the color of the actionbar button when it is pushed down."] = "Позволяет изменять цвет кнопок панелей команд во время нажатия.";
L["Allows you to choose which text format the Bags datatext uses."] = "Позволяет выбрать формат текста сумок.";
L["Allows you to make actionbars clickthrough."] = "Позволяет совершать нажатия мыши сквозь панели команд.";
Expand Down

0 comments on commit 2a58aee

Please sign in to comment.