annotate Buttons.lua @ 7:f920db5fc6b1

version 0.3
author Flick <flickerstreak@gmail.com>
date Tue, 20 Mar 2007 21:25:29 +0000
parents
children c05fd3e18b4f
rev   line source
flickerstreak@7 1 -- Buttons.lua
flickerstreak@7 2 --
flickerstreak@7 3 -- Defines button types for use with the ReAction AddOn
flickerstreak@7 4 --
flickerstreak@7 5
flickerstreak@7 6 local AceOO = AceLibrary("AceOO-2.0")
flickerstreak@7 7
flickerstreak@7 8 local Action = AceOO.Class(
flickerstreak@7 9 ReAction,
flickerstreak@7 10 ReAction.ActionType,
flickerstreak@7 11 ReAction.ActionDisplay,
flickerstreak@7 12 ReAction.DefaultColorScheme
flickerstreak@7 13 )
flickerstreak@7 14
flickerstreak@7 15 local PetAction = AceOO.Class(
flickerstreak@7 16 ReAction,
flickerstreak@7 17 ReAction.PetActionType,
flickerstreak@7 18 ReAction.PetActionDisplay,
flickerstreak@7 19 ReAction.DefaultColorScheme
flickerstreak@7 20 )
flickerstreak@7 21
flickerstreak@7 22
flickerstreak@7 23 ReAction:AddButtonType( "Action", Action, 120 )
flickerstreak@7 24 ReAction:AddButtonType( "Pet Action", PetAction, 10 )
flickerstreak@7 25
flickerstreak@7 26
flickerstreak@7 27
flickerstreak@7 28 -----------------------
flickerstreak@7 29 -- static class members
flickerstreak@7 30 -----------------------
flickerstreak@7 31 Action.defaultProfile = {
flickerstreak@7 32 type = "ReAction",
flickerstreak@7 33 subtype = "Action",
flickerstreak@7 34 ids = { },
flickerstreak@7 35 selfcast = nil,
flickerstreak@7 36 keyBindLoc = "TOPRIGHT",
flickerstreak@7 37 stackCountLoc = "BOTTOMRIGHT",
flickerstreak@7 38 showKeyBind = true,
flickerstreak@7 39 showStackCount = true,
flickerstreak@7 40 showMacroText = true,
flickerstreak@7 41 showGrid = false,
flickerstreak@7 42 showBorder = true,
flickerstreak@7 43 keyBindColorCode = false,
flickerstreak@7 44 }
flickerstreak@7 45
flickerstreak@7 46 PetAction.defaultProfile = {
flickerstreak@7 47 type = "ReAction",
flickerstreak@7 48 subtype = "Pet Action",
flickerstreak@7 49 ids = { },
flickerstreak@7 50 keyBindLoc = "TOPRIGHT",
flickerstreak@7 51 showKeyBind = false,
flickerstreak@7 52 showGrid = false,
flickerstreak@7 53 showBorder = true,
flickerstreak@7 54 keyBindColorCode = false,
flickerstreak@7 55 }
flickerstreak@7 56
flickerstreak@7 57
flickerstreak@7 58
flickerstreak@7 59 -----------------------
flickerstreak@7 60 -- static class methods
flickerstreak@7 61 -----------------------
flickerstreak@7 62 function Action:GetDefaultProfile()
flickerstreak@7 63 return self.defaultProfile
flickerstreak@7 64 end
flickerstreak@7 65
flickerstreak@7 66 function PetAction:GetDefaultProfile()
flickerstreak@7 67 return self.defaultProfile
flickerstreak@7 68 end
flickerstreak@7 69
flickerstreak@7 70
flickerstreak@7 71
flickerstreak@7 72 local labelPlacementOptions = {
flickerstreak@7 73 "TOP",
flickerstreak@7 74 "BOTTOM",
flickerstreak@7 75 "LEFT",
flickerstreak@7 76 "RIGHT",
flickerstreak@7 77 "TOPLEFT",
flickerstreak@7 78 "TOPRIGHT",
flickerstreak@7 79 "BOTTOMLEFT",
flickerstreak@7 80 "BOTTOMRIGHT"
flickerstreak@7 81 }
flickerstreak@7 82
flickerstreak@7 83
flickerstreak@7 84 function Action:GenerateOptionsTable( config, buttonListFunc )
flickerstreak@7 85
flickerstreak@7 86 local function refresh()
flickerstreak@7 87 for _, b in pairs(buttonListFunc()) do
flickerstreak@7 88 b:UpdateAction()
flickerstreak@7 89 b:UpdateTooltip()
flickerstreak@7 90 b:UpdateDisplay()
flickerstreak@7 91 end
flickerstreak@7 92 end
flickerstreak@7 93
flickerstreak@7 94 return {
flickerstreak@7 95 type = "group",
flickerstreak@7 96 args = {
flickerstreak@7 97 selfcast = {
flickerstreak@7 98 type = "text",
flickerstreak@7 99 name = "Self Cast",
flickerstreak@7 100 desc = "Choose a modifier key to hold down or an alternate button to click to self-cast spells. "..
flickerstreak@7 101 "'default' uses the settings in the Interface Options Advanced panel (use this to achieve 'smart self cast'). "..
flickerstreak@7 102 "'right-click' self-casting is not supported for multi-page bars.",
flickerstreak@7 103 get = function() return config.selfcast or "default" end,
flickerstreak@7 104 set = function(opt)
flickerstreak@7 105 if opt == "default" then opt = nil end
flickerstreak@7 106 config.selfcast = opt
flickerstreak@7 107 for _, b in pairs(buttonListFunc()) do
flickerstreak@7 108 b:UpdateSelfcast()
flickerstreak@7 109 end
flickerstreak@7 110 end,
flickerstreak@7 111 validate = { "default", "none", "alt", "ctrl", "shift", "right-click" },
flickerstreak@7 112 },
flickerstreak@7 113
flickerstreak@7 114 keyloc = {
flickerstreak@7 115 type = "text",
flickerstreak@7 116 name = "Hotkey Location",
flickerstreak@7 117 desc = "Sets hotkey location",
flickerstreak@7 118 get = function() return config.keyBindLoc end,
flickerstreak@7 119 set = function(loc) config.keyBindLoc = loc ; refresh() end,
flickerstreak@7 120 validate = labelPlacementOptions,
flickerstreak@7 121 },
flickerstreak@7 122
flickerstreak@7 123 stackloc = {
flickerstreak@7 124 type = "text",
flickerstreak@7 125 name = "Stack Count Location",
flickerstreak@7 126 desc = "Sets stack count location",
flickerstreak@7 127 get = function() return config.stackCountLoc end,
flickerstreak@7 128 set = function(loc) config.stackCountLoc = loc ; refresh() end,
flickerstreak@7 129 validate = labelPlacementOptions,
flickerstreak@7 130 },
flickerstreak@7 131
flickerstreak@7 132 showkeybind = {
flickerstreak@7 133 type = "toggle",
flickerstreak@7 134 name = "Show Hotkey",
flickerstreak@7 135 desc = "Toggle show/hide hot key labels",
flickerstreak@7 136 get = function() return config.showKeyBind end,
flickerstreak@7 137 set = function() config.showKeyBind = not config.showKeyBind ; refresh() end,
flickerstreak@7 138 },
flickerstreak@7 139
flickerstreak@7 140 showstackcount = {
flickerstreak@7 141 type = "toggle",
flickerstreak@7 142 name = "Show Stack Count",
flickerstreak@7 143 desc = "Toggle show/hide stack count labels",
flickerstreak@7 144 get = function() return config.showStackCount end,
flickerstreak@7 145 set = function() config.showStackCount = not config.showStackCount ; refresh() end,
flickerstreak@7 146 },
flickerstreak@7 147
flickerstreak@7 148 showmacrotext = {
flickerstreak@7 149 type = "toggle",
flickerstreak@7 150 name = "Show Macro Names",
flickerstreak@7 151 desc = "Toggle show/hide macro name labels",
flickerstreak@7 152 get = function() return config.showMacroText end,
flickerstreak@7 153 set = function() config.showMacroText = not config.showMacroText ; refresh() end,
flickerstreak@7 154 },
flickerstreak@7 155
flickerstreak@7 156 showgrid = {
flickerstreak@7 157 type = "toggle",
flickerstreak@7 158 name = "Always Show Buttons",
flickerstreak@7 159 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 160 get = function() return config.showGrid end,
flickerstreak@7 161 set = function() config.showGrid = not config.showGrid ; refresh() end,
flickerstreak@7 162 },
flickerstreak@7 163
flickerstreak@7 164 colorhotkeys = {
flickerstreak@7 165 type = "toggle",
flickerstreak@7 166 name = "Colorize Hotkeys",
flickerstreak@7 167 desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.",
flickerstreak@7 168 get = function() return config.keyBindColorCode end,
flickerstreak@7 169 set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end,
flickerstreak@7 170 },
flickerstreak@7 171
flickerstreak@7 172 --[[
flickerstreak@7 173 hideborder = {
flickerstreak@7 174 type = "toggle",
flickerstreak@7 175 name = "Hide Border",
flickerstreak@7 176 desc = "Toggles hiding of the button border frame.",
flickerstreak@7 177 get = function() return not config.showBorder end,
flickerstreak@7 178 set = function() config.showBorder = not config.showBorder ; refresh() end,
flickerstreak@7 179 },]]
flickerstreak@7 180 }
flickerstreak@7 181 }
flickerstreak@7 182 end
flickerstreak@7 183
flickerstreak@7 184
flickerstreak@7 185 function PetAction:GenerateOptionsTable( config, buttonListFunc )
flickerstreak@7 186
flickerstreak@7 187 local function refresh()
flickerstreak@7 188 for _, b in pairs(buttonListFunc()) do
flickerstreak@7 189 b:UpdateAction()
flickerstreak@7 190 b:UpdateTooltip()
flickerstreak@7 191 b:UpdateDisplay()
flickerstreak@7 192 end
flickerstreak@7 193 end
flickerstreak@7 194
flickerstreak@7 195 return {
flickerstreak@7 196 type = "group",
flickerstreak@7 197 args = {
flickerstreak@7 198 keyloc = {
flickerstreak@7 199 type = "text",
flickerstreak@7 200 name = "Hotkey Location",
flickerstreak@7 201 desc = "Sets hotkey location",
flickerstreak@7 202 get = function() return config.keyBindLoc end,
flickerstreak@7 203 set = function(loc) config.keyBindLoc = loc ; refresh() end,
flickerstreak@7 204 validate = { "TOP", "BOTTOM", "LEFT", "RIGHT", "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT" },
flickerstreak@7 205 },
flickerstreak@7 206
flickerstreak@7 207 showkeybind = {
flickerstreak@7 208 type = "toggle",
flickerstreak@7 209 name = "Show Hotkey",
flickerstreak@7 210 desc = "Toggle show/hide hot key labels",
flickerstreak@7 211 get = function() return config.showKeyBind end,
flickerstreak@7 212 set = function() config.showKeyBind = not config.showGrid ; refresh() end,
flickerstreak@7 213 },
flickerstreak@7 214
flickerstreak@7 215 showgrid = {
flickerstreak@7 216 type = "toggle",
flickerstreak@7 217 name = "Always Show Buttons",
flickerstreak@7 218 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 219 get = function() return config.showGrid end,
flickerstreak@7 220 set = function() config.showGrid = not config.showGrid ; refresh() end,
flickerstreak@7 221 },
flickerstreak@7 222
flickerstreak@7 223 colorhotkeys = {
flickerstreak@7 224 type = "toggle",
flickerstreak@7 225 name = "Colorize Hotkeys",
flickerstreak@7 226 desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.",
flickerstreak@7 227 get = function() return config.keyBindColorCode end,
flickerstreak@7 228 set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end,
flickerstreak@7 229 },
flickerstreak@7 230
flickerstreak@7 231 --[[
flickerstreak@7 232 hideborder = {
flickerstreak@7 233 type = "toggle",
flickerstreak@7 234 name = "Hide Border",
flickerstreak@7 235 desc = "Toggles hiding of the button border frame.",
flickerstreak@7 236 get = function() return not config.showBorder end,
flickerstreak@7 237 set = function() config.showBorder = not config.showBorder ; refresh() end,
flickerstreak@7 238 },]]
flickerstreak@7 239 }
flickerstreak@7 240 }
flickerstreak@7 241 end
flickerstreak@7 242
flickerstreak@7 243
flickerstreak@7 244
flickerstreak@7 245 ----------------------
flickerstreak@7 246 -- Instance methods
flickerstreak@7 247 ----------------------
flickerstreak@7 248 function Action.prototype:init( id )
flickerstreak@7 249 Action.super.prototype.init(self)
flickerstreak@7 250
flickerstreak@7 251 self:SetupDisplay("ReActionButton"..id)
flickerstreak@7 252 self:SetupAction()
flickerstreak@7 253
flickerstreak@7 254 -- register button with ReBound for keybinding
flickerstreak@7 255 if ReBound then
flickerstreak@7 256 ReBound:AddKeybindTarget(self:GetActionFrame())
flickerstreak@7 257 end
flickerstreak@7 258 end
flickerstreak@7 259
flickerstreak@7 260 function PetAction.prototype:init( id )
flickerstreak@7 261 Action.super.prototype.init(self)
flickerstreak@7 262
flickerstreak@7 263 self:SetupDisplay("ReActionPetButton"..id)
flickerstreak@7 264 self:SetupAction()
flickerstreak@7 265
flickerstreak@7 266 -- register button with ReBound for keybinding
flickerstreak@7 267 if ReBound then
flickerstreak@7 268 ReBound:AddKeybindTarget(self:GetActionFrame())
flickerstreak@7 269 end
flickerstreak@7 270 end
flickerstreak@7 271