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

EAPI=2
inherit eutils games

MY_ARCH="${ARCH/x86/i386}"

DESCRIPTION="a virtual themepark, populated by sentient evolving life forms, that has been overrun by a computer virus"
HOMEPAGE="http://www.introversion.co.uk/darwinia/"
SRC_URI="${PN}_${PV}_${MY_ARCH}.tar.gz"

LICENSE="Introversion"
SLOT="0"
KEYWORDS="-* amd64 ~x86"
IUSE=""
RESTRICT="fetch"

RDEPEND="media-libs/libogg
	media-libs/libsdl
	media-libs/libvorbis
	virtual/glu
	virtual/opengl
	x11-libs/libxcb
	x11-libs/libXext"
DEPEND=""

S=${WORKDIR}/${PN}

GAMEDIR=${GAMES_PREFIX_OPT}/${PN}

pkg_nofetch() {
	echo
	elog "Please purchase and download '${SRC_URI}'"
	elog "then copy to: '${DISTDIR}'"
	echo
}

src_install() {
	insinto "${GAMEDIR}"
	exeinto "${GAMEDIR}"

	# install game files
	doins *.dat || die "install dat"
	newexe ${PN}.bin.* ${PN}.bin || die "install bin"

	# install documentation
	dodoc {changes,readme-linux}.txt || die "install doc"

	# install shortcuts
	newicon darwinian.png ${PN}.png || die "install icon"
	games_make_wrapper ${PN} ./${PN}.bin "${GAMEDIR}" "${GAMEDIR}" \
		|| die "install shortcuts"
	make_desktop_entry ${PN} "Darwinia"
	prepgamesdirs
}

pkg_postinst() {
	einfo "To play the game, run:"
	einfo "${PN}"
	games_pkg_postinst
}