Skip to content

Commit

Permalink
Prepping for configurable fonts on action buttons
Browse files Browse the repository at this point in the history
No in-game config yet. I may add LSM support later...
  • Loading branch information
ls- committed Feb 4, 2018
1 parent 8730417 commit f94565d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
40 changes: 40 additions & 0 deletions core/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOM",
anchor = "UIParent",
Expand Down Expand Up @@ -2119,6 +2123,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOM",
anchor = "UIParent",
Expand Down Expand Up @@ -2149,6 +2157,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOM",
anchor = "UIParent",
Expand Down Expand Up @@ -2179,6 +2191,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOMRIGHT",
anchor = "UIParent",
Expand Down Expand Up @@ -2209,6 +2225,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOMRIGHT",
anchor = "UIParent",
Expand Down Expand Up @@ -2237,6 +2257,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 10,
flag = "Outline",
},
},
bar7 = { -- Stance
flyout_dir = "UP",
Expand All @@ -2258,6 +2282,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 10,
flag = "Outline",
},
},
pet_battle = {
num = 6,
Expand All @@ -2278,6 +2306,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOM",
anchor = "UIParent",
Expand All @@ -2300,6 +2332,10 @@ D.profile = {
min_alpha = 0,
max_alpha = 1,
},
font = {
size = 12,
flag = "Outline",
},
point = {
p = "BOTTOM",
anchor = "UIParent",
Expand Down Expand Up @@ -2414,6 +2450,10 @@ D.profile = {
visible = true,
x_growth = "RIGHT",
y_growth = "DOWN",
font = {
size = 12,
flag = "Outline",
},
fade = {
enabled = false,
out_delay = 0.75,
Expand Down
10 changes: 10 additions & 0 deletions modules/bars/actionbars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ local function bar_Update(self)
self:UpdateFading()
self:UpdateVisibility()
self:UpdateButtonConfig()
self:UpdateButtons("UpdateFontObjects")
E:UpdateBarLayout(self)
end

Expand Down Expand Up @@ -158,6 +159,13 @@ local function bar_UpdateButtonConfig(self)
end
end

local function button_UpdateFontObjects(self)
local config = self._parent._config.font
self.Count:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
self.HotKey:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
self.Name:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
end

local function button_UpdateMacroText(self, state)
if state ~= nil then
self._parent._config.macro = state
Expand Down Expand Up @@ -215,6 +223,7 @@ function MODULE.CreateActionBars()
self._config = MODULE:IsRestricted() and CFG.bar1 or C.db.profile.bars.bar1

if MODULE:IsRestricted() then
self._config.font = C.db.profile.bars.bar1.font
self._config.grid = C.db.profile.bars.bar1.grid
self._config.hotkey = C.db.profile.bars.bar1.hotkey
self._config.macro = C.db.profile.bars.bar1.macro
Expand All @@ -229,6 +238,7 @@ function MODULE.CreateActionBars()
button._command = data.type..i

button.UpdateFlyoutDirection = button_UpdateFlyoutDirection
button.UpdateFontObjects = button_UpdateFontObjects
button.UpdateGrid = button_UpdateGrid
button.UpdateHotKey = button_UpdateHotKey
button.UpdateMacroText = button_UpdateMacroText
Expand Down
12 changes: 12 additions & 0 deletions modules/bars/bags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ local function BackpackButton_OnEvent(self, event, ...)
end
end

local function button_UpdateFontObjects(self)
local config = self._parent._config.font
self.Count:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
end

function MODULE.HasBags()
return isInit
end
Expand All @@ -141,10 +146,15 @@ function MODULE.CreateBags()
bar.Update = function(self)
self:UpdateConfig()
self:UpdateFading()
self:UpdateButtons("UpdateFontObjects")
E:UpdateBarLayout(self)
end
bar.UpdateConfig = function(self)
self._config = MODULE:IsRestricted() and CFG or C.db.profile.bars.bags

if MODULE:IsRestricted() then
self._config.font = C.db.profile.bars.bags.font
end
end

for _, bag in next, bar._buttons do
Expand All @@ -153,6 +163,8 @@ function MODULE.CreateBags()
bag:SetParent(bar)
E:SkinBagButton(bag)

bag.UpdateFontObjects = button_UpdateFontObjects

if bag ~= MainMenuBarBackpackButton then
bag:Hide()
end
Expand Down
7 changes: 7 additions & 0 deletions modules/bars/extra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ local function button_UpdateHotKey(self, state)
end
end

local function button_UpdateFontObjects(self)
local config = self._parent._config.font
self.HotKey:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
end

function MODULE.CreateExtraButton()
if not isInit then
local bar = CreateFrame("Frame", "LSExtraActionBar", UIParent, "SecureHandlerStateTemplate")
Expand All @@ -34,6 +39,7 @@ function MODULE.CreateExtraButton()
self:UpdateFading()
self:UpdateVisibility()
self:UpdateButtons("UpdateHotKey")
self:UpdateButtons("UpdateFontObjects")

ExtraActionBarFrame:SetAllPoints()

Expand All @@ -55,6 +61,7 @@ function MODULE.CreateExtraButton()
E:SkinExtraActionButton(ExtraActionButton1)
bar._buttons[1] = ExtraActionButton1

ExtraActionButton1.UpdateFontObjects = button_UpdateFontObjects
ExtraActionButton1.UpdateHotKey = button_UpdateHotKey

local point = C.db.profile.bars.extra.point
Expand Down
16 changes: 16 additions & 0 deletions modules/bars/petbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ local function button_UpdateHotKey(self, state)
end
end

local function button_UpdateFontObjects(self)
local config = self._parent._config.font
self.HotKey:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
end

local function button_UpdateCooldown(self)
self.cooldown:SetDrawBling(self.cooldown:GetEffectiveAlpha() > 0.5)
CooldownFrame_Set(self.cooldown, GetPetActionCooldown(self:GetID()))
Expand Down Expand Up @@ -167,8 +172,18 @@ function MODULE.CreatePetActionBar()
self:UpdateFading()
self:UpdateVisibility()
self:UpdateButtons("Update")
self:UpdateButtons("UpdateFontObjects")
E:UpdateBarLayout(self)
end
bar.UpdateButtonFontObjects = function(self)
local fontObject = "LSFont"..self._config.font.size..(self._config.font.flag ~= "" and "_"..self._config.font.flag or "")

for _, button in next, self._buttons do
if button.HotKey then
button.HotKey:SetFontObject(fontObject)
end
end
end

for i = 1, #BUTTONS do
local button = CreateFrame("CheckButton", "$parentButton"..i, bar, "PetActionButtonTemplate")
Expand All @@ -186,6 +201,7 @@ function MODULE.CreatePetActionBar()
button.StopFlash = PetActionButton_StopFlash
button.Update = button_Update
button.UpdateCooldown = button_UpdateCooldown
button.UpdateFontObjects = button_UpdateFontObjects
button.UpdateGrid = button_UpdateGrid
button.UpdateHotKey = button_UpdateHotKey

Expand Down
8 changes: 8 additions & 0 deletions modules/bars/petbattle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ local function button_UpdateHotKey(self, state)
end
end

local function button_UpdateFontObjects(self)
local config = self._parent._config.font
self.HotKey:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
end

function MODULE.CreatePetBattleBar()
if not isInit then
local config = MODULE:IsRestricted() and CFG or C.db.profile.bars.pet_battle
Expand All @@ -59,12 +64,14 @@ function MODULE.CreatePetBattleBar()
self:UpdateFading()
self:UpdateVisibility()
self:UpdateButtons("UpdateHotKey")
self:UpdateButtons("UpdateFontObjects")
E:UpdateBarLayout(self)
end
bar.UpdateConfig = function(self)
self._config = MODULE:IsRestricted() and CFG or C.db.profile.bars.pet_battle

if MODULE:IsRestricted() then
self._config.font = C.db.profile.bars.pet_battle.font
self._config.hotkey = C.db.profile.bars.pet_battle.hotkey
end
end
Expand All @@ -82,6 +89,7 @@ function MODULE.CreatePetBattleBar()
button._command = "ACTIONBUTTON"..id
button:SetParent(bar)

button.UpdateFontObjects = button_UpdateFontObjects
button.UpdateHotKey = button_UpdateHotKey

E:SkinPetBattleButton(button)
Expand Down
7 changes: 7 additions & 0 deletions modules/bars/stancebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ local function button_UpdateHotKey(self, state)
end
end

local function button_UpdateFontObjects(self)
local config = self._parent._config.font
self.HotKey:SetFontObject("LSFont"..config.size..(config.flag ~= "" and "_"..config.flag or ""))
end

function MODULE.CreateStanceBar()
if not isInit then
local bar = CreateFrame("Frame", "LSStanceBar", UIParent, "SecureHandlerStateTemplate")
Expand All @@ -105,6 +110,7 @@ function MODULE.CreateStanceBar()
self:UpdateFading()
self:UpdateVisibility()
self:UpdateButtons("Update")
self:UpdateButtons("UpdateFontObjects")
E:UpdateBarLayout(self)
end
bar.UpdateForms = function(self)
Expand All @@ -130,6 +136,7 @@ function MODULE.CreateStanceBar()
button._command = "SHAPESHIFTBUTTON"..i

button.Update = button_Update
button.UpdateFontObjects = button_UpdateFontObjects
button.UpdateHotKey = button_UpdateHotKey

BUTTONS[i]:SetAllPoints(button)
Expand Down

0 comments on commit f94565d

Please sign in to comment.