bastd.ui.v2upgrade
UI for upgrading V1 accounts to V2.
1# Released under the MIT License. See LICENSE for details. 2# 3"""UI for upgrading V1 accounts to V2.""" 4 5from __future__ import annotations 6 7import ba 8import ba.internal 9 10 11class V2UpgradeWindow(ba.Window): 12 """A window presenting a URL to the user visually.""" 13 14 def __init__(self, login_name: str, code: str): 15 from bastd.ui.account.settings import show_what_is_v2_page 16 17 app = ba.app 18 uiscale = app.ui.uiscale 19 20 self._code = code 21 22 self._width = 700 23 self._height = 270 24 super().__init__( 25 root_widget=ba.containerwidget( 26 size=(self._width, self._height + 40), 27 transition='in_right', 28 scale=( 29 1.25 30 if uiscale is ba.UIScale.SMALL 31 else 1.25 32 if uiscale is ba.UIScale.MEDIUM 33 else 1.25 34 ), 35 ) 36 ) 37 ba.playsound(ba.getsound('error')) 38 39 ba.textwidget( 40 parent=self._root_widget, 41 position=(self._width * 0.5, self._height - 46), 42 size=(0, 0), 43 color=ba.app.ui.title_color, 44 h_align='center', 45 v_align='center', 46 text=ba.Lstr( 47 resource='deviceAccountUpgradeText', 48 subs=[('${NAME}', login_name)], 49 ), 50 maxwidth=self._width * 0.95, 51 ) 52 ba.textwidget( 53 parent=self._root_widget, 54 position=(self._width * 0.5, 125), 55 size=(0, 0), 56 scale=0.8, 57 color=(0.7, 0.8, 0.7), 58 h_align='center', 59 v_align='center', 60 text=( 61 ba.charstr(ba.SpecialChar.LOCAL_ACCOUNT) 62 + login_name 63 + ' ----> ' 64 + ba.charstr(ba.SpecialChar.V2_LOGO) 65 + login_name 66 ), 67 maxwidth=self._width * 0.95, 68 ) 69 button_width = 200 70 71 cancel_button = ba.buttonwidget( 72 parent=self._root_widget, 73 position=(20, 25), 74 size=(button_width, 65), 75 autoselect=True, 76 label=ba.Lstr(resource='notNowText'), 77 on_activate_call=self._done, 78 ) 79 80 _what_is_this_button = ba.buttonwidget( 81 parent=self._root_widget, 82 position=(self._width * 0.5 - button_width * 0.5, 25), 83 size=(button_width, 65), 84 autoselect=True, 85 label=ba.Lstr(resource='whatIsThisText'), 86 color=(0.55, 0.5, 0.6), 87 textcolor=(0.75, 0.7, 0.8), 88 on_activate_call=show_what_is_v2_page, 89 ) 90 91 upgrade_button = ba.buttonwidget( 92 parent=self._root_widget, 93 position=(self._width - button_width - 20, 25), 94 size=(button_width, 65), 95 autoselect=True, 96 label=ba.Lstr(resource='upgradeText'), 97 on_activate_call=self._upgrade_press, 98 ) 99 100 ba.containerwidget( 101 edit=self._root_widget, 102 selected_child=upgrade_button, 103 cancel_button=cancel_button, 104 ) 105 106 def _upgrade_press(self) -> None: 107 # Get rid of the window and sign out before kicking the 108 # user over to a browser to do the upgrade. This hopefully 109 # makes it more clear when they come back that they need to 110 # sign in with the 'BombSquad account' option. 111 ba.containerwidget(edit=self._root_widget, transition='out_left') 112 ba.internal.sign_out_v1() 113 bamasteraddr = ba.internal.get_master_server_address(version=2) 114 ba.open_url(f'{bamasteraddr}/v2uda/{self._code}') 115 116 def _done(self) -> None: 117 ba.containerwidget(edit=self._root_widget, transition='out_left')
class
V2UpgradeWindow(ba.ui.Window):
12class V2UpgradeWindow(ba.Window): 13 """A window presenting a URL to the user visually.""" 14 15 def __init__(self, login_name: str, code: str): 16 from bastd.ui.account.settings import show_what_is_v2_page 17 18 app = ba.app 19 uiscale = app.ui.uiscale 20 21 self._code = code 22 23 self._width = 700 24 self._height = 270 25 super().__init__( 26 root_widget=ba.containerwidget( 27 size=(self._width, self._height + 40), 28 transition='in_right', 29 scale=( 30 1.25 31 if uiscale is ba.UIScale.SMALL 32 else 1.25 33 if uiscale is ba.UIScale.MEDIUM 34 else 1.25 35 ), 36 ) 37 ) 38 ba.playsound(ba.getsound('error')) 39 40 ba.textwidget( 41 parent=self._root_widget, 42 position=(self._width * 0.5, self._height - 46), 43 size=(0, 0), 44 color=ba.app.ui.title_color, 45 h_align='center', 46 v_align='center', 47 text=ba.Lstr( 48 resource='deviceAccountUpgradeText', 49 subs=[('${NAME}', login_name)], 50 ), 51 maxwidth=self._width * 0.95, 52 ) 53 ba.textwidget( 54 parent=self._root_widget, 55 position=(self._width * 0.5, 125), 56 size=(0, 0), 57 scale=0.8, 58 color=(0.7, 0.8, 0.7), 59 h_align='center', 60 v_align='center', 61 text=( 62 ba.charstr(ba.SpecialChar.LOCAL_ACCOUNT) 63 + login_name 64 + ' ----> ' 65 + ba.charstr(ba.SpecialChar.V2_LOGO) 66 + login_name 67 ), 68 maxwidth=self._width * 0.95, 69 ) 70 button_width = 200 71 72 cancel_button = ba.buttonwidget( 73 parent=self._root_widget, 74 position=(20, 25), 75 size=(button_width, 65), 76 autoselect=True, 77 label=ba.Lstr(resource='notNowText'), 78 on_activate_call=self._done, 79 ) 80 81 _what_is_this_button = ba.buttonwidget( 82 parent=self._root_widget, 83 position=(self._width * 0.5 - button_width * 0.5, 25), 84 size=(button_width, 65), 85 autoselect=True, 86 label=ba.Lstr(resource='whatIsThisText'), 87 color=(0.55, 0.5, 0.6), 88 textcolor=(0.75, 0.7, 0.8), 89 on_activate_call=show_what_is_v2_page, 90 ) 91 92 upgrade_button = ba.buttonwidget( 93 parent=self._root_widget, 94 position=(self._width - button_width - 20, 25), 95 size=(button_width, 65), 96 autoselect=True, 97 label=ba.Lstr(resource='upgradeText'), 98 on_activate_call=self._upgrade_press, 99 ) 100 101 ba.containerwidget( 102 edit=self._root_widget, 103 selected_child=upgrade_button, 104 cancel_button=cancel_button, 105 ) 106 107 def _upgrade_press(self) -> None: 108 # Get rid of the window and sign out before kicking the 109 # user over to a browser to do the upgrade. This hopefully 110 # makes it more clear when they come back that they need to 111 # sign in with the 'BombSquad account' option. 112 ba.containerwidget(edit=self._root_widget, transition='out_left') 113 ba.internal.sign_out_v1() 114 bamasteraddr = ba.internal.get_master_server_address(version=2) 115 ba.open_url(f'{bamasteraddr}/v2uda/{self._code}') 116 117 def _done(self) -> None: 118 ba.containerwidget(edit=self._root_widget, transition='out_left')
A window presenting a URL to the user visually.
V2UpgradeWindow(login_name: str, code: str)
15 def __init__(self, login_name: str, code: str): 16 from bastd.ui.account.settings import show_what_is_v2_page 17 18 app = ba.app 19 uiscale = app.ui.uiscale 20 21 self._code = code 22 23 self._width = 700 24 self._height = 270 25 super().__init__( 26 root_widget=ba.containerwidget( 27 size=(self._width, self._height + 40), 28 transition='in_right', 29 scale=( 30 1.25 31 if uiscale is ba.UIScale.SMALL 32 else 1.25 33 if uiscale is ba.UIScale.MEDIUM 34 else 1.25 35 ), 36 ) 37 ) 38 ba.playsound(ba.getsound('error')) 39 40 ba.textwidget( 41 parent=self._root_widget, 42 position=(self._width * 0.5, self._height - 46), 43 size=(0, 0), 44 color=ba.app.ui.title_color, 45 h_align='center', 46 v_align='center', 47 text=ba.Lstr( 48 resource='deviceAccountUpgradeText', 49 subs=[('${NAME}', login_name)], 50 ), 51 maxwidth=self._width * 0.95, 52 ) 53 ba.textwidget( 54 parent=self._root_widget, 55 position=(self._width * 0.5, 125), 56 size=(0, 0), 57 scale=0.8, 58 color=(0.7, 0.8, 0.7), 59 h_align='center', 60 v_align='center', 61 text=( 62 ba.charstr(ba.SpecialChar.LOCAL_ACCOUNT) 63 + login_name 64 + ' ----> ' 65 + ba.charstr(ba.SpecialChar.V2_LOGO) 66 + login_name 67 ), 68 maxwidth=self._width * 0.95, 69 ) 70 button_width = 200 71 72 cancel_button = ba.buttonwidget( 73 parent=self._root_widget, 74 position=(20, 25), 75 size=(button_width, 65), 76 autoselect=True, 77 label=ba.Lstr(resource='notNowText'), 78 on_activate_call=self._done, 79 ) 80 81 _what_is_this_button = ba.buttonwidget( 82 parent=self._root_widget, 83 position=(self._width * 0.5 - button_width * 0.5, 25), 84 size=(button_width, 65), 85 autoselect=True, 86 label=ba.Lstr(resource='whatIsThisText'), 87 color=(0.55, 0.5, 0.6), 88 textcolor=(0.75, 0.7, 0.8), 89 on_activate_call=show_what_is_v2_page, 90 ) 91 92 upgrade_button = ba.buttonwidget( 93 parent=self._root_widget, 94 position=(self._width - button_width - 20, 25), 95 size=(button_width, 65), 96 autoselect=True, 97 label=ba.Lstr(resource='upgradeText'), 98 on_activate_call=self._upgrade_press, 99 ) 100 101 ba.containerwidget( 102 edit=self._root_widget, 103 selected_child=upgrade_button, 104 cancel_button=cancel_button, 105 )
Inherited Members
- ba.ui.Window
- get_root_widget