#!/bin/sh

# FreeBSD Dwarf Fortress Loading Script
# Created: December 2015
# Created By: Michael Williams <ports@mgwsoftware.com>
# Based off Loading Script for ArchLinux:
# (https://projects.archlinux.org/svntogit/community.git/tree/trunk/dwarffortress?h=packages/dwarffortress)

#export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch.
#export SDL_VIDEO_CENTERED=1 # Centre the screen.  Messes up resizing.

confdir="$HOME/.dwarffortress"
prefix=%%PREFIX%%
libdir=$prefix/libexec/dwarffortress
sharedir=$prefix/share/dwarffortress
datadir=$sharedir/data

if [ ! -d "$confdir" ]; then
	mkdir -p "$confdir/data"
	ln -s $libdir "$confdir/libs"
	ln -s $sharedir/raw "$confdir/raw"
	cp -rn $datadir/init "$confdir/data/init"
fi

for link in announcement art dipscript help index initial_movies movies shader.fs shader.vs sound speech; do
    cp -r $datadir/$link "$confdir/data/$link"
    chmod -R u+w "$confdir/data/$link"
done

export LD_LIBRARY_PATH=$libdir

cd "$confdir"
exec ./libs/Dwarf_Fortress "$@"
