From 60ba5d95869ea02a7cac5da66940c9f712201326 Mon Sep 17 00:00:00 2001 From: Road-block Date: Sat, 13 Jan 2024 19:50:40 +0200 Subject: [PATCH 1/2] 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 From eaa6452eb42cee9bf78961b59feb73f7f76e0d73 Mon Sep 17 00:00:00 2001 From: Road-block Date: Sun, 14 Jan 2024 12:26:20 +0200 Subject: [PATCH 2/2] another attempt at solving keybind persistence for some players --- ItemRack/ItemRack.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ItemRack/ItemRack.lua b/ItemRack/ItemRack.lua index 6a92973..0fea9b6 100644 --- a/ItemRack/ItemRack.lua +++ b/ItemRack/ItemRack.lua @@ -215,6 +215,7 @@ function ItemRack.InitEventHandlers() handler.CHARACTER_POINTS_CHANGED = ItemRack.UpdateClassSpecificStuff handler.PLAYER_TALENT_UPDATE = ItemRack.UpdateClassSpecificStuff handler.PLAYER_ENTERING_WORLD = ItemRack.OnEnterWorld + handler.PLAYER_LOGOUT = ItemRack.OnPlayerLogout handler.ACTIVE_TALENT_GROUP_CHANGED = ItemRack.UpdateClassSpecificStuff -- handler.PET_BATTLE_OPENING_START = ItemRack.OnEnteringPetBattle -- handler.PET_BATTLE_CLOSE = ItemRack.OnLeavingPetBattle @@ -266,10 +267,19 @@ function ItemRack.OnPlayerLogin() ItemRack.InitEvents() end -function ItemRack.OnEnterWorld() +function ItemRack.OnPlayerLogout() ItemRack.SetSetBindings() end +function ItemRack.OnEnterWorld(self,event,...) + local isLogin,isReload = ... + if isLogin or isReload then + C_Timer.After(15,function() + ItemRack.SetSetBindings() + end) + end +end + local loader = CreateFrame("Frame",nil, self, BackdropTemplateMixin and "BackdropTemplate") -- need a new temp frame here, ItemRackFrame is not created yet loader:RegisterEvent("PLAYER_LOGIN")