bauiv1lib.helpui

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

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

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:
624    @override
625    def get_main_window_state(self) -> bui.MainWindowState:
626        # Support recreating our window for back/refresh purposes.
627        cls = type(self)
628        return bui.BasicMainWindowState(
629            create_call=lambda transition, origin_widget: cls(
630                transition=transition, origin_widget=origin_widget
631            )
632        )

Return a WindowState to recreate this window, if supported.

Inherited Members
bauiv1._uitypes.MainWindow
main_window_back_state
main_window_close
can_change_main_window
main_window_back
main_window_replace
on_main_window_close
bauiv1._uitypes.Window
get_root_widget