#!/bin/sh --
# xbitman2 -*- shell-script -*- to run the MyMan video game under the X Window System
# Copyright 2003, 2006-2007, Benjamin Sittler <bsittler@gmail.com>
# 
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

# Make sure you compile and install the terminfo file from
#  /usr/X11R6/lib/X11/etc/xterm.terminfo
# (or wherever that is on your system...) so that curses understands
# that your xterm supports color.  Alternatively, you may be able to
# change termName to 'xterm-color', 'color_xterm', or something
# similar.

# Note that, on some systems, the color xterm is available as
# 'nxterm'. If this is the case on your system, change xterm
# accordingly.

# If you use a different-sized maze or tileset, you
# should probaby change the geometry and font.


# NOTE: automatically\ generated\ Thu\ Jul\ 10\ 09:50:03\ UTC\ 2025\ for\ myman\ 0.7.0

export MYMAN
MYMAN=myman

export SHELL
SHELL=/bin/sh

export PATH
PATH="$PATH":/usr/bin:/usr/X11R6/bin

if test :"$DISPLAY" = :"" -a -d /Applications/Utilities/X11.app/ -a -x /usr/bin/open
then
    export DISPLAY
    DISPLAY=:0
    /usr/bin/open /Applications/Utilities/X11.app/
elif test :"$DISPLAY" = :"" -a -d /Applications/XDarwin.app/ -a -x /usr/bin/open
then
    export DISPLAY
    DISPLAY=:0
    /usr/bin/open /Applications/XDarwin.app/
fi

export EXE_SUFFIX
EXE_SUFFIX=

# special characters
char_tab='	'
char_newline='
'
export char_tab
export char_newline

for myman in myman-0.7.0 myman myman
do
  if test -f "`dirname \"\$0\"`"/"${myman}" -a -x "`dirname \"\$0\"`"/"${myman}" -o -f "`dirname \"\$0\"`"/"${myman}""$EXE_SUFFIX" -a -x "`dirname \"\$0\"`"/"${myman}""$EXE_SUFFIX"
      then
      MYMAN="`dirname \"\$0\"`"/"${myman}"
  elif test -f "`dirname \"\$0\"`"/home/builder/build/pkg/myman/usr/bin/"${myman}" -a -x "`dirname \"\$0\"`"/home/builder/build/pkg/myman/usr/bin/"${myman}" -o -f "`dirname \"\$0\"`"/home/builder/build/pkg/myman/usr/bin/"${myman}""$EXE_SUFFIX" -a -x "`dirname \"\$0\"`"/home/builder/build/pkg/myman/usr/bin/"${myman}""$EXE_SUFFIX"
      then
      MYMAN="`dirname \"\$0\"`"/home/builder/build/pkg/myman/usr/bin/"${myman}"
      break
  elif test -f /home/builder/build/pkg/myman/usr/bin/"${myman}" -a -x /home/builder/build/pkg/myman/usr/bin/"${myman}" -o -f /home/builder/build/pkg/myman/usr/bin/"${myman}""$EXE_SUFFIX" -a -x /home/builder/build/pkg/myman/usr/bin/"${myman}""$EXE_SUFFIX"
      then
      MYMAN=/home/builder/build/pkg/myman/usr/bin/"${myman}"
      break
  elif test -f "`type -p \"\${myman}\"`" -a -x "`type -p \"\${myman}\"`" -o -f "`type -p \"\${myman}\"`""$EXE_SUFFIX" -a -x "`type -p \"\${myman}\"`""$EXE_SUFFIX"
      then
      MYMAN="`type -p \"\${myman}\"`"
      break
  fi
done

if test -f /bin/sh -a -x /bin/sh -o -f /bin/sh"$EXE_SUFFIX" -a -x /bin/sh"$EXE_SUFFIX"
    then
    SHELL=/bin/sh
fi

xterm=xterm
geometry=448x288
font=nil2
termName=xterm
basename="`basename \"\$0\"`"

export RESETFONT
RESETFONT="[8;50;80t]50;micro]50;fixed"

# don't pollute the child terminal's environment
unset LINES
unset COLUMNS
if ! test -f "$TERMCAP"
    then unset TERMCAP
fi

# first, probe for myman
"$MYMAN" --help >/dev/null || exit $?

