1#!/bin/bash -e 2# Install A Total War Saga: THRONES OF BRITANNIA on Linux and generate launcher scripts and preference templates 3 4# Base constants 5# 6export STEAM_GAME_ID=712100 7export GAME_PREFS="$DEBUG_REAL_HOME/.local/share/feral-interactive/Thrones of Britannia" 8export GAME_INSTALL_DIR_BASE="steamapps/common/Total War Saga Thrones of Britannia/" 9export DEFAULT_STEAM_INSTALL_BASE="$DEBUG_REAL_HOME/.steam/steam" 10 11 12# Try and install the game in case it isn't already 13# 14echo "Ensuring game is installed" 15HOME="$DEBUG_REAL_HOME" steam "steam://install/$STEAM_GAME_ID" 16 17 18# Work out the steam install directory 19# 20export CONFIG_PATH="$DEBUG_REAL_HOME/.steam/steam/config/config.vdf" 21echo "Searching ${CONFIG_PATH} for install directories" 22_INSTALL_PATHS=$( awk '/BaseInstallFolder/ { gsub(/"/, "", $2); print $2 }' "${CONFIG_PATH}" ) 23 24# Find one that contains the game 25while read -r STEAM_PATH; do 26 _NEW_FULL_PATH="${STEAM_PATH}/${GAME_INSTALL_DIR_BASE}" 27 echo "Checking for game install: ${_NEW_FULL_PATH}" 28 if [ -d "${_NEW_FULL_PATH}" ]; then 29 echo "Found game install: ${_NEW_FULL_PATH}" 30 export GAME_INSTALL_DIR="${_NEW_FULL_PATH}" 31 fi 32done <<< "${_INSTALL_PATHS}" 33 34# Allow the default location as well 35if [ ! -d "${GAME_INSTALL_DIR}" ]; then 36 export GAME_INSTALL_DIR="${DEFAULT_STEAM_INSTALL_BASE}/${GAME_INSTALL_DIR_BASE}" 37 echo "Using default directory for game install: ${GAME_INSTALL_DIR}" 38fi 39 40# Bail if we still couldn't find the game 41if [ ! -f "${GAME_INSTALL_DIR}/ThronesOfBritannia.sh" ]; then 42 >&2 echo "Missing run script in install dir - ${GAME_INSTALL_DIR}/ThronesOfBritannia.sh" 43 exit 1 44fi 45 46# Gather the steam env variables the game runs with 47# 48echo "Gathering environment variables for game" 49HOME="$DEBUG_REAL_HOME" steam steam://run/$STEAM_GAME_ID & 50sleep 6 51GAME_PID=$( pidof ThronesOfBritannia | cut -d' ' -f1 ) 52if [ -z "$GAME_PID" ]; then 53 echo "Could not find process ThronesOfBritannia" 54 exit 1 55fi 56 57echo '#!/bin/bash' > steam-env-vars.sh 58echo "# Collected steam environment for A Total War Saga: THRONES OF BRITANNIA\n# PID : $GAME_PID" >> steam-env-vars.sh 59while read -rd $'\0' ENV ; do 60 NAME=$(echo "$ENV" | cut -zd= -f1); VAL=$(echo "$ENV" | cut -zd= -f2) 61 case $NAME in 62 *DBUS*) true 63 ;; 64 *) 65 echo "export $NAME=\"$VAL\"" 66 ;; 67 esac 68done < "/proc/$GAME_PID/environ" >> steam-env-vars.sh 69killall -9 ThronesOfBritannia 70sleep 6 71 72 73# Create the game launching script 74# 75echo "Generating run script" 76cat > thronesofbritannia <<- EOM 77#!/bin/bash 78# Generated run script for A Total War Saga: THRONES OF BRITANNIA 79# $( date ) 80 81# Source the steam runtime environment 82# 83. steam-env-vars.sh 84 85# Run the game 86# 87cd "${GAME_INSTALL_DIR}" 88./ThronesOfBritannia.sh 89 90# Grab the output (most recent non _frametimes txt file) 91RESULTS_DIR="${GAME_PREFS}/VFS/User/AppData/Roaming/The Creative Assembly/ThronesofBritannia/benchmarks/" 92mkdir -p "\${RESULTS_DIR}" 93cd "\${RESULTS_DIR}" 94true > "\$LOG_FILE" 95FPS_VALUES=\$( grep -A3 "frames per second" \$(ls -t | grep -P "benchmark_.*[0-9]+.txt" | head -n 1) | tail -n 3 ) 96cat benchmark_*.txt >> "\$LOG_FILE" 97echo "\${FPS_VALUES}" >> "\$LOG_FILE" 98EOM 99chmod +x thronesofbritannia 100 101 102# Create the template preferences file 103# 104echo "Generating settings template" 105cat > preferences.template.xml <<- EOM 106<?xml version="1.0" encoding="UTF-8"?> 107<registry> 108 <key name="HKEY_CLASSES_ROOT"> 109 </key> 110 <key name="HKEY_CURRENT_CONFIG"> 111 </key> 112 <key name="HKEY_CURRENT_USER"> 113 <key name="Software"> 114 <key name="Feral Interactive"> 115 <key name="Thrones of Britannia"> 116 <key name="Setup"> 117 <!-- screen resolutions --> 118 <value name="ScreenH" type="integer">@ScreenH@</value> 119 <value name="ScreenW" type="integer">@ScreenW@</value> 120 121 <value name="FullScreen" type="integer">1</value> 122 123 <!-- disable all forms of pausing --> 124 <value name="PauseMoviesOnPause" type="integer">0</value> 125 <value name="PauseOnSuspend" type="integer">0</value> 126 <value name="PauseSoundOnPause" type="integer">0</value> 127 <value name="PauseTimersOnPause" type="integer">0</value> 128 <value name="AllowPausing" type="integer">0</value> 129 130 <!-- don't send data without consent --> 131 <value name="AllowSendUsageData" type="integer">0</value> 132 133 <!-- stop the game options dialogue showing --> 134 <value name="GameOptionsDialogShouldShow" type="integer">0</value> 135 <value name="GameOptionsDialogShouldShowBigPicture" type="integer">0</value> 136 <value name="GameOptionsDialogShown" type="integer">1</value> 137 138 <!-- stop any potential warnings --> 139 <value name="SoftwareUpdatedAskedUser" type="integer">1</value> 140 <value name="SoftwareUpdatedCanCheck" type="integer">0</value> 141 <value name="SkipDriverWarnings" type="integer">1</value> 142 <value name="SkipOSWarnings" type="integer">1</value> 143 <key name="SpecificationAlerts"> 144 <!-- NOTE: Un-comment this if comparing the effects of the CPU governor --> 145 <!-- <value name="LnxCPUGovernorSubOptimal" type="integer">1</value> --> 146 </key> 147 148 <!-- surpress per device graphics settings, otherwise the settings below will be ignored --> 149 <value name="SeenSpecificationAlertUUIDPerRendererMappedSettings" type="integer">1</value> 150 151 <key name="GraphicsSettings"> 152 <!-- Default Graphics Settings --> 153 <value name="gfx_aa" type="integer">@gfx_aa@</value> 154 <value name="gfx_building_quality" type="integer">@gfx_building_quality@</value> 155 <value name="gfx_depth_of_field" type="integer">@gfx_depth_of_field@</value> 156 <value name="gfx_distortion" type="integer">@gfx_distortion@</value> 157 <value name="gfx_effects_quality" type="integer">@gfx_effects_quality@</value> 158 <value name="gfx_fleet_size" type="integer">@gfx_fleet_size@</value> 159 <value name="gfx_grass_quality" type="integer">@gfx_grass_quality@</value> 160 <value name="gfx_screen_space_reflections" type="integer">@gfx_screen_space_reflections@</value> 161 <value name="gfx_shadow_quality" type="integer">@gfx_shadow_quality@</value> 162 <value name="gfx_sky_quality" type="integer">@gfx_sky_quality@</value> 163 <value name="gfx_ssao" type="integer">@gfx_ssao@</value> 164 <value name="gfx_terrain_quality" type="integer">@gfx_terrain_quality@</value> 165 <value name="gfx_texture_filtering" type="integer">@gfx_texture_filtering@</value> 166 <value name="gfx_texture_quality" type="integer">@gfx_texture_quality@</value> 167 <value name="gfx_tree_quality" type="integer">@gfx_tree_quality@</value> 168 <value name="gfx_unit_quality" type="integer">@gfx_unit_quality@</value> 169 <value name="gfx_unit_size" type="integer">@gfx_unit_size@</value> 170 <value name="gfx_water_quality" type="integer">@gfx_water_quality@</value> 171 172 <!-- VSync off to avoid monitor refresh-rate changing results --> 173 <value name="gfx_vsync" type="integer">0</value> 174 </key> 175 </key> 176 </key> 177 </key> 178 <key name="MacDoze"> 179 <key name="Config"> 180 <value name="ExtraCommandLine" type="string">gfx_first_run false; game_startup_mode benchmark_auto_quit Script/Benchmarks/SiegeOfWintanceaster/SiegeOfWintanceaster.xml</value> 181 <value name="ExtraCommandLineEnabled" type="integer">1</value> 182 </key> 183 </key> 184 </key> 185 </key> 186</registry> 187EOM 188