From 9c52da4e7c0444481e67c3da9d0fbf010c93206b Mon Sep 17 00:00:00 2001 From: Road-block Date: Sat, 13 Jan 2024 19:50:40 +0200 Subject: [PATCH] add support for engraved items in SoD change up binding save logic a bit --- ItemRack/ItemRack.lua | 64 ++++++++++++++++++++++++----- ItemRack/ItemRack.toc | 8 ++-- ItemRackOptions/ItemRackOptions.toc | 6 +-- 3 files changed, 61 insertions(+), 17 deletions(-) diff --git a/ItemRack/ItemRack.lua b/ItemRack/ItemRack.lua index c7d497a..6a92973 100644 --- a/ItemRack/ItemRack.lua +++ b/ItemRack/ItemRack.lua @@ -17,10 +17,15 @@ function ItemRack.IsWrath() return WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC end -local GetContainerNumSlots, GetContainerItemLink, GetContainerItemCooldown, GetContainerItemInfo, GetItemCooldown, PickupContainerItem, ContainerIDToInventoryID +function ItemRack.IsEngravingActive() + return C_Engraving and C_Engraving.IsEngravingEnabled() +end + +local GetContainerNumSlots, GetContainerItemLink, GetContainerItemID, GetContainerItemCooldown, GetContainerItemInfo, GetItemCooldown, PickupContainerItem, ContainerIDToInventoryID if C_Container then GetContainerNumSlots = C_Container.GetContainerNumSlots GetContainerItemLink = C_Container.GetContainerItemLink + GetContainerItemID = C_Container.GetContainerItemID GetContainerItemCooldown = C_Container.GetContainerItemCooldown GetItemCooldown = C_Container.GetItemCooldown PickupContainerItem = C_Container.PickupContainerItem @@ -34,8 +39,8 @@ if C_Container then end end else - GetContainerNumSlots, GetContainerItemLink, GetContainerItemCooldown, GetContainerItemInfo, GetItemCooldown, PickupContainerItem, ContainerIDToInventoryID = - _G.GetContainerNumSlots, _G.GetContainerItemLink, _G.GetContainerItemCooldown, _G.GetContainerItemInfo, _G.GetItemCooldown, _G.PickupContainerItem, _G.ContainerIDToInventoryID + GetContainerNumSlots, GetContainerItemLink, GetContainerItemID, GetContainerItemCooldown, GetContainerItemInfo, GetItemCooldown, PickupContainerItem, ContainerIDToInventoryID = + _G.GetContainerNumSlots, _G.GetContainerItemLink, _G.GetContainerItemID, _G.GetContainerItemCooldown, _G.GetContainerItemInfo, _G.GetItemCooldown, _G.PickupContainerItem, _G.ContainerIDToInventoryID end local LDB = LibStub("LibDataBroker-1.1") @@ -612,6 +617,30 @@ function ItemRack.GetIRString(inputString,baseid,regular) return string.match(inputString or "", (baseid and (regular and ItemRack.iSPatternBaseIDFromRegular or ItemRack.iSPatternBaseIDFromIR) or ItemRack.iSPatternRegularToIR)) or 0 end +-- [[ Season of Discovery Runes ]] +if ItemRack.IsEngravingActive() then + function ItemRack.AppendRuneID(bag, slot) + local inv_slot + if slot then + local item_id = GetContainerItemID(bag, slot) + if item_id then + inv_slot = C_Item.GetItemInventoryTypeByID(item_id) + end + else + inv_slot = bag + end + if inv_slot and C_Engraving.IsEquipmentSlotEngravable(inv_slot) then + local rune_info = C_Engraving.GetRuneForEquipmentSlot(inv_slot) + if rune_info then + return ":runeid:"..tostring(rune_info.skillLineAbilityID) + else + return ":runeid:0" + end + end + return "" + end +end + -- itemrack itemstring updater. -- takes a saved ItemRack-style ID and returns an updated version with the latest player level and spec injected, which helps us update outdated IDs saved when the player was lower level or different spec function ItemRack.UpdateIRString(itemRackID) @@ -628,6 +657,7 @@ end -- bag,nil = inventory slot; bag,slot = container slot function ItemRack.GetID(bag,slot) local _, itemLink + local runeSuffix = "" if slot then itemLink = GetContainerItemLink(bag,slot) else @@ -637,7 +667,10 @@ function ItemRack.GetID(bag,slot) itemLink = GetInventoryItemLink("player",bag) end end - return ItemRack.GetIRString(itemLink) + if ItemRack.AppendRuneID then + runeSuffix = ItemRack.AppendRuneID(bag,slot) + end + return ItemRack.GetIRString(itemLink)..runeSuffix end -- takes two ItemRack-style IDs (one or both of the parameters can be a baseID instead if needed) and returns true if those items share the same base itemID @@ -1979,10 +2012,21 @@ function ItemRack.ToggleHidden(id) end --[[ Key bindings ]] - +local retryCount = 0 function ItemRack.SetSetBindings() - local inLockdown = InCombatLockdown() - if not inLockdown then + if InCombatLockdown() then + ItemRack.Print("Cannot save hotkeys in combat, please try again out of combat!") + return + end + if retryCount > 3 then return end + local bindingSet = GetCurrentBindingSet() + if not bindingSet or not (Enum.BindingSet and tContains(Enum.BindingSet, bindingSet)) then + retryCount = retryCount + 1 + C_Timer.After(5, function() + ItemRack.SetSetBindings() + end) + return + else local buttonName,button for i in pairs(ItemRackUser.Sets) do if ItemRackUser.Sets[i].key then @@ -2003,9 +2047,9 @@ function ItemRack.SetSetBindings() SetBindingClick(ItemRackUser.Sets[i].key,buttonName) end end - SaveBindings(GetCurrentBindingSet()) - else - ItemRack.Print("Cannot save hotkeys in combat, please try again out of combat!") + local bindingSet = GetCurrentBindingSet() + SaveBindings(bindingSet) + retryCount = 0 end end diff --git a/ItemRack/ItemRack.toc b/ItemRack/ItemRack.toc index 2e59e01..9fbf0f0 100644 --- a/ItemRack/ItemRack.toc +++ b/ItemRack/ItemRack.toc @@ -1,9 +1,9 @@ -## Interface: 30401 -## Interface-Classic: 11403 +## Interface: 30403 +## Interface-Classic: 11500 ## Interface-BCC: 20504 -## Interface-WOTLKC: 30401 +## Interface-WOTLKC: 30403 ## Title: ItemRack - Classic -## Version: 3.75 +## Version: 3.77 ## Author: Gello - Updated for Classic by Rottenbeer,Roadblock ## SavedVariables: ItemRackSettings, ItemRackItems, ItemRackEvents ## SavedVariablesPerCharacter: ItemRackUser diff --git a/ItemRackOptions/ItemRackOptions.toc b/ItemRackOptions/ItemRackOptions.toc index a74e0f6..407fc68 100644 --- a/ItemRackOptions/ItemRackOptions.toc +++ b/ItemRackOptions/ItemRackOptions.toc @@ -1,7 +1,7 @@ -## Interface: 30401 -## Interface-Classic: 11403 +## Interface: 30403 +## Interface-Classic: 11500 ## Interface-BCC: 20504 -## Interface-WOTLKC: 30401 +## Interface-WOTLKC: 30403 ## Title: ItemRackOptions ## Notes: Load-On-Demand modules for ItemRack ## Dependencies: ItemRack, Blizzard_MacroUI