Add new settings to change font

This commit is contained in:
Roman Jaroš 2024-08-25 11:50:46 +02:00
parent f09ec0c878
commit ed20b006ec
11 changed files with 262 additions and 73 deletions

58
CzechQuests.lua Normal file
View file

@ -0,0 +1,58 @@
-- Namespace
CzechQuestsAddon = {};
CzechQuestsAddon.fontPath = "Interface\\AddOns\\CzechQuests\\Fonts\\"
-- Define data
CzechQuestsAddon.data = {};
CzechQuestsAddon.data.quest = {};
CzechQuestsAddon.data.item = {};
-- Event handler frame
local frame = CreateFrame("Frame")
-- OnEvent function for event processing
local function OnEvent(self, event, addonName, ...)
if event == "ADDON_LOADED" and addonName == 'CzechQuests' then
-- Initialize the SavedVariables if it doesn't exist
if not CzechQuestsAddon_Store then
CzechQuestsAddon_Store = {}
end
if not CzechQuestsAddon_Store.config then
CzechQuestsAddon_Store.config = {}
end
if not CzechQuestsAddon_Store.config.DEBUG_MODE then
CzechQuestsAddon_Store.config.DEBUG_MODE = false;
end
if not CzechQuestsAddon_Store.config.DARK_MODE then
CzechQuestsAddon_Store.config.DARK_MODE = false;
end
if not CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE then
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE = 18;
end
if not CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE then
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE = 16;
end
if not CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE then
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE = 14;
end
if not CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY then
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY = 'morpheus_cz.ttf';
end
if not CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY then
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY = 'frizquadratatt_cz.ttf';
end
-- Initialize Options
CzechQuestsAddon:InitializeOptions()
-- Initialize Quests
CzechQuestsAddon:InitializeTranslations()
-- Unregister the ADDON_LOADED event after handling it
self:UnregisterEvent("ADDON_LOADED")
end
end
-- Register the event
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", OnEvent)

View file

@ -3,9 +3,9 @@
## Notes: Addon displays texts of quests in Czech language as tooltip
## Author: Roman Jaroš
## Version: 0.1.9
## SavedVariables: CzechQuestsAddon.options
## SavedVariables: CzechQuestsAddon_Store
Init.lua
CzechQuests.lua
Quests/Data/warbands.lua
Quests/Data/upgrade-system.lua

View file

@ -3,9 +3,9 @@
## Notes: Addon displays texts of quests in Czech language as tooltip
## Author: Roman Jaroš
## Version: 0.1.4
## SavedVariables: CzechQuestsAddon.options
## SavedVariables: CzechQuestsAddon_Store
Init.lua
CzechQuests.lua
Quests/Data/kalimdor/thunder-bluff.lua
Quests/Data/kalimdor/teldrassil.lua

BIN
Fonts/caveat.ttf Normal file

Binary file not shown.

BIN
Fonts/quicksand.ttf Normal file

Binary file not shown.

View file

@ -1,14 +0,0 @@
-- Namespace
CzechQuestsAddon = {};
-- Define data
CzechQuestsAddon.data = {};
CzechQuestsAddon.data.quest = {};
CzechQuestsAddon.data.item = {};
-- Define options
CzechQuestsAddon.options = {}
CzechQuestsAddon.options = {
DEBUG_MODE = false,
DARK_MODE = false
}

View file

