mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Update server_switch.py
This commit is contained in:
parent
ceb8f5f00b
commit
768280103f
1 changed files with 114 additions and 111 deletions
|
|
@ -1,33 +1,34 @@
|
||||||
|
# discord @mr.smoothy#5824
|
||||||
|
|
||||||
# ba_meta require api 7
|
# ba_meta require api 8
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import copy
|
import copy
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import _ba
|
import babase
|
||||||
import ba
|
import bauiv1 as bui
|
||||||
|
import bascenev1 as bs
|
||||||
|
import _bascenev1 as _bs
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Optional, Dict, List, Tuple, Type
|
from typing import Any, Optional, Dict, List, Tuple, Type
|
||||||
import ba
|
import bascenev1 as bs
|
||||||
from bastd.ui.gather import GatherWindow
|
from bauiv1lib.gather import GatherWindow
|
||||||
|
|
||||||
from bastd.ui.confirm import ConfirmWindow
|
from bauiv1lib.confirm import ConfirmWindow
|
||||||
# discord @mr.smoothy#5824
|
|
||||||
|
|
||||||
import bastd.ui.mainmenu as bastd_ui_mainmenu
|
import bauiv1lib.mainmenu as bastd_ui_mainmenu
|
||||||
|
|
||||||
connect = ba.internal.connect_to_party
|
connect = bs.connect_to_party
|
||||||
disconnect = ba.internal.disconnect_from_host
|
disconnect = bs.disconnect_from_host
|
||||||
|
|
||||||
server = []
|
server = []
|
||||||
|
|
||||||
|
|
||||||
ip_add = "private"
|
ip_add = "private"
|
||||||
p_port = 44444
|
p_port = 44444
|
||||||
p_name = "nothing here"
|
p_name = "nothing here"
|
||||||
|
|
@ -36,9 +37,9 @@ p_name = "nothing here"
|
||||||
def newconnect_to_party(address, port=43210, print_progress=False):
|
def newconnect_to_party(address, port=43210, print_progress=False):
|
||||||
global ip_add
|
global ip_add
|
||||||
global p_port
|
global p_port
|
||||||
dd = _ba.get_connection_to_host_info()
|
dd = _bs.get_connection_to_host_info()
|
||||||
if (dd != {}):
|
if (dd != {}):
|
||||||
_ba.disconnect_from_host()
|
_bs.disconnect_from_host()
|
||||||
|
|
||||||
ip_add = address
|
ip_add = address
|
||||||
p_port = port
|
p_port = port
|
||||||
|
|
@ -53,7 +54,7 @@ def newconnect_to_party(address, port=43210, print_progress=False):
|
||||||
|
|
||||||
def newdisconnect_from_host():
|
def newdisconnect_from_host():
|
||||||
try:
|
try:
|
||||||
name = _ba.get_connection_to_host_info()['name']
|
name = _bs.get_connection_to_host_info()['name']
|
||||||
global server
|
global server
|
||||||
global ip_add
|
global ip_add
|
||||||
global p_port
|
global p_port
|
||||||
|
|
@ -67,7 +68,7 @@ def newdisconnect_from_host():
|
||||||
|
|
||||||
|
|
||||||
def printip():
|
def printip():
|
||||||
ba.screenmessage("ip address is"+ip_add)
|
bs.screenmessage("ip address is"+ip_add)
|
||||||
|
|
||||||
|
|
||||||
def new_refresh_in_game(
|
def new_refresh_in_game(
|
||||||
|
|
@ -77,19 +78,19 @@ def new_refresh_in_game(
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
# pylint: disable=too-many-statements
|
# pylint: disable=too-many-statements
|
||||||
custom_menu_entries: List[Dict[str, Any]] = []
|
custom_menu_entries: List[Dict[str, Any]] = []
|
||||||
session = _ba.get_foreground_host_session()
|
session = _bs.get_foreground_host_session()
|
||||||
if session is not None:
|
if session is not None:
|
||||||
try:
|
try:
|
||||||
custom_menu_entries = session.get_custom_menu_entries()
|
custom_menu_entries = session.get_custom_menu_entries()
|
||||||
for cme in custom_menu_entries:
|
for cme in custom_menu_entries:
|
||||||
if (not isinstance(cme, dict) or 'label' not in cme
|
if (not isinstance(cme, dict) or 'label' not in cme
|
||||||
or not isinstance(cme['label'], (str, ba.Lstr))
|
or not isinstance(cme['label'], (str, bs.Lstr))
|
||||||
or 'call' not in cme or not callable(cme['call'])):
|
or 'call' not in cme or not callable(cme['call'])):
|
||||||
raise ValueError('invalid custom menu entry: ' +
|
raise ValueError('invalid custom menu entry: ' +
|
||||||
str(cme))
|
str(cme))
|
||||||
except Exception:
|
except Exception:
|
||||||
custom_menu_entries = []
|
custom_menu_entries = []
|
||||||
ba.print_exception(
|
babase.print_exception(
|
||||||
f'Error getting custom menu entries for {session}')
|
f'Error getting custom menu entries for {session}')
|
||||||
self._width = 250.0
|
self._width = 250.0
|
||||||
self._height = 250.0 if self._input_player else 180.0
|
self._height = 250.0 if self._input_player else 180.0
|
||||||
|
|
@ -101,12 +102,12 @@ def new_refresh_in_game(
|
||||||
# In this case we have a leave *and* a disconnect button.
|
# In this case we have a leave *and* a disconnect button.
|
||||||
self._height += 50
|
self._height += 50
|
||||||
self._height += 50 * (len(custom_menu_entries))
|
self._height += 50 * (len(custom_menu_entries))
|
||||||
uiscale = ba.app.ui.uiscale
|
uiscale = bui.app.ui_v1.uiscale
|
||||||
ba.containerwidget(
|
bui.containerwidget(
|
||||||
edit=self._root_widget,
|
edit=self._root_widget,
|
||||||
size=(self._width*2, self._height),
|
size=(self._width*2, self._height),
|
||||||
scale=(2.15 if uiscale is ba.UIScale.SMALL else
|
scale=(2.15 if uiscale is bui.UIScale.SMALL else
|
||||||
1.6 if uiscale is ba.UIScale.MEDIUM else 1.0))
|
1.6 if uiscale is bui.UIScale.MEDIUM else 1.0))
|
||||||
h = 125.0
|
h = 125.0
|
||||||
v = (self._height - 80.0 if self._input_player else self._height - 60)
|
v = (self._height - 80.0 if self._input_player else self._height - 60)
|
||||||
h_offset = 0
|
h_offset = 0
|
||||||
|
|
@ -118,9 +119,9 @@ def new_refresh_in_game(
|
||||||
h += h_offset
|
h += h_offset
|
||||||
h_offset += d_h_offset
|
h_offset += d_h_offset
|
||||||
self._start_button = None
|
self._start_button = None
|
||||||
ba.app.pause()
|
bui.app.pause()
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
ba.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
draw_controller=None,
|
draw_controller=None,
|
||||||
text="IP: "+ip_add+" PORT: "+str(p_port),
|
text="IP: "+ip_add+" PORT: "+str(p_port),
|
||||||
|
|
@ -139,10 +140,10 @@ def new_refresh_in_game(
|
||||||
if (address == ip_add and port == p_port):
|
if (address == ip_add and port == p_port):
|
||||||
self._resume()
|
self._resume()
|
||||||
else:
|
else:
|
||||||
_ba.disconnect_from_host()
|
_bs.disconnect_from_host()
|
||||||
_ba.connect_to_party(address, port)
|
_bs.connect_to_party(address, port)
|
||||||
if len(server) == 0:
|
if len(server) == 0:
|
||||||
ba.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
draw_controller=None,
|
draw_controller=None,
|
||||||
text="Nothing in \n recents",
|
text="Nothing in \n recents",
|
||||||
|
|
@ -152,7 +153,7 @@ def new_refresh_in_game(
|
||||||
size=(20, 60),
|
size=(20, 60),
|
||||||
scale=1)
|
scale=1)
|
||||||
for ser in server:
|
for ser in server:
|
||||||
self._server_button = ba.buttonwidget(
|
self._server_button = bui.buttonwidget(
|
||||||
color=(0.8, 0, 1),
|
color=(0.8, 0, 1),
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h + self._button_width * scale - 80, v_h),
|
position=(h + self._button_width * scale - 80, v_h),
|
||||||
|
|
@ -161,7 +162,7 @@ def new_refresh_in_game(
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ser["name"][0:22],
|
label=ser["name"][0:22],
|
||||||
|
|
||||||
on_activate_call=ba.Call(con, ser["ip"], ser["port"]))
|
on_activate_call=bs.Call(con, ser["ip"], ser["port"]))
|
||||||
v_h = v_h-50
|
v_h = v_h-50
|
||||||
|
|
||||||
# Player name if applicable.
|
# Player name if applicable.
|
||||||
|
|
@ -169,25 +170,25 @@ def new_refresh_in_game(
|
||||||
player_name = self._input_player.getname()
|
player_name = self._input_player.getname()
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
v += 35
|
v += 35
|
||||||
ba.textwidget(parent=self._root_widget,
|
bui.textwidget(parent=self._root_widget,
|
||||||
position=(h - self._button_width / 2, v),
|
position=(h - self._button_width / 2, v),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
color=(1, 1, 1, 0.5),
|
color=(1, 1, 1, 0.5),
|
||||||
scale=0.7,
|
scale=0.7,
|
||||||
h_align='center',
|
h_align='center',
|
||||||
text=ba.Lstr(value=player_name))
|
text=bs.Lstr(value=player_name))
|
||||||
else:
|
else:
|
||||||
player_name = ''
|
player_name = ''
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
self._p_index += 1
|
self._p_index += 1
|
||||||
btn = ba.buttonwidget(parent=self._root_widget,
|
btn = bui.buttonwidget(parent=self._root_widget,
|
||||||
position=(h - self._button_width / 2, v),
|
position=(h - self._button_width / 2, v),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
label=ba.Lstr(resource=self._r + '.resumeText'),
|
label=bs.Lstr(resource=self._r + '.resumeText'),
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
on_activate_call=self._resume)
|
on_activate_call=self._resume)
|
||||||
ba.containerwidget(edit=self._root_widget, cancel_button=btn)
|
bui.containerwidget(edit=self._root_widget, cancel_button=btn)
|
||||||
|
|
||||||
# Add any custom options defined by the current game.
|
# Add any custom options defined by the current game.
|
||||||
for entry in custom_menu_entries:
|
for entry in custom_menu_entries:
|
||||||
|
|
@ -199,11 +200,11 @@ def new_refresh_in_game(
|
||||||
resume = bool(entry.get('resume_on_call', True))
|
resume = bool(entry.get('resume_on_call', True))
|
||||||
|
|
||||||
if resume:
|
if resume:
|
||||||
call = ba.Call(self._resume_and_call, entry['call'])
|
call = bs.Call(self._resume_and_call, entry['call'])
|
||||||
else:
|
else:
|
||||||
call = ba.Call(entry['call'], ba.WeakCall(self._resume))
|
call = bs.Call(entry['call'], bs.WeakCall(self._resume))
|
||||||
|
|
||||||
ba.buttonwidget(parent=self._root_widget,
|
bui.buttonwidget(parent=self._root_widget,
|
||||||
position=(h - self._button_width / 2, v),
|
position=(h - self._button_width / 2, v),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
|
|
@ -215,7 +216,7 @@ def new_refresh_in_game(
|
||||||
and not (self._is_demo or self._is_arcade)):
|
and not (self._is_demo or self._is_arcade)):
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
self._p_index += 1
|
self._p_index += 1
|
||||||
btn = ba.buttonwidget(parent=self._root_widget,
|
btn = bui.buttonwidget(parent=self._root_widget,
|
||||||
position=(h - self._button_width / 2, v),
|
position=(h - self._button_width / 2, v),
|
||||||
size=(self._button_width,
|
size=(self._button_width,
|
||||||
self._button_height),
|
self._button_height),
|
||||||
|
|
@ -226,22 +227,22 @@ def new_refresh_in_game(
|
||||||
|
|
||||||
if (player_name != '' and player_name[0] != '<'
|
if (player_name != '' and player_name[0] != '<'
|
||||||
and player_name[-1] != '>'):
|
and player_name[-1] != '>'):
|
||||||
txt = ba.Lstr(resource=self._r + '.justPlayerText',
|
txt = bs.Lstr(resource=self._r + '.justPlayerText',
|
||||||
subs=[('${NAME}', player_name)])
|
subs=[('${NAME}', player_name)])
|
||||||
else:
|
else:
|
||||||
txt = ba.Lstr(value=player_name)
|
txt = bs.Lstr(value=player_name)
|
||||||
ba.textwidget(parent=self._root_widget,
|
bui.textwidget(parent=self._root_widget,
|
||||||
position=(h, v + self._button_height *
|
position=(h, v + self._button_height *
|
||||||
(0.64 if player_name != '' else 0.5)),
|
(0.64 if player_name != '' else 0.5)),
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
text=ba.Lstr(resource=self._r + '.leaveGameText'),
|
text=bs.Lstr(resource=self._r + '.leaveGameText'),
|
||||||
scale=(0.83 if player_name != '' else 1.0),
|
scale=(0.83 if player_name != '' else 1.0),
|
||||||
color=(0.75, 1.0, 0.7),
|
color=(0.75, 1.0, 0.7),
|
||||||
h_align='center',
|
h_align='center',
|
||||||
v_align='center',
|
v_align='center',
|
||||||
draw_controller=btn,
|
draw_controller=btn,
|
||||||
maxwidth=self._button_width * 0.9)
|
maxwidth=self._button_width * 0.9)
|
||||||
ba.textwidget(parent=self._root_widget,
|
bui.textwidget(parent=self._root_widget,
|
||||||
position=(h, v + self._button_height * 0.27),
|
position=(h, v + self._button_height * 0.27),
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
text=txt,
|
text=txt,
|
||||||
|
|
@ -260,9 +261,12 @@ def new_refresh(self) -> None:
|
||||||
# pylint: disable=too-many-statements
|
# pylint: disable=too-many-statements
|
||||||
global server
|
global server
|
||||||
print(server)
|
print(server)
|
||||||
from bastd.ui.confirm import QuitWindow
|
from bauiv1lib.confirm import QuitWindow
|
||||||
from bastd.ui.store.button import StoreButton
|
from bauiv1lib.store.button import StoreButton
|
||||||
import ba
|
import bascenev1 as bs
|
||||||
|
import _bascenev1 as _bs
|
||||||
|
import bauiv1 as bui
|
||||||
|
import _baplus
|
||||||
# Clear everything that was there.
|
# Clear everything that was there.
|
||||||
children = self._root_widget.get_children()
|
children = self._root_widget.get_children()
|
||||||
for child in children:
|
for child in children:
|
||||||
|
|
@ -276,21 +280,22 @@ def new_refresh(self) -> None:
|
||||||
|
|
||||||
self._r = 'mainMenu'
|
self._r = 'mainMenu'
|
||||||
|
|
||||||
app = ba.app
|
assert bs.app.classic is not None
|
||||||
self._have_quit_button = (app.ui.uiscale is ba.UIScale.LARGE
|
app = bs.app.classic
|
||||||
|
self._have_quit_button = (bui.app.ui_v1.uiscale is bui.UIScale.LARGE
|
||||||
or (app.platform == 'windows'
|
or (app.platform == 'windows'
|
||||||
and app.subplatform == 'oculus'))
|
and app.subplatform == 'oculus'))
|
||||||
|
|
||||||
self._have_store_button = not self._in_game
|
self._have_store_button = not self._in_game
|
||||||
|
|
||||||
self._have_settings_button = (
|
self._have_settings_button = (
|
||||||
(not self._in_game or not app.toolbar_test)
|
(not self._in_game or not bui.app.toolbar_test)
|
||||||
and not (self._is_demo or self._is_arcade or self._is_iircade))
|
and not (self._is_demo or self._is_arcade or self._is_iircade))
|
||||||
|
|
||||||
self._input_device = input_device = _ba.get_ui_input_device()
|
self._input_device = input_device = _bs.get_ui_input_device()
|
||||||
self._input_player = input_device.player if input_device else None
|
self._input_player = input_device.player if input_device else None
|
||||||
self._connected_to_remote_player = (
|
self._connected_to_remote_player = (
|
||||||
input_device.is_connected_to_remote_player()
|
input_device.is_attached_to_player()
|
||||||
if input_device else False)
|
if input_device else False)
|
||||||
|
|
||||||
positions: List[Tuple[float, float, float]] = []
|
positions: List[Tuple[float, float, float]] = []
|
||||||
|
|
@ -299,14 +304,14 @@ def new_refresh(self) -> None:
|
||||||
if self._in_game:
|
if self._in_game:
|
||||||
h, v, scale = self._refresh_in_game(positions)
|
h, v, scale = self._refresh_in_game(positions)
|
||||||
print("refreshing in GAME", ip_add)
|
print("refreshing in GAME", ip_add)
|
||||||
# btn = ba.buttonwidget(parent=self._root_widget,
|
# btn = bui.buttonwidget(parent=self._root_widget,
|
||||||
# position=(80,270),
|
# position=(80,270),
|
||||||
# size=(100, 90),
|
# size=(100, 90),
|
||||||
# scale=1.2,
|
# scale=1.2,
|
||||||
# label=ip_add,
|
# label=ip_add,
|
||||||
# autoselect=None,
|
# autoselect=None,
|
||||||
# on_activate_call=printip)
|
# on_activate_call=printip)
|
||||||
ba.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
draw_controller=None,
|
draw_controller=None,
|
||||||
text="IP: "+ip_add+" PORT: "+str(p_port),
|
text="IP: "+ip_add+" PORT: "+str(p_port),
|
||||||
|
|
@ -315,31 +320,31 @@ def new_refresh(self) -> None:
|
||||||
v_align='center',
|
v_align='center',
|
||||||
size=(20, 60),
|
size=(20, 60),
|
||||||
scale=1)
|
scale=1)
|
||||||
self._server_button = ba.buttonwidget(
|
self._server_button = bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h * 3.2 + 20 - self._button_width * scale, v),
|
position=(h * 3.2 + 20 - self._button_width * scale, v),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource=self._r + '.settingsText'),
|
label=bs.Lstr(resource=self._r + '.settingsText'),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
on_activate_call=self._settings)
|
on_activate_call=self._settings)
|
||||||
self._server_button2 = ba.buttonwidget(
|
self._server_button2 = bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h * 3.2 + 20 - self._button_width * scale, v-50),
|
position=(h * 3.2 + 20 - self._button_width * scale, v-50),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource=self._r + '.settingsText'),
|
label=bs.Lstr(resource=self._r + '.settingsText'),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
on_activate_call=self._settings)
|
on_activate_call=self._settings)
|
||||||
self._server_button3 = ba.buttonwidget(
|
self._server_button3 = bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h * 3.2 + 20 - self._button_width * scale, v-100),
|
position=(h * 3.2 + 20 - self._button_width * scale, v-100),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource=self._r + '.settingsText'),
|
label=bs.Lstr(resource=self._r + '.settingsText'),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
on_activate_call=self._settings)
|
on_activate_call=self._settings)
|
||||||
|
|
||||||
|
|
@ -349,27 +354,27 @@ def new_refresh(self) -> None:
|
||||||
if self._have_settings_button:
|
if self._have_settings_button:
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
self._p_index += 1
|
self._p_index += 1
|
||||||
self._settings_button = ba.buttonwidget(
|
self._settings_button = bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h - self._button_width * 0.5 * scale, v),
|
position=(h - self._button_width * 0.5 * scale, v),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource=self._r + '.settingsText'),
|
label=bs.Lstr(resource=self._r + '.settingsText'),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
on_activate_call=self._settings)
|
on_activate_call=self._settings)
|
||||||
|
|
||||||
# Scattered eggs on easter.
|
# Scattered eggs on easter.
|
||||||
if _ba.get_account_misc_read_val('easter',
|
if _baplus.get_v1_account_misc_read_val('easter',
|
||||||
False) and not self._in_game:
|
False) and not self._in_game:
|
||||||
icon_size = 34
|
icon_size = 34
|
||||||
ba.imagewidget(parent=self._root_widget,
|
bui.imagewidget(parent=self._root_widget,
|
||||||
position=(h - icon_size * 0.5 - 15,
|
position=(h - icon_size * 0.5 - 15,
|
||||||
v + self._button_height * scale -
|
v + self._button_height * scale -
|
||||||
icon_size * 0.24 + 1.5),
|
icon_size * 0.24 + 1.5),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
size=(icon_size, icon_size),
|
size=(icon_size, icon_size),
|
||||||
texture=ba.gettexture('egg3'),
|
texture=bui.gettexture('egg3'),
|
||||||
tilt_scale=0.0)
|
tilt_scale=0.0)
|
||||||
|
|
||||||
self._tdelay += self._t_delay_inc
|
self._tdelay += self._t_delay_inc
|
||||||
|
|
@ -379,36 +384,36 @@ def new_refresh(self) -> None:
|
||||||
self._p_index += 1
|
self._p_index += 1
|
||||||
|
|
||||||
# If we're in a replay, we have a 'Leave Replay' button.
|
# If we're in a replay, we have a 'Leave Replay' button.
|
||||||
if _ba.is_in_replay():
|
if _bs.is_in_replay():
|
||||||
ba.buttonwidget(parent=self._root_widget,
|
bui.buttonwidget(parent=self._root_widget,
|
||||||
position=(h - self._button_width * 0.5 * scale,
|
position=(h - self._button_width * 0.5 * scale,
|
||||||
v),
|
v),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource='replayEndText'),
|
label=bs.Lstr(resource='replayEndText'),
|
||||||
on_activate_call=self._confirm_end_replay)
|
on_activate_call=self._confirm_end_replay)
|
||||||
elif _ba.get_foreground_host_session() is not None:
|
elif _bs.get_foreground_host_session() is not None:
|
||||||
ba.buttonwidget(
|
bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h - self._button_width * 0.5 * scale, v),
|
position=(h - self._button_width * 0.5 * scale, v),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource=self._r + '.endGameText'),
|
label=bs.Lstr(resource=self._r + '.endGameText'),
|
||||||
on_activate_call=self._confirm_end_game)
|
on_activate_call=self._confirm_end_game)
|
||||||
# Assume we're in a client-session.
|
# Assume we're in a client-session.
|
||||||
else:
|
else:
|
||||||
ba.buttonwidget(
|
bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h - self._button_width * 0.5 * scale, v),
|
position=(h - self._button_width * 0.5 * scale, v),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
label=ba.Lstr(resource=self._r + '.leavePartyText'),
|
label=bs.Lstr(resource=self._r + '.leavePartyText'),
|
||||||
on_activate_call=self._confirm_leave_party)
|
on_activate_call=self._confirm_leave_party)
|
||||||
|
|
||||||
self._store_button: Optional[ba.Widget]
|
self._store_button: Optional[bui.Widget]
|
||||||
if self._have_store_button:
|
if self._have_store_button:
|
||||||
this_b_width = self._button_width
|
this_b_width = self._button_width
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
|
|
@ -419,20 +424,20 @@ def new_refresh(self) -> None:
|
||||||
position=(h - this_b_width * 0.5 * scale, v),
|
position=(h - this_b_width * 0.5 * scale, v),
|
||||||
size=(this_b_width, self._button_height),
|
size=(this_b_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
on_activate_call=ba.WeakCall(self._on_store_pressed),
|
on_activate_call=bs.WeakCall(self._on_store_pressed),
|
||||||
sale_scale=1.3,
|
sale_scale=1.3,
|
||||||
transition_delay=self._tdelay)
|
transition_delay=self._tdelay)
|
||||||
self._store_button = store_button = sbtn.get_button()
|
self._store_button = store_button = sbtn.get_button()
|
||||||
uiscale = ba.app.ui.uiscale
|
uiscale = bui.app.ui_v1.uiscale
|
||||||
icon_size = (55 if uiscale is ba.UIScale.SMALL else
|
icon_size = (55 if uiscale is bui.UIScale.SMALL else
|
||||||
55 if uiscale is ba.UIScale.MEDIUM else 70)
|
55 if uiscale is bui.UIScale.MEDIUM else 70)
|
||||||
ba.imagewidget(
|
bui.imagewidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h - icon_size * 0.5,
|
position=(h - icon_size * 0.5,
|
||||||
v + self._button_height * scale - icon_size * 0.23),
|
v + self._button_height * scale - icon_size * 0.23),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
size=(icon_size, icon_size),
|
size=(icon_size, icon_size),
|
||||||
texture=ba.gettexture(self._store_char_tex),
|
texture=bui.gettexture(self._store_char_tex),
|
||||||
tilt_scale=0.0,
|
tilt_scale=0.0,
|
||||||
draw_controller=store_button)
|
draw_controller=store_button)
|
||||||
|
|
||||||
|
|
@ -440,35 +445,35 @@ def new_refresh(self) -> None:
|
||||||
else:
|
else:
|
||||||
self._store_button = None
|
self._store_button = None
|
||||||
|
|
||||||
self._quit_button: Optional[ba.Widget]
|
self._quit_button: Optional[bui.Widget]
|
||||||
if not self._in_game and self._have_quit_button:
|
if not self._in_game and self._have_quit_button:
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
self._p_index += 1
|
self._p_index += 1
|
||||||
self._quit_button = quit_button = ba.buttonwidget(
|
self._quit_button = quit_button = bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
autoselect=self._use_autoselect,
|
autoselect=self._use_autoselect,
|
||||||
position=(h - self._button_width * 0.5 * scale, v),
|
position=(h - self._button_width * 0.5 * scale, v),
|
||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
label=ba.Lstr(resource=self._r +
|
label=bs.Lstr(resource=self._r +
|
||||||
('.quitText' if 'Mac' in
|
('.quitText' if 'Mac' in
|
||||||
ba.app.user_agent_string else '.exitGameText')),
|
bs.app.classic.legacy_user_agent_string else '.exitGameText')),
|
||||||
on_activate_call=self._quit,
|
on_activate_call=self._quit,
|
||||||
transition_delay=self._tdelay)
|
transition_delay=self._tdelay)
|
||||||
|
|
||||||
# Scattered eggs on easter.
|
# Scattered eggs on easter.
|
||||||
if _ba.get_account_misc_read_val('easter', False):
|
if _baplus.get_v1_account_misc_read_val('easter', False):
|
||||||
icon_size = 30
|
icon_size = 30
|
||||||
ba.imagewidget(parent=self._root_widget,
|
bui.imagewidget(parent=self._root_widget,
|
||||||
position=(h - icon_size * 0.5 + 25,
|
position=(h - icon_size * 0.5 + 25,
|
||||||
v + self._button_height * scale -
|
v + self._button_height * scale -
|
||||||
icon_size * 0.24 + 1.5),
|
icon_size * 0.24 + 1.5),
|
||||||
transition_delay=self._tdelay,
|
transition_delay=self._tdelay,
|
||||||
size=(icon_size, icon_size),
|
size=(icon_size, icon_size),
|
||||||
texture=ba.gettexture('egg1'),
|
texture=bui.gettexture('egg1'),
|
||||||
tilt_scale=0.0)
|
tilt_scale=0.0)
|
||||||
|
|
||||||
ba.containerwidget(edit=self._root_widget,
|
bui.containerwidget(edit=self._root_widget,
|
||||||
cancel_button=quit_button)
|
cancel_button=quit_button)
|
||||||
self._tdelay += self._t_delay_inc
|
self._tdelay += self._t_delay_inc
|
||||||
else:
|
else:
|
||||||
|
|
@ -477,34 +482,34 @@ def new_refresh(self) -> None:
|
||||||
# If we're not in-game, have no quit button, and this is android,
|
# If we're not in-game, have no quit button, and this is android,
|
||||||
# we want back presses to quit our activity.
|
# we want back presses to quit our activity.
|
||||||
if (not self._in_game and not self._have_quit_button
|
if (not self._in_game and not self._have_quit_button
|
||||||
and ba.app.platform == 'android'):
|
and bs.app.classic.platform == 'android'):
|
||||||
|
|
||||||
def _do_quit() -> None:
|
def _do_quit() -> None:
|
||||||
QuitWindow(swish=True, back=True)
|
QuitWindow(swish=True, back=True)
|
||||||
|
|
||||||
ba.containerwidget(edit=self._root_widget,
|
bui.containerwidget(edit=self._root_widget,
|
||||||
on_cancel_call=_do_quit)
|
on_cancel_call=_do_quit)
|
||||||
|
|
||||||
# Add speed-up/slow-down buttons for replays.
|
# Add speed-up/slow-down buttons for replays.
|
||||||
# (ideally this should be part of a fading-out playback bar like most
|
# (ideally this should be part of a fading-out playback bar like most
|
||||||
# media players but this works for now).
|
# media players but this works for now).
|
||||||
if _ba.is_in_replay():
|
if _bs.is_in_replay():
|
||||||
b_size = 50.0
|
b_size = 50.0
|
||||||
b_buffer = 10.0
|
b_buffer = 10.0
|
||||||
t_scale = 0.75
|
t_scale = 0.75
|
||||||
uiscale = ba.app.ui.uiscale
|
uiscale = bui.app.ui_v1.uiscale
|
||||||
if uiscale is ba.UIScale.SMALL:
|
if uiscale is bui.UIScale.SMALL:
|
||||||
b_size *= 0.6
|
b_size *= 0.6
|
||||||
b_buffer *= 1.0
|
b_buffer *= 1.0
|
||||||
v_offs = -40
|
v_offs = -40
|
||||||
t_scale = 0.5
|
t_scale = 0.5
|
||||||
elif uiscale is ba.UIScale.MEDIUM:
|
elif uiscale is bui.UIScale.MEDIUM:
|
||||||
v_offs = -70
|
v_offs = -70
|
||||||
else:
|
else:
|
||||||
v_offs = -100
|
v_offs = -100
|
||||||
self._replay_speed_text = ba.textwidget(
|
self._replay_speed_text = bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
text=ba.Lstr(resource='watchWindow.playbackSpeedText',
|
text=bs.Lstr(resource='watchWindow.playbackSpeedText',
|
||||||
subs=[('${SPEED}', str(1.23))]),
|
subs=[('${SPEED}', str(1.23))]),
|
||||||
position=(h, v + v_offs + 7 * t_scale),
|
position=(h, v + v_offs + 7 * t_scale),
|
||||||
h_align='center',
|
h_align='center',
|
||||||
|
|
@ -516,21 +521,20 @@ def new_refresh(self) -> None:
|
||||||
self._change_replay_speed(0)
|
self._change_replay_speed(0)
|
||||||
|
|
||||||
# Keep updating in a timer in case it gets changed elsewhere.
|
# Keep updating in a timer in case it gets changed elsewhere.
|
||||||
self._change_replay_speed_timer = ba.Timer(
|
self._change_replay_speed_timer = bs.Timer(
|
||||||
0.25,
|
0.25,
|
||||||
ba.WeakCall(self._change_replay_speed, 0),
|
bs.WeakCall(self._change_replay_speed, 0),
|
||||||
timetype=ba.TimeType.REAL,
|
|
||||||
repeat=True)
|
repeat=True)
|
||||||
btn = ba.buttonwidget(parent=self._root_widget,
|
btn = bui.buttonwidget(parent=self._root_widget,
|
||||||
position=(h - b_size - b_buffer,
|
position=(h - b_size - b_buffer,
|
||||||
v - b_size - b_buffer + v_offs),
|
v - b_size - b_buffer + v_offs),
|
||||||
button_type='square',
|
button_type='square',
|
||||||
size=(b_size, b_size),
|
size=(b_size, b_size),
|
||||||
label='',
|
label='',
|
||||||
autoselect=True,
|
autoselect=True,
|
||||||
on_activate_call=ba.Call(
|
on_activate_call=bs.Call(
|
||||||
self._change_replay_speed, -1))
|
self._change_replay_speed, -1))
|
||||||
ba.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
draw_controller=btn,
|
draw_controller=btn,
|
||||||
text='-',
|
text='-',
|
||||||
|
|
@ -540,15 +544,15 @@ def new_refresh(self) -> None:
|
||||||
v_align='center',
|
v_align='center',
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
scale=3.0 * t_scale)
|
scale=3.0 * t_scale)
|
||||||
btn = ba.buttonwidget(
|
btn = bui.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(h + b_buffer, v - b_size - b_buffer + v_offs),
|
position=(h + b_buffer, v - b_size - b_buffer + v_offs),
|
||||||
button_type='square',
|
button_type='square',
|
||||||
size=(b_size, b_size),
|
size=(b_size, b_size),
|
||||||
label='',
|
label='',
|
||||||
autoselect=True,
|
autoselect=True,
|
||||||
on_activate_call=ba.Call(self._change_replay_speed, 1))
|
on_activate_call=bs.Call(self._change_replay_speed, 1))
|
||||||
ba.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
draw_controller=btn,
|
draw_controller=btn,
|
||||||
text='+',
|
text='+',
|
||||||
|
|
@ -559,14 +563,13 @@ def new_refresh(self) -> None:
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
scale=3.0 * t_scale)
|
scale=3.0 * t_scale)
|
||||||
|
|
||||||
|
|
||||||
# ba_meta export plugin
|
# ba_meta export plugin
|
||||||
|
class bySmoothy(babase.Plugin):
|
||||||
|
|
||||||
class bySmoothy(ba.Plugin):
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if _ba.env().get("build_number", 0) >= 20577:
|
if babase.env().get("build_number", 0) >= 21140:
|
||||||
bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = new_refresh_in_game
|
bastd_ui_mainmenu.MainMenuWindow._refresh_in_game = new_refresh_in_game
|
||||||
ba.internal.connect_to_party = newconnect_to_party
|
bs.connect_to_party = newconnect_to_party
|
||||||
ba.internal.disconnect_from_host = newdisconnect_from_host
|
bs.disconnect_from_host = newdisconnect_from_host
|
||||||
else:
|
else:
|
||||||
print("Server Switch only works on bs 1.7 and above")
|
print("Server Switch only works on bs 1.7.20 and above")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue