Quantcast
WoWInterface: SVN - fernir_UI - Rev 2 - /actionbars.lua

WoWInterface SVN fernir_UI

[/] [actionbars.lua] - Rev 2

Compare with Previous | Blame | View Log

nMainbar = {
    MainMenuBar = {
        scale = 0.8,
        shortBar = true,
    },
    
    vehicle = {
        scale               = 1,
    },
    
    petbar = {
        mouseover           = false,
        scale               = 1,
        alpha               = 1,
    },
    
    possessbar = {
        scale               = 1,
        alpha               = 1,
    },
    
    stanceBar = {
        mouseover           = false,
        hide                = false,
        scale               = 1.3,
        alpha               = 1,
    },
    
    multiBarLeft = {
        mouseover           = true,
        alpha               = 1,
    },
    
    multiBarRight = {
        mouseover           = true,
        alpha               = 1,
    },
    
    multiBarBottomLeft = {
        mouseover           = false,
        alpha               = 1,
    },
    
    multiBarBottomRight = {
        mouseover           = false,
        alpha               = 1,
    },
    
    totemManager = {
        scale               = 1,
        alpha               = 1,
        hideRecallButton    = false,
    },
}

local bars = {
        "MainMenuBarArtFrame",
        "MultiBarBottomLeft",
        "MultiBarBottomRight",
        "MultiBarRight",
        "MultiBarLeft",
        "BonusActionBarFrame",
        "ShapeshiftBarFrame",
        "PossessBarFrame",
}

function clearTextures(frame)
        for i = 1, select('#', frame:GetRegions()) do
                local texture = select(i, frame:GetRegions())
                if (texture and texture:GetObjectType() == 'Texture') then
                        texture:Hide()
                end
        end
end

for i, v in ipairs(bars) do
        local bar = getglobal(v)
        bar:SetAttribute("unit2", "player")
end

local f = CreateFrame("frame","RightClickSelfCast",UIParent)
f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)

function f:PLAYER_LOGIN()

        self:UnregisterEvent("PLAYER_LOGIN")
        self.PLAYER_LOGIN = nil
        
        --this is for the mod ExtraBar (Author: Cowmonster)
        --http://www.wowinterface.com/downloads/info14492-ExtraBar.html
        for id=1, 12 do
                local button = getglobal("ExtraBarButton"..id)
                if button ~= nil then
                        button:SetAttribute("unit2", "player")
                end
        end

        --this is for the mod ExtraBars (Author: Alternator)
        --http://www.wowinterface.com/downloads/info13335-ExtraBars.html
        for id=1, 4 do
                local frame = getglobal("ExtraBar"..id)
                if frame ~= nil then
                        frame:SetAttribute("unit2", "player")
                        for bid=1, 12 do
                                local button = getglobal("ExtraBar"..id.."Button"..bid)
                                if button ~= nil then
                                        button:SetAttribute("unit2", "player")
                                end
                        end
                end
        end

end

if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end

