diff --git a/plugins/maps/forest.py b/plugins/maps/forest.py index d5c4d1d..c9f04be 100644 --- a/plugins/maps/forest.py +++ b/plugins/maps/forest.py @@ -1,12 +1,15 @@ +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) -# ba_meta require api 7 +# ba_meta require api 8 from __future__ import annotations from typing import TYPE_CHECKING -import ba -from ba import _map -from bastd.gameutils import SharedObjects -from bastd.maps import * +import babase +import bauiv1 as bui +import bascenev1 as bs +from bascenev1 import _map +from bascenev1lib.gameutils import SharedObjects +from bascenev1lib.maps import * if TYPE_CHECKING: pass @@ -48,7 +51,7 @@ class ForestMapData(): points['spawn2'] = (5.0, -2.0, -2.0) + (0.5, 1.0, 3.2) -class ForestMap(ba.Map): +class ForestMap(bs.Map): defs = ForestMapData() name = 'Forest' @@ -64,11 +67,11 @@ class ForestMap(ba.Map): @classmethod def on_preload(cls) -> any: data: dict[str, any] = { - 'model': ba.getmodel('natureBackground'), - 'tex': ba.gettexture('natureBackgroundColor'), - 'collide_model': ba.getcollidemodel('natureBackgroundCollide'), - 'bgmodel': ba.getmodel('thePadBG'), - 'bgtex': ba.gettexture('menuBG') + 'mesh': bs.getmesh('natureBackground'), + 'tex': bui.gettexture('natureBackgroundColor'), + 'collision_mesh': bs.getcollisionmesh('natureBackgroundCollide'), + 'bgmesh': bs.getmesh('thePadBG'), + 'bgtex': bui.gettexture('menuBG') } return data @@ -76,27 +79,27 @@ class ForestMap(ba.Map): super().__init__() shared = SharedObjects.get() - self.node = ba.newnode( + self.node = bs.newnode( 'terrain', delegate=self, attrs={ - 'model': self.preloaddata['model'], + 'mesh': self.preloaddata['mesh'], 'color_texture': self.preloaddata['tex'], - 'collide_model': self.preloaddata['collide_model'], + 'collide_mesh': self.preloaddata['collide_mesh'], 'materials': [shared.footing_material] } ) - self.background = ba.newnode( + self.background = bs.newnode( 'terrain', attrs={ - 'model': self.preloaddata['bgmodel'], + 'mesh': self.preloaddata['bgmesh'], 'lighting': False, 'shadow': True, 'color_texture': self.preloaddata['bgtex'] } ) - gnode = ba.getactivity().globalsnode + gnode = bs.getactivity().globalsnode gnode.tint = (1.0, 1.10, 1.15) gnode.ambient_color = (0.9, 1.3, 1.1) gnode.shadow_ortho = False @@ -104,7 +107,7 @@ class ForestMap(ba.Map): gnode.vignette_inner = (0.95, 0.95, 0.99) def is_point_near_edge(self, - point: ba.Vec3, + point: babase.Vec3, running: bool = False) -> bool: xpos = point.x zpos = point.z @@ -117,5 +120,5 @@ class ForestMap(ba.Map): # ba_meta export plugin -class EnableMe(ba.Plugin): +class EnableMe(babase.Plugin): _map.register_map(ForestMap) diff --git a/plugins/utilities.json b/plugins/utilities.json index 866a659..433adf4 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -19,6 +19,7 @@ } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "2454845", @@ -106,6 +107,7 @@ } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "2fda676", @@ -125,6 +127,7 @@ } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "2fda676", @@ -163,6 +166,7 @@ } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "fed7c24", @@ -187,6 +191,7 @@ } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "2fda676", @@ -206,6 +211,7 @@ } ], "versions": { + "1.2.3": null, "1.2.2": { "api_version": 7, "commit_sha": "7753b87", @@ -239,7 +245,7 @@ { "name": "Rikko", "email": "rikkolovescats@proton.me", - "discord": "Rikko#7383" + "discord": "rikkolovescats" }, { "name": "Vishal", @@ -299,7 +305,7 @@ { "name": "Rikko", "email": "rikkolovescats@proton.me", - "discord": "Rikko#7383" + "discord": "rikkolovescats" } ], "versions": { @@ -470,6 +476,7 @@ } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "6acdea8", @@ -669,6 +676,7 @@ } ], "versions": { + "4.0.1": null, "4.0.0": { "api_version": 7, "commit_sha": "a23e8cd", @@ -684,10 +692,11 @@ { "name": "TheMikirog", "email": "", - "discord": "TheMikirog#1984" + "discord": "themikirog" } ], "versions": { + "3.0.1": null, "3.0.0": { "api_version": 7, "commit_sha": "0841b9e", @@ -703,10 +712,11 @@ { "name": "TheMikirog", "email": "", - "discord": "TheMikirog#1984" + "discord": "themikirog" } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "0841b9e", @@ -722,10 +732,11 @@ { "name": "TheMikirog", "email": "", - "discord": "TheMikirog#1984" + "discord": "themikirog" } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "0841b9e", @@ -741,10 +752,11 @@ { "name": "Cross Joy", "email": "cross.joy.official@gmail.com", - "discord": "Cross Joy#0721" + "discord": "crossjoy" } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "800125c", @@ -760,7 +772,7 @@ { "name": "Cross Joy", "email": "cross.joy.official@gmail.com", - "discord": "Cross Joy#0721" + "discord": "crossjoy" } ], "versions": { @@ -809,10 +821,11 @@ { "name": "TheMikirog", "email": "", - "discord": "TheMikirog#1984" + "discord": "themikirog" } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "cb2d952", @@ -828,10 +841,11 @@ { "name": "TheMikirog", "email": "", - "discord": "TheMikirog#1984" + "discord": "themikirog" } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "05ffa9f", @@ -847,10 +861,11 @@ { "name": "Rikko", "email": "rikkolovescats@proton.me", - "discord": "Rikko#7383" + "discord": "rikkolovescats" } ], "versions": { + "1.0.1": null, "1.0.0": { "api_version": 7, "commit_sha": "3221b3a", diff --git a/plugins/utilities/allow_invisible_models.py b/plugins/utilities/allow_invisible_models.py index b2d1403..4f33761 100644 --- a/plugins/utilities/allow_invisible_models.py +++ b/plugins/utilities/allow_invisible_models.py @@ -1,15 +1,17 @@ -# ba_meta require api 7 -import ba +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 +import babase +import bascenev1 as bs -original_getmodel = ba.getmodel +original_getmesh = bs.getmesh -def get_model_gracefully(model): - if model is not None: - return original_getmodel(model) +def get_mesh_gracefully(mesh): + if mesh is not None: + return original_getmesh(mesh) # ba_meta export plugin -class Main(ba.Plugin): +class Main(babase.Plugin): def on_app_running(self): - ba.getmodel = get_model_gracefully + bs.getmesh = get_mesh_gracefully diff --git a/plugins/utilities/auto_stunt.py b/plugins/utilities/auto_stunt.py index 0b4ca11..8566821 100644 --- a/plugins/utilities/auto_stunt.py +++ b/plugins/utilities/auto_stunt.py @@ -1,22 +1,25 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 # AutoStunt mod by - Mr.Smoothy x Rikko # https://discord.gg/ucyaesh -# https://bombsquad.ga +# https://bombsquad-community.web.app/home # Dont modify redistribute this plugin , if want to use features of this plugin in your mod write logic in seprate file # and import this as module. # If want to contribute in this original module, raise PR on github https://github.com/bombsquad-community/plugin-manager -import ba -import _ba -import bastd -from bastd.actor.text import Text -from bastd.actor.image import Image -from bastd.actor import spaz -from bastd.actor import playerspaz -from bastd.gameutils import SharedObjects -from bastd.actor.powerupbox import PowerupBoxFactory -from bastd.actor.spazfactory import SpazFactory -from bastd.game.elimination import EliminationGame +import babase +import bauiv1 as bui +import bascenev1 as bs +import _babase +import bascenev1lib +from bascenev1lib.actor.text import Text +from bascenev1lib.actor.image import Image +from bascenev1lib.actor import spaz +from bascenev1lib.actor import playerspaz +from bascenev1lib.gameutils import SharedObjects +from bascenev1lib.actor.powerupbox import PowerupBoxFactory +from bascenev1lib.actor.spazfactory import SpazFactory +from bascenev1lib.game.elimination import EliminationGame import math import json import os @@ -26,12 +29,12 @@ from typing import Optional CONTROLS_CENTER = (0, 0) CONTROLS_SCALE = 1 -BASE_STUNTS_DIRECTORY = os.path.join(_ba.env()["python_directory_user"], "CustomStunts") +BASE_STUNTS_DIRECTORY = os.path.join(_babase.env()["python_directory_user"], "CustomStunts") PLAYERS_STUNT_INFO = {} STUNT_CACHE = {} -original_on_begin = ba._activity.Activity.on_begin -original_chatmessage = _ba.chatmessage +original_on_begin = bs._activity.Activity.on_begin +original_chatmessage = bs.chatmessage class ControlsUI: @@ -105,7 +108,7 @@ CONTROLS_UI_MAP = { } -class NewSpaz(bastd.actor.spaz.Spaz): +class NewSpaz(bascenev1lib.actor.spaz.Spaz): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.move_map = { @@ -125,7 +128,7 @@ class NewSpaz(bastd.actor.spaz.Spaz): } -class NewPlayerSpaz(bastd.actor.playerspaz.PlayerSpaz): +class NewPlayerSpaz(bascenev1lib.actor.playerspaz.PlayerSpaz): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.move_map = { @@ -150,7 +153,7 @@ class NewPlayerSpaz(bastd.actor.playerspaz.PlayerSpaz): def _handle_action(self, action, value: Optional[float] = None) -> None: if self.source_player.sessionplayer in PLAYERS_STUNT_INFO: PLAYERS_STUNT_INFO[self.source_player.sessionplayer].append({ - "time": ba.time() - self.source_player.recording_start_time, + "time": bs.time() - self.source_player.recording_start_time, "move": { "action": action, "value": value, @@ -230,11 +233,11 @@ def handle_player_replay_end(player): def get_player_from_client_id(client_id, activity=None): - activity = activity or _ba.get_foreground_host_activity() + activity = activity or bs.get_foreground_host_activity() for player in activity.players: if player.sessionplayer.inputdevice.client_id == client_id: return player - raise ba.SessionPlayerNotFound() + raise bs.SessionPlayerNotFound() def mirror(clieid): @@ -243,8 +246,8 @@ def mirror(clieid): def capture(player): - with ba.Context(player.actor._activity()): - player.recording_start_time = ba.time() + with babase.ContextRef(player.actor._activity()): + player.recording_start_time = bs.time() PLAYERS_STUNT_INFO[player.sessionplayer] = [] @@ -266,33 +269,33 @@ def replay(player, stunt_name): stunt = json.load(fin) STUNT_CACHE[stunt_name] = stunt except: - ba.screenmessage(f"{stunt_name} doesn't exists") + bui.screenmessage(f"{stunt_name} doesn't exists") return player.in_replay = True - with ba.Context(player.actor._activity()): + with babase.ContextRef(player.actor._activity()): ControlsUI.display(player.actor._activity()) for move in stunt: value = move["move"]["value"] if value is None: - ba.timer( + bs.timer( move["time"], - ba.Call(player.actor.move_map[move["move"]["action"]]) + babase.Call(player.actor.move_map[move["move"]["action"]]) ) else: - ba.timer( + bs.timer( move["time"], - ba.Call(player.actor.move_map[move["move"]["action"]], move["move"]["value"]) + babase.Call(player.actor.move_map[move["move"]["action"]], move["move"]["value"]) ) last_move_time = move["time"] time_to_hide_controls = last_move_time + 1 - ba.timer(time_to_hide_controls, ba.Call(handle_player_replay_end, player)) + bs.timer(time_to_hide_controls, babase.Call(handle_player_replay_end, player)) def spawn_mirror_spaz(player): player.mirror_mode = True - with ba.Context(player.actor._activity()): + with babase.ContextRef(player.actor._activity()): bot = spaz.Spaz(player.color, player.highlight, character=player.character).autoretain() - bot.handlemessage(ba.StandMessage( + bot.handlemessage(bs.StandMessage( (player.actor.node.position[0], player.actor.node.position[1], player.actor.node.position[2]+1), 93)) bot.node.name = player.actor.node.name bot.node.name_color = player.actor.node.name_color @@ -309,51 +312,51 @@ def ghost(player, stunt_name): stunt = json.load(fin) STUNT_CACHE[stunt_name] = stunt except: - ba.screenmessage(f"{stunt_name} doesn't exists") + bui.screenmessage(f"{stunt_name} doesn't exists") return player.in_replay = True - with ba.Context(player.actor._activity()): + with babase.ContextRef(player.actor._activity()): bot = spaz.Spaz((1, 0, 0), character="Spaz").autoretain() - bot.handlemessage(ba.StandMessage(player.actor.node.position, 93)) + bot.handlemessage(bs.StandMessage(player.actor.node.position, 93)) give_ghost_power(bot) ControlsUI.display(player.actor._activity()) for move in stunt: value = move["move"]["value"] if value is None: - ba.timer( + bs.timer( move["time"], - ba.Call(bot.move_map[move["move"]["action"]]) + babase.Call(bot.move_map[move["move"]["action"]]) ) ui_activation = CONTROLS_UI_MAP.get(move["move"]["action"]) if ui_activation: - ba.timer( + bs.timer( move["time"], - ba.Call(ui_activation, player.actor._activity()) + babase.Call(ui_activation, player.actor._activity()) ) else: - ba.timer( + bs.timer( move["time"], - ba.Call(bot.move_map[move["move"]["action"]], move["move"]["value"]) + babase.Call(bot.move_map[move["move"]["action"]], move["move"]["value"]) ) ui_activation = CONTROLS_UI_MAP.get(move["move"]["action"]) if ui_activation: - ba.timer( + bs.timer( move["time"], - ba.Call(ui_activation, player.actor._activity(), move["move"]["value"]) + babase.Call(ui_activation, player.actor._activity(), move["move"]["value"]) ) last_move_time = move["time"] time_to_hide_controls = last_move_time + 1 - ba.timer(time_to_hide_controls, ba.Call(handle_player_replay_end, player)) - ba.timer(time_to_hide_controls, ba.Call(bot.node.delete)) + bs.timer(time_to_hide_controls, babase.Call(handle_player_replay_end, player)) + bs.timer(time_to_hide_controls, babase.Call(bot.node.delete)) def give_ghost_power(spaz): spaz.node.invincible = True shared = SharedObjects.get() factory = SpazFactory.get() - ghost = ba.Material() + ghost = bs.Material() # smoothy hecks ghost.add_actions( conditions=(('they_have_material', factory.spaz_material), 'or', @@ -397,7 +400,7 @@ def new_chatmessage(msg): if command == "start": capture(player) - _ba.chatmessage("Recording started for {}.".format( + bs.chatmessage("Recording started for {}.".format( player.getname(), )) return original_chatmessage(msg) @@ -406,28 +409,28 @@ def new_chatmessage(msg): if command == "save": if len(msg_splits) < 2: - ba.screenmessage("Enter name of stunt eg : *save bombjump") + bui.screenmessage("Enter name of stunt eg : *save bombjump") return original_chatmessage(msg) save(player, stunt_name) - _ba.chatmessage('Recording "{}" by {} saved.'.format( + bs.chatmessage('Recording "{}" by {} saved.'.format( stunt_name, player.getname(), )) elif command == "stunt": if len(msg_splits) < 2: - ba.screenmessage("Enter name of stunt eg : *stunt bombjump") + bui.screenmessage("Enter name of stunt eg : *stunt bombjump") return original_chatmessage(msg) replay(player, stunt_name) - _ba.chatmessage('Replaying "{}" on {}.'.format( + bs.chatmessage('Replaying "{}" on {}.'.format( stunt_name, player.getname(), )) elif command == "learn": if len(msg_splits) < 2: - ba.screenmessage("Enter name of stunt eg : *learn bombjump") + bui.screenmessage("Enter name of stunt eg : *learn bombjump") return original_chatmessage(msg) ghost(player, stunt_name) - _ba.chatmessage('Replaying "{}" on {}.'.format( + bs.chatmessage('Replaying "{}" on {}.'.format( stunt_name, player.getname(), )) @@ -473,25 +476,25 @@ def set_stick_image_position(self, x: float, y: float) -> None: def on_begin(self, *args, **kwargs) -> None: self._jump_image = Image( - ba.gettexture('buttonJump'), + bui.gettexture('buttonJump'), position=(385, 160), scale=(50, 50), color=[0.1, 0.45, 0.1, 0] ) self._pickup_image = Image( - ba.gettexture('buttonPickUp'), + bui.gettexture('buttonPickUp'), position=(385, 240), scale=(50, 50), color=[0, 0.35, 0, 0] ) self._punch_image = Image( - ba.gettexture('buttonPunch'), + bui.gettexture('buttonPunch'), position=(345, 200), scale=(50, 50), color=[0.45, 0.45, 0, 0] ) self._bomb_image = Image( - ba.gettexture('buttonBomb'), + bui.gettexture('buttonBomb'), position=(425, 200), scale=(50, 50), color=[0.45, 0.1, 0.1, 0] @@ -499,10 +502,10 @@ def on_begin(self, *args, **kwargs) -> None: self.stick_image_position_x = self.stick_image_position_y = 0.0 self._stick_base_position = p = (-328, 200) self._stick_base_image_color = c2 = (0.25, 0.25, 0.25, 1.0) - self._stick_base_image = ba.newnode( + self._stick_base_image = bs.newnode( 'image', attrs={ - 'texture': ba.gettexture('nub'), + 'texture': bui.gettexture('nub'), 'absolute_scale': True, 'vr_depth': -40, 'position': p, @@ -511,9 +514,9 @@ def on_begin(self, *args, **kwargs) -> None: }) self._stick_nub_position = p = (-328, 200) self._stick_nub_image_color = c3 = (0.4, 0.4, 0.4, 1.0) - self._stick_nub_image = ba.newnode('image', + self._stick_nub_image = bs.newnode('image', attrs={ - 'texture': ba.gettexture('nub'), + 'texture': bui.gettexture('nub'), 'absolute_scale': True, 'position': p, 'scale': (110*0.6, 110*0.66), @@ -526,22 +529,22 @@ def on_begin(self, *args, **kwargs) -> None: # ba_meta export plugin -class byHeySmoothy(ba.Plugin): +class byHeySmoothy(babase.Plugin): def on_app_running(self): - _ba.set_party_icon_always_visible(True) - ba._activity.Activity.on_begin = on_begin - _ba.chatmessage = new_chatmessage - bastd.actor.playerspaz.PlayerSpaz = NewPlayerSpaz - bastd.actor.spaz.Spaz = NewSpaz + bui.set_party_icon_always_visible(True) + bs._activity.Activity.on_begin = on_begin + bs.chatmessage = new_chatmessage + bascenev1lib.actor.playerspaz.PlayerSpaz = NewPlayerSpaz + bascenev1lib.actor.spaz.Spaz = NewSpaz # lets define a sample elimination game that can use super power of this plugin -# ba_meta export game +# ba_meta export bascenev1.GameActivity class BroEliminaition(EliminationGame): name = 'BroElimination' description = 'Elimination Game with dual character control' - def spawn_player(self, player) -> ba.Actor: + def spawn_player(self, player) -> bs.Actor: super().spawn_player(player) spawn_mirror_spaz(player) diff --git a/plugins/utilities/autorun.py b/plugins/utilities/autorun.py index 263b1b4..f72b143 100644 --- a/plugins/utilities/autorun.py +++ b/plugins/utilities/autorun.py @@ -1,4 +1,5 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 """ AutoRun by TheMikirog @@ -18,11 +19,13 @@ from __future__ import annotations from typing import TYPE_CHECKING # Let's import everything we need and nothing more. -import ba -import bastd +import babase +import bauiv1 as bui +import bascenev1 as bs +import bascenev1lib import math -from ba._generated.enums import TimeType -from bastd.actor.spaz import Spaz +from babase._mgen.enums import TimeType +from bascenev1lib.actor.spaz import Spaz if TYPE_CHECKING: pass @@ -72,8 +75,7 @@ if TYPE_CHECKING: # ba_meta export plugin -class AutoRun(ba.Plugin): - +class AutoRun(babase.Plugin): # During my research and prototyping I figured I'd have to do some linear algebgra. # I didn't want to use libraries, since this is supposed to be a standalone mod. # Because of this I made certain functions from scratch that are easily accessible. @@ -109,14 +111,13 @@ class AutoRun(ba.Plugin): # Here I'm defining a new spaz init function that'll be replaced. def new_init(func): def wrapper(*args, **kwargs): - # Here's where we execute the original game's code, so it's not lost. # We want to add our code at the end of the existing code, so our code goes under that. func(*args, **kwargs) # We define some variables that we need to keep track of. # For future reference, if you see args[0] anywhere, that is "self" in the original function. - args[0].autorun_timer: ba.Timer | None = None + args[0].autorun_timer: bs.Timer | None = None args[0].autorun_override = False # We wanna do our auto run calculations when the player moves their analog stick to make it responsive. @@ -140,12 +141,14 @@ class AutoRun(ba.Plugin): # Notice how it's the capital T Timer instead of the small letter. # That's important, because big T returns a timer object we can manipulate. # We need it assigned to a variable, because we have to delete it once it stops being relevant. - args[0].autorun_timer = ba.Timer( - 0.1, spaz_autorun_update, timetype=TimeType.SIM, repeat=True) + args[0].autorun_timer = bs.Timer(0.1, spaz_autorun_update, repeat=True) return wrapper + # Let's replace the original function with our modified version. - bastd.actor.spaz.Spaz.__init__ = new_init(bastd.actor.spaz.Spaz.__init__) + bascenev1lib.actor.spaz.Spaz.__init__ = new_init( + bascenev1lib.actor.spaz.Spaz.__init__ + ) # This is the bulk of our mod. Our run_update function. # The goal here is to change the self.node.run attribute of our character. @@ -170,8 +173,10 @@ class AutoRun(ba.Plugin): movement_vector = [horizontal, vertical] # Get our character's facing direction - facing_direction = (self.node.position[0] - self.node.position_forward[0], - self.node.position[2] - self.node.position_forward[2]) + facing_direction = ( + self.node.position[0] - self.node.position_forward[0], + self.node.position[2] - self.node.position_forward[2], + ) # We want our character's facing direction to be a normalized vector (magnitude of 1). facing_direction = AutoRun.normalize(facing_direction) @@ -216,9 +221,11 @@ class AutoRun(ba.Plugin): args[0].autorun_override = args[1] # Here's our original unchanged function func(*args, **kwargs) + return wrapper + # We replace the character running function with our modified version. - bastd.actor.spaz.Spaz.on_run = new_onrun(bastd.actor.spaz.Spaz.on_run) + bascenev1lib.actor.spaz.Spaz.on_run = new_onrun(bascenev1lib.actor.spaz.Spaz.on_run) # There's two function that are called when our player pushes the analog stick - two for each axis. # Here's for the vertical axis. @@ -229,9 +236,13 @@ class AutoRun(ba.Plugin): # If we're not holding the run button and we're a player, run our auto run behavior. if not args[0].autorun_override and args[0].source_player: AutoRun.run_update(args[0]) + return wrapper + # You get the idea. - bastd.actor.spaz.Spaz.on_move_up_down = new_updown(bastd.actor.spaz.Spaz.on_move_up_down) + bascenev1lib.actor.spaz.Spaz.on_move_up_down = new_updown( + bascenev1lib.actor.spaz.Spaz.on_move_up_down + ) # Let's do the same for our horizontal axis. # Second verse same as the first. @@ -240,9 +251,12 @@ class AutoRun(ba.Plugin): func(*args, **kwargs) if not args[0].autorun_override and args[0].source_player: AutoRun.run_update(args[0]) + return wrapper - bastd.actor.spaz.Spaz.on_move_left_right = new_leftright( - bastd.actor.spaz.Spaz.on_move_left_right) + + bascenev1lib.actor.spaz.Spaz.on_move_left_right = new_leftright( + bascenev1lib.actor.spaz.Spaz.on_move_left_right + ) # There's one downside to the looping timer - it runs constantly even if the player is dead. # We don't want to waste computational power on something like that. @@ -250,10 +264,14 @@ class AutoRun(ba.Plugin): def new_handlemessage(func): def wrapper(*args, **kwargs): # Only react to the death message. - if isinstance(args[1], ba.DieMessage): + if isinstance(args[1], bs.DieMessage): # Kill the timer. args[0].autorun_timer = None # Original function. func(*args, **kwargs) + return wrapper - bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage) + + bascenev1lib.actor.spaz.Spaz.handlemessage = new_handlemessage( + bascenev1lib.actor.spaz.Spaz.handlemessage + ) diff --git a/plugins/utilities/bomb_radius_visualizer.py b/plugins/utilities/bomb_radius_visualizer.py index 994ccef..8822961 100644 --- a/plugins/utilities/bomb_radius_visualizer.py +++ b/plugins/utilities/bomb_radius_visualizer.py @@ -1,4 +1,5 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 """ Bomb Radius Visualizer by TheMikirog @@ -16,9 +17,11 @@ from __future__ import annotations from typing import TYPE_CHECKING # Let's import everything we need and nothing more. -import ba -import bastd -from bastd.actor.bomb import Bomb +import babase +import bauiv1 as bui +import bascenev1 as bs +import bascenev1lib +from bascenev1lib.actor.bomb import Bomb if TYPE_CHECKING: pass @@ -26,7 +29,7 @@ if TYPE_CHECKING: # ba_meta export plugin -class BombRadiusVisualizer(ba.Plugin): +class BombRadiusVisualizer(babase.Plugin): # We use a decorator to add extra code to existing code, increasing mod compatibility. # Here I'm defining a new bomb init function that'll be replaced. @@ -44,7 +47,7 @@ class BombRadiusVisualizer(ba.Plugin): # Let's make a new node that's just a circle. It's the some one used in the Target Practice minigame. # This is going to make a slightly opaque red circle, signifying damaging area. # We aren't defining the size, because we're gonna animate it shortly after. - args[0].radius_visualizer = ba.newnode('locator', + args[0].radius_visualizer = bs.newnode('locator', # Remove itself when the bomb node dies. owner=args[0].node, attrs={ @@ -59,14 +62,14 @@ class BombRadiusVisualizer(ba.Plugin): # Let's do a fancy animation of that red circle growing into shape like a cartoon. # We're gonna read our bomb's blast radius and use it to decide the size of our circle. - ba.animate_array(args[0].radius_visualizer, 'size', 1, { + bs.animate_array(args[0].radius_visualizer, 'size', 1, { 0.0: [0.0], 0.2: [args[0].blast_radius * 2.2], 0.25: [args[0].blast_radius * 2.0] }) # Let's do a second circle, this time just the outline to where the damaging area ends. - args[0].radius_visualizer_circle = ba.newnode('locator', + args[0].radius_visualizer_circle = bs.newnode('locator', # Remove itself when the bomb node dies. owner=args[0].node, attrs={ @@ -81,7 +84,7 @@ class BombRadiusVisualizer(ba.Plugin): args[0].node.connectattr('position', args[0].radius_visualizer_circle, 'position') # Let's animate that circle too, but this time let's do the opacity. - ba.animate( + bs.animate( args[0].radius_visualizer_circle, 'opacity', { 0: 0.0, 0.4: 0.1 @@ -90,4 +93,4 @@ class BombRadiusVisualizer(ba.Plugin): # Finally we """travel through the game files""" to replace the function we want with our own version. # We transplant the old function's arguments into our version. - bastd.actor.bomb.Bomb.__init__ = new_bomb_init(bastd.actor.bomb.Bomb.__init__) + bascenev1lib.actor.bomb.Bomb.__init__ = new_bomb_init(bascenev1lib.actor.bomb.Bomb.__init__) diff --git a/plugins/utilities/chat_cmd.py b/plugins/utilities/chat_cmd.py index 5bb3da4..071073b 100644 --- a/plugins/utilities/chat_cmd.py +++ b/plugins/utilities/chat_cmd.py @@ -1,12 +1,22 @@ +# Ported by brostos to api 8 +# Tool used to make porting easier.(https://github.com/bombsquad-community/baport) """python 3.9 | chatcmd for a beutiful game - BombSquad OwO""" # modded by IM_NOT_PRANAV#7874 # biggggggg thankssssssssssssss to FireFighter1037 for helping everything # -*- coding: utf-8 -*- -# ba_meta require api 7 -from _ba import env, get_foreground_host_activity, get_foreground_host_session, get_game_roster, get_chat_messages, set_party_icon_always_visible, chatmessage as cmsg, screenmessage as smsg -import ba +# Ported by brostos to api 8 +# ba_meta require api 8 + +import threading +import time +from bascenev1 import get_foreground_host_activity, get_foreground_host_session, get_game_roster, get_chat_messages, chatmessage as cmsg +from bauiv1 import set_party_icon_always_visible, screenmessage as smsg +import babase +import bauiv1 as bui +import bascenev1 as bs +from bauiv1lib import mainmenu # our prefix that what we starts cmds with px = '/' @@ -17,17 +27,20 @@ px = '/' class _cmds: def _process_cmd(): - set_party_icon_always_visible(True) - messages = get_chat_messages() - if len(messages) > 1: - lastmsg = messages[len(messages)-1] + try: + messages = get_chat_messages() + if len(messages) > 1: + lastmsg = messages[len(messages)-1] - m = lastmsg.split(' ')[1] - if m.startswith(px): - return _cmds._handle() - else: - pass + m = lastmsg.split(' ')[1] + if m.startswith(px): + return _cmds._handle() + else: + pass + except: + pass + def _handle(): messages = get_chat_messages() if len(messages) > 1: @@ -137,17 +150,17 @@ class _cmds: cmsg('could not found player') elif m in [px+'quit', px+'restart']: - ba.quit() + babase.quit() elif m in [px+'mute', px+'mutechat']: - cfg = ba.app.config + cfg = babase.app.config cfg['Chat Muted'] = True cfg.apply_and_commit() cmsg('muted') smsg(f'chat muted use {px}unmute and click on send to unmute') elif m in [px+'unmute', px+'unmutechat']: - cfg = ba.app.config + cfg = babase.app.config cfg['Chat Muted'] = False cfg.apply_and_commit() cmsg('un_muted') @@ -222,16 +235,16 @@ class _cmds: elif n[0] == 'all': for i in activity_players: body = i.actor.node - if not body.torso_model == None: - body.head_model = None - body.torso_model = None - body.upper_arm_model = None - body.forearm_model = None - body.pelvis_model = None - body.hand_model = None - body.toes_model = None - body.upper_leg_model = None - body.lower_leg_model = None + if not body.torso_mesh == None: + body.head_mesh = None + body.torso_mesh = None + body.upper_arm_mesh = None + body.forearm_mesh = None + body.pelvis_mesh = None + body.hand_mesh = None + body.toes_mesh = None + body.upper_leg_mesh = None + body.lower_leg_mesh = None body.style = 'cyborg' cmsg('All invisible now Dont get cought') else: @@ -239,16 +252,16 @@ class _cmds: else: body = activity_players[int(n[0])].actor.node is_name = session_players[int(n[0])].getname() - if not body.torso_model == None: - body.head_model = None - body.torso_model = None - body.upper_arm_model = None - body.forearm_model = None - body.pelvis_model = None - body.hand_model = None - body.toes_model = None - body.upper_leg_model = None - body.lower_leg_model = None + if not body.torso_mesh == None: + body.head_mesh = None + body.torso_mesh = None + body.upper_arm_mesh = None + body.forearm_mesh = None + body.pelvis_mesh = None + body.hand_mesh = None + body.toes_mesh = None + body.upper_leg_mesh = None + body.lower_leg_mesh = None body.style = 'cyborg' cmsg(is_name+' using invisiblelity ') else: @@ -260,8 +273,8 @@ class _cmds: elif n[0] == 'all': for i in activity_players: body = i.actor.node - if not body.head_model == None: - body.head_model = None + if not body.head_mesh == None: + body.head_mesh = None body.style = 'cyborg' cmsg('headless ? xD') else: @@ -269,8 +282,8 @@ class _cmds: else: body = activity_players[int(n[0])].actor.node is_name = session_players[int(n[0])].getname() - if not body.head_model == None: - body.head_model = None + if not body.head_mesh == None: + body.head_mesh = None body.style = 'cyborg' cmsg(is_name+'is headless now xD') else: @@ -282,16 +295,16 @@ class _cmds: elif n[0] == 'all': for i in activity_players: body = i.actor.node - body.head_model = None - body.handlemessage(ba.PowerupMessage(poweruptype='punch')) - body.handlemessage(ba.PowerupMessage(poweruptype='shield')) + body.head_mesh = None + body.handlemessage(bs.PowerupMessage(poweruptype='punch')) + body.handlemessage(bs.PowerupMessage(poweruptype='shield')) cmsg('dont creep out childs all will be scared') else: try: body = activity_players[int(n[0])].actor.node - body.head_model = None - body.handlemessage(ba.PowerupMessage(poweruptype='punch')) - body.handlemessage(ba.PowerupMessage(poweruptype='shield')) + body.head_mesh = None + body.handlemessage(bs.PowerupMessage(poweruptype='punch')) + body.handlemessage(bs.PowerupMessage(poweruptype='shield')) cmsg('dont creep out childs all will be scared') except: cmsg('could not found player to make') @@ -301,11 +314,11 @@ class _cmds: cmsg(f'Use : {px}kill all or {px}kill number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.DieMessage()) + i.actor.node.handlemessage(bs.DieMessage()) cmsg('Killed all') else: is_name = session_players[int(n[0])].getname() - activity_players[int(n[0])].actor.node.handlemessage(ba.DieMessage()) + activity_players[int(n[0])].actor.node.handlemessage(bs.DieMessage()) cmsg('Killed '+is_name) elif m in [px+'heal', px+'heath']: @@ -313,12 +326,12 @@ class _cmds: cmsg(f'Use: {px}heal all or {px}heal number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='health')) + i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='health')) cmsg('Heald all') else: is_name = session_players[int(n[0])].getname() activity_players[int(n[0])].actor.node.handlemessage( - ba.PowerupMessage(poweruptype='health')) + bs.PowerupMessage(poweruptype='health')) cmsg('Heald '+is_name) elif m in [px+'curse', px+'cur']: @@ -326,12 +339,12 @@ class _cmds: cmsg(f'Use: {px}curse all or {px}curse number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='curse')) + i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='curse')) cmsg('Cursed all') else: is_name = session_players[int(n[0])].getname() activity_players[int(n[0])].actor.node.handlemessage( - ba.PowerupMessage(poweruptype='curse')) + bs.PowerupMessage(poweruptype='curse')) cmsg('Cursed '+is_name) elif m in [px+'sleep']: @@ -378,12 +391,12 @@ class _cmds: cmsg(f'Use: {px}gloves all or {px}gloves number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='punch')) + i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='punch')) cmsg('Free Gloves enjoy all') else: is_name = session_players[int(n[0])].getname() activity_players[int(n[0])].actor.node.handlemessage( - ba.PowerupMessage(poweruptype='punch')) + bs.PowerupMessage(poweruptype='punch')) cmsg(is_name+' using gloves') elif m in [px+'shield', px+'protect']: @@ -391,12 +404,12 @@ class _cmds: cmsg(f'Use: {px}shield all or {px}shield number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='shield')) + i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='shield')) cmsg('Everyone enjoy free shield :)') else: is_name = session_players[int(n[0])].getname() activity_players[int(n[0])].actor.node.handlemessage( - ba.PowerupMessage(poweruptype='shield')) + bs.PowerupMessage(poweruptype='shield')) cmsg(is_name+' using shield') elif m in [px+'freeze', px+'ice']: @@ -404,11 +417,11 @@ class _cmds: cmsg(f'Use: {px}freeze all or {px}freeze number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.FreezeMessage()) + i.actor.node.handlemessage(bs.FreezeMessage()) cmsg('Freezed all') else: is_name = session_players[int(n[0])].getname() - activity_players[int(n[0])].actor.node.handlemessage(ba.FreezeMessage()) + activity_players[int(n[0])].actor.node.handlemessage(bs.FreezeMessage()) cmsg('Un freezed '+is_name) elif m in [px+'unfreeze', px+'thaw']: @@ -416,11 +429,11 @@ class _cmds: cmsg(f'Use: {px}unfreeze/thaw all or {px}unfreeze/thaw number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.ThawMessage()) + i.actor.node.handlemessage(bs.ThawMessage()) cmsg('Un freezed all ') else: is_name = session_players[int(n[0])].getname() - activity_players[int(n[0])].actor.node.handlemessage(ba.ThawMessage()) + activity_players[int(n[0])].actor.node.handlemessage(bs.ThawMessage()) cmsg('Un freezed '+is_name) elif m in [px+'fall']: @@ -428,11 +441,11 @@ class _cmds: cmsg(f'Use: {px}fall all or {px}fall number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.StandMessage()) + i.actor.node.handlemessage(bs.StandMessage()) cmsg('Felt everyone') else: is_name = session_players[int(n[0])].getname() - activity_players[int(n[0])].actor.node.handlemessage(ba.StandMessage()) + activity_players[int(n[0])].actor.node.handlemessage(bs.StandMessage()) cmsg(is_name+' got felt') elif m in [px+'celebrate', px+'celeb']: @@ -440,11 +453,11 @@ class _cmds: cmsg(f'Use: {px}celebrate all or {px}celebrate number of list') elif n[0] == 'all': for i in activity_players: - i.actor.node.handlemessage(ba.CelebrateMessage()) + i.actor.node.handlemessage(bs.CelebrateMessage()) cmsg('Celebrate all :)') else: is_name = session_players[int(n[0])].getname() - activity_players[int(n[0])].actor.node.handlemessage(ba.CelebrateMessage()) + activity_players[int(n[0])].actor.node.handlemessage(bs.CelebrateMessage()) cmsg(is_name+' is celebrating bt why?') elif m in [px+'fly']: @@ -531,13 +544,24 @@ class _cmds: cmsg(u'\U0001F95A Nazz are past/present/future \U0001F95A') cmsg(u'\U0001F95A everything is Nazz \U0001F95A') - -# ba.timer(0.05, _update, repeat=True) +class NewMainMenuWindow(mainmenu.MainMenuWindow): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Display chat icon, but if user open/close gather it may disappear + bui.set_party_icon_always_visible(True) + +# bs.timer(0.05, _update, repeat=True) def same(): - ba.timer(0.5, _cmds._process_cmd, True) - -# ba_meta export plugin + # bs.timer(0.5, _cmds._process_cmd, True) + _cmds._process_cmd() +# ba_meta export babase.Plugin -class _enableee(ba.Plugin): - same() +class _enableee(babase.Plugin): + timer = bs.AppTimer(0.5, same,repeat=True) + + def on_app_running(self): + mainmenu.MainMenuWindow = NewMainMenuWindow + + + \ No newline at end of file diff --git a/plugins/utilities/colored_bomb_explosion_patches.py b/plugins/utilities/colored_bomb_explosion_patches.py index 3ea0ba6..813989e 100644 --- a/plugins/utilities/colored_bomb_explosion_patches.py +++ b/plugins/utilities/colored_bomb_explosion_patches.py @@ -1,13 +1,16 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 # (see https://ballistica.net/wiki/meta-tag-system) from __future__ import annotations from typing import TYPE_CHECKING -import ba +import babase +import bauiv1 as bui +import bascenev1 as bs import random -from bastd.actor import bomb +from bascenev1lib.actor import bomb if TYPE_CHECKING: from typing import Sequence @@ -20,7 +23,7 @@ class NewBlast(bomb.Blast): velocity: Sequence[float] = (0.0, 0.0, 0.0), blast_radius: float = 2.0, blast_type: str = 'normal', - source_player: ba.Player | None = None, + source_player: bs.Player | None = None, hit_type: str = 'explosion', hit_subtype: str = 'normal', ): @@ -29,7 +32,7 @@ class NewBlast(bomb.Blast): scorch_radius = light_radius = self.radius if self.blast_type == 'tnt': scorch_radius *= 1.15 - scorch = ba.newnode( + scorch = bs.newnode( 'scorch', attrs={ 'position': position, @@ -38,11 +41,11 @@ class NewBlast(bomb.Blast): }, ) random_color = (random.random(), random.random(), random.random()) - scorch.color = ba.safecolor(random_color) - ba.animate(scorch, 'presence', {3.000: 1, 13.000: 0}) - ba.timer(13.0, scorch.delete) + scorch.color = babase.safecolor(random_color) + bs.animate(scorch, 'presence', {3.000: 1, 13.000: 0}) + bs.timer(13.0, scorch.delete) # ba_meta export plugin -class RandomColorsPlugin(ba.Plugin): +class RandomColorsPlugin(babase.Plugin): bomb.Blast = NewBlast diff --git a/plugins/utilities/custom_death.py b/plugins/utilities/custom_death.py index b3730e1..bc8a66b 100644 --- a/plugins/utilities/custom_death.py +++ b/plugins/utilities/custom_death.py @@ -1,12 +1,14 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# 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.spaz import Spaz +import babase +import bascenev1 as bs +from bascenev1lib.actor.spaz import Spaz if TYPE_CHECKING: from typing import Any @@ -16,19 +18,19 @@ Spaz.oldhandlemessage = Spaz.handlemessage def handlemessage(self, msg: Any) -> Any: - if isinstance(msg, ba.DieMessage): + if isinstance(msg, bs.DieMessage): if self.node: - self.node.color_texture = ba.gettexture('bonesColor') - self.node.color_mask_texture = ba.gettexture('bonesColorMask') - self.node.head_model = ba.getmodel('bonesHead') - self.node.torso_model = ba.getmodel('bonesTorso') - self.node.pelvis_model = ba.getmodel('bonesPelvis') - self.node.upper_arm_model = ba.getmodel('bonesUpperArm') - self.node.forearm_model = ba.getmodel('bonesForeArm') - self.node.hand_model = ba.getmodel('bonesHand') - self.node.upper_leg_model = ba.getmodel('bonesUpperLeg') - self.node.lower_leg_model = ba.getmodel('bonesLowerLeg') - self.node.toes_model = ba.getmodel('bonesToes') + self.node.color_texture = bs.gettexture('bonesColor') + self.node.color_mask_texture = bs.gettexture('bonesColorMask') + self.node.head_mesh = bs.getmesh('bonesHead') + self.node.torso_mesh = bs.getmesh('bonesTorso') + self.node.pelvis_mesh = bs.getmesh('bonesPelvis') + self.node.upper_arm_mesh = bs.getmesh('bonesUpperArm') + self.node.forearm_mesh = bs.getmesh('bonesForeArm') + self.node.hand_mesh = bs.getmesh('bonesHand') + self.node.upper_leg_mesh = bs.getmesh('bonesUpperLeg') + self.node.lower_leg_mesh = bs.getmesh('bonesLowerLeg') + self.node.toes_mesh = bs.getmesh('bonesToes') self.node.style = 'bones' self.oldhandlemessage(msg) else: @@ -36,5 +38,5 @@ def handlemessage(self, msg: Any) -> Any: # ba_meta export plugin -class CustomDeath(ba.Plugin): +class CustomDeath(babase.Plugin): Spaz.handlemessage = handlemessage diff --git a/plugins/utilities/disco_light.py b/plugins/utilities/disco_light.py index b87553b..572baa0 100644 --- a/plugins/utilities/disco_light.py +++ b/plugins/utilities/disco_light.py @@ -1,3 +1,4 @@ +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) """Disco Light Mod: V1.0 Made by Cross Joy""" @@ -5,7 +6,7 @@ Made by Cross Joy""" # Can visit my github https://github.com/CrossJoy/Bombsquad-Modding # You can contact me through discord: -# My Discord Id: Cross Joy#0721 +# My Discord Id: crossjoy # My BS Discord Server: https://discord.gg/JyBY6haARJ @@ -25,19 +26,22 @@ Made by Cross Joy""" # Other clients/players can't use the commands. # ---------------------------------------------------------------------------- -# ba_meta require api 7 +# ba_meta require api 8 from __future__ import annotations from typing import TYPE_CHECKING -import ba -import _ba -from ba import _gameutils +from baenv import TARGET_BALLISTICA_BUILD as build_number +from bauiv1lib import mainmenu +import babase +import bauiv1 as bui +import bascenev1 as bs +import _babase +from bascenev1 import _gameutils, animate import random -from ba import animate if TYPE_CHECKING: from typing import Sequence, Union @@ -51,38 +55,38 @@ 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 if build_number < 21282 else babase.app.env.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 +# if is_game_version_lower_than("1.7.7"): +# ba_internal = _ba +# else: +# ba_internal = babase.internal # Activate disco light. def start(): - activity = _ba.get_foreground_host_activity() + activity = bs.get_foreground_host_activity() - with ba.Context(activity): + with activity.context: partyLight(True) rainbow(activity) # Deactivate disco light. def stop(): - activity = _ba.get_foreground_host_activity() + activity = bs.get_foreground_host_activity() - with ba.Context(activity): + with activity.context: partyLight(False) stop_rainbow(activity) # Create and animate colorful spotlight. def partyLight(switch=True): - from ba._nodeactor import NodeActor + from bascenev1._nodeactor import NodeActor x_spread = 10 y_spread = 5 positions = [[-x_spread, -y_spread], [0, -y_spread], [0, y_spread], @@ -91,14 +95,14 @@ def partyLight(switch=True): times = [0, 2700, 1000, 1800, 500, 1400] # Store this on the current activity, so we only have one at a time. - activity = _ba.getactivity() + activity = bs.getactivity() activity.camera_flash_data = [] # type: ignore for i in range(6): r = random.choice([0.5, 1]) g = random.choice([0.5, 1]) b = random.choice([0.5, 1]) light = NodeActor( - _ba.newnode('light', + bs.newnode('light', attrs={ 'position': (positions[i][0], 0, positions[i][1]), 'radius': 1.0, @@ -108,7 +112,7 @@ def partyLight(switch=True): })) sval = 1.87 iscale = 1.3 - tcombine = _ba.newnode('combine', + tcombine = bs.newnode('combine', owner=light.node, attrs={ 'size': 3, @@ -149,7 +153,7 @@ def partyLight(switch=True): loop=True, offset=times[i]) if not switch: - _ba.timer(0.1, + bs.timer(0.1, light.node.delete) activity.camera_flash_data.append(light) # type: ignore @@ -158,7 +162,7 @@ def partyLight(switch=True): def rainbow(self) -> None: """Create RGB tint.""" c_existing = self.globalsnode.tint - cnode = _ba.newnode('combine', + cnode = bs.newnode('combine', attrs={ 'input0': c_existing[0], 'input1': c_existing[1], @@ -187,11 +191,14 @@ def rainbow(self) -> None: # Revert to the original map tint. def stop_rainbow(self): """Revert to the original map tint.""" - c_existing = self.globalsnode.tint - map_name = self.map.getname() - tint = check_map_tint(map_name) + try: + c_existing = self.globalsnode.tint + map_name = self.map.getname() + tint = check_map_tint(map_name) + except: + tint = (1, 1, 1) - cnode = _ba.newnode('combine', + cnode = bs.newnode('combine', attrs={ 'input0': c_existing[0], 'input1': c_existing[1], @@ -249,11 +256,11 @@ def check_map_tint(map_name): # Get the original game codes. -old_fcm = ba_internal.chatmessage +old_fcm = bs.chatmessage # New chat func to add some commands to activate/deactivate the disco light. -def new_chat_message(msg: Union[str, ba.Lstr], clients: Sequence[int] = None, +def new_chat_message(msg: Union[str, babase.Lstr], clients: Sequence[int] = None, sender_override: str = None): old_fcm(msg, clients, sender_override) if msg == '/disco': @@ -261,13 +268,18 @@ def new_chat_message(msg: Union[str, ba.Lstr], clients: Sequence[int] = None, if msg == '/disco off': stop() - +class NewMainMenuWindow(mainmenu.MainMenuWindow): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Display chat icon, but if user open/close gather it may disappear + bui.set_party_icon_always_visible(True) + # Replace new chat func to the original game codes. -ba_internal.chatmessage = new_chat_message -if not ba_internal.is_party_icon_visible(): - ba_internal.set_party_icon_always_visible(True) +bs.chatmessage = new_chat_message # ba_meta export plugin -class ByCrossJoy(ba.Plugin): - def __init__(self): pass +class ByCrossJoy(babase.Plugin): + def on_app_running(self): + mainmenu.MainMenuWindow = NewMainMenuWindow + \ No newline at end of file diff --git a/plugins/utilities/discord_richpresence.py b/plugins/utilities/discord_richpresence.py index 70a1ee3..3028e64 100644 --- a/plugins/utilities/discord_richpresence.py +++ b/plugins/utilities/discord_richpresence.py @@ -370,7 +370,7 @@ def get_event_loop(force_fresh=False): def _generate_join_secret(self): # resp = requests.get('https://legacy.ballistica.net/bsAccessCheck').text - connection_info = bs.get_connection_to_host_info_2() + connection_info = bs.get_connection_to_host_info() if build_number < 21697 else bs.get_connection_to_host_info_2() if connection_info: addr = _last_server_addr port = _last_server_port @@ -870,7 +870,7 @@ class DiscordRP(babase.Plugin): def update_status(self) -> None: roster = bs.get_game_roster() - connection_info = bs.get_connection_to_host_info_2() + connection_info = bs.get_connection_to_host_info() if build_number < 21697 else bs.get_connection_to_host_info_2() self.rpc_thread.large_image_key = "bombsquadicon" self.rpc_thread.large_image_text = "BombSquad" @@ -963,7 +963,7 @@ class DiscordRP(babase.Plugin): points = act._score self.rpc_thread.details += f" ({points} points)" elif isinstance(act, MeteorShowerGame): - with bs.ContextRef(act): + with act.context: sec = bs.time() - act._timer.getstarttime() secfmt = "" if sec < 60: diff --git a/plugins/utilities/max_players.py b/plugins/utilities/max_players.py index 6d6257a..f18265f 100644 --- a/plugins/utilities/max_players.py +++ b/plugins/utilities/max_players.py @@ -1,29 +1,32 @@ +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) """===========MAX_PLAYERS===========""" -# 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 -import _ba -from ba._session import Session -from ba._coopsession import CoopSession, TEAM_COLORS, TEAM_NAMES -from ba._multiteamsession import MultiTeamSession -from bastd.ui.gather import GatherWindow -from bastd.ui.popup import PopupWindow +import babase +import bauiv1 as bui +import bascenev1 as bs +import _babase +from bascenev1._session import Session +from bascenev1._coopsession import CoopSession, TEAM_COLORS, TEAM_NAMES +from bascenev1._multiteamsession import MultiTeamSession +from bauiv1lib.gather import GatherWindow +from bauiv1lib.popup import PopupWindow if TYPE_CHECKING: from typing import List, Any, Optional, Sequence -cfg = ba.app.config +cfg = babase.app.config cmp = {'coop_max_players': 4, 'teams_max_players': 8, 'ffa_max_players': 8} -lang = ba.app.lang.language +lang = bs.app.lang.language if lang == 'Spanish': title_text = 'Máximo de Jugadores' title_short_text = 'Jugadores' @@ -41,7 +44,7 @@ else: class ConfigNumberEdit: def __init__(self, - parent: ba.Widget, + parent: bui.Widget, position: Tuple[float, float], value: int, config: str, @@ -53,7 +56,7 @@ class ConfigNumberEdit: self._config = config textscale = 1.0 - self.nametext = ba.textwidget( + self.nametext = bui.textwidget( parent=parent, position=(position[0], position[1]), size=(100, 30), @@ -63,7 +66,7 @@ class ConfigNumberEdit: h_align='left', v_align='center', scale=textscale) - self.valuetext = ba.textwidget( + self.valuetext = bui.textwidget( parent=parent, position=(position[0]+150, position[1]), size=(60, 28), @@ -73,21 +76,21 @@ class ConfigNumberEdit: v_align='center', text=str(value), padding=2) - self.minusbutton = ba.buttonwidget( + self.minusbutton = bui.buttonwidget( parent=parent, position=(position[0]+240, position[1]), size=(28, 28), label='-', autoselect=True, - on_activate_call=ba.Call(self._down), + on_activate_call=babase.Call(self._down), repeat=True) - self.plusbutton = ba.buttonwidget( + self.plusbutton = bui.buttonwidget( parent=parent, position=(position[0]+290, position[1]), size=(28, 28), label='+', autoselect=True, - on_activate_call=ba.Call(self._up), + on_activate_call=babase.Call(self._up), repeat=True) def _up(self) -> None: @@ -99,7 +102,7 @@ class ConfigNumberEdit: self._update_display() def _update_display(self) -> None: - ba.textwidget(edit=self.valuetext, text=str(self._value)) + bui.textwidget(edit=self.valuetext, text=str(self._value)) cfg['Config Max Players'][self._config] = self._value cfg.apply_and_commit() @@ -108,7 +111,7 @@ class SettingsMaxPlayers(PopupWindow): def __init__(self): # pylint: disable=too-many-locals - uiscale = ba.app.ui.uiscale + uiscale = bui.app.ui_v1.uiscale self._transitioning_out = False self._width = 400 self._height = 220 @@ -121,7 +124,7 @@ class SettingsMaxPlayers(PopupWindow): scale=1.2, bg_color=bg_color) - self._cancel_button = ba.buttonwidget( + self._cancel_button = bui.buttonwidget( parent=self.root_widget, position=(25, self._height - 40), size=(50, 50), @@ -130,12 +133,12 @@ class SettingsMaxPlayers(PopupWindow): color=bg_color, on_activate_call=self._on_cancel_press, autoselect=True, - 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) - ba.textwidget( + bui.textwidget( parent=self.root_widget, position=(self._width * 0.5, self._height - 30), size=(0, 0), @@ -144,7 +147,7 @@ class SettingsMaxPlayers(PopupWindow): scale=0.8, text=title_text, maxwidth=200, - color=ba.app.ui.title_color) + color=bui.app.ui_v1.title_color) posx = 33 posy = self._height @@ -176,37 +179,38 @@ class SettingsMaxPlayers(PopupWindow): def _transition_out(self) -> None: if not self._transitioning_out: self._transitioning_out = True - ba.containerwidget(edit=self.root_widget, transition='out_scale') + bui.containerwidget(edit=self.root_widget, transition='out_scale') def on_popup_cancel(self) -> None: - ba.playsound(ba.getsound('swish')) + bui.getsound('swish').play() self._transition_out() def __init__(self) -> None: """Instantiate a co-op mode session.""" # pylint: disable=cyclic-import - from ba._campaign import getcampaign - from bastd.activity.coopjoin import CoopJoinActivity + getcampaign = bui.app.classic.getcampaign + from bascenev1lib.activity.coopjoin import CoopJoinActivity - _ba.increment_analytics_count('Co-op session start') - app = _ba.app + _babase.increment_analytics_count('Co-op session start') + app = babase.app + classic = app.classic # If they passed in explicit min/max, honor that. # Otherwise defer to user overrides or defaults. - if 'min_players' in app.coop_session_args: - min_players = app.coop_session_args['min_players'] + if 'min_players' in classic.coop_session_args: + min_players = classic.coop_session_args['min_players'] else: min_players = 1 - if 'max_players' in app.coop_session_args: - max_players = app.coop_session_args['max_players'] + if 'max_players' in classic.coop_session_args: + max_players = classic.coop_session_args['max_players'] else: max_players = app.config.get( 'Coop Game Max Players', cfg['Config Max Players']['coop_max_players']) # print('FIXME: COOP SESSION WOULD CALC DEPS.') - depsets: Sequence[ba.DependencySet] = [] + depsets: Sequence[babase.DependencySet] = [] Session.__init__(self, depsets, @@ -217,30 +221,30 @@ def __init__(self) -> None: # Tournament-ID if we correspond to a co-op tournament (otherwise None) self.tournament_id: Optional[str] = ( - app.coop_session_args.get('tournament_id')) + classic.coop_session_args.get('tournament_id')) - self.campaign = getcampaign(app.coop_session_args['campaign']) - self.campaign_level_name: str = app.coop_session_args['level'] + self.campaign = getcampaign(classic.coop_session_args['campaign']) + self.campaign_level_name: str = classic.coop_session_args['level'] self._ran_tutorial_activity = False - self._tutorial_activity: Optional[ba.Activity] = None + self._tutorial_activity: Optional[babase.Activity] = None self._custom_menu_ui: List[Dict[str, Any]] = [] # Start our joining screen. - self.setactivity(_ba.newactivity(CoopJoinActivity)) + self.setactivity(bs.newactivity(CoopJoinActivity)) - self._next_game_instance: Optional[ba.GameActivity] = None + self._next_game_instance: Optional[bs.GameActivity] = None self._next_game_level_name: Optional[str] = None self._update_on_deck_game_instances() def get_max_players(self) -> int: - """Return max number of ba.Players allowed to join the game at once.""" + """Return max number of bs.Players allowed to join the game at once.""" if self.use_teams: - return _ba.app.config.get( + return _babase.app.config.get( 'Team Game Max Players', cfg['Config Max Players']['teams_max_players']) - return _ba.app.config.get( + return _babase.app.config.get( 'Free-for-All Max Players', cfg['Config Max Players']['ffa_max_players']) @@ -250,18 +254,18 @@ GatherWindow.__old_init__ = GatherWindow.__init__ def __gather_init__(self, transition: Optional[str] = 'in_right', - origin_widget: ba.Widget = None): + origin_widget: bui.Widget = None): self.__old_init__(transition, origin_widget) def _do_max_players(): SettingsMaxPlayers() - self._max_players_button = ba.buttonwidget( + self._max_players_button = bui.buttonwidget( parent=self._root_widget, position=(self._width*0.72, self._height*0.91), size=(220, 60), scale=1.0, color=(0.6, 0.0, 0.9), - icon=ba.gettexture('usersButton'), + icon=bui.gettexture('usersButton'), iconscale=1.5, autoselect=True, label=title_short_text, @@ -290,11 +294,11 @@ def _save_state(self) -> None: sel_name = 'TabContainer' else: raise ValueError(f'unrecognized selection: \'{sel}\'') - ba.app.ui.window_states[type(self)] = { + bui.app.ui_v1.window_states[type(self)] = { 'sel_name': sel_name, } except Exception: - ba.print_exception(f'Error saving state for {self}.') + babase.print_exception(f'Error saving state for {self}.') def _restore_state(self) -> None: @@ -303,12 +307,12 @@ def _restore_state(self) -> None: for tab in self._tabs.values(): tab.restore_state() - sel: Optional[ba.Widget] - winstate = ba.app.ui.window_states.get(type(self), {}) + sel: Optional[bui.Widget] + winstate = bui.app.ui_v1.window_states.get(type(self), {}) sel_name = winstate.get('sel_name', None) assert isinstance(sel_name, (str, type(None))) current_tab = self.TabID.ABOUT - gather_tab_val = ba.app.config.get('Gather Tab') + gather_tab_val = babase.app.config.get('Gather Tab') try: stored_tab = enum_by_value(self.TabID, gather_tab_val) if stored_tab in self._tab_row.tabs: @@ -331,35 +335,35 @@ def _restore_state(self) -> None: sel = self._tab_row.tabs[sel_tab_id].button else: sel = self._tab_row.tabs[current_tab].button - ba.containerwidget(edit=self._root_widget, selected_child=sel) + bui.containerwidget(edit=self._root_widget, selected_child=sel) except Exception: - ba.print_exception('Error restoring gather-win state.') + babase.print_exception('Error restoring gather-win state.') # ba_meta export plugin -class MaxPlayersPlugin(ba.Plugin): +class MaxPlayersPlugin(babase.Plugin): def has_settings_ui(self) -> bool: return True - def show_settings_ui(self, source_widget: ba.Widget | None) -> None: + def show_settings_ui(self, source_widget: bui.Widget | None) -> None: SettingsMaxPlayers() - if 'Config Max Players' in ba.app.config: - old_config = ba.app.config['Config Max Players'] + if 'Config Max Players' in babase.app.config: + old_config = babase.app.config['Config Max Players'] for setting in cmp: if setting not in old_config: - ba.app.config['Config Max Players'].update({setting: cmp[setting]}) + babase.app.config['Config Max Players'].update({setting: cmp[setting]}) remove_list = [] for setting in old_config: if setting not in cmp: remove_list.append(setting) for element in remove_list: - ba.app.config['Config Max Players'].pop(element) + babase.app.config['Config Max Players'].pop(element) else: - ba.app.config['Config Max Players'] = cmp - ba.app.config.apply_and_commit() + babase.app.config['Config Max Players'] = cmp + babase.app.config.apply_and_commit() CoopSession.__init__ = __init__ MultiTeamSession.get_max_players = get_max_players diff --git a/plugins/utilities/mood_light.py b/plugins/utilities/mood_light.py index cb94021..ec822dd 100644 --- a/plugins/utilities/mood_light.py +++ b/plugins/utilities/mood_light.py @@ -1,16 +1,20 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 from __future__ import annotations from typing import TYPE_CHECKING, cast if TYPE_CHECKING: from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union import random -import ba -import _ba -from ba._map import Map -from bastd import mainmenu -from bastd.ui.party import PartyWindow -from bastd.gameutils import SharedObjects +import babase +import bauiv1 as bui +import bascenev1 as bs +import _babase +from bascenev1._map import Map +from bascenev1lib import mainmenu +from bauiv1lib.mainmenu import MainMenuWindow +from bauiv1lib.party import PartyWindow +from bascenev1lib.gameutils import SharedObjects """mood light plugin by ʟօʊքɢǟʀօʊ type ml in chat or use plugin manager to open settings""" @@ -21,7 +25,7 @@ def Print(*args): for arg in args: a = str(arg) out += a - ba.screenmessage(out) + bui.screenmessage(out) def cprint(*args): @@ -29,26 +33,26 @@ def cprint(*args): for arg in args: a = str(arg) out += a - _ba.chatmessage(out) + bs.chatmessage(out) try: - Ldefault, Udefault = ba.app.config.get("moodlightingSettings") + Ldefault, Udefault = babase.app.config.get("moodlightingSettings") except: - ba.app.config["moodlightingSettings"] = (15, 20) - Ldefault, Udefault = ba.app.config.get("moodlightingSettings") + babase.app.config["moodlightingSettings"] = (15, 20) + Ldefault, Udefault = babase.app.config.get("moodlightingSettings") Print("settings up moodlight") Print("Type ml in chat or use plugin manager to access settings") try: - loop = ba.app.config.get("moodlightEnabled") + loop = babase.app.config.get("moodlightEnabled") except: - ba.app.config["moodlightEnabled"] = True - ba.app.config.commit() + babase.app.config["moodlightEnabled"] = True + babase.app.config.commit() loop = True -class SettingWindow(ba.Window): +class SettingWindow(bui.Window): def __init__(self): self.draw_ui() @@ -56,57 +60,57 @@ class SettingWindow(ba.Window): global Ldefault, Udefault try: if Udefault >= 29 and self.selected == "upper": - ba.textwidget(edit=self.warn_text, + bui.textwidget(edit=self.warn_text, text="Careful!You risk get blind beyond this point") elif self.selected == "lower" and Ldefault >= -20 or self.selected == "upper" and Udefault <= 30: - ba.textwidget(edit=self.warn_text, text="") + bui.textwidget(edit=self.warn_text, text="") if self.selected == "lower": Ldefault += 1 - ba.textwidget(edit=self.lower_text, text=str(Ldefault)) + bui.textwidget(edit=self.lower_text, text=str(Ldefault)) elif self.selected == "upper": Udefault += 1 - ba.textwidget(edit=self.upper_text, text=str(Udefault)) + bui.textwidget(edit=self.upper_text, text=str(Udefault)) except AttributeError: - ba.textwidget(edit=self.warn_text, text="Click on number to select it") + bui.textwidget(edit=self.warn_text, text="Click on number to select it") def decrease_limit(self): global Ldefault, Udefault try: if Ldefault <= -19 and self.selected == "lower": - ba.textwidget(edit=self.warn_text, + bui.textwidget(edit=self.warn_text, text="DON'T BE AFRAID OF DARK,IT'S A PLACE WHERE YOU CAN HIDE") elif (self.selected == "upper" and Udefault <= 30) or (self.selected == "lower" and Ldefault >= -20): - ba.textwidget(edit=self.warn_text, text="") + bui.textwidget(edit=self.warn_text, text="") if self.selected == "lower": Ldefault -= 1 - ba.textwidget(edit=self.lower_text, text=str(Ldefault)) + bui.textwidget(edit=self.lower_text, text=str(Ldefault)) elif self.selected == "upper": Udefault -= 1 - ba.textwidget(edit=self.upper_text, text=str(Udefault)) + bui.textwidget(edit=self.upper_text, text=str(Udefault)) except AttributeError: - ba.textwidget(edit=self.warn_text, text="Click on number to select it") + bui.textwidget(edit=self.warn_text, text="Click on number to select it") def on_text_click(self, selected): self.selected = selected if selected == "upper": - ba.textwidget(edit=self.upper_text, color=(0, 0, 1)) - ba.textwidget(edit=self.lower_text, color=(1, 1, 1)) + bui.textwidget(edit=self.upper_text, color=(0, 0, 1)) + bui.textwidget(edit=self.lower_text, color=(1, 1, 1)) elif selected == "lower": - ba.textwidget(edit=self.lower_text, color=(0, 0, 1)) - ba.textwidget(edit=self.upper_text, color=(1, 1, 1)) + bui.textwidget(edit=self.lower_text, color=(0, 0, 1)) + bui.textwidget(edit=self.upper_text, color=(1, 1, 1)) else: Print("this should't happen from on_text_click") def draw_ui(self): - self.uiscale = ba.app.ui.uiscale + self.uiscale = bui.app.ui_v1.uiscale super().__init__( - root_widget=ba.containerwidget( + root_widget=bui.containerwidget( size=(670, 670), on_outside_click_call=self.close, transition="in_right",)) - moodlight_label = ba.textwidget( + moodlight_label = bui.textwidget( parent=self._root_widget, size=(200, 100), position=(150, 550), @@ -117,7 +121,7 @@ class SettingWindow(ba.Window): text="Mood light settings", color=(0, 1, 0)) - self.enable_button = ba.buttonwidget( + self.enable_button = bui.buttonwidget( parent=self._root_widget, position=(100, 470), size=(90, 70), @@ -126,7 +130,7 @@ class SettingWindow(ba.Window): label="DISABLE" if loop else "ENABLE", on_activate_call=self.on_enableButton_press) - save_button = ba.buttonwidget( + save_button = bui.buttonwidget( parent=self._root_widget, position=(520, 470), size=(90, 70), @@ -134,18 +138,18 @@ class SettingWindow(ba.Window): label="SAVE", on_activate_call=self.save_settings) - self.close_button = ba.buttonwidget( + self.close_button = bui.buttonwidget( parent=self._root_widget, position=(550, 590), size=(35, 35), - icon=ba.gettexture("crossOut"), + icon=bui.gettexture("crossOut"), icon_color=(1, 0.2, 0.2), scale=2, color=(1, 0.2, 0.2), extra_touch_border_scale=5, on_activate_call=self.close) - self.lower_text = ba.textwidget( + self.lower_text = bui.textwidget( parent=self._root_widget, size=(200, 100), scale=2, @@ -157,7 +161,7 @@ class SettingWindow(ba.Window): click_activate=True, selectable=True) - lower_text_label = ba.textwidget( + lower_text_label = bui.textwidget( parent=self._root_widget, size=(200, 100), position=(100, 150), @@ -165,7 +169,7 @@ class SettingWindow(ba.Window): v_align="center", text="Limit darkness") - self.upper_text = ba.textwidget( + self.upper_text = bui.textwidget( parent=self._root_widget, size=(200, 100), scale=2, @@ -177,7 +181,7 @@ class SettingWindow(ba.Window): click_activate=True, selectable=True) - upper_text_label = ba.textwidget( + upper_text_label = bui.textwidget( parent=self._root_widget, size=(200, 100), position=(400, 150), @@ -185,25 +189,25 @@ class SettingWindow(ba.Window): v_align="center", text="Limit brightness") - decrease_button = ba.buttonwidget( + decrease_button = bui.buttonwidget( parent=self._root_widget, position=(100, 100), size=(5, 1), scale=3.5, extra_touch_border_scale=2.5, - icon=ba.gettexture("downButton"), + icon=bui.gettexture("downButton"), on_activate_call=self.decrease_limit) - increase_button = ba.buttonwidget( + increase_button = bui.buttonwidget( parent=self._root_widget, position=(600, 100), size=(5, 1), scale=3.5, extra_touch_border_scale=2.5, - icon=ba.gettexture("upButton"), + icon=bui.gettexture("upButton"), on_activate_call=self.increase_limit) - self.warn_text = ba.textwidget( + self.warn_text = bui.textwidget( parent=self._root_widget, text="", size=(400, 200), @@ -213,28 +217,28 @@ class SettingWindow(ba.Window): maxwidth=600) # ++++++++++++++++for keyboard navigation++++++++++++++++ - ba.widget(edit=self.enable_button, up_widget=decrease_button, + bui.widget(edit=self.enable_button, up_widget=decrease_button, down_widget=self.lower_text, left_widget=save_button, right_widget=save_button) - ba.widget(edit=save_button, up_widget=self.close_button, down_widget=self.upper_text, + bui.widget(edit=save_button, up_widget=self.close_button, down_widget=self.upper_text, left_widget=self.enable_button, right_widget=self.enable_button) - ba.widget(edit=self.close_button, up_widget=increase_button, down_widget=save_button, + bui.widget(edit=self.close_button, up_widget=increase_button, down_widget=save_button, left_widget=self.enable_button, right_widget=save_button) - ba.widget(edit=self.lower_text, up_widget=self.enable_button, down_widget=decrease_button, + bui.widget(edit=self.lower_text, up_widget=self.enable_button, down_widget=decrease_button, left_widget=self.upper_text, right_widget=self.upper_text) - ba.widget(edit=self.upper_text, up_widget=save_button, down_widget=increase_button, + bui.widget(edit=self.upper_text, up_widget=save_button, down_widget=increase_button, left_widget=self.lower_text, right_widget=self.lower_text) - ba.widget(edit=decrease_button, up_widget=self.lower_text, down_widget=self.enable_button, + bui.widget(edit=decrease_button, up_widget=self.lower_text, down_widget=self.enable_button, left_widget=increase_button, right_widget=increase_button) - ba.widget(edit=increase_button, up_widget=self.upper_text, down_widget=self.close_button, + bui.widget(edit=increase_button, up_widget=self.upper_text, down_widget=self.close_button, left_widget=decrease_button, right_widget=decrease_button) # -------------------------------------------------------------------------------------------------- - ba.textwidget(edit=self.upper_text, on_activate_call=ba.Call(self.on_text_click, "upper")) - ba.textwidget(edit=self.lower_text, on_activate_call=ba.Call(self.on_text_click, "lower")) + bui.textwidget(edit=self.upper_text, on_activate_call=babase.Call(self.on_text_click, "upper")) + bui.textwidget(edit=self.lower_text, on_activate_call=babase.Call(self.on_text_click, "lower")) def on_enableButton_press(self): global loop - loop = ba.app.config.get("moodlightEnabled") + loop = babase.app.config.get("moodlightEnabled") if loop: loop = False label = "ENABLE" @@ -243,49 +247,54 @@ class SettingWindow(ba.Window): loop = True label = "DISABLE" color = (1, 0, 0) - in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession) + in_game = not isinstance(bs.get_foreground_host_session(), mainmenu.MainMenuSession) if in_game: Print("Restart level to apply") - ba.app.config["moodlightEnabled"] = loop - ba.app.config.commit() - ba.buttonwidget(edit=self.enable_button, label=label, color=color) + babase.app.config["moodlightEnabled"] = loop + babase.app.config.commit() + bui.buttonwidget(edit=self.enable_button, label=label, color=color) def save_settings(self): - ba.app.config["moodlightingSettings"] = (Ldefault, Udefault) - ba.app.config.commit() + babase.app.config["moodlightingSettings"] = (Ldefault, Udefault) + babase.app.config.commit() Print("settings saved") self.close() def close(self): - ba.containerwidget(edit=self._root_widget, transition="out_right",) + bui.containerwidget(edit=self._root_widget, transition="out_right",) -def new_chat_message(msg: Union[str, ba.Lstr], clients: Sequence[int] = None, sender_override: str = None): +def new_chat_message(msg: Union[str, babase.Lstr], clients: Sequence[int] = None, sender_override: str = None): old_fcm(msg, clients, sender_override) if msg == 'ml': try: global Ldefault, Udefault - Ldefault, Udefault = ba.app.config.get("moodlightingSettings") + Ldefault, Udefault = babase.app.config.get("moodlightingSettings") SettingWindow() cprint("Mood light settings opened") except Exception as err: Print(err, "-from new_chat_message") - -old_fcm = _ba.chatmessage -_ba.chatmessage = new_chat_message -_ba.set_party_icon_always_visible(True) +class NewMainMenuWindow(MainMenuWindow): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Display chat icon, but if user open/close gather it may disappear + bui.set_party_icon_always_visible(True) + +old_fcm = bs.chatmessage +bs.chatmessage = new_chat_message Map._old_init = Map.__init__ # ba_meta export plugin -class moodlight(ba.Plugin): +class moodlight(babase.Plugin): def __init__(self): pass def on_app_running(self): - _ba.show_progress_bar() + _babase.show_progress_bar() + MainMenuWindow = NewMainMenuWindow def show_settings_ui(self, source_widget): SettingWindow() @@ -298,11 +307,11 @@ class moodlight(ba.Plugin): def _new_init(self, vr_overlay_offset: Optional[Sequence[float]] = None) -> None: self._old_init(vr_overlay_offset) - in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession) + in_game = not isinstance(bs.get_foreground_host_session(), mainmenu.MainMenuSession) if not in_game: return - gnode = _ba.getactivity().globalsnode + gnode = bs.getactivity().globalsnode default_tint = (1.100000023841858, 1.0, 0.8999999761581421) transition_duration = 1.0 # for future improvements @@ -310,16 +319,16 @@ class moodlight(ba.Plugin): if loop: Range = (random.randrange(Ldefault, Udefault)/10, random.randrange(Ldefault, Udefault)/10, random.randrange(Ldefault, Udefault)/10) - ba.animate_array(gnode, 'tint', 3, { + bs.animate_array(gnode, 'tint', 3, { 0.0: gnode.tint, transition_duration: Range }) else: global timer timer = None - ba.animate_array(gnode, "tint", 3, {0.0: gnode.tint, 0.4: default_tint}) + bs.animate_array(gnode, "tint", 3, {0.0: gnode.tint, 0.4: default_tint}) global timer - timer = ba.Timer(0.3, changetint, repeat=True) + timer = bs.Timer(0.3, changetint, repeat=True) Map.__init__ = _new_init diff --git a/plugins/utilities/quick_custom_game.py b/plugins/utilities/quick_custom_game.py index 259dff2..0857514 100644 --- a/plugins/utilities/quick_custom_game.py +++ b/plugins/utilities/quick_custom_game.py @@ -1,22 +1,25 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 # (see https://ballistica.net/wiki/meta-tag-system) from __future__ import annotations from typing import TYPE_CHECKING -import ba -import _ba -from bastd.ui.play import PlayWindow -from bastd.ui.playlist.addgame import PlaylistAddGameWindow -from ba._freeforallsession import FreeForAllSession -from bastd.activity.multiteamjoin import MultiTeamJoinActivity +import babase +import bauiv1 as bui +import bascenev1 as bs +import _babase +from bauiv1lib.play import PlayWindow +from bauiv1lib.playlist.addgame import PlaylistAddGameWindow +from bascenev1._freeforallsession import FreeForAllSession +from bascenev1lib.activity.multiteamjoin import MultiTeamJoinActivity if TYPE_CHECKING: pass -lang = ba.app.lang.language +lang = bs.app.lang.language if lang == 'Spanish': custom_txt = 'personalizar...' @@ -24,30 +27,30 @@ else: custom_txt = 'custom...' -if 'quick_game_button' in ba.app.config: - config = ba.app.config['quick_game_button'] +if 'quick_game_button' in babase.app.config: + config = babase.app.config['quick_game_button'] else: config = {'selected': None, 'config': None} - ba.app.config['quick_game_button'] = config - ba.app.config.commit() + babase.app.config['quick_game_button'] = config + babase.app.config.commit() -def start_game(session: ba.Session, fadeout: bool = True): +def start_game(session: bs.Session, fadeout: bool = True): def callback(): if fadeout: - _ba.unlock_all_input() + _babase.unlock_all_input() try: - _ba.new_host_session(session) + bs.new_host_session(session) except Exception: - from bastd import mainmenu - ba.print_exception('exception running session', session) + from bascenev1lib import mainmenu + babase.print_exception('exception running session', session) # Drop back into a main menu session. - _ba.new_host_session(mainmenu.MainMenuSession) + bs.new_host_session(mainmenu.MainMenuSession) if fadeout: - _ba.fade_screen(False, time=0.25, endcall=callback) - _ba.lock_all_input() + _babase.fade_screen(False, time=0.25, endcall=callback) + _babase.lock_all_input() else: callback() @@ -56,7 +59,7 @@ class SimplePlaylist: def __init__(self, settings: dict, - gametype: type[ba.GameActivity]): + gametype: type[bs.GameActivity]): self.settings = settings self.gametype = gametype @@ -75,7 +78,7 @@ class CustomSession(FreeForAllSession): # pylint: disable=cyclic-import self.use_teams = False self._tutorial_activity_instance = None - ba.Session.__init__(self, depsets=[], + bs.Session.__init__(self, depsets=[], team_names=None, team_colors=None, min_players=1, @@ -89,12 +92,12 @@ class CustomSession(FreeForAllSession): self._playlist = SimplePlaylist(self._config, self._gametype) config['selected'] = self._gametype.__name__ config['config'] = self._config - ba.app.config.commit() + babase.app.config.commit() # Get a game on deck ready to go. self._current_game_spec: Optional[Dict[str, Any]] = None self._next_game_spec: Dict[str, Any] = self._playlist.pull_next() - self._next_game: Type[ba.GameActivity] = ( + self._next_game: Type[bs.GameActivity] = ( self._next_game_spec['resolved_type']) # Go ahead and instantiate the next game we'll @@ -102,71 +105,71 @@ class CustomSession(FreeForAllSession): self._instantiate_next_game() # Start in our custom join screen. - self.setactivity(_ba.newactivity(MultiTeamJoinActivity)) + self.setactivity(bs.newactivity(MultiTeamJoinActivity)) class SelectGameWindow(PlaylistAddGameWindow): def __init__(self, transition: str = 'in_right'): class EditController: - _sessiontype = ba.FreeForAllSession + _sessiontype = bs.FreeForAllSession - def get_session_type(self) -> Type[ba.Session]: + def get_session_type(self) -> Type[bs.Session]: return self._sessiontype self._editcontroller = EditController() self._r = 'addGameWindow' - uiscale = ba.app.ui.uiscale - self._width = 750 if uiscale is ba.UIScale.SMALL else 650 - x_inset = 50 if uiscale is ba.UIScale.SMALL else 0 - self._height = (346 if uiscale is ba.UIScale.SMALL else - 380 if uiscale is ba.UIScale.MEDIUM else 440) - top_extra = 30 if uiscale is ba.UIScale.SMALL else 20 + uiscale = bui.app.ui_v1.uiscale + self._width = 750 if uiscale is babase.UIScale.SMALL else 650 + x_inset = 50 if uiscale is babase.UIScale.SMALL else 0 + self._height = (346 if uiscale is babase.UIScale.SMALL else + 380 if uiscale is babase.UIScale.MEDIUM else 440) + top_extra = 30 if uiscale is babase.UIScale.SMALL else 20 self._scroll_width = 210 - self._root_widget = ba.containerwidget( + self._root_widget = bui.containerwidget( size=(self._width, self._height + top_extra), transition=transition, - scale=(2.17 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), - stack_offset=(0, 1) if uiscale is ba.UIScale.SMALL else (0, 0)) + scale=(2.17 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), + stack_offset=(0, 1) if uiscale is babase.UIScale.SMALL else (0, 0)) - self._back_button = ba.buttonwidget(parent=self._root_widget, + self._back_button = bui.buttonwidget(parent=self._root_widget, position=(58 + x_inset, self._height - 53), size=(165, 70), scale=0.75, text_scale=1.2, - label=ba.Lstr(resource='backText'), + label=babase.Lstr(resource='backText'), autoselect=True, button_type='back', on_activate_call=self._back) - self._select_button = select_button = ba.buttonwidget( + self._select_button = select_button = bui.buttonwidget( parent=self._root_widget, position=(self._width - (172 + x_inset), self._height - 50), autoselect=True, size=(160, 60), scale=0.75, text_scale=1.2, - label=ba.Lstr(resource='selectText'), + label=babase.Lstr(resource='selectText'), on_activate_call=self._add) - if ba.app.ui.use_toolbars: - ba.widget(edit=select_button, - right_widget=_ba.get_special_widget('party_button')) + if bui.app.ui_v1.use_toolbars: + bui.widget(edit=select_button, + right_widget=bui.get_special_widget('party_button')) - ba.textwidget(parent=self._root_widget, + bui.textwidget(parent=self._root_widget, position=(self._width * 0.5, self._height - 28), size=(0, 0), scale=1.0, - text=ba.Lstr(resource=self._r + '.titleText'), + text=babase.Lstr(resource=self._r + '.titleText'), h_align='center', - color=ba.app.ui.title_color, + color=bui.app.ui_v1.title_color, maxwidth=250, v_align='center') v = self._height - 64 - self._selected_title_text = ba.textwidget( + self._selected_title_text = bui.textwidget( parent=self._root_widget, position=(x_inset + self._scroll_width + 50 + 30, v - 15), size=(0, 0), @@ -177,7 +180,7 @@ class SelectGameWindow(PlaylistAddGameWindow): v_align='center') v -= 30 - self._selected_description_text = ba.textwidget( + self._selected_description_text = bui.textwidget( parent=self._root_widget, position=(x_inset + self._scroll_width + 50 + 30, v), size=(0, 0), @@ -190,31 +193,31 @@ class SelectGameWindow(PlaylistAddGameWindow): v = self._height - 60 - self._scrollwidget = ba.scrollwidget(parent=self._root_widget, + self._scrollwidget = bui.scrollwidget(parent=self._root_widget, position=(x_inset + 61, v - scroll_height), size=(self._scroll_width, scroll_height), highlight=False) - ba.widget(edit=self._scrollwidget, + bui.widget(edit=self._scrollwidget, up_widget=self._back_button, left_widget=self._back_button, right_widget=select_button) - self._column: Optional[ba.Widget] = None + self._column: Optional[bui.Widget] = None v -= 35 - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, cancel_button=self._back_button, start_button=select_button) - self._selected_game_type: Optional[Type[ba.GameActivity]] = None + self._selected_game_type: Optional[Type[bs.GameActivity]] = None - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, selected_child=self._scrollwidget) - self._game_types: list[type[ba.GameActivity]] = [] + self._game_types: list[type[bs.GameActivity]] = [] # Get actual games loading in the bg. - ba.app.meta.load_exported_classes(ba.GameActivity, + babase.app.meta.load_exported_classes(bs.GameActivity, self._on_game_types_loaded, completion_cb_in_bg_thread=True) @@ -231,12 +234,12 @@ class SelectGameWindow(PlaylistAddGameWindow): def _refresh(self, select_get_more_games_button: bool = False, selected: bool = None) -> None: - # from ba.internal import get_game_types + # from babase.internal import get_game_types if self._column is not None: self._column.delete() - self._column = ba.columnwidget(parent=self._scrollwidget, + self._column = bui.columnwidget(parent=self._scrollwidget, border=2, margin=0) @@ -244,11 +247,10 @@ class SelectGameWindow(PlaylistAddGameWindow): def _doit() -> None: if self._select_button: - ba.timer(0.1, - self._select_button.activate, - timetype=ba.TimeType.REAL) + bs.apptimer(0.1, + self._select_button.activate) - txt = ba.textwidget(parent=self._column, + txt = bui.textwidget(parent=self._column, position=(0, 0), size=(self._width - 88, 24), text=gametype.get_display_string(), @@ -256,30 +258,30 @@ class SelectGameWindow(PlaylistAddGameWindow): v_align='center', color=(0.8, 0.8, 0.8, 1.0), maxwidth=self._scroll_width * 0.8, - on_select_call=ba.Call( + on_select_call=babase.Call( self._set_selected_game_type, gametype), always_highlight=True, selectable=True, on_activate_call=_doit) if i == 0: - ba.widget(edit=txt, up_widget=self._back_button) + bui.widget(edit=txt, up_widget=self._back_button) - self._get_more_games_button = ba.buttonwidget( + self._get_more_games_button = bui.buttonwidget( parent=self._column, autoselect=True, - label=ba.Lstr(resource=self._r + '.getMoreGamesText'), + label=babase.Lstr(resource=self._r + '.getMoreGamesText'), color=(0.54, 0.52, 0.67), textcolor=(0.7, 0.65, 0.7), on_activate_call=self._on_get_more_games_press, size=(178, 50)) if select_get_more_games_button: - ba.containerwidget(edit=self._column, + bui.containerwidget(edit=self._column, selected_child=self._get_more_games_button, visible_child=self._get_more_games_button) def _add(self) -> None: - _ba.lock_all_input() # Make sure no more commands happen. - ba.timer(0.1, _ba.unlock_all_input, timetype=ba.TimeType.REAL) + _babase.lock_all_input() # Make sure no more commands happen. + bs.apptimer(0.1, _babase.unlock_all_input) gameconfig = {} if config['selected'] == self._selected_game_type.__name__: if config['config']: @@ -297,13 +299,13 @@ class SelectGameWindow(PlaylistAddGameWindow): CustomSession._gametype = self._selected_game_type start_game(CustomSession) else: - ba.app.ui.clear_main_menu_window(transition='out_right') - ba.app.ui.set_main_menu_window( + bui.app.ui_v1.clear_main_menu_window(transition='out_right') + bui.app.ui_v1.set_main_menu_window( SelectGameWindow(transition='in_left').get_root_widget()) def _back(self) -> None: - ba.containerwidget(edit=self._root_widget, transition='out_right') - ba.app.ui.set_main_menu_window( + bui.containerwidget(edit=self._root_widget, transition='out_right') + bui.app.ui_v1.set_main_menu_window( PlayWindow(transition='in_left').get_root_widget()) @@ -318,11 +320,11 @@ def __init__(self, *args, **kwargs): def do_quick_game() -> None: self._save_state() - ba.containerwidget(edit=self._root_widget, transition='out_left') - ba.app.ui.set_main_menu_window( + bui.containerwidget(edit=self._root_widget, transition='out_left') + bui.app.ui_v1.set_main_menu_window( SelectGameWindow().get_root_widget()) - self._quick_game_button = ba.buttonwidget( + self._quick_game_button = bui.buttonwidget( parent=self._root_widget, position=(width - 55 - 120, height - 132), autoselect=True, @@ -350,32 +352,32 @@ def states(self) -> None: def _save_state(self) -> None: swapped = {v: k for k, v in states(self).items()} if self._root_widget.get_selected_child() in swapped: - ba.app.ui.window_states[ + bui.app.ui_v1.window_states[ self.__class__.__name__] = swapped[ self._root_widget.get_selected_child()] else: - ba.print_exception(f'Error saving state for {self}.') + babase.print_exception(f'Error saving state for {self}.') def _restore_state(self) -> None: if not hasattr(self, '_quick_game_button'): return # ensure that our monkey patched init ran - if self.__class__.__name__ not in ba.app.ui.window_states: - ba.containerwidget(edit=self._root_widget, + if self.__class__.__name__ not in bui.app.ui_v1.window_states: + bui.containerwidget(edit=self._root_widget, selected_child=self._coop_button) return sel = states(self).get( - ba.app.ui.window_states[self.__class__.__name__], None) + bui.app.ui_v1.window_states[self.__class__.__name__], None) if sel: - ba.containerwidget(edit=self._root_widget, selected_child=sel) + bui.containerwidget(edit=self._root_widget, selected_child=sel) else: - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, selected_child=self._coop_button) - ba.print_exception(f'Error restoring state for {self}.') + babase.print_exception(f'Error restoring state for {self}.') # ba_meta export plugin -class QuickGamePlugin(ba.Plugin): +class QuickGamePlugin(babase.Plugin): PlayWindow.__init__ = __init__ PlayWindow._save_state = _save_state PlayWindow._restore_state = _restore_state diff --git a/plugins/utilities/quickturn.py b/plugins/utilities/quickturn.py index 976c905..a175a3f 100644 --- a/plugins/utilities/quickturn.py +++ b/plugins/utilities/quickturn.py @@ -1,3 +1,4 @@ +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) """ Quickturn by TheMikirog @@ -9,16 +10,18 @@ No Rights Reserved """ -# ba_meta require api 7 +# ba_meta require api 8 from __future__ import annotations from typing import TYPE_CHECKING -import ba +import babase +import bauiv1 as bui +import bascenev1 as bs import math -import bastd -from bastd.actor.spaz import Spaz +import bascenev1lib +from bascenev1lib.actor.spaz import Spaz if TYPE_CHECKING: pass @@ -26,7 +29,7 @@ if TYPE_CHECKING: # ba_meta export plugin -class Quickturn(ba.Plugin): +class Quickturn(babase.Plugin): class FootConnectMessage: """Spaz started touching the ground""" @@ -46,7 +49,7 @@ class Quickturn(ba.Plugin): if self.node.knockout > 0.0 or self.frozen or self.node.hold_node: return - t_ms = ba.time(timeformat=ba.TimeFormat.MILLISECONDS) + t_ms = bs.time() * 1000 assert isinstance(t_ms, int) if t_ms - self.last_wavedash_time_ms >= self._wavedash_cooldown: @@ -77,7 +80,7 @@ class Quickturn(ba.Plugin): self.last_wavedash_time_ms = t_ms # FX - ba.emitfx(position=self.node.position, + bs.emitfx(position=self.node.position, velocity=(vel[0]*0.5, -1, vel[1]*0.5), chunk_type='spark', count=5, @@ -104,7 +107,7 @@ class Quickturn(ba.Plugin): args[0].grounded = 0 return wrapper - bastd.actor.spaz.Spaz.__init__ = new_spaz_init(bastd.actor.spaz.Spaz.__init__) + bascenev1lib.actor.spaz.Spaz.__init__ = new_spaz_init(bascenev1lib.actor.spaz.Spaz.__init__) def new_factory(func): def wrapper(*args, **kwargs): @@ -112,12 +115,12 @@ class Quickturn(ba.Plugin): args[0].roller_material.add_actions( conditions=('they_have_material', - bastd.gameutils.SharedObjects.get().footing_material), + bascenev1lib.gameutils.SharedObjects.get().footing_material), actions=(('message', 'our_node', 'at_connect', Quickturn.FootConnectMessage), ('message', 'our_node', 'at_disconnect', Quickturn.FootDisconnectMessage))) return wrapper - bastd.actor.spazfactory.SpazFactory.__init__ = new_factory( - bastd.actor.spazfactory.SpazFactory.__init__) + bascenev1lib.actor.spazfactory.SpazFactory.__init__ = new_factory( + bascenev1lib.actor.spazfactory.SpazFactory.__init__) def new_handlemessage(func): def wrapper(*args, **kwargs): @@ -129,7 +132,7 @@ class Quickturn(ba.Plugin): func(*args, **kwargs) return wrapper - bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage) + bascenev1lib.actor.spaz.Spaz.handlemessage = new_handlemessage(bascenev1lib.actor.spaz.Spaz.handlemessage) def new_on_run(func): def wrapper(*args, **kwargs): @@ -137,4 +140,4 @@ class Quickturn(ba.Plugin): Quickturn.wavedash(args[0]) func(*args, **kwargs) return wrapper - bastd.actor.spaz.Spaz.on_run = new_on_run(bastd.actor.spaz.Spaz.on_run) + bascenev1lib.actor.spaz.Spaz.on_run = new_on_run(bascenev1lib.actor.spaz.Spaz.on_run) diff --git a/plugins/utilities/ragdoll_b_gone.py b/plugins/utilities/ragdoll_b_gone.py index 7b8190d..6f229fc 100644 --- a/plugins/utilities/ragdoll_b_gone.py +++ b/plugins/utilities/ragdoll_b_gone.py @@ -1,4 +1,5 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 """ Ragdoll-B-Gone by TheMikirog @@ -18,11 +19,13 @@ from __future__ import annotations from typing import TYPE_CHECKING # Let's import everything we need and nothing more. -import ba -import bastd +import babase +import bauiv1 as bui +import bascenev1 as bs +import bascenev1lib import random -from bastd.actor.spaz import Spaz -from bastd.actor.spazfactory import SpazFactory +from bascenev1lib.actor.spaz import Spaz +from bascenev1lib.actor.spazfactory import SpazFactory if TYPE_CHECKING: pass @@ -30,7 +33,7 @@ if TYPE_CHECKING: # ba_meta export plugin -class RagdollBGone(ba.Plugin): +class RagdollBGone(babase.Plugin): # We use a decorator to add extra code to existing code, increasing mod compatibility. # Any gameplay altering mod should master the decorator! @@ -42,16 +45,16 @@ class RagdollBGone(ba.Plugin): # We're working kind of blindly here, so it's good to have the original function # open in a second window for argument reference. def wrapper(*args, **kwargs): - if isinstance(args[1], ba.DieMessage): # Replace Spaz death behavior + if isinstance(args[1], bs.DieMessage): # Replace Spaz death behavior # Here we play the gamey death noise in Co-op. if not args[1].immediate: if args[0].play_big_death_sound and not args[0]._dead: - ba.playsound(SpazFactory.get().single_player_death_sound) + SpazFactory.get().single_player_death_sound.play() # If our Spaz dies by falling out of the map, we want to keep the ragdoll. # Ragdolls don't impact gameplay if Spaz dies this way, so it's fine if we leave the behavior as is. - if args[1].how == ba.DeathType.FALL: + if args[1].how == bs.DeathType.FALL: # The next two properties are all built-in, so their behavior can't be edited directly without touching the C++ layer. # We can change their values though! # "hurt" property is basically the health bar above the player and the blinking when low on health. @@ -61,7 +64,7 @@ class RagdollBGone(ba.Plugin): # Again, this behavior is built in. We can only trigger it by setting "dead" to True. args[0].node.dead = True # After the death animation ends (which is around 2 seconds) let's remove the Spaz our of existence. - ba.timer(2.0, args[0].node.delete) + bs.timer(2.0, args[0].node.delete) else: # Here's our new behavior! # The idea is to remove the Spaz node and make some sparks for extra flair. @@ -80,7 +83,7 @@ class RagdollBGone(ba.Plugin): args[0].node.position[2]) # This function allows us to spawn particles like sparks and bomb shrapnel. # We're gonna use sparks here. - ba.emitfx(position=pos, # Here we place our edited position. + bs.emitfx(position=pos, # Here we place our edited position. velocity=args[0].node.velocity, # Random amount of sparks between 2 and 5 count=random.randrange(2, 5), @@ -95,10 +98,10 @@ class RagdollBGone(ba.Plugin): # Pick a random death noise sound = death_sounds[random.randrange(len(death_sounds))] # Play the sound where our Spaz is - ba.playsound(sound, position=args[0].node.position) + sound.play(position=args[0].node.position) # Delete our Spaz node immediately. # Removing stuff is weird and prone to errors, so we're gonna delay it. - ba.timer(0.001, args[0].node.delete) + bs.timer(0.001, args[0].node.delete) # Let's mark our Spaz as dead, so he can't die again. # Notice how we're targeting the Spaz and not it's node. @@ -116,4 +119,4 @@ class RagdollBGone(ba.Plugin): # Finally we """travel through the game files""" to replace the function we want with our own version. # We transplant the old function's arguments into our version. - bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage) + bascenev1lib.actor.spaz.Spaz.handlemessage = new_handlemessage(bascenev1lib.actor.spaz.Spaz.handlemessage) diff --git a/plugins/utilities/random_join.py b/plugins/utilities/random_join.py index 955b1a2..e29a599 100644 --- a/plugins/utilities/random_join.py +++ b/plugins/utilities/random_join.py @@ -1,17 +1,19 @@ +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) from __future__ import annotations from typing import TYPE_CHECKING, TypeVar -import _ba -import ba -import ba.internal +import _babase +import babase +import bauiv1 as bui +import bascenev1 as bs import random -from bastd.ui.gather.publictab import PublicGatherTab, PartyEntry, PingThread +from bauiv1lib.gather.publictab import PublicGatherTab, PartyEntry, PingThread if TYPE_CHECKING: from typing import Callable ClassType = TypeVar('ClassType') -MethodType = TypeVar('Methodtype') +MethodType = TypeVar('MethodType') def override(cls: ClassType) -> Callable[[MethodType], MethodType]: @@ -50,26 +52,26 @@ class NewPublicGatherTab(PublicGatherTab, PingThread): v = c_height - 35 v -= 60 - self._random_join_button = ba.buttonwidget( + self._random_join_button = bui.buttonwidget( parent=self._container, label='random', size=(90, 45), position=(710, v + 10), - on_activate_call=ba.WeakCall(self._join_random_server), + on_activate_call=bs.WeakCall(self._join_random_server), ) - ba.widget(edit=self._random_join_button, up_widget=self._host_text, + bui.widget(edit=self._random_join_button, up_widget=self._host_text, left_widget=self._filter_text) # We could place it somewhere under plugin settings which is kind of # official way to customise plugins. Although it's too deep: # Gather Window -> Main Menu -> Settings -> Advanced -(scroll)-> # Plugins -(scroll probably)-> RandomJoin Settings. - self._random_join_settings_button = ba.buttonwidget( + self._random_join_settings_button = bui.buttonwidget( parent=self._container, - icon=ba.gettexture('settingsIcon'), + icon=bui.gettexture('settingsIcon'), size=(40, 40), position=(820, v + 13), - on_activate_call=ba.WeakCall(self._show_random_join_settings), + on_activate_call=bs.WeakCall(self._show_random_join_settings), ) @override(PublicGatherTab) @@ -97,9 +99,9 @@ class NewPublicGatherTab(PublicGatherTab, PingThread): and p.ping <= randomjoin.maximum_ping)))] if not parties: - ba.screenmessage('No suitable servers found; wait', + bui.screenmessage('No suitable servers found; wait', color=(1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.getsound('error').play() return for party in parties: @@ -110,33 +112,33 @@ class NewPublicGatherTab(PublicGatherTab, PingThread): party = random.choice( [p for p in parties if p.name[:6] in name_prefixes]) - ba.internal.connect_to_party(party.address, party.port) + bs.connect_to_party(party.address, party.port) -class RandomJoinSettingsPopup(ba.Window): - def __init__(self, origin_widget: ba.Widget) -> None: +class RandomJoinSettingsPopup(bui.Window): + def __init__(self, origin_widget: bui.Widget) -> None: c_width = 600 c_height = 400 - uiscale = ba.app.ui.uiscale - super().__init__(root_widget=ba.containerwidget( + uiscale = bui.app.ui_v1.uiscale + super().__init__(root_widget=bui.containerwidget( scale=( 1.8 - if uiscale is ba.UIScale.SMALL + if uiscale is babase.UIScale.SMALL else 1.55 - if uiscale is ba.UIScale.MEDIUM + if uiscale is babase.UIScale.MEDIUM else 1.0 ), scale_origin_stack_offset=origin_widget.get_screen_space_center(), stack_offset=(0, -10) - if uiscale is ba.UIScale.SMALL + if uiscale is babase.UIScale.SMALL else (0, 15) - if uiscale is ba.UIScale.MEDIUM + if uiscale is babase.UIScale.MEDIUM else (0, 0), size=(c_width, c_height), transition='in_scale', )) - ba.textwidget( + bui.textwidget( parent=self._root_widget, size=(0, 0), h_align='center', @@ -149,7 +151,7 @@ class RandomJoinSettingsPopup(ba.Window): ) v = c_height - 120 - ba.textwidget( + bui.textwidget( parent=self._root_widget, size=(0, 0), h_align='right', @@ -158,7 +160,7 @@ class RandomJoinSettingsPopup(ba.Window): maxwidth=c_width * 0.3, position=(c_width * 0.4, v), ) - self._maximum_ping_edit = ba.textwidget( + self._maximum_ping_edit = bui.textwidget( parent=self._root_widget, size=(c_width * 0.3, 40), h_align='left', @@ -171,7 +173,7 @@ class RandomJoinSettingsPopup(ba.Window): max_chars=4, ) v -= 60 - ba.textwidget( + bui.textwidget( parent=self._root_widget, size=(0, 0), h_align='right', @@ -180,7 +182,7 @@ class RandomJoinSettingsPopup(ba.Window): maxwidth=c_width * 0.3, position=(c_width * 0.4, v), ) - self._minimum_players_edit = ba.textwidget( + self._minimum_players_edit = bui.textwidget( parent=self._root_widget, size=(c_width * 0.3, 40), h_align='left', @@ -195,27 +197,27 @@ class RandomJoinSettingsPopup(ba.Window): v -= 60 # Cancel button. - self.cancel_button = btn = ba.buttonwidget( + self.cancel_button = btn = bui.buttonwidget( parent=self._root_widget, - label=ba.Lstr(resource='cancelText'), + label=babase.Lstr(resource='cancelText'), size=(180, 60), color=(1.0, 0.2, 0.2), position=(40, 30), on_activate_call=self._cancel, autoselect=True, ) - ba.containerwidget(edit=self._root_widget, cancel_button=btn) + bui.containerwidget(edit=self._root_widget, cancel_button=btn) # Save button. - self.savebtn = btn = ba.buttonwidget( + self.savebtn = btn = bui.buttonwidget( parent=self._root_widget, - label=ba.Lstr(resource='saveText'), + label=babase.Lstr(resource='saveText'), size=(180, 60), position=(c_width - 200, 30), on_activate_call=self._save, autoselect=True, ) - ba.containerwidget(edit=self._root_widget, start_button=btn) + bui.containerwidget(edit=self._root_widget, start_button=btn) def _save(self) -> None: errored = False @@ -223,19 +225,19 @@ class RandomJoinSettingsPopup(ba.Window): maximum_ping: int | None = None try: minimum_players = int( - ba.textwidget(query=self._minimum_players_edit)) + bui.textwidget(query=self._minimum_players_edit)) except ValueError: - ba.screenmessage('"Minimum players" should be integer', + bui.screenmessage('"Minimum players" should be integer', color=(1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.getsound('error').play() errored = True try: maximum_ping = int( - ba.textwidget(query=self._maximum_ping_edit)) + bui.textwidget(query=self._maximum_ping_edit)) except ValueError: - ba.screenmessage('"Maximum ping" should be integer', + bui.screenmessage('"Maximum ping" should be integer', color=(1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.getsound('error').play() errored = True if errored: return @@ -244,16 +246,16 @@ class RandomJoinSettingsPopup(ba.Window): assert maximum_ping is not None if minimum_players < 0: - ba.screenmessage('"Minimum players" should be at least 0', + bui.screenmessage('"Minimum players" should be at least 0', color=(1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.getsound('error').play() errored = True if maximum_ping <= 0: - ba.screenmessage('"Maximum ping" should be greater than 0', + bui.screenmessage('"Maximum ping" should be greater than 0', color=(1, 0, 0)) - ba.playsound(ba.getsound('error')) - ba.screenmessage('(use 9999 as dont-care value)', + bui.getsound('error').play() + bui.screenmessage('(use 9999 as dont-care value)', color=(1, 0, 0)) errored = True @@ -264,15 +266,15 @@ class RandomJoinSettingsPopup(ba.Window): randomjoin.minimum_players = minimum_players randomjoin.commit_config() - ba.playsound(ba.getsound('shieldUp')) + bui.getsound('shieldUp').play() self._transition_out() def _cancel(self) -> None: - ba.playsound(ba.getsound('shieldDown')) + bui.getsound('shieldDown').play() self._transition_out() def _transition_out(self) -> None: - ba.containerwidget(edit=self._root_widget, transition='out_scale') + bui.containerwidget(edit=self._root_widget, transition='out_scale') class RandomJoin: @@ -283,7 +285,7 @@ class RandomJoin: self.load_config() def load_config(self) -> None: - cfg = ba.app.config.get('Random Join', { + cfg = babase.app.config.get('Random Join', { 'maximum_ping': self.maximum_ping, 'minimum_players': self.minimum_players, }) @@ -291,25 +293,25 @@ class RandomJoin: self.maximum_ping = cfg['maximum_ping'] self.minimum_players = cfg['minimum_players'] except KeyError: - ba.screenmessage('Error: RandomJoin config is broken, resetting..', + bui.screenmessage('Error: RandomJoin config is broken, resetting..', color=(1, 0, 0), log=True) - ba.playsound(ba.getsound('error')) + bui.getsound('error').play() self.commit_config() def commit_config(self) -> None: - ba.app.config['Random Join'] = { + babase.app.config['Random Join'] = { 'maximum_ping': self.maximum_ping, 'minimum_players': self.minimum_players, } - ba.app.config.commit() + babase.app.config.commit() randomjoin = RandomJoin() -# ba_meta require api 7 -# ba_meta export ba.Plugin -class RandomJoinPlugin(ba.Plugin): +# ba_meta require api 8 +# ba_meta export babase.Plugin +class RandomJoinPlugin(babase.Plugin): def on_app_running(self) -> None: # I feel bad that all patching logic happens not here. pass diff --git a/plugins/utilities/tnt_respawn_text.py b/plugins/utilities/tnt_respawn_text.py index 5005109..52b7f72 100644 --- a/plugins/utilities/tnt_respawn_text.py +++ b/plugins/utilities/tnt_respawn_text.py @@ -1,4 +1,5 @@ -# ba_meta require api 7 +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) +# ba_meta require api 8 """ TNT Respawn Text by TheMikirog @@ -16,11 +17,13 @@ from __future__ import annotations from typing import TYPE_CHECKING # Let's import everything we need and nothing more. -import ba -import bastd +import babase +import bauiv1 as bui +import bascenev1 as bs +import bascenev1lib import math import random -from bastd.actor.bomb import Bomb +from bascenev1lib.actor.bomb import Bomb if TYPE_CHECKING: pass @@ -40,7 +43,7 @@ if TYPE_CHECKING: # ba_meta export plugin -class TNTRespawnText(ba.Plugin): +class TNTRespawnText(babase.Plugin): # This clamping function will make sure a certain value can't go above or below a certain threshold. # We're gonna need this functionality in just a bit. @@ -54,7 +57,7 @@ class TNTRespawnText(ba.Plugin): def on_tnt_exploded(self): self.tnt_has_callback = False self._respawn_text.color = (1.0, 1.0, 1.0) - ba.animate( + bs.animate( self._respawn_text, 'opacity', { @@ -92,7 +95,7 @@ class TNTRespawnText(ba.Plugin): respawn_text_position = (args[0]._position[0], args[0]._position[1] - 0.4, args[0]._position[2]) - args[0]._respawn_text = ba.newnode( + args[0]._respawn_text = bs.newnode( 'text', attrs={ 'text': "", # we'll set the text later @@ -126,7 +129,7 @@ class TNTRespawnText(ba.Plugin): args[0]._tnt.node.add_death_action(tnt_callback) return wrapper # Let's replace the original init function with our modified version. - bastd.actor.bomb.TNTSpawner.__init__ = new_init(bastd.actor.bomb.TNTSpawner.__init__) + bascenev1lib.actor.bomb.TNTSpawner.__init__ = new_init(bascenev1lib.actor.bomb.TNTSpawner.__init__) # Our modified update function. # This gets called every 1.1s. Check the TNTSpawner class in the game's code for details. @@ -165,7 +168,7 @@ class TNTRespawnText(ba.Plugin): # Code goes here if we don't have a TNT box and we reached 100%. if args[0]._tnt is None or args[0]._wait_time >= args[0]._respawn_time and args[0]._respawn_text: # Animate the text "bounce" to draw attention - ba.animate( + bs.animate( args[0]._respawn_text, 'scale', { @@ -176,7 +179,7 @@ class TNTRespawnText(ba.Plugin): }, ) # Fade the text away - ba.animate( + bs.animate( args[0]._respawn_text, 'opacity', { @@ -191,7 +194,7 @@ class TNTRespawnText(ba.Plugin): args[0]._respawn_text.color = (1.0, 0.75, 0.5) # Make some sparks to draw the eye. - ba.emitfx( + bs.emitfx( position=args[0]._position, count=int(5.0 + random.random() * 10), scale=0.8, @@ -212,4 +215,4 @@ class TNTRespawnText(ba.Plugin): return wrapper # Let's replace the original update function with our modified version. - bastd.actor.bomb.TNTSpawner._update = new_update(bastd.actor.bomb.TNTSpawner._update) + bascenev1lib.actor.bomb.TNTSpawner._update = new_update(bascenev1lib.actor.bomb.TNTSpawner._update) diff --git a/plugins/utilities/ultra_party_window.py b/plugins/utilities/ultra_party_window.py index 2d39444..712b7be 100644 --- a/plugins/utilities/ultra_party_window.py +++ b/plugins/utilities/ultra_party_window.py @@ -1,7 +1,8 @@ +# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport) __author__ = 'Droopy' __version__ = 4.0 -# ba_meta require api 7 +# ba_meta require api 8 import datetime import json import math @@ -15,13 +16,17 @@ from threading import Thread from typing import List, Tuple, Sequence, Optional, Dict, Any, cast from hashlib import md5 -import _ba -import ba -import bastd.ui.party -from bastd.ui.colorpicker import ColorPickerExact -from bastd.ui.confirm import ConfirmWindow -from bastd.ui.mainmenu import MainMenuWindow -from bastd.ui.popup import PopupMenuWindow, PopupWindow, PopupMenu +import _babase +import babase +import bauiv1 as bui +import bascenev1 as bs +import bauiv1lib.party +from bauiv1lib.colorpicker import ColorPickerExact +from bauiv1lib import mainmenu +from bauiv1lib.confirm import ConfirmWindow +from bauiv1lib.mainmenu import MainMenuWindow +from bauiv1lib.popup import PopupMenuWindow, PopupWindow, PopupMenu +from baenv import TARGET_BALLISTICA_BUILD as build_number _ip = '127.0.0.1' _port = 43210 @@ -29,7 +34,7 @@ _ping = '-' url = 'http://bombsquadprivatechat.ml' last_msg = None -my_directory = _ba.env()['python_directory_user'] + '/UltraPartyWindowFiles/' +my_directory = _babase.env()['python_directory_user'] + '/UltraPartyWindowFiles/' quick_msg_file = my_directory + 'QuickMessages.txt' cookies_file = my_directory + 'cookies.txt' saved_ids_file = my_directory + 'saved_ids.json' @@ -51,7 +56,7 @@ def initialize(): 'Translate Destination Language': 'en', 'Pronunciation': True } - config = ba.app.config + config = babase.app.config for key in config_defaults: if key not in config: config[key] = config_defaults[key] @@ -69,17 +74,17 @@ def initialize(): def display_error(msg=None): if msg: - ba.screenmessage(msg, (1, 0, 0)) + bui.screenmessage(msg, (1, 0, 0)) else: - ba.screenmessage('Failed!', (1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.screenmessage('Failed!', (1, 0, 0)) + bui.getsound('error').play() def display_success(msg=None): if msg: - ba.screenmessage(msg, (0, 1, 0)) + bui.screenmessage(msg, (0, 1, 0)) else: - ba.screenmessage('Successful!', (0, 1, 0)) + bui.screenmessage('Successful!', (0, 1, 0)) class Translate(Thread): @@ -89,10 +94,10 @@ class Translate(Thread): self._callback = callback def run(self): - _ba.pushcall(ba.Call(ba.screenmessage, 'Translating...'), from_other_thread=True) + _babase.pushcall(babase.Call(bui.screenmessage, 'Translating...'), from_other_thread=True) response = messenger._send_request(f'{url}/translate', self.data) if response: - _ba.pushcall(ba.Call(self._callback, response), from_other_thread=True) + _babase.pushcall(babase.Call(self._callback, response), from_other_thread=True) class ColorTracker: @@ -103,7 +108,7 @@ class ColorTracker: while True: color = (random.random(), random.random(), random.random()) s = 0 - background = ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) + background = babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) for i, j in zip(color, background): s += (i - j) ** 2 if s > 0.1: @@ -184,7 +189,7 @@ class PrivateChatHandler: pickle.dump(cookies, f) def _cookie_login(self): - self.myid = ba.internal.get_v1_account_misc_read_val_2('resolvedAccountID', '') + self.myid = bui.app.plus.get_v1_account_misc_read_val_2('resolvedAccountID', '') try: with open(cookies_file, 'rb') as f: cookies = pickle.load(f) @@ -202,7 +207,7 @@ class PrivateChatHandler: return True def _login(self, registration_key): - self.myid = ba.internal.get_v1_account_misc_read_val_2('resolvedAccountID', '') + self.myid = bui.app.plus.get_v1_account_misc_read_val_2('resolvedAccountID', '') data = dict(pb_id=self.myid, registration_key=registration_key) response = self._send_request(url=f'{url}/login', data=data) if response == 'successful': @@ -260,8 +265,8 @@ class PrivateChatHandler: def _remove_id(self, account_id): removed = self.saved_ids.pop(account_id) self._dump_ids() - ba.screenmessage(f'Removed successfully: {removed}({account_id})', (0, 1, 0)) - ba.playsound(ba.getsound('shieldDown')) + bui.screenmessage(f'Removed successfully: {removed}({account_id})', (0, 1, 0)) + bui.getsound('shieldDown').play() def _format_message(self, msg): filter = msg['filter'] @@ -284,7 +289,7 @@ class PrivateChatHandler: else: last_seen = info["last_seen"] last_seen = _get_local_time(last_seen) - ba.screenmessage(f'Last seen on: {last_seen}') + bui.screenmessage(f'Last seen on: {last_seen}') def _get_local_time(utctime): @@ -296,8 +301,8 @@ def _get_local_time(utctime): def update_status(): if messenger.logged_in: - if ba.app.config['Self Status'] == 'online': - host = _ba.get_connection_to_host_info().get('name', '') + if babase.app.config['Self Status'] == 'online': + host = bs.get_connection_to_host_info().get('name', '') if build_number < 21697 else bs.get_connection_to_host_info_2().get('name', '') if host: my_status = f'Playing in {host}' else: @@ -357,45 +362,45 @@ def check_new_message(): def display_message(msg, msg_type, filter=None, sent=None): flag = None - notification = ba.app.config['Message Notification'] - if _ba.app.ui.party_window: - if _ba.app.ui.party_window(): - if _ba.app.ui.party_window()._private_chat: + notification = babase.app.config['Message Notification'] + if bui.app.ui_v1.party_window: + if bui.app.ui_v1.party_window(): + if bui.app.ui_v1.party_window()._private_chat: flag = 1 if msg_type == 'private': if messenger.filter == filter or messenger.filter == 'all': - _ba.app.ui.party_window().on_chat_message(msg, sent) + bui.app.ui_v1.party_window().on_chat_message(msg, sent) else: if notification == 'top': - ba.screenmessage(msg, (1, 1, 0), True, ba.gettexture('coin')) + bui.screenmessage(msg, (1, 1, 0), True, bui.gettexture('coin')) else: - ba.screenmessage(msg, (1, 1, 0), False) + bui.screenmessage(msg, (1, 1, 0), False) else: - ba.screenmessage(msg, (0.2, 1.0, 1.0), True, ba.gettexture('circleShadow')) + bui.screenmessage(msg, (0.2, 1.0, 1.0), True, bui.gettexture('circleShadow')) else: flag = 1 if msg_type == 'private': if notification == 'top': - ba.screenmessage(msg, (1, 1, 0), True, ba.gettexture('coin')) + bui.screenmessage(msg, (1, 1, 0), True, bui.gettexture('coin')) else: - ba.screenmessage(msg, (1, 1, 0), False) + bui.screenmessage(msg, (1, 1, 0), False) if not flag: if msg_type == 'private': if notification == 'top': - ba.screenmessage(msg, (1, 1, 0), True, ba.gettexture('coin')) + bui.screenmessage(msg, (1, 1, 0), True, bui.gettexture('coin')) else: - ba.screenmessage(msg, (1, 1, 0), False) + bui.screenmessage(msg, (1, 1, 0), False) else: - ba.screenmessage(msg, (0.2, 1.0, 1.0), True, ba.gettexture('circleShadow')) + bui.screenmessage(msg, (0.2, 1.0, 1.0), True, bui.gettexture('circleShadow')) def msg_displayer(): for msg in messenger.pending_messages: display_message(msg[0], 'private', msg[1], msg[2]) messenger.pending_messages.remove(msg) - if ba.app.config['Chat Muted'] and not ba.app.config['Party Chat Muted']: + if babase.app.config['Chat Muted'] and not babase.app.config['Party Chat Muted']: global last_msg - last = _ba.get_chat_messages() + last = bs.get_chat_messages() lm = last[-1] if last else None if lm != last_msg: last_msg = lm @@ -404,45 +409,45 @@ def msg_displayer(): class SortQuickMessages: def __init__(self): - uiscale = ba.app.ui.uiscale - bg_color = ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) - self._width = 750 if uiscale is ba.UIScale.SMALL else 600 - self._height = (300 if uiscale is ba.UIScale.SMALL else - 325 if uiscale is ba.UIScale.MEDIUM else 350) - self._root_widget = ba.containerwidget( + uiscale = bui.app.ui_v1.uiscale + bg_color = babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) + self._width = 750 if uiscale is babase.UIScale.SMALL else 600 + self._height = (300 if uiscale is babase.UIScale.SMALL else + 325 if uiscale is babase.UIScale.MEDIUM else 350) + self._root_widget = bui.containerwidget( size=(self._width, self._height), transition='in_right', on_outside_click_call=self._save, color=bg_color, - parent=_ba.get_special_widget('overlay_stack'), - scale=(2.0 if uiscale is ba.UIScale.SMALL else - 1.3 if uiscale is ba.UIScale.MEDIUM else 1.0), - stack_offset=(0, -16) if uiscale is ba.UIScale.SMALL else (0, 0)) - ba.textwidget(parent=self._root_widget, + parent=bui.get_special_widget('overlay_stack'), + scale=(2.0 if uiscale is babase.UIScale.SMALL else + 1.3 if uiscale is babase.UIScale.MEDIUM else 1.0), + stack_offset=(0, -16) if uiscale is babase.UIScale.SMALL else (0, 0)) + bui.textwidget(parent=self._root_widget, position=(-10, self._height - 50), size=(self._width, 25), text='Sort Quick Messages', - color=ba.app.ui.title_color, + color=bui.app.ui_v1.title_color, scale=1.05, h_align='center', v_align='center', maxwidth=270) b_textcolor = (0.4, 0.75, 0.5) - up_button = ba.buttonwidget(parent=self._root_widget, + up_button = bui.buttonwidget(parent=self._root_widget, position=(10, 170), size=(75, 75), on_activate_call=self._move_up, - label=ba.charstr(ba.SpecialChar.UP_ARROW), + label=babase.charstr(babase.SpecialChar.UP_ARROW), button_type='square', color=bg_color, textcolor=b_textcolor, autoselect=True, repeat=True) - down_button = ba.buttonwidget(parent=self._root_widget, + down_button = bui.buttonwidget(parent=self._root_widget, position=(10, 75), size=(75, 75), on_activate_call=self._move_down, - label=ba.charstr(ba.SpecialChar.DOWN_ARROW), + label=babase.charstr(babase.SpecialChar.DOWN_ARROW), button_type='square', color=bg_color, textcolor=b_textcolor, @@ -450,12 +455,12 @@ class SortQuickMessages: repeat=True) self._scroll_width = self._width - 150 self._scroll_height = self._height - 110 - self._scrollwidget = ba.scrollwidget( + self._scrollwidget = bui.scrollwidget( parent=self._root_widget, size=(self._scroll_width, self._scroll_height), color=bg_color, position=(100, 40)) - self._columnwidget = ba.columnwidget( + self._columnwidget = bui.columnwidget( parent=self._scrollwidget, border=2, margin=0) @@ -463,25 +468,25 @@ class SortQuickMessages: self.msgs = f.read().split('\n') self._msg_selected = None self._refresh() - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, on_cancel_call=self._save) def _refresh(self): for child in self._columnwidget.get_children(): child.delete() for msg in enumerate(self.msgs): - txt = ba.textwidget( + txt = bui.textwidget( parent=self._columnwidget, size=(self._scroll_width - 10, 30), selectable=True, always_highlight=True, - on_select_call=ba.Call(self._on_msg_select, msg), + on_select_call=babase.Call(self._on_msg_select, msg), text=msg[1], h_align='left', v_align='center', maxwidth=self._scroll_width) if msg == self._msg_selected: - ba.columnwidget(edit=self._columnwidget, + bui.columnwidget(edit=self._columnwidget, selected_child=txt, visible_child=txt) @@ -509,20 +514,20 @@ class SortQuickMessages: with open(quick_msg_file, 'w') as f: f.write('\n'.join(self.msgs)) except: - ba.print_exception() - ba.screenmessage('Error!', (1, 0, 0)) - ba.containerwidget( + babase.print_exception() + bui.screenmessage('Error!', (1, 0, 0)) + bui.containerwidget( edit=self._root_widget, transition='out_right') class TranslationSettings: def __init__(self): - uiscale = ba.app.ui.uiscale - height = (300 if uiscale is ba.UIScale.SMALL else - 350 if uiscale is ba.UIScale.MEDIUM else 400) - width = (500 if uiscale is ba.UIScale.SMALL else - 600 if uiscale is ba.UIScale.MEDIUM else 650) + uiscale = bui.app.ui_v1.uiscale + height = (300 if uiscale is babase.UIScale.SMALL else + 350 if uiscale is babase.UIScale.MEDIUM else 400) + width = (500 if uiscale is babase.UIScale.SMALL else + 600 if uiscale is babase.UIScale.MEDIUM else 650) self._transition_out: Optional[str] scale_origin: Optional[Tuple[float, float]] self._transition_out = 'out_scale' @@ -530,7 +535,7 @@ class TranslationSettings: transition = 'in_scale' scale_origin = None cancel_is_selected = False - cfg = ba.app.config + cfg = babase.app.config bg_color = cfg.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) LANGUAGES = { @@ -643,17 +648,17 @@ class TranslationSettings: 'yo': 'yoruba', 'zu': 'zulu'} - self.root_widget = ba.containerwidget( + self.root_widget = bui.containerwidget( size=(width, height), color=bg_color, transition=transition, toolbar_visibility='menu_minimal_no_back', - parent=_ba.get_special_widget('overlay_stack'), + parent=bui.get_special_widget('overlay_stack'), on_outside_click_call=self._cancel, - scale=(2.1 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), + scale=(2.1 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), scale_origin_stack_offset=scale_origin) - ba.textwidget(parent=self.root_widget, + bui.textwidget(parent=self.root_widget, position=(width * 0.5, height - 45), size=(20, 20), h_align='center', @@ -661,15 +666,15 @@ class TranslationSettings: text="Text Translation", scale=0.9, color=(5, 5, 5)) - cbtn = btn = ba.buttonwidget(parent=self.root_widget, + cbtn = btn = bui.buttonwidget(parent=self.root_widget, autoselect=True, position=(30, height - 60), size=(30, 30), - label=ba.charstr(ba.SpecialChar.BACK), + label=babase.charstr(babase.SpecialChar.BACK), button_type='backSmall', on_activate_call=self._cancel) - source_lang_text = ba.textwidget(parent=self.root_widget, + source_lang_text = bui.textwidget(parent=self.root_widget, position=(40, height - 110), size=(20, 20), h_align='left', @@ -680,17 +685,17 @@ class TranslationSettings: source_lang_menu = PopupMenu( parent=self.root_widget, - position=(330 if uiscale is ba.UIScale.SMALL else 400, height - 115), + position=(330 if uiscale is babase.UIScale.SMALL else 400, height - 115), width=200, - scale=(2.8 if uiscale is ba.UIScale.SMALL else - 1.8 if uiscale is ba.UIScale.MEDIUM else 1.2), + scale=(2.8 if uiscale is babase.UIScale.SMALL else + 1.8 if uiscale is babase.UIScale.MEDIUM else 1.2), current_choice=cfg['Translate Source Language'], choices=LANGUAGES.keys(), - choices_display=(ba.Lstr(value=i) for i in LANGUAGES.values()), + choices_display=(babase.Lstr(value=i) for i in LANGUAGES.values()), button_size=(130, 35), on_value_change_call=self._change_source) - destination_lang_text = ba.textwidget(parent=self.root_widget, + destination_lang_text = bui.textwidget(parent=self.root_widget, position=(40, height - 165), size=(20, 20), h_align='left', @@ -701,19 +706,19 @@ class TranslationSettings: destination_lang_menu = PopupMenu( parent=self.root_widget, - position=(330 if uiscale is ba.UIScale.SMALL else 400, height - 170), + position=(330 if uiscale is babase.UIScale.SMALL else 400, height - 170), width=200, - scale=(2.8 if uiscale is ba.UIScale.SMALL else - 1.8 if uiscale is ba.UIScale.MEDIUM else 1.2), + scale=(2.8 if uiscale is babase.UIScale.SMALL else + 1.8 if uiscale is babase.UIScale.MEDIUM else 1.2), current_choice=cfg['Translate Destination Language'], choices=list(LANGUAGES.keys())[1:], - choices_display=list(ba.Lstr(value=i) for i in LANGUAGES.values())[1:], + choices_display=list(babase.Lstr(value=i) for i in LANGUAGES.values())[1:], button_size=(130, 35), on_value_change_call=self._change_destination) try: - translation_mode_text = ba.textwidget(parent=self.root_widget, + translation_mode_text = bui.textwidget(parent=self.root_widget, position=(40, height - 215), size=(20, 20), h_align='left', @@ -721,7 +726,7 @@ class TranslationSettings: text="Translate Mode", scale=0.9, color=(1, 1, 1)) - decoration = ba.textwidget(parent=self.root_widget, + decoration = bui.textwidget(parent=self.root_widget, position=(40, height - 225), size=(20, 20), h_align='left', @@ -730,7 +735,7 @@ class TranslationSettings: scale=0.9, color=(1, 1, 1)) - language_char_text = ba.textwidget(parent=self.root_widget, + language_char_text = bui.textwidget(parent=self.root_widget, position=(85, height - 273), size=(20, 20), h_align='left', @@ -739,7 +744,7 @@ class TranslationSettings: scale=0.6, color=(1, 1, 1)) - pronunciation_text = ba.textwidget(parent=self.root_widget, + pronunciation_text = bui.textwidget(parent=self.root_widget, position=(295, height - 273), size=(20, 20), h_align='left', @@ -748,9 +753,9 @@ class TranslationSettings: scale=0.6, color=(1, 1, 1)) - from bastd.ui.radiogroup import make_radio_group - cur_val = ba.app.config.get('Pronunciation', True) - cb1 = ba.checkboxwidget( + from bauiv1lib.radiogroup import make_radio_group + cur_val = babase.app.config.get('Pronunciation', True) + cb1 = bui.checkboxwidget( parent=self.root_widget, position=(250, height - 275), size=(20, 20), @@ -758,7 +763,7 @@ class TranslationSettings: scale=1, autoselect=True, text="") - cb2 = ba.checkboxwidget( + cb2 = bui.checkboxwidget( parent=self.root_widget, position=(40, height - 275), size=(20, 20), @@ -772,40 +777,40 @@ class TranslationSettings: print(e) pass - ba.containerwidget(edit=self.root_widget, cancel_button=btn) + bui.containerwidget(edit=self.root_widget, cancel_button=btn) def _change_source(self, choice): - cfg = ba.app.config + cfg = babase.app.config cfg['Translate Source Language'] = choice cfg.apply_and_commit() def _change_destination(self, choice): - cfg = ba.app.config + cfg = babase.app.config cfg['Translate Destination Language'] = choice cfg.apply_and_commit() def _actions_changed(self, v: str) -> None: - cfg = ba.app.config + cfg = babase.app.config cfg['Pronunciation'] = v cfg.apply_and_commit() def _cancel(self) -> None: - ba.containerwidget(edit=self.root_widget, transition='out_scale') + bui.containerwidget(edit=self.root_widget, transition='out_scale') SettingsWindow() class SettingsWindow: def __init__(self): - uiscale = ba.app.ui.uiscale - height = (300 if uiscale is ba.UIScale.SMALL else - 350 if uiscale is ba.UIScale.MEDIUM else 400) - width = (500 if uiscale is ba.UIScale.SMALL else - 600 if uiscale is ba.UIScale.MEDIUM else 650) - scroll_h = (200 if uiscale is ba.UIScale.SMALL else - 250 if uiscale is ba.UIScale.MEDIUM else 270) - scroll_w = (450 if uiscale is ba.UIScale.SMALL else - 550 if uiscale is ba.UIScale.MEDIUM else 600) + uiscale = bui.app.ui_v1.uiscale + height = (300 if uiscale is babase.UIScale.SMALL else + 350 if uiscale is babase.UIScale.MEDIUM else 400) + width = (500 if uiscale is babase.UIScale.SMALL else + 600 if uiscale is babase.UIScale.MEDIUM else 650) + scroll_h = (200 if uiscale is babase.UIScale.SMALL else + 250 if uiscale is babase.UIScale.MEDIUM else 270) + scroll_w = (450 if uiscale is babase.UIScale.SMALL else + 550 if uiscale is babase.UIScale.MEDIUM else 600) self._transition_out: Optional[str] scale_origin: Optional[Tuple[float, float]] self._transition_out = 'out_scale' @@ -813,20 +818,20 @@ class SettingsWindow: transition = 'in_scale' scale_origin = None cancel_is_selected = False - cfg = ba.app.config + cfg = babase.app.config bg_color = cfg.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) - self.root_widget = ba.containerwidget( + self.root_widget = bui.containerwidget( size=(width, height), color=bg_color, transition=transition, toolbar_visibility='menu_minimal_no_back', - parent=_ba.get_special_widget('overlay_stack'), + parent=bui.get_special_widget('overlay_stack'), on_outside_click_call=self._cancel, - scale=(2.1 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), + scale=(2.1 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), scale_origin_stack_offset=scale_origin) - ba.textwidget(parent=self.root_widget, + bui.textwidget(parent=self.root_widget, position=(width * 0.5, height - 45), size=(20, 20), h_align='center', @@ -834,25 +839,25 @@ class SettingsWindow: text="Custom Settings", scale=0.9, color=(5, 5, 5)) - cbtn = btn = ba.buttonwidget(parent=self.root_widget, + cbtn = btn = bui.buttonwidget(parent=self.root_widget, autoselect=True, position=(30, height - 60), size=(30, 30), - label=ba.charstr(ba.SpecialChar.BACK), + label=babase.charstr(babase.SpecialChar.BACK), button_type='backSmall', on_activate_call=self._cancel) - scroll_position = (30 if uiscale is ba.UIScale.SMALL else - 40 if uiscale is ba.UIScale.MEDIUM else 50) - self._scrollwidget = ba.scrollwidget(parent=self.root_widget, + scroll_position = (30 if uiscale is babase.UIScale.SMALL else + 40 if uiscale is babase.UIScale.MEDIUM else 50) + self._scrollwidget = bui.scrollwidget(parent=self.root_widget, position=(30, scroll_position), simple_culling_v=20.0, highlight=False, size=(scroll_w, scroll_h), selection_loops_to_parent=True) - ba.widget(edit=self._scrollwidget, right_widget=self._scrollwidget) - self._subcontainer = ba.columnwidget(parent=self._scrollwidget, + bui.widget(edit=self._scrollwidget, right_widget=self._scrollwidget) + self._subcontainer = bui.columnwidget(parent=self._scrollwidget, selection_loops_to_parent=True) - ip_button = ba.checkboxwidget( + ip_button = bui.checkboxwidget( parent=self._subcontainer, size=(300, 30), maxwidth=300, @@ -862,7 +867,7 @@ class SettingsWindow: autoselect=True, text="IP Button", on_value_change_call=self.ip_button) - ping_button = ba.checkboxwidget( + ping_button = bui.checkboxwidget( parent=self._subcontainer, size=(300, 30), maxwidth=300, @@ -872,7 +877,7 @@ class SettingsWindow: autoselect=True, text="Ping Button", on_value_change_call=self.ping_button) - copy_button = ba.checkboxwidget( + copy_button = bui.checkboxwidget( parent=self._subcontainer, size=(300, 30), maxwidth=300, @@ -882,7 +887,7 @@ class SettingsWindow: autoselect=True, text="Copy Text Button", on_value_change_call=self.copy_button) - direct_send = ba.checkboxwidget( + direct_send = bui.checkboxwidget( parent=self._subcontainer, size=(300, 30), maxwidth=300, @@ -892,7 +897,7 @@ class SettingsWindow: autoselect=True, text="Directly Send Custom Commands", on_value_change_call=self.direct_send) - colorfulchat = ba.checkboxwidget( + colorfulchat = bui.checkboxwidget( parent=self._subcontainer, size=(300, 30), maxwidth=300, @@ -902,7 +907,7 @@ class SettingsWindow: autoselect=True, text="Colorful Chat", on_value_change_call=self.colorful_chat) - msg_notification_text = ba.textwidget(parent=self._subcontainer, + msg_notification_text = bui.textwidget(parent=self._subcontainer, scale=0.8, color=(1, 1, 1), text='Message Notifcation:', @@ -913,13 +918,13 @@ class SettingsWindow: parent=self._subcontainer, position=(100, height - 1200), width=200, - scale=(2.8 if uiscale is ba.UIScale.SMALL else - 1.8 if uiscale is ba.UIScale.MEDIUM else 1.2), + scale=(2.8 if uiscale is babase.UIScale.SMALL else + 1.8 if uiscale is babase.UIScale.MEDIUM else 1.2), choices=['top', 'bottom'], - current_choice=ba.app.config['Message Notification'], + current_choice=babase.app.config['Message Notification'], button_size=(80, 25), on_value_change_call=self._change_notification) - self_status_text = ba.textwidget(parent=self._subcontainer, + self_status_text = bui.textwidget(parent=self._subcontainer, scale=0.8, color=(1, 1, 1), text='Self Status:', @@ -930,19 +935,19 @@ class SettingsWindow: parent=self._subcontainer, position=(50, height - 1000), width=200, - scale=(2.8 if uiscale is ba.UIScale.SMALL else - 1.8 if uiscale is ba.UIScale.MEDIUM else 1.2), + scale=(2.8 if uiscale is babase.UIScale.SMALL else + 1.8 if uiscale is babase.UIScale.MEDIUM else 1.2), choices=['online', 'offline'], - current_choice=ba.app.config['Self Status'], + current_choice=babase.app.config['Self Status'], button_size=(80, 25), on_value_change_call=self._change_status) - ba.containerwidget(edit=self.root_widget, cancel_button=btn) - ba.containerwidget(edit=self.root_widget, + bui.containerwidget(edit=self.root_widget, cancel_button=btn) + bui.containerwidget(edit=self.root_widget, selected_child=(cbtn if cbtn is not None and cancel_is_selected else None), start_button=None) - self._translation_btn = ba.buttonwidget(parent=self._subcontainer, + self._translation_btn = bui.buttonwidget(parent=self._subcontainer, scale=1.2, position=(100, 1200), size=(150, 50), @@ -951,99 +956,99 @@ class SettingsWindow: autoselect=True) def ip_button(self, value: bool): - cfg = ba.app.config + cfg = babase.app.config cfg['IP button'] = value cfg.apply_and_commit() if cfg['IP button']: - ba.screenmessage("IP Button is now enabled", color=(0, 1, 0)) + bui.screenmessage("IP Button is now enabled", color=(0, 1, 0)) else: - ba.screenmessage("IP Button is now disabled", color=(1, 0.7, 0)) + bui.screenmessage("IP Button is now disabled", color=(1, 0.7, 0)) def ping_button(self, value: bool): - cfg = ba.app.config + cfg = babase.app.config cfg['ping button'] = value cfg.apply_and_commit() if cfg['ping button']: - ba.screenmessage("Ping Button is now enabled", color=(0, 1, 0)) + bui.screenmessage("Ping Button is now enabled", color=(0, 1, 0)) else: - ba.screenmessage("Ping Button is now disabled", color=(1, 0.7, 0)) + bui.screenmessage("Ping Button is now disabled", color=(1, 0.7, 0)) def copy_button(self, value: bool): - cfg = ba.app.config + cfg = babase.app.config cfg['copy button'] = value cfg.apply_and_commit() if cfg['copy button']: - ba.screenmessage("Copy Text Button is now enabled", color=(0, 1, 0)) + bui.screenmessage("Copy Text Button is now enabled", color=(0, 1, 0)) else: - ba.screenmessage("Copy Text Button is now disabled", color=(1, 0.7, 0)) + bui.screenmessage("Copy Text Button is now disabled", color=(1, 0.7, 0)) def direct_send(self, value: bool): - cfg = ba.app.config + cfg = babase.app.config cfg['Direct Send'] = value cfg.apply_and_commit() def colorful_chat(self, value: bool): - cfg = ba.app.config + cfg = babase.app.config cfg['Colorful Chat'] = value cfg.apply_and_commit() def _change_notification(self, choice): - cfg = ba.app.config + cfg = babase.app.config cfg['Message Notification'] = choice cfg.apply_and_commit() def _change_status(self, choice): - cfg = ba.app.config + cfg = babase.app.config cfg['Self Status'] = choice cfg.apply_and_commit() def _translaton_btn(self): try: - ba.containerwidget(edit=self.root_widget, transition='out_scale') + bui.containerwidget(edit=self.root_widget, transition='out_scale') TranslationSettings() except Exception as e: print(e) pass def _cancel(self) -> None: - ba.containerwidget(edit=self.root_widget, transition='out_scale') + bui.containerwidget(edit=self.root_widget, transition='out_scale') -class PartyWindow(ba.Window): +class PartyWindow(bui.Window): """Party list/chat window.""" def __del__(self) -> None: - _ba.set_party_window_open(False) + bui.set_party_window_open(False) def __init__(self, origin: Sequence[float] = (0, 0)): self._private_chat = False self._firstcall = True self.ping_server() - _ba.set_party_window_open(True) + bui.set_party_window_open(True) self._r = 'partyWindow' self._popup_type: Optional[str] = None self._popup_party_member_client_id: Optional[int] = None self._popup_party_member_is_host: Optional[bool] = None self._width = 500 - uiscale = ba.app.ui.uiscale - self._height = (365 if uiscale is ba.UIScale.SMALL else - 480 if uiscale is ba.UIScale.MEDIUM else 600) - self.bg_color = ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) - self.ping_timer = ba.Timer(5, ba.WeakCall(self.ping_server), repeat=True) + uiscale = bui.app.ui_v1.uiscale + self._height = (365 if uiscale is babase.UIScale.SMALL else + 480 if uiscale is babase.UIScale.MEDIUM else 600) + self.bg_color = babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) + self.ping_timer = bs.apptimer(5, bs.WeakCall(self.ping_server)) - ba.Window.__init__(self, root_widget=ba.containerwidget( + bui.Window.__init__(self, root_widget=bui.containerwidget( size=(self._width, self._height), transition='in_scale', color=self.bg_color, - parent=_ba.get_special_widget('overlay_stack'), + parent=bui.get_special_widget('overlay_stack'), on_outside_click_call=self.close_with_sound, scale_origin_stack_offset=origin, - scale=(2.0 if uiscale is ba.UIScale.SMALL else - 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0), - stack_offset=(0, -10) if uiscale is ba.UIScale.SMALL else ( - 240, 0) if uiscale is ba.UIScale.MEDIUM else (330, 20))) + scale=(2.0 if uiscale is babase.UIScale.SMALL else + 1.35 if uiscale is babase.UIScale.MEDIUM else 1.0), + stack_offset=(0, -10) if uiscale is babase.UIScale.SMALL else ( + 240, 0) if uiscale is babase.UIScale.MEDIUM else (330, 20))) - self._cancel_button = ba.buttonwidget(parent=self._root_widget, + self._cancel_button = bui.buttonwidget(parent=self._root_widget, scale=0.7, position=(30, self._height - 47), size=(50, 50), @@ -1051,12 +1056,12 @@ class PartyWindow(ba.Window): on_activate_call=self.close, autoselect=True, color=self.bg_color, - 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._menu_button = ba.buttonwidget( + self._menu_button = bui.buttonwidget( parent=self._root_widget, scale=0.7, position=(self._width - 80, self._height - 47), @@ -1064,17 +1069,17 @@ class PartyWindow(ba.Window): label='...', autoselect=True, button_type='square', - on_activate_call=ba.WeakCall(self._on_menu_button_press), + on_activate_call=bs.WeakCall(self._on_menu_button_press), color=self.bg_color, iconscale=1.2) - - info = _ba.get_connection_to_host_info() - if info.get('name', '') != '': - self.title = ba.Lstr(value=info['name']) - else: - self.title = ba.Lstr(resource=self._r + '.titleText') - - self._title_text = ba.textwidget(parent=self._root_widget, + try: + info = bs.get_connection_to_host_info().get('name', '') if build_number < 21697 else bs.get_connection_to_host_info_2().name + if info != '': + self.title = babase.Lstr(value=info['name']) if build_number < 21697 else babase.Lstr(value=info) + except AttributeError: + self.title = babase.Lstr(resource=self._r + '.titleText') + + self._title_text = bui.textwidget(parent=self._root_widget, scale=0.9, color=(0.5, 0.7, 0.5), text=self.title, @@ -1084,7 +1089,7 @@ class PartyWindow(ba.Window): maxwidth=self._width * 0.6, h_align='center', v_align='center') - self._empty_str = ba.textwidget(parent=self._root_widget, + self._empty_str = bui.textwidget(parent=self._root_widget, scale=0.75, size=(0, 0), position=(self._width * 0.5, @@ -1094,25 +1099,25 @@ class PartyWindow(ba.Window): v_align='center') self._scroll_width = self._width - 50 - self._scrollwidget = ba.scrollwidget(parent=self._root_widget, + self._scrollwidget = bui.scrollwidget(parent=self._root_widget, size=(self._scroll_width, self._height - 200), position=(30, 80), color=self.bg_color) - self._columnwidget = ba.columnwidget(parent=self._scrollwidget, + self._columnwidget = bui.columnwidget(parent=self._scrollwidget, border=2, margin=0) - ba.widget(edit=self._menu_button, down_widget=self._columnwidget) + bui.widget(edit=self._menu_button, down_widget=self._columnwidget) - self._muted_text = ba.textwidget( + self._muted_text = bui.textwidget( parent=self._root_widget, position=(self._width * 0.5, self._height * 0.5), size=(0, 0), h_align='center', v_align='center', - text=ba.Lstr(resource='chatMutedText')) + text=babase.Lstr(resource='chatMutedText')) - self._text_field = txt = ba.textwidget( + self._text_field = txt = bui.textwidget( parent=self._root_widget, editable=True, size=(500, 40), @@ -1121,49 +1126,49 @@ class PartyWindow(ba.Window): maxwidth=494, shadow=0.3, flatness=1.0, - description=ba.Lstr(resource=self._r + '.chatMessageText'), + description=babase.Lstr(resource=self._r + '.chatMessageText'), autoselect=True, v_align='center', corner_scale=0.7) - ba.widget(edit=self._scrollwidget, + bui.widget(edit=self._scrollwidget, autoselect=True, left_widget=self._cancel_button, up_widget=self._cancel_button, down_widget=self._text_field) - ba.widget(edit=self._columnwidget, + bui.widget(edit=self._columnwidget, autoselect=True, up_widget=self._cancel_button, down_widget=self._text_field) - ba.containerwidget(edit=self._root_widget, selected_child=txt) - self._send_button = btn = ba.buttonwidget(parent=self._root_widget, + bui.containerwidget(edit=self._root_widget, selected_child=txt) + self._send_button = btn = bui.buttonwidget(parent=self._root_widget, size=(50, 35), - label=ba.Lstr(resource=self._r + '.sendText'), + label=babase.Lstr(resource=self._r + '.sendText'), button_type='square', autoselect=True, color=self.bg_color, position=(self._width - 90, 35), on_activate_call=self._send_chat_message) - ba.textwidget(edit=txt, on_return_press_call=btn.activate) - self._previous_button = ba.buttonwidget(parent=self._root_widget, + bui.textwidget(edit=txt, on_return_press_call=btn.activate) + self._previous_button = bui.buttonwidget(parent=self._root_widget, size=(30, 30), - label=ba.charstr(ba.SpecialChar.UP_ARROW), + label=babase.charstr(babase.SpecialChar.UP_ARROW), button_type='square', autoselect=True, position=(15, 57), color=self.bg_color, scale=0.75, on_activate_call=self._previous_message) - self._next_button = ba.buttonwidget(parent=self._root_widget, + self._next_button = bui.buttonwidget(parent=self._root_widget, size=(30, 30), - label=ba.charstr(ba.SpecialChar.DOWN_ARROW), + label=babase.charstr(babase.SpecialChar.DOWN_ARROW), button_type='square', autoselect=True, color=self.bg_color, scale=0.75, position=(15, 28), on_activate_call=self._next_message) - self._translate_button = ba.buttonwidget(parent=self._root_widget, + self._translate_button = bui.buttonwidget(parent=self._root_widget, size=(55, 47), label="Trans", button_type='square', @@ -1172,8 +1177,8 @@ class PartyWindow(ba.Window): scale=0.75, position=(self._width - 28, 35), on_activate_call=self._translate) - if ba.app.config['copy button']: - self._copy_button = ba.buttonwidget(parent=self._root_widget, + if babase.app.config['copy button']: + self._copy_button = bui.buttonwidget(parent=self._root_widget, size=(15, 15), label='©', button_type='backSmall', @@ -1182,31 +1187,35 @@ class PartyWindow(ba.Window): position=(self._width - 40, 80), on_activate_call=self._copy_to_clipboard) self._ping_button = None - if info.get('name', '') != '': - if ba.app.config['ping button']: - self._ping_button = ba.buttonwidget( - parent=self._root_widget, - scale=0.7, - position=(self._width - 538, self._height - 57), - size=(75, 75), - autoselect=True, - button_type='square', - label=f'{_ping}', - on_activate_call=self._send_ping, - color=self.bg_color, - text_scale=2.3, - iconscale=1.2) - if ba.app.config['IP button']: - self._ip_port_button = ba.buttonwidget(parent=self._root_widget, - size=(30, 30), - label='IP', - button_type='square', - autoselect=True, - color=self.bg_color, - position=(self._width - 530, - self._height - 100), - on_activate_call=self._ip_port_msg) - self._settings_button = ba.buttonwidget(parent=self._root_widget, + try: + info = bs.get_connection_to_host_info().get('name', '') if build_number < 21697 else bs.get_connection_to_host_info_2().name + if info != '': + if babase.app.config['ping button']: + self._ping_button = bui.buttonwidget( + parent=self._root_widget, + scale=0.7, + position=(self._width - 538, self._height - 57), + size=(75, 75), + autoselect=True, + button_type='square', + label=f'{_ping}', + on_activate_call=self._send_ping, + color=self.bg_color, + text_scale=2.3, + iconscale=1.2) + if babase.app.config['IP button']: + self._ip_port_button = bui.buttonwidget(parent=self._root_widget, + size=(30, 30), + label='IP', + button_type='square', + autoselect=True, + color=self.bg_color, + position=(self._width - 530, + self._height - 100), + on_activate_call=self._ip_port_msg) + except AttributeError: + pass + self._settings_button = bui.buttonwidget(parent=self._root_widget, size=(50, 50), scale=0.5, button_type='square', @@ -1214,9 +1223,9 @@ class PartyWindow(ba.Window): color=self.bg_color, position=(self._width - 40, self._height - 47), on_activate_call=self._on_setting_button_press, - icon=ba.gettexture('settingsIcon'), + icon=bui.gettexture('settingsIcon'), iconscale=1.2) - self._privatechat_button = ba.buttonwidget(parent=self._root_widget, + self._privatechat_button = bui.buttonwidget(parent=self._root_widget, size=(50, 50), scale=0.5, button_type='square', @@ -1224,19 +1233,17 @@ class PartyWindow(ba.Window): color=self.bg_color, position=(self._width - 40, self._height - 80), on_activate_call=self._on_privatechat_button_press, - icon=ba.gettexture('ouyaOButton'), + icon=bui.gettexture('ouyaOButton'), iconscale=1.2) - self._name_widgets: List[ba.Widget] = [] + self._name_widgets: List[bui.Widget] = [] self._roster: Optional[List[Dict[str, Any]]] = None - self._update_timer = ba.Timer(1.0, - ba.WeakCall(self._update), - repeat=True, - timetype=ba.TimeType.REAL) + self._update_timer = bs.apptimer(1.0, + bs.WeakCall(self._update)) self._update() def on_chat_message(self, msg: str, sent=None) -> None: """Called when a new chat message comes through.""" - if ba.app.config['Party Chat Muted'] and not _ba.app.ui.party_window()._private_chat: + if babase.app.config['Party Chat Muted'] and not bui.app.ui_v1.party_window()._private_chat: return if sent: self._add_msg(msg, sent) @@ -1244,13 +1251,13 @@ class PartyWindow(ba.Window): self._add_msg(msg) def _add_msg(self, msg: str, sent=None) -> None: - if ba.app.config['Colorful Chat']: + if babase.app.config['Colorful Chat']: sender = msg.split(': ')[0] color = color_tracker._get_sender_color(sender) if sender else (1, 1, 1) else: color = (1, 1, 1) maxwidth = self._scroll_width * 0.94 - txt = ba.textwidget(parent=self._columnwidget, + txt = bui.textwidget(parent=self._columnwidget, text=msg, h_align='left', v_align='center', @@ -1261,33 +1268,33 @@ class PartyWindow(ba.Window): shadow=0.3, flatness=1.0) if sent: - ba.textwidget(edit=txt, size=(100, 15), + bui.textwidget(edit=txt, size=(100, 15), selectable=True, click_activate=True, - on_activate_call=ba.Call(ba.screenmessage, f'Message sent: {_get_local_time(sent)}')) + on_activate_call=babase.Call(bui.screenmessage, f'Message sent: {_get_local_time(sent)}')) self._chat_texts.append(txt) if len(self._chat_texts) > 40: first = self._chat_texts.pop(0) first.delete() - ba.containerwidget(edit=self._columnwidget, visible_child=txt) + bui.containerwidget(edit=self._columnwidget, visible_child=txt) def _on_menu_button_press(self) -> None: - is_muted = ba.app.config['Party Chat Muted'] - uiscale = ba.app.ui.uiscale + is_muted = babase.app.config['Party Chat Muted'] + uiscale = bui.app.ui_v1.uiscale choices = ['muteOption', 'modifyColor', 'addQuickReply', 'removeQuickReply', 'credits'] choices_display = ['Mute Option', 'Modify Main Color', 'Add as Quick Reply', 'Remove a Quick Reply', 'Credits'] - if hasattr(_ba.get_foreground_host_activity(), '_map'): + if hasattr(bs.get_foreground_host_activity(), '_map'): choices.append('manualCamera') choices_display.append('Manual Camera') PopupMenuWindow( position=self._menu_button.get_screen_space_center(), color=self.bg_color, - scale=(2.3 if uiscale is ba.UIScale.SMALL else - 1.65 if uiscale is ba.UIScale.MEDIUM else 1.23), + scale=(2.3 if uiscale is babase.UIScale.SMALL else + 1.65 if uiscale is babase.UIScale.MEDIUM else 1.23), choices=choices, choices_display=self._create_baLstr_list(choices_display), current_choice='muteOption', @@ -1296,35 +1303,35 @@ class PartyWindow(ba.Window): def _update(self) -> None: if not self._private_chat: - _ba.set_party_window_open(True) - ba.textwidget(edit=self._title_text, text=self.title) + bui.set_party_window_open(True) + bui.textwidget(edit=self._title_text, text=self.title) if self._firstcall: if hasattr(self, '_status_text'): self._status_text.delete() self._roster = [] self._firstcall = False - self._chat_texts: List[ba.Widget] = [] - if not ba.app.config['Party Chat Muted']: - msgs = _ba.get_chat_messages() + self._chat_texts: List[bui.Widget] = [] + if not babase.app.config['Party Chat Muted']: + msgs = bs.get_chat_messages() for msg in msgs: self._add_msg(msg) # update muted state - if ba.app.config['Party Chat Muted']: - ba.textwidget(edit=self._muted_text, color=(1, 1, 1, 0.3)) + if babase.app.config['Party Chat Muted']: + bui.textwidget(edit=self._muted_text, color=(1, 1, 1, 0.3)) # clear any chat texts we're showing if self._chat_texts: while self._chat_texts: first = self._chat_texts.pop() first.delete() else: - ba.textwidget(edit=self._muted_text, color=(1, 1, 1, 0.0)) + bui.textwidget(edit=self._muted_text, color=(1, 1, 1, 0.0)) if self._ping_button: - ba.buttonwidget(edit=self._ping_button, + bui.buttonwidget(edit=self._ping_button, label=f'{_ping}', textcolor=self._get_ping_color()) # update roster section - roster = _ba.get_game_roster() + roster = bs.get_game_roster() if roster != self._roster or self._firstcall: self._roster = roster @@ -1335,9 +1342,9 @@ class PartyWindow(ba.Window): self._name_widgets = [] if not self._roster: top_section_height = 60 - ba.textwidget(edit=self._empty_str, - text=ba.Lstr(resource=self._r + '.emptyText')) - ba.scrollwidget(edit=self._scrollwidget, + bui.textwidget(edit=self._empty_str, + text=babase.Lstr(resource=self._r + '.emptyText')) + bui.scrollwidget(edit=self._scrollwidget, size=(self._width - 50, self._height - top_section_height - 110), position=(30, 80)) @@ -1380,10 +1387,10 @@ class PartyWindow(ba.Window): p_str = self._roster[index][ 'display_string'] except Exception: - ba.print_exception( + babase.print_exception( 'Error calcing client name str.') p_str = '???' - widget = ba.textwidget(parent=self._root_widget, + widget = bui.textwidget(parent=self._root_widget, position=(pos[0], pos[1]), scale=t_scale, size=(c_width * 0.85, 30), @@ -1394,7 +1401,7 @@ class PartyWindow(ba.Window): selectable=True, autoselect=True, click_activate=True, - text=ba.Lstr(value=p_str), + text=babase.Lstr(value=p_str), h_align='left', v_align='center') self._name_widgets.append(widget) @@ -1412,8 +1419,8 @@ class PartyWindow(ba.Window): # FIXME: Should pass client_id to these sort of # calls; not spec-string (perhaps should wait till # client_id is more readily available though). - ba.textwidget(edit=widget, - on_activate_call=ba.Call( + bui.textwidget(edit=widget, + on_activate_call=babase.Call( self._on_party_member_press, self._roster[index]['client_id'], is_host, widget)) @@ -1427,11 +1434,11 @@ class PartyWindow(ba.Window): if is_host: twd = min( c_width * 0.85, - _ba.get_string_width( + _babase.get_string_width( p_str, suppress_warning=True) * t_scale) self._name_widgets.append( - ba.textwidget( + bui.textwidget( parent=self._root_widget, position=(pos[0] + twd + 1, pos[1] - 0.5), @@ -1440,24 +1447,24 @@ class PartyWindow(ba.Window): v_align='center', maxwidth=c_width * 0.96 - twd, color=(0.1, 1, 0.1, 0.5), - text=ba.Lstr(resource=self._r + + text=babase.Lstr(resource=self._r + '.hostText'), scale=0.4, shadow=0.1, flatness=1.0)) - ba.textwidget(edit=self._empty_str, text='') - ba.scrollwidget(edit=self._scrollwidget, + bui.textwidget(edit=self._empty_str, text='') + bui.scrollwidget(edit=self._scrollwidget, size=(self._width - 50, max(100, self._height - 139 - c_height_total)), position=(30, 80)) else: - _ba.set_party_window_open(False) + bui.set_party_window_open(False) for widget in self._name_widgets: widget.delete() self._name_widgets = [] - ba.textwidget(edit=self._title_text, text='Private Chat') - ba.textwidget(edit=self._empty_str, text='') + bui.textwidget(edit=self._title_text, text='Private Chat') + bui.textwidget(edit=self._empty_str, text='') if self._firstcall: self._firstcall = False if hasattr(self, '_status_text'): @@ -1470,15 +1477,15 @@ class PartyWindow(ba.Window): while self._chat_texts: first = self._chat_texts.pop() first.delete() - uiscale = ba.app.ui.uiscale - scroll_height = (165 if uiscale is ba.UIScale.SMALL else - 280 if uiscale is ba.UIScale.MEDIUM else 400) - ba.scrollwidget(edit=self._scrollwidget, + uiscale = bui.app.ui_v1.uiscale + scroll_height = (165 if uiscale is babase.UIScale.SMALL else + 280 if uiscale is babase.UIScale.MEDIUM else 400) + bui.scrollwidget(edit=self._scrollwidget, size=(self._width - 50, scroll_height)) for msg in msgs: message = messenger._format_message(msg) self._add_msg(message, msg['sent']) - self._filter_text = ba.textwidget(parent=self._root_widget, + self._filter_text = bui.textwidget(parent=self._root_widget, scale=0.6, color=(0.9, 1.0, 0.9), text='Filter: ', @@ -1488,17 +1495,17 @@ class PartyWindow(ba.Window): h_align='center', v_align='center') choices = [i for i in messenger.saved_ids] - choices_display = [ba.Lstr(value=messenger.saved_ids[i]) + choices_display = [babase.Lstr(value=messenger.saved_ids[i]) for i in messenger.saved_ids] choices.append('add') - choices_display.append(ba.Lstr(value='***Add New***')) + choices_display.append(babase.Lstr(value='***Add New***')) filter_widget = PopupMenu( parent=self._root_widget, position=(self._width * 0.4, self._height - 80), width=200, - scale=(2.8 if uiscale is ba.UIScale.SMALL else - 1.8 if uiscale is ba.UIScale.MEDIUM else 1.2), + scale=(2.8 if uiscale is babase.UIScale.SMALL else + 1.8 if uiscale is babase.UIScale.MEDIUM else 1.2), choices=choices, choices_display=choices_display, current_choice=messenger.filter, @@ -1513,7 +1520,7 @@ class PartyWindow(ba.Window): color = (0, 1, 0) else: color = (0.9, 1.0, 0.9) - self._status_text = ba.textwidget(parent=self._root_widget, + self._status_text = bui.textwidget(parent=self._root_widget, scale=0.5, color=color, text=f'Status:\t{user_status}', @@ -1525,8 +1532,8 @@ class PartyWindow(ba.Window): autoselect=True, selectable=True, click_activate=True) - ba.textwidget(edit=self._status_text, - on_activate_call=ba.Call(messenger._get_status, messenger.filter, 'last_seen')) + bui.textwidget(edit=self._status_text, + on_activate_call=babase.Call(messenger._get_status, messenger.filter, 'last_seen')) def _change_filter(self, choice): if choice == 'add': @@ -1596,17 +1603,17 @@ class PartyWindow(ba.Window): name = playerinfo['players'][0]['name_full'] except: name = account - for i in ba.app.config.get('Custom Commands'): + for i in babase.app.config.get('Custom Commands'): i = i.replace('$c', str(self._popup_party_member_client_id)) i = i.replace('$a', str(account)) i = i.replace('$n', str(name)) - if ba.app.config['Direct Send']: - choices.append(f'_ba.chatmessage("{i}")') + if babase.app.config['Direct Send']: + choices.append(f'bs.chatmessage("{i}")') else: choices.append(f'self._edit_text_msg_box("{i}")') - choices_display.append(ba.Lstr(value=i)) + choices_display.append(babase.Lstr(value=i)) choices.append('AddNewChoiceWindow()') - choices_display.append(ba.Lstr(value='***Add New***')) + choices_display.append(babase.Lstr(value='***Add New***')) PopupMenuWindow(position=popup_window.root_widget.get_screen_space_center(), color=self.bg_color, scale=self._get_popup_window_scale(), @@ -1640,14 +1647,14 @@ class PartyWindow(ba.Window): delegate=self, tag='') elif choice == 'addQuickReply': try: - newReply = ba.textwidget(query=self._text_field) + newReply = bui.textwidget(query=self._text_field) oldReplies = self._get_quick_responds() oldReplies.append(newReply) self._write_quick_responds(oldReplies) - ba.screenmessage(f'"{newReply}" is added.', (0, 1, 0)) - ba.playsound(ba.getsound('dingSmallHigh')) + bui.screenmessage(f'"{newReply}" is added.', (0, 1, 0)) + bui.getsound('dingSmallHigh').play() except: - ba.print_exception() + babase.print_exception() elif choice == 'removeQuickReply': quick_reply = self._get_quick_responds() PopupMenuWindow(position=self._send_button.get_screen_space_center(), @@ -1669,7 +1676,7 @@ class PartyWindow(ba.Window): ok_text="Join Discord", origin_widget=self.get_root_widget()) elif choice == 'manualCamera': - ba.containerwidget(edit=self._root_widget, transition='out_scale') + bui.containerwidget(edit=self._root_widget, transition='out_scale') Manual_camera_window() elif self._popup_type == 'muteType': @@ -1688,8 +1695,8 @@ class PartyWindow(ba.Window): data = self._get_quick_responds() data.remove(choice) self._write_quick_responds(data) - ba.screenmessage(f'"{choice}" is removed.', (1, 0, 0)) - ba.playsound(ba.getsound('shieldDown')) + bui.screenmessage(f'"{choice}" is removed.', (1, 0, 0)) + bui.getsound('shieldDown').play() else: print(f'unhandled popup type: {self._popup_type}') @@ -1697,34 +1704,34 @@ class PartyWindow(ba.Window): def _vote_kick_player(self): if self._popup_party_member_is_host: - ba.playsound(ba.getsound('error')) - ba.screenmessage( - ba.Lstr(resource='internal.cantKickHostError'), + bui.getsound('error').play() + bui.screenmessage( + babase.Lstr(resource='internal.cantKickHostError'), color=(1, 0, 0)) else: assert self._popup_party_member_client_id is not None # Ban for 5 minutes. - result = _ba.disconnect_client( + result = bs.disconnect_client( self._popup_party_member_client_id, ban_time=5 * 60) if not result: - ba.playsound(ba.getsound('error')) - ba.screenmessage( - ba.Lstr(resource='getTicketsWindow.unavailableText'), + bui.getsound('error').play() + bui.screenmessage( + babase.Lstr(resource='getTicketsWindow.unavailableText'), color=(1, 0, 0)) def _send_admin_kick_command(self): - _ba.chatmessage('/kick ' + str(self._popup_party_member_client_id)) + bs.chatmessage('/kick ' + str(self._popup_party_member_client_id)) def _translate(self): def _apply_translation(translated): if self._text_field.exists(): - ba.textwidget(edit=self._text_field, text=translated) - msg = ba.textwidget(query=self._text_field) - cfg = ba.app.config + bui.textwidget(edit=self._text_field, text=translated) + msg = bui.textwidget(query=self._text_field) + cfg = babase.app.config if msg == '': - ba.screenmessage('Nothing to translate.', (1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.screenmessage('Nothing to translate.', (1, 0, 0)) + bui.getsound('error').play() else: data = dict(message=msg) if cfg['Translate Source Language']: @@ -1736,17 +1743,17 @@ class PartyWindow(ba.Window): Translate(data, _apply_translation).start() def _copy_to_clipboard(self): - msg = ba.textwidget(query=self._text_field) + msg = bui.textwidget(query=self._text_field) if msg == '': - ba.screenmessage('Nothing to copy.', (1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.screenmessage('Nothing to copy.', (1, 0, 0)) + bui.getsound('error').play() else: - ba.clipboard_set_text(msg) - ba.screenmessage(f'"{msg}" is copied to clipboard.', (0, 1, 0)) - ba.playsound(ba.getsound('dingSmallHigh')) + babase.clipboard_set_text(msg) + bui.screenmessage(f'"{msg}" is copied to clipboard.', (0, 1, 0)) + bui.getsound('dingSmallHigh').play() def _get_current_mute_type(self): - cfg = ba.app.config + cfg = babase.app.config if cfg['Chat Muted'] == True: if cfg['Party Chat Muted'] == True: return 'muteAll' @@ -1759,7 +1766,7 @@ class PartyWindow(ba.Window): return 'unmuteAll' def _change_mute_type(self, choice): - cfg = ba.app.config + cfg = babase.app.config if choice == 'muteInGameOnly': cfg['Chat Muted'] = True cfg['Party Chat Muted'] = False @@ -1779,27 +1786,26 @@ class PartyWindow(ba.Window): """Called when the popup is closing.""" def _on_party_member_press(self, client_id: int, is_host: bool, - widget: ba.Widget) -> None: + widget: bui.Widget) -> None: # if we're the host, pop up 'kick' options for all non-host members - if _ba.get_foreground_host_session() is not None: - kick_str = ba.Lstr(resource='kickText') + if bs.get_foreground_host_session() is not None: + kick_str = babase.Lstr(resource='kickText') else: # kick-votes appeared in build 14248 - if (_ba.get_connection_to_host_info().get('build_number', 0) < - 14248): + if build_number <14248: return - kick_str = ba.Lstr(resource='kickVoteText') - uiscale = ba.app.ui.uiscale + kick_str = babase.Lstr(resource='kickVoteText') + uiscale = bui.app.ui_v1.uiscale choices = ['kick', 'mention', 'adminkick'] choices_display = [kick_str] + \ list(self._create_baLstr_list(['Mention this guy', f'Kick ID: {client_id}'])) choices.append('customCommands') - choices_display.append(ba.Lstr(value='Custom Commands')) + choices_display.append(babase.Lstr(value='Custom Commands')) PopupMenuWindow( position=widget.get_screen_space_center(), color=self.bg_color, - scale=(2.3 if uiscale is ba.UIScale.SMALL else - 1.65 if uiscale is ba.UIScale.MEDIUM else 1.23), + scale=(2.3 if uiscale is babase.UIScale.SMALL else + 1.65 if uiscale is babase.UIScale.MEDIUM else 1.23), choices=choices, choices_display=choices_display, current_choice='mention', @@ -1809,8 +1815,8 @@ class PartyWindow(ba.Window): self._popup_party_member_is_host = is_host def _send_chat_message(self) -> None: - msg = ba.textwidget(query=self._text_field) - ba.textwidget(edit=self._text_field, text='') + msg = bui.textwidget(query=self._text_field) + bui.textwidget(edit=self._text_field, text='') if '\\' in msg: msg = msg.replace('\\d', ('\ue048')) msg = msg.replace('\\c', ('\ue043')) @@ -1842,35 +1848,38 @@ class PartyWindow(ba.Window): elif msg.startswith('/info '): account = msg.replace('/info ', '') if account: - from bastd.ui.account import viewer + from bauiv1lib.account import viewer viewer.AccountViewerWindow( account_id=account) - ba.textwidget(edit=self._text_field, text='') + bui.textwidget(edit=self._text_field, text='') return if not self._private_chat: if msg == '/id': - myid = ba.internal.get_v1_account_misc_read_val_2('resolvedAccountID', '') - _ba.chatmessage(f"My Unique ID : {myid}") + myid = bui.app.plus.get_v1_account_misc_read_val_2('resolvedAccountID', '') + bs.chatmessage(f"My Unique ID : {myid}") elif msg == '/save': - info = _ba.get_connection_to_host_info() - config = ba.app.config - if info.get('name', '') != '': - title = info['name'] - if not isinstance(config.get('Saved Servers'), dict): - config['Saved Servers'] = {} - config['Saved Servers'][f'{_ip}@{_port}'] = { - 'addr': _ip, - 'port': _port, - 'name': title - } - config.commit() - ba.screenmessage("Server Added To Manual", color=(0, 1, 0), transient=True) - ba.playsound(ba.getsound('gunCocking')) + try: + info = bs.get_connection_to_host_info().get('name', '') if build_number < 21697 else bs.get_connection_to_host_info_2().name + config = babase.app.config + if info != '': + title = info['name'] + if not isinstance(config.get('Saved Servers'), dict): + config['Saved Servers'] = {} + config['Saved Servers'][f'{_ip}@{_port}'] = { + 'addr': _ip, + 'port': _port, + 'name': title + } + config.commit() + bui.screenmessage("Server Added To Manual", color=(0, 1, 0), transient=True) + bui.getsound('gunCocking').play() + except AttributeError: + pass elif msg != '': - _ba.chatmessage(cast(str, msg)) + bs.chatmessage(cast(str, msg)) else: receiver = messenger.filter - name = ba.internal.get_v1_account_display_string() + name = bui.app.plus.get_v1_account_display_string() if not receiver: display_error('Choose a valid receiver id') return @@ -1886,22 +1895,22 @@ class PartyWindow(ba.Window): self._change_filter('all') else: display_error('Cant delete this') - ba.textwidget(edit=self._text_field, text='') + bui.textwidget(edit=self._text_field, text='') return - ba.Call(messenger._send_request, url, data) - ba.Call(check_new_message) + babase.Call(messenger._send_request, url, data) + babase.Call(check_new_message) Thread(target=messenger._send_request, args=(url, data)).start() Thread(target=check_new_message).start() - ba.textwidget(edit=self._text_field, text='') + bui.textwidget(edit=self._text_field, text='') def _write_quick_responds(self, data): try: with open(quick_msg_file, 'w') as f: f.write('\n'.join(data)) except: - ba.print_exception() - ba.screenmessage('Error!', (1, 0, 0)) - ba.playsound(ba.getsound('error')) + babase.print_exception() + bui.screenmessage('Error!', (1, 0, 0)) + bui.getsound('error').play() def _get_quick_responds(self): if os.path.exists(quick_msg_file): @@ -1913,13 +1922,13 @@ class PartyWindow(ba.Window): return default_replies def color_picker_selected_color(self, picker, color) -> None: - ba.containerwidget(edit=self._root_widget, color=color) + bui.containerwidget(edit=self._root_widget, color=color) color = tuple(round(i, 2) for i in color) self.bg_color = color - ba.app.config['PartyWindow Main Color'] = color + babase.app.config['PartyWindow Main Color'] = color def color_picker_closing(self, picker) -> None: - ba.app.config.apply_and_commit() + babase.app.config.apply_and_commit() def _remove_sender_from_message(self, msg=''): msg_start = msg.find(": ") + 2 @@ -1936,7 +1945,7 @@ class PartyWindow(ba.Window): del self.msg_index try: msg_widget = msgs[self.msg_index] - msg = ba.textwidget(query=msg_widget) + msg = bui.textwidget(query=msg_widget) msg = self._remove_sender_from_message(msg) if msg in ('', ' '): self._previous_message() @@ -1956,7 +1965,7 @@ class PartyWindow(ba.Window): del self.msg_index try: msg_widget = msgs[self.msg_index] - msg = ba.textwidget(query=msg_widget) + msg = bui.textwidget(query=msg_widget) msg = self._remove_sender_from_message(msg) if msg in ('', ' '): self._next_message() @@ -1973,10 +1982,13 @@ class PartyWindow(ba.Window): self._edit_text_msg_box(msg, 'replace') def ping_server(self): - info = _ba.get_connection_to_host_info() - if info.get('name', '') != '': - self.pingThread = PingThread(_ip, _port) - self.pingThread.start() + try: + info = bs.get_connection_to_host_info().get('name', '') if build_number < 21697 else bs.get_connection_to_host_info_2().name + if info != '': + self.pingThread = PingThread(_ip, _port) + self.pingThread.start() + except AttributeError: + pass def _get_ping_color(self): try: @@ -1991,28 +2003,28 @@ class PartyWindow(ba.Window): def _send_ping(self): if isinstance(_ping, int): - _ba.chatmessage(f'My ping = {_ping}ms') + bs.chatmessage(f'My ping = {_ping}ms') def close(self) -> None: """Close the window.""" - ba.containerwidget(edit=self._root_widget, transition='out_scale') + bui.containerwidget(edit=self._root_widget, transition='out_scale') def close_with_sound(self) -> None: """Close the window and make a lovely sound.""" - ba.playsound(ba.getsound('swish')) + bui.getsound('swish').play() self.close() def _get_popup_window_scale(self) -> float: - uiscale = ba.app.ui.uiscale - return (2.4 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0) + uiscale = bui.app.ui_v1.uiscale + return (2.4 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0) def _create_baLstr_list(self, list1): - return (ba.Lstr(value=i) for i in list1) + return (babase.Lstr(value=i) for i in list1) def _get_player_info(self, clientID): info = {} - for i in _ba.get_game_roster(): + for i in bs.get_game_roster(): if i['client_id'] == clientID: info['ds'] = i['display_string'] info['players'] = i['players'] @@ -2023,16 +2035,16 @@ class PartyWindow(ba.Window): def _edit_text_msg_box(self, text, action='add'): if isinstance(text, str): if action == 'add': - ba.textwidget(edit=self._text_field, text=ba.textwidget( + bui.textwidget(edit=self._text_field, text=bui.textwidget( query=self._text_field) + text) elif action == 'replace': - ba.textwidget(edit=self._text_field, text=text) + bui.textwidget(edit=self._text_field, text=text) def _on_setting_button_press(self): try: SettingsWindow() except Exception as e: - ba.print_exception() + babase.print_exception() pass def _on_privatechat_button_press(self): @@ -2060,11 +2072,11 @@ class PartyWindow(ba.Window): else: display_error(messenger.error) except Exception as e: - ba.print_exception() + babase.print_exception() pass def join_discord(self): - ba.open_url("https://discord.gg/KvYgpEg2JR") + bui.open_url("https://discord.gg/KvYgpEg2JR") class LoginWindow: @@ -2076,19 +2088,19 @@ class LoginWindow: else: title = 'Login Window' label = 'Log In' - uiscale = ba.app.ui.uiscale - bg_color = ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) - self._root_widget = ba.containerwidget(size=(500, 250), + uiscale = bui.app.ui_v1.uiscale + bg_color = babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) + self._root_widget = bui.containerwidget(size=(500, 250), transition='in_scale', color=bg_color, toolbar_visibility='menu_minimal_no_back', - parent=_ba.get_special_widget('overlay_stack'), + parent=bui.get_special_widget('overlay_stack'), on_outside_click_call=self._close, - scale=(2.1 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), - stack_offset=(0, -10) if uiscale is ba.UIScale.SMALL else ( - 240, 0) if uiscale is ba.UIScale.MEDIUM else (330, 20)) - self._title_text = ba.textwidget(parent=self._root_widget, + scale=(2.1 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), + stack_offset=(0, -10) if uiscale is babase.UIScale.SMALL else ( + 240, 0) if uiscale is babase.UIScale.MEDIUM else (330, 20)) + self._title_text = bui.textwidget(parent=self._root_widget, scale=0.8, color=(1, 1, 1), text=title, @@ -2096,17 +2108,17 @@ class LoginWindow: position=(250, 200), h_align='center', v_align='center') - self._id = ba.textwidget(parent=self._root_widget, + self._id = bui.textwidget(parent=self._root_widget, scale=0.5, color=(1, 1, 1), text=f'Account: ' + - ba.internal.get_v1_account_misc_read_val_2( + bui.app.plus.get_v1_account_misc_read_val_2( 'resolvedAccountID', ''), size=(0, 0), position=(220, 170), h_align='center', v_align='center') - self._registrationkey_text = ba.textwidget(parent=self._root_widget, + self._registrationkey_text = bui.textwidget(parent=self._root_widget, scale=0.5, color=(1, 1, 1), text=f'Registration Key:', @@ -2114,7 +2126,7 @@ class LoginWindow: position=(100, 140), h_align='center', v_align='center') - self._text_field = ba.textwidget( + self._text_field = bui.textwidget( parent=self._root_widget, editable=True, size=(200, 40), @@ -2125,7 +2137,7 @@ class LoginWindow: autoselect=True, v_align='center', corner_scale=0.7) - self._connect_button = ba.buttonwidget(parent=self._root_widget, + self._connect_button = bui.buttonwidget(parent=self._root_widget, size=(150, 30), color=(0, 1, 0), label='Get Registration Key', @@ -2133,17 +2145,17 @@ class LoginWindow: autoselect=True, position=(150, 80), on_activate_call=self._connect) - self._confirm_button = ba.buttonwidget(parent=self._root_widget, + self._confirm_button = bui.buttonwidget(parent=self._root_widget, size=(50, 30), label=label, button_type='square', autoselect=True, position=(200, 40), on_activate_call=self._confirmcall) - ba.textwidget(edit=self._text_field, on_return_press_call=self._confirm_button.activate) + bui.textwidget(edit=self._text_field, on_return_press_call=self._confirm_button.activate) def _close(self): - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, transition=('out_scale')) def _connect(self): @@ -2151,35 +2163,35 @@ class LoginWindow: host = url.split('http://')[1].split(':')[0] import socket address = socket.gethostbyname(host) - _ba.disconnect_from_host() - _ba.connect_to_party(address, port=11111) + bs.disconnect_from_host() + bs.connect_to_party(address, port=11111) except Exception: display_error('Cant get ip from hostname') def _confirmcall(self): if self.wtype == 'signup': - key = ba.textwidget(query=self._text_field) + key = bui.textwidget(query=self._text_field) answer = messenger._signup(registration_key=key) if key else None if answer: self._close() else: - if messenger._login(registration_key=ba.textwidget(query=self._text_field)): + if messenger._login(registration_key=bui.textwidget(query=self._text_field)): self._close() class AddNewIdWindow: def __init__(self): - uiscale = ba.app.ui.uiscale - bg_color = ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) - self._root_widget = ba.containerwidget(size=(500, 250), + uiscale = bui.app.ui_v1.uiscale + bg_color = babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) + self._root_widget = bui.containerwidget(size=(500, 250), transition='in_scale', color=bg_color, toolbar_visibility='menu_minimal_no_back', - parent=_ba.get_special_widget('overlay_stack'), + parent=bui.get_special_widget('overlay_stack'), on_outside_click_call=self._close, - scale=(2.1 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0)) - self._title_text = ba.textwidget(parent=self._root_widget, + scale=(2.1 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0)) + self._title_text = bui.textwidget(parent=self._root_widget, scale=0.8, color=(1, 1, 1), text='Add New ID', @@ -2187,7 +2199,7 @@ class AddNewIdWindow: position=(250, 200), h_align='center', v_align='center') - self._accountid_text = ba.textwidget(parent=self._root_widget, + self._accountid_text = bui.textwidget(parent=self._root_widget, scale=0.6, color=(1, 1, 1), text='pb-id: ', @@ -2195,7 +2207,7 @@ class AddNewIdWindow: position=(50, 155), h_align='center', v_align='center') - self._accountid_field = ba.textwidget( + self._accountid_field = bui.textwidget( parent=self._root_widget, editable=True, size=(250, 40), @@ -2206,7 +2218,7 @@ class AddNewIdWindow: autoselect=True, v_align='center', corner_scale=0.7) - self._nickname_text = ba.textwidget(parent=self._root_widget, + self._nickname_text = bui.textwidget(parent=self._root_widget, scale=0.5, color=(1, 1, 1), text='Nickname: ', @@ -2214,7 +2226,7 @@ class AddNewIdWindow: position=(50, 115), h_align='center', v_align='center') - self._nickname_field = ba.textwidget( + self._nickname_field = bui.textwidget( parent=self._root_widget, editable=True, size=(250, 40), @@ -2225,7 +2237,7 @@ class AddNewIdWindow: autoselect=True, v_align='center', corner_scale=0.7) - self._help_text = ba.textwidget(parent=self._root_widget, + self._help_text = bui.textwidget(parent=self._root_widget, scale=0.4, color=(0.1, 0.9, 0.9), text='Help:\nEnter pb-id of account you\n want to chat to\nEnter nickname of id to\n recognize id easily\nLeave nickname \n to use their default name', @@ -2233,27 +2245,27 @@ class AddNewIdWindow: position=(325, 120), h_align='left', v_align='center') - self._add = ba.buttonwidget(parent=self._root_widget, + self._add = bui.buttonwidget(parent=self._root_widget, size=(50, 30), label='Add', button_type='square', autoselect=True, position=(100, 50), - on_activate_call=ba.Call(self._relay_function)) - ba.textwidget(edit=self._accountid_field, on_return_press_call=self._add.activate) - self._remove = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._relay_function)) + bui.textwidget(edit=self._accountid_field, on_return_press_call=self._add.activate) + self._remove = bui.buttonwidget(parent=self._root_widget, size=(75, 30), label='Remove', button_type='square', autoselect=True, position=(170, 50), on_activate_call=self._remove_id) - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, on_cancel_call=self._close) def _relay_function(self): - account_id = ba.textwidget(query=self._accountid_field) - nickname = ba.textwidget(query=self._nickname_field) + account_id = bui.textwidget(query=self._accountid_field) + nickname = bui.textwidget(query=self._nickname_field) try: if messenger._save_id(account_id, nickname): self._close() @@ -2261,15 +2273,15 @@ class AddNewIdWindow: display_error('Enter valid pb-id') def _remove_id(self): - uiscale = ba.app.ui.uiscale + uiscale = bui.app.ui_v1.uiscale if len(messenger.saved_ids) > 1: choices = [i for i in messenger.saved_ids] choices.remove('all') - choices_display = [ba.Lstr(value=messenger.saved_ids[i]) for i in choices] + choices_display = [babase.Lstr(value=messenger.saved_ids[i]) for i in choices] PopupMenuWindow(position=self._remove.get_screen_space_center(), - color=ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)), - scale=(2.4 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), + color=babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)), + scale=(2.4 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), choices=choices, choices_display=choices_display, current_choice=choices[0], @@ -2287,25 +2299,25 @@ class AddNewIdWindow: """Called when the popup is closing.""" def _close(self): - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, transition=('out_scale')) class AddNewChoiceWindow: def __init__(self): - uiscale = ba.app.ui.uiscale - bg_color = ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) - self._root_widget = ba.containerwidget(size=(500, 250), + uiscale = bui.app.ui_v1.uiscale + bg_color = babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)) + self._root_widget = bui.containerwidget(size=(500, 250), transition='in_scale', color=bg_color, toolbar_visibility='menu_minimal_no_back', - parent=_ba.get_special_widget('overlay_stack'), + parent=bui.get_special_widget('overlay_stack'), on_outside_click_call=self._close, - scale=(2.1 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), - stack_offset=(0, -10) if uiscale is ba.UIScale.SMALL else ( - 240, 0) if uiscale is ba.UIScale.MEDIUM else (330, 20)) - self._title_text = ba.textwidget(parent=self._root_widget, + scale=(2.1 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), + stack_offset=(0, -10) if uiscale is babase.UIScale.SMALL else ( + 240, 0) if uiscale is babase.UIScale.MEDIUM else (330, 20)) + self._title_text = bui.textwidget(parent=self._root_widget, scale=0.8, color=(1, 1, 1), text='Add Custom Command', @@ -2313,7 +2325,7 @@ class AddNewChoiceWindow: position=(250, 200), h_align='center', v_align='center') - self._text_field = ba.textwidget( + self._text_field = bui.textwidget( parent=self._root_widget, editable=True, size=(500, 40), @@ -2324,7 +2336,7 @@ class AddNewChoiceWindow: autoselect=True, v_align='center', corner_scale=0.7) - self._help_text = ba.textwidget(parent=self._root_widget, + self._help_text = bui.textwidget(parent=self._root_widget, scale=0.4, color=(0.2, 0.2, 0.2), text='Use\n$c = client id\n$a = account id\n$n = name', @@ -2332,44 +2344,44 @@ class AddNewChoiceWindow: position=(70, 75), h_align='left', v_align='center') - self._add = ba.buttonwidget(parent=self._root_widget, + self._add = bui.buttonwidget(parent=self._root_widget, size=(50, 30), label='Add', button_type='square', autoselect=True, position=(150, 50), on_activate_call=self._add_choice) - ba.textwidget(edit=self._text_field, on_return_press_call=self._add.activate) - self._remove = ba.buttonwidget(parent=self._root_widget, + bui.textwidget(edit=self._text_field, on_return_press_call=self._add.activate) + self._remove = bui.buttonwidget(parent=self._root_widget, size=(50, 30), label='Remove', button_type='square', autoselect=True, position=(350, 50), on_activate_call=self._remove_custom_command) - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, on_cancel_call=self._close) def _add_choice(self): - newCommand = ba.textwidget(query=self._text_field) - cfg = ba.app.config + newCommand = bui.textwidget(query=self._text_field) + cfg = babase.app.config if any(i in newCommand for i in ('$c', '$a', '$n')): cfg['Custom Commands'].append(newCommand) cfg.apply_and_commit() - ba.screenmessage('Added successfully', (0, 1, 0)) - ba.playsound(ba.getsound('dingSmallHigh')) + bui.screenmessage('Added successfully', (0, 1, 0)) + bui.getsound('dingSmallHigh').play() self._close() else: - ba.screenmessage('Use at least of these ($c, $a, $n)', (1, 0, 0)) - ba.playsound(ba.getsound('error')) + bui.screenmessage('Use at least of these ($c, $a, $n)', (1, 0, 0)) + bui.getsound('error').play() def _remove_custom_command(self): - uiscale = ba.app.ui.uiscale - commands = ba.app.config['Custom Commands'] + uiscale = bui.app.ui_v1.uiscale + commands = babase.app.config['Custom Commands'] PopupMenuWindow(position=self._remove.get_screen_space_center(), - color=ba.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)), - scale=(2.4 if uiscale is ba.UIScale.SMALL else - 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), + color=babase.app.config.get('PartyWindow Main Color', (0.5, 0.5, 0.5)), + scale=(2.4 if uiscale is babase.UIScale.SMALL else + 1.5 if uiscale is babase.UIScale.MEDIUM else 1.0), choices=commands, current_choice=commands[0], delegate=self) @@ -2379,27 +2391,27 @@ class AddNewChoiceWindow: choice: str) -> None: """Called when a choice is selected in the popup.""" if self._popup_type == 'removeCustomCommandSelect': - config = ba.app.config + config = babase.app.config config['Custom Commands'].remove(choice) config.apply_and_commit() - ba.screenmessage('Removed successfully', (0, 1, 0)) - ba.playsound(ba.getsound('shieldDown')) + bui.screenmessage('Removed successfully', (0, 1, 0)) + bui.getsound('shieldDown').play() def popup_menu_closing(self, popup_window: PopupWindow) -> None: """Called when the popup is closing.""" def _close(self): - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, transition=('out_scale')) class Manual_camera_window: def __init__(self): - self._root_widget = ba.containerwidget( + self._root_widget = bui.containerwidget( on_outside_click_call=None, size=(0, 0)) button_size = (30, 30) - self._title_text = ba.textwidget(parent=self._root_widget, + self._title_text = bui.textwidget(parent=self._root_widget, scale=0.9, color=(1, 1, 1), text='Manual Camera Setup', @@ -2407,49 +2419,49 @@ class Manual_camera_window: position=(130, 153), h_align='center', v_align='center') - self._xminus = ba.buttonwidget(parent=self._root_widget, + self._xminus = bui.buttonwidget(parent=self._root_widget, size=button_size, - label=ba.charstr(ba.SpecialChar.LEFT_ARROW), + label=babase.charstr(babase.SpecialChar.LEFT_ARROW), button_type='square', autoselect=True, position=(1, 60), - on_activate_call=ba.Call(self._change_camera_position, 'x-')) - self._xplus = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'x-')) + self._xplus = bui.buttonwidget(parent=self._root_widget, size=button_size, - label=ba.charstr(ba.SpecialChar.RIGHT_ARROW), + label=babase.charstr(babase.SpecialChar.RIGHT_ARROW), button_type='square', autoselect=True, position=(60, 60), - on_activate_call=ba.Call(self._change_camera_position, 'x')) - self._yplus = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'x')) + self._yplus = bui.buttonwidget(parent=self._root_widget, size=button_size, - label=ba.charstr(ba.SpecialChar.UP_ARROW), + label=babase.charstr(babase.SpecialChar.UP_ARROW), button_type='square', autoselect=True, position=(30, 100), - on_activate_call=ba.Call(self._change_camera_position, 'y')) - self._yminus = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'y')) + self._yminus = bui.buttonwidget(parent=self._root_widget, size=button_size, - label=ba.charstr(ba.SpecialChar.DOWN_ARROW), + label=babase.charstr(babase.SpecialChar.DOWN_ARROW), button_type='square', autoselect=True, position=(30, 20), - on_activate_call=ba.Call(self._change_camera_position, 'y-')) - self.inwards = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'y-')) + self.inwards = bui.buttonwidget(parent=self._root_widget, size=(100, 30), label='INWARDS', button_type='square', autoselect=True, position=(120, 90), - on_activate_call=ba.Call(self._change_camera_position, 'z-')) - self._outwards = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'z-')) + self._outwards = bui.buttonwidget(parent=self._root_widget, size=(100, 30), label='OUTWARDS', button_type='square', autoselect=True, position=(120, 50), - on_activate_call=ba.Call(self._change_camera_position, 'z')) - self._step_text = ba.textwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'z')) + self._step_text = bui.textwidget(parent=self._root_widget, scale=0.5, color=(1, 1, 1), text='Step:', @@ -2457,7 +2469,7 @@ class Manual_camera_window: position=(1, -20), h_align='center', v_align='center') - self._text_field = ba.textwidget( + self._text_field = bui.textwidget( parent=self._root_widget, editable=True, size=(100, 40), @@ -2468,29 +2480,29 @@ class Manual_camera_window: autoselect=True, v_align='center', corner_scale=0.7) - self._reset = ba.buttonwidget(parent=self._root_widget, + self._reset = bui.buttonwidget(parent=self._root_widget, size=(50, 30), label='Reset', button_type='square', autoselect=True, position=(120, -35), - on_activate_call=ba.Call(self._change_camera_position, 'reset')) - self._done = ba.buttonwidget(parent=self._root_widget, + on_activate_call=babase.Call(self._change_camera_position, 'reset')) + self._done = bui.buttonwidget(parent=self._root_widget, size=(50, 30), label='Done', button_type='square', autoselect=True, position=(180, -35), on_activate_call=self._close) - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, cancel_button=self._done) def _close(self): - ba.containerwidget(edit=self._root_widget, + bui.containerwidget(edit=self._root_widget, transition=('out_scale')) def _change_camera_position(self, direction): - activity = _ba.get_foreground_host_activity() + activity = bs.get_foreground_host_activity() node = activity.globalsnode aoi = list(node.area_of_interest_bounds) center = [(aoi[0] + aoi[3]) / 2, @@ -2501,9 +2513,9 @@ class Manual_camera_window: aoi[5] - aoi[2]) try: - increment = float(ba.textwidget(query=self._text_field)) + increment = float(bui.textwidget(query=self._text_field)) except: - # ba.print_exception() + # babase.print_exception() increment = 1 if direction == 'x': @@ -2542,7 +2554,7 @@ def __popup_menu_window_init__(self, scale: float = 1.0, color: Tuple[float, float, float] = (0.35, 0.55, 0.15), choices_disabled: Sequence[str] = None, - choices_display: Sequence[ba.Lstr] = None): + choices_display: Sequence[babase.Lstr] = None): # FIXME: Clean up a bit. # pylint: disable=too-many-branches # pylint: disable=too-many-locals @@ -2591,14 +2603,14 @@ def __popup_menu_window_init__(self, self._width, min( maxwidth, - _ba.get_string_width(choice_display_name, + _babase.get_string_width(choice_display_name, suppress_warning=True)) + 75) else: self._width = max( self._width, min( maxwidth, - _ba.get_string_width(choice_display_name, + _babase.get_string_width(choice_display_name, suppress_warning=True)) + 60) # init parent class - this will rescale and reposition things as @@ -2610,22 +2622,22 @@ def __popup_menu_window_init__(self, scale=self._scale) if self._use_scroll: - self._scrollwidget = ba.scrollwidget(parent=self.root_widget, + self._scrollwidget = bui.scrollwidget(parent=self.root_widget, position=(20, 20), highlight=False, color=(0.35, 0.55, 0.15), size=(self._width - 40, self._height - 40)) - self._columnwidget = ba.columnwidget(parent=self._scrollwidget, + self._columnwidget = bui.columnwidget(parent=self._scrollwidget, border=2, margin=0) else: - self._offset_widget = ba.containerwidget(parent=self.root_widget, + self._offset_widget = bui.containerwidget(parent=self.root_widget, position=(30, 15), size=(self._width - 40, self._height), background=False) - self._columnwidget = ba.columnwidget(parent=self._offset_widget, + self._columnwidget = bui.columnwidget(parent=self._offset_widget, border=2, margin=0) for index, choice in enumerate(choices): @@ -2634,9 +2646,9 @@ def __popup_menu_window_init__(self, else: choice_display_name = choice inactive = (choice in self._choices_disabled) - wdg = ba.textwidget(parent=self._columnwidget, + wdg = bui.textwidget(parent=self._columnwidget, size=(self._width - 40, 28), - on_select_call=ba.Call(self._select, index), + on_select_call=babase.Call(self._select, index), click_activate=True, color=(0.5, 0.5, 0.5, 0.5) if inactive else ((0.5, 1, 0.5, @@ -2649,7 +2661,7 @@ def __popup_menu_window_init__(self, v_align='center', selectable=(not inactive)) if choice == self._current_choice: - ba.containerwidget(edit=self._columnwidget, + bui.containerwidget(edit=self._columnwidget, selected_child=wdg, visible_child=wdg) @@ -2658,8 +2670,8 @@ def __popup_menu_window_init__(self, self._done_building = True -original_connect_to_party = _ba.connect_to_party -original_sign_in = ba.internal.sign_in_v1 +original_connect_to_party = bs.connect_to_party +original_sign_in = babase.app.plus.sign_in_v1 def modify_connect_to_party(address: str, port: int = 43210, print_progress: bool = True) -> None: @@ -2677,7 +2689,7 @@ def modify_sign_in(account_type: str) -> None: if messenger.server_online: messenger.logged_in = False global temptimer - temptimer = ba.Timer(2, messenger._cookie_login) + temptimer = bs.Timer(2, messenger._cookie_login) class PingThread(Thread): @@ -2692,7 +2704,7 @@ class PingThread(Thread): sock: Optional[socket.socket] = None try: import socket - from ba.internal import get_ip_address_type + from babase._net import get_ip_address_type socket_type = get_ip_address_type(self._address) sock = socket.socket(socket_type, socket.SOCK_DGRAM) sock.connect((self._address, self._port)) @@ -2718,38 +2730,43 @@ class PingThread(Thread): global _ping _ping = int((time.time() - starttime) * 1000.0) except Exception: - ba.print_exception('Error on gather ping', once=True) + babase.print_exception('Error on gather ping', once=True) finally: try: if sock is not None: sock.close() except Exception: - ba.print_exception('Error on gather ping cleanup', once=True) + babase.print_exception('Error on gather ping cleanup', once=True) def _get_store_char_tex(self) -> str: - _ba.set_party_icon_always_visible(True) - return ('storeCharacterXmas' if ba.internal.get_v1_account_misc_read_val( + return ('storeCharacterXmas' if bui.app.plus.get_v1_account_misc_read_val( 'xmas', False) else - 'storeCharacterEaster' if ba.internal.get_v1_account_misc_read_val( + 'storeCharacterEaster' if bui.app.plus.get_v1_account_misc_read_val( 'easter', False) else 'storeCharacter') +class NewMainMenuWindow(mainmenu.MainMenuWindow): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Display chat icon, but if user open/close gather it may disappear + bui.set_party_icon_always_visible(True) # ba_meta export plugin -class InitalRun(ba.Plugin): +class InitalRun(babase.Plugin): def __init__(self): - if _ba.env().get("build_number", 0) >= 20124: + if build_number >= 21140: global messenger, listener, displayer, color_tracker initialize() messenger = PrivateChatHandler() listener = Thread(target=messenger_thread) listener.start() - displayer = ba.Timer(0.4, msg_displayer, True) + displayer = bs.AppTimer(0.4, msg_displayer, repeat=True) color_tracker = ColorTracker() - bastd.ui.party.PartyWindow = PartyWindow + bauiv1lib.party.PartyWindow = PartyWindow + mainmenu.MainMenuWindow = NewMainMenuWindow PopupMenuWindow.__init__ = __popup_menu_window_init__ - _ba.connect_to_party = modify_connect_to_party - ba.internal.sign_in_v1 = modify_sign_in + bs.connect_to_party = modify_connect_to_party + babase.app.plus.sign_in_v1 = modify_sign_in MainMenuWindow._get_store_char_tex = _get_store_char_tex else: - display_error("This Party Window only runs with BombSquad version higer than 1.6.0.") + display_error("This Party Window only runs with BombSquad version higer than 1.7.19.")