View Single Post
12-01-11, 01:59 AM   #8
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
What I've been working on:

https://gist.github.com/fc52a4369833ec30e03f
lua Code:
  1. local addon = CreateFrame('Frame')
  2. addon:RegisterEvent('PLAYER_LOGIN')
  3. addon:SetScript('OnEvent', function(self, event) self[event](ExtraActionBarFrame, event) end)
  4.  
  5. function addon:PLAYER_LOGIN()
  6.     if(UIPARENT_MANAGED_FRAME_POSITIONS.ExtraActionBarFrame) then
  7.         UIPARENT_MANAGED_FRAME_POSITIONS.ExtraActionBarFrame = nil
  8.     end
  9.  
  10.     self:SetParent(UIParent)
  11.     self:SetMovable(true)
  12.     self:EnableMouse(true)
  13.     self:RegisterForDrag('LeftButton')
  14.  
  15.     self:ClearAllPoints()
  16.     if(ExtraBarPosition) then
  17.         local point, x, y = string.split('\031', ExtraBarPosition)
  18.         self:SetPoint(point, UIParent, point, x, y)
  19.     else
  20.         ExtraBarPosition = 'LEFT\03140\0310'
  21.         self:SetPoint('LEFT', 40, 0)
  22.     end
  23.  
  24.    
  25.     self:SetScript('OnDragStart', function(self)
  26.         if(IsAltKeyDown()) then
  27.             self:StartMoving()
  28.         end
  29.     end)
  30.  
  31.     self:SetScript('OnDragStop', function(self)
  32.         self:StopMovingOrSizing()
  33.  
  34.         local point, _, _, x, y = self:GetPoint()
  35.         ExtraBarPosition = string.format('%s\031%d\031%d', point, x, y)
  36.  
  37.         if(InCombatLockdown()) then
  38.             self:ClearAllPoints()
  39.             self:SetPoint(point, UIParent, point, x, y)
  40.         else
  41.             addon:RegisterEvent('PLAYER_REGEN_ENABLED')
  42.         end
  43.     end)
  44. end
  45.  
  46. function addon:PLAYER_REGEN_ENABLED(event)
  47.     addon:UnregisterEvent(event)
  48.  
  49.     local point, x, y = string.split('\031', ExtraBarPosition)
  50.     self:ClearAllPoints()
  51.     self:SetPoint(point, UIParent, point, x, y)
  52. end
  Reply With Quote