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