--[[ Copyright (c) 2014 Eyal Shilony <Lynxium> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]] local addonName, addon = ... local display = LibStub("EasyDisplay-1.0") local L = LibStub("AceLocale-3.0"):GetLocale(addonName) function addon:InitializeOptions() local options = { name = addon.name, type = "group", args = { { type = "description", name = function() return GetAddOnMetadata(addonName, "Notes") end, cmdHidden = true, }, { type = "header", name = "", }, { type = "description", name = "", }, { type = "toggle", name = L["Block the menu in combat"], get = function() return addon.db.profile.blockInCombat end, set = function() addon.db.profile.blockInCombat = not addon.db.profile.blockInCombat end, width = "full", }, { type = "toggle", name = L["Hide the logout and exit items from the menu"], get = function() return addon.db.profile.hideLogoutButtons end, set = function() addon.db.profile.hideLogoutButtons = not addon.db.profile.hideLogoutButtons addon.updateMenu = true end, width = "full", }, { type = "toggle", name = L["Hide the reload item from the menu"], get = function() return addon.db.profile.hideReloadUIButton end, set = function() addon.db.profile.hideReloadUIButton = not addon.db.profile.hideReloadUIButton addon.updateMenu = true end, width = "full", }, { type = "toggle", name = L["Hide the options item from the menu"], get = function() return addon.db.profile.hideOptionsButton end, set = function() addon.db.profile.hideOptionsButton = not addon.db.profile.hideOptionsButton addon.updateMenu = true end, width = "full", }, { type = "header", name = L["Tooltip"], }, { type = "description", name = "", }, { type = "toggle", name = L["Hide tooltip"], get = function() return addon.db.profile.hideTooltip end, set = function() addon.db.profile.hideTooltip = not addon.db.profile.hideTooltip end, width = "full", }, { type = "range", name = L["Number of addons to display"], get = function() return addon.db.profile.numAddOns end, set = function(_, value) addon.db.profile.numAddOns = value end, step = 1, min = 1, max = 40, width = "full", }, }, } addon:RegisterOptions(options) local accessibility = { name = L["Accessibility"], type = "group", args = { { type = "description", name = L["Bind up to four menu items to the mouse which you can use to open them quickly by clicking on the broker display."], cmdHidden = true, }, { type = "header", name = "", }, { type = "select", name = L["Mouse Setting"], get = function() return addon.db.profile.mouseButton end, set = function(_, value) addon.db.profile.mouseButton = value end, values = addon.buttons, }, { type = "header", name = "", }, }, } local num = 0 local titles = { } for _, v in display:Interfaces() do num = num + 1 table.insert(titles, v.title) end for i, v in pairs(addon.db.profile.accessibility) do table.insert(accessibility.args, { type = "select", name = L["Action %s"]:format(i), get = function() local _, index = display:GetInterface(addon.db.profile.accessibility[i].name) return index end, set = function(_, value) local interface = display:GetInterfaceByIndex(value) addon.db.profile.accessibility[i].name = interface.name end, values = titles, width = "double", }) table.insert(accessibility.args, { type = "select", name = L["Modifier"], get = function() return addon.db.profile.accessibility[i].modifier end, set = function(_, value) addon.db.profile.accessibility[i].modifier = value end, values = addon.modifiers, }) end table.insert(accessibility.args, { type = "header", name = "", }) table.insert(accessibility.args, { type = "toggle", name = L["Hide the bindings from the tooltip"], get = function() return addon.db.profile.hideTooltipAccessibilityBindings end, set = function() addon.db.profile.hideTooltipAccessibilityBindings = not addon.db.profile.hideTooltipAccessibilityBindings end, width = "full", }) addon:RegisterOptions(accessibility) local order = { name = L["Order"] , type = "group", args = { { type = "description", name = L["Sort the order of the menu items.\n\nNote, having no sorting order (zero) hides the item from the menu."], cmdHidden = true, }, { type = "header", name = "", }, }, } for _, v in display:Interfaces() do table.insert(order.args, { type = "range", name = v.title, get = function() return addon.db.profile.order[v.name] end, set = function(_, value) addon.db.profile.order[v.name] = value addon.updateMenu = true end, step = 1, min = 0, max = num, width = "full", }) end addon:RegisterOptions(order) addon:RegisterOptions(LibStub("AceDBOptions-3.0"):GetOptionsTable(addon.db), true) end