Go to Page... |
Thread Tools | Display Modes |
11-01-20, 09:34 PM | #1 |
Quest about remove 'sell price' part from tooltip
I use following codes to remove 'sell price' line from tooltip
Now 'sell price' line is gone but still there is a gap in the tooltip lua Code:
So I checked blizz source code lua Code:
Blizz insert a blank line into 'sell price' part, and GameTooltip_ClearMoney(self) cant remove it then I stuck here, any solutions? |
|
11-02-20, 03:34 PM | #2 |
Did you try calling GameTooltip:Show() afterward?
|
|
11-02-20, 08:44 PM | #3 |
11-03-20, 02:55 AM | #4 |
You could
store all tooltip lines, completely clear the tooltip, reprint all tooltip lines except the money frame line. Just after you clear, you have to temporarily override GameTooltip.GetItem such that other addons reading the tooltip afterwards can still get the original item name and link: Code:
-- This will restore the original GetItem after the tooltip is closed. local originalGetItem = GameTooltip.GetItem GameTooltip:HookScript("OnHide", function(self) GameTooltip.GetItem = originalGetItem end) -- Function to reprint stored tooltip lines. local function AddLineOrDoubleLine(tooltip, leftText, rightText, leftTextR, leftTextG, leftTextB, rightTextR, rightTextG, rightTextB, intendedWordWrap) if rightText then tooltip:AddDoubleLine(leftText, rightText, leftTextR, leftTextG, leftTextB, rightTextR, rightTextG, rightTextB) else tooltip:AddLine(leftText, leftTextR, leftTextG, leftTextB, intendedWordWrap) end end Code:
GameTooltip:HookScript("OnTooltipSetItem", function(self) if not self.shownMoneyFrames then return end -- Store for GetItem to be overridden after ClearLines. local name, link = self:GetItem() -- Just to be on the safe side... if not name or not link then return end -- The money frame is anchored to a blank line of the tootlip. -- Find out which line it is. local moneyFrameLineNumber = nil -- Check all shown money frames of the tooltip. -- (There is normally only one, except other addons have added more.) for i = 1, self.shownMoneyFrames, 1 do local moneyFrameName = self:GetName().."MoneyFrame"..i -- If the money frame's PrefixText is "SELL_PRICE:", we assume it is the one we are looking for. if _G[moneyFrameName.."PrefixText"]:GetText() == string.format("%s:", SELL_PRICE) then local _, moneyFrameAnchor = _G[moneyFrameName]:GetPoint(1) -- Get line number. moneyFrameLineNumber = tonumber(string.match(moneyFrameAnchor:GetName(), self:GetName().."TextLeft(%d+)")) break end end if not moneyFrameLineNumber then return end -- Store all text and text colours of the original tooltip lines. -- Unfortunately I do not know how to store the "indented word wrap". -- Therefore, we have to put wrap=true for all lines in the new tooltip -- except the title line which is never wrapped. local leftText = {} local leftTextR = {} local leftTextG = {} local leftTextB = {} local rightText = {} local rightTextR = {} local rightTextG = {} local rightTextB = {} -- Store the number of lines for after ClearLines(). local numLines = self:NumLines() -- Store all lines of the original tooltip. for i = 1, numLines, 1 do leftText[i] = _G[self:GetName().."TextLeft"..i]:GetText() leftTextR[i], leftTextG[i], leftTextB[i] = _G[self:GetName().."TextLeft"..i]:GetTextColor() rightText[i] = _G[self:GetName().."TextRight"..i]:GetText() rightTextR[i], rightTextG[i], rightTextB[i] = _G[self:GetName().."TextRight"..i]:GetTextColor() end self:ClearLines() -- Got to override GameTooltip.GetItem(), such that other addons can still use it -- to learn which item is displayed. Will be restored after GameTooltip:OnHide() (see above). self.GetItem = function(self) return name, link end -- Never word wrap the title line! AddLineOrDoubleLine(self, leftText[1], rightText[1], leftTextR[1], leftTextG[1], leftTextB[1], rightTextR[1], rightTextG[1], rightTextB[1], false) -- Refill the tooltip with the stored lines except the money frame. for i = 2, moneyFrameLineNumber-1, 1 do AddLineOrDoubleLine(self, leftText[i], rightText[i], leftTextR[i], leftTextG[i], leftTextB[i], rightTextR[i], rightTextG[i], rightTextB[i], true) end for i = moneyFrameLineNumber+1, numLines, 1 do AddLineOrDoubleLine(self, leftText[i], rightText[i], leftTextR[i], leftTextG[i], leftTextB[i], rightTextR[i], rightTextG[i], rightTextB[i], true) end end )
__________________
~ Be the change you want to see in the world... of warcraft interface! ~ |
|
11-03-20, 10:37 AM | #5 | |
|
||
WoWInterface » Developer Discussions » Lua/XML Help » Quest about remove 'sell price' part from tooltip |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|