initial commit

This commit is contained in:
Gitea
2020-11-13 14:27:50 -05:00
commit e2015fd9bb
581 changed files with 101308 additions and 0 deletions

File diff suppressed because it is too large Load Diff

397
Modules/ActionBars/Bind.lua Normal file
View File

@@ -0,0 +1,397 @@
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')
local _G = _G
local tonumber, format = tonumber, format
local select, pairs, floor = select, pairs, floor
local CreateFrame = CreateFrame
local HideUIPanel = HideUIPanel
local GameTooltip_Hide = GameTooltip_Hide
local GameTooltip_ShowCompareItem = GameTooltip_ShowCompareItem
local GetBindingKey = GetBindingKey
local GetCurrentBindingSet = GetCurrentBindingSet
local GetMacroInfo = GetMacroInfo
local GetSpellBookItemName = GetSpellBookItemName
local InCombatLockdown = InCombatLockdown
local IsAddOnLoaded = IsAddOnLoaded
local IsAltKeyDown, IsControlKeyDown = IsAltKeyDown, IsControlKeyDown
local IsShiftKeyDown, IsModifiedClick = IsShiftKeyDown, IsModifiedClick
local LoadBindings, SaveBindings = LoadBindings, SaveBindings
local SecureActionButton_OnClick = SecureActionButton_OnClick
local SetBinding = SetBinding
local GameTooltip = GameTooltip
local SpellBook_GetSpellBookSlot = SpellBook_GetSpellBookSlot
local MAX_ACCOUNT_MACROS = MAX_ACCOUNT_MACROS
local CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP = CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP
local CHARACTER_SPECIFIC_KEYBINDINGS = CHARACTER_SPECIFIC_KEYBINDINGS
-- GLOBALS: ElvUIBindPopupWindow, ElvUIBindPopupWindowCheckButton
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()
if not _G.GameTooltip:IsForbidden() then
_G.GameTooltip:Hide()
end
end
function AB:BindListener(key)
AB.bindingsChanged = true
if key == 'ESCAPE' 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.name))
self:BindUpdate(bind.button, bind.spellmacro)
if bind.spellmacro~='MACRO' and not _G.GameTooltip:IsForbidden() then
_G.GameTooltip:Hide()
end
return
end
--Check if this button can open a flyout menu
local isFlyout = (bind.button.FlyoutArrow and bind.button.FlyoutArrow:IsShown())
if key == 'LSHIFT' or key == 'RSHIFT' or key == 'LCTRL' or key == 'RCTRL'
or key == 'LALT' or key == 'RALT' or key == 'UNKNOWN' then return end
--Redirect LeftButton click to open flyout
if key == 'LeftButton' and isFlyout then
SecureActionButton_OnClick(bind.button)
end
if key == 'MiddleButton' then key = 'BUTTON3' end
if key:find('Button%d') then key = key:upper() end
local allowBinding = not isFlyout or (key ~= 'LeftButton') --Don't attempt to bind left mouse button for flyout buttons
if allowBinding and bind.button.bindstring then
local alt = IsAltKeyDown() and 'ALT-' or ''
local ctrl = IsControlKeyDown() and 'CTRL-' or ''
local shift = IsShiftKeyDown() and 'SHIFT-' or ''
SetBinding(alt..ctrl..shift..key, bind.button.bindstring)
E:Print(alt..ctrl..shift..key..L[" |cff00ff00bound to |r"]..bind.name..'.')
end
self:BindUpdate(bind.button, bind.spellmacro)
if bind.spellmacro~='MACRO' and bind.spellmacro~='FLYOUT' and not _G.GameTooltip:IsForbidden() then
_G.GameTooltip:Hide()
end
end
function AB:DisplayBindsTooltip()
GameTooltip:SetOwner(bind, 'ANCHOR_TOP')
GameTooltip:Point('BOTTOM', bind, 'TOP', 0, 1)
GameTooltip:AddLine(bind.name, 1, 1, 1)
end
function AB:DisplayBindings()
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
end
function AB:BindTooltip(triggerTooltip)
if GameTooltip:IsForbidden() then return end
if triggerTooltip then -- this is needed for some tooltip magic, also it helps show a tooltip when a spell isnt there
AB:DisplayBindsTooltip()
GameTooltip:AddLine(L["Trigger"])
GameTooltip:Show()
GameTooltip:SetScript('OnHide', function(tt)
AB:DisplayBindsTooltip()
AB:DisplayBindings()
tt:Show()
tt:SetScript('OnHide', nil)
end)
else
AB:DisplayBindsTooltip()
AB:DisplayBindings()
GameTooltip:Show()
end
end
function AB:BindUpdate(button, spellmacro)
if not bind.active or InCombatLockdown() then return end
local triggerTooltip = false
bind.button = button
bind.spellmacro = spellmacro
bind.name = nil
bind:ClearAllPoints()
bind:SetAllPoints(button)
bind:Show()
_G.ShoppingTooltip1:Hide()
button.bindstring = nil -- keep this clean
if spellmacro == 'FLYOUT' then
bind.name = button.spellName
button.bindstring = spellmacro..' '..bind.name
elseif spellmacro == 'SPELL' then
button.id = SpellBook_GetSpellBookSlot(button)
bind.name = GetSpellBookItemName(button.id, _G.SpellBookFrame.bookType)
button.bindstring = spellmacro..' '..bind.name
elseif spellmacro == 'MACRO' then
button.id = button:GetID()
-- no clue what this is, leaving it alone tho lol
if floor(.5+select(2,_G.MacroFrameTab1Text:GetTextColor())*10)/10==.8 then
button.id = button.id + MAX_ACCOUNT_MACROS
end
bind.name = GetMacroInfo(button.id)
button.bindstring = spellmacro..' '..bind.name
elseif spellmacro == 'MICRO' then
bind.name = button.tooltipText
button.bindstring = button.commandName
triggerTooltip = true
elseif spellmacro == 'BAG' then
if button.itemID then
bind.name = button.name
button.bindstring = 'ITEM item:'..button.itemID
triggerTooltip = true
end
else
bind.name = button:GetName()
if not bind.name then return end
triggerTooltip = true
if button.keyBoundTarget then
button.bindstring = button.keyBoundTarget
elseif button.commandName then
button.bindstring = button.commandName
elseif button.action then
local action = tonumber(button.action)
local modact = 1+(action-1)%12
if bind.name == 'ExtraActionButton1' then
button.bindstring = 'EXTRAACTIONBUTTON1'
elseif action < 25 or action > 72 then
button.bindstring = 'ACTIONBUTTON'..modact
elseif action < 73 and action > 60 then
button.bindstring = 'MULTIACTIONBAR1BUTTON'..modact
elseif action < 61 and action > 48 then
button.bindstring = 'MULTIACTIONBAR2BUTTON'..modact
elseif action < 49 and action > 36 then
button.bindstring = 'MULTIACTIONBAR4BUTTON'..modact
elseif action < 37 and action > 24 then
button.bindstring = 'MULTIACTIONBAR3BUTTON'..modact
end
end
end
if button.bindstring then
button.bindings = {GetBindingKey(button.bindstring)}
AB:BindTooltip(triggerTooltip)
end
end
local elapsed = 0
function AB:Tooltip_OnUpdate(tooltip, e)
if tooltip:IsForbidden() then return end
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
_G['MacroButton'..i]:HookScript('OnEnter', function(btn) AB:BindUpdate(btn, 'MACRO') end)
end
end
end
function AB:ChangeBindingProfile()
if ElvUIBindPopupWindowCheckButton:GetChecked() then
LoadBindings(2)
SaveBindings(2)
else
LoadBindings(1)
SaveBindings(1)
end
end
local function keybindButtonClick()
if InCombatLockdown() then return end
AB:ActivateBindMode()
HideUIPanel(_G.KeyBindingFrame)
HideUIPanel(_G.GameMenuFrame)
end
function AB:SwapKeybindButton(event, addon)
if event and addon ~= 'Blizzard_BindingUI' then return end
local parent = _G.KeyBindingFrame
parent.quickKeybindButton:Hide()
local frame = CreateFrame('Button', 'ElvUI_KeybindButton', parent, 'OptionsButtonTemplate, BackdropTemplate')
frame:Width(150)
frame:Point('TOPLEFT', parent.quickKeybindButton)
frame:SetScript('OnClick', keybindButtonClick)
frame:SetText('ElvUI Keybind')
Skins:HandleButton(frame)
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:SetColorTexture(0, 0, 0, .25)
bind:Hide()
self:SecureHookScript(_G.GameTooltip, 'OnUpdate', 'Tooltip_OnUpdate')
bind:SetScript('OnEnter', function(b) local db = b.button:GetParent().db if db and db.mouseover then AB:Button_OnEnter(b.button) end end)
bind:SetScript('OnLeave', function(b) AB:BindHide() local db = b.button:GetParent().db if db and db.mouseover then AB:Button_OnLeave(b.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 i = 1, 12 do
local b = _G['SpellButton'..i]
b:HookScript('OnEnter', function(s) AB:BindUpdate(s, 'SPELL') end)
end
local function buttonOnEnter(b) AB:BindUpdate(b) end
for b in pairs(self.handledbuttons) do
if b:IsProtected() and b:IsObjectType('CheckButton') and not b.isFlyout then
b:HookScript('OnEnter', buttonOnEnter)
end
end
if not IsAddOnLoaded('Blizzard_MacroUI') then
self:SecureHook('LoadAddOn', 'RegisterMacro')
else
self:RegisterMacro('Blizzard_MacroUI')
end
--Special Popup
local Popup = CreateFrame('Frame', 'ElvUIBindPopupWindow', _G.UIParent, 'BackdropTemplate')
Popup:SetFrameStrata('DIALOG')
Popup:EnableMouse(true)
Popup:SetMovable(true)
Popup:SetFrameLevel(99)
Popup:SetClampedToScreen(true)
Popup:Size(360, 130)
Popup:SetTemplate('Transparent')
Popup:RegisterForDrag('AnyUp', 'AnyDown')
Popup:SetScript('OnMouseDown', Popup.StartMoving)
Popup:SetScript('OnMouseUp', Popup.StopMovingOrSizing)
Popup:Hide()
Popup.header = CreateFrame('Button', nil, Popup, 'OptionsButtonTemplate, BackdropTemplate')
Popup.header:Size(100, 25)
Popup.header:Point('CENTER', Popup, 'TOP')
Popup.header:RegisterForClicks('AnyUp', 'AnyDown')
Popup.header:SetScript('OnMouseDown', function() Popup:StartMoving() end)
Popup.header:SetScript('OnMouseUp', function() Popup:StopMovingOrSizing() end)
Popup.header:SetText('Key Binds')
Popup.desc = Popup:CreateFontString(nil, 'ARTWORK')
Popup.desc:SetFontObject('GameFontHighlight')
Popup.desc:SetJustifyV('TOP')
Popup.desc:SetJustifyH('LEFT')
Popup.desc:Point('TOPLEFT', 18, -32)
Popup.desc:Point('BOTTOMRIGHT', -18, 48)
Popup.desc:SetText(L["Hover your mouse over any |cFF1784d1action|r, |cFF1784d1micro|r, |cFF1784d1macro|r, or |cFF1784d1spellbook|r button to bind it. This also works for items in your |cFF1784d1bag|r. Press the |cfd9b9b9bESC|r key to |cfd9b9b9bclear|r the current bindings."])
Popup.save = CreateFrame('Button', Popup:GetName()..'SaveButton', Popup, 'OptionsButtonTemplate, BackdropTemplate')
Popup.save:SetText(L["Save"])
Popup.save:Width(150)
Popup.save:SetScript('OnClick', function() AB:DeactivateBindMode(true) end)
Popup.discard = CreateFrame('Button', Popup:GetName()..'DiscardButton', Popup, 'OptionsButtonTemplate, BackdropTemplate')
Popup.discard:Width(150)
Popup.discard:SetText(L["Discard"])
Popup.discard:SetScript('OnClick', function() AB:DeactivateBindMode(false) end)
Popup.perCharCheck = CreateFrame('CheckButton', Popup:GetName()..'CheckButton', Popup, 'OptionsCheckButtonTemplate, BackdropTemplate')
_G[Popup.perCharCheck:GetName()..'Text']:SetText(CHARACTER_SPECIFIC_KEYBINDINGS)
Popup.perCharCheck:SetScript('OnLeave', GameTooltip_Hide)
Popup.perCharCheck:SetScript('OnShow', function(checkBtn) checkBtn:SetChecked(GetCurrentBindingSet() == 2) end)
Popup.perCharCheck:SetScript('OnClick', function()
if AB.bindingsChanged then
E:StaticPopup_Show('CONFIRM_LOSE_BINDING_CHANGES')
else
AB:ChangeBindingProfile()
end
end)
Popup.perCharCheck:SetScript('OnEnter', function(checkBtn)
_G.GameTooltip:SetOwner(checkBtn, 'ANCHOR_RIGHT')
_G.GameTooltip:SetText(CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP, nil, nil, nil, nil, 1)
end)
--position buttons
Popup.perCharCheck:Point('BOTTOMLEFT', Popup.discard, 'TOPLEFT', 0, 2)
Popup.save:Point('BOTTOMRIGHT', -14, 10)
Popup.discard:Point('BOTTOMLEFT', 14, 10)
Skins:HandleCheckBox(Popup.perCharCheck)
Skins:HandleButton(Popup.discard)
Skins:HandleButton(Popup.header)
Skins:HandleButton(Popup.save)
Popup.discard.backdrop:SetFrameLevel(Popup.discard:GetFrameLevel())
Popup.header.backdrop:SetFrameLevel(Popup.header:GetFrameLevel())
Popup.save.backdrop:SetFrameLevel(Popup.save:GetFrameLevel())
end

View File

@@ -0,0 +1,190 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local AB = E:GetModule('ActionBars')
local _G = _G
local pairs = pairs
local unpack = unpack
local tinsert = tinsert
local CreateFrame = CreateFrame
local GetBindingKey = GetBindingKey
local hooksecurefunc = hooksecurefunc
local ExtraActionBarHolder, ZoneAbilityHolder
local ExtraButtons = {}
function AB:ExtraButtons_BossStyle(button)
if not button.style then return end
button.style:SetAlpha(not E.db.actionbar.extraActionButton.clean and E.db.actionbar.extraActionButton.alpha or 0)
end
function AB:ExtraButtons_ZoneStyle()
local zoneAlpha = E.db.actionbar.zoneActionButton.alpha
_G.ZoneAbilityFrame.Style:SetAlpha(not E.db.actionbar.zoneActionButton.clean and zoneAlpha or 0)
for button in _G.ZoneAbilityFrame.SpellButtonContainer:EnumerateActive() do
button:SetAlpha(zoneAlpha)
end
end
function AB:ExtraButtons_OnEnter()
if self.holder and self.holder:GetParent() == AB.fadeParent and not AB.fadeParent.mouseLock then
E:UIFrameFadeIn(AB.fadeParent, 0.2, AB.fadeParent:GetAlpha(), 1)
end
end
function AB:ExtraButtons_OnLeave()
if self.holder and self.holder:GetParent() == AB.fadeParent and not AB.fadeParent.mouseLock then
E:UIFrameFadeOut(AB.fadeParent, 0.2, AB.fadeParent:GetAlpha(), 1 - AB.db.globalFadeAlpha)
end
end
function AB:ExtraButtons_GlobalFade()
ExtraActionBarHolder:SetParent(E.db.actionbar.extraActionButton.inheritGlobalFade and AB.fadeParent or E.UIParent)
ZoneAbilityHolder:SetParent(E.db.actionbar.zoneActionButton.inheritGlobalFade and AB.fadeParent or E.UIParent)
end
function AB:ExtraButtons_UpdateAlpha()
if not E.private.actionbar.enable then return end
local bossAlpha = E.db.actionbar.extraActionButton.alpha
for i = 1, _G.ExtraActionBarFrame:GetNumChildren() do
local button = _G['ExtraActionButton'..i]
if button then
button:SetAlpha(bossAlpha)
AB:ExtraButtons_BossStyle(button)
end
end
AB:ExtraButtons_ZoneStyle()
end
function AB:ExtraButtons_UpdateScale()
if not E.private.actionbar.enable then return end
AB:ExtraButtons_ZoneScale()
local scale = E.db.actionbar.extraActionButton.scale
_G.ExtraActionBarFrame:SetScale(scale)
local width, height = _G.ExtraActionBarFrame.button:GetSize()
ExtraActionBarHolder:SetSize(width * scale, height * scale)
end
function AB:ExtraButtons_ZoneScale()
if not E.private.actionbar.enable then return end
local scale = E.db.actionbar.zoneActionButton.scale
_G.ZoneAbilityFrame.Style:SetScale(scale)
_G.ZoneAbilityFrame.SpellButtonContainer:SetScale(scale)
local width, height = _G.ZoneAbilityFrame.SpellButtonContainer:GetSize()
ZoneAbilityHolder:SetSize(width * scale, height * scale)
end
function AB:SetupExtraButton()
local ExtraActionBarFrame = _G.ExtraActionBarFrame
local ZoneAbilityFrame = _G.ZoneAbilityFrame
ExtraActionBarHolder = CreateFrame('Frame', nil, E.UIParent)
ExtraActionBarHolder:Point('BOTTOM', E.UIParent, 'BOTTOM', -150, 300)
ZoneAbilityHolder = CreateFrame('Frame', nil, E.UIParent)
ZoneAbilityHolder:Point('BOTTOM', E.UIParent, 'BOTTOM', 150, 300)
ZoneAbilityFrame.SpellButtonContainer.holder = ZoneAbilityHolder
ZoneAbilityFrame.SpellButtonContainer:HookScript('OnEnter', AB.ExtraButtons_OnEnter)
ZoneAbilityFrame.SpellButtonContainer:HookScript('OnLeave', AB.ExtraButtons_OnLeave)
-- try to shutdown the container movement and taints
_G.UIPARENT_MANAGED_FRAME_POSITIONS.ExtraAbilityContainer = nil
_G.ExtraAbilityContainer.SetSize = E.noop
ZoneAbilityFrame:SetParent(ZoneAbilityHolder)
ZoneAbilityFrame:ClearAllPoints()
ZoneAbilityFrame:SetAllPoints()
ZoneAbilityFrame.ignoreInLayout = true
ExtraActionBarFrame:SetParent(ExtraActionBarHolder)
ExtraActionBarFrame:ClearAllPoints()
ExtraActionBarFrame:SetAllPoints()
ExtraActionBarFrame.ignoreInLayout = true
hooksecurefunc(ZoneAbilityFrame.SpellButtonContainer, 'SetSize', AB.ExtraButtons_ZoneScale)
hooksecurefunc(ZoneAbilityFrame, 'UpdateDisplayedZoneAbilities', function(frame)
AB:ExtraButtons_ZoneStyle()
for spellButton in frame.SpellButtonContainer:EnumerateActive() do
if spellButton and not spellButton.IsSkinned then
spellButton.NormalTexture:SetAlpha(0)
spellButton:GetHighlightTexture():SetColorTexture(1, 1, 1, .25)
spellButton:StyleButton(nil, true)
spellButton:CreateBackdrop()
spellButton.backdrop:SetAllPoints()
spellButton.Icon:SetDrawLayer('ARTWORK')
spellButton.Icon:SetTexCoord(unpack(E.TexCoords))
spellButton.Icon:SetInside()
--check these
--spellButton.HotKey:SetText(GetBindingKey(spellButton:GetName()))
--tinsert(ExtraButtons, spellButton)
spellButton.holder = ZoneAbilityHolder
spellButton:HookScript('OnEnter', AB.ExtraButtons_OnEnter)
spellButton:HookScript('OnLeave', AB.ExtraButtons_OnLeave)
if spellButton.Cooldown then
spellButton.Cooldown.CooldownOverride = 'actionbar'
E:RegisterCooldown(spellButton.Cooldown)
spellButton.Cooldown:SetInside(spellButton)
end
spellButton.IsSkinned = true
end
end
end)
for i = 1, ExtraActionBarFrame:GetNumChildren() do
local button = _G['ExtraActionButton'..i]
if button then
button.pushed = true
button.checked = true
self:StyleButton(button, true) -- registers cooldown too
button.icon:SetDrawLayer('ARTWORK')
button:CreateBackdrop()
button.backdrop:SetAllPoints()
button.backdrop:SetFrameLevel(button:GetFrameLevel())
AB:ExtraButtons_BossStyle(button)
button.holder = ExtraActionBarHolder
button:HookScript('OnEnter', AB.ExtraButtons_OnEnter)
button:HookScript('OnLeave', AB.ExtraButtons_OnLeave)
local tex = button:CreateTexture(nil, 'OVERLAY')
tex:SetColorTexture(0.9, 0.8, 0.1, 0.3)
tex:SetInside()
button:SetCheckedTexture(tex)
button.HotKey:SetText(GetBindingKey('ExtraActionButton'..i))
tinsert(ExtraButtons, button)
end
end
AB:ExtraButtons_UpdateAlpha()
AB:ExtraButtons_UpdateScale()
AB:ExtraButtons_GlobalFade()
E:CreateMover(ExtraActionBarHolder, 'BossButton', L["Boss Button"], nil, nil, nil, 'ALL,ACTIONBARS', nil, 'actionbar,extraActionButton')
E:CreateMover(ZoneAbilityHolder, 'ZoneAbility', L["Zone Ability"], nil, nil, nil, 'ALL,ACTIONBARS')
-- Spawn the mover before its available.
ZoneAbilityHolder:Size(52 * E.db.actionbar.zoneActionButton.scale)
end
function AB:UpdateExtraBindings()
for _, button in pairs(ExtraButtons) do
button.HotKey:SetText(_G.GetBindingKey(button:GetName()))
AB:FixKeybindText(button)
end
end

View File

@@ -0,0 +1,8 @@
<Ui xmlns='http://www.blizzard.com/wow/ui/'>
<Script file='ActionBars.lua'/>
<Script file='ExtraAB.lua'/>
<Script file='PetBar.lua'/>
<Script file='StanceBar.lua'/>
<Script file='Bind.lua'/>
<Script file='MicroBar.lua'/>
</Ui>

View File

@@ -0,0 +1,219 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local AB = E:GetModule('ActionBars')
local _G = _G
local gsub = gsub
local pairs = pairs
local assert = assert
local unpack = unpack
local CreateFrame = CreateFrame
local C_StorePublic_IsEnabled = C_StorePublic.IsEnabled
local UpdateMicroButtonsParent = UpdateMicroButtonsParent
local GetCurrentRegionName = GetCurrentRegionName
local RegisterStateDriver = RegisterStateDriver
local InCombatLockdown = InCombatLockdown
local microBar = CreateFrame('Frame', 'ElvUI_MicroBar', E.UIParent)
microBar:SetSize(100, 100)
local function onLeaveBar()
if AB.db.microbar.mouseover then
E:UIFrameFadeOut(microBar, 0.2, microBar:GetAlpha(), 0)
end
end
local watcher = 0
local function onUpdate(self, elapsed)
if watcher > 0.1 then
if not self:IsMouseOver() then
self.IsMouseOvered = nil
self:SetScript('OnUpdate', nil)
onLeaveBar()
end
watcher = 0
else
watcher = watcher + elapsed
end
end
local function onEnter(button)
if AB.db.microbar.mouseover and not microBar.IsMouseOvered then
microBar.IsMouseOvered = true
microBar:SetScript('OnUpdate', onUpdate)
E:UIFrameFadeIn(microBar, 0.2, microBar:GetAlpha(), AB.db.microbar.alpha)
end
if button.backdrop and button:IsEnabled() then
button.backdrop:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
end
-- bag keybind support from actionbar module
if E.private.actionbar.enable then
AB:BindUpdate(button, 'MICRO')
end
end
local function onLeave(button)
if button.backdrop and button:IsEnabled() then
button.backdrop:SetBackdropBorderColor(unpack(E.media.bordercolor))
end
end
function AB:HandleMicroButton(button)
assert(button, 'Invalid micro button name.')
local pushed = button:GetPushedTexture()
local normal = button:GetNormalTexture()
local disabled = button:GetDisabledTexture()
button:CreateBackdrop()
button.backdrop:SetAllPoints()
button:SetParent(microBar)
button:GetHighlightTexture():Kill()
button:HookScript('OnEnter', onEnter)
button:HookScript('OnLeave', onLeave)
button:SetHitRectInsets(0, 0, 0, 0)
if button.Flash then
button.Flash:SetInside()
button.Flash:SetTexture()
end
pushed:SetTexCoord(0.22, 0.81, 0.26, 0.82)
pushed:SetInside(button.backdrop)
normal:SetTexCoord(0.22, 0.81, 0.21, 0.82)
normal:SetInside(button.backdrop)
if disabled then
disabled:SetTexCoord(0.22, 0.81, 0.21, 0.82)
disabled:SetInside(button.backdrop)
end
end
function AB:MainMenuMicroButton_SetNormal()
_G.MainMenuBarPerformanceBar:Point('TOPLEFT', _G.MainMenuMicroButton, 'TOPLEFT', 9, -36)
end
function AB:MainMenuMicroButton_SetPushed()
_G.MainMenuBarPerformanceBar:Point('TOPLEFT', _G.MainMenuMicroButton, 'TOPLEFT', 8, -37)
end
function AB:UpdateMicroButtonsParent()
for _, x in pairs(_G.MICRO_BUTTONS) do
_G[x]:SetParent(microBar)
end
end
-- we use this table to sort the micro buttons on our bar to match Blizzard's button placements.
local __buttonIndex = {
[8] = 'CollectionsMicroButton',
[9] = 'EJMicroButton',
[10] = (not C_StorePublic_IsEnabled() and GetCurrentRegionName() == 'CN') and 'HelpMicroButton' or 'StoreMicroButton',
[11] = 'MainMenuMicroButton'
}
function AB:UpdateMicroBarVisibility()
if InCombatLockdown() then
AB.NeedsUpdateMicroBarVisibility = true
AB:RegisterEvent('PLAYER_REGEN_ENABLED')
return
end
local visibility = AB.db.microbar.visibility
visibility = gsub(visibility, '[\n\r]','')
RegisterStateDriver(microBar.visibility, 'visibility', (AB.db.microbar.enabled and visibility) or 'hide')
end
function AB:UpdateMicroPositionDimensions()
local db = AB.db.microbar
microBar.db = db
microBar.backdrop:SetShown(db.backdrop)
microBar.backdrop:ClearAllPoints()
AB:MoverMagic(microBar)
db.buttons = #_G.MICRO_BUTTONS-1
local backdropSpacing = db.backdropSpacing
local _, horizontal, anchorUp, anchorLeft = AB:GetGrowth(db.point)
local lastButton, anchorRowButton = microBar
for i = 1, #_G.MICRO_BUTTONS-1 do
local button = _G[__buttonIndex[i]] or _G[_G.MICRO_BUTTONS[i]]
local lastColumnButton = i - db.buttonsPerRow
lastColumnButton = _G[__buttonIndex[lastColumnButton]] or _G[_G.MICRO_BUTTONS[lastColumnButton]]
button.db = db
if i == 1 or i == db.buttonsPerRow then
anchorRowButton = button
end
button.handleBackdrop = true -- keep over HandleButton
AB:HandleButton(microBar, button, i, lastButton, lastColumnButton)
lastButton = button
end
microBar:SetAlpha((db.mouseover and not microBar.IsMouseOvered and 0) or db.alpha)
AB:HandleBackdropMultiplier(microBar, backdropSpacing, db.buttonSpacing, db.widthMult, db.heightMult, anchorUp, anchorLeft, horizontal, lastButton, anchorRowButton)
AB:HandleBackdropMover(microBar, backdropSpacing)
if microBar.mover then
if AB.db.microbar.enabled then
E:EnableMover(microBar.mover:GetName())
else
E:DisableMover(microBar.mover:GetName())
end
end
AB:UpdateMicroBarVisibility()
end
function AB:UpdateMicroButtons()
local GuildMicroButton = _G.GuildMicroButton
local GuildMicroButtonTabard = _G.GuildMicroButtonTabard
GuildMicroButtonTabard:SetInside(GuildMicroButton)
GuildMicroButtonTabard.background:SetInside(GuildMicroButton)
GuildMicroButtonTabard.background:SetTexCoord(0.17, 0.87, 0.5, 0.908)
GuildMicroButtonTabard.emblem:ClearAllPoints()
GuildMicroButtonTabard.emblem:Point('TOPLEFT', GuildMicroButton, 'TOPLEFT', 4, -4)
GuildMicroButtonTabard.emblem:Point('BOTTOMRIGHT', GuildMicroButton, 'BOTTOMRIGHT', -4, 8)
AB:UpdateMicroPositionDimensions()
end
function AB:SetupMicroBar()
microBar:CreateBackdrop(AB.db.transparent and 'Transparent')
microBar.backdrop:SetFrameLevel(0)
microBar:Point('TOPLEFT', E.UIParent, 'TOPLEFT', 4, -48)
microBar:EnableMouse(false)
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 _, x in pairs(_G.MICRO_BUTTONS) do
AB:HandleMicroButton(_G[x])
end
_G.MicroButtonPortrait:SetInside(_G.CharacterMicroButton.backdrop)
AB:SecureHook('UpdateMicroButtonsParent')
AB:SecureHook('MoveMicroButtons', 'UpdateMicroPositionDimensions')
AB:SecureHook('UpdateMicroButtons')
UpdateMicroButtonsParent(microBar)
AB:MainMenuMicroButton_SetNormal()
AB:UpdateMicroPositionDimensions()
-- With this method we might don't taint anything. Instead of using :Kill()
_G.MainMenuBarPerformanceBar:SetAlpha(0)
_G.MainMenuBarPerformanceBar:SetScale(0.00001)
E:CreateMover(microBar, 'MicrobarMover', L["Micro Bar"], nil, nil, nil, 'ALL,ACTIONBARS', nil, 'actionbar,microbar')
end

View File

@@ -0,0 +1,258 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local AB = E:GetModule('ActionBars')
local _G = _G
local gsub = gsub
local ipairs = ipairs
local CreateFrame = CreateFrame
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 PetActionBar_ShowGrid = PetActionBar_ShowGrid
local PetActionBar_UpdateCooldowns = PetActionBar_UpdateCooldowns
local NUM_PET_ACTION_SLOTS = NUM_PET_ACTION_SLOTS
local Masque = E.Masque
local MasqueGroup = Masque and Masque:Group('ElvUI', 'Pet Bar')
local bar = CreateFrame('Frame', 'ElvUI_BarPet', E.UIParent, 'SecureHandlerStateTemplate')
bar:SetFrameStrata('LOW')
bar.buttons = {}
function AB:UpdatePet(event, unit)
if event == 'UNIT_AURA' and unit ~= 'pet' then return end
for i = 1, NUM_PET_ACTION_SLOTS, 1 do
local name, texture, isToken, isActive, autoCastAllowed, autoCastEnabled, spellID = GetPetActionInfo(i)
local buttonName = 'PetActionButton'..i
local autoCast = _G[buttonName..'AutoCastable']
local button = _G[buttonName]
button:SetAlpha(1)
button.isToken = isToken
button.icon:Show()
if not isToken then
button.icon:SetTexture(texture)
button.tooltipName = name
else
button.icon:SetTexture(_G[texture])
button.tooltipName = _G[name]
end
if spellID then
local spell = _G.Spell:CreateFromSpellID(spellID)
button.spellDataLoadedCancelFunc = spell:ContinueWithCancelOnSpellLoad(function()
button.tooltipSubtext = spell:GetSpellSubtext()
end)
end
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(button.AutoCastShine)
else
AutoCastShine_AutoCastStop(button.AutoCastShine)
end
if not PetHasActionBar() and texture and name ~= 'PET_ACTION_FOLLOW' then
PetActionButton_StopFlash(button)
button.icon:SetDesaturation(true)
button:SetChecked(false)
end
end
end
function AB:PositionAndSizeBarPet()
local db = AB.db.barPet
local buttonSpacing = db.buttonspacing
local backdropSpacing = db.backdropSpacing
local buttonsPerRow = db.buttonsPerRow
local numButtons = db.buttons
local buttonWidth = db.buttonsize
local buttonHeight = db.keepSizeRatio and db.buttonsize or db.buttonHeight
local point = db.point
local visibility = db.visibility
local autoCastWidth = (buttonWidth / 2) - (buttonWidth / 7.5)
local autoCastHeight = (buttonHeight / 2) - (buttonHeight / 7.5)
bar.db = db
bar.mouseover = db.mouseover
if numButtons < buttonsPerRow then buttonsPerRow = numButtons end
if db.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
bar:SetParent(db.inheritGlobalFade and AB.fadeParent or E.UIParent)
bar:EnableMouse(not db.clickThrough)
bar:SetAlpha(bar.mouseover and 0 or db.alpha)
AB:FadeBarBlings(bar, bar.mouseover and 0 or db.alpha)
bar.backdrop:SetShown(db.backdrop)
bar.backdrop:ClearAllPoints()
AB:MoverMagic(bar)
local _, horizontal, anchorUp, anchorLeft = AB:GetGrowth(point)
local button, lastButton, lastColumnButton, anchorRowButton, lastShownButton, autoCast
for i = 1, NUM_PET_ACTION_SLOTS do
button = _G['PetActionButton'..i]
lastButton = _G['PetActionButton'..i-1]
autoCast = _G['PetActionButton'..i..'AutoCastable']
lastColumnButton = _G['PetActionButton'..i-buttonsPerRow]
button.db = db
bar.buttons[i] = button
if i == 1 or i == buttonsPerRow then
anchorRowButton = button
end
if i > numButtons then
button:SetScale(0.0001)
button:SetAlpha(0)
button.handleBackdrop = nil
else
button:SetScale(1)
button:SetAlpha(bar.db.alpha)
lastShownButton = button
button.handleBackdrop = true -- keep over HandleButton
end
autoCast:SetOutside(button, autoCastWidth, autoCastHeight)
AB:HandleButton(bar, button, i, lastButton, lastColumnButton)
AB:StyleButton(button, nil, MasqueGroup and E.private.actionbar.masque.petBar)
end
AB:HandleBackdropMultiplier(bar, backdropSpacing, buttonSpacing, db.widthMult, db.heightMult, anchorUp, anchorLeft, horizontal, lastShownButton, anchorRowButton)
AB:HandleBackdropMover(bar, backdropSpacing)
visibility = gsub(visibility, '[\n\r]','')
RegisterStateDriver(bar, 'show', visibility)
if MasqueGroup and E.private.actionbar.masque.petBar then
MasqueGroup:ReSkin()
for _, btn in ipairs(bar.buttons) do
AB:TrimIcon(btn, true)
end
end
end
function AB:UpdatePetCooldownSettings()
for i = 1, NUM_PET_ACTION_SLOTS do
local button = _G['PetActionButton'..i]
if button and button.cooldown then
button.cooldown:SetDrawBling(not AB.db.hideCooldownBling)
end
end
end
function AB:UpdatePetBindings()
for i = 1, NUM_PET_ACTION_SLOTS do
if AB.db.hotkeytext then
local key = GetBindingKey('BONUSACTIONBUTTON'..i)
_G['PetActionButton'..i..'HotKey']:Show()
_G['PetActionButton'..i..'HotKey']:SetText(key)
AB:FixKeybindText(_G['PetActionButton'..i])
else
_G['PetActionButton'..i..'HotKey']:Hide()
end
end
end
function AB:CreateBarPet()
bar.backdrop = CreateFrame('Frame', nil, bar, 'BackdropTemplate')
bar.backdrop:SetTemplate(AB.db.transparent and 'Transparent')
bar.backdrop:SetFrameLevel(0)
if AB.db.bar4.enabled then
bar:Point('RIGHT', _G.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
]])
bar:SetScript('OnHide', function()
for i = 1, NUM_PET_ACTION_SLOTS, 1 do
local button = _G['PetActionButton'..i]
if button.spellDataLoadedCancelFunc then
button.spellDataLoadedCancelFunc()
button.spellDataLoadedCancelFunc = nil
end
end
end)
_G.PetActionBarFrame.showgrid = 1
PetActionBar_ShowGrid()
AB:RegisterEvent('PET_BAR_UPDATE', 'UpdatePet')
AB:RegisterEvent('PLAYER_CONTROL_GAINED', 'UpdatePet')
AB:RegisterEvent('PLAYER_CONTROL_LOST', 'UpdatePet')
AB:RegisterEvent('PLAYER_ENTERING_WORLD', 'UpdatePet')
AB:RegisterEvent('PLAYER_FARSIGHT_FOCUS_CHANGED', 'UpdatePet')
AB:RegisterEvent('SPELLS_CHANGED', 'UpdatePet')
AB:RegisterEvent('UNIT_FLAGS', 'UpdatePet')
AB:RegisterEvent('UNIT_PET', 'UpdatePet')
AB:RegisterEvent('PET_BAR_UPDATE_COOLDOWN', PetActionBar_UpdateCooldowns)
E:CreateMover(bar, 'PetAB', L["Pet Bar"], nil, nil, nil, 'ALL,ACTIONBARS', nil, 'actionbar,barPet')
AB:PositionAndSizeBarPet()
AB:UpdatePetBindings()
AB:HookScript(bar, 'OnEnter', 'Bar_OnEnter')
AB:HookScript(bar, 'OnLeave', 'Bar_OnLeave')
for i = 1, NUM_PET_ACTION_SLOTS do
local button = _G['PetActionButton'..i]
AB:HookScript(button, 'OnEnter', 'Button_OnEnter')
AB:HookScript(button, 'OnLeave', 'Button_OnLeave')
if MasqueGroup and E.private.actionbar.masque.petBar then
MasqueGroup:AddButton(button)
end
end
end

