#!/bin/sh
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: © 2017 Antoine Le Gonidec <vv221@dotslashplay.it>
# SPDX-FileCopyrightText: © 2020 Jacek Szafarkiewicz
# SPDX-FileCopyrightText: © 2021 Anna Lea
set -o errexit

###
# Robin Hood: The Legend of Sherwood
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260319.7

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='robin-hood-the-legend-of-sherwood'
GAME_NAME='Robin Hood: The Legend of Sherwood'

ARCHIVE_BASE_EN_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(80557).exe'
ARCHIVE_BASE_EN_1_MD5='8ab629e662919ba32c9f1094cd7bcb4a'
ARCHIVE_BASE_EN_1_TYPE='innosetup'
ARCHIVE_BASE_EN_1_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(80557)-1.bin'
ARCHIVE_BASE_EN_1_PART1_MD5='fe407e06182b924375bcd1e4bce034af'
ARCHIVE_BASE_EN_1_SIZE='1067923'
ARCHIVE_BASE_EN_1_VERSION='1.1-gog80557'
ARCHIVE_BASE_EN_1_URL='https://www.gog.com/game/robin_hood'

ARCHIVE_BASE_FR_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(french)_(80557).exe'
ARCHIVE_BASE_FR_1_MD5='65a818f5f0a51b32b35c5aa931558b0c'
ARCHIVE_BASE_FR_1_TYPE='innosetup'
ARCHIVE_BASE_FR_1_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(french)_(80557)-1.bin'
ARCHIVE_BASE_FR_1_PART1_MD5='1e4c706155e04280ec4a28762219db6f'
ARCHIVE_BASE_FR_1_SIZE='1065021'
ARCHIVE_BASE_FR_1_VERSION='1.1-gog80557'
ARCHIVE_BASE_FR_1_URL='https://www.gog.com/game/robin_hood'

ARCHIVE_BASE_DE_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(german)_(80557).exe'
ARCHIVE_BASE_DE_1_MD5='17e600ba50f7eda57b26f7366ce080ec'
ARCHIVE_BASE_DE_1_TYPE='innosetup'
ARCHIVE_BASE_DE_1_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(german)_(80557)-1.bin'
ARCHIVE_BASE_DE_1_PART1_MD5='89e34791366cb3c899d081bbc77d1e77'
ARCHIVE_BASE_DE_1_SIZE='1081638'
ARCHIVE_BASE_DE_1_VERSION='1.1-gog80557'
ARCHIVE_BASE_DE_1_URL='https://www.gog.com/game/robin_hood'

ARCHIVE_BASE_PL_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(polish)_(80557).exe'
ARCHIVE_BASE_PL_1_MD5='4bdb5254260da2261437bc840c881ec5'
ARCHIVE_BASE_PL_1_TYPE='innosetup'
ARCHIVE_BASE_PL_1_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(polish)_(80557)-1.bin'
ARCHIVE_BASE_PL_1_PART1_MD5='96505bace4ad86164dc26b9c857c0d37'
ARCHIVE_BASE_PL_1_SIZE='1081919'
ARCHIVE_BASE_PL_1_VERSION='1.1-gog80557'
ARCHIVE_BASE_PL_1_URL='https://www.gog.com/game/robin_hood'

ARCHIVE_BASE_ES_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(spanish)_(80557).exe'
ARCHIVE_BASE_ES_1_MD5='6157e2a14fa377b23c9cdebfaa6e6ef2'
ARCHIVE_BASE_ES_1_TYPE='innosetup'
ARCHIVE_BASE_ES_1_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_gog_v3_(spanish)_(80557)-1.bin'
ARCHIVE_BASE_ES_1_PART1_MD5='2561ca1a733f8d70bfd52fd8db7eea0a'
ARCHIVE_BASE_ES_1_SIZE='1050376'
ARCHIVE_BASE_ES_1_VERSION='1.1-gog80557'
ARCHIVE_BASE_ES_1_URL='https://www.gog.com/game/robin_hood'

