bauiv1lib.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 bauiv1 as bui 8 9 10class CoopLevelLockedWindow(bui.Window): 11 """Window showing that a level is locked.""" 12 13 def __init__(self, name: bui.Lstr, dep_name: bui.Lstr): 14 width = 550.0 15 height = 250.0 16 lock_tex = bui.gettexture('lock') 17 assert bui.app.classic is not None 18 uiscale = bui.app.ui_v1.uiscale 19 super().__init__( 20 root_widget=bui.containerwidget( 21 size=(width, height), 22 transition='in_right', 23 scale=( 24 1.7 25 if uiscale is bui.UIScale.SMALL 26 else 1.3 27 if uiscale is bui.UIScale.MEDIUM 28 else 1.0 29 ), 30 ) 31 ) 32 bui.textwidget( 33 parent=self._root_widget, 34 position=(150 - 20, height * 0.63), 35 size=(0, 0), 36 h_align='left', 37 v_align='center', 38 text=bui.Lstr( 39 resource='levelIsLockedText', subs=[('${LEVEL}', name)] 40 ), 41 maxwidth=400, 42 color=(1, 0.8, 0.3, 1), 43 scale=1.1, 44 ) 45 bui.textwidget( 46 parent=self._root_widget, 47 position=(150 - 20, height * 0.48), 48 size=(0, 0), 49 h_align='left', 50 v_align='center', 51 text=bui.Lstr( 52 resource='levelMustBeCompletedFirstText', 53 subs=[('${LEVEL}', dep_name)], 54 ), 55 maxwidth=400, 56 color=bui.app.ui_v1.infotextcolor, 57 scale=0.8, 58 ) 59 bui.imagewidget( 60 parent=self._root_widget, 61 position=(56 - 20, height * 0.39), 62 size=(80, 80), 63 texture=lock_tex, 64 opacity=1.0, 65 ) 66 btn = bui.buttonwidget( 67 parent=self._root_widget, 68 position=((width - 140) / 2, 30), 69 size=(140, 50), 70 label=bui.Lstr(resource='okText'), 71 on_activate_call=self._ok, 72 ) 73 bui.containerwidget( 74 edit=self._root_widget, selected_child=btn, start_button=btn 75 ) 76 bui.getsound('error').play() 77 78 def _ok(self) -> None: 79 bui.containerwidget(edit=self._root_widget, transition='out_left')
class
CoopLevelLockedWindow(bauiv1._uitypes.Window):
11class CoopLevelLockedWindow(bui.Window): 12 """Window showing that a level is locked.""" 13 14 def __init__(self, name: bui.Lstr, dep_name: bui.Lstr): 15 width = 550.0 16 height = 250.0 17 lock_tex = bui.gettexture('lock') 18 assert bui.app.classic is not None 19 uiscale = bui.app.ui_v1.uiscale 20 super().__init__( 21 root_widget=bui.containerwidget( 22 size=(width, height), 23 transition='in_right', 24 scale=( 25 1.7 26 if uiscale is bui.UIScale.SMALL 27 else 1.3 28 if uiscale is bui.UIScale.MEDIUM 29 else 1.0 30 ), 31 ) 32 ) 33 bui.textwidget( 34 parent=self._root_widget, 35 position=(150 - 20, height * 0.63), 36 size=(0, 0), 37 h_align='left', 38 v_align='center', 39 text=bui.Lstr( 40 resource='levelIsLockedText', subs=[('${LEVEL}', name)] 41 ), 42 maxwidth=400, 43 color=(1, 0.8, 0.3, 1), 44 scale=1.1, 45 ) 46 bui.textwidget( 47 parent=self._root_widget, 48 position=(150 - 20, height * 0.48), 49 size=(0, 0), 50 h_align='left', 51 v_align='center', 52 text=bui.Lstr( 53 resource='levelMustBeCompletedFirstText', 54 subs=[('${LEVEL}', dep_name)], 55 ), 56 maxwidth=400, 57 color=bui.app.ui_v1.infotextcolor, 58 scale=0.8, 59 ) 60 bui.imagewidget( 61 parent=self._root_widget, 62 position=(56 - 20, height * 0.39), 63 size=(80, 80), 64 texture=lock_tex, 65 opacity=1.0, 66 ) 67 btn = bui.buttonwidget( 68 parent=self._root_widget, 69 position=((width - 140) / 2, 30), 70 size=(140, 50), 71 label=bui.Lstr(resource='okText'), 72 on_activate_call=self._ok, 73 ) 74 bui.containerwidget( 75 edit=self._root_widget, selected_child=btn, start_button=btn 76 ) 77 bui.getsound('error').play() 78 79 def _ok(self) -> None: 80 bui.containerwidget(edit=self._root_widget, transition='out_left')
Window showing that a level is locked.
CoopLevelLockedWindow(name: babase._language.Lstr, dep_name: babase._language.Lstr)
14 def __init__(self, name: bui.Lstr, dep_name: bui.Lstr): 15 width = 550.0 16 height = 250.0 17 lock_tex = bui.gettexture('lock') 18 assert bui.app.classic is not None 19 uiscale = bui.app.ui_v1.uiscale 20 super().__init__( 21 root_widget=bui.containerwidget( 22 size=(width, height), 23 transition='in_right', 24 scale=( 25 1.7 26 if uiscale is bui.UIScale.SMALL 27 else 1.3 28 if uiscale is bui.UIScale.MEDIUM 29 else 1.0 30 ), 31 ) 32 ) 33 bui.textwidget( 34 parent=self._root_widget, 35 position=(150 - 20, height * 0.63), 36 size=(0, 0), 37 h_align='left', 38 v_align='center', 39 text=bui.Lstr( 40 resource='levelIsLockedText', subs=[('${LEVEL}', name)] 41 ), 42 maxwidth=400, 43 color=(1, 0.8, 0.3, 1), 44 scale=1.1, 45 ) 46 bui.textwidget( 47 parent=self._root_widget, 48 position=(150 - 20, height * 0.48), 49 size=(0, 0), 50 h_align='left', 51 v_align='center', 52 text=bui.Lstr( 53 resource='levelMustBeCompletedFirstText', 54 subs=[('${LEVEL}', dep_name)], 55 ), 56 maxwidth=400, 57 color=bui.app.ui_v1.infotextcolor, 58 scale=0.8, 59 ) 60 bui.imagewidget( 61 parent=self._root_widget, 62 position=(56 - 20, height * 0.39), 63 size=(80, 80), 64 texture=lock_tex, 65 opacity=1.0, 66 ) 67 btn = bui.buttonwidget( 68 parent=self._root_widget, 69 position=((width - 140) / 2, 30), 70 size=(140, 50), 71 label=bui.Lstr(resource='okText'), 72 on_activate_call=self._ok, 73 ) 74 bui.containerwidget( 75 edit=self._root_widget, selected_child=btn, start_button=btn 76 ) 77 bui.getsound('error').play()
Inherited Members
- bauiv1._uitypes.Window
- get_root_widget