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

###
# Shogo: Mobile Armor Division
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260415.2

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='shogo-mobile-armor-division'
GAME_NAME='Shogo: Mobile Armor Division'

ARCHIVE_BASE_FR_0_NAME='setup_shogo_-_mobile_armor_division_2.2.14_(french)_(19498).exe'
ARCHIVE_BASE_FR_0_MD5='ca3029d8c6efe0d273a174b73d95e920'
ARCHIVE_BASE_FR_0_TYPE='innosetup'
ARCHIVE_BASE_FR_0_VERSION='2.2.14-gog19498'
ARCHIVE_BASE_FR_0_SIZE='487166'
ARCHIVE_BASE_FR_0_URL='https://www.gog.com/game/shogo_mobile_armor_division'

ARCHIVE_BASE_EN_0_NAME='setup_shogo_-_mobile_armor_division_2.2.14_(19498).exe'
ARCHIVE_BASE_EN_0_MD5='371cd8bbd32355f78ee7f52e4d34e94a'
ARCHIVE_BASE_EN_0_TYPE='innosetup'
ARCHIVE_BASE_EN_0_VERSION='2.2.14-gog19498'
ARCHIVE_BASE_EN_0_SIZE='481454'
ARCHIVE_BASE_EN_0_URL='https://www.gog.com/game/shogo_mobile_armor_division'

CONTENT_PATH_DEFAULT='.'
CONTENT_GAME_BIN_FILES='
Client.exe
CT.exe
CT.ini
Shogo.exe
start.exe
console.pcx
soft.ren
d3d.ren
mssb16.tsk
*.M3D'
# TODO: Move server to a dedicated package.
CONTENT_GAME0_BIN_FILES='
ShogoSrv.exe'
# TODO: Install libraries in a standard path.
# TODO: Drop unused libraries.
CONTENT_GAME1_BIN_FILES='
AM18.dll
cdaudio.dll
DE_Msg.dll
ima.dll
Launch.dll
mss16.dll
mss32.dll
MSynth25.dll
server.dll
Smackw32.dll
SoftSnd.dll'
# ima.dll requirements
CONTENT_GAME2_BIN_FILES='
IMUSIC25.DLL'
CONTENT_GAME3_BIN_PATH='__support/app'
CONTENT_GAME3_BIN_FILES='
*.cfg'
CONTENT_GAME_DATA_FILES='
Custom
Joystick
Music
Save
*.REZ'
CONTENT_DOC_DATA_FILES='
shogo.CNT
shogo.hlp
MANUAL.PDF
RefCard.pdf
Readme.txt
LisezMoi.txt'
# TODO: Move server to a dedicated package.
CONTENT_DOC0_DATA_FILES='
ShogoSrv.txt'

USER_PERSISTENT_DIRECTORIES='
save'
USER_PERSISTENT_FILES='
*.cfg'

APP_MAIN_EXE='Shogo.exe'

PACKAGES_LIST='
PKG_BIN
PKG_DATA'

PKG_BIN_ARCH='32'
PKG_BIN_ID="$GAME_ID"
PKG_BIN_ID_FR="${PKG_BIN_ID}-fr"
PKG_BIN_ID_EN="${PKG_BIN_ID}-en"
PKG_BIN_PROVIDES="
$GAME_ID"
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_DATA'
PKG_BIN_DESCRIPTION_FR='French version'
PKG_BIN_DESCRIPTION_EN='English version'

PKG_DATA_ID="${GAME_ID}-data"
PKG_DATA_ID_FR="${PKG_DATA_ID}-fr"
PKG_DATA_ID_EN="${PKG_DATA_ID}-en"
PKG_DATA_PROVIDES="
$PKG_DATA_ID"
PKG_DATA_DESCRIPTION='data'
PKG_DATA_DESCRIPTION_FR="$PKG_DATA_DESCRIPTION - French version"
PKG_DATA_DESCRIPTION_EN="$PKG_DATA_DESCRIPTION - English version"

# 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
