ModalOps.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. import EditorUI = require("../EditorUI");
  23. import ModalWindow = require("./ModalWindow");
  24. import About = require("./About");
  25. import NewProject = require("./NewProject");
  26. import CreateProject = require("./CreateProject");
  27. import EULAWindow = require("./license/EULAWindow");
  28. import ActivationWindow = require("./license/ActivationWindow");
  29. import ActivationSuccessWindow = require("./license/ActivationSuccessWindow");
  30. import ManageLicense = require("./license/ManageLicense");
  31. import Pro3DWindow = require("./license/Pro3DWindow");
  32. import ProPlatformWindow = require("./license/ProPlatformWindow");
  33. import BuildWindow = require("./build/BuildWindow");
  34. import BuildOutput = require("./build/BuildOutput");
  35. import BuildSettingsWindow = require("./build/BuildSettingsWindow");
  36. import ResourceSelection = require("./ResourceSelection");
  37. import UIResourceOps = require("./UIResourceOps");
  38. import SnapSettingsWindow = require("./SnapSettingsWindow");
  39. import ProjectTemplates = require("../../resources/ProjectTemplates");
  40. class ModalOps extends Atomic.ScriptObject {
  41. constructor() {
  42. super();
  43. this.dimmer = new Atomic.UIDimmer();
  44. }
  45. showCreateProject(projectTemplateDefinition: ProjectTemplates.ProjectTemplateDefinition) {
  46. if (this.show()) {
  47. this.opWindow = new CreateProject(projectTemplateDefinition);
  48. }
  49. }
  50. showCreateFolder(resourcePath: string) {
  51. if (this.show()) {
  52. this.opWindow = new UIResourceOps.CreateFolder(resourcePath);
  53. }
  54. }
  55. showCreateComponent(resourcePath: string) {
  56. if (this.show()) {
  57. this.opWindow = new UIResourceOps.CreateComponent(resourcePath);
  58. }
  59. }
  60. showCreateScript(resourcePath: string) {
  61. if (this.show()) {
  62. this.opWindow = new UIResourceOps.CreateScript(resourcePath);
  63. }
  64. }
  65. showCreateScene(resourcePath: string) {
  66. if (this.show()) {
  67. this.opWindow = new UIResourceOps.CreateScene(resourcePath);
  68. }
  69. }
  70. showCreateMaterial(resourcePath: string) {
  71. if (this.show()) {
  72. this.opWindow = new UIResourceOps.CreateMaterial(resourcePath);
  73. }
  74. }
  75. showResourceDelete(asset: ToolCore.Asset) {
  76. if (this.show()) {
  77. this.opWindow = new UIResourceOps.ResourceDelete(asset);
  78. }
  79. }
  80. showRenameAsset(asset: ToolCore.Asset) {
  81. if (this.show()) {
  82. this.opWindow = new UIResourceOps.RenameAsset(asset);
  83. }
  84. }
  85. showResourceSelection(windowText: string, importerType: string, resourceType: string, callback: (retObject: any, args: any) => void, args: any = undefined) {
  86. if (this.show()) {
  87. this.opWindow = new ResourceSelection(windowText, importerType, resourceType, callback, args);
  88. }
  89. }
  90. showNewProject() {
  91. if (this.show()) {
  92. this.opWindow = new NewProject();
  93. }
  94. }
  95. showEULAWindow() {
  96. if (this.show()) {
  97. this.opWindow = new EULAWindow();
  98. }
  99. }
  100. showActivationWindow() {
  101. if (this.show()) {
  102. this.opWindow = new ActivationWindow();
  103. }
  104. }
  105. showManageLicense() {
  106. if (this.show()) {
  107. this.opWindow = new ManageLicense();
  108. }
  109. }
  110. showPro3DWindow() {
  111. if (this.show()) {
  112. this.opWindow = new Pro3DWindow();
  113. }
  114. }
  115. showProPlatformWindow() {
  116. if (this.show()) {
  117. this.opWindow = new ProPlatformWindow();
  118. }
  119. }
  120. showAbout() {
  121. if (this.show()) {
  122. this.opWindow = new About();
  123. }
  124. }
  125. showBuild() {
  126. if (!ToolCore.toolSystem.project)
  127. return;
  128. if (this.show()) {
  129. this.opWindow = new BuildWindow();
  130. }
  131. }
  132. showBuildSettings() {
  133. if (!ToolCore.toolSystem.project)
  134. return;
  135. if (this.show()) {
  136. this.opWindow = new BuildSettingsWindow.BuildSettingsWindow();
  137. }
  138. }
  139. showBuildOutput(buildBase: ToolCore.BuildBase) {
  140. if (this.show()) {
  141. this.opWindow = new BuildOutput(buildBase);
  142. }
  143. }
  144. showActivationSuccessWindow() {
  145. if (this.show()) {
  146. this.opWindow = new ActivationSuccessWindow();
  147. }
  148. }
  149. showSnapSettings() {
  150. // only show snap settings if we have a project loaded
  151. if (!ToolCore.toolSystem.project)
  152. return;
  153. if (this.show()) {
  154. this.opWindow = new SnapSettingsWindow();
  155. }
  156. }
  157. private show(): boolean {
  158. if (this.dimmer.parent) {
  159. console.log("WARNING: attempting to show modal while dimmer is active");
  160. return false;
  161. }
  162. if (this.opWindow) {
  163. console.log("WARNING: attempting to show modal while another opWindow is active");
  164. return false;
  165. }
  166. var view = EditorUI.getView();
  167. view.addChild(this.dimmer);
  168. return true;
  169. }
  170. hide() {
  171. if (this.opWindow) {
  172. var window = this.opWindow;
  173. this.opWindow = null;
  174. if (window.parent)
  175. window.parent.removeChild(window, false);
  176. var view = EditorUI.getView();
  177. view.setFocusRecursive();
  178. }
  179. if (this.dimmer.parent) {
  180. this.dimmer.parent.removeChild(this.dimmer, false);
  181. }
  182. }
  183. dimmer: Atomic.UIDimmer;
  184. opWindow: ModalWindow;
  185. }
  186. export = ModalOps;