ModalOps.ts 5.6 KB

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