From ceb8f5f00b9b59f84c623b89b1691272b50f6758 Mon Sep 17 00:00:00 2001 From: A Dhextras <104954857+DhextraS@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:56:43 +0530 Subject: [PATCH 01/17] Update utilities.json --- plugins/utilities.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 2169f4d2..f71b99ff 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -422,6 +422,7 @@ } ], "versions": { + "2.0.0":null, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -739,4 +740,4 @@ } } } -} \ No newline at end of file +} From 768280103f24fb7abad11e36d8e2e3bf1da41a34 Mon Sep 17 00:00:00 2001 From: A Dhextras <104954857+DhextraS@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:57:58 +0530 Subject: [PATCH 02/17] Update server_switch.py --- plugins/utilities/server_switch.py | 225 +++++++++++++++-------------- 1 file changed, 114 insertions(+), 111 deletions(-) diff --git a/plugins/utilities/server_switch.py b/plugins/utilities/server_switch.py index ecd3c398..3c246c76 100644 --- a/plugins/utilities/server_switch.py +++ b/plugins/utilities/server_switch.py @@ -1,33 +1,34 @@ +# discord @mr.smoothy#5824 -# ba_meta require api 7 +# ba_meta require api 8 from __future__ import annotations import copy import time from typing import TYPE_CHECKING -import _ba -import ba +import babase +import bauiv1 as bui +import bascenev1 as bs +import _bascenev1 as _bs import time import threading from enum import Enum from dataclasses import dataclass if TYPE_CHECKING: from typing import Any, Optional, Dict, List, Tuple, Type - import ba - from bastd.ui.gather import GatherWindow + import bascenev1 as bs + from bauiv1lib.gather import GatherWindow -from bastd.ui.confirm import ConfirmWindow -# discord @mr.smoothy#5824 +from bauiv1lib.confirm import ConfirmWindow -import bastd.ui.mainmenu as bastd_ui_mainmenu +import bauiv1lib.mainmenu as bastd_ui_mainmenu -connect = ba.internal.connect_to_party -disconnect = ba.internal.disconnect_from_host +connect = bs.connect_to_party +disconnect = bs.disconnect_from_host server = [] - ip_add = "private" p_port = 44444 p_name = "nothing here" @@ -36,9 +37,9 @@ def newconnect_to_party(address, port=43210, print_progress=False): global ip_add global p_port - dd = _ba.get_connection_to_host_info() + dd = _bs.get_connection_to_host_info() if (dd != {}): - _ba.disconnect_from_host() + _bs.disconnect_from_host() ip_add = address p_port = port @@ -53,7 +54,7 @@ def newconnect_to_party(address, port=43210, print_progress=False): def newdisconnect_from_host(): try: - name = _ba.get_connection_to_host_info()['name'] + name = _bs.get_connection_to_host_info()['name'] global server global ip_add global p_port @@ -67,7 +68,7 @@ def newdisconnect_from_host(): def printip(): - ba.screenmessage("ip address is"+ip_add) + bs.screenmessage("ip address is"+ip_add) def new_refresh_in_game( @@ -77,19 +78,19 @@ def new_refresh_in_game( # pylint: disable=too-many-locals # pylint: disable=too-many-statements custom_menu_entries: List[Dict[str, Any]] = [] - session = _ba.get_foreground_host_session() + session = _bs.get_foreground_host_session() if session is not None: try: custom_menu_entries = session.get_custom_menu_entries() for cme in custom_menu_entries: if (not isinstance(cme, dict) or 'label' not in cme - or not isinstance(cme['label'], (str, ba.Lstr)) + or not isinstance(cme['label'], (str, bs.Lstr)) or 'call' not in cme or not callable(cme['call'])): raise ValueError('invalid custom menu entry: ' + str(cme)) except Exception: custom_menu_entries = [] - ba.print_exception( + babase.print_exception( f'Error getting custom menu entries for {session}') self._width = 250.0 self._height = 250.0 if self._input_player else 180.0 @@ -101,12 +102,12 @@ def new_refresh_in_game( # In this case we have a leave *and* a disconnect button. self._height += 50 self._height += 50 * (len(custom_menu_entries)) - uiscale = ba.app.ui.uiscale - ba.containerwidget( + uiscale = bui.app.ui_v1.uiscale + bui.containerwidget( edit=self._root_widget, size=(self._width*2, self._height), - scale=(2.15 if uiscale is ba.UIScale.SMALL else - 1.6 if uiscale is ba.UIScale.MEDIUM else 1.0)) + scale=(2.15 if uiscale is bui.UIScale.SMALL else + 1.6 if uiscale is bui.UIScale.MEDIUM else 1.0)) h = 125.0 v = (self._height - 80.0 if self._input_player else self._height - 60) h_offset = 0 @@ -118,9 +119,9 @@ def new_refresh_in_game( h += h_offset h_offset += d_h_offset self._start_button = None - ba.app.pause() + bui.app.pause() h, v, scale = positions[self._p_index] - ba.textwidget( + bui.textwidget( parent=self._root_widget, draw_controller=None, text="IP: "+ip_add+" PORT: "+str(p_port), @@ -139,10 +140,10 @@ def con(address, port): if (address == ip_add and port == p_port): self._resume() else: - _ba.disconnect_from_host() - _ba.connect_to_party(address, port) + _bs.disconnect_from_host() + _bs.connect_to_party(address, port) if len(server) == 0: - ba.textwidget( + bui.textwidget( parent=self._root_widget, draw_controller=None, text="Nothing in \n recents", @@ -152,7 +153,7 @@ def con(address, port): size=(20, 60), scale=1) for ser in server: - self._server_button = ba.buttonwidget( + self._server_button = bui.buttonwidget( color=(0.8, 0, 1), parent=self._root_widget, position=(h + self._button_width * scale - 80, v_h), @@ -161,7 +162,7 @@ def con(address, port): autoselect=self._use_autoselect, label=ser["name"][0:22], - on_activate_call=ba.Call(con, ser["ip"], ser["port"])) + on_activate_call=bs.Call(con, ser["ip"], ser["port"])) v_h = v_h-50 # Player name if applicable. @@ -169,25 +170,25 @@ def con(address, port): player_name = self._input_player.getname() h, v, scale = positions[self._p_index] v += 35 - ba.textwidget(parent=self._root_widget, + bui.textwidget(parent=self._root_widget, position=(h - self._button_width / 2, v), size=(self._button_width, self._button_height), color=(1, 1, 1, 0.5), scale=0.7, h_align='center', - text=ba.Lstr(value=player_name)) + text=bs.Lstr(value=player_name)) else: player_name = '' h, v, scale = positions[self._p_index] self._p_index += 1 - btn = ba.buttonwidget(parent=self._root_widget, + btn = bui.buttonwidget(parent=self._root_widget, position=(h - self._button_width / 2, v), size=(self._button_width, self._button_height), scale=scale, - label=ba.Lstr(resource=self._r + '.resumeText'), + label=bs.Lstr(resource=self._r + '.resumeText'), autoselect=self._use_autoselect, on_activate_call=self._resume) - ba.containerwidget(edit=self._root_widget, cancel_button=btn) + bui.containerwidget(edit=self._root_widget, cancel_button=btn) # Add any custom options defined by the current game. for entry in custom_menu_entries: @@ -199,11 +200,11 @@ def con(address, port): resume = bool(entry.get('resume_on_call', True)) if resume: - call = ba.Call(self._resume_and_call, entry['call']) + call = bs.Call(self._resume_and_call, entry['call']) else: - call = ba.Call(entry['call'], ba.WeakCall(self._resume)) + call = bs.Call(entry['call'], bs.WeakCall(self._resume)) - ba.buttonwidget(parent=self._root_widget, + bui.buttonwidget(parent=self._root_widget, position=(h - self._button_width / 2, v), size=(self._button_width, self._button_height), scale=scale, @@ -215,7 +216,7 @@ def con(address, port): and not (self._is_demo or self._is_arcade)): h, v, scale = positions[self._p_index] self._p_index += 1 - btn = ba.buttonwidget(parent=self._root_widget, + btn = bui.buttonwidget(parent=self._root_widget, position=(h - self._button_width / 2, v), size=(self._button_width, self._button_height), @@ -226,22 +227,22 @@ def con(address, port): if (player_name != '' and player_name[0] != '<' and player_name[-1] != '>'): - txt = ba.Lstr(resource=self._r + '.justPlayerText', + txt = bs.Lstr(resource=self._r + '.justPlayerText', subs=[('${NAME}', player_name)]) else: - txt = ba.Lstr(value=player_name) - ba.textwidget(parent=self._root_widget, + txt = bs.Lstr(value=player_name) + bui.textwidget(parent=self._root_widget, position=(h, v + self._button_height * (0.64 if player_name != '' else 0.5)), size=(0, 0), - text=ba.Lstr(resource=self._r + '.leaveGameText'), + text=bs.Lstr(resource=self._r + '.leaveGameText'), scale=(0.83 if player_name != '' else 1.0), color=(0.75, 1.0, 0.7), h_align='center', v_align='center', draw_controller=btn, maxwidth=self._button_width * 0.9) - ba.textwidget(parent=self._root_widget, + bui.textwidget(parent=self._root_widget, position=(h, v + self._button_height * 0.27), size=(0, 0), text=txt, @@ -260,9 +261,12 @@ def new_refresh(self) -> None: # pylint: disable=too-many-statements global server print(server) - from bastd.ui.confirm import QuitWindow - from bastd.ui.store.button import StoreButton - import ba + from bauiv1lib.confirm import QuitWindow + from bauiv1lib.store.button import StoreButton + import bascenev1 as bs + import _bascenev1 as _bs + import bauiv1 as bui + import _baplus # Clear everything that was there. children = self._root_widget.get_children() for child in children: @@ -276,21 +280,22 @@ def new_refresh(self) -> None: self._r = 'mainMenu' - app = ba.app - self._have_quit_button = (app.ui.uiscale is ba.UIScale.LARGE + assert bs.app.classic is not None + app = bs.app.classic + self._have_quit_button = (bui.app.ui_v1.uiscale is bui.UIScale.LARGE or (app.platform == 'windows' and app.subplatform == 'oculus')) self._have_store_button = not self._in_game self._have_settings_button = ( - (not self._in_game or not app.toolbar_test) + (not self._in_game or not bui.app.toolbar_test) and not (self._is_demo or self._is_arcade or self._is_iircade)) - self._input_device = input_device = _ba.get_ui_input_device() + self._input_device = input_device = _bs.get_ui_input_device() self._input_player = input_device.player if input_device else None self._connected_to_remote_player = ( - input_device.is_connected_to_remote_player() + input_device.is_attached_to_player() if input_device else False) positions: List[Tuple[float, float, float]] = [] @@ -299,14 +304,14 @@ def new_refresh(self) -> None: if self._in_game: h, v, scale = self._refresh_in_game(positions) print("refreshing in GAME", ip_add) - # btn = ba.buttonwidget(parent=self._root_widget, + # btn = bui.buttonwidget(parent=self._root_widget, # position=(80,270), # size=(100, 90), # scale=1.2, # label=ip_add, # autoselect=None, # on_activate_call=printip) - ba.textwidget( + bui.textwidget( parent=self._root_widget, draw_controller=None, text="IP: "+ip_add+" PORT: "+str(p_port), @@ -315,31 +320,31 @@ def new_refresh(self) -> None: v_align='center', size=(20, 60), scale=1) - self._server_button = ba.buttonwidget( + self._server_button = bui.buttonwidget( parent=self._root_widget, position=(h * 3.2 + 20 - self._button_width * scale, v), size=(self._button_width, self._button_height), scale=scale, autoselect=self._use_autoselect, - label=ba.Lstr(resource=self._r + '.settingsText'), + label=bs.Lstr(resource=self._r + '.settingsText'), transition_delay=self._tdelay, on_activate_call=self._settings) - self._server_button2 = ba.buttonwidget( + self._server_button2 = bui.buttonwidget( parent=self._root_widget, position=(h * 3.2 + 20 - self._button_width * scale, v-50), size=(self._button_width, self._button_height), scale=scale, autoselect=self._use_autoselect, - label=ba.Lstr(resource=self._r + '.settingsText'), + label=bs.Lstr(resource=self._r + '.settingsText'), transition_delay=self._tdelay, on_activate_call=self._settings) - self._server_button3 = ba.buttonwidget( + self._server_button3 = bui.buttonwidget( parent=self._root_widget, position=(h * 3.2 + 20 - self._button_width * scale, v-100), size=(self._button_width, self._button_height), scale=scale, autoselect=self._use_autoselect, - label=ba.Lstr(resource=self._r + '.settingsText'), + label=bs.Lstr(resource=self._r + '.settingsText'), transition_delay=self._tdelay, on_activate_call=self._settings) @@ -349,27 +354,27 @@ def new_refresh(self) -> None: if self._have_settings_button: h, v, scale = positions[self._p_index] self._p_index += 1 - self._settings_button = ba.buttonwidget( + self._settings_button = bui.buttonwidget( parent=self._root_widget, position=(h - self._button_width * 0.5 * scale, v), size=(self._button_width, self._button_height), scale=scale, autoselect=self._use_autoselect, - label=ba.Lstr(resource=self._r + '.settingsText'), + label=bs.Lstr(resource=self._r + '.settingsText'), transition_delay=self._tdelay, on_activate_call=self._settings) # Scattered eggs on easter. - if _ba.get_account_misc_read_val('easter', + if _baplus.get_v1_account_misc_read_val('easter', False) and not self._in_game: icon_size = 34 - ba.imagewidget(parent=self._root_widget, + bui.imagewidget(parent=self._root_widget, position=(h - icon_size * 0.5 - 15, v + self._button_height * scale - icon_size * 0.24 + 1.5), transition_delay=self._tdelay, size=(icon_size, icon_size), - texture=ba.gettexture('egg3'), + texture=bui.gettexture('egg3'), tilt_scale=0.0) self._tdelay += self._t_delay_inc @@ -379,36 +384,36 @@ def new_refresh(self) -> None: self._p_index += 1 # If we're in a replay, we have a 'Leave Replay' button. - if _ba.is_in_replay(): - ba.buttonwidget(parent=self._root_widget, + if _bs.is_in_replay(): + bui.buttonwidget(parent=self._root_widget, position=(h - self._button_width * 0.5 * scale, v), scale=scale, size=(self._button_width, self._button_height), autoselect=self._use_autoselect, - label=ba.Lstr(resource='replayEndText'), + label=bs.Lstr(resource='replayEndText'), on_activate_call=self._confirm_end_replay) - elif _ba.get_foreground_host_session() is not None: - ba.buttonwidget( + elif _bs.get_foreground_host_session() is not None: + bui.buttonwidget( parent=self._root_widget, position=(h - self._button_width * 0.5 * scale, v), scale=scale, size=(self._button_width, self._button_height), autoselect=self._use_autoselect, - label=ba.Lstr(resource=self._r + '.endGameText'), + label=bs.Lstr(resource=self._r + '.endGameText'), on_activate_call=self._confirm_end_game) # Assume we're in a client-session. else: - ba.buttonwidget( + bui.buttonwidget( parent=self._root_widget, position=(h - self._button_width * 0.5 * scale, v), scale=scale, size=(self._button_width, self._button_height), autoselect=self._use_autoselect, - label=ba.Lstr(resource=self._r + '.leavePartyText'), + label=bs.Lstr(resource=self._r + '.leavePartyText'), on_activate_call=self._confirm_leave_party) - self._store_button: Optional[ba.Widget] + self._store_button: Optional[bui.Widget] if self._have_store_button: this_b_width = self._button_width h, v, scale = positions[self._p_index] @@ -419,20 +424,20 @@ def new_refresh(self) -> None: position=(h - this_b_width * 0.5 * scale, v), size=(this_b_width, self._button_height), scale=scale, - on_activate_call=ba.WeakCall(self._on_store_pressed), + on_activate_call=bs.WeakCall(self._on_store_pressed), sale_scale=1.3, transition_delay=self._tdelay) self._store_button = store_button = sbtn.get_button() - uiscale = ba.app.ui.uiscale - icon_size = (55 if uiscale is ba.UIScale.SMALL else - 55 if uiscale is ba.UIScale.MEDIUM else 70) - ba.imagewidget( + uiscale = bui.app.ui_v1.uiscale + icon_size = (55 if uiscale is bui.UIScale.SMALL else + 55 if uiscale is bui.UIScale.MEDIUM else 70) + bui.imagewidget( parent=self._root_widget, position=(h - icon_size * 0.5, v + self._button_height * scale - icon_size * 0.23), transition_delay=self._tdelay, size=(icon_size, icon_size), - texture=ba.gettexture(self._store_char_tex), + texture=bui.gettexture(self._store_char_tex), tilt_scale=0.0, draw_controller=store_button) @@ -440,35 +445,35 @@ def new_refresh(self) -> None: else: self._store_button = None - self._quit_button: Optional[ba.Widget] + self._quit_button: Optional[bui.Widget] if not self._in_game and self._have_quit_button: h, v, scale = positions[self._p_index] self._p_index += 1 - self._quit_button = quit_button = ba.buttonwidget( + self._quit_button = quit_button = bui.buttonwidget( parent=self._root_widget, autoselect=self._use_autoselect, position=(h - self._button_width * 0.5 * scale, v), size=(self._button_width, self._button_height), scale=scale, - label=ba.Lstr(resource=self._r + + label=bs.Lstr(resource=self._r + ('.quitText' if 'Mac' in - ba.app.user_agent_string else '.exitGameText')), + bs.app.classic.legacy_user_agent_string else '.exitGameText')), on_activate_call=self._quit, transition_delay=self._tdelay) # Scattered eggs on easter. - if _ba.get_account_misc_read_val('easter', False): + if _baplus.get_v1_account_misc_read_val('easter', False): icon_size = 30 - ba.imagewidget(parent=self._root_widget, + bui.imagewidget(parent=self._root_widget, position=(h - icon_size * 0.5 + 25, v + self._button_height * scale - icon_size * 0.24 + 1.5), transition_delay=self._tdelay, size=(icon_size, icon_size), - texture=ba.gettexture('egg1'), + texture=bui.gettexture('egg1'), tilt_scale=0.0) - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, cancel_button=quit_button) self._tdelay += self._t_delay_inc else: @@ -477,34 +482,34 @@ def new_refresh(self) -> None: # If we're not in-game, have no quit button, and this is android, # we want back presses to quit our activity. if (not self._in_game and not self._have_quit_button - and ba.app.platform == 'android'): + and bs.app.classic.platform == 'android'): def _do_quit() -> None: QuitWindow(swish=True, back=True) - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, on_cancel_call=_do_quit) # Add speed-up/slow-down buttons for replays. # (ideally this should be part of a fading-out playback bar like most # media players but this works for now). - if _ba.is_in_replay(): + if _bs.is_in_replay(): b_size = 50.0 b_buffer = 10.0 t_scale = 0.75 - uiscale = ba.app.ui.uiscale - if uiscale is ba.UIScale.SMALL: + uiscale = bui.app.ui_v1.uiscale + if uiscale is bui.UIScale.SMALL: b_size *= 0.6 b_buffer *= 1.0 v_offs = -40 t_scale = 0.5 - elif uiscale is ba.UIScale.MEDIUM: + elif uiscale is bui.UIScale.MEDIUM: v_offs = -70 else: v_offs = -100 - self._replay_speed_text = ba.textwidget( + self._replay_speed_text = bui.textwidget( parent=self._root_widget, - text=ba.Lstr(resource='watchWindow.playbackSpeedText', + text=bs.Lstr(resource='watchWindow.playbackSpeedText', subs=[('${SPEED}', str(1.23))]), position=(h, v + v_offs + 7 * t_scale), h_align='center', @@ -516,21 +521,20 @@ def _do_quit() -> None: self._change_replay_speed(0) # Keep updating in a timer in case it gets changed elsewhere. - self._change_replay_speed_timer = ba.Timer( + self._change_replay_speed_timer = bs.Timer( 0.25, - ba.WeakCall(self._change_replay_speed, 0), - timetype=ba.TimeType.REAL, + bs.WeakCall(self._change_replay_speed, 0), repeat=True) - btn = ba.buttonwidget(parent=self._root_widget, + btn = bui.buttonwidget(parent=self._root_widget, position=(h - b_size - b_buffer, v - b_size - b_buffer + v_offs), button_type='square', size=(b_size, b_size), label='', autoselect=True, - on_activate_call=ba.Call( + on_activate_call=bs.Call( self._change_replay_speed, -1)) - ba.textwidget( + bui.textwidget( parent=self._root_widget, draw_controller=btn, text='-', @@ -540,15 +544,15 @@ def _do_quit() -> None: v_align='center', size=(0, 0), scale=3.0 * t_scale) - btn = ba.buttonwidget( + btn = bui.buttonwidget( parent=self._root_widget, position=(h + b_buffer, v - b_size - b_buffer + v_offs), button_type='square', size=(b_size, b_size), label='', autoselect=True, - on_activate_call=ba.Call(self._change_replay_speed, 1)) - ba.textwidget( + on_activate_call=bs.Call(self._change_replay_speed, 1)) + bui.textwidget( parent=self._root_widget, draw_controller=btn, text='+', @@ -559,14 +563,13 @@ def _do_quit() -> None: size=(0, 0), scale=3.0 * t_scale) -# ba_meta export plugin - -class bySmoothy(ba.Plugin): +# ba_meta export plugin +class bySmoothy(babase.Plugin): def __init__(self): - if _ba.env().get("build_number", 0) >= 20577: + if babase.env().get("build_number", 0) >= 21140: bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = new_refresh_in_game - ba.internal.connect_to_party = newconnect_to_party - ba.internal.disconnect_from_host = newdisconnect_from_host + bs.connect_to_party = newconnect_to_party + bs.disconnect_from_host = newdisconnect_from_host else: - print("Server Switch only works on bs 1.7 and above") + print("Server Switch only works on bs 1.7.20 and above") From bf3e61bc9c1fa993a8c959d94bb082df02ec83e1 Mon Sep 17 00:00:00 2001 From: DhextraS Date: Tue, 4 Jul 2023 06:29:56 +0000 Subject: [PATCH 03/17] [ci] auto-format --- plugins/utilities/server_switch.py | 152 ++++++++++++++--------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/plugins/utilities/server_switch.py b/plugins/utilities/server_switch.py index 3c246c76..aacb0fe7 100644 --- a/plugins/utilities/server_switch.py +++ b/plugins/utilities/server_switch.py @@ -171,23 +171,23 @@ def con(address, port): h, v, scale = positions[self._p_index] v += 35 bui.textwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, self._button_height), - color=(1, 1, 1, 0.5), - scale=0.7, - h_align='center', - text=bs.Lstr(value=player_name)) + position=(h - self._button_width / 2, v), + size=(self._button_width, self._button_height), + color=(1, 1, 1, 0.5), + scale=0.7, + h_align='center', + text=bs.Lstr(value=player_name)) else: player_name = '' h, v, scale = positions[self._p_index] self._p_index += 1 btn = bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, self._button_height), - scale=scale, - label=bs.Lstr(resource=self._r + '.resumeText'), - autoselect=self._use_autoselect, - on_activate_call=self._resume) + position=(h - self._button_width / 2, v), + size=(self._button_width, self._button_height), + scale=scale, + label=bs.Lstr(resource=self._r + '.resumeText'), + autoselect=self._use_autoselect, + on_activate_call=self._resume) bui.containerwidget(edit=self._root_widget, cancel_button=btn) # Add any custom options defined by the current game. @@ -205,25 +205,25 @@ def con(address, port): call = bs.Call(entry['call'], bs.WeakCall(self._resume)) bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, self._button_height), - scale=scale, - on_activate_call=call, - label=entry['label'], - autoselect=self._use_autoselect) + position=(h - self._button_width / 2, v), + size=(self._button_width, self._button_height), + scale=scale, + on_activate_call=call, + label=entry['label'], + autoselect=self._use_autoselect) # Add a 'leave' button if the menu-owner has a player. if ((self._input_player or self._connected_to_remote_player) and not (self._is_demo or self._is_arcade)): h, v, scale = positions[self._p_index] self._p_index += 1 btn = bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, - self._button_height), - scale=scale, - on_activate_call=self._leave, - label='', - autoselect=self._use_autoselect) + position=(h - self._button_width / 2, v), + size=(self._button_width, + self._button_height), + scale=scale, + on_activate_call=self._leave, + label='', + autoselect=self._use_autoselect) if (player_name != '' and player_name[0] != '<' and player_name[-1] != '>'): @@ -232,26 +232,26 @@ def con(address, port): else: txt = bs.Lstr(value=player_name) bui.textwidget(parent=self._root_widget, - position=(h, v + self._button_height * - (0.64 if player_name != '' else 0.5)), - size=(0, 0), - text=bs.Lstr(resource=self._r + '.leaveGameText'), - scale=(0.83 if player_name != '' else 1.0), - color=(0.75, 1.0, 0.7), - h_align='center', - v_align='center', - draw_controller=btn, - maxwidth=self._button_width * 0.9) + position=(h, v + self._button_height * + (0.64 if player_name != '' else 0.5)), + size=(0, 0), + text=bs.Lstr(resource=self._r + '.leaveGameText'), + scale=(0.83 if player_name != '' else 1.0), + color=(0.75, 1.0, 0.7), + h_align='center', + v_align='center', + draw_controller=btn, + maxwidth=self._button_width * 0.9) bui.textwidget(parent=self._root_widget, - position=(h, v + self._button_height * 0.27), - size=(0, 0), - text=txt, - color=(0.75, 1.0, 0.7), - h_align='center', - v_align='center', - draw_controller=btn, - scale=0.45, - maxwidth=self._button_width * 0.9) + position=(h, v + self._button_height * 0.27), + size=(0, 0), + text=txt, + color=(0.75, 1.0, 0.7), + h_align='center', + v_align='center', + draw_controller=btn, + scale=0.45, + maxwidth=self._button_width * 0.9) return h, v, scale @@ -366,16 +366,16 @@ def new_refresh(self) -> None: # Scattered eggs on easter. if _baplus.get_v1_account_misc_read_val('easter', - False) and not self._in_game: + False) and not self._in_game: icon_size = 34 bui.imagewidget(parent=self._root_widget, - position=(h - icon_size * 0.5 - 15, - v + self._button_height * scale - - icon_size * 0.24 + 1.5), - transition_delay=self._tdelay, - size=(icon_size, icon_size), - texture=bui.gettexture('egg3'), - tilt_scale=0.0) + position=(h - icon_size * 0.5 - 15, + v + self._button_height * scale - + icon_size * 0.24 + 1.5), + transition_delay=self._tdelay, + size=(icon_size, icon_size), + texture=bui.gettexture('egg3'), + tilt_scale=0.0) self._tdelay += self._t_delay_inc @@ -386,13 +386,13 @@ def new_refresh(self) -> None: # If we're in a replay, we have a 'Leave Replay' button. if _bs.is_in_replay(): bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width * 0.5 * scale, - v), - scale=scale, - size=(self._button_width, self._button_height), - autoselect=self._use_autoselect, - label=bs.Lstr(resource='replayEndText'), - on_activate_call=self._confirm_end_replay) + position=(h - self._button_width * 0.5 * scale, + v), + scale=scale, + size=(self._button_width, self._button_height), + autoselect=self._use_autoselect, + label=bs.Lstr(resource='replayEndText'), + on_activate_call=self._confirm_end_replay) elif _bs.get_foreground_host_session() is not None: bui.buttonwidget( parent=self._root_widget, @@ -465,16 +465,16 @@ def new_refresh(self) -> None: if _baplus.get_v1_account_misc_read_val('easter', False): icon_size = 30 bui.imagewidget(parent=self._root_widget, - position=(h - icon_size * 0.5 + 25, - v + self._button_height * scale - - icon_size * 0.24 + 1.5), - transition_delay=self._tdelay, - size=(icon_size, icon_size), - texture=bui.gettexture('egg1'), - tilt_scale=0.0) + position=(h - icon_size * 0.5 + 25, + v + self._button_height * scale - + icon_size * 0.24 + 1.5), + transition_delay=self._tdelay, + size=(icon_size, icon_size), + texture=bui.gettexture('egg1'), + tilt_scale=0.0) bui.containerwidget(edit=self._root_widget, - cancel_button=quit_button) + cancel_button=quit_button) self._tdelay += self._t_delay_inc else: self._quit_button = None @@ -488,7 +488,7 @@ def _do_quit() -> None: QuitWindow(swish=True, back=True) bui.containerwidget(edit=self._root_widget, - on_cancel_call=_do_quit) + on_cancel_call=_do_quit) # Add speed-up/slow-down buttons for replays. # (ideally this should be part of a fading-out playback bar like most @@ -526,14 +526,14 @@ def _do_quit() -> None: bs.WeakCall(self._change_replay_speed, 0), repeat=True) btn = bui.buttonwidget(parent=self._root_widget, - position=(h - b_size - b_buffer, - v - b_size - b_buffer + v_offs), - button_type='square', - size=(b_size, b_size), - label='', - autoselect=True, - on_activate_call=bs.Call( - self._change_replay_speed, -1)) + position=(h - b_size - b_buffer, + v - b_size - b_buffer + v_offs), + button_type='square', + size=(b_size, b_size), + label='', + autoselect=True, + on_activate_call=bs.Call( + self._change_replay_speed, -1)) bui.textwidget( parent=self._root_widget, draw_controller=btn, From 8fe773f2cdb09319635f73797c919b31689c443d Mon Sep 17 00:00:00 2001 From: DhextraS Date: Tue, 4 Jul 2023 06:29:57 +0000 Subject: [PATCH 04/17] [ci] apply-version-metadata --- plugins/utilities.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index f71b99ff..aa2b264e 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -422,7 +422,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "bf3e61b", + "released_on": "04-07-2023", + "md5sum": "289cc852b7f0ec1b254d08267c9921c2" + }, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -740,4 +745,4 @@ } } } -} +} \ No newline at end of file From 369eedf12d8fee514cdd23aa543ce975928d6390 Mon Sep 17 00:00:00 2001 From: A Dhextras <104954857+DhextraS@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:50:30 +0530 Subject: [PATCH 05/17] Update utilities.json --- plugins/utilities.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index aa2b264e..96976dbb 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -522,6 +522,7 @@ } ], "versions": { + "2.0.0": null, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", @@ -745,4 +746,4 @@ } } } -} \ No newline at end of file +} From 8194e98f653825914dcf628bcdd2282c8c7712ba Mon Sep 17 00:00:00 2001 From: DhextraS Date: Tue, 4 Jul 2023 09:20:58 +0000 Subject: [PATCH 06/17] [ci] apply-version-metadata --- plugins/utilities.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 96976dbb..7ff66c24 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -522,7 +522,12 @@ } ], "versions": { - "2.0.0": null, + "2.0.0": { + "api_version": 7, + "commit_sha": "369eedf", + "released_on": "04-07-2023", + "md5sum": "bbaee5f133b41d2eb53e3b726403a75e" + }, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", @@ -746,4 +751,4 @@ } } } -} +} \ No newline at end of file From c7ebadbe56148181cb0c35404dbd32dc5b3c573b Mon Sep 17 00:00:00 2001 From: A Dhextras <104954857+DhextraS@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:51:54 +0530 Subject: [PATCH 07/17] Update pro_unlocker.py --- plugins/utilities/pro_unlocker.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/utilities/pro_unlocker.py b/plugins/utilities/pro_unlocker.py index 5603072d..bac31447 100644 --- a/plugins/utilities/pro_unlocker.py +++ b/plugins/utilities/pro_unlocker.py @@ -1,6 +1,7 @@ -# ba_meta require api 7 -import _ba -import ba +# ba_meta require api 8 +import bascenev1 as bs +import _baplus +import babase def is_game_version_lower_than(version): @@ -9,15 +10,16 @@ def is_game_version_lower_than(version): version is lower than the passed version. Useful for addressing any breaking changes within game versions. """ - game_version = tuple(map(int, ba.app.version.split("."))) + game_version = tuple(map(int, babase.app.version.split("."))) version = tuple(map(int, version.split("."))) return game_version < version -if is_game_version_lower_than("1.7.7"): - original_get_purchased = _ba.get_purchased +if is_game_version_lower_than("1.7.20"): + original_get_purchased = _baplus.get_purchased else: - original_get_purchased = ba.internal.get_purchased + assert bs.app.plus is not None + original_get_purchased = bs.app.plus.get_purchased def get_purchased(item): @@ -27,10 +29,11 @@ def get_purchased(item): # ba_meta export plugin -class Unlock(ba.Plugin): +class Unlock(babase.Plugin): def on_app_running(self): - ba.app.accounts_v1.have_pro = lambda: True - if is_game_version_lower_than("1.7.7"): - _ba.get_purchased = get_purchased + babase.app.classic.accounts.have_pro = lambda: True + if is_game_version_lower_than("1.7.20"): + _baplus.get_purchased = get_purchased else: - ba.internal.get_purchased = get_purchased + assert bs.app.plus is not None + bs.app.plus.get_purchased = get_purchased From a0239a924e84baa92c27aab8a882326c3c9cf549 Mon Sep 17 00:00:00 2001 From: A Dhextras <104954857+DhextraS@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:03:50 +0530 Subject: [PATCH 08/17] Update utilities.json --- plugins/utilities.json | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 7ff66c24..6cdd31f4 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -522,12 +522,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 7, - "commit_sha": "369eedf", - "released_on": "04-07-2023", - "md5sum": "bbaee5f133b41d2eb53e3b726403a75e" - }, + "2.0.0":null, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", @@ -751,4 +746,4 @@ } } } -} \ No newline at end of file +} From 1ac7a9d044aab22980512ab2201c1a08c83bd9fa Mon Sep 17 00:00:00 2001 From: DhextraS Date: Tue, 4 Jul 2023 09:34:23 +0000 Subject: [PATCH 09/17] [ci] apply-version-metadata --- plugins/utilities.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 6cdd31f4..cee50f85 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -522,7 +522,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "a0239a9", + "released_on": "04-07-2023", + "md5sum": "187a9894158721c8fa1ecee9e3e38e73" + }, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", @@ -746,4 +751,4 @@ } } } -} +} \ No newline at end of file From 7f0fd37ddedcf930a3b9ddf3a1ff16fd7ea1e928 Mon Sep 17 00:00:00 2001 From: A Dhextras <104954857+DhextraS@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:04:27 +0530 Subject: [PATCH 10/17] Update pro_unlocker.py From c2832136aa647a54e9f44b91b66582fa58a25afa Mon Sep 17 00:00:00 2001 From: Ayush Saini <36878972+imayushsaini@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:21:36 +0530 Subject: [PATCH 11/17] updated server switch --- README.md | 13 +- plugins/minigames.json | 6 - plugins/minigames/alliance_elimination.py | 118 ++-- plugins/utilities.json | 28 +- plugins/utilities/character_chooser.py | 35 +- plugins/utilities/easy_connect.py | 367 ++++++------- plugins/utilities/pro_unlocker.py | 24 +- plugins/utilities/server_switch.py | 639 +++------------------- 8 files changed, 356 insertions(+), 874 deletions(-) diff --git a/README.md b/README.md index d625cccd..fe057a9e 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,8 @@ There are two different ways the plugin manager can be installed: 1. [Download plugin_manager.py][DownloadLink] to your mods directory (check it out by going into your game's Settings -> Advanced -> Show Mods Folder). This is the recommended way (read next method to know why). - If you're on a newer version of Android (11 or above) and not rooted, it probably won't be possible to copy - mods to game's mods folder. In this case, you can connect your Android phone to a computer and push `plugin_manager.py` - [using `adb`](https://www.xda-developers.com/install-adb-windows-macos-linux/): - ```bash - $ adb push plugin_manager.py /sdcard/Android/data/net.froemling.bombsquad/files/mods/plugin_manager.py - ``` - -3. Another way is to add + +2. Another way is to add [plugin_manager.py](https://raw.githubusercontent.com/bombsquad-community/plugin-manager/main/plugin_manager.py) to your workspace. However, plugin manager self-updates will fail when installed using this way since the game will overrwrite the updated plugin manager, with the older version from workspace on the next sync. However, you can @@ -199,8 +193,7 @@ That's it! Now you can make a [pull request](../../compare) with both the update will also help us to notify the maintainers of any future breaking changes in plugin manager that could affect 3rd party plugin sources. - - [rikkolovescats/sahilp-plugins](https://github.com/rikkolovescats/sahilp-plugins) - - [Aeliux/arcane](https://github.com/Aeliux/arcane) + [rikkolovescats/sahilp-plugins](https://github.com/rikkolovescats/sahilp-plugins) ## Tests diff --git a/plugins/minigames.json b/plugins/minigames.json index ae4f5406..a95fc4f5 100644 --- a/plugins/minigames.json +++ b/plugins/minigames.json @@ -166,12 +166,6 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "1b14789", - "released_on": "02-07-2023", - "md5sum": "cb2a7700dd13febe6f68c3cd979b8b19" - }, "1.1.0": { "api_version": 7, "commit_sha": "40b70fe", diff --git a/plugins/minigames/alliance_elimination.py b/plugins/minigames/alliance_elimination.py index f6d47b5f..e6f37761 100644 --- a/plugins/minigames/alliance_elimination.py +++ b/plugins/minigames/alliance_elimination.py @@ -2,25 +2,23 @@ # """Elimination mini-game.""" -# ba_meta require api 8 +# ba_meta require api 7 # (see https://ballistica.net/wiki/meta-tag-system) from __future__ import annotations from typing import TYPE_CHECKING -import babase -import bauiv1 as bui -import bascenev1 as bs -from bascenev1lib.actor.spazfactory import SpazFactory -from bascenev1lib.actor.scoreboard import Scoreboard +import ba +from bastd.actor.spazfactory import SpazFactory +from bastd.actor.scoreboard import Scoreboard if TYPE_CHECKING: from typing import (Any, Tuple, Type, List, Sequence, Optional, Union) -class Icon(bs.Actor): +class Icon(ba.Actor): """Creates in in-game icon on screen.""" def __init__(self, @@ -39,10 +37,10 @@ def __init__(self, self._show_lives = show_lives self._show_death = show_death self._name_scale = name_scale - self._outline_tex = bs.gettexture('characterIconMask') + self._outline_tex = ba.gettexture('characterIconMask') icon = player.get_icon() - self.node = bs.newnode('image', + self.node = ba.newnode('image', delegate=self, attrs={ 'texture': icon['texture'], @@ -55,12 +53,12 @@ def __init__(self, 'absolute_scale': True, 'attach': 'bottomCenter' }) - self._name_text = bs.newnode( + self._name_text = ba.newnode( 'text', owner=self.node, attrs={ - 'text': babase.Lstr(value=player.getname()), - 'color': babase.safecolor(player.team.color), + 'text': ba.Lstr(value=player.getname()), + 'color': ba.safecolor(player.team.color), 'h_align': 'center', 'v_align': 'center', 'vr_depth': 410, @@ -71,7 +69,7 @@ def __init__(self, 'v_attach': 'bottom' }) if self._show_lives: - self._lives_text = bs.newnode('text', + self._lives_text = ba.newnode('text', owner=self.node, attrs={ 'text': 'x0', @@ -127,7 +125,7 @@ def handle_player_died(self) -> None: if not self.node: return if self._show_death: - bs.animate( + ba.animate( self.node, 'opacity', { 0.00: 1.0, 0.05: 0.0, @@ -144,16 +142,16 @@ def handle_player_died(self) -> None: }) lives = self._player.lives if lives == 0: - bs.timer(0.6, self.update_for_lives) + ba.timer(0.6, self.update_for_lives) def handlemessage(self, msg: Any) -> Any: - if isinstance(msg, bs.DieMessage): + if isinstance(msg, ba.DieMessage): self.node.delete() return None return super().handlemessage(msg) -class Player(bs.Player['Team']): +class Player(ba.Player['Team']): """Our player type for this game.""" def __init__(self) -> None: @@ -161,7 +159,7 @@ def __init__(self) -> None: self.icons: List[Icon] = [] -class Team(bs.Team[Player]): +class Team(ba.Team[Player]): """Our team type for this game.""" def __init__(self) -> None: @@ -169,14 +167,14 @@ def __init__(self) -> None: self.spawn_order: List[Player] = [] -# ba_meta export bascenev1.GameActivity -class AllianceEliminationGame(bs.TeamGameActivity[Player, Team]): +# ba_meta export game +class AllianceEliminationGame(ba.TeamGameActivity[Player, Team]): """Game type where last player(s) left alive win.""" name = 'Alliance Elimination' description = 'Fight in groups of duo, trio, or more.\nLast remaining alive wins.' - scoreconfig = bs.ScoreConfig(label='Survived', - scoretype=bs.ScoreType.SECONDS, + scoreconfig = ba.ScoreConfig(label='Survived', + scoretype=ba.ScoreType.SECONDS, none_is_winner=True) # Show messages when players die since it's meaningful here. announce_player_deaths = True @@ -185,23 +183,23 @@ class AllianceEliminationGame(bs.TeamGameActivity[Player, Team]): @classmethod def get_available_settings( - cls, sessiontype: Type[bs.Session]) -> List[babase.Setting]: + cls, sessiontype: Type[ba.Session]) -> List[ba.Setting]: settings = [ - bs.IntSetting( + ba.IntSetting( 'Lives Per Player', default=1, min_value=1, max_value=10, increment=1, ), - bs.IntSetting( + ba.IntSetting( 'Players Per Team In Arena', default=2, min_value=2, max_value=10, increment=1, ), - bs.IntChoiceSetting( + ba.IntChoiceSetting( 'Time Limit', choices=[ ('None', 0), @@ -213,7 +211,7 @@ def get_available_settings( ], default=0, ), - bs.FloatChoiceSetting( + ba.FloatChoiceSetting( 'Respawn Times', choices=[ ('Shorter', 0.25), @@ -224,27 +222,27 @@ def get_available_settings( ], default=1.0, ), - bs.BoolSetting('Epic Mode', default=False), + ba.BoolSetting('Epic Mode', default=False), ] - if issubclass(sessiontype, bs.DualTeamSession): + if issubclass(sessiontype, ba.DualTeamSession): settings.append( - bs.BoolSetting('Balance Total Lives', default=False)) + ba.BoolSetting('Balance Total Lives', default=False)) return settings @classmethod - def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool: - return issubclass(sessiontype, bs.DualTeamSession) + def supports_session_type(cls, sessiontype: Type[ba.Session]) -> bool: + return issubclass(sessiontype, ba.DualTeamSession) @classmethod - def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]: - return bs.app.classic.getmaps('melee') + def get_supported_maps(cls, sessiontype: Type[ba.Session]) -> List[str]: + return ba.getmaps('melee') def __init__(self, settings: dict): super().__init__(settings) self._scoreboard = Scoreboard() self._start_time: Optional[float] = None - self._vs_text: Optional[bs.Actor] = None - self._round_end_timer: Optional[bs.Timer] = None + self._vs_text: Optional[ba.Actor] = None + self._round_end_timer: Optional[ba.Timer] = None self._epic_mode = bool(settings['Epic Mode']) self._lives_per_player = int(settings['Lives Per Player']) self._time_limit = float(settings['Time Limit']) @@ -255,16 +253,16 @@ def __init__(self, settings: dict): # Base class overrides: self.slow_motion = self._epic_mode - self.default_music = (bs.MusicType.EPIC - if self._epic_mode else bs.MusicType.SURVIVAL) + self.default_music = (ba.MusicType.EPIC + if self._epic_mode else ba.MusicType.SURVIVAL) def get_instance_description(self) -> Union[str, Sequence]: return 'Last team standing wins.' if isinstance( - self.session, bs.DualTeamSession) else 'Last one standing wins.' + self.session, ba.DualTeamSession) else 'Last one standing wins.' def get_instance_description_short(self) -> Union[str, Sequence]: return 'last team standing wins' if isinstance( - self.session, bs.DualTeamSession) else 'last one standing wins' + self.session, ba.DualTeamSession) else 'last one standing wins' def on_player_join(self, player: Player) -> None: @@ -277,9 +275,9 @@ def on_player_join(self, player: Player) -> None: if (self._get_total_team_lives(player.team) == 0 and player.team.survival_seconds is None): player.team.survival_seconds = 0 - bs.broadcastmessage( - babase.Lstr(resource='playerDelayedJoinText', - subs=[('${PLAYER}', player.getname(full=True))]), + ba.screenmessage( + ba.Lstr(resource='playerDelayedJoinText', + subs=[('${PLAYER}', player.getname(full=True))]), color=(0, 1, 0), ) return @@ -295,11 +293,11 @@ def on_player_join(self, player: Player) -> None: def on_begin(self) -> None: super().on_begin() - self._start_time = bs.time() + self._start_time = ba.time() self.setup_standard_time_limit(self._time_limit) self.setup_standard_powerup_drops() - self._vs_text = bs.NodeActor( - bs.newnode('text', + self._vs_text = ba.NodeActor( + ba.newnode('text', attrs={ 'position': (0, 92), 'h_attach': 'center', @@ -310,12 +308,12 @@ def on_begin(self) -> None: 'scale': 0.6, 'v_attach': 'bottom', 'color': (0.8, 0.8, 0.3, 1.0), - 'text': babase.Lstr(resource='vsText') + 'text': ba.Lstr(resource='vsText') })) # If balance-team-lives is on, add lives to the smaller team until # total lives match. - if (isinstance(self.session, bs.DualTeamSession) + if (isinstance(self.session, ba.DualTeamSession) and self._balance_total_lives and self.teams[0].players and self.teams[1].players): if self._get_total_team_lives( @@ -335,7 +333,7 @@ def on_begin(self) -> None: # We could check game-over conditions at explicit trigger points, # but lets just do the simple thing and poll it. - bs.timer(1.0, self._update, repeat=True) + ba.timer(1.0, self._update, repeat=True) def _update_alliance_mode(self) -> None: # For both teams, find the first player on the spawn order list with @@ -393,10 +391,10 @@ def _update_icons(self) -> None: nplayers -= 1 test_lives += 1 - def _get_spawn_point(self, player: Player) -> Optional[babase.Vec3]: + def _get_spawn_point(self, player: Player) -> Optional[ba.Vec3]: return None - def spawn_player(self, player: Player) -> bs.Actor: + def spawn_player(self, player: Player) -> ba.Actor: actor = self.spawn_player_spaz(player, self._get_spawn_point(player)) # If we have any icons, update their state. @@ -405,7 +403,7 @@ def spawn_player(self, player: Player) -> bs.Actor: return actor def _print_lives(self, player: Player) -> None: - from bascenev1lib.actor import popuptext + from bastd.actor import popuptext # We get called in a timer so it's possible our player has left/etc. if not player or not player.is_alive() or not player.node: @@ -428,20 +426,20 @@ def on_player_leave(self, player: Player) -> None: # Update icons in a moment since our team will be gone from the # list then. - bs.timer(0, self._update_icons) + ba.timer(0, self._update_icons) # If the player to leave was the last in spawn order and had # their final turn currently in-progress, mark the survival time # for their team. if self._get_total_team_lives(player.team) == 0: assert self._start_time is not None - player.team.survival_seconds = int(bs.time() - self._start_time) + player.team.survival_seconds = int(ba.time() - self._start_time) def _get_total_team_lives(self, team: Team) -> int: return sum(player.lives for player in team.players) def handlemessage(self, msg: Any) -> Any: - if isinstance(msg, bs.PlayerDiedMessage): + if isinstance(msg, ba.PlayerDiedMessage): # Augment standard behavior. super().handlemessage(msg) @@ -449,7 +447,7 @@ def handlemessage(self, msg: Any) -> Any: player.lives -= 1 if player.lives < 0: - babase.print_error( + ba.print_error( "Got lives < 0 in Alliance Elimination; this shouldn't happen.") player.lives = 0 @@ -460,14 +458,14 @@ def handlemessage(self, msg: Any) -> Any: # Play big death sound on our last death # or for every one. if player.lives == 0: - SpazFactory.get().single_player_death_sound.play() + ba.playsound(SpazFactory.get().single_player_death_sound) # If we hit zero lives, we're dead (and our team might be too). if player.lives == 0: # If the whole team is now dead, mark their survival time. if self._get_total_team_lives(player.team) == 0: assert self._start_time is not None - player.team.survival_seconds = int(bs.time() - + player.team.survival_seconds = int(ba.time() - self._start_time) # Put ourself at the back of the spawn order. @@ -495,7 +493,7 @@ def _update(self) -> None: # the game (allows the dust to settle and draws to occur if deaths # are close enough). if len(self._get_living_teams()) < 2: - self._round_end_timer = bs.Timer(0.5, self.end_game) + self._round_end_timer = ba.Timer(0.5, self.end_game) def _get_living_teams(self) -> List[Team]: return [ @@ -507,7 +505,7 @@ def _get_living_teams(self) -> List[Team]: def end_game(self) -> None: if self.has_ended(): return - results = bs.GameResults() + results = ba.GameResults() self._vs_text = None # Kill our 'vs' if its there. for team in self.teams: results.set_team_score(team, team.survival_seconds) diff --git a/plugins/utilities.json b/plugins/utilities.json index cee50f85..701e5dff 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -335,12 +335,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "0c5ce76", - "released_on": "02-07-2023", - "md5sum": "8b05407fda379d853f5c75677b19fd85" - }, + "2.0.0":null, "1.2.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -422,12 +417,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "bf3e61b", - "released_on": "04-07-2023", - "md5sum": "289cc852b7f0ec1b254d08267c9921c2" - }, + "2.0.0":null, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -453,12 +443,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "0c5ce76", - "released_on": "02-07-2023", - "md5sum": "bb5d85fb528020e809eaebb17a388e32" - }, + "2.0.0": null, "1.0.0": { "api_version": 7, "commit_sha": "ff4de19", @@ -522,12 +507,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "a0239a9", - "released_on": "04-07-2023", - "md5sum": "187a9894158721c8fa1ecee9e3e38e73" - }, + "2.0.0":null, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", diff --git a/plugins/utilities/character_chooser.py b/plugins/utilities/character_chooser.py index da12dbb3..9dbe7333 100644 --- a/plugins/utilities/character_chooser.py +++ b/plugins/utilities/character_chooser.py @@ -55,6 +55,7 @@ from bascenev1lib.actor.spazappearance import * + def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, lobby: 'Lobby') -> None: self._deek_sound = bs.getsound('deek') @@ -112,25 +113,25 @@ def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, self._profilename = self._profilenames[self._profileindex] self._text_node = bs.newnode('text', - delegate=self, - attrs={ - 'position': (-100, self._vpos), - 'maxwidth': 190, - 'shadow': 0.5, - 'vr_depth': -20, - 'h_align': 'left', - 'v_align': 'center', - 'v_attach': 'top' - }) + delegate=self, + attrs={ + 'position': (-100, self._vpos), + 'maxwidth': 190, + 'shadow': 0.5, + 'vr_depth': -20, + 'h_align': 'left', + 'v_align': 'center', + 'v_attach': 'top' + }) bs.animate(self._text_node, 'scale', {0: 0, 0.1: 1.0}) self.icon = bs.newnode('image', - owner=self._text_node, - attrs={ - 'position': (-130, self._vpos + 20), - 'mask_texture': self._mask_texture, - 'vr_depth': -10, - 'attach': 'topCenter' - }) + owner=self._text_node, + attrs={ + 'position': (-130, self._vpos + 20), + 'mask_texture': self._mask_texture, + 'vr_depth': -10, + 'attach': 'topCenter' + }) bs.animate_array(self.icon, 'scale', 2, {0: (0, 0), 0.1: (45, 45)}) diff --git a/plugins/utilities/easy_connect.py b/plugins/utilities/easy_connect.py index c9255154..abd2f43c 100644 --- a/plugins/utilities/easy_connect.py +++ b/plugins/utilities/easy_connect.py @@ -15,13 +15,13 @@ # .................___________________________________________ # Have any idea/suggestion/bug report > send message on discord mr.smoothy#5824 -# Download modshttps://bombsquad-community.web.app/mods +# Download modshttps://bombsquad-community.web.app/mods # Discord:- # mr.smoothy#5824 # DONT EDIT ANYTHING WITHOUT PERMISSION -# join Bombsquad Community Server - +# join Bombsquad Community Server - # https://discord.gg/ucyaesh @@ -73,6 +73,7 @@ def is_game_version_lower_than(version): return game_version < version + def updateBannedServersCache(): response = None config = babase.app.config @@ -111,7 +112,7 @@ def run(self) -> None: except Exception: result = None babase.pushcall(lambda: self._call(result, self._port), - from_other_thread=True) + from_other_thread=True) def newbuild_favorites_tab(self, region_height: float) -> None: @@ -147,45 +148,45 @@ def newbuild_favorites_tab(self, region_height: float) -> None: # ================= smoothy ============= bui.textwidget(parent=self._container, - position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv + - 120 if uiscale is babase.UIScale.SMALL else btnv+90), - size=(0, 0), - h_align='center', - color=(0.8, 0.8, 0.8), - v_align='top', - text="Auto") + position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv + + 120 if uiscale is babase.UIScale.SMALL else btnv+90), + size=(0, 0), + h_align='center', + color=(0.8, 0.8, 0.8), + v_align='top', + text="Auto") btnv += 50 if uiscale is babase.UIScale.SMALL else 0 bui.buttonwidget(parent=self._container, - size=(30, 30), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv+10), - - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self.auto_retry_dec, - text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, - label="-", - autoselect=True) + size=(30, 30), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv+10), + + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self.auto_retry_dec, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, + label="-", + autoselect=True) self.retry_inter_text = bui.textwidget(parent=self._container, - position=( - 90 if uiscale is babase.UIScale.SMALL else 120, btnv+25), - size=(0, 0), - h_align='center', - color=(0.8, 0.8, 0.8), - v_align='center', - text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') + position=( + 90 if uiscale is babase.UIScale.SMALL else 120, btnv+25), + size=(0, 0), + h_align='center', + color=(0.8, 0.8, 0.8), + v_align='center', + text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') bui.buttonwidget(parent=self._container, - size=(30, 30), - position=(125 if uiscale is babase.UIScale.SMALL else 155, - btnv+10), + size=(30, 30), + position=(125 if uiscale is babase.UIScale.SMALL else 155, + btnv+10), - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self.auto_retry_inc, - text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, - label="+", - autoselect=True) + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self.auto_retry_inc, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, + label="+", + autoselect=True) btnv -= b_height + b_space_extra @@ -202,31 +203,31 @@ def newbuild_favorites_tab(self, region_height: float) -> None: autoselect=True) if uiscale is babase.UIScale.SMALL and bui.app.ui_v1.use_toolbars: bui.widget(edit=btn1, - left_widget=bui.get_special_widget('back_button')) + left_widget=bui.get_special_widget('back_button')) btnv -= b_height + b_space_extra bui.buttonwidget(parent=self._container, - size=(b_width, b_height), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv), - button_type='square', - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self._on_favorites_edit_press, - text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, - label=babase.Lstr(resource='editText'), - autoselect=True) + size=(b_width, b_height), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv), + button_type='square', + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self._on_favorites_edit_press, + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='editText'), + autoselect=True) btnv -= b_height + b_space_extra bui.buttonwidget(parent=self._container, - size=(b_width, b_height), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv), - button_type='square', - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self._on_favorite_delete_press, - text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, - label=babase.Lstr(resource='deleteText'), - autoselect=True) + size=(b_width, b_height), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv), + button_type='square', + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self._on_favorite_delete_press, + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='deleteText'), + autoselect=True) v -= sub_scroll_height + 23 self._scrollwidget = scrlw = bui.scrollwidget( @@ -235,12 +236,12 @@ def newbuild_favorites_tab(self, region_height: float) -> None: size=(sub_scroll_width, sub_scroll_height), claims_left_right=True) bui.widget(edit=self._favorites_connect_button, - right_widget=self._scrollwidget) + right_widget=self._scrollwidget) self._columnwidget = bui.columnwidget(parent=scrlw, - left_border=10, - border=2, - margin=0, - claims_left_right=True) + left_border=10, + border=2, + margin=0, + claims_left_right=True) self._favorite_selected = None self._refresh_favorites() @@ -322,8 +323,9 @@ def _clear(self) -> None: self._stats_button ]: if widget: - + widget.delete() + def update(self, index: int, party: PartyEntry, sub_scroll_width: float, @@ -331,128 +333,127 @@ def update(self, index: int, party: PartyEntry, sub_scroll_width: float, columnwidget: bui.Widget, join_text: bui.Widget, filter_text: bui.Widget, existing_selection: Optional[Selection], tab: PublicGatherTab) -> None: - """Update for the given data.""" - # pylint: disable=too-many-locals - - # Quick-out: if we've been marked clean for a certain index and - # we're still at that index, we're done. - plus = bui.app.plus - assert plus is not None - - # Quick-out: if we've been marked clean for a certain index and - # we're still at that index, we're done. - if party.clean_display_index == index: - return - - ping_good = plus.get_v1_account_misc_read_val('pingGood', 100) - ping_med = plus.get_v1_account_misc_read_val('pingMed', 500) - - self._clear() - hpos = 20 - vpos = sub_scroll_height - lineheight * index - 50 - self._name_widget = bui.textwidget( - text=bui.Lstr(value=party.name), - parent=columnwidget, - size=(sub_scroll_width * 0.63, 20), - position=(0 + hpos, 4 + vpos), - selectable=True, - on_select_call=bui.WeakCall( - tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.NAME), - ), - on_activate_call=bui.WeakCall(tab.on_public_party_activate, party), - click_activate=True, - maxwidth=sub_scroll_width * 0.45, - corner_scale=1.4, - autoselect=True, - color=(1, 1, 1, 0.3 if party.ping is None else 1.0), - h_align='left', - v_align='center', - ) - bui.widget( - edit=self._name_widget, - left_widget=join_text, - show_buffer_top=64.0, - show_buffer_bottom=64.0, - ) - if existing_selection == Selection( - party.get_key(), SelectionComponent.NAME - ): - bui.containerwidget( - edit=columnwidget, selected_child=self._name_widget - ) - if party.stats_addr or True: - url = party.stats_addr.replace( - '${ACCOUNT}', - plus.get_v1_account_misc_read_val_2( - 'resolvedAccountID', 'UNKNOWN' - ), - ) - self._stats_button = bui.buttonwidget( - color=(0.3, 0.6, 0.94), - textcolor=(1.0, 1.0, 1.0), - label='....', + """Update for the given data.""" + # pylint: disable=too-many-locals + + # Quick-out: if we've been marked clean for a certain index and + # we're still at that index, we're done. + plus = bui.app.plus + assert plus is not None + + # Quick-out: if we've been marked clean for a certain index and + # we're still at that index, we're done. + if party.clean_display_index == index: + return + + ping_good = plus.get_v1_account_misc_read_val('pingGood', 100) + ping_med = plus.get_v1_account_misc_read_val('pingMed', 500) + + self._clear() + hpos = 20 + vpos = sub_scroll_height - lineheight * index - 50 + self._name_widget = bui.textwidget( + text=bui.Lstr(value=party.name), parent=columnwidget, - autoselect=True, - on_activate_call=bui.Call(bui.open_url, url), + size=(sub_scroll_width * 0.63, 20), + position=(0 + hpos, 4 + vpos), + selectable=True, on_select_call=bui.WeakCall( tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.STATS_BUTTON), + Selection(party.get_key(), SelectionComponent.NAME), ), - size=(120, 40), - position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), - scale=0.9, + on_activate_call=bui.WeakCall(tab.on_public_party_activate, party), + click_activate=True, + maxwidth=sub_scroll_width * 0.45, + corner_scale=1.4, + autoselect=True, + color=(1, 1, 1, 0.3 if party.ping is None else 1.0), + h_align='left', + v_align='center', + ) + bui.widget( + edit=self._name_widget, + left_widget=join_text, + show_buffer_top=64.0, + show_buffer_bottom=64.0, ) - bui.buttonwidget(edit=self._stats_button, on_activate_call=bui.WeakCall( - self.on_stats_click, self._stats_button, party)) if existing_selection == Selection( - party.get_key(), SelectionComponent.STATS_BUTTON + party.get_key(), SelectionComponent.NAME ): bui.containerwidget( - edit=columnwidget, selected_child=self._stats_button + edit=columnwidget, selected_child=self._name_widget ) + if party.stats_addr or True: + url = party.stats_addr.replace( + '${ACCOUNT}', + plus.get_v1_account_misc_read_val_2( + 'resolvedAccountID', 'UNKNOWN' + ), + ) + self._stats_button = bui.buttonwidget( + color=(0.3, 0.6, 0.94), + textcolor=(1.0, 1.0, 1.0), + label='....', + parent=columnwidget, + autoselect=True, + on_activate_call=bui.Call(bui.open_url, url), + on_select_call=bui.WeakCall( + tab.set_public_party_selection, + Selection(party.get_key(), SelectionComponent.STATS_BUTTON), + ), + size=(120, 40), + position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), + scale=0.9, + ) + bui.buttonwidget(edit=self._stats_button, on_activate_call=bui.WeakCall( + self.on_stats_click, self._stats_button, party)) + if existing_selection == Selection( + party.get_key(), SelectionComponent.STATS_BUTTON + ): + bui.containerwidget( + edit=columnwidget, selected_child=self._stats_button + ) + + self._size_widget = bui.textwidget( + text=str(party.size) + '/' + str(party.size_max), + parent=columnwidget, + size=(0, 0), + position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), + scale=0.7, + color=(0.8, 0.8, 0.8), + h_align='right', + v_align='center', + ) - self._size_widget = bui.textwidget( - text=str(party.size) + '/' + str(party.size_max), - parent=columnwidget, - size=(0, 0), - position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), - scale=0.7, - color=(0.8, 0.8, 0.8), - h_align='right', - v_align='center', - ) + if index == 0: + bui.widget(edit=self._name_widget, up_widget=filter_text) + if self._stats_button: + bui.widget(edit=self._stats_button, up_widget=filter_text) - if index == 0: - bui.widget(edit=self._name_widget, up_widget=filter_text) - if self._stats_button: - bui.widget(edit=self._stats_button, up_widget=filter_text) - - self._ping_widget = bui.textwidget( - parent=columnwidget, - size=(0, 0), - position=(sub_scroll_width * 0.94 + hpos, 20 + vpos), - scale=0.7, - h_align='right', - v_align='center', - ) - if party.ping is None: - bui.textwidget( - edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5) - ) - else: - bui.textwidget( - edit=self._ping_widget, - text=str(int(party.ping)), - color=(0, 1, 0) - if party.ping <= ping_good - else (1, 1, 0) - if party.ping <= ping_med - else (1, 0, 0), + self._ping_widget = bui.textwidget( + parent=columnwidget, + size=(0, 0), + position=(sub_scroll_width * 0.94 + hpos, 20 + vpos), + scale=0.7, + h_align='right', + v_align='center', ) + if party.ping is None: + bui.textwidget( + edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5) + ) + else: + bui.textwidget( + edit=self._ping_widget, + text=str(int(party.ping)), + color=(0, 1, 0) + if party.ping <= ping_good + else (1, 1, 0) + if party.ping <= ping_med + else (1, 0, 0), + ) - party.clean_display_index = index - + party.clean_display_index = index def _get_popup_window_scale() -> float: uiscale = bui.app.ui_v1.uiscale @@ -500,7 +501,7 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu, url = _party.stats_addr.replace( '${ACCOUNT}', plus.get_v1_account_misc_read_val_2('resolvedAccountID', - 'UNKNOWN')) + 'UNKNOWN')) bui.open_url(url) elif choice == 'connect': PartyQuickConnect(_party.address, _party.port) @@ -613,17 +614,17 @@ def __init__(self, address: str, port: int): scale=(1.4 if uiscale is babase.UIScale.SMALL else 1.2 if uiscale is babase.UIScale.MEDIUM else 1.0))) self._cancel_button = bui.buttonwidget(parent=self._root_widget, - scale=1.0, - position=(60, self._height - 80), - size=(50, 50), - label='', - on_activate_call=self.close, - autoselect=True, - color=(0.45, 0.63, 0.15), - icon=bui.gettexture('crossOut'), - iconscale=1.2) + scale=1.0, + position=(60, self._height - 80), + size=(50, 50), + label='', + on_activate_call=self.close, + autoselect=True, + color=(0.45, 0.63, 0.15), + icon=bui.gettexture('crossOut'), + iconscale=1.2) bui.containerwidget(edit=self._root_widget, - cancel_button=self._cancel_button) + cancel_button=self._cancel_button) self.IP = bui.textwidget( parent=self._root_widget, diff --git a/plugins/utilities/pro_unlocker.py b/plugins/utilities/pro_unlocker.py index bac31447..389140f7 100644 --- a/plugins/utilities/pro_unlocker.py +++ b/plugins/utilities/pro_unlocker.py @@ -4,23 +4,8 @@ import babase -def is_game_version_lower_than(version): - """ - Returns a boolean value indicating whether the current game - version is lower than the passed version. Useful for addressing - any breaking changes within game versions. - """ - game_version = tuple(map(int, babase.app.version.split("."))) - version = tuple(map(int, version.split("."))) - return game_version < version - - -if is_game_version_lower_than("1.7.20"): - original_get_purchased = _baplus.get_purchased -else: - assert bs.app.plus is not None - original_get_purchased = bs.app.plus.get_purchased +original_get_purchased = _baplus.get_purchased def get_purchased(item): if item.startswith('characters.') or item.startswith('icons.'): @@ -32,8 +17,5 @@ def get_purchased(item): class Unlock(babase.Plugin): def on_app_running(self): babase.app.classic.accounts.have_pro = lambda: True - if is_game_version_lower_than("1.7.20"): - _baplus.get_purchased = get_purchased - else: - assert bs.app.plus is not None - bs.app.plus.get_purchased = get_purchased + _baplus.get_purchased = get_purchased + \ No newline at end of file diff --git a/plugins/utilities/server_switch.py b/plugins/utilities/server_switch.py index aacb0fe7..ba4ffdcf 100644 --- a/plugins/utilities/server_switch.py +++ b/plugins/utilities/server_switch.py @@ -1,575 +1,108 @@ -# discord @mr.smoothy#5824 - +# -*- coding: utf-8 -*- # ba_meta require api 8 - -from __future__ import annotations -import copy -import time -from typing import TYPE_CHECKING - +''' +Server Switch Plugin by My.Smoothy +Let you switch recently joined servers very quickly ++ Added button to quicky look into public server list without leaving current game. + +discord: mr.smoothy +https://discord.gg/ucyaesh +Youtube : Hey Smoothy +Download more mods from +https://bombsquad-community.web.app/mods +''' import babase +import bauiv1lib.mainmenu as bastd_ui_mainmenu import bauiv1 as bui import bascenev1 as bs -import _bascenev1 as _bs -import time -import threading -from enum import Enum -from dataclasses import dataclass -if TYPE_CHECKING: - from typing import Any, Optional, Dict, List, Tuple, Type - import bascenev1 as bs - from bauiv1lib.gather import GatherWindow - -from bauiv1lib.confirm import ConfirmWindow - -import bauiv1lib.mainmenu as bastd_ui_mainmenu - -connect = bs.connect_to_party -disconnect = bs.disconnect_from_host - -server = [] - -ip_add = "private" -p_port = 44444 -p_name = "nothing here" - - -def newconnect_to_party(address, port=43210, print_progress=False): - global ip_add - global p_port - dd = _bs.get_connection_to_host_info() - if (dd != {}): - _bs.disconnect_from_host() - - ip_add = address - p_port = port - connect(address, port, print_progress) - else: - - ip_add = address - p_port = port - # print(ip_add,p_port) - connect(ip_add, port, print_progress) - - -def newdisconnect_from_host(): - try: - name = _bs.get_connection_to_host_info()['name'] - global server - global ip_add - global p_port - pojo = {"name": name, "ip": ip_add, "port": p_port} - if pojo not in server: - server.insert(0, pojo) - server = server[:3] - except: - pass - disconnect() - - -def printip(): - bs.screenmessage("ip address is"+ip_add) - - -def new_refresh_in_game( - self, positions: List[Tuple[float, float, - float]]) -> Tuple[float, float, float]: - # pylint: disable=too-many-branches - # pylint: disable=too-many-locals - # pylint: disable=too-many-statements - custom_menu_entries: List[Dict[str, Any]] = [] - session = _bs.get_foreground_host_session() - if session is not None: - try: - custom_menu_entries = session.get_custom_menu_entries() - for cme in custom_menu_entries: - if (not isinstance(cme, dict) or 'label' not in cme - or not isinstance(cme['label'], (str, bs.Lstr)) - or 'call' not in cme or not callable(cme['call'])): - raise ValueError('invalid custom menu entry: ' + - str(cme)) - except Exception: - custom_menu_entries = [] - babase.print_exception( - f'Error getting custom menu entries for {session}') - self._width = 250.0 - self._height = 250.0 if self._input_player else 180.0 - if (self._is_demo or self._is_arcade) and self._input_player: - self._height -= 40 - if not self._have_settings_button: - self._height -= 50 - if self._connected_to_remote_player: - # In this case we have a leave *and* a disconnect button. - self._height += 50 - self._height += 50 * (len(custom_menu_entries)) - uiscale = bui.app.ui_v1.uiscale - bui.containerwidget( - edit=self._root_widget, - size=(self._width*2, self._height), - scale=(2.15 if uiscale is bui.UIScale.SMALL else - 1.6 if uiscale is bui.UIScale.MEDIUM else 1.0)) - h = 125.0 - v = (self._height - 80.0 if self._input_player else self._height - 60) - h_offset = 0 - d_h_offset = 0 - v_offset = -50 - for _i in range(6 + len(custom_menu_entries)): - positions.append((h, v, 1.0)) - v += v_offset - h += h_offset - h_offset += d_h_offset - self._start_button = None - bui.app.pause() - h, v, scale = positions[self._p_index] - bui.textwidget( +current_server_ip = "127.0.0.1" +current_server_port = 43210 +servers = [] +def _refresh_in_game(func): + def wrapper(self, *args, **kwargs): + returnValue = func(self, *args, **kwargs) + uiscale = bui.app.ui_v1.uiscale + bui.containerwidget( + edit=self._root_widget, + size=(self._width*2, self._height), # double the width + scale=( + 2.15 + if uiscale is bui.UIScale.SMALL + else 1.6 + if uiscale is bui.UIScale.MEDIUM + else 1.0 + ), + ) + h = 125 + v = self._height - 60.0 + bui.textwidget( parent=self._root_widget, draw_controller=None, - text="IP: "+ip_add+" PORT: "+str(p_port), - position=(h+self._button_width-80, v+60), + text="IP: "+current_server_ip+" PORT: "+str(current_server_port), + position=(h-self._button_width/2 + 130 , v+60), h_align='center', v_align='center', size=(20, 60), scale=0.6) - v_h = v - - global server - - def con(address, port): - global ip_add - global p_port - if (address == ip_add and port == p_port): - self._resume() - else: - _bs.disconnect_from_host() - _bs.connect_to_party(address, port) - if len(server) == 0: - bui.textwidget( - parent=self._root_widget, - draw_controller=None, - text="Nothing in \n recents", - position=(h + self._button_width * scale, v-30), - h_align='center', - v_align='center', - size=(20, 60), - scale=1) - for ser in server: - self._server_button = bui.buttonwidget( - color=(0.8, 0, 1), - parent=self._root_widget, - position=(h + self._button_width * scale - 80, v_h), - size=(self._button_width, self._button_height), - scale=scale, - autoselect=self._use_autoselect, - label=ser["name"][0:22], - - on_activate_call=bs.Call(con, ser["ip"], ser["port"])) - v_h = v_h-50 - - # Player name if applicable. - if self._input_player: - player_name = self._input_player.getname() - h, v, scale = positions[self._p_index] - v += 35 - bui.textwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, self._button_height), - color=(1, 1, 1, 0.5), - scale=0.7, - h_align='center', - text=bs.Lstr(value=player_name)) - else: - player_name = '' - h, v, scale = positions[self._p_index] - self._p_index += 1 - btn = bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, self._button_height), - scale=scale, - label=bs.Lstr(resource=self._r + '.resumeText'), - autoselect=self._use_autoselect, - on_activate_call=self._resume) - bui.containerwidget(edit=self._root_widget, cancel_button=btn) - - # Add any custom options defined by the current game. - for entry in custom_menu_entries: - h, v, scale = positions[self._p_index] - self._p_index += 1 - - # Ask the entry whether we should resume when we call - # it (defaults to true). - resume = bool(entry.get('resume_on_call', True)) - - if resume: - call = bs.Call(self._resume_and_call, entry['call']) - else: - call = bs.Call(entry['call'], bs.WeakCall(self._resume)) - - bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, self._button_height), - scale=scale, - on_activate_call=call, - label=entry['label'], - autoselect=self._use_autoselect) - # Add a 'leave' button if the menu-owner has a player. - if ((self._input_player or self._connected_to_remote_player) - and not (self._is_demo or self._is_arcade)): - h, v, scale = positions[self._p_index] - self._p_index += 1 - btn = bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width / 2, v), - size=(self._button_width, - self._button_height), - scale=scale, - on_activate_call=self._leave, - label='', - autoselect=self._use_autoselect) - - if (player_name != '' and player_name[0] != '<' - and player_name[-1] != '>'): - txt = bs.Lstr(resource=self._r + '.justPlayerText', - subs=[('${NAME}', player_name)]) - else: - txt = bs.Lstr(value=player_name) - bui.textwidget(parent=self._root_widget, - position=(h, v + self._button_height * - (0.64 if player_name != '' else 0.5)), - size=(0, 0), - text=bs.Lstr(resource=self._r + '.leaveGameText'), - scale=(0.83 if player_name != '' else 1.0), - color=(0.75, 1.0, 0.7), - h_align='center', - v_align='center', - draw_controller=btn, - maxwidth=self._button_width * 0.9) - bui.textwidget(parent=self._root_widget, - position=(h, v + self._button_height * 0.27), - size=(0, 0), - text=txt, - color=(0.75, 1.0, 0.7), - h_align='center', - v_align='center', - draw_controller=btn, - scale=0.45, - maxwidth=self._button_width * 0.9) - return h, v, scale - - -def new_refresh(self) -> None: - # pylint: disable=too-many-branches - # pylint: disable=too-many-locals - # pylint: disable=too-many-statements - global server - print(server) - from bauiv1lib.confirm import QuitWindow - from bauiv1lib.store.button import StoreButton - import bascenev1 as bs - import _bascenev1 as _bs - import bauiv1 as bui - import _baplus - # Clear everything that was there. - children = self._root_widget.get_children() - for child in children: - child.delete() - - self._tdelay = 0.0 - self._t_delay_inc = 0.0 - self._t_delay_play = 0.0 - self._button_width = 200.0 - self._button_height = 45.0 - - self._r = 'mainMenu' - - assert bs.app.classic is not None - app = bs.app.classic - self._have_quit_button = (bui.app.ui_v1.uiscale is bui.UIScale.LARGE - or (app.platform == 'windows' - and app.subplatform == 'oculus')) - - self._have_store_button = not self._in_game - - self._have_settings_button = ( - (not self._in_game or not bui.app.toolbar_test) - and not (self._is_demo or self._is_arcade or self._is_iircade)) - - self._input_device = input_device = _bs.get_ui_input_device() - self._input_player = input_device.player if input_device else None - self._connected_to_remote_player = ( - input_device.is_attached_to_player() - if input_device else False) - - positions: List[Tuple[float, float, float]] = [] - self._p_index = 0 - - if self._in_game: - h, v, scale = self._refresh_in_game(positions) - print("refreshing in GAME", ip_add) - # btn = bui.buttonwidget(parent=self._root_widget, - # position=(80,270), - # size=(100, 90), - # scale=1.2, - # label=ip_add, - # autoselect=None, - # on_activate_call=printip) - bui.textwidget( - parent=self._root_widget, - draw_controller=None, - text="IP: "+ip_add+" PORT: "+str(p_port), - position=(150, 270), - h_align='center', - v_align='center', - size=(20, 60), - scale=1) - self._server_button = bui.buttonwidget( - parent=self._root_widget, - position=(h * 3.2 + 20 - self._button_width * scale, v), - size=(self._button_width, self._button_height), - scale=scale, - autoselect=self._use_autoselect, - label=bs.Lstr(resource=self._r + '.settingsText'), - transition_delay=self._tdelay, - on_activate_call=self._settings) - self._server_button2 = bui.buttonwidget( - parent=self._root_widget, - position=(h * 3.2 + 20 - self._button_width * scale, v-50), - size=(self._button_width, self._button_height), - scale=scale, - autoselect=self._use_autoselect, - label=bs.Lstr(resource=self._r + '.settingsText'), - transition_delay=self._tdelay, - on_activate_call=self._settings) - self._server_button3 = bui.buttonwidget( - parent=self._root_widget, - position=(h * 3.2 + 20 - self._button_width * scale, v-100), - size=(self._button_width, self._button_height), - scale=scale, - autoselect=self._use_autoselect, - label=bs.Lstr(resource=self._r + '.settingsText'), - transition_delay=self._tdelay, - on_activate_call=self._settings) - - else: - h, v, scale = self._refresh_not_in_game(positions) - - if self._have_settings_button: - h, v, scale = positions[self._p_index] - self._p_index += 1 - self._settings_button = bui.buttonwidget( - parent=self._root_widget, - position=(h - self._button_width * 0.5 * scale, v), - size=(self._button_width, self._button_height), - scale=scale, - autoselect=self._use_autoselect, - label=bs.Lstr(resource=self._r + '.settingsText'), - transition_delay=self._tdelay, - on_activate_call=self._settings) - - # Scattered eggs on easter. - if _baplus.get_v1_account_misc_read_val('easter', - False) and not self._in_game: - icon_size = 34 - bui.imagewidget(parent=self._root_widget, - position=(h - icon_size * 0.5 - 15, - v + self._button_height * scale - - icon_size * 0.24 + 1.5), - transition_delay=self._tdelay, - size=(icon_size, icon_size), - texture=bui.gettexture('egg3'), - tilt_scale=0.0) - - self._tdelay += self._t_delay_inc - - if self._in_game: - h, v, scale = positions[self._p_index] - self._p_index += 1 - - # If we're in a replay, we have a 'Leave Replay' button. - if _bs.is_in_replay(): - bui.buttonwidget(parent=self._root_widget, - position=(h - self._button_width * 0.5 * scale, - v), - scale=scale, - size=(self._button_width, self._button_height), - autoselect=self._use_autoselect, - label=bs.Lstr(resource='replayEndText'), - on_activate_call=self._confirm_end_replay) - elif _bs.get_foreground_host_session() is not None: - bui.buttonwidget( + self._public_servers = bui.buttonwidget( + color=(0.8, 0.45, 1), parent=self._root_widget, - position=(h - self._button_width * 0.5 * scale, v), - scale=scale, - size=(self._button_width, self._button_height), + position=(h+self._button_width-10, v+60+20), + size=(self._button_width/4, self._button_height/2), + scale=1.0, autoselect=self._use_autoselect, - label=bs.Lstr(resource=self._r + '.endGameText'), - on_activate_call=self._confirm_end_game) - # Assume we're in a client-session. - else: - bui.buttonwidget( + label="~~~", + on_activate_call=bs.Call(public_servers)) + for server in servers: + self._server_button = bui.buttonwidget( + color=(0.8, 0, 1), parent=self._root_widget, - position=(h - self._button_width * 0.5 * scale, v), - scale=scale, + position=( (h- self._button_width / 2 ) + self._button_width + 20, v), size=(self._button_width, self._button_height), + scale=1.0, autoselect=self._use_autoselect, - label=bs.Lstr(resource=self._r + '.leavePartyText'), - on_activate_call=self._confirm_leave_party) + label=server["name"][0:22], + on_activate_call=bs.Call(bs.connect_to_party, server["ip"], server["port"])) + + v -= 50 + + return returnValue + return wrapper - self._store_button: Optional[bui.Widget] - if self._have_store_button: - this_b_width = self._button_width - h, v, scale = positions[self._p_index] - self._p_index += 1 - - sbtn = self._store_button_instance = StoreButton( - parent=self._root_widget, - position=(h - this_b_width * 0.5 * scale, v), - size=(this_b_width, self._button_height), - scale=scale, - on_activate_call=bs.WeakCall(self._on_store_pressed), - sale_scale=1.3, - transition_delay=self._tdelay) - self._store_button = store_button = sbtn.get_button() - uiscale = bui.app.ui_v1.uiscale - icon_size = (55 if uiscale is bui.UIScale.SMALL else - 55 if uiscale is bui.UIScale.MEDIUM else 70) - bui.imagewidget( - parent=self._root_widget, - position=(h - icon_size * 0.5, - v + self._button_height * scale - icon_size * 0.23), - transition_delay=self._tdelay, - size=(icon_size, icon_size), - texture=bui.gettexture(self._store_char_tex), - tilt_scale=0.0, - draw_controller=store_button) - - self._tdelay += self._t_delay_inc - else: - self._store_button = None - - self._quit_button: Optional[bui.Widget] - if not self._in_game and self._have_quit_button: - h, v, scale = positions[self._p_index] - self._p_index += 1 - self._quit_button = quit_button = bui.buttonwidget( - parent=self._root_widget, - autoselect=self._use_autoselect, - position=(h - self._button_width * 0.5 * scale, v), - size=(self._button_width, self._button_height), - scale=scale, - label=bs.Lstr(resource=self._r + - ('.quitText' if 'Mac' in - bs.app.classic.legacy_user_agent_string else '.exitGameText')), - on_activate_call=self._quit, - transition_delay=self._tdelay) - - # Scattered eggs on easter. - if _baplus.get_v1_account_misc_read_val('easter', False): - icon_size = 30 - bui.imagewidget(parent=self._root_widget, - position=(h - icon_size * 0.5 + 25, - v + self._button_height * scale - - icon_size * 0.24 + 1.5), - transition_delay=self._tdelay, - size=(icon_size, icon_size), - texture=bui.gettexture('egg1'), - tilt_scale=0.0) - - bui.containerwidget(edit=self._root_widget, - cancel_button=quit_button) - self._tdelay += self._t_delay_inc +connect = bs.connect_to_party +def connect_to_party(address, port=43210, print_progress=False): + global current_server_ip + global current_server_port + if (bs.get_connection_to_host_info() != {}): + bs.disconnect_from_host() + current_server_ip = address + current_server_port = port + connect(address, port, print_progress) + babase.apptimer(1, check_connect_status) + +def check_connect_status(): + global servers + global current_server_ip + global current_server_port + if (bs.get_connection_to_host_info() != {}): + if (not bs.get_connection_to_host_info()['name']): + babase.apptimer(1, check_connect_status) + return + new_server = {"name": bs.get_connection_to_host_info()['name'], "ip": current_server_ip, "port": current_server_port} + if new_server not in servers: + servers.append(new_server) + servers = servers[-3:] else: - self._quit_button = None - - # If we're not in-game, have no quit button, and this is android, - # we want back presses to quit our activity. - if (not self._in_game and not self._have_quit_button - and bs.app.classic.platform == 'android'): - - def _do_quit() -> None: - QuitWindow(swish=True, back=True) - - bui.containerwidget(edit=self._root_widget, - on_cancel_call=_do_quit) - - # Add speed-up/slow-down buttons for replays. - # (ideally this should be part of a fading-out playback bar like most - # media players but this works for now). - if _bs.is_in_replay(): - b_size = 50.0 - b_buffer = 10.0 - t_scale = 0.75 - uiscale = bui.app.ui_v1.uiscale - if uiscale is bui.UIScale.SMALL: - b_size *= 0.6 - b_buffer *= 1.0 - v_offs = -40 - t_scale = 0.5 - elif uiscale is bui.UIScale.MEDIUM: - v_offs = -70 - else: - v_offs = -100 - self._replay_speed_text = bui.textwidget( - parent=self._root_widget, - text=bs.Lstr(resource='watchWindow.playbackSpeedText', - subs=[('${SPEED}', str(1.23))]), - position=(h, v + v_offs + 7 * t_scale), - h_align='center', - v_align='center', - size=(0, 0), - scale=t_scale) - - # Update to current value. - self._change_replay_speed(0) - - # Keep updating in a timer in case it gets changed elsewhere. - self._change_replay_speed_timer = bs.Timer( - 0.25, - bs.WeakCall(self._change_replay_speed, 0), - repeat=True) - btn = bui.buttonwidget(parent=self._root_widget, - position=(h - b_size - b_buffer, - v - b_size - b_buffer + v_offs), - button_type='square', - size=(b_size, b_size), - label='', - autoselect=True, - on_activate_call=bs.Call( - self._change_replay_speed, -1)) - bui.textwidget( - parent=self._root_widget, - draw_controller=btn, - text='-', - position=(h - b_size * 0.5 - b_buffer, - v - b_size * 0.5 - b_buffer + 5 * t_scale + v_offs), - h_align='center', - v_align='center', - size=(0, 0), - scale=3.0 * t_scale) - btn = bui.buttonwidget( - parent=self._root_widget, - position=(h + b_buffer, v - b_size - b_buffer + v_offs), - button_type='square', - size=(b_size, b_size), - label='', - autoselect=True, - on_activate_call=bs.Call(self._change_replay_speed, 1)) - bui.textwidget( - parent=self._root_widget, - draw_controller=btn, - text='+', - position=(h + b_size * 0.5 + b_buffer, - v - b_size * 0.5 - b_buffer + 5 * t_scale + v_offs), - h_align='center', - v_align='center', - size=(0, 0), - scale=3.0 * t_scale) + print("connection failed falling back to gather window") + public_servers() +def public_servers(origin = None): + from bauiv1lib.gather import GatherWindow + bui.app.ui_v1.set_main_menu_window( GatherWindow(origin_widget=origin).get_root_widget()) # ba_meta export plugin class bySmoothy(babase.Plugin): def __init__(self): - if babase.env().get("build_number", 0) >= 21140: - bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = new_refresh_in_game - bs.connect_to_party = newconnect_to_party - bs.disconnect_from_host = newdisconnect_from_host - else: - print("Server Switch only works on bs 1.7.20 and above") + bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = _refresh_in_game(bastd_ui_mainmenu.MainMenuWindow._refresh_in_game) + bs.connect_to_party = connect_to_party + \ No newline at end of file From b9b494428575825413921bbc7ec6f2c1193d7b57 Mon Sep 17 00:00:00 2001 From: imayushsaini Date: Sat, 8 Jul 2023 09:56:30 +0000 Subject: [PATCH 12/17] [ci] auto-format --- plugins/utilities/character_chooser.py | 35 ++- plugins/utilities/easy_connect.py | 367 ++++++++++++------------- plugins/utilities/pro_unlocker.py | 3 +- plugins/utilities/server_switch.py | 64 +++-- 4 files changed, 238 insertions(+), 231 deletions(-) diff --git a/plugins/utilities/character_chooser.py b/plugins/utilities/character_chooser.py index 9dbe7333..da12dbb3 100644 --- a/plugins/utilities/character_chooser.py +++ b/plugins/utilities/character_chooser.py @@ -55,7 +55,6 @@ from bascenev1lib.actor.spazappearance import * - def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, lobby: 'Lobby') -> None: self._deek_sound = bs.getsound('deek') @@ -113,25 +112,25 @@ def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, self._profilename = self._profilenames[self._profileindex] self._text_node = bs.newnode('text', - delegate=self, - attrs={ - 'position': (-100, self._vpos), - 'maxwidth': 190, - 'shadow': 0.5, - 'vr_depth': -20, - 'h_align': 'left', - 'v_align': 'center', - 'v_attach': 'top' - }) + delegate=self, + attrs={ + 'position': (-100, self._vpos), + 'maxwidth': 190, + 'shadow': 0.5, + 'vr_depth': -20, + 'h_align': 'left', + 'v_align': 'center', + 'v_attach': 'top' + }) bs.animate(self._text_node, 'scale', {0: 0, 0.1: 1.0}) self.icon = bs.newnode('image', - owner=self._text_node, - attrs={ - 'position': (-130, self._vpos + 20), - 'mask_texture': self._mask_texture, - 'vr_depth': -10, - 'attach': 'topCenter' - }) + owner=self._text_node, + attrs={ + 'position': (-130, self._vpos + 20), + 'mask_texture': self._mask_texture, + 'vr_depth': -10, + 'attach': 'topCenter' + }) bs.animate_array(self.icon, 'scale', 2, {0: (0, 0), 0.1: (45, 45)}) diff --git a/plugins/utilities/easy_connect.py b/plugins/utilities/easy_connect.py index abd2f43c..c9255154 100644 --- a/plugins/utilities/easy_connect.py +++ b/plugins/utilities/easy_connect.py @@ -15,13 +15,13 @@ # .................___________________________________________ # Have any idea/suggestion/bug report > send message on discord mr.smoothy#5824 -# Download modshttps://bombsquad-community.web.app/mods +# Download modshttps://bombsquad-community.web.app/mods # Discord:- # mr.smoothy#5824 # DONT EDIT ANYTHING WITHOUT PERMISSION -# join Bombsquad Community Server - +# join Bombsquad Community Server - # https://discord.gg/ucyaesh @@ -73,7 +73,6 @@ def is_game_version_lower_than(version): return game_version < version - def updateBannedServersCache(): response = None config = babase.app.config @@ -112,7 +111,7 @@ def run(self) -> None: except Exception: result = None babase.pushcall(lambda: self._call(result, self._port), - from_other_thread=True) + from_other_thread=True) def newbuild_favorites_tab(self, region_height: float) -> None: @@ -148,45 +147,45 @@ def newbuild_favorites_tab(self, region_height: float) -> None: # ================= smoothy ============= bui.textwidget(parent=self._container, - position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv + - 120 if uiscale is babase.UIScale.SMALL else btnv+90), - size=(0, 0), - h_align='center', - color=(0.8, 0.8, 0.8), - v_align='top', - text="Auto") + position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv + + 120 if uiscale is babase.UIScale.SMALL else btnv+90), + size=(0, 0), + h_align='center', + color=(0.8, 0.8, 0.8), + v_align='top', + text="Auto") btnv += 50 if uiscale is babase.UIScale.SMALL else 0 bui.buttonwidget(parent=self._container, - size=(30, 30), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv+10), - - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self.auto_retry_dec, - text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, - label="-", - autoselect=True) + size=(30, 30), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv+10), + + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self.auto_retry_dec, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, + label="-", + autoselect=True) self.retry_inter_text = bui.textwidget(parent=self._container, - position=( - 90 if uiscale is babase.UIScale.SMALL else 120, btnv+25), - size=(0, 0), - h_align='center', - color=(0.8, 0.8, 0.8), - v_align='center', - text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') + position=( + 90 if uiscale is babase.UIScale.SMALL else 120, btnv+25), + size=(0, 0), + h_align='center', + color=(0.8, 0.8, 0.8), + v_align='center', + text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') bui.buttonwidget(parent=self._container, - size=(30, 30), - position=(125 if uiscale is babase.UIScale.SMALL else 155, - btnv+10), + size=(30, 30), + position=(125 if uiscale is babase.UIScale.SMALL else 155, + btnv+10), - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self.auto_retry_inc, - text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, - label="+", - autoselect=True) + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self.auto_retry_inc, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, + label="+", + autoselect=True) btnv -= b_height + b_space_extra @@ -203,31 +202,31 @@ def newbuild_favorites_tab(self, region_height: float) -> None: autoselect=True) if uiscale is babase.UIScale.SMALL and bui.app.ui_v1.use_toolbars: bui.widget(edit=btn1, - left_widget=bui.get_special_widget('back_button')) + left_widget=bui.get_special_widget('back_button')) btnv -= b_height + b_space_extra bui.buttonwidget(parent=self._container, - size=(b_width, b_height), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv), - button_type='square', - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self._on_favorites_edit_press, - text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, - label=babase.Lstr(resource='editText'), - autoselect=True) + size=(b_width, b_height), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv), + button_type='square', + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self._on_favorites_edit_press, + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='editText'), + autoselect=True) btnv -= b_height + b_space_extra bui.buttonwidget(parent=self._container, - size=(b_width, b_height), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv), - button_type='square', - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self._on_favorite_delete_press, - text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, - label=babase.Lstr(resource='deleteText'), - autoselect=True) + size=(b_width, b_height), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv), + button_type='square', + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self._on_favorite_delete_press, + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='deleteText'), + autoselect=True) v -= sub_scroll_height + 23 self._scrollwidget = scrlw = bui.scrollwidget( @@ -236,12 +235,12 @@ def newbuild_favorites_tab(self, region_height: float) -> None: size=(sub_scroll_width, sub_scroll_height), claims_left_right=True) bui.widget(edit=self._favorites_connect_button, - right_widget=self._scrollwidget) + right_widget=self._scrollwidget) self._columnwidget = bui.columnwidget(parent=scrlw, - left_border=10, - border=2, - margin=0, - claims_left_right=True) + left_border=10, + border=2, + margin=0, + claims_left_right=True) self._favorite_selected = None self._refresh_favorites() @@ -323,9 +322,8 @@ def _clear(self) -> None: self._stats_button ]: if widget: - + widget.delete() - def update(self, index: int, party: PartyEntry, sub_scroll_width: float, @@ -333,127 +331,128 @@ def update(self, index: int, party: PartyEntry, sub_scroll_width: float, columnwidget: bui.Widget, join_text: bui.Widget, filter_text: bui.Widget, existing_selection: Optional[Selection], tab: PublicGatherTab) -> None: - """Update for the given data.""" - # pylint: disable=too-many-locals - - # Quick-out: if we've been marked clean for a certain index and - # we're still at that index, we're done. - plus = bui.app.plus - assert plus is not None - - # Quick-out: if we've been marked clean for a certain index and - # we're still at that index, we're done. - if party.clean_display_index == index: - return - - ping_good = plus.get_v1_account_misc_read_val('pingGood', 100) - ping_med = plus.get_v1_account_misc_read_val('pingMed', 500) - - self._clear() - hpos = 20 - vpos = sub_scroll_height - lineheight * index - 50 - self._name_widget = bui.textwidget( - text=bui.Lstr(value=party.name), + """Update for the given data.""" + # pylint: disable=too-many-locals + + # Quick-out: if we've been marked clean for a certain index and + # we're still at that index, we're done. + plus = bui.app.plus + assert plus is not None + + # Quick-out: if we've been marked clean for a certain index and + # we're still at that index, we're done. + if party.clean_display_index == index: + return + + ping_good = plus.get_v1_account_misc_read_val('pingGood', 100) + ping_med = plus.get_v1_account_misc_read_val('pingMed', 500) + + self._clear() + hpos = 20 + vpos = sub_scroll_height - lineheight * index - 50 + self._name_widget = bui.textwidget( + text=bui.Lstr(value=party.name), + parent=columnwidget, + size=(sub_scroll_width * 0.63, 20), + position=(0 + hpos, 4 + vpos), + selectable=True, + on_select_call=bui.WeakCall( + tab.set_public_party_selection, + Selection(party.get_key(), SelectionComponent.NAME), + ), + on_activate_call=bui.WeakCall(tab.on_public_party_activate, party), + click_activate=True, + maxwidth=sub_scroll_width * 0.45, + corner_scale=1.4, + autoselect=True, + color=(1, 1, 1, 0.3 if party.ping is None else 1.0), + h_align='left', + v_align='center', + ) + bui.widget( + edit=self._name_widget, + left_widget=join_text, + show_buffer_top=64.0, + show_buffer_bottom=64.0, + ) + if existing_selection == Selection( + party.get_key(), SelectionComponent.NAME + ): + bui.containerwidget( + edit=columnwidget, selected_child=self._name_widget + ) + if party.stats_addr or True: + url = party.stats_addr.replace( + '${ACCOUNT}', + plus.get_v1_account_misc_read_val_2( + 'resolvedAccountID', 'UNKNOWN' + ), + ) + self._stats_button = bui.buttonwidget( + color=(0.3, 0.6, 0.94), + textcolor=(1.0, 1.0, 1.0), + label='....', parent=columnwidget, - size=(sub_scroll_width * 0.63, 20), - position=(0 + hpos, 4 + vpos), - selectable=True, + autoselect=True, + on_activate_call=bui.Call(bui.open_url, url), on_select_call=bui.WeakCall( tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.NAME), + Selection(party.get_key(), SelectionComponent.STATS_BUTTON), ), - on_activate_call=bui.WeakCall(tab.on_public_party_activate, party), - click_activate=True, - maxwidth=sub_scroll_width * 0.45, - corner_scale=1.4, - autoselect=True, - color=(1, 1, 1, 0.3 if party.ping is None else 1.0), - h_align='left', - v_align='center', - ) - bui.widget( - edit=self._name_widget, - left_widget=join_text, - show_buffer_top=64.0, - show_buffer_bottom=64.0, + size=(120, 40), + position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), + scale=0.9, ) + bui.buttonwidget(edit=self._stats_button, on_activate_call=bui.WeakCall( + self.on_stats_click, self._stats_button, party)) if existing_selection == Selection( - party.get_key(), SelectionComponent.NAME + party.get_key(), SelectionComponent.STATS_BUTTON ): bui.containerwidget( - edit=columnwidget, selected_child=self._name_widget + edit=columnwidget, selected_child=self._stats_button ) - if party.stats_addr or True: - url = party.stats_addr.replace( - '${ACCOUNT}', - plus.get_v1_account_misc_read_val_2( - 'resolvedAccountID', 'UNKNOWN' - ), - ) - self._stats_button = bui.buttonwidget( - color=(0.3, 0.6, 0.94), - textcolor=(1.0, 1.0, 1.0), - label='....', - parent=columnwidget, - autoselect=True, - on_activate_call=bui.Call(bui.open_url, url), - on_select_call=bui.WeakCall( - tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.STATS_BUTTON), - ), - size=(120, 40), - position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), - scale=0.9, - ) - bui.buttonwidget(edit=self._stats_button, on_activate_call=bui.WeakCall( - self.on_stats_click, self._stats_button, party)) - if existing_selection == Selection( - party.get_key(), SelectionComponent.STATS_BUTTON - ): - bui.containerwidget( - edit=columnwidget, selected_child=self._stats_button - ) - - self._size_widget = bui.textwidget( - text=str(party.size) + '/' + str(party.size_max), - parent=columnwidget, - size=(0, 0), - position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), - scale=0.7, - color=(0.8, 0.8, 0.8), - h_align='right', - v_align='center', - ) - if index == 0: - bui.widget(edit=self._name_widget, up_widget=filter_text) - if self._stats_button: - bui.widget(edit=self._stats_button, up_widget=filter_text) + self._size_widget = bui.textwidget( + text=str(party.size) + '/' + str(party.size_max), + parent=columnwidget, + size=(0, 0), + position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), + scale=0.7, + color=(0.8, 0.8, 0.8), + h_align='right', + v_align='center', + ) - self._ping_widget = bui.textwidget( - parent=columnwidget, - size=(0, 0), - position=(sub_scroll_width * 0.94 + hpos, 20 + vpos), - scale=0.7, - h_align='right', - v_align='center', + if index == 0: + bui.widget(edit=self._name_widget, up_widget=filter_text) + if self._stats_button: + bui.widget(edit=self._stats_button, up_widget=filter_text) + + self._ping_widget = bui.textwidget( + parent=columnwidget, + size=(0, 0), + position=(sub_scroll_width * 0.94 + hpos, 20 + vpos), + scale=0.7, + h_align='right', + v_align='center', + ) + if party.ping is None: + bui.textwidget( + edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5) ) - if party.ping is None: - bui.textwidget( - edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5) - ) - else: - bui.textwidget( - edit=self._ping_widget, - text=str(int(party.ping)), - color=(0, 1, 0) - if party.ping <= ping_good - else (1, 1, 0) - if party.ping <= ping_med - else (1, 0, 0), - ) + else: + bui.textwidget( + edit=self._ping_widget, + text=str(int(party.ping)), + color=(0, 1, 0) + if party.ping <= ping_good + else (1, 1, 0) + if party.ping <= ping_med + else (1, 0, 0), + ) + + party.clean_display_index = index - party.clean_display_index = index def _get_popup_window_scale() -> float: uiscale = bui.app.ui_v1.uiscale @@ -501,7 +500,7 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu, url = _party.stats_addr.replace( '${ACCOUNT}', plus.get_v1_account_misc_read_val_2('resolvedAccountID', - 'UNKNOWN')) + 'UNKNOWN')) bui.open_url(url) elif choice == 'connect': PartyQuickConnect(_party.address, _party.port) @@ -614,17 +613,17 @@ def __init__(self, address: str, port: int): scale=(1.4 if uiscale is babase.UIScale.SMALL else 1.2 if uiscale is babase.UIScale.MEDIUM else 1.0))) self._cancel_button = bui.buttonwidget(parent=self._root_widget, - scale=1.0, - position=(60, self._height - 80), - size=(50, 50), - label='', - on_activate_call=self.close, - autoselect=True, - color=(0.45, 0.63, 0.15), - icon=bui.gettexture('crossOut'), - iconscale=1.2) + scale=1.0, + position=(60, self._height - 80), + size=(50, 50), + label='', + on_activate_call=self.close, + autoselect=True, + color=(0.45, 0.63, 0.15), + icon=bui.gettexture('crossOut'), + iconscale=1.2) bui.containerwidget(edit=self._root_widget, - cancel_button=self._cancel_button) + cancel_button=self._cancel_button) self.IP = bui.textwidget( parent=self._root_widget, diff --git a/plugins/utilities/pro_unlocker.py b/plugins/utilities/pro_unlocker.py index 389140f7..409cdfc7 100644 --- a/plugins/utilities/pro_unlocker.py +++ b/plugins/utilities/pro_unlocker.py @@ -4,9 +4,9 @@ import babase - original_get_purchased = _baplus.get_purchased + def get_purchased(item): if item.startswith('characters.') or item.startswith('icons.'): return original_get_purchased(item) @@ -18,4 +18,3 @@ class Unlock(babase.Plugin): def on_app_running(self): babase.app.classic.accounts.have_pro = lambda: True _baplus.get_purchased = get_purchased - \ No newline at end of file diff --git a/plugins/utilities/server_switch.py b/plugins/utilities/server_switch.py index ba4ffdcf..2dbc667f 100644 --- a/plugins/utilities/server_switch.py +++ b/plugins/utilities/server_switch.py @@ -18,13 +18,15 @@ current_server_ip = "127.0.0.1" current_server_port = 43210 servers = [] + + def _refresh_in_game(func): def wrapper(self, *args, **kwargs): returnValue = func(self, *args, **kwargs) uiscale = bui.app.ui_v1.uiscale bui.containerwidget( edit=self._root_widget, - size=(self._width*2, self._height), # double the width + size=(self._width*2, self._height), # double the width scale=( 2.15 if uiscale is bui.UIScale.SMALL @@ -36,40 +38,43 @@ def wrapper(self, *args, **kwargs): h = 125 v = self._height - 60.0 bui.textwidget( - parent=self._root_widget, - draw_controller=None, - text="IP: "+current_server_ip+" PORT: "+str(current_server_port), - position=(h-self._button_width/2 + 130 , v+60), - h_align='center', - v_align='center', - size=(20, 60), - scale=0.6) + parent=self._root_widget, + draw_controller=None, + text="IP: "+current_server_ip+" PORT: "+str(current_server_port), + position=(h-self._button_width/2 + 130, v+60), + h_align='center', + v_align='center', + size=(20, 60), + scale=0.6) self._public_servers = bui.buttonwidget( - color=(0.8, 0.45, 1), - parent=self._root_widget, - position=(h+self._button_width-10, v+60+20), - size=(self._button_width/4, self._button_height/2), - scale=1.0, - autoselect=self._use_autoselect, - label="~~~", - on_activate_call=bs.Call(public_servers)) + color=(0.8, 0.45, 1), + parent=self._root_widget, + position=(h+self._button_width-10, v+60+20), + size=(self._button_width/4, self._button_height/2), + scale=1.0, + autoselect=self._use_autoselect, + label="~~~", + on_activate_call=bs.Call(public_servers)) for server in servers: self._server_button = bui.buttonwidget( color=(0.8, 0, 1), parent=self._root_widget, - position=( (h- self._button_width / 2 ) + self._button_width + 20, v), + position=((h - self._button_width / 2) + self._button_width + 20, v), size=(self._button_width, self._button_height), scale=1.0, autoselect=self._use_autoselect, label=server["name"][0:22], on_activate_call=bs.Call(bs.connect_to_party, server["ip"], server["port"])) - + v -= 50 - - return returnValue + + return returnValue return wrapper + connect = bs.connect_to_party + + def connect_to_party(address, port=43210, print_progress=False): global current_server_ip global current_server_port @@ -79,7 +84,8 @@ def connect_to_party(address, port=43210, print_progress=False): current_server_port = port connect(address, port, print_progress) babase.apptimer(1, check_connect_status) - + + def check_connect_status(): global servers global current_server_ip @@ -88,7 +94,8 @@ def check_connect_status(): if (not bs.get_connection_to_host_info()['name']): babase.apptimer(1, check_connect_status) return - new_server = {"name": bs.get_connection_to_host_info()['name'], "ip": current_server_ip, "port": current_server_port} + new_server = {"name": bs.get_connection_to_host_info( + )['name'], "ip": current_server_ip, "port": current_server_port} if new_server not in servers: servers.append(new_server) servers = servers[-3:] @@ -96,13 +103,16 @@ def check_connect_status(): print("connection failed falling back to gather window") public_servers() -def public_servers(origin = None): + +def public_servers(origin=None): from bauiv1lib.gather import GatherWindow - bui.app.ui_v1.set_main_menu_window( GatherWindow(origin_widget=origin).get_root_widget()) + bui.app.ui_v1.set_main_menu_window(GatherWindow(origin_widget=origin).get_root_widget()) # ba_meta export plugin + + class bySmoothy(babase.Plugin): def __init__(self): - bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = _refresh_in_game(bastd_ui_mainmenu.MainMenuWindow._refresh_in_game) + bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = _refresh_in_game( + bastd_ui_mainmenu.MainMenuWindow._refresh_in_game) bs.connect_to_party = connect_to_party - \ No newline at end of file From d076534a526c4b98b270beed5b27fa6f932cace3 Mon Sep 17 00:00:00 2001 From: imayushsaini Date: Sat, 8 Jul 2023 09:56:31 +0000 Subject: [PATCH 13/17] [ci] apply-version-metadata --- plugins/utilities.json | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 701e5dff..e929fbe9 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -335,7 +335,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "b9b4944", + "released_on": "08-07-2023", + "md5sum": "8b05407fda379d853f5c75677b19fd85" + }, "1.2.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -417,7 +422,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "b9b4944", + "released_on": "08-07-2023", + "md5sum": "30a21cb1c739b098dcaa791e4a2cd481" + }, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -443,7 +453,12 @@ } ], "versions": { - "2.0.0": null, + "2.0.0": { + "api_version": 8, + "commit_sha": "b9b4944", + "released_on": "08-07-2023", + "md5sum": "bb5d85fb528020e809eaebb17a388e32" + }, "1.0.0": { "api_version": 7, "commit_sha": "ff4de19", @@ -507,7 +522,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "b9b4944", + "released_on": "08-07-2023", + "md5sum": "7403fcea1855ddf561aa412d703fcc6e" + }, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", From 4eb520fa19088c6ae13b851c8232c07305e41857 Mon Sep 17 00:00:00 2001 From: Ayush Saini <36878972+imayushsaini@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:44:27 +0530 Subject: [PATCH 14/17] Revert "updated server switch" oop This reverts commit c2832136aa647a54e9f44b91b66582fa58a25afa. --- README.md | 13 +- plugins/minigames.json | 6 + plugins/minigames/alliance_elimination.py | 118 ++-- plugins/utilities.json | 28 +- plugins/utilities/character_chooser.py | 35 +- plugins/utilities/easy_connect.py | 367 +++++++------ plugins/utilities/pro_unlocker.py | 24 +- plugins/utilities/server_switch.py | 639 +++++++++++++++++++--- 8 files changed, 874 insertions(+), 356 deletions(-) diff --git a/README.md b/README.md index fe057a9e..d625cccd 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,14 @@ There are two different ways the plugin manager can be installed: 1. [Download plugin_manager.py][DownloadLink] to your mods directory (check it out by going into your game's Settings -> Advanced -> Show Mods Folder). This is the recommended way (read next method to know why). - -2. Another way is to add + If you're on a newer version of Android (11 or above) and not rooted, it probably won't be possible to copy + mods to game's mods folder. In this case, you can connect your Android phone to a computer and push `plugin_manager.py` + [using `adb`](https://www.xda-developers.com/install-adb-windows-macos-linux/): + ```bash + $ adb push plugin_manager.py /sdcard/Android/data/net.froemling.bombsquad/files/mods/plugin_manager.py + ``` + +3. Another way is to add [plugin_manager.py](https://raw.githubusercontent.com/bombsquad-community/plugin-manager/main/plugin_manager.py) to your workspace. However, plugin manager self-updates will fail when installed using this way since the game will overrwrite the updated plugin manager, with the older version from workspace on the next sync. However, you can @@ -193,7 +199,8 @@ That's it! Now you can make a [pull request](../../compare) with both the update will also help us to notify the maintainers of any future breaking changes in plugin manager that could affect 3rd party plugin sources. - [rikkolovescats/sahilp-plugins](https://github.com/rikkolovescats/sahilp-plugins) + - [rikkolovescats/sahilp-plugins](https://github.com/rikkolovescats/sahilp-plugins) + - [Aeliux/arcane](https://github.com/Aeliux/arcane) ## Tests diff --git a/plugins/minigames.json b/plugins/minigames.json index a95fc4f5..ae4f5406 100644 --- a/plugins/minigames.json +++ b/plugins/minigames.json @@ -166,6 +166,12 @@ } ], "versions": { + "2.0.0": { + "api_version": 8, + "commit_sha": "1b14789", + "released_on": "02-07-2023", + "md5sum": "cb2a7700dd13febe6f68c3cd979b8b19" + }, "1.1.0": { "api_version": 7, "commit_sha": "40b70fe", diff --git a/plugins/minigames/alliance_elimination.py b/plugins/minigames/alliance_elimination.py index e6f37761..f6d47b5f 100644 --- a/plugins/minigames/alliance_elimination.py +++ b/plugins/minigames/alliance_elimination.py @@ -2,23 +2,25 @@ # """Elimination mini-game.""" -# ba_meta require api 7 +# ba_meta require api 8 # (see https://ballistica.net/wiki/meta-tag-system) from __future__ import annotations from typing import TYPE_CHECKING -import ba -from bastd.actor.spazfactory import SpazFactory -from bastd.actor.scoreboard import Scoreboard +import babase +import bauiv1 as bui +import bascenev1 as bs +from bascenev1lib.actor.spazfactory import SpazFactory +from bascenev1lib.actor.scoreboard import Scoreboard if TYPE_CHECKING: from typing import (Any, Tuple, Type, List, Sequence, Optional, Union) -class Icon(ba.Actor): +class Icon(bs.Actor): """Creates in in-game icon on screen.""" def __init__(self, @@ -37,10 +39,10 @@ def __init__(self, self._show_lives = show_lives self._show_death = show_death self._name_scale = name_scale - self._outline_tex = ba.gettexture('characterIconMask') + self._outline_tex = bs.gettexture('characterIconMask') icon = player.get_icon() - self.node = ba.newnode('image', + self.node = bs.newnode('image', delegate=self, attrs={ 'texture': icon['texture'], @@ -53,12 +55,12 @@ def __init__(self, 'absolute_scale': True, 'attach': 'bottomCenter' }) - self._name_text = ba.newnode( + self._name_text = bs.newnode( 'text', owner=self.node, attrs={ - 'text': ba.Lstr(value=player.getname()), - 'color': ba.safecolor(player.team.color), + 'text': babase.Lstr(value=player.getname()), + 'color': babase.safecolor(player.team.color), 'h_align': 'center', 'v_align': 'center', 'vr_depth': 410, @@ -69,7 +71,7 @@ def __init__(self, 'v_attach': 'bottom' }) if self._show_lives: - self._lives_text = ba.newnode('text', + self._lives_text = bs.newnode('text', owner=self.node, attrs={ 'text': 'x0', @@ -125,7 +127,7 @@ def handle_player_died(self) -> None: if not self.node: return if self._show_death: - ba.animate( + bs.animate( self.node, 'opacity', { 0.00: 1.0, 0.05: 0.0, @@ -142,16 +144,16 @@ def handle_player_died(self) -> None: }) lives = self._player.lives if lives == 0: - ba.timer(0.6, self.update_for_lives) + bs.timer(0.6, self.update_for_lives) def handlemessage(self, msg: Any) -> Any: - if isinstance(msg, ba.DieMessage): + if isinstance(msg, bs.DieMessage): self.node.delete() return None return super().handlemessage(msg) -class Player(ba.Player['Team']): +class Player(bs.Player['Team']): """Our player type for this game.""" def __init__(self) -> None: @@ -159,7 +161,7 @@ def __init__(self) -> None: self.icons: List[Icon] = [] -class Team(ba.Team[Player]): +class Team(bs.Team[Player]): """Our team type for this game.""" def __init__(self) -> None: @@ -167,14 +169,14 @@ def __init__(self) -> None: self.spawn_order: List[Player] = [] -# ba_meta export game -class AllianceEliminationGame(ba.TeamGameActivity[Player, Team]): +# ba_meta export bascenev1.GameActivity +class AllianceEliminationGame(bs.TeamGameActivity[Player, Team]): """Game type where last player(s) left alive win.""" name = 'Alliance Elimination' description = 'Fight in groups of duo, trio, or more.\nLast remaining alive wins.' - scoreconfig = ba.ScoreConfig(label='Survived', - scoretype=ba.ScoreType.SECONDS, + scoreconfig = bs.ScoreConfig(label='Survived', + scoretype=bs.ScoreType.SECONDS, none_is_winner=True) # Show messages when players die since it's meaningful here. announce_player_deaths = True @@ -183,23 +185,23 @@ class AllianceEliminationGame(ba.TeamGameActivity[Player, Team]): @classmethod def get_available_settings( - cls, sessiontype: Type[ba.Session]) -> List[ba.Setting]: + cls, sessiontype: Type[bs.Session]) -> List[babase.Setting]: settings = [ - ba.IntSetting( + bs.IntSetting( 'Lives Per Player', default=1, min_value=1, max_value=10, increment=1, ), - ba.IntSetting( + bs.IntSetting( 'Players Per Team In Arena', default=2, min_value=2, max_value=10, increment=1, ), - ba.IntChoiceSetting( + bs.IntChoiceSetting( 'Time Limit', choices=[ ('None', 0), @@ -211,7 +213,7 @@ def get_available_settings( ], default=0, ), - ba.FloatChoiceSetting( + bs.FloatChoiceSetting( 'Respawn Times', choices=[ ('Shorter', 0.25), @@ -222,27 +224,27 @@ def get_available_settings( ], default=1.0, ), - ba.BoolSetting('Epic Mode', default=False), + bs.BoolSetting('Epic Mode', default=False), ] - if issubclass(sessiontype, ba.DualTeamSession): + if issubclass(sessiontype, bs.DualTeamSession): settings.append( - ba.BoolSetting('Balance Total Lives', default=False)) + bs.BoolSetting('Balance Total Lives', default=False)) return settings @classmethod - def supports_session_type(cls, sessiontype: Type[ba.Session]) -> bool: - return issubclass(sessiontype, ba.DualTeamSession) + def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool: + return issubclass(sessiontype, bs.DualTeamSession) @classmethod - def get_supported_maps(cls, sessiontype: Type[ba.Session]) -> List[str]: - return ba.getmaps('melee') + def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]: + return bs.app.classic.getmaps('melee') def __init__(self, settings: dict): super().__init__(settings) self._scoreboard = Scoreboard() self._start_time: Optional[float] = None - self._vs_text: Optional[ba.Actor] = None - self._round_end_timer: Optional[ba.Timer] = None + self._vs_text: Optional[bs.Actor] = None + self._round_end_timer: Optional[bs.Timer] = None self._epic_mode = bool(settings['Epic Mode']) self._lives_per_player = int(settings['Lives Per Player']) self._time_limit = float(settings['Time Limit']) @@ -253,16 +255,16 @@ def __init__(self, settings: dict): # Base class overrides: self.slow_motion = self._epic_mode - self.default_music = (ba.MusicType.EPIC - if self._epic_mode else ba.MusicType.SURVIVAL) + self.default_music = (bs.MusicType.EPIC + if self._epic_mode else bs.MusicType.SURVIVAL) def get_instance_description(self) -> Union[str, Sequence]: return 'Last team standing wins.' if isinstance( - self.session, ba.DualTeamSession) else 'Last one standing wins.' + self.session, bs.DualTeamSession) else 'Last one standing wins.' def get_instance_description_short(self) -> Union[str, Sequence]: return 'last team standing wins' if isinstance( - self.session, ba.DualTeamSession) else 'last one standing wins' + self.session, bs.DualTeamSession) else 'last one standing wins' def on_player_join(self, player: Player) -> None: @@ -275,9 +277,9 @@ def on_player_join(self, player: Player) -> None: if (self._get_total_team_lives(player.team) == 0 and player.team.survival_seconds is None): player.team.survival_seconds = 0 - ba.screenmessage( - ba.Lstr(resource='playerDelayedJoinText', - subs=[('${PLAYER}', player.getname(full=True))]), + bs.broadcastmessage( + babase.Lstr(resource='playerDelayedJoinText', + subs=[('${PLAYER}', player.getname(full=True))]), color=(0, 1, 0), ) return @@ -293,11 +295,11 @@ def on_player_join(self, player: Player) -> None: def on_begin(self) -> None: super().on_begin() - self._start_time = ba.time() + self._start_time = bs.time() self.setup_standard_time_limit(self._time_limit) self.setup_standard_powerup_drops() - self._vs_text = ba.NodeActor( - ba.newnode('text', + self._vs_text = bs.NodeActor( + bs.newnode('text', attrs={ 'position': (0, 92), 'h_attach': 'center', @@ -308,12 +310,12 @@ def on_begin(self) -> None: 'scale': 0.6, 'v_attach': 'bottom', 'color': (0.8, 0.8, 0.3, 1.0), - 'text': ba.Lstr(resource='vsText') + 'text': babase.Lstr(resource='vsText') })) # If balance-team-lives is on, add lives to the smaller team until # total lives match. - if (isinstance(self.session, ba.DualTeamSession) + if (isinstance(self.session, bs.DualTeamSession) and self._balance_total_lives and self.teams[0].players and self.teams[1].players): if self._get_total_team_lives( @@ -333,7 +335,7 @@ def on_begin(self) -> None: # We could check game-over conditions at explicit trigger points, # but lets just do the simple thing and poll it. - ba.timer(1.0, self._update, repeat=True) + bs.timer(1.0, self._update, repeat=True) def _update_alliance_mode(self) -> None: # For both teams, find the first player on the spawn order list with @@ -391,10 +393,10 @@ def _update_icons(self) -> None: nplayers -= 1 test_lives += 1 - def _get_spawn_point(self, player: Player) -> Optional[ba.Vec3]: + def _get_spawn_point(self, player: Player) -> Optional[babase.Vec3]: return None - def spawn_player(self, player: Player) -> ba.Actor: + def spawn_player(self, player: Player) -> bs.Actor: actor = self.spawn_player_spaz(player, self._get_spawn_point(player)) # If we have any icons, update their state. @@ -403,7 +405,7 @@ def spawn_player(self, player: Player) -> ba.Actor: return actor def _print_lives(self, player: Player) -> None: - from bastd.actor import popuptext + from bascenev1lib.actor import popuptext # We get called in a timer so it's possible our player has left/etc. if not player or not player.is_alive() or not player.node: @@ -426,20 +428,20 @@ def on_player_leave(self, player: Player) -> None: # Update icons in a moment since our team will be gone from the # list then. - ba.timer(0, self._update_icons) + bs.timer(0, self._update_icons) # If the player to leave was the last in spawn order and had # their final turn currently in-progress, mark the survival time # for their team. if self._get_total_team_lives(player.team) == 0: assert self._start_time is not None - player.team.survival_seconds = int(ba.time() - self._start_time) + player.team.survival_seconds = int(bs.time() - self._start_time) def _get_total_team_lives(self, team: Team) -> int: return sum(player.lives for player in team.players) def handlemessage(self, msg: Any) -> Any: - if isinstance(msg, ba.PlayerDiedMessage): + if isinstance(msg, bs.PlayerDiedMessage): # Augment standard behavior. super().handlemessage(msg) @@ -447,7 +449,7 @@ def handlemessage(self, msg: Any) -> Any: player.lives -= 1 if player.lives < 0: - ba.print_error( + babase.print_error( "Got lives < 0 in Alliance Elimination; this shouldn't happen.") player.lives = 0 @@ -458,14 +460,14 @@ def handlemessage(self, msg: Any) -> Any: # Play big death sound on our last death # or for every one. if player.lives == 0: - ba.playsound(SpazFactory.get().single_player_death_sound) + SpazFactory.get().single_player_death_sound.play() # If we hit zero lives, we're dead (and our team might be too). if player.lives == 0: # If the whole team is now dead, mark their survival time. if self._get_total_team_lives(player.team) == 0: assert self._start_time is not None - player.team.survival_seconds = int(ba.time() - + player.team.survival_seconds = int(bs.time() - self._start_time) # Put ourself at the back of the spawn order. @@ -493,7 +495,7 @@ def _update(self) -> None: # the game (allows the dust to settle and draws to occur if deaths # are close enough). if len(self._get_living_teams()) < 2: - self._round_end_timer = ba.Timer(0.5, self.end_game) + self._round_end_timer = bs.Timer(0.5, self.end_game) def _get_living_teams(self) -> List[Team]: return [ @@ -505,7 +507,7 @@ def _get_living_teams(self) -> List[Team]: def end_game(self) -> None: if self.has_ended(): return - results = ba.GameResults() + results = bs.GameResults() self._vs_text = None # Kill our 'vs' if its there. for team in self.teams: results.set_team_score(team, team.survival_seconds) diff --git a/plugins/utilities.json b/plugins/utilities.json index 701e5dff..cee50f85 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -335,7 +335,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "0c5ce76", + "released_on": "02-07-2023", + "md5sum": "8b05407fda379d853f5c75677b19fd85" + }, "1.2.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -417,7 +422,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "bf3e61b", + "released_on": "04-07-2023", + "md5sum": "289cc852b7f0ec1b254d08267c9921c2" + }, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -443,7 +453,12 @@ } ], "versions": { - "2.0.0": null, + "2.0.0": { + "api_version": 8, + "commit_sha": "0c5ce76", + "released_on": "02-07-2023", + "md5sum": "bb5d85fb528020e809eaebb17a388e32" + }, "1.0.0": { "api_version": 7, "commit_sha": "ff4de19", @@ -507,7 +522,12 @@ } ], "versions": { - "2.0.0":null, + "2.0.0": { + "api_version": 8, + "commit_sha": "a0239a9", + "released_on": "04-07-2023", + "md5sum": "187a9894158721c8fa1ecee9e3e38e73" + }, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", diff --git a/plugins/utilities/character_chooser.py b/plugins/utilities/character_chooser.py index 9dbe7333..da12dbb3 100644 --- a/plugins/utilities/character_chooser.py +++ b/plugins/utilities/character_chooser.py @@ -55,7 +55,6 @@ from bascenev1lib.actor.spazappearance import * - def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, lobby: 'Lobby') -> None: self._deek_sound = bs.getsound('deek') @@ -113,25 +112,25 @@ def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, self._profilename = self._profilenames[self._profileindex] self._text_node = bs.newnode('text', - delegate=self, - attrs={ - 'position': (-100, self._vpos), - 'maxwidth': 190, - 'shadow': 0.5, - 'vr_depth': -20, - 'h_align': 'left', - 'v_align': 'center', - 'v_attach': 'top' - }) + delegate=self, + attrs={ + 'position': (-100, self._vpos), + 'maxwidth': 190, + 'shadow': 0.5, + 'vr_depth': -20, + 'h_align': 'left', + 'v_align': 'center', + 'v_attach': 'top' + }) bs.animate(self._text_node, 'scale', {0: 0, 0.1: 1.0}) self.icon = bs.newnode('image', - owner=self._text_node, - attrs={ - 'position': (-130, self._vpos + 20), - 'mask_texture': self._mask_texture, - 'vr_depth': -10, - 'attach': 'topCenter' - }) + owner=self._text_node, + attrs={ + 'position': (-130, self._vpos + 20), + 'mask_texture': self._mask_texture, + 'vr_depth': -10, + 'attach': 'topCenter' + }) bs.animate_array(self.icon, 'scale', 2, {0: (0, 0), 0.1: (45, 45)}) diff --git a/plugins/utilities/easy_connect.py b/plugins/utilities/easy_connect.py index abd2f43c..c9255154 100644 --- a/plugins/utilities/easy_connect.py +++ b/plugins/utilities/easy_connect.py @@ -15,13 +15,13 @@ # .................___________________________________________ # Have any idea/suggestion/bug report > send message on discord mr.smoothy#5824 -# Download modshttps://bombsquad-community.web.app/mods +# Download modshttps://bombsquad-community.web.app/mods # Discord:- # mr.smoothy#5824 # DONT EDIT ANYTHING WITHOUT PERMISSION -# join Bombsquad Community Server - +# join Bombsquad Community Server - # https://discord.gg/ucyaesh @@ -73,7 +73,6 @@ def is_game_version_lower_than(version): return game_version < version - def updateBannedServersCache(): response = None config = babase.app.config @@ -112,7 +111,7 @@ def run(self) -> None: except Exception: result = None babase.pushcall(lambda: self._call(result, self._port), - from_other_thread=True) + from_other_thread=True) def newbuild_favorites_tab(self, region_height: float) -> None: @@ -148,45 +147,45 @@ def newbuild_favorites_tab(self, region_height: float) -> None: # ================= smoothy ============= bui.textwidget(parent=self._container, - position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv + - 120 if uiscale is babase.UIScale.SMALL else btnv+90), - size=(0, 0), - h_align='center', - color=(0.8, 0.8, 0.8), - v_align='top', - text="Auto") + position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv + + 120 if uiscale is babase.UIScale.SMALL else btnv+90), + size=(0, 0), + h_align='center', + color=(0.8, 0.8, 0.8), + v_align='top', + text="Auto") btnv += 50 if uiscale is babase.UIScale.SMALL else 0 bui.buttonwidget(parent=self._container, - size=(30, 30), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv+10), - - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self.auto_retry_dec, - text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, - label="-", - autoselect=True) + size=(30, 30), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv+10), + + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self.auto_retry_dec, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, + label="-", + autoselect=True) self.retry_inter_text = bui.textwidget(parent=self._container, - position=( - 90 if uiscale is babase.UIScale.SMALL else 120, btnv+25), - size=(0, 0), - h_align='center', - color=(0.8, 0.8, 0.8), - v_align='center', - text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') + position=( + 90 if uiscale is babase.UIScale.SMALL else 120, btnv+25), + size=(0, 0), + h_align='center', + color=(0.8, 0.8, 0.8), + v_align='center', + text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') bui.buttonwidget(parent=self._container, - size=(30, 30), - position=(125 if uiscale is babase.UIScale.SMALL else 155, - btnv+10), + size=(30, 30), + position=(125 if uiscale is babase.UIScale.SMALL else 155, + btnv+10), - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self.auto_retry_inc, - text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, - label="+", - autoselect=True) + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self.auto_retry_inc, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, + label="+", + autoselect=True) btnv -= b_height + b_space_extra @@ -203,31 +202,31 @@ def newbuild_favorites_tab(self, region_height: float) -> None: autoselect=True) if uiscale is babase.UIScale.SMALL and bui.app.ui_v1.use_toolbars: bui.widget(edit=btn1, - left_widget=bui.get_special_widget('back_button')) + left_widget=bui.get_special_widget('back_button')) btnv -= b_height + b_space_extra bui.buttonwidget(parent=self._container, - size=(b_width, b_height), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv), - button_type='square', - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self._on_favorites_edit_press, - text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, - label=babase.Lstr(resource='editText'), - autoselect=True) + size=(b_width, b_height), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv), + button_type='square', + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self._on_favorites_edit_press, + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='editText'), + autoselect=True) btnv -= b_height + b_space_extra bui.buttonwidget(parent=self._container, - size=(b_width, b_height), - position=(25 if uiscale is babase.UIScale.SMALL else 40, - btnv), - button_type='square', - color=(0.6, 0.53, 0.63), - textcolor=(0.75, 0.7, 0.8), - on_activate_call=self._on_favorite_delete_press, - text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, - label=babase.Lstr(resource='deleteText'), - autoselect=True) + size=(b_width, b_height), + position=(25 if uiscale is babase.UIScale.SMALL else 40, + btnv), + button_type='square', + color=(0.6, 0.53, 0.63), + textcolor=(0.75, 0.7, 0.8), + on_activate_call=self._on_favorite_delete_press, + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='deleteText'), + autoselect=True) v -= sub_scroll_height + 23 self._scrollwidget = scrlw = bui.scrollwidget( @@ -236,12 +235,12 @@ def newbuild_favorites_tab(self, region_height: float) -> None: size=(sub_scroll_width, sub_scroll_height), claims_left_right=True) bui.widget(edit=self._favorites_connect_button, - right_widget=self._scrollwidget) + right_widget=self._scrollwidget) self._columnwidget = bui.columnwidget(parent=scrlw, - left_border=10, - border=2, - margin=0, - claims_left_right=True) + left_border=10, + border=2, + margin=0, + claims_left_right=True) self._favorite_selected = None self._refresh_favorites() @@ -323,9 +322,8 @@ def _clear(self) -> None: self._stats_button ]: if widget: - + widget.delete() - def update(self, index: int, party: PartyEntry, sub_scroll_width: float, @@ -333,127 +331,128 @@ def update(self, index: int, party: PartyEntry, sub_scroll_width: float, columnwidget: bui.Widget, join_text: bui.Widget, filter_text: bui.Widget, existing_selection: Optional[Selection], tab: PublicGatherTab) -> None: - """Update for the given data.""" - # pylint: disable=too-many-locals - - # Quick-out: if we've been marked clean for a certain index and - # we're still at that index, we're done. - plus = bui.app.plus - assert plus is not None - - # Quick-out: if we've been marked clean for a certain index and - # we're still at that index, we're done. - if party.clean_display_index == index: - return - - ping_good = plus.get_v1_account_misc_read_val('pingGood', 100) - ping_med = plus.get_v1_account_misc_read_val('pingMed', 500) - - self._clear() - hpos = 20 - vpos = sub_scroll_height - lineheight * index - 50 - self._name_widget = bui.textwidget( - text=bui.Lstr(value=party.name), + """Update for the given data.""" + # pylint: disable=too-many-locals + + # Quick-out: if we've been marked clean for a certain index and + # we're still at that index, we're done. + plus = bui.app.plus + assert plus is not None + + # Quick-out: if we've been marked clean for a certain index and + # we're still at that index, we're done. + if party.clean_display_index == index: + return + + ping_good = plus.get_v1_account_misc_read_val('pingGood', 100) + ping_med = plus.get_v1_account_misc_read_val('pingMed', 500) + + self._clear() + hpos = 20 + vpos = sub_scroll_height - lineheight * index - 50 + self._name_widget = bui.textwidget( + text=bui.Lstr(value=party.name), + parent=columnwidget, + size=(sub_scroll_width * 0.63, 20), + position=(0 + hpos, 4 + vpos), + selectable=True, + on_select_call=bui.WeakCall( + tab.set_public_party_selection, + Selection(party.get_key(), SelectionComponent.NAME), + ), + on_activate_call=bui.WeakCall(tab.on_public_party_activate, party), + click_activate=True, + maxwidth=sub_scroll_width * 0.45, + corner_scale=1.4, + autoselect=True, + color=(1, 1, 1, 0.3 if party.ping is None else 1.0), + h_align='left', + v_align='center', + ) + bui.widget( + edit=self._name_widget, + left_widget=join_text, + show_buffer_top=64.0, + show_buffer_bottom=64.0, + ) + if existing_selection == Selection( + party.get_key(), SelectionComponent.NAME + ): + bui.containerwidget( + edit=columnwidget, selected_child=self._name_widget + ) + if party.stats_addr or True: + url = party.stats_addr.replace( + '${ACCOUNT}', + plus.get_v1_account_misc_read_val_2( + 'resolvedAccountID', 'UNKNOWN' + ), + ) + self._stats_button = bui.buttonwidget( + color=(0.3, 0.6, 0.94), + textcolor=(1.0, 1.0, 1.0), + label='....', parent=columnwidget, - size=(sub_scroll_width * 0.63, 20), - position=(0 + hpos, 4 + vpos), - selectable=True, + autoselect=True, + on_activate_call=bui.Call(bui.open_url, url), on_select_call=bui.WeakCall( tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.NAME), + Selection(party.get_key(), SelectionComponent.STATS_BUTTON), ), - on_activate_call=bui.WeakCall(tab.on_public_party_activate, party), - click_activate=True, - maxwidth=sub_scroll_width * 0.45, - corner_scale=1.4, - autoselect=True, - color=(1, 1, 1, 0.3 if party.ping is None else 1.0), - h_align='left', - v_align='center', - ) - bui.widget( - edit=self._name_widget, - left_widget=join_text, - show_buffer_top=64.0, - show_buffer_bottom=64.0, + size=(120, 40), + position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), + scale=0.9, ) + bui.buttonwidget(edit=self._stats_button, on_activate_call=bui.WeakCall( + self.on_stats_click, self._stats_button, party)) if existing_selection == Selection( - party.get_key(), SelectionComponent.NAME + party.get_key(), SelectionComponent.STATS_BUTTON ): bui.containerwidget( - edit=columnwidget, selected_child=self._name_widget + edit=columnwidget, selected_child=self._stats_button ) - if party.stats_addr or True: - url = party.stats_addr.replace( - '${ACCOUNT}', - plus.get_v1_account_misc_read_val_2( - 'resolvedAccountID', 'UNKNOWN' - ), - ) - self._stats_button = bui.buttonwidget( - color=(0.3, 0.6, 0.94), - textcolor=(1.0, 1.0, 1.0), - label='....', - parent=columnwidget, - autoselect=True, - on_activate_call=bui.Call(bui.open_url, url), - on_select_call=bui.WeakCall( - tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.STATS_BUTTON), - ), - size=(120, 40), - position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), - scale=0.9, - ) - bui.buttonwidget(edit=self._stats_button, on_activate_call=bui.WeakCall( - self.on_stats_click, self._stats_button, party)) - if existing_selection == Selection( - party.get_key(), SelectionComponent.STATS_BUTTON - ): - bui.containerwidget( - edit=columnwidget, selected_child=self._stats_button - ) - - self._size_widget = bui.textwidget( - text=str(party.size) + '/' + str(party.size_max), - parent=columnwidget, - size=(0, 0), - position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), - scale=0.7, - color=(0.8, 0.8, 0.8), - h_align='right', - v_align='center', - ) - if index == 0: - bui.widget(edit=self._name_widget, up_widget=filter_text) - if self._stats_button: - bui.widget(edit=self._stats_button, up_widget=filter_text) + self._size_widget = bui.textwidget( + text=str(party.size) + '/' + str(party.size_max), + parent=columnwidget, + size=(0, 0), + position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), + scale=0.7, + color=(0.8, 0.8, 0.8), + h_align='right', + v_align='center', + ) - self._ping_widget = bui.textwidget( - parent=columnwidget, - size=(0, 0), - position=(sub_scroll_width * 0.94 + hpos, 20 + vpos), - scale=0.7, - h_align='right', - v_align='center', + if index == 0: + bui.widget(edit=self._name_widget, up_widget=filter_text) + if self._stats_button: + bui.widget(edit=self._stats_button, up_widget=filter_text) + + self._ping_widget = bui.textwidget( + parent=columnwidget, + size=(0, 0), + position=(sub_scroll_width * 0.94 + hpos, 20 + vpos), + scale=0.7, + h_align='right', + v_align='center', + ) + if party.ping is None: + bui.textwidget( + edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5) ) - if party.ping is None: - bui.textwidget( - edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5) - ) - else: - bui.textwidget( - edit=self._ping_widget, - text=str(int(party.ping)), - color=(0, 1, 0) - if party.ping <= ping_good - else (1, 1, 0) - if party.ping <= ping_med - else (1, 0, 0), - ) + else: + bui.textwidget( + edit=self._ping_widget, + text=str(int(party.ping)), + color=(0, 1, 0) + if party.ping <= ping_good + else (1, 1, 0) + if party.ping <= ping_med + else (1, 0, 0), + ) + + party.clean_display_index = index - party.clean_display_index = index def _get_popup_window_scale() -> float: uiscale = bui.app.ui_v1.uiscale @@ -501,7 +500,7 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu, url = _party.stats_addr.replace( '${ACCOUNT}', plus.get_v1_account_misc_read_val_2('resolvedAccountID', - 'UNKNOWN')) + 'UNKNOWN')) bui.open_url(url) elif choice == 'connect': PartyQuickConnect(_party.address, _party.port) @@ -614,17 +613,17 @@ def __init__(self, address: str, port: int): scale=(1.4 if uiscale is babase.UIScale.SMALL else 1.2 if uiscale is babase.UIScale.MEDIUM else 1.0))) self._cancel_button = bui.buttonwidget(parent=self._root_widget, - scale=1.0, - position=(60, self._height - 80), - size=(50, 50), - label='', - on_activate_call=self.close, - autoselect=True, - color=(0.45, 0.63, 0.15), - icon=bui.gettexture('crossOut'), - iconscale=1.2) + scale=1.0, + position=(60, self._height - 80), + size=(50, 50), + label='', + on_activate_call=self.close, + autoselect=True, + color=(0.45, 0.63, 0.15), + icon=bui.gettexture('crossOut'), + iconscale=1.2) bui.containerwidget(edit=self._root_widget, - cancel_button=self._cancel_button) + cancel_button=self._cancel_button) self.IP = bui.textwidget( parent=self._root_widget, diff --git a/plugins/utilities/pro_unlocker.py b/plugins/utilities/pro_unlocker.py index 389140f7..bac31447 100644 --- a/plugins/utilities/pro_unlocker.py +++ b/plugins/utilities/pro_unlocker.py @@ -4,8 +4,23 @@ import babase +def is_game_version_lower_than(version): + """ + Returns a boolean value indicating whether the current game + version is lower than the passed version. Useful for addressing + any breaking changes within game versions. + """ + game_version = tuple(map(int, babase.app.version.split("."))) + version = tuple(map(int, version.split("."))) + return game_version < version + + +if is_game_version_lower_than("1.7.20"): + original_get_purchased = _baplus.get_purchased +else: + assert bs.app.plus is not None + original_get_purchased = bs.app.plus.get_purchased -original_get_purchased = _baplus.get_purchased def get_purchased(item): if item.startswith('characters.') or item.startswith('icons.'): @@ -17,5 +32,8 @@ def get_purchased(item): class Unlock(babase.Plugin): def on_app_running(self): babase.app.classic.accounts.have_pro = lambda: True - _baplus.get_purchased = get_purchased - \ No newline at end of file + if is_game_version_lower_than("1.7.20"): + _baplus.get_purchased = get_purchased + else: + assert bs.app.plus is not None + bs.app.plus.get_purchased = get_purchased diff --git a/plugins/utilities/server_switch.py b/plugins/utilities/server_switch.py index ba4ffdcf..aacb0fe7 100644 --- a/plugins/utilities/server_switch.py +++ b/plugins/utilities/server_switch.py @@ -1,108 +1,575 @@ -# -*- coding: utf-8 -*- +# discord @mr.smoothy#5824 + # ba_meta require api 8 -''' -Server Switch Plugin by My.Smoothy -Let you switch recently joined servers very quickly -+ Added button to quicky look into public server list without leaving current game. - -discord: mr.smoothy -https://discord.gg/ucyaesh -Youtube : Hey Smoothy -Download more mods from -https://bombsquad-community.web.app/mods -''' + +from __future__ import annotations +import copy +import time +from typing import TYPE_CHECKING + import babase -import bauiv1lib.mainmenu as bastd_ui_mainmenu import bauiv1 as bui import bascenev1 as bs -current_server_ip = "127.0.0.1" -current_server_port = 43210 -servers = [] -def _refresh_in_game(func): - def wrapper(self, *args, **kwargs): - returnValue = func(self, *args, **kwargs) - uiscale = bui.app.ui_v1.uiscale - bui.containerwidget( - edit=self._root_widget, - size=(self._width*2, self._height), # double the width - scale=( - 2.15 - if uiscale is bui.UIScale.SMALL - else 1.6 - if uiscale is bui.UIScale.MEDIUM - else 1.0 - ), - ) - h = 125 - v = self._height - 60.0 - bui.textwidget( +import _bascenev1 as _bs +import time +import threading +from enum import Enum +from dataclasses import dataclass +if TYPE_CHECKING: + from typing import Any, Optional, Dict, List, Tuple, Type + import bascenev1 as bs + from bauiv1lib.gather import GatherWindow + +from bauiv1lib.confirm import ConfirmWindow + +import bauiv1lib.mainmenu as bastd_ui_mainmenu + +connect = bs.connect_to_party +disconnect = bs.disconnect_from_host + +server = [] + +ip_add = "private" +p_port = 44444 +p_name = "nothing here" + + +def newconnect_to_party(address, port=43210, print_progress=False): + global ip_add + global p_port + dd = _bs.get_connection_to_host_info() + if (dd != {}): + _bs.disconnect_from_host() + + ip_add = address + p_port = port + connect(address, port, print_progress) + else: + + ip_add = address + p_port = port + # print(ip_add,p_port) + connect(ip_add, port, print_progress) + + +def newdisconnect_from_host(): + try: + name = _bs.get_connection_to_host_info()['name'] + global server + global ip_add + global p_port + pojo = {"name": name, "ip": ip_add, "port": p_port} + if pojo not in server: + server.insert(0, pojo) + server = server[:3] + except: + pass + disconnect() + + +def printip(): + bs.screenmessage("ip address is"+ip_add) + + +def new_refresh_in_game( + self, positions: List[Tuple[float, float, + float]]) -> Tuple[float, float, float]: + # pylint: disable=too-many-branches + # pylint: disable=too-many-locals + # pylint: disable=too-many-statements + custom_menu_entries: List[Dict[str, Any]] = [] + session = _bs.get_foreground_host_session() + if session is not None: + try: + custom_menu_entries = session.get_custom_menu_entries() + for cme in custom_menu_entries: + if (not isinstance(cme, dict) or 'label' not in cme + or not isinstance(cme['label'], (str, bs.Lstr)) + or 'call' not in cme or not callable(cme['call'])): + raise ValueError('invalid custom menu entry: ' + + str(cme)) + except Exception: + custom_menu_entries = [] + babase.print_exception( + f'Error getting custom menu entries for {session}') + self._width = 250.0 + self._height = 250.0 if self._input_player else 180.0 + if (self._is_demo or self._is_arcade) and self._input_player: + self._height -= 40 + if not self._have_settings_button: + self._height -= 50 + if self._connected_to_remote_player: + # In this case we have a leave *and* a disconnect button. + self._height += 50 + self._height += 50 * (len(custom_menu_entries)) + uiscale = bui.app.ui_v1.uiscale + bui.containerwidget( + edit=self._root_widget, + size=(self._width*2, self._height), + scale=(2.15 if uiscale is bui.UIScale.SMALL else + 1.6 if uiscale is bui.UIScale.MEDIUM else 1.0)) + h = 125.0 + v = (self._height - 80.0 if self._input_player else self._height - 60) + h_offset = 0 + d_h_offset = 0 + v_offset = -50 + for _i in range(6 + len(custom_menu_entries)): + positions.append((h, v, 1.0)) + v += v_offset + h += h_offset + h_offset += d_h_offset + self._start_button = None + bui.app.pause() + h, v, scale = positions[self._p_index] + bui.textwidget( parent=self._root_widget, draw_controller=None, - text="IP: "+current_server_ip+" PORT: "+str(current_server_port), - position=(h-self._button_width/2 + 130 , v+60), + text="IP: "+ip_add+" PORT: "+str(p_port), + position=(h+self._button_width-80, v+60), h_align='center', v_align='center', size=(20, 60), scale=0.6) - self._public_servers = bui.buttonwidget( - color=(0.8, 0.45, 1), + v_h = v + + global server + + def con(address, port): + global ip_add + global p_port + if (address == ip_add and port == p_port): + self._resume() + else: + _bs.disconnect_from_host() + _bs.connect_to_party(address, port) + if len(server) == 0: + bui.textwidget( + parent=self._root_widget, + draw_controller=None, + text="Nothing in \n recents", + position=(h + self._button_width * scale, v-30), + h_align='center', + v_align='center', + size=(20, 60), + scale=1) + for ser in server: + self._server_button = bui.buttonwidget( + color=(0.8, 0, 1), + parent=self._root_widget, + position=(h + self._button_width * scale - 80, v_h), + size=(self._button_width, self._button_height), + scale=scale, + autoselect=self._use_autoselect, + label=ser["name"][0:22], + + on_activate_call=bs.Call(con, ser["ip"], ser["port"])) + v_h = v_h-50 + + # Player name if applicable. + if self._input_player: + player_name = self._input_player.getname() + h, v, scale = positions[self._p_index] + v += 35 + bui.textwidget(parent=self._root_widget, + position=(h - self._button_width / 2, v), + size=(self._button_width, self._button_height), + color=(1, 1, 1, 0.5), + scale=0.7, + h_align='center', + text=bs.Lstr(value=player_name)) + else: + player_name = '' + h, v, scale = positions[self._p_index] + self._p_index += 1 + btn = bui.buttonwidget(parent=self._root_widget, + position=(h - self._button_width / 2, v), + size=(self._button_width, self._button_height), + scale=scale, + label=bs.Lstr(resource=self._r + '.resumeText'), + autoselect=self._use_autoselect, + on_activate_call=self._resume) + bui.containerwidget(edit=self._root_widget, cancel_button=btn) + + # Add any custom options defined by the current game. + for entry in custom_menu_entries: + h, v, scale = positions[self._p_index] + self._p_index += 1 + + # Ask the entry whether we should resume when we call + # it (defaults to true). + resume = bool(entry.get('resume_on_call', True)) + + if resume: + call = bs.Call(self._resume_and_call, entry['call']) + else: + call = bs.Call(entry['call'], bs.WeakCall(self._resume)) + + bui.buttonwidget(parent=self._root_widget, + position=(h - self._button_width / 2, v), + size=(self._button_width, self._button_height), + scale=scale, + on_activate_call=call, + label=entry['label'], + autoselect=self._use_autoselect) + # Add a 'leave' button if the menu-owner has a player. + if ((self._input_player or self._connected_to_remote_player) + and not (self._is_demo or self._is_arcade)): + h, v, scale = positions[self._p_index] + self._p_index += 1 + btn = bui.buttonwidget(parent=self._root_widget, + position=(h - self._button_width / 2, v), + size=(self._button_width, + self._button_height), + scale=scale, + on_activate_call=self._leave, + label='', + autoselect=self._use_autoselect) + + if (player_name != '' and player_name[0] != '<' + and player_name[-1] != '>'): + txt = bs.Lstr(resource=self._r + '.justPlayerText', + subs=[('${NAME}', player_name)]) + else: + txt = bs.Lstr(value=player_name) + bui.textwidget(parent=self._root_widget, + position=(h, v + self._button_height * + (0.64 if player_name != '' else 0.5)), + size=(0, 0), + text=bs.Lstr(resource=self._r + '.leaveGameText'), + scale=(0.83 if player_name != '' else 1.0), + color=(0.75, 1.0, 0.7), + h_align='center', + v_align='center', + draw_controller=btn, + maxwidth=self._button_width * 0.9) + bui.textwidget(parent=self._root_widget, + position=(h, v + self._button_height * 0.27), + size=(0, 0), + text=txt, + color=(0.75, 1.0, 0.7), + h_align='center', + v_align='center', + draw_controller=btn, + scale=0.45, + maxwidth=self._button_width * 0.9) + return h, v, scale + + +def new_refresh(self) -> None: + # pylint: disable=too-many-branches + # pylint: disable=too-many-locals + # pylint: disable=too-many-statements + global server + print(server) + from bauiv1lib.confirm import QuitWindow + from bauiv1lib.store.button import StoreButton + import bascenev1 as bs + import _bascenev1 as _bs + import bauiv1 as bui + import _baplus + # Clear everything that was there. + children = self._root_widget.get_children() + for child in children: + child.delete() + + self._tdelay = 0.0 + self._t_delay_inc = 0.0 + self._t_delay_play = 0.0 + self._button_width = 200.0 + self._button_height = 45.0 + + self._r = 'mainMenu' + + assert bs.app.classic is not None + app = bs.app.classic + self._have_quit_button = (bui.app.ui_v1.uiscale is bui.UIScale.LARGE + or (app.platform == 'windows' + and app.subplatform == 'oculus')) + + self._have_store_button = not self._in_game + + self._have_settings_button = ( + (not self._in_game or not bui.app.toolbar_test) + and not (self._is_demo or self._is_arcade or self._is_iircade)) + + self._input_device = input_device = _bs.get_ui_input_device() + self._input_player = input_device.player if input_device else None + self._connected_to_remote_player = ( + input_device.is_attached_to_player() + if input_device else False) + + positions: List[Tuple[float, float, float]] = [] + self._p_index = 0 + + if self._in_game: + h, v, scale = self._refresh_in_game(positions) + print("refreshing in GAME", ip_add) + # btn = bui.buttonwidget(parent=self._root_widget, + # position=(80,270), + # size=(100, 90), + # scale=1.2, + # label=ip_add, + # autoselect=None, + # on_activate_call=printip) + bui.textwidget( + parent=self._root_widget, + draw_controller=None, + text="IP: "+ip_add+" PORT: "+str(p_port), + position=(150, 270), + h_align='center', + v_align='center', + size=(20, 60), + scale=1) + self._server_button = bui.buttonwidget( + parent=self._root_widget, + position=(h * 3.2 + 20 - self._button_width * scale, v), + size=(self._button_width, self._button_height), + scale=scale, + autoselect=self._use_autoselect, + label=bs.Lstr(resource=self._r + '.settingsText'), + transition_delay=self._tdelay, + on_activate_call=self._settings) + self._server_button2 = bui.buttonwidget( + parent=self._root_widget, + position=(h * 3.2 + 20 - self._button_width * scale, v-50), + size=(self._button_width, self._button_height), + scale=scale, + autoselect=self._use_autoselect, + label=bs.Lstr(resource=self._r + '.settingsText'), + transition_delay=self._tdelay, + on_activate_call=self._settings) + self._server_button3 = bui.buttonwidget( + parent=self._root_widget, + position=(h * 3.2 + 20 - self._button_width * scale, v-100), + size=(self._button_width, self._button_height), + scale=scale, + autoselect=self._use_autoselect, + label=bs.Lstr(resource=self._r + '.settingsText'), + transition_delay=self._tdelay, + on_activate_call=self._settings) + + else: + h, v, scale = self._refresh_not_in_game(positions) + + if self._have_settings_button: + h, v, scale = positions[self._p_index] + self._p_index += 1 + self._settings_button = bui.buttonwidget( + parent=self._root_widget, + position=(h - self._button_width * 0.5 * scale, v), + size=(self._button_width, self._button_height), + scale=scale, + autoselect=self._use_autoselect, + label=bs.Lstr(resource=self._r + '.settingsText'), + transition_delay=self._tdelay, + on_activate_call=self._settings) + + # Scattered eggs on easter. + if _baplus.get_v1_account_misc_read_val('easter', + False) and not self._in_game: + icon_size = 34 + bui.imagewidget(parent=self._root_widget, + position=(h - icon_size * 0.5 - 15, + v + self._button_height * scale - + icon_size * 0.24 + 1.5), + transition_delay=self._tdelay, + size=(icon_size, icon_size), + texture=bui.gettexture('egg3'), + tilt_scale=0.0) + + self._tdelay += self._t_delay_inc + + if self._in_game: + h, v, scale = positions[self._p_index] + self._p_index += 1 + + # If we're in a replay, we have a 'Leave Replay' button. + if _bs.is_in_replay(): + bui.buttonwidget(parent=self._root_widget, + position=(h - self._button_width * 0.5 * scale, + v), + scale=scale, + size=(self._button_width, self._button_height), + autoselect=self._use_autoselect, + label=bs.Lstr(resource='replayEndText'), + on_activate_call=self._confirm_end_replay) + elif _bs.get_foreground_host_session() is not None: + bui.buttonwidget( parent=self._root_widget, - position=(h+self._button_width-10, v+60+20), - size=(self._button_width/4, self._button_height/2), - scale=1.0, + position=(h - self._button_width * 0.5 * scale, v), + scale=scale, + size=(self._button_width, self._button_height), autoselect=self._use_autoselect, - label="~~~", - on_activate_call=bs.Call(public_servers)) - for server in servers: - self._server_button = bui.buttonwidget( - color=(0.8, 0, 1), + label=bs.Lstr(resource=self._r + '.endGameText'), + on_activate_call=self._confirm_end_game) + # Assume we're in a client-session. + else: + bui.buttonwidget( parent=self._root_widget, - position=( (h- self._button_width / 2 ) + self._button_width + 20, v), + position=(h - self._button_width * 0.5 * scale, v), + scale=scale, size=(self._button_width, self._button_height), - scale=1.0, autoselect=self._use_autoselect, - label=server["name"][0:22], - on_activate_call=bs.Call(bs.connect_to_party, server["ip"], server["port"])) - - v -= 50 - - return returnValue - return wrapper + label=bs.Lstr(resource=self._r + '.leavePartyText'), + on_activate_call=self._confirm_leave_party) -connect = bs.connect_to_party -def connect_to_party(address, port=43210, print_progress=False): - global current_server_ip - global current_server_port - if (bs.get_connection_to_host_info() != {}): - bs.disconnect_from_host() - current_server_ip = address - current_server_port = port - connect(address, port, print_progress) - babase.apptimer(1, check_connect_status) - -def check_connect_status(): - global servers - global current_server_ip - global current_server_port - if (bs.get_connection_to_host_info() != {}): - if (not bs.get_connection_to_host_info()['name']): - babase.apptimer(1, check_connect_status) - return - new_server = {"name": bs.get_connection_to_host_info()['name'], "ip": current_server_ip, "port": current_server_port} - if new_server not in servers: - servers.append(new_server) - servers = servers[-3:] + self._store_button: Optional[bui.Widget] + if self._have_store_button: + this_b_width = self._button_width + h, v, scale = positions[self._p_index] + self._p_index += 1 + + sbtn = self._store_button_instance = StoreButton( + parent=self._root_widget, + position=(h - this_b_width * 0.5 * scale, v), + size=(this_b_width, self._button_height), + scale=scale, + on_activate_call=bs.WeakCall(self._on_store_pressed), + sale_scale=1.3, + transition_delay=self._tdelay) + self._store_button = store_button = sbtn.get_button() + uiscale = bui.app.ui_v1.uiscale + icon_size = (55 if uiscale is bui.UIScale.SMALL else + 55 if uiscale is bui.UIScale.MEDIUM else 70) + bui.imagewidget( + parent=self._root_widget, + position=(h - icon_size * 0.5, + v + self._button_height * scale - icon_size * 0.23), + transition_delay=self._tdelay, + size=(icon_size, icon_size), + texture=bui.gettexture(self._store_char_tex), + tilt_scale=0.0, + draw_controller=store_button) + + self._tdelay += self._t_delay_inc else: - print("connection failed falling back to gather window") - public_servers() + self._store_button = None + + self._quit_button: Optional[bui.Widget] + if not self._in_game and self._have_quit_button: + h, v, scale = positions[self._p_index] + self._p_index += 1 + self._quit_button = quit_button = bui.buttonwidget( + parent=self._root_widget, + autoselect=self._use_autoselect, + position=(h - self._button_width * 0.5 * scale, v), + size=(self._button_width, self._button_height), + scale=scale, + label=bs.Lstr(resource=self._r + + ('.quitText' if 'Mac' in + bs.app.classic.legacy_user_agent_string else '.exitGameText')), + on_activate_call=self._quit, + transition_delay=self._tdelay) + + # Scattered eggs on easter. + if _baplus.get_v1_account_misc_read_val('easter', False): + icon_size = 30 + bui.imagewidget(parent=self._root_widget, + position=(h - icon_size * 0.5 + 25, + v + self._button_height * scale - + icon_size * 0.24 + 1.5), + transition_delay=self._tdelay, + size=(icon_size, icon_size), + texture=bui.gettexture('egg1'), + tilt_scale=0.0) + + bui.containerwidget(edit=self._root_widget, + cancel_button=quit_button) + self._tdelay += self._t_delay_inc + else: + self._quit_button = None + + # If we're not in-game, have no quit button, and this is android, + # we want back presses to quit our activity. + if (not self._in_game and not self._have_quit_button + and bs.app.classic.platform == 'android'): + + def _do_quit() -> None: + QuitWindow(swish=True, back=True) + + bui.containerwidget(edit=self._root_widget, + on_cancel_call=_do_quit) + + # Add speed-up/slow-down buttons for replays. + # (ideally this should be part of a fading-out playback bar like most + # media players but this works for now). + if _bs.is_in_replay(): + b_size = 50.0 + b_buffer = 10.0 + t_scale = 0.75 + uiscale = bui.app.ui_v1.uiscale + if uiscale is bui.UIScale.SMALL: + b_size *= 0.6 + b_buffer *= 1.0 + v_offs = -40 + t_scale = 0.5 + elif uiscale is bui.UIScale.MEDIUM: + v_offs = -70 + else: + v_offs = -100 + self._replay_speed_text = bui.textwidget( + parent=self._root_widget, + text=bs.Lstr(resource='watchWindow.playbackSpeedText', + subs=[('${SPEED}', str(1.23))]), + position=(h, v + v_offs + 7 * t_scale), + h_align='center', + v_align='center', + size=(0, 0), + scale=t_scale) + + # Update to current value. + self._change_replay_speed(0) + + # Keep updating in a timer in case it gets changed elsewhere. + self._change_replay_speed_timer = bs.Timer( + 0.25, + bs.WeakCall(self._change_replay_speed, 0), + repeat=True) + btn = bui.buttonwidget(parent=self._root_widget, + position=(h - b_size - b_buffer, + v - b_size - b_buffer + v_offs), + button_type='square', + size=(b_size, b_size), + label='', + autoselect=True, + on_activate_call=bs.Call( + self._change_replay_speed, -1)) + bui.textwidget( + parent=self._root_widget, + draw_controller=btn, + text='-', + position=(h - b_size * 0.5 - b_buffer, + v - b_size * 0.5 - b_buffer + 5 * t_scale + v_offs), + h_align='center', + v_align='center', + size=(0, 0), + scale=3.0 * t_scale) + btn = bui.buttonwidget( + parent=self._root_widget, + position=(h + b_buffer, v - b_size - b_buffer + v_offs), + button_type='square', + size=(b_size, b_size), + label='', + autoselect=True, + on_activate_call=bs.Call(self._change_replay_speed, 1)) + bui.textwidget( + parent=self._root_widget, + draw_controller=btn, + text='+', + position=(h + b_size * 0.5 + b_buffer, + v - b_size * 0.5 - b_buffer + 5 * t_scale + v_offs), + h_align='center', + v_align='center', + size=(0, 0), + scale=3.0 * t_scale) -def public_servers(origin = None): - from bauiv1lib.gather import GatherWindow - bui.app.ui_v1.set_main_menu_window( GatherWindow(origin_widget=origin).get_root_widget()) # ba_meta export plugin class bySmoothy(babase.Plugin): def __init__(self): - bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = _refresh_in_game(bastd_ui_mainmenu.MainMenuWindow._refresh_in_game) - bs.connect_to_party = connect_to_party - \ No newline at end of file + if babase.env().get("build_number", 0) >= 21140: + bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = new_refresh_in_game + bs.connect_to_party = newconnect_to_party + bs.disconnect_from_host = newdisconnect_from_host + else: + print("Server Switch only works on bs 1.7.20 and above") From ed88413c43f058cd21951c17add1a2ad29b0b5fb Mon Sep 17 00:00:00 2001 From: imayushsaini Date: Sat, 8 Jul 2023 10:24:14 +0000 Subject: [PATCH 15/17] [ci] auto-format --- plugins/utilities/server_switch.py | 64 +++++++++++++++++------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/plugins/utilities/server_switch.py b/plugins/utilities/server_switch.py index ba4ffdcf..2dbc667f 100644 --- a/plugins/utilities/server_switch.py +++ b/plugins/utilities/server_switch.py @@ -18,13 +18,15 @@ current_server_ip = "127.0.0.1" current_server_port = 43210 servers = [] + + def _refresh_in_game(func): def wrapper(self, *args, **kwargs): returnValue = func(self, *args, **kwargs) uiscale = bui.app.ui_v1.uiscale bui.containerwidget( edit=self._root_widget, - size=(self._width*2, self._height), # double the width + size=(self._width*2, self._height), # double the width scale=( 2.15 if uiscale is bui.UIScale.SMALL @@ -36,40 +38,43 @@ def wrapper(self, *args, **kwargs): h = 125 v = self._height - 60.0 bui.textwidget( - parent=self._root_widget, - draw_controller=None, - text="IP: "+current_server_ip+" PORT: "+str(current_server_port), - position=(h-self._button_width/2 + 130 , v+60), - h_align='center', - v_align='center', - size=(20, 60), - scale=0.6) + parent=self._root_widget, + draw_controller=None, + text="IP: "+current_server_ip+" PORT: "+str(current_server_port), + position=(h-self._button_width/2 + 130, v+60), + h_align='center', + v_align='center', + size=(20, 60), + scale=0.6) self._public_servers = bui.buttonwidget( - color=(0.8, 0.45, 1), - parent=self._root_widget, - position=(h+self._button_width-10, v+60+20), - size=(self._button_width/4, self._button_height/2), - scale=1.0, - autoselect=self._use_autoselect, - label="~~~", - on_activate_call=bs.Call(public_servers)) + color=(0.8, 0.45, 1), + parent=self._root_widget, + position=(h+self._button_width-10, v+60+20), + size=(self._button_width/4, self._button_height/2), + scale=1.0, + autoselect=self._use_autoselect, + label="~~~", + on_activate_call=bs.Call(public_servers)) for server in servers: self._server_button = bui.buttonwidget( color=(0.8, 0, 1), parent=self._root_widget, - position=( (h- self._button_width / 2 ) + self._button_width + 20, v), + position=((h - self._button_width / 2) + self._button_width + 20, v), size=(self._button_width, self._button_height), scale=1.0, autoselect=self._use_autoselect, label=server["name"][0:22], on_activate_call=bs.Call(bs.connect_to_party, server["ip"], server["port"])) - + v -= 50 - - return returnValue + + return returnValue return wrapper + connect = bs.connect_to_party + + def connect_to_party(address, port=43210, print_progress=False): global current_server_ip global current_server_port @@ -79,7 +84,8 @@ def connect_to_party(address, port=43210, print_progress=False): current_server_port = port connect(address, port, print_progress) babase.apptimer(1, check_connect_status) - + + def check_connect_status(): global servers global current_server_ip @@ -88,7 +94,8 @@ def check_connect_status(): if (not bs.get_connection_to_host_info()['name']): babase.apptimer(1, check_connect_status) return - new_server = {"name": bs.get_connection_to_host_info()['name'], "ip": current_server_ip, "port": current_server_port} + new_server = {"name": bs.get_connection_to_host_info( + )['name'], "ip": current_server_ip, "port": current_server_port} if new_server not in servers: servers.append(new_server) servers = servers[-3:] @@ -96,13 +103,16 @@ def check_connect_status(): print("connection failed falling back to gather window") public_servers() -def public_servers(origin = None): + +def public_servers(origin=None): from bauiv1lib.gather import GatherWindow - bui.app.ui_v1.set_main_menu_window( GatherWindow(origin_widget=origin).get_root_widget()) + bui.app.ui_v1.set_main_menu_window(GatherWindow(origin_widget=origin).get_root_widget()) # ba_meta export plugin + + class bySmoothy(babase.Plugin): def __init__(self): - bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = _refresh_in_game(bastd_ui_mainmenu.MainMenuWindow._refresh_in_game) + bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = _refresh_in_game( + bastd_ui_mainmenu.MainMenuWindow._refresh_in_game) bs.connect_to_party = connect_to_party - \ No newline at end of file From 506f850283780028f2cd2e7d27064b9a41eaf93f Mon Sep 17 00:00:00 2001 From: Ayush Saini <36878972+imayushsaini@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:56:34 +0530 Subject: [PATCH 16/17] updated utilities --- plugins/utilities.json | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index cee50f85..706cd6b0 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -422,12 +422,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "bf3e61b", - "released_on": "04-07-2023", - "md5sum": "289cc852b7f0ec1b254d08267c9921c2" - }, + "2.0.0": null, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -522,12 +517,7 @@ } ], "versions": { - "2.0.0": { - "api_version": 8, - "commit_sha": "a0239a9", - "released_on": "04-07-2023", - "md5sum": "187a9894158721c8fa1ecee9e3e38e73" - }, + "2.0.0": null, "1.0.0": { "api_version": 7, "commit_sha": "41e239c", From bae5ca90102c16eccbf817e50a001ab14694969d Mon Sep 17 00:00:00 2001 From: imayushsaini Date: Sat, 8 Jul 2023 10:27:37 +0000 Subject: [PATCH 17/17] [ci] apply-version-metadata --- plugins/utilities.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 706cd6b0..34c98c1e 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -422,7 +422,12 @@ } ], "versions": { - "2.0.0": null, + "2.0.0": { + "api_version": 8, + "commit_sha": "a18a595", + "released_on": "08-07-2023", + "md5sum": "30a21cb1c739b098dcaa791e4a2cd481" + }, "1.0.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -517,7 +522,12 @@ } ], "versions": { - "2.0.0": null, + "2.0.0": { + "api_version": 8, + "commit_sha": "a18a595", + "released_on": "08-07-2023", + "md5sum": "7403fcea1855ddf561aa412d703fcc6e" + }, "1.0.0": { "api_version": 7, "commit_sha": "41e239c",