bastd.ui.coop.level

Bits of utility functionality related to co-op levels.

 1# Released under the MIT License. See LICENSE for details.
 2#
 3"""Bits of utility functionality related to co-op levels."""
 4
 5from __future__ import annotations
 6
 7import ba
 8
 9
10class CoopLevelLockedWindow(ba.Window):
11    """Window showing that a level is locked."""
12
13    def __init__(self, name: ba.Lstr, dep_name: ba.Lstr):
14        width = 550.0
15        height = 250.0
16        lock_tex = ba.gettexture('lock')
17        uiscale = ba.app.ui.uiscale
18        super().__init__(root_widget=ba.containerwidget(
19            size=(width, height),
20            transition='in_right',
21            scale=(1.7 if uiscale is ba.UIScale.SMALL else
22                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0)))
23        ba.textwidget(parent=self._root_widget,
24                      position=(150 - 20, height * 0.63),
25                      size=(0, 0),
26                      h_align='left',
27                      v_align='center',
28                      text=ba.Lstr(resource='levelIsLockedText',
29                                   subs=[('${LEVEL}', name)]),
30                      maxwidth=400,
31                      color=(1, 0.8, 0.3, 1),
32                      scale=1.1)
33        ba.textwidget(parent=self._root_widget,
34                      position=(150 - 20, height * 0.48),
35                      size=(0, 0),
36                      h_align='left',
37                      v_align='center',
38                      text=ba.Lstr(resource='levelMustBeCompletedFirstText',
39                                   subs=[('${LEVEL}', dep_name)]),
40                      maxwidth=400,
41                      color=ba.app.ui.infotextcolor,
42                      scale=0.8)
43        ba.imagewidget(parent=self._root_widget,
44                       position=(56 - 20, height * 0.39),
45                       size=(80, 80),
46                       texture=lock_tex,
47                       opacity=1.0)
48        btn = ba.buttonwidget(parent=self._root_widget,
49                              position=((width - 140) / 2, 30),
50                              size=(140, 50),
51                              label=ba.Lstr(resource='okText'),
52                              on_activate_call=self._ok)
53        ba.containerwidget(edit=self._root_widget,
54                           selected_child=btn,
55                           start_button=btn)
56        ba.playsound(ba.getsound('error'))
57
58    def _ok(self) -> None:
59        ba.containerwidget(edit=self._root_widget, transition='out_left')
class CoopLevelLockedWindow(ba.ui.Window):
11class CoopLevelLockedWindow(ba.Window):
12    """Window showing that a level is locked."""
13
14    def __init__(self, name: ba.Lstr, dep_name: ba.Lstr):
15        width = 550.0
16        height = 250.0
17        lock_tex = ba.gettexture('lock')
18        uiscale = ba.app.ui.uiscale
19        super().__init__(root_widget=ba.containerwidget(
20            size=(width, height),
21            transition='in_right',
22            scale=(1.7 if uiscale is ba.UIScale.SMALL else
23                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0)))
24        ba.textwidget(parent=self._root_widget,
25                      position=(150 - 20, height * 0.63),
26                      size=(0, 0),
27                      h_align='left',
28                      v_align='center',
29                      text=ba.Lstr(resource='levelIsLockedText',
30                                   subs=[('${LEVEL}', name)]),
31                      maxwidth=400,
32                      color=(1, 0.8, 0.3, 1),
33                      scale=1.1)
34        ba.textwidget(parent=self._root_widget,
35                      position=(150 - 20, height * 0.48),
36                      size=(0, 0),
37                      h_align='left',
38                      v_align='center',
39                      text=ba.Lstr(resource='levelMustBeCompletedFirstText',
40                                   subs=[('${LEVEL}', dep_name)]),
41                      maxwidth=400,
42                      color=ba.app.ui.infotextcolor,
43                      scale=0.8)
44        ba.imagewidget(parent=self._root_widget,
45                       position=(56 - 20, height * 0.39),
46                       size=(80, 80),
47                       texture=lock_tex,
48                       opacity=1.0)
49        btn = ba.buttonwidget(parent=self._root_widget,
50                              position=((width - 140) / 2, 30),
51                              size=(140, 50),
52                              label=ba.Lstr(resource='okText'),
53                              on_activate_call=self._ok)
54        ba.containerwidget(edit=self._root_widget,
55                           selected_child=btn,
56                           start_button=btn)
57        ba.playsound(ba.getsound('error'))
58
59    def _ok(self) -> None:
60        ba.containerwidget(edit=self._root_widget, transition='out_left')

Window showing that a level is locked.

CoopLevelLockedWindow(name: ba._language.Lstr, dep_name: ba._language.Lstr)
14    def __init__(self, name: ba.Lstr, dep_name: ba.Lstr):
15        width = 550.0
16        height = 250.0
17        lock_tex = ba.gettexture('lock')
18        uiscale = ba.app.ui.uiscale
19        super().__init__(root_widget=ba.containerwidget(
20            size=(width, height),
21            transition='in_right',
22            scale=(1.7 if uiscale is ba.UIScale.SMALL else
23                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0)))
24        ba.textwidget(parent=self._root_widget,
25                      position=(150 - 20, height * 0.63),
26                      size=(0, 0),
27                      h_align='left',
28                      v_align='center',
29                      text=ba.Lstr(resource='levelIsLockedText',
30                                   subs=[('${LEVEL}', name)]),
31                      maxwidth=400,
32                      color=(1, 0.8, 0.3, 1),
33                      scale=1.1)
34        ba.textwidget(parent=self._root_widget,
35                      position=(150 - 20, height * 0.48),
36                      size=(0, 0),
37                      h_align='left',
38                      v_align='center',
39                      text=ba.Lstr(resource='levelMustBeCompletedFirstText',
40                                   subs=[('${LEVEL}', dep_name)]),
41                      maxwidth=400,
42                      color=ba.app.ui.infotextcolor,
43                      scale=0.8)
44        ba.imagewidget(parent=self._root_widget,
45                       position=(56 - 20, height * 0.39),
46                       size=(80, 80),
47                       texture=lock_tex,
48                       opacity=1.0)
49        btn = ba.buttonwidget(parent=self._root_widget,
50                              position=((width - 140) / 2, 30),
51                              size=(140, 50),
52                              label=ba.Lstr(resource='okText'),
53                              on_activate_call=self._ok)
54        ba.containerwidget(edit=self._root_widget,
55                           selected_child=btn,
56                           start_button=btn)
57        ba.playsound(ba.getsound('error'))
Inherited Members
ba.ui.Window
get_root_widget