diff --git a/ItemRack/ItemRack.lua b/ItemRack/ItemRack.lua index 0fea9b6..0a58161 100644 --- a/ItemRack/ItemRack.lua +++ b/ItemRack/ItemRack.lua @@ -215,7 +215,6 @@ 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 @@ -267,19 +266,10 @@ function ItemRack.OnPlayerLogin() ItemRack.InitEvents() end -function ItemRack.OnPlayerLogout() +function ItemRack.OnEnterWorld() 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") @@ -623,6 +613,7 @@ ItemRack.iSPatternRegularToIR = "item:(.-)\124h" --example: "62384:0:4041:4041:0 ItemRack.iSPatternBaseIDFromIR = "^(%-?%d+)" --this must *only* be used on ItemRack-style IDs, and will return the first field (the itemID), allowing us to do loose item matching ItemRack.iSPatternBaseIDFromRegular = "item:(%-?%d+)" --this must *only* be used regular itemLinks/itemStrings, and will return the first field (the itemID), allowing us to do loose item matching ItemRack.iSPatternEnhancementsFromIR = "^(%-?%d+):(%-?%d*):(%-?%d*):(%-?%d*):(%-?%d*)" --this must *only* be used on ItemRack-style IDs, and will return itemID, enchantID, gem1, gem2, gem3 +ItemRack.iSPatternRuneIDFromIR = ":runeid:(%d+)" 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 @@ -630,24 +621,28 @@ end -- [[ Season of Discovery Runes ]] if ItemRack.IsEngravingActive() then function ItemRack.AppendRuneID(bag, slot) - local inv_slot + local rune_info if slot then - local item_id = GetContainerItemID(bag, slot) - if item_id then - inv_slot = C_Item.GetItemInventoryTypeByID(item_id) - end + rune_info = C_Engraving.GetRuneForInventorySlot(bag, slot) else - inv_slot = bag + rune_info = C_Engraving.GetRuneForEquipmentSlot(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" + return ":runeid:"..tostring(rune_info and rune_info.skillLineAbilityID or 0) + end + + function ItemRack.GetRuneID(inputString) + return tonumber(string.match(inputString or "", ItemRack.iSPatternRuneIDFromIR)) + end + + function ItemRack.GetRuneTexture(runeID) + if not runeID or runeID == 0 then return end + local categories = C_Engraving.GetRuneCategories(true, true); + for _, category in ipairs(categories) do + local runes = C_Engraving.GetRunesForCategory(category, true); + for _, rune in ipairs(runes) do + if rune.skillLineAbilityID == runeID then return rune.iconTexture end end end - return "" end end @@ -1074,9 +1069,7 @@ function ItemRack.BuildMenu(id,menuInclude,masqueGroup) local showButtonMenu = (ItemRackButtonMenu and ItemRack.menuMovable) and (IsAltKeyDown() or ItemRackUser.Locked=="OFF") - for i in pairs(ItemRack.Menu) do - ItemRack.Menu[i] = nil - end + wipe(ItemRack.Menu) local itemLink,itemID,itemName,equipSlot,itemTexture @@ -1301,9 +1294,9 @@ end function ItemRack.CreateMenuButton(idx,itemID) if itemID=="MENU" then return end - local button - if not _G["ItemRackMenu"..idx] then - button = CreateFrame("CheckButton","ItemRackMenu"..idx,ItemRackMenuFrame,"ActionButtonTemplate") + local button = _G["ItemRackMenu"..idx] + if not button then + button = CreateFrame("CheckButton","ItemRackMenu"..idx,ItemRackMenuFrame,"ActionButtonTemplate,ItemButtonTemplate") button:SetID(idx) button:SetFrameStrata("HIGH") -- button:SetFrameLevel(ItemRackMenuFrame:GetFrameLevel()+1) @@ -1322,15 +1315,21 @@ function ItemRack.CreateMenuButton(idx,itemID) end if itemID~=0 then if ItemRackUser.Sets[itemID] then - _G["ItemRackMenu"..idx.."Icon"]:SetTexture(ItemRackUser.Sets[itemID].icon) + SetItemButtonTexture(button, ItemRackUser.Sets[itemID].icon) + SetItemButtonSubTexture(button, nil); else local _,texture = ItemRack.GetInfoByID(itemID) - _G["ItemRackMenu"..idx.."Icon"]:SetTexture(texture) + SetItemButtonTexture(button, texture) + if ItemRack.IsEngravingActive() then + local texture = ItemRack.GetRuneTexture(ItemRack.GetRuneID(itemID)) + SetItemButtonSubTexture(button, texture); + end end else - _G["ItemRackMenu"..idx.."Icon"]:SetTexture(select(2,GetInventorySlotInfo(ItemRack.SlotInfo[ItemRack.menuOpen].name))) + SetItemButtonTexture(button, select(2,GetInventorySlotInfo(ItemRack.SlotInfo[ItemRack.menuOpen].name))) + SetItemButtonSubTexture(button, nil); end - return _G["ItemRackMenu"..idx] + return button end -- takes an ItemRack-style ID, finds the best match in the player's inventory, and puts its ItemLink to the chat editbox. @@ -2022,44 +2021,31 @@ function ItemRack.ToggleHidden(id) end --[[ Key bindings ]] -local retryCount = 0 function ItemRack.SetSetBindings() 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 - buttonName = "ItemRack"..UnitName("player")..GetRealmName()..i - button = _G[buttonName] or CreateFrame("Button",buttonName,nil,"SecureActionButtonTemplate") - - button:SetAttribute("type","macro") - local macrotext = "/script ItemRack.RunSetBinding(\""..i.."\")\n" - for slot = 16, 18 do - if ItemRackUser.Sets[i].equip[slot] then - local name,_,_,_,_,_,_,_,_,_ = GetItemInfo("item:"..ItemRackUser.Sets[i].equip[slot]) - if name then - macrotext = macrotext .. "/equipslot [combat]" .. slot .. " " .. name .. "\n"; - end + + local buttonName,button + for i in pairs(ItemRackUser.Sets) do + if ItemRackUser.Sets[i].key then + buttonName = "ItemRack"..UnitName("player")..GetRealmName()..i + button = _G[buttonName] or CreateFrame("Button",buttonName,nil,"SecureActionButtonTemplate") + + button:SetAttribute("type","macro") + local macrotext = "/script ItemRack.RunSetBinding(\""..i.."\")\n" + for slot = 16, 18 do + if ItemRackUser.Sets[i].equip[slot] then + local name,_,_,_,_,_,_,_,_,_ = GetItemInfo("item:"..ItemRackUser.Sets[i].equip[slot]) + if name then + macrotext = macrotext .. "/equipslot [combat]" .. slot .. " " .. name .. "\n"; end end - button:SetAttribute("macrotext",macrotext) - SetBindingClick(ItemRackUser.Sets[i].key,buttonName) end + button:SetAttribute("macrotext",macrotext) + SetBindingClick(ItemRackUser.Sets[i].key,buttonName) end - local bindingSet = GetCurrentBindingSet() - SaveBindings(bindingSet) - retryCount = 0 end end diff --git a/ItemRack/ItemRackButtons.lua b/ItemRack/ItemRackButtons.lua index a9ddec5..8e682ac 100644 --- a/ItemRack/ItemRackButtons.lua +++ b/ItemRack/ItemRackButtons.lua @@ -354,8 +354,14 @@ end -- updates icons for equipment slots by grabbing the texture directly from the player's worn items function ItemRack.UpdateButtons() for i in pairs(ItemRackUser.Buttons) do + local button = _G["ItemRackButton"..i] if i<20 then - _G["ItemRackButton"..i.."Icon"]:SetTexture(ItemRack.GetTextureBySlot(i)) + SetItemButtonTexture(button, ItemRack.GetTextureBySlot(i)) + + if ItemRack.IsEngravingActive() then + local rune_info = C_Engraving.GetRuneForEquipmentSlot(i) + SetItemButtonSubTexture(button, rune_info and rune_info.iconTexture); + end end --ranged ammo is now infinite, so the below ammo count updater has been commented out if i==0 then --ranged "ammo" slot diff --git a/ItemRack/ItemRackButtons.xml b/ItemRack/ItemRackButtons.xml index d413e80..c627fe6 100644 --- a/ItemRack/ItemRackButtons.xml +++ b/ItemRack/ItemRackButtons.xml @@ -23,7 +23,7 @@ -