ModalOps.ts 4.4 KB

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