Editor.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import MainFrame = require("../ui/MainFrame");
  2. import UIEvents = require("../ui/UIEvents");
  3. import AssetImport = require("../assets/AssetImport");
  4. class Editor extends Atomic.ScriptObject {
  5. project: ToolCore.Project;
  6. view: Atomic.UIView;
  7. mainframe: MainFrame;
  8. assetImport: AssetImport;
  9. static instance: Editor;
  10. loadProject(projectPath: string): boolean {
  11. var system = ToolCore.getToolSystem();
  12. if (system.project) {
  13. this.sendEvent(UIEvents.MessageModalEvent,
  14. { type: "error", title: "Project already loaded", message: "Project already loaded" });
  15. return false;
  16. }
  17. return system.loadProject(projectPath);
  18. }
  19. parseArguments() {
  20. var args = Atomic.getArguments();
  21. var idx = 0;
  22. while (idx < args.length) {
  23. if (args[idx] == "--project") {
  24. this.loadProject(args[idx + 1]);
  25. }
  26. idx++;
  27. }
  28. }
  29. constructor() {
  30. super();
  31. Editor.instance = this;
  32. Atomic.getResourceCache().autoReloadResources = true;
  33. this.assetImport = new AssetImport();
  34. var graphics = Atomic.getGraphics();
  35. this.view = new Atomic.UIView();
  36. this.mainframe = new MainFrame();
  37. this.view.addChild(this.mainframe);
  38. // set initial size
  39. this.mainframe.setSize(graphics.width, graphics.height);
  40. this.parseArguments();
  41. }
  42. }
  43. export = Editor;