[#6763] Implement TemplatePlacement to replace AbilityTemplate#6778
Conversation
dev7355608
left a comment
There was a problem hiding this comment.
What is the reason that we don't use the new RegionLayer#placeRegion API?
We need to support placing more than one shape at a time would be the big one. I also have plans for adding additional UI that is shared with our token placement system. |
|
Could you write up a feature request for the limitations you currently facing with |
These cover much of it:
But I will say our implementation also shares a bunch of the internals with our There are also other features for placement restriction/guidance that might not make sense in core:
|
|
At least one of those are mentioned in foundryvtt/foundryvtt#9840 |
The options |
7335281 to
54aa781
Compare
494ddb3 to
e0507eb
Compare
e0507eb to
65395d1
Compare
Fyorl
left a comment
There was a problem hiding this comment.
Good simplification. Seem to have lost the handling for gridAlignedSquareTemplates.
| * @param {TemplatePlacementConfiguration} placementConfig Configuration that drives template placement. | ||
| * @returns {boolean} Return `false` to prevent template placement. | ||
| */ | ||
| if ( Hooks.call("dnd5e.preCreateMeasuredTemplate", activity, config) === false ) return null; |
There was a problem hiding this comment.
createActivityTemplate was the hook we were using before. Did we mean to change it?
There was a problem hiding this comment.
I changed it because the config data here is very different than the templateData data we used in the original hook. Same with the post hooks which have region data as their second argument rather than measured templates.
Adds a new `dnd5e.canvas.TemplatePlacement` API to handle placing shapes within a scene. This base API deals with basic shape data but the `fromActivity` factory method behaves similar to the old method on `AbilityTemplate` to create a full measured template region. The created regions are set up to work as similar as possible to the old measured templates, using `coverage` highlight mode and the user's color. When the area of effect count is larger than one, all of the shapes are combined into a single measured template. `TokenPlacement` has been refactored and much of its code has been shifted into a new `BasePlacement` class that is shared between the two canvas placement systems. Closes #6763
Rewrites both placement APIs to rely on core's `placeToken` and `placeRegion` mathods rather than a new implementation. Removes `BasePlacement` since there is no longer much shared code.
Finds all applications that are not minimized, have a frame, and are not detached and minimizes them until placement is completed. This behavior can be disabled using the `minimizeWindows` option in the placement configuration. Also adds a `restoreLayer` option to the configuration to control whether the original canvas layer is made active after placement. Both of these options are enabled by default. Closes #6763
65395d1 to
e222c9e
Compare
Adds a new
dnd5e.canvas.TemplatePlacementAPI to handle placing shapes within a scene. This base API deals with basic shape data but thefromActivityfactory method behaves similar to the old method onAbilityTemplateto create a full measured template region.The created regions are set up to work as similar as possible to the old measured templates, using
coveragehighlight mode and the user's color. When the area of effect count is larger than one, all of the shapes are combined into a single measured template.TokenPlacementhas been refactored and much of its code has been shifted into a newBasePlacementclass that is shared between the two canvas placement systems.Closes #6763