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

###
# The Lamplighters League
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260711.1

PLAYIT_COMPATIBILITY_LEVEL=2.35

GAME_ID=the-lamplighters-league
GAME_NAME='The Lamplighters League'

ARCHIVE_BASE_0_NAME='setup_the_lamplighters_league_1.3.1-67360_(75947).exe'
ARCHIVE_BASE_0_MD5=bc06890044afe8cd3395249a4553c1f7
ARCHIVE_BASE_0_TYPE=innosetup
ARCHIVE_BASE_0_PART1_NAME='setup_the_lamplighters_league_1.3.1-67360_(75947)-1.bin'
ARCHIVE_BASE_0_PART1_MD5=6a217c893d0cc2b93ec561ad0880eb73
ARCHIVE_BASE_0_PART2_NAME='setup_the_lamplighters_league_1.3.1-67360_(75947)-2.bin'
ARCHIVE_BASE_0_PART2_MD5=2a56f3cdc2bd2898fb7bc3eacedefec7
ARCHIVE_BASE_0_PART3_NAME='setup_the_lamplighters_league_1.3.1-67360_(75947)-3.bin'
ARCHIVE_BASE_0_PART3_MD5=e398fc1ae766a81f1374f971be55929e
ARCHIVE_BASE_0_SIZE=15634809
ARCHIVE_BASE_0_VERSION=1.3.1-1

UNITY3D_NAME='LamplightersLeague'
# TODO: Unity3D plugins.

CONTENT_PATH_DEFAULT='.'
# The game fails to start if this GOG Galaxy setting file is not included,
# as it then expects to be running from Steam.
CONTENT_GAME0_BIN_FILES='
galaxyconfig.json'

# Prevent rendering problems, including flashing bright colours.
# (WINE 8.0)
# Due to the flashes being potentially harmful, this should not be removed
# at least until a WINE build not triggering them reaches Debian oldstable.
WINE_DIRECT3D_RENDERER=dxvk
WINE_PERSISTENT_DIRECTORIES='
users/${USER}/AppData/LocalLow/HarebrainedSchemes/LamplightersLeague'

PACKAGES_LIST='
PKG_BIN
PKG_DATA'

PKG_BIN_ARCH=64
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_DATA'

PKG_DATA_ID=${GAME_ID}-data
PKG_DATA_DESCRIPTION='data'
# Easier upgrades from pre-20260711.1 packages
PKG_DATA_PROVIDES='
the-lamplighters-league-data-bundles-1
the-lamplighters-league-data-bundles-2'

# 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 archive contents.

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
