ModalOps.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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 EditorUI = require("../EditorUI");
  8. import ModalWindow = require("./ModalWindow");
  9. import About = require("./About");
  10. import NewProject = require("./NewProject");
  11. import CreateProject = require("./CreateProject");
  12. import EULAWindow = require("./license/EULAWindow");
  13. import ActivationWindow = require("./license/ActivationWindow");
  14. import ActivationSuccessWindow = require("./license/ActivationSuccessWindow");
  15. import ManageLicense = require("./license/ManageLicense");
  16. import Pro3DWindow = require("./license/Pro3DWindow");
  17. import ProPlatformWindow = require("./license/ProPlatformWindow");
  18. import BuildWindow = require("./build/BuildWindow");
  19. import BuildOutput = require("./build/BuildOutput");
  20. import BuildSettingsWindow = require("./build/BuildSettingsWindow");
  21. import ResourceSelection = require("./ResourceSelection");
  22. import UIResourceOps = require("./UIResourceOps");
  23. import SnapSettingsWindow = require("./SnapSettingsWindow");
  24. import ProjectTemplates = require("../../resources/ProjectTemplates");
  25. class ModalOps extends Atomic.ScriptObject {
  26. constructor() {
  27. super();
  28. this.dimmer = new Atomic.UIDimmer();
  29. }
  30. showCreateProject(projectTemplateDefinition: ProjectTemplates.ProjectTemplateDefinition) {
  31. if (this.show()) {
  32. this.opWindow = new CreateProject(projectTemplateDefinition);
  33. }
  34. }
  35. showCreateFolder(resourcePath: string) {
  36. if (this.show()) {
  37. this.opWindow = new UIResourceOps.CreateFolder(resourcePath);
  38. }
  39. }
  40. showCreateComponent(resourcePath: string) {
  41. if (this.show()) {
  42. this.opWindow = new UIResourceOps.CreateComponent(resourcePath);
  43. }
  44. }
  45. showCreateScript(resourcePath: string) {
  46. if (this.show()) {
  47. this.opWindow = new UIResourceOps.CreateScript(resourcePath);
  48. }
  49. }
  50. showCreateScene(resourcePath: string) {
  51. if (this.show()) {
  52. this.opWindow = new UIResourceOps.CreateScene(resourcePath);
  53. }
  54. }
  55. showCreateMaterial(resourcePath: string) {
  56. if (this.show()) {
  57. this.opWindow = new UIResourceOps.CreateMaterial(resourcePath);
  58. }
  59. }
  60. showResourceDelete(asset: ToolCore.Asset) {
  61. if (this.show()) {
  62. this.opWindow = new UIResourceOps.ResourceDelete(asset);
  63. }
  64. }
  65. showRenameAsset(asset: ToolCore.Asset) {
  66. if (this.show()) {
  67. this.opWindow = new UIResourceOps.RenameAsset(asset);
  68. }
  69. }
  70. showResourceSelection(windowText: string, importerType: string, resourceType: string, callback: (retObject: any, args: any) => void, args: any = undefined) {
  71. if (this.show()) {
  72. this.opWindow = new ResourceSelection(windowText, importerType, resourceType, callback, args);
  73. }
  74. }
  75. showNewProject() {
  76. if (this.show()) {
  77. this.opWindow = new NewProject();
  78. }
  79. }
  80. showEULAWindow() {
  81. if (this.show()) {
  82. this.opWindow = new EULAWindow();
  83. }
  84. }
  85. showActivationWindow() {
  86. if (this.show()) {
  87. this.opWindow = new ActivationWindow();
  88. }
  89. }
  90. showManageLicense() {
  91. if (this.show()) {
  92. this.opWindow = new ManageLicense();
  93. }
  94. }
  95. showPro3DWindow() {
  96. if (this.show()) {
  97. this.opWindow = new Pro3DWindow();
  98. }
  99. }
  100. showProPlatformWindow() {
  101. if (this.show()) {
  102. this.opWindow = new ProPlatformWindow();
  103. }
  104. }
  105. showAbout() {
  106. if (this.show()) {
  107. this.opWindow = new About();
  108. }
  109. }
  110. showBuild() {
  111. if (!ToolCore.toolSystem.project)
  112. return;
  113. if (this.show()) {
  114. this.opWindow = new BuildWindow();
  115. }
  116. }
  117. showBuildSettings() {
  118. if (!ToolCore.toolSystem.project)
  119. return;
  120. if (this.show()) {
  121. this.opWindow = new BuildSettingsWindow.BuildSettingsWindow();
  122. }
  123. }
  124. showBuildOutput(buildBase: ToolCore.BuildBase) {
  125. if (this.show()) {
  126. this.opWindow = new BuildOutput(buildBase);
  127. }
  128. }
  129. showActivationSuccessWindow() {
  130. if (this.show()) {
  131. this.opWindow = new ActivationSuccessWindow();
  132. }
  133. }
  134. showSnapSettings() {
  135. // only show snap settings if we have a project loaded
  136. if (!ToolCore.toolSystem.project)
  137. return;
  138. if (this.show()) {
  139. this.opWindow = new SnapSettingsWindow();
  140. }
  141. }
  142. private show(): boolean {
  143. if (this.dimmer.parent) {
  144. console.log("WARNING: attempting to show modal while dimmer is active");
  145. return false;
  146. }
  147. if (this.opWindow) {
  148. console.log("WARNING: attempting to show modal while another opWindow is active");
  149. return false;
  150. }
  151. var view = EditorUI.getView();
  152. view.addChild(this.dimmer);
  153. return true;
  154. }
  155. hide() {
  156. if (this.opWindow) {
  157. var window = this.opWindow;
  158. this.opWindow = null;
  159. if (window.parent)
  160. window.parent.removeChild(window, false);
  161. var view = EditorUI.getView();
  162. view.setFocusRecursive();
  163. }
  164. if (this.dimmer.parent) {
  165. this.dimmer.parent.removeChild(this.dimmer, false);
  166. }
  167. }
  168. dimmer: Atomic.UIDimmer;
  169. opWindow: ModalWindow;
  170. }
  171. export = ModalOps;