Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
fixes #342, more correctly parse BlizzMacro names and ActionID names
Browse files Browse the repository at this point in the history
  • Loading branch information
brittyazel committed Apr 3, 2020
1 parent 5df80b2 commit ef97b36
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 37 deletions.
68 changes: 41 additions & 27 deletions Objects/ACTIONBUTTON.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ function ACTIONBUTTON:UpdateData()
end
end



self.unit = target or "target"

if abilityOrItem and #abilityOrItem > 0 and command:find("/castsequence") then --this always will set the button info the next ability or item in the sequence
Expand Down Expand Up @@ -505,7 +507,7 @@ ACTIONBUTTON.PLAYER_STOPPED_MOVING = ACTIONBUTTON.PLAYER_STARTED_MOVING

function ACTIONBUTTON:BAG_UPDATE_COOLDOWN()
if self.item then
self:UpdateState()
self:UpdateStatus()
end
end
ACTIONBUTTON.BAG_UPDATE = ACTIONBUTTON.BAG_UPDATE_COOLDOWN
Expand Down Expand Up @@ -721,25 +723,20 @@ end
function ACTIONBUTTON:SetSpellIcon(spell)
local texture

if not self.data.macro_BlizzMacro and not self.data.macro_EquipmentSet then
spell = spell:lower()
spell = spell:lower()

if NeuronSpellCache[spell] then
texture = GetSpellTexture(spell) --try getting a new texture first (this is important for things like Wild Charge that has different icons per spec
if not texture then --if you don't find a new icon (meaning the spell isn't currently learned) default to icon in the database
texture = NeuronSpellCache[spell].icon
end
elseif NeuronCollectionCache[spell] then
texture = NeuronCollectionCache[spell].icon
elseif spell then
texture = GetSpellTexture(spell)
end
else
if self.data.macro_BlizzMacro then
_, texture = GetMacroInfo(self.data.macro_BlizzMacro)
if NeuronSpellCache[spell] then
texture = GetSpellTexture(spell) --try getting a new texture first (this is important for things like Wild Charge that has different icons per spec
if not texture then --if you don't find a new icon (meaning the spell isn't currently learned) default to icon in the database
texture = NeuronSpellCache[spell].icon
end
elseif NeuronCollectionCache[spell] then
texture = NeuronCollectionCache[spell].icon
elseif spell then
texture = GetSpellTexture(spell)
end


if texture then
self.elements.IconFrameIcon:SetTexture(texture)
else
Expand Down Expand Up @@ -777,7 +774,7 @@ function ACTIONBUTTON:SetActionIcon(action)
local texture
local actionID = tonumber(action)

if actionID and HasAction(actionID)then
if actionID and HasAction(actionID) then
texture = GetActionTexture(actionID)
end

Expand All @@ -792,24 +789,28 @@ function ACTIONBUTTON:SetActionIcon(action)
end

-----------------------------------------------------------------------------------------
-------------------------------------- Set State ----------------------------------------
-------------------------------------- Set Status ---------------------------------------
-----------------------------------------------------------------------------------------

function ACTIONBUTTON:UpdateState()
function ACTIONBUTTON:UpdateStatus()
if self.actionID then
self:SetActionState(self.actionID)
self:SetActionStatus(self.actionID)
elseif self.data.macro_BlizzMacro then
self.elements.Name:SetText(self.data.macro_Name)
elseif self.data.macro_EquipmentSet then
self.elements.Name:SetText(self.data.macro_Name)
elseif self.spell then
self:SetSpellState(self.spell)
self:SetSpellStatus(self.spell)
elseif self.item then
self:SetItemState(self.item)
self:SetItemStatus(self.item)
else
self:SetChecked(nil)
self.elements.Name:SetText("")
self.elements.Count:SetText("")
end
end

function ACTIONBUTTON:SetSpellState(spell)
function ACTIONBUTTON:SetSpellStatus(spell)
if IsCurrentSpell(spell) or IsAutoRepeatSpell(spell) then
self:SetChecked(1)
else
Expand All @@ -819,10 +820,9 @@ function ACTIONBUTTON:SetSpellState(spell)
self.elements.Name:SetText(self.data.macro_Name)
self:UpdateSpellCount(spell)
self:UpdateUsable()

end

function ACTIONBUTTON:SetItemState(item)
function ACTIONBUTTON:SetItemStatus(item)
if IsCurrentItem(item) then
self:SetChecked(1)
else
Expand All @@ -834,20 +834,34 @@ function ACTIONBUTTON:SetItemState(item)
self:UpdateUsable()
end

