Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Global
- GOG_BASH_LIBRARY_VERSION="1.1"
- HELP_TEXTS=""
- _OPTION_FOUND="false"
- library_sanity_test() {
- echo "Library responding!"
- }
- get_gameinfo() {
- cat gameinfo | head -n "${1}" | tail -n 1
- }
- _option_found() {
- _OPTION_FOUND="true"
- }
- # define option (short_name,long_name,help_text,arguments,action, arguments)
- define_option() {
- local short_name=$1
- local long_name=$2
- local help_text=$3
- local function=$4
- local arguments=$5
- local help_text="${short_name}, \t${long_name} \t\t- ${help_text}"
- HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
- if [ "${arguments}" == "${short_name}" ] || [ "${arguments}" == "${long_name}" ] ; then
- _option_found
- "${function}" $arguments
- fi
- }
- # version_option (version_gog,version_original)
- version_option() {
- local help_text="-v, \t--version \t\t- show version of this package"
- HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
- local version_gog=$1
- local version_original=$2
- local arguments=$3
- if [ "${arguments}" == "-v" ] || [ "${arguments}" == "--version" ] ; then
- _option_found
- echo "${version_gog} (GOG.com)"
- echo "${version_original} (Developer)"
- fi
- }
- system_report_option() {
- local arguments=$1
- local help_text="-p, \t--sysrep \t\t- generate a system report"
- HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
- if [ "${arguments}" == "-p" ] || [ "${arguments}" == "--sysrep" ] ; then
- _option_found
- cd support
- ./gog-system-report.sh
- fi
- }
- # help_option (arguments)
- help_option(){
- local arguments=$1
- local help_text="-h, \t--help \t\t\t- display this help"
- HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
- if [ "${arguments}" == "-h" ] || [ "${arguments}" == "--help" ] ; then
- _option_found
- echo -e "${GAME_NAME} [ ${VERSION} ] (GOG.com)\n"
- echo -e "usage: [command] [argument]\n"
- echo -e "Arguments: "
- echo -e $HELP_TEXTS | column -t -s $'\t'
- echo -e ""
- cat support/support_notice.txt
- fi
- }
- default_option() {
- if [ "${_OPTION_FOUND}" != "true" ] ; then
- default
- fi
- }
- standard_options() {
- version_option "${VERSION}" "${VERSION_DEV}" "$@"
- system_report_option "$@"
- help_option "$@" # this has to be latest option before default_option
- default_option
- }
- ###
- # Native
- ###
- execute_game() {
- local bin_32="${1}"
- local bin_64="${2}"
- local bin_path32="${3}"
- local bin_path64="${4}"
- local lib_path32="${5}"
- local lib_path64="${6}"
- local arch=$(uname -m)
- if [ "$arch" == "x86_64" ]
- then
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
- cd "${bin_path64}"
- ./"${bin_64}"
- else
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
- cd "${bin_path32}"
- ./"${bin_32}"
- fi
- }
- execute_game_with_params() {
- local bin_32="${1}"
- local bin_64="${2}"
- local bin_path32="${3}"
- local bin_path64="${4}"
- local lib_path32="${5}"
- local lib_path64="${6}"
- local arch=$(uname -m)
- if [ "$arch" == "x86_64" ]
- then
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
- cd "${bin_path64}"
- ./"${bin_64}" "$@"
- else
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
- cd "${bin_path32}"
- ./"${bin_32}" "$@"
- fi
- }
- execute_game_aoss() {
- local bin_32="${1}"
- local bin_64="${2}"
- local bin_path32="${3}"
- local bin_path64="${4}"
- local lib_path32="${5}"
- local lib_path64="${6}"
- local arch=$(uname -m)
- if [ "$arch" == "x86_64" ]
- then
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
- cd "${bin_path64}"
- ./aoss ./"${bin_64}"
- else
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
- cd "${bin_path32}"
- ./aoss ./"${bin_32}"
- fi
- }
- ###
- # DOSBox
- ###
- run_dosbox() {
- local conf_1="${1}"
- local conf_2="${2}"
- ./dosbox/dosbox -conf "${conf_1}" -conf "${conf_2}" -no-console -c exit
- }
- ###
- # ScummVM
- ###
- run_scummvm() {
- local conf="${1}"
- ./scummvm/scummvm -c "${conf}" --themepath=scummvm
- }
- ###
- # Wine
- ###
- run_wine() {
- local game_path="${1}"
- local executable="${2}"
- local args="${3}"
- cd "${CURRENT_DIR}/prefix/${game_path}"
- export WINEPREFIX="${CURRENT_DIR}/prefix"
- echo "WINEPREFIX="$WINEPREFIX
- "${CURRENT_DIR}/wine_standalone/wine" "${game_path}" "${executable}" "${args}"
- }
- run_wine_virtual() {
- local game_path="${1}"
- local executable="${2}"
- local args="${3}"
- cd "${CURRENT_DIR}/prefix/${game_path}"
- export WINEPREFIX="${CURRENT_DIR}/prefix"
- echo "WINEPREFIX="$WINEPREFIX
- "${CURRENT_DIR}/wine_standalone/wine-virtual" "${game_path}" "${executable}" "${args}"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement