GlowOutput.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. class GlowOutput extends Atomic.UIWindow {
  24. constructor() {
  25. super();
  26. this.settings = Atomic.UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT & ~Atomic.UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_CLOSE_BUTTON;
  27. this.text = "Atomic Glow";
  28. this.load("AtomicEditor/editor/ui/atomicglowoutput.tb.txt");
  29. this.outputField = <Atomic.UIEditField>this.getWidget("output");
  30. this.resizeToFitContent();
  31. this.center();
  32. this.subscribeToEvent(Editor.AtomicGlowLogEvent((ev: Editor.AtomicGlowLogEvent) => {
  33. this.textOutput += ev.message + "\n";
  34. this.outputField.text = this.textOutput;
  35. this.outputField.scrollTo(0, 0xffffff);
  36. }));
  37. this.subscribeToEvent(this, Atomic.UIWidgetEvent((data) => this.handleWidgetEvent(data)));
  38. this.dimmer = new Atomic.UIDimmer();
  39. }
  40. handleWidgetEvent(ev: Atomic.UIWidgetEvent): boolean {
  41. if (ev.type == Atomic.UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  42. if (ev.target.id == "cancel") {
  43. this.sendEvent(Editor.AtomicGlowBakeCancelEventType);
  44. return true;
  45. }
  46. if (ev.target.id == "ok") {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. show() {
  53. var view = EditorUI.getView();
  54. view.addChild(this.dimmer);
  55. view.addChild(this);
  56. }
  57. hide() {
  58. this.unsubscribeFromEvent(Editor.AtomicGlowLogEventType);
  59. if (this.dimmer.parent)
  60. this.dimmer.parent.removeChild(this.dimmer, false);
  61. if (this.parent)
  62. this.parent.removeChild(this, false);
  63. }
  64. dimmer: Atomic.UIDimmer;
  65. textOutput: string = "";
  66. outputField: Atomic.UIEditField;
  67. }
  68. export = GlowOutput;