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@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@7: 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@7: stackCountLoc = "BOTTOMRIGHT", flickerstreak@7: showKeyBind = true, flickerstreak@7: showStackCount = true, flickerstreak@7: showMacroText = true, flickerstreak@7: showGrid = false, flickerstreak@7: showBorder = true, flickerstreak@7: keyBindColorCode = 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@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@7: }, flickerstreak@7: 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 = labelPlacementOptions, flickerstreak@7: }, flickerstreak@7: flickerstreak@7: stackloc = { flickerstreak@7: type = "text", flickerstreak@7: name = "Stack Count Location", flickerstreak@7: desc = "Sets stack count location", flickerstreak@7: get = function() return config.stackCountLoc end, flickerstreak@7: set = function(loc) config.stackCountLoc = loc ; refresh() end, flickerstreak@7: validate = labelPlacementOptions, 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.showKeyBind ; refresh() end, 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@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@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: 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@7: flickerstreak@7: -- register button with ReBound for keybinding flickerstreak@7: if ReBound then flickerstreak@7: ReBound:AddKeybindTarget(self:GetActionFrame()) flickerstreak@7: end 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@7: flickerstreak@7: -- register button with ReBound for keybinding flickerstreak@7: if ReBound then flickerstreak@7: ReBound:AddKeybindTarget(self:GetActionFrame()) flickerstreak@7: end flickerstreak@7: end flickerstreak@7: