Displaying M+ loot table

I eventually have to check mythicpl.us to see whats the ilvl reward for a certain dungeon I'm applying for, or what key should I aim to get a certain ilvl gear. This got old fast, I hate alt tabbing.

My idea was to add a tooltip to the dungeon finder window, similar to how the raider.io addon does, but displaying the table from https://mythicpl.us/ :


0 340 - -
2 345 355 340
3 345 355 340
4 350 360 355
5 355 360 355
6 355 365 355
7 360 370 370
8 365 370 370
9 365 375 370
10+*370 380 385


My questions:
1) How do I create such tooltip? I'm reading through raider.io code to understand how they do it, but I have yet to find it.
2) How do I attach this tooltip to that window?
Okay, this is coming from someone with more than 25 years in IT and I've seen this problem before.

That's a very discrete table with very clear, very limited information on it.

If it were me, I would simply format it neatly, print it out, and use some cellophane tape to stick the thing on the my monitor (top, bottom, or side, depending on how your rig is laid out).

The effort of putting that into a tooltip versus just doing the print-it-and-tape-it thing just doesn't seem justified.
But that would benefit only myself.
I eventually have to check mythicpl.us to see whats the ilvl reward for a certain dungeon I'm applying for, or what key should I aim to get a certain ilvl gear. This got old fast, I hate alt tabbing.
I'm sorry, but I did see a reference to doing this for anyone else's benefit. I apologize.
1 Like
Paste the following into the website addon.bool.no to create your addon.
Fill in the lines I was too lazy to do.
It will show a tooltip when you mouse over the eye (Topleft)
local f = CreateFrame("Frame", nil, PVEFrame)
f:SetPoint("TOPLEFT", PVEFramePortrait)
f:SetPoint("BOTTOMRIGHT", PVEFramePortrait)
f:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetText("0 340 - -")
GameTooltip:AddLine("2 345 355 340")
GameTooltip:AddLine("3 345 355 340")
GameTooltip:AddLine(" ... ")
GameTooltip:AddLine("10+* 370 380 385")
GameTooltip:Show()
end)
f:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)


I'm not sure which is easier or more useful ;)
09/18/2018 11:57 AMPosted by Ehiztari
I eventually have to check mythicpl.us to see whats the ilvl reward for a certain dungeon I'm applying for, or what key should I aim to get a certain ilvl gear. This got old fast, I hate alt tabbing.
I'm sorry, but I did see a reference to doing this for anyone else's benefit. I apologize.


Well, sorry. But I assumed that making an addon only for myself wouldnt make sense.
09/18/2018 02:11 PMPosted by Ezmeralda
Well, sorry. But I assumed that making an addon only for myself wouldnt make sense.
I make add-ons for myself all the time. I know others who do as well. Partly that's because they're very narrowly tailored add-ons and partly that's because I don't want to deal with the additional technical burden of figuring out the packaging at Curse and partly that's because I don't want to have to maintain them over time (if Blizzard yanks the rug out from under my code too badly, I can abandon the add-on with a clean conscience - without messing up anyone else's play who might have become dependent on it).
09/18/2018 01:03 PMPosted by Fizzlemizz
Paste the following into the website addon.bool.no to create your addon.
Fill in the lines I was too lazy to do.
It will show a tooltip when you mouse over the eye (Topleft)
local f = CreateFrame("Frame", nil, PVEFrame)
f:SetPoint("TOPLEFT", PVEFramePortrait)
f:SetPoint("BOTTOMRIGHT", PVEFramePortrait)
f:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetText("0 340 - -")
GameTooltip:AddLine("2 345 355 340")
GameTooltip:AddLine("3 345 355 340")
GameTooltip:AddLine(" ... ")
GameTooltip:AddLine("10+* 370 380 385")
GameTooltip:Show()
end)
f:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)


I'm not sure which is easier or more useful ;)


wow, thanks a lot!
Just for learning purposes, why f:SetPoint twice?
The two setpoints are making the frame the same position and size as the portrait texture ie, it's setting the top left point of the frame to the top left point of the texture, the second is stretching the bottom right of the frame to the bottom right point of the texture.

It's the same as
f:SetSize(PVEFramePortrait:GetSize())
f:SetPoint("CENTER", PVEFramePortrait)


Without a :ClearAllPoints() :SetPoint() will just keep adjusting the various points without altering those already set.
https://imgur.com/a/jdkV6p3

Its almost ok... i just want to move it down a bit, so it can be ligned up with the top of the pveframe.
Also, how could I properly format the information in the window?

