bastd.ui.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 TYPE_CHECKING
  8
  9import ba
 10import ba.internal
 11
 12if TYPE_CHECKING:
 13    pass
 14
 15
 16class HelpWindow(ba.Window):
 17    """A window providing help on how to play."""
 18
 19    def __init__(
 20        self, main_menu: bool = False, origin_widget: ba.Widget | None = None
 21    ):
 22        # pylint: disable=too-many-statements
 23        # pylint: disable=too-many-locals
 24        from ba.internal import get_remote_app_name
 25
 26        ba.set_analytics_screen('Help Window')
 27
 28        # If they provided an origin-widget, scale up from that.
 29        scale_origin: tuple[float, float] | None
 30        if origin_widget is not None:
 31            self._transition_out = 'out_scale'
 32            scale_origin = origin_widget.get_screen_space_center()
 33            transition = 'in_scale'
 34        else:
 35            self._transition_out = 'out_right'
 36            scale_origin = None
 37            transition = 'in_right'
 38
 39        self._r = 'helpWindow'
 40
 41        getres = ba.app.lang.get_resource
 42
 43        self._main_menu = main_menu
 44        uiscale = ba.app.ui.uiscale
 45        width = 950 if uiscale is ba.UIScale.SMALL else 750
 46        x_offs = 100 if uiscale is ba.UIScale.SMALL else 0
 47        height = (
 48            460
 49            if uiscale is ba.UIScale.SMALL
 50            else 530
 51            if uiscale is ba.UIScale.MEDIUM
 52            else 600
 53        )
 54
 55        super().__init__(
 56            root_widget=ba.containerwidget(
 57                size=(width, height),
 58                transition=transition,
 59                toolbar_visibility='menu_minimal',
 60                scale_origin_stack_offset=scale_origin,
 61                scale=(
 62                    1.77
 63                    if uiscale is ba.UIScale.SMALL
 64                    else 1.25
 65                    if uiscale is ba.UIScale.MEDIUM
 66                    else 1.0
 67                ),
 68                stack_offset=(0, -30)
 69                if uiscale is ba.UIScale.SMALL
 70                else (0, 15)
 71                if uiscale is ba.UIScale.MEDIUM
 72                else (0, 0),
 73            )
 74        )
 75
 76        ba.textwidget(
 77            parent=self._root_widget,
 78            position=(0, height - (50 if uiscale is ba.UIScale.SMALL else 45)),
 79            size=(width, 25),
 80            text=ba.Lstr(
 81                resource=self._r + '.titleText',
 82                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
 83            ),
 84            color=ba.app.ui.title_color,
 85            h_align='center',
 86            v_align='top',
 87        )
 88
 89        self._scrollwidget = ba.scrollwidget(
 90            parent=self._root_widget,
 91            position=(44 + x_offs, 55 if uiscale is ba.UIScale.SMALL else 55),
 92            simple_culling_v=100.0,
 93            size=(
 94                width - (88 + 2 * x_offs),
 95                height - 120 + (5 if uiscale is ba.UIScale.SMALL else 0),
 96            ),
 97            capture_arrows=True,
 98        )
 99
