3.0.6 update

Added little preview frame for things like tier tokens and sets
added ability to change page with mouse wheel
some minor fixes
This commit is contained in:
Spit
2025-01-04 01:23:43 +03:00
parent 0282c19601
commit 2c4f7d8580
22 changed files with 4003 additions and 1876 deletions
+159 -100
View File
@@ -4,28 +4,28 @@ local AtlasLootTip = CreateFrame("Frame", "AtlasLootTip", GameTooltip)
local GREY = "|cff999999"
local lastSearchName = nil
local lastSearchLink = nil
local function GetItemLinkByName(name)
local lastSearchID = nil
local function GetItemIDByName(name)
if name ~= lastSearchName then
for itemID = 1, 90000 do
local itemName, hyperLink, itemQuality = GetItemInfo(itemID)
for itemID = 1, 99999 do
local itemName = GetItemInfo(itemID)
if (itemName and itemName == name) then
local _, _, _, hex = GetItemQualityColor(tonumber(itemQuality))
lastSearchLink = hex.. "|H"..hyperLink.."|h["..itemName.."]|h|r"
lastSearchID = itemID
break
end
end
lastSearchName = name
end
return lastSearchLink
return lastSearchID
end
local HookSetItemRef = SetItemRef
SetItemRef = function(link, text, button)
local item, _, id = string.find(link, "item:(%d+):.*")
local item, _, id = string.find(link, "item:(%d+)")
ItemRefTooltip.itemID = id
HookSetItemRef(link, text, button)
if not IsShiftKeyDown() and not IsControlKeyDown() and item then
AtlasLootTip.extendTooltip(ItemRefTooltip, "ItemRefTooltip")
AtlasLootTip.extendTooltip(ItemRefTooltip)
end
end
@@ -34,7 +34,7 @@ function GameTooltip.SetHyperlink(self, arg1)
if arg1 then
local _, _, linktype = string.find(arg1, "^(.-):(.+)$")
if linktype == "item" then
local _, _, id = string.find(arg1,"item:(%d+):.*")
local _, _, id = string.find(arg1,"item:(%d+)")
GameTooltip.itemID = id
end
end
@@ -44,7 +44,7 @@ end
local HookSetBagItem = GameTooltip.SetBagItem
function GameTooltip.SetBagItem(self, container, slot)
if GetContainerItemLink(container, slot) then
local _, _, id = string.find(GetContainerItemLink(container, slot),"item:(%d+):.*")
local _, _, id = string.find(GetContainerItemLink(container, slot),"item:(%d+)")
GameTooltip.itemID = id
end
return HookSetBagItem(self, container, slot)
@@ -54,8 +54,7 @@ local HookSetInboxItem = GameTooltip.SetInboxItem
function GameTooltip.SetInboxItem(self, mailID, attachmentIndex)
local itemName = GetInboxItem(mailID)
if itemName then
local _, _, id = string.find(GetItemLinkByName(itemName),"item:(%d+):.*")
GameTooltip.itemID = id
GameTooltip.itemID = GetItemIDByName(itemName)
end
return HookSetInboxItem(self, mailID, attachmentIndex)
end
@@ -63,7 +62,7 @@ end
local HookSetInventoryItem = GameTooltip.SetInventoryItem
function GameTooltip.SetInventoryItem(self, unit, slot)
if GetInventoryItemLink(unit, slot) then
local _, _, id = string.find(GetInventoryItemLink(unit, slot),"item:(%d+):.*")
local _, _, id = string.find(GetInventoryItemLink(unit, slot),"item:(%d+)")
GameTooltip.itemID = id
end
return HookSetInventoryItem(self, unit, slot)
@@ -72,7 +71,7 @@ end
local HookSetCraftItem = GameTooltip.SetCraftItem
function GameTooltip.SetCraftItem(self, skill, slot)
if GetCraftReagentItemLink(skill, slot) then
local _, _, id = string.find(GetCraftReagentItemLink(skill, slot),"item:(%d+):.*")
local _, _, id = string.find(GetCraftReagentItemLink(skill, slot),"item:(%d+)")
GameTooltip.itemID = id
end
return HookSetCraftItem(self, skill, slot)
@@ -82,12 +81,12 @@ local HookSetTradeSkillItem = GameTooltip.SetTradeSkillItem
function GameTooltip.SetTradeSkillItem(self, skillIndex, reagentIndex)
if reagentIndex then
if GetTradeSkillReagentItemLink(skillIndex, reagentIndex) then
local _, _, id = string.find(GetTradeSkillReagentItemLink(skillIndex, reagentIndex),"item:(%d+):.*")
local _, _, id = string.find(GetTradeSkillReagentItemLink(skillIndex, reagentIndex),"item:(%d+)")
GameTooltip.itemID = id
end
else
if GetTradeSkillItemLink(skillIndex) then
local _, _, id = string.find(GetTradeSkillItemLink(skillIndex),"item:(%d+):.*")
local _, _, id = string.find(GetTradeSkillItemLink(skillIndex),"item:(%d+)")
GameTooltip.itemID = id
end
end
@@ -98,8 +97,7 @@ local HookSetAuctionItem = GameTooltip.SetAuctionItem
function GameTooltip.SetAuctionItem(self, atype, index)
local itemName = GetAuctionItemInfo(atype, index)
if itemName then
local _, _, id = string.find(GetItemLinkByName(itemName),"item:(%d+):.*")
GameTooltip.itemID = id
GameTooltip.itemID = GetItemIDByName(itemName)
end
return HookSetAuctionItem(self, atype, index)
end
@@ -108,8 +106,7 @@ local HookSetAuctionSellItem = GameTooltip.SetAuctionSellItem
function GameTooltip.SetAuctionSellItem(self)
local itemName = GetAuctionSellItemInfo()
if itemName then
local _, _, id = string.find(GetItemLinkByName(itemName),"item:(%d+):.*")
GameTooltip.itemID = id
GameTooltip.itemID = GetItemIDByName(itemName)
end
return HookSetAuctionSellItem(self)
end
@@ -117,7 +114,7 @@ end
local HookSetTradePlayerItem = GameTooltip.SetTradePlayerItem
function GameTooltip.SetTradePlayerItem(self, index)
if GetTradePlayerItemLink(index) then
local _, _, id = string.find(GetTradePlayerItemLink(index),"item:(%d+):.*")
local _, _, id = string.find(GetTradePlayerItemLink(index),"item:(%d+)")
GameTooltip.itemID = id
end
return HookSetTradePlayerItem(self, index)
@@ -126,27 +123,51 @@ end
local HookSetTradeTargetItem = GameTooltip.SetTradeTargetItem
function GameTooltip.SetTradeTargetItem(self, index)
if GetTradeTargetItemLink(index) then
local _, _, id = string.find(GetTradeTargetItemLink(index),"item:(%d+):.*")
local _, _, id = string.find(GetTradeTargetItemLink(index),"item:(%d+)")
GameTooltip.itemID = id
end
return HookSetTradeTargetItem(self, index)
end
local sets = {
["SpiritofEskhandar"]=true,
["HakkariBlades"]=true,
["PrimalBlessing"]=true,
["ShardOfGods"]=true,
["DalRend"]=true,
["SpiderKiss"]=true,
["UnobMounts"]=true,
["Legendaries"]=true,
["Artifacts"]=true,
["ZGRings"]=true,
["Tabards"]=true,
}
local function SetContains(set, key)
if not set or not key then
return false
end
return set[key] ~= nil
end
local lastItemID, lastSourceStr, lastDropRate
function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
function AtlasLootTip.extendTooltip(tooltip)
if AtlasLootCharDB.ShowSource ~= true or IsShiftKeyDown() then
return
end
local strfind = string.find
local pairs = pairs
local tooltipName = tooltip:GetName()
local originalTooltip = {}
local itemName = getglobal(tooltipTypeStr .. "TextLeft1"):GetText()
local line2 = getglobal(tooltipTypeStr .. "TextLeft2")
local itemName = getglobal(tooltipName .. "TextLeft1"):GetText()
local line2 = getglobal(tooltipName .. "TextLeft2")
local craftSpell, source, sourceStr, dropRate
local isCraft, isWBLoot, isPvP, isRepReward, isSetPiece, isWorldEvent = false, false, false, false, false, false
if itemName and itemName ~= "Fashion Coin" and tooltip.itemID then
if tooltip.itemID ~= lastItemID then
local itemID = tonumber(tooltip.itemID)
if itemName and itemName ~= "Fashion Coin" and itemID then
if itemID ~= lastItemID then
for row = 1, 30 do
local tooltipRowLeft = getglobal(tooltipTypeStr .. 'TextLeft' .. row)
local tooltipRowLeft = getglobal(tooltipName .. 'TextLeft' .. row)
if tooltipRowLeft then
local rowtext = tooltipRowLeft:GetText()
if rowtext then
@@ -156,47 +177,50 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
end
end
for row=1, table.getn(originalTooltip) do
if string.find(originalTooltip[row].text, "",1,true) then -- skip items that state which rep they require
if strfind(originalTooltip[row].text, "",1,true) then -- skip items that state which rep they require
return
end
end
-- first check if its craftable item
for k,v in pairs(GetSpellInfoAtlasLootDB["craftspells"]) do
if v["craftItem"] == tonumber(tooltip.itemID) then
if v["craftItem"] == itemID then
craftSpell = "s"..tostring(k)
end
end
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootCrafting"]) do
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootCrafting"][k1]) do
for k1, v1 in pairs(AtlasLoot_Data["AtlasLootCrafting"]) do
if source then
break
end
for k2, v2 in pairs(AtlasLoot_Data["AtlasLootCrafting"][k1]) do
if v2[1] ~= 0 and v2[1] ~= "" and string.sub(v2[1], 1, 1) ~= "e" then
if (v2[1] == craftSpell or v2[1] == tonumber(tooltip.itemID))
and
(string.find(k1, "Apprentice",1,true) or
string.find(k1, "Journeyman",1,true) or
string.find(k1, "Expert",1,true) or
string.find(k1, "Artisan",1,true) or
string.find(k1, "Goblin",1,true) or
string.find(k1, "Gnomish",1,true) or
string.find(k1, "Survival",1,true) or
string.find(k1, "Herbalism",1,true) or
string.find(k1, "FirstAid",1,true) or
string.find(k1, "Poisons",1,true) or
string.find(k1, "Mining",1,true) or
string.find(k1, "Smelting",1,true) or
string.find(k1, "Elemental",1,true) or
string.find(k1, "Tribal",1,true) or
string.find(k1, "Dragonscale",1,true)or
string.find(k1, "Weaponsmith",1,true)or
string.find(k1, "Axesmith",1,true)or
string.find(k1, "Hammersmith",1,true)or
string.find(k1, "Swordsmith",1,true)or
string.find(k1, "Armorsmith",1,true)or
string.find(k1, "Gemology",1,true)or
string.find(k1, "Goldsmithing",1,true))
if (v2[1] == craftSpell or v2[1] == itemID) and
(strfind(k1, "Apprentice", 1, true) or
strfind(k1, "Journeyman", 1, true) or
strfind(k1, "Expert", 1, true) or
strfind(k1, "Artisan", 1, true) or
strfind(k1, "Goblin", 1, true) or
strfind(k1, "Gnomish", 1, true) or
strfind(k1, "Survival", 1, true) or
strfind(k1, "Herbalism", 1, true) or
strfind(k1, "FirstAid", 1, true) or
strfind(k1, "Poisons", 1, true) or
strfind(k1, "Mining", 1, true) or
strfind(k1, "Smelting", 1, true) or
strfind(k1, "Elemental", 1, true) or
strfind(k1, "Tribal", 1, true) or
strfind(k1, "Dragonscale", 1, true) or
strfind(k1, "Weaponsmith", 1, true) or
strfind(k1, "Axesmith", 1, true) or
strfind(k1, "Hammersmith", 1, true) or
strfind(k1, "Swordsmith", 1, true) or
strfind(k1, "Armorsmith", 1, true) or
strfind(k1, "Gemology", 1, true) or
strfind(k1, "Goldsmithing", 1, true))
then
source = k1
isCraft = true
lastDropRate = nil
break
end
end
end
@@ -204,8 +228,11 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
-- check if its world boss loot
if not isCraft then
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootWBItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootWBItems"][k1]) do
if v2[1] == tonumber(tooltip.itemID) then
if v2[1] == itemID then
source = k1
isWBLoot = true
if v2[5] then
@@ -214,6 +241,7 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
else
lastDropRate = nil
end
break
end
end
end
@@ -221,11 +249,15 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
-- check if its a pvp reward
if not isCraft and not isWBLoot then
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootGeneralPvPItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootGeneralPvPItems"][k1]) do
if v2[1] == tonumber(tooltip.itemID) then
if v2[1] == itemID then
source = k1
isPvP = true
lastDropRate = nil
break
end
end
end
@@ -234,8 +266,11 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
-- bgs
if not isCraft and not isWBLoot and not isPvP then
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootBGItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootBGItems"][k1]) do
if v2[1] == tonumber(tooltip.itemID) then
if v2[1] == itemID then
source = k1
isRepReward = true
if v2[5] then
@@ -244,21 +279,26 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
else
lastDropRate = nil
end
break
end
end
end
-- factions
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootRepItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootRepItems"][k1]) do
if v2[1] == tonumber(tooltip.itemID) then
if v2[1] == itemID then
source = k1
isRepReward = true
if v2[5] and source ~= "Darkmoon" and not string.find(source, "Cenarion",1,true) then
if v2[5] and source ~= "Darkmoon" and not strfind(source, "Cenarion",1,true) then
dropRate = v2[5]
lastDropRate = dropRate
else
lastDropRate = nil
end
break
end
end
end
@@ -266,25 +306,19 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
-- check if its a set piece
if not isCraft and not isWBLoot and not isPvP and not isRepReward then
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootSetItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootSetItems"][k1]) do
if v2[1] == tonumber(tooltip.itemID) then
if v2[1] == itemID then
source = k1
isSetPiece = true
if (source == "SpiritofEskhandar" or
source == "HakkariBlades" or
source == "PrimalBlessing" or
source == "ShardOfGods" or
source == "DalRend" or
source == "SpiderKiss" or
source == "UnobMounts" or
source == "Legendaries" or
source == "Artifacts" or
source == "ZGRings" or
source == "Tabards" or string.find(source, "WorldEpics",1,true)) then
if (SetContains(sets, source) or strfind(source, "WorldEpics",1,true)) then
source = nil
isSetPiece = false
end
lastDropRate = nil
break
end
end
end
@@ -292,12 +326,12 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
-- check world events
if not isCraft and not isWBLoot and not isPvP and not isRepReward and not isSetPiece then
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootWorldEvents"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootWorldEvents"][k1]) do
if v2[1] == tonumber(tooltip.itemID) and string.find(v2[3], itemName, 1, true) then
if v2[1] == itemID then
source = k1
if source == "WintervielSnowball" and not (tonumber(tooltip.itemID) == 51249 or tonumber(tooltip.itemID) == 61089) then
return
end
isWorldEvent = true
if v2[5] then
dropRate = v2[5]
@@ -305,6 +339,7 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
else
lastDropRate = nil
end
break
end
end
end
@@ -312,34 +347,59 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
-- check if its a dungeon/raid loot
if not isCraft and not isWBLoot and not isPvP and not isRepReward and not isWorldEvent and not isSetPiece then
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootItems"][k1]) do
if v2[1] ~= 0 then
if v2[1] == tonumber(tooltip.itemID) then
if k1 ~= "VanillaKeys" then
source = k1
if v2[1] == itemID then
if k1 ~= "VanillaKeys" then
source = k1
end
if v2[5] then
dropRate = v2[5]
lastDropRate = dropRate
else
lastDropRate = nil
end
break
end
end
end
-- check containers
for k1,v1 in pairs(AtlasLoot_Data["AtlasLootItems"]) do
if source then
break
end
for k2,v2 in pairs(AtlasLoot_Data["AtlasLootItems"][k1]) do
if source then
break
end
if v2[16] then
for i, n in pairs(v2[16]) do
if source then
break
end
if v2[5] then
dropRate = v2[5]
lastDropRate = dropRate
else
lastDropRate = nil
for i2, n2 in pairs(v2[16][i]) do
if v2[16][i][i2][1] == itemID then
source = k1
break
end
end
end
end
end
end
end
lastItemID = tooltip.itemID
lastItemID = itemID
if not source then
lastSourceStr = nil
return
end
for k,v in pairs(AtlasLoot_TableNames) do
if k == source then
sourceStr = AtlasLoot_TableNames[k][1]
lastSourceStr = sourceStr
break
end
end
@@ -360,8 +420,7 @@ function AtlasLootTip.extendTooltip(tooltip, tooltipTypeStr)
tooltip:AddLine(GREY..sourceStr.."|r")
end
end
elseif tooltip.itemID == lastItemID then
elseif itemID == lastItemID then
if lastSourceStr then
if line2:GetText() then
if lastDropRate then
@@ -388,7 +447,7 @@ AtlasLootTip:SetScript("OnHide", function()
end)
AtlasLootTip:SetScript("OnShow", function()
AtlasLootTip.extendTooltip(GameTooltip, "GameTooltip")
AtlasLootTip.extendTooltip(GameTooltip)
end)
-- adapted from http://shagu.org/ShaguTweaks/
@@ -399,10 +458,10 @@ AtlasLootTip.HookAddonOrVariable = function(addon, func)
lurker:RegisterEvent("VARIABLES_LOADED")
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
lurker:SetScript("OnEvent",function()
if IsAddOnLoaded(addon) or getglobal(addon) then
this:func()
this:UnregisterAllEvents()
end
if IsAddOnLoaded(addon) or getglobal(addon) then
this:func()
this:UnregisterAllEvents()
end
end)
end
@@ -410,10 +469,10 @@ AtlasLootTip.HookAddonOrVariable("Tmog", function()
local tmog = CreateFrame("Frame", nil, TmogTooltip)
tmog:SetScript("OnHide", function()
for row=1, 30 do
getglobal("TmogTooltip" .. 'TextRight' .. row):SetText("")
getglobal("TmogTooltipTextRight" .. row):SetText("")
end
end)
tmog:SetScript("OnShow", function()
AtlasLootTip.extendTooltip(TmogTooltip, "TmogTooltip")
AtlasLootTip.extendTooltip(TmogTooltip)
end)
end)