Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game tooltips now include info from AtlasLoot about drop source and rate #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Core/AtlasLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ local WHITE = "|cffFFFFFF";
local GREEN = "|cff1eff00";
local PURPLE = "|cff9F3FFF";
local BLUE = "|cff0070dd";
local LIGHTBLUE = "|cff27c0ea";
local ORANGE = "|cffFF8400";
local DEFAULT = "|cffFFd200";

Expand Down Expand Up @@ -271,13 +272,68 @@ function AtlasLoot_OnEvent(event)
--Addons all loaded
if(event == "VARIABLES_LOADED") then
AtlasLoot_OnVariablesLoaded();
AtlasLoot_BuildItemNameMapping()
AtlasLoot_HookGameTooltip();
--Taint errors
elseif(arg1 == "AtlasLoot") then
--Junk command to suppress taint message
local i=3;
end
end

function AtlasLoot_BuildItemNameMapping()
AtlasLoot_ItemNameMapping = {}
local bossIdMapping = {}
for dungeon, bosses in pairs(AtlasLoot_TableNamesBoss) do
for boss, bossInfo in pairs(bosses) do
if type(bossInfo) == "table" then
bossIdMapping[boss] = { dungeon, bossInfo[1] }
end
end
end

for boss, drops in pairs(AtlasLoot_Data["AtlasLootItems"]) do
for _, loot in pairs(drops) do
if (loot[3] and loot[3] ~= "" and bossIdMapping[boss]) then
local itemName = AtlasLoot_removeFormatting(loot[3])
local dungeon = bossIdMapping[boss][1]
local bossName= bossIdMapping[boss][2]

local dropRate = "??%"
if loot[5] then
dropRate = loot[5]
end
AtlasLoot_ItemNameMapping[itemName] = {dungeon, bossName, dropRate}
end
end
end
end

function AtlasLoot_HookGameTooltip()
AtlasLoot_GT_OnShow_Orig = GameTooltip:GetScript("OnShow")
GameTooltip:SetScript( "OnShow", AtlasLoot_GameTooltip_OnShow )
end

function AtlasLoot_GameTooltip_OnShow()
local firstline = getglobal("GameTooltipTextLeft1");

if UnitCreatureType("mouseover") then
return
end

local itemName = firstline:GetText()
local itemInfo = AtlasLoot_ItemNameMapping[itemName]
if (itemInfo) then
GameTooltip:AddLine(GREEN.."AtlasLoot:")
GameTooltip:AddLine(" "..LIGHTBLUE..itemInfo[1].." - "..itemInfo[2].." ("..itemInfo[3]..")")
end

-- call original WoW event for GameTooltip:OnShow()
if AtlasLoot_GT_OnShow_Orig then
MI2_GT_OnShow_Orig(event)
end
end

--[[
AtlasLoot_OnVariablesLoaded:
Invoked by the VARIABLES_LOADED event. Now that we are sure all the assets
Expand Down Expand Up @@ -2148,6 +2204,13 @@ function AtlasLootMinimapButton_SetPosition(v)
AtlasLootMinimapButton_UpdatePosition();
end

function AtlasLoot_removeFormatting(text)
unformatted = gsub(text, "=q%d=", "")
unformatted = gsub(unformatted, "=ds=", "")

return unformatted
end

function strsplit(delim, str, maxNb, onlyLast)
-- Eliminate bad cases...
if string.find(str, delim) == nil then
Expand Down