init
This commit is contained in:
@@ -0,0 +1,997 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local AB = E:GetModule("ActionBars")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local pairs, select, unpack = pairs, select, unpack
|
||||
local ceil = math.ceil
|
||||
local format, gsub, match, split = string.format, string.gsub, string.match, string.split
|
||||
--WoW API / Variables
|
||||
local hooksecurefunc = hooksecurefunc
|
||||
local CreateFrame = CreateFrame
|
||||
local UnitHealth = UnitHealth
|
||||
local UnitHealthMax = UnitHealthMax
|
||||
local UnitCastingInfo = UnitCastingInfo
|
||||
local UnitChannelInfo = UnitChannelInfo
|
||||
local UnitAffectingCombat = UnitAffectingCombat
|
||||
local UnitExists = UnitExists
|
||||
local PetDismiss = PetDismiss
|
||||
local CanExitVehicle = CanExitVehicle
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local ClearOverrideBindings = ClearOverrideBindings
|
||||
local GetBindingKey = GetBindingKey
|
||||
local SetOverrideBindingClick = SetOverrideBindingClick
|
||||
local SetCVar = SetCVar
|
||||
local SetModifiedClick = SetModifiedClick
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
local UnregisterStateDriver = UnregisterStateDriver
|
||||
local NUM_ACTIONBAR_BUTTONS = NUM_ACTIONBAR_BUTTONS
|
||||
local LEAVE_VEHICLE = LEAVE_VEHICLE
|
||||
|
||||
local LAB = E.Libs.LAB
|
||||
local LSM = E.Libs.LSM
|
||||
local LBF = E.Libs.LBF
|
||||
|
||||
local UIHider
|
||||
|
||||
AB.RegisterCooldown = E.RegisterCooldown
|
||||
|
||||
AB.handledBars = {} --List of all bars
|
||||
AB.handledbuttons = {} --List of all buttons that have been modified.
|
||||
AB.barDefaults = {
|
||||
bar1 = {
|
||||
page = 1,
|
||||
bindButtons = "ACTIONBUTTON",
|
||||
conditions = "[bonusbar:5] 11; [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6;",
|
||||
position = "BOTTOM,ElvUIParent,BOTTOM,0,4",
|
||||
},
|
||||
bar2 = {
|
||||
page = 5,
|
||||
bindButtons = "MULTIACTIONBAR2BUTTON",
|
||||
conditions = "",
|
||||
position = "BOTTOM,ElvUI_Bar1,TOP,0,2"
|
||||
},
|
||||
bar3 = {
|
||||
page = 6,
|
||||
bindButtons = "MULTIACTIONBAR1BUTTON",
|
||||
conditions = "",
|
||||
position = "LEFT,ElvUI_Bar1,RIGHT,4,0"
|
||||
},
|
||||
bar4 = {
|
||||
page = 4,
|
||||
bindButtons = "MULTIACTIONBAR4BUTTON",
|
||||
conditions = "",
|
||||
position = "RIGHT,ElvUIParent,RIGHT,-4,0"
|
||||
},
|
||||
bar5 = {
|
||||
page = 3,
|
||||
bindButtons = "MULTIACTIONBAR3BUTTON",
|
||||
conditions = "",
|
||||
position = "RIGHT,ElvUI_Bar1,LEFT,-4,0"
|
||||
},
|
||||
bar6 = {
|
||||
page = 2,
|
||||
bindButtons = "ELVUIBAR6BUTTON",
|
||||
conditions = "",
|
||||
position = "BOTTOM,ElvUI_Bar2,TOP,0,2"
|
||||
}
|
||||
}
|
||||
|
||||
AB.customExitButton = {
|
||||
func = function()
|
||||
if UnitExists("vehicle") then
|
||||
VehicleExit()
|
||||
else
|
||||
PetDismiss()
|
||||
end
|
||||
end,
|
||||
texture = "Interface\\Icons\\Spell_Shadow_SacrificialShield",
|
||||
tooltip = LEAVE_VEHICLE
|
||||
}
|
||||
|
||||
function AB:PositionAndSizeBar(barName)
|
||||
local buttonSpacing = E:Scale(self.db[barName].buttonspacing)
|
||||
local backdropSpacing = E:Scale((self.db[barName].backdropSpacing or self.db[barName].buttonspacing))
|
||||
local buttonsPerRow = self.db[barName].buttonsPerRow
|
||||
local numButtons = self.db[barName].buttons
|
||||
local size = E:Scale(self.db[barName].buttonsize)
|
||||
local point = self.db[barName].point
|
||||
local numColumns = ceil(numButtons / buttonsPerRow)
|
||||
local widthMult = self.db[barName].widthMult
|
||||
local heightMult = self.db[barName].heightMult
|
||||
local visibility = self.db[barName].visibility
|
||||
local bar = self.handledBars[barName]
|
||||
|
||||
bar.db = self.db[barName]
|
||||
|
||||
if visibility and match(visibility, "[\n\r]") then
|
||||
visibility = gsub(visibility, "[\n\r]","")
|
||||
end
|
||||
|
||||
if numButtons < buttonsPerRow then
|
||||
buttonsPerRow = numButtons
|
||||
end
|
||||
|
||||
if numColumns < 1 then
|
||||
numColumns = 1
|
||||
end
|
||||
|
||||
if bar.db.backdrop then
|
||||
bar.backdrop:Show()
|
||||
else
|
||||
bar.backdrop:Hide()
|
||||
--Set size multipliers to 1 when backdrop is disabled
|
||||
widthMult = 1
|
||||
heightMult = 1
|
||||
end
|
||||
|
||||
local sideSpacing = (bar.db.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)
|
||||
--Size of all buttons + Spacing between all buttons + Spacing between additional rows of buttons + Spacing between backdrop and buttons + Spacing on end borders with non-thin borders
|
||||
local barWidth = (size * (buttonsPerRow * widthMult)) + ((buttonSpacing * (buttonsPerRow - 1)) * widthMult) + (buttonSpacing * (widthMult - 1)) + (sideSpacing*2)
|
||||
local barHeight = (size * (numColumns * heightMult)) + ((buttonSpacing * (numColumns - 1)) * heightMult) + (buttonSpacing * (heightMult - 1)) + (sideSpacing*2)
|
||||
bar:Width(barWidth)
|
||||
bar:Height(barHeight)
|
||||
|
||||
bar.mouseover = bar.db.mouseover
|
||||
|
||||
local horizontalGrowth, verticalGrowth
|
||||
if point == "TOPLEFT" or point == "TOPRIGHT" then
|
||||
verticalGrowth = "DOWN"
|
||||
else
|
||||
verticalGrowth = "UP"
|
||||
end
|
||||
|
||||
if point == "BOTTOMLEFT" or point == "TOPLEFT" then
|
||||
horizontalGrowth = "RIGHT"
|
||||
else
|
||||
horizontalGrowth = "LEFT"
|
||||
end
|
||||
|
||||
if bar.db.mouseover then
|
||||
bar:SetAlpha(0)
|
||||
else
|
||||
bar:SetAlpha(bar.db.alpha)
|
||||
end
|
||||
|
||||
if bar.db.inheritGlobalFade then
|
||||
bar:SetParent(self.fadeParent)
|
||||
else
|
||||
bar:SetParent(E.UIParent)
|
||||
end
|
||||
|
||||
local button, lastButton, lastColumnButton
|
||||
for i = 1, NUM_ACTIONBAR_BUTTONS do
|
||||
button = bar.buttons[i]
|
||||
lastButton = bar.buttons[i - 1]
|
||||
lastColumnButton = bar.buttons[i-buttonsPerRow]
|
||||
button:SetParent(bar)
|
||||
button:ClearAllPoints()
|
||||
button:Size(size)
|
||||
button:SetAttribute("showgrid", 1)
|
||||
|
||||
if i == 1 then
|
||||
local x, y
|
||||
if point == "BOTTOMLEFT" then
|
||||
x, y = sideSpacing, sideSpacing
|
||||
elseif point == "TOPRIGHT" then
|
||||
x, y = -sideSpacing, -sideSpacing
|
||||
elseif point == "TOPLEFT" then
|
||||
x, y = sideSpacing, -sideSpacing
|
||||
else
|
||||
x, y = -sideSpacing, sideSpacing
|
||||
end
|
||||
|
||||
button:Point(point, bar, point, x, y)
|
||||
elseif (i - 1) % buttonsPerRow == 0 then
|
||||
local y = -buttonSpacing
|
||||
local buttonPoint, anchorPoint = "TOP", "BOTTOM"
|
||||
if verticalGrowth == "UP" then
|
||||
y = buttonSpacing
|
||||
buttonPoint = "BOTTOM"
|
||||
anchorPoint = "TOP"
|
||||
end
|
||||
button:Point(buttonPoint, lastColumnButton, anchorPoint, 0, y)
|
||||
else
|
||||
local x = buttonSpacing
|
||||
local buttonPoint, anchorPoint = "LEFT", "RIGHT"
|
||||
if horizontalGrowth == "LEFT" then
|
||||
x = -buttonSpacing
|
||||
buttonPoint = "RIGHT"
|
||||
anchorPoint = "LEFT"
|
||||
end
|
||||
|
||||
button:Point(buttonPoint, lastButton, anchorPoint, x, 0)
|
||||
end
|
||||
|
||||
if i > numButtons then
|
||||
button:Hide()
|
||||
else
|
||||
button:Show()
|
||||
end
|
||||
|
||||
self:StyleButton(button, nil, self.LBFGroup and E.private.actionbar.lbf.enable and true or nil)
|
||||
end
|
||||
|
||||
if bar.db.enabled or not bar.initialized then
|
||||
if not bar.db.mouseover then
|
||||
bar:SetAlpha(bar.db.alpha)
|
||||
end
|
||||
|
||||
local page = self:GetPage(barName, self.barDefaults[barName].page, self.barDefaults[barName].conditions)
|
||||
bar:Show()
|
||||
RegisterStateDriver(bar, "visibility", visibility) -- this is ghetto
|
||||
RegisterStateDriver(bar, "page", page)
|
||||
bar:SetAttribute("page", page)
|
||||
|
||||
if not bar.initialized then
|
||||
bar.initialized = true
|
||||
AB:PositionAndSizeBar(barName)
|
||||
return
|
||||
end
|
||||
E:EnableMover(bar.mover:GetName())
|
||||
else
|
||||
E:DisableMover(bar.mover:GetName())
|
||||
bar:Hide()
|
||||
UnregisterStateDriver(bar, "visibility")
|
||||
end
|
||||
|
||||
E:SetMoverSnapOffset("ElvAB_"..bar.id, bar.db.buttonspacing / 2)
|
||||
|
||||
if self.LBFGroup and E.private.actionbar.lbf.enable then
|
||||
self.LBFGroup:Skin(E.private.actionbar.lbf.skin)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:CreateBar(id)
|
||||
local bar = CreateFrame("Frame", "ElvUI_Bar"..id, E.UIParent, "SecureHandlerStateTemplate")
|
||||
local point, anchor, attachTo, x, y = split(",", self.barDefaults["bar"..id].position)
|
||||
bar:Point(point, anchor, attachTo, x, y)
|
||||
bar.id = id
|
||||
bar:CreateBackdrop(self.db.transparentBackdrops and "Transparent")
|
||||
bar:SetFrameStrata("LOW")
|
||||
|
||||
--Use this method instead of :SetAllPoints, as the size of the mover would otherwise be incorrect
|
||||
bar.backdrop:SetPoint("TOPLEFT", bar, "TOPLEFT", E.Spacing, -E.Spacing)
|
||||
bar.backdrop:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", -E.Spacing, E.Spacing)
|
||||
|
||||
bar.buttons = {}
|
||||
bar.bindButtons = self.barDefaults["bar"..id].bindButtons
|
||||
self:HookScript(bar, "OnEnter", "Bar_OnEnter")
|
||||
self:HookScript(bar, "OnLeave", "Bar_OnLeave")
|
||||
|
||||
for i = 1, 12 do
|
||||
bar.buttons[i] = LAB:CreateButton(i, format(bar:GetName().."Button%d", i), bar, nil)
|
||||
bar.buttons[i]:SetState(0, "action", i)
|
||||
for k = 1, 11 do
|
||||
bar.buttons[i]:SetState(k, "action", (k - 1) * 12 + i)
|
||||
end
|
||||
|
||||
if i == 12 then
|
||||
bar.buttons[i]:SetState(11, "custom", AB.customExitButton)
|
||||
end
|
||||
|
||||
if self.LBFGroup and E.private.actionbar.lbf.enable then
|
||||
self.LBFGroup:AddButton(bar.buttons[i])
|
||||
end
|
||||
|
||||
self:HookScript(bar.buttons[i], "OnEnter", "Button_OnEnter")
|
||||
self:HookScript(bar.buttons[i], "OnLeave", "Button_OnLeave")
|
||||
end
|
||||
self:UpdateButtonConfig(bar, bar.bindButtons)
|
||||
|
||||
bar:SetAttribute("_onstate-page", [[
|
||||
if newstate ~= 0 then
|
||||
self:SetAttribute("state", newstate)
|
||||
control:ChildUpdate("state", newstate)
|
||||
else
|
||||
local newCondition = self:GetAttribute("newCondition")
|
||||
if newCondition then
|
||||
newstate = SecureCmdOptionParse(newCondition)
|
||||
self:SetAttribute("state", newstate)
|
||||
control:ChildUpdate("state", newstate)
|
||||
end
|
||||
end
|
||||
]])
|
||||
|
||||
self.handledBars["bar"..id] = bar
|
||||
E:CreateMover(bar, "ElvAB_"..id, L["Bar "]..id, nil, nil, nil,"ALL,ACTIONBARS",nil,"actionbar,bar"..id)
|
||||
self:PositionAndSizeBar("bar"..id)
|
||||
return bar
|
||||
end
|
||||
|
||||
function AB:PLAYER_REGEN_ENABLED()
|
||||
if AB.NeedsUpdateButtonSettings then
|
||||
self:UpdateButtonSettings()
|
||||
AB.NeedsUpdateButtonSettings = nil
|
||||
end
|
||||
if AB.NeedsUpdateMicroBarVisibility then
|
||||
self:UpdateMicroBarVisibility()
|
||||
AB.NeedsUpdateMicroBarVisibility = nil
|
||||
end
|
||||
if AB.NeedsAdjustMaxStanceButtons then
|
||||
AB:AdjustMaxStanceButtons(AB.NeedsAdjustMaxStanceButtons) --sometimes it holds the event, otherwise true. pass it before we nil it.
|
||||
AB.NeedsAdjustMaxStanceButtons = nil
|
||||
end
|
||||
if AB.NeedsPositionAndSizeBarTotem then
|
||||
self:PositionAndSizeBarTotem()
|
||||
AB.NeedsPositionAndSizeBarTotem = nil
|
||||
end
|
||||
if AB.NeedRecallButtonUpdate then
|
||||
MultiCastRecallSpellButton_Update(MultiCastRecallSpellButton)
|
||||
AB.NeedRecallButtonUpdate = nil
|
||||
end
|
||||
|
||||
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
|
||||
end
|
||||
|
||||
local function Vehicle_OnEvent(self, event)
|
||||
if CanExitVehicle() and not E.db.general.minimap.icons.vehicleLeave.hide then
|
||||
self:Show()
|
||||
else
|
||||
self:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function AB:UpdateVehicleLeave()
|
||||
if not self.vehicle then return end
|
||||
|
||||
local pos = E.db.general.minimap.icons.vehicleLeave.position
|
||||
|
||||
self.vehicle:ClearAllPoints()
|
||||
self.vehicle:Point(pos, Minimap, pos, E.db.general.minimap.icons.vehicleLeave.xOffset, E.db.general.minimap.icons.vehicleLeave.yOffset)
|
||||
self.vehicle:Size(26 * E.db.general.minimap.icons.vehicleLeave.scale)
|
||||
|
||||
Vehicle_OnEvent(self.vehicle)
|
||||
end
|
||||
|
||||
function AB:CreateVehicleLeave()
|
||||
local vehicle = CreateFrame("Button", "ElvUI_LeaveVehicleButton", E.UIParent)
|
||||
vehicle:Hide()
|
||||
vehicle:SetFrameStrata("HIGH")
|
||||
vehicle:SetNormalTexture(E.Media.Textures.ExitVehicle)
|
||||
vehicle:SetPushedTexture(E.Media.Textures.ExitVehicle)
|
||||
vehicle:SetHighlightTexture(E.Media.Textures.ExitVehicle)
|
||||
vehicle:SetTemplate()
|
||||
vehicle:EnableMouse(true)
|
||||
vehicle:RegisterForClicks("AnyUp")
|
||||
|
||||
vehicle:SetScript("OnClick", VehicleExit)
|
||||
vehicle:SetScript("OnEvent", Vehicle_OnEvent)
|
||||
vehicle:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
vehicle:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
|
||||
vehicle:RegisterEvent("UPDATE_MULTI_CAST_ACTIONBAR")
|
||||
vehicle:RegisterEvent("UNIT_ENTERED_VEHICLE")
|
||||
vehicle:RegisterEvent("UNIT_EXITED_VEHICLE")
|
||||
vehicle:RegisterEvent("VEHICLE_UPDATE")
|
||||
|
||||
self.vehicle = vehicle
|
||||
self:UpdateVehicleLeave()
|
||||
end
|
||||
|
||||
function AB:ReassignBindings(event)
|
||||
if event == "UPDATE_BINDINGS" then
|
||||
self:UpdatePetBindings()
|
||||
self:UpdateStanceBindings()
|
||||
end
|
||||
|
||||
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
|
||||
|
||||
if InCombatLockdown() then return end
|
||||
|
||||
for _, bar in pairs(self.handledBars) do
|
||||
if bar then
|
||||
ClearOverrideBindings(bar)
|
||||
for i = 1, #bar.buttons do
|
||||
local button = format(bar.bindButtons.."%d", i)
|
||||
local real_button = format(bar:GetName().."Button%d", i)
|
||||
for k = 1, select("#", GetBindingKey(button)) do
|
||||
local key = select(k, GetBindingKey(button))
|
||||
if key and key ~= "" then
|
||||
SetOverrideBindingClick(bar, false, key, real_button)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:RemoveBindings()
|
||||
if InCombatLockdown() then return end
|
||||
|
||||
for _, bar in pairs(self.handledBars) do
|
||||
if bar then
|
||||
ClearOverrideBindings(bar)
|
||||
end
|
||||
end
|
||||
|
||||
self:RegisterEvent("PLAYER_REGEN_DISABLED", "ReassignBindings")
|
||||
end
|
||||
|
||||
function AB:UpdateBar1Paging()
|
||||
if self.db.bar6.enabled then
|
||||
AB.barDefaults.bar1.conditions = "[bonusbar:5] 11; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6;"
|
||||
else
|
||||
AB.barDefaults.bar1.conditions = "[bonusbar:5] 11; [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6;"
|
||||
end
|
||||
|
||||
if (E.private.actionbar.enable ~= true or InCombatLockdown()) or not self.isInitialized then return end
|
||||
local bar2Option = InterfaceOptionsActionBarsPanelBottomRight
|
||||
local bar3Option = InterfaceOptionsActionBarsPanelBottomLeft
|
||||
local bar4Option = InterfaceOptionsActionBarsPanelRightTwo
|
||||
local bar5Option = InterfaceOptionsActionBarsPanelRight
|
||||
|
||||
if (self.db.bar2.enabled and not bar2Option:GetChecked()) or (not self.db.bar2.enabled and bar2Option:GetChecked()) then
|
||||
bar2Option:Click()
|
||||
end
|
||||
|
||||
if (self.db.bar3.enabled and not bar3Option:GetChecked()) or (not self.db.bar3.enabled and bar3Option:GetChecked()) then
|
||||
bar3Option:Click()
|
||||
end
|
||||
|
||||
if not self.db.bar5.enabled and not self.db.bar4.enabled then
|
||||
if bar4Option:GetChecked() then
|
||||
bar4Option:Click()
|
||||
end
|
||||
|
||||
if bar5Option:GetChecked() then
|
||||
bar5Option:Click()
|
||||
end
|
||||
elseif not self.db.bar5.enabled then
|
||||
if not bar5Option:GetChecked() then
|
||||
bar5Option:Click()
|
||||
end
|
||||
|
||||
if not bar4Option:GetChecked() then
|
||||
bar4Option:Click()
|
||||
end
|
||||
elseif (self.db.bar4.enabled and not bar4Option:GetChecked()) or (not self.db.bar4.enabled and bar4Option:GetChecked()) then
|
||||
bar4Option:Click()
|
||||
elseif (self.db.bar5.enabled and not bar5Option:GetChecked()) or (not self.db.bar5.enabled and bar5Option:GetChecked()) then
|
||||
bar5Option:Click()
|
||||
end
|
||||
end
|
||||
|
||||
function AB:UpdateButtonSettingsForBar(barName)
|
||||
local bar = self.handledBars[barName]
|
||||
self:UpdateButtonConfig(bar, bar.bindButtons)
|
||||
end
|
||||
|
||||
function AB:UpdateButtonSettings()
|
||||
if E.private.actionbar.enable ~= true then return end
|
||||
|
||||
if InCombatLockdown() then
|
||||
AB.NeedsUpdateButtonSettings = true
|
||||
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
return
|
||||
end
|
||||
|
||||
for button in pairs(self.handledbuttons) do
|
||||
if button then
|
||||
self:StyleButton(button, button.noBackdrop, button.useMasque)
|
||||
else
|
||||
self.handledbuttons[button] = nil
|
||||
end
|
||||
end
|
||||
|
||||
self:UpdatePetBindings()
|
||||
self:UpdateStanceBindings()
|
||||
|
||||
for barName, bar in pairs(self.handledBars) do
|
||||
if bar then
|
||||
self:UpdateButtonConfig(bar, bar.bindButtons)
|
||||
self:PositionAndSizeBar(barName)
|
||||
end
|
||||
end
|
||||
|
||||
self:AdjustMaxStanceButtons()
|
||||
self:PositionAndSizeBarPet()
|
||||
self:PositionAndSizeBarShapeShift()
|
||||
end
|
||||
|
||||
function AB:GetPage(bar, defaultPage, condition)
|
||||
local page = self.db[bar].paging[E.myclass]
|
||||
if not condition then condition = "" end
|
||||
if not page then
|
||||
page = ""
|
||||
elseif match(page, "[\n\r]") then
|
||||
page = gsub(page, "[\n\r]","")
|
||||
end
|
||||
|
||||
if page then
|
||||
condition = condition.." "..page
|
||||
end
|
||||
condition = condition.." "..defaultPage
|
||||
|
||||
return condition
|
||||
end
|
||||
|
||||
function AB:StyleButton(button, noBackdrop, useMasque)
|
||||
local name = button:GetName()
|
||||
local icon = _G[name.."Icon"]
|
||||
local count = _G[name.."Count"]
|
||||
local flash = _G[name.."Flash"]
|
||||
local hotkey = _G[name.."HotKey"]
|
||||
local border = _G[name.."Border"]
|
||||
local macroText = _G[name.."Name"]
|
||||
local normal = _G[name.."NormalTexture"]
|
||||
local normal2 = button:GetNormalTexture()
|
||||
local buttonCooldown = _G[name.."Cooldown"]
|
||||
|
||||
local color = self.db.fontColor
|
||||
local countPosition = self.db.countTextPosition or "BOTTOMRIGHT"
|
||||
local countXOffset = self.db.countTextXOffset or 0
|
||||
local countYOffset = self.db.countTextYOffset or 2
|
||||
|
||||
button.noBackdrop = noBackdrop
|
||||
button.useMasque = useMasque
|
||||
|
||||
if flash then flash:SetTexture(nil) end
|
||||
if normal then normal:SetTexture(nil) normal:Hide() normal:SetAlpha(0) end
|
||||
if normal2 then normal2:SetTexture(nil) normal2:Hide() normal2:SetAlpha(0) end
|
||||
if border and not button.useMasque then border:Kill() end
|
||||
|
||||
if count then
|
||||
count:ClearAllPoints()
|
||||
count:Point(countPosition, countXOffset, countYOffset)
|
||||
count:FontTemplate(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
count:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
if macroText then
|
||||
macroText:ClearAllPoints()
|
||||
macroText:Point("BOTTOM", 0, 1)
|
||||
macroText:FontTemplate(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
macroText:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
if not button.noBackdrop and not button.backdrop and not button.useMasque then
|
||||
button:CreateBackdrop(self.db.transparentButtons and "Transparent", true)
|
||||
button.backdrop:SetAllPoints()
|
||||
end
|
||||
|
||||
if icon then
|
||||
icon:SetTexCoord(unpack(E.TexCoords))
|
||||
icon:SetInside()
|
||||
end
|
||||
|
||||
if self.db.hotkeytext or self.db.useRangeColorText then
|
||||
hotkey:FontTemplate(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
if button.config and (button.config.outOfRangeColoring ~= "hotkey") then
|
||||
button.hotkey:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
self:FixKeybindText(button)
|
||||
|
||||
if not button.useMasque then
|
||||
button:StyleButton()
|
||||
else
|
||||
button:StyleButton(true, true, true)
|
||||
end
|
||||
|
||||
if not self.handledbuttons[button] then
|
||||
buttonCooldown.CooldownOverride = "actionbar"
|
||||
|
||||
E:RegisterCooldown(buttonCooldown)
|
||||
|
||||
self.handledbuttons[button] = true
|
||||
end
|
||||
end
|
||||
|
||||
function AB:Bar_OnEnter(bar)
|
||||
if bar:GetParent() == self.fadeParent then
|
||||
if not self.fadeParent.mouseLock then
|
||||
E:UIFrameFadeIn(self.fadeParent, 0.2, self.fadeParent:GetAlpha(), 1)
|
||||
end
|
||||
end
|
||||
|
||||
if bar.mouseover then
|
||||
E:UIFrameFadeIn(bar, 0.2, bar:GetAlpha(), bar.db.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:Bar_OnLeave(bar)
|
||||
if bar:GetParent() == self.fadeParent then
|
||||
if not self.fadeParent.mouseLock then
|
||||
E:UIFrameFadeOut(self.fadeParent, 0.2, self.fadeParent:GetAlpha(), 1 - self.db.globalFadeAlpha)
|
||||
end
|
||||
end
|
||||
|
||||
if bar.mouseover then
|
||||
E:UIFrameFadeOut(bar, 0.2, bar:GetAlpha(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:Button_OnEnter(button)
|
||||
local bar = button:GetParent()
|
||||
if bar:GetParent() == self.fadeParent then
|
||||
if not self.fadeParent.mouseLock then
|
||||
E:UIFrameFadeIn(self.fadeParent, 0.2, self.fadeParent:GetAlpha(), 1)
|
||||
end
|
||||
end
|
||||
|
||||
if bar.mouseover then
|
||||
E:UIFrameFadeIn(bar, 0.2, bar:GetAlpha(), bar.db.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:Button_OnLeave(button)
|
||||
local bar = button:GetParent()
|
||||
if bar:GetParent() == self.fadeParent then
|
||||
if not self.fadeParent.mouseLock then
|
||||
E:UIFrameFadeOut(self.fadeParent, 0.2, self.fadeParent:GetAlpha(), 1 - self.db.globalFadeAlpha)
|
||||
end
|
||||
end
|
||||
|
||||
if bar.mouseover then
|
||||
E:UIFrameFadeOut(bar, 0.2, bar:GetAlpha(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:BlizzardOptionsPanel_OnEvent()
|
||||
InterfaceOptionsActionBarsPanelBottomRightText:SetFormattedText(L["Remove Bar %d Action Page"], 2)
|
||||
InterfaceOptionsActionBarsPanelBottomLeftText:SetFormattedText(L["Remove Bar %d Action Page"], 3)
|
||||
InterfaceOptionsActionBarsPanelRightTwoText:SetFormattedText(L["Remove Bar %d Action Page"], 4)
|
||||
InterfaceOptionsActionBarsPanelRightText:SetFormattedText(L["Remove Bar %d Action Page"], 5)
|
||||
|
||||
InterfaceOptionsActionBarsPanelBottomRight:SetScript("OnEnter", nil)
|
||||
InterfaceOptionsActionBarsPanelBottomLeft:SetScript("OnEnter", nil)
|
||||
InterfaceOptionsActionBarsPanelRightTwo:SetScript("OnEnter", nil)
|
||||
InterfaceOptionsActionBarsPanelRight:SetScript("OnEnter", nil)
|
||||
end
|
||||
|
||||
function AB:FadeParent_OnEvent(event, unit)
|
||||
if (event == "UNIT_SPELLCAST_START"
|
||||
or event == "UNIT_SPELLCAST_STOP"
|
||||
or event == "UNIT_SPELLCAST_CHANNEL_START"
|
||||
or event == "UNIT_SPELLCAST_CHANNEL_STOP"
|
||||
or event == "UNIT_HEALTH") and unit ~= "player" then return end
|
||||
|
||||
local cur, max = UnitHealth("player"), UnitHealthMax("player")
|
||||
local cast, channel = UnitCastingInfo("player"), UnitChannelInfo("player")
|
||||
local target, focus = UnitExists("target"), UnitExists("focus")
|
||||
local combat = UnitAffectingCombat("player")
|
||||
if (cast or channel) or (cur ~= max) or (target or focus) or combat then
|
||||
self.mouseLock = true
|
||||
E:UIFrameFadeIn(self, 0.2, self:GetAlpha(), 1)
|
||||
else
|
||||
self.mouseLock = false
|
||||
E:UIFrameFadeOut(self, 0.2, self:GetAlpha(), 1 - AB.db.globalFadeAlpha)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:DisableBlizzard()
|
||||
UIHider = CreateFrame("Frame")
|
||||
UIHider:Hide()
|
||||
|
||||
MultiBarBottomLeft:SetParent(UIHider)
|
||||
MultiBarBottomLeft.Show = E.noop
|
||||
MultiBarBottomLeft.Hide = E.noop
|
||||
MultiBarBottomRight:SetParent(UIHider)
|
||||
MultiBarBottomRight.Hide = E.noop
|
||||
MultiBarBottomRight.Show = E.noop
|
||||
MultiBarLeft:SetParent(UIHider)
|
||||
MultiBarLeft.Show = E.noop
|
||||
MultiBarLeft.Hide = E.noop
|
||||
MultiBarRight:SetParent(UIHider)
|
||||
MultiBarRight.Show = E.noop
|
||||
MultiBarRight.Hide = E.noop
|
||||
|
||||
-- Hide MultiBar Buttons, but keep the bars alive
|
||||
for i = 1, 12 do
|
||||
_G["ActionButton"..i]:Hide()
|
||||
_G["ActionButton"..i]:UnregisterAllEvents()
|
||||
_G["ActionButton"..i]:SetAttribute("statehidden", true)
|
||||
|
||||
_G["MultiBarBottomLeftButton"..i]:Hide()
|
||||
_G["MultiBarBottomLeftButton"..i]:UnregisterAllEvents()
|
||||
_G["MultiBarBottomLeftButton"..i]:SetAttribute("statehidden", true)
|
||||
|
||||
_G["MultiBarBottomRightButton"..i]:Hide()
|
||||
_G["MultiBarBottomRightButton"..i]:UnregisterAllEvents()
|
||||
_G["MultiBarBottomRightButton"..i]:SetAttribute("statehidden", true)
|
||||
|
||||
_G["MultiBarRightButton"..i]:Hide()
|
||||
_G["MultiBarRightButton"..i]:UnregisterAllEvents()
|
||||
_G["MultiBarRightButton"..i]:SetAttribute("statehidden", true)
|
||||
|
||||
_G["MultiBarLeftButton"..i]:Hide()
|
||||
_G["MultiBarLeftButton"..i]:UnregisterAllEvents()
|
||||
_G["MultiBarLeftButton"..i]:SetAttribute("statehidden", true)
|
||||
|
||||
if _G["VehicleMenuBarActionButton"..i] then
|
||||
_G["VehicleMenuBarActionButton"..i]:Hide()
|
||||
_G["VehicleMenuBarActionButton"..i]:UnregisterAllEvents()
|
||||
_G["VehicleMenuBarActionButton"..i]:SetAttribute("statehidden", true)
|
||||
end
|
||||
|
||||
_G["BonusActionButton"..i]:Hide()
|
||||
_G["BonusActionButton"..i]:UnregisterAllEvents()
|
||||
_G["BonusActionButton"..i]:SetAttribute("statehidden", true)
|
||||
|
||||
end
|
||||
|
||||
MultiCastActionBarFrame.ignoreFramePositionManager = true
|
||||
|
||||
MainMenuBar:Hide()
|
||||
MainMenuBar:SetParent(UIHider)
|
||||
|
||||
MainMenuExpBar:UnregisterAllEvents()
|
||||
MainMenuExpBar:Hide()
|
||||
MainMenuExpBar:SetParent(UIHider)
|
||||
|
||||
ReputationWatchBar:UnregisterAllEvents()
|
||||
ReputationWatchBar:Hide()
|
||||
ReputationWatchBar:SetParent(UIHider)
|
||||
|
||||
MainMenuBarArtFrame:UnregisterAllEvents()
|
||||
MainMenuBarArtFrame:RegisterEvent("KNOWN_CURRENCY_TYPES_UPDATE")
|
||||
MainMenuBarArtFrame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
|
||||
MainMenuBarArtFrame:Hide()
|
||||
MainMenuBarArtFrame:SetParent(UIHider)
|
||||
|
||||
ShapeshiftBarFrame:UnregisterAllEvents()
|
||||
ShapeshiftBarFrame:Hide()
|
||||
ShapeshiftBarFrame:SetParent(UIHider)
|
||||
|
||||
BonusActionBarFrame:UnregisterAllEvents()
|
||||
BonusActionBarFrame:Hide()
|
||||
BonusActionBarFrame:SetParent(UIHider)
|
||||
|
||||
PossessBarFrame:UnregisterAllEvents()
|
||||
PossessBarFrame:Hide()
|
||||
PossessBarFrame:SetParent(UIHider)
|
||||
|
||||
PetActionBarFrame:UnregisterAllEvents()
|
||||
PetActionBarFrame:Hide()
|
||||
PetActionBarFrame:SetParent(UIHider)
|
||||
|
||||
VehicleMenuBar:UnregisterAllEvents()
|
||||
VehicleMenuBar:Hide()
|
||||
VehicleMenuBar:SetParent(UIHider)
|
||||
|
||||
InterfaceOptionsActionBarsPanelAlwaysShowActionBars:EnableMouse(false)
|
||||
InterfaceOptionsActionBarsPanelAlwaysShowActionBars:SetAlpha(0)
|
||||
|
||||
InterfaceOptionsActionBarsPanelLockActionBars:EnableMouse(false)
|
||||
InterfaceOptionsActionBarsPanelLockActionBars:SetAlpha(0)
|
||||
|
||||
InterfaceOptionsStatusTextPanelXP:SetAlpha(0)
|
||||
InterfaceOptionsStatusTextPanelXP:SetScale(0.0001)
|
||||
|
||||
self:SecureHook("BlizzardOptionsPanel_OnEvent")
|
||||
|
||||
if PlayerTalentFrame then
|
||||
PlayerTalentFrame:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
|
||||
else
|
||||
hooksecurefunc("TalentFrame_LoadUI", function() PlayerTalentFrame:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED") end)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:UpdateButtonConfig(bar, buttonName)
|
||||
if InCombatLockdown() then
|
||||
AB.NeedsUpdateButtonSettings = true
|
||||
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
return
|
||||
end
|
||||
|
||||
if not bar.buttonConfig then bar.buttonConfig = {hideElements = {}, colors = {}} end
|
||||
bar.buttonConfig.hideElements.macro = not self.db.macrotext
|
||||
bar.buttonConfig.hideElements.hotkey = not self.db.hotkeytext
|
||||
bar.buttonConfig.showGrid = self.db["bar"..bar.id].showGrid
|
||||
bar.buttonConfig.clickOnDown = self.db.keyDown
|
||||
bar.buttonConfig.outOfRangeColoring = (self.db.useRangeColorText and "hotkey") or "button"
|
||||
SetModifiedClick("PICKUPACTION", self.db.movementModifier)
|
||||
bar.buttonConfig.colors.range = E:SetColorTable(bar.buttonConfig.colors.range, self.db.noRangeColor)
|
||||
bar.buttonConfig.colors.mana = E:SetColorTable(bar.buttonConfig.colors.mana, self.db.noPowerColor)
|
||||
bar.buttonConfig.colors.usable = E:SetColorTable(bar.buttonConfig.colors.usable, self.db.usableColor)
|
||||
bar.buttonConfig.colors.notUsable = E:SetColorTable(bar.buttonConfig.colors.notUsable, self.db.notUsableColor)
|
||||
|
||||
for i, button in pairs(bar.buttons) do
|
||||
bar.buttonConfig.keyBoundTarget = format(buttonName.."%d", i)
|
||||
button.keyBoundTarget = bar.buttonConfig.keyBoundTarget
|
||||
button.postKeybind = AB.FixKeybindText
|
||||
button:SetAttribute("buttonlock", self.db.lockActionBars)
|
||||
button:SetAttribute("checkselfcast", true)
|
||||
button:SetAttribute("checkfocuscast", true)
|
||||
if self.db.rightClickSelfCast then
|
||||
button:SetAttribute("unit2", "player")
|
||||
else
|
||||
button:SetAttribute("unit2", nil)
|
||||
end
|
||||
|
||||
button:UpdateConfig(bar.buttonConfig)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:FixKeybindText(button)
|
||||
local hotkey = _G[button:GetName().."HotKey"]
|
||||
local text = hotkey:GetText()
|
||||
|
||||
local hotkeyPosition = E.db.actionbar.hotkeyTextPosition or "TOPRIGHT"
|
||||
local hotkeyXOffset = E.db.actionbar.hotkeyTextXOffset or 0
|
||||
local hotkeyYOffset = E.db.actionbar.hotkeyTextYOffset or -3
|
||||
|
||||
local justify = "RIGHT"
|
||||
if hotkeyPosition == "TOPLEFT" or hotkeyPosition == "BOTTOMLEFT" then
|
||||
justify = "LEFT"
|
||||
elseif hotkeyPosition == "TOP" or hotkeyPosition == "BOTTOM" then
|
||||
justify = "CENTER"
|
||||
end
|
||||
|
||||
if text then
|
||||
text = gsub(text, "SHIFT%-", L["KEY_SHIFT"])
|
||||
text = gsub(text, "ALT%-", L["KEY_ALT"])
|
||||
text = gsub(text, "CTRL%-", L["KEY_CTRL"])
|
||||
text = gsub(text, "BUTTON", L["KEY_MOUSEBUTTON"])
|
||||
text = gsub(text, "MOUSEWHEELUP", L["KEY_MOUSEWHEELUP"])
|
||||
text = gsub(text, "MOUSEWHEELDOWN", L["KEY_MOUSEWHEELDOWN"])
|
||||
text = gsub(text, "NUMPAD", L["KEY_NUMPAD"])
|
||||
text = gsub(text, "PAGEUP", L["KEY_PAGEUP"])
|
||||
text = gsub(text, "PAGEDOWN", L["KEY_PAGEDOWN"])
|
||||
text = gsub(text, "SPACE", L["KEY_SPACE"])
|
||||
text = gsub(text, "INSERT", L["KEY_INSERT"])
|
||||
text = gsub(text, "HOME", L["KEY_HOME"])
|
||||
text = gsub(text, "DELETE", L["KEY_DELETE"])
|
||||
text = gsub(text, "NMULTIPLY", "*")
|
||||
text = gsub(text, "NMINUS", "N-")
|
||||
text = gsub(text, "NPLUS", "N+")
|
||||
|
||||
hotkey:SetText(text)
|
||||
hotkey:SetJustifyH(justify)
|
||||
end
|
||||
|
||||
if not button.useMasque then
|
||||
hotkey:ClearAllPoints()
|
||||
hotkey:Point(hotkeyPosition, hotkeyXOffset, hotkeyYOffset)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:LAB_ButtonUpdate(button)
|
||||
local color = AB.db.fontColor
|
||||
button.count:SetTextColor(color.r, color.g, color.b)
|
||||
if button.config and (button.config.outOfRangeColoring ~= "hotkey") then
|
||||
button.hotkey:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
if button.backdrop then
|
||||
if AB.db.equippedItem then
|
||||
if button:IsEquipped() and AB.db.equippedItemColor then
|
||||
color = AB.db.equippedItemColor
|
||||
button.backdrop:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
button.backdrop.isColored = true
|
||||
elseif button.backdrop.isColored then
|
||||
button.backdrop.isColored = nil
|
||||
button.backdrop:SetBackdropBorderColor(unpack(E.media.bordercolor))
|
||||
end
|
||||
elseif button.backdrop.isColored then
|
||||
button.backdrop.isColored = nil
|
||||
button.backdrop:SetBackdropBorderColor(unpack(E.media.bordercolor))
|
||||
end
|
||||
end
|
||||
end
|
||||
LAB.RegisterCallback(AB, "OnButtonUpdate", AB.LAB_ButtonUpdate)
|
||||
|
||||
local function OnCooldownUpdate(_, button, start, duration)
|
||||
if button._state_type ~= "action" then return end
|
||||
|
||||
if duration and duration > 1.5 then
|
||||
button.saturationLocked = true --Lock any new actions that are created after we activated desaturation option
|
||||
|
||||
button.icon:SetDesaturated(true)
|
||||
|
||||
if (E.db.cooldown.enable and AB.db.cooldown.reverse) or (not E.db.cooldown.enable and not AB.db.cooldown.reverse) then
|
||||
if not button.onCooldownDoneHooked then
|
||||
AB:HookScript(button.cooldown, "OnHide", function()
|
||||
button.icon:SetDesaturated(false)
|
||||
end)
|
||||
|
||||
button.onCooldownDoneHooked = true
|
||||
end
|
||||
else
|
||||
if not button.onCooldownTimerDoneHooked then
|
||||
if button.cooldown.timer then
|
||||
AB:HookScript(button.cooldown.timer, "OnHide", function()
|
||||
if (E.db.cooldown.enable and AB.db.cooldown.reverse) or (not E.db.cooldown.enable and not AB.db.cooldown.reverse) then return end
|
||||
|
||||
button.icon:SetDesaturated(false)
|
||||
end)
|
||||
|
||||
button.onCooldownTimerDoneHooked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:ToggleDesaturation(value)
|
||||
value = value or self.db.desaturateOnCooldown
|
||||
|
||||
if value then
|
||||
LAB.RegisterCallback(AB, "OnCooldownUpdate", OnCooldownUpdate)
|
||||
local start, duration
|
||||
for button in pairs(LAB.actionButtons) do
|
||||
button.saturationLocked = true
|
||||
start, duration = button:GetCooldown()
|
||||
OnCooldownUpdate(nil, button, start, duration)
|
||||
end
|
||||
else
|
||||
LAB.UnregisterCallback(AB, "OnCooldownUpdate")
|
||||
for button in pairs(LAB.actionButtons) do
|
||||
button.saturationLocked = nil
|
||||
button.icon:SetDesaturated(false)
|
||||
if (E.db.cooldown.enable and AB.db.cooldown.reverse) or (not E.db.cooldown.enable and not AB.db.cooldown.reverse) then
|
||||
if button.onCooldownDoneHooked then
|
||||
AB:Unhook(button.cooldown, "OnHide")
|
||||
|
||||
button.onCooldownDoneHooked = nil
|
||||
end
|
||||
else
|
||||
if button.onCooldownTimerDoneHooked then
|
||||
if button.cooldown.timer then
|
||||
if (E.db.cooldown.enable and AB.db.cooldown.reverse) or (not E.db.cooldown.enable and not AB.db.cooldown.reverse) then return end
|
||||
|
||||
AB:Unhook(button.cooldown.timer, "OnHide")
|
||||
|
||||
button.onCooldownTimerDoneHooked = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:Initialize()
|
||||
self.db = E.db.actionbar
|
||||
if E.private.actionbar.enable ~= true then return end
|
||||
self.Initialized = true
|
||||
|
||||
self.LBFGroup = LBF and LBF:Group("ElvUI", "ActionBars")
|
||||
|
||||
self.fadeParent = CreateFrame("Frame", "Elv_ABFade", UIParent)
|
||||
self.fadeParent:SetAlpha(1 - self.db.globalFadeAlpha)
|
||||
self.fadeParent:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
self.fadeParent:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
self.fadeParent:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
self.fadeParent:RegisterEvent("UNIT_SPELLCAST_START")
|
||||
self.fadeParent:RegisterEvent("UNIT_SPELLCAST_STOP")
|
||||
self.fadeParent:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
|
||||
self.fadeParent:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
|
||||
self.fadeParent:RegisterEvent("UNIT_HEALTH")
|
||||
self.fadeParent:RegisterEvent("PLAYER_FOCUS_CHANGED")
|
||||
self.fadeParent:SetScript("OnEvent", self.FadeParent_OnEvent)
|
||||
|
||||
self:DisableBlizzard()
|
||||
self:SetupMicroBar()
|
||||
self:UpdateBar1Paging()
|
||||
|
||||
for i = 1, 6 do
|
||||
self:CreateBar(i)
|
||||
end
|
||||
|
||||
self:CreateBarPet()
|
||||
self:CreateBarShapeShift()
|
||||
self:CreateVehicleLeave()
|
||||
|
||||
if self.db.barTotem.enabled then
|
||||
self:CreateTotemBar()
|
||||
end
|
||||
|
||||
self:UpdateButtonSettings()
|
||||
self:LoadKeyBinder()
|
||||
|
||||
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
|
||||
self:ReassignBindings()
|
||||
|
||||
--We handle actionbar lock for regular bars, but the lock on PetBar needs to be handled by WoW so make some necessary updates
|
||||
SetCVar("lockActionBars", (self.db.lockActionBars == true and 1 or 0))
|
||||
LOCK_ACTIONBAR = (self.db.lockActionBars == true and "1" or "0") --Keep an eye on this, in case it taints
|
||||
|
||||
self:ToggleDesaturation()
|
||||
end
|
||||
|
||||
local function InitializeCallback()
|
||||
AB:Initialize()
|
||||
end
|
||||
|
||||
E:RegisterModule(AB:GetName(), InitializeCallback)
|
||||
@@ -0,0 +1,392 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local AB = E:GetModule("ActionBars")
|
||||
local Skins = E:GetModule("Skins")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local select, tonumber, pairs = select, tonumber, pairs
|
||||
local floor = math.floor
|
||||
local find, format, upper = string.find, string.format, string.upper
|
||||
--WoW API / Variables
|
||||
local hooksecurefunc = hooksecurefunc
|
||||
local CreateFrame = CreateFrame
|
||||
local IsAddOnLoaded = IsAddOnLoaded
|
||||
local LoadBindings, SaveBindings = LoadBindings, SaveBindings
|
||||
local GetCurrentBindingSet = GetCurrentBindingSet
|
||||
local SetBinding = SetBinding
|
||||
local GetBindingKey = GetBindingKey
|
||||
local IsAltKeyDown, IsControlKeyDown = IsAltKeyDown, IsControlKeyDown
|
||||
local IsShiftKeyDown, IsModifiedClick = IsShiftKeyDown, IsModifiedClick
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local GameTooltip_ShowCompareItem = GameTooltip_ShowCompareItem
|
||||
local GetMacroInfo = GetMacroInfo
|
||||
local SecureActionButton_OnClick = SecureActionButton_OnClick
|
||||
local GameTooltip_Hide = GameTooltip_Hide
|
||||
local CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP = CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP
|
||||
local CHARACTER_SPECIFIC_KEYBINDINGS = CHARACTER_SPECIFIC_KEYBINDINGS
|
||||
|
||||
local bind = CreateFrame("Frame", "ElvUI_KeyBinder", E.UIParent)
|
||||
|
||||
function AB:ActivateBindMode()
|
||||
if InCombatLockdown() then
|
||||
return
|
||||
end
|
||||
|
||||
bind.active = true
|
||||
E:StaticPopupSpecial_Show(ElvUIBindPopupWindow)
|
||||
AB:RegisterEvent("PLAYER_REGEN_DISABLED", "DeactivateBindMode", false)
|
||||
end
|
||||
|
||||
function AB:DeactivateBindMode(save)
|
||||
if save then
|
||||
SaveBindings(GetCurrentBindingSet())
|
||||
E:Print(L["Binds Saved"])
|
||||
else
|
||||
LoadBindings(GetCurrentBindingSet())
|
||||
E:Print(L["Binds Discarded"])
|
||||
end
|
||||
|
||||
bind.active = false
|
||||
self:BindHide()
|
||||
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
|
||||
E:StaticPopupSpecial_Hide(ElvUIBindPopupWindow)
|
||||
AB.bindingsChanged = false
|
||||
end
|
||||
|
||||
function AB:BindHide()
|
||||
bind:ClearAllPoints()
|
||||
bind:Hide()
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
|
||||
function AB:BindListener(key)
|
||||
AB.bindingsChanged = true
|
||||
if key == "ESCAPE" or key == "RightButton" then
|
||||
if bind.button.bindings then
|
||||
for i = 1, #bind.button.bindings do
|
||||
SetBinding(bind.button.bindings[i])
|
||||
end
|
||||
end
|
||||
E:Print(format(L["All keybindings cleared for |cff00ff00%s|r."], bind.button.name))
|
||||
self:BindUpdate(bind.button, bind.spellmacro)
|
||||
if bind.spellmacro ~= "MACRO" then
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if key == "LSHIFT"
|
||||
or key == "RSHIFT"
|
||||
or key == "LCTRL"
|
||||
or key == "RCTRL"
|
||||
or key == "LALT"
|
||||
or key == "RALT"
|
||||
or key == "UNKNOWN"
|
||||
or key == "LeftButton"
|
||||
then return end
|
||||
|
||||
if key == "MiddleButton" then key = "BUTTON3" end
|
||||
if find(key, "Button%d") then
|
||||
key = upper(key)
|
||||
end
|
||||
|
||||
local alt = IsAltKeyDown() and "ALT-" or ""
|
||||
local ctrl = IsControlKeyDown() and "CTRL-" or ""
|
||||
local shift = IsShiftKeyDown() and "SHIFT-" or ""
|
||||
local keybind = format("%s%s%s%s", alt, ctrl, shift, key)
|
||||
|
||||
if not bind.spellmacro or bind.spellmacro == "PET" or bind.spellmacro == "SHAPESHIFT" then
|
||||
SetBinding(keybind, bind.button.bindstring)
|
||||
else
|
||||
SetBinding(keybind, bind.spellmacro.." "..bind.button.name)
|
||||
end
|
||||
|
||||
E:Print(format("%s%s%s.", keybind, L[" |cff00ff00bound to |r"], bind.button.name))
|
||||
self:BindUpdate(bind.button, bind.spellmacro)
|
||||
|
||||
if bind.spellmacro ~= "MACRO" then
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function AB:BindUpdate(button, spellmacro)
|
||||
if not bind.active or InCombatLockdown() then return end
|
||||
|
||||
bind.button = button
|
||||
bind.spellmacro = spellmacro
|
||||
|
||||
bind:ClearAllPoints()
|
||||
bind:SetAllPoints(button)
|
||||
bind:Show()
|
||||
|
||||
ShoppingTooltip1:Hide()
|
||||
|
||||
if not bind:IsMouseEnabled() then
|
||||
bind:EnableMouse(true)
|
||||
end
|
||||
|
||||
if spellmacro == "MACRO" then
|
||||
bind.button.id = bind.button:GetID()
|
||||
|
||||
if floor(.5 + select(2, MacroFrameTab1Text:GetTextColor()) * 10) / 10 == .8 then bind.button.id = bind.button.id + MAX_ACCOUNT_MACROS end
|
||||
|
||||
bind.button.name = GetMacroInfo(bind.button.id)
|
||||
|
||||
GameTooltip:SetOwner(bind, "ANCHOR_TOP")
|
||||
GameTooltip:SetPoint("BOTTOM", bind, "TOP", 0, 1)
|
||||
GameTooltip:AddLine(bind.button.name, 1, 1, 1)
|
||||
|
||||
bind.button.bindings = {GetBindingKey(spellmacro.." "..bind.button.name)}
|
||||
|
||||
if #bind.button.bindings == 0 then
|
||||
GameTooltip:AddLine(L["No bindings set."], .6, .6, .6)
|
||||
else
|
||||
GameTooltip:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6)
|
||||
for i = 1, #bind.button.bindings do
|
||||
GameTooltip:AddDoubleLine(L["Binding"]..i, bind.button.bindings[i], 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
GameTooltip:Show()
|
||||
elseif spellmacro == "SHAPESHIFT" or spellmacro == "PET" then
|
||||
bind.button.id = tonumber(button:GetID())
|
||||
bind.button.name = button:GetName()
|
||||
|
||||
if not bind.button.name then return end
|
||||
|
||||
if not bind.button.id or bind.button.id < 1 or bind.button.id > (spellmacro=="SHAPESHIFT" and 10 or 12) then
|
||||
bind.button.bindstring = "CLICK "..bind.button.name..":LeftButton"
|
||||
else
|
||||
bind.button.bindstring = (spellmacro=="SHAPESHIFT" and "SHAPESHIFTBUTTON" or "BONUSACTIONBUTTON")..bind.button.id
|
||||
end
|
||||
|
||||
GameTooltip:AddLine(L["Trigger"])
|
||||
GameTooltip:Show()
|
||||
GameTooltip:SetScript("OnHide", function(tt)
|
||||
tt:SetOwner(bind, "ANCHOR_NONE")
|
||||
tt:SetPoint("BOTTOM", bind, "TOP", 0, 1)
|
||||
tt:AddLine(bind.button.name, 1, 1, 1)
|
||||
bind.button.bindings = {GetBindingKey(bind.button.bindstring)}
|
||||
if #bind.button.bindings == 0 then
|
||||
tt:AddLine(L["No bindings set."], .6, .6, .6)
|
||||
else
|
||||
tt:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6)
|
||||
for i = 1, #bind.button.bindings do
|
||||
tt:AddDoubleLine(i, bind.button.bindings[i])
|
||||
end
|
||||
end
|
||||
tt:Show()
|
||||
tt:SetScript("OnHide", nil)
|
||||
end)
|
||||
else
|
||||
bind.button.action = tonumber(button.action)
|
||||
bind.button.name = button:GetName()
|
||||
|
||||
if not bind.button.name then return end
|
||||
if (not bind.button.action or bind.button.action < 1 or bind.button.action > 132) and not (bind.button.keyBoundTarget) then
|
||||
bind.button.bindstring = "CLICK "..bind.button.name..":LeftButton"
|
||||
elseif bind.button.keyBoundTarget then
|
||||
bind.button.bindstring = bind.button.keyBoundTarget
|
||||
else
|
||||
local modact = 1 + (bind.button.action-1) % 12
|
||||
if bind.button.action < 25 or bind.button.action > 72 then
|
||||
bind.button.bindstring = "ACTIONBUTTON"..modact
|
||||
elseif bind.button.action < 73 and bind.button.action > 60 then
|
||||
bind.button.bindstring = "MULTIACTIONBAR1BUTTON"..modact
|
||||
elseif bind.button.action < 61 and bind.button.action > 48 then
|
||||
bind.button.bindstring = "MULTIACTIONBAR2BUTTON"..modact
|
||||
elseif bind.button.action < 49 and bind.button.action > 36 then
|
||||
bind.button.bindstring = "MULTIACTIONBAR4BUTTON"..modact
|
||||
elseif bind.button.action < 37 and bind.button.action > 24 then
|
||||
bind.button.bindstring = "MULTIACTIONBAR3BUTTON"..modact
|
||||
end
|
||||
end
|
||||
|
||||
GameTooltip:AddLine(L["Trigger"])
|
||||
GameTooltip:Show()
|
||||
GameTooltip:SetScript("OnHide", function(tt)
|
||||
tt:SetOwner(bind, "ANCHOR_TOP")
|
||||
tt:SetPoint("BOTTOM", bind, "TOP", 0, 4)
|
||||
tt:AddLine(bind.button.name, 1, 1, 1)
|
||||
bind.button.bindings = {GetBindingKey(bind.button.bindstring)}
|
||||
if #bind.button.bindings == 0 then
|
||||
tt:AddLine(L["No bindings set."], .6, .6, .6)
|
||||
else
|
||||
tt:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6)
|
||||
for i = 1, #bind.button.bindings do
|
||||
tt:AddDoubleLine(i, bind.button.bindings[i])
|
||||
end
|
||||
end
|
||||
tt:Show()
|
||||
tt:SetScript("OnHide", nil)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:RegisterButton(button, override)
|
||||
local shapeshift = ShapeshiftButton1:GetScript("OnClick")
|
||||
local pet = PetActionButton1:GetScript("OnClick")
|
||||
local secureOnClick = SecureActionButton_OnClick
|
||||
|
||||
if button.IsProtected and button.GetObjectType and button.GetScript and button:GetObjectType() == "CheckButton" and button:IsProtected() then
|
||||
local script = button:GetScript("OnClick")
|
||||
|
||||
if script == secureOnClick or override then
|
||||
button:HookScript("OnEnter", function(b) self:BindUpdate(b) end)
|
||||
|
||||
if script == shapeshift then
|
||||
button:HookScript("OnEnter", function(b) self:BindUpdate(b, "SHAPESHIFT") end)
|
||||
elseif script == pet then
|
||||
button:HookScript("OnEnter", function(b) self:BindUpdate(b, "PET") end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local elapsed = 0
|
||||
function AB:Tooltip_OnUpdate(tooltip, e)
|
||||
elapsed = elapsed + e
|
||||
if elapsed < .2 then return else elapsed = 0 end
|
||||
|
||||
local compareItems = IsModifiedClick("COMPAREITEMS")
|
||||
if not tooltip.comparing and compareItems and tooltip:GetItem() then
|
||||
GameTooltip_ShowCompareItem(tooltip)
|
||||
tooltip.comparing = true
|
||||
elseif tooltip.comparing and not compareItems then
|
||||
for _, frame in pairs(tooltip.shoppingTooltips) do frame:Hide() end
|
||||
tooltip.comparing = false
|
||||
end
|
||||
end
|
||||
|
||||
function AB:RegisterMacro(addon)
|
||||
if addon == "Blizzard_MacroUI" then
|
||||
for i = 1, MAX_ACCOUNT_MACROS do
|
||||
local button = _G["MacroButton"..i]
|
||||
button:HookScript("OnEnter", function(b) AB:BindUpdate(b, "MACRO") end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:ChangeBindingProfile()
|
||||
if ElvUIBindPopupWindowCheckButton:GetChecked() then
|
||||
LoadBindings(2)
|
||||
SaveBindings(2)
|
||||
else
|
||||
LoadBindings(1)
|
||||
SaveBindings(1)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:LoadKeyBinder()
|
||||
bind:SetFrameStrata("DIALOG")
|
||||
bind:SetFrameLevel(99)
|
||||
bind:EnableMouse(true)
|
||||
bind:EnableKeyboard(true)
|
||||
bind:EnableMouseWheel(true)
|
||||
bind.texture = bind:CreateTexture()
|
||||
bind.texture:SetAllPoints(bind)
|
||||
bind.texture:SetTexture(0, 0, 0, .25)
|
||||
bind:Hide()
|
||||
|
||||
self:HookScript(GameTooltip, "OnUpdate", "Tooltip_OnUpdate")
|
||||
hooksecurefunc(GameTooltip, "Hide", function(tooltip) for _, tt in pairs(tooltip.shoppingTooltips) do tt:Hide() end end)
|
||||
|
||||
bind:SetScript("OnEnter", function(self) local db = self.button:GetParent().db if db and db.mouseover then AB:Button_OnEnter(self.button) end end)
|
||||
bind:SetScript("OnLeave", function(self) AB:BindHide() local db = self.button:GetParent().db if db and db.mouseover then AB:Button_OnLeave(self.button) end end)
|
||||
bind:SetScript("OnKeyUp", function(_, key) self:BindListener(key) end)
|
||||
bind:SetScript("OnMouseUp", function(_, key) self:BindListener(key) end)
|
||||
bind:SetScript("OnMouseWheel", function(_, delta) if delta > 0 then self:BindListener("MOUSEWHEELUP") else self:BindListener("MOUSEWHEELDOWN") end end)
|
||||
|
||||
for b, _ in pairs(self.handledbuttons) do
|
||||
self:RegisterButton(b, true)
|
||||
end
|
||||
|
||||
if not IsAddOnLoaded("Blizzard_MacroUI") then
|
||||
self:SecureHook("LoadAddOn", "RegisterMacro")
|
||||
else
|
||||
self:RegisterMacro("Blizzard_MacroUI")
|
||||
end
|
||||
|
||||
--Special Popup
|
||||
local f = CreateFrame("Frame", "ElvUIBindPopupWindow", UIParent)
|
||||
f:SetFrameStrata("DIALOG")
|
||||
f:SetToplevel(true)
|
||||
f:EnableMouse(true)
|
||||
f:SetMovable(true)
|
||||
f:SetFrameLevel(99)
|
||||
f:SetClampedToScreen(true)
|
||||
f:SetWidth(360)
|
||||
f:SetHeight(130)
|
||||
f:SetTemplate("Transparent")
|
||||
f:Hide()
|
||||
|
||||
local header = CreateFrame("Button", nil, f)
|
||||
header:SetTemplate(nil, true)
|
||||
header:Width(100)
|
||||
header:Height(25)
|
||||
header:Point("CENTER", f, "TOP")
|
||||
header:SetFrameLevel(header:GetFrameLevel() + 2)
|
||||
header:EnableMouse(true)
|
||||
header:RegisterForClicks("AnyUp", "AnyDown")
|
||||
header:SetScript("OnMouseDown", function() f:StartMoving() end)
|
||||
header:SetScript("OnMouseUp", function() f:StopMovingOrSizing() end)
|
||||
|
||||
local title = header:CreateFontString("OVERLAY")
|
||||
title:FontTemplate()
|
||||
title:Point("CENTER", header, "CENTER")
|
||||
title:SetText("Key Binds")
|
||||
|
||||
local desc = f:CreateFontString("ARTWORK")
|
||||
desc:SetFontObject("GameFontHighlight")
|
||||
desc:SetJustifyV("TOP")
|
||||
desc:SetJustifyH("LEFT")
|
||||
desc:Point("TOPLEFT", 18, -32)
|
||||
desc:Point("BOTTOMRIGHT", -18, 48)
|
||||
desc:SetText(L["Hover your mouse over any actionbutton or spellbook button to bind it. Press the ESC key to clear the current actionbutton's keybinding."])
|
||||
|
||||
local perCharCheck = CreateFrame("CheckButton", f:GetName().."CheckButton", f, "OptionsCheckButtonTemplate")
|
||||
_G[perCharCheck:GetName().."Text"]:SetText(CHARACTER_SPECIFIC_KEYBINDINGS)
|
||||
|
||||
perCharCheck:SetScript("OnShow", function(self)
|
||||
self:SetChecked(GetCurrentBindingSet() == 2)
|
||||
end)
|
||||
|
||||
perCharCheck:SetScript("OnClick", function()
|
||||
if ( AB.bindingsChanged ) then
|
||||
E:StaticPopup_Show("CONFIRM_LOSE_BINDING_CHANGES")
|
||||
else
|
||||
AB:ChangeBindingProfile()
|
||||
end
|
||||
end)
|
||||
|
||||
perCharCheck:SetScript("OnEnter", function(self)
|
||||
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||||
GameTooltip:SetText(CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP, nil, nil, nil, nil, 1)
|
||||
end)
|
||||
|
||||
perCharCheck:SetScript("OnLeave", GameTooltip_Hide)
|
||||
|
||||
local save = CreateFrame("Button", f:GetName().."SaveButton", f, "OptionsButtonTemplate")
|
||||
_G[save:GetName().."Text"]:SetText(L["Save"])
|
||||
save:Width(150)
|
||||
save:SetScript("OnClick", function()
|
||||
AB:DeactivateBindMode(true)
|
||||
end)
|
||||
|
||||
local discard = CreateFrame("Button", f:GetName().."DiscardButton", f, "OptionsButtonTemplate")
|
||||
discard:Width(150)
|
||||
_G[discard:GetName().."Text"]:SetText(L["Discard"])
|
||||
|
||||
discard:SetScript("OnClick", function()
|
||||
AB:DeactivateBindMode(false)
|
||||
end)
|
||||
|
||||
--position buttons
|
||||
perCharCheck:Point("BOTTOMLEFT", discard, "TOPLEFT", 0, 2)
|
||||
save:Point("BOTTOMRIGHT", -14, 10)
|
||||
discard:Point("BOTTOMLEFT", 14, 10)
|
||||
|
||||
Skins:HandleCheckBox(perCharCheck)
|
||||
Skins:HandleButton(save)
|
||||
Skins:HandleButton(discard)
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="ActionBars.lua"/>
|
||||
<Script file="MicroBar.lua"/>
|
||||
<Script file="PetBar.lua"/>
|
||||
<Script file="StanceBar.lua"/>
|
||||
<Script file="TotemBar.lua"/>
|
||||
<Script file="Bind.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,194 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local AB = E:GetModule("ActionBars")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
|
||||
local MICRO_BUTTONS = {
|
||||
"CharacterMicroButton",
|
||||
"SpellbookMicroButton",
|
||||
"TalentMicroButton",
|
||||
"AchievementMicroButton",
|
||||
"QuestLogMicroButton",
|
||||
"SocialsMicroButton",
|
||||
"PVPMicroButton",
|
||||
"LFDMicroButton",
|
||||
"MainMenuMicroButton",
|
||||
"HelpMicroButton"
|
||||
}
|
||||
|
||||
local function onEnter(button)
|
||||
if AB.db.microbar.mouseover then
|
||||
E:UIFrameFadeIn(ElvUI_MicroBar, 0.2, ElvUI_MicroBar:GetAlpha(), AB.db.microbar.alpha)
|
||||
end
|
||||
|
||||
if button and button ~= ElvUI_MicroBar and button.backdrop then
|
||||
button.backdrop:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
|
||||
end
|
||||
end
|
||||
|
||||
local function onLeave(button)
|
||||
if AB.db.microbar.mouseover then
|
||||
E:UIFrameFadeOut(ElvUI_MicroBar, 0.2, ElvUI_MicroBar:GetAlpha(), 0)
|
||||
end
|
||||
|
||||
if button and button ~= ElvUI_MicroBar and button.backdrop then
|
||||
button.backdrop:SetBackdropBorderColor(unpack(E.media.bordercolor))
|
||||
end
|
||||
end
|
||||
|
||||
function AB:HandleMicroButton(button)
|
||||
local pushed = button:GetPushedTexture()
|
||||
local normal = button:GetNormalTexture()
|
||||
local disabled = button:GetDisabledTexture()
|
||||
|
||||
local f = CreateFrame("Frame", nil, button)
|
||||
f:SetFrameLevel(button:GetFrameLevel() - 1)
|
||||
f:SetTemplate("Default", true)
|
||||
f:SetOutside(button)
|
||||
button.backdrop = f
|
||||
|
||||
button:SetParent(ElvUI_MicroBar)
|
||||
button:GetHighlightTexture():Kill()
|
||||
button:HookScript("OnEnter", onEnter)
|
||||
button:HookScript("OnLeave", onLeave)
|
||||
button:SetHitRectInsets(0, 0, 0, 0)
|
||||
button:Show()
|
||||
|
||||
pushed:SetTexCoord(0.17, 0.87, 0.5, 0.908)
|
||||
pushed:SetInside(f)
|
||||
|
||||
normal:SetTexCoord(0.17, 0.87, 0.5, 0.908)
|
||||
normal:SetInside(f)
|
||||
|
||||
if disabled then
|
||||
disabled:SetTexCoord(0.17, 0.87, 0.5, 0.908)
|
||||
disabled:SetInside(f)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:UpdateMicroButtonsParent()
|
||||
if CharacterMicroButton:GetParent() == ElvUI_MicroBar then return end
|
||||
|
||||
for i = 1, #MICRO_BUTTONS do
|
||||
_G[MICRO_BUTTONS[i]]:SetParent(ElvUI_MicroBar)
|
||||
end
|
||||
|
||||
AB:UpdateMicroPositionDimensions()
|
||||
end
|
||||
|
||||
function AB:UpdateMicroBarVisibility()
|
||||
if InCombatLockdown() then
|
||||
AB.NeedsUpdateMicroBarVisibility = true
|
||||
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
return
|
||||
end
|
||||
|
||||
local visibility = self.db.microbar.visibility
|
||||
if visibility and string.match(visibility, "[\n\r]") then
|
||||
visibility = string.gsub(visibility, "[\n\r]", "")
|
||||
end
|
||||
|
||||
RegisterStateDriver(ElvUI_MicroBar.visibility, "visibility", (self.db.microbar.enabled and visibility) or "hide")
|
||||
end
|
||||
|
||||
function AB:UpdateMicroPositionDimensions()
|
||||
if not ElvUI_MicroBar then return end
|
||||
|
||||
local numRows = 1
|
||||
local prevButton = ElvUI_MicroBar
|
||||
local offset = E:Scale(E.PixelMode and 1 or 3)
|
||||
local spacing = E:Scale(offset + self.db.microbar.buttonSpacing)
|
||||
|
||||
for i = 1, #MICRO_BUTTONS do
|
||||
local button = _G[MICRO_BUTTONS[i]]
|
||||
local lastColumnButton = i - self.db.microbar.buttonsPerRow
|
||||
lastColumnButton = _G[MICRO_BUTTONS[lastColumnButton]]
|
||||
|
||||
button:Size(self.db.microbar.buttonSize, self.db.microbar.buttonSize * 1.4)
|
||||
button:ClearAllPoints()
|
||||
|
||||
if prevButton == ElvUI_MicroBar then
|
||||
button:Point("TOPLEFT", prevButton, "TOPLEFT", offset, -offset)
|
||||
elseif (i - 1) % self.db.microbar.buttonsPerRow == 0 then
|
||||
button:Point("TOP", lastColumnButton, "BOTTOM", 0, -spacing)
|
||||
numRows = numRows + 1
|
||||
else
|
||||
button:Point("LEFT", prevButton, "RIGHT", spacing, 0)
|
||||
end
|
||||
|
||||
prevButton = button
|
||||
end
|
||||
|
||||
if AB.db.microbar.mouseover and not ElvUI_MicroBar:IsMouseOver() then
|
||||
ElvUI_MicroBar:SetAlpha(0)
|
||||
else
|
||||
ElvUI_MicroBar:SetAlpha(self.db.microbar.alpha)
|
||||
end
|
||||
|
||||
AB.MicroWidth = (((CharacterMicroButton:GetWidth() + spacing) * self.db.microbar.buttonsPerRow) - spacing) + (offset * 2)
|
||||
AB.MicroHeight = (((CharacterMicroButton:GetHeight() + spacing) * numRows) - spacing) + (offset * 2)
|
||||
ElvUI_MicroBar:Size(AB.MicroWidth, AB.MicroHeight)
|
||||
|
||||
if ElvUI_MicroBar.mover then
|
||||
if self.db.microbar.enabled then
|
||||
E:EnableMover(ElvUI_MicroBar.mover:GetName())
|
||||
else
|
||||
E:DisableMover(ElvUI_MicroBar.mover:GetName())
|
||||
end
|
||||
end
|
||||
|
||||
self:UpdateMicroBarVisibility()
|
||||
end
|
||||
|
||||
function AB:UpdateMicroButtons()
|
||||
-- PvP Micro Button
|
||||
PVPMicroButtonTexture:Point("TOPLEFT", PVPMicroButton, "TOPLEFT")
|
||||
PVPMicroButtonTexture:Point("BOTTOMRIGHT", PVPMicroButton, "BOTTOMRIGHT")
|
||||
PVPMicroButtonTexture:SetTexture("Interface\\AddOns\\ElvUI\\media\\textures\\PVP-Icons")
|
||||
|
||||
if E.mylevel < PVPMicroButton.minLevel then
|
||||
PVPMicroButtonTexture:SetDesaturated(true)
|
||||
else
|
||||
PVPMicroButtonTexture:SetDesaturated(false)
|
||||
end
|
||||
|
||||
self:UpdateMicroPositionDimensions()
|
||||
end
|
||||
|
||||
function AB:SetupMicroBar()
|
||||
local microBar = CreateFrame("Frame", "ElvUI_MicroBar", E.UIParent)
|
||||
microBar:Point("TOPLEFT", E.UIParent, "TOPLEFT", 4, -48)
|
||||
microBar:SetFrameStrata("LOW")
|
||||
microBar:EnableMouse(true)
|
||||
microBar:SetScript("OnEnter", onEnter)
|
||||
microBar:SetScript("OnLeave", onLeave)
|
||||
|
||||
microBar.visibility = CreateFrame("Frame", nil, E.UIParent, "SecureHandlerStateTemplate")
|
||||
microBar.visibility:SetScript("OnShow", function() microBar:Show() end)
|
||||
microBar.visibility:SetScript("OnHide", function() microBar:Hide() end)
|
||||
|
||||
for i = 1, #MICRO_BUTTONS do
|
||||
self:HandleMicroButton(_G[MICRO_BUTTONS[i]])
|
||||
end
|
||||
|
||||
MicroButtonPortrait:SetInside(CharacterMicroButton.backdrop)
|
||||
|
||||
if E.myfaction == "Alliance" then
|
||||
PVPMicroButtonTexture:SetTexCoord(0.545, 0.935, 0.070, 0.940)
|
||||
else
|
||||
PVPMicroButtonTexture:SetTexCoord(0.100, 0.475, 0.070, 0.940)
|
||||
end
|
||||
|
||||
self:SecureHook("VehicleMenuBar_MoveMicroButtons", "UpdateMicroButtonsParent")
|
||||
self:SecureHook("UpdateMicroButtons")
|
||||
|
||||
self:UpdateMicroPositionDimensions()
|
||||
MainMenuBarPerformanceBar:Kill()
|
||||
|
||||
E:CreateMover(microBar, "MicrobarMover", L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS", nil, "actionbar,microbar")
|
||||
end
|
||||
@@ -0,0 +1,308 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local AB = E:GetModule("ActionBars")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local ceil = math.ceil
|
||||
--WoW API / Variables
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
local GetBindingKey = GetBindingKey
|
||||
local PetHasActionBar = PetHasActionBar
|
||||
local GetPetActionInfo = GetPetActionInfo
|
||||
local IsPetAttackAction = IsPetAttackAction
|
||||
local PetActionButton_StartFlash = PetActionButton_StartFlash
|
||||
local PetActionButton_StopFlash = PetActionButton_StopFlash
|
||||
local AutoCastShine_AutoCastStart = AutoCastShine_AutoCastStart
|
||||
local AutoCastShine_AutoCastStop = AutoCastShine_AutoCastStop
|
||||
local GetPetActionSlotUsable = GetPetActionSlotUsable
|
||||
local SetDesaturation = SetDesaturation
|
||||
local PetActionBar_ShowGrid = PetActionBar_ShowGrid
|
||||
local PetActionBar_UpdateCooldowns = PetActionBar_UpdateCooldowns
|
||||
local NUM_PET_ACTION_SLOTS = NUM_PET_ACTION_SLOTS
|
||||
|
||||
local bar = CreateFrame("Frame", "ElvUI_BarPet", E.UIParent, "SecureHandlerStateTemplate")
|
||||
bar:SetFrameStrata("LOW")
|
||||
|
||||
function AB:UpdatePet(event, unit)
|
||||
if (event == "UNIT_FLAGS" or event == "UNIT_AURA") and unit ~= "pet" then return end
|
||||
if event == "UNIT_PET" and unit ~= "player" then return end
|
||||
|
||||
for i = 1, NUM_PET_ACTION_SLOTS, 1 do
|
||||
local buttonName = "PetActionButton"..i
|
||||
local button = _G[buttonName]
|
||||
local icon = _G[buttonName.."Icon"]
|
||||
local autoCast = _G[buttonName.."AutoCastable"]
|
||||
local shine = _G[buttonName.."Shine"]
|
||||
local name, subtext, texture, isToken, isActive, autoCastAllowed, autoCastEnabled = GetPetActionInfo(i)
|
||||
|
||||
if not isToken then
|
||||
icon:SetTexture(texture)
|
||||
button.tooltipName = name
|
||||
else
|
||||
icon:SetTexture(_G[texture])
|
||||
button.tooltipName = _G[name]
|
||||
end
|
||||
|
||||
button.isToken = isToken
|
||||
button.tooltipSubtext = subtext
|
||||
|
||||
if isActive --[[and name ~= "PET_ACTION_FOLLOW"]] then
|
||||
button:SetChecked(true)
|
||||
|
||||
if IsPetAttackAction(i) then
|
||||
PetActionButton_StartFlash(button)
|
||||
end
|
||||
else
|
||||
button:SetChecked(false)
|
||||
if IsPetAttackAction(i) then
|
||||
PetActionButton_StopFlash(button)
|
||||
end
|
||||
end
|
||||
|
||||
if autoCastAllowed then
|
||||
autoCast:Show()
|
||||
else
|
||||
autoCast:Hide()
|
||||
end
|
||||
|
||||
if autoCastEnabled then
|
||||
AutoCastShine_AutoCastStart(shine)
|
||||
else
|
||||
AutoCastShine_AutoCastStop(shine)
|
||||
end
|
||||
|
||||
if texture then
|
||||
if GetPetActionSlotUsable(i) then
|
||||
SetDesaturation(icon, nil)
|
||||
SetDesaturation(autoCast, nil)
|
||||
else
|
||||
SetDesaturation(icon, 1)
|
||||
SetDesaturation(autoCast, 1)
|
||||
end
|
||||
icon:Show()
|
||||
else
|
||||
icon:Hide()
|
||||
end
|
||||
|
||||
if not PetHasActionBar() and texture --[[and name ~= "PET_ACTION_FOLLOW"]] then
|
||||
PetActionButton_StopFlash(button)
|
||||
SetDesaturation(icon, 1)
|
||||
button:SetChecked(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:PositionAndSizeBarPet()
|
||||
local buttonSpacing = E:Scale(self.db.barPet.buttonspacing)
|
||||
local backdropSpacing = E:Scale((self.db.barPet.backdropSpacing or self.db.barPet.buttonspacing))
|
||||
local buttonsPerRow = self.db.barPet.buttonsPerRow
|
||||
local numButtons = self.db.barPet.buttons
|
||||
local size = E:Scale(self.db.barPet.buttonsize)
|
||||
local autoCastSize = (size / 2) - (size / 7.5)
|
||||
local point = self.db.barPet.point
|
||||
local numColumns = ceil(numButtons / buttonsPerRow)
|
||||
local widthMult = self.db.barPet.widthMult
|
||||
local heightMult = self.db.barPet.heightMult
|
||||
local visibility = self.db.barPet.visibility
|
||||
|
||||
bar.db = self.db.barPet
|
||||
|
||||
if visibility and string.match(visibility, "[\n\r]") then
|
||||
visibility = string.gsub(visibility, "[\n\r]","")
|
||||
end
|
||||
|
||||
if numButtons < buttonsPerRow then
|
||||
buttonsPerRow = numButtons
|
||||
end
|
||||
|
||||
if numColumns < 1 then
|
||||
numColumns = 1
|
||||
end
|
||||
|
||||
if self.db.barPet.backdrop == true then
|
||||
bar.backdrop:Show()
|
||||
else
|
||||
bar.backdrop:Hide()
|
||||
--Set size multipliers to 1 when backdrop is disabled
|
||||
widthMult = 1
|
||||
heightMult = 1
|
||||
end
|
||||
|
||||
local barWidth = (size * (buttonsPerRow * widthMult)) + ((buttonSpacing * (buttonsPerRow - 1)) * widthMult) + (buttonSpacing * (widthMult-1)) + ((self.db.barPet.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2)
|
||||
local barHeight = (size * (numColumns * heightMult)) + ((buttonSpacing * (numColumns - 1)) * heightMult) + (buttonSpacing * (heightMult-1)) + ((self.db.barPet.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2)
|
||||
bar:Width(barWidth)
|
||||
bar:Height(barHeight)
|
||||
|
||||
if self.db.barPet.enabled then
|
||||
bar:SetScale(1)
|
||||
bar:SetAlpha(bar.db.alpha)
|
||||
E:EnableMover(bar.mover:GetName())
|
||||
else
|
||||
bar:SetScale(0.0001)
|
||||
bar:SetAlpha(0)
|
||||
E:DisableMover(bar.mover:GetName())
|
||||
end
|
||||
|
||||
local horizontalGrowth, verticalGrowth
|
||||
if point == "TOPLEFT" or point == "TOPRIGHT" then
|
||||
verticalGrowth = "DOWN"
|
||||
else
|
||||
verticalGrowth = "UP"
|
||||
end
|
||||
|
||||
if point == "BOTTOMLEFT" or point == "TOPLEFT" then
|
||||
horizontalGrowth = "RIGHT"
|
||||
else
|
||||
horizontalGrowth = "LEFT"
|
||||
end
|
||||
|
||||
bar.mouseover = self.db.barPet.mouseover
|
||||
if bar.mouseover then
|
||||
bar:SetAlpha(0)
|
||||
else
|
||||
bar:SetAlpha(bar.db.alpha)
|
||||
end
|
||||
|
||||
if self.db.barPet.inheritGlobalFade then
|
||||
bar:SetParent(self.fadeParent)
|
||||
else
|
||||
bar:SetParent(E.UIParent)
|
||||
end
|
||||
|
||||
local button, lastButton, lastColumnButton, autoCast, shine
|
||||
local firstButtonSpacing = (self.db.barPet.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)
|
||||
for i = 1, NUM_PET_ACTION_SLOTS do
|
||||
button = _G["PetActionButton"..i]
|
||||
lastButton = _G["PetActionButton"..i - 1]
|
||||
autoCast = _G["PetActionButton"..i.."AutoCastable"]
|
||||
shine = _G["PetActionButton"..i.."Shine"]
|
||||
lastColumnButton = _G["PetActionButton"..i - buttonsPerRow]
|
||||
|
||||
button:SetParent(bar)
|
||||
button:ClearAllPoints()
|
||||
button:Size(size)
|
||||
autoCast:SetOutside(button, autoCastSize, autoCastSize)
|
||||
shine:Size(size - E.Border*2)
|
||||
button:SetAttribute("showgrid", 1)
|
||||
|
||||
if i == 1 then
|
||||
local x, y
|
||||
if point == "BOTTOMLEFT" then
|
||||
x, y = firstButtonSpacing, firstButtonSpacing
|
||||
elseif point == "TOPRIGHT" then
|
||||
x, y = -firstButtonSpacing, -firstButtonSpacing
|
||||
elseif point == "TOPLEFT" then
|
||||
x, y = firstButtonSpacing, -firstButtonSpacing
|
||||
else
|
||||
x, y = -firstButtonSpacing, firstButtonSpacing
|
||||
end
|
||||
|
||||
button:Point(point, bar, point, x, y)
|
||||
elseif (i - 1) % buttonsPerRow == 0 then
|
||||
local x = 0
|
||||
local y = -buttonSpacing
|
||||
local buttonPoint, anchorPoint = "TOP", "BOTTOM"
|
||||
if verticalGrowth == "UP" then
|
||||
y = buttonSpacing
|
||||
buttonPoint = "BOTTOM"
|
||||
anchorPoint = "TOP"
|
||||
end
|
||||
button:Point(buttonPoint, lastColumnButton, anchorPoint, x, y)
|
||||
else
|
||||
local x = buttonSpacing
|
||||
local y = 0
|
||||
local buttonPoint, anchorPoint = "LEFT", "RIGHT"
|
||||
if horizontalGrowth == "LEFT" then
|
||||
x = -buttonSpacing
|
||||
buttonPoint = "RIGHT"
|
||||
anchorPoint = "LEFT"
|
||||
end
|
||||
|
||||
button:Point(buttonPoint, lastButton, anchorPoint, x, y)
|
||||
end
|
||||
|
||||
if i > numButtons then
|
||||
button:SetScale(0.0001)
|
||||
button:SetAlpha(0)
|
||||
else
|
||||
button:SetScale(1)
|
||||
button:SetAlpha(bar.db.alpha)
|
||||
end
|
||||
|
||||
self:StyleButton(button, nil, self.LBFGroup and E.private.actionbar.lbf.enable and true or nil)
|
||||
end
|
||||
|
||||
RegisterStateDriver(bar, "show", visibility)
|
||||
|
||||
--Fix issue with mover not updating size when bar is hidden
|
||||
bar:GetScript("OnSizeChanged")(bar)
|
||||
|
||||
if self.LBFGroup and E.private.actionbar.lbf.enable then self.LBFGroup:Skin(E.private.actionbar.lbf.skin) end
|
||||
end
|
||||
|
||||
function AB:UpdatePetBindings()
|
||||
local color = self.db.fontColor
|
||||
|
||||
for i = 1, NUM_PET_ACTION_SLOTS do
|
||||
if self.db.hotkeytext then
|
||||
local key = GetBindingKey("BONUSACTIONBUTTON"..i)
|
||||
_G["PetActionButton"..i.."HotKey"]:Show()
|
||||
_G["PetActionButton"..i.."HotKey"]:SetText(key)
|
||||
_G["PetActionButton"..i.."HotKey"]:SetTextColor(color.r, color.g, color.b)
|
||||
self:FixKeybindText(_G["PetActionButton"..i])
|
||||
else
|
||||
_G["PetActionButton"..i.."HotKey"]:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:CreateBarPet()
|
||||
bar:CreateBackdrop(self.db.transparentBackdrops and "Transparent")
|
||||
bar.backdrop:SetAllPoints()
|
||||
if self.db.bar4.enabled then
|
||||
bar:Point("RIGHT", ElvUI_Bar4, "LEFT", -4, 0)
|
||||
else
|
||||
bar:Point("RIGHT", E.UIParent, "RIGHT", -4, 0)
|
||||
end
|
||||
|
||||
bar:SetAttribute("_onstate-show", [[
|
||||
if newstate == "hide" then
|
||||
self:Hide()
|
||||
else
|
||||
self:Show()
|
||||
end
|
||||
]])
|
||||
|
||||
PetActionBarFrame.showgrid = 1
|
||||
PetActionBar_ShowGrid()
|
||||
|
||||
self:HookScript(bar, "OnEnter", "Bar_OnEnter")
|
||||
self:HookScript(bar, "OnLeave", "Bar_OnLeave")
|
||||
|
||||
self:RegisterEvent("SPELLS_CHANGED", "UpdatePet")
|
||||
self:RegisterEvent("PLAYER_CONTROL_GAINED", "UpdatePet")
|
||||
self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdatePet")
|
||||
self:RegisterEvent("PLAYER_CONTROL_LOST", "UpdatePet")
|
||||
self:RegisterEvent("PET_BAR_UPDATE", "UpdatePet")
|
||||
self:RegisterEvent("UNIT_PET", "UpdatePet")
|
||||
self:RegisterEvent("UNIT_FLAGS", "UpdatePet")
|
||||
self:RegisterEvent("UNIT_AURA", "UpdatePet")
|
||||
self:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED", "UpdatePet")
|
||||
self:RegisterEvent("PET_BAR_UPDATE_COOLDOWN", PetActionBar_UpdateCooldowns)
|
||||
|
||||
E:CreateMover(bar, "ElvBar_Pet", L["Pet Bar"], nil, nil, nil,"ALL,ACTIONBARS", nil, "actionbar,barPet")
|
||||
|
||||
self:PositionAndSizeBarPet()
|
||||
self:UpdatePetBindings()
|
||||
|
||||
for i = 1, NUM_PET_ACTION_SLOTS do
|
||||
local button = _G["PetActionButton"..i]
|
||||
|
||||
self:HookScript(button, "OnEnter", "Button_OnEnter")
|
||||
self:HookScript(button, "OnLeave", "Button_OnLeave")
|
||||
|
||||
if self.LBFGroup and E.private.actionbar.lbf.enable then
|
||||
self.LBFGroup:AddButton(button)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,330 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local AB = E:GetModule("ActionBars")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local ceil = math.ceil
|
||||
local format, gsub, match = string.format, string.gsub, string.match
|
||||
--WoW API / Variables
|
||||
local CooldownFrame_SetTimer = CooldownFrame_SetTimer
|
||||
local CreateFrame = CreateFrame
|
||||
local GetBindingKey = GetBindingKey
|
||||
local GetNumShapeshiftForms = GetNumShapeshiftForms
|
||||
local GetShapeshiftForm = GetShapeshiftForm
|
||||
local GetShapeshiftFormCooldown = GetShapeshiftFormCooldown
|
||||
local GetShapeshiftFormInfo = GetShapeshiftFormInfo
|
||||
local GetSpellInfo = GetSpellInfo
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
|
||||
local NUM_SHAPESHIFT_SLOTS = NUM_SHAPESHIFT_SLOTS
|
||||
|
||||
local bar = CreateFrame("Frame", "ElvUI_StanceBar", E.UIParent, "SecureHandlerStateTemplate")
|
||||
bar:SetFrameStrata("LOW")
|
||||
|
||||
function AB:UPDATE_SHAPESHIFT_COOLDOWN()
|
||||
local numForms = GetNumShapeshiftForms()
|
||||
local start, duration, enable, cooldown
|
||||
for i = 1, NUM_SHAPESHIFT_SLOTS do
|
||||
if i <= numForms then
|
||||
cooldown = _G["ElvUI_StanceBarButton"..i.."Cooldown"]
|
||||
start, duration, enable = GetShapeshiftFormCooldown(i)
|
||||
CooldownFrame_SetTimer(cooldown, start, duration, enable)
|
||||
end
|
||||
end
|
||||
|
||||
self:StyleShapeShift("UPDATE_SHAPESHIFT_COOLDOWN")
|
||||
end
|
||||
|
||||
function AB:StyleShapeShift()
|
||||
local numForms = GetNumShapeshiftForms()
|
||||
local texture, name, isActive, isCastable, _
|
||||
local buttonName, button, icon, cooldown
|
||||
local stance = GetShapeshiftForm()
|
||||
|
||||
for i = 1, NUM_SHAPESHIFT_SLOTS do
|
||||
buttonName = "ElvUI_StanceBarButton"..i
|
||||
button = _G[buttonName]
|
||||
icon = _G[buttonName.."Icon"]
|
||||
cooldown = _G[buttonName.."Cooldown"]
|
||||
|
||||
if i <= numForms then
|
||||
texture, name, isActive, isCastable = GetShapeshiftFormInfo(i)
|
||||
|
||||
if self.db.stanceBar.style == "darkenInactive" then
|
||||
if name then
|
||||
_, _, texture = GetSpellInfo(name)
|
||||
end
|
||||
end
|
||||
|
||||
if not texture then
|
||||
texture = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
|
||||
if texture then
|
||||
cooldown:SetAlpha(1)
|
||||
else
|
||||
cooldown:SetAlpha(0)
|
||||
end
|
||||
|
||||
if isActive then
|
||||
button:GetCheckedTexture():SetTexture(1, 1, 1, 0.5)
|
||||
|
||||
if numForms == 1 then
|
||||
button:SetChecked(true)
|
||||
else
|
||||
button:SetChecked(self.db.stanceBar.style ~= "darkenInactive")
|
||||
end
|
||||
else
|
||||
if numForms == 1 or stance == 0 then
|
||||
button:SetChecked(false)
|
||||
else
|
||||
button:SetChecked(self.db.stanceBar.style == "darkenInactive")
|
||||
button:GetCheckedTexture():SetAlpha(1)
|
||||
if self.db.stanceBar.style == "darkenInactive" then
|
||||
button:GetCheckedTexture():SetTexture(0, 0, 0, 0.5)
|
||||
else
|
||||
button:GetCheckedTexture():SetTexture(1, 1, 1, 0.5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
icon:SetTexture(texture)
|
||||
|
||||
if isCastable then
|
||||
icon:SetVertexColor(1.0, 1.0, 1.0)
|
||||
else
|
||||
icon:SetVertexColor(0.4, 0.4, 0.4)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:PositionAndSizeBarShapeShift()
|
||||
local buttonSpacing = E:Scale(self.db.stanceBar.buttonspacing)
|
||||
local backdropSpacing = E:Scale((self.db.stanceBar.backdropSpacing or self.db.stanceBar.buttonspacing))
|
||||
local buttonsPerRow = self.db.stanceBar.buttonsPerRow
|
||||
local numButtons = self.db.stanceBar.buttons
|
||||
local size = E:Scale(self.db.stanceBar.buttonsize)
|
||||
local point = self.db.stanceBar.point
|
||||
local widthMult = self.db.stanceBar.widthMult
|
||||
local heightMult = self.db.stanceBar.heightMult
|
||||
if bar.mover then
|
||||
bar.mover.positionOverride = point
|
||||
E:UpdatePositionOverride(bar.mover:GetName())
|
||||
end
|
||||
bar.db = self.db.stanceBar
|
||||
bar.mouseover = self.db.stanceBar.mouseover
|
||||
|
||||
if bar.LastButton and numButtons > bar.LastButton then
|
||||
numButtons = bar.LastButton
|
||||
end
|
||||
|
||||
if bar.LastButton and buttonsPerRow > bar.LastButton then
|
||||
buttonsPerRow = bar.LastButton
|
||||
end
|
||||
|
||||
if numButtons < buttonsPerRow then
|
||||
buttonsPerRow = numButtons
|
||||
end
|
||||
|
||||
local numColumns = ceil(numButtons / buttonsPerRow)
|
||||
if numColumns < 1 then
|
||||
numColumns = 1
|
||||
end
|
||||
|
||||
if self.db.stanceBar.backdrop then
|
||||
bar.backdrop:Show()
|
||||
else
|
||||
bar.backdrop:Hide()
|
||||
--Set size multipliers to 1 when backdrop is disabled
|
||||
widthMult = 1
|
||||
heightMult = 1
|
||||
end
|
||||
|
||||
local barWidth = (size * (buttonsPerRow * widthMult)) + ((buttonSpacing * (buttonsPerRow - 1)) * widthMult) + (buttonSpacing * (widthMult-1)) + ((self.db.stanceBar.backdrop and (E.Border + backdropSpacing) or E.Spacing)*2)
|
||||
local barHeight = (size * (numColumns * heightMult)) + ((buttonSpacing * (numColumns - 1)) * heightMult) + (buttonSpacing * (heightMult-1)) + ((self.db.stanceBar.backdrop and (E.Border + backdropSpacing) or E.Spacing)*2)
|
||||
bar:Width(barWidth)
|
||||
bar:Height(barHeight)
|
||||
|
||||
if self.db.stanceBar.enabled then
|
||||
bar:SetScale(1)
|
||||
bar:SetAlpha(bar.db.alpha)
|
||||
E:EnableMover(bar.mover:GetName())
|
||||
else
|
||||
bar:SetScale(0.0001)
|
||||
bar:SetAlpha(0)
|
||||
E:DisableMover(bar.mover:GetName())
|
||||
end
|
||||
|
||||
local horizontalGrowth, verticalGrowth
|
||||
if point == "TOPLEFT" or point == "TOPRIGHT" then
|
||||
verticalGrowth = "DOWN"
|
||||
else
|
||||
verticalGrowth = "UP"
|
||||
end
|
||||
|
||||
if point == "BOTTOMLEFT" or point == "TOPLEFT" then
|
||||
horizontalGrowth = "RIGHT"
|
||||
else
|
||||
horizontalGrowth = "LEFT"
|
||||
end
|
||||
|
||||
if self.db.stanceBar.inheritGlobalFade then
|
||||
bar:SetParent(self.fadeParent)
|
||||
else
|
||||
bar:SetParent(E.UIParent)
|
||||
end
|
||||
|
||||
local button, lastButton, lastColumnButton
|
||||
local firstButtonSpacing = (self.db.stanceBar.backdrop and (E.Border + backdropSpacing) or E.Spacing)
|
||||
for i = 1, NUM_SHAPESHIFT_SLOTS do
|
||||
button = _G["ElvUI_StanceBarButton"..i]
|
||||
lastButton = _G["ElvUI_StanceBarButton"..i - 1]
|
||||
lastColumnButton = _G["ElvUI_StanceBarButton"..i - buttonsPerRow]
|
||||
|
||||
button:SetParent(bar)
|
||||
button:ClearAllPoints()
|
||||
button:Size(size)
|
||||
|
||||
if self.db.stanceBar.mouseover then
|
||||
bar:SetAlpha(0)
|
||||
else
|
||||
bar:SetAlpha(bar.db.alpha)
|
||||
end
|
||||
|
||||
if i == 1 then
|
||||
local x, y
|
||||
if point == "BOTTOMLEFT" then
|
||||
x, y = firstButtonSpacing, firstButtonSpacing
|
||||
elseif point == "TOPRIGHT" then
|
||||
x, y = -firstButtonSpacing, -firstButtonSpacing
|
||||
elseif point == "TOPLEFT" then
|
||||
x, y = firstButtonSpacing, -firstButtonSpacing
|
||||
else
|
||||
x, y = -firstButtonSpacing, firstButtonSpacing
|
||||
end
|
||||
|
||||
button:Point(point, bar, point, x, y)
|
||||
elseif (i - 1) % buttonsPerRow == 0 then
|
||||
local x = 0
|
||||
local y = -buttonSpacing
|
||||
local buttonPoint, anchorPoint = "TOP", "BOTTOM"
|
||||
if verticalGrowth == "UP" then
|
||||
y = buttonSpacing
|
||||
buttonPoint = "BOTTOM"
|
||||
anchorPoint = "TOP"
|
||||
end
|
||||
button:Point(buttonPoint, lastColumnButton, anchorPoint, x, y)
|
||||
else
|
||||
local x = buttonSpacing
|
||||
local y = 0
|
||||
local buttonPoint, anchorPoint = "LEFT", "RIGHT"
|
||||
if horizontalGrowth == "LEFT" then
|
||||
x = -buttonSpacing
|
||||
buttonPoint = "RIGHT"
|
||||
anchorPoint = "LEFT"
|
||||
end
|
||||
|
||||
button:Point(buttonPoint, lastButton, anchorPoint, x, y)
|
||||
end
|
||||
|
||||
if i > numButtons then
|
||||
button:SetScale(0.0001)
|
||||
button:SetAlpha(0)
|
||||
else
|
||||
button:SetScale(1)
|
||||
button:SetAlpha(bar.db.alpha)
|
||||
end
|
||||
|
||||
self:StyleButton(button, nil, self.LBFGroup and E.private.actionbar.lbf.enable or nil)
|
||||
end
|
||||
|
||||
if self.LBFGroup and E.private.actionbar.lbf.enable then self.LBFGroup:Skin(E.private.actionbar.lbf.skin) end
|
||||
end
|
||||
|
||||
function AB:AdjustMaxStanceButtons(event)
|
||||
if InCombatLockdown() then
|
||||
AB.NeedsAdjustMaxStanceButtons = event or true
|
||||
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
return
|
||||
end
|
||||
|
||||
local visibility = self.db.stanceBar.visibility
|
||||
if visibility and match(visibility, "[\n\r]") then
|
||||
visibility = gsub(visibility, "[\n\r]", "")
|
||||
end
|
||||
|
||||
for i = 1, #bar.buttons do
|
||||
bar.buttons[i]:Hide()
|
||||
end
|
||||
|
||||
local numButtons = GetNumShapeshiftForms()
|
||||
for i = 1, NUM_SHAPESHIFT_SLOTS do
|
||||
if not bar.buttons[i] then
|
||||
bar.buttons[i] = CreateFrame("CheckButton", format(bar:GetName().."Button%d", i), bar, "ShapeshiftButtonTemplate")
|
||||
bar.buttons[i]:SetID(i)
|
||||
if self.LBFGroup and E.private.actionbar.lbf.enable then
|
||||
self.LBFGroup:AddButton(bar.buttons[i])
|
||||
end
|
||||
self:HookScript(bar.buttons[i], "OnEnter", "Button_OnEnter")
|
||||
self:HookScript(bar.buttons[i], "OnLeave", "Button_OnLeave")
|
||||
end
|
||||
|
||||
if i <= numButtons then
|
||||
bar.buttons[i]:Show()
|
||||
bar.LastButton = i
|
||||
else
|
||||
bar.buttons[i]:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
self:PositionAndSizeBarShapeShift()
|
||||
|
||||
-- sometimes after combat lock down `event` may be true because of passing it back with `AB.NeedsAdjustMaxStanceButtons`
|
||||
if event == "UPDATE_SHAPESHIFT_FORMS" then
|
||||
self:StyleShapeShift()
|
||||
end
|
||||
|
||||
RegisterStateDriver(bar, "visibility", (numButtons == 0 and "hide") or visibility)
|
||||
end
|
||||
|
||||
function AB:UpdateStanceBindings()
|
||||
local color = self.db.fontColor
|
||||
|
||||
for i = 1, NUM_SHAPESHIFT_SLOTS do
|
||||
if self.db.hotkeytext then
|
||||
local key = GetBindingKey("SHAPESHIFTBUTTON"..i)
|
||||
local hotkey = _G["ElvUI_StanceBarButton"..i.."HotKey"]
|
||||
hotkey:Show()
|
||||
hotkey:SetText(key)
|
||||
hotkey:SetTextColor(color.r, color.g, color.b)
|
||||
self:FixKeybindText(_G["ElvUI_StanceBarButton"..i])
|
||||
else
|
||||
_G["ElvUI_StanceBarButton"..i.."HotKey"]:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:CreateBarShapeShift()
|
||||
bar:CreateBackdrop(self.db.transparentBackdrops and "Transparent")
|
||||
bar.backdrop:SetAllPoints()
|
||||
bar:Point("TOPLEFT", E.UIParent, "TOPLEFT", 4, -4)
|
||||
bar.buttons = {}
|
||||
|
||||
self:HookScript(bar, "OnEnter", "Bar_OnEnter")
|
||||
self:HookScript(bar, "OnLeave", "Bar_OnLeave")
|
||||
|
||||
self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS", "AdjustMaxStanceButtons")
|
||||
self:RegisterEvent("UPDATE_SHAPESHIFT_COOLDOWN")
|
||||
self:RegisterEvent("UPDATE_SHAPESHIFT_USABLE", "StyleShapeShift")
|
||||
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "StyleShapeShift")
|
||||
self:RegisterEvent("ACTIONBAR_PAGE_CHANGED", "StyleShapeShift")
|
||||
E:ShapeshiftDelayedUpdate(AB.StyleShapeShift, self)
|
||||
|
||||
E:CreateMover(bar, "ShiftAB", L["Stance Bar"], nil, -3, nil, "ALL,ACTIONBARS", nil, "actionbar,stanceBar")
|
||||
self:AdjustMaxStanceButtons()
|
||||
self:PositionAndSizeBarShapeShift()
|
||||
self:StyleShapeShift()
|
||||
self:UpdateStanceBindings()
|
||||
end
|
||||
@@ -0,0 +1,347 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local AB = E:GetModule("ActionBars")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local unpack, ipairs, pairs = unpack, ipairs, pairs
|
||||
local gsub, match = string.gsub, string.match
|
||||
--WoW API / Variables
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
|
||||
local bar = CreateFrame("Frame", "ElvUI_BarTotem", E.UIParent, "SecureHandlerStateTemplate")
|
||||
bar:SetFrameStrata("LOW")
|
||||
|
||||
local SLOT_BORDER_COLORS = {
|
||||
["summon"] = {r = 0, g = 0, b = 0},
|
||||
[EARTH_TOTEM_SLOT] = {r = 0.23, g = 0.45, b = 0.13},
|
||||
[FIRE_TOTEM_SLOT] = {r = 0.58, g = 0.23, b = 0.10},
|
||||
[WATER_TOTEM_SLOT] = {r = 0.19, g = 0.48, b = 0.60},
|
||||
[AIR_TOTEM_SLOT] = {r = 0.42, g = 0.18, b = 0.74}
|
||||
}
|
||||
|
||||
local SLOT_EMPTY_TCOORDS = {
|
||||
[EARTH_TOTEM_SLOT] = {left = 66/128, right = 96/128, top = 3/256, bottom = 33/256},
|
||||
[FIRE_TOTEM_SLOT] = {left = 67/128, right = 97/128, top = 100/256, bottom = 130/256},
|
||||
[WATER_TOTEM_SLOT] = {left = 39/128, right = 69/128, top = 209/256, bottom = 239/256},
|
||||
[AIR_TOTEM_SLOT] = {left = 66/128, right = 96/128, top = 36/256, bottom = 66/256}
|
||||
}
|
||||
|
||||
local oldMultiCastRecallSpellButton_Update = MultiCastRecallSpellButton_Update
|
||||
function MultiCastRecallSpellButton_Update(self)
|
||||
if InCombatLockdown() then AB.NeedRecallButtonUpdate = true; AB:RegisterEvent("PLAYER_REGEN_ENABLED") return end
|
||||
|
||||
oldMultiCastRecallSpellButton_Update(self)
|
||||
end
|
||||
|
||||
function AB:MultiCastFlyoutFrameOpenButton_Show(button, type, parent)
|
||||
local color = type == "page" and SLOT_BORDER_COLORS.summon or SLOT_BORDER_COLORS[parent:GetID()]
|
||||
button.backdrop:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
|
||||
button:ClearAllPoints()
|
||||
if AB.db.barTotem.flyoutDirection == "UP" then
|
||||
button:Point("BOTTOM", parent, "TOP")
|
||||
button.icon:SetRotation(0)
|
||||
elseif AB.db.barTotem.flyoutDirection == "DOWN" then
|
||||
button:Point("TOP", parent, "BOTTOM")
|
||||
button.icon:SetRotation(3.14)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:MultiCastActionButton_Update(button, _, _, slot)
|
||||
local color = SLOT_BORDER_COLORS[slot]
|
||||
if color then
|
||||
button:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
if InCombatLockdown() then bar.eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED") return end
|
||||
button:ClearAllPoints()
|
||||
button:SetAllPoints(button.slotButton)
|
||||
end
|
||||
|
||||
function AB:StyleTotemSlotButton(button, slot)
|
||||
local color = SLOT_BORDER_COLORS[slot]
|
||||
if color then
|
||||
button:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
button.ignoreBorderColors = true
|
||||
end
|
||||
end
|
||||
|
||||
function AB:SkinSummonButton(button)
|
||||
local name = button:GetName()
|
||||
local icon = _G[name.."Icon"]
|
||||
local highlight = _G[name.."Highlight"]
|
||||
local normal = _G[name.."NormalTexture"]
|
||||
|
||||
button:SetTemplate("Default")
|
||||
button:StyleButton()
|
||||
|
||||
icon:SetTexCoord(unpack(E.TexCoords))
|
||||
icon:SetDrawLayer("ARTWORK")
|
||||
icon:SetInside(button)
|
||||
|
||||
highlight:SetTexture(nil)
|
||||
normal:SetTexture(nil)
|
||||
end
|
||||
|
||||
function AB:MultiCastFlyoutFrame_ToggleFlyout(frame, type, parent)
|
||||
frame.top:SetTexture(nil)
|
||||
frame.middle:SetTexture(nil)
|
||||
|
||||
local color = type == "page" and SLOT_BORDER_COLORS.summon or SLOT_BORDER_COLORS[parent:GetID()]
|
||||
local numButtons = 0
|
||||
for i, button in ipairs(frame.buttons) do
|
||||
if not button.isSkinned then
|
||||
button:SetTemplate("Default")
|
||||
button:StyleButton()
|
||||
|
||||
AB:HookScript(button, "OnEnter", "TotemOnEnter")
|
||||
AB:HookScript(button, "OnLeave", "TotemOnLeave")
|
||||
|
||||
button.icon:SetDrawLayer("ARTWORK")
|
||||
button.icon:SetInside(button)
|
||||
|
||||
bar.buttons[button] = true
|
||||
|
||||
button.isSkinned = true
|
||||
end
|
||||
|
||||
if button:IsShown() then
|
||||
numButtons = numButtons + 1
|
||||
button:Size(AB.db.barTotem.buttonsize)
|
||||
button:ClearAllPoints()
|
||||
|
||||
if AB.db.barTotem.flyoutDirection == "UP" then
|
||||
if i == 1 then
|
||||
button:Point("BOTTOM", parent, "TOP", 0, AB.db.barTotem.flyoutSpacing)
|
||||
else
|
||||
button:Point("BOTTOM", frame.buttons[i - 1], "TOP", 0, AB.db.barTotem.flyoutSpacing)
|
||||
end
|
||||
elseif AB.db.barTotem.flyoutDirection == "DOWN" then
|
||||
if i == 1 then
|
||||
button:Point("TOP", parent, "BOTTOM", 0, -AB.db.barTotem.flyoutSpacing)
|
||||
else
|
||||
button:Point("TOP", frame.buttons[i - 1], "BOTTOM", 0, -AB.db.barTotem.flyoutSpacing)
|
||||
end
|
||||
end
|
||||
|
||||
button:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
|
||||
button.icon:SetTexCoord(unpack(E.TexCoords))
|
||||
end
|
||||
end
|
||||
|
||||
if type == "slot" then
|
||||
local tCoords = SLOT_EMPTY_TCOORDS[parent:GetID()]
|
||||
frame.buttons[1].icon:SetTexCoord(tCoords.left, tCoords.right, tCoords.top, tCoords.bottom)
|
||||
end
|
||||
|
||||
frame.buttons[1]:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
MultiCastFlyoutFrameCloseButton.backdrop:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
|
||||
frame:ClearAllPoints()
|
||||
MultiCastFlyoutFrameCloseButton:ClearAllPoints()
|
||||
if AB.db.barTotem.flyoutDirection == "UP" then
|
||||
frame:Point("BOTTOM", parent, "TOP")
|
||||
|
||||
MultiCastFlyoutFrameCloseButton:Point("TOP", frame, "TOP")
|
||||
MultiCastFlyoutFrameCloseButton.icon:SetRotation(3.14)
|
||||
elseif AB.db.barTotem.flyoutDirection == "DOWN" then
|
||||
frame:Point("TOP", parent, "BOTTOM")
|
||||
|
||||
MultiCastFlyoutFrameCloseButton:Point("BOTTOM", frame, "BOTTOM")
|
||||
MultiCastFlyoutFrameCloseButton.icon:SetRotation(0)
|
||||
end
|
||||
|
||||
frame:Height(((AB.db.barTotem.buttonsize + AB.db.barTotem.flyoutSpacing) * numButtons) + MultiCastFlyoutFrameCloseButton:GetHeight())
|
||||
end
|
||||
|
||||
function AB:TotemOnEnter()
|
||||
if bar.mouseover then
|
||||
E:UIFrameFadeIn(bar, 0.2, bar:GetAlpha(), AB.db.barTotem.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:TotemOnLeave()
|
||||
if bar.mouseover then
|
||||
E:UIFrameFadeOut(bar, 0.2, bar:GetAlpha(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:ShowMultiCastActionBar()
|
||||
self:PositionAndSizeBarTotem()
|
||||
end
|
||||
|
||||
function AB:PositionAndSizeBarTotem()
|
||||
if InCombatLockdown() then
|
||||
AB.NeedsPositionAndSizeBarTotem = true
|
||||
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
return
|
||||
end
|
||||
|
||||
local buttonSpacing = E:Scale(self.db.barTotem.buttonspacing)
|
||||
local size = E:Scale(self.db.barTotem.buttonsize)
|
||||
local numActiveSlots = MultiCastActionBarFrame.numActiveSlots
|
||||
|
||||
bar:Width((size * (2 + numActiveSlots)) + (buttonSpacing * (2 + numActiveSlots - 1)))
|
||||
MultiCastActionBarFrame:Width((size * (2 + numActiveSlots)) + (buttonSpacing * (2 + numActiveSlots - 1)))
|
||||
bar:Height(size + 2)
|
||||
MultiCastActionBarFrame:Height(size + 2)
|
||||
bar.db = self.db.barTotem
|
||||
|
||||
bar.mouseover = self.db.barTotem.mouseover
|
||||
if bar.mouseover then
|
||||
bar:SetAlpha(0)
|
||||
else
|
||||
bar:SetAlpha(self.db.barTotem.alpha)
|
||||
end
|
||||
|
||||
local visibility = bar.db.visibility
|
||||
if visibility and match(visibility, "[\n\r]") then
|
||||
visibility = gsub(visibility, "[\n\r]","")
|
||||
end
|
||||
|
||||
RegisterStateDriver(bar, "visibility", visibility)
|
||||
|
||||
MultiCastSummonSpellButton:ClearAllPoints()
|
||||
MultiCastSummonSpellButton:Size(size)
|
||||
MultiCastSummonSpellButton:Point("BOTTOMLEFT", E.Border*2, E.Border*2)
|
||||
|
||||
for i = 1, numActiveSlots do
|
||||
local button = _G["MultiCastSlotButton"..i]
|
||||
local lastButton = _G["MultiCastSlotButton"..i - 1]
|
||||
|
||||
button:ClearAllPoints()
|
||||
button:Size(size)
|
||||
|
||||
if i == 1 then
|
||||
button:Point("LEFT", MultiCastSummonSpellButton, "RIGHT", buttonSpacing, 0)
|
||||
else
|
||||
button:Point("LEFT", lastButton, "RIGHT", buttonSpacing, 0)
|
||||
end
|
||||
end
|
||||
|
||||
MultiCastRecallSpellButton:Size(size)
|
||||
MultiCastRecallSpellButton_Update(MultiCastRecallSpellButton)
|
||||
|
||||
MultiCastFlyoutFrameCloseButton:Width(size)
|
||||
MultiCastFlyoutFrameOpenButton:Width(size)
|
||||
end
|
||||
|
||||
function AB:CreateTotemBar()
|
||||
bar:Point("BOTTOM", E.UIParent, "BOTTOM", 0, 250)
|
||||
bar.buttons = {}
|
||||
|
||||
bar.eventFrame = CreateFrame("Frame")
|
||||
bar.eventFrame:Hide()
|
||||
bar.eventFrame:SetScript("OnEvent", function(self)
|
||||
AB:PositionAndSizeBarTotem()
|
||||
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
|
||||
end)
|
||||
|
||||
MultiCastActionBarFrame:SetParent(bar)
|
||||
MultiCastActionBarFrame:ClearAllPoints()
|
||||
MultiCastActionBarFrame:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT", -E.Border, -E.Border)
|
||||
MultiCastActionBarFrame:SetScript("OnUpdate", nil)
|
||||
MultiCastActionBarFrame:SetScript("OnShow", nil)
|
||||
MultiCastActionBarFrame:SetScript("OnHide", nil)
|
||||
MultiCastActionBarFrame.SetParent = E.noop
|
||||
MultiCastActionBarFrame.SetPoint = E.noop
|
||||
|
||||
self:HookScript(MultiCastActionBarFrame, "OnEnter", "TotemOnEnter")
|
||||
self:HookScript(MultiCastActionBarFrame, "OnLeave", "TotemOnLeave")
|
||||
|
||||
self:HookScript(MultiCastFlyoutFrame, "OnEnter", "TotemOnEnter")
|
||||
self:HookScript(MultiCastFlyoutFrame, "OnLeave", "TotemOnLeave")
|
||||
|
||||
local closeButton = MultiCastFlyoutFrameCloseButton
|
||||
closeButton:CreateBackdrop("Default", true, true)
|
||||
closeButton.backdrop:SetPoint("TOPLEFT", 0, -(E.Border + E.Spacing))
|
||||
closeButton.backdrop:SetPoint("BOTTOMRIGHT", 0, E.Border + E.Spacing)
|
||||
closeButton.icon = closeButton:CreateTexture(nil, "ARTWORK")
|
||||
closeButton.icon:Size(16)
|
||||
closeButton.icon:SetPoint("CENTER")
|
||||
closeButton.icon:SetTexture(E.Media.Textures.ArrowUp)
|
||||
closeButton.normalTexture:SetTexture("")
|
||||
closeButton:StyleButton()
|
||||
closeButton.hover:SetInside(closeButton.backdrop)
|
||||
closeButton.pushed:SetInside(closeButton.backdrop)
|
||||
bar.buttons[closeButton] = true
|
||||
|
||||
local openButton = MultiCastFlyoutFrameOpenButton
|
||||
openButton:CreateBackdrop("Default", true, true)
|
||||
openButton.backdrop:SetPoint("TOPLEFT", 0, -(E.Border + E.Spacing))
|
||||
openButton.backdrop:SetPoint("BOTTOMRIGHT", 0, E.Border + E.Spacing)
|
||||
openButton.icon = openButton:CreateTexture(nil, "ARTWORK")
|
||||
openButton.icon:Size(16)
|
||||
openButton.icon:SetPoint("CENTER")
|
||||
openButton.icon:SetTexture(E.Media.Textures.ArrowUp)
|
||||
openButton.normalTexture:SetTexture("")
|
||||
openButton:StyleButton()
|
||||
openButton.hover:SetInside(openButton.backdrop)
|
||||
openButton.pushed:SetInside(openButton.backdrop)
|
||||
bar.buttons[openButton] = true
|
||||
|
||||
self:SkinSummonButton(MultiCastSummonSpellButton)
|
||||
bar.buttons[MultiCastSummonSpellButton] = true
|
||||
|
||||
hooksecurefunc(MultiCastRecallSpellButton, "SetPoint", function(self, point, attachTo, anchorPoint, xOffset, yOffset)
|
||||
if xOffset ~= AB.db.barTotem.buttonspacing then
|
||||
if InCombatLockdown() then AB.NeedRecallButtonUpdate = true AB:RegisterEvent("PLAYER_REGEN_ENABLED") return end
|
||||
|
||||
self:SetPoint(point, attachTo, anchorPoint, AB.db.barTotem.buttonspacing, yOffset)
|
||||
end
|
||||
end)
|
||||
|
||||
self:SkinSummonButton(MultiCastRecallSpellButton)
|
||||
bar.buttons[MultiCastRecallSpellButton] = true
|
||||
|
||||
for i = 1, 4 do
|
||||
local button = _G["MultiCastSlotButton"..i]
|
||||
|
||||
button:StyleButton()
|
||||
button:SetTemplate("Default")
|
||||
|
||||
button.background:SetTexCoord(unpack(E.TexCoords))
|
||||
button.background:SetDrawLayer("ARTWORK")
|
||||
button.background:SetInside(button)
|
||||
|
||||
button.overlay:SetTexture(nil)
|
||||
bar.buttons[button] = true
|
||||
end
|
||||
|
||||
for i = 1, 12 do
|
||||
local button = _G["MultiCastActionButton"..i]
|
||||
local icon = _G["MultiCastActionButton"..i.."Icon"]
|
||||
local normal = _G["MultiCastActionButton"..i.."NormalTexture"]
|
||||
local cooldown = _G["MultiCastActionButton"..i.."Cooldown"]
|
||||
|
||||
button:StyleButton()
|
||||
|
||||
icon:SetTexCoord(unpack(E.TexCoords))
|
||||
icon:SetDrawLayer("ARTWORK")
|
||||
icon:SetInside()
|
||||
|
||||
button.overlay:SetTexture(nil)
|
||||
normal:SetTexture(nil)
|
||||
normal:Hide()
|
||||
normal:SetAlpha(0)
|
||||
|
||||
E:RegisterCooldown(cooldown)
|
||||
|
||||
bar.buttons[button] = true
|
||||
end
|
||||
|
||||
for button in pairs(bar.buttons) do
|
||||
button:HookScript("OnEnter", AB.TotemOnEnter)
|
||||
button:HookScript("OnLeave", AB.TotemOnLeave)
|
||||
end
|
||||
|
||||
self:SecureHook("MultiCastFlyoutFrameOpenButton_Show")
|
||||
self:SecureHook("MultiCastActionButton_Update")
|
||||
self:SecureHook("MultiCastSlotButton_Update", "StyleTotemSlotButton")
|
||||
self:SecureHook("MultiCastFlyoutFrame_ToggleFlyout")
|
||||
self:SecureHook("ShowMultiCastActionBar")
|
||||
|
||||
E:CreateMover(bar, "ElvBar_Totem", TUTORIAL_TITLE47, nil, nil, nil,"ALL,ACTIONBARS", nil, "actionbar,barTotem")
|
||||
end
|
||||
Reference in New Issue
Block a user