PrefabInspector.ts 3.2 KB

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