Advertisement
Guest User

terraria

a guest
Jun 28th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. #!/bin/bash
  2. # Global
  3. GOG_BASH_LIBRARY_VERSION="1.1"
  4. HELP_TEXTS=""
  5. _OPTION_FOUND="false"
  6.  
  7. library_sanity_test() {
  8. echo "Library responding!"
  9. }
  10.  
  11. get_gameinfo() {
  12. cat gameinfo | head -n "${1}" | tail -n 1
  13. }
  14.  
  15. _option_found() {
  16. _OPTION_FOUND="true"
  17. }
  18.  
  19. # define option (short_name,long_name,help_text,arguments,action, arguments)
  20. define_option() {
  21. local short_name=$1
  22. local long_name=$2
  23. local help_text=$3
  24. local function=$4
  25. local arguments=$5
  26. local help_text="${short_name}, \t${long_name} \t\t- ${help_text}"
  27. HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  28. if [ "${arguments}" == "${short_name}" ] || [ "${arguments}" == "${long_name}" ] ; then
  29. _option_found
  30. "${function}" $arguments
  31. fi
  32. }
  33.  
  34. # version_option (version_gog,version_original)
  35. version_option() {
  36. local help_text="-v, \t--version \t\t- show version of this package"
  37. HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  38.  
  39. local version_gog=$1
  40. local version_original=$2
  41. local arguments=$3
  42. if [ "${arguments}" == "-v" ] || [ "${arguments}" == "--version" ] ; then
  43. _option_found
  44. echo "${version_gog} (GOG.com)"
  45. echo "${version_original} (Developer)"
  46. fi
  47. }
  48.  
  49. system_report_option() {
  50. local arguments=$1
  51. local help_text="-p, \t--sysrep \t\t- generate a system report"
  52. HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  53. if [ "${arguments}" == "-p" ] || [ "${arguments}" == "--sysrep" ] ; then
  54. _option_found
  55. cd support
  56. ./gog-system-report.sh
  57. fi
  58. }
  59.  
  60. # help_option (arguments)
  61. help_option(){
  62. local arguments=$1
  63. local help_text="-h, \t--help \t\t\t- display this help"
  64. HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  65. if [ "${arguments}" == "-h" ] || [ "${arguments}" == "--help" ] ; then
  66. _option_found
  67. echo -e "${GAME_NAME} [ ${VERSION} ] (GOG.com)\n"
  68. echo -e "usage: [command] [argument]\n"
  69. echo -e "Arguments: "
  70. echo -e $HELP_TEXTS | column -t -s $'\t'
  71. echo -e ""
  72. cat support/support_notice.txt
  73. fi
  74. }
  75.  
  76. default_option() {
  77. if [ "${_OPTION_FOUND}" != "true" ] ; then
  78. default
  79. fi
  80. }
  81.  
  82. standard_options() {
  83. version_option "${VERSION}" "${VERSION_DEV}" "$@"
  84. system_report_option "$@"
  85.  
  86. help_option "$@" # this has to be latest option before default_option
  87. default_option
  88. }
  89.  
  90. ###
  91. # Native
  92. ###
  93.  
  94. execute_game() {
  95. local bin_32="${1}"
  96. local bin_64="${2}"
  97. local bin_path32="${3}"
  98. local bin_path64="${4}"
  99. local lib_path32="${5}"
  100. local lib_path64="${6}"
  101. local arch=$(uname -m)
  102. if [ "$arch" == "x86_64" ]
  103. then
  104. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
  105. cd "${bin_path64}"
  106. ./"${bin_64}"
  107. else
  108. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
  109. cd "${bin_path32}"
  110. ./"${bin_32}"
  111. fi
  112. }
  113.  
  114. execute_game_with_params() {
  115. local bin_32="${1}"
  116. local bin_64="${2}"
  117. local bin_path32="${3}"
  118. local bin_path64="${4}"
  119. local lib_path32="${5}"
  120. local lib_path64="${6}"
  121. local arch=$(uname -m)
  122. if [ "$arch" == "x86_64" ]
  123. then
  124. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
  125. cd "${bin_path64}"
  126. ./"${bin_64}" "$@"
  127. else
  128. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
  129. cd "${bin_path32}"
  130. ./"${bin_32}" "$@"
  131. fi
  132. }
  133.  
  134. execute_game_aoss() {
  135. local bin_32="${1}"
  136. local bin_64="${2}"
  137. local bin_path32="${3}"
  138. local bin_path64="${4}"
  139. local lib_path32="${5}"
  140. local lib_path64="${6}"
  141. local arch=$(uname -m)
  142. if [ "$arch" == "x86_64" ]
  143. then
  144. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
  145. cd "${bin_path64}"
  146. ./aoss ./"${bin_64}"
  147. else
  148. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
  149. cd "${bin_path32}"
  150. ./aoss ./"${bin_32}"
  151. fi
  152. }
  153.  
  154. ###
  155. # DOSBox
  156. ###
  157.  
  158. run_dosbox() {
  159. local conf_1="${1}"
  160. local conf_2="${2}"
  161. ./dosbox/dosbox -conf "${conf_1}" -conf "${conf_2}" -no-console -c exit
  162. }
  163.  
  164. ###
  165. # ScummVM
  166. ###
  167.  
  168. run_scummvm() {
  169. local conf="${1}"
  170. ./scummvm/scummvm -c "${conf}" --themepath=scummvm
  171. }
  172.  
  173. ###
  174. # Wine
  175. ###
  176.  
  177. run_wine() {
  178. local game_path="${1}"
  179. local executable="${2}"
  180. local args="${3}"
  181. cd "${CURRENT_DIR}/prefix/${game_path}"
  182. export WINEPREFIX="${CURRENT_DIR}/prefix"
  183. echo "WINEPREFIX="$WINEPREFIX
  184. "${CURRENT_DIR}/wine_standalone/wine" "${game_path}" "${executable}" "${args}"
  185. }
  186.  
  187. run_wine_virtual() {
  188. local game_path="${1}"
  189. local executable="${2}"
  190. local args="${3}"
  191. cd "${CURRENT_DIR}/prefix/${game_path}"
  192. export WINEPREFIX="${CURRENT_DIR}/prefix"
  193. echo "WINEPREFIX="$WINEPREFIX
  194. "${CURRENT_DIR}/wine_standalone/wine-virtual" "${game_path}" "${executable}" "${args}"
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement