bauiv1lib.debug
UIs for debugging purposes.
1# Released under the MIT License. See LICENSE for details. 2# 3"""UIs for debugging purposes.""" 4 5from __future__ import annotations 6 7import logging 8from typing import cast 9 10import bauiv1 as bui 11 12 13class DebugWindow(bui.Window): 14 """Window for debugging internal values.""" 15 16 def __init__(self, transition: str | None = 'in_right'): 17 # pylint: disable=too-many-statements 18 # pylint: disable=cyclic-import 19 from bauiv1lib import popup 20 21 assert bui.app.classic is not None 22 bui.app.ui_v1.set_main_menu_location('Benchmarks & Stress Tests') 23 uiscale = bui.app.ui_v1.uiscale 24 self._width = width = 580 25 self._height = height = ( 26 350 27 if uiscale is bui.UIScale.SMALL 28 else 420 if uiscale is bui.UIScale.MEDIUM else 520 29 ) 30 31 self._scroll_width = self._width - 100 32 self._scroll_height = self._height - 120 33 34 self._sub_width = self._scroll_width * 0.95 35 self._sub_height = 520 36 37 self._stress_test_game_type = 'Random' 38 self._stress_test_playlist = '__default__' 39 self._stress_test_player_count = 8 40 self._stress_test_round_duration = 30 41 42 self._r = 'debugWindow' 43 uiscale = bui.app.ui_v1.uiscale 44 super().__init__( 45 root_widget=bui.containerwidget( 46 size=(width, height), 47 transition=transition, 48 scale=( 49 2.35 50 if uiscale is bui.UIScale.SMALL 51 else 1.55 if uiscale is bui.UIScale.MEDIUM else 1.0 52 ), 53 stack_offset=( 54 (0, -30) if uiscale is bui.UIScale.SMALL else (0, 0) 55 ), 56 ) 57 ) 58 59 self._done_button = btn = bui.buttonwidget( 60 parent=self._root_widget, 61 position=(40, height - 67), 62 size=(120, 60), 63 scale=0.8, 64 autoselect=True, 65 label=bui.Lstr(resource='doneText'), 66 on_activate_call=self._done, 67 ) 68 bui.containerwidget(edit=self._root_widget, cancel_button=btn) 69 bui.textwidget( 70 parent=self._root_widget, 71 position=(0, height - 60), 72 size=(width, 30), 73 text=bui.Lstr(resource=f'{self._r}.titleText'), 74 h_align='center', 75 color=bui.app.ui_v1.title_color, 76 v_align='center', 77 maxwidth=260, 78 ) 79 80 self._scrollwidget = bui.scrollwidget( 81 parent=self._root_widget, 82 highlight=False, 83 size=(self._scroll_width, self._scroll_height), 84 position=((self._width - self._scroll_width) * 0.5, 50), 85 ) 86 bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) 87 88 self._subcontainer = bui.containerwidget( 89 parent=self._scrollwidget, 90 size=(self._sub_width, self._sub_height), 91 background=False, 92 ) 93 94 v = self._sub_height - 70 95 button_width = 300 96 btn = bui.buttonwidget( 97 parent=self._subcontainer, 98 position=((self._sub_width - button_width) * 0.5, v), 99 size=(button_width, 60), 100 autoselect=True, 101 label=bui.Lstr(resource=f'{self._r}.runCPUBenchmarkText'), 102 on_activate_call=self._run_cpu_benchmark_pressed, 103 ) 104 bui.widget( 105 edit=btn, up_widget=self._done_button, left_widget=self._done_button 106 ) 107 v -= 60 108 109 bui.buttonwidget( 110 parent=self._subcontainer, 111 position=((self._sub_width - button_width) * 0.5, v), 112 size=(button_width, 60), 113 autoselect=True, 114 label=bui.Lstr(resource=f'{self._r}.runGPUBenchmarkText'), 115 on_activate_call=self._run_gpu_benchmark_pressed, 116 ) 117 v -= 60 118 119 bui.buttonwidget( 120 parent=self._subcontainer, 121 position=((self._sub_width - button_width) * 0.5, v), 122 size=(button_width, 60), 123 autoselect=True, 124 label=bui.Lstr(resource=f'{self._r}.runMediaReloadBenchmarkText'), 125 on_activate_call=self._run_media_reload_benchmark_pressed, 126 ) 127 v -= 60 128 129 bui.textwidget( 130 parent=self._subcontainer, 131 position=(self._sub_width * 0.5, v + 22), 132 size=(0, 0), 133 text=bui.Lstr(resource=f'{self._r}.stressTestTitleText'), 134 maxwidth=200, 135 color=bui.app.ui_v1.heading_color, 136 scale=0.85, 137 h_align='center', 138 v_align='center', 139 ) 140 v -= 45 141 142 x_offs = 165 143 bui.textwidget( 144 parent=self._subcontainer, 145 position=(x_offs - 10, v + 22), 146 size=(0, 0), 147 text=bui.Lstr(resource=f'{self._r}.stressTestPlaylistTypeText'), 148 maxwidth=130, 149 color=bui.app.ui_v1.heading_color, 150 scale=0.65, 151 h_align='right', 152 v_align='center', 153 ) 154 155 popup.PopupMenu( 156 parent=self._subcontainer, 157 position=(x_offs, v), 158 width=150, 159 choices=['Random', 'Teams', 'Free-For-All'], 160 choices_display=[ 161 bui.Lstr(resource=a) 162 for a in [ 163 'randomText', 164 'playModes.teamsText', 165 'playModes.freeForAllText', 166 ] 167 ], 168 current_choice='Auto', 169 on_value_change_call=self._stress_test_game_type_selected, 170 ) 171 172 v -= 46 173 bui.textwidget( 174 parent=self._subcontainer, 175 position=(x_offs - 10, v + 22), 176 size=(0, 0), 177 text=bui.Lstr(resource=f'{self._r}.stressTestPlaylistNameText'), 178 maxwidth=130, 179 color=bui.app.ui_v1.heading_color, 180 scale=0.65, 181 h_align='right', 182 v_align='center', 183 ) 184 185 self._stress_test_playlist_name_field = bui.textwidget( 186 parent=self._subcontainer, 187 position=(x_offs + 5, v - 5), 188 size=(250, 46), 189 text=self._stress_test_playlist, 190 h_align='left', 191 v_align='center', 192 autoselect=True, 193 color=(0.9, 0.9, 0.9, 1.0), 194 description=bui.Lstr( 195 resource=f'{self._r}.stressTestPlaylistDescriptionText' 196 ), 197 editable=True, 198 padding=4, 199 ) 200 v -= 29 201 x_sub = 60 202 203 # Player count. 204 bui.textwidget( 205 parent=self._subcontainer, 206 position=(x_offs - 10, v), 207 size=(0, 0), 208 text=bui.Lstr(resource=f'{self._r}.stressTestPlayerCountText'), 209 color=(0.8, 0.8, 0.8, 1.0), 210 h_align='right', 211 v_align='center', 212 scale=0.65, 213 maxwidth=130, 214 ) 215 self._stress_test_player_count_text = bui.textwidget( 216 parent=self._subcontainer, 217 position=(246 - x_sub, v - 14), 218 size=(60, 28), 219 editable=False, 220 color=(0.3, 1.0, 0.3, 1.0), 221 h_align='right', 222 v_align='center', 223 text=str(self._stress_test_player_count), 224 padding=2, 225 ) 226 bui.buttonwidget( 227 parent=self._subcontainer, 228 position=(330 - x_sub, v - 11), 229 size=(28, 28), 230 label='-', 231 autoselect=True, 232 on_activate_call=bui.Call(self._stress_test_player_count_decrement), 233 repeat=True, 234 enable_sound=True, 235 ) 236 bui.buttonwidget( 237 parent=self._subcontainer, 238 position=(380 - x_sub, v - 11), 239 size=(28, 28), 240 label='+', 241 autoselect=True, 242 on_activate_call=bui.Call(self._stress_test_player_count_increment), 243 repeat=True, 244 enable_sound=True, 245 ) 246 v -= 42 247 248 # Round duration. 249 bui.textwidget( 250 parent=self._subcontainer, 251 position=(x_offs - 10, v), 252 size=(0, 0), 253 text=bui.Lstr(resource=f'{self._r}.stressTestRoundDurationText'), 254 color=(0.8, 0.8, 0.8, 1.0), 255 h_align='right', 256 v_align='center', 257 scale=0.65, 258 maxwidth=130, 259 ) 260 self._stress_test_round_duration_text = bui.textwidget( 261 parent=self._subcontainer, 262 position=(246 - x_sub, v - 14), 263 size=(60, 28), 264 editable=False, 265 color=(0.3, 1.0, 0.3, 1.0), 266 h_align='right', 267 v_align='center', 268 text=str(self._stress_test_round_duration), 269 padding=2, 270 ) 271 bui.buttonwidget( 272 parent=self._subcontainer, 273 position=(330 - x_sub, v - 11), 274 size=(28, 28), 275 label='-', 276 autoselect=True, 277 on_activate_call=bui.Call( 278 self._stress_test_round_duration_decrement 279 ), 280 repeat=True, 281 enable_sound=True, 282 ) 283 bui.buttonwidget( 284 parent=self._subcontainer, 285 position=(380 - x_sub, v - 11), 286 size=(28, 28), 287 label='+', 288 autoselect=True, 289 on_activate_call=bui.Call( 290 self._stress_test_round_duration_increment 291 ), 292 repeat=True, 293 enable_sound=True, 294 ) 295 v -= 82 296 btn = bui.buttonwidget( 297 parent=self._subcontainer, 298 position=((self._sub_width - button_width) * 0.5, v), 299 size=(button_width, 60), 300 autoselect=True, 301 label=bui.Lstr(resource=f'{self._r}.runStressTestText'), 302 on_activate_call=self._stress_test_pressed, 303 ) 304 bui.widget(btn, show_buffer_bottom=50) 305 306 def _stress_test_player_count_decrement(self) -> None: 307 self._stress_test_player_count = max( 308 1, self._stress_test_player_count - 1 309 ) 310 bui.textwidget( 311 edit=self._stress_test_player_count_text, 312 text=str(self._stress_test_player_count), 313 ) 314 315 def _stress_test_player_count_increment(self) -> None: 316 self._stress_test_player_count = self._stress_test_player_count + 1 317 bui.textwidget( 318 edit=self._stress_test_player_count_text, 319 text=str(self._stress_test_player_count), 320 ) 321 322 def _stress_test_round_duration_decrement(self) -> None: 323 self._stress_test_round_duration = max( 324 10, self._stress_test_round_duration - 10 325 ) 326 bui.textwidget( 327 edit=self._stress_test_round_duration_text, 328 text=str(self._stress_test_round_duration), 329 ) 330 331 def _stress_test_round_duration_increment(self) -> None: 332 self._stress_test_round_duration = self._stress_test_round_duration + 10 333 bui.textwidget( 334 edit=self._stress_test_round_duration_text, 335 text=str(self._stress_test_round_duration), 336 ) 337 338 def _stress_test_game_type_selected(self, game_type: str) -> None: 339 self._stress_test_game_type = game_type 340 341 def _run_cpu_benchmark_pressed(self) -> None: 342 if bui.app.classic is None: 343 logging.warning('run-cpu-benchmark requires classic') 344 return 345 bui.app.classic.run_cpu_benchmark() 346 347 def _run_gpu_benchmark_pressed(self) -> None: 348 if bui.app.classic is None: 349 logging.warning('run-gpu-benchmark requires classic') 350 return 351 bui.app.classic.run_gpu_benchmark() 352 353 def _run_media_reload_benchmark_pressed(self) -> None: 354 if bui.app.classic is None: 355 logging.warning('run-media-reload-benchmark requires classic') 356 return 357 bui.app.classic.run_media_reload_benchmark() 358 359 def _stress_test_pressed(self) -> None: 360 if bui.app.classic is None: 361 logging.warning('stress-test requires classic') 362 return 363 364 bui.app.classic.run_stress_test( 365 playlist_type=self._stress_test_game_type, 366 playlist_name=cast( 367 str, bui.textwidget(query=self._stress_test_playlist_name_field) 368 ), 369 player_count=self._stress_test_player_count, 370 round_duration=self._stress_test_round_duration, 371 ) 372 bui.containerwidget(edit=self._root_widget, transition='out_right') 373 374 def _done(self) -> None: 375 # pylint: disable=cyclic-import 376 from bauiv1lib.settings.advanced import AdvancedSettingsWindow 377 378 # no-op if our underlying widget is dead or on its way out. 379 if not self._root_widget or self._root_widget.transitioning_out: 380 return 381 382 bui.containerwidget(edit=self._root_widget, transition='out_right') 383 assert bui.app.classic is not None 384 bui.app.ui_v1.set_main_menu_window( 385 AdvancedSettingsWindow(transition='in_left').get_root_widget(), 386 from_window=self._root_widget, 387 )
class
DebugWindow(bauiv1._uitypes.Window):
14class DebugWindow(bui.Window): 15 """Window for debugging internal values.""" 16 17 def __init__(self, transition: str | None = 'in_right'): 18 # pylint: disable=too-many-statements 19 # pylint: disable=cyclic-import 20 from bauiv1lib import popup 21 22 assert bui.app.classic is not None 23 bui.app.ui_v1.set_main_menu_location('Benchmarks & Stress Tests') 24 uiscale = bui.app.ui_v1.uiscale 25 self._width = width = 580 26 self._height = height = ( 27 350 28 if uiscale is bui.UIScale.SMALL 29 else 420 if uiscale is bui.UIScale.MEDIUM else 520 30 ) 31 32 self._scroll_width = self._width - 100 33 self._scroll_height = self._height - 120 34 35 self._sub_width = self._scroll_width * 0.95 36 self._sub_height = 520 37 38 self._stress_test_game_type = 'Random' 39 self._stress_test_playlist = '__default__' 40 self._stress_test_player_count = 8 41 self._stress_test_round_duration = 30 42 43 self._r = 'debugWindow' 44 uiscale = bui.app.ui_v1.uiscale 45 super().__init__( 46 root_widget=bui.containerwidget( 47 size=(width, height), 48 transition=transition, 49 scale=( 50 2.35 51 if uiscale is bui.UIScale.SMALL 52 else 1.55 if uiscale is bui.UIScale.MEDIUM else 1.0 53 ), 54 stack_offset=( 55 (0, -30) if uiscale is bui.UIScale.SMALL else (0, 0) 56 ), 57 ) 58 ) 59 60 self._done_button = btn = bui.buttonwidget( 61 parent=self._root_widget, 62 position=(40, height - 67), 63 size=(120, 60), 64 scale=0.8, 65 autoselect=True, 66 label=bui.Lstr(resource='doneText'), 67 on_activate_call=self._done, 68 ) 69 bui.containerwidget(edit=self._root_widget, cancel_button=btn) 70 bui.textwidget( 71 parent=self._root_widget, 72 position=(0, height - 60), 73 size=(width, 30), 74 text=bui.Lstr(resource=f'{self._r}.titleText'), 75 h_align='center', 76 color=bui.app.ui_v1.title_color, 77 v_align='center', 78 maxwidth=260, 79 ) 80 81 self._scrollwidget = bui.scrollwidget( 82 parent=self._root_widget, 83 highlight=False, 84 size=(self._scroll_width, self._scroll_height), 85 position=((self._width - self._scroll_width) * 0.5, 50), 86 ) 87 bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) 88 89 self._subcontainer = bui.containerwidget( 90 parent=self._scrollwidget, 91 size=(self._sub_width, self._sub_height), 92 background=False, 93 ) 94 95 v = self._sub_height - 70 96 button_width = 300 97 btn = bui.buttonwidget( 98 parent=self._subcontainer, 99 position=((self._sub_width - button_width) * 0.5, v), 100 size=(button_width, 60), 101 autoselect=True, 102 label=bui.Lstr(resource=f'{self._r}.runCPUBenchmarkText'), 103 on_activate_call=self._run_cpu_benchmark_pressed, 104 ) 105 bui.widget( 106 edit=btn, up_widget=self._done_button, left_widget=self._done_button 107 ) 108 v -= 60 109 110 bui.buttonwidget( 111 parent=self._subcontainer, 112 position=((self._sub_width - button_width) * 0.5, v), 113 size=(button_width, 60), 114 autoselect=True, 115 label=bui.Lstr(resource=f'{self._r}.runGPUBenchmarkText'), 116 on_activate_call=self._run_gpu_benchmark_pressed, 117 ) 118 v -= 60 119 120 bui.buttonwidget( 121 parent=self._subcontainer, 122 position=((self._sub_width - button_width) * 0.5, v), 123 size=(button_width, 60), 124 autoselect=True, 125 label=bui.Lstr(resource=f'{self._r}.runMediaReloadBenchmarkText'), 126 on_activate_call=self._run_media_reload_benchmark_pressed, 127 ) 128 v -= 60 129 130 bui.textwidget( 131 parent=self._subcontainer, 132 position=(self._sub_width * 0.5, v + 22), 133 size=(0, 0), 134 text=bui.Lstr(resource=f'{self._r}.stressTestTitleText'), 135 maxwidth=200, 136 color=bui.app.ui_v1.heading_color, 137 scale=0.85, 138 h_align='center', 139 v_align='center', 140 ) 141 v -= 45 142 143 x_offs = 165 144 bui.textwidget( 145 parent=self._subcontainer, 146 position=(x_offs - 10, v + 22), 147 size=(0, 0), 148 text=bui.Lstr(resource=f'{self._r}.stressTestPlaylistTypeText'), 149 maxwidth=130, 150 color=bui.app.ui_v1.heading_color, 151 scale=0.65, 152 h_align='right', 153 v_align='center', 154 ) 155 156 popup.PopupMenu( 157 parent=self._subcontainer, 158 position=(x_offs, v), 159 width=150, 160 choices=['Random', 'Teams', 'Free-For-All'], 161 choices_display=[ 162 bui.Lstr(resource=a) 163 for a in [ 164 'randomText', 165 'playModes.teamsText', 166 'playModes.freeForAllText', 167 ] 168 ], 169 current_choice='Auto', 170 on_value_change_call=self._stress_test_game_type_selected, 171 ) 172 173 v -= 46 174 bui.textwidget( 175 parent=self._subcontainer, 176 position=(x_offs - 10, v + 22), 177 size=(0, 0), 178 text=bui.Lstr(resource=f'{self._r}.stressTestPlaylistNameText'), 179 maxwidth=130, 180 color=bui.app.ui_v1.heading_color, 181 scale=0.65, 182 h_align='right', 183 v_align='center', 184 ) 185 186 self._stress_test_playlist_name_field = bui.textwidget( 187 parent=self._subcontainer, 188 position=(x_offs + 5, v - 5), 189 size=(250, 46), 190 text=self._stress_test_playlist, 191 h_align='left', 192 v_align='center', 193 autoselect=True, 194 color=(0.9, 0.9, 0.9, 1.0), 195 description=bui.Lstr( 196 resource=f'{self._r}.stressTestPlaylistDescriptionText' 197 ), 198 editable=True, 199 padding=4, 200 ) 201 v -= 29 202 x_sub = 60 203 204 # Player count. 205 bui.textwidget( 206 parent=self._subcontainer, 207 position=(x_offs - 10, v), 208 size=(0, 0), 209 text=bui.Lstr(resource=f'{self._r}.stressTestPlayerCountText'), 210 color=(0.8, 0.8, 0.8, 1.0), 211 h_align='right', 212 v_align='center', 213 scale=0.65, 214 maxwidth=130, 215 ) 216 self._stress_test_player_count_text = bui.textwidget( 217 parent=self._subcontainer, 218 position=(246 - x_sub, v - 14), 219 size=(60, 28), 220 editable=False, 221 color=(0.3, 1.0, 0.3, 1.0), 222 h_align='right', 223 v_align='center', 224 text=str(self._stress_test_player_count), 225 padding=2, 226 ) 227 bui.buttonwidget( 228 parent=self._subcontainer, 229 position=(330 - x_sub, v - 11), 230 size=(28, 28), 231 label='-', 232 autoselect=True, 233 on_activate_call=bui.Call(self._stress_test_player_count_decrement), 234 repeat=True, 235 enable_sound=True, 236 ) 237 bui.buttonwidget( 238 parent=self._subcontainer, 239 position=(380 - x_sub, v - 11), 240 size=(28, 28), 241 label='+', 242 autoselect=True, 243 on_activate_call=bui.Call(self._stress_test_player_count_increment), 244 repeat=True, 245 enable_sound=True, 246 ) 247 v -= 42 248 249 # Round duration. 250 bui.textwidget( 251 parent=self._subcontainer, 252 position=(x_offs - 10, v), 253 size=(0, 0), 254 text=bui.Lstr(resource=f'{self._r}.stressTestRoundDurationText'), 255 color=(0.8, 0.8, 0.8, 1.0), 256 h_align='right', 257 v_align='center', 258 scale=0.65, 259 maxwidth=130, 260 ) 261 self._stress_test_round_duration_text = bui.textwidget( 262 parent=self._subcontainer, 263 position=(246 - x_sub, v - 14), 264 size=(60, 28), 265 editable=False, 266 color=(0.3, 1.0, 0.3, 1.0), 267 h_align='right', 268 v_align='center', 269 text=str(self._stress_test_round_duration), 270 padding=2, 271 ) 272 bui.buttonwidget( 273 parent=self._subcontainer, 274 position=(330 - x_sub, v - 11), 275 size=(28, 28), 276 label='-', 277 autoselect=True, 278 on_activate_call=bui.Call( 279 self._stress_test_round_duration_decrement 280 ), 281 repeat=True, 282 enable_sound=True, 283 ) 284 bui.buttonwidget( 285 parent=self._subcontainer, 286 position=(380 - x_sub, v - 11), 287 size=(28, 28), 288 label='+', 289 autoselect=True, 290 on_activate_call=bui.Call( 291 self._stress_test_round_duration_increment 292 ), 293 repeat=True, 294 enable_sound=True, 295 ) 296 v -= 82 297 btn = bui.buttonwidget( 298 parent=self._subcontainer, 299 position=((self._sub_width - button_width) * 0.5, v), 300 size=(button_width, 60), 301 autoselect=True, 302 label=bui.Lstr(resource=f'{self._r}.runStressTestText'), 303 on_activate_call=self._stress_test_pressed, 304 ) 305 bui.widget(btn, show_buffer_bottom=50) 306 307 def _stress_test_player_count_decrement(self) -> None: 308 self._stress_test_player_count = max( 309 1, self._stress_test_player_count - 1 310 ) 311 bui.textwidget( 312 edit=self._stress_test_player_count_text, 313 text=str(self._stress_test_player_count), 314 ) 315 316 def _stress_test_player_count_increment(self) -> None: 317 self._stress_test_player_count = self._stress_test_player_count + 1 318 bui.textwidget( 319 edit=self._stress_test_player_count_text, 320 text=str(self._stress_test_player_count), 321 ) 322 323 def _stress_test_round_duration_decrement(self) -> None: 324 self._stress_test_round_duration = max( 325 10, self._stress_test_round_duration - 10 326 ) 327 bui.textwidget( 328 edit=self._stress_test_round_duration_text, 329 text=str(self._stress_test_round_duration), 330 ) 331 332 def _stress_test_round_duration_increment(self) -> None: 333 self._stress_test_round_duration = self._stress_test_round_duration + 10 334 bui.textwidget( 335 edit=self._stress_test_round_duration_text, 336 text=str(self._stress_test_round_duration), 337 ) 338 339 def _stress_test_game_type_selected(self, game_type: str) -> None: 340 self._stress_test_game_type = game_type 341 342 def _run_cpu_benchmark_pressed(self) -> None: 343 if bui.app.classic is None: 344 logging.warning('run-cpu-benchmark requires classic') 345 return 346 bui.app.classic.run_cpu_benchmark() 347 348 def _run_gpu_benchmark_pressed(self) -> None: 349 if bui.app.classic is None: 350 logging.warning('run-gpu-benchmark requires classic') 351 return 352 bui.app.classic.run_gpu_benchmark() 353 354 def _run_media_reload_benchmark_pressed(self) -> None: 355 if bui.app.classic is None: 356 logging.warning('run-media-reload-benchmark requires classic') 357 return 358 bui.app.classic.run_media_reload_benchmark() 359 360 def _stress_test_pressed(self) -> None: 361 if bui.app.classic is None: 362 logging.warning('stress-test requires classic') 363 return 364 365 bui.app.classic.run_stress_test( 366 playlist_type=self._stress_test_game_type, 367 playlist_name=cast( 368 str, bui.textwidget(query=self._stress_test_playlist_name_field) 369 ), 370 player_count=self._stress_test_player_count, 371 round_duration=self._stress_test_round_duration, 372 ) 373 bui.containerwidget(edit=self._root_widget, transition='out_right') 374 375 def _done(self) -> None: 376 # pylint: disable=cyclic-import 377 from bauiv1lib.settings.advanced import AdvancedSettingsWindow 378 379 # no-op if our underlying widget is dead or on its way out. 380 if not self._root_widget or self._root_widget.transitioning_out: 381 return 382 383 bui.containerwidget(edit=self._root_widget, transition='out_right') 384 assert bui.app.classic is not None 385 bui.app.ui_v1.set_main_menu_window( 386 AdvancedSettingsWindow(transition='in_left').get_root_widget(), 387 from_window=self._root_widget, 388 )
Window for debugging internal values.
DebugWindow(transition: str | None = 'in_right')
17 def __init__(self, transition: str | None = 'in_right'): 18 # pylint: disable=too-many-statements 19 # pylint: disable=cyclic-import 20 from bauiv1lib import popup 21 22 assert bui.app.classic is not None 23 bui.app.ui_v1.set_main_menu_location('Benchmarks & Stress Tests') 24 uiscale = bui.app.ui_v1.uiscale 25 self._width = width = 580 26 self._height = height = ( 27 350 28 if uiscale is bui.UIScale.SMALL 29 else 420 if uiscale is bui.UIScale.MEDIUM else 520 30 ) 31 32 self._scroll_width = self._width - 100 33 self._scroll_height = self._height - 120 34 35 self._sub_width = self._scroll_width * 0.95 36 self._sub_height = 520 37 38 self._stress_test_game_type = 'Random' 39 self._stress_test_playlist = '__default__' 40 self._stress_test_player_count = 8 41 self._stress_test_round_duration = 30 42 43 self._r = 'debugWindow' 44 uiscale = bui.app.ui_v1.uiscale 45 super().__init__( 46 root_widget=bui.containerwidget( 47 size=(width, height), 48 transition=transition, 49 scale=( 50 2.35 51 if uiscale is bui.UIScale.SMALL 52 else 1.55 if uiscale is bui.UIScale.MEDIUM else 1.0 53 ), 54 stack_offset=( 55 (0, -30) if uiscale is bui.UIScale.SMALL else (0, 0) 56 ), 57 ) 58 ) 59 60 self._done_button = btn = bui.buttonwidget( 61 parent=self._root_widget, 62 position=(40, height - 67), 63 size=(120, 60), 64 scale=0.8, 65 autoselect=True, 66 label=bui.Lstr(resource='doneText'), 67 on_activate_call=self._done, 68 ) 69 bui.containerwidget(edit=self._root_widget, cancel_button=btn) 70 bui.textwidget( 71 parent=self._root_widget, 72 position=(0, height - 60), 73 size=(width, 30), 74 text=bui.Lstr(resource=f'{self._r}.titleText'), 75 h_align='center', 76 color=bui.app.ui_v1.title_color, 77 v_align='center', 78 maxwidth=260, 79 ) 80 81 self._scrollwidget = bui.scrollwidget( 82 parent=self._root_widget, 83 highlight=False, 84 size=(self._scroll_width, self._scroll_height), 85 position=((self._width - self._scroll_width) * 0.5, 50), 86 ) 87 bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) 88 89 self._subcontainer = bui.containerwidget( 90 parent=self._scrollwidget, 91 size=(self._sub_width, self._sub_height), 92 background=False, 93 ) 94 95 v = self._sub_height - 70 96 button_width = 300 97 btn = bui.buttonwidget( 98 parent=self._subcontainer, 99 position=((self._sub_width - button_width) * 0.5, v), 100 size=(button_width, 60), 101 autoselect=True, 102 label=bui.Lstr(resource=f'{self._r}.runCPUBenchmarkText'), 103 on_activate_call=self._run_cpu_benchmark_pressed, 104 ) 105 bui.widget( 106 edit=btn, up_widget=self._done_button, left_widget=self._done_button 107 ) 108 v -= 60 109 110 bui.buttonwidget( 111 parent=self._subcontainer, 112 position=((self._sub_width - button_width) * 0.5, v), 113 size=(button_width, 60), 114 autoselect=True, 115 label=bui.Lstr(resource=f'{self._r}.runGPUBenchmarkText'), 116 on_activate_call=self._run_gpu_benchmark_pressed, 117 ) 118 v -= 60 119 120 bui.buttonwidget( 121 parent=self._subcontainer, 122 position=((self._sub_width - button_width) * 0.5, v), 123 size=(button_width, 60), 124 autoselect=True, 125 label=bui.Lstr(resource=f'{self._r}.runMediaReloadBenchmarkText'), 126 on_activate_call=self._run_media_reload_benchmark_pressed, 127 ) 128 v -= 60 129 130 bui.textwidget( 131 parent=self._subcontainer, 132 position=(self._sub_width * 0.5, v + 22), 133 size=(0, 0), 134 text=bui.Lstr(resource=f'{self._r}.stressTestTitleText'), 135 maxwidth=200, 136 color=bui.app.ui_v1.heading_color, 137 scale=0.85, 138 h_align='center', 139 v_align='center', 140 ) 141 v -= 45 142 143 x_offs = 165 144 bui.textwidget( 145 parent=self._subcontainer, 146 position=(x_offs - 10, v + 22), 147 size=(0, 0), 148 text=bui.Lstr(resource=f'{self._r}.stressTestPlaylistTypeText'), 149 maxwidth=130, 150 color=bui.app.ui_v1.heading_color, 151 scale=0.65, 152 h_align='right', 153 v_align='center', 154 ) 155 156 popup.PopupMenu( 157 parent=self._subcontainer, 158 position=(x_offs, v), 159 width=150, 160 choices=['Random', 'Teams', 'Free-For-All'], 161 choices_display=[ 162 bui.Lstr(resource=a) 163 for a in [ 164 'randomText', 165 'playModes.teamsText', 166 'playModes.freeForAllText', 167 ] 168 ], 169 current_choice='Auto', 170 on_value_change_call=self._stress_test_game_type_selected, 171 ) 172 173 v -= 46 174 bui.textwidget( 175 parent=self._subcontainer, 176 position=(x_offs - 10, v + 22), 177 size=(0, 0), 178 text=bui.Lstr(resource=f'{self._r}.stressTestPlaylistNameText'), 179 maxwidth=130, 180 color=bui.app.ui_v1.heading_color, 181 scale=0.65, 182 h_align='right', 183 v_align='center', 184 ) 185 186 self._stress_test_playlist_name_field = bui.textwidget( 187 parent=self._subcontainer, 188 position=(x_offs + 5, v - 5), 189 size=(250, 46), 190 text=self._stress_test_playlist, 191 h_align='left', 192 v_align='center', 193 autoselect=True, 194 color=(0.9, 0.9, 0.9, 1.0), 195 description=bui.Lstr( 196 resource=f'{self._r}.stressTestPlaylistDescriptionText' 197 ), 198 editable=True, 199 padding=4, 200 ) 201 v -= 29 202 x_sub = 60 203 204 # Player count. 205 bui.textwidget( 206 parent=self._subcontainer, 207 position=(x_offs - 10, v), 208 size=(0, 0), 209 text=bui.Lstr(resource=f'{self._r}.stressTestPlayerCountText'), 210 color=(0.8, 0.8, 0.8, 1.0), 211 h_align='right', 212 v_align='center', 213 scale=0.65, 214 maxwidth=130, 215 ) 216 self._stress_test_player_count_text = bui.textwidget( 217 parent=self._subcontainer, 218 position=(246 - x_sub, v - 14), 219 size=(60, 28), 220 editable=False, 221 color=(0.3, 1.0, 0.3, 1.0), 222 h_align='right', 223 v_align='center', 224 text=str(self._stress_test_player_count), 225 padding=2, 226 ) 227 bui.buttonwidget( 228 parent=self._subcontainer, 229 position=(330 - x_sub, v - 11), 230 size=(28, 28), 231 label='-', 232 autoselect=True, 233 on_activate_call=bui.Call(self._stress_test_player_count_decrement), 234 repeat=True, 235 enable_sound=True, 236 ) 237 bui.buttonwidget( 238 parent=self._subcontainer, 239 position=(380 - x_sub, v - 11), 240 size=(28, 28), 241 label='+', 242 autoselect=True, 243 on_activate_call=bui.Call(self._stress_test_player_count_increment), 244 repeat=True, 245 enable_sound=True, 246 ) 247 v -= 42 248 249 # Round duration. 250 bui.textwidget( 251 parent=self._subcontainer, 252 position=(x_offs - 10, v), 253 size=(0, 0), 254 text=bui.Lstr(resource=f'{self._r}.stressTestRoundDurationText'), 255 color=(0.8, 0.8, 0.8, 1.0), 256 h_align='right', 257 v_align='center', 258 scale=0.65, 259 maxwidth=130, 260 ) 261 self._stress_test_round_duration_text = bui.textwidget( 262 parent=self._subcontainer, 263 position=(246 - x_sub, v - 14), 264 size=(60, 28), 265 editable=False, 266 color=(0.3, 1.0, 0.3, 1.0), 267 h_align='right', 268 v_align='center', 269 text=str(self._stress_test_round_duration), 270 padding=2, 271 ) 272 bui.buttonwidget( 273 parent=self._subcontainer, 274 position=(330 - x_sub, v - 11), 275 size=(28, 28), 276 label='-', 277 autoselect=True, 278 on_activate_call=bui.Call( 279 self._stress_test_round_duration_decrement 280 ), 281 repeat=True, 282 enable_sound=True, 283 ) 284 bui.buttonwidget( 285 parent=self._subcontainer, 286 position=(380 - x_sub, v - 11), 287 size=(28, 28), 288 label='+', 289 autoselect=True, 290 on_activate_call=bui.Call( 291 self._stress_test_round_duration_increment 292 ), 293 repeat=True, 294 enable_sound=True, 295 ) 296 v -= 82 297 btn = bui.buttonwidget( 298 parent=self._subcontainer, 299 position=((self._sub_width - button_width) * 0.5, v), 300 size=(button_width, 60), 301 autoselect=True, 302 label=bui.Lstr(resource=f'{self._r}.runStressTestText'), 303 on_activate_call=self._stress_test_pressed, 304 ) 305 bui.widget(btn, show_buffer_bottom=50)
Inherited Members
- bauiv1._uitypes.Window
- get_root_widget