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.internal 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.internal.get_special_widget('overlay_stack') 22 uiscale = ba.app.ui.uiscale 23 super().__init__( 24 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=( 30 1.8 31 if uiscale is ba.UIScale.SMALL 32 else 1.35 33 if uiscale is ba.UIScale.MEDIUM 34 else 1.0 35 ), 36 ) 37 ) 38 self._cancel_button = ba.buttonwidget( 39 parent=self._root_widget, 40 scale=0.7, 41 position=(40, self._height - 50), 42 size=(50, 50), 43 label='', 44 on_activate_call=self.close, 45 autoselect=True, 46 color=(0.4, 0.4, 0.5), 47 icon=ba.gettexture('crossOut'), 48 iconscale=1.2, 49 ) 50 ba.containerwidget( 51 edit=self._root_widget, cancel_button=self._cancel_button 52 ) 53 ba.textwidget( 54 parent=self._root_widget, 55 position=(self._width * 0.5, self._height * 0.64), 56 size=(0, 0), 57 color=(1, 1, 1, 0.8), 58 scale=1.2, 59 h_align='center', 60 v_align='center', 61 text=ba.Lstr(resource='reportThisPlayerReasonText'), 62 maxwidth=self._width * 0.85, 63 ) 64 ba.buttonwidget( 65 parent=self._root_widget, 66 size=(235, 60), 67 position=(20, 30), 68 label=ba.Lstr(resource='reportThisPlayerLanguageText'), 69 on_activate_call=self._on_language_press, 70 autoselect=True, 71 ) 72 ba.buttonwidget( 73 parent=self._root_widget, 74 size=(235, 60), 75 position=(self._width - 255, 30), 76 label=ba.Lstr(resource='reportThisPlayerCheatingText'), 77 on_activate_call=self._on_cheating_press, 78 autoselect=True, 79 ) 80 81 def _on_language_press(self) -> None: 82 from urllib import parse 83 84 ba.internal.add_transaction( 85 { 86 'type': 'REPORT_ACCOUNT', 87 'reason': 'language', 88 'account': self._account_id, 89 } 90 ) 91 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 92 ba.open_url( 93 'mailto:support@froemling.net' 94 f'?subject={ba.internal.appnameupper()} Player Report: ' 95 + self._account_id 96 + '&body=' 97 + parse.quote(body) 98 ) 99 self.close() 100 101 def _on_cheating_press(self) -> None: 102 from urllib import parse 103 104 ba.internal.add_transaction( 105 { 106 'type': 'REPORT_ACCOUNT', 107 'reason': 'cheating', 108 'account': self._account_id, 109 } 110 ) 111 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 112 ba.open_url( 113 'mailto:support@froemling.net' 114 f'?subject={ba.internal.appnameupper()} Player Report: ' 115 + self._account_id 116 + '&body=' 117 + parse.quote(body) 118 ) 119 self.close() 120 121 def close(self) -> None: 122 """Close the window.""" 123 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.internal.get_special_widget('overlay_stack') 23 uiscale = ba.app.ui.uiscale 24 super().__init__( 25 root_widget=ba.containerwidget( 26 size=(self._width, self._height), 27 parent=overlay_stack, 28 transition='in_scale', 29 scale_origin_stack_offset=scale_origin, 30 scale=( 31 1.8 32 if uiscale is ba.UIScale.SMALL 33 else 1.35 34 if uiscale is ba.UIScale.MEDIUM 35 else 1.0 36 ), 37 ) 38 ) 39 self._cancel_button = ba.buttonwidget( 40 parent=self._root_widget, 41 scale=0.7, 42 position=(40, self._height - 50), 43 size=(50, 50), 44 label='', 45 on_activate_call=self.close, 46 autoselect=True, 47 color=(0.4, 0.4, 0.5), 48 icon=ba.gettexture('crossOut'), 49 iconscale=1.2, 50 ) 51 ba.containerwidget( 52 edit=self._root_widget, cancel_button=self._cancel_button 53 ) 54 ba.textwidget( 55 parent=self._root_widget, 56 position=(self._width * 0.5, self._height * 0.64), 57 size=(0, 0), 58 color=(1, 1, 1, 0.8), 59 scale=1.2, 60 h_align='center', 61 v_align='center', 62 text=ba.Lstr(resource='reportThisPlayerReasonText'), 63 maxwidth=self._width * 0.85, 64 ) 65 ba.buttonwidget( 66 parent=self._root_widget, 67 size=(235, 60), 68 position=(20, 30), 69 label=ba.Lstr(resource='reportThisPlayerLanguageText'), 70 on_activate_call=self._on_language_press, 71 autoselect=True, 72 ) 73 ba.buttonwidget( 74 parent=self._root_widget, 75 size=(235, 60), 76 position=(self._width - 255, 30), 77 label=ba.Lstr(resource='reportThisPlayerCheatingText'), 78 on_activate_call=self._on_cheating_press, 79 autoselect=True, 80 ) 81 82 def _on_language_press(self) -> None: 83 from urllib import parse 84 85 ba.internal.add_transaction( 86 { 87 'type': 'REPORT_ACCOUNT', 88 'reason': 'language', 89 'account': self._account_id, 90 } 91 ) 92 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 93 ba.open_url( 94 'mailto:support@froemling.net' 95 f'?subject={ba.internal.appnameupper()} Player Report: ' 96 + self._account_id 97 + '&body=' 98 + parse.quote(body) 99 ) 100 self.close() 101 102 def _on_cheating_press(self) -> None: 103 from urllib import parse 104 105 ba.internal.add_transaction( 106 { 107 'type': 'REPORT_ACCOUNT', 108 'reason': 'cheating', 109 'account': self._account_id, 110 } 111 ) 112 body = ba.Lstr(resource='reportPlayerExplanationText').evaluate() 113 ba.open_url( 114 'mailto:support@froemling.net' 115 f'?subject={ba.internal.appnameupper()} Player Report: ' 116 + self._account_id 117 + '&body=' 118 + parse.quote(body) 119 ) 120 self.close() 121 122 def close(self) -> None: 123 """Close the window.""" 124 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.internal.get_special_widget('overlay_stack') 23 uiscale = ba.app.ui.uiscale 24 super().__init__( 25 root_widget=ba.containerwidget( 26 size=(self._width, self._height), 27 parent=overlay_stack, 28 transition='in_scale', 29 scale_origin_stack_offset=scale_origin, 30 scale=( 31 1.8 32 if uiscale is ba.UIScale.SMALL 33 else 1.35 34 if uiscale is ba.UIScale.MEDIUM 35 else 1.0 36 ), 37 ) 38 ) 39 self._cancel_button = ba.buttonwidget( 40 parent=self._root_widget, 41 scale=0.7, 42 position=(40, self._height - 50), 43 size=(50, 50), 44 label='', 45 on_activate_call=self.close, 46 autoselect=True, 47 color=(0.4, 0.4, 0.5), 48 icon=ba.gettexture('crossOut'), 49 iconscale=1.2, 50 ) 51 ba.containerwidget( 52 edit=self._root_widget, cancel_button=self._cancel_button 53 ) 54 ba.textwidget( 55 parent=self._root_widget, 56 position=(self._width * 0.5, self._height * 0.64), 57 size=(0, 0), 58 color=(1, 1, 1, 0.8), 59 scale=1.2, 60 h_align='center', 61 v_align='center', 62 text=ba.Lstr(resource='reportThisPlayerReasonText'), 63 maxwidth=self._width * 0.85, 64 ) 65 ba.buttonwidget( 66 parent=self._root_widget, 67 size=(235, 60), 68 position=(20, 30), 69 label=ba.Lstr(resource='reportThisPlayerLanguageText'), 70 on_activate_call=self._on_language_press, 71 autoselect=True, 72 ) 73 ba.buttonwidget( 74 parent=self._root_widget, 75 size=(235, 60), 76 position=(self._width - 255, 30), 77 label=ba.Lstr(resource='reportThisPlayerCheatingText'), 78 on_activate_call=self._on_cheating_press, 79 autoselect=True, 80 )
def
close(self) -> None:
122 def close(self) -> None: 123 """Close the window.""" 124 ba.containerwidget(edit=self._root_widget, transition='out_scale')
Close the window.
Inherited Members
- ba.ui.Window
- get_root_widget