#!/usr/bin/env bash
# author: chal55rus (Sergey P.)
# type: games
# name: Ankama Launcher
# image: ankama
# info_en: Launcher for Ankama studio games.
# info_ru: Лаунчер для игр Ankama.
########################################################################
export LAUNCH_PARAMETERS="/S"
export PW_AUTOINSTALL_EXE="${PORT_WINE_TMP_PATH}/Ankama-Setup.exe"
export PW_WINE_USE="WINE_LG"
export PW_PREFIX_NAME="ANKAMA"

start_portproton
if try_download "https://download.ankama.com/launcher/full/win/" "${PW_AUTOINSTALL_EXE}" no_mirror
then
    get_and_set_reg_file --add 'Software\Wine\X11 Driver' 'Decorated' 'REG_SZ' "N" "user"
    pw_run "${PW_AUTOINSTALL_EXE}"
    PW_EXE_FILE="$WINEPREFIX/drive_c/users/steamuser/AppData/Local/Programs/Ankama Launcher/Ankama Launcher.exe"
    try_remove_file "${PW_AUTOINSTALL_EXE}"
    try_remove_file "${PW_EXE_FILE}.ppdb"
    kill_portwine
    export PORTWINE_CREATE_SHORTCUT_NAME="Ankama Launcher"
    portwine_create_shortcut
fi
stop_portproton
