덱 그리드 툴팁 호버 처리 수정 #115

Merged
maple merged 1 commits from codex/grid-hover-tooltip-fix into main 2026-07-11 23:19:31 +09:00
5 changed files with 474 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@@ -71,6 +71,13 @@ if allDeckClose ~= nil and (allDeckClose.ButtonComponent ~= nil or allDeckClose:
self.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end) self.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end)
end end
self:BindClassDeckTabs() self:BindClassDeckTabs()
local allDeckGrid = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Grid")
if allDeckGrid ~= nil and (allDeckGrid.UITouchReceiveComponent ~= nil or allDeckGrid:AddComponent("UITouchReceiveComponent") ~= nil) then
allDeckGrid:ConnectEvent(UITouchEnterEvent, function(ev) self:HoverGridCard("/ui/DeckUIGroup/DeckAllHud/Grid", ev.TouchPoint) end)
allDeckGrid:ConnectEvent(UITouchDownEvent, function(ev) self:HoverGridCard("/ui/DeckUIGroup/DeckAllHud/Grid", ev.TouchPoint) end)
allDeckGrid:ConnectEvent(UITouchDragEvent, function(ev) self:HoverGridCard("/ui/DeckUIGroup/DeckAllHud/Grid", ev.TouchPoint) end)
allDeckGrid:ConnectEvent(UITouchExitEvent, function() self:UnhoverGridCard("/ui/DeckUIGroup/DeckAllHud/Grid") end)
end
for i = 1, 120 do for i = 1, 120 do
local allCard = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Grid/Card" .. tostring(i)) local allCard = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Grid/Card" .. tostring(i))
if allCard ~= nil and (allCard.ButtonComponent ~= nil or allCard:AddComponent("ButtonComponent") ~= nil) then if allCard ~= nil and (allCard.ButtonComponent ~= nil or allCard:AddComponent("ButtonComponent") ~= nil) then
@@ -78,9 +85,45 @@ for i = 1, 120 do
allCard.SpriteGUIRendererComponent.RaycastTarget = true allCard.SpriteGUIRendererComponent.RaycastTarget = true
end end
local slot = i local slot = i
local cardPath = "/ui/DeckUIGroup/DeckAllHud/Grid/Card" .. tostring(i)
allCard:ConnectEvent(ButtonStateChangeEvent, function(ev)
local state = nil
if ev ~= nil then
state = ev.CurrentState or ev.ButtonState or ev.State
end
if state == ButtonState.Highlighted or state == ButtonState.Pressed or tostring(state) == "1" or tostring(state) == "2" then
self:HoverCardByPath(cardPath)
else
self:UnhoverCardByPath(cardPath)
end
end)
allCard:ConnectEvent(ButtonClickEvent, function() self:OnAllDeckCardButton(slot) end) allCard:ConnectEvent(ButtonClickEvent, function() self:OnAllDeckCardButton(slot) end)
end end
end end
local inspectGrid = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckInspectHud/Grid")
if inspectGrid ~= nil and (inspectGrid.UITouchReceiveComponent ~= nil or inspectGrid:AddComponent("UITouchReceiveComponent") ~= nil) then
inspectGrid:ConnectEvent(UITouchEnterEvent, function(ev) self:HoverGridCard("/ui/DeckUIGroup/DeckInspectHud/Grid", ev.TouchPoint) end)
inspectGrid:ConnectEvent(UITouchDownEvent, function(ev) self:HoverGridCard("/ui/DeckUIGroup/DeckInspectHud/Grid", ev.TouchPoint) end)
inspectGrid:ConnectEvent(UITouchDragEvent, function(ev) self:HoverGridCard("/ui/DeckUIGroup/DeckInspectHud/Grid", ev.TouchPoint) end)
inspectGrid:ConnectEvent(UITouchExitEvent, function() self:UnhoverGridCard("/ui/DeckUIGroup/DeckInspectHud/Grid") end)
end
for i = 1, 60 do
local inspectCard = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckInspectHud/Grid/Card" .. tostring(i))
if inspectCard ~= nil and (inspectCard.ButtonComponent ~= nil or inspectCard:AddComponent("ButtonComponent") ~= nil) then
local cardPath = "/ui/DeckUIGroup/DeckInspectHud/Grid/Card" .. tostring(i)
inspectCard:ConnectEvent(ButtonStateChangeEvent, function(ev)
local state = nil
if ev ~= nil then
state = ev.CurrentState or ev.ButtonState or ev.State
end
if state == ButtonState.Highlighted or state == ButtonState.Pressed or tostring(state) == "1" or tostring(state) == "2" then
self:HoverCardByPath(cardPath)
else
self:UnhoverCardByPath(cardPath)
end
end)
end
end
for i = 1, 10 do for i = 1, 10 do
local cardEntity = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(i)) local cardEntity = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(i))
if cardEntity ~= nil and cardEntity.UITouchReceiveComponent ~= nil then if cardEntity ~= nil and cardEntity.UITouchReceiveComponent ~= nil then
@@ -105,6 +148,8 @@ for i = 1, 3 do
local cardPath = "/ui/RunUIGroup/RewardHud/Reward" .. tostring(i) local cardPath = "/ui/RunUIGroup/RewardHud/Reward" .. tostring(i)
rc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end) rc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)
rc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end) rc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)
rc:ConnectEvent(UITouchEnterEvent, function() self:HoverCardByPath(cardPath) end)
rc:ConnectEvent(UITouchExitEvent, function() self:UnhoverCardByPath(cardPath) end)
end end
end end
end end
@@ -134,6 +179,8 @@ for i = 1, 3 do
local cardPath = "/ui/RunUIGroup/ShopHud/Card" .. tostring(i) local cardPath = "/ui/RunUIGroup/ShopHud/Card" .. tostring(i)
sc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end) sc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)
sc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end) sc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)
sc:ConnectEvent(UITouchEnterEvent, function() self:HoverCardByPath(cardPath) end)
sc:ConnectEvent(UITouchExitEvent, function() self:UnhoverCardByPath(cardPath) end)
end end
end end
end end

