Clear vector lines from cards when they're not being dragged
The events which can indicate a drag stop are varied: - Drag a card into another on the table (tryObjectEnterContainer) - Drag multiple cards into another on the table (onCollisionEnter, tryObjectEnterContainer) - Group multiple cards while holding them (tryObjectEnterContainer)
This commit is contained in:
parent
6b52e412e9
commit
e6854801fb
@ -184,6 +184,14 @@ function onObjectSearchEnd(object, playerColor)
|
||||
end
|
||||
end
|
||||
|
||||
-- Pass object enter container events to the PlayArea to clear vector lines from dragged cards.
|
||||
-- This requires the try method as cards won't exist any more after they enter a deck, so the lines
|
||||
-- can't be cleared.
|
||||
function tryObjectEnterContainer(container, object)
|
||||
playAreaAPI.tryObjectEnterContainer(container, object)
|
||||
return true
|
||||
end
|
||||
|
||||
function drawEncountercard(params)
|
||||
local position = params[1]
|
||||
local rotation = params[2]
|
||||
@ -875,7 +883,7 @@ function applyOptionPanelChange(id, state)
|
||||
-- option: Show CYOA campaign guides
|
||||
elseif id == "showCYOA" then
|
||||
optionPanel[id] = spawnOrRemoveHelper(state, "CYOA Campaign Guides", {65, 1.6, -11})
|
||||
|
||||
|
||||
-- option: Show custom playmat images
|
||||
elseif id == "showCustomPlaymatImages" then
|
||||
optionPanel[id] = spawnOrRemoveHelper(state, "Custom Playmat Images", {67.5, 1.6, 37})
|
||||
|
@ -103,7 +103,12 @@ function onCollisionEnter(collisionInfo)
|
||||
if shouldSpawnTokens(card) then
|
||||
tokenManager.spawnForCard(card)
|
||||
end
|
||||
draggingGuids[card.getGUID()] = nil
|
||||
-- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send
|
||||
-- the dropped card immediately into a deck, so this has to be done here
|
||||
if draggingGuids[card.getGUID()] ~= nil then
|
||||
card.setVectorLines(nil)
|
||||
draggingGuids[card.getGUID()] = nil
|
||||
end
|
||||
maybeTrackLocation(card)
|
||||
end
|
||||
|
||||
@ -202,6 +207,18 @@ function maybeUntrackLocation(card)
|
||||
end
|
||||
end
|
||||
|
||||
-- Global event handler, delegated from Global. Clears any connection lines from dragged cards
|
||||
-- before they are destroyed by entering a deck. Removal of the card from the dragging list will
|
||||
-- be handled during the next onUpdate() call.
|
||||
function tryObjectEnterContainer(params)
|
||||
for draggedGuid, _ in pairs(draggingGuids) do
|
||||
local draggedObj = getObjectFromGUID(draggedGuid)
|
||||
if draggedObj ~= nil then
|
||||
draggedObj.setVectorLines(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Builds a list of GUID to GUID connection information based on the currently tracked locations.
|
||||
-- This will update the connection information and store it in the locationConnections data member,
|
||||
-- but does not draw those connections. This should often be followed by a call to
|
||||
|
@ -47,6 +47,13 @@ do
|
||||
PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
|
||||
getObjectFromGUID(PLAY_AREA_GUID).call("setLimitSnapsByType", matchCardTypes)
|
||||
end
|
||||
|
||||
|
||||
-- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged
|
||||
-- cards before they're destroyed by entering the container
|
||||
PlayAreaApi.tryObjectEnterContainer = function(container, object)
|
||||
getObjectFromGUID(PLAY_AREA_GUID).call("tryObjectEnterContainer",
|
||||
{ container = container, object = object })
|
||||
end
|
||||
|
||||
return PlayAreaApi
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user