Updating tag.py to api 9

This commit is contained in:
Vishal 2025-01-22 21:09:21 +05:30 committed by GitHub
parent aafab93c0e
commit bc21a7d3e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 43 deletions

View file

@ -1539,6 +1539,7 @@
} }
], ],
"versions": { "versions": {
"2.1.0": null,
"2.0.1": { "2.0.1": {
"api_version": 8, "api_version": 8,
"commit_sha": "718039b", "commit_sha": "718039b",

View file

@ -1,5 +1,3 @@
# Ported by brostos to api 8
# Tool used to make porting easier.(https://github.com/bombsquad-community/baport)
""" """
I apreciate any kind of modification. So feel free to use or edit code or change credit string.... no problem. I apreciate any kind of modification. So feel free to use or edit code or change credit string.... no problem.
@ -16,10 +14,8 @@ how to use:
from __future__ import annotations from __future__ import annotations
from bauiv1lib.profile.edit import EditProfileWindow from bauiv1lib.profile.edit import EditProfileWindow
from bauiv1lib.colorpicker import ColorPicker
from bauiv1lib.popup import PopupMenu from bauiv1lib.popup import PopupMenu
from bascenev1lib.actor.playerspaz import PlayerSpaz from bascenev1lib.actor.playerspaz import PlayerSpaz
from baenv import TARGET_BALLISTICA_BUILD as build_number
import babase import babase
import bauiv1 as bui import bauiv1 as bui
import bascenev1 as bs import bascenev1 as bs
@ -95,7 +91,7 @@ def gethostname() -> str:
if player.inputdevice.client_id == -1: if player.inputdevice.client_id == -1:
name = player.getname(full=True, icon=False) name = player.getname(full=True, icon=False)
break break
if name == bui.app.plus.get_v1_account_name: if name == bui.app.plus.get_v1_account_name():
return '__account__' return '__account__'
return name return name
@ -113,7 +109,11 @@ def NewPlayerSzapInit(self,
highlight: Sequence[float] = (0.5, 0.5, 0.5), highlight: Sequence[float] = (0.5, 0.5, 0.5),
character: str = 'Spaz', character: str = 'Spaz',
powerups_expire: bool = True) -> None: powerups_expire: bool = True) -> None:
self.init(player, color, highlight, character, powerups_expire) self.init(player,
color=color,
highlight=highlight,
character=character,
powerups_expire=powerups_expire)
self.curname = gethostname() self.curname = gethostname()
try: try:
@ -153,14 +153,13 @@ def NewPlayerSzapInit(self,
def NewEditProfileWindowInit(self, def NewEditProfileWindowInit(self,
existing_profile: Optional[str], existing_profile: Optional[str],
in_main_menu: bool, transition: str = 'in_right',
transition: str = 'in_right') -> None: origin_widget: bui.Widget | None = None) -> None:
""" """
New boilerplate for editprofilewindow, addeds button to call TagSettings window New boilerplate for editprofilewindow, addeds button to call TagSettings window
""" """
self.existing_profile = existing_profile self.existing_profile = existing_profile
self.in_main_menu = in_main_menu self.init(existing_profile, transition, origin_widget)
self.init(existing_profile, in_main_menu, transition)
v = self._height - 115.0 v = self._height - 115.0
x_inset = self._x_inset x_inset = self._x_inset
@ -178,20 +177,23 @@ def NewEditProfileWindowInit(self,
text_scale=1.2, text_scale=1.2,
on_activate_call=babase.Call(_on_tagwinbtn_press, self)) on_activate_call=babase.Call(_on_tagwinbtn_press, self))
def _on_tagwinbtn_press(self): def _on_tagwinbtn_press(self):
""" """
Calls tag config window passes all paramisters Calls tag config window passes all paramisters
""" """
bui.containerwidget(edit=self._root_widget, transition='out_scale') if not self.main_window_has_control():
bui.app.ui_v1.set_main_menu_window( return
TagWindow(self.existing_profile,
self.in_main_menu, self.main_window_replace(
TagWindow(
self.existing_profile,
self._name, self._name,
transition='in_right').get_root_widget(), from_window=self._root_widget) transition='in_right',
origin_widget=self.tagwinbtn
)
)
# ba_meta require api 9
# ba_meta require api 8
# ba_meta export plugin # ba_meta export plugin
class Tag(babase.Plugin): class Tag(babase.Plugin):
def __init__(self) -> None: def __init__(self) -> None:
@ -211,15 +213,14 @@ class Tag(babase.Plugin):
EditProfileWindow.__init__ = NewEditProfileWindowInit EditProfileWindow.__init__ = NewEditProfileWindowInit
class TagWindow(bui.Window): class TagWindow(bui.MainWindow):
def __init__(self, def __init__(self,
existing_profile: Optional[str], existing_profile: Optional[str],
in_main_menu: bool,
profilename: str, profilename: str,
transition: Optional[str] = 'in_right'): transition: Optional[str] = 'in_right',
origin_widget: bui.Widget | None = None):
self.existing_profile = existing_profile self.existing_profile = existing_profile
self.in_main_menu = in_main_menu
self.profilename = profilename self.profilename = profilename
uiscale = bui.app.ui_v1.uiscale uiscale = bui.app.ui_v1.uiscale
@ -233,9 +234,11 @@ class TagWindow(bui.Window):
super().__init__( super().__init__(
root_widget=bui.containerwidget( root_widget=bui.containerwidget(
size=(self._width, self._height), size=(self._width, self._height),
transition=transition,
scale=(2.06 if uiscale is babase.UIScale.SMALL else scale=(2.06 if uiscale is babase.UIScale.SMALL else
1.4 if uiscale is babase.UIScale.MEDIUM else 1.0))) 1.4 if uiscale is babase.UIScale.MEDIUM else 1.0)
),
transition=transition,
origin_widget=origin_widget)
self._back_button = bui.buttonwidget( self._back_button = bui.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
@ -246,7 +249,7 @@ class TagWindow(bui.Window):
scale=0.8, scale=0.8,
label=babase.charstr(babase.SpecialChar.BACK), label=babase.charstr(babase.SpecialChar.BACK),
button_type='backSmall', button_type='backSmall',
on_activate_call=self._back) on_activate_call=self.main_window_back)
bui.containerwidget(edit=self._root_widget, cancel_button=self._back_button) bui.containerwidget(edit=self._root_widget, cancel_button=self._back_button)
self._save_button = bui.buttonwidget( self._save_button = bui.buttonwidget(
@ -419,17 +422,6 @@ class TagWindow(bui.Window):
increment=0.1, increment=0.1,
textscale=1.25) textscale=1.25)
def _back(self) -> None:
"""
transit window into back window
"""
bui.containerwidget(edit=self._root_widget,
transition='out_scale')
bui.app.ui_v1.set_main_menu_window(EditProfileWindow(
self.existing_profile,
self.in_main_menu,
transition='in_left').get_root_widget(), from_window=self._root_widget)
def change_val(self, config: List[str], val: bool) -> None: def change_val(self, config: List[str], val: bool) -> None:
""" """
chamges the value of check boxes chamges the value of check boxes
@ -465,13 +457,7 @@ class TagWindow(bui.Window):
bui.screenmessage(f"please define tag", color=(1, 0, 0)) bui.screenmessage(f"please define tag", color=(1, 0, 0))
bui.getsound('error').play() bui.getsound('error').play()
bui.containerwidget(edit=self._root_widget, self.main_window_back()
transition='out_scale')
bui.app.ui_v1.set_main_menu_window(EditProfileWindow(
self.existing_profile,
self.in_main_menu,
transition='in_left').get_root_widget(), from_window=self._root_widget)
class CustomConfigNumberEdit: class CustomConfigNumberEdit:
"""A set of controls for editing a numeric config value. """A set of controls for editing a numeric config value.