comparison modules/ReAction_Action/ReAction_Action.lua @ 49:dcf8116560a1

added hide empty buttons
author Flick <flickerstreak@gmail.com>
date Mon, 14 Apr 2008 23:03:19 +0000
parents 7b7d178dec52
children c3c64e2def50
comparison
equal deleted inserted replaced
48:7b7d178dec52 49:dcf8116560a1
26 buttons = { } 26 buttons = { }
27 } 27 }
28 } 28 }
29 ) 29 )
30 self.buttons = { } 30 self.buttons = { }
31
32 ReAction:RegisterOptions("global", self, {
33 hideEmpty = {
34 type = "toggle",
35 name = L["Hide Empty Buttons"],
36 get = function() return self.db.profile.hideEmptyButtons end,
37 set = function(info, val) module:SetHideEmptyButtons(val) end,
38 }
39 })
31 end 40 end
32 41
33 function module:OnEnable() 42 function module:OnEnable()
34 ReAction:RegisterDefaultBarConfig(L["Action Bar"], { type = "actionbar" }, true) 43 ReAction:RegisterDefaultBarConfig(L["Action Bar"], { type = "actionbar" }, true)
35 end 44 end
97 function module:RenameBarConfig(oldname, newname) 106 function module:RenameBarConfig(oldname, newname)
98 local b = self.db.profile.buttons 107 local b = self.db.profile.buttons
99 b[newname], b[oldname] = b[oldname], nil 108 b[newname], b[oldname] = b[oldname], nil
100 end 109 end
101 110
111 function module:SetHideEmptyButtons(hide)
112 if hide ~= self.db.profile.hideEmptyButtons then
113 for _, bar in pairs(self.buttons) do
114 for _, b in pairs(bar) do
115 if hide then
116 ActionButton_HideGrid(b.frame)
117 else
118 ActionButton_ShowGrid(b.frame)
119 end
120 end
121 end
122 self.db.profile.hideEmptyButtons = hide
123 end
124 end
125
102 function module:ApplyConfigMode(mode,bars) 126 function module:ApplyConfigMode(mode,bars)
103 for _, btns in pairs(self.buttons) do 127 for _, bar in pairs(bars) do
104 if btn then 128 if bar and self.buttons[bar] then
105 for _, b in pairs(btns) do 129 for _, b in pairs(self.buttons[bar]) do
106 if b then 130 if b then
107 if mode then 131 if mode then
132 ActionButton_ShowGrid(b.frame)
108 if not b.actionIDLabel then 133 if not b.actionIDLabel then
109 local label = b:GetFrame():CreateFontString(nil,"OVERLAY","GameFontNormalLarge") 134 local label = b:GetFrame():CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
110 label:SetAllPoints() 135 label:SetAllPoints()
111 label:SetJustifyH("CENTER") 136 label:SetJustifyH("CENTER")
112 label:SetShadowColor(0,0,0,1) 137 label:SetShadowColor(0,0,0,1)
113 label:SetShadowOffset(2,-2) 138 label:SetShadowOffset(2,-2)
114 label:SetText(tostring(b:GetActionID())) 139 label:SetText(tostring(b:GetActionID()))
115 b.actionIDLabel = label 140 b.actionIDLabel = label
116 end 141 end
117 b.actionIDLabel:Show() 142 b.actionIDLabel:Show()
118 elseif b.actionIDLabel then 143 else
119 b.actionIDLabel:Hide() 144 if b.actionIDLabel then
145 b.actionIDLabel:Hide()
146 end
147 ActionButton_HideGrid(b.frame)
120 end 148 end
149
121 end 150 end
122 end 151 end
123 end 152 end
124 end 153 end
125 end 154 end
162 local function Constructor( self, bar, idx, config ) 191 local function Constructor( self, bar, idx, config )
163 self.bar, self.idx, self.config = bar, idx, config 192 self.bar, self.idx, self.config = bar, idx, config
164 193
165 local barFrame = bar:GetFrame() 194 local barFrame = bar:GetFrame()
166 195
167 self.name = config.name or "ReAction_"..bar:GetName().."_"..idx 196 config.name = config.name or "ReAction_"..bar:GetName().."_"..idx
197 self.name = config.name
168 config.actionID = ActionIDList[config.actionID] -- gets a free one if none configured 198 config.actionID = ActionIDList[config.actionID] -- gets a free one if none configured
169 199
170 local f = CreateFrame("CheckButton", self.name, barFrame, "ActionBarButtonTemplate") 200 local f = CreateFrame("CheckButton", self.name, barFrame, "ActionBarButtonTemplate")
201
171 -- TODO: re-implement ActionButton event handlers that don't do secure stuff 202 -- TODO: re-implement ActionButton event handlers that don't do secure stuff
172 203
173 -- this will probably cause taint, using right now for display/debugging purposes 204 -- this will probably cause taint, using right now for display/debugging purposes
174 f:SetScript("OnAttributeChanged", ActionButton_UpdateAction) 205 f:SetScript("OnAttributeChanged", ActionButton_UpdateAction)
175 f:SetAttribute("action", config.actionID) 206 f:SetAttribute("action", config.actionID)
207
176 barFrame:SetAttribute("addchild",f) 208 barFrame:SetAttribute("addchild",f)
209
177 self.frame = f 210 self.frame = f
178 self:Refresh(bar,idx) 211 self:Refresh(bar,idx)
212
213 if not module.db.profile.hideEmptyButtons then
214 ActionButton_ShowGrid(self.frame)
215 end
179 end 216 end
180 217
181 function Button:Destroy() 218 function Button:Destroy()
182 local f = self.frame 219 local f = self.frame
183 f:UnregisterAllEvents() 220 f:UnregisterAllEvents()