updated character chooser , easy connect

This commit is contained in:
Ayush Saini 2023-07-02 18:28:55 +05:30
parent 018c962743
commit eb205fe7b1
3 changed files with 314 additions and 295 deletions

View file

@ -335,6 +335,7 @@
} }
], ],
"versions": { "versions": {
"2.0.0":null,
"1.2.1": { "1.2.1": {
"api_version": 7, "api_version": 7,
"commit_sha": "64e8a5c", "commit_sha": "64e8a5c",
@ -436,6 +437,7 @@
} }
], ],
"versions": { "versions": {
"2.0.0": null,
"1.0.0": { "1.0.0": {
"api_version": 7, "api_version": 7,
"commit_sha": "ff4de19", "commit_sha": "ff4de19",

View file

@ -1,4 +1,4 @@
# ba_meta require api 7 # ba_meta require api 8
''' '''
Character Chooser by Mr.Smoothy Character Chooser by Mr.Smoothy
@ -34,41 +34,42 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import ba import babase
import _ba import bauiv1 as bui
from bastd.actor.playerspaz import PlayerSpaz import bascenev1 as bs
import _babase
from bascenev1lib.actor.playerspaz import PlayerSpaz
from ba._error import print_exception, print_error, NotFoundError from babase._error import print_exception, print_error, NotFoundError
from ba._gameutils import animate, animate_array
from ba._language import Lstr from babase._language import Lstr
from ba._generated.enums import SpecialChar, InputType
from ba._profile import get_player_profile_colors
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
import weakref import weakref
import os import os
import json import json
from ba import _lobby from bascenev1._lobby import ChangeMessage, PlayerReadyMessage
from bastd.actor.spazappearance import * from bascenev1 import _lobby
from ba._lobby import ChangeMessage from bascenev1lib.actor.spazappearance import *
from ba._lobby import PlayerReadyMessage
def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer,
def __init__(self, vpos: float, sessionplayer: bs.SessionPlayer,
lobby: 'Lobby') -> None: lobby: 'Lobby') -> None:
self._deek_sound = _ba.getsound('deek') self._deek_sound = bs.getsound('deek')
self._click_sound = _ba.getsound('click01') self._click_sound = bs.getsound('click01')
self._punchsound = _ba.getsound('punch01') self._punchsound = bs.getsound('punch01')
self._swish_sound = _ba.getsound('punchSwish') self._swish_sound = bs.getsound('punchSwish')
self._errorsound = _ba.getsound('error') self._errorsound = bs.getsound('error')
self._mask_texture = _ba.gettexture('characterIconMask') self._mask_texture = bs.gettexture('characterIconMask')
self._vpos = vpos self._vpos = vpos
self._lobby = weakref.ref(lobby) self._lobby = weakref.ref(lobby)
self._sessionplayer = sessionplayer self._sessionplayer = sessionplayer
self._inited = False self._inited = False
self._dead = False self._dead = False
self._text_node: Optional[ba.Node] = None self._text_node: Optional[bs.Node] = None
self._profilename = '' self._profilename = ''
self._profilenames: List[str] = [] self._profilenames: List[str] = []
self._ready: bool = False 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._last_change: Sequence[Union[float, int]] = (0, 0)
self._profiles: Dict[str, Dict[str, Any]] = {} self._profiles: Dict[str, Dict[str, Any]] = {}
app = _ba.app app = babase.app
self.bakwas_chars = ["Lee", "Todd McBurton", "Zola", "Butch", "Witch", "warrior", self.bakwas_chars = ["Lee", "Todd McBurton", "Zola", "Butch", "Witch", "warrior",
"Middle-Man", "Alien", "OldLady", "Gladiator", "Wrestler", "Gretel", "Robot"] "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 # Load available player profiles either from the local config or
# from the remote device. # from the remote device.
self.reload_profiles() 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: if name not in self._character_names and name not in self.bakwas_chars:
self._character_names.append(name) self._character_names.append(name)
# Note: this is just our local index out of available teams; *not* # 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 # it. This will give a persistent character for them between games
# and will distribute characters nicely if everyone is random. # and will distribute characters nicely if everyone is random.
self._random_color, self._random_highlight = ( 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 # 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 # unlocked list and then locate that character's index in the full
# list. # list.
char_index_offset = app.lobby_random_char_index_offset char_index_offset = app.classic.lobby_random_char_index_offset
self._random_character_index = ( self._random_character_index = (
(sessionplayer.inputdevice.id + char_index_offset) % (sessionplayer.inputdevice.id + char_index_offset) %
len(self._character_names)) len(self._character_names))
@ -111,7 +112,7 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer,
self._profileindex = self._select_initial_profile() self._profileindex = self._select_initial_profile()
self._profilename = self._profilenames[self._profileindex] self._profilename = self._profilenames[self._profileindex]
self._text_node = _ba.newnode('text', self._text_node = bs.newnode('text',
delegate=self, delegate=self,
attrs={ attrs={
'position': (-100, self._vpos), 'position': (-100, self._vpos),
@ -122,8 +123,8 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer,
'v_align': 'center', 'v_align': 'center',
'v_attach': 'top' 'v_attach': 'top'
}) })
animate(self._text_node, 'scale', {0: 0, 0.1: 1.0}) bs.animate(self._text_node, 'scale', {0: 0, 0.1: 1.0})
self.icon = _ba.newnode('image', self.icon = bs.newnode('image',
owner=self._text_node, owner=self._text_node,
attrs={ attrs={
'position': (-130, self._vpos + 20), 'position': (-130, self._vpos + 20),
@ -132,7 +133,7 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer,
'attach': 'topCenter' '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 '<choosing player>' in case anyone asks. # Set our initial name to '<choosing player>' in case anyone asks.
self._sessionplayer.setname( self._sessionplayer.setname(
@ -154,39 +155,39 @@ def __init__(self, vpos: float, sessionplayer: _ba.SessionPlayer,
def _set_ready(self, ready: bool) -> None: def _set_ready(self, ready: bool) -> None:
# pylint: disable=cyclic-import # pylint: disable=cyclic-import
from bastd.ui.profile import browser as pbrowser from bauiv1lib.profile import browser as pbrowser
from ba._general import Call from babase._general import Call
profilename = self._profilenames[self._profileindex] profilename = self._profilenames[self._profileindex]
# Handle '_edit' as a special case. # Handle '_edit' as a special case.
if profilename == '_edit' and ready: if profilename == '_edit' and ready:
with _ba.Context('ui'): with _babase.Context('ui'):
pbrowser.ProfileBrowserWindow(in_main_menu=False) pbrowser.ProfileBrowserWindow(in_main_menu=False)
# Give their input-device UI ownership too # Give their input-device UI ownership too
# (prevent someone else from snatching it in crowded games) # (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 return
if ready == False: if ready == False:
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
InputType.LEFT_PRESS, babase.InputType.LEFT_PRESS,
Call(self.handlemessage, ChangeMessage('team', -1))) Call(self.handlemessage, ChangeMessage('team', -1)))
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
InputType.RIGHT_PRESS, babase.InputType.RIGHT_PRESS,
Call(self.handlemessage, ChangeMessage('team', 1))) Call(self.handlemessage, ChangeMessage('team', 1)))
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
InputType.BOMB_PRESS, babase.InputType.BOMB_PRESS,
Call(self.handlemessage, ChangeMessage('character', 1))) Call(self.handlemessage, ChangeMessage('character', 1)))
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
InputType.UP_PRESS, babase.InputType.UP_PRESS,
Call(self.handlemessage, ChangeMessage('profileindex', -1))) Call(self.handlemessage, ChangeMessage('profileindex', -1)))
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
InputType.DOWN_PRESS, babase.InputType.DOWN_PRESS,
Call(self.handlemessage, ChangeMessage('profileindex', 1))) Call(self.handlemessage, ChangeMessage('profileindex', 1)))
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
(InputType.JUMP_PRESS, InputType.PICK_UP_PRESS, (babase.InputType.JUMP_PRESS, babase.InputType.PICK_UP_PRESS,
InputType.PUNCH_PRESS), babase.InputType.PUNCH_PRESS),
Call(self.handlemessage, ChangeMessage('ready', 1))) Call(self.handlemessage, ChangeMessage('ready', 1)))
self._ready = False self._ready = False
self._update_text() self._update_text()
@ -194,26 +195,26 @@ def _set_ready(self, ready: bool) -> None:
elif ready == True: elif ready == True:
self.characterchooser = True self.characterchooser = True
self._sessionplayer.assigninput( self._sessionplayer.assigninput(
(InputType.LEFT_PRESS, InputType.RIGHT_PRESS, (babase.InputType.LEFT_PRESS, babase.InputType.RIGHT_PRESS,
InputType.UP_PRESS, InputType.DOWN_PRESS, babase.InputType.UP_PRESS, babase.InputType.DOWN_PRESS,
InputType.JUMP_PRESS, InputType.BOMB_PRESS, babase.InputType.JUMP_PRESS, babase.InputType.BOMB_PRESS,
InputType.PICK_UP_PRESS), self._do_nothing) babase.InputType.PICK_UP_PRESS), self._do_nothing)
self._sessionplayer.assigninput( 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( 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( 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( 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))) Call(self.handlemessage, ChangeMessage('ready', 2)))
# Store the last profile picked by this input for reuse. # Store the last profile picked by this input for reuse.
input_device = self._sessionplayer.inputdevice input_device = self._sessionplayer.inputdevice
name = input_device.name name = input_device.name
unique_id = input_device.unique_identifier unique_id = input_device.unique_identifier
device_profiles = _ba.app.config.setdefault( device_profiles = _babase.app.config.setdefault(
'Default Player Profiles', {}) 'Default Player Profiles', {})
# Make an exception if we have no custom profiles and are set # 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] del device_profiles[profilekey]
else: else:
device_profiles[profilekey] = profilename device_profiles[profilekey] = profilename
_ba.app.config.commit() _babase.app.config.commit()
# Set this player's short and full name. # Set this player's short and full name.
self._sessionplayer.setname(self._getname(), self._sessionplayer.setname(self._getname(),
@ -240,7 +241,7 @@ def _set_ready(self, ready: bool) -> None:
else: else:
# Inform the session that this player is ready. # Inform the session that this player is ready.
_ba.getsession().handlemessage(PlayerReadyMessage(self)) bs.getsession().handlemessage(PlayerReadyMessage(self))
def handlemessage(self, msg: Any) -> Any: def handlemessage(self, msg: Any) -> Any:
@ -258,7 +259,7 @@ def handlemessage(self, msg: Any) -> Any:
print_error('got ChangeMessage after nodes died') print_error('got ChangeMessage after nodes died')
return return
if msg.what == 'characterchooser': if msg.what == 'characterchooser':
_ba.playsound(self._click_sound) self._click_sound.play()
# update our index in our local list of characters # update our index in our local list of characters
self._character_index = ((self._character_index + msg.value) % self._character_index = ((self._character_index + msg.value) %
len(self._character_names)) len(self._character_names))
@ -268,7 +269,7 @@ def handlemessage(self, msg: Any) -> Any:
if msg.what == 'team': if msg.what == 'team':
sessionteams = self.lobby.sessionteams sessionteams = self.lobby.sessionteams
if len(sessionteams) > 1: if len(sessionteams) > 1:
_ba.playsound(self._swish_sound) self._swish_sound.play()
self._selected_team_index = ( self._selected_team_index = (
(self._selected_team_index + msg.value) % (self._selected_team_index + msg.value) %
len(sessionteams)) len(sessionteams))
@ -281,18 +282,18 @@ def handlemessage(self, msg: Any) -> Any:
# This should be pretty hard to hit now with # This should be pretty hard to hit now with
# automatic local accounts. # automatic local accounts.
_ba.playsound(_ba.getsound('error')) bui.getsound('error').play()
else: else:
# Pick the next player profile and assign our name # Pick the next player profile and assign our name
# and character based on that. # and character based on that.
_ba.playsound(self._deek_sound) self._deek_sound.play()
self._profileindex = ((self._profileindex + msg.value) % self._profileindex = ((self._profileindex + msg.value) %
len(self._profilenames)) len(self._profilenames))
self.update_from_profile() self.update_from_profile()
elif msg.what == 'character': elif msg.what == 'character':
_ba.playsound(self._click_sound) self._click_sound.play()
self.characterchooser = True self.characterchooser = True
# update our index in our local list of characters # update our index in our local list of characters
self._character_index = ((self._character_index + msg.value) % 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 can_switch_teams = len(self.lobby.sessionteams) > 1
# Flash as we're coming in. # 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: if not self._inited:
animate_array(self._text_node, 'color', 4, { bs.animate_array(self._text_node, 'color', 4, {
0.15: fin_color, 0.15: fin_color,
0.25: (2, 2, 2, 1), 0.25: (2, 2, 2, 1),
0.35: fin_color 0.35: fin_color
@ -338,7 +339,7 @@ def _update_text(self) -> None:
# Blend if we're in teams mode; switch instantly otherwise. # Blend if we're in teams mode; switch instantly otherwise.
if can_switch_teams: 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: self._text_node.color,
0.1: fin_color 0.1: fin_color
}) })
@ -350,7 +351,7 @@ def _update_text(self) -> None:
# ba_meta export plugin # ba_meta export plugin
class HeySmoothy(ba.Plugin): class HeySmoothy(babase.Plugin):
def __init__(self): def __init__(self):
_lobby.Chooser.__init__ = __init__ _lobby.Chooser.__init__ = __init__

View file

@ -1,50 +1,48 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# ba_meta require api 7 # ba_meta require api 8
# ===============================================
# EasyConnect by Mr.Smoothy |
# verion 1.2 |
# https://discord.gg/ucyaesh |
# Serverconnector X IPPORTRevealer |
# for bombsquad v1.7 + |
# ===============================================
''' ===========================================
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 # WATCH IN ACTION https://www.youtube.com/watch?v=jwi2wKwZblQ
# .................___________________________________________ # .................___________________________________________
# Have any idea/suggestion/bug report > send message on discord mr.smoothy#5824 # Have any idea/suggestion/bug report > send message on discord mr.smoothy#5824
# Download modshttps://bombsquad-community.web.app/mods
# Discord:- # Discord:-
# mr.smoothy#5824 # mr.smoothy#5824
# DONT EDIT ANYTHING WITHOUT PERMISSION # DONT EDIT ANYTHING WITHOUT PERMISSION
# join Bombspot - bombsquad biggest modding community .... open for everyone https://discord.gg/2RKd9QQdQY # join Bombsquad Community Server -
# join Bombsquad Consultancy Service - for more mods, modding help ------- for all modders and server owners
# https://discord.gg/2RKd9QQdQY
# https://discord.gg/ucyaesh # https://discord.gg/ucyaesh
# REQUIREMENTS # 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 _babase
import ba import babase
import bastd import bauiv1 as bui
import bascenev1 as bs
import threading import threading
from bastd.ui.gather import manualtab, publictab from bauiv1lib.gather import manualtab, publictab
from bastd.ui import popup from bauiv1lib import popup
from dataclasses import dataclass from dataclasses import dataclass
import random import random
from enum import Enum from enum import Enum
from bastd.ui.popup import PopupMenuWindow, PopupWindow from bauiv1lib.popup import PopupMenuWindow, PopupWindow
from typing import Any, Optional, Dict, List, Tuple, Type, Union, Callable from typing import Any, Optional, Callable
from bastd.ui.gather.publictab import PublicGatherTab from bauiv1lib.gather.publictab import PublicGatherTab
import json import json
import urllib.request import urllib.request
import time import time
@ -61,7 +59,7 @@ Report such case on community discord channels
https://discord.gg/ucyaesh https://discord.gg/ucyaesh
https://ballistica.net/discord https://ballistica.net/discord
""" """
BCSURL = 'https://bcsserver.bombsquad.ga/bannedservers' BCSURL = 'https://bcs.ballistica.workers.dev/bannedservers'
def is_game_version_lower_than(version): 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 version is lower than the passed version. Useful for addressing
any breaking changes within game versions. 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("."))) version = tuple(map(int, version.split(".")))
return game_version < version return game_version < version
if is_game_version_lower_than("1.7.7"):
ba_internal = _ba
else:
ba_internal = ba.internal
def updateBannedServersCache(): def updateBannedServersCache():
response = None response = None
config = ba.app.config config = babase.app.config
if not isinstance(config.get('Banned Servers'), list): if not isinstance(config.get('Banned Servers'), list):
config['Banned Servers'] = [] config['Banned Servers'] = []
try: 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')) data = json.loads(response.decode('utf-8'))
bannedlist = [] bannedlist = []
for server in data["servers"]: for server in data["servers"]:
@ -116,133 +111,133 @@ class _HostLookupThread(threading.Thread):
result = socket.gethostbyname(self._name) result = socket.gethostbyname(self._name)
except Exception: except Exception:
result = None result = None
ba.pushcall(lambda: self._call(result, self._port), babase.pushcall(lambda: self._call(result, self._port),
from_other_thread=True) 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 c_height = region_height - 20
v = c_height - 35 - 25 - 30 v = c_height - 35 - 25 - 30
self.retry_inter = 0.0 self.retry_inter = 0.0
uiscale = ba.app.ui.uiscale uiscale = bui.app.ui_v1.uiscale
self._width = 1240 if uiscale is ba.UIScale.SMALL else 1040 self._width = 1240 if uiscale is babase.UIScale.SMALL else 1040
x_inset = 100 if uiscale is ba.UIScale.SMALL else 0 x_inset = 100 if uiscale is babase.UIScale.SMALL else 0
self._height = (578 if uiscale is ba.UIScale.SMALL else self._height = (578 if uiscale is babase.UIScale.SMALL else
670 if uiscale is ba.UIScale.MEDIUM else 800) 670 if uiscale is babase.UIScale.MEDIUM else 800)
self._scroll_width = self._width - 130 + 2 * x_inset self._scroll_width = self._width - 130 + 2 * x_inset
self._scroll_height = self._height - 180 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 c_height = self._scroll_height - 20
sub_scroll_height = c_height - 63 sub_scroll_height = c_height - 63
self._favorites_scroll_width = sub_scroll_width = ( 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 v = c_height - 30
b_width = 140 if uiscale is ba.UIScale.SMALL else 178 b_width = 140 if uiscale is babase.UIScale.SMALL else 178
b_height = (90 if uiscale is ba.UIScale.SMALL else b_height = (90 if uiscale is babase.UIScale.SMALL else
142 if uiscale is ba.UIScale.MEDIUM else 130) 142 if uiscale is babase.UIScale.MEDIUM else 130)
b_space_extra = (0 if uiscale is ba.UIScale.SMALL else b_space_extra = (0 if uiscale is babase.UIScale.SMALL else
-2 if uiscale is ba.UIScale.MEDIUM else -5) -2 if uiscale is babase.UIScale.MEDIUM else -5)
btnv = (c_height - (48 if uiscale is ba.UIScale.SMALL else btnv = (c_height - (48 if uiscale is babase.UIScale.SMALL else
45 if uiscale is ba.UIScale.MEDIUM else 40) - 45 if uiscale is babase.UIScale.MEDIUM else 40) -
b_height) b_height)
# ================= smoothy ============= # ================= smoothy =============
ba.textwidget(parent=self._container, bui.textwidget(parent=self._container,
position=(90 if uiscale is ba.UIScale.SMALL else 120, btnv + position=(90 if uiscale is babase.UIScale.SMALL else 120, btnv +
120 if uiscale is ba.UIScale.SMALL else btnv+90), 120 if uiscale is babase.UIScale.SMALL else btnv+90),
size=(0, 0), size=(0, 0),
h_align='center', h_align='center',
color=(0.8, 0.8, 0.8), color=(0.8, 0.8, 0.8),
v_align='top', v_align='top',
text="Auto") 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), 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), btnv+10),
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
textcolor=(0.75, 0.7, 0.8), textcolor=(0.75, 0.7, 0.8),
on_activate_call=self.auto_retry_dec, 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="-", label="-",
autoselect=True) autoselect=True)
self.retry_inter_text = ba.textwidget(parent=self._container, self.retry_inter_text = bui.textwidget(parent=self._container,
position=( 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), size=(0, 0),
h_align='center', h_align='center',
color=(0.8, 0.8, 0.8), color=(0.8, 0.8, 0.8),
v_align='center', v_align='center',
text=str(self.retry_inter) if self.retry_inter > 0.0 else 'off') 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), 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), btnv+10),
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
textcolor=(0.75, 0.7, 0.8), textcolor=(0.75, 0.7, 0.8),
on_activate_call=self.auto_retry_inc, 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="+", label="+",
autoselect=True) autoselect=True)
btnv -= b_height + b_space_extra btnv -= b_height + b_space_extra
self._favorites_connect_button = btn1 = ba.buttonwidget( self._favorites_connect_button = btn1 = bui.buttonwidget(
parent=self._container, parent=self._container,
size=(b_width, b_height), 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', button_type='square',
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
textcolor=(0.75, 0.7, 0.8), textcolor=(0.75, 0.7, 0.8),
on_activate_call=self._on_favorites_connect_press, on_activate_call=self._on_favorites_connect_press,
text_scale=1.0 if uiscale is ba.UIScale.SMALL else 1.2, text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2,
label=ba.Lstr(resource='gatherWindow.manualConnectText'), label=babase.Lstr(resource='gatherWindow.manualConnectText'),
autoselect=True) autoselect=True)
if uiscale is ba.UIScale.SMALL and ba.app.ui.use_toolbars: if uiscale is babase.UIScale.SMALL and bui.app.ui_v1.use_toolbars:
ba.widget(edit=btn1, bui.widget(edit=btn1,
left_widget=ba_internal.get_special_widget('back_button')) left_widget=bui.get_special_widget('back_button'))
btnv -= b_height + b_space_extra btnv -= b_height + b_space_extra
ba.buttonwidget(parent=self._container, bui.buttonwidget(parent=self._container,
size=(b_width, b_height), 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), btnv),
button_type='square', button_type='square',
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
textcolor=(0.75, 0.7, 0.8), textcolor=(0.75, 0.7, 0.8),
on_activate_call=self._on_favorites_edit_press, on_activate_call=self._on_favorites_edit_press,
text_scale=1.0 if uiscale is ba.UIScale.SMALL else 1.2, text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2,
label=ba.Lstr(resource='editText'), label=babase.Lstr(resource='editText'),
autoselect=True) autoselect=True)
btnv -= b_height + b_space_extra btnv -= b_height + b_space_extra
ba.buttonwidget(parent=self._container, bui.buttonwidget(parent=self._container,
size=(b_width, b_height), 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), btnv),
button_type='square', button_type='square',
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
textcolor=(0.75, 0.7, 0.8), textcolor=(0.75, 0.7, 0.8),
on_activate_call=self._on_favorite_delete_press, on_activate_call=self._on_favorite_delete_press,
text_scale=1.0 if uiscale is ba.UIScale.SMALL else 1.2, text_scale=1.0 if uiscale is babase.UIScale.SMALL else 1.2,
label=ba.Lstr(resource='deleteText'), label=babase.Lstr(resource='deleteText'),
autoselect=True) autoselect=True)
v -= sub_scroll_height + 23 v -= sub_scroll_height + 23
self._scrollwidget = scrlw = ba.scrollwidget( self._scrollwidget = scrlw = bui.scrollwidget(
parent=self._container, 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), size=(sub_scroll_width, sub_scroll_height),
claims_left_right=True) claims_left_right=True)
ba.widget(edit=self._favorites_connect_button, bui.widget(edit=self._favorites_connect_button,
right_widget=self._scrollwidget) right_widget=self._scrollwidget)
self._columnwidget = ba.columnwidget(parent=scrlw, self._columnwidget = bui.columnwidget(parent=scrlw,
left_border=10, left_border=10,
border=2, border=2,
margin=0, margin=0,
@ -257,22 +252,22 @@ def new_on_favorites_connect_press(self) -> None:
self._no_favorite_selected_error() self._no_favorite_selected_error()
else: else:
config = ba.app.config['Saved Servers'][self._favorite_selected] config = babase.app.config['Saved Servers'][self._favorite_selected]
_HostLookupThread(name=config['addr'], _HostLookupThread(name=config['addr'],
port=config['port'], port=config['port'],
call=ba.WeakCall( call=bs.WeakCall(
self._host_lookup_result)).start() 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): if self.retry_inter > 0 and (bs.get_connection_to_host_info() == {} or bs.get_connection_to_host_info()['build_number'] == 0):
ba.screenmessage("Server full or unreachable, Retrying....") bui.screenmessage("Server full or unreachable, Retrying....")
self._retry_timer = ba.Timer(self.retry_inter, ba.Call( self._retry_timer = bs.AppTimer(self.retry_inter, babase.Call(
self._on_favorites_connect_press), timetype=ba.TimeType.REAL) self._on_favorites_connect_press))
def auto_retry_inc(self): def auto_retry_inc(self):
self.retry_inter += 0.5 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): def auto_retry_dec(self):
@ -280,9 +275,9 @@ def auto_retry_dec(self):
self.retry_inter -= 0.5 self.retry_inter -= 0.5
if self.retry_inter == 0.0: 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: 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 @dataclass
@ -328,121 +323,142 @@ def _clear(self) -> None:
self._stats_button self._stats_button
]: ]:
if widget: if widget:
try:
widget.delete() widget.delete()
except:
pass
def update(self, index: int, party: PartyEntry, sub_scroll_width: float, def update(self, index: int, party: PartyEntry, sub_scroll_width: float,
sub_scroll_height: float, lineheight: float, sub_scroll_height: float, lineheight: float,
columnwidget: ba.Widget, join_text: ba.Widget, columnwidget: bui.Widget, join_text: bui.Widget,
filter_text: ba.Widget, existing_selection: Optional[Selection], filter_text: bui.Widget, existing_selection: Optional[Selection],
tab: PublicGatherTab) -> None: tab: PublicGatherTab) -> None:
"""Update for the given data.""" """Update for the given data."""
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
# Quick-out: if we've been marked clean for a certain index and # Quick-out: if we've been marked clean for a certain index and
# we're still at that index, we're done. # we're still at that index, we're done.
if party.clean_display_index == index: plus = bui.app.plus
return assert plus is not None
ping_good = ba_internal.get_v1_account_misc_read_val('pingGood', 100) # Quick-out: if we've been marked clean for a certain index and
ping_med = ba_internal.get_v1_account_misc_read_val('pingMed', 500) # we're still at that index, we're done.
if party.clean_display_index == index:
return
self._clear() ping_good = plus.get_v1_account_misc_read_val('pingGood', 100)
hpos = 20 ping_med = plus.get_v1_account_misc_read_val('pingMed', 500)
vpos = sub_scroll_height - lineheight * index - 50
self._name_widget = ba.textwidget( self._clear()
text=ba.Lstr(value=party.name), hpos = 20
parent=columnwidget, vpos = sub_scroll_height - lineheight * index - 50
size=(sub_scroll_width * 0.63, 20), self._name_widget = bui.textwidget(
position=(0 + hpos, 4 + vpos), text=bui.Lstr(value=party.name),
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='....',
parent=columnwidget, parent=columnwidget,
autoselect=True, size=(sub_scroll_width * 0.63, 20),
position=(0 + hpos, 4 + vpos),
on_select_call=ba.WeakCall( selectable=True,
on_select_call=bui.WeakCall(
tab.set_public_party_selection, tab.set_public_party_selection,
Selection(party.get_key(), Selection(party.get_key(), SelectionComponent.NAME),
SelectionComponent.STATS_BUTTON)), ),
size=(100, 40), on_activate_call=bui.WeakCall(tab.on_public_party_activate, party),
position=(sub_scroll_width * 0.66 + hpos, 1 + vpos), click_activate=True,
scale=0.9) maxwidth=sub_scroll_width * 0.45,
ba.buttonwidget(edit=self._stats_button, on_activate_call=ba.Call( corner_scale=1.4,
self.on_stats_click, self._stats_button, party)) 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( if existing_selection == Selection(
party.get_key(), SelectionComponent.STATS_BUTTON): party.get_key(), SelectionComponent.NAME
ba.containerwidget(edit=columnwidget, ):
selected_child=self._stats_button) 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( self._size_widget = bui.textwidget(
text=str(party.size) + '/' + str(party.size_max), text=str(party.size) + '/' + str(party.size_max),
parent=columnwidget, parent=columnwidget,
size=(0, 0), size=(0, 0),
position=(sub_scroll_width * 0.86 + hpos, 20 + vpos), position=(sub_scroll_width * 0.86 + hpos, 20 + vpos),
scale=0.7, scale=0.7,
color=(0.8, 0.8, 0.8), color=(0.8, 0.8, 0.8),
h_align='right', h_align='right',
v_align='center') v_align='center',
)
if index == 0: if index == 0:
ba.widget(edit=self._name_widget, up_widget=filter_text) bui.widget(edit=self._name_widget, up_widget=filter_text)
if self._stats_button: if self._stats_button:
ba.widget(edit=self._stats_button, up_widget=filter_text) bui.widget(edit=self._stats_button, up_widget=filter_text)
self._ping_widget = ba.textwidget(parent=columnwidget, self._ping_widget = bui.textwidget(
size=(0, 0), parent=columnwidget,
position=(sub_scroll_width * 0.94 + size=(0, 0),
hpos, 20 + vpos), position=(sub_scroll_width * 0.94 + hpos, 20 + vpos),
scale=0.7, scale=0.7,
h_align='right', h_align='right',
v_align='center') v_align='center',
if party.ping is None: )
ba.textwidget(edit=self._ping_widget, if party.ping is None:
text='-', bui.textwidget(
color=(0.5, 0.5, 0.5)) edit=self._ping_widget, text='-', color=(0.5, 0.5, 0.5)
else: )
ba.textwidget(edit=self._ping_widget, else:
text=str(int(party.ping)), bui.textwidget(
color=(0, 1, 0) if party.ping <= ping_good else edit=self._ping_widget,
(1, 1, 0) if party.ping <= ping_med else (1, 0, 0)) text=str(int(party.ping)),
color=(0, 1, 0)
party.clean_display_index = index 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: def _get_popup_window_scale() -> float:
uiscale = ba.app.ui.uiscale uiscale = bui.app.ui_v1.uiscale
return (2.3 if uiscale is ba.UIScale.SMALL else return (2.3 if uiscale is babase.UIScale.SMALL else
1.65 if uiscale is ba.UIScale.MEDIUM else 1.23) 1.65 if uiscale is babase.UIScale.MEDIUM else 1.23)
_party = None _party = None
@ -452,8 +468,8 @@ def on_stats_click(self, widget, party):
global _party global _party
_party = party _party = party
choices = ['connect', 'copyqueue', "save"] choices = ['connect', 'copyqueue', "save"]
DisChoices = [ba.Lstr(resource="ipp", fallback_value="Connect by IP"), ba.Lstr( DisChoices = [babase.Lstr(resource="ipp", fallback_value="Connect by IP"), babase.Lstr(
resource="copy id", fallback_value="Copy Queue ID"), ba.Lstr(value="Save")] resource="copy id", fallback_value="Copy Queue ID"), babase.Lstr(value="Save")]
if party.stats_addr: if party.stats_addr:
choices.append('stats') choices.append('stats')
if 'discord' in party.stats_addr: if 'discord' in party.stats_addr:
@ -462,7 +478,7 @@ def on_stats_click(self, widget, party):
txt = "Youtube" txt = "Youtube"
else: else:
txt = party.stats_addr[0:13] txt = party.stats_addr[0:13]
DisChoices.append(ba.Lstr(value=txt)) DisChoices.append(babase.Lstr(value=txt))
PopupMenuWindow( PopupMenuWindow(
position=widget.get_screen_space_center(), position=widget.get_screen_space_center(),
scale=_get_popup_window_scale(), scale=_get_popup_window_scale(),
@ -480,17 +496,17 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu,
choice: str) -> None: choice: str) -> None:
"""Called when a menu entry is selected.""" """Called when a menu entry is selected."""
# Unused arg. # Unused arg.
plus = babase.app.plus
if choice == 'stats': if choice == 'stats':
url = _party.stats_addr.replace( url = _party.stats_addr.replace(
'${ACCOUNT}', '${ACCOUNT}',
ba_internal.get_v1_account_misc_read_val_2('resolvedAccountID', plus.get_v1_account_misc_read_val_2('resolvedAccountID',
'UNKNOWN')) 'UNKNOWN'))
ba.open_url(url) bui.open_url(url)
elif choice == 'connect': elif choice == 'connect':
PartyQuickConnect(_party.address, _party.port) PartyQuickConnect(_party.address, _party.port)
elif choice == 'save': elif choice == 'save':
config = ba.app.config config = babase.app.config
ip_add = _party.address ip_add = _party.address
p_port = _party.port p_port = _party.port
title = _party.name title = _party.name
@ -502,18 +518,19 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu,
'name': title 'name': title
} }
config.commit() config.commit()
ba.screenmessage("Server saved to manual") bui.screenmessage("Server saved to manual")
ba.playsound(ba.getsound('gunCocking')) bui.getsound('gunCocking').play()
elif choice == "copyqueue": elif choice == "copyqueue":
ba.clipboard_set_text(_party.queue) babase.clipboard_set_text(_party.queue)
ba.playsound(ba.getsound('gunCocking')) bui.getsound('gunCocking').play()
def _update_party_lists(self) -> None: def _update_party_lists(self) -> None:
if not self._party_lists_dirty: if not self._party_lists_dirty:
return return
starttime = time.time() starttime = time.time()
config = ba.app.config config = babase.app.config
plus = babase.app.plus
bannedservers = config.get('Banned Servers', []) bannedservers = config.get('Banned Servers', [])
assert len(self._parties_sorted) == len(self._parties) 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 signed out or errored, show no parties.
if ( if (
ba.internal.get_v1_account_state() != 'signed_in' plus.get_v1_account_state() != 'signed_in'
or not self._have_valid_server_list or not self._have_valid_server_list
): ):
self._parties_displayed = {} self._parties_displayed = {}
@ -568,7 +585,7 @@ def _update_party_lists(self) -> None:
def replace(): 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._on_favorites_connect_press = new_on_favorites_connect_press
manualtab.ManualGatherTab.auto_retry_dec = auto_retry_dec manualtab.ManualGatherTab.auto_retry_dec = auto_retry_dec
manualtab.ManualGatherTab.auto_retry_inc = auto_retry_inc manualtab.ManualGatherTab.auto_retry_inc = auto_retry_inc
@ -577,26 +594,26 @@ def replace():
publictab.UIRow.on_stats_click = on_stats_click publictab.UIRow.on_stats_click = on_stats_click
publictab.UIRow.popup_menu_closing = popup_menu_closing publictab.UIRow.popup_menu_closing = popup_menu_closing
publictab.UIRow.popup_menu_selected_choice = popup_menu_selected_choice 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): def __init__(self, address: str, port: int):
self._width = 800 self._width = 800
self._height = 400 self._height = 400
self._white_tex = ba.gettexture('white') self._white_tex = bui.gettexture('white')
self.lineup_tex = ba.gettexture('playerLineup') self.lineup_tex = bui.gettexture('playerLineup')
self.lineup_1_transparent_model = ba.getmodel( self.lineup_1_transparent_mesh = bui.getmesh(
'playerLineup1Transparent') 'playerLineup1Transparent')
self.eyes_model = ba.getmodel('plasticEyesTransparent') self.eyes_mesh = bui.getmesh('plasticEyesTransparent')
uiscale = ba.app.ui.uiscale uiscale = bui.app.ui_v1.uiscale
super().__init__(root_widget=ba.containerwidget( super().__init__(root_widget=bui.containerwidget(
size=(self._width, self._height), size=(self._width, self._height),
color=(0.45, 0.63, 0.15), color=(0.45, 0.63, 0.15),
transition='in_scale', transition='in_scale',
scale=(1.4 if uiscale is ba.UIScale.SMALL else scale=(1.4 if uiscale is babase.UIScale.SMALL else
1.2 if uiscale is ba.UIScale.MEDIUM else 1.0))) 1.2 if uiscale is babase.UIScale.MEDIUM else 1.0)))
self._cancel_button = ba.buttonwidget(parent=self._root_widget, self._cancel_button = bui.buttonwidget(parent=self._root_widget,
scale=1.0, scale=1.0,
position=(60, self._height - 80), position=(60, self._height - 80),
size=(50, 50), size=(50, 50),
@ -604,12 +621,12 @@ class PartyQuickConnect(ba.Window):
on_activate_call=self.close, on_activate_call=self.close,
autoselect=True, autoselect=True,
color=(0.45, 0.63, 0.15), color=(0.45, 0.63, 0.15),
icon=ba.gettexture('crossOut'), icon=bui.gettexture('crossOut'),
iconscale=1.2) iconscale=1.2)
ba.containerwidget(edit=self._root_widget, bui.containerwidget(edit=self._root_widget,
cancel_button=self._cancel_button) cancel_button=self._cancel_button)
self.IP = ba.textwidget( self.IP = bui.textwidget(
parent=self._root_widget, parent=self._root_widget,
position=(self._width * 0.5, self._height * 0.55 + 60), position=(self._width * 0.5, self._height * 0.55 + 60),
size=(0, 0), size=(0, 0),
@ -619,7 +636,7 @@ class PartyQuickConnect(ba.Window):
v_align='center', v_align='center',
text="IP: "+address + " PORT: "+str(port), text="IP: "+address + " PORT: "+str(port),
maxwidth=self._width * 0.65) maxwidth=self._width * 0.65)
self._title_text = ba.textwidget( self._title_text = bui.textwidget(
parent=self._root_widget, parent=self._root_widget,
position=(self._width * 0.5, self._height * 0.55), position=(self._width * 0.5, self._height * 0.55),
size=(0, 0), size=(0, 0),
@ -629,7 +646,7 @@ class PartyQuickConnect(ba.Window):
v_align='center', v_align='center',
text="Retrying....", text="Retrying....",
maxwidth=self._width * 0.65) maxwidth=self._width * 0.65)
self._line_image = ba.imagewidget( self._line_image = bui.imagewidget(
parent=self._root_widget, parent=self._root_widget,
color=(0.0, 0.0, 0.0), color=(0.0, 0.0, 0.0),
opacity=0.2, opacity=0.2,
@ -637,39 +654,38 @@ class PartyQuickConnect(ba.Window):
size=(800-190+80, 4.0), size=(800-190+80, 4.0),
texture=self._white_tex) texture=self._white_tex)
self.dude_x = 60 self.dude_x = 60
self._body_image_target = ba.buttonwidget( self._body_image_target = bui.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
size=(1 * 60, 1 * 80), size=(1 * 60, 1 * 80),
color=(random.random(), random.random(), random.random()), color=(random.random(), random.random(), random.random()),
label='', label='',
texture=self.lineup_tex, texture=self.lineup_tex,
position=(40, 110), position=(40, 110),
model_transparent=self.lineup_1_transparent_model) mesh_transparent=self.lineup_1_transparent_mesh)
self._eyes_image = ba.imagewidget( self._eyes_image = bui.imagewidget(
parent=self._root_widget, parent=self._root_widget,
size=(1 * 36, 1 * 18), size=(1 * 36, 1 * 18),
texture=self.lineup_tex, texture=self.lineup_tex,
color=(1, 1, 1), color=(1, 1, 1),
position=(40, 165), position=(40, 165),
model_transparent=self.eyes_model) mesh_transparent=self.eyes_mesh)
# self._body_image_target2 = ba.imagewidget( # self._body_image_target2 = bui.imagewidget(
# parent=self._root_widget, # parent=self._root_widget,
# size=(1* 60, 1 * 80), # size=(1* 60, 1 * 80),
# color=(1,0.3,0.4), # color=(1,0.3,0.4),
# texture=self.lineup_tex, # texture=self.lineup_tex,
# position=(700,130), # position=(700,130),
# model_transparent=self.lineup_1_transparent_model) # mesh_transparent=self.lineup_1_transparent_mesh)
self.closed = False self.closed = False
self.retry_count = 1 self.retry_count = 1
self.direction = "right" self.direction = "right"
self.connect(address, port) self.connect(address, port)
self.move_R = ba.Timer(0.01, ba.Call(self.move_right), self.move_R = bs.AppTimer(0.01, babase.Call(self.move_right), repeat=True)
timetype=ba.TimeType.REAL, repeat=True)
def move_right(self): def move_right(self):
if self._body_image_target and self._eyes_image: if self._body_image_target and self._eyes_image:
ba.buttonwidget(edit=self._body_image_target, position=(self.dude_x, 110)) bui.buttonwidget(edit=self._body_image_target, position=(self.dude_x, 110))
ba.imagewidget(edit=self._eyes_image, position=(self.dude_x+10, 165)) bui.imagewidget(edit=self._eyes_image, position=(self.dude_x+10, 165))
else: else:
self.move_R = None self.move_R = None
if self.direction == "right": if self.direction == "right":
@ -682,23 +698,23 @@ class PartyQuickConnect(ba.Window):
self.direction = "right" self.direction = "right"
def connect(self, address, port): 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): if not self.closed and (bs.get_connection_to_host_info() == {} or bs.get_connection_to_host_info()['build_number'] == 0):
ba.textwidget(edit=self._title_text, text="Retrying....("+str(self.retry_count)+")") bui.textwidget(edit=self._title_text, text="Retrying....("+str(self.retry_count)+")")
self.retry_count += 1 self.retry_count += 1
ba_internal.connect_to_party(address, port=port) bs.connect_to_party(address, port=port)
self._retry_timer = ba.Timer(1.5, ba.Call( self._retry_timer = bs.AppTimer(1.5, babase.Call(
self.connect, address, port), timetype=ba.TimeType.REAL) self.connect, address, port))
def close(self) -> None: def close(self) -> None:
"""Close the ui.""" """Close the ui."""
self.closed = True 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 # ba_meta export plugin
class InitalRun(ba.Plugin): class InitalRun(babase.Plugin):
def __init__(self): def __init__(self):
replace() replace()
config = ba.app.config config = babase.app.config
if config["launchCount"] % 5 == 0: if config["launchCount"] % 5 == 0:
updateBannedServersCache() updateBannedServersCache()