SonyWWS / ATF

Authoring Tools Framework (ATF) is a set of C#/.NET components for making tools on Windows. ATF has been in continuous development in Sony Computer Entertainment's (SCE) Worldwide Studios central tools group since early 2005. ATF has been used by most SCE first party studios to make many custom tools such as Naughty Dog’s level editor and shader editor for The Last of Us, Guerrilla Games’ sequence editor for Killzone games (including the Killzone: Shadow Fall PS4 launch title), an animation blending tool at Santa Monica Studio, a level editor at Bend Studio, a visual state machine editor for Quantic Dream, sound editing tools, and many others.
Apache License 2.0
1.89k stars 262 forks source link

CircuitEditor: Creating a palette item that creates a DomNode group with sub-groups #22

Closed vkashkash closed 9 years ago

vkashkash commented 10 years ago

Hello,

I have types that are groups which contain sub-groups, and those groups may also contain sub-groups and so forth. I have a palette item of this type and I am calling IPaletteClient.Convert to create a node, but I am unsure what the best way is to add child sub-groups. I have a certain set of rules for each group type:

TypeA should generate a child sub-group TypeB TypeB should generate child sub-groups TypeC, TypeD, TypeE TypeE should generate a child sub-group TypeF

If there is a palette item of TypeA, it should recursively generate all of its descendants. What is the best way to go about this? On a related note, I also want the ability to have right-click support which will add child nodes while selecting a group. For example, right-clicking on TypeE should have the ability to add nodes of TypeF.

Here is some pseudo-code (for my function AddChildren) I have been trying that seems to work in most cases:

List childDataList = new List(); if (parentType == TypeA) childDataList add all children (but not grand-children)

foreach ( ChildData childData in childDataList ) { var childNode = new DomNode(childData.ChildType); if (childData.ChildType.IdAttribute != null) childNode.SetAttribute(childData.ChildType.IdAttribute, childData.ChildId);

  parentNode.GetChildList(childData.ChildInfo).Add(childNode);

  AddChildren(childNode, childData.ChildType);

}

Currently, the only time there is an issue is when one of the sub-types has an input/output pin and only in very certain circumstances. For example, if TypeF has an output pin and the canvas (circuit) is empty, dragging and dropping a palette item with a grand-child (not child) of TypeF will not correctly propagate the output pin to all parent groups of TypeF. This leads to an assert in Debug builds on validation. If I drag the same base type again (grand-parent or higher of TypeF), the pins are correctly updated. The issue has something to do with the way the Dirty flag is updated; however, before I go into more detail, I want to know if my approach for adding descendants is correct or if you guys have a more elegant solution (which may then solve the pin issue).

Thanks

jhshen commented 10 years ago

Interesting scenarios. I don't think we have used Circuits Pallete to drag/drop nested groups from the Circuits Pallete. Items on the pallete are usually primitive building blocks, and a nested group is an hierarchical way to organize these primitives.

ATF's Circuit Editor sample uses template library to store and reuse groups, see Sharing with Template Library under https://github.com/SonyWWS/ATF/wiki/Circuit-Group-Feature

Basically you promote selected groups to the template library. The template library itself has a tree view. You can select any item(group) in the template library view, and drag/drop to a Circuit window, similar to drag/drop from the circuit pallete. The difference is that an item dropped from template library is a reference to the dragged group, not a direct copy of the group, but there is a command "Demote to Copy Instance" to convert a reference instance to a copy instance.

Do you think the template library will work for you too?

Shen

jhshen commented 10 years ago

For the problem of parent group pins are not in sync with child node pins, it seems the change are not observed in the parent group. Here are 2 wild shots:

1) after you create the new group, call newGroupDomNode.InitializeExtensions()

after this call , all Dom node adapters will have been bound to their underlying Dom node.

if this is not sufficient,

2) set node dirty then call Group.Update() after each insertion of new group node

vkashkash commented 9 years ago

Calling InitializeExtensions seems to have worked. Regarding templates, they can potentially work for my needs; however, in their current incarnation, they seem to only work in the file they were created in. I need to have them as a library to be used by all of my files. I read this will be a feature in the future. Is there an ETA on this?

Thanks

jhshen commented 9 years ago

We have added external template folder support in ATF3.8 to load templates from external files for sharing. So the ETA is right now :-), because ATF3.8 was released to GuitHub over a months ago.

Right click in the template library window to bring up the context menu, then select "Import Templates from Document...", choose a file that has templates in it.

Need to update the document pages.

vkashkash commented 9 years ago

Yes, I was reading the docs so I assumed it was still a work in progress :) I did get "Import Templates from Document" to work. Thanks.