#!/usr/bin/env bash
# Author: Castro-Fidel (linux-gaming.ru)
# type: games
# name: Steam (UNSTABLE)
# image: steam
# info_en: Launcher for the Steam game library.
# info_ru: Лаунчер для библиотеки игр Steam.
########################################################################
export PW_WINE_USE="WINE_LG"
export LAUNCH_PARAMETERS="/S /D=c:\Program Files (x86)\Steam"
export PW_AUTOINSTALL_EXE="${PORT_WINE_TMP_PATH}/SteamSetup.exe"

start_portproton
if try_download "https://cdn.akamai.steamstatic.com/client/installer/SteamSetup.exe" "${PW_AUTOINSTALL_EXE}" no_mirror
then
    pw_kill_autostart steam.exe &
    pw_run "${PW_AUTOINSTALL_EXE}"
    if [[ -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/Steam.exe" ]]
    then mv -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/Steam.exe" "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"
    fi
    PW_EXE_FILE="$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${PW_EXE_FILE}.ppdb"
    kill_portwine
    export PORTWINE_CREATE_SHORTCUT_NAME="STEAM_PP"
    portwine_create_shortcut
fi
stop_portproton
