summarylogtreecommitdiffstats
path: root/zelda-classic.sh
blob: 65e1cf6d1696feac45dc72a572bb44cc0eb81ac7 (plain)
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
#!/bin/bash
#
# Zelda Classic launcher - (c) carstene1ns 2013
#
# Does some magic juggling with the data files

# Changelog:
#  * 11-2016: Added XDG support

jail_dir=${XDG_CONFIG_HOME:-$HOME/.config}/zelda-classic

# migrate files from old location
jail_old=$HOME/.zelda-classic

if [ ! -e $jail_dir ]; then
  mkdir -p $jail_dir

  if [ -e $jail_old ]; then
    for f in $jail_old/{*.{qst,dat,nsf,txt},samplesoundset,{zelda,zlaunch,zquest}-l}; do
      [ -L $f ] && rm $f
    done

    mv $jail_old/{ag.cfg,allegro.log,zc.{icn,lck,sav}} $jail_dir
  fi

fi

# symlink files from installation directory
for f in /opt/zelda-classic/{*.{qst,dat,nsf,so},samplesoundset,z*-l} \
         /usr/share/doc/zelda-classic/zquest.txt; do
  [ ! -e $jail_dir/${f##*/} ] && ln -s $f $jail_dir
done

# change to directory and launch
cd $jail_dir

case "${0##*/}" in
  zelda-classic)
    exec ./zelda-l "$@"
    ;;
  zelda-classic-zlaunch)
    exec ./zlaunch-l "$@"
    ;;
  zelda-classic-zquest)
    exec ./zquest-l "$@"
    ;;
  *)
    echo "Something is wrong with your Zelda Classic installation."
    ;;
esac

cd - &>/dev/null