Bladeren bron

Can open Atomic Editor and compile/run project from Atom

Josh Engebretson 10 jaren geleden
bovenliggende
commit
d2fb132948

+ 2 - 1
CLI/atomic-game-engine/keymaps/atomic-game-engine.cson

@@ -8,4 +8,5 @@
 # For more detailed documentation see
 # https://atom.io/docs/latest/behind-atom-keymaps-in-depth
 'atom-workspace':
-  'ctrl-alt-o': 'atomic-game-engine:toggle'
+  'cmd-shift-e': 'atomic-game-engine:openEditor'
+  'cmd-shift-r': 'atomic-game-engine:run'

+ 24 - 12
CLI/atomic-game-engine/lib/atomic-game-engine.coffee

@@ -10,25 +10,37 @@ module.exports = AtomicGameEngine =
     @subscriptions = new CompositeDisposable
 
     # Register command that toggles this view
-    @subscriptions.add atom.commands.add 'atom-workspace', 'atomic-game-engine:toggle': => @toggle()
+    @subscriptions.add atom.commands.add 'atom-workspace', 'atomic-game-engine:openEditor': => @openEditor()
+    @subscriptions.add atom.commands.add 'atom-workspace', 'atomic-game-engine:run': => @run()
 
   deactivate: ->
     @subscriptions.dispose()
 
   serialize: ->
 
-  toggle: ->
 
-    # AtomicCLI.atomiceditor([])
+  getAtomicProjectPath: ->
+
     paths = atom.project.getPaths();
 
-    gotone = false;
     for path in paths
-      glob path + "/*.atomic", (er, files) ->
-        if files.length
-          gotone = true
-          AtomicCLI.atomiceditor ["-project", path]
-      if gotone
-        break
-
-    console.log 'AtomicGameEngine was toggled!'
+      files = glob.sync path + "/*.atomic"
+      if files.length
+        return path
+
+    return null
+
+  openEditor: ->
+
+    path = @getAtomicProjectPath()
+
+    if path
+      AtomicCLI.atomiceditor ["-project", path]
+
+  run: ->
+
+    path = @getAtomicProjectPath()
+
+    if path
+      process.chdir(path)
+      AtomicCLI.run("mac")

+ 13 - 4
CLI/atomic-game-engine/menus/atomic-game-engine.cson

@@ -2,8 +2,12 @@
 'context-menu':
   'atom-text-editor': [
     {
-      'label': 'Toggle atomic-game-engine'
-      'command': 'atomic-game-engine:toggle'
+      'label': 'Open Atomic Editor'
+      'command': 'atomic-game-engine:openEditor'
+    },
+    {
+      'label': 'Run in Atomic Player'
+      'command': 'atomic-game-engine:run'
     }
   ]
 'menu': [
@@ -13,9 +17,14 @@
       'label': 'Atomic Game Engine'
       'submenu': [
         {
-          'label': 'Toggle'
-          'command': 'atomic-game-engine:toggle'
+          'label': 'Open Atomic Editor'
+          'command': 'atomic-game-engine:openEditor'
+        },
+        {
+          'label': 'Run in Atomic Player'
+          'command': 'atomic-game-engine:run'
         }
+
       ]
     ]
   }

+ 1 - 1
CLI/atomic-game-engine/package.json

@@ -4,7 +4,7 @@
   "version": "0.0.0",
   "description": "A short description of your package",
   "activationCommands": {
-    "atom-workspace": "atomic-game-engine:toggle"
+    "atom-workspace": ["atomic-game-engine:openEditor", "atomic-game-engine:run"] 
   },
   "repository": "https://github.com/atom/atomic-game-engine",
   "license": "MIT",