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

###
# My Time at Portia
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260712.1

PLAYIT_COMPATIBILITY_LEVEL=2.35

GAME_ID=my-time-at-portia
GAME_NAME='My Time at Portia'

ARCHIVE_BASE_2_NAME='setup_my_time_at_portia_build-20250620-1430-141719-win-gog_(64bit)_(83118).exe'
ARCHIVE_BASE_2_MD5=d4023a582cd0b6289c556d5c5fd5ae4c
ARCHIVE_BASE_2_TYPE=innosetup
ARCHIVE_BASE_2_PART1_NAME='setup_my_time_at_portia_build-20250620-1430-141719-win-gog_(64bit)_(83118)-1.bin'
ARCHIVE_BASE_2_PART1_MD5=bac8d05f2b63feb5f2e08ae26fd13505
ARCHIVE_BASE_2_PART2_NAME='setup_my_time_at_portia_build-20250620-1430-141719-win-gog_(64bit)_(83118)-2.bin'
ARCHIVE_BASE_2_PART2_MD5=52cf469986aeb712cd82bb8e8d43cb8d
ARCHIVE_BASE_2_SIZE=10104598
ARCHIVE_BASE_2_VERSION=2.0.141719-1

ARCHIVE_BASE_1_NAME='setup_my_time_at_portia_20210813-1123-141541_(64bit)_(49522).exe'
ARCHIVE_BASE_1_MD5=73890f1c7a86bdcab47a00b72366928a
ARCHIVE_BASE_1_TYPE=innosetup
ARCHIVE_BASE_1_PART1_NAME='setup_my_time_at_portia_20210813-1123-141541_(64bit)_(49522)-1.bin'
ARCHIVE_BASE_1_PART1_MD5=87fb19e0f0f04a499e81e7a81b49818d
ARCHIVE_BASE_1_PART2_NAME='setup_my_time_at_portia_20210813-1123-141541_(64bit)_(49522)-2.bin'
ARCHIVE_BASE_1_PART2_MD5=2ef18dcfdc16f1d7f52c2a49cfd63010
ARCHIVE_BASE_1_SIZE=10038490
ARCHIVE_BASE_1_VERSION=2.0.141541-1

ARCHIVE_BASE_0_NAME='setup_my_time_at_portia_2.0.141235_(64bit)_(41960).exe'
ARCHIVE_BASE_0_MD5=9f21752466f3ce96719cfea66bce05d5
ARCHIVE_BASE_0_TYPE=innosetup
ARCHIVE_BASE_0_PART1_NAME='setup_my_time_at_portia_2.0.141235_(64bit)_(41960)-1.bin'
ARCHIVE_BASE_0_PART1_MD5=881179a255b81a165411ca88fc99dcc7
ARCHIVE_BASE_0_PART2_NAME='setup_my_time_at_portia_2.0.141235_(64bit)_(41960)-2.bin'
ARCHIVE_BASE_0_PART2_MD5=b84720aea74b713c8738197872f4add0
ARCHIVE_BASE_0_SIZE=9800000
ARCHIVE_BASE_0_VERSION=2.0.141235-1

UNITY3D_NAME='Portia'
# TODO: Unity3D plugins

CONTENT_PATH_DEFAULT='.'

WINE_PERSISTENT_DIRECTORIES='
users/${USER}/AppData/LocalLow/Pathea Games/My Time at Portia'

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=my-time-at-portia-data-asssetbundles

# 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
