diff --git a/client/user-interface.lisp b/client/user-interface.lisp index fe7009c..30b36ca 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -46,13 +46,9 @@ (croatoan:refresh scr) (let ((mw (make-instance 'croatoan:dialog-window :title "Welcome!" - :center t - :border t - :width 50 - :max-item-length 42 - :input-blocking t - :cyclic-selection t - :current-item-mark "* " + :center t :border t :width 50 + :max-item-length 42 :input-blocking t + :cyclic-selection t :current-item-mark "* " :items '("Start a local game" ;;TODO "Load a saved game" "Connect to a remote server")))) @@ -73,7 +69,7 @@ (defun start-local-game (scr) "Start a local game" - ;;TODO choose world size + (choose-world-size scr) (start-server) (setf *host* (first *defaulthost*) *port* (second *defaulthost*)) @@ -83,7 +79,35 @@ (connect-server) (query-server "signup localuser default")) ;;just use a default user -;;TODO (choose-world-size) +(defun choose-world-size (scr) + "Let the user choose his preferred world size" + (croatoan:clear scr) + (croatoan:refresh scr) + (let ((mw (make-instance 'croatoan:dialog-window + :title "Please choose a world size" + :center t :border t :width 50 + :max-item-length 42 :input-blocking t + :cyclic-selection t :current-item-mark "* " + :items '("Small (100)" "Standard (250)" "Medium (500)" + "Large (1000)")))) ; "Huge (5000)")))) + ;;XXX I have to effectively reimplement (select-item menu) because + ;; the screen grabs all user input and none arrives at the window + (setf (croatoan:.current-item-number mw) 1) + (croatoan:draw-menu mw) + (croatoan:event-case (scr event) + ((nil) nil) + ((:up :down) + (croatoan:update-menu mw event) + (croatoan:draw-menu mw)) + (#\newline + (case (croatoan:.current-item-number mw) + (0 (setf *world-size* 100)) + (1 (setf *world-size* 250)) + (2 (setf *world-size* 500)) + (3 (setf *world-size* 1000))) + ;;XXX uses >1GB RAM -> heap exhaustion + ;;(4 (setf *world-size* 5000))) + (return-from croatoan:event-case))))) (defun connect-remote-game (scr) "Ask the user which server to connect to and do so" @@ -93,9 +117,12 @@ :default (second *defaulthost*) :cls T))) (if (user-confirm-p scr (format nil "Connect to ~A:~S?" *host* *port*) T) ;;TODO ask for username/password! + ;;(login-or-signup scr) (connect-server) (start-or-connect-to-server scr))) +;;TODO (defun login-or-signup (scr)) + (defun user-interface (scr) "Create the screen on the ncurses interface and hand over to window functions" (let ((width (croatoan:.width scr)) (height (1- (croatoan:.height scr)))) diff --git a/client/user-interface.lisp b/client/user-interface.lisp index fe7009c..30b36ca 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -46,13 +46,9 @@ (croatoan:refresh scr) (let ((mw (make-instance 'croatoan:dialog-window :title "Welcome!" - :center t - :border t - :width 50 - :max-item-length 42 - :input-blocking t - :cyclic-selection t - :current-item-mark "* " + :center t :border t :width 50 + :max-item-length 42 :input-blocking t + :cyclic-selection t :current-item-mark "* " :items '("Start a local game" ;;TODO "Load a saved game" "Connect to a remote server")))) @@ -73,7 +69,7 @@ (defun start-local-game (scr) "Start a local game" - ;;TODO choose world size + (choose-world-size scr) (start-server) (setf *host* (first *defaulthost*) *port* (second *defaulthost*)) @@ -83,7 +79,35 @@ (connect-server) (query-server "signup localuser default")) ;;just use a default user -;;TODO (choose-world-size) +(defun choose-world-size (scr) + "Let the user choose his preferred world size" + (croatoan:clear scr) + (croatoan:refresh scr) + (let ((mw (make-instance 'croatoan:dialog-window + :title "Please choose a world size" + :center t :border t :width 50 + :max-item-length 42 :input-blocking t + :cyclic-selection t :current-item-mark "* " + :items '("Small (100)" "Standard (250)" "Medium (500)" + "Large (1000)")))) ; "Huge (5000)")))) + ;;XXX I have to effectively reimplement (select-item menu) because + ;; the screen grabs all user input and none arrives at the window + (setf (croatoan:.current-item-number mw) 1) + (croatoan:draw-menu mw) + (croatoan:event-case (scr event) + ((nil) nil) + ((:up :down) + (croatoan:update-menu mw event) + (croatoan:draw-menu mw)) + (#\newline + (case (croatoan:.current-item-number mw) + (0 (setf *world-size* 100)) + (1 (setf *world-size* 250)) + (2 (setf *world-size* 500)) + (3 (setf *world-size* 1000))) + ;;XXX uses >1GB RAM -> heap exhaustion + ;;(4 (setf *world-size* 5000))) + (return-from croatoan:event-case))))) (defun connect-remote-game (scr) "Ask the user which server to connect to and do so" @@ -93,9 +117,12 @@ :default (second *defaulthost*) :cls T))) (if (user-confirm-p scr (format nil "Connect to ~A:~S?" *host* *port*) T) ;;TODO ask for username/password! + ;;(login-or-signup scr) (connect-server) (start-or-connect-to-server scr))) +;;TODO (defun login-or-signup (scr)) + (defun user-interface (scr) "Create the screen on the ncurses interface and hand over to window functions" (let ((width (croatoan:.width scr)) (height (1- (croatoan:.height scr)))) diff --git a/params.lisp b/params.lisp index a4c500f..3b1f3fa 100644 --- a/params.lisp +++ b/params.lisp @@ -30,10 +30,10 @@ ;;Localhost defaults (defparameter *defaulthost* '("127.0.0.1" 21895)) ;default port: 21895 -;;Host server address to connect to +;;Host server address to connect to - XXX global variable! (defparameter *host* (first *defaulthost*)) -;;Network port to use +;;Network port to use - XXX global variable! (defparameter *port* (second *defaulthost*)) ;;Compass directions needed for spatial functions