|
@@ -1,15 +1,22 @@
|
|
|
|
|
|
|
|
|
|
+import CreateComponentButton = require("./CreateComponentButton");
|
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
|
import EditorEvents = require("editor/EditorEvents");
|
|
import EditorEvents = require("editor/EditorEvents");
|
|
|
import SerializableEditType = require("./SerializableEditType");
|
|
import SerializableEditType = require("./SerializableEditType");
|
|
|
import SelectionSection = require("./SelectionSection");
|
|
import SelectionSection = require("./SelectionSection");
|
|
|
|
|
+import SelectionPrefabWidget = require("./SelectionPrefabWidget");
|
|
|
|
|
|
|
|
class NodeSection extends SelectionSection {
|
|
class NodeSection extends SelectionSection {
|
|
|
|
|
|
|
|
|
|
+ prefabWidget: SelectionPrefabWidget;
|
|
|
|
|
+
|
|
|
constructor(editType: SerializableEditType) {
|
|
constructor(editType: SerializableEditType) {
|
|
|
|
|
|
|
|
super(editType);
|
|
super(editType);
|
|
|
|
|
|
|
|
|
|
+ this.prefabWidget = new SelectionPrefabWidget();
|
|
|
|
|
+ this.attrLayout.addChild(this.prefabWidget);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -28,6 +35,9 @@ class ComponentSection extends SelectionSection {
|
|
|
|
|
|
|
|
class SelectionInspector extends ScriptWidget {
|
|
class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
|
|
+ createComponentButton: CreateComponentButton;
|
|
|
|
|
+ nodeSection: NodeSection;
|
|
|
|
|
+
|
|
|
constructor(sceneEditor: Editor.SceneEditor3D) {
|
|
constructor(sceneEditor: Editor.SceneEditor3D) {
|
|
|
|
|
|
|
|
super();
|
|
super();
|
|
@@ -47,10 +57,15 @@ class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
this.addChild(mainLayout);
|
|
this.addChild(mainLayout);
|
|
|
|
|
|
|
|
|
|
+ this.createComponentButton = new CreateComponentButton();
|
|
|
|
|
+ mainLayout.addChild(this.createComponentButton);
|
|
|
|
|
+
|
|
|
this.subscribeToEvent(sceneEditor.scene, "SceneEditStateChangesBegin", (data) => this.handleSceneEditStateChangesBeginEvent());
|
|
this.subscribeToEvent(sceneEditor.scene, "SceneEditStateChangesBegin", (data) => this.handleSceneEditStateChangesBeginEvent());
|
|
|
this.subscribeToEvent("SceneEditStateChange", (data) => this.handleSceneEditStateChangeEvent(data));
|
|
this.subscribeToEvent("SceneEditStateChange", (data) => this.handleSceneEditStateChangeEvent(data));
|
|
|
this.subscribeToEvent(sceneEditor.scene, "SceneEditStateChangesEnd", (data) => this.handleSceneEditStateChangesEndEvent());
|
|
this.subscribeToEvent(sceneEditor.scene, "SceneEditStateChangesEnd", (data) => this.handleSceneEditStateChangesEndEvent());
|
|
|
|
|
|
|
|
|
|
+ this.subscribeToEvent(this.createComponentButton, "SelectionCreateComponent", (data) => this.handleSelectionCreateComponent(data));
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
pruneSections() {
|
|
pruneSections() {
|
|
@@ -128,6 +143,10 @@ class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (this.nodeSection) {
|
|
|
|
|
+ this.nodeSection.prefabWidget.updateSelection(this.nodes);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Atomic.ui.blockChangedEvents = false;
|
|
Atomic.ui.blockChangedEvents = false;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -138,7 +157,13 @@ class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
if (editType.typeName == "Node") {
|
|
if (editType.typeName == "Node") {
|
|
|
|
|
|
|
|
- section = new NodeSection(editType);
|
|
|
|
|
|
|
+ this.nodeSection = new NodeSection(editType);
|
|
|
|
|
+ section = this.nodeSection;
|
|
|
|
|
+
|
|
|
|
|
+ this.subscribeToEvent(this.nodeSection.prefabWidget, "SelectionPrefabSave", (data) => this.handleSelectionPrefabSave());
|
|
|
|
|
+ this.subscribeToEvent(this.nodeSection.prefabWidget, "SelectionPrefabUndo", (data) => this.handleSelectionPrefabUndo());
|
|
|
|
|
+ this.subscribeToEvent(this.nodeSection.prefabWidget, "SelectionPrefabBreak", (data) => this.handleSelectionPrefabBreak());
|
|
|
|
|
+
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
@@ -146,7 +171,14 @@ class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.mainLayout.removeChild(this.createComponentButton, false);
|
|
|
|
|
+
|
|
|
this.mainLayout.addChild(section);
|
|
this.mainLayout.addChild(section);
|
|
|
|
|
+
|
|
|
|
|
+ // move the create component button down
|
|
|
|
|
+ this.mainLayout.addChild(this.createComponentButton);
|
|
|
|
|
+
|
|
|
this.sections.push(section);
|
|
this.sections.push(section);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -266,11 +298,33 @@ class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ handleSelectionCreateComponent(ev) {
|
|
|
|
|
+
|
|
|
|
|
+ for (var i in this.nodes) {
|
|
|
|
|
+
|
|
|
|
|
+ var node = this.nodes[i];
|
|
|
|
|
+
|
|
|
|
|
+ var c = node.createComponent(ev.componentTypeName);
|
|
|
|
|
+
|
|
|
|
|
+ if (!c) {
|
|
|
|
|
+ console.log("ERROR: unable to create component ", ev.componentTypeName);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var editType = this.addSerializable(c);
|
|
|
|
|
+ editType.addNode(node);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.refresh();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
handleSceneEditStateChangeEvent(ev: Editor.SceneEditStateChangeEvent) {
|
|
handleSceneEditStateChangeEvent(ev: Editor.SceneEditStateChangeEvent) {
|
|
|
|
|
|
|
|
if (!this.stateChangesInProgress)
|
|
if (!this.stateChangesInProgress)
|
|
|
- return;
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
if (this.stateChanges.indexOf(ev.serializable) == -1) {
|
|
if (this.stateChanges.indexOf(ev.serializable) == -1) {
|
|
|
this.stateChanges.push(ev.serializable);
|
|
this.stateChanges.push(ev.serializable);
|
|
@@ -278,6 +332,62 @@ class SelectionInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getPrefabComponent(node: Atomic.Node): Atomic.PrefabComponent {
|
|
|
|
|
+
|
|
|
|
|
+ if (node.getComponent("PrefabComponent"))
|
|
|
|
|
+ return <Atomic.PrefabComponent>node.getComponent("PrefabComponent");
|
|
|
|
|
+
|
|
|
|
|
+ if (node.parent)
|
|
|
|
|
+ return this.getPrefabComponent(node.parent);
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ handleSelectionPrefabSave() {
|
|
|
|
|
+
|
|
|
|
|
+ if (this.nodes.length != 1)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ var c = this.getPrefabComponent(this.nodes[0]);
|
|
|
|
|
+ if (!c)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ c.savePrefab();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ handleSelectionPrefabBreak() {
|
|
|
|
|
+
|
|
|
|
|
+ if (this.nodes.length != 1)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ var c = this.getPrefabComponent(this.nodes[0]);
|
|
|
|
|
+ if (!c)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ c.breakPrefab();
|
|
|
|
|
+ this.refresh();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ handleSelectionPrefabUndo() {
|
|
|
|
|
+
|
|
|
|
|
+ if (this.nodes.length != 1)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ var c = this.getPrefabComponent(this.nodes[0]);
|
|
|
|
|
+ if (!c)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ c.undoPrefab();
|
|
|
|
|
+
|
|
|
|
|
+ var node = this.nodes[0];
|
|
|
|
|
+ this.removeNode(node);
|
|
|
|
|
+ this.addNode(node);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
handleSceneEditStateChangesEndEvent() {
|
|
handleSceneEditStateChangesEndEvent() {
|
|
|
|
|
|
|
|
Atomic.ui.blockChangedEvents = true;
|
|
Atomic.ui.blockChangedEvents = true;
|
|
@@ -319,7 +429,7 @@ class SelectionInspector extends ScriptWidget {
|
|
|
sections: SelectionSection[] = [];
|
|
sections: SelectionSection[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
- stateChangesInProgress:boolean = false;
|
|
|
|
|
|
|
+ stateChangesInProgress: boolean = false;
|
|
|
stateChanges: Atomic.Serializable[] = [];
|
|
stateChanges: Atomic.Serializable[] = [];
|
|
|
|
|
|
|
|
// ------------------------------------
|
|
// ------------------------------------
|