BuildWindow.ts 5.7 KB

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