# second, probe for XCurses myman
if "$MYMAN" --help | fgrep toolkit-options > /dev/null
then
    exec \
        "$MYMAN" -a -2 -z kpac "$@" \
        -- \
        -lines "${geometry##*x}" \
        -cols "${geometry%x*}" \
        -normalFont "$font" \
        -colorBlack "#000000" \
        -colorBlue "#0000DD" \
        -colorGreen "#00B700" \
        -colorCyan "#00DDDD" \
        -colorRed "#DD9646" \
        -colorMagenta "#FF2096" \
        -colorYellow "#FFB746" \
        -colorWhite "#FFB796" \
        -colorBoldBlack "#666666" \
        -colorBoldBlue "#2020DD" \
        -colorBoldGreen "#96FF00" \
        -colorBoldCyan "#00FFDD" \
        -colorBoldRed "#FF0000" \
        -colorBoldMagenta "#F9B2D7" \
        -colorBoldYellow "#FFFF00" \
        -colorBoldWhite "#DDDDDD" \
        -cursorColor "#0000DB" \
        -pointerForeColor "#FAB393" \
        -pointerBackColor "#000000" \
        -borderWidth 0
        -xrm "*waitForMap: true" \
        -xrm "*iconName: xbitman2"
fi

export statusfile
statusfile="${TMPDIR:-/tmp}/${basename}$$.st"

cleanup()
{
    rm -f "${statusfile}"
}

trap cleanup 0

export arglist
arglist="-a -2 -z kpac"
while test $# -gt 0
do
  arglist="${arglist}"' ${arg'$#'}'
  eval export 'arg'$#
  eval 'arg'$#'="${1}"'
  shift
done

echo 1 > "${statusfile}" || exit $?

"$xterm" \
-geometry "$geometry" \
+sb \
-fn "$font" \
-bg "#000000" \
-fg "#FAB393" \
-cr "#0000DB" \
-xrm "*vt100.cjkWidth: false" \
-xrm "*vt100.boldFont: $font" \
-xrm "*vt100.boldMode: false" \
-xrm "*termName: $termName" \
-xrm "*iconName: xbitman2" \
-xrm "*title: X MyMan" \
-xrm "*waitForMap: true" \
-xrm "*vt100.underLine: false" \
-xrm "*vt100.color0:  #000000" \
-xrm "*vt100.color1:  #DD9646" \
-xrm "*vt100.color2:  #00B700" \
-xrm "*vt100.color3:  #FFB746" \
-xrm "*vt100.color4:  #0000DD" \
-xrm "*vt100.color5:  #FF2096" \
-xrm "*vt100.color6:  #00DDDD" \
-xrm "*vt100.color7:  #FFB796" \
-xrm "*vt100.color8:  #666666" \
-xrm "*vt100.color9:  #FF0000" \
-xrm "*vt100.color10: #96FF00" \
-xrm "*vt100.color11: #FFFF00" \
-xrm "*vt100.color12: #2020DD" \
-xrm "*vt100.color13: #F9B2D7" \
-xrm "*vt100.color14: #00FFDD" \
-xrm "*vt100.color15: #DDDDDD" \
-xrm "*vt100.colorBD: #FAFA00" \
-xrm "*vt100.colorUL: #2020D8" \
-xrm "*vt100.colorMode: true" \
-xrm "*vt100.colorBDMode: true" \
-xrm "*vt100.colorULMode: true" \
-xrm "*vt100.pointerColor: #FAB393" \
-xrm "*vt100.pointerColorBackground: #000000" \
-xrm "*vt100.reverseVideo: false" \
-xrm "*vt100.tekStartup: false" \
-xrm "*vt100.activeIcon: true" \
-xrm "*vt100.dynamicColors: true" \
-xrm "*vt100.internalBorder: 0" \
-xrm "*vt100.internalBorder: 0" \
-e "$SHELL" -c 'unset DISPLAY; export GGICURSES_FIXEDPAL; GGICURSES_FIXEDPAL="${GGICURSES_FIXEDPAL-t}"; export GGI_DISPLAY; GGI_DISPLAY="${GGI_DISPLAY:-terminfo}"; export CACA_DRIVER; CACA_DRIVER="${CACA_DRIVER:-ncurses}"; stty cbreak -echo 2>/dev/null; "$MYMAN" -o '"${arglist}"'; st=$?; echo "${st}" > "${statusfile}"; echo; echo "${RESETFONT}[ press RETURN to continue ]"; stty -echo; read x; exit "${st}"'
st="${?}"
if test :"${st}" = :"0"
then
    read st < "${statusfile}"
fi
cleanup
exit "${st:-1}"
