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

EAPI=2
inherit eutils games

MY_PN="${PN//-/}"

DESCRIPTION="a comic fantasy roguelike dungeon crawler game"
HOMEPAGE="http://www.dungeonsofdredmor.com/"
SRC_URI="dredmor_humblebundle-linux-${PV}.tar.gz"

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

RDEPEND="app-arch/bzip2
	media-libs/freetype
	media-libs/libsdl
	media-libs/openal
	media-libs/sdl-ttf
	sys-libs/zlib"
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 -r achievements DredmorSchema.xsd dungeon fonts game items playLogs \
		sfx skills sprites tilesets tunes ui || die "install data failed"
	newexe Dredmor-${ARCH} Dredmor || die "install bin failed"

	# install shortcuts
	#newicon darwinian.png ${PN}.png || die "install icon failed"
	games_make_wrapper ${PN} "./Dredmor" "${GAMEDIR}" \
		|| die "install shortcuts failed"
	make_desktop_entry ${PN} "Dungeons of Dredmor" ""
	prepgamesdirs
}

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