AllInOnePlugin.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. namespace phasereditor2d.allInOne {
  2. export const CMD_CAT_ALL_IN_ONE = "phasereditor2d.allInOne";
  3. export const CMD_OPEN_PROJECT = "phasereditor2d.allInOne.openProject";
  4. export const CMD_CLOSE_PROJECT = "phasereditor2d.allInOne.closeProject";
  5. export const CMD_NEW_WINDOW = "phasereditor2d.allInOne.newWindow";
  6. export class AllInOnePlugin extends colibri.Plugin {
  7. private static _instance: AllInOnePlugin;
  8. static getInstance() {
  9. return this._instance || (this._instance = new AllInOnePlugin());
  10. }
  11. constructor() {
  12. super("phasereditor2d.allInOne");
  13. }
  14. registerExtensions(reg: colibri.ExtensionRegistry) {
  15. reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => {
  16. manager.addCategory({
  17. id: CMD_CAT_ALL_IN_ONE,
  18. name: "All In One"
  19. });
  20. manager.add({
  21. command: {
  22. category: CMD_CAT_ALL_IN_ONE,
  23. id: CMD_OPEN_PROJECT,
  24. name: "Open Project",
  25. tooltip: "Open an existing project.",
  26. },
  27. handler: {
  28. executeFunc: args => {
  29. colibri.Platform.getElectron().sendMessage({
  30. method: "open-project"
  31. });
  32. }
  33. },
  34. keys: {
  35. control: true,
  36. alt: true,
  37. key: "KeyJ"
  38. }
  39. });
  40. manager.add({
  41. command: {
  42. category: CMD_CAT_ALL_IN_ONE,
  43. id: CMD_CLOSE_PROJECT,
  44. name: "Close Project",
  45. tooltip: "Close the current project.",
  46. },
  47. handler: {
  48. executeFunc: args => {
  49. colibri.Platform.getElectron().sendMessage({
  50. method: "close-project"
  51. });
  52. }
  53. },
  54. keys: {
  55. control: true,
  56. alt: true,
  57. key: "KeyC"
  58. }
  59. });
  60. manager.add({
  61. command: {
  62. category: CMD_CAT_ALL_IN_ONE,
  63. id: CMD_NEW_WINDOW,
  64. name: "New Window",
  65. tooltip: "Open a new window.",
  66. },
  67. handler: {
  68. executeFunc: args => {
  69. colibri.Platform.getElectron().sendMessage({
  70. method: "new-window"
  71. });
  72. }
  73. }
  74. });
  75. }));
  76. reg.addExtension(new colibri.ui.controls.MenuExtension(
  77. phasereditor2d.ide.ui.DesignWindow.MENU_MAIN_START,
  78. {
  79. command: CMD_OPEN_PROJECT,
  80. },
  81. {
  82. command: CMD_CLOSE_PROJECT,
  83. },
  84. {
  85. separator: true
  86. },
  87. {
  88. command: CMD_NEW_WINDOW
  89. },
  90. {
  91. separator: true
  92. }));
  93. }
  94. }
  95. colibri.Platform.addPlugin(AllInOnePlugin.getInstance());
  96. }