#!/usr/bin/env bash
# Author: chal55rus
# type: games
# name: Lesta Game Center
# image: lgc
# info_en: Launcher for Lesta Games studio games.
# info_ru: Лаунчер для игр Lesta Games.
########################################################################
export LAUNCH_PARAMETERS="/VERYSILENT"
export PW_AUTOINSTALL_EXE="${PORT_WINE_TMP_PATH}/Lesta_Game_Center_Install_RU.exe"
export PW_PREFIX_NAME="LGC"
export PW_USE_ESYNC="1"
export PW_USE_FSYNC="1"
export PW_USE_NTSYNC="0"

start_portproton

if try_download "https://redirect.lesta.ru/LGC/Lesta_Game_Center_Install_RU.exe" "${PW_AUTOINSTALL_EXE}" no_mirror
then
    pw_kill_autostart lgc.exe &
    pw_run "${PW_AUTOINSTALL_EXE}"
    PW_EXE_FILE="$WINEPREFIX/drive_c/ProgramData/Lesta/GameCenter/api/lgc_api.exe"
    export PORTWINE_CREATE_SHORTCUT_NAME="Lesta Game Center"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${PW_EXE_FILE}.ppdb"
    kill_portwine
    portwine_create_shortcut
fi

stop_portproton
