#!/bin/sh
# SPDX-License-Identifier: ACSL
# SPDX-FileCopyrightText: © 2016 Antoine Le Gonidec <vv221@dotslashplay.it>
set -o errexit

###
# The Temple of Elemental Evil
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260709.1

PLAYIT_COMPATIBILITY_LEVEL=2.35

GAME_ID='the-temple-of-elemental-evil'
GAME_NAME='The Temple of Elemental Evil'

ARCHIVE_BASE_1_NAME='setup_temple_of_elemental_evil_1.0_(15416).exe'
ARCHIVE_BASE_1_MD5=1c7b493f71c2c92050a63535b3abec67
ARCHIVE_BASE_1_TYPE=innosetup
ARCHIVE_BASE_1_SIZE=1320488
ARCHIVE_BASE_1_VERSION=1.3-2

ARCHIVE_BASE_0_NAME='setup_temple_of_elemental_evil_2.0.0.13.exe'
ARCHIVE_BASE_0_MD5=44ea1e38ed1da26aefb32a39a899f770
ARCHIVE_BASE_0_TYPE=innosetup
ARCHIVE_BASE_0_SIZE=1400000
ARCHIVE_BASE_0_VERSION=1.3-1

CONTENT_PATH_DEFAULT='.'
CONTENT_PATH_DEFAULT_0='app'
CONTENT_GAME_MAIN_FILES='
miles
ToEE.exe
ToEEa.exe
_sre.pyd
_sre_d.pyd'
# TODO: Drop unused libraries.
# TODO: Install libraries in a standard path
CONTENT_GAME0_MAIN_FILES='
binkw32.dll
dbghelp.dll
Mss32.dll
msvcr70.dll
msvcr71.dll
python22.dll
pyToEE22.dll
temple.dll
tio.dll
zlib-1.2.1.dll'
CONTENT_GAME1_MAIN_RELATIVE_PATH='__support/app'
CONTENT_GAME1_MAIN_RELATIVE_PATH_0='.'
CONTENT_GAME1_MAIN_FILES='
toee.cfg'
CONTENT_GAME2_MAIN_FILES='
data
modules
tig.dat
ToEE1.dat
ToEE2.dat
ToEE3.dat
ToEE4.dat
RT_ToEE4.dat'
# TODO: Is this icon required?
CONTENT_GAME3_MAIN_FILES='
ToEE.ico'
CONTENT_DOC_MAIN_FILES='
Manual.pdf
Readme.txt
mt19937ar.txt'

USER_PERSISTENT_DIRECTORIES='
data/maps
data/save
data/scr
modules/ToEE'
USER_PERSISTENT_FILES='
toee.cfg'

APP_MAIN_EXE='ToEE.exe'
APP_MAIN_ICON='ToEE.ico'

PKG_MAIN_ARCH=32
# Easier upgrades from pre-20260709.1 packages
PKG_MAIN_PROVIDES='
the-temple-of-elemental-evil-data'

# Load common functions.

if [ -z "$PLAYIT_LIB2" ]; then
	for playit_lib_dir in \
		"$PWD" \
		"${HOME}/.local/lib/play.it" \
		'/usr/local/lib/play.it' \
		'/usr/lib/play.it'
	do
		playit_lib_path=${playit_lib_dir}/libplayit.sh.2
		if [ -e "$playit_lib_path" ]; then
			PLAYIT_LIB2=$playit_lib_path
			break
		fi
	done
fi
if [ -z "$PLAYIT_LIB2" ]; then
	printf '\n\033[1;31mError:\033[0m\n'
	printf 'libplayit.sh.2 not found.\n'
	exit 1
fi
. "$PLAYIT_LIB2"

# Run default initialisation actions.

initialization_default "$@"

# Extract game data.

archive_extraction_default

# Include game data.

content_inclusion_icons
content_inclusion_default

# Write launchers.

launchers_generation

# Build packages.

packages_generation
print_instructions

# Clean up.

working_directory_cleanup

exit 0