100        if ba.app.ui.use_toolbars:
101            ba.widget(
102                edit=self._scrollwidget,
103                right_widget=ba.internal.get_special_widget('party_button'),
104            )
105        ba.containerwidget(
106            edit=self._root_widget, selected_child=self._scrollwidget
107        )
108
109        # ugly: create this last so it gets first dibs at touch events (since
110        # we have it close to the scroll widget)
111        if uiscale is ba.UIScale.SMALL and ba.app.ui.use_toolbars:
112            ba.containerwidget(
113                edit=self._root_widget, on_cancel_call=self._close
114            )
115            ba.widget(
116                edit=self._scrollwidget,
117                left_widget=ba.internal.get_special_widget('back_button'),
118            )
119        else:
120            btn = ba.buttonwidget(
121                parent=self._root_widget,
122                position=(
123                    x_offs + (40 + 0 if uiscale is ba.UIScale.SMALL else 70),
124                    height - (59 if uiscale is ba.UIScale.SMALL else 50),
125                ),
126                size=(140, 60),
127                scale=0.7 if uiscale is ba.UIScale.SMALL else 0.8,
128                label=ba.Lstr(resource='backText')
129                if self._main_menu
130                else 'Close',
131                button_type='back' if self._main_menu else None,
132                extra_touch_border_scale=2.0,
133                autoselect=True,
134                on_activate_call=self._close,
135            )
136            ba.containerwidget(edit=self._root_widget, cancel_button=btn)
137
138            if self._main_menu:
139                ba.buttonwidget(
140                    edit=btn,
141                    button_type='backSmall',
142                    size=(60, 55),
143                    label=ba.charstr(ba.SpecialChar.BACK),
144                )
145
146        self._sub_width = 660
147        self._sub_height = (
148            1590
149            + ba.app.lang.get_resource(self._r + '.someDaysExtraSpace')
150            + ba.app.lang.get_resource(
151                self._r + '.orPunchingSomethingExtraSpace'
152            )
153        )
154
155        self._subcontainer = ba.containerwidget(
156            parent=self._scrollwidget,
157            size=(self._sub_width, self._sub_height),
158            background=False,
159            claims_left_right=False,
160            claims_tab=False,
161        )
162
163        spacing = 1.0
164        h = self._sub_width * 0.5
165        v = self._sub_height - 55
166        logo_tex = ba.gettexture('logo')
167        icon_buffer = 1.1
168        header = (0.7, 1.0, 0.7, 1.0)
169        header2 = (0.8, 0.8, 1.0, 1.0)
170        paragraph = (0.8, 0.8, 1.0, 1.0)
171
172        txt = ba.Lstr(
173            resource=self._r + '.welcomeText',
174            subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
175        ).evaluate()
176        txt_scale = 1.4
177        txt_maxwidth = 480
178        ba.textwidget(
179            parent=self._subcontainer,
180            position=(h, v),
181            size=(0, 0),
182            scale=txt_scale,
183            flatness=0.5,
184            res_scale=1.5,
185            text=txt,
186            h_align='center',
187            color=header,
188            v_align='center',
189            maxwidth=txt_maxwidth,
190        )
191        txt_width = min(
192            txt_maxwidth,
193            ba.internal.get_string_width(txt, suppress_warning=True)
194            * txt_scale,
195        )
196
197        icon_size = 70
198        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
199        ba.imagewidget(
200            parent=self._subcontainer,
201            size=(icon_size, icon_size),
202            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
203            texture=logo_tex,
204        )
205
206        force_test = False
207        app = ba.app
208        if (
209            app.platform == 'android' and app.subplatform == 'alibaba'
210        ) or force_test:
211            v -= 120.0
212            txtv = (
213                '\xe8\xbf\x99\xe6\x98\xaf\xe4\xb8\x80\xe4\xb8\xaa\xe5\x8f\xaf'
214                '\xe4\xbb\xa5\xe5\x92\x8c\xe5\xae\xb6\xe4\xba\xba\xe6\x9c\x8b'
215                '\xe5\x8f\x8b\xe4\xb8\x80\xe8\xb5\xb7\xe7\x8e\xa9\xe7\x9a\x84'
216                '\xe6\xb8\xb8\xe6\x88\x8f,\xe5\x90\x8c\xe6\x97\xb6\xe6\x94\xaf'
217                '\xe6\x8c\x81\xe8\x81\x94 \xe2\x80\xa8\xe7\xbd\x91\xe5\xaf\xb9'
218                '\xe6\x88\x98\xe3\x80\x82\n'
219                '\xe5\xa6\x82\xe6\xb2\xa1\xe6\x9c\x89\xe6\xb8\xb8\xe6\x88\x8f'
220                '\xe6\x89\x8b\xe6\x9f\x84,\xe5\x8f\xaf\xe4\xbb\xa5\xe4\xbd\xbf'
221                '\xe7\x94\xa8\xe7\xa7\xbb\xe5\x8a\xa8\xe8\xae\xbe\xe5\xa4\x87'
222                '\xe6\x89\xab\xe7\xa0\x81\xe4\xb8\x8b\xe8\xbd\xbd\xe2\x80\x9c'
223                '\xe9\x98\xbf\xe9\x87\x8c\xc2'
224                '\xa0TV\xc2\xa0\xe5\x8a\xa9\xe6\x89'
225                '\x8b\xe2\x80\x9d\xe7\x94\xa8 \xe6\x9d\xa5\xe4\xbb\xa3\xe6\x9b'
226                '\xbf\xe5\xa4\x96\xe8\xae\xbe\xe3\x80\x82\n'
227                '\xe6\x9c\x80\xe5\xa4\x9a\xe6\x94\xaf\xe6\x8c\x81\xe6\x8e\xa5'
228                '\xe5\x85\xa5\xc2\xa08\xc2\xa0\xe4\xb8\xaa\xe5\xa4\x96\xe8'
229                '\xae\xbe'
230            )
231            ba.textwidget(
232                parent=self._subcontainer,
233                size=(0, 0),
234                h_align='center',
235                v_align='center',
236                maxwidth=self._sub_width * 0.9,
237                position=(self._sub_width * 0.5, v - 180),
238                text=txtv,
239            )
240            ba.imagewidget(
241                parent=self._subcontainer,
242                position=(self._sub_width - 320, v - 120),
243                size=(200, 200),
244                texture=ba.gettexture('aliControllerQR'),
245            )
246            ba.imagewidget(
247                parent=self._subcontainer,
248                position=(90, v - 130),
249                size=(210, 210),
250                texture=ba.gettexture('multiplayerExamples'),
251            )
252            v -= 120.0
253
254        else:
255            v -= spacing * 50.0
256            txt = ba.Lstr(resource=self._r + '.someDaysText').evaluate()
257            ba.textwidget(
258                parent=self._subcontainer,
259                position=(h, v),
260                size=(0, 0),
261                scale=1.2,
262                maxwidth=self._sub_width * 0.9,
263                text=txt,
264                h_align='center',
265                color=paragraph,
266                v_align='center',
267                flatness=1.0,
268            )
269            v -= spacing * 25.0 + getres(self._r + '.someDaysExtraSpace')
270            txt_scale = 0.66
271            txt = ba.Lstr(
272                resource=self._r + '.orPunchingSomethingText'
273            ).evaluate()
274            ba.textwidget(
275                parent=self._subcontainer,
276                position=(h, v),
277                size=(0, 0),
278                scale=txt_scale,
279                maxwidth=self._sub_width * 0.9,
280                text=txt,
281                h_align='center',
282                color=paragraph,
283                v_align='center',
284                flatness=1.0,
285            )
286            v -= spacing * 27.0 + getres(
287                self._r + '.orPunchingSomethingExtraSpace'
288            )
289            txt_scale = 1.0
290            txt = ba.Lstr(
291                resource=self._r + '.canHelpText',
292                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
293            ).evaluate()
294            ba.textwidget(
295                parent=self._subcontainer,
296                position=(h, v),
297                size=(0, 0),
298                scale=txt_scale,
299                flatness=1.0,
300                text=txt,
301                h_align='center',
302                color=paragraph,
303                v_align='center',
304            )
305
306            v -= spacing * 70.0
307            txt_scale = 1.0
308            txt = ba.Lstr(resource=self._r + '.toGetTheMostText').evaluate()
309            ba.textwidget(
310                parent=self._subcontainer,
311                position=(h, v),
312                size=(0, 0),
313                scale=txt_scale,
314                maxwidth=self._sub_width * 0.9,
315                text=txt,
316                h_align='center',
317                color=header,
318                v_align='center',
319                flatness=1.0,
320            )
321
322            v -= spacing * 40.0
323            txt_scale = 0.74
324            txt = ba.Lstr(resource=self._r + '.friendsText').evaluate()
325            hval2 = h - 220
326            ba.textwidget(
327                parent=self._subcontainer,
328                position=(hval2, v),
329                size=(0, 0),
330                scale=txt_scale,
331                maxwidth=100,
332                text=txt,
333                h_align='right',
334                color=header,
335                v_align='center',
336                flatness=1.0,
337            )
338
339            txt = ba.Lstr(
340                resource=self._r + '.friendsGoodText',
341                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
342            ).evaluate()
343            txt_scale = 0.7
344            ba.textwidget(
345                parent=self._subcontainer,
346                position=(hval2 + 10, v + 8),
347                size=(0, 0),
348                scale=txt_scale,
349                maxwidth=500,
350                text=txt,
351                h_align='left',
352                color=paragraph,
353                flatness=1.0,
354            )
355
356            app = ba.app
357
358            v -= spacing * 45.0
359            txt = (
360                ba.Lstr(resource=self._r + '.devicesText').evaluate()
361                if app.vr_mode
362                else ba.Lstr(resource=self._r + '.controllersText').evaluate()
363            )
364            txt_scale = 0.74
365            hval2 = h - 220
366            ba.textwidget(
367                parent=self._subcontainer,
368                position=(hval2, v),
369                size=(0, 0),
370                scale=txt_scale,
371                maxwidth=100,
372                text=txt,
373                h_align='right',
374                v_align='center',
375                color=header,
376                flatness=1.0,
377            )
378
379            txt_scale = 0.7
380            if not app.vr_mode:
381                infotxt = (
382                    '.controllersInfoTextRemoteOnly'
383                    if app.iircade_mode
384                    else '.controllersInfoText'
385                )
386                txt = ba.Lstr(
387                    resource=self._r + infotxt,
388                    fallback_resource=self._r + '.controllersInfoText',
389                    subs=[
390                        ('${APP_NAME}', ba.Lstr(resource='titleText')),
391                        ('${REMOTE_APP_NAME}', get_remote_app_name()),
392                    ],
393                ).evaluate()
394            else:
395                txt = ba.Lstr(
396                    resource=self._r + '.devicesInfoText',
397                    subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
398                ).evaluate()
399
400            ba.textwidget(
401                parent=self._subcontainer,
402                position=(hval2 + 10, v + 8),
403                size=(0, 0),
404                scale=txt_scale,
405                maxwidth=500,
406                max_height=105,
407                text=txt,
408                h_align='left',
409                color=paragraph,
410                flatness=1.0,
411            )
412
413        v -= spacing * 150.0
414
415        txt = ba.Lstr(resource=self._r + '.controlsText').evaluate()
416        txt_scale = 1.4
417        txt_maxwidth = 480
418        ba.textwidget(
419            parent=self._subcontainer,
420            position=(h, v),
421            size=(0, 0),
422            scale=txt_scale,
423            flatness=0.5,
424            text=txt,
425            h_align='center',
426            color=header,
427            v_align='center',
428            res_scale=1.5,
429            maxwidth=txt_maxwidth,
430        )
431        txt_width = min(
432            txt_maxwidth,
433            ba.internal.get_string_width(txt, suppress_warning=True)
434            * txt_scale,
435        )
436        icon_size = 70
437
438        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
439        ba.imagewidget(
440            parent=self._subcontainer,
441            size=(icon_size, icon_size),
442            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
443            texture=logo_tex,
444        )
445
446        v -= spacing * 45.0
447
448        txt_scale = 0.7
449        txt = ba.Lstr(
450            resource=self._r + '.controlsSubtitleText',
451            subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
452        ).evaluate()
453        ba.textwidget(
454            parent=self._subcontainer,
455            position=(h, v),
456            size=(0, 0),
457            scale=txt_scale,
458            maxwidth=self._sub_width * 0.9,
459            flatness=1.0,
460            text=txt,
461            h_align='center',
462            color=paragraph,
463            v_align='center',
464        )
465        v -= spacing * 160.0
466
467        sep = 70
468        icon_size = 100
469        # icon_size_2 = 30
470        hval2 = h - sep
471        vval2 = v
472        ba.imagewidget(
473            parent=self._subcontainer,
474            size=(icon_size, icon_size),
475            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
476            texture=ba.gettexture('buttonPunch'),
477            color=(1, 0.7, 0.3),
478        )
479
480        txt_scale = getres(self._r + '.punchInfoTextScale')
481        txt = ba.Lstr(resource=self._r + '.punchInfoText').evaluate()
482        ba.textwidget(
483            parent=self._subcontainer,
484            position=(h - sep - 185 + 70, v + 120),
485            size=(0, 0),
486            scale=txt_scale,
487            flatness=1.0,
488            text=txt,
489            h_align='center',
490            color=(1, 0.7, 0.3, 1.0),
491            v_align='top',
492        )
493
494        hval2 = h + sep
495        vval2 = v
496        ba.imagewidget(
497            parent=self._subcontainer,
498            size=(icon_size, icon_size),
499            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
500            texture=ba.gettexture('buttonBomb'),
501            color=(1, 0.3, 0.3),
502        )
503
504        txt = ba.Lstr(resource=self._r + '.bombInfoText').evaluate()
505        txt_scale = getres(self._r + '.bombInfoTextScale')
506        ba.textwidget(
507            parent=self._subcontainer,
508            position=(h + sep + 50 + 60, v - 35),
509            size=(0, 0),
510            scale=txt_scale,
511            flatness=1.0,
512            maxwidth=270,
513            text=txt,
514            h_align='center',
515            color=(1, 0.3, 0.3, 1.0),
516            v_align='top',
517        )
518
519        hval2 = h
520        vval2 = v + sep
521        ba.imagewidget(
522            parent=self._subcontainer,
523            size=(icon_size, icon_size),
524            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
525            texture=ba.gettexture('buttonPickUp'),
526            color=(0.5, 0.5, 1),
527        )
528
529        txtl = ba.Lstr(resource=self._r + '.pickUpInfoText')
530        txt_scale = getres(self._r + '.pickUpInfoTextScale')
531        ba.textwidget(
532            parent=self._subcontainer,
533            position=(h + 60 + 120, v + sep + 50),
534            size=(0, 0),
535            scale=txt_scale,
536            flatness=1.0,
537            text=txtl,
538            h_align='center',
539            color=(0.5, 0.5, 1, 1.0),
540            v_align='top',
541        )
542
543        hval2 = h
544        vval2 = v - sep
545        ba.imagewidget(
546            parent=self._subcontainer,
547            size=(icon_size, icon_size),
548            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
549            texture=ba.gettexture('buttonJump'),
550            color=(0.4, 1, 0.4),
551        )
552
553        txt = ba.Lstr(resource=self._r + '.jumpInfoText').evaluate()
554        txt_scale = getres(self._r + '.jumpInfoTextScale')
555        ba.textwidget(
556            parent=self._subcontainer,
557            position=(h - 250 + 75, v - sep - 15 + 30),
558            size=(0, 0),
559            scale=txt_scale,
560            flatness=1.0,
561            text=txt,
562            h_align='center',
563            color=(0.4, 1, 0.4, 1.0),
564            v_align='top',
565        )
566
567        txt = ba.Lstr(resource=self._r + '.runInfoText').evaluate()
568        txt_scale = getres(self._r + '.runInfoTextScale')
569        ba.textwidget(
570            parent=self._subcontainer,
571            position=(h, v - sep - 100),
572            size=(0, 0),
573            scale=txt_scale,
574            maxwidth=self._sub_width * 0.93,
575            flatness=1.0,
576            text=txt,
577            h_align='center',
578            color=(0.7, 0.7, 1.0, 1.0),
579            v_align='center',
580        )
581
582        v -= spacing * 280.0
583
584        txt = ba.Lstr(resource=self._r + '.powerupsText').evaluate()
585        txt_scale = 1.4
586        txt_maxwidth = 480
587        ba.textwidget(
588            parent=self._subcontainer,
589            position=(h, v),
590            size=(0, 0),
591            scale=txt_scale,
592            flatness=0.5,
593            text=txt,
594            h_align='center',
595            color=header,
596            v_align='center',
597            maxwidth=txt_maxwidth,
598        )
599        txt_width = min(
600            txt_maxwidth,
601            ba.internal.get_string_width(txt, suppress_warning=True)
602            * txt_scale,
603        )
604        icon_size = 70
605        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
606        ba.imagewidget(
607            parent=self._subcontainer,
608            size=(icon_size, icon_size),
609            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
610            texture=logo_tex,
611        )
612
613        v -= spacing * 50.0
614        txt_scale = getres(self._r + '.powerupsSubtitleTextScale')
615        txt = ba.Lstr(resource=self._r + '.powerupsSubtitleText').evaluate()
616        ba.textwidget(
617            parent=self._subcontainer,
618            position=(h, v),
619            size=(0, 0),
620            scale=txt_scale,
621            maxwidth=self._sub_width * 0.9,
622            text=txt,
623            h_align='center',
624            color=paragraph,
625            v_align='center',
626            flatness=1.0,
627        )
628
629        v -= spacing * 1.0
630
631        mm1 = -270
632        mm2 = -215
633        mm3 = 0
634        icon_size = 50
635        shadow_size = 80
636        shadow_offs_x = 3
637        shadow_offs_y = -4
638        t_big = 1.1
639        t_small = 0.65
640
641        shadow_tex = ba.gettexture('shadowSharp')
642
643        for tex in [
644            'powerupPunch',
645            'powerupShield',
646            'powerupBomb',
647            'powerupHealth',
648            'powerupIceBombs',
649            'powerupImpactBombs',
650            'powerupStickyBombs',
651            'powerupLandMines',
652            'powerupCurse',
653        ]:
654            name = ba.Lstr(resource=self._r + '.' + tex + 'NameText')
655            desc = ba.Lstr(resource=self._r + '.' + tex + 'DescriptionText')
656
657            v -= spacing * 60.0
658
659            ba.imagewidget(
660                parent=self._subcontainer,
661                size=(shadow_size, shadow_size),
662                position=(
663                    h + mm1 + shadow_offs_x - 0.5 * shadow_size,
664                    v + shadow_offs_y - 0.5 * shadow_size,
665                ),
666                texture=shadow_tex,
667                color=(0, 0, 0),
668                opacity=0.5,
669            )
670            ba.imagewidget(
671                parent=self._subcontainer,
672                size=(icon_size, icon_size),
673                position=(h + mm1 - 0.5 * icon_size, v - 0.5 * icon_size),
674                texture=ba.gettexture(tex),
675            )
676
677            txt_scale = t_big
678            txtl = name
679            ba.textwidget(
680                parent=self._subcontainer,
681                position=(h + mm2, v + 3),
682                size=(0, 0),
683                scale=txt_scale,
684                maxwidth=200,
685                flatness=1.0,
686                text=txtl,
687                h_align='left',
688                color=header2,
689                v_align='center',
690            )
691            txt_scale = t_small
692            txtl = desc
693            ba.textwidget(
694                parent=self._subcontainer,
695                position=(h + mm3, v),
696                size=(0, 0),
697                scale=txt_scale,
698                maxwidth=300,
699                flatness=1.0,
700                text=txtl,
701                h_align='left',
702                color=paragraph,
703                v_align='center',
704                res_scale=0.5,
705            )
706
707    def _close(self) -> None:
708        # pylint: disable=cyclic-import
709        from bastd.ui.mainmenu import MainMenuWindow
710
711        ba.containerwidget(
712            edit=self._root_widget, transition=self._transition_out
713        )
714        if self._main_menu:
715            ba.app.ui.set_main_menu_window(
716                MainMenuWindow(transition='in_left').get_root_widget()
717            )
class HelpWindow(ba.ui.Window):
 17class HelpWindow(ba.Window):
 18    """A window providing help on how to play."""
 19
 20    def __init__(
 21        self, main_menu: bool = False, origin_widget: ba.Widget | None = None
 22    ):
 23        # pylint: disable=too-many-statements
 24        # pylint: disable=too-many-locals
 25        from ba.internal import get_remote_app_name
 26
 27        ba.set_analytics_screen('Help Window')
 28
 29        # If they provided an origin-widget, scale up from that.
 30        scale_origin: tuple[float, float] | None
 31        if origin_widget is not None:
 32            self._transition_out = 'out_scale'
 33            scale_origin = origin_widget.get_screen_space_center()
 34            transition = 'in_scale'
 35        else:
 36            self._transition_out = 'out_right'
 37            scale_origin = None
 38            transition = 'in_right'
 39
 40        self._r = 'helpWindow'
 41
 42        getres = ba.app.lang.get_resource
 43
 44        self._main_menu = main_menu
 45        uiscale = ba.app.ui.uiscale
 46        width = 950 if uiscale is ba.UIScale.SMALL else 750
 47        x_offs = 100 if uiscale is ba.UIScale.SMALL else 0
 48        height = (
 49            460
 50            if uiscale is ba.UIScale.SMALL
 51            else 530
 52            if uiscale is ba.UIScale.MEDIUM
 53            else 600
 54        )
 55
 56        super().__init__(
 57            root_widget=ba.containerwidget(
 58                size=(width, height),
 59                transition=transition,
 60                toolbar_visibility='menu_minimal',
 61                scale_origin_stack_offset=scale_origin,
 62                scale=(
 63                    1.77
 64                    if uiscale is ba.UIScale.SMALL
 65                    else 1.25
 66                    if uiscale is ba.UIScale.MEDIUM
 67                    else 1.0
 68                ),
 69                stack_offset=(0, -30)
 70                if uiscale is ba.UIScale.SMALL
 71                else (0, 15)
 72                if uiscale is ba.UIScale.MEDIUM
 73                else (0, 0),
 74            )
 75        )
 76
 77        ba.textwidget(
 78            parent=self._root_widget,
 79            position=(0, height - (50 if uiscale is ba.UIScale.SMALL else 45)),
 80            size=(width, 25),
 81            text=ba.Lstr(
 82                resource=self._r + '.titleText',
 83                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
 84            ),
 85            color=ba.app.ui.title_color,
 86            h_align='center',
 87            v_align='top',
 88        )
 89
 90        self._scrollwidget = ba.scrollwidget(
 91            parent=self._root_widget,
 92            position=(44 + x_offs, 55 if uiscale is ba.UIScale.SMALL else 55),
 93            simple_culling_v=100.0,
 94            size=(
 95                width - (88 + 2 * x_offs),
 96                height - 120 + (5 if uiscale is ba.UIScale.SMALL else 0),
 97            ),
 98            capture_arrows=True,
 99        )
