EditorUI.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import EditorEvents = require("../editor/EditorEvents");
  2. import MainFrame = require("../ui/MainFrame");
  3. import ModalOps = require("./modal/ModalOps");
  4. // this is designed with public get functions to solve
  5. // circular dependency issues in TS
  6. var editorUI:EditorUI;
  7. export function getMainFrame():MainFrame {
  8. return editorUI.mainframe;
  9. }
  10. export function getModelOps():ModalOps {
  11. return editorUI.modalOps;
  12. }
  13. export function getView():Atomic.UIView {
  14. return editorUI.view;
  15. }
  16. export function initialize() {
  17. editorUI = new EditorUI();
  18. }
  19. export function showModalError(windowText:string, message:string) {
  20. editorUI.showModalError(windowText, message);
  21. }
  22. class EditorUI extends Atomic.ScriptObject {
  23. constructor() {
  24. super();
  25. var graphics = Atomic.getGraphics();
  26. this.view = new Atomic.UIView();
  27. this.mainframe = new MainFrame();
  28. this.view.addChild(this.mainframe);
  29. // set initial size
  30. this.mainframe.setSize(graphics.width, graphics.height);
  31. this.modalOps = new ModalOps();
  32. this.subscribeToEvent(EditorEvents.ModalError, (event:EditorEvents.ModalErrorEvent) => {
  33. this.showModalError(event.title, event.message);
  34. })
  35. }
  36. showModalError(windowText:string, message:string)
  37. {
  38. var window = new Atomic.UIMessageWindow(this.view, "modal_error");
  39. window.show(windowText, message, 640, 360);
  40. }
  41. view: Atomic.UIView;
  42. mainframe: MainFrame;
  43. modalOps: ModalOps;
  44. }