#!/usr/bin/env bash
# Author: Castro-Fidel (linux-gaming.ru)
# type: games
# name: GOG Galaxy Launcher
# image: gog
# info_en: Launcher for the GOG game library.
# info_ru: Лаунчер для библиотеки игр GOG.
########################################################################
GOG_VER=2.0

export PW_AUTOINSTALL_EXE="${PORT_WINE_TMP_PATH}/setup_galaxy_${GOG_VER}.exe"
export LAUNCH_PARAMETERS="/VERYSILENT"
export PW_PREFIX_NAME="GOG"
export DISABLE_CP_DEFPFX="1"
export PW_WINE_USE="PROTON_LG_9-12"
export PORTWINE_CREATE_SHORTCUT_NAME="GOG GALAXY"

start_portproton
if try_download "https://webinstallers.gog-statics.com/download/GOG_Galaxy_${GOG_VER}.exe" "${PW_AUTOINSTALL_EXE}" no_mirror
then
    pw_run "${PW_AUTOINSTALL_EXE}"
    PW_EXE_FILE="$WINEPREFIX/drive_c/Program Files (x86)/GOG Galaxy/GalaxyClient.exe"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${PW_EXE_FILE}.ppdb"
    kill_portwine
    portwine_create_shortcut
fi
stop_portproton