My current code:
local lootTable = CreateFrame("Frame", nil, PVEFrame)
lootTable:SetPoint("TOPLEFT", PVEFrame)
lootTable:SetPoint("BOTTOMRIGHT", PVEFrame)
lootTable:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetText("Key Loot Cache Azerite")
GameTooltip:AddLine(" 0 340 - - ")
GameTooltip:AddLine(" 2 345 355 340")
GameTooltip:AddLine(" 3 345 355 340")
GameTooltip:AddLine(" 4 350 360 355")
GameTooltip:AddLine(" 5 355 360 355")
GameTooltip:AddLine(" 6 355 365 360")
GameTooltip:AddLine(" 7 360 370 370")
GameTooltip:AddLine(" 8 365 370 370")
GameTooltip:AddLine(" 9 365 375 370")
GameTooltip:AddLine("10+ 370 380 385")
GameTooltip:Show()
end)
Change:
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
To:
GameTooltip:SetOwner(self, "ANCHOR_NONE")
GameTooltip:SetPoint("TOPLEFT", PVEFrame, "TOPRIGHT")


As for the formatting, that's probably the best you will get for multi column alignment without getting a whole lot more complicated. Lua doesn't treat multiple spaces in text strings as "hard".
The more complicated version.
local stringtable = {
{ " Key ", " Loot ", " Cache ", " Azerite " },
{ "0", "340", "-", "-" },
{ "2", "345", "355", "340" },
{ "3", "345", "355", "340" },
{ "4", "350", "360", "355" },
{ "5", "355", "360", "355" },
{ "6", "355", "365", "360" },
{ "7", "360", "370", "370" },
{ "8", "365", "370", "370" },
{ "9", "365", "375", "370" },
{ "10+", "370", "380", "385" },
}

local lootTable = CreateFrame("Frame", nil, PVEFrame)
lootTable:SetPoint("TOPLEFT", PVEFrame)
lootTable:SetPoint("BOTTOMRIGHT", PVEFrame)

