MainFrame.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. import ProjectFrame = require("./ProjectFrame");
  8. import ResourceFrame = require("./ResourceFrame");
  9. import WelcomeFrame = require("./WelcomeFrame");
  10. import InspectorFrame = require("./inspector/InspectorFrame");
  11. import HierarchyFrame = require("./HierarchyFrame");
  12. import MainToolbar = require("ui//MainToolbar");
  13. import UIEvents = require("ui/UIEvents");
  14. import ScriptWidget = require("ui/ScriptWidget");
  15. import MainFrameMenu = require("./menus/MainFrameMenu");
  16. import MenuItemSources = require("./menus/MenuItemSources");
  17. class MainFrame extends ScriptWidget {
  18. constructor() {
  19. super();
  20. this.load("AtomicEditor/editor/ui/mainframe.tb.txt");
  21. this.inspectorlayout = <Atomic.UILayout> this.getWidget("inspectorlayout");
  22. this.getWidget("consolecontainer").visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  23. this.inspectorframe = new InspectorFrame();
  24. this.inspectorlayout.addChild(this.inspectorframe);
  25. this.projectframe = new ProjectFrame(this);
  26. this.hierarchyFrame = new HierarchyFrame(this);
  27. this.welcomeFrame = new WelcomeFrame(this);
  28. this.resourceframe = new ResourceFrame(this);
  29. this.mainToolbar = new MainToolbar(this.getWidget("maintoolbarcontainer"));
  30. this.menu = new MainFrameMenu();
  31. this.subscribeToEvent(UIEvents.ResourceEditorChanged, (data) => this.handleResourceEditorChanged(data));
  32. this.subscribeToEvent("ProjectLoaded", (data) => {
  33. this.showWelcomeFrame(false);
  34. });
  35. this.subscribeToEvent("ProjectUnloaded", (data) => {
  36. this.showWelcomeFrame(true);
  37. });
  38. this.showWelcomeFrame(true);
  39. }
  40. frameVisible(frame: Atomic.UIWidget): boolean {
  41. var container = <Atomic.UILayout> this.getWidget("resourceviewcontainer");
  42. var child = null;
  43. for (child = container.firstChild; child; child = child.next) {
  44. if (child == frame)
  45. return true;
  46. }
  47. return false;
  48. }
  49. showWelcomeFrame(show: boolean) {
  50. if (show) {
  51. this.showInspectorFrame(false);
  52. this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  53. this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  54. }
  55. else {
  56. this.showInspectorFrame(true);
  57. this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  58. this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  59. }
  60. }
  61. showInspectorFrame(show: boolean) {
  62. if (show) {
  63. this.inspectorlayout.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  64. this.inspectorframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  65. } else {
  66. this.inspectorframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  67. this.inspectorlayout.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  68. }
  69. }
  70. onEventClick(target: Atomic.UIWidget, refid: string): boolean {
  71. if (this.menu.handlePopupMenu(target, refid))
  72. return true;
  73. var src = MenuItemSources.getMenuItemSource(target.id);
  74. if (src) {
  75. var menu = new Atomic.UIMenuWindow(target, target.id + " popup");
  76. menu.show(src);
  77. return true;
  78. }
  79. return false;
  80. }
  81. shutdown() {
  82. this.resourceframe.shutdown();
  83. this.deleteAllChildren();
  84. }
  85. handleResourceEditorChanged(data): void {
  86. var editor = <Editor.ResourceEditor> data.editor;
  87. if (editor) {
  88. //this.showInspectorFrame(editor.requiresInspector());
  89. } else {
  90. //this.showInspectorFrame(false);
  91. }
  92. }
  93. projectframe: ProjectFrame;
  94. resourceframe: ResourceFrame;
  95. inspectorframe: InspectorFrame;
  96. hierarchyFrame: HierarchyFrame;
  97. welcomeFrame: WelcomeFrame;
  98. inspectorlayout: Atomic.UILayout;
  99. mainToolbar: MainToolbar;
  100. menu: MainFrameMenu;
  101. }
  102. export = MainFrame;