BuildWindow.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 EditorEvents = require("editor/EditorEvents");
  23. import EditorUI = require("ui/EditorUI");
  24. import ModalWindow = require("../ModalWindow");
  25. import ProgressModal = require("../ProgressModal");
  26. import UIEvents = require("../../UIEvents");
  27. import WindowsSettingsWidget = require("./platforms/WindowsSettingsWidget");
  28. import MacSettingsWidget = require("./platforms/MacSettingsWidget");
  29. import AndroidSettingsWidget = require("./platforms/AndroidSettingsWidget");
  30. import IOSSettingsWidget = require("./platforms/IOSSettingsWidget");
  31. import WebSettingsWidget = require("./platforms/WebSettingsWidget");
  32. class BuildWindow extends ModalWindow {
  33. constructor() {
  34. super();
  35. this.init("Build Settings", "AtomicEditor/editor/ui/build.tb.txt");
  36. this.buildPathField = <Atomic.UITextField>this.getWidget("build_path");
  37. this.platformIndicator = <Atomic.UISkinImage>this.getWidget("current_platform_indicator");
  38. var currentPlatform = ToolCore.toolSystem.currentPlatform;
  39. this.buildPathField.text = ToolCore.toolSystem.project.userPrefs.lastBuildPath;
  40. switch (currentPlatform.name) {
  41. case "WINDOWS": this.platformIndicator.skinBg = "LogoWindows"; break;
  42. case "MAC": this.platformIndicator.skinBg = "LogoMac"; break;
  43. case "ANDROID": this.platformIndicator.skinBg = "LogoAndroid"; break;
  44. case "IOS": this.platformIndicator.skinBg = "LogoIOS"; break;
  45. case "WEB": this.platformIndicator.skinBg = "LogoHTML5"; break;
  46. }
  47. this.subscribeToEvent(this, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
  48. }
  49. handleWidgetEvent(ev: Atomic.UIWidgetEvent): boolean {
  50. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  51. if (ev.target.id == "cancel") {
  52. this.hide();
  53. return true;
  54. }
  55. if (ev.target.id == "build") {
  56. var toolSystem = ToolCore.toolSystem;
  57. var userPrefs = ToolCore.toolSystem.project.userPrefs;
  58. if (this.buildPathField.text != userPrefs.lastBuildPath) {
  59. userPrefs.lastBuildPath = this.buildPathField.text;
  60. ToolCore.toolSystem.project.saveUserPrefs();
  61. }
  62. if (!userPrefs.lastBuildPath.length || !Atomic.fileSystem.dirExists(userPrefs.lastBuildPath)) {
  63. new Atomic.UIMessageWindow(this, "modal_error").show("Build Folder", "Please select an existing build folder", Atomic.UI_MESSAGEWINDOW_SETTINGS_OK, true, 480, 240);
  64. return true;
  65. }
  66. this.hide();
  67. this.build();
  68. return true;
  69. }
  70. if (ev.target.id == "choose_path") {
  71. var utils = new Editor.FileUtils();
  72. var buildPath = utils.getBuildPath("");
  73. if (buildPath && buildPath.length)
  74. this.buildPathField.text = buildPath;
  75. return true;
  76. }
  77. }
  78. }
  79. build() {
  80. var buildSystem = ToolCore.buildSystem;
  81. var toolSystem = ToolCore.toolSystem;
  82. var userPrefs = ToolCore.toolSystem.project.userPrefs;
  83. buildSystem.buildPath = userPrefs.lastBuildPath;
  84. var project = toolSystem.project;
  85. var platform = toolSystem.currentPlatform;
  86. var buildBase = platform.newBuild(project);
  87. EditorUI.getModelOps().showBuildOutput(buildBase);
  88. buildSystem.queueBuild(buildBase);
  89. buildSystem.startNextBuild();
  90. }
  91. buildPathField: Atomic.UITextField;
  92. platformIndicator: Atomic.UISkinImage;
  93. }
  94. export = BuildWindow;
  95. /*
  96. buildPathField_ = delegate_->GetWidgetByIDAndType<TBTextField>(TBIDC("build_path"));
  97. assert(buildPathField_);
  98. String buildPath = project->GetLastBuildPath();
  99. buildPathField_->SetText(buildPath.CString());
  100. window_->ResizeToFitContent();
  101. Center();
  102. AEEditorPlatform platform = editor->GetCurrentPlatform();
  103. TBSkinImage* platformIndicator = window_->GetContentRoot()->GetWidgetByIDAndType<TBSkinImage>(TBIDC("current_platform_indicator"));
  104. assert(platformIndicator);
  105. if (platform == AE_PLATFORM_MAC)
  106. platformIndicator->SetSkinBg(TBIDC("LogoMac"));
  107. else if (platform == AE_PLATFORM_WINDOWS)
  108. platformIndicator->SetSkinBg(TBIDC("LogoWindows"));
  109. else if (platform == AE_PLATFORM_ANDROID)
  110. platformIndicator->SetSkinBg(TBIDC("LogoAndroid"));
  111. else if (platform == AE_PLATFORM_HTML5)
  112. platformIndicator->SetSkinBg(TBIDC("LogoHTML5"));
  113. else if (platform == AE_PLATFORM_IOS)
  114. platformIndicator->SetSkinBg(TBIDC("LogoIOS"));
  115. */