This PR adds a new feature to PA tentatively called "selection collapsing".
When moving a selection of multiple shapes around, it can often be a pain to navigate tight corridors or corners, due to some shapes in your selection colliding with walls.
This is an approach to help you as a DM or even player to circumvent these issues.
How to trigger
While you have a selection and are actively dragging it (e.g. your left mouse is down) you can hold the "c" key (c for collapsing; not to be confused with ctrl+c!).
While this key is down, the selection will collapse to your currently selected shape. When you release the key the shapes will expand out again.
An alternative is to right click on a shape in your selection and choose the new context menu item "Collapse". Later on you can right click the shape again and press "Expand".[^1]
Collapsing
Collapsed shapes are all moved to the center of the shape you're dragging and will automatically move along with it.
As all the shapes are now located in 1 position, the shape you're actively dragging is automatically put on top of all the others.
A first version made them invisible, but shapes with bigger dimensions than the one you're dragging can still end up blocking entry through a door and while invisible this is not really clear to the user.
Expanding
When the selection is expanded, all shapes originally collapsed will be pushed in the direction that they originally had relative to the shape that was moved (e.g. if shape X was left of the dragged shape, it will be put left again upon expanding).
These pushes are actually properly checked for wall collisions so that no shape is suddenly able to jump to the other side of a wall.
This can however mean that multiple shapes are pushed together if the expansion happens in a small area or if the expanded shapes are all towards the side where the wall is located. I intend to improve this behavior in the future by for example trying to put shapes in free grid cells or something alike. [^2]
Example
Here is an example of the behaviour: (ignore the 'shift' key showing, I was still in DM mode where I move things around with shift :D)
It's important to realise that this is fully managed client-side. If you refresh or for some reason the websocket resets and reloads, the information of collapsed shapes is lost.
That said, the shapes are still there, they're just below the selected shape, so nothing is really lost, which is why I decided to not sync this to the server. Collapsing is intended to be done for short operations during a session and not something that should be used across sessions.
Selection focus changes
A small side effect that happened as a part to implement this functionality is that now when you left or right click a shape in a selection that was not the original focused shape (i.e. the shape that has context info on the right of the screen), will now become the focused shape.
This makes more sense in general, but was not the case today.
[^1]: Do note that some inconsistencies can happen if one of the collapsed shapes is being moved between a collapse and expand action!
[^2]: This expansion behaviour may also be applied on teleports in the future, as those currently result in everybody being stacked on the teleport target today and that's also a bit of a pain.
Intro
This PR adds a new feature to PA tentatively called "selection collapsing".
When moving a selection of multiple shapes around, it can often be a pain to navigate tight corridors or corners, due to some shapes in your selection colliding with walls.
This is an approach to help you as a DM or even player to circumvent these issues.
How to trigger
While you have a selection and are actively dragging it (e.g. your left mouse is down) you can hold the "c" key (c for collapsing; not to be confused with ctrl+c!). While this key is down, the selection will collapse to your currently selected shape. When you release the key the shapes will expand out again.
An alternative is to right click on a shape in your selection and choose the new context menu item "Collapse". Later on you can right click the shape again and press "Expand".[^1]
Collapsing
Collapsed shapes are all moved to the center of the shape you're dragging and will automatically move along with it.
As all the shapes are now located in 1 position, the shape you're actively dragging is automatically put on top of all the others.
A first version made them invisible, but shapes with bigger dimensions than the one you're dragging can still end up blocking entry through a door and while invisible this is not really clear to the user.
Expanding
When the selection is expanded, all shapes originally collapsed will be pushed in the direction that they originally had relative to the shape that was moved (e.g. if shape X was left of the dragged shape, it will be put left again upon expanding).
These pushes are actually properly checked for wall collisions so that no shape is suddenly able to jump to the other side of a wall.
This can however mean that multiple shapes are pushed together if the expansion happens in a small area or if the expanded shapes are all towards the side where the wall is located. I intend to improve this behavior in the future by for example trying to put shapes in free grid cells or something alike. [^2]
Example
Here is an example of the behaviour: (ignore the 'shift' key showing, I was still in DM mode where I move things around with shift :D)
pa-collapse.webm
State
It's important to realise that this is fully managed client-side. If you refresh or for some reason the websocket resets and reloads, the information of collapsed shapes is lost.
That said, the shapes are still there, they're just below the selected shape, so nothing is really lost, which is why I decided to not sync this to the server. Collapsing is intended to be done for short operations during a session and not something that should be used across sessions.
Selection focus changes
A small side effect that happened as a part to implement this functionality is that now when you left or right click a shape in a selection that was not the original focused shape (i.e. the shape that has context info on the right of the screen), will now become the focused shape.
This makes more sense in general, but was not the case today.
[^1]: Do note that some inconsistencies can happen if one of the collapsed shapes is being moved between a collapse and expand action! [^2]: This expansion behaviour may also be applied on teleports in the future, as those currently result in everybody being stacked on the teleport target today and that's also a bit of a pain.