flickerstreak@7: -- Buttons.lua flickerstreak@7: -- flickerstreak@7: -- Defines button types for use with the ReAction AddOn flickerstreak@7: -- flickerstreak@7: flickerstreak@7: local AceOO = AceLibrary("AceOO-2.0") flickerstreak@10: local ReBound = AceLibrary("ReBound-1.0") flickerstreak@7: flickerstreak@7: local Action = AceOO.Class( flickerstreak@7: ReAction, flickerstreak@7: ReAction.ActionType, flickerstreak@7: ReAction.ActionDisplay, flickerstreak@7: ReAction.DefaultColorScheme flickerstreak@7: ) flickerstreak@7: flickerstreak@7: local PetAction = AceOO.Class( flickerstreak@7: ReAction, flickerstreak@7: ReAction.PetActionType, flickerstreak@7: ReAction.PetActionDisplay, flickerstreak@7: ReAction.DefaultColorScheme flickerstreak@7: ) flickerstreak@7: flickerstreak@7: flickerstreak@10: ReAction:AddButtonType( "Action", Action, 120 ) flickerstreak@7: ReAction:AddButtonType( "Pet Action", PetAction, 10 ) flickerstreak@7: flickerstreak@7: flickerstreak@7: flickerstreak@7: ----------------------- flickerstreak@7: -- static class members flickerstreak@7: ----------------------- flickerstreak@7: Action.defaultProfile = { flickerstreak@7: type = "ReAction", flickerstreak@7: subtype = "Action", flickerstreak@7: ids = { }, flickerstreak@7: selfcast = nil, flickerstreak@7: keyBindLoc = "TOPRIGHT", flickerstreak@10: keyBindRightLoc = "RIGHT", flickerstreak@7: stackCountLoc = "BOTTOMRIGHT", flickerstreak@7: showKeyBind = true, flickerstreak@10: showKeyBindRight = false, flickerstreak@7: showStackCount = true, flickerstreak@7: showMacroText = true, flickerstreak@7: showBorder = true, flickerstreak@7: keyBindColorCode = false, flickerstreak@8: hideCooldown = false, flickerstreak@8: hideGlobalCooldown = false, flickerstreak@7: } flickerstreak@7: flickerstreak@7: PetAction.defaultProfile = { flickerstreak@7: type = "ReAction", flickerstreak@7: subtype = "Pet Action", flickerstreak@7: ids = { }, flickerstreak@7: keyBindLoc = "TOPRIGHT", flickerstreak@7: showKeyBind = false, flickerstreak@7: showGrid = false, flickerstreak@7: showBorder = true, flickerstreak@7: keyBindColorCode = false, flickerstreak@7: } flickerstreak@7: flickerstreak@7: flickerstreak@7: flickerstreak@7: ----------------------- flickerstreak@7: -- static class methods flickerstreak@7: ----------------------- flickerstreak@7: function Action:GetDefaultProfile() flickerstreak@7: return self.defaultProfile flickerstreak@7: end flickerstreak@7: flickerstreak@7: function PetAction:GetDefaultProfile() flickerstreak@7: return self.defaultProfile flickerstreak@7: end flickerstreak@7: flickerstreak@7: flickerstreak@7: flickerstreak@7: local labelPlacementOptions = { flickerstreak@7: "TOP", flickerstreak@7: "BOTTOM", flickerstreak@7: "LEFT", flickerstreak@7: "RIGHT", flickerstreak@7: "TOPLEFT", flickerstreak@7: "TOPRIGHT", flickerstreak@7: "BOTTOMLEFT", flickerstreak@7: "BOTTOMRIGHT" flickerstreak@7: } flickerstreak@7: flickerstreak@7: flickerstreak@7: function Action:GenerateOptionsTable( config, buttonListFunc ) flickerstreak@7: flickerstreak@7: local function refresh() flickerstreak@7: for _, b in pairs(buttonListFunc()) do flickerstreak@7: b:UpdateAction() flickerstreak@7: b:UpdateTooltip() flickerstreak@7: b:UpdateDisplay() flickerstreak@7: end flickerstreak@7: end flickerstreak@7: flickerstreak@8: local function setOpacity(field, value) flickerstreak@8: if not config.opacity then flickerstreak@8: config.opacity = { } flickerstreak@8: end flickerstreak@8: config.opacity[field] = (value and value / 100) flickerstreak@8: refresh() flickerstreak@8: end flickerstreak@8: flickerstreak@8: local function getOpacity(field, default) flickerstreak@8: local o = config.opacity and config.opacity[field] or (default and default/100) or 1 flickerstreak@8: return o * 100 flickerstreak@8: end flickerstreak@8: flickerstreak@7: return { flickerstreak@7: type = "group", flickerstreak@7: args = { flickerstreak@7: selfcast = { flickerstreak@7: type = "text", flickerstreak@7: name = "Self Cast", flickerstreak@7: desc = "Choose a modifier key to hold down or an alternate button to click to self-cast spells. ".. flickerstreak@7: "'default' uses the settings in the Interface Options Advanced panel (use this to achieve 'smart self cast'). ".. flickerstreak@7: "'right-click' self-casting is not supported for multi-page bars.", flickerstreak@7: get = function() return config.selfcast or "default" end, flickerstreak@7: set = function(opt) flickerstreak@7: if opt == "default" then opt = nil end flickerstreak@7: config.selfcast = opt flickerstreak@7: for _, b in pairs(buttonListFunc()) do flickerstreak@7: b:UpdateSelfcast() flickerstreak@7: end flickerstreak@7: end, flickerstreak@7: validate = { "default", "none", "alt", "ctrl", "shift", "right-click" }, flickerstreak@10: order = 101 flickerstreak@7: }, flickerstreak@7: flickerstreak@8: opacity = { flickerstreak@8: type = "group", flickerstreak@8: name = "Opacity", flickerstreak@8: desc = "Set options for variable button opacity", flickerstreak@8: args = { flickerstreak@8: usable = { flickerstreak@8: type = "range", flickerstreak@8: name = "Usable", flickerstreak@8: desc = "Button opacity when the action is currently usable", flickerstreak@8: min = 0, flickerstreak@8: max = 100, flickerstreak@8: step = 1, flickerstreak@8: get = function() return getOpacity("usable") end, flickerstreak@8: set = function(x) setOpacity("usable", x) end, flickerstreak@8: order = 1, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: notUsable = { flickerstreak@8: type = "range", flickerstreak@8: name = "Not Usable", flickerstreak@8: desc = "Button opacity when the action is currently not usable", flickerstreak@8: min = 0, flickerstreak@8: max = 100, flickerstreak@8: step = 1, flickerstreak@8: get = function() return getOpacity("notUsable") end, flickerstreak@8: set = function(x) setOpacity("notUsable",x) end, flickerstreak@8: order = 2, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: oom = { flickerstreak@8: type = "range", flickerstreak@8: name = "Out of Power", flickerstreak@8: desc = "Button opacity when the action is not usable due to not enough mana/energy/rage. ".. flickerstreak@8: "By default this uses the generic 'not-usable' setting.", flickerstreak@8: min = 0, flickerstreak@8: max = 100, flickerstreak@8: step = 1, flickerstreak@8: get = function() return getOpacity("oom",getOpacity("notUsable")) end, flickerstreak@8: set = function(x) setOpacity("oom", x ~= getOpacity("notUsable") and x) end, flickerstreak@8: order = 3, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: oorange = { flickerstreak@8: type = "range", flickerstreak@8: name = "Out of Range", flickerstreak@8: desc = "Button opacity when the action is not usable due to the target not being in range. ".. flickerstreak@8: "By default this uses the generic 'not-usable' setting.", flickerstreak@8: min = 0, flickerstreak@8: max = 100, flickerstreak@8: step = 1, flickerstreak@8: get = function() return getOpacity("ooRange",getOpacity("notUsable")) end, flickerstreak@8: set = function(x) setOpacity("ooRange", x ~= getOpacity("notUsable") and x) end, flickerstreak@8: order = 4, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: empty = { flickerstreak@8: type = "range", flickerstreak@8: name = "Empty Slot", flickerstreak@8: desc = "Button opacity when the button's action slot is empty. By default this is 0 (fully transparent), ".. flickerstreak@8: "but note that they still block mouse clicks. Empty slots are automatically made opaque (per the ".. flickerstreak@8: "'usable' opacity setting) when moving actions around.", flickerstreak@8: min = 0, flickerstreak@8: max = 100, flickerstreak@8: step = 1, flickerstreak@8: get = function() return getOpacity("empty",0) end, flickerstreak@8: set = function(x) setOpacity("empty",x) end, flickerstreak@8: order = 5, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: hideEmpty = { flickerstreak@8: type = "toggle", flickerstreak@8: name = "Hide Empty Slots", flickerstreak@8: desc = "Hides empty action slots rather than changing their opacity. This has the advantage that empty slots ".. flickerstreak@8: "don't block mouse clicks. WARNING: this makes it impossible to re-arrange actions with drag-and-drop ".. flickerstreak@8: "while in combat.", flickerstreak@8: get = function() return config.hideEmptySlots end, flickerstreak@8: set = function() config.hideEmptySlots = not config.hideEmptySlots ; refresh() end, flickerstreak@8: order = 6, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: }, flickerstreak@10: order = 102, flickerstreak@10: }, flickerstreak@10: flickerstreak@10: displaysep = { flickerstreak@10: type = "header", flickerstreak@10: name = " ", flickerstreak@10: desc = " ", flickerstreak@10: order = 103, flickerstreak@10: }, flickerstreak@10: flickerstreak@10: showkeybind = { flickerstreak@10: type = "toggle", flickerstreak@10: name = "Show Hotkey", flickerstreak@10: desc = "Toggle show/hide hot key labels", flickerstreak@10: get = function() return config.showKeyBind end, flickerstreak@10: set = function() config.showKeyBind = not config.showKeyBind ; refresh() end, flickerstreak@10: order = 104, flickerstreak@8: }, flickerstreak@8: flickerstreak@7: keyloc = { flickerstreak@7: type = "text", flickerstreak@7: name = "Hotkey Location", flickerstreak@7: desc = "Sets hotkey location", flickerstreak@7: get = function() return config.keyBindLoc end, flickerstreak@7: set = function(loc) config.keyBindLoc = loc ; refresh() end, flickerstreak@10: hidden = function() return not config.showKeyBind end, flickerstreak@7: validate = labelPlacementOptions, flickerstreak@10: order = 105, flickerstreak@7: }, flickerstreak@7: flickerstreak@10: showKeyBindRight = { flickerstreak@10: type = "toggle", flickerstreak@10: name = "Show Right-click Hotkey", flickerstreak@10: desc = "Toggle show/hide right-click hot key labels", flickerstreak@10: get = function() return config.showKeyBindRight end, flickerstreak@10: set = function() config.showKeyBindRight = not config.showKeyBindRight ; refresh() end, flickerstreak@10: order = 106, flickerstreak@7: }, flickerstreak@7: flickerstreak@10: rightkeyloc = { flickerstreak@10: type = "text", flickerstreak@10: name = "Right-click Hotkey Location", flickerstreak@10: desc = "Sets right-click hotkey location", flickerstreak@10: get = function() return config.keyBindRightLoc end, flickerstreak@10: set = function(loc) config.keyBindRightLoc = loc ; refresh() end, flickerstreak@10: hidden = function() return not config.showKeyBindRight end, flickerstreak@10: validate = labelPlacementOptions, flickerstreak@10: order = 107, flickerstreak@10: }, flickerstreak@10: flickerstreak@10: colorhotkeys = { flickerstreak@7: type = "toggle", flickerstreak@10: name = "Colorize Hotkeys", flickerstreak@10: desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.", flickerstreak@10: get = function() return config.keyBindColorCode end, flickerstreak@10: set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end, flickerstreak@10: hidden = function() return not config.showKeyBind and not config.showKeyBindRight end, flickerstreak@10: order = 109, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: showstackcount = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Show Stack Count", flickerstreak@7: desc = "Toggle show/hide stack count labels", flickerstreak@7: get = function() return config.showStackCount end, flickerstreak@7: set = function() config.showStackCount = not config.showStackCount ; refresh() end, flickerstreak@10: order = 110, flickerstreak@10: }, flickerstreak@10: flickerstreak@10: stackloc = { flickerstreak@10: type = "text", flickerstreak@10: name = "Stack Count Location", flickerstreak@10: desc = "Sets stack count location", flickerstreak@10: get = function() return config.stackCountLoc end, flickerstreak@10: set = function(loc) config.stackCountLoc = loc ; refresh() end, flickerstreak@10: hidden = function() return not config.showStackCount end, flickerstreak@10: validate = labelPlacementOptions, flickerstreak@10: order = 111, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: showmacrotext = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Show Macro Names", flickerstreak@7: desc = "Toggle show/hide macro name labels", flickerstreak@7: get = function() return config.showMacroText end, flickerstreak@7: set = function() config.showMacroText = not config.showMacroText ; refresh() end, flickerstreak@10: order = 112, flickerstreak@7: }, flickerstreak@7: flickerstreak@8: hidecooldown = { flickerstreak@7: type = "toggle", flickerstreak@8: name = "Hide Cooldowns", flickerstreak@8: desc = "Hides all cooldown displays on buttons. Toggling this on does not hide currently running cooldowns.", flickerstreak@8: get = function() return config.hideCooldown end, flickerstreak@8: set = function() config.hideCooldown = not config.hideCooldown ; refresh() end, flickerstreak@10: order = 114, flickerstreak@8: }, flickerstreak@8: flickerstreak@8: hideglobalcooldown = { flickerstreak@8: type = "toggle", flickerstreak@8: name = "Hide Global Cooldown", flickerstreak@8: desc = "Disables the global cooldown from being displayed on buttons.", flickerstreak@8: get = function() return config.hideGlobalCooldown end, flickerstreak@8: set = function() config.hideGlobalCooldown = not config.hideGlobalCooldown ; refresh() end, flickerstreak@10: hidden = function() return not config.hideCooldown end, flickerstreak@10: order = 115, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: --[[ flickerstreak@7: hideborder = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Hide Border", flickerstreak@7: desc = "Toggles hiding of the button border frame.", flickerstreak@7: get = function() return not config.showBorder end, flickerstreak@7: set = function() config.showBorder = not config.showBorder ; refresh() end, flickerstreak@7: },]] flickerstreak@7: } flickerstreak@7: } flickerstreak@7: end flickerstreak@7: flickerstreak@7: flickerstreak@7: function PetAction:GenerateOptionsTable( config, buttonListFunc ) flickerstreak@7: flickerstreak@7: local function refresh() flickerstreak@7: for _, b in pairs(buttonListFunc()) do flickerstreak@7: b:UpdateAction() flickerstreak@7: b:UpdateTooltip() flickerstreak@7: b:UpdateDisplay() flickerstreak@7: end flickerstreak@7: end flickerstreak@7: flickerstreak@7: return { flickerstreak@7: type = "group", flickerstreak@7: args = { flickerstreak@7: keyloc = { flickerstreak@7: type = "text", flickerstreak@7: name = "Hotkey Location", flickerstreak@7: desc = "Sets hotkey location", flickerstreak@7: get = function() return config.keyBindLoc end, flickerstreak@7: set = function(loc) config.keyBindLoc = loc ; refresh() end, flickerstreak@7: validate = { "TOP", "BOTTOM", "LEFT", "RIGHT", "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT" }, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: showkeybind = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Show Hotkey", flickerstreak@7: desc = "Toggle show/hide hot key labels", flickerstreak@7: get = function() return config.showKeyBind end, flickerstreak@7: set = function() config.showKeyBind = not config.showGrid ; refresh() end, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: showgrid = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Always Show Buttons", flickerstreak@7: desc = "Show button placeholders when no action is assigned or on the cursor. Note that buttons are always shown when bars are unlocked.", flickerstreak@7: get = function() return config.showGrid end, flickerstreak@7: set = function() config.showGrid = not config.showGrid ; refresh() end, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: colorhotkeys = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Colorize Hotkeys", flickerstreak@7: desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.", flickerstreak@7: get = function() return config.keyBindColorCode end, flickerstreak@7: set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: --[[ flickerstreak@7: hideborder = { flickerstreak@7: type = "toggle", flickerstreak@7: name = "Hide Border", flickerstreak@7: desc = "Toggles hiding of the button border frame.", flickerstreak@7: get = function() return not config.showBorder end, flickerstreak@7: set = function() config.showBorder = not config.showBorder ; refresh() end, flickerstreak@7: },]] flickerstreak@7: } flickerstreak@7: } flickerstreak@7: end flickerstreak@7: flickerstreak@7: flickerstreak@7: flickerstreak@7: ---------------------- flickerstreak@7: -- Instance methods flickerstreak@7: ---------------------- flickerstreak@7: function Action.prototype:init( id ) flickerstreak@7: Action.super.prototype.init(self) flickerstreak@7: flickerstreak@7: self:SetupDisplay("ReActionButton"..id) flickerstreak@7: self:SetupAction() flickerstreak@10: ReBound:Register(self:GetActionFrame()) flickerstreak@7: end flickerstreak@7: flickerstreak@7: function PetAction.prototype:init( id ) flickerstreak@7: Action.super.prototype.init(self) flickerstreak@7: flickerstreak@7: self:SetupDisplay("ReActionPetButton"..id) flickerstreak@7: self:SetupAction() flickerstreak@10: ReBound:Register(self:GetActionFrame()) flickerstreak@7: end flickerstreak@7: