Skip to content

Commit

Permalink
Font thing
Browse files Browse the repository at this point in the history
  • Loading branch information
d87 committed Oct 8, 2020
1 parent b63f076 commit bb4da08
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 19 deletions.
Binary file added AlegreyaSans-Medium.ttf
Binary file not shown.
Binary file removed ClearFont.ttf
Binary file not shown.
4 changes: 2 additions & 2 deletions Options/WidgetForms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function ns.WidgetForms.Icon.Create(form)

CreateSizeSettings(form)
CreateAnchorSettings(form)
local font = ns.AddFontDropdown(form, 0.46, L"Stacks Font", "font", "ClearFont", callbackUpdateForm)
local font = ns.AddFontDropdown(form, 0.46, L"Stacks Font", "font", AptechkaDefaultConfig.defaultFont, callbackUpdateForm)
local textsize = ns.AddSlider(form, 0.46, L"Font Size", "textsize", 12, 6, 30, 1, callbackUpdateForm)
local alpha = ns.AddSlider(form, 0.95, L"Alpha", "alpha", 1, 0, 1, 0.05, callbackUpdateForm)
local outline = ns.AddCheckbox(form, 0.46, L"Outline", "outline", false, callbackUpdateForm)
Expand Down Expand Up @@ -373,7 +373,7 @@ function ns.WidgetForms.Text.Create(form)
form = form or ns.InitForm()

CreateAnchorSettings(form)
local font = ns.AddFontDropdown(form, 0.46, L"Font", "font", "ClearFont", callbackUpdateForm)
local font = ns.AddFontDropdown(form, 0.46, L"Font", "font", AptechkaDefaultConfig, callbackUpdateForm)
local textsize = ns.AddSlider(form, 0.46, L"Font Size", "textsize", 12, 6, 30, 1, callbackUpdateForm)
local effect = ns.AddDropdown(form, 0.46, L"Effect", "effect", "NONE", textEffects, callbackUpdateForm)

Expand Down
14 changes: 7 additions & 7 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config.maxgroups = 8
config.petcolor = {1,.5,.5}
--A maximum of 5 pets can be displayed.

