"""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)