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        )
141
142        spacing = 1.0
143        h = self._sub_width * 0.5
144        v = self._sub_height - 55
145        logo_tex = bui.gettexture('logo')
146        icon_buffer = 1.1
147        header = (0.7, 1.0, 0.7, 1.0)
148        header2 = (0.8, 0.8, 1.0, 1.0)
149        paragraph = (0.8, 0.8, 1.0, 1.0)
150
151        txt = bui.Lstr(
152            resource=f'{self._r}.welcomeText',
153            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
154        ).evaluate()
155        txt_scale = 1.4
156        txt_maxwidth = 480
157        bui.textwidget(
158            parent=self._subcontainer,
159            position=(h, v),
160            size=(0, 0),
161            scale=txt_scale,
162            flatness=0.5,
163            res_scale=1.5,
164            text=txt,
165            h_align='center',
166            color=header,
167            v_align='center',
168            maxwidth=txt_maxwidth,
169        )
170        txt_width = min(
171            txt_maxwidth,
172            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
173        )
174
175        icon_size = 70
176        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
177        bui.imagewidget(
178            parent=self._subcontainer,
179            size=(icon_size, icon_size),
180            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
181            texture=logo_tex,
182        )
183
184        app = bui.app
185        assert app.classic is not None
186
187        v -= spacing * 50.0
188        txt = bui.Lstr(resource=f'{self._r}.someDaysText').evaluate()
189        bui.textwidget(
190            parent=self._subcontainer,
191            position=(h, v),
192            size=(0, 0),
193            scale=1.2,
194            maxwidth=self._sub_width * 0.9,
195            text=txt,
196            h_align='center',
197            color=paragraph,
198            v_align='center',
199            flatness=1.0,
200        )
201        v -= spacing * 25.0 + getres(f'{self._r}.someDaysExtraSpace')
202        txt_scale = 0.66
203        txt = bui.Lstr(resource=f'{self._r}.orPunchingSomethingText').evaluate()
204        bui.textwidget(
205            parent=self._subcontainer,
206            position=(h, v),
207            size=(0, 0),
208            scale=txt_scale,
209            maxwidth=self._sub_width * 0.9,
210            text=txt,
211            h_align='center',
212            color=paragraph,
213            v_align='center',
214            flatness=1.0,
215        )
216        v -= spacing * 27.0 + getres(f'{self._r}.orPunchingSomethingExtraSpace')
217        txt_scale = 1.0
218        txt = bui.Lstr(
219            resource=f'{self._r}.canHelpText',
220            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
221        ).evaluate()
222        bui.textwidget(
223            parent=self._subcontainer,
224            position=(h, v),
225            size=(0, 0),
226            scale=txt_scale,
227            flatness=1.0,
228            text=txt,
229            h_align='center',
230            color=paragraph,
231            v_align='center',
232        )
233
234        v -= spacing * 70.0
235        txt_scale = 1.0
236        txt = bui.Lstr(resource=f'{self._r}.toGetTheMostText').evaluate()
237        bui.textwidget(
238            parent=self._subcontainer,
239            position=(h, v),
240            size=(0, 0),
241            scale=txt_scale,
242            maxwidth=self._sub_width * 0.9,
243            text=txt,
244            h_align='center',
245            color=header,
246            v_align='center',
247            flatness=1.0,
248        )
249
250        v -= spacing * 40.0
251        txt_scale = 0.74
252        txt = bui.Lstr(resource=f'{self._r}.friendsText').evaluate()
253        hval2 = h - 220
254        bui.textwidget(
255            parent=self._subcontainer,
256            position=(hval2, v),
257            size=(0, 0),
258            scale=txt_scale,
259            maxwidth=100,
260            text=txt,
261            h_align='right',
262            color=header,
263            v_align='center',
264            flatness=1.0,
265        )
266
267        txt = bui.Lstr(
268            resource=f'{self._r}.friendsGoodText',
269            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
270        ).evaluate()
271        txt_scale = 0.7
272        bui.textwidget(
273            parent=self._subcontainer,
274            position=(hval2 + 10, v + 8),
275            size=(0, 0),
276            scale=txt_scale,
277            maxwidth=500,
278            text=txt,
279            h_align='left',
280            color=paragraph,
281            flatness=1.0,
282        )
283
284        app = bui.app
285
286        v -= spacing * 45.0
287        txt = (
288            bui.Lstr(resource=f'{self._r}.devicesText').evaluate()
289            if app.env.vr
290            else bui.Lstr(resource=f'{self._r}.controllersText').evaluate()
291        )
292        txt_scale = 0.74
293        hval2 = h - 220
294        bui.textwidget(
295            parent=self._subcontainer,
296            position=(hval2, v),
297            size=(0, 0),
298            scale=txt_scale,
299            maxwidth=100,
300            text=txt,
301            h_align='right',
302            v_align='center',
303            color=header,
304            flatness=1.0,
305        )
306
307        txt_scale = 0.7
308        if not app.env.vr:
309            infotxt = '.controllersInfoText'
310            txt = bui.Lstr(
311                resource=self._r + infotxt,
312                fallback_resource=f'{self._r}.controllersInfoText',
313                subs=[
314                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
315                    ('${REMOTE_APP_NAME}', bui.get_remote_app_name()),
316                ],
317            ).evaluate()
318        else:
319            txt = bui.Lstr(
320                resource=f'{self._r}.devicesInfoText',
321                subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
322            ).evaluate()
323
324        bui.textwidget(
325            parent=self._subcontainer,
326            position=(hval2 + 10, v + 8),
327            size=(0, 0),
328            scale=txt_scale,
329            maxwidth=500,
330            max_height=105,
331            text=txt,
332            h_align='left',
333            color=paragraph,
334            flatness=1.0,
335        )
336
337        v -= spacing * 150.0
338
339        txt = bui.Lstr(resource=f'{self._r}.controlsText').evaluate()
340        txt_scale = 1.4
341        txt_maxwidth = 480
342        bui.textwidget(
343            parent=self._subcontainer,
344            position=(h, v),
345            size=(0, 0),
346            scale=txt_scale,
347            flatness=0.5,
348            text=txt,
349            h_align='center',
350            color=header,
351            v_align='center',
352            res_scale=1.5,
353            maxwidth=txt_maxwidth,
354        )
355        txt_width = min(
356            txt_maxwidth,
357            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
358        )
359        icon_size = 70
360
361        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
362        bui.imagewidget(
363            parent=self._subcontainer,
364            size=(icon_size, icon_size),
365            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
366            texture=logo_tex,
367        )
368
369        v -= spacing * 45.0
370
371        txt_scale = 0.7
372        txt = bui.Lstr(
373            resource=f'{self._r}.controlsSubtitleText',
374            subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
375        ).evaluate()
376        bui.textwidget(
377            parent=self._subcontainer,
378            position=(h, v),
379            size=(0, 0),
380            scale=txt_scale,
381            maxwidth=self._sub_width * 0.9,
382            flatness=1.0,
383            text=txt,
384            h_align='center',
385            color=paragraph,
386            v_align='center',
387        )
388        v -= spacing * 160.0
389
390        sep = 70
391        icon_size = 100
392        # icon_size_2 = 30
393        hval2 = h - sep
394        vval2 = v
395        bui.imagewidget(
396            parent=self._subcontainer,
397            size=(icon_size, icon_size),
398            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
399            texture=bui.gettexture('buttonPunch'),
400            color=(1, 0.7, 0.3),
401        )
402
403        txt_scale = getres(f'{self._r}.punchInfoTextScale')
404        txt = bui.Lstr(resource=f'{self._r}.punchInfoText').evaluate()
405        bui.textwidget(
406            parent=self._subcontainer,
407            position=(h - sep - 185 + 70, v + 120),
408            size=(0, 0),
409            scale=txt_scale,
410            flatness=1.0,
411            text=txt,
412            h_align='center',
413            color=(1, 0.7, 0.3, 1.0),
414            v_align='top',
415        )
416
417        hval2 = h + sep
418        vval2 = v
419        bui.imagewidget(
420            parent=self._subcontainer,
421            size=(icon_size, icon_size),
422            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
423            texture=bui.gettexture('buttonBomb'),
424            color=(1, 0.3, 0.3),
425        )
426
427        txt = bui.Lstr(resource=f'{self._r}.bombInfoText').evaluate()
428        txt_scale = getres(f'{self._r}.bombInfoTextScale')
429        bui.textwidget(
430            parent=self._subcontainer,
431            position=(h + sep + 50 + 60, v - 35),
432            size=(0, 0),
433            scale=txt_scale,
434            flatness=1.0,
435            maxwidth=270,
436            text=txt,
437            h_align='center',
438            color=(1, 0.3, 0.3, 1.0),
439            v_align='top',
440        )
441
442        hval2 = h
443        vval2 = v + sep
444        bui.imagewidget(
445            parent=self._subcontainer,
446            size=(icon_size, icon_size),
447            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
448            texture=bui.gettexture('buttonPickUp'),
449            color=(0.5, 0.5, 1),
450        )
451
452        txtl = bui.Lstr(resource=f'{self._r}.pickUpInfoText')
453        txt_scale = getres(f'{self._r}.pickUpInfoTextScale')
454        bui.textwidget(
455            parent=self._subcontainer,
456            position=(h + 60 + 120, v + sep + 50),
457            size=(0, 0),
458            scale=txt_scale,
459            flatness=1.0,
460            text=txtl,
461            h_align='center',
462            color=(0.5, 0.5, 1, 1.0),
463            v_align='top',
464        )
465
466        hval2 = h
467        vval2 = v - sep
468        bui.imagewidget(
469            parent=self._subcontainer,
470            size=(icon_size, icon_size),
471            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
472            texture=bui.gettexture('buttonJump'),
473            color=(0.4, 1, 0.4),
474        )
475
476        txt = bui.Lstr(resource=f'{self._r}.jumpInfoText').evaluate()
477        txt_scale = getres(f'{self._r}.jumpInfoTextScale')
478        bui.textwidget(
479            parent=self._subcontainer,
480            position=(h - 250 + 75, v - sep - 15 + 30),
481            size=(0, 0),
482            scale=txt_scale,
483            flatness=1.0,
484            text=txt,
485            h_align='center',
486            color=(0.4, 1, 0.4, 1.0),
487            v_align='top',
488        )
489
490        txt = bui.Lstr(resource=f'{self._r}.runInfoText').evaluate()
491        txt_scale = getres(f'{self._r}.runInfoTextScale')
492        bui.textwidget(
493            parent=self._subcontainer,
494            position=(h, v - sep - 100),
495            size=(0, 0),
496            scale=txt_scale,
497            maxwidth=self._sub_width * 0.93,
498            flatness=1.0,
499            text=txt,
500            h_align='center',
501            color=(0.7, 0.7, 1.0, 1.0),
502            v_align='center',
503        )
504
505        v -= spacing * 280.0
506
507        txt = bui.Lstr(resource=f'{self._r}.powerupsText').evaluate()
508        txt_scale = 1.4
509        txt_maxwidth = 480
510        bui.textwidget(
511            parent=self._subcontainer,
512            position=(h, v),
513            size=(0, 0),
514            scale=txt_scale,
515            flatness=0.5,
516            text=txt,
517            h_align='center',
518            color=header,
519            v_align='center',
520            maxwidth=txt_maxwidth,
521        )
522        txt_width = min(
523            txt_maxwidth,
524            bui.get_string_width(txt, suppress_warning=True) * txt_scale,
525        )
526        icon_size = 70
527        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
528        bui.imagewidget(
529            parent=self._subcontainer,
530            size=(icon_size, icon_size),
531            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
532            texture=logo_tex,
533        )
534
535        v -= spacing * 50.0
536        txt_scale = getres(f'{self._r}.powerupsSubtitleTextScale')
537        txt = bui.Lstr(resource=f'{self._r}.powerupsSubtitleText').evaluate()
538        bui.textwidget(
539            parent=self._subcontainer,
540            position=(h, v),
541            size=(0, 0),
542            scale=txt_scale,
543            maxwidth=self._sub_width * 0.9,
544            text=txt,
545            h_align='center',
546            color=paragraph,
547            v_align='center',
548            flatness=1.0,
549        )
550
551        v -= spacing * 1.0
552
553        mm1 = -270
554        mm2 = -215
555        mm3 = 0
556        icon_size = 50
557        shadow_size = 80
558        shadow_offs_x = 3
559        shadow_offs_y = -4
560        t_big = 1.1
561        t_small = 0.65
562
563        shadow_tex = bui.gettexture('shadowSharp')
564
565        for tex in [
566            'powerupPunch',
567            'powerupShield',
568            'powerupBomb',
569            'powerupHealth',
570            'powerupIceBombs',
571            'powerupImpactBombs',
572            'powerupStickyBombs',
573            'powerupLandMines',
574            'powerupCurse',
575        ]:
576            name = bui.Lstr(resource=f'{self._r}.' + tex + 'NameText')
577            desc = bui.Lstr(resource=f'{self._r}.' + tex + 'DescriptionText')
578
579            v -= spacing * 60.0
580
581            bui.imagewidget(
582                parent=self._subcontainer,
583                size=(shadow_size, shadow_size),
584                position=(
585                    h + mm1 + shadow_offs_x - 0.5 * shadow_size,
586                    v + shadow_offs_y - 0.5 * shadow_size,
587                ),
588                texture=shadow_tex,
589                color=(0, 0, 0),
590                opacity=0.5,
591            )
592            bui.imagewidget(
593                parent=self._subcontainer,
594                size=(icon_size, icon_size),
595                position=(h + mm1 - 0.5 * icon_size, v - 0.5 * icon_size),
596                texture=bui.gettexture(tex),
597            )
598
599            txt_scale = t_big
600            txtl = name
601            bui.textwidget(
602                parent=self._subcontainer,
603                position=(h + mm2, v + 3),
604                size=(0, 0),
605                scale=txt_scale,
606                maxwidth=200,
607                flatness=1.0,
608                text=txtl,
609                h_align='left',
610                color=header2,
611                v_align='center',
612            )
613            txt_scale = t_small
614            txtl = desc
615            bui.textwidget(
616                parent=self._subcontainer,
617                position=(h + mm3, v),
618                size=(0, 0),
619                scale=txt_scale,
620                maxwidth=300,
621                flatness=1.0,
622                text=txtl,
623                h_align='left',
624                color=paragraph,
625                v_align='center',
626                res_scale=0.5,
627            )
628
629    @override
630    def get_main_window_state(self) -> bui.MainWindowState:
631        # Support recreating our window for back/refresh purposes.
632        cls = type(self)
633        return bui.BasicMainWindowState(
634            create_call=lambda transition, origin_widget: cls(
635                transition=transition, origin_widget=origin_widget
636            )
637        )
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        )
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        )

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        )
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            )

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:
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        )

Return a WindowState to recreate this window, if supported.