Commit da47561c authored by Simpy's avatar Simpy 🐹

fix dt tooltip jumping to a panel which has the same dt

- this requires dts to update their code and put "DT.tooltip:ClearLines()" in the "OnEnter" for most datatexts
parent 909ec95c
......@@ -20,8 +20,8 @@ local function OnEvent(self)
lastPanel = self
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
DT.tooltip:AddLine(L["Mitigation By Level: "])
DT.tooltip:AddLine(' ')
......@@ -37,8 +37,6 @@ local function OnEnter(self)
local armorReduction = PaperDollFrame_GetArmorReduction(effectiveArmor, lv)
DT.tooltip:AddDoubleLine(lv, format(chanceString, armorReduction),1,1,1)
end
DT.tooltip:Show()
end
local function ValueColorUpdate(hex)
......
......@@ -86,8 +86,8 @@ local function OnEvent(self)
lastPanel = self
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local rightString = targetlv > 1 and strjoin('', ' (', L['lvl'], ' ', targetlv, ')') or targetlv == -1 and strjoin('', ' (', BOSS, ')') or strjoin('', ' (', L['lvl'], ' ', playerlv, ')')
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], rightString)
......@@ -100,7 +100,6 @@ local function OnEnter(self)
DT.tooltip:AddLine(' ')
DT.tooltip:AddDoubleLine(L["Unhittable:"], (unhittable > 0 and '+' or '')..format(chanceString, unhittable), 1, 1, 1, (unhittable < 0 and 1 or 0), (unhittable > 0 and 1 or 0), 0)
DT.tooltip:Show()
end
local function ValueColorUpdate(hex)
......
......@@ -30,8 +30,8 @@ local function OnClick()
ToggleAllBags()
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
for i = 0, NUM_BAG_SLOTS do
local bagName = GetBagName(i)
......@@ -62,8 +62,6 @@ local function OnEnter(self)
DT.tooltip:AddDoubleLine(format(iconString, icon, name), count, 1, 1, 1, 1, 1, 1)
end
end
DT.tooltip:Show()
end
local function ValueColorUpdate(hex)
......
......@@ -60,8 +60,6 @@ local function columnSort(lhs,rhs)
end
function DT:HoverBattleStats()
DT:SetupTooltip(self)
if myIndex and DT.ShowingBattleStats == 'pvp' then
local columns = C_PvP_GetMatchPVPStatColumns()
if columns then
......@@ -83,8 +81,6 @@ function DT:HoverBattleStats()
DT.tooltip:AddDoubleLine(name, GetBattlefieldStatData(myIndex, i), 1,1,1)
end
end
DT.tooltip:Show()
end
end
end
......
......@@ -82,12 +82,11 @@ local function ValueColorUpdate(hex)
end
E.valueColorUpdateFuncs[ValueColorUpdate] = true
local function OnEnter(self)
if not enteredFrame then
enteredFrame = true
end
local function OnEnter()
DT.tooltip:ClearLines()
enteredFrame = true
DT:SetupTooltip(self)
local numCTA = 0
local addTooltipHeader = true
for i=1, GetNumRandomDungeons() do
......@@ -146,8 +145,6 @@ local function OnEnter(self)
if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
end
end
DT.tooltip:Show()
end
local updateInterval = 10
......@@ -166,7 +163,6 @@ local function Update(self, elapsed)
end
local function OnLeave()
DT.tooltip:Hide()
enteredFrame = false
end
......
......@@ -14,12 +14,11 @@ local lastPanel
local function OnEvent(self)
lastPanel = self
self.text:SetFormattedText(displayString, configText)
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
DT.tooltip:AddDoubleLine(L["Left Click:"], L["Toggle Configuration"], 1, 1, 1)
DT.tooltip:AddDoubleLine(L["Hold Shift + Right Click:"], reloadText, 1, 1, 1)
......@@ -35,8 +34,6 @@ local function OnEnter(self)
end
end
end
DT.tooltip:Show()
end
local function Click(_, button)
......
......@@ -25,8 +25,8 @@ local SPELL_CRIT_CHANCE = SPELL_CRIT_CHANCE
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
local displayString, lastPanel = ''
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local text, tooltip
if E.role == "Caster" then
......@@ -44,7 +44,6 @@ local function OnEnter(self)
DT.tooltip:AddDoubleLine(text, nil, 1, 1, 1)
DT.tooltip:AddLine(tooltip, nil, nil, nil, true)
DT.tooltip:Show()
end
local function OnEvent(self)
......
......@@ -68,8 +68,8 @@ local function OnEvent(self)
end
local faction = (E.myfaction == 'Alliance' and 1717) or 1716
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
DT.tooltip:AddDoubleLine(L["Gold"]..':', goldText, nil, nil, nil, 1, 1, 1)
DT.tooltip:AddLine(' ')
......@@ -105,8 +105,6 @@ local function OnEnter(self)
end
end
end
DT.tooltip:Show()
end
DT:RegisterDatatext('Currencies', nil, {'PLAYER_MONEY', 'SEND_MAIL_MONEY_CHANGED', 'SEND_MAIL_COD_CHANGED', 'PLAYER_TRADE_MONEY', 'TRADE_MONEY_CHANGED', 'CHAT_MSG_CURRENCY', 'CURRENCY_DISPLAY_UPDATE'}, OnEvent, nil, OnClick, OnEnter, nil, _G.CURRENCY)
......@@ -38,13 +38,14 @@ local function OnEvent(self)
end
local function OnEnter(self)
if not CustomCurrencies[self.name].USE_TOOLTIP then return; end
local index = CurrencyListNameToIndex[self.name]
if not index then return; end
DT.tooltip:ClearLines()
local currency = CustomCurrencies[self.name]
if not currency or not currency.USE_TOOLTIP then return end
DT:SetupTooltip(self)
local index = CurrencyListNameToIndex[self.name]
if not index then return end
DT.tooltip:SetCurrencyToken(index)
DT.tooltip:Show()
end
local function AddCurrencyNameToIndex(name)
......
......@@ -30,6 +30,9 @@ local GetSpecializationInfo = GetSpecializationInfo
local ActivateHyperMode
local HyperList = {}
DT.tooltip = CreateFrame('GameTooltip', 'DataTextTooltip', E.UIParent, 'GameTooltipTemplate')
DT.EasyMenu = CreateFrame('Frame', 'DataTextEasyMenu', E.UIParent, 'UIDropDownMenuTemplate')
DT.SelectedDatatext = nil
DT.HyperList = HyperList
DT.RegisteredPanels = {}
......@@ -40,6 +43,7 @@ DT.PanelPool = {
Free = {},
Count = 0
}
DT.UnitEvents = {
UNIT_AURA = true,
UNIT_RESISTANCES = true,
......@@ -49,6 +53,7 @@ DT.UnitEvents = {
UNIT_TARGET = true,
UNIT_SPELL_HASTE = true
}
DT.SPECIALIZATION_CACHE = {}
function DT:SetEasyMenuAnchor(menu, dt)
......@@ -113,10 +118,14 @@ function DT:OnEnter()
DT.SelectedDatatext = self
end
DT:SetupTooltip(self)
if self.MouseEnters then
for _, func in ipairs(self.MouseEnters) do
func(self)
end
DT.tooltip:Show()
end
DT.MouseEnter(self)
......@@ -231,19 +240,18 @@ function DT:BuildPanelFunctions(name, obj)
local panel
local function OnEnter(dt)
DT:SetupTooltip(dt)
if obj.OnTooltipShow then obj.OnTooltipShow(DT.tooltip) end
if obj.OnEnter then obj.OnEnter(dt) end
DT.tooltip:Show()
end
local function OnLeave(dt)
if obj.OnLeave then obj.OnLeave(dt) end
DT.tooltip:Hide()
end
local function OnClick(dt, button)
if obj.OnClick then obj.OnClick(dt, button) end
if obj.OnClick then
obj.OnClick(dt, button)
end
end
local function UpdateText(_, Name, _, Value)
......@@ -305,9 +313,7 @@ end
function DT:SetupTooltip(panel)
local parent = panel:GetParent()
DT.tooltip:Hide()
DT.tooltip:SetOwner(panel, parent.anchor, parent.xOff, parent.yOff)
DT.tooltip:ClearLines()
if not _G.GameTooltip:IsForbidden() then
_G.GameTooltip:Hide() -- WHY??? BECAUSE FUCK GAMETOOLTIP, THATS WHY!!
......@@ -357,7 +363,9 @@ function DT:AssignPanelToDataText(dt, data, event, ...)
if not dt.objectEventFunc then
dt.objectEvent = data.objectEvent
dt.objectEventFunc = function(_, ...)
if data.eventFunc then data.eventFunc(dt, ...) end
if data.eventFunc then
data.eventFunc(dt, ...)
end
end
end
if not E:HasFunctionForObject(ev, data.objectEvent, dt.objectEventFunc) then
......@@ -684,8 +692,6 @@ function DT:Initialize()
DT.Initialized = true
DT.db = E.db.datatexts
DT.tooltip = CreateFrame('GameTooltip', 'DataTextTooltip', E.UIParent, 'GameTooltipTemplate')
DT.EasyMenu = CreateFrame('Frame', 'DataTextEasyMenu', E.UIParent, 'UIDropDownMenuTemplate')
DT.EasyMenu:SetClampedToScreen(true)
DT.EasyMenu:EnableMouse(true)
DT.EasyMenu.MenuSetItem = function(dt, value)
......
......@@ -101,7 +101,6 @@ local function GetLabelTexture(ID)
end
local function OnClick(self)
DT.tooltip:Hide()
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(RightClickMenu, DT.EasyMenu, nil, nil, nil, "MENU")
end
......@@ -120,16 +119,14 @@ local function OnEvent(self)
end
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
DT.tooltip:SetText(L["Current Difficulties:"])
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine(format('%s %s', DungeonTexture, DiffLabel[DungeonDifficultyID]), 1, 1, 1)
DT.tooltip:AddLine(format('%s %s', RaidTexture, DiffLabel[RaidDifficultyID]), 1, 1, 1)
DT.tooltip:AddLine(format('%s %s', LegacyTexture, DiffLabel[LegacyRaidDifficultyID]), 1, 1, 1)
DT.tooltip:Show()
end
DT:RegisterDatatext('Difficulty', nil, {'CHAT_MSG_SYSTEM', 'LOADING_SCREEN_DISABLED'}, OnEvent, nil, OnClick, OnEnter, nil, 'Difficulty')
......@@ -69,8 +69,8 @@ local function Click()
ToggleCharacter("PaperDollFrame")
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
for slot, durability in pairs(invDurability) do
DT.tooltip:AddDoubleLine(format('|T%s:14:14:0:0:64:64:4:60:4:60|t %s', GetInventoryItemTexture("player", slot), GetInventoryItemLink("player", slot)), format(tooltipString, durability), 1, 1, 1, E:ColorGradient(durability * 0.01, 1, .1, .1, 1, 1, .1, .1, 1, .1))
......@@ -80,8 +80,6 @@ local function OnEnter(self)
DT.tooltip:AddLine(" ")
DT.tooltip:AddDoubleLine(REPAIR_COST, GetMoneyString(totalRepairCost), .6, .8, 1, 1, 1, 1)
end
DT.tooltip:Show()
end
DT:RegisterDatatext('Durability', nil, {"UPDATE_INVENTORY_DURABILITY", "MERCHANT_SHOW"}, OnEvent, nil, Click, OnEnter, nil, DURABILITY)
......@@ -55,11 +55,10 @@ local function OnEvent(self)
end
self.text:SetText(displayString)
-- self.text:SetFormattedText()
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local cur, max = UnitXP('player'), UnitXPMax('player')
local rested = GetXPExhaustion()
......@@ -72,8 +71,6 @@ local function OnEnter(self)
if rested then
DT.tooltip:AddDoubleLine(L["Rested:"], format('+%d (%d%%)', rested, E:Round(rested / max * 100)), 1, 1, 1)
end
DT.tooltip:Show()
end
DT:RegisterDatatext('Experience', nil, {'PLAYER_XP_UPDATE', 'DISABLE_XP_GAIN', 'ENABLE_XP_GAIN', 'UPDATE_EXHAUSTION'}, OnEvent, nil, nil, OnEnter, nil, _G.COMBAT_XP_GAIN)
......@@ -356,8 +356,6 @@ local function BuildBNTable(total)
end
local function Click(self, btn)
DT.tooltip:Hide()
if btn == "RightButton" then
local menuCountWhispers = 0
local menuCountInvites = 0
......@@ -449,8 +447,9 @@ local function TooltipAddXLine(X, header, ...)
DT.tooltip[X](DT.tooltip, ...)
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
lastTooltipXLineHeader = nil
local onlineFriends = C_FriendList_GetNumOnlineFriends()
......@@ -547,8 +546,6 @@ local function OnEnter(self)
end
end
end
DT.tooltip:Show()
end
local function OnEvent(self, event, message)
......
......@@ -95,11 +95,9 @@ local function Click(self, btn)
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, "MENU")
DT.tooltip:Hide()
elseif IsControlKeyDown() then
Profit = 0
Spent = 0
DT.tooltip:Hide()
end
else
_G.ToggleAllBags()
......@@ -107,8 +105,9 @@ local function Click(self, btn)
end
local myGold = {}
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local textOnly = not E.db.datatexts.goldCoins and true or false
local style = E.db.datatexts.goldFormat or 'BLIZZARD'
......@@ -185,8 +184,6 @@ local function OnEnter(self)
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine(resetCountersFormatter)
DT.tooltip:AddLine(resetInfoFormatter)
DT.tooltip:Show()
end
DT:RegisterDatatext('Gold', nil, {"PLAYER_MONEY", "SEND_MAIL_MONEY_CHANGED", "SEND_MAIL_COD_CHANGED", "PLAYER_TRADE_MONEY", "TRADE_MONEY_CHANGED"}, OnEvent, nil, Click, OnEnter, nil, L["Gold"])
......@@ -190,8 +190,6 @@ end
local function Click(self, btn)
if btn == "RightButton" and IsInGuild() then
DT.tooltip:Hide()
local menuCountWhispers = 0
local menuCountInvites = 0
......@@ -225,10 +223,9 @@ local function Click(self, btn)
end
end
local function OnEnter(self, _, noUpdate)
local function OnEnter(_, _, noUpdate)
if not IsInGuild() then return end
DT:SetupTooltip(self)
DT.tooltip:ClearLines()
local total, _, online = GetNumGuildMembers()
if #guildTable == 0 then BuildGuildTable() end
......@@ -279,8 +276,6 @@ local function OnEnter(self, _, noUpdate)
end
end
DT.tooltip:Show()
if not noUpdate then
C_GuildInfo_GuildRoster()
end
......
......@@ -27,8 +27,8 @@ local function OnEvent(self)
lastPanel = self
end
local OnEnter = function(self)
DT:SetupTooltip(self)
local OnEnter = function()
DT.tooltip:ClearLines()
local rating = CR_HASTE_MELEE
local classTooltip = _G["STAT_HASTE_"..E.myclass.."_TOOLTIP"]
......@@ -47,8 +47,6 @@ local OnEnter = function(self)
DT.tooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_HASTE).." ".. format(hasteFormatString, format("%.2F%%", haste))..FONT_COLOR_CODE_CLOSE)
DT.tooltip:AddLine(classTooltip..format(STAT_HASTE_BASE_TOOLTIP, BreakUpLargeNumbers(GetCombatRating(rating)), GetCombatRatingBonus(rating)))
DT.tooltip:Show()
end
local function ValueColorUpdate(hex)
......
......@@ -33,7 +33,7 @@ local function OnEvent(self)
end
local function OnEnter(self)
DT:SetupTooltip(self)
DT.tooltip:ClearLines()
local avg, avgEquipped, avgPvp = GetAverageItemLevel()
DT.tooltip:AddDoubleLine(STAT_AVERAGE_ITEM_LEVEL, format('%0.2f', avg), 1, 1, 1, .1, 1, .1)
......@@ -51,7 +51,6 @@ local function OnEnter(self)
end
end
DT.tooltip:Show()
lastPanel = self
end
......
......@@ -17,16 +17,14 @@ local STAT_LIFESTEAL = STAT_LIFESTEAL
local displayString, lastPanel = ''
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local text, tooltip
text = HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_LIFESTEAL).." "..format("%.2F%%", GetLifesteal())..FONT_COLOR_CODE_CLOSE
tooltip = format(CR_LIFESTEAL_TOOLTIP, BreakUpLargeNumbers(GetCombatRating(CR_LIFESTEAL)), GetCombatRatingBonus(CR_LIFESTEAL))
local text = HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_LIFESTEAL).." "..format("%.2F%%", GetLifesteal())..FONT_COLOR_CODE_CLOSE
local tooltip = format(CR_LIFESTEAL_TOOLTIP, BreakUpLargeNumbers(GetCombatRating(CR_LIFESTEAL)), GetCombatRatingBonus(CR_LIFESTEAL))
DT.tooltip:AddDoubleLine(text, nil, 1, 1, 1)
DT.tooltip:AddLine(tooltip, nil, nil, nil, true)
DT.tooltip:Show()
end
local function OnEvent(self)
......
......@@ -15,17 +15,16 @@ local function OnEvent(self)
self.text:SetFormattedText(displayString, HasNewMail() and "New Mail" or "No Mail")
end
local function OnEnter(self)
local function OnEnter()
DT.tooltip:ClearLines()
local senders = { GetLatestThreeSenders() }
if #senders > 0 then
DT:SetupTooltip(self)
DT.tooltip:AddLine(HasNewMail() and HAVE_MAIL_FROM or MAIL_LABEL, 1, 1, 1)
DT.tooltip:AddLine(' ')
for _, sender in pairs(senders) do
DT.tooltip:AddLine(sender)
end
DT.tooltip:Show()
end
end
......
......@@ -15,23 +15,20 @@ local function OnEvent(self)
self.text:SetFormattedText(displayString, STAT_MASTERY, GetMasteryEffect())
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local primaryTalentTree = GetSpecialization()
if (primaryTalentTree) then
if primaryTalentTree then
local masterySpell, masterySpell2 = GetSpecializationMasterySpells(primaryTalentTree)
if (masterySpell) then
if masterySpell then
DT.tooltip:AddSpellByID(masterySpell)
end
if (masterySpell2) then
if masterySpell2 then
DT.tooltip:AddLine(" ")
DT.tooltip:AddSpellByID(masterySpell2)
end
end
DT.tooltip:Show()
end
local function ValueColorUpdate(hex)
......
......@@ -183,8 +183,8 @@ local function AddInfo(id)
return format('%s %s', icon, BreakUpLargeNumbers(num))
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
DT.tooltip:AddLine(EXPANSION_NAME7, 1, .5, 0)
DT.tooltip:AddDoubleLine(L["Mission(s) Report:"], AddInfo(1560), nil, nil, nil, 1, 1, 1)
......@@ -294,14 +294,11 @@ local function OnEnter(self)
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine("Hold Shift - Show Previous Expansion", .66, .66, .66)
end
DT.tooltip:Show()
end
local function OnClick(self)
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
DT.tooltip:Hide()
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, "MENU")
end
......
......@@ -16,18 +16,16 @@ local UNKNOWN, QUICK_JOIN = UNKNOWN, QUICK_JOIN
local displayString = ''
local quickJoin = {}
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
if not next(quickJoin) then return end
DT.tooltip:ClearLines()
DT.tooltip:AddLine(QUICK_JOIN, nil, nil, nil, true)
DT.tooltip:AddLine(" ")
for name, activity in pairs(quickJoin) do
DT.tooltip:AddDoubleLine(name, activity, nil, nil, nil, 1, 1, 1)
end
DT.tooltip:Show()
end
local function Update(lastPanel)
......
......@@ -77,8 +77,8 @@ local function OnEvent(self)
self.text:SetText(text)
end
local function OnEnter(self)
DT:SetupTooltip(self)
local function OnEnter()
DT.tooltip:ClearLines()
local name, reaction, min, max, value, factionID = GetWatchedFactionInfo()
if factionID and C_Reputation_IsFactionParagon(factionID) then
......@@ -104,8 +104,6 @@ local function OnEnter(self)
DT.tooltip:AddDoubleLine(REPUTATION..':', format('%d / %d (%d%%)', value - min, max - min, (value - min) / ((max - min == 0) and max or (max - min)) * 100), 1, 1, 1)
end
end
DT.tooltip:Show()
end
local function OnClick()
......
......@@ -73,8 +73,8 @@ local function AddTexture(texture)
return texture and format(listIcon, texture) or ''
end
local function OnEnter(self)