PrefabInspector.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 InspectorWidget = require("./InspectorWidget");
  23. import InspectorUtils = require("./InspectorUtils");
  24. class PrefabInspector extends InspectorWidget {
  25. constructor() {
  26. super();
  27. this.fd.id = "Vera";
  28. this.fd.size = 11;
  29. this.subscribeToEvent(this, Atomic.UIWidgetEvent((data) => this.handleWidgetEvent(data)));
  30. }
  31. handleWidgetEvent(ev: Atomic.UIWidgetEvent):boolean {
  32. return false;
  33. }
  34. onApply() {
  35. var nameText = this.nameEdit.text;
  36. if (nameText != this.asset.name) {
  37. if (!this.asset.rename(nameText)) {
  38. this.nameEdit.text = this.asset.name;
  39. }
  40. }
  41. }
  42. inspect(asset: ToolCore.Asset) {
  43. this.asset = asset;
  44. this.importer = <ToolCore.PrefabImporter>asset.importer;
  45. // node attr layout
  46. var rootLayout = this.rootLayout;
  47. // Assembly Section
  48. var prefabLayout = this.createSection(rootLayout, "Prefab", 1);
  49. var container = InspectorUtils.createContainer();
  50. container.gravity = Atomic.UI_GRAVITY.UI_GRAVITY_ALL;
  51. prefabLayout.addChild(container);
  52. var panel = new Atomic.UILayout();
  53. panel.axis = Atomic.UI_AXIS.UI_AXIS_Y;
  54. panel.layoutSize = Atomic.UI_LAYOUT_SIZE.UI_LAYOUT_SIZE_PREFERRED;
  55. panel.layoutPosition = Atomic.UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_LEFT_TOP;
  56. container.addChild(panel);
  57. // Name Edit
  58. this.nameEdit = this.createAttrEditField("Name", panel);
  59. this.nameEdit.text = this.asset.name;
  60. var applyButton = this.createApplyButton();
  61. panel.addChild(applyButton);
  62. /*
  63. var editButton = new Atomic.UIButton();
  64. editButton.fontDescription = this.fd;
  65. editButton.text = "Edit";
  66. editButton.onClick = function() {
  67. }.bind(this);
  68. prefabLayout.addChild(editButton);
  69. */
  70. }
  71. nameEdit: Atomic.UIEditField;
  72. asset: ToolCore.Asset;
  73. importer: ToolCore.PrefabImporter;
  74. fd: Atomic.UIFontDescription = new Atomic.UIFontDescription();
  75. }
  76. export = PrefabInspector;