#!/bin/sh
DIALOG=${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --title "Examples programs for the Allegro library" \
        --menu "\nHi, using this menu you can run some of example \
        programs and utilities distributed with the Allegro library.\
        Some of them may work on your system, some may not. Just try and \
        you could find some nice looking demos and useful tools.\n\n" \
        20 80 10 \
'akaitest' 'Audio input test program for the Allegro library.' \
  'digitest' 'Digital sample playing test program.' \
  'ex12bit ' 'fake 12-bit truecolor on an 8 bit card.' \
  'ex3d    ' '3d "bouncy cubes" demo' \
  'exaccel ' 'using offscreen video memory to store source graphics' \
  'exalpha ' '32 bit RGBA sprites' \
  'exbitmap' 'loading and displaying PCX and BMP files' \
  'exblend ' 'truecolor translucency' \
  'excamera' 'viewing a 3d world from an arbitrary camera position' \
  'excolmap' 'color mapping table effects.' \
  'excustom' 'creating custom GUI objects' \
  'exdata  ' 'accessing the contents of datafiles' \
  'exdbuf  ' 'double buffering in VGA mode 13h' \
  'exdodgy ' 'a cool trick you can do with the MIDI player' \
  'exexedat' 'appending datafiles onto your executable.' \
  'exfixed ' 'using fixed point maths' \
  'exflame ' 'how to write directly to video memory' \
  'exflip  ' 'double buffering and page flipping in mode-X' \
  'exgui   ' 'using the GUI routines' \
  'exhello ' 'simple "hello world" program' \
  'exjoy   ' 'joystick input.' \
  'exkeys  ' 'getting input from the keyboard' \
  'exlights' 'one way to do colored lighting effects in a hicolor video mode' \
  'exmem   ' 'drawing onto memory bitmaps and then blitting them...' \
  'exmidi  ' 'playing MIDI music' \
  'exmouse ' 'getting input from the mouse' \
  'expal   ' 'palette effects and color cycling' \
  'expat   ' 'using patterned drawing modes and sub-bitmaps' \
  'exquat  ' 'quaternion rotations.' \
  'exrgbhsv' 'RGB <-> HSV colorspace conversions' \
  'exsample' 'playing digital samples' \
  'exscale ' 'loading PCX files and bitmap stretching' \
  'exscroll' 'mode-X hardware scrolling and split screens' \
  'exshade ' 'gouraud shaded sprites, by Patrick Hogan' \
  'exspline' 'constructing smooth movement paths from spline curves' \
  'exsprite' 'datafiles and sprite animation, by Grzegorz Ludorowski' \
  'exstars ' '3d starfield and lightsourced spaceship, by Dave Thomson' \
  'exstream' 'playing audio streams' \
  'exswitch' 'controlling the console switch mode' \
  'extimer ' 'using the timer (delays and interrupts)' \
  'extrans ' 'lighting and translucency effects, by Owen Embury' \
  'extruec ' 'truecolor pixel format conversions' \
  'exupdate' 'supporting different screen update methods in a single program' \
  'exxfade ' 'truecolor image loading and fades' \
  'exzbuf  ' 'Z-buffered polygons demo.' \
  'mathtest' 'Fixed point maths test program.' \
  'miditest' 'MIDI instrument playing test program.' \
  'play' 'Sound code test program for the Allegro library.' \
  'playfli' 'FLI player test program for the Allegro library.' \
  'test' 'Main test program for the Allegro library.' \
   2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    cd /usr/share/games/allegro-examples/
    /usr/lib/games/allegro-examples/$choice
    echo Press RETURN to continue...
    read
    exec $0;;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac
