From fee6e59440a9e2a77208429eb4c0001d2ee96345 Mon Sep 17 00:00:00 2001 From: Vishal Date: Wed, 25 Sep 2024 02:08:10 +0530 Subject: [PATCH] Stopping stress tests from running when you are already in a game --- .../ba_data/python/bauiv1lib/benchmarks.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/assets/ba_data/python/bauiv1lib/benchmarks.py b/src/assets/ba_data/python/bauiv1lib/benchmarks.py index 927300ba..e1319cce 100644 --- a/src/assets/ba_data/python/bauiv1lib/benchmarks.py +++ b/src/assets/ba_data/python/bauiv1lib/benchmarks.py @@ -366,16 +366,22 @@ class BenchmarksAndStressTestsWindow(bui.MainWindow): bui.app.classic.run_media_reload_benchmark() def _stress_test_pressed(self) -> None: + from bascenev1lib.mainmenu import MainMenuActivity + if bui.app.classic is None: logging.warning('stress-test requires classic') return - bui.app.classic.run_stress_test( - playlist_type=self._stress_test_game_type, - playlist_name=cast( - str, bui.textwidget(query=self._stress_test_playlist_name_field) - ), - player_count=self._stress_test_player_count, - round_duration=self._stress_test_round_duration, - ) - bui.containerwidget(edit=self._root_widget, transition='out_right') + activity = bs.get_foreground_host_activity() + if isinstance(activity, MainMenuActivity): + bui.app.classic.run_stress_test( + playlist_type=self._stress_test_game_type, + playlist_name=cast( + str, bui.textwidget(query=self._stress_test_playlist_name_field) + ), + player_count=self._stress_test_player_count, + round_duration=self._stress_test_round_duration, + ) + bui.containerwidget(edit=self._root_widget, transition='out_right') + else: + bui.screenmessage(bui.Lstr(value='Already present in another activity.'))