Quantcast
WoWInterface: SVN - zz_Actionbuttons - Path Comparison - / Rev 9 and / Rev 10

WoWInterface SVN zz_Actionbuttons

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 9 to Rev 10
    Reverse comparison

Rev 9 → Rev 10

trunk/zz_Actionbuttons/core.lua
3,25 → 3,143
local options, db
local _,class = UnitClass('player')
local _G = _G
local xoffset, yoffset = 8,0
local xoffset, yoffset = 4,4
local buttons = {}
 
local function createBar(bid)
local f = CreateFrame("Frame", "zzABar"..bid, UIParent, "SecureHandlerStateTemplate",bid)
addon['MSQ'] = LibStub("Masque",true)
if(addon['MSQ']) then addon['MSQGroup'] = addon['MSQ']:Group(name,name) end
 
local function hideBlizz()
local hide = {
MainMenuBar,
ReputationWatchBar,
MainMenuExpBar,
BonusActionBarFrame,
BonusActionBarFrameTexture1,
BonusActionBarFrameTexture2,
BonusActionBarFrameTexture3,
BonusActionBarFrameTexture4,
}
for i = 1, #hide do
local f = hide[i]
if(type(f.UnregisterAllEvents) == 'function') then f:UnregisterAllEvents() end
f.Show = f.Hide
f:Hide()
end
end
 
local function applySettings(bname, bh)
 
db = addon['updateDB'](addon['db']['profile'])
local f = _G[bname]
if(not f) then return end
local spr = db['bars'][bname]['cols']
local y,row = 1,0
local lastbutton = f
f:SetScale(db['bars'][bname]['scale'])
if(f['sbuttons']) then
for i = 1, #f['sbuttons'] do
local btn = f['sbuttons'][i]
bh = bh or btn:GetHeight()
btn:SetParent(f)
btn:ClearAllPoints()
if(y == 1) then
 
btn:SetPoint("TOPLEFT", f, "TOPLEFT",0 , -row * bh + yoffset)
else
btn:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT",xoffset,0)
end
y = y + 1
if(not f['skipMasque'] and addon['MSQ'] and addon['MSQGroup'] and not buttons[btn]) then
buttons[btn] = true
addon['MSQGroup']:AddButton(btn)
end
lastbutton = btn
if(y > spr) then
y = 1
row = row + 1
end
end
end
if(row < 1) then row = 1 end
if(db['bars'][bname]['cols'] > f['maxslots']) then db['bars'][bname]['cols'] = f['maxslots'] end
bh = bh or 0
f:SetWidth(db['bars'][bname]['cols']*(lastbutton:GetWidth() + xoffset) -xoffset)
f:SetHeight(row * (bh + yoffset) - yoffset)
end
addon['applySettings'] = applySettings
local function getButton(parent, id, offset)
local btn
if(offset <= 12) then
btn = _G['ActionButton'..id]
elseif(offset <= 24) then
 
elseif(offset <= 36) then
btn = _G['MultiBarRightButton'..id]
elseif(offset <= 48) then
btn = _G['MultiBarLeftButton'..id]
elseif(offset <= 60) then
btn = _G['MultiBarBottomRightButton'..id]
elseif(offset <= 72) then
btn = _G['MultiBarBottomLeftButton'..id]
elseif((offset > 190) and (offset <= 200)) then
btn = _G['ShapeshiftButton'..id]
elseif((offset > 200) and (offset <= 210)) then
btn = _G['PetActionButton'..id]
end
 
if(not btn) then
btn = CreateFrame("CheckButton", "$PARENTActionButton"..offset, parent, "ActionButtonTemplate ActionBarButtonCodeTemplate",id)
btn['buttonType'] = "ZZACTIONBUTTON"
else
-- btn:GetParent():UnregisterAllEvents()
btn:GetParent():Hide()
btn:GetParent().Show = btn:GetParent().Hide
btn:ClearAllPoints()
btn:SetParent(parent)
end
-- print(parent, id, offset, btn:GetName())
return btn
end
 
