# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               github 1.0
PortGroup               cmake 1.1
PortGroup               app 1.1

github.setup            TerryCavanagh VVVVVV 2.4.3
revision                0
categories              games
maintainers             {i0ntempest @i0ntempest} openmaintainer
license                 Restrictive/Distributable

description             The indie platformer game where you reversed gravity instead of jumping
long_description        {*}${description}. Developed by Terry Cavanagh, with music by Magnus Pålsson.
homepage                https://thelettervsixtim.es

github.tarball_from     releases
use_zip                 yes
set data_file           data.zip
set main_distfile       ${distfiles}
master_sites-append     ${homepage}/makeandplay/:data
distfiles-append        ${data_file}:data

checksums               ${main_distfile} \
                        rmd160  921dafe85d30ff41032a2334e2f81d8b4cd4b583 \
                        sha256  146a34f2e5499ea30ecf2ec6bb8ed6b08c388b6d386da9cd1808d0863541c167 \
                        size    11037985 \
                        ${data_file} \
                        rmd160  3278bcda68a285af19f8a0e5d9234e7beadea5f5 \
                        sha256  c767809594f6472da9f56136e76657e38640d584164a46112250ac6293ecc0ea \
                        size    61405423

depends_lib-append      port:libsdl2 \
                        port:tinyxml2 \
                        port:physfs \
                        port:FAudio

cmake.source_dir        ${worksrcpath}/desktop_version
cmake.build_type        Release

extract.only            ${main_distfile}
extract.rename          yes
post-extract {
    system -W ${cmake.source_dir} "unzip -p ${distpath}/data.zip VVVVVV.png > icon.png"
}

post-patch {
    reinplace "s|RELEASE_VERSION \"v.*\"|RELEASE_VERSION \"v${version}\"|" ${worksrcpath}/desktop_version/src/ReleaseVersion.h
}

configure.args-append   -DOFFICIAL_BUILD=ON \
                        -DBUNDLE_DEPENDENCIES=OFF \
                        -DSTEAM=OFF \
                        -DGOG=OFF \
                        -DMAKEANDPLAY=ON

configure.cxxflags-append \
                        -I${prefix}/include/FAudio

app.executable          ${build.dir}/${name}
app.icon                ${cmake.source_dir}/icon.png

destroot {}
post-destroot {
    copy ${distpath}/data.zip ${cmake.source_dir}/lang ${cmake.source_dir}/fonts ${worksrcpath}/LICENSE.md\
         ${destroot}${applications_dir}/${app.name}.app/Contents/Resources/
}

variant campaign description {Game will include the main campaign} {
    license             Restrictive
    configure.args-replace \
                        -DMAKEANDPLAY=ON \
                        -DMAKEANDPLAY=OFF
}

if {![variant_isset campaign]} {
    notes-append {
        By default this port compiles the "Make and Play Edition" which does not include the main campaign.
        To play the main campaign, use +campaign variant which makes the game non-redistributable.
    }
}
