Files
nharris-lmg 28d582837d Update total war III test harness (#75)
* Update TWW3

* missed one

* please the linting gods
2023-10-20 09:57:16 -07:00

26 lines
951 B
Python

"""Utility functions for Total War: Warhammer III test script"""
import os
import re
APPDATA = os.getenv("APPDATA")
CONFIG_LOCATION = f"{APPDATA}\\The Creative Assembly\\Warhammer3\\scripts"
CONFIG_FILENAME = "preferences.script.txt"
def read_current_resolution():
"""Reads resolutions settings from local game file"""
height_pattern = re.compile(r"y_res (\d+);")
width_pattern = re.compile(r"x_res (\d+);")
cfg = f"{CONFIG_LOCATION}\\{CONFIG_FILENAME}"
height_value = 0
width_value = 0
with open(cfg, encoding="utf-8") as file:
lines = file.readlines()
for line in lines:
height_match = height_pattern.search(line)
width_match = width_pattern.search(line)
if height_match is not None:
height_value = height_match.group(1)
if width_match is not None:
width_value = width_match.group(1)
return (height_value, width_value)