mirror of
https://github.com/LTTLabsOSS/markbench-tests.git
synced 2026-01-09 14:07:56 -05:00
added scaling multiple so click lands on all resolutions (#133)
added scaling multiple so click lands on all resolutions and some linting
This commit is contained in:
@@ -43,7 +43,8 @@ kerasService = KerasService(args.keras_host, args.keras_port)
|
||||
|
||||
def start_game():
|
||||
"""Launch the game with console enabled and FPS unlocked"""
|
||||
return exec_steam_game(STEAM_GAME_ID, game_params=["-console", "+fps_max 0"])
|
||||
return exec_steam_game(
|
||||
STEAM_GAME_ID, game_params=["-console", "+fps_max 0"])
|
||||
|
||||
|
||||
def console_command(command):
|
||||
@@ -68,25 +69,38 @@ def run_benchmark():
|
||||
time.sleep(1)
|
||||
|
||||
# waiting about a minute for the main menu to appear
|
||||
if kerasService.wait_for_word(word="heroes", timeout=80, interval=1) is None:
|
||||
logging.error("Game didn't start in time. Check settings and try again.")
|
||||
if kerasService.wait_for_word(
|
||||
word="heroes", timeout=80, interval=1) is None:
|
||||
logging.error(
|
||||
"Game didn't start in time. Check settings and try again.")
|
||||
sys.exit(1)
|
||||
|
||||
height, width = get_resolution()
|
||||
screen_height, screen_width = get_resolution()
|
||||
location = None
|
||||
|
||||
click_multiple = 0
|
||||
# We check the resolution so we know which screenshot to use for the locate on screen function
|
||||
match width:
|
||||
case "1280":
|
||||
location = gui.locateOnScreen(f"{SCRIPT_DIRECTORY}\\screenshots\\settings_720.png", confidence=0.9)
|
||||
location = gui.locateOnScreen(
|
||||
f"{SCRIPT_DIRECTORY}\\screenshots\\settings_720.png",
|
||||
confidence=0.9)
|
||||
click_multiple = 0.8
|
||||
case "1920":
|
||||
location = gui.locateOnScreen(f"{SCRIPT_DIRECTORY}\\screenshots\\settings_1080.png")
|
||||
location = gui.locateOnScreen(
|
||||
f"{SCRIPT_DIRECTORY}\\screenshots\\settings_1080.png")
|
||||
click_multiple = 1
|
||||
case "2560":
|
||||
location = gui.locateOnScreen(f"{SCRIPT_DIRECTORY}\\screenshots\\settings_1440.png")
|
||||
location = gui.locateOnScreen(
|
||||
f"{SCRIPT_DIRECTORY}\\screenshots\\settings_1440.png")
|
||||
click_multiple = 1.5
|
||||
case "3840":
|
||||
location = gui.locateOnScreen(f"{SCRIPT_DIRECTORY}\\screenshots\\settings_2160.png")
|
||||
location = gui.locateOnScreen(
|
||||
f"{SCRIPT_DIRECTORY}\\screenshots\\settings_2160.png")
|
||||
click_multiple = 2
|
||||
case _:
|
||||
logging.error("Could not find the settings cog. The game resolution is currently %s, %s. Are you using a standard resolution?", height, width)
|
||||
logging.error(
|
||||
"Could not find the settings cog. The game resolution is currently %s, %s. Are you using a standard resolution?",
|
||||
screen_height, screen_width)
|
||||
sys.exit(1)
|
||||
|
||||
# navigating to the video config section
|
||||
@@ -99,20 +113,25 @@ def run_benchmark():
|
||||
|
||||
result = kerasService.look_for_word(word="video", attempts=10, interval=1)
|
||||
if not result:
|
||||
logging.info("Did not find the video menu button. Did Keras enter settings correctly?")
|
||||
logging.info(
|
||||
"Did not find the video menu button. Did Keras enter settings correctly?")
|
||||
sys.exit(1)
|
||||
|
||||
gui.moveTo(result["x"] + 10, result["y"] + 8)
|
||||
gui.moveTo(result["x"] + int(50 * click_multiple),
|
||||
result["y"] + int(20 * click_multiple))
|
||||
gui.mouseDown()
|
||||
time.sleep(0.2)
|
||||
gui.mouseUp()
|
||||
time.sleep(0.2)
|
||||
|
||||
if kerasService.wait_for_word(word="resolution", timeout=30, interval=1) is None:
|
||||
logging.info("Did not find the video settings menu. Did the menu get stuck?")
|
||||
if kerasService.wait_for_word(
|
||||
word="resolution", timeout=30, interval=1) is None:
|
||||
logging.info(
|
||||
"Did not find the video settings menu. Did the menu get stuck?")
|
||||
sys.exit(1)
|
||||
|
||||
am.take_screenshot("video.png", ArtifactType.CONFIG_IMAGE, "picture of video settings")
|
||||
am.take_screenshot("video.png", ArtifactType.CONFIG_IMAGE,
|
||||
"picture of video settings")
|
||||
|
||||
# starting the benchmark
|
||||
user.press("escape")
|
||||
@@ -124,7 +143,8 @@ def run_benchmark():
|
||||
user.press("\\")
|
||||
|
||||
time.sleep(5)
|
||||
if kerasService.wait_for_word(word="directed", timeout=30, interval=0.1) is None:
|
||||
if kerasService.wait_for_word(
|
||||
word="directed", timeout=30, interval=0.1) is None:
|
||||
logging.error("Didn't see directed camera. Did the replay load?")
|
||||
sys.exit(1)
|
||||
|
||||
@@ -138,26 +158,29 @@ def run_benchmark():
|
||||
|
||||
result = kerasService.wait_for_word(word="2560", timeout=30, interval=0.1)
|
||||
if result is None:
|
||||
logging.error("Unable to find Leshrac's HP. Using default start time value.")
|
||||
logging.error(
|
||||
"Unable to find Leshrac's HP. Using default start time value.")
|
||||
else:
|
||||
test_start_time = int(time.time())
|
||||
logging.info("Found Leshrac's HP! Marking the start time accordingly.")
|
||||
|
||||
time.sleep(73) # sleep duration during gameplay
|
||||
time.sleep(73) # sleep duration during gameplay
|
||||
|
||||
# Default fallback end time
|
||||
test_end_time = int(time.time())
|
||||
|
||||
result = kerasService.wait_for_word(word="1195", timeout=30, interval=0.1)
|
||||
if result is None:
|
||||
logging.error("Unable to find gold count of 1195. Using default end time value.")
|
||||
logging.error(
|
||||
"Unable to find gold count of 1195. Using default end time value.")
|
||||
else:
|
||||
test_end_time = int(time.time())
|
||||
logging.info("Found the gold. Marking end time.")
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
if kerasService.wait_for_word(word="heroes", timeout=25, interval=1) is None:
|
||||
if kerasService.wait_for_word(
|
||||
word="heroes", timeout=25, interval=1) is None:
|
||||
logging.error("Main menu after running benchmark not found, exiting")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user