ModalOps.ts 3.1 KB

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