Merge pull request #82 from rileyrg/run-scene-enhance

Select scene to run from a gdscript buffer, enable projectile (helm) for scene selection.
This commit is contained in:
Nathan Lovato
2020-08-30 09:54:29 -06:00
committed by GitHub
3 changed files with 16 additions and 10 deletions

View File

@@ -100,9 +100,9 @@ When run with prefix argument, it offers extra debug options to choose from."
(gdscript-godot--run-command "-d" debug-options)))
(defun gdscript-godot-run-current-scene ()
"Run the current script file in Godot Engine."
"Run the current script file in Godot Engine. Use the universal prefix (C-u) to force a scene select."
(interactive)
(gdscript-godot--run-command (gdscript-godot--select-scene)))
(gdscript-godot--run-command (gdscript-godot--select-scene current-prefix-arg)))
(defun gdscript-godot-run-current-scene-debug ()
"Run the current script file in Godot Engine.
@@ -115,13 +115,15 @@ When run with prefix argument, it offers extra debug options to choose from."
(defun gdscript-godot-edit-current-scene ()
"Run the current script file in Godot Engine."
(interactive)
(gdscript-godot--run-command "-e" (gdscript-godot--select-scene)))
(gdscript-godot--run-command "-e" (gdscript-godot--select-scene current-prefix-arg)))
(defun gdscript-godot--select-scene ()
"Run the current script file in Godot Engine."
(let ((scene-name (gdscript-project--current-buffer-scene)))
(if scene-name scene-name
(gdscript-project--select-scene))))
(defun gdscript-godot--select-scene (&optional select-scene)
"Select scene to run"
(if select-scene
(gdscript-project--select-scene)
(let ((scene-name (gdscript-project--current-buffer-scene)))
(if scene-name scene-name
(gdscript-project--select-scene)))))
(defun gdscript-godot-run-current-script ()
"Run the current script file in Godot Engine.

View File

@@ -47,9 +47,10 @@ If current buffer is not visiting scene file return nil."
(defun gdscript-project--select-scene ()
"Find all scenes files and let user choose one."
(message "selecting scene")
(let* ((rl (gdscript-util--find-project-configuration-file))
(scene-list (mapcar (lambda (x) (file-relative-name x rl)) (directory-files-recursively rl ".*.tscn" t)))
(prompt (format "Buffer %s is not scene file, select scene to run" (buffer-name))))
(prompt (format "Select scene to run" (buffer-name))))
(gdscript-util--read scene-list prompt)))
(defun gdscript-project--current-buffer-script ()

View File

@@ -144,8 +144,11 @@ For example:
"Let's choose single item from ITEMS from mini-buffer.
PROMPT is prompt for read command."
(message "gdscript util read")
(let ((p (if prompt prompt "Options")))
(cond ((fboundp 'ivy-read)
(cond ((and (featurep 'projectile) )
(projectile-completing-read (format "%s: " p) items))
((fboundp 'ivy-read)
(ivy-read (format "%s: " p) items))
((fboundp 'ido-completing-read)
(ido-completing-read (format "%s: " p) items))