local frame = AceGUI:Create("Frame")
frame:SetWidth(600)
frame:SetHeight(525)
frame:SetTitle(L._ObjectiveBuilder("title"))
frame:SetLayout("Fill")
self.ObjectiveBuilder = frame
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
local scrollcontainer = AceGUI:Create("SimpleGroup")
scrollcontainer:SetFullWidth(true)
scrollcontainer:SetLayout("Fill")
frame:AddChild(scrollcontainer)
local scrollframe = AceGUI:Create("ScrollFrame")
scrollframe:SetFullWidth(true)
scrollframe:SetLayout("Fill")
scrollcontainer:AddChild(scrollframe)
local treecontainer = AceGUI:Create("SimpleGroup")
treecontainer:SetFullWidth(true)
treecontainer:SetLayout("Fill")
scrollframe:AddChild(treecontainer)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
local tree = AceGUI:Create("TreeGroup")
tree:SetFullHeight(true)
tree:SetLayout("Flow")
tree:SetTree(self:GetObjectiveTree())
treecontainer:AddChild(tree)
tree:SetCallback("OnGroupSelected", function(container, _, group, ...)
container:ReleaseChildren()
if group == "newObjective" then
print("Create a new objective.")
else
-- Draw Objective Group and load objective info
local group = {strsplit("\001", group)}
tremove(group, 1)
group = strjoin("?", unpack(group))
if group ~= "" then
frame:DrawObjectiveGroup(container, group)
end
end
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function frame:DrawObjectiveGroup(container, objectiveTitle)
container:ReleaseChildren()
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Objective info
container.objectiveTitle = objectiveTitle
local objectiveInfo = addon.db.global.objectives[objectiveTitle]
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- titleEditBox
local titleEditBox = AceGUI:Create("EditBox")
titleEditBox:SetFullWidth(true)
titleEditBox:SetLabel(L["Title"])
titleEditBox:SetText(objectiveTitle)
container:AddChild(titleEditBox)
titleEditBox:SetCallback("OnEnterPressed", function(self)
local success, err = addon:UpdateObjectiveTitle(container.objectiveTitle, self:GetText())
self:ClearFocus()
if err then
self:SetText(objectiveTitle)
if err == "exists" then
self:SetFocus()
self:HighlightText()
end
elseif success then
tree:SetTree(addon:GetObjectiveTree())
container.objectiveTitle = self:GetText()
end
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- automaticIconCheck
local iconEditBox, iconChooseButton
local automaticIconCheck = AceGUI:Create("CheckBox")
automaticIconCheck:SetType("checkbox")
automaticIconCheck:SetFullWidth(true)
automaticIconCheck:SetLabel(L["Automatic Icon"])
automaticIconCheck:SetValue(objectiveInfo.autoIcon)
container:AddChild(automaticIconCheck)
automaticIconCheck:SetCallback("OnValueChanged", function(self)
addon.db.global.objectives[container.objectiveTitle].autoIcon = self:GetValue()
frame:DrawObjectiveGroup(container, objectiveTitle)
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- iconEditBox
iconEditBox = AceGUI:Create("EditBox")
iconEditBox:SetRelativeWidth(1/2)
iconEditBox:SetLabel(L["Display Icon"])
iconEditBox:SetText(objectiveInfo.icon)
iconEditBox:SetCallback("OnEnterPressed", function(self)
addon.db.global.objectives[container.objectiveTitle].icon = self:GetText()
self:ClearFocus()
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- iconChooseButton
iconChooseButton = AceGUI:Create("Button")
iconChooseButton:SetRelativeWidth(1/4)
iconChooseButton:SetText(L["Choose"])
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
if not automaticIconCheck:GetValue() then
container:AddChild(iconEditBox)
container:AddChild(iconChooseButton)
end
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- buttonHeading
local buttonHeading = AceGUI:Create("Heading")
buttonHeading:SetFullWidth(true)
buttonHeading:SetText(L["Button Settings"])
container:AddChild(buttonHeading)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- buttonEditBox
local buttonEditBox = AceGUI:Create("EditBox")
buttonEditBox:SetRelativeWidth(1/2)
buttonEditBox:SetLabel(L["Button ID"])
container:AddChild(buttonEditBox)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- buttonChooseButton
local buttonChooseButton = AceGUI:Create("Button")
buttonChooseButton:SetRelativeWidth(1/4)
buttonChooseButton:SetText(L["Choose"])
container:AddChild(buttonChooseButton)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- trackersHeading
local trackersHeading = AceGUI:Create("Heading")
trackersHeading:SetFullWidth(true)
trackersHeading:SetText(L["Trackers"])
container:AddChild(trackersHeading)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- trackDropDown
local trackDropDown = AceGUI:Create("Dropdown")
trackDropDown:SetFullWidth(true)
trackDropDown:SetList({ALL = L["All"], ANY = L["Any"], CUSTOM = L["Custom"]}, {"ALL", "ANY", "CUSTOM"})
trackDropDown:SetLabel("Track")
trackDropDown:SetValue(objectiveInfo.trackType)
container:AddChild(trackDropDown)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- newTrackerButton
local newTrackerButton = AceGUI:Create("Button")
newTrackerButton:SetRelativeWidth(1/4)
newTrackerButton:SetText("New")
container:AddChild(newTrackerButton)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- trackerTree
local trackerTreeContainer = AceGUI:Create("SimpleGroup")
trackerTreeContainer:SetFullWidth(true)
trackerTreeContainer:SetLayout("Fill")
container:AddChild(trackerTreeContainer)
local trackerTree = AceGUI:Create("TreeGroup")
trackerTree:SetLayout("Flow")
trackerTree:SetTree(addon:GetTrackerTree())
trackerTreeContainer:AddChild(trackerTree)
end
tree:SelectByPath("Active")