patchimage/scripts/mkwii/mkwiimm_karts.sh

130 lines
3.2 KiB
Bash
Raw Normal View History

2015-04-11 21:01:24 +02:00
#!/bin/bash
GAME_TYPE="GENERIC"
2016-08-05 21:09:04 +02:00
GAMENAME="Mario Kart Wiimm"
2015-04-11 21:01:24 +02:00
show_notes () {
echo -e \
"************************************************
2016-08-05 21:09:04 +02:00
${GAMENAME}
2015-04-11 21:01:24 +02:00
Custom Mario Kart Wii
Source: http://wiiki.wii-homebrew.com/Wiimms_Mario_Kart_Fun
Base Image: Mario Kart Wii (RMC?01)
Supported Versions: EUR, JAP, USA
************************************************"
}
check_input_image_special () {
ask_input_image_mkwiimm
echo -e "type ALL or RMC???.wbfs:\n"
read -r ID
2015-04-11 21:01:24 +02:00
if [[ -f ${PWD}/${ID} ]]; then
GAMEDIR="${PWD}"
elif [[ -f ${PATCHIMAGE_WBFS_DIR}/${ID} ]]; then
GAMEDIR="${PATCHIMAGE_WBFS_DIR}"
else echo "invalid user input."
2015-04-11 21:01:24 +02:00
exit 75
fi
}
ask_slot () {
echo -e "\nFirst choose a vehicle to be replaced\n"
gawk -F : '{print $1 "\t\t" $2}' < "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm_vehicles.db
2015-04-11 21:01:24 +02:00
echo -e "\ntype in ??_??? as in first column\n"
read -r VEHICLE
2015-04-11 21:01:24 +02:00
echo -e "\nNow choose a character to be replaced\n"
gawk -F : '{print $1 "\t\t" $2}' < "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm_characters.db
2015-04-11 21:01:24 +02:00
echo -e "\ntype in -?? as in first column\n"
read -r CHARACTER
2015-04-11 21:01:24 +02:00
choosenkarts=( ${choosenkarts[@]} ${kart}:${VEHICLE}${CHARACTER} )
}
download_wiimm () {
if [[ -f ${HOME}/.patchimage.choice ]]; then
echo "Your choices from last time can be re-used."
echo "y (yes) or n (no)"
read -r choice
2015-04-11 21:01:24 +02:00
if [[ ${choice} == y ]]; then
source "${HOME}"/.patchimage.choice
2015-04-11 21:01:24 +02:00
fi
fi
if [[ ${choosenkarts[@]} == "" ]]; then
echo -e "Choose a character to add to the game\n"
gawk -F : '{print $1 "\t\t" $2}' < "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm_karts.db
2015-04-11 21:01:24 +02:00
echo -e "\ntype ???.szs (multiple possible, space separated)"
read -r KART
2015-04-11 21:01:24 +02:00
for kart in "${KART[@]}"; do
if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_karts/${kart} ]]; then
echo "unknown Kart ${kart}"
exit 75
2015-04-11 21:01:24 +02:00
fi
done
2015-04-11 22:28:59 +02:00
ask_slot
2015-04-11 21:01:24 +02:00
echo "${choosenkarts[@]}"
echo "choosenkarts=( ${choosenkarts[*]} )" > "${HOME}"/.patchimage.choice
2015-04-11 21:01:24 +02:00
fi
}
build_mkwiimm () {
rm -rf workdir
echo "*** 5) extracting image"
"${WIT}" extract "${GAMEDIR}"/"${ID}" workdir -q || exit 51
2015-04-11 21:01:24 +02:00
if [[ ! -d "${PATCHIMAGE_RIIVOLUTION_DIR}"/${ID/.*}_SZS ]]; then
echo "*** 6) this is the first run, so backing up original files
(in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations"
mkdir "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${ID/.*}"_SZS
2015-04-11 21:01:24 +02:00
cp workdir/files/Race/Kart/* \
"${PATCHIMAGE_RIIVOLUTION_DIR}"/"${ID/.*}"_SZS
2015-04-11 21:01:24 +02:00
else
echo "*** 6) restoring original files"
cp "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${ID/.*}"_SZS/* \
2015-04-11 21:01:24 +02:00
workdir/files/Race/Kart/
fi
echo "*** 7) replacing kart(s)"
for kart in "${choosenkarts[@]}"; do
source="${kart/*:}"
dest="${kart/:*}"
2015-04-11 21:01:24 +02:00
echo " old: ${dest}.szs new: ${source}"
cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_karts/"${source}" \
workdir/files/Race/Kart/"${dest}".szs
cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_karts/"${source}" \
workdir/files/Race/Kart/"${dest}"_2.szs
cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_karts/"${source}" \
workdir/files/Race/Kart/"${dest}"_4.szs
2015-04-11 21:01:24 +02:00
done
echo "*** 8) rebuilding game"
echo " (storing game in ${PATCHIMAGE_GAME_DIR}/${ID})"
"${WIT}" cp -o -q -B workdir "${PATCHIMAGE_GAME_DIR}"/"${ID}" || exit 51
2015-04-11 21:01:24 +02:00
rm -rf workdir
}
pi_action () {
2015-04-11 21:01:24 +02:00
download_wiimm
2015-04-11 21:01:24 +02:00
build_mkwiimm
}