PlayerOutput.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import EditorEvents = require("../../editor/EditorEvents");
  2. import EditorUI = require("../EditorUI");
  3. class PlayerOutput extends Atomic.UIWindow {
  4. output: Atomic.UIEditField;
  5. constructor() {
  6. super();
  7. var view = EditorUI.getView();
  8. view.addChild(this);
  9. this.text = "Player Output";
  10. this.load("AtomicEditor/editor/ui/playeroutput.tb.txt")
  11. this.output = <Atomic.UIEditField> this.getWidget("output");
  12. (<Atomic.UIButton>this.getWidget("closebutton")).onClick = () => {
  13. this.close();
  14. }
  15. this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
  16. this.subscribeToEvent(EditorEvents.PlayerLog, (ev: EditorEvents.PlayerLogEvent) => this.handlePlayerLog(ev));
  17. this.resizeToFitContent();
  18. this.center();
  19. this.setFocus();
  20. }
  21. handlePlayerLog(ev: EditorEvents.PlayerLogEvent) {
  22. var text = this.output.text;
  23. if (text.length > 32768)
  24. this.output.text = "";
  25. this.output.appendText(ev.message + "\n");
  26. this.output.scrollTo(0, 0xffffff);
  27. }
  28. handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
  29. }
  30. }
  31. export = PlayerOutput;