bauiv1lib.help

Provides help related ui.

  1# Released under the MIT License. See LICENSE for details.
  2#
  3"""Provides help related ui."""
  4
  5from __future__ import annotations
  6
  7from typing import override
  8
  9import random
 10
 11import bauiv1 as bui
 12
 13
 14class HelpWindow(bui.MainWindow):
 15    """A window providing help on how to play."""
 16
 17    def __init__(
 18        self,
 19        transition: str | None = 'in_right',
 20        origin_widget: bui.Widget | None = None,
 21    ):
 22        # pylint: disable=too-many-statements
 23        # pylint: disable=too-many-locals
 24
 25        bui.set_analytics_screen('Help Window')
 26
 27        self._r = 'helpWindow'
 28
 29        getres = bui.app.lang.get_resource
 30
 31        assert bui.app.classic is not None
 32        uiscale = bui.app.ui_v1.uiscale
 33        width = 1050 if uiscale is bui.UIScale.SMALL else 750
 34        xoffs = 70 if uiscale is bui.UIScale.SMALL else 0
 35        yoffs = -33 if uiscale is bui.UIScale.SMALL else 0
 36
 37        height = (
 38            500
 39            if uiscale is bui.UIScale.SMALL
 40            else 530 if uiscale is bui.UIScale.MEDIUM else 600
 41        )
 42
 43        super().__init__(
 44            root_widget=bui.containerwidget(
 45                size=(width, height),
 46                toolbar_visibility=(
 47                    'menu_minimal'
 48                    if uiscale is bui.UIScale.SMALL
 49                    else 'menu_full'
 50                ),
 51                scale=(
 52                    1.55
 53                    if uiscale is bui.UIScale.SMALL
 54                    else 1.15 if uiscale is bui.UIScale.MEDIUM else 1.0
 55                ),
 56                stack_offset=(
 57                    (0, 0)
 58                    if uiscale is bui.UIScale.SMALL
 59                    else (0, 15) if uiscale is bui.UIScale.MEDIUM else (0, 0)
 60                ),
 61            ),
 62            transition=transition,
 63            origin_widget=origin_widget,
 64        )
 65
 66        bui.textwidget(
 67            parent=self._root_widget,
 68            position=(
 69                0,
 70                height - (50 if uiscale is bui.UIScale.SMALL else 45) + yoffs,
 71            ),
 72            size=(width, 25),
 73            text=bui.Lstr(
 74                resource=f'{self._r}.titleText',
 75                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
 76            ),
 77            color=bui.app.ui_v1.title_color,
 78            h_align='center',
 79            v_align='top',
 80        )
 81
 82        self._scrollwidget = bui.scrollwidget(
 83            parent=self._root_widget,
 84            position=(
 85                44 + xoffs,
 86                (92 if uiscale is bui.UIScale.SMALL else 55) + yoffs,
 87            ),
 88            simple_culling_v=100.0,
 89            size=(
 90                width - (88 + 2 * xoffs),
 91                height - (150 if uiscale is bui.UIScale.SMALL else 120),
 92            ),
 93            capture_arrows=True,
 94            border_opacity=0.4,
 95        )
 96
 97        bui.widget(
 98            edit=self._scrollwidget,
 99            right_widget=bui.get_special_widget('squad_button'),
100        )
101        bui.containerwidget(
102            edit=self._root_widget, selected_child=self._scrollwidget
103        )
104
105        # ugly: create this last so it gets first dibs at touch events (since
106        # we have it close to the scroll widget)
107        if uiscale is bui.UIScale.SMALL:
108            bui.containerwidget(
109                edit=self._root_widget, on_cancel_call=self.main_window_back
110            )
111            bui.widget(
112                edit=self._scrollwidget,
113                left_widget=bui.get_special_widget('back_button'),
114            )
115        else:
116            btn = bui.buttonwidget(
117                parent=self._root_widget,
118                position=(xoffs + 50, height - 55),
119                size=(60, 55),
120                scale=0.8,
121                label=bui.charstr(bui.SpecialChar.BACK),
122                button_type='backSmall',
123                extra_touch_border_scale=2.0,
124                autoselect=True,
125                on_activate_call=self.main_window_back,
126            )
127            bui.containerwidget(edit=self._root_widget, cancel_button=btn)
128
129        self._sub_width = 810 if uiscale is bui.UIScale.SMALL else 660
130        self._sub_height = (
131            1590
132            + bui.app.lang.get_resource(f'{self._r}.someDaysExtraSpace')
133            + bui.app.lang.get_resource(
134                f'{self._r}.orPunchingSomethingExtraSpace'
135            )
136        )
137
138        self._subcontainer = bui.containerwidget(
139            parent=self._scrollwidget,
140            size=(self._sub_width, self._sub_height),
141            background=False,
142            claims_left_right=False,
143        )
144
145        spacing = 1.0
146        h = self._sub_width * 0.5
147        v = self._sub_height - 55
148        logo_tex = bui.gettexture('logo')
149        icon_buffer = 1.1
150        header = (0.7, 1.0, 0.7, 1.0)
151        header2 = (0.8, 0.8, 1.0, 1.0)
152        paragraph = (0.8, 0.8, 1.0, 1.0)
153
154        txt = bui.Lstr(
155            resource=f'{self._r}.welcomeText',
156            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
157        ).evaluate()
158        txt_scale = 1.4
159        txt_maxwidth = 480
160        bui.textwidget(
161            parent=self._subcontainer,
162            position=(h, v),
163            size=(0, 0),
164            scale=txt_scale,
165            flatness=0.5,
166            res_scale=1.5,
167            text=txt,
168            h_align='center',
169            color=header,
170            v_align='center',
171            maxwidth=txt_maxwidth,
172        )
173        txt_width = min(
174            txt_maxwidth,
175            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
176        )
177
178        icon_size = 70
179        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
180        bui.imagewidget(
181            parent=self._subcontainer,
182            size=(icon_size, icon_size),
183            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
184            texture=logo_tex,
185        )
186
187        app = bui.app
188        assert app.classic is not None
189
190        v -= spacing * 50.0
191        txt = bui.Lstr(resource=f'{self._r}.someDaysText').evaluate()
192        bui.textwidget(
193            parent=self._subcontainer,
194            position=(h, v),
195            size=(0, 0),
196            scale=1.2,
197            maxwidth=self._sub_width * 0.9,
198            text=txt,
199            h_align='center',
200            color=paragraph,
201            v_align='center',
202            flatness=1.0,
203        )
204        v -= spacing * 25.0 + getres(f'{self._r}.someDaysExtraSpace')
205        txt_scale = 0.66
206        txt = bui.Lstr(resource=f'{self._r}.orPunchingSomethingText').evaluate()
207        bui.textwidget(
208            parent=self._subcontainer,
209            position=(h, v),
210            size=(0, 0),
211            scale=txt_scale,
212            maxwidth=self._sub_width * 0.9,
213            text=txt,
214            h_align='center',
215            color=paragraph,
216            v_align='center',
217            flatness=1.0,
218        )
219        v -= spacing * 27.0 + getres(f'{self._r}.orPunchingSomethingExtraSpace')
220        txt_scale = 1.0
221        txt = bui.Lstr(
222            resource=f'{self._r}.canHelpText',
223            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
224        ).evaluate()
225        bui.textwidget(
226            parent=self._subcontainer,
227            position=(h, v),
228            size=(0, 0),
229            scale=txt_scale,
230            flatness=1.0,
231            text=txt,
232            h_align='center',
233            color=paragraph,
234            v_align='center',
235        )
236
237        v -= spacing * 70.0
238        txt_scale = 1.0
239        txt = bui.Lstr(resource=f'{self._r}.toGetTheMostText').evaluate()
240        bui.textwidget(
241            parent=self._subcontainer,
242            position=(h, v),
243            size=(0, 0),
244            scale=txt_scale,
245            maxwidth=self._sub_width * 0.9,
246            text=txt,
247            h_align='center',
248            color=header,
249            v_align='center',
250            flatness=1.0,
251        )
252
253        v -= spacing * 40.0
254        txt_scale = 0.74
255        txt = bui.Lstr(resource=f'{self._r}.friendsText').evaluate()
256        hval2 = h - 220
257        bui.textwidget(
258            parent=self._subcontainer,
259            position=(hval2, v),
260            size=(0, 0),
261            scale=txt_scale,
262            maxwidth=100,
263            text=txt,
264            h_align='right',
265            color=header,
266            v_align='center',
267            flatness=1.0,
268        )
269
270        txt = bui.Lstr(
271            resource=f'{self._r}.friendsGoodText',
272            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
273        ).evaluate()
274        txt_scale = 0.7
275        bui.textwidget(
276            parent=self._subcontainer,
277            position=(hval2 + 10, v + 8),
278            size=(0, 0),
279            scale=txt_scale,
280            maxwidth=500,
281            text=txt,
282            h_align='left',
283            color=paragraph,
284            flatness=1.0,
285        )
286
287        app = bui.app
288
289        v -= spacing * 45.0
290        txt = (
291            bui.Lstr(resource=f'{self._r}.devicesText').evaluate()
292            if app.env.vr
293            else bui.Lstr(resource=f'{self._r}.controllersText').evaluate()
294        )
295        txt_scale = 0.74
296        hval2 = h - 220
297        bui.textwidget(
298            parent=self._subcontainer,
299            position=(hval2, v),
300            size=(0, 0),
301            scale=txt_scale,
302            maxwidth=100,
303            text=txt,
304            h_align='right',
305            v_align='center',
306            color=header,
307            flatness=1.0,
308        )
309
310        txt_scale = 0.7
311        if not app.env.vr:
312            infotxt = '.controllersInfoText'
313            txt = bui.Lstr(
314                resource=self._r + infotxt,
315                fallback_resource=f'{self._r}.controllersInfoText',
316                subs=[
317                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
318                    ('${REMOTE_APP_NAME}', bui.get_remote_app_name()),
319                ],
320            ).evaluate()
321        else:
322            txt = bui.Lstr(
323                resource=f'{self._r}.devicesInfoText',
324                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
325            ).evaluate()
326
327        bui.textwidget(
328            parent=self._subcontainer,
329            position=(hval2 + 10, v + 8),
330            size=(0, 0),
331            scale=txt_scale,
332            maxwidth=500,
333            max_height=105,
334            text=txt,
335            h_align='left',
336            color=paragraph,
337            flatness=1.0,
338        )
339
340        v -= spacing * 150.0
341
342        txt = bui.Lstr(resource=f'{self._r}.controlsText').evaluate()
343        txt_scale = 1.4
344        txt_maxwidth = 480
345        bui.textwidget(
346            parent=self._subcontainer,
347            position=(h, v),
348            size=(0, 0),
349            scale=txt_scale,
350            flatness=0.5,
351            text=txt,
352            h_align='center',
353            color=header,
354            v_align='center',
355            res_scale=1.5,
356            maxwidth=txt_maxwidth,
357        )
358        txt_width = min(
359            txt_maxwidth,
360            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
361        )
362        icon_size = 70
363
364        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
365        bui.imagewidget(
366            parent=self._subcontainer,
367            size=(icon_size, icon_size),
368            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
369            texture=logo_tex,
370        )
371
372        v -= spacing * 45.0
373
374        txt_scale = 0.7
375        txt = bui.Lstr(
376            resource=f'{self._r}.controlsSubtitleText',
377            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
378        ).evaluate()
379        bui.textwidget(
380            parent=self._subcontainer,
381            position=(h, v),
382            size=(0, 0),
383            scale=txt_scale,
384            maxwidth=self._sub_width * 0.9,
385            flatness=1.0,
386            text=txt,
387            h_align='center',
388            color=paragraph,
389            v_align='center',
390        )
391        v -= spacing * 160.0
392
393        sep = 70
394        icon_size = 100
395        # icon_size_2 = 30
396        hval2 = h - sep
397        vval2 = v
398        bui.buttonwidget(
399            parent=self._subcontainer,
400            label='',
401            size=(icon_size, icon_size),
402            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
403            texture=bui.gettexture('buttonPunch'),
404            color=(1, 0.7, 0.3),
405            selectable=False,
406            enable_sound=False,
407            on_activate_call=bui.WeakCall(self._play_sound, 'spazAttack0', 4),
408        )
409
410        txt_scale = getres(f'{self._r}.punchInfoTextScale')
411        txt = bui.Lstr(resource=f'{self._r}.punchInfoText').evaluate()
412        bui.textwidget(
413            parent=self._subcontainer,
414            position=(h - sep - 185 + 70, v + 120),
415            size=(0, 0),
416            scale=txt_scale,
417            flatness=1.0,
418            text=txt,
419            h_align='center',
420            color=(1, 0.7, 0.3, 1.0),
421            v_align='top',
422        )
423
424        hval2 = h + sep
425        vval2 = v
426        bui.buttonwidget(
427            parent=self._subcontainer,
428            label='',
429            size=(icon_size, icon_size),
430            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
431            texture=bui.gettexture('buttonBomb'),
432            color=(1, 0.3, 0.3),
433            selectable=False,
434            enable_sound=False,
435            on_activate_call=bui.WeakCall(self._play_sound, 'explosion0', 5),
436        )
437
438        txt = bui.Lstr(resource=f'{self._r}.bombInfoText').evaluate()
439        txt_scale = getres(f'{self._r}.bombInfoTextScale')
440        bui.textwidget(
441            parent=self._subcontainer,
442            position=(h + sep + 50 + 60, v - 35),
443            size=(0, 0),
444            scale=txt_scale,
445            flatness=1.0,
446            maxwidth=270,
447            text=txt,
448            h_align='center',
449            color=(1, 0.3, 0.3, 1.0),
450            v_align='top',
451        )
452
453        hval2 = h
454        vval2 = v + sep
455        bui.buttonwidget(
456            parent=self._subcontainer,
457            label='',
458            size=(icon_size, icon_size),
459            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
460            texture=bui.gettexture('buttonPickUp'),
461            color=(0.5, 0.5, 1),
462            selectable=False,
463            enable_sound=False,
464            on_activate_call=bui.WeakCall(self._play_sound, 'spazPickup0', 1),
465        )
466
467        txtl = bui.Lstr(resource=f'{self._r}.pickUpInfoText')
468        txt_scale = getres(f'{self._r}.pickUpInfoTextScale')
469        bui.textwidget(
470            parent=self._subcontainer,
471            position=(h + 60 + 120, v + sep + 50),
472            size=(0, 0),
473            scale=txt_scale,
474            flatness=1.0,
475            text=txtl,
476            h_align='center',
477            color=(0.5, 0.5, 1, 1.0),
478            v_align='top',
479        )
480
481        hval2 = h
482        vval2 = v - sep
483        bui.buttonwidget(
484            parent=self._subcontainer,
485            label='',
486            size=(icon_size, icon_size),
487            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
488            texture=bui.gettexture('buttonJump'),
489            color=(0.4, 1, 0.4),
490            selectable=False,
491            enable_sound=False,
492            on_activate_call=bui.WeakCall(self._play_sound, 'spazJump0', 4),
493        )
494
495        txt = bui.Lstr(resource=f'{self._r}.jumpInfoText').evaluate()
496        txt_scale = getres(f'{self._r}.jumpInfoTextScale')
497        bui.textwidget(
498            parent=self._subcontainer,
499            position=(h - 250 + 75, v - sep - 15 + 30),
500            size=(0, 0),
501            scale=txt_scale,
502            flatness=1.0,
503            text=txt,
504            h_align='center',
505            color=(0.4, 1, 0.4, 1.0),
506            v_align='top',
507        )
508
509        txt = bui.Lstr(resource=f'{self._r}.runInfoText').evaluate()
510        txt_scale = getres(f'{self._r}.runInfoTextScale')
511        bui.textwidget(
512            parent=self._subcontainer,
513            position=(h, v - sep - 100),
514            size=(0, 0),
515            scale=txt_scale,
516            maxwidth=self._sub_width * 0.93,
517            flatness=1.0,
518            text=txt,
519            h_align='center',
520            color=(0.7, 0.7, 1.0, 1.0),
521            v_align='center',
522        )
523
524        v -= spacing * 280.0
525
526        txt = bui.Lstr(resource=f'{self._r}.powerupsText').evaluate()
527        txt_scale = 1.4
528        txt_maxwidth = 480
529        bui.textwidget(
530            parent=self._subcontainer,
531            position=(h, v),
532            size=(0, 0),
533            scale=txt_scale,
534            flatness=0.5,
535            text=txt,
536            h_align='center',
537            color=header,
538            v_align='center',
539            maxwidth=txt_maxwidth,
540        )
541        txt_width = min(
542            txt_maxwidth,
543            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
544        )
545        icon_size = 70
546        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
547        bui.imagewidget(
548            parent=self._subcontainer,
549            size=(icon_size, icon_size),
550            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
551            texture=logo_tex,
552        )
553
554        v -= spacing * 50.0
555        txt_scale = getres(f'{self._r}.powerupsSubtitleTextScale')
556        txt = bui.Lstr(resource=f'{self._r}.powerupsSubtitleText').evaluate()
557        bui.textwidget(
558            parent=self._subcontainer,
559            position=(h, v),
560            size=(0, 0),
561            scale=txt_scale,
562            maxwidth=self._sub_width * 0.9,
563            text=txt,
564            h_align='center',
565            color=paragraph,
566            v_align='center',
567            flatness=1.0,
568        )
569
570        v -= spacing * 1.0
571
572        mm1 = -270
573        mm2 = -215
574        mm3 = 0
575        icon_size = 50
576        shadow_size = 80
577        shadow_offs_x = 3
578        shadow_offs_y = -4
579        t_big = 1.1
580        t_small = 0.65
581
582        shadow_tex = bui.gettexture('shadowSharp')
583
584        for tex in [
585            'powerupPunch',
586            'powerupShield',
587            'powerupBomb',
588            'powerupHealth',
589            'powerupIceBombs',
590            'powerupImpactBombs',
591            'powerupStickyBombs',
592            'powerupLandMines',
593            'powerupCurse',
594        ]:
595            name = bui.Lstr(resource=f'{self._r}.' + tex + 'NameText')
596            desc = bui.Lstr(resource=f'{self._r}.' + tex + 'DescriptionText')
597
598            v -= spacing * 60.0
599
600            bui.imagewidget(
601                parent=self._subcontainer,
602                size=(shadow_size, shadow_size),
603                position=(
604                    h + mm1 + shadow_offs_x - 0.5 * shadow_size,
605                    v + shadow_offs_y - 0.5 * shadow_size,
606                ),
607                texture=shadow_tex,
608                color=(0, 0, 0),
609                opacity=0.5,
610            )
611            bui.imagewidget(
612                parent=self._subcontainer,
613                size=(icon_size, icon_size),
614                position=(h + mm1 - 0.5 * icon_size, v - 0.5 * icon_size),
615                texture=bui.gettexture(tex),
616            )
617
618            txt_scale = t_big
619            txtl = name
620            bui.textwidget(
621                parent=self._subcontainer,
622                position=(h + mm2, v + 3),
623                size=(0, 0),
624                scale=txt_scale,
625                maxwidth=200,
626                flatness=1.0,
627                text=txtl,
628                h_align='left',
629                color=header2,
630                v_align='center',
631            )
632            txt_scale = t_small
633            txtl = desc
634            bui.textwidget(
635                parent=self._subcontainer,
636                position=(h + mm3, v),
637                size=(0, 0),
638                scale=txt_scale,
639                maxwidth=300,
640                flatness=1.0,
641                text=txtl,
642                h_align='left',
643                color=paragraph,
644                v_align='center',
645                res_scale=0.5,
646            )
647
648    def _play_sound(self, text: str, num: int) -> None:
649        bui.getsound(text + str(random.randint(1, num))).play()
650
651    @override
652    def get_main_window_state(self) -> bui.MainWindowState:
653        # Support recreating our window for back/refresh purposes.
654        cls = type(self)
655        return bui.BasicMainWindowState(
656            create_call=lambda transition, origin_widget: cls(
657                transition=transition, origin_widget=origin_widget
658            )
659        )
class HelpWindow(bauiv1._uitypes.MainWindow):
 15class HelpWindow(bui.MainWindow):
 16    """A window providing help on how to play."""
 17
 18    def __init__(
 19        self,
 20        transition: str | None = 'in_right',
 21        origin_widget: bui.Widget | None = None,
 22    ):
 23        # pylint: disable=too-many-statements
 24        # pylint: disable=too-many-locals
 25
 26        bui.set_analytics_screen('Help Window')
 27
 28        self._r = 'helpWindow'
 29
 30        getres = bui.app.lang.get_resource
 31
 32        assert bui.app.classic is not None
 33        uiscale = bui.app.ui_v1.uiscale
 34        width = 1050 if uiscale is bui.UIScale.SMALL else 750
 35        xoffs = 70 if uiscale is bui.UIScale.SMALL else 0
 36        yoffs = -33 if uiscale is bui.UIScale.SMALL else 0
 37
 38        height = (
 39            500
 40            if uiscale is bui.UIScale.SMALL
 41            else 530 if uiscale is bui.UIScale.MEDIUM else 600
 42        )
 43
 44        super().__init__(
 45            root_widget=bui.containerwidget(
 46                size=(width, height),
 47                toolbar_visibility=(
 48                    'menu_minimal'
 49                    if uiscale is bui.UIScale.SMALL
 50                    else 'menu_full'
 51                ),
 52                scale=(
 53                    1.55
 54                    if uiscale is bui.UIScale.SMALL
 55                    else 1.15 if uiscale is bui.UIScale.MEDIUM else 1.0
 56                ),
 57                stack_offset=(
 58                    (0, 0)
 59                    if uiscale is bui.UIScale.SMALL
 60                    else (0, 15) if uiscale is bui.UIScale.MEDIUM else (0, 0)
 61                ),
 62            ),
 63            transition=transition,
 64            origin_widget=origin_widget,
 65        )
 66
 67        bui.textwidget(
 68            parent=self._root_widget,
 69            position=(
 70                0,
 71                height - (50 if uiscale is bui.UIScale.SMALL else 45) + yoffs,
 72            ),
 73            size=(width, 25),
 74            text=bui.Lstr(
 75                resource=f'{self._r}.titleText',
 76                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
 77            ),
 78            color=bui.app.ui_v1.title_color,
 79            h_align='center',
 80            v_align='top',
 81        )
 82
 83        self._scrollwidget = bui.scrollwidget(
 84            parent=self._root_widget,
 85            position=(
 86                44 + xoffs,
 87                (92 if uiscale is bui.UIScale.SMALL else 55) + yoffs,
 88            ),
 89            simple_culling_v=100.0,
 90            size=(
 91                width - (88 + 2 * xoffs),
 92                height - (150 if uiscale is bui.UIScale.SMALL else 120),
 93            ),
 94            capture_arrows=True,
 95            border_opacity=0.4,
 96        )
 97
 98        bui.widget(
 99            edit=self._scrollwidget,
100            right_widget=bui.get_special_widget('squad_button'),
101        )
102        bui.containerwidget(
103            edit=self._root_widget, selected_child=self._scrollwidget
104        )
105
106        # ugly: create this last so it gets first dibs at touch events (since
107        # we have it close to the scroll widget)
108        if uiscale is bui.UIScale.SMALL:
109            bui.containerwidget(
110                edit=self._root_widget, on_cancel_call=self.main_window_back
111            )
112            bui.widget(
113                edit=self._scrollwidget,
114                left_widget=bui.get_special_widget('back_button'),
115            )
116        else:
117            btn = bui.buttonwidget(
118                parent=self._root_widget,
119                position=(xoffs + 50, height - 55),
120                size=(60, 55),
121                scale=0.8,
122                label=bui.charstr(bui.SpecialChar.BACK),
123                button_type='backSmall',
124                extra_touch_border_scale=2.0,
125                autoselect=True,
126                on_activate_call=self.main_window_back,
127            )
128            bui.containerwidget(edit=self._root_widget, cancel_button=btn)
129
130        self._sub_width = 810 if uiscale is bui.UIScale.SMALL else 660
131        self._sub_height = (
132            1590
133            + bui.app.lang.get_resource(f'{self._r}.someDaysExtraSpace')
134            + bui.app.lang.get_resource(
135                f'{self._r}.orPunchingSomethingExtraSpace'
136            )
137        )
138
139        self._subcontainer = bui.containerwidget(
140            parent=self._scrollwidget,
141            size=(self._sub_width, self._sub_height),
142            background=False,
143            claims_left_right=False,
144        )
145
146        spacing = 1.0
147        h = self._sub_width * 0.5
148        v = self._sub_height - 55
149        logo_tex = bui.gettexture('logo')
150        icon_buffer = 1.1
151        header = (0.7, 1.0, 0.7, 1.0)
152        header2 = (0.8, 0.8, 1.0, 1.0)
153        paragraph = (0.8, 0.8, 1.0, 1.0)
154
155        txt = bui.Lstr(
156            resource=f'{self._r}.welcomeText',
157            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
158        ).evaluate()
159        txt_scale = 1.4
160        txt_maxwidth = 480
161        bui.textwidget(
162            parent=self._subcontainer,
163            position=(h, v),
164            size=(0, 0),
165            scale=txt_scale,
166            flatness=0.5,
167            res_scale=1.5,
168            text=txt,
169            h_align='center',
170            color=header,
171            v_align='center',
172            maxwidth=txt_maxwidth,
173        )
174        txt_width = min(
175            txt_maxwidth,
176            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
177        )
178
179        icon_size = 70
180        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
181        bui.imagewidget(
182            parent=self._subcontainer,
183            size=(icon_size, icon_size),
184            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
185            texture=logo_tex,
186        )
187
188        app = bui.app
189        assert app.classic is not None
190
191        v -= spacing * 50.0
192        txt = bui.Lstr(resource=f'{self._r}.someDaysText').evaluate()
193        bui.textwidget(
194            parent=self._subcontainer,
195            position=(h, v),
196            size=(0, 0),
197            scale=1.2,
198            maxwidth=self._sub_width * 0.9,
199            text=txt,
200            h_align='center',
201            color=paragraph,
202            v_align='center',
203            flatness=1.0,
204        )
205        v -= spacing * 25.0 + getres(f'{self._r}.someDaysExtraSpace')
206        txt_scale = 0.66
207        txt = bui.Lstr(resource=f'{self._r}.orPunchingSomethingText').evaluate()
208        bui.textwidget(
209            parent=self._subcontainer,
210            position=(h, v),
211            size=(0, 0),
212            scale=txt_scale,
213            maxwidth=self._sub_width * 0.9,
214            text=txt,
215            h_align='center',
216            color=paragraph,
217            v_align='center',
218            flatness=1.0,
219        )
220        v -= spacing * 27.0 + getres(f'{self._r}.orPunchingSomethingExtraSpace')
221        txt_scale = 1.0
222        txt = bui.Lstr(
223            resource=f'{self._r}.canHelpText',
224            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
225        ).evaluate()
226        bui.textwidget(
227            parent=self._subcontainer,
228            position=(h, v),
229            size=(0, 0),
230            scale=txt_scale,
231            flatness=1.0,
232            text=txt,
233            h_align='center',
234            color=paragraph,
235            v_align='center',
236        )
237
238        v -= spacing * 70.0
239        txt_scale = 1.0
240        txt = bui.Lstr(resource=f'{self._r}.toGetTheMostText').evaluate()
241        bui.textwidget(
242            parent=self._subcontainer,
243            position=(h, v),
244            size=(0, 0),
245            scale=txt_scale,
246            maxwidth=self._sub_width * 0.9,
247            text=txt,
248            h_align='center',
249            color=header,
250            v_align='center',
251            flatness=1.0,
252        )
253
254        v -= spacing * 40.0
255        txt_scale = 0.74
256        txt = bui.Lstr(resource=f'{self._r}.friendsText').evaluate()
257        hval2 = h - 220
258        bui.textwidget(
259            parent=self._subcontainer,
260            position=(hval2, v),
261            size=(0, 0),
262            scale=txt_scale,
263            maxwidth=100,
264            text=txt,
265            h_align='right',
266            color=header,
267            v_align='center',
268            flatness=1.0,
269        )
270
271        txt = bui.Lstr(
272            resource=f'{self._r}.friendsGoodText',
273            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
274        ).evaluate()
275        txt_scale = 0.7
276        bui.textwidget(
277            parent=self._subcontainer,
278            position=(hval2 + 10, v + 8),
279            size=(0, 0),
280            scale=txt_scale,
281            maxwidth=500,
282            text=txt,
283            h_align='left',
284            color=paragraph,
285            flatness=1.0,
286        )
287
288        app = bui.app
289
290        v -= spacing * 45.0
291        txt = (
292            bui.Lstr(resource=f'{self._r}.devicesText').evaluate()
293            if app.env.vr
294            else bui.Lstr(resource=f'{self._r}.controllersText').evaluate()
295        )
296        txt_scale = 0.74
297        hval2 = h - 220
298        bui.textwidget(
299            parent=self._subcontainer,
300            position=(hval2, v),
301            size=(0, 0),
302            scale=txt_scale,
303            maxwidth=100,
304            text=txt,
305            h_align='right',
306            v_align='center',
307            color=header,
308            flatness=1.0,
309        )
310
311        txt_scale = 0.7
312        if not app.env.vr:
313            infotxt = '.controllersInfoText'
314            txt = bui.Lstr(
315                resource=self._r + infotxt,
316                fallback_resource=f'{self._r}.controllersInfoText',
317                subs=[
318                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
319                    ('${REMOTE_APP_NAME}', bui.get_remote_app_name()),
320                ],
321            ).evaluate()
322        else:
323            txt = bui.Lstr(
324                resource=f'{self._r}.devicesInfoText',
325                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
326            ).evaluate()
327
328        bui.textwidget(
329            parent=self._subcontainer,
330            position=(hval2 + 10, v + 8),
331            size=(0, 0),
332            scale=txt_scale,
333            maxwidth=500,
334            max_height=105,
335            text=txt,
336            h_align='left',
337            color=paragraph,
338            flatness=1.0,
339        )
340
341        v -= spacing * 150.0
342
343        txt = bui.Lstr(resource=f'{self._r}.controlsText').evaluate()
344        txt_scale = 1.4
345        txt_maxwidth = 480
346        bui.textwidget(
347            parent=self._subcontainer,
348            position=(h, v),
349            size=(0, 0),
350            scale=txt_scale,
351            flatness=0.5,
352            text=txt,
353            h_align='center',
354            color=header,
355            v_align='center',
356            res_scale=1.5,
357            maxwidth=txt_maxwidth,
358        )
359        txt_width = min(
360            txt_maxwidth,
361            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
362        )
363        icon_size = 70
364
365        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
366        bui.imagewidget(
367            parent=self._subcontainer,
368            size=(icon_size, icon_size),
369            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
370            texture=logo_tex,
371        )
372
373        v -= spacing * 45.0
374
375        txt_scale = 0.7
376        txt = bui.Lstr(
377            resource=f'{self._r}.controlsSubtitleText',
378            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
379        ).evaluate()
380        bui.textwidget(
381            parent=self._subcontainer,
382            position=(h, v),
383            size=(0, 0),
384            scale=txt_scale,
385            maxwidth=self._sub_width * 0.9,
386            flatness=1.0,
387            text=txt,
388            h_align='center',
389            color=paragraph,
390            v_align='center',
391        )
392        v -= spacing * 160.0
393
394        sep = 70
395        icon_size = 100
396        # icon_size_2 = 30
397        hval2 = h - sep
398        vval2 = v
399        bui.buttonwidget(
400            parent=self._subcontainer,
401            label='',
402            size=(icon_size, icon_size),
403            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
404            texture=bui.gettexture('buttonPunch'),
405            color=(1, 0.7, 0.3),
406            selectable=False,
407            enable_sound=False,
408            on_activate_call=bui.WeakCall(self._play_sound, 'spazAttack0', 4),
409        )
410
411        txt_scale = getres(f'{self._r}.punchInfoTextScale')
412        txt = bui.Lstr(resource=f'{self._r}.punchInfoText').evaluate()
413        bui.textwidget(
414            parent=self._subcontainer,
415            position=(h - sep - 185 + 70, v + 120),
416            size=(0, 0),
417            scale=txt_scale,
418            flatness=1.0,
419            text=txt,
420            h_align='center',
421            color=(1, 0.7, 0.3, 1.0),
422            v_align='top',
423        )
424
425        hval2 = h + sep
426        vval2 = v
427        bui.buttonwidget(
428            parent=self._subcontainer,
429            label='',
430            size=(icon_size, icon_size),
431            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
432            texture=bui.gettexture('buttonBomb'),
433            color=(1, 0.3, 0.3),
434            selectable=False,
435            enable_sound=False,
436            on_activate_call=bui.WeakCall(self._play_sound, 'explosion0', 5),
437        )
438
439        txt = bui.Lstr(resource=f'{self._r}.bombInfoText').evaluate()
440        txt_scale = getres(f'{self._r}.bombInfoTextScale')
441        bui.textwidget(
442            parent=self._subcontainer,
443            position=(h + sep + 50 + 60, v - 35),
444            size=(0, 0),
445            scale=txt_scale,
446            flatness=1.0,
447            maxwidth=270,
448            text=txt,
449            h_align='center',
450            color=(1, 0.3, 0.3, 1.0),
451            v_align='top',
452        )
453
454        hval2 = h
455        vval2 = v + sep
456        bui.buttonwidget(
457            parent=self._subcontainer,
458            label='',
459            size=(icon_size, icon_size),
460            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
461            texture=bui.gettexture('buttonPickUp'),
462            color=(0.5, 0.5, 1),
463            selectable=False,
464            enable_sound=False,
465            on_activate_call=bui.WeakCall(self._play_sound, 'spazPickup0', 1),
466        )
467
468        txtl = bui.Lstr(resource=f'{self._r}.pickUpInfoText')
469        txt_scale = getres(f'{self._r}.pickUpInfoTextScale')
470        bui.textwidget(
471            parent=self._subcontainer,
472            position=(h + 60 + 120, v + sep + 50),
473            size=(0, 0),
474            scale=txt_scale,
475            flatness=1.0,
476            text=txtl,
477            h_align='center',
478            color=(0.5, 0.5, 1, 1.0),
479            v_align='top',
480        )
481
482        hval2 = h
483        vval2 = v - sep
484        bui.buttonwidget(
485            parent=self._subcontainer,
486            label='',
487            size=(icon_size, icon_size),
488            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
489            texture=bui.gettexture('buttonJump'),
490            color=(0.4, 1, 0.4),
491            selectable=False,
492            enable_sound=False,
493            on_activate_call=bui.WeakCall(self._play_sound, 'spazJump0', 4),
494        )
495
496        txt = bui.Lstr(resource=f'{self._r}.jumpInfoText').evaluate()
497        txt_scale = getres(f'{self._r}.jumpInfoTextScale')
498        bui.textwidget(
499            parent=self._subcontainer,
500            position=(h - 250 + 75, v - sep - 15 + 30),
501            size=(0, 0),
502            scale=txt_scale,
503            flatness=1.0,
504            text=txt,
505            h_align='center',
506            color=(0.4, 1, 0.4, 1.0),
507            v_align='top',
508        )
509
510        txt = bui.Lstr(resource=f'{self._r}.runInfoText').evaluate()
511        txt_scale = getres(f'{self._r}.runInfoTextScale')
512        bui.textwidget(
513            parent=self._subcontainer,
514            position=(h, v - sep - 100),
515            size=(0, 0),
516            scale=txt_scale,
517            maxwidth=self._sub_width * 0.93,
518            flatness=1.0,
519            text=txt,
520            h_align='center',
521            color=(0.7, 0.7, 1.0, 1.0),
522            v_align='center',
523        )
524
525        v -= spacing * 280.0
526
527        txt = bui.Lstr(resource=f'{self._r}.powerupsText').evaluate()
528        txt_scale = 1.4
529        txt_maxwidth = 480
530        bui.textwidget(
531            parent=self._subcontainer,
532            position=(h, v),
533            size=(0, 0),
534            scale=txt_scale,
535            flatness=0.5,
536            text=txt,
537            h_align='center',
538            color=header,
539            v_align='center',
540            maxwidth=txt_maxwidth,
541        )
542        txt_width = min(
543            txt_maxwidth,
544            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
545        )
546        icon_size = 70
547        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
548        bui.imagewidget(
549            parent=self._subcontainer,
550            size=(icon_size, icon_size),
551            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
552            texture=logo_tex,
553        )
554
555        v -= spacing * 50.0
556        txt_scale = getres(f'{self._r}.powerupsSubtitleTextScale')
557        txt = bui.Lstr(resource=f'{self._r}.powerupsSubtitleText').evaluate()
558        bui.textwidget(
559            parent=self._subcontainer,
560            position=(h, v),
561            size=(0, 0),
562            scale=txt_scale,
563            maxwidth=self._sub_width * 0.9,
564            text=txt,
565            h_align='center',
566            color=paragraph,
567            v_align='center',
568            flatness=1.0,
569        )
570
571        v -= spacing * 1.0
572
573        mm1 = -270
574        mm2 = -215
575        mm3 = 0
576        icon_size = 50
577        shadow_size = 80
578        shadow_offs_x = 3
579        shadow_offs_y = -4
580        t_big = 1.1
581        t_small = 0.65
582
583        shadow_tex = bui.gettexture('shadowSharp')
584
585        for tex in [
586            'powerupPunch',
587            'powerupShield',
588            'powerupBomb',
589            'powerupHealth',
590            'powerupIceBombs',
591            'powerupImpactBombs',
592            'powerupStickyBombs',
593            'powerupLandMines',
594            'powerupCurse',
595        ]:
596            name = bui.Lstr(resource=f'{self._r}.' + tex + 'NameText')
597            desc = bui.Lstr(resource=f'{self._r}.' + tex + 'DescriptionText')
598
599            v -= spacing * 60.0
600
601            bui.imagewidget(
602                parent=self._subcontainer,
603                size=(shadow_size, shadow_size),
604                position=(
605                    h + mm1 + shadow_offs_x - 0.5 * shadow_size,
606                    v + shadow_offs_y - 0.5 * shadow_size,
607                ),
608                texture=shadow_tex,
609                color=(0, 0, 0),
610                opacity=0.5,
611            )
612            bui.imagewidget(
613                parent=self._subcontainer,
614                size=(icon_size, icon_size),
615                position=(h + mm1 - 0.5 * icon_size, v - 0.5 * icon_size),
616                texture=bui.gettexture(tex),
617            )
618
619            txt_scale = t_big
620            txtl = name
621            bui.textwidget(
622                parent=self._subcontainer,
623                position=(h + mm2, v + 3),
624                size=(0, 0),
625                scale=txt_scale,
626                maxwidth=200,
627                flatness=1.0,
628                text=txtl,
629                h_align='left',
630                color=header2,
631                v_align='center',
632            )
633            txt_scale = t_small
634            txtl = desc
635            bui.textwidget(
636                parent=self._subcontainer,
637                position=(h + mm3, v),
638                size=(0, 0),
639                scale=txt_scale,
640                maxwidth=300,
641                flatness=1.0,
642                text=txtl,
643                h_align='left',
644                color=paragraph,
645                v_align='center',
646                res_scale=0.5,
647            )
648
649    def _play_sound(self, text: str, num: int) -> None:
650        bui.getsound(text + str(random.randint(1, num))).play()
651
652    @override
653    def get_main_window_state(self) -> bui.MainWindowState:
654        # Support recreating our window for back/refresh purposes.
655        cls = type(self)
656        return bui.BasicMainWindowState(
657            create_call=lambda transition, origin_widget: cls(
658                transition=transition, origin_widget=origin_widget
659            )
660        )

