The goal is basically to be able to clone a grid of widget groups first (like the current clone tool already does) and then all changes to the original should immediately apply to the clones. All automation and relations between widgets should be fixed automatically.
This was already my goal when adding the duplicate feature in the JSON editor and when I added inheritFrom. But while those are already super useful, I always thought it could be a lot smarter...
This uses a property editorSmartClone that is exclusively recognized in the editor. It won't have any effect while playing. There was already a property editorGroup so the editor can recognize a group it created earlier.
In time, I will probably introduce more editor* properties that basically tell the editor and the user that the editor is in charge of parts of the widget definition. So if the user wants to regain full control, they have to remove those properties (can be done through editor UI of course).
Other use-cases for editor* properties would be generated decks so the editor knows that it generated the deck itself and can show simplified UI to edit it. Or in a automation editor where it could show simplified versions of groups of routine operations it created itself.
Options for editorSmartClone:
flipX / flipY: true/false/"all" - if true the layout of the first level will be flipped; if "all", all levels of children will be flipped (this only sets x or y, nothing else)
replaces: object - string in key will be replaced by string in value in all properties of the children
Still very much WIP but at this point it is fun to play around with.
Things I want to do:
[x] Add a new button to the drag toolbar or make this the default for the grid cloning.
[x] Redirect selection from a cloned child to the topmost clone with editorSmartClone because editing the children is not a good idea.
[x] Replace source ids by clone ids automatically (without having to add them to replace).
[x] Make flipX and flipY optionally just flip the first level of children (should be the default).
[ ] Test and fix recursion (so one smartClone inside another one).
[x] Make seats receive unique indices.
[ ] Make seat indices smarter.
[ ] Exclude cards from cloning unless their deck is part of the group. Can be a setting.
[ ] Add JSON editor commands for the editorSmartClone settings.
[x] Show a UI in the Properties panel when selecting a clone, allowing to change settings or remove the link entirely.
[x] It doesn't unset properties on the clones if they got unset in the source.
[x] Update references to internal widgets when they don't get caught by replaces.
[x] score for seats should be excluded dynamically (as stated in scoreboard scoreProperty).
[x] inheritFrom should be updated when it should changes (for example changing movable).
[x] If properties were set but a change leads to them being identical again, they can be removed.
[x] IDs in ${PROPERTY x OF id} syntax still need to be updated.
[ ] Remove debug output and re-enable selection filtering before merging.
[x] Check if it makes sense to update references from outside the source to the source. For example a button that deals a card to a player area. When smart-cloning the player area, it could add the clones to the array of destinations.
[x] Find a solution for bad seat sizing. Probably use clientRect. Or an exception for seats.
[x] Dragging a movable widget out of a smart clone doesn't remove it from smartCloneSourceMap.
[x] Changing flipX (and probably others) doesn't update anymore. Also see #2304.
[x] Renaming top-level clone did not update button clickRoutine.
[ ] The smart clone button should insert an editorGroup parent or be more dynamic about how the top level clone looks like. (Cloning a dice makes it inherit activeFace for example.)
[ ] Gotta handle receiving a new state.
[ ] Test stuff with two clients having edit mode active.
The goal is basically to be able to clone a grid of widget groups first (like the current clone tool already does) and then all changes to the original should immediately apply to the clones. All automation and relations between widgets should be fixed automatically.
This was already my goal when adding the duplicate feature in the JSON editor and when I added
inheritFrom
. But while those are already super useful, I always thought it could be a lot smarter...This uses a property
editorSmartClone
that is exclusively recognized in the editor. It won't have any effect while playing. There was already a propertyeditorGroup
so the editor can recognize a group it created earlier.In time, I will probably introduce more
editor*
properties that basically tell the editor and the user that the editor is in charge of parts of the widget definition. So if the user wants to regain full control, they have to remove those properties (can be done through editor UI of course).Other use-cases for
editor*
properties would be generated decks so the editor knows that it generated the deck itself and can show simplified UI to edit it. Or in a automation editor where it could show simplified versions of groups of routine operations it created itself.Options for
editorSmartClone
:flipX
/flipY
: true/false/"all" - iftrue
the layout of the first level will be flipped; if"all"
, all levels of children will be flipped (this only setsx
ory
, nothing else)replaces
: object - string in key will be replaced by string in value in all properties of the childrenStill very much WIP but at this point it is fun to play around with.
Things I want to do:
editorSmartClone
because editing the children is not a good idea.id
s by cloneid
s automatically (without having to add them toreplace
).flipX
andflipY
optionally just flip the first level of children (should be the default).editorSmartClone
settings.replaces
.score
for seats should be excluded dynamically (as stated in scoreboardscoreProperty
).inheritFrom
should be updated when it should changes (for example changingmovable
).${PROPERTY x OF id}
syntax still need to be updated.Check if it makes sense to update references from outside the source to the source. For example a button that deals a card to a player area. When smart-cloning the player area, it could add the clones to the array of destinations.Or an exception for seats.smartCloneSourceMap
.flipX
(and probably others) doesn't update anymore. Also see #2304.activeFace
for example.)