# Copyright 2016 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require desktop-utils
require github [ user=solarus-games tag=v${PV} ]
require cmake [ api=2 ]
require gtk-icon-cache

SUMMARY="Zelda fangame with Solarus - Remake of Zelda Return of the Hylian"
HOMEPAGE="http://www.solarus-games.org/ ${HOMEPAGE}"

LICENCES="CCPL-Attribution-ShareAlike-3.0 GPL-3"
SLOT="0"
PLATFORMS="~amd64 ~x86"

DEPENDENCIES="
    build:
        app-arch/zip
    run:
        games-engines/solarus[~>1.5.0]
"

CMAKE_SRC_CONFIGURE_PARAMS=(
    -DSOLARUS_INSTALL_DATAROOTDIR=/usr/share
    -DSOLARUS_INSTALL_BINDIR="/usr/$(exhost --target)/bin"
)

DEFAULT_SRC_PREPARE_PATCHES=(
    "${FILES}"/e9b5bd907f5b50b17d65ebe2fa50760d322c537c.patch
)

src_install() {
    cmake_src_install

    insinto /usr/share/icons/hicolor/128x128/apps
    newins "${CMAKE_SOURCE}"/data/logos/icon_128.png ${PN}.png

    # install proper wrapper script
    edo rm "${IMAGE%/}"/usr/$(exhost --target)/bin/zelda_roth_se
    herebin ${PN} <<EOF
#!/bin/sh
exec solarus-run "/usr/share/solarus/zelda_roth_se" "\$@"
EOF

    install_desktop_entry "Name=Zelda: Return of the Hylian"
}