changeset 108:b2fb8f7dc780

ButtonFacade support
author Flick <flickerstreak@gmail.com>
date Wed, 07 Jan 2009 00:57:02 +0000
parents 110ec60c7a66
children 410d036c43b2
files Bar.lua modules/ReAction_Action/ReAction_Action.lua modules/ReAction_ButtonFacade/ReAction_ButtonFacade.lua modules/ReAction_ButtonFacade/ReAction_ButtonFacade.toc modules/ReAction_ButtonFacade/ReAction_ButtonFacade.xml modules/ReAction_PetAction/ReAction_PetAction.lua modules/modules.xml
diffstat 7 files changed, 163 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Bar.lua	Tue Jan 06 21:10:03 2009 +0000
+++ b/Bar.lua	Wed Jan 07 00:57:02 2009 +0000
@@ -240,3 +240,6 @@
   end
 end
 
+function Bar:SkinButton()
+  -- does nothing by default
+end
\ No newline at end of file
--- a/modules/ReAction_Action/ReAction_Action.lua	Tue Jan 06 21:10:03 2009 +0000
+++ b/modules/ReAction_Action/ReAction_Action.lua	Wed Jan 07 00:57:02 2009 +0000
@@ -20,6 +20,7 @@
 
 -- libraries
 local KB = LibStub("LibKeyBound-1.0")
+local LBF -- initialized later
 
 -- module declaration
 local moduleID = "Action"
@@ -50,6 +51,8 @@
   ReAction.RegisterCallback(self, "OnRenameBar")
   ReAction.RegisterCallback(self, "OnConfigModeChanged")
 
+  LBF = LibStub("LibButtonFacade",true)
+
   KB.RegisterCallback(self, "LIBKEYBOUND_ENABLED")
   KB.RegisterCallback(self, "LIBKEYBOUND_DISABLED")
   KB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED")
@@ -962,7 +965,7 @@
       ]])
 
     self.frame = f
-    self.normalTexture = getglobal(format("%sNormalTexture",f:GetName()))
+
 
     -- initialize the hide state
     f:SetAttribute("showgrid",0)
@@ -977,6 +980,13 @@
     -- attach the keybinder
     KBAttach(self)
 
+    -- attach to skinner
+    bar:SkinButton(self,
+      {
+        HotKey = self.hotkey,
+      }
+    )
+
     self:Refresh()
     return self
   end
@@ -1103,7 +1113,11 @@
       f:SetAttribute("showgrid",count)
 
       if count >= 1 and not f:GetAttribute("statehidden") then
-        self.normalTexture:SetVertexColor(1.0, 1.0, 1.0, 0.5);
+        if LBF then
+          LBF:SetNormalVertexColor(self.frame, 1.0, 1.0, 1.0, 0.5)
+        else
+          self.frame:GetNormalTexture():SetVertexColor(1.0, 1.0, 1.0, 0.5);
+        end
         f:Show()
       elseif count < 1 and not HasAction(self:GetActionID()) then
         f:Hide()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ButtonFacade/ReAction_ButtonFacade.lua	Wed Jan 07 00:57:02 2009 +0000