if (nMainbar.MainMenuBar.shortBar) then

        MultiBarBottomLeft:ClearAllPoints()
        MultiBarBottomLeft:SetPoint('BOTTOMLEFT', ActionButton1, 'TOPLEFT', 0, 6)
        MultiBarBottomLeft.SetPoint = function() end

        MultiBarBottomRight:ClearAllPoints()
        MultiBarBottomRight:SetPoint('BOTTOM', MultiBarBottomLeft, 'TOP', 0, 4)
        MultiBarBottomRight.SetPoint = function() end


        function ShapeshiftBar_Update() 
                 ShapeshiftBar_UpdateState()
        end

        for _, frame in pairs({
                 'MultiBarRight',
                 'MultiBarBottomRight',
                 'ShapeshiftBarFrame',
                 'PossessBarFrame',
                 'MULTICASTACTIONBAR_YPOS',
                 'MultiCastActionBarFrame',
                 'PETACTIONBAR_YPOS',
        }) do
                 UIPARENT_MANAGED_FRAME_POSITIONS[frame] = nil
        end

        for _, frame in pairs({        
                 _G['PetActionBarFrame'],
                 _G['ShapeshiftBarFrame'],
                 _G['PossessBarFrame'],
                 _G['MultiCastActionBarFrame'],
        }) do
                 frame:SetMovable(true)
                 frame:SetUserPlaced(true)
                 frame:EnableMouse(false)
        end

                 -- -----------------------------------
                 -- make the new totemmanager moveable
                 -- -----------------------------------


        local f = CreateFrame('Frame', 'MultiCastActionBarFrameAnchor')
        f:RegisterEvent('PLAYER_ENTERING_WORLD')
        f:SetHeight(10)
        f:SetWidth(10)
        f:SetScript('OnEvent', function(self, event)
                 MultiCastActionBarFrame:ClearAllPoints()   
                 MultiCastActionBarFrame:SetPoint('CENTER', MultiCastActionBarFrameAnchor) 
                 MultiCastActionBarFrame.SetPoint = function() end
                 self:UnregisterAllEvents()
        end)

        for i = 1, 12 do
                 for _, button in pairs({        
                          _G['MultiCastActionButton'..i],
                          
                          _G['MultiCastSlotButton1'],
                          _G['MultiCastSlotButton2'],
                          _G['MultiCastSlotButton3'],
                          _G['MultiCastSlotButton4'],
                          
                          _G['MultiCastRecallSpellButton'],
                          _G['MultiCastSummonSpellButton'],
                 }) do
                          MultiCastActionBarFrameAnchor:ClearAllPoints()
                          MultiCastActionBarFrameAnchor:SetPoint('CENTER', UIParent)  
                                        
                          MultiCastActionBarFrameAnchor:SetMovable(true)
                          MultiCastActionBarFrameAnchor:SetUserPlaced(true)
                          
                          button:RegisterForDrag('LeftButton')

                          button:HookScript('OnDragStart', function()
                                        if (IsControlKeyDown()) then
                                                 MultiCastActionBarFrameAnchor:StartMoving() 
                                        end
                          end)

                          button:HookScript('OnDragStop', function() 
                                        MultiCastActionBarFrameAnchor:StopMovingOrSizing()
                          end)
                 end
        end

        for i = 1, 12 do
                 for _, button in pairs({        
                          _G['MultiCastActionButton'..i],
                          
                          _G['MultiCastSlotButton1'],
                          _G['MultiCastSlotButton2'],
                          _G['MultiCastSlotButton3'],
                          _G['MultiCastSlotButton4'],
                          _G['MultiCastRecallSpellButton'],
                          _G['MultiCastSummonSpellButton'],
                          
                          _G['MultiCastActionBarFrame'],
                 }) do
                          button:SetScale(nMainbar.totemManager.scale)
                          button:SetAlpha(nMainbar.totemManager.alpha)
                 end
        end

        MultiCastActionButton1:ClearAllPoints()   
        MultiCastActionButton1:SetPoint('CENTER', MultiCastSlotButton1) 

        MultiCastActionButton5:ClearAllPoints()   
        MultiCastActionButton5:SetPoint('CENTER', MultiCastSlotButton1) 

        MultiCastActionButton9:ClearAllPoints()   
        MultiCastActionButton9:SetPoint('CENTER', MultiCastSlotButton1) 

        hooksecurefunc('MultiCastFlyoutFrame_LoadSlotSpells', function(self, slot, ...)
                local numSpells = select('#', ...)
                if (numSpells == 0) then
                        return false
                end

                numSpells = numSpells + 1
                 
                 for i = 2, numSpells do
                          _G['MultiCastFlyoutButton'..i..'Icon']:SetTexCoord(0.1, 0.9, 0.1, 0.9)
                 end
        end)

        MultiCastFlyoutFrame:SetScale(nMainbar.totemManager.scale * 1.1)

        if (nMainbar.totemManager.hideRecallButton) then
                 MultiCastRecallSpellButton:SetAlpha(0)
                 MultiCastRecallSpellButton.SetAlpha = function() end
                 MultiCastRecallSpellButton:EnableMouse(false)
                 MultiCastRecallSpellButton.EnableMouse = function() end
        end

                 -- -----------------------------------
                 -- moveable bars
                 -- -----------------------------------
                 
        for _, button in pairs({        
                 _G['PossessButton1'],
                 _G['PetActionButton1'],
                 _G['ShapeshiftButton1'],
        }) do
                 button:ClearAllPoints()
                 button:SetPoint('CENTER', UIParent)
                 
                 button:SetMovable(true)
                 button:SetUserPlaced(true)
                 button:RegisterForDrag('LeftButton')
                 
                 button:HookScript('OnDragStart', function(self)
                          if (IsShiftKeyDown() and IsAltKeyDown()) then
                                        self:StartMoving() 
                          end
                 end)

                 button:HookScript('OnDragStop', function(self) 
                          self:StopMovingOrSizing()
                 end)
        end

        for _, button in pairs({
                 _G['ActionBarUpButton'],
                 _G['ActionBarDownButton'],
                 
                 _G['MainMenuBarBackpackButton'],
                 _G['KeyRingButton'],
                 
                 _G['CharacterBag0Slot'],
                 _G['CharacterBag1Slot'],
                 _G['CharacterBag2Slot'],
                 _G['CharacterBag3Slot'],
        }) do
                 button:SetAlpha(0)
                 button:EnableMouse(false)
        end

        local f = CreateFrame('Frame')
        f:Hide()

        for i = 2, 3 do
                 for _, texture in pairs({
                          _G['MainMenuBarTexture'..i],
                          _G['MainMenuMaxLevelBar'..i],
                          _G['MainMenuXPBarTexture'..i],
                          _G['ReputationWatchBarTexture'..i],
                          _G['ReputationXPBarTexture'..i],
                          
                          _G['MainMenuBarPageNumber'],

                          _G['SlidingActionBarTexture0'],
                          _G['SlidingActionBarTexture1'],
                          
                          _G['ShapeshiftBarLeft'],
                          _G['ShapeshiftBarMiddle'],
                          _G['ShapeshiftBarRight'],
                          
                          _G['PossessBackground1'],
                          _G['PossessBackground2'],
                          _G['MainMenuExpBar'],
                          _G["ReputationWatchBar"],
                          _G["VehicleMenuBarHealthBar"],
                          _G["VehicleMenuBarPowerBar"],
                 }) do
                          texture:SetParent(f)
                 end
        end

        for _, bar in pairs({
                 _G['MainMenuBar'],
                 _G['MainMenuExpBar'],
                 _G['MainMenuBarMaxLevelBar'],

                 _G['ReputationWatchStatusBar'],
                 _G['ReputationWatchBar'],
        }) do
                 bar:SetWidth(512)
        end
        
        for _, texture in pairs (
                {
                        _G["MainMenuBarTexture0"],
                        _G["MainMenuBarTexture1"],
                        _G["MainMenuBarTexture2"],
                        _G["MainMenuMaxLevelBar0"],
                        _G["MainMenuXPBarTexture0"],
                        _G["MainMenuXPBarTexture1"],
                        _G["MainMenuXPBarTexture2"],
                        _G["MainMenuXPBarTexture3"],
                        _G["MainMenuBarLeftEndCap"],
                        _G["MainMenuBarRightEndCap"],
                        _G["BonusActionBarTexture0"],
                        _G["BonusActionBarTexture1"],
                        _G["MainMenuMaxLevelBar0"],
                        _G["MainMenuMaxLevelBar1"],
                        _G["MainMenuMaxLevelBar2"],
                        _G["MainMenuMaxLevelBar3"],
                        _G["ExhaustionTickNormal"],
                        _G["ExhaustionTickHighlight"],
                        _G["ExhaustionLevelFillBar"],
                }
        ) do
                texture:Hide()
        end

        clearTextures(MainMenuBar)
        clearTextures(VehicleMenuBarArtFrame)

        CharacterMicroButton:ClearAllPoints()
        CharacterMicroButton:SetPoint('BOTTOMLEFT', 9000, 9000)

        SocialsMicroButton:ClearAllPoints()
        SocialsMicroButton:SetPoint('TOPLEFT', CharacterMicroButton, 'BOTTOMLEFT', 0, 20)
                          
                 hooksecurefunc('VehicleMenuBar_MoveMicroButtons', function()
                          if (not self) then
                                        CharacterMicroButton:ClearAllPoints()
                                        CharacterMicroButton:SetPoint('BOTTOMLEFT', 9000, 9000)
                          elseif (self == 'Mechanical') then
                                        CharacterMicroButton:ClearAllPoints()
                                        CharacterMicroButton:SetPoint('BOTTOMLEFT', VehicleMenuBar, 'BOTTOMRIGHT', -340, 41)
                          elseif (self == 'Natural') then
                                        CharacterMicroButton:ClearAllPoints()
                                        CharacterMicroButton:SetPoint('BOTTOMLEFT', VehicleMenuBar, 'BOTTOMRIGHT', -340, 41)
                          end
                 end) 
