function addon:CreateObjectiveBuilder()
-- self:AddTestDBValues()
local frame = AceGUI:Create("Frame")
frame:SetTitle(L._ObjectiveBuilder("title"))
frame:SetWidth(600)
frame:SetHeight(525)
frame:SetLayout("Fill")
self.ObjectiveBuilder = frame
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
local objectiveTree = AceGUI:Create("TreeGroup")
objectiveTree:SetFullHeight(true)
objectiveTree:SetLayout("Flow")
objectiveTree:SetTree(self:GetObjectiveTree())
frame:AddChild(objectiveTree)
objectiveTree:SetCallback("OnGroupSelected", function(container, _, selected)
container:ReleaseChildren()
if selected == "newObjective" then
print("Create a new objective.")
else
-- Finding out the selected path to get the objectiveTitle
-- Not conerned with ever clicking on Active/Inactive itself
local objectiveTitle = {strsplit("\001", selected)}
tremove(objectiveTitle, 1)
objectiveTitle = strjoin("?", unpack(objectiveTitle))
if objectiveTitle ~= "" then
addon:DrawObjectiveGroup(container, objectiveTitle)
end
end
end)
objectiveTree:SelectByPath("Active")
end
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function addon:DrawObjectiveGroup(group, objectiveTitle)
local objectiveInfo = self.db.global.objectives[objectiveTitle]
group.objectiveTitle = objectiveTitle
-- Need to redraw again for when icon editbox/button are shown and hidden
group:ReleaseChildren()
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- groupScrollContainer
local groupScrollContainer = AceGUI:Create("SimpleGroup")
groupScrollContainer:SetFullWidth(true)
groupScrollContainer:SetFullHeight(true)
groupScrollContainer:SetLayout("Fill")
group:AddChild(groupScrollContainer)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- groupScrollFrame
local groupScrollFrame = AceGUI:Create("ScrollFrame")
groupScrollFrame:SetFullWidth(true)
groupScrollFrame:SetLayout("Flow")
groupScrollContainer:AddChild(groupScrollFrame)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- titleEditBox
local titleEditBox = AceGUI:Create("EditBox")
titleEditBox:SetFullWidth(true)
titleEditBox:SetLabel(L["Title"])
titleEditBox:SetText(group.objectiveTitle)
groupScrollFrame:AddChild(titleEditBox)
titleEditBox:SetCallback("OnEnterPressed", function(self)
local success, err = addon:UpdateObjectiveTitle(group.objectiveTitle, self:GetText())
self:ClearFocus()
if err and err == "exists" then
-- If err is because objective exists, restore title, focus and highlight for user to change
-- The other err would be because the title hasn't changed
self:SetText(group.objectiveTitle)
self:SetFocus()
self:HighlightText()
elseif success then
-- Update the objectiveTree to repopulate objectiveTitles
group:SetTree(addon:GetObjectiveTree())
-- Update the container's title reference
group.objectiveTitle = self:GetText()
end
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- autoIconCheckBox
local autoIconCheckBox = AceGUI:Create("CheckBox")
autoIconCheckBox:SetType("checkbox")
autoIconCheckBox:SetFullWidth(true)
autoIconCheckBox:SetLabel(L["Automatic Icon"])
autoIconCheckBox:SetValue(objectiveInfo.autoIcon)
groupScrollFrame:AddChild(autoIconCheckBox)
autoIconCheckBox:SetCallback("OnValueChanged", function(self)
addon.db.global.objectives[group.objectiveTitle].autoIcon = self:GetValue()
-- Redraw the group container to display/hide icon editbox and choose button
addon:DrawObjectiveGroup(group, objectiveTitle)
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- iconDisplayEditBox
local iconDisplayEditBox = AceGUI:Create("EditBox")
iconDisplayEditBox:SetRelativeWidth(1/2)
iconDisplayEditBox:SetLabel(L["Display Icon"])
iconDisplayEditBox:SetText(objectiveInfo.icon)
iconDisplayEditBox:SetCallback("OnEnterPressed", function(self)
addon.db.global.objectives[group.objectiveTitle].icon = self:GetText()
self:ClearFocus()
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- iconChooseButton
local iconChooseButton = AceGUI:Create("Button")
iconChooseButton:SetRelativeWidth(1/4)
iconChooseButton:SetText(L["Choose"])
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
if not objectiveInfo.autoIcon then
groupScrollFrame:AddChild(iconDisplayEditBox)
groupScrollFrame:AddChild(iconChooseButton)
end
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- buttonsHeading
local buttonsHeading = AceGUI:Create("Heading")
buttonsHeading:SetFullWidth(true)
buttonsHeading:SetText(L["Buttons"])
groupScrollFrame:AddChild(buttonsHeading)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- buttonIDEditBox
local buttonIDEditBox = AceGUI:Create("EditBox")
buttonIDEditBox:SetRelativeWidth(1/2)
buttonIDEditBox:SetLabel(L["Button ID"])
groupScrollFrame:AddChild(buttonIDEditBox)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- buttonIDChooseButton
local buttonIDChooseButton = AceGUI:Create("Button")
buttonIDChooseButton:SetRelativeWidth(1/4)
buttonIDChooseButton:SetText(L["Choose"])
groupScrollFrame:AddChild(buttonIDChooseButton)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- trackersHeading
local trackersHeading = AceGUI:Create("Heading")
trackersHeading:SetFullWidth(true)
trackersHeading:SetText(L["Trackers"])
groupScrollFrame:AddChild(trackersHeading)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- trackDropDown
local trackDropDown = AceGUI:Create("Dropdown")
trackDropDown:SetFullWidth(true)
trackDropDown:SetLabel(L["Track"])
trackDropDown:SetList({ALL = L["All"], ANY = L["Any"], CUSTOM = L["Custom"]}, {"ALL", "ANY", "CUSTOM"})
trackDropDown:SetValue(objectiveInfo.trackType)
groupScrollFrame:AddChild(trackDropDown)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- newTrackerButton
local newTrackerButton = AceGUI:Create("Button")
newTrackerButton:SetRelativeWidth(1/4)
newTrackerButton:SetText(L["New Tracker"])
groupScrollFrame:AddChild(newTrackerButton)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- trackerTree
local trackerTreeContainer = AceGUI:Create("SimpleGroup")
trackerTreeContainer:SetFullWidth(true)
trackerTreeContainer:SetHeight(400)
trackerTreeContainer:SetLayout("Fill")
groupScrollFrame:AddChild(trackerTreeContainer)
local trackerTree = AceGUI:Create("TreeGroup")
trackerTree:SetLayout("Flow")
trackerTree:SetTree(addon:GetTrackerTree())
trackerTreeContainer:AddChild(trackerTree)
end