EditorUI.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 shutdown() {
  20. editorUI.mainframe.shutdown();
  21. var view = editorUI.view;
  22. view.deleteAllChildren();
  23. view.parent.removeChild(view);
  24. }
  25. export function showModalError(windowText:string, message:string) {
  26. editorUI.showModalError(windowText, message);
  27. }
  28. class EditorUI extends Atomic.ScriptObject {
  29. constructor() {
  30. super();
  31. var graphics = Atomic.getGraphics();
  32. this.view = new Atomic.UIView();
  33. this.mainframe = new MainFrame();
  34. this.view.addChild(this.mainframe);
  35. // set initial size
  36. this.mainframe.setSize(graphics.width, graphics.height);
  37. this.modalOps = new ModalOps();
  38. this.subscribeToEvent(EditorEvents.ModalError, (event:EditorEvents.ModalErrorEvent) => {
  39. this.showModalError(event.title, event.message);
  40. })
  41. }
  42. showModalError(windowText:string, message:string)
  43. {
  44. var window = new Atomic.UIMessageWindow(this.view, "modal_error");
  45. window.show(windowText, message, 640, 360);
  46. }
  47. view: Atomic.UIView;
  48. mainframe: MainFrame;
  49. modalOps: ModalOps;
  50. }