#!/usr/bin/env bash
# Author: chal55rus (Sergey P.)
########################################################################
export LAUNCH_PARAMETERS=("")
export PW_PREFIX_NAME="ROBLOX"
export PW_AUTOINSTALL_EXE="${PW_USER_TEMP}/roblox_installer.exe"
export WINEDLLOVERRIDES="mscoree,mshtml="
# export DISABLE_CP_DEFPFX=1
export PW_MUST_HAVE_DLL=""
export PORTWINE_CREATE_SHORTCUT_NAME="RobloxPlayerBeta"

start_portwine
if try_download_no_mirror "https://setup.rbxcdn.com/RobloxPlayerLauncher.exe" "${PW_AUTOINSTALL_EXE}"
then
    pw_kill_autostart MicrosoftEdge &
    pw_run "${PW_AUTOINSTALL_EXE}"
    portwine_exe="$(find "$WINEPREFIX/drive_c/Program Files (x86)/Roblox/" -type f -name "RobloxPlayerBeta.exe" | head -n 1)"
    try_remove_file "${portwine_exe}.ppdb"
    pw_stop_progress_bar
    portwine_create_shortcut
fi
stop_portwine