100
101        if ba.app.ui.use_toolbars:
102            ba.widget(
103                edit=self._scrollwidget,
104                right_widget=ba.internal.get_special_widget('party_button'),
105            )
106        ba.containerwidget(
107            edit=self._root_widget, selected_child=self._scrollwidget
108        )
109
110        # ugly: create this last so it gets first dibs at touch events (since
111        # we have it close to the scroll widget)
112        if uiscale is ba.UIScale.SMALL and ba.app.ui.use_toolbars:
113            ba.containerwidget(
114                edit=self._root_widget, on_cancel_call=self._close
115            )
116            ba.widget(
117                edit=self._scrollwidget,
118                left_widget=ba.internal.get_special_widget('back_button'),
119            )
120        else:
121            btn = ba.buttonwidget(
122                parent=self._root_widget,
123                position=(
124                    x_offs + (40 + 0 if uiscale is ba.UIScale.SMALL else 70),
125                    height - (59 if uiscale is ba.UIScale.SMALL else 50),
126                ),
127                size=(140, 60),
128                scale=0.7 if uiscale is ba.UIScale.SMALL else 0.8,
129                label=ba.Lstr(resource='backText')
130                if self._main_menu
131                else 'Close',
132                button_type='back' if self._main_menu else None,
133                extra_touch_border_scale=2.0,
134                autoselect=True,
135                on_activate_call=self._close,
136            )
137            ba.containerwidget(edit=self._root_widget, cancel_button=btn)
138
139            if self._main_menu:
140                ba.buttonwidget(
141                    edit=btn,
142                    button_type='backSmall',
143                    size=(60, 55),
144                    label=ba.charstr(ba.SpecialChar.BACK),
145                )
146
147        self._sub_width = 660
148        self._sub_height = (
149            1590
150            + ba.app.lang.get_resource(self._r + '.someDaysExtraSpace')
151            + ba.app.lang.get_resource(
152                self._r + '.orPunchingSomethingExtraSpace'
153            )
154        )
155
156        self._subcontainer = ba.containerwidget(
157            parent=self._scrollwidget,
158            size=(self._sub_width, self._sub_height),
159            background=False,
160            claims_left_right=False,
161            claims_tab=False,
162        )
163
164        spacing = 1.0
165        h = self._sub_width * 0.5
166        v = self._sub_height - 55
167        logo_tex = ba.gettexture('logo')
168        icon_buffer = 1.1
169        header = (0.7, 1.0, 0.7, 1.0)
170        header2 = (0.8, 0.8, 1.0, 1.0)
171        paragraph = (0.8, 0.8, 1.0, 1.0)
172
173        txt = ba.Lstr(
174            resource=self._r + '.welcomeText',
175            subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
176        ).evaluate()
177        txt_scale = 1.4
178        txt_maxwidth = 480
179        ba.textwidget(
180            parent=self._subcontainer,
181            position=(h, v),
182            size=(0, 0),
183            scale=txt_scale,
184            flatness=0.5,
185            res_scale=1.5,
186            text=txt,
187            h_align='center',
188            color=header,
189            v_align='center',
190            maxwidth=txt_maxwidth,
191        )
192        txt_width = min(
193            txt_maxwidth,
194            ba.internal.get_string_width(txt, suppress_warning=True)
195            * txt_scale,
196        )
197
198        icon_size = 70
199        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
200        ba.imagewidget(
201            parent=self._subcontainer,
202            size=(icon_size, icon_size),
203            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
204            texture=logo_tex,
205        )
206
207        force_test = False
208        app = ba.app
209        if (
210            app.platform == 'android' and app.subplatform == 'alibaba'
211        ) or force_test:
212            v -= 120.0
213            txtv = (
214                '\xe8\xbf\x99\xe6\x98\xaf\xe4\xb8\x80\xe4\xb8\xaa\xe5\x8f\xaf'
215                '\xe4\xbb\xa5\xe5\x92\x8c\xe5\xae\xb6\xe4\xba\xba\xe6\x9c\x8b'
216                '\xe5\x8f\x8b\xe4\xb8\x80\xe8\xb5\xb7\xe7\x8e\xa9\xe7\x9a\x84'
217                '\xe6\xb8\xb8\xe6\x88\x8f,\xe5\x90\x8c\xe6\x97\xb6\xe6\x94\xaf'
218                '\xe6\x8c\x81\xe8\x81\x94 \xe2\x80\xa8\xe7\xbd\x91\xe5\xaf\xb9'
219                '\xe6\x88\x98\xe3\x80\x82\n'
220                '\xe5\xa6\x82\xe6\xb2\xa1\xe6\x9c\x89\xe6\xb8\xb8\xe6\x88\x8f'
221                '\xe6\x89\x8b\xe6\x9f\x84,\xe5\x8f\xaf\xe4\xbb\xa5\xe4\xbd\xbf'
222                '\xe7\x94\xa8\xe7\xa7\xbb\xe5\x8a\xa8\xe8\xae\xbe\xe5\xa4\x87'
223                '\xe6\x89\xab\xe7\xa0\x81\xe4\xb8\x8b\xe8\xbd\xbd\xe2\x80\x9c'
224                '\xe9\x98\xbf\xe9\x87\x8c\xc2'
225                '\xa0TV\xc2\xa0\xe5\x8a\xa9\xe6\x89'
226                '\x8b\xe2\x80\x9d\xe7\x94\xa8 \xe6\x9d\xa5\xe4\xbb\xa3\xe6\x9b'
227                '\xbf\xe5\xa4\x96\xe8\xae\xbe\xe3\x80\x82\n'
228                '\xe6\x9c\x80\xe5\xa4\x9a\xe6\x94\xaf\xe6\x8c\x81\xe6\x8e\xa5'
229                '\xe5\x85\xa5\xc2\xa08\xc2\xa0\xe4\xb8\xaa\xe5\xa4\x96\xe8'
230                '\xae\xbe'
231            )
232            ba.textwidget(
233                parent=self._subcontainer,
234                size=(0, 0),
235                h_align='center',
236                v_align='center',
237                maxwidth=self._sub_width * 0.9,
238                position=(self._sub_width * 0.5, v - 180),
239                text=txtv,
240            )
241            ba.imagewidget(
242                parent=self._subcontainer,
243                position=(self._sub_width - 320, v - 120),
244                size=(200, 200),
245                texture=ba.gettexture('aliControllerQR'),
246            )
247            ba.imagewidget(
248                parent=self._subcontainer,
249                position=(90, v - 130),
250                size=(210, 210),
251                texture=ba.gettexture('multiplayerExamples'),
252            )
253            v -= 120.0
254
255        else:
256            v -= spacing * 50.0
257            txt = ba.Lstr(resource=self._r + '.someDaysText').evaluate()
258            ba.textwidget(
259                parent=self._subcontainer,
260                position=(h, v),
261                size=(0, 0),
262                scale=1.2,
263                maxwidth=self._sub_width * 0.9,
264                text=txt,
265                h_align='center',
266                color=paragraph,
267                v_align='center',
268                flatness=1.0,
269            )
270            v -= spacing * 25.0 + getres(self._r + '.someDaysExtraSpace')
271            txt_scale = 0.66
272            txt = ba.Lstr(
273                resource=self._r + '.orPunchingSomethingText'
274            ).evaluate()
275            ba.textwidget(
276                parent=self._subcontainer,
277                position=(h, v),
278                size=(0, 0),
279                scale=txt_scale,
280                maxwidth=self._sub_width * 0.9,
281                text=txt,
282                h_align='center',
283                color=paragraph,
284                v_align='center',
285                flatness=1.0,
286            )
287            v -= spacing * 27.0 + getres(
288                self._r + '.orPunchingSomethingExtraSpace'
289            )
290            txt_scale = 1.0
291            txt = ba.Lstr(
292                resource=self._r + '.canHelpText',
293                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
294            ).evaluate()
295            ba.textwidget(
296                parent=self._subcontainer,
297                position=(h, v),
298                size=(0, 0),
299                scale=txt_scale,
300                flatness=1.0,
301                text=txt,
302                h_align='center',
303                color=paragraph,
304                v_align='center',
305            )
306
307            v -= spacing * 70.0
308            txt_scale = 1.0
309            txt = ba.Lstr(resource=self._r + '.toGetTheMostText').evaluate()
310            ba.textwidget(
311                parent=self._subcontainer,
312                position=(h, v),
313                size=(0, 0),
314                scale=txt_scale,
315                maxwidth=self._sub_width * 0.9,
316                text=txt,
317                h_align='center',
318                color=header,
319                v_align='center',
320                flatness=1.0,
321            )
322
323            v -= spacing * 40.0
324            txt_scale = 0.74
325            txt = ba.Lstr(resource=self._r + '.friendsText').evaluate()
326            hval2 = h - 220
327            ba.textwidget(
328                parent=self._subcontainer,
329                position=(hval2, v),
330                size=(0, 0),
331                scale=txt_scale,
332                maxwidth=100,
333                text=txt,
334                h_align='right',
335                color=header,
336                v_align='center',
337                flatness=1.0,
338            )
339
340            txt = ba.Lstr(
341                resource=self._r + '.friendsGoodText',
342                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
343            ).evaluate()
344            txt_scale = 0.7
345            ba.textwidget(
346                parent=self._subcontainer,
347                position=(hval2 + 10, v + 8),
348                size=(0, 0),
349                scale=txt_scale,
350                maxwidth=500,
351                text=txt,
352                h_align='left',
353                color=paragraph,
354                flatness=1.0,
355            )
356
357            app = ba.app
358
359            v -= spacing * 45.0
360            txt = (
361                ba.Lstr(resource=self._r + '.devicesText').evaluate()
362                if app.vr_mode
363                else ba.Lstr(resource=self._r + '.controllersText').evaluate()
364            )
365            txt_scale = 0.74
366            hval2 = h - 220
367            ba.textwidget(
368                parent=self._subcontainer,
369                position=(hval2, v),
370                size=(0, 0),
371                scale=txt_scale,
372                maxwidth=100,
373                text=txt,
374                h_align='right',
375                v_align='center',
376                color=header,
377                flatness=1.0,
378            )
379
380            txt_scale = 0.7
381            if not app.vr_mode:
382                infotxt = (
383                    '.controllersInfoTextRemoteOnly'
384                    if app.iircade_mode
385                    else '.controllersInfoText'
386                )
387                txt = ba.Lstr(
388                    resource=self._r + infotxt,
389                    fallback_resource=self._r + '.controllersInfoText',
390                    subs=[
391                        ('${APP_NAME}', ba.Lstr(resource='titleText')),
392                        ('${REMOTE_APP_NAME}', get_remote_app_name()),
393                    ],
394                ).evaluate()
395            else:
396                txt = ba.Lstr(
397                    resource=self._r + '.devicesInfoText',
398                    subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
399                ).evaluate()
400
401            ba.textwidget(
402                parent=self._subcontainer,
403                position=(hval2 + 10, v + 8),
404                size=(0, 0),
405                scale=txt_scale,
406                maxwidth=500,
407                max_height=105,
408                text=txt,
409                h_align='left',
410                color=paragraph,
411                flatness=1.0,
412            )
413
414        v -= spacing * 150.0
415
416        txt = ba.Lstr(resource=self._r + '.controlsText').evaluate()
417        txt_scale = 1.4
418        txt_maxwidth = 480
419        ba.textwidget(
420            parent=self._subcontainer,
421            position=(h, v),
422            size=(0, 0),
423            scale=txt_scale,
424            flatness=0.5,
425            text=txt,
426            h_align='center',
427            color=header,
428            v_align='center',
429            res_scale=1.5,
430            maxwidth=txt_maxwidth,
431        )
432        txt_width = min(
433            txt_maxwidth,
434            ba.internal.get_string_width(txt, suppress_warning=True)
435            * txt_scale,
436        )
437        icon_size = 70
438
439        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
440        ba.imagewidget(
441            parent=self._subcontainer,
442            size=(icon_size, icon_size),
443            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
444            texture=logo_tex,
445        )
446
447        v -= spacing * 45.0
448
449        txt_scale = 0.7
450        txt = ba.Lstr(
451            resource=self._r + '.controlsSubtitleText',
452            subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
453        ).evaluate()
454        ba.textwidget(
455            parent=self._subcontainer,
456            position=(h, v),
457            size=(0, 0),
458            scale=txt_scale,
459            maxwidth=self._sub_width * 0.9,
460            flatness=1.0,
461            text=txt,
462            h_align='center',
463            color=paragraph,
464            v_align='center',
465        )
466        v -= spacing * 160.0
467
468        sep = 70
469        icon_size = 100
470        # icon_size_2 = 30
471        hval2 = h - sep
472        vval2 = v
473        ba.imagewidget(
474            parent=self._subcontainer,
475            size=(icon_size, icon_size),
476            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
477            texture=ba.gettexture('buttonPunch'),
478            color=(1, 0.7, 0.3),
479        )
480
481        txt_scale = getres(self._r + '.punchInfoTextScale')
482        txt = ba.Lstr(resource=self._r + '.punchInfoText').evaluate()
483        ba.textwidget(
484            parent=self._subcontainer,
485            position=(h - sep - 185 + 70, v + 120),
486            size=(0, 0),
487            scale=txt_scale,
488            flatness=1.0,
489            text=txt,
490            h_align='center',
491            color=(1, 0.7, 0.3, 1.0),
492            v_align='top',
493        )
494
495        hval2 = h + sep
496        vval2 = v
497        ba.imagewidget(
498            parent=self._subcontainer,
499            size=(icon_size, icon_size),
500            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
501            texture=ba.gettexture('buttonBomb'),
502            color=(1, 0.3, 0.3),
503        )
504
505        txt = ba.Lstr(resource=self._r + '.bombInfoText').evaluate()
506        txt_scale = getres(self._r + '.bombInfoTextScale')
507        ba.textwidget(
508            parent=self._subcontainer,
509            position=(h + sep + 50 + 60, v - 35),
510            size=(0, 0),
511            scale=txt_scale,
512            flatness=1.0,
513            maxwidth=270,
514            text=txt,
515            h_align='center',
516            color=(1, 0.3, 0.3, 1.0),
517            v_align='top',
518        )
519
520        hval2 = h
521        vval2 = v + sep
522        ba.imagewidget(
523            parent=self._subcontainer,
524            size=(icon_size, icon_size),
525            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
526            texture=ba.gettexture('buttonPickUp'),
527            color=(0.5, 0.5, 1),
528        )
529
530        txtl = ba.Lstr(resource=self._r + '.pickUpInfoText')
531        txt_scale = getres(self._r + '.pickUpInfoTextScale')
532        ba.textwidget(
533            parent=self._subcontainer,
534            position=(h + 60 + 120, v + sep + 50),
535            size=(0, 0),
536            scale=txt_scale,
537            flatness=1.0,
538            text=txtl,
539            h_align='center',
540            color=(0.5, 0.5, 1, 1.0),
541            v_align='top',
542        )
543
544        hval2 = h
545        vval2 = v - sep
546        ba.imagewidget(
547            parent=self._subcontainer,
548            size=(icon_size, icon_size),
549            position=(hval2 - 0.5 * icon_size, vval2 - 0.5 * icon_size),
550            texture=ba.gettexture('buttonJump'),
551            color=(0.4, 1, 0.4),
552        )
553
554        txt = ba.Lstr(resource=self._r + '.jumpInfoText').evaluate()
555        txt_scale = getres(self._r + '.jumpInfoTextScale')
556        ba.textwidget(
557            parent=self._subcontainer,
558            position=(h - 250 + 75, v - sep - 15 + 30),
559            size=(0, 0),
560            scale=txt_scale,
561            flatness=1.0,
562            text=txt,
563            h_align='center',
564            color=(0.4, 1, 0.4, 1.0),
565            v_align='top',
566        )
567
568        txt = ba.Lstr(resource=self._r + '.runInfoText').evaluate()
569        txt_scale = getres(self._r + '.runInfoTextScale')
570        ba.textwidget(
571            parent=self._subcontainer,
572            position=(h, v - sep - 100),
573            size=(0, 0),
574            scale=txt_scale,
575            maxwidth=self._sub_width * 0.93,
576            flatness=1.0,
577            text=txt,
578            h_align='center',
579            color=(0.7, 0.7, 1.0, 1.0),
580            v_align='center',
581        )
582
583        v -= spacing * 280.0
584
585        txt = ba.Lstr(resource=self._r + '.powerupsText').evaluate()
586        txt_scale = 1.4
587        txt_maxwidth = 480
588        ba.textwidget(
589            parent=self._subcontainer,
590            position=(h, v),
591            size=(0, 0),
592            scale=txt_scale,
593            flatness=0.5,
594            text=txt,
595            h_align='center',
596            color=header,
597            v_align='center',
598            maxwidth=txt_maxwidth,
599        )
600        txt_width = min(
601            txt_maxwidth,
602            ba.internal.get_string_width(txt, suppress_warning=True)
603            * txt_scale,
604        )
605        icon_size = 70
606        hval2 = h - (txt_width * 0.5 + icon_size * 0.5 * icon_buffer)
607        ba.imagewidget(
608            parent=self._subcontainer,
609            size=(icon_size, icon_size),
610            position=(hval2 - 0.5 * icon_size, v - 0.45 * icon_size),
611            texture=logo_tex,
612        )
613
614        v -= spacing * 50.0
615        txt_scale = getres(self._r + '.powerupsSubtitleTextScale')
616        txt = ba.Lstr(resource=self._r + '.powerupsSubtitleText').evaluate()
617        ba.textwidget(
618            parent=self._subcontainer,
619            position=(h, v),
620            size=(0, 0),
621            scale=txt_scale,
622            maxwidth=self._sub_width * 0.9,
623            text=txt,
624            h_align='center',
625            color=paragraph,
626            v_align='center',
627            flatness=1.0,
628        )
629
630        v -= spacing * 1.0
631
632        mm1 = -270
633        mm2 = -215
634        mm3 = 0
635        icon_size = 50
636        shadow_size = 80
637        shadow_offs_x = 3
638        shadow_offs_y = -4
639        t_big = 1.1
640        t_small = 0.65
641
642        shadow_tex = ba.gettexture('shadowSharp')
643
644        for tex in [
645            'powerupPunch',
646            'powerupShield',
647            'powerupBomb',
648            'powerupHealth',
649            'powerupIceBombs',
650            'powerupImpactBombs',
651            'powerupStickyBombs',
652            'powerupLandMines',
653            'powerupCurse',
654        ]:
655            name = ba.Lstr(resource=self._r + '.' + tex + 'NameText')
656            desc = ba.Lstr(resource=self._r + '.' + tex + 'DescriptionText')
657
658            v -= spacing * 60.0
659
660            ba.imagewidget(
661                parent=self._subcontainer,
662                size=(shadow_size, shadow_size),
663                position=(
664                    h + mm1 + shadow_offs_x - 0.5 * shadow_size,
665                    v + shadow_offs_y - 0.5 * shadow_size,
666                ),
667                texture=shadow_tex,
668                color=(0, 0, 0),
669                opacity=0.5,
670            )
671            ba.imagewidget(
672                parent=self._subcontainer,
673                size=(icon_size, icon_size),
674                position=(h + mm1 - 0.5 * icon_size, v - 0.5 * icon_size),
675                texture=ba.gettexture(tex),
676            )
677
678            txt_scale = t_big
679            txtl = name
680            ba.textwidget(
681                parent=self._subcontainer,
682                position=(h + mm2, v + 3),
683                size=(0, 0),
684                scale=txt_scale,
685                maxwidth=200,
686                flatness=1.0,
687                text=txtl,
688                h_align='left',
689                color=header2,
690                v_align='center',
691            )
692            txt_scale = t_small
693            txtl = desc
694            ba.textwidget(
695                parent=self._subcontainer,
696                position=(h + mm3, v),
697                size=(0, 0),
698                scale=txt_scale,
699                maxwidth=300,
700                flatness=1.0,
701                text=txtl,
702                h_align='left',
703                color=paragraph,
704                v_align='center',
705                res_scale=0.5,
706            )
707
708    def _close(self) -> None:
709        # pylint: disable=cyclic-import
710        from bastd.ui.mainmenu import MainMenuWindow
711
712        ba.containerwidget(
713            edit=self._root_widget, transition=self._transition_out
714        )
715        if self._main_menu:
716            ba.app.ui.set_main_menu_window(
717                MainMenuWindow(transition='in_left').get_root_widget()
718            )

A window providing help on how to play.

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