SHARE
TWEET

glb

PhysixCat May 25th, 2020 (edited) 1,196 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # GLBoom+ launching script
  3. # Author: PhysixCat
  4.  
  5. printf '\e[1m%s\e[0m\n' "GLBoom+ launching script"
  6. printf '%s\n\n' "----------------------------------------------------------"
  7.  
  8. # ----------------------------------------------------------
  9. # IMPORTANT!!!
  10. # ----------------------------------------------------------
  11.  
  12. # User should edit $glb_path to point to their glb binary
  13. # If it was installed through your distro's repo, the binary name is enough
  14.  
  15. glb_path="glboom-plus"
  16. #glb_path="$HOME/Vidya/prboomfork-umapinfo/prboom2/build/glboom-plus"
  17.  
  18. # I use "libstrangle" to limit GLB+'s FPS to 60 without vsync
  19. # https://gitlab.com/torkel104/libstrangle
  20. # If you don't, simply leave this commented out
  21.  
  22. #libstrangle="strangle 62"
  23.  
  24. # ----------------------------------------------------------
  25.  
  26. # Initializing script variables
  27. interactive="true"
  28. strict_check="false"
  29. fancy_check="false"
  30. verbose_check="false"
  31. dry_check="false"
  32. playdemo_check="false"
  33. recorddemo_check="false"
  34. valid_iwads=( 'doom' 'doom2' 'tnt' 'plutonia' 'miniwad' 'freedoom' 'freedoom2' )
  35.  
  36. showhelp () {
  37.     echo "Usage: glb [OPTION]... [FILE]..."
  38.     echo
  39.     echo "Launches GLBoom+, a source port for Doom & Doom 2."
  40.     echo "Auto-applies sprite fixes and dssecret sounds."
  41.     echo "Additional mods such as DoomSFX or DEH patches are optional"
  42.     echo "Can be ran interactively or by using launch arguments"
  43.     echo
  44.     echo "If WAD is not recognized, user is prompted to specify complevel and IWAD."
  45.     echo
  46.     echo "  -d, --dry           Dry test run of script (doesn't launch GLB+)."
  47.     echo "  -f, --fancy         Apply vsmooth DEH patch by fraggle."
  48.     echo "  -h, --help          Display this help and exit."
  49.     echo "  -p, --play          Play specified demo file."
  50.     echo "  -r, --record        Record specified demo file."
  51.     echo "  -s, --strict        Guarantee no DEH lumps are loaded before WAD."
  52.     echo "  -v, --verbose       Display GLB+ output to console after launch."
  53.     echo "  -w, --wad           Load specified WAD file."
  54.     echo
  55.     echo "Anything not recognized by this script will be passed through to"
  56.     echo "GLBoom+ verbatim (such as -skill #, -warp ##, etc...)"
  57.     echo
  58.     echo "script by PhysixCat"
  59. }
  60.  
  61. # Loop until all parameters are used up
  62. while [ "$1" != "" ]; do
  63.     case "$1" in
  64.         -d|--dry)
  65.             dry_check="true"
  66.             printf '%s\n' "This is a dry run of the script"
  67.             ;;
  68.         -f|--fancy)
  69.             fancy_check="true"
  70.             smooth='vsmooth'
  71.             ;;
  72.         -h|--help)
  73.             showhelp
  74.             exit 0
  75.             ;;
  76.         -p|--play)
  77.             shift
  78.             cvars+=( '-playdemo' "$1" )
  79.             playdemo_check="true"
  80.             interactive="false"
  81.             ;;
  82.         -r|--record)
  83.             shift
  84.             cvars+=( '-record' "$1" )
  85.             recorddemo_check="true"
  86.             interactive="false"
  87.             ;;
  88.         -s|--strict)
  89.             strict_check="true"
  90.             ;;
  91.         -v|--verbose)
  92.             verbose_check="true"
  93.             ;;
  94.         -w|--wad)
  95.             shift
  96.             map="$1"
  97.             interactive="false"
  98.             ;;
  99.         *)
  100.             cvars+=( "$1" )
  101.             ;;
  102.     esac
  103.     shift
  104.  
  105. done
  106.  
  107. # Check for contradictions in the arguments
  108. [[ $strict_check == 'true' && $fancy_check == 'true' ]] && printf '%s\n\n' "what the fug" && exit 1
  109. [[ $playdemo_check == 'true' && $recorddemo_check == 'true' ]] && printf '%s\n\n' "what the fug" && exit 1
  110. [[ $verbose_check == 'true' && $dry_check == 'true' ]] && printf '%s\n' "can't be very verbose on a dry run..."
  111.  
  112. case $interactive in
  113.     true)
  114.         # Ask user for desired map
  115.         read -r -p 'wad?'$'\n> ' map
  116.         ;;
  117. esac
  118.  
  119. # Requested map is checked against some hardcoded WAD names. If not recognized, ask user for corresponding complevel and IWAD
  120. case $map in
  121.     # Maps for Doom 2 and limit-removing source ports
  122.     ''|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)
  123.         iwad='doom2'
  124.         complevel='2'
  125.         case $map in
  126.             av)
  127.                 postpatch='-deh av.deh'
  128.                 ;;
  129.             hr)
  130.                 postpatch='hr_mus'
  131.                 ;;
  132.             btsx)
  133.                 map='btsx_e1a btsx_e1b'
  134.                 ;;
  135.             btsx2)
  136.                 map='btsx_e2a btsx_e2b'
  137.                 ;;
  138.             jpcp)
  139.                 postpatch='jpcp_hud'
  140.                 ;;
  141.             mutiny)
  142.                 postpatch='-deh mutiny.deh'
  143.                 ;;
  144.             tvr)
  145.                 postpatch='tvrmidi'
  146.                 ;;
  147.         esac
  148.         ;;
  149.     # Maps for The Ultimate Doom and limit-removing source ports
  150.     doom|dtwid|dtwid-*|sigil|neis|dbimpact|sgnsym|deathless|dmpurge|draftex|hadron|indifference|doom_maps|freedoom_maps|git|nihility|nmdu|shpo1)
  151.         iwad='doom'
  152.         complevel='3'
  153.         case $map in
  154.             dtwid)
  155.                 map='dtwid udtwid'
  156.                 ;;
  157.             dtwid-e5)
  158.                 map='dtwid-le dtwid-e5'
  159.                 ;;
  160.             hadron)
  161.                 map='hadron hadrone2'
  162.                 ;;
  163.             sigil)
  164.                 postpatch='d1spfx_sigil'
  165.                 map='sigil_compat'
  166.                 ;;
  167.             git)
  168.                 postpatch='-deh git.deh'
  169.                 ;;
  170.         esac
  171.         ;;
  172.     # Maps for TNT: Evilution
  173.     tnt|tntr)
  174.         iwad='tnt'
  175.         complevel='4'
  176.         ;;
  177.     # Maps for The Plutonia Experiment
  178.     plutonia|plutonia_maps|prcp|pl2|urania)
  179.         iwad='plutonia'
  180.         complevel='4'
  181.         case $map in
  182.             plutonia)
  183.                 postpatch='plutmidi'
  184.                 ;;
  185.         esac
  186.         ;;
  187.     # Maps for The Plutonia Experiment but that also require Boom
  188.     c-shock)
  189.         iwad='plutonia'
  190.         complevel='9'
  191.         ;;
  192.     # Maps for Boom-compatible source ports
  193.     ayy|aaliens|vanguard|gd|swtw|stardate*|sod|preacher|sunlust|jenesis|catk|crumpets|finely*|magnolia|sunder|cchest*|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)
  194.         iwad='doom2'
  195.         complevel='9'
  196.         case $map in
  197.             ayy|aaliens)
  198.                 postpatch='d2spfx_aaliens'
  199.                 map='aaliens'
  200.                 ;;
  201.             mayhem17)
  202.                 postpatch='d2spfx_mayhem17'
  203.                 map='mayhem17 mayhem17_updatev1'
  204.                 ;;
  205.             sunlust)
  206.                 postpatch='d2spfx_sunlust'
  207.                 ;;
  208.             catk)
  209.                 postpatch='catk_bar'
  210.                 ;;
  211.         esac
  212.         ;;
  213.     # Maps for MBF-compatible source ports
  214.     valiant|eviternity|exomoon|dotb|motm|sawdust)
  215.         iwad='doom2'
  216.         complevel='11'
  217.         case $map in
  218.             dotb)
  219.                 postpatch='d2spfx_dotb'
  220.                 ;;
  221.         esac
  222.         ;;
  223.     *)
  224.         # Ask user for complevel
  225.         printf '%s\n' "2 = Doom2, 3 = UltimateDoom, 4 = FinalDoom, 9 = Boom, 11 = MBF"
  226.         read -r -p 'complevel?'$'\n> ' complevel
  227.         if ! [[ "$complevel" =~ ^[0-9]+$ ]] || ! ((complevel >= 0 && complevel <=17)); then
  228.             echo "complevel must be an integer between 0 and 17"
  229.             exit 1
  230.         fi
  231.  
  232.         # Old way of determining correct IWAD
  233.         # Abandoned because of possible weird edge cases
  234.         #case $complevel in
  235.         #    2|9|11)
  236.         #        iwad='doom2'
  237.         #        ;;
  238.         #    3)
  239.         #        iwad='doom'
  240.         #        ;;
  241.         #    4)
  242.         #        read -r -p 'tnt or plutonia based?'$'\n> ' iwad
  243.         #        case $iwad in
  244.         #            tnt|plutonia)
  245.         #                ;;
  246.         #            *)
  247.         #                printf '%s\n\n' "what the fug"
  248.         #                exit 1
  249.         #                ;;
  250.         #        esac
  251.         #        ;;
  252.         #    *)
  253.         #        printf '%s\n\n' "what the fug"
  254.         #        exit 1
  255.         #        ;;
  256.         #esac
  257.  
  258.         # Ask user for IWAD
  259.         printf '%s\n' "doom, doom2, tnt, plutonia, miniwad"
  260.         read -r -p 'IWAD?'$'\n> ' iwad
  261.         if [[ " ${valid_iwads[*]} " != *" $iwad "* ]]; then
  262.             echo "not a valid IWAD"
  263.             exit 1
  264.         fi
  265.         printf '\n'
  266.         ;;
  267. esac
  268.  
  269. case $interactive in
  270.     true)
  271.         # Ask user for cvars
  272.         read -r -p 'map# & cvars?'$'\n> ' -a cvars_raw
  273.         [[ -n "${cvars_raw[*]}" ]] && cvars=( '-skill 4' '-warp' "${cvars_raw[*]}" )
  274.         # Ask user if they want smooth weapons
  275.         [[ $strict_check == 'false' && $fancy_check == 'false' ]] &&
  276.         read -r -p 'apply smooth DEH? [y/N] - WARNING: may cause bugs/crashes if map also includes DEH lump'$'\n> ' fancy_check &&
  277.         case $fancy_check in
  278.             ''|n)
  279.                 ;;
  280.             y)
  281.                 smooth='vsmooth'
  282.                 ;;
  283.             *)
  284.                 printf '%s\n\n' "what the fug"
  285.                 exit 1
  286.                 ;;
  287.         esac
  288.         ;;
  289. esac
  290.  
  291. # Make sure map is unset if it's an IWAD
  292. [[ "$iwad" == "$map" ]] && unset map
  293.  
  294. # Determine whether to load DEH lumps in the sprite fixes or not
  295. case $iwad in
  296.     doom)
  297.         case $strict_check in
  298.             true)
  299.                 prepatch=( 'd1spfx19_nodeh' 'dssecret' )
  300.                 ;;
  301.             false)
  302.                 prepatch=( 'd1spfx19' 'doomsfx' 'dssecret' )
  303.                 ;;
  304.         esac
  305.         ;;
  306.     doom2|tnt|plutonia)
  307.         case $strict_check in
  308.             true)
  309.                 prepatch=( 'd2spfx19_nodeh' 'dssecret' )
  310.                 ;;
  311.             false)
  312.                 prepatch=( 'd2spfx19' 'doomsfx' 'dssecret' )
  313.                 ;;
  314.         esac
  315.         ;;
  316.     *)
  317.         prepatch=( 'dssecret' )
  318.         ;;
  319. esac
  320.  
  321. # Show selected variables
  322. glb_arguments=( '-iwad' "$iwad" '-file' "${prepatch[@]}" "$smooth" "$map" "$postpatch" "${cvars[@]}" '-complevel' "$complevel" )
  323. printf '%s' "iwad      = [$iwad]"
  324. printf '\n%s' "prepatch  = [${prepatch[*]}]" "smooth    = [$smooth]" "map       = [$map]" "postpatch = [$postpatch]" "cvars     = [${cvars[*]}]" "complevel = [$complevel]"
  325. printf '\n\n%s\n\n' "----------------------------------------------------------"
  326. printf '\e[1m%s\e[0m' "here we go..."
  327. # Determine if using libstrangle or not
  328. if [ -v libstrangle ]; then
  329.     launch_var=$(printf '%s' "$libstrangle $glb_path ${glb_arguments[*]}" | tr -s ' ')
  330. else
  331.     launch_var=$(printf '%s' "$glb_path ${glb_arguments[*]}" | tr -s ' ')
  332. fi
  333. # Copy final launch command to the clipboard, so you may return easily after quitting
  334. printf '%s' "$launch_var" | tr -d '\n' | xclip
  335. # Display final launch command without binary path
  336. printf '\n%s\n' "glboom-plus ${glb_arguments[*]}" | tr -s ' '
  337. printf '\n%s\n' "----------------------------------------------------------"
  338.  
  339. # Launch GLBoom+ with selected variables
  340. case $dry_check in
  341.     false)
  342.         case $verbose_check in
  343.             false)
  344.                 # Hide GLBoom+'s output
  345.                 eval "$launch_var" > /dev/null 2>&1
  346.                 ;;
  347.             true)
  348.                 # Show GLBoom+'s output
  349.                 eval "$launch_var"
  350.                 ;;
  351.         esac
  352.         ;;
  353. esac
  354.  
  355. # Copyright 2020 PhysixCat
  356.  
  357. # Licensed under the Apache License, Version 2.0 (the "License");
  358. # you may not use this file except in compliance with the License.
  359. # You may obtain a copy of the License at
  360.  
  361. # http://www.apache.org/licenses/LICENSE-2.0
  362.  
  363. # Unless required by applicable law or agreed to in writing, software
  364. # distributed under the License is distributed on an "AS IS" BASIS,
  365. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  366. # See the License for the specific language governing permissions and
  367. # limitations under the License.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top