MainFrameMenu.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. import strings = require("ui/EditorStrings");
  2. import EditorEvents = require("editor/EditorEvents");
  3. import EditorUI = require("ui/EditorUI");
  4. import MenuItemSources = require("./MenuItemSources");
  5. class MainFrameMenu extends Atomic.ScriptObject {
  6. constructor() {
  7. super();
  8. MenuItemSources.createMenuItemSource("menu atomic editor", editorItems);
  9. MenuItemSources.createMenuItemSource("menu edit", editItems);
  10. MenuItemSources.createMenuItemSource("menu file", fileItems);
  11. MenuItemSources.createMenuItemSource("menu build", buildItems);
  12. MenuItemSources.createMenuItemSource("menu tools", toolsItems);
  13. MenuItemSources.createMenuItemSource("menu developer", developerItems);
  14. MenuItemSources.createMenuItemSource("menu help", helpItems);
  15. }
  16. handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
  17. if (target.id == "menu atomic editor popup") {
  18. if (refid == "about atomic editor") {
  19. EditorUI.getModelOps().showAbout();
  20. return true;
  21. }
  22. if (refid == "manage license") {
  23. EditorUI.getModelOps().showManageLicense();
  24. return true;
  25. }
  26. if (refid == "quit") {
  27. this.sendEvent(EditorEvents.Quit);
  28. return true;
  29. }
  30. } else if (target.id == "menu edit popup") {
  31. if (refid == "edit play") {
  32. EditorUI.getShortcuts().invokePlay();
  33. return true;
  34. }
  35. if (refid == "edit format code") {
  36. EditorUI.getShortcuts().invokeFormatCode();
  37. return true;
  38. }
  39. return false;
  40. } else if (target.id == "menu file popup") {
  41. if (refid == "file new project") {
  42. if (ToolCore.toolSystem.project) {
  43. EditorUI.showModalError("Project Open",
  44. "Please close the current project before creating a new one");
  45. return true;
  46. }
  47. var mo = EditorUI.getModelOps();
  48. mo.showNewProject();
  49. return true;
  50. }
  51. if (refid == "file open project") {
  52. if (ToolCore.toolSystem.project) {
  53. EditorUI.showModalError("Project Open",
  54. "Please close the current project before opening new one");
  55. return true;
  56. }
  57. var utils = new Editor.FileUtils();
  58. var path = utils.openProjectFileDialog();
  59. if (path) {
  60. this.sendEvent(EditorEvents.LoadProject, { path: path });
  61. }
  62. return true;
  63. }
  64. if (refid == "file close project") {
  65. this.sendEvent(EditorEvents.CloseProject);
  66. return true;
  67. }
  68. if (refid == "file save file") {
  69. EditorUI.getShortcuts().invokeFileSave();
  70. return true;
  71. }
  72. if (refid == "file close file") {
  73. EditorUI.getShortcuts().invokeFileClose();
  74. return true;
  75. }
  76. if (refid == "file save all") {
  77. this.sendEvent(EditorEvents.SaveAllResources);
  78. return true;
  79. }
  80. return false;
  81. } else if (target.id == "menu developer popup") {
  82. if (refid == "developer show console") {
  83. Atomic.ui.showConsole(true);
  84. return true;
  85. }
  86. } else if (target.id == "menu tools popup") {
  87. if (refid == "tools toggle profiler") {
  88. Atomic.ui.toggleDebugHud();
  89. return true;
  90. }
  91. } else if (target.id == "menu build popup") {
  92. if (refid == "build build") {
  93. EditorUI.getModelOps().showBuild();
  94. return true;
  95. }
  96. } else if (target.id == "menu help popup") {
  97. if (refid == "help forums") {
  98. Atomic.fileSystem.systemOpen("http://atomicgameengine.com/forum/")
  99. return true;
  100. } else if (refid == "help chat") {
  101. Atomic.fileSystem.systemOpen("https://gitter.im/AtomicGameEngine/AtomicGameEngine/")
  102. return true;
  103. } else if (refid == "help github") {
  104. Atomic.fileSystem.systemOpen("https://github.com/AtomicGameEngine/AtomicGameEngine/")
  105. return true;
  106. } else if (refid == "help api") {
  107. var url = "file://" + ToolCore.toolEnvironment.toolDataDir + "Docs/JSDocs/Atomic.html";
  108. Atomic.fileSystem.systemOpen(url);
  109. return true;
  110. }
  111. }
  112. }
  113. }
  114. export = MainFrameMenu;
  115. // initialization
  116. var StringID = strings.StringID;
  117. var editorItems = {
  118. "About Atomic Editor": "about atomic editor",
  119. "-1": null,
  120. "Manage License": "manage license",
  121. "-2": null,
  122. "Check for Updates": "check update",
  123. "-3": null,
  124. "Quit": "quit"
  125. };
  126. var editItems = {
  127. "Undo": ["edit undo", StringID.ShortcutUndo],
  128. "Redo": ["edit redo", StringID.ShortcutRedo],
  129. "-1": null,
  130. "Cut": ["edit cut", StringID.ShortcutCut],
  131. "Copy": ["edit copy", StringID.ShortcutCopy],
  132. "Paste": ["edit paste", StringID.ShortcutPaste],
  133. "Select All": ["edit select all", StringID.ShortcutSelectAll],
  134. "-2": null,
  135. "Find": ["edit find", StringID.ShortcutFind],
  136. "Find Next": ["edit find next", StringID.ShortcutFindNext],
  137. "Find Prev": ["edit find prev", StringID.ShortcutFindPrev],
  138. "-3": null,
  139. "Format Code": ["edit format code", StringID.ShortcutBeautify],
  140. "-4": null,
  141. "Play": ["edit play", StringID.ShortcutPlay]
  142. };
  143. var toolsItems = {
  144. "Toggle Profiler": ["tools toggle profiler"]
  145. }
  146. var buildItems = {
  147. "Build": ["build build", StringID.ShortcutBuild],
  148. "Build Settings": ["build settings", StringID.ShortcutBuildSettings]
  149. }
  150. var developerItems = {
  151. "Show Console": ["developer show console"]
  152. }
  153. var fileItems = {
  154. "New Project": ["file new project"],
  155. "Open Project": ["file open project"],
  156. "Save Project": ["file save project"],
  157. "-1": null,
  158. "Close Project": ["file close project"],
  159. "-2": null,
  160. "Save File": ["file save file", StringID.ShortcutSaveFile],
  161. "Save All Files": ["file save all"],
  162. "Close File": ["file close file", StringID.ShortcutCloseFile]
  163. }
  164. var helpItems = {
  165. "API Documentation": ["help api"],
  166. "-1": null,
  167. "Atomic Chat": ["help chat"],
  168. "Atomic Forums": ["help forums"],
  169. "-2": null,
  170. "Atomic Game Engine on GitHub": ["help github"]
  171. }