#!/usr/bin/env bash
# Author: Castro-Fidel (linux-gaming.ru)
########################################################################
export PW_PREFIX_NAME="LEAGUE_OF_LEGENDS"
export PW_AUTOINSTALL_EXE="${PW_USER_TEMP}/live.na.exe"
export LAUNCH_PARAMETERS="--launch-product=league_of_legends --launch-patchline=live"
export PW_MUST_HAVE_DLL=""
export PW_VULKAN_USE=1
export PW_WINE_USE=WINE_LOL_GE_8.27
# export WINEDLLOVERRIDES="mscoree,mshtml="
export PW_USE_D3D_EXTRAS=1
export DISABLE_CP_DEFPFX=1

gui_proton_downloader silent "${PW_WINE_USE}"

pw_clear_pfx
start_portwine
wait_wineserver
if try_download_game "https://lol.secure.dyn.riotcdn.net/channels/public/x/installer/current/live.na.exe" "${PW_AUTOINSTALL_EXE}"
then
    pw_start_progress_bar_block "Installing League of Legends. ${loc_gui_please_wait} "
    if [ "${update_loc}" = "RUS" ] ; then
       yad_info "Вы должны нажать кнопку установки, не изменяя настроек!"
   fi
   if [ "${update_loc}" = "ENG" ] ; then
       yad_info "You must click the install button without changing the settings!"
  fi
    pw_kill_autostart RiotClientServices.exe &
    pw_run "${PW_AUTOINSTALL_EXE}" 
    portwine_exe="$WINEPREFIX/drive_c/Riot Games/Riot Client/RiotClientServices.exe"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${portwine_exe}.ppdb"
    kill_portwine
    pw_stop_progress_bar
    export PORTWINE_CREATE_SHORTCUT_NAME="League of Legend"
    portwine_create_shortcut
fi
stop_portwine