Quantcast
WoWInterface: SVN - zz_Actionbuttons - Diff - Rev 10 and 9 - /trunk/zz_Actionbuttons/core.lua

WoWInterface SVN zz_Actionbuttons

[/] [trunk/] [zz_Actionbuttons/] [core.lua] - Diff between revs 9 and 10

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 9 Rev 10
Line 1... Line 1...
local name, addon = ...
local name, addon = ...
local defaults = {}
local defaults = {}
local options, db
local options, db
local _,class = UnitClass('player')
local _,class = UnitClass('player')
local _G = _G
local _G = _G
local xoffset, yoffset = 8,0
local xoffset, yoffset = 4,4
 
local buttons = {}
 
 
local function createBar(bid)
addon['MSQ'] = LibStub("Masque",true)
        local f = CreateFrame("Frame", "zzABar"..bid, UIParent, "SecureHandlerStateTemplate",bid)
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:SetWidth(1)
        f:SetHeight(1)
        f:SetHeight(1)
        f:SetPoint("CENTER")
        f:SetPoint("CENTER", xoffset, yoff)
 
        if(bid > 1 and bid < 7) then
        f:SetAttribute('actionpage', bid)
        f:SetAttribute('actionpage', bid)
--      if(bid == 1) then
        end
 
        if(bid == 1) then
                f:SetAttribute('_onstate-page', [[
                f:SetAttribute('_onstate-page', [[
                print(newstate)
 
                        if(self:GetID() == 1) then
                        if(self:GetID() == 1) then
                                self:SetAttribute('actionpage', newstate)
                                self:SetAttribute('actionpage', newstate)
                                control:ChildUpdate('actionpage', newstate)
                                control:ChildUpdate('actionpage', newstate)
                        else
                        else
                                control:ChildUpdate('actionpage', self:GetID())
                                control:ChildUpdate('actionpage', self:GetID())
                        end
                        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
                if(class == "WARRIOR") then
                        RegisterStateDriver(f, "page", "[bonusbar:1] 7;[bonusbar:2] 8;[bonusbar:3] 9;1")
                        RegisterStateDriver(f, "page", "[bonusbar:1] 7;[bonusbar:2] 8;[bonusbar:3] 9;1")
                elseif(class == "DRUID") then
                elseif(class == "DRUID") then
                        RegisterStateDriver(f, "page", "[stance:1] 9;[stance:3,stealth] 8;[stance:3] 7;[stance:5] 10;1") -- 1 bear/ 3 cat/ 5 moonkin
                        RegisterStateDriver(f, "page", "[stance:1] 9;[stance:3,stealth] 8;[stance:3] 7;[stance:5] 10;1") -- 1 bear/ 3 cat/ 5 moonkin
                elseif(class == "ROGUE") then
                elseif(class == "ROGUE") then
                        RegisterStateDriver(f, "page", "[stance:1] 7;[stance:3] 8; 1") -- 1 stealth/ 3 shadow dance
                        RegisterStateDriver(f, "page", "[stance:1] 7;[stance:3] 8; 1") -- 1 stealth/ 3 shadow dance
                elseif(class == "PRIEST") then
                elseif(class == "PRIEST") then
                        RegisterStateDriver(f, "page", "[stance:1] 7; 1")
                        RegisterStateDriver(f, "page", "[stance:1] 7; 1")
                end
                end
--      end
                RegisterStateDriver(f, "possess", "[bonusbar:5] 11")
 
                RegisterStateDriver(f, "vehicle", "[vehicleui]vehicle;novehicle")
 
        end
        local lastbutton = f
        local lastbutton = f
        local yoff =-yoffset - 40 * (bid-1)
 
        for i = 1, 12 do
        for i = 1, mb do
                local offset = bid*12-12+i
                local offset = bid*mb-mb+i
                local b = CreateFrame("CheckButton", "$PARENTActionButton"..offset, f, "ActionButtonTemplate ActionBarButtonCodeTemplate",i)
                local b = getButton(f, i, offset)
--              b:SetWidth(32)
                b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset,0)
--              b:SetHeight(32)
 
                b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset, yoff)
 
                yoff = 0
                yoff = 0
                lastbutton = b
                lastbutton = b
                b:SetAttribute('action--base',offset)
                b:SetAttribute('action--base',b:GetAttribute('action') or i)
                if(bid == 1) then
                if(bid == 1) then
                        b:SetAttribute('_childupdate-actionpage', [[
                        b:SetAttribute('_childupdate-actionpage', [[
                                self:SetAttribute('action--base', self:GetAttribute('action--base'))
                                self:SetAttribute('action--base', self:GetAttribute('action--base'))
                        ]])
                        ]])
                else
                elseif(bid<7) then
                        b:SetAttribute('_childupdate-actionpage', [[
                        b:SetAttribute('_childupdate-actionpage', [[
                                local offset = message * 12 -12 + self:GetID()
 
                                print(offset,GetBindingKey("MULTIBARBOTTOMLEFTACTIONBUTTON"..self:GetID()))
 
                        ]])
                        ]])
                end
                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
        end
 
 
 
local function resetCenter(pref)
 
        _G[pref[#pref-1]]:center()
end
end
 
 
local function init(self, event, ...)
local function init(self, event, ...)
        _,class = UnitClass('player')
        _,class = UnitClass('player')
end
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,...)
addon['preloads'][#addon['preloads'] + 1] = function(self,event,...)
 
        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
        for i = 1,6 do
                createBar(i)
                        addP(createBar(i, NUM_ACTIONBAR_BUTTONS))
        end
        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
end
 
 
addon['startup'](addon, name, name, init, true, defaults)
addon['startup'](addon, name, name, init, true, defaults)
 No newline at end of file
 No newline at end of file