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

A window providing help on how to play.

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