WebSettingsWidget.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 WebSettingsWidget extends Atomic.UIWidget implements BuildSettingsWindow.BuildSettingsWidget {
  24. constructor() {
  25. super();
  26. this.settings = ToolCore.toolSystem.project.buildSettings.webBuildSettings;
  27. this.load("AtomicEditor/editor/ui/buildsettings_html5.tb.txt");
  28. this.appNameEdit = <Atomic.UIEditField>this.getWidget("app_name");
  29. this.radioDark = <Atomic.UICheckBox>this.getWidget("web_dark");
  30. this.radioLight = <Atomic.UICheckBox>this.getWidget("web_light");
  31. this.radioAtomic = <Atomic.UICheckBox>this.getWidget("web_atomic");
  32. this.radioLake = <Atomic.UICheckBox>this.getWidget("web_lake");
  33. this.radioFireworks = <Atomic.UICheckBox>this.getWidget("web_fireworks");
  34. this.radioRetro = <Atomic.UICheckBox>this.getWidget("web_retro");
  35. this.faviconName = <Atomic.UIEditField>this.getWidget("favicon_name");
  36. this.gameWidth = <Atomic.UIEditField>this.getWidget("web_game_width");
  37. this.gameHeight = <Atomic.UIEditField>this.getWidget("web_game_height");
  38. this.refreshWidgets();
  39. this.subscribeToEvent(this, Atomic.UIWidgetEvent((ev) => this.handleWidgetEvent(ev)));
  40. }
  41. handleWidgetEvent(ev: Atomic.UIWidgetEvent): boolean {
  42. if (ev.target.id == "favicon_choose") {
  43. var fileUtils = new Editor.FileUtils();
  44. var path = fileUtils.findFile("", "");
  45. if ( path.length > 0 )
  46. this.faviconName.text = path;
  47. return true;
  48. }
  49. if (ev.type == Atomic.UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  50. if (ev.target.id == "web_dark") {
  51. this.settings.pageTheme = 0;
  52. }
  53. if (ev.target.id == "web_light") {
  54. this.settings.pageTheme = 1;
  55. }
  56. if (ev.target.id == "web_atomic") {
  57. this.settings.pageTheme = 2;
  58. }
  59. if (ev.target.id == "web_lake") {
  60. this.settings.pageTheme = 3;
  61. }
  62. if (ev.target.id == "web_fireworks") {
  63. this.settings.pageTheme = 4;
  64. }
  65. if (ev.target.id == "web_retro") {
  66. this.settings.pageTheme = 5;
  67. }
  68. return true;
  69. }
  70. return false;
  71. }
  72. refreshWidgets() {
  73. this.appNameEdit.text = this.settings.appName;
  74. this.faviconName.text = this.settings.faviconName;
  75. this.gameWidth.text = this.settings.gameWidth;
  76. this.gameHeight.text = this.settings.gameHeight;
  77. if ( this.settings.pageTheme == 0 ) this.radioDark.value = 1;
  78. else this.radioDark.value = 0;
  79. if ( this.settings.pageTheme == 1 ) this.radioLight.value = 1;
  80. else this.radioLight.value = 0;
  81. if ( this.settings.pageTheme == 2 ) this.radioAtomic.value = 1;
  82. else this.radioAtomic.value = 0;
  83. if ( this.settings.pageTheme == 3 ) this.radioLake.value = 1;
  84. else this.radioLake.value = 0;
  85. if ( this.settings.pageTheme == 4 ) this.radioFireworks.value = 1;
  86. else this.radioFireworks.value = 0;
  87. if ( this.settings.pageTheme == 5 ) this.radioRetro.value = 1;
  88. else this.radioRetro.value = 0;
  89. }
  90. storeValues() {
  91. this.settings.appName = this.appNameEdit.text;
  92. this.settings.faviconName = this.faviconName.text;
  93. this.settings.gameWidth = this.gameWidth.text;
  94. this.settings.gameHeight = this.gameHeight.text;
  95. if ( this.radioDark.value == 1 ) this.settings.pageTheme = 0;
  96. if ( this.radioLight.value == 1 ) this.settings.pageTheme = 1;
  97. if ( this.radioAtomic.value == 1 ) this.settings.pageTheme = 2;
  98. if ( this.radioLake.value == 1 ) this.settings.pageTheme = 3;
  99. if ( this.radioFireworks.value == 1 ) this.settings.pageTheme = 4;
  100. if ( this.radioRetro.value == 1 ) this.settings.pageTheme = 5;
  101. }
  102. appNameEdit: Atomic.UIEditField;
  103. radioRetro: Atomic.UICheckBox;
  104. radioDark: Atomic.UICheckBox;
  105. radioLight: Atomic.UICheckBox;
  106. radioAtomic: Atomic.UICheckBox;
  107. radioLake: Atomic.UICheckBox;
  108. radioFireworks: Atomic.UICheckBox;
  109. faviconChoose: Atomic.UIButton;
  110. faviconName: Atomic.UIEditField;
  111. gameWidth: Atomic.UIEditField;
  112. gameHeight: Atomic.UIEditField;
  113. settings: ToolCore.WebBuildSettings;
  114. }
  115. export = WebSettingsWidget;