Skip to content

Commit

Permalink
Re-add missing icons to Classic tooltips (#864)
Browse files Browse the repository at this point in the history
* Re-add missing icons to Classic tooltips

* Comment clarifications
  • Loading branch information
Meorawr authored Apr 29, 2024
1 parent fc01289 commit 343bf76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
11 changes: 3 additions & 8 deletions totalRP3/Core/Globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,12 @@ TRP3_API.globals = {
PSYCHO_MAX_VALUE_V2 = 20,
};

-- TODO: Expansion constants are temporary and can be cleaned up once the next
-- Classic Era patch (1.14.4+/1.15.0) goes live.

local TRP3_EXPANSION_CATACLYSM = LE_EXPANSION_CATACLYSM or 3;
local TRP3_EXPANSION_BATTLE_FOR_AZEROTH = LE_EXPANSION_BATTLE_FOR_AZEROTH or 7;

TRP3_ClientFeatures = {
ChannelBroadcasts = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE),
WarMode = (LE_EXPANSION_LEVEL_CURRENT >= TRP3_EXPANSION_BATTLE_FOR_AZEROTH),
Transmogrification = (LE_EXPANSION_LEVEL_CURRENT >= TRP3_EXPANSION_CATACLYSM),
WarMode = (LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_BATTLE_FOR_AZEROTH),
Transmogrification = (LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_CATACLYSM),
WaterElementalWorkaround = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE),
OldTooltipAPI = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE),
};

TRP3_OOCIndicatorStyle = {
Expand Down
19 changes: 18 additions & 1 deletion totalRP3/Modules/Register/Main/RegisterTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,24 @@ end
---@param texture TextureAssetDisk
---@param options TooltipTextureInfo
function TooltipBuilder:AddTexture(texture, options)
self.tooltip:AddTexture(texture, options);
if not TRP3_ClientFeatures.OldTooltipAPI then
self.tooltip:AddTexture(texture, options);
else
-- In Classic, AddTexture won't work on the first line of the tooltip,
-- which is also coincidentally the only line that we actually care
-- to stick icons on currently.
--
-- Fall back to a legacy |T string prefix approach for this case. Note
-- that we can't use the size values in the options table either, as
-- for some reason they aren't equivalent.

local line = self.tooltip:NumLines();
local leftFontString = TRP3_TooltipUtil.GetLineFontStrings(self.tooltip, line);
local leftText = leftFontString:GetText();
local iconText = string.format("|T%s:%d:%d|t ", texture, 24, 24);

leftFontString:SetText(iconText .. leftText);
end
end

function TooltipBuilder:Build()
Expand Down

0 comments on commit 343bf76

Please sign in to comment.