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

EAPI=2
inherit eutils games

MY_REV="-1"
MY_ARCH="${ARCH/x86/i386}"

DESCRIPTION="real-time-strategy game featuring six different game modes"
HOMEPAGE="http://www.introversion.co.uk/multiwinia/"
SRC_URI="${PN}_${PV}${MY_REV}_${MY_ARCH}.tar.gz"

LICENSE="Introversion"
SLOT="0"
KEYWORDS="-* amd64 ~x86"
IUSE="doc"
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() {
	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 failed"
	newexe ${PN}.bin.* ${PN}.bin || die "install bin failed"

	# install documentation
	dodoc docs/readme.txt || die "install required doc failed"
	if use doc; then
		dodoc docs/manual.pdf || die "install optional doc failed"
	fi

	# install shortcuts
	doicon ${PN}.png || die "install icon failed"
	games_make_wrapper ${PN} ./${PN}.bin "${GAMEDIR}" "${GAMEDIR}" \
		|| die "install wrapper failed"
	make_desktop_entry ${PN} "Darwinia" \
		|| die "install shortcut failed"
	prepgamesdirs
}

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