diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 497b298..107d7a0 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -163,16 +163,14 @@ (update-ui mapwin playerwin placewin newswin))) (croatoan:event-case (scr event) ;;TODO add other commands + ;;(#\h -> help window ;;(#\a -> toggle attack mode ;;(#\c -> command console ;;(#\p -> pickup item ;;(#\i -> manage inventory (#\q (disconnect) ;;terminate if we're running a local game - (when (member "server-thread" (bt:all-threads) :test - #'(lambda (nm th) - (equalp nm (bt:thread-name th)))) - (terminate)) + (when (runningp) (terminate)) (return-from croatoan:event-case)) (#\n (set-popup 'NEWS) (ui-update)) ;;XXX How about moving diagonally? @@ -182,6 +180,14 @@ (:right (query-server "move e") (ui-update)) ((nil) (ui-update))))))) +;;TODO This is not yet a good solution. First, window objects are +;; constantly created. Secondly, these windows cannot be controlled, +;; because all key events are still handled by the main UI... + +;;TODO I'm going to have to do this with the window stack +;; -> set .stacked T in all windows, use `refresh-stack' +;; (see croatoan CLOS tests line 980) + (let ((popup nil) (popup-modes '(NEWS CONSOLE INVENTORY))) (defun set-popup (&optional next-popup) "Which popup window should be shown?" @@ -190,16 +196,13 @@ (error "~S is not a permitted popup mode." next-popup))) (defun update-ui (mapwin playerwin placewin newswin) - "Update all four UI elements" - (draw-map mapwin) - (draw-descriptive-panel playerwin "describe-player") - (draw-descriptive-panel placewin "describe-patch") - (draw-news-panel newswin) - (draw-popup-window)) + "Update all active UI elements" + (unless popup + (draw-map mapwin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") + (draw-news-panel newswin))) - ;;TODO This is not yet a good solution. First, window objects are - ;; constantly created. Secondly, these windows cannot be controlled, - ;; because all key events are still handled by the main UI... (defun draw-popup-window () "Draw the current popup window, if appropriate" (case popup diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 497b298..107d7a0 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -163,16 +163,14 @@ (update-ui mapwin playerwin placewin newswin))) (croatoan:event-case (scr event) ;;TODO add other commands + ;;(#\h -> help window ;;(#\a -> toggle attack mode ;;(#\c -> command console ;;(#\p -> pickup item ;;(#\i -> manage inventory (#\q (disconnect) ;;terminate if we're running a local game - (when (member "server-thread" (bt:all-threads) :test - #'(lambda (nm th) - (equalp nm (bt:thread-name th)))) - (terminate)) + (when (runningp) (terminate)) (return-from croatoan:event-case)) (#\n (set-popup 'NEWS) (ui-update)) ;;XXX How about moving diagonally? @@ -182,6 +180,14 @@ (:right (query-server "move e") (ui-update)) ((nil) (ui-update))))))) +;;TODO This is not yet a good solution. First, window objects are +;; constantly created. Secondly, these windows cannot be controlled, +;; because all key events are still handled by the main UI... + +;;TODO I'm going to have to do this with the window stack +;; -> set .stacked T in all windows, use `refresh-stack' +;; (see croatoan CLOS tests line 980) + (let ((popup nil) (popup-modes '(NEWS CONSOLE INVENTORY))) (defun set-popup (&optional next-popup) "Which popup window should be shown?" @@ -190,16 +196,13 @@ (error "~S is not a permitted popup mode." next-popup))) (defun update-ui (mapwin playerwin placewin newswin) - "Update all four UI elements" - (draw-map mapwin) - (draw-descriptive-panel playerwin "describe-player") - (draw-descriptive-panel placewin "describe-patch") - (draw-news-panel newswin) - (draw-popup-window)) + "Update all active UI elements" + (unless popup + (draw-map mapwin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") + (draw-news-panel newswin))) - ;;TODO This is not yet a good solution. First, window objects are - ;; constantly created. Secondly, these windows cannot be controlled, - ;; because all key events are still handled by the main UI... (defun draw-popup-window () "Draw the current popup window, if appropriate" (case popup diff --git a/naledi.asd b/naledi.asd index ffb2713..7051d2b 100644 --- a/naledi.asd +++ b/naledi.asd @@ -43,4 +43,7 @@ ((:file "crt-ext") (:file "networking") (:file "user-interface")))) + :build-operation "program-op" + ;;TODO builds in a cache directory - but `merge-pathnames' is not evaluated + :build-pathname "naledi" ;;(merge-pathnames "naledi" (uiop:getcwd)) :entry-point "naledi:start-game") diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 497b298..107d7a0 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -163,16 +163,14 @@ (update-ui mapwin playerwin placewin newswin))) (croatoan:event-case (scr event) ;;TODO add other commands + ;;(#\h -> help window ;;(#\a -> toggle attack mode ;;(#\c -> command console ;;(#\p -> pickup item ;;(#\i -> manage inventory (#\q (disconnect) ;;terminate if we're running a local game - (when (member "server-thread" (bt:all-threads) :test - #'(lambda (nm th) - (equalp nm (bt:thread-name th)))) - (terminate)) + (when (runningp) (terminate)) (return-from croatoan:event-case)) (#\n (set-popup 'NEWS) (ui-update)) ;;XXX How about moving diagonally? @@ -182,6 +180,14 @@ (:right (query-server "move e") (ui-update)) ((nil) (ui-update))))))) +;;TODO This is not yet a good solution. First, window objects are +;; constantly created. Secondly, these windows cannot be controlled, +;; because all key events are still handled by the main UI... + +;;TODO I'm going to have to do this with the window stack +;; -> set .stacked T in all windows, use `refresh-stack' +;; (see croatoan CLOS tests line 980) + (let ((popup nil) (popup-modes '(NEWS CONSOLE INVENTORY))) (defun set-popup (&optional next-popup) "Which popup window should be shown?" @@ -190,16 +196,13 @@ (error "~S is not a permitted popup mode." next-popup))) (defun update-ui (mapwin playerwin placewin newswin) - "Update all four UI elements" - (draw-map mapwin) - (draw-descriptive-panel playerwin "describe-player") - (draw-descriptive-panel placewin "describe-patch") - (draw-news-panel newswin) - (draw-popup-window)) + "Update all active UI elements" + (unless popup + (draw-map mapwin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") + (draw-news-panel newswin))) - ;;TODO This is not yet a good solution. First, window objects are - ;; constantly created. Secondly, these windows cannot be controlled, - ;; because all key events are still handled by the main UI... (defun draw-popup-window () "Draw the current popup window, if appropriate" (case popup diff --git a/naledi.asd b/naledi.asd index ffb2713..7051d2b 100644 --- a/naledi.asd +++ b/naledi.asd @@ -43,4 +43,7 @@ ((:file "crt-ext") (:file "networking") (:file "user-interface")))) + :build-operation "program-op" + ;;TODO builds in a cache directory - but `merge-pathnames' is not evaluated + :build-pathname "naledi" ;;(merge-pathnames "naledi" (uiop:getcwd)) :entry-point "naledi:start-game") diff --git a/server/server.lisp b/server/server.lisp index e2dcb8a..7fbfd81 100644 --- a/server/server.lisp +++ b/server/server.lisp @@ -134,6 +134,8 @@ (defun run-server () "Start a server, listening for connections" + ;;TODO wrap in an `unwind-protect' clause + ;; (or is that implicit in `with-socket-listener'? (usocket:with-socket-listener (socket "127.0.0.1" *port*) (while running (usocket:wait-for-input socket)