SelectionInspector.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. import EditorUI = require("../../EditorUI");
  23. import CreateComponentButton = require("./CreateComponentButton");
  24. import ScriptWidget = require("ui/ScriptWidget");
  25. import EditorEvents = require("editor/EditorEvents");
  26. import SerializableEditType = require("./SerializableEditType");
  27. import SelectionSection = require("./SelectionSection");
  28. import SelectionPrefabWidget = require("./SelectionPrefabWidget");
  29. import AttributeInfoEdit = require("./AttributeInfoEdit");
  30. class NodeSection extends SelectionSection {
  31. prefabWidget: SelectionPrefabWidget;
  32. transformEdits: AttributeInfoEdit[] = [];
  33. updateDelta: number = 0.0;
  34. constructor(editType: SerializableEditType) {
  35. super(editType);
  36. this.prefabWidget = new SelectionPrefabWidget();
  37. this.attrLayout.addChild(this.prefabWidget);
  38. this.transformEdits.push(this.attrEdits["Position"]);
  39. this.transformEdits.push(this.attrEdits["Rotation"]);
  40. this.transformEdits.push(this.attrEdits["Scale"]);
  41. this.subscribeToEvent("Update", (ev) => this.handleUpdate(ev));
  42. }
  43. handleUpdate(ev) {
  44. this.updateDelta -= ev.timeStep;
  45. if (this.updateDelta < 0.0) {
  46. this.updateDelta = 0.1;
  47. Atomic.ui.blockChangedEvents = true;
  48. for (var i in this.transformEdits) {
  49. this.transformEdits[i].refresh();
  50. }
  51. Atomic.ui.blockChangedEvents = false;
  52. }
  53. }
  54. }
  55. class ComponentSection extends SelectionSection {
  56. constructor(editType: SerializableEditType, inspector: SelectionInspector) {
  57. super(editType);
  58. var deleteButton = new Atomic.UIButton();
  59. deleteButton.text = "Delete Component";
  60. deleteButton.fontDescription = SelectionSection.fontDesc;
  61. deleteButton.onClick = () => {
  62. inspector.onComponentDelete(editType);
  63. return true;
  64. };
  65. var copyButton = new Atomic.UIButton();
  66. copyButton.text = "Copy Settings";
  67. copyButton.onClick = () => {
  68. inspector.onComponentCopy(editType);
  69. return true;
  70. };
  71. var pasteButton = new Atomic.UIButton();
  72. pasteButton.text = "Paste Settings";
  73. pasteButton.onClick = () => {
  74. inspector.onComponentPaste(editType);
  75. return true;
  76. };
  77. this.attrLayout.addChild(deleteButton);
  78. this.attrLayout.addChild(copyButton);
  79. this.attrLayout.addChild(pasteButton);
  80. }
  81. }
  82. class SceneSection extends SelectionSection {
  83. constructor(editType: SerializableEditType) {
  84. super(editType);
  85. }
  86. }
  87. interface AttributeEditResourceChangedEvent {
  88. attrInfoEdit: AttributeInfoEdit;
  89. resource: Atomic.Resource;
  90. }
  91. class JSComponentSection extends ComponentSection {
  92. constructor(editType: SerializableEditType, inspector: SelectionInspector) {
  93. super(editType, inspector);
  94. this.hasDynamicAttr = true;
  95. this.subscribeToEvent(this, "AttributeEditResourceChanged", (ev) => this.handleAttributeEditResourceChanged(ev));
  96. this.updateTitleFromComponentClass();
  97. }
  98. private handleAttributeEditResourceChanged(ev: AttributeEditResourceChangedEvent) {
  99. var jsc = <Atomic.JSComponent>this.editType.getFirstObject();
  100. if (!jsc)
  101. return;
  102. var attrInfos = jsc.getAttributes();
  103. this.updateDynamicAttrInfos(attrInfos);
  104. this.updateTitleFromComponentClass();
  105. }
  106. private updateTitleFromComponentClass() {
  107. this.text = this.editType.typeName;
  108. let jsc = this.editType.getFirstObject() as Atomic.JSComponent;
  109. if (jsc && jsc.componentFile) {
  110. this.text = jsc.componentFile.name.split("/").pop();
  111. let jscf = <Atomic.JSComponentFile> jsc.componentFile;
  112. if (jscf.typeScriptClass) {
  113. this.text = this.text.replace(".js", ".ts");
  114. }
  115. }
  116. }
  117. }
  118. class CSComponentSection extends ComponentSection {
  119. constructor(editType: SerializableEditType, inspector: SelectionInspector) {
  120. super(editType, inspector);
  121. this.updateTextFromClassAttr();
  122. this.hasDynamicAttr = true;
  123. this.subscribeToEvent(this, "AttributeEditResourceChanged", (ev) => this.handleAttributeEditResourceChanged(ev));
  124. this.subscribeToEvent("CSComponentAssemblyChanged", (ev) => this.handleCSComponentAssemblyChanged(ev));
  125. this.subscribeToEvent("CSComponentClassChanged", (ev) => this.handleCSComponentClassChanged(ev));
  126. }
  127. private handleCSComponentAssemblyChanged(ev) {
  128. var csc = <AtomicNETScript.CSComponent>this.editType.getFirstObject();
  129. if (!csc)
  130. return;
  131. if (csc.componentFile == <Atomic.ScriptComponentFile> ev.resource) {
  132. var attrInfos = csc.getAttributes();
  133. this.updateDynamicAttrInfos(attrInfos);
  134. this.updateTextFromClassAttr();
  135. }
  136. }
  137. private handleCSComponentClassChanged(ev) {
  138. var csc = <AtomicNETScript.CSComponent>this.editType.getFirstObject();
  139. if (!csc)
  140. return;
  141. var attrInfos = csc.getAttributes();
  142. this.updateDynamicAttrInfos(attrInfos);
  143. this.updateTextFromClassAttr();
  144. }
  145. private handleAttributeEditResourceChanged(ev: AttributeEditResourceChangedEvent) {
  146. var csc = <AtomicNETScript.CSComponent>this.editType.getFirstObject();
  147. if (!csc)
  148. return;
  149. var attrInfos = csc.getAttributes();
  150. this.updateDynamicAttrInfos(attrInfos);
  151. }
  152. private updateTextFromClassAttr() {
  153. this.text = this.editType.typeName;
  154. var object = this.editType.getFirstObject();
  155. if (object) {
  156. var value = object.getAttribute("Class");
  157. if (value)
  158. this.text = value + " - C#";
  159. }
  160. }
  161. }
  162. // Node Inspector + Component Inspectors
  163. class SelectionInspector extends ScriptWidget {
  164. component: Atomic.Component;
  165. constructor(sceneEditor: Editor.SceneEditor3D) {
  166. super();
  167. this.sceneEditor = sceneEditor;
  168. var mainLayout = this.mainLayout = new Atomic.UILayout();
  169. mainLayout.spacing = 4;
  170. var lp = new Atomic.UILayoutParams();
  171. lp.width = 304;
  172. mainLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  173. mainLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_LEFT_TOP;
  174. mainLayout.layoutParams = lp;
  175. mainLayout.axis = Atomic.UI_AXIS.UI_AXIS_Y;
  176. this.addChild(mainLayout);
  177. var noticeLayout = this.multipleSelectNotice = new Atomic.UILayout();
  178. noticeLayout.axis = Atomic.UI_AXIS.UI_AXIS_Y;
  179. noticeLayout.layoutParams = lp;
  180. var noticeText = new Atomic.UITextField();
  181. noticeText.textAlign = Atomic.UI_TEXT_ALIGN.UI_TEXT_ALIGN_CENTER;
  182. noticeText.skinBg = "InspectorTextAttrName";
  183. noticeText.text = "Multiple Selection - Some components are hidden";
  184. noticeText.fontDescription = SelectionSection.fontDesc;
  185. noticeText.gravity = Atomic.UI_GRAVITY.UI_GRAVITY_LEFT_RIGHT;
  186. noticeText.layoutParams = lp;
  187. noticeLayout.addChild(noticeText);
  188. noticeLayout.visibility = Atomic.UI_WIDGET_VISIBILITY.UI_WIDGET_VISIBILITY_GONE;
  189. mainLayout.addChild(noticeLayout);
  190. this.createComponentButton = new CreateComponentButton();
  191. mainLayout.addChild(this.createComponentButton);
  192. this.subscribeToEvent(sceneEditor.scene, "SceneEditStateChangesBegin", (data) => this.handleSceneEditStateChangesBeginEvent());
  193. this.subscribeToEvent("SceneEditStateChange", (data) => this.handleSceneEditStateChangeEvent(data));
  194. this.subscribeToEvent(sceneEditor.scene, "SceneEditStateChangesEnd", (data) => this.handleSceneEditStateChangesEndEvent());
  195. this.subscribeToEvent(sceneEditor.scene, "SceneEditNodeRemoved", (ev: Editor.SceneEditNodeRemovedEvent) => this.handleSceneEditNodeRemoved(ev));
  196. this.subscribeToEvent(sceneEditor.scene, "SceneEditComponentAddedRemoved", (ev) => this.handleSceneEditComponentAddedRemovedEvent(ev));
  197. this.subscribeToEvent(this.createComponentButton, "SelectionCreateComponent", (data) => this.handleSelectionCreateComponent(data));
  198. }
  199. pruneSections() {
  200. var remove: SelectionSection[] = [];
  201. for (var i in this.sections) {
  202. var section = this.sections[i];
  203. var editType = section.editType;
  204. if (editType.typeName == "Node") {
  205. continue;
  206. }
  207. if (editType.typeName == "Scene") {
  208. var gotone = false;
  209. for (var j in this.nodes) {
  210. if (this.nodes[j].typeName == "Scene") {
  211. gotone = true;
  212. break;
  213. }
  214. }
  215. if (gotone)
  216. continue;
  217. }
  218. if (!editType.nodes.length) {
  219. remove.push(section);
  220. }
  221. }
  222. if (remove.length) {
  223. for (var i in remove) {
  224. var section = remove[i];
  225. this.removeSection(section);
  226. }
  227. this.suppressSections();
  228. }
  229. }
  230. suppressSections() {
  231. this.multipleSelectNotice.visibility = Atomic.UI_WIDGET_VISIBILITY.UI_WIDGET_VISIBILITY_GONE;
  232. for (var i in this.sections) {
  233. var section = this.sections[i];
  234. var editType = section.editType;
  235. if (editType.typeName == "Node" || editType.typeName == "Scene") {
  236. continue;
  237. }
  238. var suppressed = false;
  239. for (var j in this.nodes) {
  240. if (editType.nodes.indexOf(this.nodes[j]) == -1) {
  241. suppressed = true;
  242. break;
  243. }
  244. }
  245. if (suppressed)
  246. this.multipleSelectNotice.visibility = Atomic.UI_WIDGET_VISIBILITY.UI_WIDGET_VISIBILITY_VISIBLE;
  247. section.suppress(suppressed);
  248. }
  249. }
  250. refresh() {
  251. Atomic.ui.blockChangedEvents = true;
  252. this.pruneSections();
  253. this.suppressSections();
  254. for (var i in this.sections) {
  255. this.sections[i].refresh();
  256. }
  257. if (this.nodeSection) {
  258. this.nodeSection.prefabWidget.updateSelection(this.nodes);
  259. }
  260. Atomic.ui.blockChangedEvents = false;
  261. }
  262. addSection(editType: SerializableEditType) {
  263. var section: SelectionSection;
  264. if (editType.typeName == "Node") {
  265. this.nodeSection = new NodeSection(editType);
  266. section = this.nodeSection;
  267. } else if (editType.typeName == "Scene") {
  268. section = new SceneSection(editType);
  269. } else if (editType.typeName == "JSComponent") {
  270. section = new JSComponentSection(editType, this);
  271. } else if (editType.typeName == "CSComponent") {
  272. section = new CSComponentSection(editType, this);
  273. }
  274. else {
  275. section = new ComponentSection(editType, this);
  276. }
  277. section.value = SelectionInspector.sectionStates[editType.typeName] ? 1 : 0;
  278. this.mainLayout.removeChild(this.createComponentButton, false);
  279. this.mainLayout.removeChild(this.multipleSelectNotice, false);
  280. // sort it in alphabetically
  281. this.sections.push(section);
  282. this.sections.sort(function(a, b) {
  283. if (a.editType.typeName == "Node" && b.editType.typeName == "Scene")
  284. return -1;
  285. if (a.editType.typeName == "Scene" && b.editType.typeName == "Node")
  286. return 1;
  287. if (a.editType.typeName == "Node" || a.editType.typeName == "Scene")
  288. return -1;
  289. if (b.editType.typeName == "Node" || b.editType.typeName == "Scene")
  290. return 1;
  291. return a.editType.typeName.localeCompare(b.editType.typeName);
  292. });
  293. var idx = this.sections.indexOf(section);
  294. if (idx == 0) {
  295. if (this.sections.length == 1) {
  296. this.mainLayout.addChild(section);
  297. } else {
  298. this.mainLayout.addChildBefore(section, this.sections[1]);
  299. }
  300. }
  301. else if (idx == this.sections.length - 1) {
  302. this.mainLayout.addChild(section);
  303. }
  304. else {
  305. this.mainLayout.addChildAfter(section, this.sections[idx - 1]);
  306. }
  307. // move the create component button down
  308. this.mainLayout.addChild(this.multipleSelectNotice);
  309. this.mainLayout.addChild(this.createComponentButton);
  310. }
  311. removeSection(section: SelectionSection) {
  312. SelectionInspector.sectionStates[section.editType.typeName] = section.value ? true : false;
  313. var index = this.sections.indexOf(section);
  314. this.sections.splice(index, 1);
  315. this.mainLayout.removeChild(section);
  316. }
  317. removeSerializable(serial: Atomic.Serializable) {
  318. for (var i in this.sections) {
  319. var section = this.sections[i];
  320. var e = section.editType;
  321. var index = e.objects.indexOf(serial);
  322. if (index != -1) {
  323. e.objects.splice(index, 1);
  324. }
  325. if (serial.typeName == "Node") {
  326. index = e.nodes.indexOf(<Atomic.Node>serial);
  327. if (index != -1) {
  328. e.nodes.splice(index, 1);
  329. }
  330. }
  331. }
  332. }
  333. addSerializable(serial: Atomic.Serializable): SerializableEditType {
  334. var editType = this.getEditType(serial);
  335. // does it already exist?
  336. for (var i in this.sections) {
  337. var section = this.sections[i];
  338. var e = section.editType;
  339. if (e.compareTypes(editType, this.nodes.length > 1)) {
  340. e.addSerializable(serial);
  341. return e;
  342. }
  343. }
  344. this.addSection(editType);
  345. return editType;
  346. }
  347. getEditType(serial: Atomic.Serializable): SerializableEditType {
  348. var typeName = serial.typeName;
  349. if (SelectionInspector._editTypes[typeName]) {
  350. return new SelectionInspector._editTypes[typeName](serial);
  351. }
  352. return new SerializableEditType(serial);
  353. }
  354. addNode(node: Atomic.Node) {
  355. var index = this.nodes.indexOf(node);
  356. if (index == -1) {
  357. this.nodes.push(node);
  358. this.addSerializable(node);
  359. var components = node.getComponents();
  360. for (var i in components) {
  361. if (this.filterComponent(components[i]))
  362. continue;
  363. var editType = this.addSerializable(components[i]);
  364. editType.addNode(node);
  365. }
  366. this.refresh();
  367. }
  368. }
  369. removeNode(node: Atomic.Node) {
  370. var index = this.nodes.indexOf(node);
  371. if (index != -1) {
  372. this.nodes.splice(index, 1);
  373. this.removeSerializable(node);
  374. var components = node.getComponents();
  375. for (var i in components) {
  376. if (this.filterComponent(components[i]))
  377. continue;
  378. this.removeSerializable(components[i]);
  379. }
  380. this.refresh();
  381. }
  382. // save node section state
  383. if (!this.nodes.length && this.nodeSection)
  384. SelectionInspector.sectionStates["Node"] = this.nodeSection.value ? true : false;
  385. }
  386. handleSceneEditStateChangesBeginEvent() {
  387. this.stateChangesInProgress = true;
  388. }
  389. handleSceneEditNodeRemoved(ev: Editor.SceneEditNodeRemovedEvent) {
  390. this.removeNode(ev.node);
  391. }
  392. handleSceneEditComponentAddedRemovedEvent(ev: Editor.SceneEditComponentAddedRemovedEvent) {
  393. if (this.filterComponent(ev.component)) {
  394. // still refresh as may affect UI (for example PrefabComponents)
  395. this.refresh();
  396. return;
  397. }
  398. var editType;
  399. if (!ev.removed) {
  400. editType = this.addSerializable(ev.component);
  401. editType.addNode(ev.node);
  402. } else {
  403. for (var i in this.sections) {
  404. var section = this.sections[i];
  405. editType = section.editType;
  406. var index = editType.objects.indexOf(ev.component);
  407. if (index != -1) {
  408. editType.objects.splice(index, 1);
  409. index = editType.nodes.indexOf(ev.node);
  410. if (index != -1) {
  411. editType.nodes.splice(index, 1);
  412. }
  413. break;
  414. }
  415. }
  416. }
  417. this.refresh();
  418. }
  419. onComponentDelete(editType: SerializableEditType) {
  420. var removed: Atomic.Component[] = [];
  421. for (var i in editType.objects) {
  422. var c = <Atomic.Component>editType.objects[i];
  423. removed.push(c);
  424. }
  425. for (var i in removed) {
  426. var c = removed[i];
  427. var node = c.node;
  428. c.remove();
  429. this.removeSerializable(removed[i]);
  430. var index = editType.nodes.indexOf(node);
  431. if (index != -1) {
  432. editType.nodes.splice(index, 1);
  433. }
  434. }
  435. if (removed.length) {
  436. this.sceneEditor.scene.sendEvent("SceneEditEnd");
  437. this.refresh();
  438. }
  439. }
  440. onComponentCopy(editType: SerializableEditType) {
  441. var copy: Atomic.Component[] = [];
  442. for (var i in editType.objects) {
  443. var c = <Atomic.Component>editType.objects[i];
  444. copy.push(c);
  445. }
  446. for (var i in copy) {
  447. var c = copy[i];
  448. this.component = c;
  449. this.sceneEditor.scene.sendEvent("SceneEditComponentCopy", { component: this.component });
  450. this.refresh();
  451. }
  452. }
  453. onComponentPaste(editType: SerializableEditType) {
  454. var paste: Atomic.Component[] = [];
  455. for (var i in editType.objects) {
  456. var c = <Atomic.Component>editType.objects[i];
  457. paste.push(c);
  458. }
  459. for (var i in paste) {
  460. var c = paste[i];
  461. this.component = c;
  462. this.sceneEditor.scene.sendEvent("SceneEditComponentPaste", { component: this.component });
  463. this.refresh();
  464. }
  465. }
  466. handleSelectionCreateComponent(ev) {
  467. var valid = true;
  468. if (ev.componentTypeName != "JSComponent" && ev.componentTypeName != "CSComponent") {
  469. for (var i in this.nodes) {
  470. var node = this.nodes[i];
  471. if (node.getComponent(ev.componentTypeName, false)) {
  472. valid = false;
  473. break;
  474. }
  475. }
  476. }
  477. if (!valid) {
  478. EditorUI.showModalError("Component Create", "Unable to create component, a node with an existing " + ev.componentTypeName + " component is selected");
  479. return;
  480. }
  481. for (var i in this.nodes) {
  482. var node = this.nodes[i];
  483. var c = node.createComponent(ev.componentTypeName);
  484. if (!c) {
  485. console.log("ERROR: unable to create component ", ev.componentTypeName);
  486. return;
  487. }
  488. var editType = this.addSerializable(c);
  489. editType.addNode(node);
  490. for (var i in this.sections) {
  491. if (this.sections[i].editType == editType) {
  492. this.sections[i].value = 1;
  493. break;
  494. }
  495. }
  496. }
  497. this.refresh();
  498. }
  499. handleSceneEditStateChangeEvent(ev: Editor.SceneEditStateChangeEvent) {
  500. if (!this.stateChangesInProgress)
  501. return;
  502. if (this.stateChanges.indexOf(ev.serializable) == -1) {
  503. this.stateChanges.push(ev.serializable);
  504. }
  505. }
  506. getPrefabComponent(node: Atomic.Node): Atomic.PrefabComponent {
  507. if (node.getComponent("PrefabComponent"))
  508. return <Atomic.PrefabComponent>node.getComponent("PrefabComponent");
  509. if (node.parent)
  510. return this.getPrefabComponent(node.parent);
  511. return null;
  512. }
  513. filterComponent(component: Atomic.Component): boolean {
  514. if (component.typeName == "PrefabComponent") {
  515. return true;
  516. }
  517. return false;
  518. }
  519. handleSceneEditStateChangesEndEvent() {
  520. Atomic.ui.blockChangedEvents = true;
  521. var sections: SelectionSection[] = [];
  522. for (var i in this.stateChanges) {
  523. var serial = this.stateChanges[i];
  524. for (var j in this.sections) {
  525. var section = this.sections[j];
  526. if (sections.indexOf(section) != -1)
  527. continue;
  528. if (section.editType.objects.indexOf(serial) != -1) {
  529. sections.push(section);
  530. if (section.hasDynamicAttr) {
  531. var object = section.editType.getFirstObject();
  532. if (object) {
  533. var attrInfos = object.getAttributes();
  534. section.updateDynamicAttrInfos(attrInfos);
  535. }
  536. }
  537. section.refresh();
  538. }
  539. }
  540. }
  541. Atomic.ui.blockChangedEvents = false;
  542. this.stateChanges = [];
  543. this.stateChangesInProgress = false;
  544. }
  545. mainLayout: Atomic.UILayout;
  546. multipleSelectNotice: Atomic.UILayout;
  547. sceneEditor: Editor.SceneEditor3D;
  548. nodes: Atomic.Node[] = [];
  549. sections: SelectionSection[] = [];
  550. createComponentButton: CreateComponentButton;
  551. nodeSection: NodeSection;
  552. stateChangesInProgress: boolean = false;
  553. stateChanges: Atomic.Serializable[] = [];
  554. // ------------------------------------
  555. static registerEditType(typeName: string, type: typeof SerializableEditType) {
  556. SelectionInspector._editTypes[typeName] = type;
  557. }
  558. private static sectionStates: { [typeName: string]: boolean } = {};
  559. private static _editTypes: { [typeName: string]: typeof SerializableEditType } = {};
  560. private static Ctor = (() => {
  561. SelectionInspector.sectionStates["Node"] = true;
  562. })();
  563. }
  564. export = SelectionInspector;