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