From 331b1a5c71162e29b174065e69426fae5fb9e2ff Mon Sep 17 00:00:00 2001 From: Sluimerstand Date: Sun, 24 Nov 2024 16:40:23 +0100 Subject: [PATCH] Customisations and spellbooks are now also supported --- Database.lua | 1 + modules/ItemOverlay.lua | 93 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/Database.lua b/Database.lua index 9d45a37..2605779 100644 --- a/Database.lua +++ b/Database.lua @@ -102,6 +102,7 @@ app.Icon = { ["Recipe"] = "Interface\\Icons\\inv_misc_note_01", ["ProfessionKnowledge"] = "Interface\\Icons\\inv_cosmicvoid_orb", + ["Customisation"] = "Interface\\Icons\\inv_10_jewelcrafting_gem1leveling_uncut_transparent", ["Container"] = "Interface\\Icons\\inv_misc_bag_16", ["Unknown"] = "Interface\\Icons\\inv_misc_questionMark", } diff --git a/modules/ItemOverlay.lua b/modules/ItemOverlay.lua index 9a9ae57..9830335 100644 --- a/modules/ItemOverlay.lua +++ b/modules/ItemOverlay.lua @@ -53,6 +53,12 @@ function app.TooltipInfo() return end + -- Filter out recipe "books" that aren't associated with any profession + local _, _, _, _, _, _, _, _, _, _, _, classID, subclassID = C_Item.GetItemInfo(itemID) + if classID == 9 and subclassID == 0 then + return + end + -- Only run this if the item is known to be a recipe if app.RecipeItem[itemID] then local recipeID = app.RecipeItem[itemID] @@ -225,8 +231,12 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo) break end end - -- Check for profession knowledge items + -- Class books + elseif classID == 9 and subclassID == 0 then + itemEquipLoc = "Customisation" + -- Check for other item types else + -- Profession Knowledge local localeProfessionKnowledge = { "Use: Study to increase your", "Benutzen: Studieren, um Euer", @@ -244,6 +254,26 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo) break end end + + -- Customisations + local localeCustomisations = { + "Use: Unlock", + "Benutzen: Schaltet", + "Uso: Desbloquea", + "Utilise: Débloque", + "Usa: Sblocca", + "Uso: Desbloqueia", + "Использование: Открывает", + "잠금 해제", + "지를 잠금 해제합니다.", + "解锁", + } + for k, v in pairs(localeCustomisations) do + if app.GetTooltipText(itemLink, v) then + itemEquipLoc = "Customisation" + break + end + end end -- Cache this info, so we don't need to check it again @@ -304,12 +334,17 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo) end -- Ensembles elseif TransmogLootHelper_Settings["iconNewMog"] and itemEquipLoc == "Ensemble" then + -- Learned if app.GetTooltipText(itemLink, ITEM_SPELL_KNOWN) then if TransmogLootHelper_Settings["iconLearned"] then showOverlay("green") else hideOverlay() end + -- Unusable + elseif app.GetTooltipRedText(itemLink) then + showOverlay("red") + -- Unlearned else showOverlay("purple") end @@ -322,22 +357,26 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo) else hideOverlay() end + -- Unusable + elseif app.GetTooltipRedText(itemLink) then + showOverlay("red") -- Unlearned else - if app.GetTooltipRedText(itemLink) then - showOverlay("red") - else - showOverlay("purple") - end + showOverlay("purple") end -- Mounts elseif TransmogLootHelper_Settings["iconNewMount"] and itemEquipLoc == "Mount" then + -- Learned if app.GetTooltipText(itemLink, ITEM_SPELL_KNOWN) then if TransmogLootHelper_Settings["iconLearned"] then showOverlay("green") else hideOverlay() end + -- Unusable + elseif app.GetTooltipRedText(itemLink) then + showOverlay("red") + -- Unlearned else showOverlay("purple") end @@ -409,6 +448,22 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo) -- Profession Knowledge elseif TransmogLootHelper_Settings["iconUsable"] and itemEquipLoc == "ProfessionKnowledge" then showOverlay("yellow") + -- Customisations (includes spellbooks) + elseif TransmogLootHelper_Settings["iconUsable"] and itemEquipLoc == "Customisation" then + -- Learned + if app.GetTooltipText(itemLink, ITEM_SPELL_KNOWN) or TransmogLootHelper_Cache.Recipes[app.RecipeItem[itemID]] then + if TransmogLootHelper_Settings["iconLearned"] then + showOverlay("green") + else + hideOverlay() + end + -- Unusable + elseif app.GetTooltipRedText(itemLink) then + showOverlay("red") + -- Unlearned + else + showOverlay("purple") + end -- Containers elseif TransmogLootHelper_Settings["iconContainer"] and itemEquipLoc == "Container" then if not containerInfo then @@ -897,9 +952,9 @@ function app.ItemOverlayHooks() app.Event:Register("AUCTION_HOUSE_THROTTLED_SYSTEM_READY", auctionHouseOverlay) - -- Update our overlays if a mog or recipe is learned + -- Update our overlay if a mog, recipe, or spell is learned function api.UpdateOverlay() - C_Timer.After(0.1, function() + C_Timer.After(1, function() -- bagsOverlay() reagentBankOverlay() warbankOverlay() @@ -920,6 +975,26 @@ function app.ItemOverlayHooks() TransmogLootHelper_Cache.Recipes[recipeID] = true -- Also cache the recipe as learned, otherwise updating the overlay won't do much good api.UpdateOverlay() end) + + -- Cache player spells, for books that teach these + local function cacheSpells() + C_Timer.After(0.9, function() + for k, v in pairs(app.RecipeItem) do + if IsSpellKnown(v) or IsPlayerSpell(v) then + TransmogLootHelper_Cache.Recipes[v] = true + end + end + end) + end + + app.Event:Register("PLAYER_ENTERING_WORLD", function(isInitialLogin, isReloadingUi) + cacheSpells() + end) + + app.Event:Register("SPELLS_CHANGED", function() + cacheSpells() + api.UpdateOverlay() + end) end end @@ -1024,7 +1099,7 @@ function app.SettingsItemOverlay() local setting = Settings.RegisterAddOnSetting(category, appName.."_"..variable, variable, TransmogLootHelper_Settings, Settings.VarType.Boolean, name, true) Settings.CreateCheckbox(category, setting, tooltip) - local variable, name, tooltip = "iconUsable", "Usable Items", "Show an icon to indicate an item can be used (currently only Profession Knowledge items)." + local variable, name, tooltip = "iconUsable", "Usable Items", "Show an icon to indicate an item can be used (profession knowledge, unlockable customisations, and spellbooks)." local setting = Settings.RegisterAddOnSetting(category, appName.."_"..variable, variable, TransmogLootHelper_Settings, Settings.VarType.Boolean, name, true) Settings.CreateCheckbox(category, setting, tooltip)