View File

@@ -0,0 +1,270 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local AB = E:GetModule('ActionBars')
local _G = _G
local gsub = gsub
local format, ipairs = format, ipairs
local CooldownFrame_Set = CooldownFrame_Set
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_STANCE_SLOTS = NUM_STANCE_SLOTS
local Masque = E.Masque
local MasqueGroup = Masque and Masque:Group('ElvUI', 'Stance Bar')
local WispSplode = [[Interface\Icons\Spell_Nature_WispSplode]]
local bar = CreateFrame('Frame', 'ElvUI_StanceBar', E.UIParent, 'SecureHandlerStateTemplate')
bar.buttons = {}
function AB:UPDATE_SHAPESHIFT_COOLDOWN()
local numForms = GetNumShapeshiftForms()
local start, duration, enable, cooldown
for i = 1, NUM_STANCE_SLOTS do
if i <= numForms then
cooldown = _G['ElvUI_StanceBarButton'..i..'Cooldown']
start, duration, enable = GetShapeshiftFormCooldown(i)
CooldownFrame_Set(cooldown, start, duration, enable)
cooldown:SetDrawBling(cooldown:GetEffectiveAlpha() > 0.5) --Cooldown Bling Fix
end
end
AB:StyleShapeShift('UPDATE_SHAPESHIFT_COOLDOWN')
end
function AB:StyleShapeShift()
local numForms = GetNumShapeshiftForms()
local stance = GetShapeshiftForm()
local darkenInactive = AB.db.stanceBar.style == 'darkenInactive'
for i = 1, NUM_STANCE_SLOTS do
local buttonName = 'ElvUI_StanceBarButton'..i
local button = _G[buttonName]
local cooldown = _G[buttonName..'Cooldown']
if i <= numForms then
local texture, isActive, isCastable, spellID, _ = GetShapeshiftFormInfo(i)
if darkenInactive then
_, _, texture = GetSpellInfo(spellID)
end
if not texture then texture = WispSplode end
button.icon:SetTexture(texture)
if not button.useMasque then
cooldown:SetAlpha(1)
if isActive then
_G.StanceBarFrame.lastSelected = button:GetID()
if numForms == 1 then
button.checked:SetColorTexture(1, 1, 1, 0.5)
button:SetChecked(true)
else
button.checked:SetColorTexture(1, 1, 1, 0.5)
button:SetChecked(not darkenInactive)
end
else
if numForms == 1 or stance == 0 then
button:SetChecked(false)
else
button:SetChecked(darkenInactive)
button.checked:SetAlpha(1)
if darkenInactive then
button.checked:SetColorTexture(0, 0, 0, 0.5)
else
button.checked:SetColorTexture(1, 1, 1, 0.5)
end
end
end
else
if isActive then
button:SetChecked(true)
else
button:SetChecked(false)
end
end
if isCastable then
button.icon:SetVertexColor(1.0, 1.0, 1.0)
else
button.icon:SetVertexColor(0.4, 0.4, 0.4)
end
end
end
end
function AB:PositionAndSizeBarShapeShift()
local db = AB.db.stanceBar
local buttonSpacing = db.buttonspacing
local backdropSpacing = db.backdropSpacing
local buttonsPerRow = db.buttonsPerRow
local numButtons = db.buttons
local point = db.point
local visibility = db.visibility
bar.db = db
bar.mouseover = db.mouseover
if bar.LastButton then
if numButtons > bar.LastButton then numButtons = bar.LastButton end
if buttonsPerRow > bar.LastButton then buttonsPerRow = bar.LastButton end
end
if numButtons < buttonsPerRow then
buttonsPerRow = numButtons
end
bar:SetParent(db.inheritGlobalFade and AB.fadeParent or E.UIParent)
bar:EnableMouse(not db.clickThrough)
bar:SetAlpha(bar.mouseover and 0 or db.alpha)
AB:FadeBarBlings(bar, bar.mouseover and 0 or db.alpha)
bar.backdrop:SetShown(db.backdrop)
bar.backdrop:ClearAllPoints()
AB:MoverMagic(bar)
local _, horizontal, anchorUp, anchorLeft = AB:GetGrowth(point)
local button, lastButton, lastColumnButton, anchorRowButton, lastShownButton
local useMasque = MasqueGroup and E.private.actionbar.masque.stanceBar
for i = 1, NUM_STANCE_SLOTS do
button = _G['ElvUI_StanceBarButton'..i]
lastButton = _G['ElvUI_StanceBarButton'..i-1]
lastColumnButton = _G['ElvUI_StanceBarButton'..i-buttonsPerRow]
button.db = db
if i == 1 or i == buttonsPerRow then
anchorRowButton = button
end
if i > numButtons then
button:SetAlpha(0)
button.handleBackdrop = nil
else
button:SetAlpha(db.alpha)
lastShownButton = button
button.handleBackdrop = true -- keep over HandleButton
end
AB:HandleButton(bar, button, i, lastButton, lastColumnButton)
if useMasque then
MasqueGroup:AddButton(bar.buttons[i])
end
if not button.FlyoutUpdateFunc then
AB:StyleButton(button, nil, useMasque, true)
if not useMasque then
if db.style == 'darkenInactive' then
button.checked:SetBlendMode('BLEND')
else
button.checked:SetBlendMode('ADD')
end
end
end
end
AB:HandleBackdropMultiplier(bar, backdropSpacing, buttonSpacing, db.widthMult, db.heightMult, anchorUp, anchorLeft, horizontal, lastShownButton, anchorRowButton)
AB:HandleBackdropMover(bar, backdropSpacing)
if db.enabled then
visibility = gsub(visibility,'[\n\r]','')
RegisterStateDriver(bar, 'visibility', (GetNumShapeshiftForms() == 0 and 'hide') or visibility)
E:EnableMover(bar.mover:GetName())
else
RegisterStateDriver(bar, 'visibility', 'hide')
E:DisableMover(bar.mover:GetName())
end
if useMasque then
MasqueGroup:ReSkin()
for _, btn in ipairs(bar.buttons) do
AB:TrimIcon(btn, true)
end
end
end
function AB:AdjustMaxStanceButtons(event)
if InCombatLockdown() then
AB.NeedsAdjustMaxStanceButtons = event or true
AB:RegisterEvent('PLAYER_REGEN_ENABLED')
return
end
for _, button in ipairs(bar.buttons) do
button:Hide()
end
local numButtons = GetNumShapeshiftForms()
for i = 1, NUM_STANCE_SLOTS do
if not bar.buttons[i] then
bar.buttons[i] = CreateFrame('CheckButton', format(bar:GetName()..'Button%d', i), bar, 'StanceButtonTemplate')
bar.buttons[i]:SetID(i)
AB:HookScript(bar.buttons[i], 'OnEnter', 'Button_OnEnter')
AB:HookScript(bar.buttons[i], 'OnLeave', 'Button_OnLeave')
end
local blizz = _G[format('StanceButton%d', i)]
if blizz and blizz.commandName then
bar.buttons[i].commandName = blizz.commandName
end
if i <= numButtons then
bar.buttons[i]:Show()
bar.LastButton = i
end
end
AB:PositionAndSizeBarShapeShift()
-- sometimes after combat lock down `event` may be true because of passing it back with `AB.NeedsAdjustMaxStanceButtons`
if event == 'UPDATE_SHAPESHIFT_FORMS' or event == 'PLAYER_ENTERING_WORLD' then
AB:StyleShapeShift()
end
end
function AB:UpdateStanceBindings()
for i = 1, NUM_STANCE_SLOTS do
local button = _G['ElvUI_StanceBarButton'..i]
if not button then break end
if AB.db.hotkeytext then
button.HotKey:Show()
button.HotKey:SetText(GetBindingKey('SHAPESHIFTBUTTON'..i))
AB:FixKeybindText(button)
else
button.HotKey:Hide()
end
end
end
function AB:CreateBarShapeShift()
bar:CreateBackdrop(AB.db.transparent and 'Transparent')
bar.backdrop:SetFrameLevel(0)
bar:Point('TOPLEFT', E.UIParent, 'BOTTOMLEFT', 4, -769)
AB:HookScript(bar, 'OnEnter', 'Bar_OnEnter')
AB:HookScript(bar, 'OnLeave', 'Bar_OnLeave')
AB:RegisterEvent('UPDATE_SHAPESHIFT_COOLDOWN')
AB:RegisterEvent('UPDATE_SHAPESHIFT_FORMS', 'AdjustMaxStanceButtons')
AB:RegisterEvent('UPDATE_SHAPESHIFT_FORM', 'StyleShapeShift')
AB:RegisterEvent('UPDATE_SHAPESHIFT_USABLE', 'StyleShapeShift')
AB:RegisterEvent('ACTIONBAR_PAGE_CHANGED', 'StyleShapeShift')
E:CreateMover(bar, 'ShiftAB', L["Stance Bar"], nil, -3, nil, 'ALL,ACTIONBARS', nil, 'actionbar,stanceBar', true)
end