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