bastd.ui.report
UI related to reporting bad behavior/etc.
1# Released under the MIT License. See LICENSE for details. 2# 3"""UI related to reporting bad behavior/etc.""" 4 5from __future__ import annotations 6 7import _ba 8import ba 9 10 11class ReportPlayerWindow(ba.Window): 12 """Player for reporting naughty players.""" 13 14 def __init__(self, account_id: str, origin_widget: ba.Widget): 15 self._width = 550 16 self._height = 220 17 self._account_id = account_id 18 self._transition_out = 'out_scale' 19 scale_origin = origin_widget.get_screen_space_center() 20 21 overlay_stack = _ba.get_special_widget('overlay_stack') 22 uiscale = ba.app.ui.uiscale 23 super().__init__(root_widget=ba.containerwidget( 24 size=(self._width, self._height), 25 parent=overlay_stack, 26 transition='in_scale', 27 scale_origin_stack_offset=scale_origin, 28 scale=(1.8 if uiscale is ba.UIScale.SMALL else 29 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0))) 30 self._cancel_button = ba.buttonwidget(parent=self._root_widget, 31 scale=0.7, 32 position=(40, self._height - 50), 33 size=(50, 50), 34 label='', 35 on_activate_call=self.close, 36 autoselect=True, 37 color=(0.4, 0.4, 0.5), 38 icon=ba.gettexture('crossOut'), 39 iconscale=1.2) 40 ba.containerwidget(edit=self._root_widget, 41 cancel_button=self._cancel_button) 42 ba.textwidget(parent=self._root_widget, 43 position=(self._width * 0.5, self._height * 0.64), 44 size=(0, 0), 45 color=(1, 1, 1, 0.8), 46 scale=1.2, 47 h_align='center', 48 v_align='center', 49 text=ba.Lstr(resource='reportThisPlayerReasonText'), 50 maxwidth=self._width * 0.85) 51 ba.buttonwidget(parent=self._root_widget, 52 size=(235, 60), 53 position=(20, 30), 54 label=ba.Lstr(resource='reportThisPlayerLanguageText'), 55 on_activate_call=self._on_language_press, 56 autoselect=True) 57 ba.buttonwidget(parent=self._root_widget, 58 size=(235, 60), 59 position=(self._width - 255, 30), 60 label=ba.Lstr(resource='reportThisPlayerCheatingText'), 61 on_activate_call=self._on_cheating_press, 62 autoselect=True) 63 64 def _on_language_press(self) -> None: 65 from urllib import parse 66 _ba.add_transaction({ 67 'type': 'REPORT_ACCOUNT', 68 'reason': 'language', 69 'account': self._account_id 70 }) 71 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 72 ba.open_url('mailto:support@froemling.net' 73 f'?subject={_ba.appnameupper()} Player Report: ' + 74 self._account_id + '&body=' + parse.quote(body)) 75 self.close() 76 77 def _on_cheating_press(self) -> None: 78 from urllib import parse 79 _ba.add_transaction({ 80 'type': 'REPORT_ACCOUNT', 81 'reason': 'cheating', 82 'account': self._account_id 83 }) 84 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 85 ba.open_url('mailto:support@froemling.net' 86 f'?subject={_ba.appnameupper()} Player Report: ' + 87 self._account_id + '&body=' + parse.quote(body)) 88 self.close() 89 90 def close(self) -> None: 91 """Close the window.""" 92 ba.containerwidget(edit=self._root_widget, transition='out_scale')
class
ReportPlayerWindow(ba.ui.Window):
12class ReportPlayerWindow(ba.Window): 13 """Player for reporting naughty players.""" 14 15 def __init__(self, account_id: str, origin_widget: ba.Widget): 16 self._width = 550 17 self._height = 220 18 self._account_id = account_id 19 self._transition_out = 'out_scale' 20 scale_origin = origin_widget.get_screen_space_center() 21 22 overlay_stack = _ba.get_special_widget('overlay_stack') 23 uiscale = ba.app.ui.uiscale 24 super().__init__(root_widget=ba.containerwidget( 25 size=(self._width, self._height), 26 parent=overlay_stack, 27 transition='in_scale', 28 scale_origin_stack_offset=scale_origin, 29 scale=(1.8 if uiscale is ba.UIScale.SMALL else 30 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0))) 31 self._cancel_button = ba.buttonwidget(parent=self._root_widget, 32 scale=0.7, 33 position=(40, self._height - 50), 34 size=(50, 50), 35 label='', 36 on_activate_call=self.close, 37 autoselect=True, 38 color=(0.4, 0.4, 0.5), 39 icon=ba.gettexture('crossOut'), 40 iconscale=1.2) 41 ba.containerwidget(edit=self._root_widget, 42 cancel_button=self._cancel_button) 43 ba.textwidget(parent=self._root_widget, 44 position=(self._width * 0.5, self._height * 0.64), 45 size=(0, 0), 46 color=(1, 1, 1, 0.8), 47 scale=1.2, 48 h_align='center', 49 v_align='center', 50 text=ba.Lstr(resource='reportThisPlayerReasonText'), 51 maxwidth=self._width * 0.85) 52 ba.buttonwidget(parent=self._root_widget, 53 size=(235, 60), 54 position=(20, 30), 55 label=ba.Lstr(resource='reportThisPlayerLanguageText'), 56 on_activate_call=self._on_language_press, 57 autoselect=True) 58 ba.buttonwidget(parent=self._root_widget, 59 size=(235, 60), 60 position=(self._width - 255, 30), 61 label=ba.Lstr(resource='reportThisPlayerCheatingText'), 62 on_activate_call=self._on_cheating_press, 63 autoselect=True) 64 65 def _on_language_press(self) -> None: 66 from urllib import parse 67 _ba.add_transaction({ 68 'type': 'REPORT_ACCOUNT', 69 'reason': 'language', 70 'account': self._account_id 71 }) 72 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 73 ba.open_url('mailto:support@froemling.net' 74 f'?subject={_ba.appnameupper()} Player Report: ' + 75 self._account_id + '&body=' + parse.quote(body)) 76 self.close() 77 78 def _on_cheating_press(self) -> None: 79 from urllib import parse 80 _ba.add_transaction({ 81 'type': 'REPORT_ACCOUNT', 82 'reason': 'cheating', 83 'account': self._account_id 84 }) 85 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 86 ba.open_url('mailto:support@froemling.net' 87 f'?subject={_ba.appnameupper()} Player Report: ' + 88 self._account_id + '&body=' + parse.quote(body)) 89 self.close() 90 91 def close(self) -> None: 92 """Close the window.""" 93 ba.containerwidget(edit=self._root_widget, transition='out_scale')
Player for reporting naughty players.
ReportPlayerWindow(account_id: str, origin_widget: _ba.Widget)
15 def __init__(self, account_id: str, origin_widget: ba.Widget): 16 self._width = 550 17 self._height = 220 18 self._account_id = account_id 19 self._transition_out = 'out_scale' 20 scale_origin = origin_widget.get_screen_space_center() 21 22 overlay_stack = _ba.get_special_widget('overlay_stack') 23 uiscale = ba.app.ui.uiscale 24 super().__init__(root_widget=ba.containerwidget( 25 size=(self._width, self._height), 26 parent=overlay_stack, 27 transition='in_scale', 28 scale_origin_stack_offset=scale_origin, 29 scale=(1.8 if uiscale is ba.UIScale.SMALL else 30 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0))) 31 self._cancel_button = ba.buttonwidget(parent=self._root_widget, 32 scale=0.7, 33 position=(40, self._height - 50), 34 size=(50, 50), 35 label='', 36 on_activate_call=self.close, 37 autoselect=True, 38 color=(0.4, 0.4, 0.5), 39 icon=ba.gettexture('crossOut'), 40 iconscale=1.2) 41 ba.containerwidget(edit=self._root_widget, 42 cancel_button=self._cancel_button) 43 ba.textwidget(parent=self._root_widget, 44 position=(self._width * 0.5, self._height * 0.64), 45 size=(0, 0), 46 color=(1, 1, 1, 0.8), 47 scale=1.2, 48 h_align='center', 49 v_align='center', 50 text=ba.Lstr(resource='reportThisPlayerReasonText'), 51 maxwidth=self._width * 0.85) 52 ba.buttonwidget(parent=self._root_widget, 53 size=(235, 60), 54 position=(20, 30), 55 label=ba.Lstr(resource='reportThisPlayerLanguageText'), 56 on_activate_call=self._on_language_press, 57 autoselect=True) 58 ba.buttonwidget(parent=self._root_widget, 59 size=(235, 60), 60 position=(self._width - 255, 30), 61 label=ba.Lstr(resource='reportThisPlayerCheatingText'), 62 on_activate_call=self._on_cheating_press, 63 autoselect=True)
def
close(self) -> None:
91 def close(self) -> None: 92 """Close the window.""" 93 ba.containerwidget(edit=self._root_widget, transition='out_scale')
Close the window.
Inherited Members
- ba.ui.Window
- get_root_widget