diff options
Diffstat (limited to 'src/main.lisp')
| -rw-r--r-- | src/main.lisp | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/main.lisp b/src/main.lisp index 5713a65..0153da4 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -17,11 +17,11 @@ :display-time t :display-function 'display-title) (zone-price :application - :display-time :command-loop + :display-time t :scroll-bar nil :display-function 'display-zone-price) (panel :application - :display-time :command-loop + :display-time t :scroll-bar nil :display-function 'display-panel) (int :interactor)) @@ -39,6 +39,11 @@ (defmethod frame-standard-output ((frame superapp)) (clim:get-frame-pane frame 'int)) +(defun redisplay (panel) + (clim:with-application-frame (frame) + (setf (clim:pane-needs-redisplay + (clim:get-frame-pane frame panel)) + t))) (defun format-zone-price (panel stream) (loop for it in panel do (format stream "~a :~T ~$$ [~@$$] owned: ~a~%" @@ -83,33 +88,50 @@ (game:get-zone g (cdr (cur-panel frame)))) stream))))) - - ;; Panel command + + ;; Prices command -> changes the panel to prices for zone (define-superapp-command (com-prices :name t) ((zone 'string)) (clim:with-application-frame (frame) (if (game:get-zone g zone) - (setf (cur-panel frame) (cons 'prices zone)) + (progn + (setf (cur-panel frame) (cons 'prices zone)) + (redisplay 'panel)) (format (frame-standard-output frame) "Zone ~A does not exist~%" zone)))) - ;; Stats command + ;; Stats command -> changes the panel to player stats (define-superapp-command (com-stats :name t) () (clim:with-application-frame (frame) - (setf (cur-panel frame) '(stats)))) - + (setf (cur-panel frame) '(stats)) + (redisplay 'panel))) + ;; Buy command (define-superapp-command (com-buy :name t) ((item 'string) (quantity 'integer)) (clim:with-application-frame (frame) (let ((out (frame-standard-output frame))) (if (game:buy-item g item quantity) - (format out "Bought ~a ~a~%" quantity item) + (progn + (when (eq 'stats (car (cur-panel frame))) + (redisplay 'panel)) + (redisplay 'zone-price) + (format out "Bought ~a ~a~%" quantity item)) (format out "Could not buy ~a ~a~%" quantity item))))) ;; Sell command (define-superapp-command (com-sell :name t) ((item 'string) (quantity 'integer)) - (game:sell-item g item quantity)) + (clim:with-application-frame (frame) + (let ((out (frame-standard-output frame)) + (sold (game:sell-item g item quantity))) + (if sold + (progn + (when (eq 'stats (car (cur-panel frame))) + (redisplay 'panel)) + (redisplay 'zone-price) + (format out "Sold ~a ~a~%" sold item)) + (format out "Could not sell any ~a" item))))) + ;; Goto command (define-superapp-command (com-goto :name t) ((dest 'string)) @@ -118,7 +140,8 @@ (if (game:change-zone g dest) (progn (setf (cur-zone frame) (zone:name (game:get-cur-zone g))) - (setf (clim:pane-needs-redisplay (clim:get-frame-pane frame 'title)) t) + (redisplay 'title) + (redisplay 'zone-price) (format out "Arrived in ~a" (zone:name (game:get-cur-zone g)))) (format out "Zone ~a does not exist!" dest))))) |