ARCHIVE_BASE_EN_0_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(24778).exe'
ARCHIVE_BASE_EN_0_MD5='a52ed21f93f17457a3a137b54ee60919'
ARCHIVE_BASE_EN_0_TYPE='innosetup'
ARCHIVE_BASE_EN_0_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(24778)-1.bin'
ARCHIVE_BASE_EN_0_PART1_MD5='6fbcea908c83933326294c0706838da5'
ARCHIVE_BASE_EN_0_SIZE='1100000'
ARCHIVE_BASE_EN_0_VERSION='1.1-gog24778'

ARCHIVE_BASE_FR_0_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(french)_(24778).exe'
ARCHIVE_BASE_FR_0_MD5='2f945bd2a1d70c1c9ff3b9938e1adf9a'
ARCHIVE_BASE_FR_0_TYPE='innosetup'
ARCHIVE_BASE_FR_0_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(french)_(24778)-1.bin'
ARCHIVE_BASE_FR_0_PART1_MD5='060df1c05868593a59ccc4ca2832cf36'
ARCHIVE_BASE_FR_0_SIZE='1100000'
ARCHIVE_BASE_FR_0_VERSION='1.1-gog24778'

ARCHIVE_BASE_DE_0_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(german)_(24778).exe'
ARCHIVE_BASE_DE_0_MD5='cdba08e0613408bc3709f387144c7a1d'
ARCHIVE_BASE_DE_0_TYPE='innosetup'
ARCHIVE_BASE_DE_0_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(german)_(24778)-1.bin'
ARCHIVE_BASE_DE_0_PART1_MD5='6291dbee561468bb4fbb769aaf74eb36'
ARCHIVE_BASE_DE_0_SIZE='1100000'
ARCHIVE_BASE_DE_0_VERSION='1.1-gog24778'

ARCHIVE_BASE_PL_0_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(polish)_(24778).exe'
ARCHIVE_BASE_PL_0_MD5='42066791c34c3ff6f6b9a1404f7afb1e'
ARCHIVE_BASE_PL_0_TYPE='innosetup'
ARCHIVE_BASE_PL_0_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(polish)_(24778)-1.bin'
ARCHIVE_BASE_PL_0_PART1_MD5='dc4bf92553c3a6e436b8d79c99a6287c'
ARCHIVE_BASE_PL_0_SIZE='1100000'
ARCHIVE_BASE_PL_0_VERSION='1.1-gog24778'

ARCHIVE_BASE_ES_0_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(spanish)_(24778).exe'
ARCHIVE_BASE_ES_0_MD5='7db0f8d9c40bb398acb406224a225eb9'
ARCHIVE_BASE_ES_0_TYPE='innosetup'
ARCHIVE_BASE_ES_0_PART1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_hotfix_(spanish)_(24778)-1.bin'
ARCHIVE_BASE_ES_0_PART1_MD5='e9ba8791951285a814ef86fcf3b8614f'
ARCHIVE_BASE_ES_0_SIZE='1100000'
ARCHIVE_BASE_ES_0_VERSION='1.1-gog24778'

ARCHIVE_BASE_EN_OLDPATH_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_1.1_(17797).exe'
ARCHIVE_BASE_EN_OLDPATH_1_MD5='e8808cdafc7ea75cbcfaa850275b3dd6'
ARCHIVE_BASE_EN_OLDPATH_1_TYPE='innosetup'
ARCHIVE_BASE_EN_OLDPATH_1_SIZE='1200000'
ARCHIVE_BASE_EN_OLDPATH_1_VERSION='1.1-gog17797'

ARCHIVE_BASE_FR_OLDPATH_1_NAME='setup_robin_hood_-_the_legend_of_sherwood_french_1.1_(17797).exe'
ARCHIVE_BASE_FR_OLDPATH_1_MD5='8b19812fb424651fc482cb7a9c5ed665'
ARCHIVE_BASE_FR_OLDPATH_1_SIZE='1200000'
ARCHIVE_BASE_FR_OLDPATH_1_VERSION='1.1-gog17797'

