Skip to content

Commit

Permalink
Close #114: Support more font customization (#121)
Browse files Browse the repository at this point in the history
* Close #114: Support more font customization

* Fix trunk, fix tests
  • Loading branch information
Mctalian authored Sep 20, 2024
1 parent 4ff2d07 commit dd68483
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ externals:
Libs/AceTimer-3.0: https://repos.wowace.com/wow/ace3/trunk/AceTimer-3.0
Libs/AceLocale-3.0: https://repos.wowace.com/wow/ace3/trunk/AceLocale-3.0
Libs/AceBucket-3.0: https://repos.wowace.com/wow/ace3/trunk/AceBucket-3.0
Libs/LibSharedMedia-3.0: https://repos.curseforge.com/wow/libsharedmedia-3-0/trunk/LibSharedMedia-3.0
Libs/AceGUI-3.0-SharedMediaWidgets: https://repos.curseforge.com/wow/ace-gui-3-0-shared-media-widgets/trunk/AceGUI-3.0-SharedMediaWidgets

enable-nolib-creation: yes

Expand Down
6 changes: 6 additions & 0 deletions .release/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3387,6 +3387,12 @@ if [[ -z $skip_upload && -n $archive && -s $archive ]]; then
fi
fi

if [[ ${LOCAL_FLAG} == true ]]; then
if [[ -f ${wowi_changelog} ]]; then
rm -f "${wowi_changelog}" 2>/dev/null
fi
fi

# All done.

echo
Expand Down
Binary file added Fonts/BAR_SADY_Variable.ttf
Binary file not shown.
9 changes: 8 additions & 1 deletion LootDisplay/LootDisplay.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local LootDisplay = G_RLF.RLF:NewModule("LootDisplay", "AceBucket-3.0", "AceEvent-3.0")

local lsm = LibStub("LibSharedMedia-3.0")

-- Private method declaration
local processRow
local processFromQueue
Expand Down Expand Up @@ -162,7 +164,12 @@ end
G_RLF.LootDisplay = LootDisplay

getTextWidth = function(text)
tempFontString:SetFontObject(G_RLF.db.global.font)
if G_RLF.db.global.useFontObjects or not G_RLF.db.global.fontFace then
tempFontString:SetFontObject(G_RLF.db.global.font)
else
local fontPath = lsm:Fetch(lsm.MediaType.FONT, G_RLF.db.global.fontFace)
tempFontString:SetFont(fontPath, G_RLF.db.global.fontSize, G_RLF.defaults.global.fontFlags)
end
tempFontString:SetText(text)
local width = tempFontString:GetStringWidth()
return width
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LootDisplayRowMixin = {}

local ae = LibStub("AceEvent-3.0")
local lsm = LibStub("LibSharedMedia-3.0")

local Masque = LibStub and LibStub("Masque", true)
local iconGroup = Masque and Masque:Group(G_RLF.addonName)
Expand Down Expand Up @@ -34,7 +35,12 @@ local function rowIcon(row, icon)
end

local function rowAmountText(row, icon)
row.AmountText:SetFontObject(G_RLF.db.global.font)
if G_RLF.db.global.useFontObjects or not G_RLF.db.global.fontFace then
row.AmountText:SetFontObject(G_RLF.db.global.font)
else
local fontPath = lsm:Fetch(lsm.MediaType.FONT, G_RLF.db.global.fontFace)
row.AmountText:SetFont(fontPath, G_RLF.db.global.fontSize, G_RLF.defaults.global.fontFlags)
end
local anchor = "LEFT"
local iconAnchor = "RIGHT"
local xOffset = G_RLF.db.global.iconSize / 2
Expand Down
2 changes: 2 additions & 0 deletions RPGLootFeed.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
local addonName = G_RLF.addonName
local acd = LibStub("AceConfigDialog-3.0")
local lsm = LibStub("LibSharedMedia-3.0")
RLF = G_RLF.RLF

function RLF:OnInitialize()
G_RLF.db = LibStub("AceDB-3.0"):New(G_RLF.dbName, G_RLF.defaults, true)
LibStub("AceConfig-3.0"):RegisterOptionsTable(addonName, G_RLF.options)
lsm:Register(lsm.MediaType.FONT, "BAR SADY Regular", "Interface\\AddOns\\RPGLootFeed\\Fonts\\BAR_SADY_Variable.ttf")
self:Hook(acd, "Open", "OnOptionsOpen")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterChatCommand("rlf", "SlashCommand")
Expand Down
86 changes: 85 additions & 1 deletion config/Styling.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
local Styling = {}

local lsm = LibStub("LibSharedMedia-3.0")

G_RLF.defaults.global.leftAlign = true
G_RLF.defaults.global.growUp = true
G_RLF.defaults.global.rowBackgroundGradientStart = { 0.1, 0.1, 0.1, 0.8 } -- Default to dark grey with 80% opacity
G_RLF.defaults.global.rowBackgroundGradientEnd = { 0.1, 0.1, 0.1, 0 } -- Default to dark grey with 0% opacity
G_RLF.defaults.global.disableRowHighlight = false
G_RLF.defaults.global.useFontObjects = true
G_RLF.defaults.global.font = "GameFontNormalSmall"
G_RLF.defaults.global.fontFace = "Friz Quadrata TT"
G_RLF.defaults.global.fontSize = 10
G_RLF.defaults.global.fontFlags = ""

