Skip to content

Commit

Permalink
add support for engraved items in SoD
Browse files Browse the repository at this point in the history
change up binding save logic a bit
  • Loading branch information
Road-block authored and Rottenbeer committed Jan 20, 2024
1 parent af55755 commit 9c52da4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 17 deletions.
64 changes: 54 additions & 10 deletions ItemRack/ItemRack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions ItemRack/ItemRack.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions ItemRackOptions/ItemRackOptions.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 9c52da4

Please sign in to comment.