local function createBar(bid,mb)
mb = mb or 12
local yoff =-yoffset - 40 * (bid-1)
local f = CreateFrame("Frame", "zzABar"..bid, UIParent, "SecureHandlerStateTemplate",bid == 1 and bid or nil)
f['sbuttons'] = {}
f['maxslots'] = mb
f:SetWidth(1)
f:SetHeight(1)
f:SetPoint("CENTER")
f:SetAttribute('actionpage', bid)
-- if(bid == 1) then
f:SetPoint("CENTER", xoffset, yoff)
if(bid > 1 and bid < 7) then
f:SetAttribute('actionpage', bid)
end
if(bid == 1) then
f:SetAttribute('_onstate-page', [[
print(newstate)
if(self:GetID() == 1) then
self:SetAttribute('actionpage', newstate)
control:ChildUpdate('actionpage', newstate)
else
control:ChildUpdate('actionpage', self:GetID())
end
 
]])
f:SetAttribute('_onstate-possess', [[
if(self:GetID() == 1) then
self:SetAttribute('actionpage', newstate)
control:ChildUpdate('actionpage', newstate)
else
control:ChildUpdate('actionpage', self:GetID())
end
]])
f:SetAttribute('_onstate-vehicle', [[
if(newstate == 'vehicle') then
control:ChildUpdate('actionpage', self:GetID())
elseif(newstate == 'novehicle') then
self:SetAttribute('actionpage', nil)
control:ChildUpdate('actionpage', self:GetID())
end
print(newstate, self:GetAttribute('action--old'),self:GetAttribute('actionpage'))
]])
if(class == "WARRIOR") then
RegisterStateDriver(f, "page", "[bonusbar:1] 7;[bonusbar:2] 8;[bonusbar:3] 9;1")
elseif(class == "DRUID") then
31,40 → 149,96
elseif(class == "PRIEST") then
RegisterStateDriver(f, "page", "[stance:1] 7; 1")
end
-- end
RegisterStateDriver(f, "possess", "[bonusbar:5] 11")
RegisterStateDriver(f, "vehicle", "[vehicleui]vehicle;novehicle")
end
local lastbutton = f
local yoff =-yoffset - 40 * (bid-1)
for i = 1, 12 do
local offset = bid*12-12+i
local b = CreateFrame("CheckButton", "$PARENTActionButton"..offset, f, "ActionButtonTemplate ActionBarButtonCodeTemplate",i)
-- b:SetWidth(32)
-- b:SetHeight(32)
b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset, yoff)
 
for i = 1, mb do
local offset = bid*mb-mb+i
local b = getButton(f, i, offset)
b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset,0)
yoff = 0
lastbutton = b
b:SetAttribute('action--base',offset)
b:SetAttribute('action--base',b:GetAttribute('action') or i)
if(bid == 1) then
b:SetAttribute('_childupdate-actionpage', [[
self:SetAttribute('action--base', self:GetAttribute('action--base'))
]])
else
elseif(bid<7) then
b:SetAttribute('_childupdate-actionpage', [[
local offset = message * 12 -12 + self:GetID()
print(offset,GetBindingKey("MULTIBARBOTTOMLEFTACTIONBUTTON"..self:GetID()))
 
]])
end
b:SetAttribute('action', i)
f['sbuttons'][#f['sbuttons'] + 1] = b
-- b:SetAttribute('action', i)
end
addon['applySettings'](f:GetName())
addon['addDrag'](f)
return f:GetName()
end
 
local function getBarPref(pref)
return db['bars'][pref[#pref-1]][pref[#pref]]
end
 
local function setBarPref(pref,value)
db['bars'][pref[#pref-1]][pref[#pref]] = value
applySettings(pref[#pref-1])
end
 
local function resetCenter(pref)
_G[pref[#pref-1]]:center()
end
 
local function init(self, event, ...)
_,class = UnitClass('player')
end
 
addon['updateDB'] = function(db)
db['bars'] = db['bars'] or {}
db['bars']['MultiCastActionBarFrame'] = db['bars']['MultiCastActionBarFrame'] or {
['cols'] = 12,
['scale'] = 1,
}
return db
end
addon['preloads'][#addon['preloads'] + 1] = function(self,event,...)
for i = 1,6 do
createBar(i)
options = addon['InitConfig'](addon, name, true, {
['type'] = "launcher",
}, getPref, setPref)
db = addon['updateDB'](addon['db']['profile'])
 
db['bars']['MultiCastActionBarFrame']['cols'] = db['bars']['MultiCastActionBarFrame']['cols'] or 12
addon['AddConfigEntry'](addon, name, 'toggle', 'dragAble', 'Unlocked', 'Use alt+click to move your bars', 0)
do
local function addP(bname)
local o = addon['AddConfigMenu'](addon, {
['name'] = bname,
['menuGet'] = getBarPref,
['menuSet'] = setBarPref,
}, addon['options']['args'][name])
addon['AddConfigEntry'](addon, name, 'range', 'cols', 'Colums', 'Number of columns', 0,1,12,1,false,o)
addon['AddConfigEntry'](addon, name, 'range', 'scale', 'Scale', 'Scale of this bar', 1,0.1,3,0.1,true,o)
addon['AddConfigEntry'](addon, name, 'execute', 'center', 'Center', 'Reset position', 2,resetCenter,nil,nil,nil,o)
end
for i = 1,6 do
addP(createBar(i, NUM_ACTIONBAR_BUTTONS))
end
addP(createBar(20, NUM_SHAPESHIFT_SLOTS))
addP(createBar(21, NUM_PET_ACTION_SLOTS))
 
addP("MultiCastActionBarFrame")
addP(name.."MicroMenu")
addP(name.."BagBar")
end
MultiCastActionBarFrame:ClearAllPoints()
MultiCastActionBarFrame:SetPoint("CENTER")
UIPARENT_MANAGED_FRAME_POSITIONS["MultiCastActionBarFrame"] = nil
addon['addDrag'](MultiCastActionBarFrame)
MoveMicroButtons = function() end
VehicleMenuBar_MoveMicroButtons = function() end
-- hooksecurefunc("ChangeMultiCastActionPage", updateMCB)
hideBlizz()
end
 
addon['startup'](addon, name, name, init, true, defaults)
\ No newline at end of file