end


local function GetNumShapeSlots()
    local _, class = UnitClass('Player')
    if (class == 'DEATHKNIGHT' or class == 'WARRIOR') then
        return 3
    elseif (class == 'ROGUE') then
        return 1
    else
        return 10
    end
end
    
    -- if you move the bar you get some problems, so what can we make? We move the buttons!
do
    MultiBarRightButton1:ClearAllPoints()
    MultiBarRightButton1:SetPoint('TOPRIGHT', UIParent, 'RIGHT', -6, (MultiBarRight:GetHeight() / 2))

    MultiBarLeftButton1:ClearAllPoints() 
    MultiBarLeftButton1:SetPoint('TOPRIGHT', MultiBarRightButton1, 'TOPLEFT', -6, 0)
end

if (nMainbar.stanceBar.hide) then
    for i = 1, NUM_SHAPESHIFT_SLOTS do
        local button = _G['ShapeshiftButton'..i]
        button:SetAlpha(0)
        button.SetAlpha = function() end
        
        button:EnableMouse(false)
        button.EnableMouse = function() end
    end
end

local function EnableMouseOver(self, bar, min, max, alpha)
    local minAlpha = 0

    for i = min, max do
        local button = _G[self..i]
        
        local f = CreateFrame('Frame', bar, bar)
        f:RegisterEvent('PLAYER_LOGIN')
        f:SetFrameStrata('LOW')
        f:SetFrameLevel(1)
        f:EnableMouse()
        f:SetPoint('TOPLEFT', self..min, -5, 5)
        f:SetPoint('BOTTOMRIGHT', self..max, 5, 5)
        f:SetScript('OnEvent', function(self)
            bar:SetAlpha(minAlpha)
            self:UnregisterAllEvents()
        end)
        
        f:SetScript('OnEnter', function()
            bar:SetAlpha(alpha)
        end)
                    
        f:SetScript('OnLeave', function() 
            if (not MouseIsOver(button)) then
                bar:SetAlpha(minAlpha)
            end
        end)
    
        button:HookScript('OnEnter', function()
            bar:SetAlpha(alpha)
        end)
            
        button:HookScript('OnLeave', function() 
            if (not MouseIsOver(bar)) then
                bar:SetAlpha(minAlpha)
            end
        end)
    end
