addon/Quests/Frames/OptionsFrame.lua

157 lines
7.9 KiB
Lua
Executable file

function CzechQuestsAddon:InitializeOptions()
CzechQuestsAddon.optionsFrame = {};
CzechQuestsAddon.optionsFrame = Settings.RegisterVerticalLayoutCategory("CzechQuests")
-- Add DEBUG checkbox
local debugCheckbox = Settings.RegisterAddOnSetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__DEBUG_MODE",
"DEBUG_MODE",
CzechQuestsAddon_Store.config,
type(CzechQuestsAddon_Store.config.DEBUG_MODE),
"Enable DEBUG mode",
CzechQuestsAddon_Store.config.DEBUG_MODE
)
Settings.CreateCheckbox(CzechQuestsAddon.optionsFrame, debugCheckbox)
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
-- Add DARK mode checkbox
local darkModeCheckbox = Settings.RegisterAddOnSetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__DARK_MODE",
"DARK_MODE",
CzechQuestsAddon_Store.config,
type(CzechQuestsAddon_Store.config.DARK_MODE),
"Use dark mode",
CzechQuestsAddon_Store.config.DARK_MODE
)
Settings.CreateCheckbox(CzechQuestsAddon.optionsFrame, darkModeCheckbox)
end
-- 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)
-- Add slider for change secondary header font size
local textureAlphaSlider = Settings.RegisterProxySetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__TRANSLATION_FRAME_TEXTURE_ALPHA",
type(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA),
"Texture transparency",
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA,
function()
return CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA
end,
function(value)
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA = value
end
)
local textureAlphaSliderOptions = Settings.CreateSliderOptions(10, 100, 10)
textureAlphaSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
Settings.CreateSlider(CzechQuestsAddon.optionsFrame, textureAlphaSlider, textureAlphaSliderOptions)
-- Store it into Addon options
Settings.RegisterAddOnCategory(CzechQuestsAddon.optionsFrame)
end