05bd74b8d9c4

Clarify colors
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 18 Apr 2021 17:40:08 -0400
parents 41f2c758451f
children 614ad4a1d44e
branches/tags (none)
files dark.asd src/main.lisp

Changes

--- a/dark.asd	Sun Apr 18 16:28:24 2021 -0400
+++ b/dark.asd	Sun Apr 18 17:40:08 2021 -0400
@@ -14,6 +14,7 @@
                :losh)
 
   :serial t
-  :components ((:module "src" :serial t
-                :components ((:file "package")
-                             (:file "main")))))
+  :components
+  ((:module "src" :serial t
+    :components ((:file "package")
+                 (:file "main")))))
--- a/src/main.lisp	Sun Apr 18 16:28:24 2021 -0400
+++ b/src/main.lisp	Sun Apr 18 17:40:08 2021 -0400
@@ -6,6 +6,7 @@
 (defconstant +amber+ (boots:rgb #xFB #x7D #x01))
 (defconstant +default+ (boots:attr :fg +amber+ :bg +black+))
 (defconstant +reverse+ (boots:attr :fg +black+ :bg +amber+))
+(defconstant +ooc+ (boots:attr :fg +white+ :bg +black+))
 
 (defvar *event* nil)
 (defvar *mods* nil)
@@ -21,6 +22,14 @@
   (boots:read-event)
   (values))
 
+(defmacro with-in-game-colors (&body body)
+  `(let ((boots:*border-attr* +default+))
+     ,@body))
+
+(defmacro with-ooc-colors (&body body)
+  `(let ((boots:*border-attr* +ooc+))
+     ,@body))
+
 (defmacro with-ui (ui &body body)
   (alexandria:with-gensyms (prev)
     `(let ((,prev (boots:root boots:*screen*)))
@@ -28,19 +37,20 @@
        (unwind-protect (progn ,@body)
          (setf (boots:root boots:*screen*) ,prev)))))
 
-
 ;;;; Splash -------------------------------------------------------------------
 (defun draw/splash (pad)
   (boots:draw pad 0 0 *asset/splash*))
 
 (defun splash ()
-  (with-ui (boots:make-canvas :width 50 :height 10 :border t :margin t
-                              :fill-attr +default+
-                              :draw #'draw/splash)
-    (boots:redraw)
-    (press-any-key))
+  (with-ooc-colors
+    (with-ui (boots:make-canvas :width 50 :height 10 :border t :margin t
+                                :fill-attr +default+
+                                :draw #'draw/splash)
+      (boots:redraw)
+      (press-any-key)))
   (journal))
 
+
 ;;;; Journal ------------------------------------------------------------------
 (defun draw/journal (pad)
   (boots:draw pad 0 0 *asset/journal* +default+))
@@ -52,23 +62,25 @@
           (boots:event-case (boots:read-event-no-hang)
             (#\esc (pause))))))
 
+
 ;;;; Pause --------------------------------------------------------------------
 (defun draw/pause (pad)
-  (boots:draw pad 0 0 "Paused" +default+)
-  (boots:draw pad 0 2 "[R]esume" +reverse+)
-  (boots:draw pad 0 3 "[Q]uit" +default+))
+  (boots:draw pad 0 0 "Paused" +ooc+)
+  (boots:draw pad 0 2 "[R]esume" +ooc+)
+  (boots:draw pad 0 3 "[Q]uit Game" +ooc+))
+
 
 (defun pause ()
-  (with-ui (boots:make-canvas :width 30 :height 10 :border t :margin t
-                              :fill-attr +default+
-                              :draw #'draw/pause)
-    (loop (boots:redraw)
-          (multiple-value-bind (e m)
-              (boots:read-event-no-hang)
-            (boots:event-case (values e m)
-              ((#\r #\esc) (return-from pause))
-              (#\q (throw 'quit nil))
-              (t (setf *event* e *mods* m)))))))
+  (with-ooc-colors
+    (with-ui (boots:make-canvas :width 30 :height 10 :border t :margin t
+                                :fill-attr +ooc+
+                                :draw #'draw/pause)
+      (loop (boots:redraw)
+            (multiple-value-bind (e m) (boots:read-event)
+              (boots:event-case (values e m)
+                ((#\r #\esc) (return-from pause))
+                (#\q (throw 'quit nil))
+                (t (setf *event* e *mods* m))))))))
 
 
 ;;;; Main ---------------------------------------------------------------------
@@ -76,7 +88,7 @@
   (boots/terminals/ansi:with-ansi-terminal (terminal :truecolor t)
     (boots:with-screen (boots:*screen* terminal)
       (boots:with-light-borders
-        (let ((boots:*border-attr* +default+))
+        (with-in-game-colors
           (catch 'quit
             (splash)))))))