Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions gdscript-godot.el
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,26 @@ When run with prefix argument, it offers extra debug options to choose from."
(defun gdscript-godot-run-current-scene ()
"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 current-prefix-arg)))
(let ((scene (gdscript-godot--select-scene current-prefix-arg)))
(when scene
(gdscript-godot--run-command scene))))

(defun gdscript-godot-run-current-scene-debug ()
"Run the current script file in Godot Engine.

When run with prefix argument, it offers extra debug options to choose from."
(interactive)
(gdscript-godot--debug-options-handler debug-options
(gdscript-godot--run-command "-d" debug-options (gdscript-godot--select-scene))))
(let ((scene (gdscript-godot--select-scene current-prefix-arg)))
(when scene
(gdscript-godot--debug-options-handler debug-options
(gdscript-godot--run-command "-d" debug-options scene)))))

(defun gdscript-godot-edit-current-scene ()
"Run the current script file in Godot Engine."
(interactive)
(gdscript-godot--run-command "-e" (gdscript-godot--select-scene current-prefix-arg)))
(let ((scene (gdscript-godot--select-scene current-prefix-arg)))
(when scene
(gdscript-godot--run-command "-e" scene))))

(defun gdscript-godot--select-scene (&optional select-scene)
"Select scene to run"
Expand Down
9 changes: 5 additions & 4 deletions gdscript-project.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ If current buffer is not visiting scene file return nil."
(when (file-exists-p scene-name) scene-name))))

(defun gdscript-project--select-scene ()
"Find all scenes files and let user choose one."
"Find all scenes files and let user choose one. Return `nil' if user cancels selection."
(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 "Select scene to run" (buffer-name))))
(gdscript-util--read scene-list prompt)))
(prompt (format "Select scene to run" (buffer-name)))
(selected-scene (gdscript-util--read scene-list prompt)))
selected-scene))

(defun gdscript-project--current-buffer-script ()
"Return the name of current script.
Expand All @@ -70,7 +71,7 @@ If current buffer is not visiting script file return nil."
(unwind-protect
(let* ((prompt (format "Buffer %s is not script file, select script to run" (buffer-name)))
(script-name (gdscript-util--read gdscript-project--script-list prompt)))
(gdscript-godot--run-script script-name))
(when script-name (gdscript-godot--run-script script-name)))
(when hydra-open (gdscript-hydra--menu/body)))))

(defun gdscript-project--ag-cleanup ()
Expand Down
9 changes: 4 additions & 5 deletions gdscript-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,17 @@ For example:

(defun gdscript-util--read (items &optional prompt)
"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 ((and (featurep 'projectile) )
PROMPT is prompt for read command. Return `nil' if user aborts."
(let* ((p (if prompt prompt "Options"))
(result (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))
(t
(completing-read (format "%s (hit TAB to auto-complete): " p) items nil t)))))
(if quit-flag nil result)))

(provide 'gdscript-utils)

Expand Down