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

Window for debugging internal values.

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