@@ -0,0 +1,115 @@
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+local _G = _G
+
+-- module declaration
+local moduleID = "ButtonFacade"
+local module = ReAction:NewModule( moduleID )
+
+-- handlers
+function module:OnInitialize()
+  self.db = ReAction.db:RegisterNamespace( moduleID,
+    {
+      profile = {
+        -- default profile goes here
+      }
+    }
+  )
+
+  local LBF = LibStub("LibButtonFacade",true)
+
+  if not LBF then -- no more initialization
+    return
+  end
+
+  self.LBF = LBF
+  self.groups = { }
+
+  -- override a method of ReAction.Bar
+  -- note that 'self' in this context refers to the bar
+  function ReAction.Bar:SkinButton( button, data )
+    module:GetGroup(self:GetName()):AddButton(button:GetFrame(), data)
+  end
+
+  -- register some common events
+  ReAction.RegisterCallback(self, "OnCreateBar")
+  ReAction.RegisterCallback(self, "OnDestroyBar")
+  ReAction.RegisterCallback(self, "OnRefreshBar")
+  ReAction.RegisterCallback(self, "OnEraseBar")
+  ReAction.RegisterCallback(self, "OnRenameBar")
+
+  self.LBF:RegisterSkinCallback("ReAction", self.OnSkinChanged, self)
+end
+
+function module:OnEnable()
+
+end
+
+function module:OnDisable()
+
+end
+
+function module:OnCreateBar(event, bar, name)
+  local c = self.db.profile[name]
+  if not c then
+     c = { 
+      skinID = "Blizzard",
+      backdrop = true,
+      gloss = 0,
+      colors = {},
+    }
+    self.db.profile[name] = c
+  end
+
+  local g = self:GetGroup(name)
+  g.SkinID   = c.skinID or "Blizzard"
+  g.Backdrop = c.backdrop
+  g.Gloss    = c.gloss
+  g.Colors   = c.colors
+end
+
+function module:OnDestroyBar(event, bar, name)
+  if self.groups[name] then
+    self.groups[name]:Delete()
+    self.groups[name] = nil
+  end
+end
+
+function module:OnRefreshBar(event, bar, name)
+  local c = self.db.profile[name]
+  local g = self.groups[name]
+  if c and g then
+    g:Skin(c.skinID, c.gloss, c.backdrop, c.colors)
+  end
+end
+
+function module:OnEraseBar(event, bar, name)
+  self:OnDestroyBar(event, bar, name)
+  self.db.profile[name] = nil
+end
+
+function module:OnRenameBar(event, bar, oldName, newName)
+  if self.groups[name] then
+    self.groups[name]:Delete(true)
+    self.db.profile[oldName], self.db.profile[newName] = nil, self.db.profile[oldName]
+    self:OnCreateBar(event, bar, newName)
+  end
+end
+
+function module:OnSkinChanged( skinID, gloss, backdrop, group, button, colors )
+  local c = self.db.profile[group]
+  if c then
+    c.skinID   = skinID
+    c.gloss    = gloss
+    c.backdrop = backdrop
+    c.colors   = colors
+  end  
+end
+
+function module:GetGroup( name )
+  if not self.groups[name] then
+    self.groups[name] = self.LBF:Group("ReAction", name)
+  end
+  return self.groups[name]
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ButtonFacade/ReAction_ButtonFacade.toc	Wed Jan 07 00:57:02 2009 +0000
@@ -0,0 +1,11 @@
+## Interface: 30000
+## Title: ReAction: ButtonFacade
+## Notes: ButtonFacade support for ReAction
+## DefaultState: enabled
+## LoadOnDemand: 1
+## Author: Flick
+## Version: 1.0
+## X-Category: Action Bars
+## Dependencies: ReAction
+
+ReAction_ButtonFacade.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ButtonFacade/ReAction_ButtonFacade.xml	Wed Jan 07 00:57:02 2009 +0000
@@ -0,0 +1,7 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
+
+<Script file="ReAction_ButtonFacade.lua"/>
+
+</Ui>
\ No newline at end of file
--- a/modules/ReAction_PetAction/ReAction_PetAction.lua	Tue Jan 06 21:10:03 2009 +0000
+++ b/modules/ReAction_PetAction/ReAction_PetAction.lua	Wed Jan 07 00:57:02 2009 +0000
@@ -495,6 +495,13 @@
 
   KBAttach(self)
 
+  -- attach to skinner
+  bar:SkinButton(self,
+    {
+      HotKey = self.hotkey,
+    }
+  )
+
   self:Refresh()
   self:SetKeybindMode(ReAction:GetKeybindMode())
 
--- a/modules/modules.xml	Tue Jan 06 21:10:03 2009 +0000
+++ b/modules/modules.xml	Wed Jan 07 00:57:02 2009 +0000
@@ -11,4 +11,8 @@
 <Include file="ReAction_Action\ReAction_Action.xml"/>
 <Include file="ReAction_PetAction\ReAction_PetAction.xml"/>
 
+
+<!-- other modules -->
+<Include file="ReAction_ButtonFacade\ReAction_ButtonFacade.xml"/>
+
 </Ui>
\ No newline at end of file