#!/bin/sh
# SPDX-License-Identifier: ACSL
# SPDX-FileCopyrightText: © 2015 mortalius
# SPDX-FileCopyrightText: © 2016 Antoine Le Gonidec <vv221@dotslashplay.it>
# SPDX-FileCopyrightText: © 2020 HS-157
set -o errexit

###
# Pier Solar and the Great Architects
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260714.1

PLAYIT_COMPATIBILITY_LEVEL=2.35

GAME_ID=pier-solar
GAME_NAME='Pier Solar and the Great Architects'

ARCHIVE_BASE_HUMBLE_0_NAME='PierSolar_linux.zip'
ARCHIVE_BASE_HUMBLE_0_MD5=e5ceda3a75cab3fe9b1ad1cbaf2d4a1d
ARCHIVE_BASE_HUMBLE_0_SIZE=2389378
ARCHIVE_BASE_HUMBLE_0_VERSION=1.3.2-2
ARCHIVE_BASE_HUMBLE_0_URL=https://www.humblebundle.com/store/pier-solar-and-the-great-architects-special-edition

ARCHIVE_BASE_GOG_0_NAME='gog_pier_solar_and_the_great_architects_2.1.0.4.sh'
ARCHIVE_BASE_GOG_0_MD5=2de03fb6d69944e3f204d5ae45147a3e
ARCHIVE_BASE_GOG_0_SIZE=2400000
ARCHIVE_BASE_GOG_0_VERSION=1.3.2-1

CONTENT_PATH_DEFAULT_GOG='data/noarch/game'
CONTENT_PATH_DEFAULT_HUMBLE='PierSolar_linux'
CONTENT_GAME_MAIN_FILES='
pshd.linux64
data
icon.png'
CONTENT_DOC_MAIN_FILES='
README.txt'

APP_MAIN_EXE='pshd.linux64'
APP_MAIN_ICON='icon.png'

PKG_MAIN_ARCH=64
PKG_MAIN_DEPENDENCIES_LIBRARIES='
libc.so.6
libdl.so.2
libGL.so.1
libm.so.6
libpthread.so.0'
# Easier upgrades from pre-20260707.1 packages
PKG_MAIN_PROVIDES='
pier-solar-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
content_inclusion_default

# Write launchers.

# Crash on launch with SDL wayland backend.
APP_MAIN_PRERUN="$(application_prerun APP_MAIN)
$(launcher_tweak_sdl_override)
$(launcher_tweak_sdl_force_x11)"
PKG_MAIN_DEPENDENCIES_LIBRARIES="$(dependencies_libraries_list PKG_MAIN)
libSDL2-2.0.so.0"

launchers_generation

# Build packages.

packages_generation
print_instructions

# Clean up.

working_directory_cleanup

exit 0
