--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/intro1.txt Sat Jan 07 12:54:06 2017 +0000
@@ -0,0 +1,1 @@
+They tried to warn us.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/intro2.txt Sat Jan 07 12:54:06 2017 +0000
@@ -0,0 +1,3 @@
+For decades scientists told us we were changing
+the climate of our planet. They warned us that
+if we continued we'd cause irreparable damage.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/intro3.txt Sat Jan 07 12:54:06 2017 +0000
@@ -0,0 +1,1 @@
+We didn't listen.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/intro4.txt Sat Jan 07 12:54:06 2017 +0000
@@ -0,0 +1,7 @@
+By the time we started to feel the effects it
+was too late.
+
+Earth was caught in the same spiral Venus
+experienced billions of years ago. The global
+temperature rose twenty degrees and species
+after species fell to extinction.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/intro5.txt Sat Jan 07 12:54:06 2017 +0000
@@ -0,0 +1,2 @@
+Thirty years after the spiral begun, you are one
+of the few humans left on the planet.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/intro6.txt Sat Jan 07 12:54:06 2017 +0000
@@ -0,0 +1,5 @@
+The only habitable places left are the North and
+South poles during their respective winters.
+
+Twice each a year the surviving human population
+must migrate to the opposing pole to stay alive.
--- a/package.lisp Sat Jan 07 12:10:22 2017 +0000
+++ b/package.lisp Sat Jan 07 12:54:06 2017 +0000
@@ -17,6 +17,7 @@
:border
:redraw
:write-string-left
+ :write-string-right
:write-string-centered
:write-lines-left
:write-lines-centered
--- a/src/main.lisp Sat Jan 07 12:10:22 2017 +0000
+++ b/src/main.lisp Sat Jan 07 12:54:06 2017 +0000
@@ -3,6 +3,12 @@
;;;; Data ---------------------------------------------------------------------
(defparameter *logo* (read-file-into-string "data/logo.txt"))
+(defparameter *intro1* (read-file-into-string "data/intro1.txt"))
+(defparameter *intro2* (read-file-into-string "data/intro2.txt"))
+(defparameter *intro3* (read-file-into-string "data/intro3.txt"))
+(defparameter *intro4* (read-file-into-string "data/intro4.txt"))
+(defparameter *intro5* (read-file-into-string "data/intro5.txt"))
+(defparameter *intro6* (read-file-into-string "data/intro6.txt"))
(defparameter *screen-width* nil)
(defparameter *screen-height* nil)
@@ -11,7 +17,52 @@
(defparameter *height* nil)
-;;;; State Machine ------------------------------------------------------------
+;;;; Intro --------------------------------------------------------------------
+(defmacro dialog (&body body)
+ `(with-dims (50 10)
+ (with-panel-and-window
+ (pan win *width* *height*
+ (center *width* *screen-width*)
+ (center *height* *screen-height*))
+ (charms:clear-window win)
+ (border win)
+ ,@body
+ (write-string-right win "Press any key" -1 (1- *height*))
+ (redraw)
+ (charms:get-char win))))
+
+(defun intro1 ()
+ (if (eq :left (dialog (write-lines-left win *intro1* 1 1)))
+ (title)
+ (intro2)))
+
+(defun intro2 ()
+ (if (eq :left (dialog (write-lines-left win *intro2* 1 1)))
+ (intro1)
+ (intro3)))
+
+(defun intro3 ()
+ (if (eq :left (dialog (write-lines-left win *intro3* 1 1)))
+ (intro2)
+ (intro4)))
+
+(defun intro4 ()
+ (if (eq :left (dialog (write-lines-left win *intro4* 1 1)))
+ (intro3)
+ (intro5)))
+
+(defun intro5 ()
+ (if (eq :left (dialog (write-lines-left win *intro5* 1 1)))
+ (intro4)
+ (intro6)))
+
+(defun intro6 ()
+ (if (eq :left (dialog (write-lines-left win *intro6* 1 1)))
+ (intro5)
+ nil))
+
+
+;;;; Title --------------------------------------------------------------------
(defun title ()
(with-dims (50 10)
(with-panel-and-window
@@ -20,7 +71,8 @@
(center *height* *screen-height*))
(write-lines-centered win *logo* 0)
(redraw)
- (charms:get-char win))))
+ (charms:get-char win))
+ (intro1)))
;;;; Main ---------------------------------------------------------------------
--- a/src/utilities.lisp Sat Jan 07 12:10:22 2017 +0000
+++ b/src/utilities.lisp Sat Jan 07 12:54:06 2017 +0000
@@ -3,6 +3,7 @@
;;;; Charms -------------------------------------------------------------------
(defmacro with-window ((symbol width height x y) &body body)
`(let ((,symbol (charms:make-window ,width ,height ,x ,y)))
+ (charms:enable-extra-keys ,symbol)
(unwind-protect (progn ,@body)
(charms:destroy-window ,symbol))))
@@ -52,8 +53,14 @@
(defun write-string-left (window string x y)
(charms:write-string-at-point window string x y))
+(defun write-string-right (window string x-offset y)
+ (charms:write-string-at-point
+ window string
+ (- ap::*width* (length string) (abs x-offset))
+ y))
+
(defun write-string-centered (window string y)
- (charms:write-string-at-point window string (center (length string) *width*) y))
+ (charms:write-string-at-point window string (center (length string) ap::*width*) y))
(defun write-lines-left (window string start-x start-y)
(iterate (for line :in (cl-strings:split string #\newline))