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

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
 30            if uiscale is bui.UIScale.MEDIUM
 31            else 520
 32        )
 33
 34        self._scroll_width = self._width - 100
 35        self._scroll_height = self._height - 120
 36
 37        self._sub_width = self._scroll_width * 0.95
 38        self._sub_height = 520
 39
 40        self._stress_test_game_type = 'Random'
 41        self._stress_test_playlist = '__default__'
 42        self._stress_test_player_count = 8
 43        self._stress_test_round_duration = 30
 44
 45        self._r = 'debugWindow'
 46        uiscale = bui.app.ui_v1.uiscale
 47        super().__init__(
 48            root_widget=bui.containerwidget(
 49                size=(width, height),
 50                transition=transition,
 51                scale=(
 52                    2.35
 53                    if uiscale is bui.UIScale.SMALL
 54                    else 1.55
 55                    if uiscale is bui.UIScale.MEDIUM
 56                    else 1.0
 57                ),
 58                stack_offset=(0, -30)
 59                if uiscale is bui.UIScale.SMALL
 60                else (0, 0),
 61            )
 62        )
 63
 64        self._done_button = btn = bui.buttonwidget(
 65            parent=self._root_widget,
 66            position=(40, height - 67),
 67            size=(120, 60),
 68            scale=0.8,
 69            autoselect=True,
 70            label=bui.Lstr(resource='doneText'),
 71            on_activate_call=self._done,
 72        )
 73        bui.containerwidget(edit=self._root_widget, cancel_button=btn)
 74        bui.textwidget(
 75            parent=self._root_widget,
 76            position=(0, height - 60),
 77            size=(width, 30),
 78            text=bui.Lstr(resource=self._r + '.titleText'),
 79            h_align='center',
 80            color=bui.app.ui_v1.title_color,
 81            v_align='center',
 82            maxwidth=260,
 83        )
 84
 85        self._scrollwidget = bui.scrollwidget(
 86            parent=self._root_widget,
 87            highlight=False,
 88            size=(self._scroll_width, self._scroll_height),
 89            position=((self._width - self._scroll_width) * 0.5, 50),
 90        )
 91        bui.containerwidget(edit=self._scrollwidget, claims_left_right=True)
 92
 93        self._subcontainer = bui.containerwidget(
 94            parent=self._scrollwidget,
 95            size=(self._sub_width, self._sub_height),
 96            background=False,
 97        )
 98
 99        v = self._sub_height - 70