end

    
if (nMainbar.multiBarLeft.mouseover) then
    EnableMouseOver('MultiBarLeftButton', MultiBarLeft, 1, 12, nMainbar.multiBarLeft.alpha)
end

if (nMainbar.multiBarRight.mouseover) then
    EnableMouseOver('MultiBarRightButton', MultiBarRight, 1, 12, nMainbar.multiBarRight.alpha)
end

if (nMainbar.multiBarBottomLeft.mouseover) then
    EnableMouseOver('MultiBarBottomLeftButton', MultiBarBottomLeft, 1, 12, nMainbar.multiBarBottomLeft.alpha)
end

if (nMainbar.multiBarBottomRight.mouseover) then
    EnableMouseOver('MultiBarBottomRightButton', MultiBarBottomRight, 1, 12, nMainbar.multiBarBottomRight.alpha)
end

if (nMainbar.petbar.mouseover) then
    PetActionBarFrame:SetFrameStrata('HIGH')
    EnableMouseOver('PetActionButton', PetActionBarFrame, 1, 10, nMainbar.petbar.alpha)
end

if (nMainbar.stanceBar.mouseover) then
    ShapeshiftBarFrame:SetFrameStrata('HIGH')
    EnableMouseOver('ShapeshiftButton', ShapeshiftBarFrame, 1, GetNumShapeSlots(), nMainbar.stanceBar.alpha)
end

Compare with Previous | Blame