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

A window providing help on how to play.

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

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:
631    @override
632    def get_main_window_state(self) -> bui.MainWindowState:
633        # Support recreating our window for back/refresh purposes.
634        cls = type(self)
635        return bui.BasicMainWindowState(
636            create_call=lambda transition, origin_widget: cls(
637                transition=transition, origin_widget=origin_widget
638            )
639        )

Return a WindowState to recreate this window, if supported.