#!/usr/bin/env bash
# Author: cefeiko
# type: games
# name: Wargaming Game Center
# image: wgc
# info_en:
# info_ru:
########################################################################
export LAUNCH_PARAMETERS=("/VERYSILENT")
[[ "$LANGUAGE" == "ru" ]] && export WGC_LOC=RU || export WGC_LOC=EU
export PW_AUTOINSTALL_EXE="${PW_USER_TEMP}/Wargaming_Game_Center_Install_WoT_${WGC_LOC}.exe"
export PW_PREFIX_NAME="WGC"

start_portwine

if try_download "https://redirect.wargaming.net/WGC/Wargaming_Game_Center_Install_WoT_${WGC_LOC}.exe" "${PW_AUTOINSTALL_EXE}" no_mirror
then
    pw_start_progress_bar_install_game "WGC."
    pw_kill_autostart wgc.exe &
    pw_run "${PW_AUTOINSTALL_EXE}"
    portwine_exe="$WINEPREFIX/drive_c/ProgramData/Wargaming.net/GameCenter/api/wgc_api.exe"
    export PORTWINE_CREATE_SHORTCUT_NAME="Wargaming Game Center"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${portwine_exe}.ppdb"
    kill_portwine
    portwine_create_shortcut
fi
stop_portwine
