Forráskód Böngészése

implementing pr feedback

Kyle Belfort 5 éve
szülő
commit
7e8a1466f6

+ 2 - 3
nodeEditor/src/diagram/graphCanvas.tsx

@@ -234,13 +234,12 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
 
         // Store additional data to serialization object
         this.props.globalState.storeEditorData = (editorData, graphFrame) => {
-            editorData.x = this.x;
-            editorData.y = this.y;
-
             editorData.frames = [];
             if (graphFrame) {
                 editorData.frames.push(graphFrame!.serialize());
             } else {
+                editorData.x = this.x;
+                editorData.y = this.y;
                 editorData.zoom = this.zoom;
                 for (var frame of this._frames) {
                     editorData.frames.push(frame.serialize());

+ 1 - 1
nodeEditor/src/diagram/graphFrame.ts

@@ -1302,7 +1302,7 @@ export class GraphFrame {
 
     public export() {
         const state = this._ownerCanvas.globalState;
-        const json = SerializationTools.Serialize(state.nodeMaterial, state, this.nodes.map(n => n.block), this);
+        const json = SerializationTools.Serialize(state.nodeMaterial, state, this);
         StringTools.DownloadAsFile(state.hostDocument, json, this._name + ".json");
     }
 

+ 7 - 9
nodeEditor/src/serializationTools.ts

@@ -8,18 +8,14 @@ import { GraphFrame } from './diagram/graphFrame';
 
 export class SerializationTools {
 
-    public static UpdateLocations(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[], frame?: Nullable<GraphFrame>) {
+    public static UpdateLocations(material: NodeMaterial, globalState: GlobalState, frame?: Nullable<GraphFrame>) {
         material.editorData = {
             locations: []
         };
 
         // Store node locations
-        let blocks: NodeMaterialBlock[];
-        if (selectedBlocks) {
-            blocks = selectedBlocks;
-        } else {
-            blocks = material.attachedBlocks;
-        }
+        const blocks: NodeMaterialBlock[] = frame ? frame.nodes.map(n => n.block) : material.attachedBlocks;
+
         for (var block of blocks) {
             let node = globalState.onGetNodeFromBlock(block);
 
@@ -33,11 +29,13 @@ export class SerializationTools {
         globalState.storeEditorData(material.editorData, frame);
     }
 
-    public static Serialize(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[], frame?: Nullable<GraphFrame>) {
+    public static Serialize(material: NodeMaterial, globalState: GlobalState, frame?: Nullable<GraphFrame>) {
         let bufferSerializationState = Texture.SerializeBuffers;
         Texture.SerializeBuffers = DataStorage.ReadBoolean("EmbedTextures", true);
 
-        this.UpdateLocations(material, globalState, selectedBlocks, frame);
+        this.UpdateLocations(material, globalState, frame);
+
+        const selectedBlocks = frame ? frame.nodes.map(n => n.block) : undefined;
 
         let serializationObject = material.serialize(selectedBlocks);