ModalOps.ts 5.3 KB

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