ModalOps.ts 3.8 KB

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