Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
Added option to save maze as an image
Browse files Browse the repository at this point in the history
  • Loading branch information
fourier committed Apr 22, 2019
1 parent 43236a8 commit de3cf5c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/ui.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(in-package :maze-gen)

(defparameter *version* 0.2)
(defparameter *version* 0.3)

;; shortcut/convenience macro
(defmacro with-pane-process ((self) &body body)
Expand Down Expand Up @@ -48,6 +48,10 @@
("Export..."
:callback
#'preview-trechbroom
:callback-type :interface)
("Save as image..."
:callback
#'save-image
:callback-type :interface))))))
(:panes
(draw-board output-pane
Expand Down Expand Up @@ -265,7 +269,20 @@
(with-slots (draw-board) self
(gp:invalidate-rectangle draw-board)))


(defun save-image (interface)
(with-slots (draw-board) interface
;; (gp:invalidate-rectangle draw-board))))
(multiple-value-bind (filename successp filter-name)
(prompt-for-file "Enter a filename:"
:if-exists :prompt :if-does-not-exist :ok
:operation :save
:filter "*.png")
(declare (ignore filter-name))
(when successp
(let ((img (gp:make-image-from-port draw-board)))
(gp:externalize-and-write-image draw-board img filename))))))


(defun main-ui ()
(capi:display (make-instance 'maze-gen-ui)))

0 comments on commit de3cf5c

Please sign in to comment.