-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathPlay-Mac.command
More file actions
executable file
·84 lines (72 loc) · 2.93 KB
/
Copy pathPlay-Mac.command
File metadata and controls
executable file
·84 lines (72 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Pokémon Red (LÖVE2D) - double-click launcher for macOS.
#
# First run: decodes a user-provided .gb file, installs anything missing,
# builds the game data, then launches.
# Every later run: launches the game straight away.
cd "$(dirname "$0")" || exit 1
say() { printf '\033[1;32m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m !!\033[0m %s\n' "$*"; }
err() { printf '\033[1;31merror:\033[0m %s\n' "$*"; }
pause_exit() { # keep the Terminal window readable after a failure
echo
read -n 1 -s -r -p "Press any key to close this window..."
echo
exit "${1:-0}"
}
ask() { # ask "question" -> yes by default
local a
read -r -p "$1 [Y/n] " a
case "$a" in n|N|no|NO) return 1 ;; *) return 0 ;; esac
}
printf '\n \033[1mPokémon Red - LÖVE2D port\033[0m\n\n'
have_love() {
command -v love >/dev/null 2>&1 && return 0
[ -x "/Applications/love.app/Contents/MacOS/love" ] && return 0
[ -x "$HOME/Applications/love.app/Contents/MacOS/love" ] && return 0
return 1
}
# ---------------------------------------------------------------- fast path
if [ -f data/generated/maps.lua ] && have_love; then
say "already set up, launching the game"
scripts/run.sh || { err "the game failed to start"; pause_exit 1; }
exit 0
fi
say "first-time setup"
# ------------------------------------------------------- Xcode CLT (python3)
if ! command -v python3 >/dev/null 2>&1; then
warn "python3 is missing; it comes with Apple's command-line tools"
if ask "Install Apple's command-line tools now?"; then
xcode-select --install 2>/dev/null || true
echo
warn "Finish the Apple installer window that just opened, then"
warn "double-click Play-Mac.command again to continue."
pause_exit 0
else
err "cannot continue without python3"
pause_exit 1
fi
fi
# ----------------------------------------------------------------- Homebrew
if ! have_love && ! command -v brew >/dev/null 2>&1 \
&& [ ! -x /opt/homebrew/bin/brew ] && [ ! -x /usr/local/bin/brew ]; then
warn "LÖVE (the game engine) is not installed; the easiest installer is Homebrew"
if ask "Install Homebrew now? (asks for your macOS password)"; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \
|| { err "Homebrew install failed"; pause_exit 1; }
else
warn "OK, download LÖVE 11.x yourself from https://love2d.org,"
warn "drop love.app into /Applications, then run this again."
pause_exit 1
fi
fi
# make brew visible in THIS shell (fresh installs aren't on PATH yet)
[ -x /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
[ -x /usr/local/bin/brew ] && eval "$(/usr/local/bin/brew shellenv)"
# ------------------------------------------------------------------- build
echo
scripts/setup.sh \
|| { err "setup failed - see the messages above"; pause_exit 1; }
say "setup done, launching the game"
scripts/run.sh || { err "the game failed to start"; pause_exit 1; }
exit 0