IOSSettingsWidget.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 BuildSettingsWindow = require("../BuildSettingsWindow");
  23. class IOSSettingsWidget extends Atomic.UIWidget implements BuildSettingsWindow.BuildSettingsWidget {
  24. constructor() {
  25. super();
  26. this.load("AtomicEditor/editor/ui/buildsettings_ios.tb.txt");
  27. this.settings = ToolCore.toolSystem.project.buildSettings.iOSBuildSettings;
  28. this.appNameEdit = <Atomic.UIEditField>this.getWidget("app_name");
  29. this.packageNameEdit = <Atomic.UIEditField>this.getWidget("app_package");
  30. this.productNameEdit = <Atomic.UIEditField>this.getWidget("product_name");
  31. this.companyNameEdit = <Atomic.UIEditField>this.getWidget("company_name");
  32. this.provisionPathEdit = <Atomic.UIEditField>this.getWidget("provision_path");
  33. this.appIDPrefixField = <Atomic.UITextField>this.getWidget("appid_prefix");
  34. this.refreshWidgets();
  35. this.subscribeToEvent(this, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
  36. }
  37. refreshWidgets() {
  38. this.appNameEdit.text = this.settings.appName;
  39. this.packageNameEdit.text = this.settings.packageName;
  40. this.productNameEdit.text = this.settings.productName;
  41. this.companyNameEdit.text = this.settings.companyName;
  42. this.provisionPathEdit.text = this.settings.provisionFile;
  43. this.appIDPrefixField.text = this.settings.appIDPrefix;
  44. }
  45. handleWidgetEvent(ev: Atomic.UIWidgetEvent): boolean {
  46. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  47. if (ev.target.id == "choose_provision_path") {
  48. var fileUtils = new Editor.FileUtils();
  49. var path = fileUtils.getMobileProvisionPath();
  50. if (path.length) {
  51. var platform = <ToolCore.PlatformIOS> ToolCore.toolSystem.getPlatformByName("IOS");
  52. var prefix = platform.parseProvisionAppIdentifierPrefix(path);
  53. if (prefix.length) {
  54. this.provisionPathEdit.text = path;
  55. this.appIDPrefixField.text = prefix;
  56. }
  57. }
  58. return true;
  59. }
  60. }
  61. return true;
  62. }
  63. storeValues() {
  64. this.settings.appName = this.appNameEdit.text;
  65. this.settings.packageName = this.packageNameEdit.text;
  66. this.settings.productName = this.productNameEdit.text;
  67. this.settings.companyName = this.companyNameEdit.text;
  68. this.settings.provisionFile = this.provisionPathEdit.text;
  69. this.settings.appIDPrefix = this.appIDPrefixField.text;
  70. }
  71. settings: ToolCore.IOSBuildSettings;
  72. appNameEdit: Atomic.UIEditField;
  73. packageNameEdit: Atomic.UIEditField;
  74. productNameEdit: Atomic.UIEditField;
  75. companyNameEdit: Atomic.UIEditField;
  76. provisionPathEdit: Atomic.UIEditField;
  77. appIDPrefixField: Atomic.UITextField;
  78. }
  79. export = IOSSettingsWidget;