#!/usr/bin/env bash
# Author: Castro-Fidel (linux-gaming.ru)
########################################################################
export PW_PREFIX_NAME="BLACK_DESERT_ONLINE"
export PW_AUTOINSTALL_EXE="${PW_USER_TEMP}/BlackDesert_Installer_RU.exe"
export LAUNCH_PARAMETERS="/silent"
export PW_MUST_HAVE_DLL=""
export PW_VULKAN_USE=1
export PW_USE_D3D_EXTRAS=1
export PW_WINE_USE=PROTON_LG
# export DISABLE_CP_DEFPFX=1

pw_clear_pfx
start_portwine
wait_wineserver

if try_download_no_mirror "https://nez-o-dn.playblackdesert.com/UploadData/installer/BlackDesert_Installer_RU.exe" "${PW_AUTOINSTALL_EXE}"
then
    pw_start_progress_bar_block "${loc_gui_installing_the} Black Desert Online. ${loc_gui_please_wait} "
    pw_run "${PW_AUTOINSTALL_EXE}" 
    portwine_exe="$WINEPREFIX/drive_c/Pearlabyss/BlackDesert/BlackDesertLauncher.exe"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${portwine_exe}.ppdb"
    kill_portwine
    pw_stop_progress_bar
    export PORTWINE_CREATE_SHORTCUT_NAME="Black Desert Online"
    portwine_create_shortcut
fi
stop_portwine
