ModalOps.ts 4.6 KB

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