From: Freddy Date: Thu, 21 May 2020 14:24:41 +0000 (+0200) Subject: Simple script to help (standalone) map setup X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=477ee6c6543adcc592f8c4f013446bf74c0a7b9b;p=xonotic%2Fxonotic.git Simple script to help (standalone) map setup --- diff --git a/misc/tools/mapping-helper.sh b/misc/tools/mapping-helper.sh new file mode 100755 index 00000000..c28ddee2 --- /dev/null +++ b/misc/tools/mapping-helper.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Tiny script to set up and package standalone maps + +list () { + for PK3DIR in $(find ${BASEDIR} -type d -name "map-*.pk3dir"); do + PK3DIR=${PK3DIR%.pk3dir} + PK3DIR=${PK3DIR##${BASEDIR}/map-} + echo $PK3DIR + done +} + +create_stub () { + MAPNAME=$1 + [[ -z "${MAPNAME}" ]] && { echo "Please specify mapname"; exit -1; } + [[ -d "${BASEDIR}/map-${MAPNAME}.pk3dir" ]] && { echo "Map ${MAPNAME} already exists"; exit -1; } + TEMP=$(find ${BASEDIR} -maxdepth 1 -type d -name "map-"${MAPNAME}"_[[:digit:]].[[:digit:]][[:digit:]].pk3dir") + [[ -n "${TEMP}" ]] && { echo "Map ${MAPNAME} already exists"; exit -1; } + mkdir -p "${BASEDIR}/map-${MAPNAME}_0.01.pk3dir/"{cubemaps,env,map,models,scripts,sounds,textures} + touch "${BASEDIR}/map-${MAPNAME}_0.01.pk3dir/map/${MAPNAME}_0.01.map" +} + +package () { + MAPNAME=$1 + [[ -z "${MAPNAME}" ]] && { echo "Please specify mapname"; exit -1; } + [[ ! -d "${BASEDIR}/map-${MAPNAME}.pk3dir" ]] && { echo "Map ${MAPNAME} not found"; exit -1; } + # TODO: check for License, mapinfo and mapshot + pushd ${BASEDIR}/map-${MAPNAME}.pk3dir + zip -r -D ${BASEDIR}/map-${MAPNAME}.pk3 * -x "*.srf" "*.prt" "*.bak" + popd +} + +while getopts "b:" FLAG; do + case "${FLAG}" in + b) + BASEDIR=$OPTARG + ;; + esac +done + +shift $( expr ${OPTIND} - 1 ) + +case $(uname -s) in + Linux*) + DEFAULT_BASEDIR="${HOME}/.xonotic/data" + ;; + Darwin*) + DEFAULT_BASEDIR="~/Library/Application Support/xonotic/data" + ;; + CYGWIN*|MINGW*) + echo "WINDOWS NOT SUPPORTED (YET?)" && exit -1 + ;; + *) + echo "Unknown platform, assuming posix" + DEFAULT_BASEDIR="${HOME}/.xonotic/data" + ;; +esac + +BASEDIR=${BASEDIR:-$DEFAULT_BASEDIR} + +TASK=$1 + +shift + +case "${TASK}" in + ls|list) + list + ;; + stub) + create_stub $@ + ;; + package) + package $@ + ;; + # TODO: increment version command + *) + echo "Unsupported option" && exit -1 + ;; +esac +