#!/usr/bin/env bash
#Author: PortWINE
#Origin.exe 
#Rating=?
#####################examples###########################
##export PW_COMMENT_DB="blablabla"

##export PW_WINDOWS_VER=10                        # Set windows version 10, 7 or XP
export PW_DLL_INSTALL="vcrun2012 vcrun2019 d3dcompiler_43 d3dcompiler_47 d3dx9"               # Install DDL in port prefix (used winetricks) 
##export WINEDLLOVERRIDES="blabla=n,b"
##export LAUNCH_PARAMETERS="('"+com_skipIntroVideo 1"' '"+com_skipSignInManager 1"')"                # Additional launch options

export PW_VULKAN_USE=1                       # dxvk, vkd3d or 0 for OpenGL
##export PW_DXVK_VER=1.8.1 
##export PW_VKD3D_VER=2.2
##export PW_USE_DXR10=1
##export PW_VULKAN_NO_ASYNC=1                     # Disabled ASYNC for VULKAN
export PW_USE_NVAPI_AND_DLSS=0
##export PW_OLD_GL_STRING=0
##export PW_HIDE_NVIDIA_GPU=0
##export PW_FORCE_USE_VSYNC=2                     # Vsync: 0-FORCE_OFF, 1-FORCE_ON, 2-BY_DEFAULT
##export PW_VKD3D_FEATURE_LEVEL=0
##export PW_DXGI_FROM_DXVK=0
##export PW_VIRTUAL_DESKTOP=1
##export VKD3D_CONFIG=force_bindless_texel_buffer,multi_queue

##export PW_NO_FSYNC=1                            # Do not use futex-based in-process synchronization primitives. (Automatically disabled on systems with no FUTEX_WAIT_MULTIPLE support.
##export PW_NO_ESYNC=1                            # Do not use eventfd-based in-process synchronization primitives

##export PULSE_LATENCY_MSEC=60                    # Fix crackling audio in games

##export PW_USE_GAMEMODE=0              # Force disabele gamemod
##export PW_FORCE_LARGE_ADDRESS_AWARE=1           # Force Wine to enable the LARGE_ADDRESS_AWARE flag for all executables. Enabled by default.
##export PW_NO_WRITE_WATCH=0                      # Disable support for memory write watches in ntdll. This is a very dangerous hack and should only be applied if you have verified that the game can operate without write watches. This improves performance for some very specific games (e.g. CoreRT-based games).
##export PW_HEAP_DELAY_FREE=0

##export WINEARCH=win32                           # defaut = win64
##export WINEPREFIX=

##export PW_WINEDBG_DISABLE=1                     # Disabled WINEDBG
##export PW_USE_TERMINAL=0                        # Force run in terminal
##export PW_LOG=0                                 # Enable debug mode fo terminal 
##export PW_GUI_DISABLED_CS=1                     # 1 = disabled GUI 

export STAGING_SHARED_MEMORY=0

#add_in_start_portwine () {
#     export PW_USER_TEMP="$WINEPREFIX/drive_c/users/${USER}/Temp"    
#     if try_download "download.dm.origin.com/origin/live/OriginSetup.exe" "${PW_USER_TEMP}/OriginSetup.exe" ; then
#         pw_start_progress_bar_block "Extracting files for update the Origin..."
#         unzip "${PW_USER_TEMP}/OriginSetup.exe" 'update/*.zip' -d "${PW_USER_TEMP}/" 
#         unzip -o "${PW_USER_TEMP}/update/"*.zip -d "$WINEPREFIX/drive_c/Program Files (x86)/Origin/"
#         try_remove_dir "${PW_USER_TEMP}/update"
#         try_remove_file "${PW_USER_TEMP}/OriginSetup.exe"
#         pw_stop_progress_bar
#         pw_start_progress_bar_cs "Starting the Origin..."
        
#         check_origin_update () {
#             while : 
#             do  
#                 sleep 3
#                 if [ ! -z `pgrep Origin.exe | head -n 1` ] ; then 
#                     sleep 1
#                 else
#                     if [ ! -z `pgrep OriginSetup* | head -n 1` ] ; then
#                         kill -n 9 `pgrep OriginSetup* | head -n 1`
#                     fi
#                     if [ ! -z `pgrep OriginThin* | head -n 1` ] ; then
#                         kill -n 9 `pgrep OriginThin* | head -n 1`
#                     fi
#                     break
#                 fi
#             done
#         }
#         check_origin_update &
#     fi
#}