@ -2,10 +2,10 @@ local function CreateCheckbox(parent, frame, text, optionKey)
local checkbox = CreateFrame("CheckButton", nil, frame, "InterfaceOptionsCheckButtonTemplate")
checkbox.Text:SetText(text)
checkbox:SetScript("OnClick", function(self)
CzechQuestsAddon.options[optionKey] = self:GetChecked()
CzechQuestsAddon_Store.config[optionKey] = self:GetChecked()
end)
checkbox:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -8)
checkbox:SetChecked(CzechQuestsAddon.options[optionKey])
checkbox:SetChecked(CzechQuestsAddon_Store.config[optionKey])
return checkbox
end
@ -42,10 +42,10 @@ function CzechQuestsAddon:InitializeOptions()
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__DEBUG_MODE",
"DEBUG_MODE",
CzechQuestsAddon.options,
type(CzechQuestsAddon.options.DEBUG_MODE),
CzechQuestsAddon_Store.config,
type(CzechQuestsAddon_Store.config.DEBUG_MODE),
"Enable DEBUG mode",
CzechQuestsAddon.options.DEBUG_MODE
CzechQuestsAddon_Store.config.DEBUG_MODE
)
Settings.CreateCheckbox(CzechQuestsAddon.optionsFrame, debugCheckbox)
@ -54,17 +54,120 @@ function CzechQuestsAddon:InitializeOptions()
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__DARK_MODE",
"DARK_MODE",
CzechQuestsAddon.options,
type(CzechQuestsAddon.options.DARK_MODE),
CzechQuestsAddon_Store.config,
type(CzechQuestsAddon_Store.config.DARK_MODE),
"Use dark mode",
CzechQuestsAddon.options.DARK_MODE
CzechQuestsAddon_Store.config.DARK_MODE
)
Settings.CreateCheckbox(CzechQuestsAddon.optionsFrame, darkModeCheckbox)
-- define FontOptions
local function GetFontOptions()
local container = Settings.CreateControlTextContainer()
container:Add("morpheus_cz.ttf", "Morpheus (cz)")
container:Add("frizquadratatt_cz.ttf", "Friz Quadrata TT (cz)")
container:Add("quicksand.ttf", "Quicksand")
container:Add("caveat.ttf", "Caveat")
return container:GetData()
end
-- Add header font dropdown menu
local headerFontFamilyDropdown = Settings.RegisterProxySetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__TRANSLATION_FRAME_HEADER_FONT_FAMILY",
type(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY),
"Header font",
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY,
function()
return CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY
end,
function(value)
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY = value
CzechQuestsAddon:UpdateTranslationFrameFontSettings()
end
)
Settings.CreateDropdown(CzechQuestsAddon.optionsFrame, headerFontFamilyDropdown, GetFontOptions)
-- Add text font dropdown menu
local textFontFamilyDropdown = Settings.RegisterProxySetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__TRANSLATION_FRAME_TEXT_FONT_FAMILY",
type(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY),
"Text font",
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY,
function()
return CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY
end,
function(value)
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY = value
CzechQuestsAddon:UpdateTranslationFrameFontSettings()
end
)
Settings.CreateDropdown(CzechQuestsAddon.optionsFrame, textFontFamilyDropdown, GetFontOptions)
-- Add slider for change primary header font size
local primaryHeaderFontSizeSlider = Settings.RegisterProxySetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE",
type(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE),
"Quest title size",
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE,
function()
return CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE
end,
function(value)
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE = value
CzechQuestsAddon:UpdateTranslationFrameFontSettings()
end
)
local primaryHeaderFontSizeSliderOptions = Settings.CreateSliderOptions(10, 30, 1)
primaryHeaderFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
Settings.CreateSlider(CzechQuestsAddon.optionsFrame, primaryHeaderFontSizeSlider, primaryHeaderFontSizeSliderOptions)
-- Add slider for change secondary header font size
local secondaryHeaderFontSizeSlider = Settings.RegisterProxySetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE",
type(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE),
"Secondary title size",
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE,
function()
return CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE
end,
function(value)
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE = value
CzechQuestsAddon:UpdateTranslationFrameFontSettings()
end
)
local secondaryHeaderFontSizeSliderOptions = Settings.CreateSliderOptions(10, 30, 1)
secondaryHeaderFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
Settings.CreateSlider(CzechQuestsAddon.optionsFrame, secondaryHeaderFontSizeSlider, secondaryHeaderFontSizeSliderOptions)
-- Add slider for change secondary header font size
local textFontSizeSlider = Settings.RegisterProxySetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__TRANSLATION_FRAME_TEXT_FONT_SIZE",
type(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE),
"Text size",
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE,
function()
return CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE
end,
function(value)
local currentFont, _, currentFlags = {}
currentFont, _, currentFlags = CzechQuestsAddon.translationFrame.primaryText:GetFont()
CzechQuestsAddon.translationFrame.primaryText:SetFont(currentFont, value, currentFlags)
currentFont, _, currentFlags = CzechQuestsAddon.translationFrame.secondaryText:GetFont()
CzechQuestsAddon.translationFrame.secondaryText:SetFont(currentFont, value, currentFlags)
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE = value
end
)
local textFontSizeSliderOptions = Settings.CreateSliderOptions(10, 30, 1)
textFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
Settings.CreateSlider(CzechQuestsAddon.optionsFrame, textFontSizeSlider, textFontSizeSliderOptions)
-- Store it into Addon options
Settings.RegisterAddOnCategory(CzechQuestsAddon.optionsFrame)
end
end
-- initialize options frame
CzechQuestsAddon:InitializeOptions()

