addon/Quests/Frames/OptionsFrame.lua

70 lines
2.8 KiB
Lua
Executable file

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()
end)
checkbox:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -8)
checkbox:SetChecked(CzechQuestsAddon.options[optionKey])
return checkbox
end
function CzechQuestsAddon:InitializeOptions()
CzechQuestsAddon.optionsFrame = {};
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
local frame
-- Create Frame
CzechQuestsAddon.optionsFrame = CreateFrame("Frame", "CzechQuestsOptionsPanel", UIParent)
CzechQuestsAddon.optionsFrame.name = "CzechQuests"
-- Create frame title
local title = CzechQuestsAddon.optionsFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("CzechQuests")
-- Add DEBUG checkbox
local debugModeCheckbox = CreateCheckbox(title, CzechQuestsAddon.optionsFrame, "Enable DEBUG mode", "DEBUG_MODE")
debugModeCheckbox:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -16)
-- Add Dark Mode checkbox
local darkModeCheckbox = CreateCheckbox(debugModeCheckbox, CzechQuestsAddon.optionsFrame, "Dark mode (require reload)", "DARK_MODE")
darkModeCheckbox:SetPoint("TOPLEFT", debugModeCheckbox, "BOTTOMLEFT", 0, -4)
-- Store it into Addon options
InterfaceOptions_AddCategory(CzechQuestsAddon.optionsFrame)
else
CzechQuestsAddon.optionsFrame = Settings.RegisterVerticalLayoutCategory("CzechQuests")
-- Add DEBUG checkbox
local debugCheckbox = Settings.RegisterAddOnSetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__DEBUG_MODE",
"DEBUG_MODE",
CzechQuestsAddon.options,
type(CzechQuestsAddon.options.DEBUG_MODE),
"Enable DEBUG mode",
CzechQuestsAddon.options.DEBUG_MODE
)
Settings.CreateCheckbox(CzechQuestsAddon.optionsFrame, debugCheckbox)
-- Add DARK mode checkbox
local darkModeCheckbox = Settings.RegisterAddOnSetting(
CzechQuestsAddon.optionsFrame,
"CzechQuestsAddon__DARK_MODE",
"DARK_MODE",
CzechQuestsAddon.options,
type(CzechQuestsAddon.options.DARK_MODE),
"Use dark mode",
CzechQuestsAddon.options.DARK_MODE
)
Settings.CreateCheckbox(CzechQuestsAddon.optionsFrame, darkModeCheckbox)
-- Store it into Addon options
Settings.RegisterAddOnCategory(CzechQuestsAddon.optionsFrame)
end
end
-- initialize options frame
CzechQuestsAddon:InitializeOptions()