62 lines
2.7 KiB
Bash
Executable File
62 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# OpenRA OSX launcher script
|
|
# Checks for a sufficiently recent mono version, then launches the game from the resources directory.
|
|
# Based on code from the monodevelop project
|
|
|
|
REQUIRED_MAJOR=3
|
|
REQUIRED_MINOR=2
|
|
|
|
# Require a framework build of mono.
|
|
# The game files assume that mono-installed libraries are present in /Library/Frameworks/Mono.framework/Libraries
|
|
MONO_BIN="/Library/Frameworks/Mono.framework/Commands/mono"
|
|
|
|
TITLE="Cannot launch OpenRA"
|
|
MESSAGE="OpenRA requires Mono $REQUIRED_MAJOR.$REQUIRED_MINOR or later. Please install the Mono MRE package and try again."
|
|
MONO_URL="http://www.mono-project.com/download/"
|
|
|
|
CRASH_TITLE="Fatal Error"
|
|
CRASH_MESSAGE="OpenRA has encountered a fatal error.\nRefer to the crash logs and FAQ for more information."
|
|
FAQ_URL="http://wiki.openra.net/FAQ"
|
|
|
|
DIR=$(cd "$(dirname "$0")"; pwd)
|
|
RESOURCES="$DIR/../Resources"
|
|
|
|
MONO_VERSION="$($MONO_BIN --version | grep 'Mono JIT compiler version ' | cut -f5 -d\ )"
|
|
MONO_VERSION_MAJOR="$(echo $MONO_VERSION | cut -f1 -d.)"
|
|
MONO_VERSION_MINOR="$(echo $MONO_VERSION | cut -f2 -d.)"
|
|
|
|
if [ -z "$MONO_VERSION" ] \
|
|
|| [ $MONO_VERSION_MAJOR -lt $REQUIRED_MAJOR ] \
|
|
|| [ $MONO_VERSION_MAJOR -eq $REQUIRED_MAJOR -a $MONO_VERSION_MINOR -lt $REQUIRED_MINOR ]
|
|
then
|
|
osascript \
|
|
-e "tell application \"Finder\"" \
|
|
-e " set question to display dialog \"$MESSAGE\" with title \"$TITLE\" with icon alias (POSIX file \"$RESOURCES/OpenRA.icns\") buttons {\"Quit\", \"Download Mono\"} default button 2" \
|
|
-e " if button returned of question is equal to \"Download Mono\" then open location \"$MONO_URL\"" \
|
|
-e " activate" \
|
|
-e "end tell"
|
|
exit 1
|
|
fi
|
|
|
|
# Override fontconfig with our own dummy config that prevents long cache delays
|
|
cd "$RESOURCES" && FONTCONFIG_PATH="." $MONO_BIN --debug OpenRA.Game.exe Graphics.Renderer=Sdl2
|
|
|
|
# Display an error dialog on game crash
|
|
if [ $? != 0 -a $? != 1 ]
|
|
then
|
|
osascript \
|
|
-e "set logsPath to ((path to application support folder from user domain) as text) & \"OpenRA:Logs:\"" \
|
|
-e "log logsPath" \
|
|
-e "tell application \"Finder\"" \
|
|
-e " repeat" \
|
|
-e " set question to display dialog \"$CRASH_MESSAGE\" with title \"$CRASH_TITLE\" with icon alias (POSIX file \"$RESOURCES/OpenRA.icns\") buttons {\"View Logs\", \"View FAQ\", \"Quit\"} default button 3" \
|
|
-e " if button returned of question is equal to \"View Logs\" then open logsPath" \
|
|
-e " if button returned of question is equal to \"View FAQ\" then open location \"$FAQ_URL\"" \
|
|
-e " if button returned of question is equal to \"Quit\" then exit repeat" \
|
|
-e " if button returned of question is equal to \"Download Mono\" then open location \"$MONO_URL\"" \
|
|
-e " activate" \
|
|
-e " end repeat" \
|
|
-e "end tell"
|
|
exit 1
|
|
fi
|