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

###
# Cube Escape
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260418.1

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='cube-escape'
GAME_NAME='Cube Escape'

ARCHIVE_BASE_0_NAME='setup_cube_escape_collection_1.0_(43930).exe'
ARCHIVE_BASE_0_MD5='bd5035262ff2b9adc3a1887d8168ebaf'
ARCHIVE_BASE_0_TYPE='innosetup'
ARCHIVE_BASE_0_SIZE='130000'
ARCHIVE_BASE_0_VERSION='1.0-gog43930'
ARCHIVE_BASE_0_URL='https://www.gog.com/game/cube_escape_collection'

# AIR_NAME is not supported by the library yet,
# the current game script is a prototype.
# (./play.it 2.35)
AIR_NAME='Cube Escape Collection'

CONTENT_PATH_DEFAULT='.'
CONTENT_GAME_BIN_FILES="
Adobe AIR
META-INF
mimetype
${AIR_NAME}.exe"
# TODO: Empty file, check if it is required.
CONTENT_GAME0_BIN_PATH='app'
CONTENT_GAME0_BIN_FILES='
Adobe AIR/Versions/1.0/Resources/adobecp.vch'
CONTENT_GAME_DATA_FILES="
${AIR_NAME}.swf"
CONTENT_GAME0_DATA_FILES='
sounds.swf
cube-escape-translations.xml'

WINE_PERSISTENT_DIRECTORIES='
users/${USER}/Documents/Rusty Lake/CubeEscapeCollection'

APP_MAIN_EXE="${AIR_NAME}.exe"
APP_MAIN_ICONS_LIST='
APP_MAIN_ICON_16
APP_MAIN_ICON_32
APP_MAIN_ICON_48
APP_MAIN_ICON_128'
APP_MAIN_ICON_16='icons/Icon16.png'
APP_MAIN_ICON_32='icons/Icon32.png'
APP_MAIN_ICON_48='icons/Icon48.png'
APP_MAIN_ICON_128='icons/Icon128.png'

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