function ACTIONBUTTON:SetActionState(action)
function ACTIONBUTTON:SetActionStatus(action)
local actionID = tonumber(action)
local name

if actionID then
if IsCurrentAction(actionID) or IsAutoRepeatAction(actionID) then
self:SetChecked(1)
else
self:SetChecked(nil)
end

--find out the action name
local type, id, _ = GetActionInfo(self.actionID)
if type == "spell" then
name = GetSpellInfo(id)
elseif type == "item" then
name = GetItemInfo(id)
end

else
self:SetChecked(nil)
end

self.elements.Name:SetText("")
if name then
self.elements.Name:SetText(name)
else
self.elements.Name:SetText("")
end
self.elements.Count:SetText("")
self:UpdateUsable()
end
Expand Down
2 changes: 1 addition & 1 deletion Objects/ACTIONBUTTON_DragAndDrop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ function ACTIONBUTTON:PlaceBlizzEquipSet(equipmentSetName)
end

local name, texture = C_EquipmentSet.GetEquipmentSetInfo(equipsetNameIndex)

if texture then
self.data.macro_Text = "/equipset "..equipmentSetName
self.data.macro_Name = name
Expand All @@ -360,7 +361,6 @@ function ACTIONBUTTON:PlaceBlizzEquipSet(equipmentSetName)
self.data.macro_EquipmentSet = false
end

self.data.macro_Name = ""
self.data.macro_Note = ""
self.data.macro_UseNote = false
self.data.macro_BlizzMacro = false
Expand Down
6 changes: 3 additions & 3 deletions Objects/ACTIONBUTTON_Flyout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ function ACTIONBUTTON:Flyout_PostClick()
button:MACRO_Reset()
button:UpdateAll()

self:UpdateState()
self:UpdateStatus()
end

function ACTIONBUTTON:Flyout_GetButton()
Expand Down Expand Up @@ -893,8 +893,8 @@ function ACTIONBUTTON:Flyout_GetButton()
newButton:SetScript("OnEnter", function(self, ...) self:OnEnter(...) end)
newButton:SetScript("OnLeave", function(self, ...) self:OnLeave(...) end)

newButton:SetScript("OnShow", function(self) self:UpdateUsable(); self:UpdateIcon(); self:UpdateState() end)
newButton:SetScript("OnHide", function(self) self:UpdateUsable(); self:UpdateIcon(); self:UpdateState() end)
newButton:SetScript("OnShow", function(self) self:UpdateUsable(); self:UpdateIcon(); self:UpdateStatus() end)
newButton:SetScript("OnHide", function(self) self:UpdateUsable(); self:UpdateIcon(); self:UpdateStatus() end)

newButton:WrapScript(newButton, "OnClick", [[
local button = self:GetParent():GetParent()
Expand Down
4 changes: 2 additions & 2 deletions Objects/BAR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ function BAR:ClearStates(handler, state)
end


function BAR:UpdateStates(handler)
function BAR:UpdateStatuss(handler)
for state, values in pairs(MAS) do

if self.data[state] then
Expand Down Expand Up @@ -1064,7 +1064,7 @@ function BAR:Update(show, hide)

if self.stateschanged then

self:UpdateStates(handler)
self:UpdateStatuss(handler)

self.stateschanged = nil
end
Expand Down
4 changes: 2 additions & 2 deletions Objects/BUTTON.lua
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ function BUTTON:UpdateAll()
self:UpdateData()
self:UpdateUsable()
self:UpdateIcon()
self:UpdateState()
self:UpdateStatus()
self:UpdateTimers()
self:UpdateNormalTexture()
end
Expand All @@ -856,7 +856,7 @@ function BUTTON:UpdateIcon()
-- empty --
end

function BUTTON:UpdateState()
function BUTTON:UpdateStatus()
-- empty --
end

Expand Down
4 changes: 2 additions & 2 deletions Objects/PETBTN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function PETBTN:PET_UpdateIcon(spell, texture, isToken)
end
end

function PETBTN:PET_UpdateState(isActive, allowed, enabled)
function PETBTN:PET_UpdateStatus(isActive, allowed, enabled)

if isActive then

Expand Down Expand Up @@ -221,7 +221,7 @@ function PETBTN:PET_UpdateOnEvent(state)
end
end

self:PET_UpdateState(isActive, allowed, enabled)
self:PET_UpdateStatus(isActive, allowed, enabled)

end

Expand Down

0 comments on commit ef97b36

Please sign in to comment.