# DEPRECATED: wine-8.0 has full media foundation support
# Keeping this for wine-7.0 and wine-5.0.5
# Install Media Foundation Libraries, required for UE4 games
# https://en.wikipedia.org/wiki/List_of_Unreal_Engine_games#Unreal_Engine_4
TEMPDIR="$(realpath -m ~/.var/app/${FLATPAK_NAME}/data/tmp)"
WINEZGUIDIR="$(realpath -m ~/.var/app/${FLATPAK_NAME}/data/winezgui)"

mkdir -p "${WINEZGUIDIR}"
mkdir -p "${TEMPDIR}"

cd "${TEMPDIR}"
echo "Downloading mf-install..."
wget -c https://github.com/z0z0z/mf-install/archive/refs/tags/1.0.tar.gz

if [ -f "${TEMPDIR}/1.0.tar.gz" ]; then
            echo "found ${TEMPDIR}/1.0.tar.gz"
            DOWNLOAD_CHECKSUM="$(sha256sum ${TEMPDIR}/1.0.tar.gz|cut -f1 -d ' ')"
            SHA256="f0274fd22f27dfdf212c3a55ca0269f455150410639b00adc41a578fe4478bec"
            
            if [ "${SHA256}" = "${DOWNLOAD_CHECKSUM}" ]; then
                 echo "Sha256sum success! Installing..."
                 cd "${TEMPDIR}"
                 tar -zxvf 1.0.tar.gz
                 cd "${TEMPDIR}/mf-install-1.0/"
                 sh ./mf-install.sh
            else
                 echo "sha256 mismatch... removing downloaded file."
                 rm -v "${TEMPDIR}/1.0.tar.gz"
                 echo "run this script again... to install mf"
            fi
            
fi

    


