Fix deck grid tooltip hover handling

This commit is contained in:
2026-07-11 23:15:58 +09:00
parent 2928e2b45f
commit 84381947be
5 changed files with 474 additions and 18 deletions

View File

@@ -102,6 +102,214 @@ for i = 1, #lines do
out = out .. lines[i]
end
return out`, [{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'c' }], 0, 'string'),
method('GetHoveredCardId', `if path == nil or path == "" then
return nil
end
if string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
if self.Hand == nil then
return nil
end
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
return self.Hand[slot]
end
if string.find(path, "/ui/RunUIGroup/RewardHud/Reward", 1, true) == 1 then
if self.RewardCards == nil then
return nil
end
local slot = tonumber(string.match(path, "Reward(%d+)")) or 0
return self.RewardCards[slot]
end
if string.find(path, "/ui/RunUIGroup/ShopHud/Card", 1, true) == 1 then
if self.ShopCards == nil then
return nil
end
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
return self.ShopCards[slot]
end
if string.find(path, "/ui/DeckUIGroup/DeckInspectHud/Grid/Card", 1, true) == 1 then
local pile = nil
if self.DeckInspectKind == "discard" then
pile = self.DiscardPile
elseif self.DeckInspectKind == "exhaust" then
pile = self.ExhaustPile
else
pile = self.DrawPile
end
if pile == nil then
return nil
end
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
return pile[slot]
end
if string.find(path, "/ui/DeckUIGroup/DeckAllHud/Grid/Card", 1, true) == 1 then
local pile = self.RunDeck
if self.ClassDeckMode == true then
pile = self.ClassDeckCards
elseif self.CodexMode == true then
pile = self.CodexCards
end
if pile == nil then
return nil
end
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
return pile[slot]
end
return nil`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }], 0, 'string'),
method('GetGridCardPathAtPoint', `if gridPath == nil or gridPath == "" or touchPoint == nil then
return nil
end
local prefix = nil
local maxSlots = 0
if gridPath == "/ui/DeckUIGroup/DeckAllHud/Grid" then
prefix = "/ui/DeckUIGroup/DeckAllHud/Grid/Card"
maxSlots = 120
elseif gridPath == "/ui/DeckUIGroup/DeckInspectHud/Grid" then
prefix = "/ui/DeckUIGroup/DeckInspectHud/Grid/Card"
maxSlots = 60
else
return nil
end
local uiPos = _UILogic:ScreenToUIPosition(touchPoint)
local bestPath = nil
local bestDist = 999999
for i = 1, maxSlots do
local path = prefix .. tostring(i)
local cardEntity = _EntityService:GetEntityByPath(path)
if cardEntity ~= nil and cardEntity.Enable == true and cardEntity.UITransformComponent ~= nil then
local pos = self:GetUiPathPosition(path)
local dx = uiPos.x - pos.x
local dy = uiPos.y - pos.y
if math.abs(dx) <= 90 and math.abs(dy) <= 125 then
local dist = dx * dx + dy * dy
if bestPath == nil or dist < bestDist then
bestPath = path
bestDist = dist
end
end
end
end
return bestPath`, [
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'gridPath' },
{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'touchPoint' },
], 0, 'string'),
method('GetUiPathPosition', `if path == nil or path == "" then
return Vector2(0, 0)
end
local sumX = 0
local sumY = 0
local cur = path
while cur ~= nil and cur ~= "" do
local e = _EntityService:GetEntityByPath(cur)
if e ~= nil and e.UITransformComponent ~= nil then
local pos = e.UITransformComponent.anchoredPosition
if pos ~= nil then
sumX = sumX + (pos.x or 0)
sumY = sumY + (pos.y or 0)
end
end
local slash = string.match(cur, "^.*()/")
if slash == nil or slash <= 1 then
break
end
cur = string.sub(cur, 1, slash - 1)
if cur == "/ui" then
break
end
end
return Vector2(sumX, sumY)`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }], 0, 'any'),
method('GetTooltipAnchorForPath', `local pos = self:GetUiPathPosition(path)
local x = pos.x
local y = pos.y
local sideOffset = 230
local verticalOffset = 0
if string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
verticalOffset = 90
elseif string.find(path, "/ui/RunUIGroup/RewardHud/Reward", 1, true) == 1 then
verticalOffset = 30
elseif string.find(path, "/ui/RunUIGroup/ShopHud/Card", 1, true) == 1 then
verticalOffset = 20
else
verticalOffset = 0
end
local tipX = x + sideOffset
if x > 180 then
tipX = x - sideOffset
end
if tipX > 760 then
tipX = x - sideOffset
end
if tipX < -760 then
tipX = x + sideOffset
end
local tipY = y + verticalOffset
if tipY > 430 then
tipY = 430
end
if tipY < -430 then
tipY = -430
end
return Vector2(tipX, tipY)`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }], 0, 'any'),
method('HoverCardByPath', `if path == nil or path == "" then
return
end
if self.DragSlot ~= nil and self.DragSlot > 0 and string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
return
end
local cardId = self:GetHoveredCardId(path)
if cardId == nil or self.Cards == nil then
self:HideTooltip()
return
end
local c = self.Cards[cardId]
if c == nil then
self:HideTooltip()
return
end
local tip = self:BuildCardKeywordTooltip(c)
if tip == nil or tip == "" then
self:HideTooltip()
return
end
local e = _EntityService:GetEntityByPath(path)
if e ~= nil and e.UITransformComponent ~= nil then
if string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
e.UITransformComponent.UIScale = Vector3(1.3, 1.3, 1)
end
end
local anchor = self:GetTooltipAnchorForPath(path)
self:ShowTooltipAt("키워드", tip, anchor.x, anchor.y)`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }]),
method('HoverGridCard', `if gridPath == nil or touchPoint == nil then
return
end
local path = self:GetGridCardPathAtPoint(gridPath, touchPoint)
local lastPath = self.GridHoverPath
if lastPath == path then
return
end
if lastPath ~= nil and lastPath ~= "" then
self:UnhoverCardByPath(lastPath)
end
self.GridHoverPath = path or ""
if path ~= nil and path ~= "" then
self:HoverCardByPath(path)
end`, [
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'gridPath' },
{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'touchPoint' },
]),
method('UnhoverGridCard', `local path = self.GridHoverPath
self.GridHoverPath = ""
if path ~= nil and path ~= "" then
self:UnhoverCardByPath(path)
else
self:HideTooltip()
end`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'gridPath' }]),
method('UnhoverCardByPath', `if path ~= nil and string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
local e = _EntityService:GetEntityByPath(path)
if e ~= nil and e.UITransformComponent ~= nil then
e.UITransformComponent.UIScale = Vector3(1, 1, 1)
end
end
self:HideTooltip()`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }]),
method('HoverCard', `if self.DragSlot ~= nil and self.DragSlot > 0 then
return
end
@@ -113,20 +321,15 @@ if cardId == nil then
return
end
local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
local tx = 0
if e ~= nil and e.UITransformComponent ~= nil then
tx = e.UITransformComponent.anchoredPosition.x
e.UITransformComponent.UIScale = Vector3(1.3, 1.3, 1)
end
local c = self.Cards[cardId]
if c ~= nil then
local tip = self:BuildCardKeywordTooltip(c)
if tip ~= "" then
local tipX = tx + 270
if tx > 180 then tipX = tx - 270 end
if tipX > 760 then tipX = tx - 270 end
if tipX < -760 then tipX = tx + 270 end
self:ShowTooltipAt("키워드", tip, tipX, 90)
local anchor = self:GetTooltipAnchorForPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
self:ShowTooltipAt("키워드", tip, anchor.x, anchor.y)
else
self:HideTooltip()
end
@@ -141,9 +344,9 @@ self:HideTooltip()`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, At
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'desc' },
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'x' },
]),
method('ShowTooltipAt', `self:SetText("/ui/RunUIGroup/CombatHud/TooltipBox/Name", name)
self:SetText("/ui/RunUIGroup/CombatHud/TooltipBox/Desc", desc)
local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/TooltipBox")
method('ShowTooltipAt', `self:SetText("/ui/ToolTipGroup/TooltipBox/Name", name)
self:SetText("/ui/ToolTipGroup/TooltipBox/Desc", desc)
local e = _EntityService:GetEntityByPath("/ui/ToolTipGroup/TooltipBox")
if e ~= nil then
if e.UITransformComponent ~= nil then
e.UITransformComponent.anchoredPosition = Vector2(x, y)
@@ -155,5 +358,5 @@ end`, [
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'x' },
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'y' },
]),
method('HideTooltip', `self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/TooltipBox", false)`),
method('HideTooltip', `self:SetEntityEnabled("/ui/ToolTipGroup/TooltipBox", false)`),
];