diff --git a/plugins/utilities.json b/plugins/utilities.json index a2f49fe..7d21818 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -335,6 +335,7 @@ } ], "versions": { + "2.0.0":null, "1.2.1": { "api_version": 7, "commit_sha": "64e8a5c", @@ -436,6 +437,7 @@ } ], "versions": { + "2.0.0": null, "1.0.0": { "api_version": 7, "commit_sha": "ff4de19", diff --git a/plugins/utilities/character_chooser.py b/plugins/utilities/character_chooser.py index 006c0a4..9dbe733 100644 --- a/plugins/utilities/character_chooser.py +++ b/plugins/utilities/character_chooser.py @@ -1,4 +1,4 @@ -# ba_meta require api 7 +# ba_meta require api 8 ''' Character Chooser by Mr.Smoothy @@ -34,41 +34,42 @@ from __future__ import annotations from typing import TYPE_CHECKING -import ba -import _ba -from bastd.actor.playerspaz import PlayerSpaz +import babase +import bauiv1 as bui +import bascenev1 as bs +import _babase +from bascenev1lib.actor.playerspaz import PlayerSpaz -from ba._error import print_exception, print_error, NotFoundError -from ba._gameutils import animate, animate_array -from ba._language import Lstr -from ba._generated.enums import SpecialChar, InputType -from ba._profile import get_player_profile_colors +from babase._error import print_exception, print_error, NotFoundError + +from babase._language import Lstr + if TYPE_CHECKING: from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional import weakref import os import json -from ba import _lobby -from bastd.actor.spazappearance import * -from ba._lobby import ChangeMessage -from ba._lobby import PlayerReadyMessage +from bascenev1._lobby import ChangeMessage, PlayerReadyMessage +from bascenev1 import _lobby +from bascenev1lib.actor.spazappearance import * -def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, + +def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer, lobby: 'Lobby') -> None: - self._deek_sound = _ba.getsound('deek') - self._click_sound = _ba.getsound('click01') - self._punchsound = _ba.getsound('punch01') - self._swish_sound = _ba.getsound('punchSwish') - self._errorsound = _ba.getsound('error') - self._mask_texture = _ba.gettexture('characterIconMask') + self._deek_sound = bs.getsound('deek') + self._click_sound = bs.getsound('click01') + self._punchsound = bs.getsound('punch01') + self._swish_sound = bs.getsound('punchSwish') + self._errorsound = bs.getsound('error') + self._mask_texture = bs.gettexture('characterIconMask') self._vpos = vpos self._lobby = weakref.ref(lobby) self._sessionplayer = sessionplayer self._inited = False self._dead = False - self._text_node: Optional[ba.Node] = None + self._text_node: Optional[bs.Node] = None self._profilename = '' self._profilenames: List[str] = [] self._ready: bool = False @@ -76,7 +77,7 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, self._last_change: Sequence[Union[float, int]] = (0, 0) self._profiles: Dict[str, Dict[str, Any]] = {} - app = _ba.app + app = babase.app self.bakwas_chars = ["Lee", "Todd McBurton", "Zola", "Butch", "Witch", "warrior", "Middle-Man", "Alien", "OldLady", "Gladiator", "Wrestler", "Gretel", "Robot"] @@ -84,7 +85,7 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, # Load available player profiles either from the local config or # from the remote device. self.reload_profiles() - for name in _ba.app.spaz_appearances: + for name in bs.app.classic.spaz_appearances: if name not in self._character_names and name not in self.bakwas_chars: self._character_names.append(name) # Note: this is just our local index out of available teams; *not* @@ -96,12 +97,12 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, # it. This will give a persistent character for them between games # and will distribute characters nicely if everyone is random. self._random_color, self._random_highlight = ( - get_player_profile_colors(None)) + bs.get_player_profile_colors(None)) # To calc our random character we pick a random one out of our # unlocked list and then locate that character's index in the full # list. - char_index_offset = app.lobby_random_char_index_offset + char_index_offset = app.classic.lobby_random_char_index_offset self._random_character_index = ( (sessionplayer.inputdevice.id + char_index_offset) % len(self._character_names)) @@ -111,7 +112,7 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, self._profileindex = self._select_initial_profile() self._profilename = self._profilenames[self._profileindex] - self._text_node = _ba.newnode('text', + self._text_node = bs.newnode('text', delegate=self, attrs={ 'position': (-100, self._vpos), @@ -122,8 +123,8 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, 'v_align': 'center', 'v_attach': 'top' }) - animate(self._text_node, 'scale', {0: 0, 0.1: 1.0}) - self.icon = _ba.newnode('image', + 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), @@ -132,7 +133,7 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, 'attach': 'topCenter' }) - animate_array(self.icon, 'scale', 2, {0: (0, 0), 0.1: (45, 45)}) + bs.animate_array(self.icon, 'scale', 2, {0: (0, 0), 0.1: (45, 45)}) # Set our initial name to '' in case anyone asks. self._sessionplayer.setname( @@ -154,39 +155,39 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer, def _set_ready(self, ready: bool) -> None: # pylint: disable=cyclic-import - from bastd.ui.profile import browser as pbrowser - from ba._general import Call + from bauiv1lib.profile import browser as pbrowser + from babase._general import Call profilename = self._profilenames[self._profileindex] # Handle '_edit' as a special case. if profilename == '_edit' and ready: - with _ba.Context('ui'): + with _babase.Context('ui'): pbrowser.ProfileBrowserWindow(in_main_menu=False) # Give their input-device UI ownership too # (prevent someone else from snatching it in crowded games) - _ba.set_ui_input_device(self._sessionplayer.inputdevice) + _babase.set_ui_input_device(self._sessionplayer.inputdevice) return if ready == False: self._sessionplayer.assigninput( - InputType.LEFT_PRESS, + babase.InputType.LEFT_PRESS, Call(self.handlemessage, ChangeMessage('team', -1))) self._sessionplayer.assigninput( - InputType.RIGHT_PRESS, + babase.InputType.RIGHT_PRESS, Call(self.handlemessage, ChangeMessage('team', 1))) self._sessionplayer.assigninput( - InputType.BOMB_PRESS, + babase.InputType.BOMB_PRESS, Call(self.handlemessage, ChangeMessage('character', 1))) self._sessionplayer.assigninput( - InputType.UP_PRESS, + babase.InputType.UP_PRESS, Call(self.handlemessage, ChangeMessage('profileindex', -1))) self._sessionplayer.assigninput( - InputType.DOWN_PRESS, + babase.InputType.DOWN_PRESS, Call(self.handlemessage, ChangeMessage('profileindex', 1))) self._sessionplayer.assigninput( - (InputType.JUMP_PRESS, InputType.PICK_UP_PRESS, - InputType.PUNCH_PRESS), + (babase.InputType.JUMP_PRESS, babase.InputType.PICK_UP_PRESS, + babase.InputType.PUNCH_PRESS), Call(self.handlemessage, ChangeMessage('ready', 1))) self._ready = False self._update_text() @@ -194,26 +195,26 @@ def _set_ready(self, ready: bool) -> None: elif ready == True: self.characterchooser = True self._sessionplayer.assigninput( - (InputType.LEFT_PRESS, InputType.RIGHT_PRESS, - InputType.UP_PRESS, InputType.DOWN_PRESS, - InputType.JUMP_PRESS, InputType.BOMB_PRESS, - InputType.PICK_UP_PRESS), self._do_nothing) + (babase.InputType.LEFT_PRESS, babase.InputType.RIGHT_PRESS, + babase.InputType.UP_PRESS, babase.InputType.DOWN_PRESS, + babase.InputType.JUMP_PRESS, babase.InputType.BOMB_PRESS, + babase.InputType.PICK_UP_PRESS), self._do_nothing) self._sessionplayer.assigninput( - (InputType.UP_PRESS), Call(self.handlemessage, ChangeMessage('characterchooser', -1))) + (babase.InputType.UP_PRESS), Call(self.handlemessage, ChangeMessage('characterchooser', -1))) self._sessionplayer.assigninput( - (InputType.DOWN_PRESS), Call(self.handlemessage, ChangeMessage('characterchooser', 1))) + (babase.InputType.DOWN_PRESS), Call(self.handlemessage, ChangeMessage('characterchooser', 1))) self._sessionplayer.assigninput( - (InputType.BOMB_PRESS), Call(self.handlemessage, ChangeMessage('ready', 0))) + (babase.InputType.BOMB_PRESS), Call(self.handlemessage, ChangeMessage('ready', 0))) self._sessionplayer.assigninput( - (InputType.JUMP_PRESS, InputType.PICK_UP_PRESS, InputType.PUNCH_PRESS), + (babase.InputType.JUMP_PRESS, babase.InputType.PICK_UP_PRESS, babase.InputType.PUNCH_PRESS), Call(self.handlemessage, ChangeMessage('ready', 2))) # Store the last profile picked by this input for reuse. input_device = self._sessionplayer.inputdevice name = input_device.name unique_id = input_device.unique_identifier - device_profiles = _ba.app.config.setdefault( + device_profiles = _babase.app.config.setdefault( 'Default Player Profiles', {}) # Make an exception if we have no custom profiles and are set @@ -229,7 +230,7 @@ def _set_ready(self, ready: bool) -> None: del device_profiles[profilekey] else: device_profiles[profilekey] = profilename - _ba.app.config.commit() + _babase.app.config.commit() # Set this player's short and full name. self._sessionplayer.setname(self._getname(), @@ -240,7 +241,7 @@ def _set_ready(self, ready: bool) -> None: else: # Inform the session that this player is ready. - _ba.getsession().handlemessage(PlayerReadyMessage(self)) + bs.getsession().handlemessage(PlayerReadyMessage(self)) def handlemessage(self, msg: Any) -> Any: @@ -258,7 +259,7 @@ def handlemessage(self, msg: Any) -> Any: print_error('got ChangeMessage after nodes died') return if msg.what == 'characterchooser': - _ba.playsound(self._click_sound) + self._click_sound.play() # update our index in our local list of characters self._character_index = ((self._character_index + msg.value) % len(self._character_names)) @@ -268,7 +269,7 @@ def handlemessage(self, msg: Any) -> Any: if msg.what == 'team': sessionteams = self.lobby.sessionteams if len(sessionteams) > 1: - _ba.playsound(self._swish_sound) + self._swish_sound.play() self._selected_team_index = ( (self._selected_team_index + msg.value) % len(sessionteams)) @@ -281,18 +282,18 @@ def handlemessage(self, msg: Any) -> Any: # This should be pretty hard to hit now with # automatic local accounts. - _ba.playsound(_ba.getsound('error')) + bui.getsound('error').play() else: # Pick the next player profile and assign our name # and character based on that. - _ba.playsound(self._deek_sound) + self._deek_sound.play() self._profileindex = ((self._profileindex + msg.value) % len(self._profilenames)) self.update_from_profile() elif msg.what == 'character': - _ba.playsound(self._click_sound) + self._click_sound.play() self.characterchooser = True # update our index in our local list of characters self._character_index = ((self._character_index + msg.value) % @@ -327,9 +328,9 @@ def _update_text(self) -> None: can_switch_teams = len(self.lobby.sessionteams) > 1 # Flash as we're coming in. - fin_color = _ba.safecolor(self.get_color()) + (1, ) + fin_color = _babase.safecolor(self.get_color()) + (1, ) if not self._inited: - animate_array(self._text_node, 'color', 4, { + bs.animate_array(self._text_node, 'color', 4, { 0.15: fin_color, 0.25: (2, 2, 2, 1), 0.35: fin_color @@ -338,7 +339,7 @@ def _update_text(self) -> None: # Blend if we're in teams mode; switch instantly otherwise. if can_switch_teams: - animate_array(self._text_node, 'color', 4, { + bs.animate_array(self._text_node, 'color', 4, { 0: self._text_node.color, 0.1: fin_color }) @@ -350,7 +351,7 @@ def _update_text(self) -> None: # ba_meta export plugin -class HeySmoothy(ba.Plugin): +class HeySmoothy(babase.Plugin): def __init__(self): _lobby.Chooser.__init__ = __init__ diff --git a/plugins/utilities/easy_connect.py b/plugins/utilities/easy_connect.py index d14745c..abd2f43 100644 --- a/plugins/utilities/easy_connect.py +++ b/plugins/utilities/easy_connect.py @@ -1,50 +1,48 @@ # -*- coding: utf-8 -*- -# ba_meta require api 7 - -# =============================================== -# EasyConnect by Mr.Smoothy | -# verion 1.2 | -# https://discord.gg/ucyaesh | -# Serverconnector X IPPORTRevealer | -# for bombsquad v1.7 + | -# =============================================== +# ba_meta require api 8 +''' =========================================== + EasyConnect by Mr.Smoothy | + verion 1.7 | + https://discord.gg/ucyaesh | + Serverconnector X IPPORTRevealer | + for bombsquad v1.7.20+ | + ============================================== +''' # .................___________________________________________ # WATCH IN ACTION https://www.youtube.com/watch?v=jwi2wKwZblQ # .................___________________________________________ # Have any idea/suggestion/bug report > send message on discord mr.smoothy#5824 - +# Download modshttps://bombsquad-community.web.app/mods # Discord:- # mr.smoothy#5824 - # DONT EDIT ANYTHING WITHOUT PERMISSION -# join Bombspot - bombsquad biggest modding community .... open for everyone https://discord.gg/2RKd9QQdQY -# join Bombsquad Consultancy Service - for more mods, modding help ------- for all modders and server owners +# join Bombsquad Community Server - -# https://discord.gg/2RKd9QQdQY # https://discord.gg/ucyaesh # REQUIREMENTS -# built for bs 1.7 and above +# built for bs 1.7.20 and above -# by Mr.Smoothy for Bombsquad version 1.7 +# by Mr.Smoothy for Bombsquad version 1.7.20+ -import _ba -import ba -import bastd +import _babase +import babase +import bauiv1 as bui +import bascenev1 as bs import threading -from bastd.ui.gather import manualtab, publictab -from bastd.ui import popup +from bauiv1lib.gather import manualtab, publictab +from bauiv1lib import popup from dataclasses import dataclass import random from enum import Enum -from bastd.ui.popup import PopupMenuWindow, PopupWindow -from typing import Any, Optional, Dict, List, Tuple, Type, Union, Callable -from bastd.ui.gather.publictab import PublicGatherTab +from bauiv1lib.popup import PopupMenuWindow, PopupWindow +from typing import Any, Optional, Callable +from bauiv1lib.gather.publictab import PublicGatherTab import json import urllib.request import time @@ -61,7 +59,7 @@ Report such case on community discord channels https://discord.gg/ucyaesh https://ballistica.net/discord """ -BCSURL = 'https://bcsserver.bombsquad.ga/bannedservers' +BCSURL = 'https://bcs.ballistica.workers.dev/bannedservers' def is_game_version_lower_than(version): @@ -70,24 +68,21 @@ 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"): - ba_internal = _ba -else: - ba_internal = ba.internal - def updateBannedServersCache(): response = None - config = ba.app.config + config = babase.app.config if not isinstance(config.get('Banned Servers'), list): config['Banned Servers'] = [] try: - response = urllib.request.urlopen(BCSURL).read() + req = urllib.request.Request(BCSURL, headers={ + "User-Agent": f'BS{_babase.env().get("build_number", 0)}', "Accept-Language": "en-US,en;q=0.9", }) + response = urllib.request.urlopen(req).read() data = json.loads(response.decode('utf-8')) bannedlist = [] for server in data["servers"]: @@ -116,133 +111,133 @@ class _HostLookupThread(threading.Thread): result = socket.gethostbyname(self._name) except Exception: result = None - ba.pushcall(lambda: self._call(result, self._port), + babase.pushcall(lambda: self._call(result, self._port), from_other_thread=True) -def new_build_favorites_tab(self, region_height: float) -> None: +def newbuild_favorites_tab(self, region_height: float) -> None: c_height = region_height - 20 v = c_height - 35 - 25 - 30 self.retry_inter = 0.0 - uiscale = ba.app.ui.uiscale - self._width = 1240 if uiscale is ba.UIScale.SMALL else 1040 - x_inset = 100 if uiscale is ba.UIScale.SMALL else 0 - self._height = (578 if uiscale is ba.UIScale.SMALL else - 670 if uiscale is ba.UIScale.MEDIUM else 800) + uiscale = bui.app.ui_v1.uiscale + self._width = 1240 if uiscale is babase.UIScale.SMALL else 1040 + x_inset = 100 if uiscale is babase.UIScale.SMALL else 0 + self._height = (578 if uiscale is babase.UIScale.SMALL else + 670 if uiscale is babase.UIScale.MEDIUM else 800) self._scroll_width = self._width - 130 + 2 * x_inset self._scroll_height = self._height - 180 - x_inset = 100 if uiscale is ba.UIScale.SMALL else 0 + x_inset = 100 if uiscale is babase.UIScale.SMALL else 0 c_height = self._scroll_height - 20 sub_scroll_height = c_height - 63 self._favorites_scroll_width = sub_scroll_width = ( - 680 if uiscale is ba.UIScale.SMALL else 640) + 680 if uiscale is babase.UIScale.SMALL else 640) v = c_height - 30 - b_width = 140 if uiscale is ba.UIScale.SMALL else 178 - b_height = (90 if uiscale is ba.UIScale.SMALL else - 142 if uiscale is ba.UIScale.MEDIUM else 130) - b_space_extra = (0 if uiscale is ba.UIScale.SMALL else - -2 if uiscale is ba.UIScale.MEDIUM else -5) + b_width = 140 if uiscale is babase.UIScale.SMALL else 178 + b_height = (90 if uiscale is babase.UIScale.SMALL else + 142 if uiscale is babase.UIScale.MEDIUM else 130) + b_space_extra = (0 if uiscale is babase.UIScale.SMALL else + -2 if uiscale is babase.UIScale.MEDIUM else -5) - btnv = (c_height - (48 if uiscale is ba.UIScale.SMALL else - 45 if uiscale is ba.UIScale.MEDIUM else 40) - + btnv = (c_height - (48 if uiscale is babase.UIScale.SMALL else + 45 if uiscale is babase.UIScale.MEDIUM else 40) - b_height) # ================= smoothy ============= - ba.textwidget(parent=self._container, - position=(90 if uiscale is ba.UIScale.SMALL else 120, btnv + - 120 if uiscale is ba.UIScale.SMALL else btnv+90), + 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") - btnv += 50 if uiscale is ba.UIScale.SMALL else 0 + btnv += 50 if uiscale is babase.UIScale.SMALL else 0 - ba.buttonwidget(parent=self._container, + bui.buttonwidget(parent=self._container, size=(30, 30), - position=(25 if uiscale is ba.UIScale.SMALL else 40, + 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 ba.UIScale.SMALL else 1.2, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, label="-", autoselect=True) - self.retry_inter_text = ba.textwidget(parent=self._container, + self.retry_inter_text = bui.textwidget(parent=self._container, position=( - 90 if uiscale is ba.UIScale.SMALL else 120, btnv+25), + 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') - ba.buttonwidget(parent=self._container, + bui.buttonwidget(parent=self._container, size=(30, 30), - position=(125 if uiscale is ba.UIScale.SMALL else 155, + 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 ba.UIScale.SMALL else 1.2, + text_scale=1.3 if uiscale is babase.UIScale.SMALL else 1.2, label="+", autoselect=True) btnv -= b_height + b_space_extra - self._favorites_connect_button = btn1 = ba.buttonwidget( + self._favorites_connect_button = btn1 = bui.buttonwidget( parent=self._container, size=(b_width, b_height), - position=(25 if uiscale is ba.UIScale.SMALL else 40, btnv), + 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_connect_press, - text_scale=1.0 if uiscale is ba.UIScale.SMALL else 1.2, - label=ba.Lstr(resource='gatherWindow.manualConnectText'), + text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2, + label=babase.Lstr(resource='gatherWindow.manualConnectText'), autoselect=True) - if uiscale is ba.UIScale.SMALL and ba.app.ui.use_toolbars: - ba.widget(edit=btn1, - left_widget=ba_internal.get_special_widget('back_button')) + 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')) btnv -= b_height + b_space_extra - ba.buttonwidget(parent=self._container, + bui.buttonwidget(parent=self._container, size=(b_width, b_height), - position=(25 if uiscale is ba.UIScale.SMALL else 40, + 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 ba.UIScale.SMALL else 1.2, - label=ba.Lstr(resource='editText'), + 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 - ba.buttonwidget(parent=self._container, + bui.buttonwidget(parent=self._container, size=(b_width, b_height), - position=(25 if uiscale is ba.UIScale.SMALL else 40, + 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 ba.UIScale.SMALL else 1.2, - label=ba.Lstr(resource='deleteText'), + 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 = ba.scrollwidget( + self._scrollwidget = scrlw = bui.scrollwidget( parent=self._container, - position=(190 if uiscale is ba.UIScale.SMALL else 225, v), + position=(190 if uiscale is babase.UIScale.SMALL else 225, v), size=(sub_scroll_width, sub_scroll_height), claims_left_right=True) - ba.widget(edit=self._favorites_connect_button, + bui.widget(edit=self._favorites_connect_button, right_widget=self._scrollwidget) - self._columnwidget = ba.columnwidget(parent=scrlw, + self._columnwidget = bui.columnwidget(parent=scrlw, left_border=10, border=2, margin=0, @@ -257,22 +252,22 @@ def new_on_favorites_connect_press(self) -> None: self._no_favorite_selected_error() else: - config = ba.app.config['Saved Servers'][self._favorite_selected] + config = babase.app.config['Saved Servers'][self._favorite_selected] _HostLookupThread(name=config['addr'], port=config['port'], - call=ba.WeakCall( + call=bs.WeakCall( self._host_lookup_result)).start() - if self.retry_inter > 0 and (ba_internal.get_connection_to_host_info() == {} or ba_internal.get_connection_to_host_info()['build_number'] == 0): - ba.screenmessage("Server full or unreachable, Retrying....") - self._retry_timer = ba.Timer(self.retry_inter, ba.Call( - self._on_favorites_connect_press), timetype=ba.TimeType.REAL) + if self.retry_inter > 0 and (bs.get_connection_to_host_info() == {} or bs.get_connection_to_host_info()['build_number'] == 0): + bui.screenmessage("Server full or unreachable, Retrying....") + self._retry_timer = bs.AppTimer(self.retry_inter, babase.Call( + self._on_favorites_connect_press)) def auto_retry_inc(self): self.retry_inter += 0.5 - ba.textwidget(edit=self.retry_inter_text, text='%.1f' % self.retry_inter) + bui.textwidget(edit=self.retry_inter_text, text='%.1f' % self.retry_inter) def auto_retry_dec(self): @@ -280,9 +275,9 @@ def auto_retry_dec(self): self.retry_inter -= 0.5 if self.retry_inter == 0.0: - ba.textwidget(edit=self.retry_inter_text, text='off') + bui.textwidget(edit=self.retry_inter_text, text='off') else: - ba.textwidget(edit=self.retry_inter_text, text='%.1f' % self.retry_inter) + bui.textwidget(edit=self.retry_inter_text, text='%.1f' % self.retry_inter) @dataclass @@ -328,121 +323,142 @@ def _clear(self) -> None: self._stats_button ]: if widget: - try: - widget.delete() - except: - pass + + widget.delete() + def update(self, index: int, party: PartyEntry, sub_scroll_width: float, sub_scroll_height: float, lineheight: float, - columnwidget: ba.Widget, join_text: ba.Widget, - filter_text: ba.Widget, existing_selection: Optional[Selection], + 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 + """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. - if party.clean_display_index == index: - return + # 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 - ping_good = ba_internal.get_v1_account_misc_read_val('pingGood', 100) - ping_med = ba_internal.get_v1_account_misc_read_val('pingMed', 500) + # 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 - self._clear() - hpos = 20 - vpos = sub_scroll_height - lineheight * index - 50 - self._name_widget = ba.textwidget( - text=ba.Lstr(value=party.name), - parent=columnwidget, - size=(sub_scroll_width * 0.63, 20), - position=(0 + hpos, 4 + vpos), - selectable=True, - on_select_call=ba.WeakCall( - tab.set_public_party_selection, - Selection(party.get_key(), SelectionComponent.NAME)), - on_activate_call=ba.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') - ba.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): - ba.containerwidget(edit=columnwidget, - selected_child=self._name_widget) - if party.stats_addr or True: - url = party.stats_addr.replace( - '${ACCOUNT}', - ba_internal.get_v1_account_misc_read_val_2('resolvedAccountID', - 'UNKNOWN')) - self._stats_button = ba.buttonwidget( - color=(0.5, 0.8, 0.8), - textcolor=(1.0, 1.0, 1.0), - label='....', + 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_select_call=ba.WeakCall( + 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)), - size=(100, 40), - position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), - scale=0.9) - ba.buttonwidget(edit=self._stats_button, on_activate_call=ba.Call( - self.on_stats_click, self._stats_button, party)) + 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.STATS_BUTTON): - ba.containerwidget(edit=columnwidget, - selected_child=self._stats_button) + 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, + 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 = ba.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: - ba.widget(edit=self._name_widget, up_widget=filter_text) - if self._stats_button: - ba.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 = ba.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: - ba.textwidget(edit=self._ping_widget, - text='-', - color=(0.5, 0.5, 0.5)) - else: - ba.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 + 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 def _get_popup_window_scale() -> float: - uiscale = ba.app.ui.uiscale - return (2.3 if uiscale is ba.UIScale.SMALL else - 1.65 if uiscale is ba.UIScale.MEDIUM else 1.23) + uiscale = bui.app.ui_v1.uiscale + return (2.3 if uiscale is babase.UIScale.SMALL else + 1.65 if uiscale is babase.UIScale.MEDIUM else 1.23) _party = None @@ -452,8 +468,8 @@ def on_stats_click(self, widget, party): global _party _party = party choices = ['connect', 'copyqueue', "save"] - DisChoices = [ba.Lstr(resource="ipp", fallback_value="Connect by IP"), ba.Lstr( - resource="copy id", fallback_value="Copy Queue ID"), ba.Lstr(value="Save")] + DisChoices = [babase.Lstr(resource="ipp", fallback_value="Connect by IP"), babase.Lstr( + resource="copy id", fallback_value="Copy Queue ID"), babase.Lstr(value="Save")] if party.stats_addr: choices.append('stats') if 'discord' in party.stats_addr: @@ -462,7 +478,7 @@ def on_stats_click(self, widget, party): txt = "Youtube" else: txt = party.stats_addr[0:13] - DisChoices.append(ba.Lstr(value=txt)) + DisChoices.append(babase.Lstr(value=txt)) PopupMenuWindow( position=widget.get_screen_space_center(), scale=_get_popup_window_scale(), @@ -480,17 +496,17 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu, choice: str) -> None: """Called when a menu entry is selected.""" # Unused arg. - + plus = babase.app.plus if choice == 'stats': url = _party.stats_addr.replace( '${ACCOUNT}', - ba_internal.get_v1_account_misc_read_val_2('resolvedAccountID', + plus.get_v1_account_misc_read_val_2('resolvedAccountID', 'UNKNOWN')) - ba.open_url(url) + bui.open_url(url) elif choice == 'connect': PartyQuickConnect(_party.address, _party.port) elif choice == 'save': - config = ba.app.config + config = babase.app.config ip_add = _party.address p_port = _party.port title = _party.name @@ -502,18 +518,19 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu, 'name': title } config.commit() - ba.screenmessage("Server saved to manual") - ba.playsound(ba.getsound('gunCocking')) + bui.screenmessage("Server saved to manual") + bui.getsound('gunCocking').play() elif choice == "copyqueue": - ba.clipboard_set_text(_party.queue) - ba.playsound(ba.getsound('gunCocking')) + babase.clipboard_set_text(_party.queue) + bui.getsound('gunCocking').play() def _update_party_lists(self) -> None: if not self._party_lists_dirty: return starttime = time.time() - config = ba.app.config + config = babase.app.config + plus = babase.app.plus bannedservers = config.get('Banned Servers', []) assert len(self._parties_sorted) == len(self._parties) @@ -526,7 +543,7 @@ def _update_party_lists(self) -> None: # If signed out or errored, show no parties. if ( - ba.internal.get_v1_account_state() != 'signed_in' + plus.get_v1_account_state() != 'signed_in' or not self._have_valid_server_list ): self._parties_displayed = {} @@ -568,7 +585,7 @@ def _update_party_lists(self) -> None: def replace(): - manualtab.ManualGatherTab._build_favorites_tab = new_build_favorites_tab + manualtab.ManualGatherTab._build_favorites_tab = newbuild_favorites_tab manualtab.ManualGatherTab._on_favorites_connect_press = new_on_favorites_connect_press manualtab.ManualGatherTab.auto_retry_dec = auto_retry_dec manualtab.ManualGatherTab.auto_retry_inc = auto_retry_inc @@ -577,26 +594,26 @@ def replace(): publictab.UIRow.on_stats_click = on_stats_click publictab.UIRow.popup_menu_closing = popup_menu_closing publictab.UIRow.popup_menu_selected_choice = popup_menu_selected_choice - publictab.PublicGatherTab._update_party_lists = _update_party_lists + # publictab.PublicGatherTab._update_party_lists = _update_party_lists -class PartyQuickConnect(ba.Window): +class PartyQuickConnect(bui.Window): def __init__(self, address: str, port: int): self._width = 800 self._height = 400 - self._white_tex = ba.gettexture('white') - self.lineup_tex = ba.gettexture('playerLineup') - self.lineup_1_transparent_model = ba.getmodel( + self._white_tex = bui.gettexture('white') + self.lineup_tex = bui.gettexture('playerLineup') + self.lineup_1_transparent_mesh = bui.getmesh( 'playerLineup1Transparent') - self.eyes_model = ba.getmodel('plasticEyesTransparent') - uiscale = ba.app.ui.uiscale - super().__init__(root_widget=ba.containerwidget( + self.eyes_mesh = bui.getmesh('plasticEyesTransparent') + uiscale = bui.app.ui_v1.uiscale + super().__init__(root_widget=bui.containerwidget( size=(self._width, self._height), color=(0.45, 0.63, 0.15), transition='in_scale', - scale=(1.4 if uiscale is ba.UIScale.SMALL else - 1.2 if uiscale is ba.UIScale.MEDIUM else 1.0))) - self._cancel_button = ba.buttonwidget(parent=self._root_widget, + 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), @@ -604,12 +621,12 @@ class PartyQuickConnect(ba.Window): on_activate_call=self.close, autoselect=True, color=(0.45, 0.63, 0.15), - icon=ba.gettexture('crossOut'), + icon=bui.gettexture('crossOut'), iconscale=1.2) - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, cancel_button=self._cancel_button) - self.IP = ba.textwidget( + self.IP = bui.textwidget( parent=self._root_widget, position=(self._width * 0.5, self._height * 0.55 + 60), size=(0, 0), @@ -619,7 +636,7 @@ class PartyQuickConnect(ba.Window): v_align='center', text="IP: "+address + " PORT: "+str(port), maxwidth=self._width * 0.65) - self._title_text = ba.textwidget( + self._title_text = bui.textwidget( parent=self._root_widget, position=(self._width * 0.5, self._height * 0.55), size=(0, 0), @@ -629,7 +646,7 @@ class PartyQuickConnect(ba.Window): v_align='center', text="Retrying....", maxwidth=self._width * 0.65) - self._line_image = ba.imagewidget( + self._line_image = bui.imagewidget( parent=self._root_widget, color=(0.0, 0.0, 0.0), opacity=0.2, @@ -637,39 +654,38 @@ class PartyQuickConnect(ba.Window): size=(800-190+80, 4.0), texture=self._white_tex) self.dude_x = 60 - self._body_image_target = ba.buttonwidget( + self._body_image_target = bui.buttonwidget( parent=self._root_widget, size=(1 * 60, 1 * 80), color=(random.random(), random.random(), random.random()), label='', texture=self.lineup_tex, position=(40, 110), - model_transparent=self.lineup_1_transparent_model) - self._eyes_image = ba.imagewidget( + mesh_transparent=self.lineup_1_transparent_mesh) + self._eyes_image = bui.imagewidget( parent=self._root_widget, size=(1 * 36, 1 * 18), texture=self.lineup_tex, color=(1, 1, 1), position=(40, 165), - model_transparent=self.eyes_model) - # self._body_image_target2 = ba.imagewidget( + mesh_transparent=self.eyes_mesh) + # self._body_image_target2 = bui.imagewidget( # parent=self._root_widget, # size=(1* 60, 1 * 80), # color=(1,0.3,0.4), # texture=self.lineup_tex, # position=(700,130), - # model_transparent=self.lineup_1_transparent_model) + # mesh_transparent=self.lineup_1_transparent_mesh) self.closed = False self.retry_count = 1 self.direction = "right" self.connect(address, port) - self.move_R = ba.Timer(0.01, ba.Call(self.move_right), - timetype=ba.TimeType.REAL, repeat=True) + self.move_R = bs.AppTimer(0.01, babase.Call(self.move_right), repeat=True) def move_right(self): if self._body_image_target and self._eyes_image: - ba.buttonwidget(edit=self._body_image_target, position=(self.dude_x, 110)) - ba.imagewidget(edit=self._eyes_image, position=(self.dude_x+10, 165)) + bui.buttonwidget(edit=self._body_image_target, position=(self.dude_x, 110)) + bui.imagewidget(edit=self._eyes_image, position=(self.dude_x+10, 165)) else: self.move_R = None if self.direction == "right": @@ -682,23 +698,23 @@ class PartyQuickConnect(ba.Window): self.direction = "right" def connect(self, address, port): - if not self.closed and (ba_internal.get_connection_to_host_info() == {} or ba_internal.get_connection_to_host_info()['build_number'] == 0): - ba.textwidget(edit=self._title_text, text="Retrying....("+str(self.retry_count)+")") + if not self.closed and (bs.get_connection_to_host_info() == {} or bs.get_connection_to_host_info()['build_number'] == 0): + bui.textwidget(edit=self._title_text, text="Retrying....("+str(self.retry_count)+")") self.retry_count += 1 - ba_internal.connect_to_party(address, port=port) - self._retry_timer = ba.Timer(1.5, ba.Call( - self.connect, address, port), timetype=ba.TimeType.REAL) + bs.connect_to_party(address, port=port) + self._retry_timer = bs.AppTimer(1.5, babase.Call( + self.connect, address, port)) def close(self) -> None: """Close the ui.""" self.closed = True - ba.containerwidget(edit=self._root_widget, transition='out_scale') + bui.containerwidget(edit=self._root_widget, transition='out_scale') # ba_meta export plugin -class InitalRun(ba.Plugin): +class InitalRun(babase.Plugin): def __init__(self): replace() - config = ba.app.config + config = babase.app.config if config["launchCount"] % 5 == 0: updateBannedServersCache()