--[[ Author: Jarth Filename: CBs_Menu.lua ]] -- ------------------------------------------------------------------------------------------------- -- Libraries -- ------------------------------------------------------------------------------------------------- local LAM2 = LibStub:GetLibrary("LibAddonMenu-2.0") ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars ------------------------------------------------------------------------------------------------- -- Menu Functions -- ------------------------------------------------------------------------------------------------- function base.CreateSettingsWindow() local panelData = { _type = "panel", name = base.Addon.DisplayName, displayName = base.Addon.DisplayName, author = base.Addon.Author, version = base.GetVersion(true), slashCommand = base.Addon.Command, registerForRefresh = true, registerForDefaults = true } LAM2:RegisterAddonPanel(base.Addon.Name, panelData) local whenOnTheBar = "When ON the bar will show the bar " local optionsData = { { type = "header", name = base.Addon.DisplayName .. " Settings" }, { type = "description", text = string.format("Here you can setup %s.\nCMD: %s", base.Addon.DisplayName, base.Addon.Command) }, { type = "checkbox", name = "Use account settings", tooltip = "When ON the account settings will be used. When OFF character settings will be used", default = base.Default.UseAccountSettings, warning = "Reload to see full effect", requiresReload = true, getFunc = function() return base.Saved.UseAccountSettings end, setFunc = function(newValue) base.SetAndUpdateAccountSettings(newValue) end }, { type = "submenu", name = "General settings", tooltip = "Setup some general settings", controls = { { type = "description", text = "Setup some general settings" }, { type = "submenu", name = "Position and size", tooltip = "Setup position and size", controls = { { type = "description", text = "Here you can setup position and size \n(Unlock to move the bar)" }, { type = "checkbox", name = "Unlock movement of bar", tooltip = "When ON the bar will show the X,Y position of the top left corner, and is draggable", default = function() return base.Global.IsMoveEnabled end, getFunc = function() return base.Global.IsMoveEnabled end, setFunc = function(newValue) base.Global.IsMoveEnabled = newValue base.RestoreFrames() end }, { type = "slider", name = "Choose snap size when moving", default = base.Default.SnapSize, getFunc = function() return base.Saved.SnapSize end, setFunc = function(value) base.Saved.SnapSize = value base.RestoreFrames() end, min = 1, max = 10 }, { type = "slider", name = "Choose default bar depth (number of rows/columns)", default = base.Default.BarDepth, getFunc = function() return base.Saved.BarDepth end, setFunc = function(value) base.Saved.BarDepth = value base.RestoreFrames() end, min = 1, max = base.Global.HighestUnlocked }, { type = "slider", name = "Choose max bar height (number of inverse rows/columns)", default = base.Default.BarWidth, getFunc = function() return base.Saved.BarWidth end, setFunc = function(value) base.Saved.BarWidth = value base.RestoreFrames() end, min = 0, max = base.Global.HighestUnlocked }, { type = "checkbox", name = "Show binding's on bar", tooltip = "When ON the binding's will be shown on the bar", default = base.Default.ShowBinding, getFunc = function() return base.Saved.ShowBinding end, setFunc = function(newValue) base.Saved.ShowBinding = newValue base.RestoreFrames() end }, { type = "slider", name = "Button size", default = ZO_GAMEPAD_ACTION_BUTTON_SIZE, getFunc = function() return base.Saved.ButtonXY end, setFunc = function(value) base.Saved.ButtonXY = value base.RestoreFrames() end, min = 1, max = 100, width = "half" } } }, { type = "submenu", name = "Audio", tooltip = "Setup audio", controls = { { type = "description", text = "Here you can setup the audio" }, { type = "checkbox", name = "Play hover audio", tooltip = "When ON hover events on the bar, will play audio", default = function() return base.Saved.IsAudioEnabled end, getFunc = function() return base.Saved.IsAudioEnabled end, setFunc = function(newValue) base.Saved.IsAudioEnabled = newValue base.RestoreFrames() end } } }, { type = "submenu", name = "Visibility", tooltip = "Setup visibility", controls = { { type = "description", text = "Here you can setup what views the bars are visible in" }, { type = "checkbox", name = "Show bar " .. "on main view/hud", tooltip = whenOnTheBar .. "on main view/hud", default = base.Default.ShowBarOnHud, getFunc = function() return base.Saved.ShowBarOnHud end, setFunc = function(newValue) base.Saved.ShowBarOnHud = newValue base.UpdateFragments("ShowBarOnHud") end }, { type = "checkbox", name = "Show bar " .. "on the main view when an overlay is activated/hudui", tooltip = whenOnTheBar .. "on the main view when an overlay is activated/hudui", default = base.Default.ShowBarOnHudUI, getFunc = function() return base.Saved.ShowBarOnHudUI end, setFunc = function(newValue) base.Saved.ShowBarOnHudUI = newValue base.UpdateFragments("ShowBarOnHudUI") end }, { type = "checkbox", name = "Show bar " .. "in menu", tooltip = whenOnTheBar .. "in menu", default = base.Default.ShowBarInMenu, getFunc = function() return base.Saved.ShowBarInMenu end, setFunc = function(newValue) base.Saved.ShowBarInMenu = newValue base.UpdateFragments("ShowBarInMenu") end }, { type = "checkbox", name = "Show bar " .. "in the inventory", tooltip = whenOnTheBar .. "in the inventory", default = base.Default.ShowBarInInventory, getFunc = function() return base.Saved.ShowBarInInventory end, setFunc = function(newValue) base.Saved.ShowBarInInventory = newValue base.UpdateFragments("ShowBarInInventory") end }, { type = "checkbox", name = "Show bar " .. "in interactions", tooltip = whenOnTheBar .. "in interactions", default = base.Default.ShowBarInInteract, getFunc = function() return base.Saved.ShowBarInInteract end, setFunc = function(newValue) base.Saved.ShowBarInInteract = newValue base.UpdateFragments("ShowBarInInteract") end }, { type = "checkbox", name = "Show bar " .. "at a bank", tooltip = whenOnTheBar .. "at a bank", default = base.Default.ShowBarInBank, getFunc = function() return base.Saved.ShowBarInBank end, setFunc = function(newValue) base.Saved.ShowBarInBank = newValue base.UpdateFragments("ShowBarInBank") end }, { type = "checkbox", name = "Show bar " .. "at a fence", tooltip = whenOnTheBar .. "at a fence", default = base.Default.ShowBarInFence, getFunc = function() return base.Saved.ShowBarInFence end, setFunc = function(newValue) base.Saved.ShowBarInFence = newValue base.UpdateFragments("ShowBarInFence") end }, { type = "checkbox", name = "Show bar " .. "at a store", tooltip = whenOnTheBar .. "at a store", default = base.Default.ShowBarInStore, getFunc = function() return base.Saved.ShowBarInStore end, setFunc = function(newValue) base.Saved.ShowBarInStore = newValue base.UpdateFragments("ShowBarInStore") end } } }, { type = "submenu", name = "Active and activation", tooltip = "Setup active and activation indication", controls = { { type = "description", text = "Here you can setup the active and activation indication" }, { type = "checkbox", name = "Show active and activation", tooltip = "When ON the active collectibles will be highlighted, and activation animation will display", default = function() return base.Saved.IsActiveActivationEnabled end, getFunc = function() return base.Saved.IsActiveActivationEnabled end, setFunc = function(newValue) base.Saved.IsActiveActivationEnabled = newValue base.RestoreFrames() end } } }, { type = "checkbox", name = "Show debug messages", default = false, getFunc = function() return base.Global.IsDebugEnabled end, setFunc = function(newValue) base.Global.IsDebugEnabled = newValue end } } }, { type = "submenu", name = "Combined bar", tooltip = "Setup the combined bar", controls = { { type = "submenu", name = "Display name and labels", tooltip = "Setup display name, labels", controls = { { type = "slider", name = "Display name offset horizontal (X)", default = base.Default.Combine.Label.OffsetX, getFunc = function() return base.Saved.Combine.Label.OffsetX end, setFunc = function(value) base.Saved.Combine.Label.OffsetX = value base.RestoreCombineLabels() end, min = -500, max = 500, width = "half" }, { type = "slider", name = "Display name offset vertical (Y)", default = base.Default.Combine.Label.OffsetY, getFunc = function() return base.Saved.Combine.Label.OffsetY end, setFunc = function(value) base.Saved.Combine.Label.OffsetY = value base.RestoreCombineLabels() end, min = -500, max = 500, width = "half" }, { type = "dropdown", name = "Display name anchor position on button", tooltip = "Select display name anchor position on the button", choices = base.Global.ChoiceCornerLocations, default = base.Default.Combine.Label.PositionTarget, getFunc = function() return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) end, setFunc = function(value) base.Saved.Combine.Label.PositionTarget = base.GetLocationValue(value) base.Saved.Combine.AnchorXY = base.GetLocationValue(value) base.RestoreCombineLabels() end, width = "half" }, { type = "dropdown", name = "Display name anchor position on label", tooltip = "Select display name anchor position on the label", choices = base.Global.ChoiceLocations, default = base.Default.Combine.Label.Position, getFunc = function() return base.GetLocationText(base.Saved.Combine.Label.Position) end, setFunc = function(value) base.Saved.Combine.Label.Position = base.GetLocationValue(value) base.RestoreCombineLabels() end, width = "half" }, { type = "dropdown", name = "Bar anchor location", tooltip = "Select Bar anchor location, used when bar is collapsed", choices = base.Global.ChoiceCornerLocations, default = base.Default.Combine.AnchorXY, getFunc = function() return base.GetLocationText(base.Saved.Combine.AnchorXY) end, setFunc = function(value) base.Saved.Combine.AnchorXY = base.GetLocationValue(value) base.RestoreCombineLabels() end, width = "half" } } }, { type = "submenu", name = "Position and size", tooltip = "Setup position and size", controls = { { type = "description", text = "Here you can setup position and size \n(Unlock to move the bar)" }, { type = "slider", name = "Choose default bar depth (number of rows/columns)", default = base.Default.BarDepth, getFunc = function() return base.Saved.Combine.BarDepth end, setFunc = function(value) base.Saved.Combine.BarDepth = value base.RestoreFrames() end, min = 0, max = base.Global.HighestUnlocked }, { type = "slider", name = "Choose max bar height (number of inverse rows/columns)", default = base.Default.BarWidth, getFunc = function() return base.Saved.Combine.BarWidth end, setFunc = function(value) base.Saved.Combine.BarWidth = value base.RestoreFrames() end, min = 0, max = base.Global.HighestUnlocked } } } } }, { type = "submenu", name = "Collection types", tooltip = "Select what collection types you want enabled", controls = { { type = "description", text = "The selected collection types will be displayed when ON\nReload to see effect in menu" } } } } local function AppendShowCollection(controlIndex, _type) table.insert( optionsData[controlIndex].controls, { type = "checkbox", name = string.format("Show %s (Total: %s Unlocked: %s) ", _type.Name, _type.Total, _type.Unlocked), tooltip = "When ON the menu item " .. _type.Name .. " will be available for selection", default = base.Default[_type.Name].Enabled, warning = "Reload to see full effect", requiresReload = true, getFunc = function() return _type.Saved.Enabled end, setFunc = function(newValue) _type.Saved.Enabled = newValue end } ) end local function AppendDataToMenu(controlIndex, _type) local typeName = _type.Name local controls = { { type = "submenu", name = "Tooltip", tooltip = "Setup tooltip for " .. typeName, controls = { { type = "checkbox", name = "Show tooltip", tooltip = "When ON tooltips will be shown, when hovering buttons on the bar", default = base.Default[typeName].Tooltip.Show, getFunc = function() return _type.Saved.Tooltip.Show end, setFunc = function(newValue) _type.Saved.Tooltip.Show = newValue base.SetupButtons(_type) end, width = "half" }, { type = "dropdown", name = "Show tooltip anchor position", tooltip = "Select tooltip anchor position", choices = base.Global.ChoiceSideLocations, default = base.Default[typeName].Tooltip.Position, disabled = function() return not _type.Saved.Tooltip.Show end, getFunc = function() return base.GetLocationText(_type.Saved.Tooltip.Position) end, setFunc = function(value) _type.Saved.Tooltip.Position = base.GetLocationValue(value) base.SetupButtons(_type) end, width = "half" } } }, { type = "submenu", name = "Display name and labels", tooltip = "Setup display name, labels", controls = { { type = "checkbox", name = "Enable hide", disabled = function() return _type.Saved.Combine end, default = base.Default[typeName].HideAllEnabled, getFunc = function() return _type.Saved.Combine or _type.Saved.HideAllEnabled end, setFunc = function(newValue) if (not newValue) then _type.Saved.HideAll = newValue base.RestoreFrame(_type) end _type.Saved.HideAllEnabled = newValue _type.Saved.LabelShow = true base.SetupLabel(_type) base.RestoreLabel(_type) end, width = "half" }, { type = "checkbox", name = "Show label", disabled = function() return _type.Saved.HideAllEnabled or _type.Saved.Combine end, default = base.Default[typeName].LabelShow, getFunc = function() return _type.Saved.LabelShow or _type.Saved.Combine end, setFunc = function(newValue) _type.Saved.LabelShow = newValue base.SetupLabel(_type) base.RestoreLabel(_type) end, width = "half" }, { type = "editbox", name = "Display name", disabled = function() return not _type.Saved.LabelShow end, default = base.Default[typeName].Display, getFunc = function() return _type.Saved.Display end, setFunc = function(value) _type.Saved.Display = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, width = "half" }, { type = "dropdown", name = "Display name font", disabled = function() return not _type.Saved.LabelShow end, choices = base.Global.AvailableFonts, default = base.Default[typeName].Label.Font, getFunc = function() return _type.Saved.Label.Font end, setFunc = function(value) _type.Saved.Label.Font = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, width = "half" }, { type = "slider", name = "Display name height", disabled = function() return not _type.Saved.LabelShow end, default = base.Default[typeName].Label.Height, getFunc = function() return _type.Saved.Label.Height end, setFunc = function(value) _type.Saved.Label.Height = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, min = 0, max = 500, width = "half" }, { type = "slider", name = "Display name width", disabled = function() return not _type.Saved.LabelShow end, default = base.Default[typeName].Label.Width, getFunc = function() return _type.Saved.Label.Width end, setFunc = function(value) _type.Saved.Label.Width = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, min = 0, max = 500, width = "half" }, { type = "slider", name = "Display name offset horizontal (X)", disabled = function() return not _type.Saved.LabelShow end, default = base.Default[typeName].Label.OffsetX, getFunc = function() return _type.Saved.Label.OffsetX end, setFunc = function(value) _type.Saved.Label.OffsetX = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, min = -500, max = 500, width = "half" }, { type = "slider", name = "Display name offset vertical (Y)", disabled = function() return not _type.Saved.LabelShow end, default = base.Default[typeName].Label.OffsetY, getFunc = function() return _type.Saved.Label.OffsetY end, setFunc = function(value) _type.Saved.Label.OffsetY = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, min = -500, max = 500, width = "half" }, { type = "dropdown", name = "Display name anchor position on button", tooltip = "Select display name anchor position on the button", disabled = function() return not _type.Saved.LabelShow or not _type.Saved.Label.PositionTarget or _type.Saved.Combine end, choices = base.Global.ChoiceLocations, default = base.Default.BindingLocation, getFunc = function() if _type.Saved.Combine then return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) else return base.GetLocationText(_type.Saved.Label.PositionTarget) end end, setFunc = function(value) _type.Saved.Label.PositionTarget = base.GetLocationValue(value) _type.Saved.AnchorXY = base.GetLocationValue(value) base.RestoreFrame(_type) base.RestoreCombineLabels() end, width = "half" }, { type = "dropdown", name = "Display name anchor position on label", tooltip = "Select display name anchor position on the label", disabled = function() return not _type.Saved.LabelShow or not _type.Saved.Label.Position or _type.Saved.Combine end, choices = base.Global.ChoiceLocations, default = base.Default.BindingLocation, getFunc = function() if _type.Saved.Combine then return base.GetLocationText(base.Saved.Combine.Label.Position) else return base.GetLocationText(_type.Saved.Label.Position) end end, setFunc = function(value) _type.Saved.Label.Position = base.GetLocationValue(value) base.RestoreFrame(_type) base.RestoreCombineLabels() end, width = "half" }, { type = "dropdown", name = "Bar anchor location", tooltip = "Select Bar anchor location, used when bar is collapsed", choices = base.Global.ChoiceCornerLocations, default = base.Default[typeName].AnchorXY, disabled = function() return not _type.Saved.AnchorXY or _type.Saved.Combine end, getFunc = function() if _type.Saved.Combine then return base.GetLocationText(base.Saved.Combine.AnchorXY) else return base.GetLocationText(_type.Saved.AnchorXY) end end, setFunc = function(value) _type.Saved.AnchorXY = base.GetLocationValue(value) base.RestoreFrame(_type) base.RestoreCombineLabels() end, width = "half" } } }, { type = "submenu", name = "Position and size", tooltip = "Setup position and size for " .. typeName, controls = { { type = "slider", name = "Choose bar depth (number of rows/columns)", default = base.Default[typeName].BarDepth, disabled = function() return _type.Saved.Combine end, getFunc = function() return _type.Saved.BarDepth end, setFunc = function(value) _type.Saved.BarDepth = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, min = 0, max = _type.Unlocked }, { type = "slider", name = "Choose max bar height (number of inverse rows/columns)", default = base.Default[typeName].BarWidth, disabled = function() return _type.Saved.Combine end, getFunc = function() return _type.Saved.BarWidth end, setFunc = function(value) _type.Saved.BarWidth = value base.RestoreFrame(_type) base.RestoreCombineLabels() end, min = 0, max = _type.Unlocked }, { type = "checkbox", name = "Bar orientation horizontal", default = base.Default[typeName].Horizontal, disabled = function() return _type.Saved.Combine end, getFunc = function() return _type.Saved.Horizontal end, setFunc = function(newValue) _type.Saved.Horizontal = newValue base.RestoreFrame(_type) base.RestoreCombineLabels() end } } }, { type = "checkbox", name = "Combine bar " .. typeName, tooltip = "When ON " .. typeName .. " will be attached to a combined bar", default = base.Default[typeName].Combine, getFunc = function() return _type.Saved.Combine end, setFunc = function(newValue) _type.Saved.Combine = newValue base.RestoreFrame(_type) base.RestoreCombineLabels() end }, { type = "checkbox", name = "Show disabled " .. typeName, tooltip = "When ON disabled elements will be shown for " .. typeName, warning = "Reload to see full effect", requiresReload = true, default = base.Default[typeName].MenuShowDisabled, getFunc = function() return _type.Saved.MenuShowDisabled end, setFunc = function(newValue) _type.Saved.MenuShowDisabled = newValue end }, { type = "checkbox", name = "Show all " .. typeName, warning = "When pressed all " .. typeName .. " will either be selected or deselected", default = function() return base.IsAllSelected(_type) end, getFunc = function() return base.IsAllSelected(_type) end, setFunc = function(newValue) base.SelectAll(_type, newValue) base.RestoreFrame(_type) base.RestoreCombineLabels() end }, { type = "description", text = "Choose what collection's you want enabled" } } for _, collection in ipairs(_type.OrderedCollection) do table.insert( controls, { type = "checkbox", name = "Show " .. collection.Name, tooltip = collection.Tooltip, default = not collection.Disabled, disabled = collection.Disabled, getFunc = function() return _type.Saved.Selected[collection.Id] end, setFunc = function(newValue) if newValue == true then _type.Saved.Selected[collection.Id] = newValue else _type.Saved.Selected[collection.Id] = nil end base.RestoreFrame(_type) base.RestoreCombineLabels() end } ) end table.insert( optionsData, controlIndex, { type = "submenu", name = string.format("%s (Total: %s Unlocked: %s) ", typeName, _type.Total, _type.Unlocked), tooltip = "Choose what collection's you want on the bar", controls = controls } ) end local indexShowCollection = 6 local indexDataToMenu = 7 for _, _type in ipairs(base.TypeOrdered) do AppendShowCollection(indexShowCollection, _type) if _type.Saved.Enabled then AppendDataToMenu(indexDataToMenu, _type) indexDataToMenu = indexDataToMenu + 1 end end LAM2:RegisterOptionControls(base.Addon.Name, optionsData) end