View File

@@ -64,7 +64,7 @@ end, 0.2)`),
self:KickCombatCamera() self:KickCombatCamera()
self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/Result", false) self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/Result", false)
self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/PotionMenu", false) self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/PotionMenu", false)
self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/TooltipBox", false) self:SetEntityEnabled("/ui/ToolTipGroup/TooltipBox", false)
self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/DiscardPrompt", false) self:SetEntityEnabled("/ui/RunUIGroup/CombatHud/DiscardPrompt", false)
self:SetText("/ui/RunUIGroup/CombatHud/PlayerPanel/Name", self:JobLabel()) self:SetText("/ui/RunUIGroup/CombatHud/PlayerPanel/Name", self:JobLabel())
self.MaxEnergy = 3 self.MaxEnergy = 3

View File

@@ -102,6 +102,214 @@ for i = 1, #lines do
out = out .. lines[i] out = out .. lines[i]
end end
return out`, [{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'c' }], 0, 'string'), 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 method('HoverCard', `if self.DragSlot ~= nil and self.DragSlot > 0 then
return return
end end
@@ -113,20 +321,15 @@ if cardId == nil then
return return
end end
local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot)) local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
local tx = 0
if e ~= nil and e.UITransformComponent ~= nil then if e ~= nil and e.UITransformComponent ~= nil then
tx = e.UITransformComponent.anchoredPosition.x
e.UITransformComponent.UIScale = Vector3(1.3, 1.3, 1) e.UITransformComponent.UIScale = Vector3(1.3, 1.3, 1)
end end
local c = self.Cards[cardId] local c = self.Cards[cardId]
if c ~= nil then if c ~= nil then
local tip = self:BuildCardKeywordTooltip(c) local tip = self:BuildCardKeywordTooltip(c)
if tip ~= "" then if tip ~= "" then
local tipX = tx + 270 local anchor = self:GetTooltipAnchorForPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
if tx > 180 then tipX = tx - 270 end self:ShowTooltipAt("키워드", tip, anchor.x, anchor.y)
if tipX > 760 then tipX = tx - 270 end
if tipX < -760 then tipX = tx + 270 end
self:ShowTooltipAt("키워드", tip, tipX, 90)
else else
self:HideTooltip() self:HideTooltip()
end end
@@ -141,9 +344,9 @@ self:HideTooltip()`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, At
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'desc' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'desc' },
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'x' }, { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'x' },
]), ]),
method('ShowTooltipAt', `self:SetText("/ui/RunUIGroup/CombatHud/TooltipBox/Name", name) method('ShowTooltipAt', `self:SetText("/ui/ToolTipGroup/TooltipBox/Name", name)
self:SetText("/ui/RunUIGroup/CombatHud/TooltipBox/Desc", desc) self:SetText("/ui/ToolTipGroup/TooltipBox/Desc", desc)
local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/TooltipBox") local e = _EntityService:GetEntityByPath("/ui/ToolTipGroup/TooltipBox")
if e ~= nil then if e ~= nil then
if e.UITransformComponent ~= nil then if e.UITransformComponent ~= nil then
e.UITransformComponent.anchoredPosition = Vector2(x, y) 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: 'x' },
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'y' }, { 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)`),
]; ];

View File

@@ -77,6 +77,7 @@ function writeCodeblocks() {
prop('any', 'ClassDeckCards'), prop('any', 'ClassDeckCards'),
prop('string', 'ClassDeckTitle', '""'), prop('string', 'ClassDeckTitle', '""'),
prop('string', 'ClassDeckClass', '""'), prop('string', 'ClassDeckClass', '""'),
prop('string', 'GridHoverPath', '""'),
prop('any', 'SoulUnlocks'), prop('any', 'SoulUnlocks'),
prop('any', 'SoulShopDef'), prop('any', 'SoulShopDef'),
prop('boolean', 'SoulShopBound', 'false'), prop('boolean', 'SoulShopBound', 'false'),