mirror of
https://github.com/hypervortex/VH-Bombsquad-Modded-Server-Files
synced 2025-11-07 17:36:08 +00:00
117 lines
3.7 KiB
Python
117 lines
3.7 KiB
Python
# Released under the MIT License. See LICENSE for details.
|
|
#
|
|
"""UI for upgrading V1 accounts to V2."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import ba
|
|
import ba.internal
|
|
|
|
|
|
class V2UpgradeWindow(ba.Window):
|
|
"""A window presenting a URL to the user visually."""
|
|
|
|
def __init__(self, login_name: str, code: str):
|
|
from bastd.ui.account.settings import show_what_is_v2_page
|
|
|
|
app = ba.app
|
|
uiscale = app.ui.uiscale
|
|
|
|
self._code = code
|
|
|
|
self._width = 700
|
|
self._height = 270
|
|
super().__init__(
|
|
root_widget=ba.containerwidget(
|
|
size=(self._width, self._height + 40),
|
|
transition='in_right',
|
|
scale=(
|
|
1.25
|
|
if uiscale is ba.UIScale.SMALL
|
|
else 1.25
|
|
if uiscale is ba.UIScale.MEDIUM
|
|
else 1.25
|
|
),
|
|
)
|
|
)
|
|
ba.playsound(ba.getsound('error'))
|
|
|
|
ba.textwidget(
|
|
parent=self._root_widget,
|
|
position=(self._width * 0.5, self._height - 46),
|
|
size=(0, 0),
|
|
color=ba.app.ui.title_color,
|
|
h_align='center',
|
|
v_align='center',
|
|
text=ba.Lstr(
|
|
resource='deviceAccountUpgradeText',
|
|
subs=[('${NAME}', login_name)],
|
|
),
|
|
maxwidth=self._width * 0.95,
|
|
)
|
|
ba.textwidget(
|
|
parent=self._root_widget,
|
|
position=(self._width * 0.5, 125),
|
|
size=(0, 0),
|
|
scale=0.8,
|
|
color=(0.7, 0.8, 0.7),
|
|
h_align='center',
|
|
v_align='center',
|
|
text=(
|
|
ba.charstr(ba.SpecialChar.LOCAL_ACCOUNT)
|
|
+ login_name
|
|
+ ' ----> '
|
|
+ ba.charstr(ba.SpecialChar.V2_LOGO)
|
|
+ login_name
|
|
),
|
|
maxwidth=self._width * 0.95,
|
|
)
|
|
button_width = 200
|
|
|
|
cancel_button = ba.buttonwidget(
|
|
parent=self._root_widget,
|
|
position=(20, 25),
|
|
size=(button_width, 65),
|
|
autoselect=True,
|
|
label=ba.Lstr(resource='notNowText'),
|
|
on_activate_call=self._done,
|
|
)
|
|
|
|
_what_is_this_button = ba.buttonwidget(
|
|
parent=self._root_widget,
|
|
position=(self._width * 0.5 - button_width * 0.5, 25),
|
|
size=(button_width, 65),
|
|
autoselect=True,
|
|
label=ba.Lstr(resource='whatIsThisText'),
|
|
color=(0.55, 0.5, 0.6),
|
|
textcolor=(0.75, 0.7, 0.8),
|
|
on_activate_call=show_what_is_v2_page,
|
|
)
|
|
|
|
upgrade_button = ba.buttonwidget(
|
|
parent=self._root_widget,
|
|
position=(self._width - button_width - 20, 25),
|
|
size=(button_width, 65),
|
|
autoselect=True,
|
|
label=ba.Lstr(resource='upgradeText'),
|
|
on_activate_call=self._upgrade_press,
|
|
)
|
|
|
|
ba.containerwidget(
|
|
edit=self._root_widget,
|
|
selected_child=upgrade_button,
|
|
cancel_button=cancel_button,
|
|
)
|
|
|
|
def _upgrade_press(self) -> None:
|
|
# Get rid of the window and sign out before kicking the
|
|
# user over to a browser to do the upgrade. This hopefully
|
|
# makes it more clear when they come back that they need to
|
|
# sign in with the 'BombSquad account' option.
|
|
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
|
ba.internal.sign_out_v1()
|
|
bamasteraddr = ba.internal.get_master_server_address(version=2)
|
|
ba.open_url(f'{bamasteraddr}/v2uda/{self._code}')
|
|
|
|
def _done(self) -> None:
|
|
ba.containerwidget(edit=self._root_widget, transition='out_left')
|