config.defaultFont = "ClearFont"
config.defaultFont = "AlegreyaSans-Medium"
do
local locale = GetLocale()
if locale == "zhTW" or locale == "zhCN" or locale == "koKR" then
Expand Down Expand Up @@ -81,19 +81,19 @@ config.MindControlStatus = { name = "MIND_CONTROL", assignto = set("border", "mi
config.DefaultWidgets = {
raidbuff = { type = "IndicatorArray", width = 5, height = 5, point = "TOPLEFT", x = 0, y = 0, growth = "DOWN", max = 5 },
mitigation = { type = "Bar", width=22, height=4, point="BOTTOMLEFT", x=4, y=-5, vertical = false},
icon = { type = "Icon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = "ClearFont", textsize = 12, outline = true, edge = true },
icon = { type = "Icon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 12, outline = true, edge = true },
spell1 = { type = "Indicator", width = 9, height = 8, point = "BOTTOMRIGHT", x = 0, y = 0, },
-- spell2 = { type = "Indicator", width = 9, height = 8, point = "TOP", x = 0, y = 0, },
spell3 = { type = "Indicator", width = 9, height = 8, point = "TOPRIGHT", x = 0, y = 0, },
bar4 = { type = "Bar", width=21, height=5, point="TOPRIGHT", x=0, y=2, vertical = false},
buffIcons = { type = "IconArray", width = 12, height = 18, point = "TOPRIGHT", x = 5, y = -6, alpha = 1, growth = "LEFT", max = 3, edge = true, outline = true, font = "ClearFont", textsize = 12 },
buffIcons = { type = "IconArray", width = 12, height = 18, point = "TOPRIGHT", x = 5, y = -6, alpha = 1, growth = "LEFT", max = 3, edge = true, outline = true, font = config.defaultFont, textsize = 12 },
bars = { type = "BarArray", width = 21, height = 5, point = "BOTTOMRIGHT", x = 0, y = 0, vertical = false, growth = "UP", max = 7 },
vbar1 = { type = "Bar", width=4, height=20, point="TOPRIGHT", x=-9, y=2, vertical = true},
text1 = { type = "StaticText", point="CENTER", x=0, y=0, font = config.defaultFont, textsize = 12, effect = "SHADOW" },
text2 = { type = "StaticText", point="CENTER", x=0, y=-10, font = "ClearFont", textsize = 10, effect = "NONE" },
text3 = { type = "Text", point="TOPLEFT", x=2, y=0, font = "ClearFont", textsize = 9, effect = "NONE" },
incomingCastIcon = { type = "ProgressIcon", width = 18, height = 18, point = "TOPLEFT", x = -3, y = 3, alpha = 1, font = "ClearFont", textsize = 12, outline = false, edge = false },
debuffIcons = { type = "DebuffIconArray", width = 13, height = 13, point = "BOTTOMLEFT", x = 0, y = 0, style = "STRIP_RIGHT", animdir = "LEFT", alpha = 1, growth = "UP", max = 4, edge = true, outline = true, font = "ClearFont", textsize = 12, bigscale = 1.3 },
text2 = { type = "StaticText", point="CENTER", x=0, y=-10, font = config.defaultFont, textsize = 10, effect = "NONE" },
text3 = { type = "Text", point="TOPLEFT", x=2, y=0, font = config.defaultFont, textsize = 9, effect = "NONE" },
incomingCastIcon = { type = "ProgressIcon", width = 18, height = 18, point = "TOPLEFT", x = -3, y = 3, alpha = 1, font = config.defaultFont, textsize = 12, outline = false, edge = false },
debuffIcons = { type = "DebuffIconArray", width = 13, height = 13, point = "BOTTOMLEFT", x = 0, y = 0, style = "STRIP_RIGHT", animdir = "LEFT", alpha = 1, growth = "UP", max = 4, edge = true, outline = true, font = config.defaultFont, textsize = 12, bigscale = 1.3 },
-- bossdebuff = { type = "Indicator", width = 13, height = 13, point = "BOTTOMLEFT", x = 0, y = -0, },
statusIcon = { type = "Texture", width = 20, height = 20, point = "CENTER", x = 0, y = 14, texture = nil, rotation = 0, zorder = 1, alpha = 1, blendmode = "BLEND", disableOverrides = false },
roleIcon = { type = "Texture", width = 13, height = 13, point = "BOTTOMLEFT", x = -8, y = -8, texture = nil, rotation = 0, zorder = 1, alpha = 1, blendmode = "BLEND", disableOverrides = false },
Expand Down
20 changes: 11 additions & 9 deletions frame.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
local _, helpers = ...
local Aptechka = Aptechka

local config = AptechkaDefaultConfig

local pixelperfect = helpers.pixelperfect

local LSM = LibStub("LibSharedMedia-3.0")

LSM:Register("statusbar", "Gradient", [[Interface\AddOns\Aptechka\gradient.tga]])
LSM:Register("font", "ClearFont", [[Interface\AddOns\Aptechka\ClearFont.ttf]], GetLocale() ~= "enUS" and 15)
LSM:Register("font", "AlegreyaSans-Medium", [[Interface\AddOns\Aptechka\AlegreyaSans-Medium.ttf]], GetLocale() ~= "enUS" and 15)

local isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC

Expand Down Expand Up @@ -1109,7 +1111,7 @@ Aptechka.Widget.IndicatorArray.Reconf = Aptechka.Widget.BarArray.Reconf
----------------------------------------------------------

Aptechka.Widget.IconArray = {}
Aptechka.Widget.IconArray.default = { type = "IconArray", width = 15, height = 15, point = "TOPRIGHT", x = 0, y = 0, alpha = 1, font = "ClearFont", textsize = 10, outline = true, edge = true, growth = "LEFT", max = 3 }
Aptechka.Widget.IconArray.default = { type = "IconArray", width = 15, height = 15, point = "TOPRIGHT", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 10, outline = true, edge = true, growth = "LEFT", max = 3 }
function Aptechka.Widget.IconArray.Create(parent, popts, gopts)
local opts = InheritGlobalOptions(popts, gopts)
return CreateArrayHeader("Icon", parent, opts.point, opts.x, opts.y, opts, opts.growth, opts.max)
Expand Down Expand Up @@ -1328,7 +1330,7 @@ end
AptechkaDefaultConfig.GridSkin_CreateIcon = CreateIcon

Aptechka.Widget.Icon = {}
Aptechka.Widget.Icon.default = { type = "Icon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = "ClearFont", textsize = 12, outline = true, edge = true }
Aptechka.Widget.Icon.default = { type = "Icon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 12, outline = true, edge = true }
function Aptechka.Widget.Icon.Create(parent, popts, gopts)
local opts = InheritGlobalOptions(popts, gopts)
return CreateIcon(parent, opts.width, opts.height, opts.alpha, opts.point, parent, opts.point, opts.x, opts.y, opts.font, opts.textsize, opts.outline, opts.edge)
Expand All @@ -1344,7 +1346,7 @@ function Aptechka.Widget.Icon.Reconf(parent, f, popts, gopts)
f:SetPoint(opts.point, parent, opts.point, opts.x, opts.y)
f:SetAlpha(opts.alpha)

local fontName = opts.font or "ClearFont"
local fontName = opts.font or config.defaultFont
local font = LSM:Fetch("font", fontName)
local flags = opts.effect == "OUTLINE" and "OUTLINE"
if opts.effect == "SHADOW" then
Expand Down Expand Up @@ -1547,7 +1549,7 @@ local function CreateDebuffIcon(parent, width, height, alpha, point, frame, to,
return icon
end
Aptechka.Widget.DebuffIcon = {}
Aptechka.Widget.DebuffIcon.default = { type = "DebuffIcon", width = 13, height = 13, point = "CENTER", x = 0, y = 0, alpha = 1, style = "STRIP_RIGHT", animdir = "LEFT", font = "ClearFont", textsize = 12, edge = false }
Aptechka.Widget.DebuffIcon.default = { type = "DebuffIcon", width = 13, height = 13, point = "CENTER", x = 0, y = 0, alpha = 1, style = "STRIP_RIGHT", animdir = "LEFT", font = config.defaultFont, textsize = 12, edge = false }
function Aptechka.Widget.DebuffIcon.Create(parent, popts, gopts)
local opts = InheritGlobalOptions(popts, gopts)
local icon = CreateDebuffIcon(parent, opts.width, opts.height, opts.alpha, opts.point, parent, opts.point, opts.x, opts.y, opts.font, opts.textsize, opts.outline, opts.edge)
Expand Down Expand Up @@ -1676,7 +1678,7 @@ local function CreateProgressIcon(parent, width, height, alpha, point, frame, to
end

Aptechka.Widget.ProgressIcon = {}
Aptechka.Widget.ProgressIcon.default = { type = "ProgressIcon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = "ClearFont", textsize = 12, outline = false, edge = false }
Aptechka.Widget.ProgressIcon.default = { type = "ProgressIcon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 12, outline = false, edge = false }
function Aptechka.Widget.ProgressIcon.Create(parent, popts, gopts)
local opts = InheritGlobalOptions(popts, gopts)
return CreateProgressIcon(parent, opts.width, opts.height, opts.alpha, opts.point, parent, opts.point, opts.x, opts.y, opts.font, opts.textsize, opts.outline, opts.edge)
Expand Down Expand Up @@ -1940,10 +1942,10 @@ end
AptechkaDefaultConfig.GridSkin_CreateTextTimer = CreateTextTimer

Aptechka.Widget.Text = {}
Aptechka.Widget.Text.default = { type = "Text", point = "TOPLEFT", x = 0, y = 0, --[[justify = "LEFT",]] font = "ClearFont", textsize = 13, effect = "NONE" }
Aptechka.Widget.Text.default = { type = "Text", point = "TOPLEFT", x = 0, y = 0, --[[justify = "LEFT",]] font = config.defaultFont, textsize = 13, effect = "NONE" }
function Aptechka.Widget.Text.Create(parent, popts, gopts)
local opts = InheritGlobalOptions(popts, gopts)
local font = LSM:Fetch("font", opts.font) or LSM:Fetch("font", "ClearFont")
local font = LSM:Fetch("font", opts.font) or LSM:Fetch("font", config.defaultFont)
local flags = opts.effect == "OUTLINE" and "OUTLINE"
local text = CreateTextTimer(parent, opts.point, parent, opts.point, opts.x, opts.y, opts.justify, opts.textsize, font, flags)
if opts.effect == "SHADOW" then
Expand All @@ -1962,7 +1964,7 @@ function Aptechka.Widget.Text.Reconf(parent, f, popts, gopts)
f.text:ClearAllPoints()
f.text:SetPoint(opts.point, parent, opts.point, opts.x, opts.y)
-- f.text:SetJustifyH(opts.justify:upper())
local font = LSM:Fetch("font", opts.font) or LSM:Fetch("font", "ClearFont")
local font = LSM:Fetch("font", opts.font) or LSM:Fetch("font", config.defaultFont)
local flags = opts.effect == "OUTLINE" and "OUTLINE"
if opts.effect == "SHADOW" then
f.text:SetShadowOffset(1,-1)
Expand Down
40 changes: 39 additions & 1 deletion migrations.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local addonName, helpers = ...

do
local CURRENT_DB_VERSION = 9
local CURRENT_DB_VERSION = 10
function Aptechka:DoMigrations(db)
if not next(db) or db.DB_VERSION == CURRENT_DB_VERSION then -- skip if db is empty or current
db.DB_VERSION = CURRENT_DB_VERSION
Expand Down Expand Up @@ -332,6 +332,31 @@ do
db.DB_VERSION = 9
end

if db.DB_VERSION == 9 then
local function SwapFont(opts, widgetName, profileName)
if opts.font and opts.font == "ClearFont" then
opts.font = "AlegreyaSans-Medium"
end
end
local func = SwapFont
if db and db.global and db.global.widgetConfig then
for wname, opts in pairs(db.global.widgetConfig) do
func(opts, wname, "global")
end
end
if db.profiles then
for profileName, profile in pairs(db.profiles) do
if profile.widgetConfig then
for wname, opts in pairs(profile.widgetConfig) do
func(opts, wname, profileName)
end
end
end
end

db.DB_VERSION = 10
end

db.DB_VERSION = CURRENT_DB_VERSION
end
end
Expand Down Expand Up @@ -362,6 +387,19 @@ function Aptechka:ForAllCustomWidgets(func)
end
end

function Aptechka:ForAllWidgets(func)
for wname, opts in pairs(self.db.global.widgetConfig) do
func(opts, wname, "global")
end
for profileName, profile in pairs(self.db.profiles) do
if profile.widgetConfig then
for wname, opts in pairs(profile.widgetConfig) do
func(opts, wname, profileName)
end
end
end
end

function Aptechka:ForAllCustomStatuses(func, searchAllClasses)
local list = Aptechka.GetWidgetList()

Expand Down

0 comments on commit bb4da08

Please sign in to comment.