fix: money tooltip position
This commit is contained in:
+5
-9
@@ -5,14 +5,10 @@ local addon = Guda
|
|||||||
local Utils = {}
|
local Utils = {}
|
||||||
addon.Modules.Utils = Utils
|
addon.Modules.Utils = Utils
|
||||||
|
|
||||||
-- Format money (copper to gold/silver/copper string)
|
-- Format money (copper to gold/silver/copper string) - WoW 1.12.1 version
|
||||||
function Utils:FormatMoney(copper, showZero)
|
function Utils:FormatMoney(copper, showZero)
|
||||||
if not copper or copper == 0 then
|
if not copper or copper == 0 then
|
||||||
if showZero then
|
return "0c"
|
||||||
return "0|cFFFFD700g|r 0|cFFC0C0C0s|r 0|cFFFF6600c|r"
|
|
||||||
else
|
|
||||||
return "0|cFFC0C0C0s|r"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local gold = math.floor(copper / 10000)
|
local gold = math.floor(copper / 10000)
|
||||||
@@ -21,12 +17,12 @@ function Utils:FormatMoney(copper, showZero)
|
|||||||
|
|
||||||
local str = ""
|
local str = ""
|
||||||
if gold > 0 then
|
if gold > 0 then
|
||||||
str = str .. gold .. "|cFFFFD700g|r "
|
str = str .. gold .. "g "
|
||||||
end
|
end
|
||||||
if silver > 0 or gold > 0 then
|
if silver > 0 or gold > 0 then
|
||||||
str = str .. silver .. "|cFFC0C0C0s|r "
|
str = str .. silver .. "s "
|
||||||
end
|
end
|
||||||
str = str .. bronze .. "|cFFFF6600c|r"
|
str = str .. bronze .. "c"
|
||||||
|
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|||||||
+60
-18
@@ -206,7 +206,7 @@ function BagFrame:ResizeFrame(currentRow, currentCol, columns)
|
|||||||
local containerWidth = (columns * (buttonSize + spacing)) + 20
|
local containerWidth = (columns * (buttonSize + spacing)) + 20
|
||||||
local containerHeight = (totalRows * (buttonSize + spacing)) + 20
|
local containerHeight = (totalRows * (buttonSize + spacing)) + 20
|
||||||
local frameWidth = containerWidth + 20
|
local frameWidth = containerWidth + 20
|
||||||
local frameHeight = containerHeight + 100 -- Title (40) + search (30) + footer (30)
|
local frameHeight = containerHeight + 120 -- Title (40) + search (30) + footer (50)
|
||||||
|
|
||||||
-- Minimum sizes
|
-- Minimum sizes
|
||||||
if containerWidth < 200 then
|
if containerWidth < 200 then
|
||||||
@@ -328,29 +328,80 @@ function BagFrame:PassesSearchFilter(itemData)
|
|||||||
return matches
|
return matches
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update money display
|
-- Update money display with colored text (WoW 1.12.1 version like pfUI)
|
||||||
function BagFrame:UpdateMoney()
|
function BagFrame:UpdateMoney()
|
||||||
local currentMoney = addon.Modules.MoneyTracker:GetCurrentMoney()
|
local currentMoney = addon.Modules.MoneyTracker:GetCurrentMoney()
|
||||||
local moneyFrame = getglobal("Guda_BagFrame_MoneyFrame")
|
local moneyFrame = getglobal("Guda_BagFrame_MoneyFrame")
|
||||||
|
|
||||||
-- Current character money only
|
if not moneyFrame then
|
||||||
if not moneyFrame.text then
|
addon:Debug("MoneyFrame not found!")
|
||||||
moneyFrame.text = moneyFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
return
|
||||||
moneyFrame.text:SetPoint("CENTER", moneyFrame, "CENTER", 0, 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
moneyFrame.text:SetText(addon.Modules.Utils:FormatMoney(currentMoney))
|
-- Create text frame if it doesn't exist
|
||||||
|
if not moneyFrame.text then
|
||||||
|
moneyFrame.text = moneyFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
|
||||||
|
moneyFrame.text:SetPoint("CENTER", moneyFrame, "CENTER", 0, 0)
|
||||||
|
moneyFrame.text:SetJustifyH("CENTER")
|
||||||
|
|
||||||
|
-- Simple backdrop without border (better for mouse events)
|
||||||
|
moneyFrame:SetBackdrop({
|
||||||
|
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
||||||
|
tile = true,
|
||||||
|
tileSize = 16,
|
||||||
|
edgeSize = 0,
|
||||||
|
insets = { left = 0, right = 0, top = 0, bottom = 0 }
|
||||||
|
})
|
||||||
|
moneyFrame:SetBackdropColor(0, 0, 0, 0.6)
|
||||||
|
|
||||||
|
-- Set hit rect to make entire frame area responsive to mouse
|
||||||
|
-- This ensures hovering anywhere in the 180x35 frame triggers OnEnter
|
||||||
|
moneyFrame:SetHitRectInsets(0, 0, 0, 0)
|
||||||
|
|
||||||
|
-- Raise frame level to ensure it's on top and can receive mouse events
|
||||||
|
moneyFrame:SetFrameLevel(moneyFrame:GetParent():GetFrameLevel() + 10)
|
||||||
|
|
||||||
|
moneyFrame:Show() -- Ensure frame is visible
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Calculate gold, silver, copper
|
||||||
|
local gold = math.floor(currentMoney / 10000)
|
||||||
|
local silver = math.floor(mod(currentMoney, 10000) / 100)
|
||||||
|
local copper = mod(currentMoney, 100)
|
||||||
|
|
||||||
|
-- Create colored string like pfUI (white numbers, colored letters)
|
||||||
|
local moneyString = ""
|
||||||
|
if gold > 0 then
|
||||||
|
moneyString = moneyString .. "|cffffffff" .. gold .. "|cffffd700g"
|
||||||
|
end
|
||||||
|
if silver > 0 or gold > 0 then
|
||||||
|
moneyString = moneyString .. "|cffffffff " .. silver .. "|cffc7c7cfs"
|
||||||
|
end
|
||||||
|
moneyString = moneyString .. "|cffffffff " .. copper .. "|cffeda55fc"
|
||||||
|
|
||||||
|
moneyFrame.text:SetText(moneyString)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Money tooltip handler
|
-- Money tooltip handler
|
||||||
function Guda_BagFrame_MoneyOnEnter(self)
|
function Guda_BagFrame_MoneyOnEnter(self)
|
||||||
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM")
|
if not self then return end
|
||||||
|
|
||||||
|
-- Anchor tooltip to TOPRIGHT - aligns tooltip's right edge with money container's right edge
|
||||||
|
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 0)
|
||||||
GameTooltip:ClearLines()
|
GameTooltip:ClearLines()
|
||||||
|
|
||||||
-- Get all characters and total
|
-- Get all characters and total
|
||||||
local chars = addon.Modules.DB:GetAllCharacters(true)
|
local chars = addon.Modules.DB:GetAllCharacters(true)
|
||||||
local totalMoney = addon.Modules.DB:GetTotalMoney(true)
|
local totalMoney = addon.Modules.DB:GetTotalMoney(true)
|
||||||
local currentPlayerName = addon.Modules.DB:GetPlayerFullName()
|
|
||||||
|
-- Header with faction/realm total
|
||||||
|
GameTooltip:AddDoubleLine(
|
||||||
|
"Faction/realm-wide gold:",
|
||||||
|
addon.Modules.Utils:FormatMoney(totalMoney),
|
||||||
|
1, 0.82, 0,
|
||||||
|
1, 1, 1
|
||||||
|
)
|
||||||
|
GameTooltip:AddLine(" ")
|
||||||
|
|
||||||
-- List each character with class-colored names
|
-- List each character with class-colored names
|
||||||
for _, char in ipairs(chars) do
|
for _, char in ipairs(chars) do
|
||||||
@@ -371,15 +422,6 @@ function Guda_BagFrame_MoneyOnEnter(self)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add separator and total at the bottom
|
|
||||||
GameTooltip:AddLine(" ")
|
|
||||||
GameTooltip:AddDoubleLine(
|
|
||||||
"Total:",
|
|
||||||
addon.Modules.Utils:FormatMoney(totalMoney),
|
|
||||||
1, 0.82, 0,
|
|
||||||
1, 1, 1
|
|
||||||
)
|
|
||||||
|
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -67,7 +67,7 @@
|
|||||||
<Anchors>
|
<Anchors>
|
||||||
<Anchor point="BOTTOMLEFT">
|
<Anchor point="BOTTOMLEFT">
|
||||||
<Offset>
|
<Offset>
|
||||||
<AbsDimension x="10" y="20"/>
|
<AbsDimension x="10" y="10"/>
|
||||||
</Offset>
|
</Offset>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Anchors>
|
</Anchors>
|
||||||
@@ -343,10 +343,10 @@
|
|||||||
<!-- Money Display Frame (moved to bottom right) -->
|
<!-- Money Display Frame (moved to bottom right) -->
|
||||||
<Frame name="$parent_MoneyFrame" enableMouse="true">
|
<Frame name="$parent_MoneyFrame" enableMouse="true">
|
||||||
<Size>
|
<Size>
|
||||||
<AbsDimension x="150" y="30"/>
|
<AbsDimension x="180" y="35"/>
|
||||||
</Size>
|
</Size>
|
||||||
<Anchors>
|
<Anchors>
|
||||||
<Anchor point="BOTTOMRIGHT">
|
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT">
|
||||||
<Offset>
|
<Offset>
|
||||||
<AbsDimension x="-10" y="10"/>
|
<AbsDimension x="-10" y="10"/>
|
||||||
</Offset>
|
</Offset>
|
||||||
|
|||||||
Reference in New Issue
Block a user