ModalOps.ts 3.6 KB

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