ModalOps.ts 4.2 KB

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