ModalOps.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 ExtensionWindow = require("./ExtensionWindow");
  40. import ProjectTemplates = require("../../resources/ProjectTemplates");
  41. class ModalOps extends Atomic.ScriptObject {
  42. constructor() {
  43. super();
  44. this.dimmer = new Atomic.UIDimmer();
  45. }
  46. showCreateProject(projectTemplateDefinition: ProjectTemplates.ProjectTemplateDefinition) {
  47. if (this.show()) {
  48. this.opWindow = new CreateProject(projectTemplateDefinition);
  49. }
  50. }
  51. showCreateFolder(resourcePath: string) {
  52. if (this.show()) {
  53. this.opWindow = new UIResourceOps.CreateFolder(resourcePath);
  54. }
  55. }
  56. showCreateComponent(resourcePath: string) {
  57. if (this.show()) {
  58. this.opWindow = new UIResourceOps.CreateComponent(resourcePath);
  59. }
  60. }
  61. showCreateScript(resourcePath: string) {
  62. if (this.show()) {
  63. this.opWindow = new UIResourceOps.CreateScript(resourcePath);
  64. }
  65. }
  66. showCreateScene(resourcePath: string) {
  67. if (this.show()) {
  68. this.opWindow = new UIResourceOps.CreateScene(resourcePath);
  69. }
  70. }
  71. showCreateMaterial(resourcePath: string) {
  72. if (this.show()) {
  73. this.opWindow = new UIResourceOps.CreateMaterial(resourcePath);
  74. }
  75. }
  76. showResourceDelete(asset: ToolCore.Asset) {
  77. if (this.show()) {
  78. this.opWindow = new UIResourceOps.ResourceDelete(asset);
  79. }
  80. }
  81. showRenameAsset(asset: ToolCore.Asset) {
  82. if (this.show()) {
  83. this.opWindow = new UIResourceOps.RenameAsset(asset);
  84. }
  85. }
  86. showResourceSelection(windowText: string, importerType: string, resourceType: string, callback: (retObject: any, args: any) => void, args: any = undefined) {
  87. if (this.show()) {
  88. this.opWindow = new ResourceSelection(windowText, importerType, resourceType, callback, args);
  89. }
  90. }
  91. showNewProject() {
  92. if (this.show()) {
  93. this.opWindow = new NewProject();
  94. }
  95. }
  96. showEULAWindow() {
  97. if (this.show()) {
  98. this.opWindow = new EULAWindow();
  99. }
  100. }
  101. showActivationWindow() {
  102. if (this.show()) {
  103. this.opWindow = new ActivationWindow();
  104. }
  105. }
  106. showManageLicense() {
  107. if (this.show()) {
  108. this.opWindow = new ManageLicense();
  109. }
  110. }
  111. showPro3DWindow() {
  112. if (this.show()) {
  113. this.opWindow = new Pro3DWindow();
  114. }
  115. }
  116. showProPlatformWindow() {
  117. if (this.show()) {
  118. this.opWindow = new ProPlatformWindow();
  119. }
  120. }
  121. showAbout() {
  122. if (this.show()) {
  123. this.opWindow = new About();
  124. }
  125. }
  126. showBuild() {
  127. if (!ToolCore.toolSystem.project)
  128. return;
  129. if (this.show()) {
  130. this.opWindow = new BuildWindow();
  131. }
  132. }
  133. showBuildSettings() {
  134. if (!ToolCore.toolSystem.project)
  135. return;
  136. if (this.show()) {
  137. this.opWindow = new BuildSettingsWindow.BuildSettingsWindow();
  138. }
  139. }
  140. showBuildOutput(buildBase: ToolCore.BuildBase) {
  141. if (this.show()) {
  142. this.opWindow = new BuildOutput(buildBase);
  143. }
  144. }
  145. showActivationSuccessWindow() {
  146. if (this.show()) {
  147. this.opWindow = new ActivationSuccessWindow();
  148. }
  149. }
  150. showSnapSettings() {
  151. // only show snap settings if we have a project loaded
  152. if (!ToolCore.toolSystem.project)
  153. return;
  154. if (this.show()) {
  155. this.opWindow = new SnapSettingsWindow();
  156. }
  157. }
  158. showExtensionWindow(windowText: string, uifilename: string, handleWidgetEventCB: (ev: Atomic.UIWidgetEvent) => void): Editor.Modal.ExtensionWindow {
  159. if (this.show()) {
  160. this.opWindow = new ExtensionWindow(windowText, uifilename, handleWidgetEventCB);
  161. return this.opWindow;
  162. }
  163. }
  164. private show(): boolean {
  165. if (this.dimmer.parent) {
  166. console.log("WARNING: attempting to show modal while dimmer is active");
  167. return false;
  168. }
  169. if (this.opWindow) {
  170. console.log("WARNING: attempting to show modal while another opWindow is active");
  171. return false;
  172. }
  173. var view = EditorUI.getView();
  174. view.addChild(this.dimmer);
  175. return true;
  176. }
  177. hide() {
  178. if (this.opWindow) {
  179. var window = this.opWindow;
  180. this.opWindow = null;
  181. if (window.parent)
  182. window.parent.removeChild(window, false);
  183. var view = EditorUI.getView();
  184. view.setFocusRecursive();
  185. }
  186. if (this.dimmer.parent) {
  187. this.dimmer.parent.removeChild(this.dimmer, false);
  188. }
  189. }
  190. dimmer: Atomic.UIDimmer;
  191. opWindow: ModalWindow;
  192. }
  193. export = ModalOps;