annotate modules/PetAction.lua @ 234:0e20f65375d5

Reworked button creation to not use goofy event driven semantics.
author Flick
date Tue, 22 Mar 2011 17:05:51 -0700
parents c4b134512c50
children
rev   line source
flickerstreak@28 1 --[[
Flick@234 2 ReAction Pet Action button options module
flickerstreak@28 3 --]]
flickerstreak@28 4
flickerstreak@28 5 -- local imports
flickerstreak@175 6 local addonName, addonTable = ...
flickerstreak@175 7 local ReAction = addonTable.ReAction
flickerstreak@28 8 local L = ReAction.L
flickerstreak@28 9 local _G = _G
flickerstreak@53 10 local CreateFrame = CreateFrame
flickerstreak@95 11 local format = string.format
flickerstreak@28 12
flickerstreak@28 13 -- module declaration
flickerstreak@28 14 local moduleID = "PetAction"
flickerstreak@28 15 local module = ReAction:NewModule( moduleID )
flickerstreak@28 16
flickerstreak@130 17 -- Button class
flickerstreak@130 18 local Button = ReAction.Button.PetAction
flickerstreak@77 19
flickerstreak@102 20
flickerstreak@28 21 -- module methods
flickerstreak@28 22 function module:OnInitialize()
flickerstreak@63 23 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions")
flickerstreak@28 24 end
flickerstreak@28 25
flickerstreak@53 26
flickerstreak@53 27
flickerstreak@53 28
flickerstreak@60 29 ---- Options ----
flickerstreak@102 30 local Handler = { }
flickerstreak@102 31 local meta = { __index = Handler }
flickerstreak@102 32
flickerstreak@102 33 function Handler:New(bar)
flickerstreak@102 34 return setmetatable(
flickerstreak@102 35 {
flickerstreak@102 36 bar = bar,
flickerstreak@102 37 config = bar.config
flickerstreak@102 38 }, meta)
flickerstreak@102 39 end
flickerstreak@102 40
flickerstreak@102 41 function Handler:GetLockButtons()
flickerstreak@130 42 return self.config.lockButtons
flickerstreak@102 43 end
flickerstreak@102 44
flickerstreak@102 45 function Handler:SetLockButtons(info, value)
flickerstreak@102 46 self.config.lockButtons = value
Flick@234 47 Button:UpdateButtonLock(self.bar)
flickerstreak@102 48 end
flickerstreak@102 49
flickerstreak@102 50 function Handler:GetLockButtonsCombat()
flickerstreak@102 51 return self.config.lockButtonsCombat
flickerstreak@102 52 end
flickerstreak@102 53
flickerstreak@102 54 function Handler:SetLockButtonsCombat(info, value)
flickerstreak@102 55 self.config.lockButtonsCombat = value
Flick@234 56 Button:UpdateButtonLock(self.bar)
flickerstreak@102 57 end
flickerstreak@102 58
flickerstreak@102 59 function Handler:LockButtonsCombatDisabled()
flickerstreak@130 60 return not self.config.lockButtons
flickerstreak@102 61 end
flickerstreak@102 62
flickerstreak@102 63
flickerstreak@60 64 function module:GetBarOptions(bar)
flickerstreak@91 65 if bar.config.type == moduleID then
flickerstreak@91 66 return {
flickerstreak@91 67 type = "group",
flickerstreak@91 68 name = L["Pet Buttons"],
flickerstreak@102 69 handler = Handler:New(bar),
flickerstreak@91 70 args = {
flickerstreak@102 71 lockButtons = {
flickerstreak@102 72 name = L["Lock Buttons"],
flickerstreak@147 73 desc = L["Prevents picking up/dragging actions (use SHIFT to override this behavior)"],
flickerstreak@102 74 order = 2,
flickerstreak@102 75 type = "toggle",
flickerstreak@102 76 get = "GetLockButtons",
flickerstreak@102 77 set = "SetLockButtons",
flickerstreak@102 78 },
flickerstreak@102 79 lockOnlyCombat = {
flickerstreak@102 80 name = L["Only in Combat"],
flickerstreak@102 81 desc = L["Only lock the buttons when in combat"],
flickerstreak@102 82 order = 3,
flickerstreak@102 83 type = "toggle",
flickerstreak@102 84 disabled = "LockButtonsCombatDisabled",
flickerstreak@102 85 get = "GetLockButtonsCombat",
flickerstreak@102 86 set = "SetLockButtonsCombat",
flickerstreak@102 87 },
flickerstreak@91 88 }
flickerstreak@60 89 }
flickerstreak@91 90 end
flickerstreak@59 91 end
flickerstreak@59 92
flickerstreak@53 93