PlayerOutput.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. import EditorEvents = require("../../editor/EditorEvents");
  8. import EditorUI = require("../EditorUI");
  9. class PlayerOutput extends Atomic.UIWindow {
  10. output: Atomic.UIEditField;
  11. constructor() {
  12. super();
  13. var view = EditorUI.getView();
  14. view.addChild(this);
  15. this.text = "Player Output";
  16. this.load("AtomicEditor/editor/ui/playeroutput.tb.txt")
  17. this.output = <Atomic.UIEditField> this.getWidget("output");
  18. (<Atomic.UIButton>this.getWidget("closebutton")).onClick = () => {
  19. this.close();
  20. }
  21. this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
  22. this.subscribeToEvent(EditorEvents.PlayerLog, (ev: EditorEvents.PlayerLogEvent) => this.handlePlayerLog(ev));
  23. this.resizeToFitContent();
  24. this.center();
  25. this.setFocus();
  26. }
  27. handlePlayerLog(ev: EditorEvents.PlayerLogEvent) {
  28. var text = this.output.text;
  29. if (text.length > 32768)
  30. this.output.text = "";
  31. this.output.appendText(ev.message + "\n");
  32. this.output.scrollTo(0, 0xffffff);
  33. }
  34. handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
  35. }
  36. }
  37. export = PlayerOutput;