>&2echo"Invalid OS \"$OSCHOICE\"! Cannot patch anything!"
exit1
fi
# Put everything from temp directory into the proper output directory
# Moving does *not* work, as mv doesn't allow to overwrite existing directories
mkdir -p $output
cp -r -f $GAMEDIR/* $output
echo""
echo"The operation was completed successfully. See you next mission!"
return0
}
# ----
# Main function starts here
# ---
main ()
{
echo"-------------------------------------------"
echo""
echo"AM2R ${VERSION} Shell Autopatching Utility"
echo""
echo"-------------------------------------------"
if(($# <=0));then
APPIMAGE=true
AM2RZIP="$SCRIPT_DIR/AM2R_11.zip"
localinput=""
echo"Running in interactive mode. For a full list of arguments, run the script with \"--help\""
echo"Select your patch type:"
echo""
echo"1 - Linux"
echo"2 - Android"
echo""
echo"Awaiting input:"
read -n1 input
echo""
if[["${input}"="1"]];then
OSCHOICE="linux"
elif[["${input}"="2"]];then
OSCHOICE="android"
else
>&2echo"Invalid OS!"
exit1
fi
echo"Install high quality in-game music? Increases filesize by 194 MB!"
echo"[y/n]"
read -n1 input
echo""
if[["${input,,}"="y"]];then
HQMUSIC=true
fi
if[$OSCHOICE="linux"];then
echo"Do you want to install AM2R systemwide?"
echo"[y/n]"
read -n1 input
echo""
if[["${input,,}"="y"]];then
SYSTEMWIDE=true
fi
fi
patch_am2r
localresult=$?
echo"Press any key to quit..."
read -s -n1 INPUT
exit$result
fi
while(($# > 0));do
case$1 in
-s|--os)
OSCHOICE="$2"
shift2# past argument and value
;;
-m|--hqmusic)
HQMUSIC=true
shift# past argument
;;
-w|--systemwide)
SYSTEMWIDE=true
shift# past argument
;;
-a|--appimage)
APPIMAGE=true
shift# past argument
;;
-p|--prefix)
PREFIX=$(realpath "$2")
shift2# past argument and value
;;
-z|--am2rzip)
AM2RZIP="$2"
shift2# past argument and value
;;
-h|--help)
echo -e "-s, --os\t\t\tThe operating system to patch to. Valid are \"linux\" and \"android\". Default is \"linux\""
echo -e "-m, --hqmusic\t\t\tIf provided, high quality music will be used, otherwise low quality music will be used instead."
echo -e "-w, --systemwide\t\tIf provided, Linux will get installed systemwide, otherwise Linux will get installed portably. Has no effect on Android."
echo -e "-a, --appimage\t\t\tIf provided, an AppImage will get generated, otherwise the raw binary will get generated instead. Has no effect on Android."
echo -e "-p, --prefix\t\t\tThe prefix used for patching operations. Default for systemwide is \"/usr/local\" and for non-systemwide \"<directory where this script resides>/am2r_<VersionNumber>\". As systemwide is ignored on Android, for Android this will always default to the latter option."
echo -e "-z, --am2rzip\t\t\tThe path to the AM2R_11 zip or directory. Default is \"<directory where the script resides>/AM2R_11.zip\""
exit0
;;
*)
>&2echo"Unknown option $1"
exit1
;;
esac
done
# restore positional parameters
set -- "${POSITIONAL_ARGS[@]}"
# check if necessary variables are provided
if[ -z "$OSCHOICE"];then
>&2echo"Missing argument! The OS needs to be provided via the \"--os\" flag! For further info use --help."