tukui-org / ElvUI

User Interface replacement AddOn for World of Warcraft.
https://tukui.org
Other
396 stars 136 forks source link

Incorrect tooltip is being used for crit chance DataText on retail #1208

Closed Ikerstreamer closed 1 month ago

Ikerstreamer commented 1 month ago

Troubleshooting Steps

When playing the game in retail and using a DataText for Critical Strike the tooltip used is the one you should be getting in classic.

This gif show how distinctly different Critical Strike is from all other secondary stats. [Image from Gyazo]

Below is an image of how the tooltip is displayed on the character sheet. Image from Gyazo

Here is one more image with the status screen showing that all other addons are turned off. Image from Gyazo

Describe the expected behavior and what actually happened?

This has been bugging me for a while now so I decided to look into the source code and fix the bug myself by copying how haste is done.

In the file ElvUI/ElvUI/Core/Datatexts/Crit.lua, the function OnEvent() does not properly distinguish between classic and retail.

    local format = format
+   local BreakUpLargeNumbers = BreakUpLargeNumbers
    local strjoin = strjoin
    local GetCritChance = GetCritChance
    local GetRangedCritChance = GetRangedCritChance
    local GetCombatRating = GetCombatRating
    local GetCombatRatingBonus = GetCombatRatingBonus
    local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
    local CRIT_ABBR = CRIT_ABBR

    local MELEE_CRIT_CHANCE = MELEE_CRIT_CHANCE
    local CR_CRIT_MELEE_TOOLTIP = CR_CRIT_MELEE_TOOLTIP
    local CR_CRIT_MELEE = CR_CRIT_MELEE
    local CR_CRIT_RANGED = CR_CRIT_RANGED
+   local CR_CRIT_TOOLTIP = CR_CRIT_TOOLTIP

    local displayString, db = ''
    local meleeCrit, rangedCrit, ratingIndex = 0, 0

    local function OnEnter()
        DT.tooltip:ClearLines()
+       if E.Classic then
            DT.tooltip:AddLine(format('%s: %.2f%%', MELEE_CRIT_CHANCE, meleeCrit))
+       else
-       if not E.Classic then
-           DT.tooltip:AddLine(' ')
-           DT.tooltip:AddLine(format(CR_CRIT_MELEE_TOOLTIP, GetCombatRating(ratingIndex), GetCombatRatingBonus(ratingIndex)))

+           DT.tooltip:AddLine(format('|cffFFFFFF%s|r %s%.2F%%|r', MELEE_CRIT_CHANCE, '|cffFFFFFF', meleeCrit))
+           DT.tooltip:AddDoubleLine(format(CR_CRIT_TOOLTIP, BreakUpLargeNumbers(critical) , GetCombatRatingBonus(ratingIndex)))
        end

        DT.tooltip:Show()
    end

If you were to apply this change this tooltip now looks like the image below. Image from Gyazo

This is the same as what the character sheet shows and is no longer mismatched from the other DataTexts.

Reproducing the issue.

No response

Lua Errors

No response

Verification Steps