ModalOps.ts 4.9 KB

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