#!/bin/sh
# SPDX-License-Identifier: ACSL
# SPDX-FileCopyrightText: © 2017 HS-157
# SPDX-FileCopyrightText: © 2018 Antoine Le Gonidec <vv221@dotslashplay.it>
# SPDX-FileCopyrightText: © 2018 Phil Morrell
set -o errexit

###
# Total Annihilation: Kingdoms
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260402.1

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='total-annihilation-kingdoms'
GAME_NAME='Total Annihilation: Kingdoms'

ARCHIVE_BASE_0_NAME='setup_total_annihilation_kingdoms_2.0.0.22.exe'
ARCHIVE_BASE_0_MD5='206f4b8e9159414ee38ec609831907bb'
# TODO: Update APP_MAIN_EXE to no longer require a forced conversion to lower case.
ARCHIVE_BASE_0_EXTRACTOR='innoextract'
ARCHIVE_BASE_0_EXTRACTOR_OPTIONS='--lowercase'
ARCHIVE_BASE_0_SIZE='1100000'
ARCHIVE_BASE_0_VERSION='1.0-gog2.0.0.22'
ARCHIVE_BASE_0_URL='https://www.gog.com/game/total_annihilation_kingdoms'

CONTENT_PATH_DEFAULT='app'
CONTENT_GAME_BIN_FILES='
*.asi
*.exe
*.tsk'
# TODO: Include an explicit list of libraries.
# TODO: Install libraries in a standard path.
# TODO: Drop unused libraries.
CONTENT_GAME_BIN_FILES='
*.dll'
CONTENT_GAME_DATA_FILES='
atlas
boneyards
docs
gc
maps
movies
music
*.256
*.esk
*.hpi
*.htm
*.icd
*.id
*.isu
*.key
*.mmz
*.pdf
*.tdf
*.txt'

APP_MAIN_EXE='kingdoms.exe'

PACKAGES_LIST='
PKG_BIN
PKG_DATA'

PKG_BIN_ARCH='32'
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_DATA'

PKG_DATA_ID="${GAME_ID}-data"
PKG_DATA_DESCRIPTION='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
# shellcheck source=libplayit.sh.2
. "$PLAYIT_LIB2"

# Run default initialisation actions.

initialization_default "$@"

# Extract game data.

archive_extraction_default

# Include game data.

content_inclusion_icons 'PKG_DATA'
content_inclusion_default

# Write launchers.

launchers_generation

# Build packages.

packages_generation
print_instructions

# Clean up.

working_directory_cleanup

exit 0
