bauiv1lib.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 bauiv1 as bui 8 9 10class ReportPlayerWindow(bui.Window): 11 """Player for reporting naughty players.""" 12 13 def __init__(self, account_id: str, origin_widget: bui.Widget): 14 self._width = 550 15 self._height = 220 16 self._account_id = account_id 17 self._transition_out = 'out_scale' 18 scale_origin = origin_widget.get_screen_space_center() 19 20 overlay_stack = bui.get_special_widget('overlay_stack') 21 assert bui.app.classic is not None 22 uiscale = bui.app.ui_v1.uiscale 23 super().__init__( 24 root_widget=bui.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 bui.UIScale.SMALL 32 else 1.35 33 if uiscale is bui.UIScale.MEDIUM 34 else 1.0 35 ), 36 ) 37 ) 38 self._cancel_button = bui.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=bui.gettexture('crossOut'), 48 iconscale=1.2, 49 ) 50 bui.containerwidget( 51 edit=self._root_widget, cancel_button=self._cancel_button 52 ) 53 bui.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=bui.Lstr(resource='reportThisPlayerReasonText'), 62 maxwidth=self._width * 0.85, 63 ) 64 bui.buttonwidget( 65 parent=self._root_widget, 66 size=(235, 60), 67 position=(20, 30), 68 label=bui.Lstr(resource='reportThisPlayerLanguageText'), 69 on_activate_call=self._on_language_press, 70 autoselect=True, 71 ) 72 bui.buttonwidget( 73 parent=self._root_widget, 74 size=(235, 60), 75 position=(self._width - 255, 30), 76 label=bui.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 plus = bui.app.plus 85 assert plus is not None 86 87 plus.add_v1_account_transaction( 88 { 89 'type': 'REPORT_ACCOUNT', 90 'reason': 'language', 91 'account': self._account_id, 92 } 93 ) 94 body = bui.Lstr(resource='reportPlayerExplanationText').evaluate() 95 bui.open_url( 96 'mailto:support@froemling.net' 97 f'?subject={bui.appnameupper()} Player Report: ' 98 + self._account_id 99 + '&body=' 100 + parse.quote(body) 101 ) 102 self.close() 103 104 def _on_cheating_press(self) -> None: 105 from urllib import parse 106 107 plus = bui.app.plus 108 assert plus is not None 109 110 plus.add_v1_account_transaction( 111 { 112 'type': 'REPORT_ACCOUNT', 113 'reason': 'cheating', 114 'account': self._account_id, 115 } 116 ) 117 body = bui.Lstr(resource='reportPlayerExplanationText').evaluate() 118 bui.open_url( 119 'mailto:support@froemling.net' 120 f'?subject={bui.appnameupper()} Player Report: ' 121 + self._account_id 122 + '&body=' 123 + parse.quote(body) 124 ) 125 self.close() 126 127 def close(self) -> None: 128 """Close the window.""" 129 bui.containerwidget(edit=self._root_widget, transition='out_scale')
class
ReportPlayerWindow(bauiv1._uitypes.Window):
11class ReportPlayerWindow(bui.Window): 12 """Player for reporting naughty players.""" 13 14 def __init__(self, account_id: str, origin_widget: bui.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 = bui.get_special_widget('overlay_stack') 22 assert bui.app.classic is not None 23 uiscale = bui.app.ui_v1.uiscale 24 super().__init__( 25 root_widget=bui.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 bui.UIScale.SMALL 33 else 1.35 34 if uiscale is bui.UIScale.MEDIUM 35 else 1.0 36 ), 37 ) 38 ) 39 self._cancel_button = bui.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=bui.gettexture('crossOut'), 49 iconscale=1.2, 50 ) 51 bui.containerwidget( 52 edit=self._root_widget, cancel_button=self._cancel_button 53 ) 54 bui.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=bui.Lstr(resource='reportThisPlayerReasonText'), 63 maxwidth=self._width * 0.85, 64 ) 65 bui.buttonwidget( 66 parent=self._root_widget, 67 size=(235, 60), 68 position=(20, 30), 69 label=bui.Lstr(resource='reportThisPlayerLanguageText'), 70 on_activate_call=self._on_language_press, 71 autoselect=True, 72 ) 73 bui.buttonwidget( 74 parent=self._root_widget, 75 size=(235, 60), 76 position=(self._width - 255, 30), 77 label=bui.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 plus = bui.app.plus 86 assert plus is not None 87 88 plus.add_v1_account_transaction( 89 { 90 'type': 'REPORT_ACCOUNT', 91 'reason': 'language', 92 'account': self._account_id, 93 } 94 ) 95 body = bui.Lstr(resource='reportPlayerExplanationText').evaluate() 96 bui.open_url( 97 'mailto:support@froemling.net' 98 f'?subject={bui.appnameupper()} Player Report: ' 99 + self._account_id 100 + '&body=' 101 + parse.quote(body) 102 ) 103 self.close() 104 105 def _on_cheating_press(self) -> None: 106 from urllib import parse 107 108 plus = bui.app.plus 109 assert plus is not None 110 111 plus.add_v1_account_transaction( 112 { 113 'type': 'REPORT_ACCOUNT', 114 'reason': 'cheating', 115 'account': self._account_id, 116 } 117 ) 118 body = bui.Lstr(resource='reportPlayerExplanationText').evaluate() 119 bui.open_url( 120 'mailto:support@froemling.net' 121 f'?subject={bui.appnameupper()} Player Report: ' 122 + self._account_id 123 + '&body=' 124 + parse.quote(body) 125 ) 126 self.close() 127 128 def close(self) -> None: 129 """Close the window.""" 130 bui.containerwidget(edit=self._root_widget, transition='out_scale')
Player for reporting naughty players.
ReportPlayerWindow(account_id: str, origin_widget: _bauiv1.Widget)
14 def __init__(self, account_id: str, origin_widget: bui.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 = bui.get_special_widget('overlay_stack') 22 assert bui.app.classic is not None 23 uiscale = bui.app.ui_v1.uiscale 24 super().__init__( 25 root_widget=bui.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 bui.UIScale.SMALL 33 else 1.35 34 if uiscale is bui.UIScale.MEDIUM 35 else 1.0 36 ), 37 ) 38 ) 39 self._cancel_button = bui.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=bui.gettexture('crossOut'), 49 iconscale=1.2, 50 ) 51 bui.containerwidget( 52 edit=self._root_widget, cancel_button=self._cancel_button 53 ) 54 bui.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=bui.Lstr(resource='reportThisPlayerReasonText'), 63 maxwidth=self._width * 0.85, 64 ) 65 bui.buttonwidget( 66 parent=self._root_widget, 67 size=(235, 60), 68 position=(20, 30), 69 label=bui.Lstr(resource='reportThisPlayerLanguageText'), 70 on_activate_call=self._on_language_press, 71 autoselect=True, 72 ) 73 bui.buttonwidget( 74 parent=self._root_widget, 75 size=(235, 60), 76 position=(self._width - 255, 30), 77 label=bui.Lstr(resource='reportThisPlayerCheatingText'), 78 on_activate_call=self._on_cheating_press, 79 autoselect=True, 80 )
def
close(self) -> None:
128 def close(self) -> None: 129 """Close the window.""" 130 bui.containerwidget(edit=self._root_widget, transition='out_scale')
Close the window.
Inherited Members
- bauiv1._uitypes.Window
- get_root_widget