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

###
# Cat Quest series:
# - Cat Quest
# - Cat Quest 2
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260709.1

PLAYIT_COMPATIBILITY_LEVEL=2.35

GAME_ID_EPISODE1=cat-quest-1
GAME_NAME_EPISODE1='Cat Quest'

GAME_ID_EPISODE2=cat-quest-2
GAME_NAME_EPISODE2='Cat Quest II'

ARCHIVE_BASE_EPISODE1_0_NAME='setup_cat_quest_1.2.10.2_(42782).exe'
ARCHIVE_BASE_EPISODE1_0_MD5=496d069ea28098aa6d575fc56f8c71ec
ARCHIVE_BASE_EPISODE1_0_TYPE=innosetup
ARCHIVE_BASE_EPISODE1_0_SIZE=334416
ARCHIVE_BASE_EPISODE1_0_VERSION=1.2.10.2-1

ARCHIVE_BASE_EPISODE2_0_NAME='setup_cat_quest_ii_1.7.7.3_(51746).exe'
ARCHIVE_BASE_EPISODE2_0_MD5=78f1001f07099b398ce66d971bf9b17c
ARCHIVE_BASE_EPISODE2_0_TYPE=innosetup
ARCHIVE_BASE_EPISODE2_0_SIZE=511796
ARCHIVE_BASE_EPISODE2_0_VERSION=1.7.7.3-1

UNITY3D_NAME_EPISODE1='Cat Quest'
UNITY3D_NAME_EPISODE2='Cat Quest II'
# TODO: Include an explicit list of Unity3D plugins.

CONTENT_PATH_DEFAULT='.'

WINE_PERSISTENT_DIRECTORIES_EPISODE1='
users/${USER}/AppData/LocalLow/The Gentlebros Pte_ Ltd_/Cat Quest'
WINE_PERSISTENT_DIRECTORIES_EPISODE2='
users/${USER}/Documents/Cat Quest II'

PACKAGES_LIST='
PKG_BIN
PKG_DATA'

PKG_BIN_ARCH=32
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_DATA'

PKG_DATA_ID_EPISODE1="${GAME_ID_EPISODE1}-data"
PKG_DATA_ID_EPISODE2="${GAME_ID_EPISODE2}-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
. "$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
