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

EAPI=3

inherit eutils games

DESCRIPTION="Osmos is a high physics puzzle game where you must survive eating small matter or avoiding big matter"
HOMEPAGE="http://www.hemispheregames.com/osmos/"
RESTRICT="fetch strip"

SLOT="0"
KEYWORDS="x86 amd64"
IUSE="djvu"

LICENSE="hemispheregames-EULA"

DEPEND="
media-libs/freetype
media-libs/libvorbis
media-libs/openal
x11-libs/libX11
virtual/opengl
djvu? (
		app-text/djvu
	)
!djvu? (
		<media-libs/freetype-2.4.3
	)
"
RDEPEND="${DEPEND}"

MY_PN="OsmosDemo"
SRC_URI="${MY_PN}_${PV}.tar.gz"
S=${WORKDIR}/${MY_PN}

pkg_nofetch() {
	echo
	elog "Download tar.gz version of Osmos Demo from"
	elog "${HOMEPAGE} and place it"
	elog "in ${DISTDIR}"
	echo
}


src_install() {

	local d=${GAMES_PREFIX_OPT}/${MY_PN}

	#Replace the font for DejaVu Sans. >=freetype-2.4.3 doesnt like the original.
	if use djvu ; then
	  rm "Fonts/FortuneCity.ttf"
	  dosym "/usr/share/fonts/dejavu/DejaVuSans.ttf" "${d}/Fonts/FortuneCity.ttf" ||
	  die "I cant found DejaVuSans installed"
	fi
	
	insinto "${d}"
	doins -r * || die

	# create a symlink to the binary in the games bin directory
	dosym ${d}/${MY_PN} "${GAMES_BINDIR}"/${PN}

	# create an icon in the /usr/share/pixmaps directory
	newicon Icons/32x32.png ${PN}.png

	# create a desktop entry
	make_desktop_entry ${PN} "Osmos (Demo)"

	pushd "${D}${d}" >/dev/null
	chmod a+rx ${MY_PN}* || die
	popd >/dev/null
	
	prepgamesdirs
}