# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit games

HOMEPAGE="http://jonof.edgenetwork.org/index.php?p=jfsw"
DESCRIPTION="An OpenGL port of Shadow Warrior with support for true-colour textures and 3D objects"
SRC_URI="http://jonof.edgenetwork.org/dl/buildport/jfbuild_src_${PV}.zip
	 http://jonof.edgenetwork.org/dl/buildport/${PN}_src_${PV}.zip"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86"
RESTRICT="nomirror"

RDEPEND="x11-base/xorg-x11
	virtual/opengl
	media-libs/sdl-mixer
	media-sound/timidity++
	media-sound/timidity-eawpatches"

DEPEND="${RDEPEND}
	dev-lang/nasm"

src_unpack() {
	unpack ${A}
	mv "jfbuild_src_${PV}" build
	cd build
	epatch "${FILESDIR}/jfbuild_src_${PV}.patch" # Fix various problems
	cd "${WORKDIR}/jfsw_src_${PV}"
	epatch "${FILESDIR}/${PN}_src_${PV}.patch" # Sound support
}

src_compile() {
	cd "${WORKDIR}/${PN}_src_${PV}"
	emake || die = "Compilation failed"
	mv sw ${PN}-bin
}

src_install() {
	cd "${WORKDIR}/jfsw_src_${PV}/"
	games_make_wrapper ${PN} "${GAMES_BINDIR}/${PN}-bin" "${GAMES_DATADIR}/sw"
	dogamesbin ${PN}-bin || die "dogamesbin failed."
	insinto "${GAMES_DATADIR}/sw"
	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst
	einfo "Put 'sw.grp' in '${GAMES_DATADIR}/sw',"
	einfo "or emerge swdata-demo to play the demo."
	einfo "Do not enable ambient sounds; they will crash"
	einfo "the game.  This version has no music support."
}