From 605204b497a84626449c37aea1625b092917b2d0 Mon Sep 17 00:00:00 2001 From: dvipid Date: Wed, 29 Aug 2018 20:05:34 -0400 Subject: [PATCH] Fixes Equipment Set buttons. Fixes Random Favorite Battle Pet button. Fixes some spells that could not be cast (Thrash, Stampeding Roar, and probably a lot more). Fixes dragging out some spells would clear the cursor instead of picking up the spell. --- ButtonForge/Button.lua | 46 ++++++++++++++++++++++++++++++++++-------- ButtonForge/Const.lua | 2 ++ ButtonForge/Util.lua | 23 +++++++++++++++------ README.md | 4 ++-- 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/ButtonForge/Button.lua b/ButtonForge/Button.lua index c80dad0..9fd2897 100644 --- a/ButtonForge/Button.lua +++ b/ButtonForge/Button.lua @@ -588,9 +588,15 @@ function Button:SetCommandCompanion(MountID) --local SpellName = GetSpellInfo(SpellId); self:SetCommandExplicitCompanion(MountID); end -function Button:SetCommandEquipmentSet(Name) - local Id = select(2, GetEquipmentSetInfoByName(Name)); --Id isn't really used, but since it is available and appears reliable (i.e. doesn't change??) I will store it away just in case - self:SetCommandExplicitEquipmentSet(Id, Name); +function Button:SetCommandEquipmentSet(SetName) + local SetCount = C_EquipmentSet.GetNumEquipmentSets(); + for i=0,SetCount-1 do + name, texture, setIndex, isEquipped, totalItems, equippedItems, inventoryItems, missingItems, ignoredSlots = C_EquipmentSet.GetEquipmentSetInfo(i); + if (name == SetName ) then + self:SetCommandExplicitEquipmentSet(setIndex, name); + break; + end + end; end function Button:SetCommandBonusAction(Id) self:SetCommandExplicitBonusAction(Id); @@ -886,7 +892,7 @@ function Button:SetEnvEquipmentSet(Id, Name) self.Mode = "equipmentset"; self.EquipmentSetId = Id; self.EquipmentSetName = Name; - self.Texture = select(2, GetEquipmentSetInfo(Index)) or ""; --"Interface/Icons/"..(GetEquipmentSetInfoByName(Name) or ""); --safe provided Name ~= nil + self.Texture = select(2, C_EquipmentSet.GetEquipmentSetInfo(Index)) or ""; --"Interface/Icons/"..(GetEquipmentSetInfoByName(Name) or ""); --safe provided Name ~= nil self.Target = "target"; self:ResetAppearance(); @@ -1001,7 +1007,11 @@ function Button:SetEnvBattlePet(Id) self.Mode = "battlepet"; self.BattlePetId = Id; - self.Texture = select(9, C_PetJournal.GetPetInfoByPetID(Id)); + if (Id == Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_ID) then + self.Texture = Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_TEXTURE; + else + self.Texture = select(9, C_PetJournal.GetPetInfoByPetID(Id)); + end self.Target = "target"; self:ResetAppearance(); @@ -1131,7 +1141,19 @@ function Button:SetAttributes(Type, Value) self.Widget:SetAttribute("id", nil); --Now if a valid type is passed in set it - if (Type == "spell" or Type == "item" or Type == "macro") then + if (Type == "spell") then + -- Patch to fix some spell that doesnt like to be cast with ID (Thrash, Stampeding Roar, ...) + local SpellName = GetSpellInfo(Value); + if ( SpellName ) then + self.Widget:SetAttribute("type", Type); + self.Widget:SetAttribute(Type, SpellName); + else + -- fallback to the old method if the name cannot be resolved + self.Widget:SetAttribute("type", Type); + self.Widget:SetAttribute(Type, Value); + end + + elseif (Type == "item" or Type == "macro") then self.Widget:SetAttribute("type", Type); self.Widget:SetAttribute(Type, Value); @@ -1770,6 +1792,10 @@ function Button:UpdateTooltipBattlePet() GameTooltip:AddLine(SPELL_CAST_TIME_INSTANT, 1, 1, 1, true); GameTooltip:AddLine(string.format(BATTLE_PET_TOOLTIP_SUMMON, name), nil, nil, nil, true); GameTooltip:Show(); + elseif (self.BattlePetId == Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_ID) then + GameTooltip:SetText(PET_JOURNAL_SUMMON_RANDOM_FAVORITE_PET, 1, 1, 1); + GameTooltip:AddLine(SPELL_CAST_TIME_INSTANT, 1, 1, 1, true); + GameTooltip:Show(); end end @@ -2091,7 +2117,11 @@ end function Button:RefreshBattlePet() if (self.Mode == "battlepet") then - self.Texture = select(9, C_PetJournal.GetPetInfoByPetID(self.BattlePetId)); + if (self.BattlePetId == Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_ID) then + self.Texture = Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_TEXTURE; + else + self.Texture = select(9, C_PetJournal.GetPetInfoByPetID(self.BattlePetId)); + end self.Texture = self.Texture or "Interface/Icons/INV_Misc_QuestionMark"; self:DisplayActive(); end @@ -2126,7 +2156,7 @@ function Button:RefreshEquipmentSet() -- This equip set is gone so clear it from the button return self:ClearCommand(); end - local TextureName = select(2, GetEquipmentSetInfo(Index)); + local TextureName = select(2, C_EquipmentSet.GetEquipmentSetInfo(Index)); if (TextureName) then self.Texture = TextureName; self:DisplayActive(); diff --git a/ButtonForge/Const.lua b/ButtonForge/Const.lua index 5d4262a..97484a8 100644 --- a/ButtonForge/Const.lua +++ b/ButtonForge/Const.lua @@ -9,6 +9,8 @@ local Const = BFConst; Const.SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544; Const.SUMMON_RANDOM_FAVORITE_MOUNT_ID = 268435455; +Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_ID = "BattlePet-0-FFFFFFFFFFFFFF"; +Const.SUMMON_RANDOM_FAVORITE_BATTLE_PET_TEXTURE = "Interface/Icons/INV_Pet_Achievement_CaptureAPetFromEachFamily_Battle"; Const.Version = 0.9; Const.VersionMinor = 50; Const.MAX_ACCOUNT_MACROS = 120; diff --git a/ButtonForge/Util.lua b/ButtonForge/Util.lua index 3652302..108acf8 100644 --- a/ButtonForge/Util.lua +++ b/ButtonForge/Util.lua @@ -1536,8 +1536,12 @@ function Util.SetCursor(Command, Data, Subvalue, Subsubvalue) UILib.StopDraggingIcon(); SpellFlyout:Hide(); if (Command == "spell") then - --PickupSpellBookItem(Data, Subvalue); - PickupSpell(Subsubvalue); + local SpellName = GetSpellInfo(Subsubvalue); + if ( SpellName ) then + PickupSpellBookItem(SpellName) + else + PickupSpell(Subsubvalue); + end elseif (Command == "item") then PickupItem(Data); elseif (Command == "macro") then @@ -1548,7 +1552,14 @@ function Util.SetCursor(Command, Data, Subvalue, Subsubvalue) --end C_MountJournal.Pickup(Util.GetMountIndexFromMountID(Data)); elseif (Command == "equipmentset") then - PickupEquipmentSetByName(Data); + local SetCount = C_EquipmentSet.GetNumEquipmentSets(); + for i=0,SetCount-1 do + name, _, setIndex = C_EquipmentSet.GetEquipmentSetInfo(i); + if (name == Data) then + C_EquipmentSet.PickupEquipmentSet(setIndex); + break; + end + end; elseif (Command == "bonusaction") then local page = 12; --The page for vehicleactionbar if (HasOverrideActionBar()) then @@ -2534,9 +2545,9 @@ end function Util.LookupEquipmentSetIndex(EquipmentSetID) - local Total = GetNumEquipmentSets(); - for i = 1, Total do - if (select(3, GetEquipmentSetInfo(i)) == EquipmentSetID) then + local Total = C_EquipmentSet.GetNumEquipmentSets(); + for i = 0, Total-1 do + if (select(3, C_EquipmentSet.GetEquipmentSetInfo(i)) == EquipmentSetID) then return i; end end diff --git a/README.md b/README.md index bab9927..f2f6f56 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# ButtonForge - Legion +# ButtonForge - Battle for Azeroth . #### Author: Alternator (Massiner of Nathrezim) -#### Bug Fixes: DT85 (Zaranias - Aman'thul) +#### Bug Fixes: DT85 (Zaranias - Aman'thul), dvipid (Arhenn - Zul'jin)