bastd.ui.resourcetypeinfo
Provides a window which shows info about resource types.
1# Released under the MIT License. See LICENSE for details. 2# 3"""Provides a window which shows info about resource types.""" 4 5from __future__ import annotations 6 7import ba 8from bastd.ui import popup 9 10 11class ResourceTypeInfoWindow(popup.PopupWindow): 12 """Popup window providing info about resource types.""" 13 14 def __init__(self, origin_widget: ba.Widget): 15 uiscale = ba.app.ui.uiscale 16 scale = ( 17 2.3 18 if uiscale is ba.UIScale.SMALL 19 else 1.65 20 if uiscale is ba.UIScale.MEDIUM 21 else 1.23 22 ) 23 self._transitioning_out = False 24 self._width = 570 25 self._height = 350 26 bg_color = (0.5, 0.4, 0.6) 27 popup.PopupWindow.__init__( 28 self, 29 size=(self._width, self._height), 30 toolbar_visibility='inherit', 31 scale=scale, 32 bg_color=bg_color, 33 position=origin_widget.get_screen_space_center(), 34 ) 35 self._cancel_button = ba.buttonwidget( 36 parent=self.root_widget, 37 position=(50, self._height - 30), 38 size=(50, 50), 39 scale=0.5, 40 label='', 41 color=bg_color, 42 on_activate_call=self._on_cancel_press, 43 autoselect=True, 44 icon=ba.gettexture('crossOut'), 45 iconscale=1.2, 46 ) 47 48 def _on_cancel_press(self) -> None: 49 self._transition_out() 50 51 def _transition_out(self) -> None: 52 if not self._transitioning_out: 53 self._transitioning_out = True 54 ba.containerwidget(edit=self.root_widget, transition='out_scale') 55 56 def on_popup_cancel(self) -> None: 57 ba.playsound(ba.getsound('swish')) 58 self._transition_out()
12class ResourceTypeInfoWindow(popup.PopupWindow): 13 """Popup window providing info about resource types.""" 14 15 def __init__(self, origin_widget: ba.Widget): 16 uiscale = ba.app.ui.uiscale 17 scale = ( 18 2.3 19 if uiscale is ba.UIScale.SMALL 20 else 1.65 21 if uiscale is ba.UIScale.MEDIUM 22 else 1.23 23 ) 24 self._transitioning_out = False 25 self._width = 570 26 self._height = 350 27 bg_color = (0.5, 0.4, 0.6) 28 popup.PopupWindow.__init__( 29 self, 30 size=(self._width, self._height), 31 toolbar_visibility='inherit', 32 scale=scale, 33 bg_color=bg_color, 34 position=origin_widget.get_screen_space_center(), 35 ) 36 self._cancel_button = ba.buttonwidget( 37 parent=self.root_widget, 38 position=(50, self._height - 30), 39 size=(50, 50), 40 scale=0.5, 41 label='', 42 color=bg_color, 43 on_activate_call=self._on_cancel_press, 44 autoselect=True, 45 icon=ba.gettexture('crossOut'), 46 iconscale=1.2, 47 ) 48 49 def _on_cancel_press(self) -> None: 50 self._transition_out() 51 52 def _transition_out(self) -> None: 53 if not self._transitioning_out: 54 self._transitioning_out = True 55 ba.containerwidget(edit=self.root_widget, transition='out_scale') 56 57 def on_popup_cancel(self) -> None: 58 ba.playsound(ba.getsound('swish')) 59 self._transition_out()
Popup window providing info about resource types.
ResourceTypeInfoWindow(origin_widget: _ba.Widget)
15 def __init__(self, origin_widget: ba.Widget): 16 uiscale = ba.app.ui.uiscale 17 scale = ( 18 2.3 19 if uiscale is ba.UIScale.SMALL 20 else 1.65 21 if uiscale is ba.UIScale.MEDIUM 22 else 1.23 23 ) 24 self._transitioning_out = False 25 self._width = 570 26 self._height = 350 27 bg_color = (0.5, 0.4, 0.6) 28 popup.PopupWindow.__init__( 29 self, 30 size=(self._width, self._height), 31 toolbar_visibility='inherit', 32 scale=scale, 33 bg_color=bg_color, 34 position=origin_widget.get_screen_space_center(), 35 ) 36 self._cancel_button = ba.buttonwidget( 37 parent=self.root_widget, 38 position=(50, self._height - 30), 39 size=(50, 50), 40 scale=0.5, 41 label='', 42 color=bg_color, 43 on_activate_call=self._on_cancel_press, 44 autoselect=True, 45 icon=ba.gettexture('crossOut'), 46 iconscale=1.2, 47 )