Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # GLBoom+ launching script
- # Author: PhysixCat
- printf '\e[1m%s\e[0m\n' "GLBoom+ launching script"
- printf '%s\n\n' "----------------------------------------------------------"
- # User should edit $glb_path to point to their glb binary
- # If it was installed through your distro's repo, the binary name is enough
- glb_path="glboom-plus"
- #glb_path="$HOME/Vidya/Native/Doom/prboomfork-umapinfo/prboom2/build/glboom-plus"
- # I use "libstrangle" to limit GLB+'s FPS to 60 without vsync
- # https://gitlab.com/torkel104/libstrangle
- # If you don't, simply leave this commented out
- #libstrangle="strangle 62"
- # Initializing script variables
- interactive="true"
- strict_check="false"
- fancy_check="false"
- verbose_check="false"
- dry_check="false"
- playdemo_check="false"
- recorddemo_check="false"
- righthand_status="righthanded"
- valid_iwads=( 'doom' 'doom2' 'tnt' 'plutonia' 'miniwad' 'freedoom' 'freedoom2' )
- # Suggestion: Don't bother string-checking, run true or false as commands
- # Suggestion: Another common trick for booleans is string length checks
- # Suggestion: heredocs and herestrings could replace printf/echo in many places
- # Suggestion: replace tr with ${//} and extglob expressions
- showhelp () {
- echo "Usage: glb [OPTION]... [FILE]..."
- echo
- echo "Launches GLBoom+, a source port for Doom & Doom 2."
- echo "Auto-applies sprite fixes and dssecret sounds."
- echo "Additional mods such as DoomSFX or DEH patches are optional"
- echo "Can be ran interactively or by using launch arguments"
- echo
- echo "If WAD is not recognized, user is prompted to specify complevel and IWAD."
- echo
- echo " -d, --dry Dry test run of script (doesn't launch GLB+)."
- echo " -f, --fancy Apply vsmooth DEH patch by fraggle."
- echo " -h, --help Display this help and exit."
- echo " -p, --play Play specified demo file."
- echo " -r, --record Record specified demo file."
- echo " -s, --strict Guarantee no DEH lumps are loaded before WAD."
- echo " -v, --verbose Display GLB+ output to console after launch."
- echo " -w, --wad Load specified WAD file."
- echo
- echo "Anything not recognized by this script will be passed through to"
- echo "GLBoom+ verbatim (such as -skill #, -warp ##, etc...)"
- echo
- echo "script by PhysixCat"
- }
- # Suggestion: Loop should be while [ $# -gt 0 ]
- # Suggestion: Use getopt !!!
- # Loop until all parameters are used up
- while [ "$1" != "" ]; do
- case "$1" in
- -d|--dry)
- dry_check="true"
- printf '%s\n' "This is a dry run of the script"
- ;;
- -f|--fancy)
- fancy_check="true"
- smooth='vsmooth'
- unset righthand_status
- ;;
- -h|--help)
- showhelp
- exit 0
- ;;
- -p|--play)
- shift
- cvars+=( '-playdemo' "$1" )
- playdemo_check="true"
- interactive="false"
- ;;
- -r|--record)
- shift
- cvars+=( '-record' "$1" )
- recorddemo_check="true"
- interactive="false"
- ;;
- -s|--strict)
- strict_check="true"
- ;;
- -v|--verbose)
- verbose_check="true"
- ;;
- -w|--wad)
- shift
- map="$1"
- interactive="false"
- ;;
- *)
- cvars+=( "$1" )
- ;;
- esac
- shift
- done
- # Check for contradictions in the arguments
- [[ $strict_check == 'true' && $fancy_check == 'true' ]] && printf '%s\n\n' "what the fug" && exit 1
- [[ $playdemo_check == 'true' && $recorddemo_check == 'true' ]] && printf '%s\n\n' "what the fug" && exit 1
- [[ $verbose_check == 'true' && $dry_check == 'true' ]] && printf '%s\n' "can't be very verbose on a dry run..."
- case $interactive in
- true)
- # Ask user for desired map
- read -r -p 'wad?'$'\n> ' map
- ;;
- esac
- # Requested map is checked against some hardcoded WAD names. If not recognized, ask user for corresponding complevel and IWAD
- case $map in
- # Maps for Doom 2 and limit-removing source ports
- ''|doom2|scythe*|av|hr*|btsx*|aterfier|d2twid|dbp*|jpcp|*minvr|remnant|manolaik|bstain|comatose|dmonfear|doom2_maps|dv|eviltech|freedoom2_maps|gravity|intercep|ksutra|lilium|marswar|miasma|nuts|akeldama|mutiny|ndcp|nova*|oceansde|sid|strg|syringe|tvr|cchest|nerve|masterlevels|uyane3|kuchitsu)
- iwad='doom2'
- complevel='2'
- case $map in
- av)
- dehpatch='av.deh'
- ;;
- hr)
- postpatch='hr_mus'
- ;;
- btsx)
- map='btsx_e1a btsx_e1b'
- ;;
- btsx2)
- map='btsx_e2a btsx_e2b'
- ;;
- jpcp)
- postpatch='jpcp_hud'
- ;;
- mutiny)
- dehpatch='mutiny.deh'
- ;;
- tvr)
- postpatch='tvrmidi'
- ;;
- esac
- ;;
- # Maps for The Ultimate Doom and limit-removing source ports
- doom|dtwid|dtwid-*|sigil|neis|dbimpact|sgnsym|deathless|dmpurge|draftex|hadron|indifference|doom_maps|freedoom_maps|git|nihility|nmdu|shpo1|e1m4b|e1m8b)
- iwad='doom'
- complevel='3'
- case $map in
- dtwid)
- map='dtwid udtwid'
- ;;
- dtwid-e5)
- map='dtwid-le dtwid-e5'
- ;;
- hadron)
- map='hadron hadrone2'
- ;;
- sigil)
- postpatch='d1spfx_sigil'
- map='sigil_compat'
- ;;
- git)
- dehpatch='git.deh'
- ;;
- esac
- ;;
- # Maps for TNT: Evilution
- tnt|tntr)
- iwad='tnt'
- complevel='4'
- ;;
- # Maps for The Plutonia Experiment
- plutonia|plutonia_maps|prcp|pl2|urania)
- iwad='plutonia'
- complevel='4'
- case $map in
- plutonia)
- postpatch='plutmidi'
- ;;
- esac
- ;;
- # Maps for The Plutonia Experiment but that also require Boom
- c-shock)
- iwad='plutonia'
- complevel='9'
- ;;
- # Maps for Boom-compatible source ports
- ayy|aaliens|vanguard|gd|swtw|stardate*|sod|preacher|sunlust|jenesis|catk|crumpets|fcff|magnolia|sunder|cchest2|cchest3|cchest4|avactor|c-shock2|mayhem*|cryogenics|demonastery|disjunct|dmdclockout|dmnsns|dv2|epic|flotsam|frozent|hg|jadearth|joi_lstcv15|legher|lunatic|maskimxul|memorial|oku2v31|mohu*|moonbld|ngmvmt1|portglacia|resurge|rush|sf2012|thtthren|uacultra|vrack|wos|2s1k)
- iwad='doom2'
- complevel='9'
- case $map in
- ayy|aaliens)
- postpatch='d2spfx_aaliens'
- map='aaliens'
- ;;
- mayhem17)
- postpatch='d2spfx_mayhem17'
- map='mayhem17 mayhem17_updatev1'
- ;;
- sunlust)
- postpatch='d2spfx_sunlust'
- ;;
- catk)
- postpatch='catk_bar'
- ;;
- esac
- ;;
- # Maps for MBF-compatible source ports
- valiant|eviternity*|exomoon|dotb|motm|sawdust)
- iwad='doom2'
- complevel='11'
- case $map in
- dotb)
- postpatch='d2spfx_dotb'
- ;;
- eviternity*)
- righthand_status='righthanded_fist'
- ;;
- esac
- ;;
- *)
- # Ask user for complevel
- printf '%s\n' "2 = Doom2, 3 = UltimateDoom, 4 = FinalDoom, 9 = Boom, 11 = MBF"
- read -r -p 'complevel?'$'\n> ' complevel
- if ! [[ "$complevel" =~ ^[0-9]+$ ]] || ! ((complevel >= 0 && complevel <=17)); then
- echo "complevel must be an integer between 0 and 17"
- exit 1
- fi
- # Old way of determining correct IWAD
- # Abandoned because of possible weird edge cases
- #case $complevel in
- # 2|9|11)
- # iwad='doom2'
- # ;;
- # 3)
- # iwad='doom'
- # ;;
- # 4)
- # read -r -p 'tnt or plutonia based?'$'\n> ' iwad
- # case $iwad in
- # tnt|plutonia)
- # ;;
- # *)
- # printf '%s\n\n' "what the fug"
- # exit 1
- # ;;
- # esac
- # ;;
- # *)
- # printf '%s\n\n' "what the fug"
- # exit 1
- # ;;
- #esac
- # Ask user for IWAD
- printf '%s\n' "doom, doom2, tnt, plutonia, miniwad, freedoom, freedoom2"
- read -r -p 'IWAD?'$'\n> ' iwad
- if [[ " ${valid_iwads[*]} " != *" $iwad "* ]]; then
- echo "not a valid IWAD"
- exit 1
- fi
- printf '\n'
- ;;
- esac
- case $interactive in
- true)
- # Ask user for cvars
- read -r -p 'map# & cvars?'$'\n> ' -a cvars_raw
- [[ -n "${cvars_raw[*]}" ]] && cvars=( '-skill 4' '-warp' "${cvars_raw[*]}" )
- # Ask user if they want smooth weapons
- [[ $strict_check == 'false' && $fancy_check == 'false' ]] &&
- read -r -p 'apply smooth DEH? [y/N] - WARNING: may cause bugs/crashes if map also includes DEH lump'$'\n> ' fancy_check &&
- case $fancy_check in
- ''|n)
- ;;
- y)
- smooth='vsmooth'
- unset righthand_status
- ;;
- *)
- printf '%s\n\n' "what the fug"
- exit 1
- ;;
- esac
- ;;
- esac
- # Make sure map is unset if it's an IWAD
- [[ "$iwad" == "$map" ]] && unset map
- # Determine whether to load DEH lumps in the sprite fixes or not
- case $iwad in
- doom)
- case $strict_check in
- true)
- prepatch=( 'd1spfx19_nodeh' 'dssecret' )
- ;;
- false)
- prepatch=( 'd1spfx19' 'doomsfx' 'doom3_plasma' 'dssecret' )
- ;;
- esac
- ;;
- doom2|tnt|plutonia)
- case $strict_check in
- true)
- prepatch=( 'd2spfx19_nodeh' 'dssecret' )
- ;;
- false)
- prepatch=( 'd2spfx19' 'doomsfx' 'doom3_plasma' 'dssecret' )
- ;;
- esac
- ;;
- *)
- prepatch=( 'dssecret' )
- ;;
- esac
- # Show selected variables
- glb_arguments=( '-iwad' "$iwad" '-file' "${prepatch[@]}" "$righthand_status" "$smooth" "$map" "$postpatch" '-deh' 'trans_on.deh' "$dehpatch" "${cvars[@]}" '-shorttics' '-complevel' "$complevel" )
- printf '%s' "iwad = [$iwad]"
- printf '\n%s' "prepatch = [${prepatch[*]}]" "righthand = [$righthand_status]" "smooth = [$smooth]" "map = [$map]" "postpatch = [$postpatch]" "dehpatch = [$dehpatch]" "cvars = [${cvars[*]}]" "complevel = [$complevel]"
- printf '\n\n%s\n\n' "----------------------------------------------------------"
- printf '\e[1m%s\e[0m' "here we go..."
- # Determine if using libstrangle or not
- if [ -v libstrangle ]; then
- launch_var=$(printf '%s' "$libstrangle $glb_path ${glb_arguments[*]}" | tr -s ' ')
- else
- launch_var=$(printf '%s' "$glb_path ${glb_arguments[*]}" | tr -s ' ')
- fi
- # Copy final launch command to the clipboard, so you may return easily after quitting
- printf '%s' "$launch_var" | tr -d '\n' | xclip
- # Display final launch command without binary path
- printf '\n%s\n' "glboom-plus ${glb_arguments[*]}" | tr -s ' '
- printf '\n%s\n' "----------------------------------------------------------"
- # Launch GLBoom+ with selected variables
- case $dry_check in
- false)
- case $verbose_check in
- false)
- # Hide GLBoom+'s output
- eval "$launch_var" > /dev/null 2>&1
- ;;
- true)
- # Show GLBoom+'s output
- eval "$launch_var"
- ;;
- esac
- ;;
- esac
- # Copyright 2020 PhysixCat
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- # http://www.apache.org/licenses/LICENSE-2.0
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
Add Comment
Please, Sign In to add comment