G_RLF.options.args.styles = {
type = "group",
Expand Down Expand Up @@ -59,15 +65,59 @@ G_RLF.options.args.styles = {
set = "SetRowHighlight",
order = 5,
},
useFontObjects = {
type = "toggle",
name = G_RLF.L["Use Font Objects"],
desc = G_RLF.L["UseFontObjectsDesc"],
width = "double",
get = "GetUseFontObjects",
set = "SetUseFontObjects",
order = 6,
},
font = {
type = "select",
name = G_RLF.L["Font"],
desc = G_RLF.L["FontDesc"],
disabled = "DisableFontObjects",
width = "double",
values = "GetFonts",
get = "GetRowFont",
set = "SetRowFont",
order = 6,
order = 7,
},
customFonts = {
type = "group",
name = G_RLF.L["Custom Fonts"],
desc = G_RLF.L["CustomFontsDesc"],
disabled = "DisableCustomFonts",
inline = true,
order = 8,
args = {
font = {
type = "select",
dialogControl = "LSM30_Font",
name = G_RLF.L["Font Face"],
desc = G_RLF.L["FontFaceDesc"],
width = "double",
values = lsm:HashTable(lsm.MediaType.FONT),
get = "GetRowFontFace",
set = "SetRowFontFace",
order = 1,
},
fontSize = {
type = "range",
name = G_RLF.L["Font Size"],
desc = G_RLF.L["FontSizeDesc"],
softMin = 6,
softMax = 24,
min = 1,
max = 72,
bigStep = 1,
get = "GetRowFontSize",
set = "SetRowFontSize",
order = 2,
},
},
},
},
}
Expand Down Expand Up @@ -135,6 +185,40 @@ function Styling:SetRowHighlight(info, value)
G_RLF.db.global.disableRowHighlight = value
end

function Styling:GetUseFontObjects(info, value)
return G_RLF.db.global.useFontObjects
end

function Styling:SetUseFontObjects(info, value)
G_RLF.db.global.useFontObjects = value
end

function Styling:DisableFontObjects(info, value)
return G_RLF.db.global.useFontObjects == false
end

function Styling:DisableCustomFonts(info, value)
return G_RLF.db.global.useFontObjects == true
end

function Styling:GetRowFontFace(info, value)
return G_RLF.db.global.fontFace
end

function Styling:SetRowFontFace(info, value)
G_RLF.db.global.fontFace = value
G_RLF.LootDisplay:UpdateRowStyles()
end

function Styling:GetRowFontSize(info, value)
return G_RLF.db.global.fontSize
end

function Styling:SetRowFontSize(info, value)
G_RLF.db.global.fontSize = value
G_RLF.LootDisplay:UpdateRowStyles()
end

function Styling:SetRowFont(info, value)
G_RLF.db.global.font = value
G_RLF.LootDisplay:UpdateRowStyles()
Expand Down
2 changes: 2 additions & 0 deletions embeds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
<Include file="Libs\AceTimer-3.0\AceTimer-3.0.xml"/>
<Include file="Libs\AceLocale-3.0\AceLocale-3.0.xml"/>
<Include file="Libs\AceBucket-3.0\AceBucket-3.0.xml"/>
<Include file="Libs\LibSharedMedia-3.0\lib.xml"/>
<Include file="Libs\AceGUI-3.0-SharedMediaWidgets\widget.xml"/>
</Ui>
8 changes: 8 additions & 0 deletions locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,16 @@ L["Background Gradient End"] = true
L["GradientEndDesc"] = "The end color of the row background gradient."
L["Disable Row Highlight"] = true
L["DisableRowHighlightDesc"] = "If checked, don't highlight a row when you loot the same item again and the quanity is updated."
L["Use Font Objects"] = true
L["UseFontObjectsDesc"] = "If checked, use a font object to determine font face and font size."
L["Font"] = true
L["FontDesc"] = "The font object for the loot text."
L["Custom Fonts"] = true
L["CustomFontsDesc"] = "Customize the font face, font sizing, and font flags to personalize the loot feed."
L["Font Face"] = true
L["FontFaceDesc"] = "The style of the text that will show in the loot feed."
L["Font Size"] = true
L["FontSizeDesc"] = "The size of the loot feed text in \"points\"."

-- ConfigOptions - Timing Group
L["Timing"] = true
Expand Down
1 change: 1 addition & 0 deletions spec/LootDisplay/LootDisplay_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe("LootDisplay module", function()
before_each(function()
-- Define the global G_RLF
common_stubs.setup_G_RLF(spy)
_G.LibStub = function() end
-- Load the list module before each test
LootDisplayModule = require("LootDisplay.LootDisplay")
end)
Expand Down
15 changes: 15 additions & 0 deletions spec/config/Styling_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ describe("Styling module", function()
DISABLE_GROUP_LOOT = 4,
},
}
_G.LibStub = function(lib)
if lib == "LibSharedMedia-3.0" then
local l = {}
function l:HashTable()
return {
["Test"] = "Test",
}
end
l.MediaType = {
["FONT"] = "font",
}
return l
end
return nil
end
-- Load the list module before each test
dofile("config/Styling.lua")
end)
Expand Down

0 comments on commit dd68483

Please sign in to comment.