A window providing help on how to play.

HelpWindow( transition: str | None = 'in_right', origin_widget: _bauiv1.Widget | None = None)
 18    def __init__(
 19        self,
 20        transition: str | None = 'in_right',
 21        origin_widget: bui.Widget | None = None,
 22    ):
 23        # pylint: disable=too-many-statements
 24        # pylint: disable=too-many-locals
 25
 26        bui.set_analytics_screen('Help Window')
 27
 28        self._r = 'helpWindow'
 29
 30        getres = bui.app.lang.get_resource
 31
 32        assert bui.app.classic is not None
 33        uiscale = bui.app.ui_v1.uiscale
 34        width = 1050 if uiscale is bui.UIScale.SMALL else 750
 35        xoffs = 70 if uiscale is bui.UIScale.SMALL else 0
 36        yoffs = -33 if uiscale is bui.UIScale.SMALL else 0
 37
 38        height = (
 39            500
 40            if uiscale is bui.UIScale.SMALL
 41            else 530 if uiscale is bui.UIScale.MEDIUM else 600
 42        )
 43
 44        super().__init__(
 45            root_widget=bui.containerwidget(
 46                size=(width, height),
 47                toolbar_visibility=(
 48                    'menu_minimal'
 49                    if uiscale is bui.UIScale.SMALL
 50                    else 'menu_full'
 51                ),
 52                scale=(
 53                    1.55
 54                    if uiscale is bui.UIScale.SMALL
 55                    else 1.15 if uiscale is bui.UIScale.MEDIUM else 1.0
 56                ),
 57                stack_offset=(
 58                    (0, 0)
 59                    if uiscale is bui.UIScale.SMALL
 60                    else (0, 15) if uiscale is bui.UIScale.MEDIUM else (0, 0)
 61                ),
 62            ),
 63            transition=transition,
 64            origin_widget=origin_widget,
 65        )
 66
 67        bui.textwidget(
 68            parent=self._root_widget,
 69            position=(
 70                0,
 71                height - (50 if uiscale is bui.UIScale.SMALL else 45) + yoffs,
 72            ),
 73            size=(width, 25),
 74            text=bui.Lstr(
 75                resource=f'{self._r}.titleText',
 76                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
 77            ),
 78            color=bui.app.ui_v1.title_color,
 79            h_align='center',
 80            v_align='top',
 81        )
 82
 83        self._scrollwidget = bui.scrollwidget(
 84            parent=self._root_widget,
 85            position=(
 86                44 + xoffs,
 87                (92 if uiscale is bui.UIScale.SMALL else 55) + yoffs,
 88            ),
 89            simple_culling_v=100.0,
 90            size=(
 91                width - (88 + 2 * xoffs),
 92                height - (150 if uiscale is bui.UIScale.SMALL else 120),
 93            ),
 94            capture_arrows=True,
 95            border_opacity=0.4,
 96        )
 97
 98        bui.widget(
 99            edit=self._scrollwidget,
100            right_widget=bui.get_special_widget('squad_button'),
101        )
102        bui.containerwidget(
103            edit=self._root_widget, selected_child=self._scrollwidget
104        )
105
106        # ugly: create this last so it gets first dibs at touch events (since
107        # we have it close to the scroll widget)
108        if uiscale is bui.UIScale.SMALL:
109            bui.containerwidget(
110                edit=self._root_widget, on_cancel_call=self.main_window_back
111            )
112            bui.widget(
113                edit=self._scrollwidget,
114                left_widget=bui.get_special_widget('back_button'),
115            )
116        else:
117            btn = bui.buttonwidget(
118                parent=self._root_widget,
119                position=(xoffs + 50, height - 55),
120                size=(60, 55),
121                scale=0.8,
122                label=bui.charstr(bui.SpecialChar.BACK),
123                button_type='backSmall',
124                extra_touch_border_scale=2.0,
125                autoselect=True,
126                on_activate_call=self.main_window_back,
127            )
128            bui.containerwidget(edit=self._root_widget, cancel_button=btn)
129
130        self._sub_width = 810 if uiscale is bui.UIScale.SMALL else 660
131        self._sub_height = (
132            1590
133            + bui.app.lang.get_resource(f'{self._r}.someDaysExtraSpace')
134            + bui.app.lang.get_resource(
135                f'{self._r}.orPunchingSomethingExtraSpace'
136            )
137        )
138
139        self._subcontainer = bui.containerwidget(
140            parent=self._scrollwidget,
141            size=(self._sub_width, self._sub_height),
142            background=False,
143            claims_left_right=False,
144        )
145
146        spacing = 1.0
147        h = self._sub_width * 0.5
148        v = self._sub_height - 55
149        logo_tex = bui.gettexture('logo')
150        icon_buffer = 1.1
151        header = (0.7, 1.0, 0.7, 1.0)
152        header2 = (0.8, 0.8, 1.0, 1.0)
153        paragraph = (0.8, 0.8, 1.0, 1.0)
154
155        txt = bui.Lstr(
156            resource=f'{self._r}.welcomeText',
157            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
158        ).evaluate()
159        txt_scale = 1.4
160        txt_maxwidth = 480
161        bui.textwidget(
162            parent=self._subcontainer,
163            position=(h, v),
164            size=(0, 0),
165            scale=txt_scale,
166            flatness=0.5,
167            res_scale=1.5,
168            text=txt,
169            h_align='center',
170            color=header,
171            v_align='center',
172            maxwidth=txt_maxwidth,
173        )
174        txt_width = min(
175            txt_maxwidth,
176            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
177        )
178
179        icon_size = 70
180        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
181        bui.imagewidget(
182            parent=self._subcontainer,
183            size=(icon_size, icon_size),
184            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
185            texture=logo_tex,
186        )
187
188        app = bui.app
189        assert app.classic is not None
190
191        v -= spacing * 50.0
192        txt = bui.Lstr(resource=f'{self._r}.someDaysText').evaluate()
193        bui.textwidget(
194            parent=self._subcontainer,
195            position=(h, v),
196            size=(0, 0),
197            scale=1.2,
198            maxwidth=self._sub_width * 0.9,
199            text=txt,
200            h_align='center',
201            color=paragraph,
202            v_align='center',
203            flatness=1.0,
204        )
205        v -= spacing * 25.0 + getres(f'{self._r}.someDaysExtraSpace')
206        txt_scale = 0.66
207        txt = bui.Lstr(resource=f'{self._r}.orPunchingSomethingText').evaluate()
208        bui.textwidget(
209            parent=self._subcontainer,
210            position=(h, v),
211            size=(0, 0),
212            scale=txt_scale,
213            maxwidth=self._sub_width * 0.9,
214            text=txt,
215            h_align='center',
216            color=paragraph,
217            v_align='center',
218            flatness=1.0,
219        )
220        v -= spacing * 27.0 + getres(f'{self._r}.orPunchingSomethingExtraSpace')
221        txt_scale = 1.0
222        txt = bui.Lstr(
223            resource=f'{self._r}.canHelpText',
224            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
225        ).evaluate()
226        bui.textwidget(
227            parent=self._subcontainer,
228            position=(h, v),
229            size=(0, 0),
230            scale=txt_scale,
231            flatness=1.0,
232            text=txt,
233            h_align='center',
234            color=paragraph,
235            v_align='center',
236        )
237
238        v -= spacing * 70.0
239        txt_scale = 1.0
240        txt = bui.Lstr(resource=f'{self._r}.toGetTheMostText').evaluate()
241        bui.textwidget(
242            parent=self._subcontainer,
243            position=(h, v),
244            size=(0, 0),
245            scale=txt_scale,
246            maxwidth=self._sub_width * 0.9,
247            text=txt,
248            h_align='center',
249            color=header,
250            v_align='center',
251            flatness=1.0,
252        )
253
254        v -= spacing * 40.0
255        txt_scale = 0.74
256        txt = bui.Lstr(resource=f'{self._r}.friendsText').evaluate()
257        hval2 = h - 220
258        bui.textwidget(
259            parent=self._subcontainer,
260            position=(hval2, v),
261            size=(0, 0),
262            scale=txt_scale,
263            maxwidth=100,
264            text=txt,
265            h_align='right',
266            color=header,
267            v_align='center',
268            flatness=1.0,
269        )
270
271        txt = bui.Lstr(
272            resource=f'{self._r}.friendsGoodText',
273            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
274        ).evaluate()
275        txt_scale = 0.7
276        bui.textwidget(
277            parent=self._subcontainer,
278            position=(hval2 + 10, v + 8),
279            size=(0, 0),
280            scale=txt_scale,
281            maxwidth=500,
282            text=txt,
283            h_align='left',
284            color=paragraph,
285            flatness=1.0,
286        )
287
288        app = bui.app
289
290        v -= spacing * 45.0
291        txt = (
292            bui.Lstr(resource=f'{self._r}.devicesText').evaluate()
293            if app.env.vr
294            else bui.Lstr(resource=f'{self._r}.controllersText').evaluate()
295        )
296        txt_scale = 0.74
297        hval2 = h - 220
298        bui.textwidget(
299            parent=self._subcontainer,
300            position=(hval2, v),
301            size=(0, 0),
302            scale=txt_scale,
303            maxwidth=100,
304            text=txt,
305            h_align='right',
306            v_align='center',
307            color=header,
308            flatness=1.0,
309        )
310
311        txt_scale = 0.7
312        if not app.env.vr:
313            infotxt = '.controllersInfoText'
314            txt = bui.Lstr(
315                resource=self._r + infotxt,
316                fallback_resource=f'{self._r}.controllersInfoText',
317                subs=[
318                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
319                    ('${REMOTE_APP_NAME}', bui.get_remote_app_name()),
320                ],
321            ).evaluate()
322        else:
323            txt = bui.Lstr(
324                resource=f'{self._r}.devicesInfoText',
325                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
326            ).evaluate()
327
328        bui.textwidget(
329            parent=self._subcontainer,
330            position=(hval2 + 10, v + 8),
331            size=(0, 0),
332            scale=txt_scale,
333            maxwidth=500,
334            max_height=105,
335            text=txt,
336            h_align='left',
337            color=paragraph,
338            flatness=1.0,
339        )
340
341        v -= spacing * 150.0
342
343        txt = bui.Lstr(resource=f'{self._r}.controlsText').evaluate()
344        txt_scale = 1.4
345        txt_maxwidth = 480
346        bui.textwidget(
347            parent=self._subcontainer,
348            position=(h, v),
349            size=(0, 0),
350            scale=txt_scale,
351            flatness=0.5,
352            text=txt,
353            h_align='center',
354            color=header,
355            v_align='center',
356            res_scale=1.5,
357            maxwidth=txt_maxwidth,
358        )
359        txt_width = min(
360            txt_maxwidth,
361            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
362        )
363        icon_size = 70
364
365        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
366        bui.imagewidget(
367            parent=self._subcontainer,
368            size=(icon_size, icon_size),
369            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
370            texture=logo_tex,
371        )
372
373        v -= spacing * 45.0
374
375        txt_scale = 0.7
376        txt = bui.Lstr(
377            resource=f'{self._r}.controlsSubtitleText',
378            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
379        ).evaluate()
380        bui.textwidget(
381            parent=self._subcontainer,
382            position=(h, v),
383            size=(0, 0),
384            scale=txt_scale,
385            maxwidth=self._sub_width * 0.9,
386            flatness=1.0,
387            text=txt,
388            h_align='center',
389            color=paragraph,
390            v_align='center',
391        )
392        v -= spacing * 160.0
393
394        sep = 70
395        icon_size = 100
396        # icon_size_2 = 30
397        hval2 = h - sep
398        vval2 = v
399        bui.buttonwidget(
400            parent=self._subcontainer,
401            label='',
402            size=(icon_size, icon_size),
403            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
404            texture=bui.gettexture('buttonPunch'),
405            color=(1, 0.7, 0.3),
406            selectable=False,
407            enable_sound=False,
408            on_activate_call=bui.WeakCall(self._play_sound, 'spazAttack0', 4),
409        )
410
411        txt_scale = getres(f'{self._r}.punchInfoTextScale')
412        txt = bui.Lstr(resource=f'{self._r}.punchInfoText').evaluate()
413        bui.textwidget(
414            parent=self._subcontainer,
415            position=(h - sep - 185 + 70, v + 120),
416            size=(0, 0),
417            scale=txt_scale,
418            flatness=1.0,
419            text=txt,
420            h_align='center',
421            color=(1, 0.7, 0.3, 1.0),
422            v_align='top',
423        )
424
425        hval2 = h + sep
426        vval2 = v
427        bui.buttonwidget(
428            parent=self._subcontainer,
429            label='',
430            size=(icon_size, icon_size),
431            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
432            texture=bui.gettexture('buttonBomb'),
433            color=(1, 0.3, 0.3),
434            selectable=False,
435            enable_sound=False,
436            on_activate_call=bui.WeakCall(self._play_sound, 'explosion0', 5),
437        )
438
439        txt = bui.Lstr(resource=f'{self._r}.bombInfoText').evaluate()
440        txt_scale = getres(f'{self._r}.bombInfoTextScale')
441        bui.textwidget(
442            parent=self._subcontainer,
443            position=(h + sep + 50 + 60, v - 35),
444            size=(0, 0),
445            scale=txt_scale,
446            flatness=1.0,
447            maxwidth=270,
448            text=txt,
449            h_align='center',
450            color=(1, 0.3, 0.3, 1.0),
451            v_align='top',
452        )
453
454        hval2 = h
455        vval2 = v + sep
456        bui.buttonwidget(
457            parent=self._subcontainer,
458            label='',
459            size=(icon_size, icon_size),
460            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
461            texture=bui.gettexture('buttonPickUp'),
462            color=(0.5, 0.5, 1),
463            selectable=False,
464            enable_sound=False,
465            on_activate_call=bui.WeakCall(self._play_sound, 'spazPickup0', 1),
466        )
467
468        txtl = bui.Lstr(resource=f'{self._r}.pickUpInfoText')
469        txt_scale = getres(f'{self._r}.pickUpInfoTextScale')
470        bui.textwidget(
471            parent=self._subcontainer,
472            position=(h + 60 + 120, v + sep + 50),
473            size=(0, 0),
474            scale=txt_scale,
475            flatness=1.0,
476            text=txtl,
477            h_align='center',
478            color=(0.5, 0.5, 1, 1.0),
479            v_align='top',
480        )
481
482        hval2 = h
483        vval2 = v - sep
484        bui.buttonwidget(
485            parent=self._subcontainer,
486            label='',
487            size=(icon_size, icon_size),
488            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
489            texture=bui.gettexture('buttonJump'),
490            color=(0.4, 1, 0.4),
491            selectable=False,
492            enable_sound=False,
493            on_activate_call=bui.WeakCall(self._play_sound, 'spazJump0', 4),
494        )
495
496        txt = bui.Lstr(resource=f'{self._r}.jumpInfoText').evaluate()
497        txt_scale = getres(f'{self._r}.jumpInfoTextScale')
498        bui.textwidget(
499            parent=self._subcontainer,
500            position=(h - 250 + 75, v - sep - 15 + 30),
501            size=(0, 0),
502            scale=txt_scale,
503            flatness=1.0,
504            text=txt,
505            h_align='center',
506            color=(0.4, 1, 0.4, 1.0),
507            v_align='top',
508        )
509
510        txt = bui.Lstr(resource=f'{self._r}.runInfoText').evaluate()
511        txt_scale = getres(f'{self._r}.runInfoTextScale')
512        bui.textwidget(
513            parent=self._subcontainer,
514            position=(h, v - sep - 100),
515            size=(0, 0),
516            scale=txt_scale,
517            maxwidth=self._sub_width * 0.93,
518            flatness=1.0,
519            text=txt,
520            h_align='center',
521            color=(0.7, 0.7, 1.0, 1.0),
522            v_align='center',
523        )
524
525        v -= spacing * 280.0
526
527        txt = bui.Lstr(resource=f'{self._r}.powerupsText').evaluate()
528        txt_scale = 1.4
529        txt_maxwidth = 480
530        bui.textwidget(
531            parent=self._subcontainer,
532            position=(h, v),
533            size=(0, 0),
534            scale=txt_scale,
535            flatness=0.5,
536            text=txt,
537            h_align='center',
538            color=header,
539            v_align='center',
540            maxwidth=txt_maxwidth,
541        )
542        txt_width = min(
543            txt_maxwidth,
544            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
545        )
546        icon_size = 70
547        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
548        bui.imagewidget(
549            parent=self._subcontainer,
550            size=(icon_size, icon_size),
551            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
552            texture=logo_tex,
553        )
554
555        v -= spacing * 50.0
556        txt_scale = getres(f'{self._r}.powerupsSubtitleTextScale')
557        txt = bui.Lstr(resource=f'{self._r}.powerupsSubtitleText').evaluate()
558        bui.textwidget(
559            parent=self._subcontainer,
560            position=(h, v),
561            size=(0, 0),
562            scale=txt_scale,
563            maxwidth=self._sub_width * 0.9,
564            text=txt,
565            h_align='center',
566            color=paragraph,
567            v_align='center',
568            flatness=1.0,
569        )
570
571        v -= spacing * 1.0
572
573        mm1 = -270
574        mm2 = -215
575        mm3 = 0
576        icon_size = 50
577        shadow_size = 80
578        shadow_offs_x = 3
579        shadow_offs_y = -4
580        t_big = 1.1
581        t_small = 0.65
582
583        shadow_tex = bui.gettexture('shadowSharp')
584
585        for tex in [
586            'powerupPunch',
587            'powerupShield',
588            'powerupBomb',
589            'powerupHealth',
590            'powerupIceBombs',
591            'powerupImpactBombs',
592            'powerupStickyBombs',
593            'powerupLandMines',
594            'powerupCurse',
595        ]:
596            name = bui.Lstr(resource=f'{self._r}.' + tex + 'NameText')
597            desc = bui.Lstr(resource=f'{self._r}.' + tex + 'DescriptionText')
598
599            v -= spacing * 60.0
600
601            bui.imagewidget(
602                parent=self._subcontainer,
603                size=(shadow_size, shadow_size),
604                position=(
605                    h + mm1 + shadow_offs_x - 0.5 * shadow_size,
606                    v + shadow_offs_y - 0.5 * shadow_size,
607                ),
608                texture=shadow_tex,
609                color=(0, 0, 0),
610                opacity=0.5,
611            )
612            bui.imagewidget(
613                parent=self._subcontainer,
614                size=(icon_size, icon_size),
615                position=(h + mm1 - 0.5 * icon_size, v - 0.5 * icon_size),
616                texture=bui.gettexture(tex),
617            )
618
619            txt_scale = t_big
620            txtl = name
621            bui.textwidget(
622                parent=self._subcontainer,
623                position=(h + mm2, v + 3),
624                size=(0, 0),
625                scale=txt_scale,
626                maxwidth=200,
627                flatness=1.0,
628                text=txtl,
629                h_align='left',
630                color=header2,
631                v_align='center',
632            )
633            txt_scale = t_small
634            txtl = desc
635            bui.textwidget(
636                parent=self._subcontainer,
637                position=(h + mm3, v),
638                size=(0, 0),
639                scale=txt_scale,
640                maxwidth=300,
641                flatness=1.0,
642                text=txtl,
643                h_align='left',
644                color=paragraph,
645                v_align='center',
646                res_scale=0.5,
647            )

Create a MainWindow given a root widget and transition info.

Automatically handles in and out transitions on the provided widget, so there is no need to set transitions when creating it.

@override
def get_main_window_state(self) -> bauiv1.MainWindowState:
652    @override
653    def get_main_window_state(self) -> bui.MainWindowState:
654        # Support recreating our window for back/refresh purposes.
655        cls = type(self)
656        return bui.BasicMainWindowState(
657            create_call=lambda transition, origin_widget: cls(
658                transition=transition, origin_widget=origin_widget
659            )
660        )

Return a WindowState to recreate this window, if supported.