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

Copy/Paste DomNodeAdapter Member #16

Closed RomainBL closed 9 years ago

RomainBL commented 10 years ago

Hello,

I have found the function Copy() in the DomNode class which clone only attributes.

In my case I would like to copy a member in a DomNodeAdapter object when a DomNode is copied.

What is the best way to implement this ?

I was thinking of implementing an ICopy or IClone Interface for DomNode Adapter and loop through all the adapter in the DomNode Copy func. But I am not sure if this is the best way for the ATF framework.

Cheers. Romain.

Ron2 commented 10 years ago

Hi Romain,

The usual way that DomNodeAdapters initialize themselves when the DomNode is copied is to override OnNodeSet() and then initialize their fields from the DomNode's data (attributes and/or children).

If that doesn't work for you, then you might need a custom implementation of IInstancingContext.

I think of DomNodeAdapters as the "business class" that offers a custom view of a DomNode's data in a convenient way. If the DomNodeAdapter starts having its own data that is independent of the DomNode, then you will have to have special handling for persistence and copy/paste and undo/redo, because you have data that is not observable in the DOM.

--Ron