ModalOps.ts 4.0 KB

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