gen_engine_command.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/sh
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. show_usage (){
  7. printf "Usage: $0 [options [parameters]]\n"
  8. printf "\n"
  9. printf "Mandatory options:\n"
  10. printf " -g|--game [doom|doom2|tnt|plutonia|heretic|hexen|chex3]\n"
  11. printf " -e|--engine [chocolate|crispy|prboom|dsda|gzdoom]\n"
  12. printf " -l|--map_limit [none|vanilla|nolimit|boom|zdoom]\n"
  13. printf "\n"
  14. printf "Options:\n"
  15. printf " -d|--game-dir [/path/to/doom/base/directory] (Optional, default: '~/games/doom')\n"
  16. printf " -s|--skill [1, 2, 3, 4, 5] (Optional, default: '3')\n"
  17. printf " -r|--map_generator [none|slige|obsidian] (Optional, default: 'none')\n"
  18. printf " -m|--mods [none|vanilla|improved|beautiful|brutal|samsara] (Optional, default: 'vanilla')\n"
  19. printf " -u|--mangohud [true|false] (Optional, default: 'no')\n"
  20. printf " --nomo no monsters [true|false] (Optional, default: 'false')\n"
  21. printf " -h|--help, Print help\n"
  22. exit
  23. }
  24. if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
  25. show_usage
  26. fi
  27. if [ -z "$1" ]; then
  28. show_usage
  29. fi
  30. while [ ! -z "$1" ]; do
  31. case "$1" in
  32. --game-dir|-d)
  33. shift
  34. echo "INFO: param - game directory: $1"
  35. param_game_dir=$1
  36. ;;
  37. --game|-g)
  38. shift
  39. echo "INFO: param - iwad: $1"
  40. param_iwad=$1
  41. ;;
  42. --engine|-e)
  43. shift
  44. echo "INFO: param - engine: $1"
  45. param_engine=$1
  46. ;;
  47. --map_limit|-l)
  48. shift
  49. echo "INFO: param - map limit $1"
  50. param_map_limit=$1
  51. ;;
  52. --skill|-s)
  53. shift
  54. echo "INFO: param - skill: $1"
  55. param_skill=$1
  56. ;;
  57. --map_generator|-r)
  58. shift
  59. echo "INFO: param - map generator: $1"
  60. param_map_generator=$1
  61. ;;
  62. --nomo)
  63. shift
  64. echo "INFO: param - no monsters: $1"
  65. param_nomo=$1
  66. ;;
  67. --mods|-m)
  68. shift
  69. echo "INFO: param - mods: $1"
  70. param_mods=$1
  71. ;;
  72. --mangohud|-u)
  73. shift
  74. echo "INFO: param - mangohud: $1"
  75. param_mangohud=$1
  76. ;;
  77. *)
  78. show_usage
  79. ;;
  80. esac
  81. shift
  82. done
  83. ### Configuration
  84. if [ -z "$param_game_dir" ]; then
  85. param_game_dir=~/games/doom
  86. fi
  87. config_script_dir="$(pwd $(dirname $0))"
  88. config_iwads_dir=$param_game_dir/wads/iwads
  89. if [ -z "$param_engine" ]; then
  90. echo "ERROR: 'engine' parameter is mandatory"
  91. fi
  92. if [ -z "$param_map_generator" ]; then
  93. param_map_generator=none
  94. fi
  95. if [ -z "$param_skill" ]; then
  96. param_skill=3
  97. fi
  98. if [ -z "$param_mods" ]; then
  99. param_mods=vanilla
  100. fi
  101. if [ -z "$param_nomo" ]; then
  102. param_mods=false
  103. fi
  104. if [ -z "$param_mangohud" ]; then
  105. param_mangohud=false
  106. fi
  107. ### check parameter values
  108. # iwad
  109. games="doom doom2 tnt plutonia heretic hexen chex3"
  110. echo "$games" | tr ' ' '\n' | while read -r item; do
  111. if [ "$item" = "$param_iwad" ]; then touch match; fi
  112. done
  113. if [ ! -f match ]; then echo "ERROR: $param_iwad is not a valid option, valid options are: $games"; exit 1; fi; rm match
  114. map_limit="none vanilla nolimit boom zdoom"
  115. echo "$map_limit" | tr ' ' '\n' | while read -r item; do
  116. if [ "$item" = "$param_map_limit" ]; then touch match; fi
  117. done
  118. if [ ! -f match ]; then echo "ERROR: $param_map_limit is not a valid option, valid options are: $map_limit"; exit 1; fi; rm match
  119. map_generators="none slige obsidian"
  120. echo "$map_generators" | tr ' ' '\n' | while read -r item; do
  121. if [ "$item" = "$param_map_generator" ]; then touch match; fi
  122. done
  123. if [ ! -f match ]; then echo "ERROR: $param_map_generator is not a valid option, valid options are: $map_generators"; exit 1; fi; rm match
  124. mods="none vanilla improved beautiful brutal samsara"
  125. echo "$mods" | tr ' ' '\n' | while read -r item; do
  126. if [ "$item" = "$param_mods" ]; then touch match; fi
  127. done
  128. if [ ! -f match ]; then echo "ERROR: $param_mods is not a valid option, valid options are: $mods"; exit 1; fi; rm match
  129. skills="1 2 3 4 5"
  130. echo "$skills" | tr ' ' '\n' | while read -r item; do
  131. if [ "$item" = "$param_skill" ]; then touch match; fi
  132. done
  133. if [ ! -f match ]; then echo "ERROR: $param_skill is not a valid option, valid options are: $skills"; exit 1; fi; rm match