summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEl-BG-1970 <elouan.gros.fr@gmail.com>2022-08-25 21:22:54 +0200
committerEl-BG-1970 <elouan.gros.fr@gmail.com>2022-08-25 21:22:54 +0200
commitba291bd4a870048e48b5527878604c9fc31ef07c (patch)
tree4cdbfabea69223b4a9b550f36a4c716821a1d74c
parentd6ff28e518c4dec62d8520f74a8f4d1a527a47bc (diff)
downloadtransacc-ba291bd4a870048e48b5527878604c9fc31ef07c.tar.gz
added gui top banner with name and current zone
-rw-r--r--src/game.lisp4
-rw-r--r--src/main.lisp35
2 files changed, 32 insertions, 7 deletions
diff --git a/src/game.lisp b/src/game.lisp
index 08184fc..24f5581 100644
--- a/src/game.lisp
+++ b/src/game.lisp
@@ -6,6 +6,7 @@
:change-zone
:get-profit
:get-profit-in-zone
+ :get-cur-zone
:commodities-panel))
(in-package :game)
@@ -16,7 +17,8 @@
(zones :initarg :zones
:accessor zones)
(cur-zone :initarg :start-zone
- :accessor cur-zone)))
+ :accessor cur-zone
+ :reader get-cur-zone)))
(defun new-game (player start-zone zones)
(make-instance 'game
diff --git a/src/main.lisp b/src/main.lisp
index 1fd05a9..b3c6933 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -6,16 +6,22 @@
(in-package :transacc)
(clim:define-application-frame superapp ()
- ()
+ ((cur-zone :initarg :start-zone
+ :accessor cur-zone))
;; :panes section describes different parts of the
;; application-frame. This application has only one pane.
(:panes
- (int :interactor :height 400 :width 600))
+ (title :title-pane
+ :display-time :command-loop
+ :display-function 'display-title)
+ (int :interactor))
;; :layouts section describes how the panes are layed out.
;; This application has one layout named "default" which has a single pane.
(:layouts
- (default int)))
+ (default (clim:vertically ()
+ (1/8 title)
+ (7/8 int)))))
(defun format-panel (panel)
(loop for it in panel do
@@ -35,6 +41,13 @@
(z2 (zone:new-zone "Manhattan" c2))
(g (game:new-game p z2 (list z z2))))
+ (defmethod display-title ((frame superapp) stream)
+ (clim:draw-text* stream
+ (format nil "Joze~%~a" (zone:name (game:get-cur-zone g)))
+ 300 2
+ :align-x :center
+ :align-y :top))
+
;; Panel command
(define-superapp-command (com-panel :name t) ()
(format-panel (game:commodities-panel g)))
@@ -49,6 +62,16 @@
;; Goto command
(define-superapp-command (com-goto :name t)
((dest 'string))
- (game:change-zone g dest))
-
- (clim:run-frame-top-level (clim:make-application-frame 'superapp))))
+ (clim:with-application-frame (frame)
+ (if (game:change-zone g dest)
+ (progn
+ (setf (cur-zone frame) (zone:name (game:get-cur-zone g)))
+ (format t "~a~%" (cur-zone frame))
+ (format t "Arrived in ~a" (zone:name (game:get-cur-zone g))))
+ (format t "Zone ~a does not exist!" dest))))
+
+ (clim:run-frame-top-level
+ (clim:make-application-frame 'superapp
+ :height 400
+ :width 600
+ :start-zone (game:get-cur-zone g)))))