revert some changes to the action button code again to resolve a weird issue with moving spells (once again its not possible to move actions in combat)
This commit is contained in:
@@ -171,9 +171,10 @@ function ActionBar:UpdateButtons(numbuttons)
|
|||||||
|
|
||||||
-- show active buttons
|
-- show active buttons
|
||||||
for i = 1, numbuttons do
|
for i = 1, numbuttons do
|
||||||
self:SetAttribute("addchild", buttons[i])
|
buttons[i]:SetParent(self)
|
||||||
|
buttons[i]:SetLevels()
|
||||||
buttons[i]:Show()
|
buttons[i]:Show()
|
||||||
buttons[i]:Update()
|
buttons[i]:UpdateAction(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hide inactive buttons
|
-- hide inactive buttons
|
||||||
@@ -256,7 +257,7 @@ function ActionBar:SetHideHotkey(state)
|
|||||||
if state ~= nil then
|
if state ~= nil then
|
||||||
self.config.hidehotkey = state
|
self.config.hidehotkey = state
|
||||||
end
|
end
|
||||||
self:ForAll("UpdateHotkey")
|
self:ForAll("Update")
|
||||||
end
|
end
|
||||||
|
|
||||||
function ActionBar:GetHideHotkey()
|
function ActionBar:GetHideHotkey()
|
||||||
|
|||||||
+3
-1
@@ -342,7 +342,9 @@ function ActionBar:UpdateStates()
|
|||||||
self:ApplyStateButton()
|
self:ApplyStateButton()
|
||||||
|
|
||||||
SecureStateHeader_Refresh(self)
|
SecureStateHeader_Refresh(self)
|
||||||
self:SetAttribute("state", self:GetAttribute("state-page"))
|
|
||||||
|
local newState = self:GetAttribute("state-page")
|
||||||
|
self:SetAttribute("state", newState)
|
||||||
|
|
||||||
self:ApplyVisibilityDriver()
|
self:ApplyVisibilityDriver()
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-2
@@ -183,7 +183,7 @@ function BT4ActionBars:ReassignBindings()
|
|||||||
local frame = self.actionbars[1]
|
local frame = self.actionbars[1]
|
||||||
ClearOverrideBindings(frame)
|
ClearOverrideBindings(frame)
|
||||||
for i = 1,min(#frame.buttons, 12) do
|
for i = 1,min(#frame.buttons, 12) do
|
||||||
local button, real_button = ("ACTIONBUTTON%d"):format(i), ("BT4Button%d"):format(i)
|
local button, real_button = ("ACTIONBUTTON%d"):format(i), ("BT4Button%dSecure"):format(i)
|
||||||
for k=1, select('#', GetBindingKey(button)) do
|
for k=1, select('#', GetBindingKey(button)) do
|
||||||
local key = select(k, GetBindingKey(button))
|
local key = select(k, GetBindingKey(button))
|
||||||
SetOverrideBindingClick(frame, false, key, real_button)
|
SetOverrideBindingClick(frame, false, key, real_button)
|
||||||
@@ -192,7 +192,7 @@ function BT4ActionBars:ReassignBindings()
|
|||||||
|
|
||||||
for i = 1, 120 do
|
for i = 1, 120 do
|
||||||
-- rename old bindings from <buttonname>Secure to only <buttonname)
|
-- rename old bindings from <buttonname>Secure to only <buttonname)
|
||||||
local button, real_button = ("CLICK BT4Button%dSecure:LeftButton"):format(i), ("BT4Button%d"):format(i)
|
local button, real_button = ("CLICK BT4Button%d:LeftButton"):format(i), ("BT4Button%dSecure"):format(i)
|
||||||
|
|
||||||
for k=1, select('#', GetBindingKey(button)) do
|
for k=1, select('#', GetBindingKey(button)) do
|
||||||
local key = select(k, GetBindingKey(button))
|
local key = select(k, GetBindingKey(button))
|
||||||
|
|||||||
@@ -463,8 +463,6 @@ function Bar:ApplyVisibilityDriver()
|
|||||||
-- default state is shown
|
-- default state is shown
|
||||||
self:RegisterVisibilityCondition("show")
|
self:RegisterVisibilityCondition("show")
|
||||||
RegisterStateDriver(self, "visibility", table_concat(self.hidedriver, ";"))
|
RegisterStateDriver(self, "visibility", table_concat(self.hidedriver, ";"))
|
||||||
self:SetAttribute("statemap-visibility", "$input")
|
|
||||||
self:SetAttribute("state-visibility", self:GetAttribute("state-visibility"))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Bar:DisableVisibilityDriver()
|
function Bar:DisableVisibilityDriver()
|
||||||
|
|||||||
+391
-83
@@ -5,10 +5,9 @@
|
|||||||
--[[ $Id$ ]]
|
--[[ $Id$ ]]
|
||||||
|
|
||||||
local Button = CreateFrame("CheckButton")
|
local Button = CreateFrame("CheckButton")
|
||||||
Button.BT4 = true
|
|
||||||
local Button_MT = {__index = Button}
|
local Button_MT = {__index = Button}
|
||||||
|
|
||||||
local onEnter, onUpdate
|
local onEnter, onLeave, onUpdate, onDragStart, onReceiveDrag
|
||||||
|
|
||||||
-- upvalues
|
-- upvalues
|
||||||
local _G = _G
|
local _G = _G
|
||||||
@@ -24,65 +23,146 @@ Bartender4.Button.prototype = Button
|
|||||||
function Bartender4.Button:Create(id, parent)
|
function Bartender4.Button:Create(id, parent)
|
||||||
local absid = (parent.id - 1) * 12 + id
|
local absid = (parent.id - 1) * 12 + id
|
||||||
local name = ("BT4Button%d"):format(absid)
|
local name = ("BT4Button%d"):format(absid)
|
||||||
local button = setmetatable(CreateFrame("CheckButton", name, parent, "ActionBarButtonTemplate"), Button_MT)
|
local button = setmetatable(CreateFrame("CheckButton", name.."Secure", parent, "SecureActionButtonTemplate"), Button_MT)
|
||||||
button.rid = id
|
button.rid = id
|
||||||
button.id = absid
|
button.id = absid
|
||||||
button.parent = parent
|
button.parent = parent
|
||||||
|
|
||||||
button.hotkey = _G[("%sHotKey"):format(name)]
|
button:SetFrameStrata("MEDIUM")
|
||||||
button.icon = _G[("%sIcon"):format(name)]
|
button:SetFrameLevel(parent:GetFrameLevel() + 2)
|
||||||
button.flash = _G[("%sFlash"):format(name)]
|
button:SetWidth(36)
|
||||||
button.macroName = _G[("%sName"):format(name)]
|
button:SetHeight(36)
|
||||||
|
|
||||||
|
button:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress")
|
||||||
|
button:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
|
||||||
|
button:GetHighlightTexture():SetBlendMode("ADD")
|
||||||
|
button:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight")
|
||||||
|
button:GetCheckedTexture():SetBlendMode("ADD")
|
||||||
button:SetNormalTexture("")
|
button:SetNormalTexture("")
|
||||||
local oldNT = _G[("%sNormalTexture"):format(name)]
|
|
||||||
oldNT:Hide()
|
|
||||||
|
|
||||||
button.normalTexture = button:CreateTexture(("%sBTNT"):format(name))
|
button.Proxy = CreateFrame("CheckButton", name, button, "ActionButtonTemplate")
|
||||||
button.normalTexture:SetAllPoints(oldNT)
|
button.Proxy:SetFrameStrata("MEDIUM")
|
||||||
button.SetNormalTexture = function(...) button.normalTexture:SetTexture(...) end
|
button.Proxy:SetFrameLevel(parent:GetFrameLevel() + 1)
|
||||||
button.GetNormalTexture = function() return button.normalTexture end
|
button.Proxy:ClearAllPoints()
|
||||||
|
button.Proxy:SetAllPoints(button)
|
||||||
|
button.Proxy:SetPushedTexture("")
|
||||||
|
button.Proxy:SetHighlightTexture("")
|
||||||
|
button.Proxy:SetCheckedTexture("")
|
||||||
|
button.Proxy:Show()
|
||||||
|
button.Proxy.Secure = button
|
||||||
|
|
||||||
|
local NormalTexture = button.Proxy:GetNormalTexture()
|
||||||
|
NormalTexture:SetWidth(66)
|
||||||
|
NormalTexture:SetHeight(66)
|
||||||
|
NormalTexture:ClearAllPoints()
|
||||||
|
NormalTexture:SetPoint("CENTER", 0, -1)
|
||||||
|
NormalTexture:Show()
|
||||||
|
|
||||||
|
button.normalTexture = NormalTexture
|
||||||
|
button.pushedTexture = button:GetPushedTexture()
|
||||||
|
button.highlightTexture = button:GetHighlightTexture()
|
||||||
|
|
||||||
|
button:SetScript("OnEvent", button.EventHandler)
|
||||||
|
button:SetScript("OnUpdate", onUpdate)
|
||||||
|
button:SetScript("OnEnter", onEnter)
|
||||||
|
button:SetScript("OnLeave", onLeave)
|
||||||
|
button:SetScript("OnAttributeChanged", button.UpdateAction)
|
||||||
|
button:SetScript("OnDragStart", onDragStart)
|
||||||
|
button:SetScript("OnReceiveDrag", onReceiveDrag)
|
||||||
|
button:SetScript("PostClick", button.UpdateState)
|
||||||
|
|
||||||
|
button.icon = _G[("%sIcon"):format(name)]
|
||||||
|
button.border = _G[("%sBorder"):format(name)]
|
||||||
|
button.cooldown = _G[("%sCooldown"):format(name)]
|
||||||
|
button.macroName = _G[("%sName"):format(name)]
|
||||||
|
button.hotkey = _G[("%sHotKey"):format(name)]
|
||||||
|
button.count = _G[("%sCount"):format(name)]
|
||||||
|
button.flash = _G[("%sFlash"):format(name)]
|
||||||
|
button.flash:Hide()
|
||||||
|
|
||||||
|
button.textureCache = {}
|
||||||
|
button.textureCache.pushed = button.pushedTexture:GetTexture()
|
||||||
|
button.textureCache.highlight = button.highlightTexture:GetTexture()
|
||||||
|
|
||||||
|
parent:SetAttribute("addchild", button)
|
||||||
|
|
||||||
|
button:SetAttribute("type", "action")
|
||||||
button:SetAttribute("action", absid)
|
button:SetAttribute("action", absid)
|
||||||
button:SetID(0)
|
|
||||||
button:ClearAllPoints()
|
|
||||||
button:SetAttribute("useparent-unit", true)
|
button:SetAttribute("useparent-unit", true)
|
||||||
button:SetAttribute("useparent-statebutton", true)
|
button:SetAttribute("useparent-statebutton", true)
|
||||||
button:SetAttribute("useparent-actionbar", nil)
|
--button:SetAttribute("hidestates", "-1")
|
||||||
button:SetScript('OnEnter', onEnter)
|
|
||||||
button:SetScript('OnUpdate', onUpdate)
|
button:RegisterForDrag("LeftButton", "RightButton")
|
||||||
|
button:RegisterForClicks("AnyUp")
|
||||||
|
|
||||||
|
button.showgrid = 0
|
||||||
|
button.flashing = 0
|
||||||
|
button.flashtime = 0
|
||||||
|
|
||||||
|
button:RegisterButtonEvents()
|
||||||
|
|
||||||
if LBF and parent.LBFGroup then
|
if LBF and parent.LBFGroup then
|
||||||
parent.LBFGroup:AddButton(button)
|
local group = parent.LBFGroup
|
||||||
|
button.LBFButtonData = {
|
||||||
|
Button = button.Proxy,
|
||||||
|
Highlight = button:GetHighlightTexture(),
|
||||||
|
Pushed = button:GetPushedTexture(),
|
||||||
|
Checked = button:GetCheckedTexture(),
|
||||||
|
}
|
||||||
|
group:AddButton(button.Proxy, button.LBFButtonData)
|
||||||
end
|
end
|
||||||
|
|
||||||
button:Update()
|
|
||||||
button:UpdateHotkey()
|
|
||||||
|
|
||||||
return button
|
return button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Button:SetLevels()
|
||||||
|
local parent = self:GetParent()
|
||||||
|
self:SetFrameLevel(parent:GetFrameLevel() + 3)
|
||||||
|
self.Proxy:SetFrameLevel(parent:GetFrameLevel() + 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
function onDragStart(self)
|
||||||
|
if InCombatLockdown() then return end
|
||||||
|
if not Bartender4.db.profile.buttonlock or IsModifiedClick("PICKUPACTION") then
|
||||||
|
PickupAction(self.action)
|
||||||
|
self:UpdateState()
|
||||||
|
self:UpdateFlash()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function onReceiveDrag(self)
|
||||||
|
if InCombatLockdown() then return end
|
||||||
|
PlaceAction(self.action)
|
||||||
|
self:UpdateState()
|
||||||
|
self:UpdateFlash()
|
||||||
|
end
|
||||||
|
|
||||||
function onEnter(self)
|
function onEnter(self)
|
||||||
if not (Bartender4.db.profile.tooltip == "nocombat" and InCombatLockdown()) and Bartender4.db.profile.tooltip ~= "disabled" then
|
if not (Bartender4.db.profile.tooltip == "nocombat" and InCombatLockdown()) and Bartender4.db.profile.tooltip ~= "disabled" then
|
||||||
ActionButton_SetTooltip(self)
|
self:SetTooltip()
|
||||||
end
|
end
|
||||||
KeyBound:Set(self)
|
KeyBound:Set(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onLeave()
|
||||||
|
GameTooltip:Hide()
|
||||||
|
end
|
||||||
|
|
||||||
local oor, oorcolor, oomcolor
|
local oor, oorcolor, oomcolor
|
||||||
|
|
||||||
function onUpdate(self, elapsed)
|
function onUpdate(self, elapsed)
|
||||||
if ( self.flashing == 1 ) then
|
if self.flashing == 1 then
|
||||||
self.flashtime = self.flashtime - elapsed;
|
self.flashtime = self.flashtime - elapsed
|
||||||
if ( self.flashtime <= 0 ) then
|
if self.flashtime <= 0 then
|
||||||
local overtime = -self.flashtime
|
local overtime = -self.flashtime
|
||||||
if ( overtime >= ATTACK_BUTTON_FLASH_TIME ) then
|
if overtime >= ATTACK_BUTTON_FLASH_TIME then
|
||||||
overtime = 0
|
overtime = 0
|
||||||
end
|
end
|
||||||
self.flashtime = ATTACK_BUTTON_FLASH_TIME - overtime
|
self.flashtime = ATTACK_BUTTON_FLASH_TIME - overtime
|
||||||
|
|
||||||
local flashTexture = self.flash
|
local flashTexture = self.flash
|
||||||
if ( flashTexture:IsShown() ) then
|
if flashTexture:IsVisible() then
|
||||||
flashTexture:Hide()
|
flashTexture:Hide()
|
||||||
else
|
else
|
||||||
flashTexture:Show()
|
flashTexture:Show()
|
||||||
@@ -90,16 +170,16 @@ function onUpdate(self, elapsed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ( self.rangeTimer ) then
|
if self.rangeTimer then
|
||||||
self.rangeTimer = self.rangeTimer - elapsed
|
self.rangeTimer = self.rangeTimer - elapsed
|
||||||
|
|
||||||
if self.rangeTimer <= 0 then
|
if self.rangeTimer <= 0 then
|
||||||
local valid = IsActionInRange(self.action)
|
local valid = IsActionInRange(self.action)
|
||||||
local shown = (self.hotkey:GetText() == RANGE_INDICATOR and oor == "hotkey")
|
local hotkey = self.hotkey
|
||||||
if valid and shown then
|
local hkshown = (hotkey:GetText() == RANGE_INDICATOR and oor == "hotkey")
|
||||||
self.hotkey:Show()
|
if valid and hkshown then
|
||||||
elseif shown then
|
hotkey:Show()
|
||||||
self.hotkey:Hide()
|
elseif hkshown then
|
||||||
|
hotkey:Hide()
|
||||||
end
|
end
|
||||||
self.outOfRange = (valid == 0)
|
self.outOfRange = (valid == 0)
|
||||||
self:UpdateUsable()
|
self:UpdateUsable()
|
||||||
@@ -150,50 +230,86 @@ function Button:SetStateAction(state, action)
|
|||||||
self:SetAttribute(("*action-S%dRight"):format(state), action)
|
self:SetAttribute(("*action-S%dRight"):format(state), action)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Button:CalculateAction()
|
||||||
|
return SecureButton_GetModifiedAttribute(self, "action", SecureButton_GetEffectiveButton(self)) or 1
|
||||||
|
end
|
||||||
|
|
||||||
function Button:GetActionID()
|
function Button:GetActionID()
|
||||||
return self.action
|
return self.action
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:BlizzCall(func, ...)
|
function Button:UpdateAction(force)
|
||||||
local oldThis = this
|
local action = self:CalculateAction()
|
||||||
this = self
|
if action ~= self.action or force then
|
||||||
func(...)
|
self.action = action
|
||||||
this = oldThis
|
self:Update()
|
||||||
end
|
|
||||||
|
|
||||||
orig_ActionButton_UpdateUsable = ActionButton_UpdateUsable
|
|
||||||
ActionButton_UpdateUsable = function(...) if this.BT4 then this:UpdateUsable() else return orig_ActionButton_UpdateUsable(...) end end
|
|
||||||
function Button:UpdateUsable()
|
|
||||||
local isUsable, notEnoughMana = IsUsableAction(self.action)
|
|
||||||
local icon, hotkey = self.icon, self.hotkey
|
|
||||||
if not oor then
|
|
||||||
oor = Bartender4.db.profile.outofrange
|
|
||||||
oorcolor, oomcolor = Bartender4.db.profile.colors.range, Bartender4.db.profile.colors.mana
|
|
||||||
end
|
|
||||||
|
|
||||||
if oor == "button" and self.outOfRange then
|
|
||||||
icon:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b)
|
|
||||||
hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
|
||||||
else
|
|
||||||
if oor == "hotkey" and self.outOfRange then
|
|
||||||
hotkey:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b)
|
|
||||||
else
|
|
||||||
hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
|
||||||
end
|
|
||||||
|
|
||||||
if isUsable then
|
|
||||||
icon:SetVertexColor(1.0, 1.0, 1.0)
|
|
||||||
elseif notEnoughMana then
|
|
||||||
icon:SetVertexColor(oomcolor.r, oomcolor.g, oomcolor.b)
|
|
||||||
else
|
|
||||||
icon:SetVertexColor(0.4, 0.4, 0.4)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:Update()
|
function Button:Update()
|
||||||
oor = nil
|
local action = self.action
|
||||||
self:BlizzCall(ActionButton_Update)
|
self:UpdateIcon()
|
||||||
|
self:UpdateCount()
|
||||||
|
self:UpdateHotkeys()
|
||||||
|
if ( HasAction(action) ) then
|
||||||
|
self:RegisterActionEvents()
|
||||||
|
|
||||||
|
self:UpdateState()
|
||||||
|
self:UpdateUsable(true)
|
||||||
|
self:UpdateCooldown()
|
||||||
|
self:UpdateFlash()
|
||||||
|
|
||||||
|
self:ShowButton()
|
||||||
|
self:SetScript("OnUpdate", onUpdate)
|
||||||
|
else
|
||||||
|
self:UnregisterActionEvents()
|
||||||
|
|
||||||
|
self.cooldown:Hide()
|
||||||
|
|
||||||
|
if ( self.showgrid == 0 and not self.parent.config.showgrid ) then
|
||||||
|
self:HideButton()
|
||||||
|
end
|
||||||
|
|
||||||
|
self:SetScript("OnUpdate", nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( IsEquippedAction(action) ) then
|
||||||
|
self.border:SetVertexColor(0, 1.0, 0, 0.75)
|
||||||
|
self.border:Show()
|
||||||
|
else
|
||||||
|
self.border:Hide()
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( GameTooltip:GetOwner() == self) then
|
||||||
|
self:SetTooltip()
|
||||||
|
end
|
||||||
|
|
||||||
|
if not IsConsumableAction(action) and not IsStackableAction(action) and not self.parent.config.hidemacrotext then
|
||||||
|
self.macroName:SetText(GetActionText(action))
|
||||||
|
else
|
||||||
|
self.macroName:SetText("")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:UpdateIcon()
|
||||||
|
local texture = GetActionTexture(self.action)
|
||||||
|
if ( texture ) then
|
||||||
|
self.rangeTimer = -1
|
||||||
|
self.icon:SetTexture(texture)
|
||||||
|
self.icon:Show()
|
||||||
|
self.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot2")
|
||||||
|
self.normalTexture:SetTexCoord(0, 0, 0, 0)
|
||||||
|
self.iconTex = texture
|
||||||
|
else
|
||||||
|
self.rangeTimer = nil
|
||||||
|
self.icon:Hide()
|
||||||
|
self.cooldown:Hide()
|
||||||
|
self.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot")
|
||||||
|
self.normalTexture:SetTexCoord(-0.15, 1.15, -0.15, 1.17)
|
||||||
|
self.hotkey:SetVertexColor(0.6, 0.6, 0.6)
|
||||||
|
self.iconTex = nil
|
||||||
|
end
|
||||||
if self.parent.config.hidemacrotext then
|
if self.parent.config.hidemacrotext then
|
||||||
self.macroName:Hide()
|
self.macroName:Hide()
|
||||||
else
|
else
|
||||||
@@ -201,9 +317,16 @@ function Button:Update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
orig_ActionButton_UpdateHotkeys = ActionButton_UpdateHotkeys
|
function Button:UpdateCount()
|
||||||
ActionButton_UpdateHotkeys = function(...) if this.BT4 then Button.UpdateHotkey(this) else orig_ActionButton_UpdateHotkeys(...) end end
|
local action = self.action
|
||||||
function Button:UpdateHotkey()
|
if ( IsConsumableAction(action) or IsStackableAction(action) ) then
|
||||||
|
self.count:SetText(GetActionCount(action))
|
||||||
|
else
|
||||||
|
self.count:SetText("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:UpdateHotkeys()
|
||||||
local key = self:GetHotkey() or ""
|
local key = self:GetHotkey() or ""
|
||||||
local hotkey = self.hotkey
|
local hotkey = self.hotkey
|
||||||
|
|
||||||
@@ -275,20 +398,205 @@ function Button:GetActionName()
|
|||||||
return format(actionTmpl, self.parent.id, self.rid)
|
return format(actionTmpl, self.parent.id, self.rid)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:ShowGrid()
|
function Button:UpdateState()
|
||||||
if not self.gridShown then
|
local action = self.action
|
||||||
self.gridShown = true
|
if ( IsCurrentAction(action) or IsAutoRepeatAction(action) ) then
|
||||||
self:SetAttribute("showgrid", self:GetAttribute("showgrid") + 1)
|
self:SetChecked(1)
|
||||||
|
else
|
||||||
|
self:SetChecked(0)
|
||||||
end
|
end
|
||||||
ActionButton_ShowGrid(self)
|
end
|
||||||
|
|
||||||
|
function Button:UpdateUsable(force)
|
||||||
|
local isUsable, notEnoughMana = IsUsableAction(self.action)
|
||||||
|
local icon, hotkey = self.icon, self.hotkey
|
||||||
|
if force or not oor then
|
||||||
|
oor = Bartender4.db.profile.outofrange
|
||||||
|
oorcolor, oomcolor = Bartender4.db.profile.colors.range, Bartender4.db.profile.colors.mana
|
||||||
|
end
|
||||||
|
|
||||||
|
if oor == "button" and self.outOfRange then
|
||||||
|
icon:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b)
|
||||||
|
hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
||||||
|
else
|
||||||
|
if oor == "hotkey" and self.outOfRange then
|
||||||
|
hotkey:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b)
|
||||||
|
else
|
||||||
|
hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
||||||
|
end
|
||||||
|
|
||||||
|
if isUsable then
|
||||||
|
icon:SetVertexColor(1.0, 1.0, 1.0)
|
||||||
|
elseif notEnoughMana then
|
||||||
|
icon:SetVertexColor(oomcolor.r, oomcolor.g, oomcolor.b)
|
||||||
|
else
|
||||||
|
icon:SetVertexColor(0.4, 0.4, 0.4)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:UpdateCooldown()
|
||||||
|
local start, duration, enable = GetActionCooldown(self.action)
|
||||||
|
CooldownFrame_SetTimer(self.cooldown, start, duration, enable)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:UpdateFlash()
|
||||||
|
local action = self.action
|
||||||
|
if ( (IsAttackAction(action) and IsCurrentAction(action)) or IsAutoRepeatAction(action) ) then
|
||||||
|
self:StartFlash()
|
||||||
|
else
|
||||||
|
self:StopFlash()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:StartFlash()
|
||||||
|
self.flashing = 1
|
||||||
|
self.flashtime = 0
|
||||||
|
self:UpdateState()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:StopFlash()
|
||||||
|
self.flashing = 0
|
||||||
|
self.flash:Hide()
|
||||||
|
self:UpdateState()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:SetTooltip()
|
||||||
|
if ( GetCVar("UberTooltips") == "1" ) then
|
||||||
|
GameTooltip_SetDefaultAnchor(GameTooltip, self)
|
||||||
|
else
|
||||||
|
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( GameTooltip:SetAction(self.action) ) then
|
||||||
|
self.UpdateTooltip = self.SetTooltip
|
||||||
|
else
|
||||||
|
self.UpdateTooltip = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:ShowButton()
|
||||||
|
if self.Proxy:IsShown() then return end
|
||||||
|
self.pushedTexture:SetTexture(self.textureCache.pushed)
|
||||||
|
self.highlightTexture:SetTexture(self.textureCache.highlight)
|
||||||
|
|
||||||
|
self.Proxy:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:HideButton()
|
||||||
|
if not self.Proxy:IsShown() then return end
|
||||||
|
self.textureCache.pushed = self.pushedTexture:GetTexture()
|
||||||
|
self.textureCache.highlight = self.highlightTexture:GetTexture()
|
||||||
|
|
||||||
|
self.pushedTexture:SetTexture("")
|
||||||
|
self.highlightTexture:SetTexture("")
|
||||||
|
|
||||||
|
self.Proxy:Hide()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:ShowGrid()
|
||||||
|
self.showgrid = self.showgrid + 1
|
||||||
|
|
||||||
|
self:ShowButton()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:HideGrid()
|
function Button:HideGrid()
|
||||||
if self.gridShown then
|
if self.showgrid > 0 then self.showgrid = self.showgrid - 1 end
|
||||||
self.gridShown = nil
|
if ( self.showgrid == 0 and not HasAction(self.action) and not self.parent.config.showgrid ) then
|
||||||
self:SetAttribute("showgrid", self:GetAttribute("showgrid") - 1)
|
self:HideButton()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:RegisterButtonEvents()
|
||||||
|
self:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
|
||||||
|
self:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
self:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
|
||||||
|
self:RegisterEvent("ACTIONBAR_SHOWGRID")
|
||||||
|
self:RegisterEvent("ACTIONBAR_HIDEGRID")
|
||||||
|
self:RegisterEvent("UPDATE_BINDINGS")
|
||||||
|
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
|
||||||
|
end
|
||||||
|
|
||||||
|
local actionevents = {
|
||||||
|
"PLAYER_TARGET_CHANGED",
|
||||||
|
"ACTIONBAR_UPDATE_STATE",
|
||||||
|
"ACTIONBAR_UPDATE_USABLE",
|
||||||
|
"ACTIONBAR_UPDATE_COOLDOWN",
|
||||||
|
--"UPDATE_INVENTORY_ALERTS",
|
||||||
|
--"PLAYER_AURAS_CHANGED",
|
||||||
|
"CRAFT_SHOW",
|
||||||
|
"CRAFT_CLOSE",
|
||||||
|
"TRADE_SKILL_SHOW",
|
||||||
|
"TRADE_SKILL_CLOSE",
|
||||||
|
"PLAYER_ENTER_COMBAT",
|
||||||
|
"PLAYER_LEAVE_COMBAT",
|
||||||
|
"START_AUTOREPEAT_SPELL",
|
||||||
|
"STOP_AUTOREPEAT_SPELL",
|
||||||
|
}
|
||||||
|
|
||||||
|
function Button:RegisterActionEvents()
|
||||||
|
if self.eventsregistered then return end
|
||||||
|
self.eventsregistered = true
|
||||||
|
|
||||||
|
for _, event in ipairs(actionevents) do
|
||||||
|
self:RegisterEvent(event)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:UnregisterActionEvents()
|
||||||
|
if not self.eventsregistered then return end
|
||||||
|
self.eventsregistered = nil
|
||||||
|
|
||||||
|
for _, event in ipairs(actionevents) do
|
||||||
|
self:UnregisterEvent(event)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Button:EventHandler(event, arg1)
|
||||||
|
if ( event == "ACTIONBAR_SLOT_CHANGED" ) then
|
||||||
|
if ( arg1 == 0 or arg1 == self.action ) then
|
||||||
|
self:Update()
|
||||||
|
end
|
||||||
|
elseif ( event == "PLAYER_ENTERING_WORLD" ) then
|
||||||
|
self:Update()
|
||||||
|
elseif ( event == "ACTIONBAR_PAGE_CHANGED" or event == "UPDATE_BONUS_ACTIONBAR" ) then
|
||||||
|
self:UpdateAction()
|
||||||
|
elseif ( event == "ACTIONBAR_SHOWGRID" ) then
|
||||||
|
self:ShowGrid()
|
||||||
|
elseif ( event == "ACTIONBAR_HIDEGRID" ) then
|
||||||
|
self:HideGrid()
|
||||||
|
elseif ( event == "UPDATE_BINDINGS" ) then
|
||||||
|
self:UpdateHotkeys()
|
||||||
|
elseif not self.eventsregistered then
|
||||||
|
return
|
||||||
|
-- Action Event Handlers, only set when the button actually has an action
|
||||||
|
elseif ( event == "PLAYER_TARGET_CHANGED" ) then
|
||||||
|
self.rangeTimer = -1
|
||||||
|
elseif ( event == "ACTIONBAR_UPDATE_STATE" ) then
|
||||||
|
self:UpdateState()
|
||||||
|
elseif ( event == "ACTIONBAR_UPDATE_USABLE" ) then
|
||||||
|
self:UpdateUsable()
|
||||||
|
elseif ( event == "ACTIONBAR_UPDATE_COOLDOWN" ) then
|
||||||
|
self:UpdateCooldown()
|
||||||
|
elseif ( event == "CRAFT_SHOW" or event == "CRAFT_CLOSE" or event == "TRADE_SKILL_SHOW" or event == "TRADE_SKILL_CLOSE" ) then
|
||||||
|
self:UpdateState()
|
||||||
|
elseif ( event == "PLAYER_ENTER_COMBAT" ) then
|
||||||
|
if ( IsAttackAction(self.action) ) then
|
||||||
|
self:StartFlash()
|
||||||
|
end
|
||||||
|
elseif ( event == "PLAYER_LEAVE_COMBAT" ) then
|
||||||
|
if ( IsAttackAction(self.action) ) then
|
||||||
|
self:StopFlash()
|
||||||
|
end
|
||||||
|
elseif ( event == "START_AUTOREPEAT_SPELL" ) then
|
||||||
|
if ( IsAutoRepeatAction(self.action) ) then
|
||||||
|
self:StartFlash()
|
||||||
|
end
|
||||||
|
elseif ( event == "STOP_AUTOREPEAT_SPELL" ) then
|
||||||
|
if ( self.flashing == 1 and not IsAttackAction(self.action) ) then
|
||||||
|
self:StopFlash()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
ActionButton_HideGrid(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:ClearSetPoint(...)
|
function Button:ClearSetPoint(...)
|
||||||
|
|||||||
+2
-2
@@ -34,14 +34,14 @@ local function getOptions()
|
|||||||
get = function() return Bartender4.Locked end,
|
get = function() return Bartender4.Locked end,
|
||||||
set = function(info, value) Bartender4[value and "Lock" or "Unlock"](Bartender4) end,
|
set = function(info, value) Bartender4[value and "Lock" or "Unlock"](Bartender4) end,
|
||||||
},
|
},
|
||||||
--[[buttonlock = {
|
buttonlock = {
|
||||||
order = 2,
|
order = 2,
|
||||||
type = "toggle",
|
type = "toggle",
|
||||||
name = "Button Lock",
|
name = "Button Lock",
|
||||||
desc = "Lock the buttons.",
|
desc = "Lock the buttons.",
|
||||||
get = getFunc,
|
get = getFunc,
|
||||||
set = setFunc,
|
set = setFunc,
|
||||||
},--]]
|
},
|
||||||
bars = {
|
bars = {
|
||||||
order = 20,
|
order = 20,
|
||||||
type = "group",
|
type = "group",
|
||||||
|
|||||||
Reference in New Issue
Block a user