100        button_width = 300
101        btn = bui.buttonwidget(
102            parent=self._subcontainer,
103            position=((self._sub_width - button_width) * 0.5, v),
104            size=(button_width, 60),
105            autoselect=True,
106            label=bui.Lstr(resource=self._r + '.runCPUBenchmarkText'),
107            on_activate_call=self._run_cpu_benchmark_pressed,
108        )
109        bui.widget(
110            edit=btn, up_widget=self._done_button, left_widget=self._done_button
111        )
112        v -= 60
113
114        bui.buttonwidget(
115            parent=self._subcontainer,
116            position=((self._sub_width - button_width) * 0.5, v),
117            size=(button_width, 60),
118            autoselect=True,
119            label=bui.Lstr(resource=self._r + '.runGPUBenchmarkText'),
120            on_activate_call=self._run_gpu_benchmark_pressed,
121        )
122        v -= 60
123
124        bui.buttonwidget(
125            parent=self._subcontainer,
126            position=((self._sub_width - button_width) * 0.5, v),
127            size=(button_width, 60),
128            autoselect=True,
129            label=bui.Lstr(resource=self._r + '.runMediaReloadBenchmarkText'),
130            on_activate_call=self._run_media_reload_benchmark_pressed,
131        )
132        v -= 60
133
134        bui.textwidget(
135            parent=self._subcontainer,
136            position=(self._sub_width * 0.5, v + 22),
137            size=(0, 0),
138            text=bui.Lstr(resource=self._r + '.stressTestTitleText'),
139            maxwidth=200,
140            color=bui.app.ui_v1.heading_color,
141            scale=0.85,
142            h_align='center',
143            v_align='center',
144        )
145        v -= 45
146
147        x_offs = 165
148        bui.textwidget(
149            parent=self._subcontainer,
150            position=(x_offs - 10, v + 22),
151            size=(0, 0),
152            text=bui.Lstr(resource=self._r + '.stressTestPlaylistTypeText'),
153            maxwidth=130,
154            color=bui.app.ui_v1.heading_color,
155            scale=0.65,
156            h_align='right',
157            v_align='center',
158        )
159
160        popup.PopupMenu(
161            parent=self._subcontainer,
162            position=(x_offs, v),
163            width=150,
164            choices=['Random', 'Teams', 'Free-For-All'],
165            choices_display=[
166                bui.Lstr(resource=a)
167                for a in [
168                    'randomText',
169                    'playModes.teamsText',
170                    'playModes.freeForAllText',
171                ]
172            ],
173            current_choice='Auto',
174            on_value_change_call=self._stress_test_game_type_selected,
175        )
176
177        v -= 46
178        bui.textwidget(
179            parent=self._subcontainer,
180            position=(x_offs - 10, v + 22),
181            size=(0, 0),
182            text=bui.Lstr(resource=self._r + '.stressTestPlaylistNameText'),
183            maxwidth=130,
184            color=bui.app.ui_v1.heading_color,
185            scale=0.65,
186            h_align='right',
187            v_align='center',
188        )
189
190        self._stress_test_playlist_name_field = bui.textwidget(
191            parent=self._subcontainer,
192            position=(x_offs + 5, v - 5),
193            size=(250, 46),
194            text=self._stress_test_playlist,
195            h_align='left',
196            v_align='center',
197            autoselect=True,
198            color=(0.9, 0.9, 0.9, 1.0),
199            description=bui.Lstr(
200                resource=self._r + '.stressTestPlaylistDescriptionText'
201            ),
202            editable=True,
203            padding=4,
204        )
205        v -= 29
206        x_sub = 60
207
208        # Player count.
209        bui.textwidget(
210            parent=self._subcontainer,
211            position=(x_offs - 10, v),
212            size=(0, 0),
213            text=bui.Lstr(resource=self._r + '.stressTestPlayerCountText'),
214            color=(0.8, 0.8, 0.8, 1.0),
215            h_align='right',
216            v_align='center',
217            scale=0.65,
218            maxwidth=130,
219        )
220        self._stress_test_player_count_text = bui.textwidget(
221            parent=self._subcontainer,
222            position=(246 - x_sub, v - 14),
223            size=(60, 28),
224            editable=False,
225            color=(0.3, 1.0, 0.3, 1.0),
226            h_align='right',
227            v_align='center',
228            text=str(self._stress_test_player_count),
229            padding=2,
230        )
231        bui.buttonwidget(
232            parent=self._subcontainer,
233            position=(330 - x_sub, v - 11),
234            size=(28, 28),
235            label='-',
236            autoselect=True,
237            on_activate_call=bui.Call(self._stress_test_player_count_decrement),
238            repeat=True,
239            enable_sound=True,
240        )
241        bui.buttonwidget(
242            parent=self._subcontainer,
243            position=(380 - x_sub, v - 11),
244            size=(28, 28),
245            label='+',
246            autoselect=True,
247            on_activate_call=bui.Call(self._stress_test_player_count_increment),
248            repeat=True,
249            enable_sound=True,
250        )
251        v -= 42
252
253        # Round duration.
254        bui.textwidget(
255            parent=self._subcontainer,
256            position=(x_offs - 10, v),
257            size=(0, 0),
258            text=bui.Lstr(resource=self._r + '.stressTestRoundDurationText'),
259            color=(0.8, 0.8, 0.8, 1.0),
260            h_align='right',
261            v_align='center',
262            scale=0.65,
263            maxwidth=130,
264        )
265        self._stress_test_round_duration_text = bui.textwidget(
266            parent=self._subcontainer,
267            position=(246 - x_sub, v - 14),
268            size=(60, 28),
269            editable=False,
270            color=(0.3, 1.0, 0.3, 1.0),
271            h_align='right',
272            v_align='center',
273            text=str(self._stress_test_round_duration),
274            padding=2,
275        )
276        bui.buttonwidget(
277            parent=self._subcontainer,
278            position=(330 - x_sub, v - 11),
279            size=(28, 28),
280            label='-',
281            autoselect=True,
282            on_activate_call=bui.Call(
283                self._stress_test_round_duration_decrement
284            ),
285            repeat=True,
286            enable_sound=True,
287        )
288        bui.buttonwidget(
289            parent=self._subcontainer,
290            position=(380 - x_sub, v - 11),
291            size=(28, 28),
292            label='+',
293            autoselect=True,
294            on_activate_call=bui.Call(
295                self._stress_test_round_duration_increment
296            ),
297            repeat=True,
298            enable_sound=True,
299        )
300        v -= 82
301        btn = bui.buttonwidget(
302            parent=self._subcontainer,
303            position=((self._sub_width - button_width) * 0.5, v),
304            size=(button_width, 60),
305            autoselect=True,
306            label=bui.Lstr(resource=self._r + '.runStressTestText'),
307            on_activate_call=self._stress_test_pressed,
308        )
309        bui.widget(btn, show_buffer_bottom=50)
Inherited Members
bauiv1._uitypes.Window
get_root_widget