#!/usr/bin/env bash
# Author: Castro-Fidel (linux-gaming.ru)
# type: games
# name: Black Desert Online (RU)
# image: bdo
# info_en: A massively multiplayer online role-playing game set in an open world, renowned for its stunning graphics and deep character customization system. Players can explore vast lands, complete quests, engage in PvP battles, and participate in various crafting activities.
# info_ru: Многопользовательская ролевая игра с открытым миром, известная своей потрясающей графикой и глубокой системой кастомизации персонажей. Игроки могут исследовать обширные земли, выполнять задания, участвовать в PvP-сражениях и заниматься различными ремеслами.
########################################################################
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 "https://nez-o-dn.playblackdesert.com/UploadData/installer/BlackDesert_Installer_RU.exe" "${PW_AUTOINSTALL_EXE}" no_mirror
then
    pw_start_progress_bar_install_game "Black Desert Online."
    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
