From b729d2f97a9002cd9810b07d5a8178c3f6dd83e9 Mon Sep 17 00:00:00 2001 From: El-BG-1970 Date: Fri, 26 Aug 2022 16:56:03 +0200 Subject: added prices panel to gui and panel switching --- src/main.lisp | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src/main.lisp') diff --git a/src/main.lisp b/src/main.lisp index 8baf355..12c1483 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -7,7 +7,9 @@ (clim:define-application-frame superapp () ((cur-zone :initarg :start-zone - :accessor cur-zone)) + :accessor cur-zone) + (cur-panel :initform '(stats) + :accessor cur-panel)) ;; :panes section describes different parts of the ;; application-frame. This application has only one pane. (:panes @@ -30,8 +32,8 @@ (default (clim:vertically () (1/8 title) (4/8 (clim:horizontally () - (2/3 zone-price) - (1/3 panel))) + (1/2 zone-price) + (1/2 panel))) (3/8 int))))) (defmethod frame-standard-output ((frame superapp)) @@ -68,14 +70,33 @@ :align-x :center :align-y :top)) (defmethod display-zone-price ((frame superapp) stream) - (format-zone-price (game:commodities-panel g) stream)) + (format stream "Prices for ~a~%" (zone:name (game:get-cur-zone g))) + (format-zone-price + (game:commodities-panel g (game:get-cur-zone g)) stream)) (defmethod display-panel ((frame superapp) stream) - (format-stats (game:player-stats g) stream)) + (case (car (cur-panel frame)) + ('stats (format-stats (game:player-stats g) stream)) + ('prices (progn + (format stream "Prices for ~a~%" (cdr (cur-panel frame))) + (format-zone-price + (game:commodities-panel g + (game:get-zone g + (cdr (cur-panel frame)))) + stream))))) ;; Panel command - (define-superapp-command (com-panel :name t) () - (format-zone-price (game:commodities-panel g) t)) - + (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)) + (format (frame-standard-output frame) + "Zone ~A does not exist~%" + zone)))) + ;; Stats command + (define-superapp-command (com-stats :name t) () + (clim:with-application-frame (frame) + (setf (cur-panel frame) '(stats)))) + ;; Buy command (define-superapp-command (com-buy :name t) ((item 'string) (quantity 'integer)) -- cgit v1.2.3