Initial commit.
[existenz.git] / common / options.lisp
1 ;;; -*- mode: lisp; syntax: common-lisp; package: existenz-client; coding: utf-8-unix; -*-
2
3 (in-package #:existenz-common)
4 \f
5 (defvar *options* NIL)
6
7 (defun option (name)
8   (cdr (assoc name *options*)))
9
10 (defun set-option (name new-value)
11   (setf *options*
12         `((,name . ,new-value)
13           ,@(remove name *options* :test #'eq :key #'car)))
14   new-value)
15
16 (defsetf option set-option)
17
18 (defvar *options-mappings* NIL)
19
20 (defun load-options ()
21   (iterate
22     (for (name . variables) in *options-mappings*)
23     (iterate
24       (for value in (option name))
25       (for variable in variables)
26       (set variable value))))
27 \f
28 ;; TODO: make emacs macros for this
29
30 #|
31 (defmacro defcustom (name value documentation &key (type T)))
32
33 (defcustom window-resolution
34   (list 640 480)
35   "Width and height of window.  Two-element LIST of INTEGERS.  Is mapped
36 to the global variables *WINDOW-WIDTH* and *WINDOW-HEIGHT*."
37   :type list)
38
39 (defcustom window-fullscreen
40   NIL
41   "Whether the application runs in fullscreen or windowed mode.  Is mapped
42 to the global variable *WINDOW-FULLSCREEN*."
43   :type boolean)
44 |#