ARCHIVE_BASE_EN_OLDPATH_0_NAME='setup_robin_hood_2.0.0.12.exe'
ARCHIVE_BASE_EN_OLDPATH_0_MD5='9e2452c88f154c5e0306ca98e6b773ef'
ARCHIVE_BASE_EN_OLDPATH_0_SIZE='1100000'
ARCHIVE_BASE_EN_OLDPATH_0_VERSION='1.1-gog2.0.0.12'

ARCHIVE_BASE_FR_OLDPATH_0_NAME='setup_robin_hood_french_2.1.0.15.exe'
ARCHIVE_BASE_FR_OLDPATH_0_MD5='f6775cefa54e15141b855d037eafb8d9'
ARCHIVE_BASE_FR_OLDPATH_0_SIZE='1100000'
ARCHIVE_BASE_FR_OLDPATH_0_VERSION='1.1-gog2.1.0.15'

CONTENT_PATH_DEFAULT='.'
CONTENT_PATH_DEFAULT_EN_OLDPATH='app'
CONTENT_PATH_DEFAULT_FR_OLDPATH='app'
CONTENT_GAME_BIN_FILES='
Game.exe
Robin Hood.exe
DATA/SaveGame.exe
Launch/Settings.ini'
# Game.exe requirements
# TODO: Install libraries in a standard path.
CONTENT_GAME0_BIN_FILES='
binkw32.dll
Fmod.dll'
CONTENT_GAME_L10N_FILES='
1031
1036
1045
2047
3082
DATA/Configuration
DATA/Interface
DATA/Text
DATA/Levels/*.rhm
DATA/Levels/*.scb
DATA/Sounds/fx_0017.sfk
DATA/Sounds/snd_055.sfk'
CONTENT_GAME_DATA_FILES='
DATA/Animations
DATA/Characters
DATA/Levels
DATA/Musics
DATA/Sounds
DATA/robinhood.bks
DATA/robinhood.dic'
CONTENT_DOC_L10N_FILES='
Manual.pdf'

USER_PERSISTENT_DIRECTORIES='
DATA/Configuration
DATA/Savegame'
USER_PERSISTENT_FILES='
campaign.bck
Launch/Settings.ini'

# Without a virtual desktop, the game background covers a bigger surface than the game interface.
WINE_VIRTUAL_DESKTOP='1024x768'

APP_MAIN_EXE='Game.exe'
APP_MAIN_ICON='Robin Hood.exe'

PACKAGES_LIST='
PKG_BIN
PKG_L10N
PKG_DATA'

PKG_BIN_ARCH='32'
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_L10N_BASE
PKG_DATA'

PKG_L10N_BASE_ID="${GAME_ID}-l10n"
PKG_L10N_ID_EN="${PKG_L10N_BASE_ID}-en"
PKG_L10N_ID_FR="${PKG_L10N_BASE_ID}-fr"
PKG_L10N_ID_DE="${PKG_L10N_BASE_ID}-de"
PKG_L10N_ID_PL="${PKG_L10N_BASE_ID}-pl"
PKG_L10N_ID_ES="${PKG_L10N_BASE_ID}-es"
PKG_L10N_PROVIDES="
$PKG_L10N_BASE_ID"
PKG_L10N_DESCRIPTION_EN='English localisation'
PKG_L10N_DESCRIPTION_FR='French localisation'
PKG_L10N_DESCRIPTION_DE='German localisation'
PKG_L10N_DESCRIPTION_PL='Polish localisation'
PKG_L10N_DESCRIPTION_ES='Spanish localisation'

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 'libplayit2.sh not found.\n'
	exit 1
fi
# shellcheck source=libplayit2.sh
. "$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
