diff --git a/Modules/votingFrame.lua b/Modules/votingFrame.lua index 2ff6cb04..da982966 100644 --- a/Modules/votingFrame.lua +++ b/Modules/votingFrame.lua @@ -1435,7 +1435,7 @@ function RCVotingFrame.SetCellClass(rowFrame, frame, data, cols, row, realrow, c return end local specID = lootTable[session].candidates[name].specID - local specIcon = specID and select(4, GetSpecializationInfoByID(specID)) + local _, specName, _, specIcon = GetSpecializationInfoByID(specID or 0) if specIcon and db.showSpecIcon then frame:SetNormalTexture(specIcon); frame:GetNormalTexture():SetTexCoord(0, 1, 0, 1); @@ -1443,6 +1443,17 @@ function RCVotingFrame.SetCellClass(rowFrame, frame, data, cols, row, realrow, c addon.SetCellClassIcon(rowFrame, frame, data, cols, row, realrow, column, fShow, table, lootTable[session].candidates[name].class) end data[realrow].cols[column].value = lootTable[session].candidates[name].class or "" + + frame:SetScript("OnLeave", addon.UI.HideTooltip) + frame:SetScript("OnEnter", function() + local class = lootTable[session].candidates[name].class + local classText = addon:WrapTextInClassColor(class, addon.classTagNameToDisplayName[class]) + if specName then + addon:CreateTooltip(addon:AddClassIconToText(class, classText, 16), addon:AddSpecIconToText(specID, specName, 14)) + else + addon:CreateTooltip(addon:AddClassIconToText(class, classText, 16)) + end + end) end function RCVotingFrame.SetCellName(rowFrame, frame, data, cols, row, realrow, column, fShow, table, ...) diff --git a/changelog.md b/changelog.md index 27314058..14e1f3db 100644 --- a/changelog.md +++ b/changelog.md @@ -20,6 +20,10 @@ The tooltip includes specific information as to why it won't do group loot, such Module specific options (show more info, show tooltip, filters, etc) are no longer included in exported/synced profiles. +### Voting Frame + +Hovering a candidate's class/spec icon will now show the name of their current class and spec. + ## Bugfixes - *WuE items will no longer register as BoEs (despite GetItemInfo saying so).* diff --git a/core.lua b/core.lua index 1cc29272..cf6bc939 100644 --- a/core.lua +++ b/core.lua @@ -1199,12 +1199,14 @@ function RCLootCouncil:InitClassIDs() self.classDisplayNameToID = {} -- Key: localized class display name. value: class id(number) self.classTagNameToID = {} -- key: class name in capital english letters without space. value: class id(number) self.classIDToDisplayName = {} -- key: class id. Value: localized name + self.classTagNameToDisplayName = {} --- @type table Class File name to display name self.classIDToFileName = {} -- key: class id. Value: File name for i = 1, self.Utils.GetNumClasses() do local info = C_CreatureInfo.GetClassInfo(i) if info then -- Just in case class doesn't exists #Classic self.classDisplayNameToID[info.className] = i self.classTagNameToID[info.classFile] = i + self.classTagNameToDisplayName[info.classFile] = info.className end end self.classIDToDisplayName = tInvert(self.classDisplayNameToID) @@ -2282,9 +2284,24 @@ function RCLootCouncil:GetClassIconAndColoredName(nameOrPlayer, size) size = size or 12 if not (player and player:GetClass()) then self.Log:E("GetClassIconAndColoredName: No class found for ", nameOrPlayer) - return nameOrPlayer or "" + return nameOrPlayer --[[@as string]] or "" end - return format("|W%s %s|w", CreateAtlasMarkup(self.CLASS_TO_ATLAS[player:GetClass()], size, size), player:GetClassColoredName()) + return format("|W%s|w", self:AddClassIconToText(player:GetClass(), player:GetClassColoredName())) +end + +local classAtlasCache = {} + +--- Adds class icon in front of text. +---@param class ClassFile Class name to add +---@param text string Text +---@param size number? Size of the icon +function RCLootCouncil:AddClassIconToText(class, text, size) + size = size or 12 + local id = class..size + if not classAtlasCache[id] then + classAtlasCache[id] = CreateAtlasMarkup(self.CLASS_TO_ATLAS[class], size, size) + end + return format("%s %s", classAtlasCache[id], text) end --- Creates a string with spec icon in front of a class colored name of the player. @@ -2298,8 +2315,23 @@ function RCLootCouncil:GetSpecIconAndColoredName(nameOrPlayer, size) -- No spec ID, fallback to class return self:GetClassIconAndColoredName(player or nameOrPlayer, size) end - local specIcon = select(4, GetSpecializationInfoByID(player.specID)) - return format("|W%s %s|w", CreateSimpleTextureMarkup(specIcon, size), player:GetClassColoredName()) + return format("|W%s|w", self:AddSpecIconToText(player.specID, player:GetClassColoredName(), size)) +end + +local specIconCache = {} + +---Adds spec icon in front of text. +---@param specID integer SpecID +---@param text string Text +---@param size number? Size of the icon, defaults to 12. +function RCLootCouncil:AddSpecIconToText(specID, text, size) + size = size or 12 + local specIcon = select(4, GetSpecializationInfoByID(specID)) + local id = specIcon .. "-" .. size + if not specIconCache[id] then + specIconCache[id] = CreateSimpleTextureMarkup(specIcon, size) + end + return format("%s %s", specIconCache[id], text) end -- cName is name of the module