#!/bin/sh
exec lush "$0" "$@"
!#

;; a menu of demos

(when (or (member "-h" argv)
          (member "--help" argv))
  (writing "$stderr" 
    (render-brace-text 0 72
       '{<p> Synopsis: ,,(basename (car argv)) [-h]{<br>}
         A menu for starting the Lush demos with a mouse click
        }))
  (exit 0))

(ogre)

(defvar demogrid)
(defvar demowin)

(setq demogrid (new grid 4))

(de new-demo-btn (title desc nlin)
  (let ((pgm (concat-fname (concat-fname lushdir "demos") title)))
    (==> demogrid insert 
         (new stdbutton "Run"
              (eval `(lambda(c)
                       (sys (concat ,pgm " &")))) ) )
    (==> demogrid insert 
         (new stdbutton "Help"
              (eval `(lambda(c) 
                       (repeat 72 (printf "="))
                       (printf "\n")
                       (sys (concat ,pgm " -h")))) ) )
    (==> demogrid insert
         (new string title) )
    (==> demogrid insert
         (new textpane 40 nlin desc) ) ) )

(new-demo-btn "calculator" 
              '("A simple GUI calculator") 1)
(new-demo-btn "lunar-lander" 
              '("A Lunar Lander game with SDL") 1)
(new-demo-btn "lushdoc" 
              '("Launches the Lush documentation browser") 1)
(new-demo-btn "lushlife" 
              '("Conway's Game of Life with LUSH graphics") 1)
(new-demo-btn "sdl-lushlife" 
              '("Conway's Game of Life with SDL") 1)
(new-demo-btn "sdl-bounce" 
              '("Bounces a bunch of SDL sprites"
                "around the screen") 2)
(new-demo-btn "sdlgl-triangle" 
              '("Rotate an OpenGL object using"
                "the keyboard.") 2)
(new-demo-btn "sdl-slimevolley" 
              '("A modern version of Pong") 1)
(new-demo-btn "show-image" 
              '("Shows an image (in any format)") 1)
(new-demo-btn "simple-gui" 
              '("A simple demo of the Ogre GUI toolkit") 1)

(setq demowin
      (new autowindowobject 10 10 100 100 "Simple GUI"
           demogrid) )

(wait demowin)

  