ModalOps.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. showCreateMaterial(resourcePath:string) {
  36. if (this.show()) {
  37. this.opWindow = new UIResourceOps.CreateMaterial(resourcePath);
  38. }
  39. }
  40. showResourceDelete(asset:ToolCore.Asset) {
  41. if (this.show()) {
  42. this.opWindow = new UIResourceOps.ResourceDelete(asset);
  43. }
  44. }
  45. showResourceSelection(windowText:string, importerType:string, callback: (asset: ToolCore.Asset, args:any) => void, args:any = undefined) {
  46. if (this.show()) {
  47. this.opWindow = new ResourceSelection(windowText, importerType, callback, args);
  48. }
  49. }
  50. showNewProject() {
  51. if (this.show()) {
  52. this.opWindow = new NewProject();
  53. }
  54. }
  55. showEULAWindow() {
  56. if (this.show()) {
  57. this.opWindow = new EULAWindow();
  58. }
  59. }
  60. showActivationWindow() {
  61. if (this.show()) {
  62. this.opWindow = new ActivationWindow();
  63. }
  64. }
  65. showActivationSuccessWindow() {
  66. if (this.show()) {
  67. this.opWindow = new ActivationSuccessWindow();
  68. }
  69. }
  70. private show(): boolean {
  71. if (this.dimmer.parent) {
  72. console.log("WARNING: attempting to show modal while dimmer is active");
  73. return false;
  74. }
  75. if (this.opWindow) {
  76. console.log("WARNING: attempting to show modal while another opWindow is active");
  77. return false;
  78. }
  79. var view = EditorUI.getView();
  80. view.addChild(this.dimmer);
  81. return true;
  82. }
  83. hide() {
  84. if (this.opWindow) {
  85. var window = this.opWindow;
  86. this.opWindow = null;
  87. if (window.parent)
  88. window.parent.removeChild(window, false);
  89. var view = EditorUI.getView();
  90. view.setFocusRecursive();
  91. }
  92. if (this.dimmer.parent) {
  93. this.dimmer.parent.removeChild(this.dimmer, false);
  94. }
  95. }
  96. dimmer: Atomic.UIDimmer;
  97. opWindow: ModalWindow;
  98. }
  99. export = ModalOps;