View file

@ -1,6 +1,3 @@
local headerFont = "Interface\\AddOns\\CzechQuests\\morpheus_cz.ttf"
local textFont = "Interface\\AddOns\\CzechQuests\\frizquadratatt_cz.ttf"
function CzechQuestsAddon:CreateTranslationFrame()
local frame = {};
@ -24,10 +21,30 @@ function CzechQuestsAddon:CreateTranslationFrame()
CzechQuestsAddon:SetTextureFromSettings(frame)
end
frame.primaryHeader = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationPrimaryHeader", headerFont, 18)
frame.secondaryHeader = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationSecondaryHeader", headerFont, 16)
frame.primaryText = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationPrimaryText", textFont, 14)
frame.secondaryText = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationSecondaryText", textFont, 14)
frame.primaryHeader = CzechQuestsAddon:CreateTranslationFont(
frame,
"CzechQuestTranslationPrimaryHeader",
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE
)
frame.secondaryHeader = CzechQuestsAddon:CreateTranslationFont(
frame,
"CzechQuestTranslationSecondaryHeader",
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE
)
frame.primaryText = CzechQuestsAddon:CreateTranslationFont(
frame,
"CzechQuestTranslationPrimaryText",
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE
)
frame.secondaryText = CzechQuestsAddon:CreateTranslationFont(
frame,
"CzechQuestTranslationSecondaryText",
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE
)
return frame;
end
@ -50,7 +67,7 @@ end
function CzechQuestsAddon:SetTextureFromSettings(frame)
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
if CzechQuestsAddon.options.DARK_MODE then
if CzechQuestsAddon_Store.config.DARK_MODE then
frame:SetBackdropColor(0, 0, 0, 1)
frame.texture:SetColorTexture(0, 0, 0, 1)
frame.primaryHeader:SetTextColor(255, 255, 255, 1)
@ -68,3 +85,26 @@ function CzechQuestsAddon:SetTextureFromSettings(frame)
end
end
end
function CzechQuestsAddon:UpdateTranslationFrameFontSettings()
CzechQuestsAddon.translationFrame.primaryHeader:SetFont(
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_PRIMARY_HEADER_FONT_SIZE,
nil
)
CzechQuestsAddon.translationFrame.secondaryHeader:SetFont(
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_HEADER_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_SECONDARY_HEADER_FONT_SIZE,
nil
)
CzechQuestsAddon.translationFrame.primaryText:SetFont(
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE,
nil
)
CzechQuestsAddon.translationFrame.secondaryText:SetFont(
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_FAMILY,
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXT_FONT_SIZE,
nil
)
end

View file

@ -75,7 +75,7 @@ function CzechQuestsAddon:ShowQuestTranslation(event)
local questId = select(8, GetQuestLogTitle(questIndex))
local questData = CzechQuestsAddon:GetData("quest", questId)
if questData then
local suffix = CzechQuestsAddon.options.DEBUG_MODE and " (" .. questId .. ")" or ""
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
local questTitle = questData.title .. suffix
CzechQuestsAddon:ShowTranslationFrame(
questTitle,
@ -102,7 +102,7 @@ function CzechQuestsAddon:ShowQuestTranslation(event)
-- show translation frame
local questData = CzechQuestsAddon:GetData("quest", questId)
if questData then
local suffix = CzechQuestsAddon.options.DEBUG_MODE and " (" .. questId .. ")" or ""
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
local questTitle = questData.title .. suffix
local xOffset = hasModel and 210 or 0
CzechQuestsAddon:ShowTranslationFrame(
@ -132,7 +132,7 @@ function CzechQuestsAddon:ShowQuestTranslation(event)
local questData = CzechQuestsAddon:GetData("quest", questId)
if questData then
CzechQuestsAddon.translationFrame:Show()
local suffix = CzechQuestsAddon.options.DEBUG_MODE and " (" .. questId .. ")" or ""
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
local questTitle = questData.title .. suffix
local xOffset = hasModel and 210 or 0
if event == "QUEST_PROGRESS" then
@ -213,6 +213,7 @@ local function SetHoverScripts(frame)
end
end
function CzechQuestsAddon:InitializeTranslations()
-- create translation frame
CzechQuestsAddon.translationFrame = CzechQuestsAddon:CreateTranslationFrame()
@ -252,3 +253,4 @@ CzechQuestsAddon.translationFrame:SetScript("OnEvent", function(self, event, ...
CzechQuestsAddon:ShowQuestItemTranslation()
end
end)
end