-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.github.dxx_rebirth.dxx-rebirth.sh
62 lines (59 loc) · 2.03 KB
/
io.github.dxx_rebirth.dxx-rebirth.sh
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
#!/bin/bash
GAME=$1
ARGS="${@:2}"
echo "Game: $GAME"
echo "Arguments: $ARGS"
if [[ -z $GAME ]]; then
selection=$(zenity --question --title="Select game" --text "Select whether to launch Descent or Descent II" --extra-button="Descent" --extra-button="Descent II" --extra-button="Cancel" --switch)
case $selection in
"Descent")
GAME="d1x"
;;
"Descent II")
GAME="d2x"
;;
*)
exit 1
;;
esac
fi
case $GAME in
"d1x")
DATAFILE="descent.hog"
DATADIR="$XDG_DATA_HOME/.d1x-rebirth"
EXECUTABLE="d1x-rebirth"
HOMEVAR="D1X_REBIRTH_HOME"
GAMETITLE="Descent"
;;
"d2x")
DATAFILE="descent2.hog"
DATADIR="$XDG_DATA_HOME/.d2x-rebirth"
EXECUTABLE="d2x-rebirth"
HOMEVAR="D2X_REBIRTH_HOME"
GAMETITLE="Descent II"
;;
*)
zenity --error --title="Unknown game specified"\
--text "<b>Unknown game: <tt>$GAME</tt></b>\\n\\nPlease run this Flatpak launcher with either <tt><b>d1x</b></tt> or <tt><b>d2x</b></tt> as a parameter to select Descent or Descent II." \
--ok-label 'Quit' \
--no-wrap
exit 1
;;
esac
if [[ $(find "$DATADIR/data/" -iname $DATAFILE) ]]; then
# Prefer data and savegames in Flatpak installation
export $HOMEVAR="$DATADIR/saves"
$EXECUTABLE -hogdir "$DATADIR/data/" $ARGS
elif [[ $(find "$HOME/.$EXECUTABLE/data/" -iname "$DATAFILE") ]]; then
# Otherwise try and run from existing installation
exec $EXECUTABLE
else
# Create game data/save paths if needed to take at least that step off the user
if [[ ! -d "$DATADIR/data" ]]; then mkdir -p "$DATADIR/data"; fi
if [[ ! -d "$DATADIR/saves" ]]; then mkdir -p "$DATADIR/saves"; fi
# Finally, fail with error message.
zenity --error \
--text "<b>Could not find $GAMETITLE game data!</b>\\n\\nPlease copy the game data files for $GAMETITLE to <tt><b>$DATADIR/data/</b></tt>." \
--ok-label 'Quit'
exit 1
fi