# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# Nonofficial ebuild by Ycarus. For new version look here : http://gentoo.zugaina.org/

inherit eutils games

MY_P="MegaMek-v0.29-stable-10"
DESCRIPTION="MegaMek is an unofficial, online version of the Classic BattleTech board game."
DESCRIPTION_FR="MegaMek est une version non-officielle et en-ligne de BattleTech."
SRC_URI="mirror://sourceforge/megamek/${MY_P}.zip"
HOMEPAGE="http://megamek.sourceforge.net/"

SLOT="0"
LICENSE="GPL2"
KEYWORDS="x86"
IUSE=""
RESTRICT="nomirror"

DEPEND=">=virtual/jdk-1.4"
RDEPEND=">=virtual/jre-1.4"

S=${WORKDIR}

src_install() {
    dodir "${GAMES_DATADIR}/megamek"
    cd ${S}
    cp -r ./* "${D}${GAMES_DATADIR}/megamek"
    games_make_wrapper_special MegaMek.jar megamek
    dodoc license.txt readme.txt todo.txt history.txt ai-readme.txt
}

games_make_wrapper_special() {
    # This is a special wrapper script
    local binname="$1"
    local finalbinname="$2"
    local tmpwrapper="${T}/tmp$1"
    cat << EOF > ${tmpwrapper}
#!/bin/sh
cd ${GAMES_DATADIR}/megamek
java -jar ${binname}
EOF
    dodir ${GAMES_BINDIR}
    exeinto ${GAMES_BINDIR}
    newexe ${tmpwrapper} ${finalbinname}
    prepgamesdirs
    fperms 770 "${GAMES_DATADIR}/megamek"
}