diff --git a/ui/main_options.lua b/ui/main_options.lua
index 53a9b91..fe41795 100644
--- a/ui/main_options.lua
+++ b/ui/main_options.lua
@@ -4,198 +4,105 @@ local O = addonName .. "OptionsPanel"
AutoTurnIn.OptionsPanel = CreateFrame("Frame", O)
AutoTurnIn.OptionsPanel.name=addonName
local OptionsPanel = AutoTurnIn.OptionsPanel
-
+-- switch flag. 'false' signals that reset must be made. 'true' allows redraw the screen keeping values
local MakeACopy=true
-- Title
local title = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetText(addonName .." ".. AutoTurnIn.defaults.version)
+
-- Description
local notes = GetAddOnMetadata(addonName, "Notes-" .. GetLocale()) or GetAddOnMetadata(addonName, "Notes")
local subText = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subText:SetText(notes)
+
-- Reset button
local ResetButton = CreateFrame("Button", nil, OptionsPanel, "OptionsButtonTemplate")
ResetButton:SetText(L["resetbutton"])
ResetButton:SetScript("OnClick", function()
ptable.TempConfig = CopyTable(AutoTurnIn.defaults)
-
MakeACopy=false;
AutoTurnIn.RewardPanel.refresh();
AutoTurnIn.OptionsPanel.refresh();
end)
-local function CreateCheckbox(name, marginx, marginy)
- local nm = O..name
- local cb = CreateFrame("CheckButton", nm, OptionsPanel, "OptionsCheckButtonTemplate")
- _G[nm.."Text"]:SetText(L[name])
- cb:SetPoint("TOPLEFT", OptionsPanel, "BOTTOMLEFT", marginx, marginy)
-
- cb:SetScript("OnClick", function(self)
- ptable.TempConfig[name] = self:GetChecked() == 1
- end)
- return cb
+local function newCheckbox(name, caption, config)
+ local cb = CreateFrame("CheckButton", "$parent"..name, OptionsPanel, "OptionsCheckButtonTemplate")
+ _G[cb:GetName().."Text"]:SetText(caption and caption or name)
+ cb:SetScript("OnClick", function(self)
+ ptable.TempConfig[config] = self:GetChecked() == 1
+ end)
+ return cb
end
--- 'Enable' CheckBox
-local Enable = CreateCheckbox("enabled", 0, -14)
-
--- Quest types to handle
-local QuestLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
-QuestLabel:SetText(L["questTypeLabel"])
-local QuestConst = {L["questTypeAll"], L["questTypeList"]}
-local QuestDropDown = CreateFrame("Frame", O.."QuestDropDown", OptionsPanel, "UIDropDownMenuTemplate")
-UIDropDownMenu_Initialize(QuestDropDown, function (self, level)
- for k, v in ipairs(QuestConst) do
- local info = UIDropDownMenu_CreateInfo()
- info.text, info.value = v, k
- info.func = function(self)
- UIDropDownMenu_SetSelectedID(QuestDropDown, self:GetID())
- ptable.TempConfig.all = (self:GetID() == 1)
- end
- UIDropDownMenu_AddButton(info, level)
- end
-end)
-UIDropDownMenu_SetWidth(QuestDropDown, 200);
-UIDropDownMenu_JustifyText(QuestDropDown, "LEFT")
-
--- DarkmoonTeleport
-local TrivialQuests = CreateFrame("CheckButton", O.."TrivialQuests", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[TrivialQuests:GetName().."Text"]:SetText(L["TrivialQuests"])
-TrivialQuests:SetScript("OnClick", function(self)
- ptable.TempConfig.trivial = self:GetChecked() == 1
-end)
-
--- Tournament loot type
-local TournamentDropDownLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
-TournamentDropDownLabel:SetText(L["tournamentLabel"])
-local TournamentConst = {L["tournamentWrit"], L["tournamentPurse"]};
-local TournamentDropDown = CreateFrame("Frame", O.."TournamentDropDown", OptionsPanel, "UIDropDownMenuTemplate")
-function TournamentDropDown:initialize ()
- for k, v in ipairs(TournamentConst) do
- local info = UIDropDownMenu_CreateInfo()
- info.text, info.value = v, k
- info.func = function(self)
- UIDropDownMenu_SetSelectedID(TournamentDropDown, self:GetID())
- ptable.TempConfig.tournament = self:GetID()
- end
- UIDropDownMenu_AddButton(info, level)
- end
+local function newDropDown(caption, name, values, config)
+ local label = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
+ label:SetText(caption)
+
+ local dropDown = CreateFrame("Frame", O..name, OptionsPanel, "UIDropDownMenuTemplate")
+ UIDropDownMenu_Initialize(dropDown, function (self, level)
+ for k, v in ipairs(values) do
+ local info = UIDropDownMenu_CreateInfo()
+ info.text, info.value = v, k
+ info.func = function(self)
+ UIDropDownMenu_SetSelectedID(dropDown, self:GetID())
+ ptable.TempConfig[config] = self:GetID()
+ end
+ UIDropDownMenu_AddButton(info, level)
+ end
+ end)
+ UIDropDownMenu_SetWidth(dropDown, 200);
+ UIDropDownMenu_JustifyText(dropDown, "LEFT")
+ label:SetPoint("BOTTOMLEFT", dropDown, "TOPLEFT", 18, 0)
+ return dropDown
end
-UIDropDownMenu_SetWidth(TournamentDropDown, 200);
-UIDropDownMenu_JustifyText(TournamentDropDown, "LEFT")
--- How to loot
-local LootLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
-LootLabel:SetText(L["lootTypeLabel"])
-local LootConst = {L["lootTypeFalse"], L["lootTypeGreed"], L["lootTypeNeed"]}
-local LootDropDown = CreateFrame("Frame", O.."LootDropDown", OptionsPanel, "UIDropDownMenuTemplate")
-UIDropDownMenu_Initialize(LootDropDown, function (self, level)
- for k, v in ipairs(LootConst) do
- local info = UIDropDownMenu_CreateInfo()
- info.text, info.value = v, k
- info.func = function(self)
- UIDropDownMenu_SetSelectedID(LootDropDown, self:GetID())
- ptable.TempConfig.lootreward = self:GetID()
- end
- UIDropDownMenu_AddButton(info, level)
- end
-end)
-UIDropDownMenu_SetWidth(LootDropDown, 200);
-UIDropDownMenu_JustifyText(LootDropDown, "LEFT")
-
--- Teleport to Darkmoon Faire
-local ToDarkMoon= CreateFrame("CheckButton", O.."ToDarkMoon", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[O.."ToDarkMoonText"]:SetText(L["ToDarkmoonLabel"])
-ToDarkMoon:SetScript("OnClick", function(self)
- ptable.TempConfig.todarkmoon = self:GetChecked() == 1
-end)
+-- 'Enable' CheckBox
+local Enable = newCheckbox("enabled", L["enabled"], "enabled")
+-- trivial, so called grayed quests
+local TrivialQuests = newCheckbox("TrivialQuests", L["TrivialQuests"], "trivial")
-- DarkmoonTeleport
-local DarkMoonCannon = CreateFrame("CheckButton", O.."DarkMoonCannon", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[O.."DarkMoonCannonText"]:SetText(L["DarkmoonTeleLabel"])
-DarkMoonCannon:SetScript("OnClick", function(self)
- ptable.TempConfig.darkmoonteleport = self:GetChecked() == 1
-end)
-
+local ToDarkMoon = newCheckbox("ToDarkMoon", L["ToDarkmoonLabel"], "todarkmoon")
+-- Darkmoon Teleport to cannon
+local DarkMoonCannon = newCheckbox("DarkMoonCannon", L["DarkmoonTeleLabel"], "darkmoonteleport")
-- Darkmoon games
-local DarkMoonAutoStart = CreateFrame("CheckButton", O.."DarkMoonAutoStart", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[DarkMoonAutoStart:GetName().."Text"]:SetText(L["DarkmoonAutoLabel"])
-DarkMoonAutoStart:SetScript("OnClick", function(self)
- ptable.TempConfig.darkmoonautostart = self:GetChecked() == 1
-end)
-
+local DarkMoonAutoStart = newCheckbox("DarkMoonAutoStart", L["DarkmoonAutoLabel"], "darkmoonautostart")
-- 'Show Reward Text' CheckBox
-local ShowRewardText = CreateFrame("CheckButton", O.."Reward", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[ShowRewardText:GetName().."Text"]:SetText(L["rewardtext"])
-ShowRewardText:SetScript("OnClick", function(self)
- ptable.TempConfig.showrewardtext = self:GetChecked() == 1
-end)
-
--- 'Equip Reward Text' CheckBox
-local EquipReward = CreateFrame("CheckButton", O.."Equip", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[EquipReward:GetName().."Text"]:SetText(L["autoequip"])
-EquipReward:SetScript("OnClick", function(self)
- ptable.TempConfig.autoequip = self:GetChecked() == 1
-end)
-
--- 'Equip Reward Text' CheckBox
-local Debug = CreateFrame("CheckButton", O.."Debug", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[Debug:GetName().."Text"]:SetText(L["debug"])
-Debug:SetScript("OnClick", function(self)
- ptable.TempConfig.debug = self:GetChecked() == 1
-end)
-
-local ShareQuests = CreateFrame("CheckButton", O.."ShareQuests", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[ShareQuests:GetName().."Text"]:SetText(L["ShareQuestsLabel"])
-ShareQuests:SetScript("OnClick", function(self)
- ptable.TempConfig.questshare = self:GetChecked() == 1
-end)
+local ShowRewardText = newCheckbox("Reward", L["rewardtext"], "showrewardtext")
+-- 'Equip Reward' CheckBox
+local EquipReward = newCheckbox("Equip", L["autoequip"], "autoequip")
+-- reward loot explanation
+local Debug = newCheckbox("Debug", L["debug"], "debug")
+-- share quest (!!! alpha)
+local ShareQuests = newCheckbox("ShareQuests", L["ShareQuestsLabel"], "questshare")
+-- 'Show QuestLevel' CheckBox
+local ShowQuestLevel = newCheckbox("QuestLevel", L["questlevel"], "questlevel")
+-- 'Show Watch Quest Level' CheckBox
+local ShowWatchLevel = newCheckbox("WatchLevel", L["watchlevel"], "watchlevel")
-- Auto toggle key
-local ToggleKeyLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
-ToggleKeyLabel:SetText(L["togglekey"])
local ToggleKeyConst = {NONE_KEY, ALT_KEY, CTRL_KEY, SHIFT_KEY}
-local ToggleKeyDropDown = CreateFrame("Frame", O.."ToggleKeyDropDown", OptionsPanel, "UIDropDownMenuTemplate")
-UIDropDownMenu_Initialize(ToggleKeyDropDown, function (self, level)
- for k, v in ipairs(ToggleKeyConst) do
- local info = UIDropDownMenu_CreateInfo()
- info.text, info.value = v, k
- info.func = function(self)
- UIDropDownMenu_SetSelectedID(ToggleKeyDropDown, self:GetID())
- ptable.TempConfig.togglekey = self:GetID()
- end
- UIDropDownMenu_AddButton(info, level)
- end
-end)
-UIDropDownMenu_SetWidth(ToggleKeyDropDown, 200);
-UIDropDownMenu_JustifyText(ToggleKeyDropDown, "LEFT")
-
--- 'Show QuestLevel' CheckBox
-local ShowQuestLevel = CreateFrame("CheckButton", O.."QuestLevel", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[ShowQuestLevel:GetName().."Text"]:SetText(L["questlevel"])
-ShowQuestLevel:SetScript("OnClick", function(self)
- ptable.TempConfig.questlevel = self:GetChecked() == 1
-end)
+local ToggleKeyDropDown = newDropDown(L["togglekey"], "ToggleKeyDropDown", ToggleKeyConst, "ToggleKeyConst")
+-- Quest types to handle
+local QuestConst = {L["questTypeAll"], L["questTypeList"]}
+local QuestDropDown = newDropDown(L["questTypeLabel"], "QuestDropDown", QuestConst, "all") -- self:GetID() == 1
+-- Tournament loot type
+local TournamentConst = {L["tournamentWrit"], L["tournamentPurse"]}
+local TournamentDropDown = newDropDown(L["tournamentLabel"], "TournamentDropDown", TournamentConst, "tournament")
+-- How to loot
+local LootConst = {L["lootTypeFalse"], L["lootTypeGreed"], L["lootTypeNeed"]}
+local LootDropDown = newDropDown(L["lootTypeLabel"], "LootDropDown", LootConst, "lootreward")
--- 'Show Watch Quest Level' CheckBox
-local ShowWatchLevel = CreateFrame("CheckButton", O.."WatchLevel", OptionsPanel, "OptionsCheckButtonTemplate")
-_G[ShowWatchLevel:GetName().."Text"]:SetText(L["watchlevel"])
-ShowWatchLevel:SetScript("OnClick", function(self)
- ptable.TempConfig.watchlevel = self:GetChecked() == 1
-end)
-- Control placement
title:SetPoint("TOPLEFT", 16, -16)
subText:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
ResetButton:SetPoint("TOPRIGHT", OptionsPanel, "TOPRIGHT", -10, -10)
Enable:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -14)
-QuestLabel:SetPoint("BOTTOMLEFT", QuestDropDown, "TOPLEFT", 18, 0)
QuestDropDown:SetPoint("TOPLEFT", Enable, "BOTTOMLEFT", -15, -22)
TrivialQuests:SetPoint("TOPLEFT", QuestDropDown, "TOPRIGHT", 30, 0)
-LootLabel:SetPoint("BOTTOMLEFT", LootDropDown, "TOPLEFT", 18, 0)
LootDropDown:SetPoint("TOPLEFT", QuestDropDown, "BOTTOMLEFT", 0, -22)
-TournamentDropDownLabel:SetPoint("BOTTOMLEFT", TournamentDropDown, "TOPLEFT", 18, 0)
TournamentDropDown:SetPoint("TOPLEFT", LootDropDown, "TOPRIGHT", 17, 0)
EquipReward:SetPoint("TOPLEFT", LootDropDown, "BOTTOMLEFT", 16, -10)
ShowRewardText:SetPoint("TOPLEFT", EquipReward, "BOTTOMLEFT", 0, -10)
@@ -203,7 +110,6 @@ ToDarkMoon:SetPoint("TOPLEFT", ShowRewardText, "BOTTOMLEFT", 0, -10)
DarkMoonCannon:SetPoint("TOPLEFT", ToDarkMoon, "BOTTOMLEFT", 0, -10)
DarkMoonAutoStart:SetPoint("TOPLEFT", DarkMoonCannon, "BOTTOMLEFT", 0, -10)
Debug:SetPoint("TOPLEFT", ResetButton, "BOTTOMLEFT", 0, -10)
-ToggleKeyLabel:SetPoint("BOTTOMLEFT", ToggleKeyDropDown, "TOPLEFT", 18, 0)
ToggleKeyDropDown:SetPoint("TOPLEFT", DarkMoonAutoStart, "BOTTOMLEFT", -15, -22)
ShowQuestLevel:SetPoint("TOPLEFT", ToggleKeyDropDown, "BOTTOMLEFT", 16, -10)
ShowWatchLevel:SetPoint("TOPLEFT", ShowQuestLevel, "BOTTOMLEFT", 0, -10)
@@ -223,7 +129,7 @@ OptionsPanel.refresh = function()
UIDropDownMenu_SetText(LootDropDown, LootConst[ptable.TempConfig.lootreward])
UIDropDownMenu_SetSelectedID(TournamentDropDown, ptable.TempConfig.tournament)
- UIDropDownMenu_SetText(TournamentDropDown,TournamentConst[ptable.TempConfig.tournament])
+ UIDropDownMenu_SetText(TournamentDropDown, TournamentConst[ptable.TempConfig.tournament])
ToDarkMoon:SetChecked(ptable.TempConfig.todarkmoon)
DarkMoonCannon:SetChecked(ptable.TempConfig.darkmoonteleport)
DarkMoonAutoStart:SetChecked(ptable.TempConfig.darkmoonautostart)