Files
OpenRA/packaging/osx/template.app/Contents/MacOS/OpenRA
2010-10-09 20:05:37 +13:00

85 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
# This file is part of OpenRA, which is free software. It is made
# available to you under the terms of the GNU General Public License
# as published by the Free Software Foundation. For more information,
# see LICENSE.
# Internal options
APP_PATH=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+3] != "") { if (patharr[idx] != "/") {printf("%s/", patharr[idx]); idx++ }} }'`
EXE_PATH=$APP_PATH/Contents/MacOS/
export LD_LIBRARY_PATH="$EXE_PATH/lib":$LD_LIBRARY_PATH
export MONO_PATH="$EXE_PATH/lib"
RESOURCES_PATH=$APP_PATH/Contents/Resources
# Tweakable options
#export MONO_LOG_LEVEL=debug
GAME_PATH=$RESOURCES_PATH
SUPPORT_PATH=~/Library/"Application Support"/OpenRA
# Downloadable content
DEPS_PACKAGE="osx-deps-v4.zip"
DEPS_URL="http://open-ra.org/get-dependency.php?file=osx-deps-v4"
RA_PACKAGE="ra-packages.zip"
RA_URL="http://open-ra.org/get-dependency.php?file=ra-packages"
CNC_PACKAGE="cnc-packages.zip"
CNC_URL="http://open-ra.org/get-dependency.php?file=cnc-packages"
cd "$EXE_PATH"
# Download and install game dependencies if needed
if [[ ! -e "mono" ]]; then
./download_package "$DEPS_PACKAGE" "$EXE_PATH" "14.5 Mb" "required game dependencies" $DEPS_URL
if [[ ! -e "mono" ]]; then
./display_error "Installation failed" "Package install failed."
exit 1
fi
fi
# Prompt for the mod to run
MODBUTTON=`/usr/bin/osascript << EOT
tell application "Finder"
activate
display dialog "Choose a mod" buttons {"Red Alert", "C&C", "Quit"} \
default button "Red Alert" \
with icon alias (POSIX file "$RESOURCES_PATH/OpenRA.icns") \
with title "OpenRA Mod Selector"
set result to button returned of result
end tell
EOT`
if [ "$MODBUTTON" == "Quit" ]; then
exit 0
fi
MOD="ra"
if [ "$MODBUTTON" == "C&C" ]; then
MOD="cnc"
fi
# Check that the game data is installed
if [[ $MOD == "ra" && ! -e "$GAME_PATH/mods/ra/packages/redalert.mix" ]]; then
./download_package "ra-packages.zip" "$GAME_PATH/mods/ra/packages/" "10 Mb" "the Red Alert game data" $RA_URL
if [[ ! -e "$GAME_PATH/mods/ra/packages/redalert.mix" ]]; then
./display_error "Installation failed" "Package install failed."
exit 1
fi
fi
if [[ $MOD == "cnc" && ! -e "$GAME_PATH/mods/cnc/packages/conquer.mix" ]]; then
./download_package "cnc-packages.zip" "$GAME_PATH/mods/cnc/packages/" "5.9 Mb" "the C&C game data" $CNC_URL
if [[ ! -e "$GAME_PATH/mods/cnc/packages/conquer.mix" ]]; then
./display_error "Installation failed" "Package install failed."
exit 1
fi
fi
# Run the game
cd "${GAME_PATH}"
"${EXE_PATH}"mono --debug "OpenRA.Game.exe" Game.Mods=$MOD SupportDir=~/Library/"Application Support"/OpenRA
# Did we crash?
STATUS=$?
if [ "$STATUS" != "0" ]; then
"$EXE_PATH"/display_error "OpenRA Crashed" "Sorry about that!\nA crash log has been saved to ~/Library/Application Support/OpenRA/Logs."
fi