local viewtable
local function CreateViewTable(addbackground)
viewtable = CreateFrame("Frame", "MythciPlusLootzViewer", UIParent)
viewtable:SetSize(50, 50)
viewtable:Hide()
viewtable:SetPoint("TOPLEFT", PVEFrame, "TOPRIGHT")
local last, lastline
local widths = {}
for i=1, #stringtable do
for t=1, #stringtable[i] do
local s = viewtable:CreateFontString()
s:SetFontObject(GameFontNormalLarge)
if i == 1 then
s:SetTextColor(1, 1, 1)
else
s:SetTextColor(1, 1, 0)
end
s:SetText(stringtable[i][t])
if i == 1 and t == 1 then
s:SetPoint("TOPLEFT", viewtable)
viewtable.first = s
elseif t == 1 then
s:SetPoint("TOPLEFT", lastline, "BOTTOMLEFT")
else
s:SetPoint("LEFT", last, "RIGHT")
end
if i == 1 then
widths[t] = s:GetWidth()
else
s:SetWidth(widths[t])
end
last = s
if t == 1 then
lastline = s
end
end
end
if addbackground then
local width = 0
for i=1, #widths do
width = width + widths[i]
end
viewtable:SetSize(width + 10, (last:GetHeight() * #stringtable) + 10)
local backdrop = {
bgFile = "Interface/BUTTONS/WHITE8X8",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true,
edgeSize = 7,
tileSize = 7,
insets = {
left = 2,
right = 2,
top = 2,
bottom = 2,
},
}
viewtable:SetBackdrop(backdrop)
viewtable:SetBackdropColor(0, 0, 0)
viewtable.first:ClearAllPoints()
viewtable.first:SetPoint("TOPLEFT", 5, -5)
end
end
lootTable:SetScript("OnEnter", function(self)
if not viewtable then CreateViewTable() end
viewtable:Show()
end)
lootTable:SetScript("OnLeave", function(self)
viewtable:Hide()
end)


If you want the table to have a background, change:
if not viewtable then CreateViewTable() end
to:
if not viewtable then CreateViewTable(true) end
If the numbers get longer than the titles you may have to get creative with the title names or fix the FontString widths when creating row 1 (they determine the column widths) otherwise you should be able to just add/remove columns or rows, change titles/values to stringtable as needed.
That looks pretty amazing, ty a lot.
But the tooltip isnt fadding once I close the pveframe.

EDIT: I fixed it, just had some lines from previous code breaking it.
But now the cool tooltip background is gone.
I added an optional background with the last version of the code.

If you want the table to have a background, change:
if not viewtable then CreateViewTable() end
to:
if not viewtable then CreateViewTable(true) end
Thanks a lot again. I will credit you for everything.

The frame shows up when I mouseover inside the pveframe, and hides when I mouse out. I wish it would load when I open the pveframe, and only hide when the pveframe is closed.

Also, how could I add some paddin to left and top of the frame? I tried by changing the inset values, but that didnt work.

https://imgur.com/a/ur2dnlt
local rewards = {
{ " Key ", " Loot ", " Cache ", " Azerite " },
{ "0", "340", "-", "-" },
{ "2", "345", "355", "340" },
{ "3", "345", "355", "340" },
{ "4", "350", "360", "355" },
{ "5", "355", "360", "355" },
{ "6", "355", "365", "360" },
{ "7", "360", "370", "370" },
{ "8", "365", "370", "370" },
{ "9", "365", "375", "370" },
{ "10+", "370", "380", "385" },
}

local mplustable = CreateFrame("Frame", "MythciPlusLootzViewer", PVEFrame)
mplustable:SetSize(50, 50)
mplustable:SetPoint("TOPLEFT", PVEFrame, "TOPRIGHT")
local last, lastline
local widths = {}
for i=1, #rewards do
for t=1, #rewards[i] do
local s = mplustable:CreateFontString()
s:SetFontObject(GameFontNormalLarge)
if i == 1 then
s:SetTextColor(1, 1, 1)
else
s:SetTextColor(1, 1, 0)
end
s:SetText(rewards[i][t])
if i == 1 and t == 1 then
s:SetPoint("TOPLEFT", mplustable)
mplustable.first = s
elseif t == 1 then
s:SetPoint("TOPLEFT", lastline, "BOTTOMLEFT")
else
s:SetPoint("LEFT", last, "RIGHT")
end
if i == 1 then
widths[t] = s:GetWidth()
else
s:SetWidth(widths[t])
end
last = s
if t == 1 then
lastline = s
end
end
end
local width = 0
for i=1, #widths do
width = width + widths[i]
end
mplustable:SetSize(width + 10, (last:GetHeight() * #rewards) + 10)
local backdrop = {
bgFile = "Interface/BUTTONS/WHITE8X8",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true,
edgeSize = 7,
tileSize = 7,
insets = {
left = 2,
right = 2,
top = 2,
bottom = 2,
},
}
mplustable:SetBackdrop(backdrop)
mplustable:SetBackdropColor(0, 0, 0)
mplustable.first:ClearAllPoints()
mplustable.first:SetPoint("TOPLEFT", 5, -5)
I cant see a difference regarding the displaying on mouseover. I will try text-comparing once I get home.

Also, how could I add some paddin to left and top of the frame? I tried by changing the inset values, but that didnt work.

Is there a better way for freshing the addon changes in game, instead of /reload the entire UI?

Is there a better source to learn this stuff, like you did, than http://wowwiki.wikia.com/wiki/World_of_Warcraft_API ?
Replace everything you had from the previous post with the code from the last. The last one has no mouseover at all, it just parents to the PVEFrame so it shows/hides when the PVEFrame does.

To adjust the padding, increase the 5 and 5 numbers in
mplustable.first:SetPoint("TOPLEFT", 5, -5)
and increase the 10 and 10 numbers in
mplustable:SetSize(width + 10, (last:GetHeight() * #rewards) + 10)
so they are twice the size of the numbres in the SetPoint line.

Adding in-game adjustments would require a mechanism to input a new table, save the new table for using next time, rebuild the display list with adjustments if there is any substantial difference ...

Learning lua and the WoW API mostly comes from looking at other addons or code created by Blizzard that makes up the entire default UI.
https://wow.gamepedia.com/Viewing_Blizzard%27s_interface_code

Useful sites like
https://wow.gamepedia.com/World_of_Warcraft_API

If you want to get into the nitty gritty of lua then
https://www.lua.org/start.html
NOTE: WoW uses lua version 5.1 as at the time of posting.

After that, it's trial and error and asking questions, usually in that order :).
Thanks a lot.
Btw, is there a way to check if a certain addon is loaded?
My loot table looks fine when raider.io windows is showing, but its floating in mid air when not. I'd like to adjust its position if raider.io isnt showing up or loaded.
You can force an addon to wait for another addon to load first by adding...## Dependencies: OtherAddOn...to the *.toc file.

If you're not sure the other addon WILL be loaded but IF it's loaded it needs to load first, you can use...## OptionalDeps: OtherAddOn...instead.

I'm not certain what to do if the addon you're wanting to be sure is there first is itself only conditionally loaded, though.