Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1056, correct variable name #1059

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions modules/corelib/ui/tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ g_tooltip = {}

-- private variables
local toolTipLabel
local SpecialoolTipLabel
local SpecialToolTipLabel
local currentHoveredWidget

-- private functions
Expand Down Expand Up @@ -34,13 +34,13 @@ local function moveToolTip(first)
toolTipLabel:setPosition(pos)
end
local function moveSpecialToolTip(first)
if not first and (not SpecialoolTipLabel:isVisible() or SpecialoolTipLabel:getOpacity() < 0.1) then
if not first and (not SpecialToolTipLabel:isVisible() or SpecialToolTipLabel:getOpacity() < 0.1) then
return
end

local pos = g_window.getMousePosition()
local windowSize = g_window.getSize()
local labelSize = SpecialoolTipLabel:getSize()
local labelSize = SpecialToolTipLabel:getSize()

pos.x = pos.x + 1
pos.y = pos.y + 1
Expand All @@ -57,7 +57,7 @@ local function moveSpecialToolTip(first)
pos.y = pos.y + 10
end

SpecialoolTipLabel:setPosition(pos)
SpecialToolTipLabel:setPosition(pos)
end

local function onWidgetDestroy(widget)
Expand Down Expand Up @@ -142,16 +142,18 @@ function g_tooltip.init()
toolTipLabel:setBorderWidth(1)
toolTipLabel:setTextOffset(topoint('5 3'))
toolTipLabel:hide()
toolTipLabel:setPhantom(true)
end)

addEvent(function()
SpecialoolTipLabel = g_ui.createWidget('UIWidget', rootWidget)
SpecialoolTipLabel:setBackgroundColor('#c0c0c0ff')
SpecialoolTipLabel:setBorderColor("#4c4c4cff")
SpecialoolTipLabel:setBorderWidth(1)
SpecialoolTipLabel:setWidth(455)
SpecialoolTipLabel:setPaddingTop(2)
SpecialoolTipLabel:hide()
SpecialToolTipLabel = g_ui.createWidget('UIWidget', rootWidget)
SpecialToolTipLabel:setBackgroundColor('#c0c0c0ff')
SpecialToolTipLabel:setBorderColor("#4c4c4cff")
SpecialToolTipLabel:setBorderWidth(1)
SpecialToolTipLabel:setWidth(455)
SpecialToolTipLabel:setPaddingTop(2)
SpecialToolTipLabel:hide()
SpecialToolTipLabel:setPhantom(true)
end)
end

Expand Down Expand Up @@ -192,18 +194,18 @@ function g_tooltip.display(text)
end

function g_tooltip.displaySpecial(special)
if not SpecialoolTipLabel then
if not SpecialToolTipLabel then
return
end

local width = 4
local height = 4
SpecialoolTipLabel:destroyChildren()
SpecialToolTipLabel:destroyChildren()
for index, data in ipairs(special) do
local headerW = 0
local headerH = 0
if string.len(data.header) > 0 then
local header = g_ui.createWidget('UILabel', SpecialoolTipLabel)
local header = g_ui.createWidget('UILabel', SpecialToolTipLabel)
if index == 1 then
header:addAnchor(AnchorTop, 'parent', AnchorTop)
else
Expand All @@ -221,7 +223,7 @@ function g_tooltip.displaySpecial(special)
headerH = header:getHeight()
end

local info = g_ui.createWidget('UILabel', SpecialoolTipLabel)
local info = g_ui.createWidget('UILabel', SpecialToolTipLabel)
if string.len(data.header) > 0 then
info:addAnchor(AnchorTop, 'prev', AnchorBottom)
else
Expand All @@ -238,11 +240,11 @@ function g_tooltip.displaySpecial(special)
height = height + headerH + info:getHeight()
end

SpecialoolTipLabel:resize(width, height)
SpecialoolTipLabel:show()
SpecialoolTipLabel:raise()
SpecialoolTipLabel:enable()
g_effects.fadeIn(SpecialoolTipLabel, 100)
SpecialToolTipLabel:resize(width, height)
SpecialToolTipLabel:show()
SpecialToolTipLabel:raise()
SpecialToolTipLabel:enable()
g_effects.fadeIn(SpecialToolTipLabel, 100)
moveSpecialToolTip(true)

connect(rootWidget, {
Expand All @@ -259,8 +261,7 @@ function g_tooltip.hide()
end

function g_tooltip.hideSpecial()
g_effects.fadeOut(SpecialoolTipLabel, 100)

g_effects.fadeOut(SpecialToolTipLabel, 100)
disconnect(rootWidget, {
onMouseMove = moveSpecialToolTip
})
Expand Down
Loading