[ci] auto-format

This commit is contained in:
BroBordd 2025-08-10 13:02:22 +00:00 committed by github-actions[bot]
parent bba1a27837
commit 99611b9ae6
8 changed files with 1960 additions and 1387 deletions

View file

@ -46,11 +46,13 @@ from bauiv1lib.ingamemenu import InGameMenuWindow as igm
from babase import Plugin, InputType as IT from babase import Plugin, InputType as IT
from math import sqrt, dist from math import sqrt, dist
class Camera: class Camera:
__doc__ = 'A simple camera.' __doc__ = 'A simple camera.'
__ins__ = None __ins__ = None
__lst__ = None __lst__ = None
__yes__ = False __yes__ = False
def __init__(s) -> None: def __init__(s) -> None:
c = s.__class__ c = s.__class__
if c.__yes__: if c.__yes__:
@ -59,7 +61,8 @@ class Camera:
return return
c.__ins__ = s c.__ins__ = s
c.__yes__ = True c.__yes__ = True
if c.__lst__: SCM(False) if c.__lst__:
SCM(False)
s.stage = 0 s.stage = 0
p = (0, 1, 0) p = (0, 1, 0)
s.tex = 'achievementCrossHair' s.tex = 'achievementCrossHair'
@ -130,7 +133,8 @@ class Camera:
'h_align': h 'h_align': h
} }
) )
if b: s.kids.append(n) if b:
s.kids.append(n)
return n return n
"""Create a dot""" """Create a dot"""
def dot(s, p, b=True, tex='black'): def dot(s, p, b=True, tex='black'):
@ -147,7 +151,8 @@ class Camera:
'materials': [s.M], 'materials': [s.M],
} }
) )
if b: s.kids.append(n) if b:
s.kids.append(n)
return n return n
"""Draw a line""" """Draw a line"""
def line(s, p1, p2, i=2, tex='black'): def line(s, p1, p2, i=2, tex='black'):
@ -167,7 +172,8 @@ class Camera:
p = s.getpos() p = s.getpos()
s.p1 = (p[0]-0.01, p[1], p[2]) s.p1 = (p[0]-0.01, p[1], p[2])
s.okay.append(s.dot(s.p1, b=False)) s.okay.append(s.dot(s.p1, b=False))
s.okay.append(s.tip(f'Camera position\n{tuple([round(i,2) for i in s.p1])}',s.p1,b=False)) s.okay.append(
s.tip(f'Camera position\n{tuple([round(i, 2) for i in s.p1])}', s.p1, b=False))
else: else:
[i.delete() for i in s.kids] [i.delete() for i in s.kids]
s.kids.clear() s.kids.clear()
@ -207,7 +213,8 @@ class Camera:
s.line(bl, br, m, **j) s.line(bl, br, m, **j)
s.line(br, tr, m, **j) s.line(br, tr, m, **j)
s.tip(f'Your display\n{r[0]}x{r[1]} px\n{tuple([round(i,2) for i in p2])}',tr,'right') s.tip(
f'Your display\n{r[0]}x{r[1]} px\n{tuple([round(i, 2) for i in p2])}', tr, 'right')
s.stage = 2 s.stage = 2
s.overlay.press(3) s.overlay.press(3)
tick(0.25, animate(s.node, 'mesh_scale', {0: 0.5, 0.1: 0.2, 0.2: 0.5}).delete) tick(0.25, animate(s.node, 'mesh_scale', {0: 0.5, 0.1: 0.2, 0.2: 0.5}).delete)
@ -237,19 +244,25 @@ class Camera:
def reset(s): def reset(s):
s.__class__.__yes__ = False s.__class__.__yes__ = False
me = getme() me = getme()
if not me: return if not me:
return
me.resetinput() me.resetinput()
with ga().context: me.actor.connect_controls_to_player() with ga().context:
me.actor.connect_controls_to_player()
[i.delete() for i in (s.kids+s.okay)] [i.delete() for i in (s.kids+s.okay)]
"""Manage movement""" """Manage movement"""
def manage(s, a, lr=0): def manage(s, a, lr=0):
if lr: s.llr = a; return if lr:
s.llr = a
return
s.lud = a s.lud = a
"""Move""" """Move"""
def move(s): def move(s):
m = getme(1) m = getme(1)
if (not m) or m._dead: s.destroy() if (not m) or m._dead:
try: p = s.getpos() s.destroy()
try:
p = s.getpos()
except: except:
s.overlay.destroy() s.overlay.destroy()
return return
@ -264,9 +277,12 @@ class Camera:
s.loop(i) s.loop(i)
"""Keep elevating""" """Keep elevating"""
def loop(s, i): def loop(s, i):
if s.mode != i: return if s.mode != i:
try: p = list(s.node.position) return
except: return try:
p = list(s.node.position)
except:
return
p[1] += s.step if i else -s.step p[1] += s.step if i else -s.step
s.node.position = tuple(p) s.node.position = tuple(p)
teck(s.wait, lambda: s.loop(i)) teck(s.wait, lambda: s.loop(i))
@ -284,8 +300,10 @@ class Camera:
def done(s, talk=True): def done(s, talk=True):
s.overlay.press(1) s.overlay.press(1)
s.overlay.destroy() s.overlay.destroy()
try: p = s.node.position try:
except: return p = s.node.position
except:
return
with ga().context: with ga().context:
gbs('laser').play(position=p) gbs('laser').play(position=p)
tick(0.2, animate(s.node, 'mesh_scale', {0: 0.5, 0.08: 1, 0.2: 0}).delete) tick(0.2, animate(s.node, 'mesh_scale', {0: 0.5, 0.08: 1, 0.2: 0}).delete)
@ -300,9 +318,13 @@ class Camera:
nice('Applied!') nice('Applied!')
elif talk: elif talk:
note('Incomplete camera setup\nNo changes applied.') note('Incomplete camera setup\nNo changes applied.')
if s.__class__.__ins__ == s: s.__class__.__ins__ = None if s.__class__.__ins__ == s:
s.__class__.__ins__ = None
"""Controls overlay""" """Controls overlay"""
class Overlay: class Overlay:
__lst__ = None __lst__ = None
"""Place nodes""" """Place nodes"""
@ -403,7 +425,9 @@ class Overlay:
new = [x, y, z] new = [x, y, z]
for i in range(3): for i in range(3):
c = s.colors[[1, 0, 2][i]] c = s.colors[[1, 0, 2][i]]
if s.old[i] == new[i]: s.pset(i,c[0]); continue if s.old[i] == new[i]:
s.pset(i, c[0])
continue
t = s.pos[i] t = s.pos[i]
t.text = str(round(new[i], 5)) t.text = str(round(new[i], 5))
s.pset(i, c[1]) s.pset(i, c[1])
@ -417,30 +441,39 @@ class Overlay:
s.nub[1].position = (p[0]+lr*d, p[1]+ud*d) s.nub[1].position = (p[0]+lr*d, p[1]+ud*d)
"""Fade""" """Fade"""
def fade(s, i=0): def fade(s, i=0):
if str(ga()) != s.__class__.__lst__: return if str(ga()) != s.__class__.__lst__:
return
mem = s.nodes() mem = s.nodes()
[tick(1, animate(n, 'opacity', {0: i, 0.5: abs(i-0.7)}).delete) for n in mem] [tick(1, animate(n, 'opacity', {0: i, 0.5: abs(i-0.7)}).delete) for n in mem]
"""Destroy overlay""" """Destroy overlay"""
def destroy(s): def destroy(s):
if s.dead: return if s.dead:
return
s.dead = True s.dead = True
with ga().context: with ga().context:
tick(0.2, lambda: s.fade(0.7)) tick(0.2, lambda: s.fade(0.7))
tick(2, lambda: [n.delete() for n in s.nodes()]) tick(2, lambda: [n.delete() for n in s.nodes()])
# Mini tools # Mini tools
note = lambda t, b=False: (push(t,color=(1,1,0)),gs('block').play() if b else None) def note(t, b=False): return (push(t, color=(1, 1, 0)), gs('block').play() if b else None)
nice = lambda t: (push(t,color=(0,1,0)),gs('dingSmallHigh').play()) def nice(t): return (push(t, color=(0, 1, 0)), gs('dingSmallHigh').play())
SCM = lambda b: (setattr(Camera,'__lst__',b),SSCM(b)) def SCM(b): return (setattr(Camera, '__lst__', b), SSCM(b))
scale = lambda v,s: (v[0]*s,v[1]*s,v[2]*s) def scale(v, s): return (v[0]*s, v[1]*s, v[2]*s)
cross = lambda a,b: (a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]) def cross(a, b): return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])
sub = lambda a,b: (a[0]-b[0],a[1]-b[1],a[2]-b[2]) def sub(a, b): return (a[0]-b[0], a[1]-b[1], a[2]-b[2])
add = lambda a,b: (a[0]+b[0],a[1]+b[1],a[2]+b[2]) def add(a, b): return (a[0]+b[0], a[1]+b[1], a[2]+b[2])
def getme(actor=0): def getme(actor=0):
for p in ga().players: for p in ga().players:
if p.sessionplayer.inputdevice.client_id == -1: if p.sessionplayer.inputdevice.client_id == -1:
return p.actor if actor else p return p.actor if actor else p
def LN(d): me = getme(); [me.assigninput(getattr(IT, k), d[k]) for k in d] def LN(d): me = getme(); [me.assigninput(getattr(IT, k), d[k]) for k in d]
def RESUME(): def RESUME():
u = APP.ui_v1 u = APP.ui_v1
c = APP.classic c = APP.classic
@ -448,26 +481,35 @@ def RESUME():
u.clear_main_window() u.clear_main_window()
[z() for z in c.main_menu_resume_callbacks] [z() for z in c.main_menu_resume_callbacks]
c.main_menu_resume_callbacks.clear() c.main_menu_resume_callbacks.clear()
def norm(v): def norm(v):
a, b, c = v a, b, c = v
l = sqrt(a**2+b**2+c**2) l = sqrt(a**2+b**2+c**2)
return (0, 0, 0) if l == 0 else (a/l, b/l, c/l) return (0, 0, 0) if l == 0 else (a/l, b/l, c/l)
def var(s, v=None): def var(s, v=None):
c = APP.config c = APP.config
s = 'cam_'+s s = 'cam_'+s
if v is None: return c.get(s,v) if v is None:
return c.get(s, v)
c[s] = v c[s] = v
c.commit() c.commit()
# brobord collide grass # brobord collide grass
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
has_settings_ui = lambda s: True def has_settings_ui(s): return True
show_settings_ui = lambda s, src: s.ui(source=src) def show_settings_ui(s, src): return s.ui(source=src)
col = (0.18, 0.18, 0.18) col = (0.18, 0.18, 0.18)
def __init__(s): def __init__(s):
o = igm._refresh_in_game o = igm._refresh_in_game
def e(f, *a, **k): def e(f, *a, **k):
r = o(f, *a, **k) r = o(f, *a, **k)
b = bw( b = bw(
@ -506,7 +548,8 @@ class byBordd(Plugin):
parent=gsw('overlay_stack'), parent=gsw('overlay_stack'),
scale_origin_stack_offset=off scale_origin_stack_offset=off
) )
s.back = lambda b=True: (cw(w,transition=['out_right','out_scale'][bool(source) and b]),gs('swish').play() if b else None) s.back = lambda b=True: (
cw(w, transition=['out_right', 'out_scale'][bool(source) and b]), gs('swish').play() if b else None)
cw(w, on_outside_click_call=s.back) cw(w, on_outside_click_call=s.back)
b = Camera.__yes__ b = Camera.__yes__
t = [ t = [
@ -561,17 +604,26 @@ class byBordd(Plugin):
nice('Resetored original settings!') nice('Resetored original settings!')
"""Copy last""" """Copy last"""
def copy(s): def copy(s):
if not CIS(): note('Unsupported!',True); return if not CIS():
note('Unsupported!', True)
return
g = s.gather() g = s.gather()
if not g[1]: note('Apply something first!',True); return if not g[1]:
note('Apply something first!', True)
return
g = [tuple([round(i, 2) for i in j]) for j in g] g = [tuple([round(i, 2) for i in j]) for j in g]
COPY(f'from _babase import set_camera_manual as SCM, set_camera_target as SCT, set_camera_position as SCP; SCM(True); SCP(*{g[0]}); SCT(*{g[1]})') COPY(
f'from _babase import set_camera_manual as SCM, set_camera_target as SCT, set_camera_position as SCP; SCM(True); SCP(*{g[0]}); SCT(*{g[1]})')
nice('Copied command!\nPaste it in dev console anytime to load config!') nice('Copied command!\nPaste it in dev console anytime to load config!')
"""Load last""" """Load last"""
def load(s): def load(s):
g = s.gather() g = s.gather()
if not g[1]: note('Apply something first!',True); return if not g[1]:
if Camera.__yes__: note('Stop camera first!',True); return note('Apply something first!', True)
return
if Camera.__yes__:
note('Stop camera first!', True)
return
SCM(True) SCM(True)
SCP(*g[0]) SCP(*g[0])
SCT(*g[1]) SCT(*g[1])
@ -579,8 +631,13 @@ class byBordd(Plugin):
"""Start camera""" """Start camera"""
def start(s): def start(s):
a = ga() a = ga()
if not a: note('Only mapping requires you to be the host!\nYou still can load previous config though',True); return if not a:
if not getme(): note('Join the game first!',True); return note('Only mapping requires you to be the host!\nYou still can load previous config though', True)
return
if not getme():
note('Join the game first!', True)
return
s.back(False) s.back(False)
RESUME() if s.main else None RESUME() if s.main else None
with a.context: Camera() with a.context:
Camera()

File diff suppressed because it is too large Load diff

View file

@ -44,6 +44,7 @@ from bascenev1 import (
get_game_roster as GGR get_game_roster as GGR
) )
class Finder: class Finder:
COL1 = (0, 0.3, 0.3) COL1 = (0, 0.3, 0.3)
COL2 = (0, 0.55, 0.55) COL2 = (0, 0.55, 0.55)
@ -56,6 +57,7 @@ class Finder:
MEM = [] MEM = []
BST = [] BST = []
SL = None SL = None
def __init__(s, src): def __init__(s, src):
s.thr = [] s.thr = []
s.ikids = [] s.ikids = []
@ -232,10 +234,12 @@ class Finder:
maxwidth=170, maxwidth=170,
h_align='center' h_align='center'
) if c.SL is None else 0 ) if c.SL is None else 0
def hl(s, _, p): def hl(s, _, p):
[tw(t, color=s.COL3) for t in s.kids] [tw(t, color=s.COL3) for t in s.kids]
tw(s.kids[_], color=s.COL4) tw(s.kids[_], color=s.COL4)
s.info(p) s.info(p)
def info(s, p): def info(s, p):
[_.delete() for _ in s.ikids] [_.delete() for _ in s.ikids]
s.ikids.clear() s.ikids.clear()
@ -270,10 +274,12 @@ class Finder:
textcolor=s.COL4, textcolor=s.COL4,
oac=Call(CON, i['a'], i['p'], False) oac=Call(CON, i['a'], i['p'], False)
)) ))
def copy(s, t): def copy(s, t):
s.ding(1, 1) s.ding(1, 1)
TIP('Copied to clipboard!') TIP('Copied to clipboard!')
COPY(t) COPY(t)
def plys(s): def plys(s):
z = [] z = []
me = app.plus.get_v1_account_name() me = app.plus.get_v1_account_name()
@ -285,24 +291,30 @@ class Finder:
ds = p['display_string'] ds = p['display_string']
0 if ds in me else z.append((ds, a)) 0 if ds in me else z.append((ds, a))
return sorted(z, key=lambda _: _[0].startswith('\ue030Server')) return sorted(z, key=lambda _: _[0].startswith('\ue030Server'))
def snd(s, t): def snd(s, t):
l = gs(t) l = gs(t)
l.play() l.play()
teck(uf(0.14, 0.18), l.stop) teck(uf(0.14, 0.18), l.stop)
return l return l
def bye(s): def bye(s):
s.s1.stop() s.s1.stop()
ocw(s.p, transition='out_scale') ocw(s.p, transition='out_scale')
l = s.snd('laser') l = s.snd('laser')
f = lambda: teck(0.01,f) if s.p else l.stop() def f(): return teck(0.01, f) if s.p else l.stop()
f() f()
def ding(s, i, j): def ding(s, i, j):
a = ['Small', ''] a = ['Small', '']
x, y = a[i], a[j] x, y = a[i], a[j]
s.snd('ding'+x) s.snd('ding'+x)
teck(0.1, gs('ding'+y).play) teck(0.1, gs('ding'+y).play)
def fresh(s): def fresh(s):
if s.busy: BTW("Still busy!"); return if s.busy:
BTW("Still busy!")
return
TIP('Fetching servers...') TIP('Fetching servers...')
s.ding(1, 0) s.ding(1, 0)
s.busy = True s.busy = True
@ -316,6 +328,7 @@ class Finder:
callback=s.kang, callback=s.kang,
) )
p.run_v1_account_transactions() p.run_v1_account_transactions()
def kang(s, r): def kang(s, r):
c = s.__class__ c = s.__class__
c.MEM = r['l'] c.MEM = r['l']
@ -325,6 +338,7 @@ class Finder:
s.thr.append(t) s.thr.append(t)
t.start() t.start()
teck(s.MAX*4, s.join) teck(s.MAX*4, s.join)
def join(s): def join(s):
c = s.__class__ c = s.__class__
[t.join() for t in s.thr] [t.join() for t in s.thr]
@ -335,8 +349,11 @@ class Finder:
TIP(f'Loaded {len(c.MEM)} servers!') TIP(f'Loaded {len(c.MEM)} servers!')
s.ding(0, 1) s.ding(0, 1)
s.busy = False s.busy = False
def find(s): def find(s):
if s.busy: BTW("Still busy!"); return if s.busy:
BTW("Still busy!")
return
c = s.__class__ c = s.__class__
if not c.MEM: if not c.MEM:
BTW('Fetch some servers first!') BTW('Fetch some servers first!')
@ -356,16 +373,23 @@ class Finder:
s.ci = s.lr = 0 s.ci = s.lr = 0
c.BST = c.MEM[:top] c.BST = c.MEM[:top]
s.cycle() s.cycle()
def cycle(s): def cycle(s):
_ = s.__class__.BST[s.ci] _ = s.__class__.BST[s.ci]
s.ca = _['a'] s.ca = _['a']
CON(s.ca, _['p'], False) CON(s.ca, _['p'], False)
s.wait() s.wait()
def wait(s, i=5): def wait(s, i=5):
r = GGR() r = GGR()
if (r != s.lr) and r: s.__class__.BST[s.ci]['roster'] = s.lr = r; return s.next() if (r != s.lr) and r:
if not i: s.__class__.BST[s.ci]['roster'] = []; return s.next() s.__class__.BST[s.ci]['roster'] = s.lr = r
return s.next()
if not i:
s.__class__.BST[s.ci]['roster'] = []
return s.next()
teck(0.1, Call(s.wait, i-1)) teck(0.1, Call(s.wait, i-1))
def next(s): def next(s):
s.ci += 1 s.ci += 1
if s.ci >= len(s.__class__.BST): if s.ci >= len(s.__class__.BST):
@ -373,18 +397,22 @@ class Finder:
teck(0.5, s.yay) teck(0.5, s.yay)
return return
s.cycle() s.cycle()
def yay(s): def yay(s):
TIP('Cycle finished!') TIP('Cycle finished!')
s.ding(0, 1) s.ding(0, 1)
s.busy = False s.busy = False
zw('squad_button').activate() zw('squad_button').activate()
teck(0.3, byBordd.up) teck(0.3, byBordd.up)
def ping(s, _): def ping(s, _):
sock = ping = None sock = ping = None
a, p = _['a'], _['p'] a, p = _['a'], _['p']
sock = socket(IPT(a), SOCK_DGRAM) sock = socket(IPT(a), SOCK_DGRAM)
try: sock.connect((a,p)) try:
except: ping = None sock.connect((a, p))
except:
ping = None
else: else:
st = time() st = time()
sock.settimeout(s.MAX) sock.settimeout(s.MAX)
@ -393,7 +421,8 @@ class Finder:
try: try:
sock.send(b'\x0b') sock.send(b'\x0b')
r = sock.recv(10) r = sock.recv(10)
except: r = None except:
r = None
if r == b'\x0c': if r == b'\x0c':
yes = True yes = True
break break
@ -403,6 +432,7 @@ class Finder:
_['ping'] = ping _['ping'] = ping
sock.close() sock.close()
# Patches # Patches
bw = lambda *, oac=None, **k: obw( bw = lambda *, oac=None, **k: obw(
texture=gt('white'), texture=gt('white'),
@ -432,22 +462,29 @@ cw = lambda *,size=None,oac=None,**k: (p:=ocw(
)) ))
# Global # Global
BTW = lambda t: (push(t,color=(1,1,0)),gs('block').play())
TIP = lambda t: push(t,Finder.COL3)
def BTW(t): return (push(t, color=(1, 1, 0)), gs('block').play())
def TIP(t): return push(t, Finder.COL3)
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
BTN = None BTN = None
@classmethod @classmethod
def up(c): def up(c):
c.BTN.activate() if c.BTN.exists() else None c.BTN.activate() if c.BTN.exists() else None
def __init__(s): def __init__(s):
from bauiv1lib import party from bauiv1lib import party
p = party.PartyWindow p = party.PartyWindow
a = '__init__' a = '__init__'
o = getattr(p, a) o = getattr(p, a)
setattr(p, a, lambda z, *a, **k: (o(z, *a, **k), s.make(z))[0]) setattr(p, a, lambda z, *a, **k: (o(z, *a, **k), s.make(z))[0])
def make(s, z): def make(s, z):
sz = (80, 30) sz = (80, 30)
p = z._root_widget p = z._root_widget

View file

@ -16,12 +16,15 @@ from bascenev1 import (
newnode newnode
) )
class Path: class Path:
def __init__(s, node, holder=None): def __init__(s, node, holder=None):
if node.body == 'crate': return if node.body == 'crate':
return
s.node, s.kids = node, [] s.node, s.kids = node, []
s.me = holder s.me = holder
s.spy() s.spy()
def spy(s): def spy(s):
n = s.node n = s.node
if not n.exists(): if not n.exists():
@ -29,7 +32,8 @@ class Path:
s.kids.clear() s.kids.clear()
return return
[_.delete() for _ in s.kids]; s.kids.clear() [_.delete() for _ in s.kids]
s.kids.clear()
ip = n.position ip = n.position
iv = n.velocity iv = n.velocity
@ -81,6 +85,8 @@ class Path:
# brobord collide grass # brobord collide grass
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
def __init__(s): def __init__(s):
_ = __import__('bascenev1lib').actor.bomb.Bomb _ = __import__('bascenev1lib').actor.bomb.Bomb

View file

@ -69,8 +69,10 @@ from ast import (
Name Name
) )
class PlugTools(TAB): class PlugTools(TAB):
KEY = 'PT_BY' KEY = 'PT_BY'
def __init__(s): def __init__(s):
s.bys = META() s.bys = META()
s.bad = [] s.bad = []
@ -79,6 +81,7 @@ class PlugTools(TAB):
s.eye = look() s.eye = look()
s.e = False s.e = False
s.spy() s.spy()
def spy(s): def spy(s):
b = 0 b = 0
for _ in s.bys.copy(): for _ in s.bys.copy():
@ -87,10 +90,12 @@ class PlugTools(TAB):
push(f'Plugin {_} suddenly disappeared!\nAnd so, was removed from list.', color=(1, 1, 0)) push(f'Plugin {_} suddenly disappeared!\nAnd so, was removed from list.', color=(1, 1, 0))
gs('block').play() gs('block').play()
s.eye = look() s.eye = look()
if s.hl() == _: s.hl(None) if s.hl() == _:
s.hl(None)
b = 1 b = 1
sp = app.plugins.plugin_specs.get(_, 0) sp = app.plugins.plugin_specs.get(_, 0)
if not sp: continue if not sp:
continue
p = app.plugins p = app.plugins
if getattr(sp, 'enabled', False): if getattr(sp, 'enabled', False):
o = s.sp.plugin o = s.sp.plugin
@ -100,8 +105,10 @@ class PlugTools(TAB):
p.plugin_specs.pop(o) p.plugin_specs.pop(o)
del s.sp.plugin, o del s.sp.plugin, o
collect() collect()
try: reload(modules[NAM(_,0)]) try:
except: pass reload(modules[NAM(_, 0)])
except:
pass
continue continue
if MT(_) != s.mem[_] and _ not in s.bad: if MT(_) != s.mem[_] and _ not in s.bad:
s.bad.append(_) s.bad.append(_)
@ -120,7 +127,8 @@ class PlugTools(TAB):
nu = [] nu = []
if df: if df:
for dd in df: for dd in df:
try: _ = kang(dd) try:
_ = kang(dd)
except: except:
eye.remove(dd) eye.remove(dd)
continue continue
@ -132,12 +140,16 @@ class PlugTools(TAB):
b = 1 b = 1
if nu: if nu:
l = len(nu) l = len(nu)
push(f"Found {l} new plugin{['s',''][l==1]}:\n{', '.join(nu)}\nSee what to do with {['it','them'][l!=1]}",color=(1,1,0)) push(f"Found {l} new plugin{['s', ''][l == 1]}:\n{', '.join(nu)}\nSee what to do with {['it', 'them'][l != 1]}", color=(
1, 1, 0))
gs('dingSmallHigh').play() gs('dingSmallHigh').play()
if b: if b:
try: s.request_refresh() try:
except RuntimeError: pass s.request_refresh()
except RuntimeError:
pass
teck(0.1, s.spy) teck(0.1, s.spy)
@override @override
def refresh(s): def refresh(s):
# Preload # Preload
@ -231,7 +243,8 @@ class PlugTools(TAB):
for i in range(5): for i in range(5):
for j in range(2): for j in range(2):
k = j*5+i+s.i*10 k = j*5+i+s.i*10
if k >= len(s.bys): break if k >= len(s.bys):
break
t = s.bys[k] t = s.bys[k]
tw = GSW(t) tw = GSW(t)
s.button( s.button(
@ -253,7 +266,8 @@ class PlugTools(TAB):
call=s.prev, call=s.prev,
disabled=s.i == 0 disabled=s.i == 0
) )
if s.height <= 100: return if s.height <= 100:
return
# Expanded logs # Expanded logs
t = s.logs t = s.logs
h = 25 h = 25
@ -273,7 +287,9 @@ class PlugTools(TAB):
xf = 0 xf = 0
for i in range(z): for i in range(z):
p[0] += [l*sk, 0][i == 0] p[0] += [l*sk, 0][i == 0]
if xf: xf = 0; continue if xf:
xf = 0
continue
j = t[i] j = t[i]
k = t[i+1] if (i+1) < z else j k = t[i+1] if (i+1) < z else j
if j == '\\' and k == 'n': if j == '\\' and k == 'n':
@ -288,13 +304,16 @@ class PlugTools(TAB):
v_align='top', v_align='top',
scale=sk scale=sk
) )
def hl(s, i=None): def hl(s, i=None):
i and deek() i and deek()
c = app.config c = app.config
if i is None: return c.get(s.KEY,None) if i is None:
return c.get(s.KEY, None)
c[s.KEY] = i c[s.KEY] = i
c.commit() c.commit()
s.request_refresh() s.request_refresh()
def _load(s): def _load(s):
h = ['load', 'reload'][s.e] h = ['load', 'reload'][s.e]
ex, er = s.load() ex, er = s.load()
@ -309,10 +328,12 @@ class PlugTools(TAB):
s.request_refresh() s.request_refresh()
return return
s.logs = 'No errors' s.logs = 'No errors'
if ex is False: return if ex is False:
return
push(h.title()+'ed '+s.by, color=(0, 1, 0)) push(h.title()+'ed '+s.by, color=(0, 1, 0))
gs('gunCocking').play() gs('gunCocking').play()
s.request_refresh() s.request_refresh()
def load(s): def load(s):
_ = s.by _ = s.by
if _ in s.bad: if _ in s.bad:
@ -326,25 +347,35 @@ class PlugTools(TAB):
p.active_plugins.remove(o) p.active_plugins.remove(o)
del s.sp.plugin del s.sp.plugin
collect() collect()
try: m = reload(modules[NAM(_,0)]) try:
m = reload(modules[NAM(_, 0)])
except KeyError: except KeyError:
gs('block').play() gs('block').play()
push(f"{s.by} is malformed!\nAre you sure there's no errors?", color=(1, 1, 0)) push(f"{s.by} is malformed!\nAre you sure there's no errors?", color=(1, 1, 0))
return (False, 0) return (False, 0)
except Exception as ex: return (ex,ERR()) except Exception as ex:
else: m = __import__(NAM(_,0)) return (ex, ERR())
try: cls = getattr(m,_.split('.',1)[1]) else:
except Exception as ex: return (ex,ERR()) m = __import__(NAM(_, 0))
try: ins = cls() try:
except Exception as ex: return (ex,ERR()) cls = getattr(m, _.split('.', 1)[1])
try: ins.on_app_running() except Exception as ex:
except Exception as ex: return (ex,ERR()) return (ex, ERR())
try:
ins = cls()
except Exception as ex:
return (ex, ERR())
try:
ins.on_app_running()
except Exception as ex:
return (ex, ERR())
s.sp = PluginSpec(class_path=_, loadable=True) s.sp = PluginSpec(class_path=_, loadable=True)
s.sp.enabled = True s.sp.enabled = True
s.sp.plugin = ins s.sp.plugin = ins
p.plugin_specs[_] = s.sp p.plugin_specs[_] = s.sp
p.active_plugins.append(ins) p.active_plugins.append(ins)
return (0, 0) return (0, 0)
def metadata(s): def metadata(s):
f = PAT(s.sp.class_path) f = PAT(s.sp.class_path)
info = [] info = []
@ -409,21 +440,30 @@ class PlugTools(TAB):
info.append("File Exists: No") info.append("File Exists: No")
push('\n'.join(info)) push('\n'.join(info))
gs('powerup01').play() gs('powerup01').play()
def next(s): def next(s):
deek() deek()
s.i += 1 s.i += 1
s.request_refresh() s.request_refresh()
def prev(s): def prev(s):
deek() deek()
s.i -= 1 s.i -= 1
s.request_refresh() s.request_refresh()
MT = lambda _: stat(PAT(_))
GSW = lambda s: sw(s,suppress_warning=True) def MT(_): return stat(PAT(_))
NAM = lambda _,py=1: _.split('.',1)[0]+['','.py'][py] def GSW(s): return sw(s, suppress_warning=True)
PAT = lambda _: join(ROOT,NAM(_))
def NAM(_, py=1): return _.split('.', 1)[0]+['', '.py'][py]
def PAT(_): return join(ROOT, NAM(_))
ROOT = env()['python_directory_user'] ROOT = env()['python_directory_user']
META = lambda: app.meta.scanresults.exports_by_name('babase.Plugin') def META(): return app.meta.scanresults.exports_by_name('babase.Plugin')
def look(): def look():
python_files = [] python_files = []
try: try:
@ -437,6 +477,8 @@ def look():
except PermissionError: except PermissionError:
pass pass
return python_files return python_files
def kang(file_path): def kang(file_path):
with open(file_path, 'r', encoding='utf-8') as f: with open(file_path, 'r', encoding='utf-8') as f:
source_code = f.read() source_code = f.read()
@ -460,11 +502,15 @@ def kang(file_path):
(isinstance(base, Attribute) and base.attr == 'Plugin' and isinstance(base.value, Name) and base.value.id == 'babase'): (isinstance(base, Attribute) and base.attr == 'Plugin' and isinstance(base.value, Name) and base.value.id == 'babase'):
return f"{filename_without_ext}.{node.name}" return f"{filename_without_ext}.{node.name}"
return None return None
deek = lambda: gs('deek').play()
def deek(): return gs('deek').play()
# brobord collide grass # brobord collide grass
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
def __init__(s): def __init__(s):
C = PlugTools C = PlugTools

View file

@ -41,17 +41,23 @@ from bauiv1 import (
Call Call
) )
class Power(TAB): class Power(TAB):
def __init__(s): def __init__(s):
s.j = [None,None,None]; s.ji = 1 s.j = [None, None, None]
s.ji = 1
[setattr(s, _, None) for _ in 'cpnh'] [setattr(s, _, None) for _ in 'cpnh']
[setattr(s, _, {}) for _ in ['rr', 'hi']] [setattr(s, _, {}) for _ in ['rr', 'hi']]
[setattr(s, _, []) for _ in ['cm', 'og', 'r', 'ls']] [setattr(s, _, []) for _ in ['cm', 'og', 'r', 'ls']]
[setattr(s, _, 0) for _ in ['ii', 'eii', 'ci', 're', 'ri', 'eri', 'li', 'lii']] [setattr(s, _, 0) for _ in ['ii', 'eii', 'ci', 're', 'ri', 'eri', 'li', 'lii']]
teck(3, s.spy) teck(3, s.spy)
def rf(s): def rf(s):
try: s.request_refresh() try:
except RuntimeError: pass s.request_refresh()
except RuntimeError:
pass
def spy(s): def spy(s):
_ = 0 _ = 0
r = ROST() r = ROST()
@ -79,23 +85,30 @@ class Power(TAB):
s.og = ng s.og = ng
ls = ng[-1] ls = ng[-1]
ch = s.cm[0][1] if len(s.cm) else 0 ch = s.cm[0][1] if len(s.cm) else 0
if ch and ls == s.cm[0][0]: s.cm[0] = (ls,ch+1) if ch and ls == s.cm[0][0]:
else: s.cm.insert(0,(ls,1)) s.cm[0] = (ls, ch+1)
if s.ci: s.ci += 1 else:
s.cm.insert(0, (ls, 1))
if s.ci:
s.ci += 1
_ = 1 _ = 1
_ and s.rf() _ and s.rf()
teck(0.1, s.spy) teck(0.1, s.spy)
@override @override
def refresh(s): def refresh(s):
sf = s.width / 1605.3 sf = s.width / 1605.3
zf = s.height / 648 zf = s.height / 648
x = -s.width/2 x = -s.width/2
T, B = s.text, s.button T, B = s.text, s.button
if len(s.r) and s.ri >= len(s.r): s.ri = len(s.r) - 1 if len(s.r) and s.ri >= len(s.r):
if len(s.r) and s.eri >= len(s.r): s.eri = len(s.r) - 1 s.ri = len(s.r) - 1
if len(s.r) and s.eri >= len(s.r):
s.eri = len(s.r) - 1
if s.j[0] == 'JRejoin' and s.ji <= s.re: if s.j[0] == 'JRejoin' and s.ji <= s.re:
s.ji = s.re + 1 s.ji = s.re + 1
push('Job time cannot be less than rejoin time\nwhen job is JRejoin. Updated job time to '+str(s.ji),color=(1,1,0)) push('Job time cannot be less than rejoin time\nwhen job is JRejoin. Updated job time to ' +
str(s.ji), color=(1, 1, 0))
if s.height > 100: if s.height > 100:
B( B(
cs(sc.UP_ARROW), cs(sc.UP_ARROW),
@ -121,8 +134,10 @@ class Power(TAB):
scale=1 if w < (290*sf) else (290*sf)/w scale=1 if w < (290*sf) else (290*sf)/w
) )
for i, z in enumerate(s.rr.items()): for i, z in enumerate(s.rr.items()):
if i < s.eri: continue if i < s.eri:
if i>=(s.eri+7): break continue
if i >= (s.eri+7):
break
n, g = z n, g = z
c, p = g c, p = g
w = GSW(n) w = GSW(n)
@ -159,7 +174,8 @@ class Power(TAB):
'Players', 'Players',
size=(280 * sf, 40*zf), size=(280 * sf, 40*zf),
pos=(x + 10 * sf, 140*zf), pos=(x + 10 * sf, 140*zf),
call=Call(push,'\n'.join([' '.join([f'{i}={j}' for i,j in _.items()]) for _ in s.p]) if s.p else ''), call=Call(push, '\n'.join(
[' '.join([f'{i}={j}' for i, j in _.items()]) for _ in s.p]) if s.p else ''),
disabled=bb or (not s.p) disabled=bb or (not s.p)
) )
B( B(
@ -199,7 +215,8 @@ class Power(TAB):
pos=(x + 311 * sf, 606*zf), pos=(x + 311 * sf, 606*zf),
disabled=not s.h, disabled=not s.h,
label_scale=1 if w < 390 * sf else (390 * sf)/w, label_scale=1 if w < 390 * sf else (390 * sf)/w,
call=Call(push,f"{t}\nHosted on build {getattr(s.h,'build_number','0')}" if t.strip() else 'Server is still loading...\nIf it remains stuck on this\nthen either party is full, or a network issue.'), call=Call(push, f"{t}\nHosted on build {getattr(s.h, 'build_number', '0')}" if t.strip(
) else 'Server is still loading...\nIf it remains stuck on this\nthen either party is full, or a network issue.'),
) )
w = GSW(a) w = GSW(a)
B( B(
@ -250,7 +267,8 @@ class Power(TAB):
str(s.re or 0.1), str(s.re or 0.1),
size=(131 * sf, 35*zf), size=(131 * sf, 35*zf),
pos=(x + 444 * sf, 454*zf), pos=(x + 444 * sf, 454*zf),
call=Call(push,f"Rejoins after {s.re or 0.1} second{['','s'][s.re!=1]}\nKeep this 0.1 unless server kicks fast rejoins\nLife in server = job time - rejoin time") call=Call(
push, f"Rejoins after {s.re or 0.1} second{['', 's'][s.re != 1]}\nKeep this 0.1 unless server kicks fast rejoins\nLife in server = job time - rejoin time")
) )
B( B(
'-', '-',
@ -272,8 +290,10 @@ class Power(TAB):
style='bright' style='bright'
) )
for i, e in enumerate(s.hi.items()): for i, e in enumerate(s.hi.items()):
if i < s.eii: continue if i < s.eii:
if i >= (s.eii+9): break continue
if i >= (s.eii+9):
break
g, v = e g, v = e
_, a = g _, a = g
n, p = v n, p = v
@ -374,8 +394,10 @@ class Power(TAB):
pos=(x+1320 * sf, 330 * zf) pos=(x+1320 * sf, 330 * zf)
) )
for i, g in enumerate(s.cm): for i, g in enumerate(s.cm):
if i < s.ci: continue if i < s.ci:
if i >= s.ci+15: break continue
if i >= s.ci+15:
break
i = i - s.ci i = i - s.ci
m, _ = g m, _ = g
sn, ms = m.split(': ', 1) sn, ms = m.split(': ', 1)
@ -446,8 +468,10 @@ class Power(TAB):
pos=(x+875*sf, 232*zf) pos=(x+875*sf, 232*zf)
) )
for _, g in enumerate(s.ls): for _, g in enumerate(s.ls):
if _ < s.li: continue if _ < s.li:
if _ >= s.li+16: break continue
if _ >= s.li+16:
break
_ = _ - s.li _ = _ - s.li
l, t = g l, t = g
B( B(
@ -490,8 +514,10 @@ class Power(TAB):
scale=1 if w < (200*sf) else (200*sf)/w scale=1 if w < (200*sf) else (200*sf)/w
) )
for i, z in enumerate(s.rr.items()): for i, z in enumerate(s.rr.items()):
if i < s.ri: continue if i < s.ri:
if i>=(s.ri+3): break continue
if i >= (s.ri+3):
break
n, g = z n, g = z
c, p = g c, p = g
w = GSW(n) w = GSW(n)
@ -522,7 +548,8 @@ class Power(TAB):
'Players', 'Players',
size=(120 * sf, 27), size=(120 * sf, 27),
pos=(x + 287 * sf, s.height-62), pos=(x + 287 * sf, s.height-62),
call=Call(push,'\n'.join([' '.join([f'{i}={j}' for i,j in _.items()]) for _ in s.p]) if s.p else ''), call=Call(push, '\n'.join(
[' '.join([f'{i}={j}' for i, j in _.items()]) for _ in s.p]) if s.p else ''),
disabled=bb or (not s.p) disabled=bb or (not s.p)
) )
B( B(
@ -611,7 +638,8 @@ class Power(TAB):
pos=(x + 732 * sf, s.height-34), pos=(x + 732 * sf, s.height-34),
disabled=not s.h, disabled=not s.h,
label_scale=1 if w < 290 * sf else (290 * sf)/w, label_scale=1 if w < 290 * sf else (290 * sf)/w,
call=Call(push,f"{t}\nHosted on build {getattr(s.h,'build_number','0')}" if t.strip() else 'Server is still loading...\nIf it remains stuck on this\nthen either party is full, or a network issue.'), call=Call(push, f"{t}\nHosted on build {getattr(s.h, 'build_number', '0')}" if t.strip(
) else 'Server is still loading...\nIf it remains stuck on this\nthen either party is full, or a network issue.'),
) )
w = GSW(a) w = GSW(a)
B( B(
@ -662,7 +690,8 @@ class Power(TAB):
str(s.re or 0.1), str(s.re or 0.1),
size=(50 * sf, 27), size=(50 * sf, 27),
pos=(x + 1035 * sf, s.height-62), pos=(x + 1035 * sf, s.height-62),
call=Call(push,f"Rejoins after {s.re or 0.1} second{['','s'][s.re!=1]}\nKeep this 0.1 unless server kicks fast rejoins\nLife in server = job time - rejoin time") call=Call(
push, f"Rejoins after {s.re or 0.1} second{['', 's'][s.re != 1]}\nKeep this 0.1 unless server kicks fast rejoins\nLife in server = job time - rejoin time")
) )
B( B(
'-', '-',
@ -678,8 +707,10 @@ class Power(TAB):
style='bright' style='bright'
) )
for i, e in enumerate(s.hi.items()): for i, e in enumerate(s.hi.items()):
if i < s.ii: continue if i < s.ii:
if i >= (s.ii+3): break continue
if i >= (s.ii+3):
break
g, v = e g, v = e
_, a = g _, a = g
n, p = v n, p = v
@ -734,16 +765,21 @@ class Power(TAB):
pos=(x + 1469 * sf, s.height-90), pos=(x + 1469 * sf, s.height-90),
size=(130 * sf, 27) size=(130 * sf, 27)
) )
def log(s, t): def log(s, t):
s.ls.append((t, NOW())) s.ls.append((t, NOW()))
if s.lii < 99: if s.lii < 99:
s.lii += 1 s.lii += 1
if s.li == s.lii-17: s.li += 1 if s.li == s.lii-17:
else: s.ls.pop(0) s.li += 1
else:
s.ls.pop(0)
s.rf() s.rf()
def mv(s, a, i): def mv(s, a, i):
setattr(s, a, getattr(s, a)+i) setattr(s, a, getattr(s, a)+i)
s.rf() s.rf()
def job(s, f, j): def job(s, f, j):
s.j = j s.j = j
s.lf = f s.lf = f
@ -751,38 +787,62 @@ class Power(TAB):
if f is not None: if f is not None:
s._job(f) s._job(f)
push('Job started', color=(1, 1, 0)) push('Job started', color=(1, 1, 0))
else: push('Job stopped',color=(1,1,0)) else:
push('Job stopped', color=(1, 1, 0))
s.rf() s.rf()
def _job(s, f): def _job(s, f):
if f != s.lf: return if f != s.lf:
return
s.log(f'[{s.lii:02}] [{s.j[0]}] {s.hd}') s.log(f'[{s.lii:02}] [{s.j[0]}] {s.hd}')
f(); teck(s.ji or 0.1,Call(s._job,f)) f()
teck(s.ji or 0.1, Call(s._job, f))
def prv(s, c, p, n): def prv(s, c, p, n):
s.c, s.p, s.n = c, p, n s.c, s.p, s.n = c, p, n
s.rf() s.rf()
def chk(s, pn): def chk(s, pn):
y = 0 y = 0
for n, g in s.rr.items(): for n, g in s.rr.items():
c, p = g c, p = g
if n == pn: y = 1 if n == pn:
y = 1
else: else:
for _ in p: for _ in p:
if pn in [_['name'],_['name_full']]: y = 1 if pn in [_['name'], _['name_full']]:
if y: s.prv(c,p,n); break y = 1
if y:
s.prv(c, p, n)
break
HAS = app.ui_v1.has_main_window HAS = app.ui_v1.has_main_window
SAVE = app.classic.save_ui_state SAVE = app.classic.save_ui_state
KICK = lambda f: DISC(f()) def KICK(f): return DISC(f())
FORCE = lambda: teck(0.7 if HAS() else 0.1,lambda: 0 if HAS() else app.classic.return_to_main_menu_session_gracefully())
def FORCE(): return teck(0.7 if HAS() else 0.1, lambda: 0 if HAS()
else app.classic.return_to_main_menu_session_gracefully())
JOIN = lambda *a: (SAVE() or 1) and CON(*a) JOIN = lambda *a: (SAVE() or 1) and CON(*a)
GSW = lambda s: sw(s,suppress_warning=True) def GSW(s): return sw(s, suppress_warning=True)
REJOIN = lambda a,p,f: ((LEAVE() if getattr(HOST(),'name','') else 0) or 1) and teck(f() or 0.1,Call(JOIN,a,p,False))
COPY = lambda s: ((CST(s) or 1) if CIS() else push('Clipboard not supported!')) and push('Copied!',color=(0,1,0))
NOW = lambda: DT.now().strftime("%H:%M:%S") def REJOIN(a, p, f): return ((LEAVE() if getattr(HOST(), 'name', '') else 0)
or 1) and teck(f() or 0.1, Call(JOIN, a, p, False))
def COPY(s): return ((CST(s) or 1) if CIS() else push(
'Clipboard not supported!')) and push('Copied!', color=(0, 1, 0))
def NOW(): return DT.now().strftime("%H:%M:%S")
# brobord collide grass # brobord collide grass
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
def __init__(s): def __init__(s):
C = Power C = Power

View file

@ -66,6 +66,7 @@ from threading import Thread
from os import listdir as ls from os import listdir as ls
from struct import unpack from struct import unpack
class Replay: class Replay:
VER = '2.5' VER = '2.5'
COL1 = (0.18, 0.18, 0.18) COL1 = (0.18, 0.18, 0.18)
@ -73,10 +74,13 @@ class Replay:
COL3 = (0, 1, 0) COL3 = (0, 1, 0)
COL4 = (0, 1, 1) COL4 = (0, 1, 1)
BUSY = False BUSY = False
@classmethod @classmethod
def BUS(c, b=None): def BUS(c, b=None):
if b is None: return c.BUSY if b is None:
return c.BUSY
c.BUSY = b c.BUSY = b
def __init__(s, source=None): def __init__(s, source=None):
s.sl = s.rn = s.buf = None s.sl = s.rn = s.buf = None
s.ohno = False s.ohno = False
@ -85,7 +89,8 @@ class Replay:
src=source.get_screen_space_center(), src=source.get_screen_space_center(),
p=GOS(), p=GOS(),
size=(400, 500), size=(400, 500),
oac=lambda:(ocw(s.p,transition='out_scale' if source and source.exists() else 'out_left'),s.snd('laser'),s.trs.stop()) oac=lambda: (ocw(s.p, transition='out_scale' if source and source.exists()
else 'out_left'), s.snd('laser'), s.trs.stop())
) )
s.trs = s.snd('powerup01') s.trs = s.snd('powerup01')
s.tw( s.tw(
@ -133,25 +138,36 @@ class Replay:
oac=Call(s.con, [s.show, s.copy, s.play][_]), oac=Call(s.con, [s.show, s.copy, s.play][_]),
icon=gt(['folder', 'file', 'nextLevelIcon'][_]) icon=gt(['folder', 'file', 'nextLevelIcon'][_])
) )
if _ == 2: s.psrc = b if _ == 2:
s.psrc = b
def snd(s, t): def snd(s, t):
h = gs(t) h = gs(t)
h.play() h.play()
teck(uf(0.14, 0.17), h.stop) teck(uf(0.14, 0.17), h.stop)
return h return h
def get(s): def get(s):
return join(s.rd, s.rn) return join(s.rd, s.rn)
def copy(s): def copy(s):
s.snd('dingSmallHigh') s.snd('dingSmallHigh')
COPY(s.get()) COPY(s.get())
push('Copied replay path to clipboard!', color=s.COL3) push('Copied replay path to clipboard!', color=s.COL3)
def show(s): def show(s):
gs('ding').play() gs('ding').play()
push(s.get(), color=s.COL3) push(s.get(), color=s.COL3)
def con(s, f): def con(s, f):
if s.sl is None: BTW('Select a replay!'); return if s.sl is None:
if ON(): BTW('A replay is already running!'); return BTW('Select a replay!')
return
if ON():
BTW('A replay is already running!')
return
return f() return f()
def hl(s, i, n): def hl(s, i, n):
if s.sl == i: if s.sl == i:
s.psrc = s.kids[i] s.psrc = s.kids[i]
@ -161,11 +177,14 @@ class Replay:
s.rn = n s.rn = n
[otw(_, color=s.COL2) for _ in s.kids] [otw(_, color=s.COL2) for _ in s.kids]
otw(s.kids[i], color=s.COL3) otw(s.kids[i], color=s.COL3)
def play(s): def play(s):
if s.BUS(): return if s.BUS():
return
s.BUS(True) s.BUS(True)
gs('deek').play() gs('deek').play()
s.load() s.load()
def load(s): def load(s):
src = s.psrc.get_screen_space_center() src = s.psrc.get_screen_space_center()
if s.psrc.get_widget_type() == 'text': if s.psrc.get_widget_type() == 'text':
@ -209,20 +228,27 @@ class Replay:
teck(0.5, Thread(target=s.calc).start) teck(0.5, Thread(target=s.calc).start)
teck(0.5, s.fpar) teck(0.5, s.fpar)
s.spy(s.calc2) s.spy(s.calc2)
def fpar(s): def fpar(s):
a, b = s.par a, b = s.par
teck(0.1, s.fpar) if (a != b) and (not s.ohno) else 0 teck(0.1, s.fpar) if (a != b) and (not s.ohno) else 0
if not a: return if not a:
return
p = a/b*100 p = a/b*100
t = '\u2588'*int(p)+'\u2591'*int(100-p) t = '\u2588'*int(p)+'\u2591'*int(100-p)
if not s.ohno: if not s.ohno:
try: try:
otw(s.tpar, text=t) otw(s.tpar, text=t)
otw(s.tpar2, text=f'{a} of {b} bytes read') otw(s.tpar2, text=f'{a} of {b} bytes read')
except: return except:
return
def calc(s): def calc(s):
try: s.buf = GMS(s._h,s.get(),s.par) try:
except: s.buf = 0 s.buf = GMS(s._h, s.get(), s.par)
except:
s.buf = 0
def calc2(s, t): def calc2(s, t):
otw(s.st, text='Starting...' if t else 'Wait what?') otw(s.st, text='Starting...' if t else 'Wait what?')
otw(s.tpar2, text=f'result was {t} milleseconds') if t else t otw(s.tpar2, text=f'result was {t} milleseconds') if t else t
@ -231,6 +257,7 @@ class Replay:
otw(s.tpar, text='pybrp returned zero duration, error?\nclosing this window in 5 seconds') otw(s.tpar, text='pybrp returned zero duration, error?\nclosing this window in 5 seconds')
otw(s.tpar2, text='') otw(s.tpar2, text='')
teck(1 if t else 5, Call(s._play, t)) teck(1 if t else 5, Call(s._play, t))
def spy(s, f, i=60): def spy(s, f, i=60):
if not i: if not i:
s.buf = None s.buf = None
@ -242,6 +269,7 @@ class Replay:
f(b) f(b)
return return
teck(0.5, Call(s.spy, f, i-1)) teck(0.5, Call(s.spy, f, i-1))
def _play(s, t): def _play(s, t):
if t == 0: if t == 0:
BTW("Couldn't load replay!") BTW("Couldn't load replay!")
@ -279,6 +307,7 @@ class Replay:
**k **k
) )
class Player: class Player:
TICK = 0.01 TICK = 0.01
COL0 = (0.5, 0, 0) COL0 = (0.5, 0, 0)
@ -299,6 +328,7 @@ class Player:
COL15 = (1, 1, 1) COL15 = (1, 1, 1)
COL16 = (0.1, 0.2, 0.4) COL16 = (0.1, 0.2, 0.4)
COL17 = (1, 1.7, 2) COL17 = (1, 1.7, 2)
def __init__(s, path, duration): def __init__(s, path, duration):
s.path = path s.path = path
s.du = duration s.du = duration
@ -329,6 +359,7 @@ class Player:
s.sp = 1 s.sp = 1
s.foc() s.foc()
s.play() s.play()
def mkhd(s): def mkhd(s):
f = s.hdkids.append f = s.hdkids.append
s.tex = ['\u25bc', '\u25b2'] s.tex = ['\u25bc', '\u25b2']
@ -357,9 +388,11 @@ class Player:
texture=gt('white'), texture=gt('white'),
opacity=0.4 opacity=0.4
)) ))
def killhd(s): def killhd(s):
[_.delete() for _ in s.hdkids] [_.delete() for _ in s.hdkids]
s.hdkids.clear() s.hdkids.clear()
def mkui(s): def mkui(s):
s.up = True s.up = True
f = s.kids.append f = s.kids.append
@ -560,6 +593,7 @@ class Player:
maxwidth=ix-20 maxwidth=ix-20
) )
f(s.ok3) f(s.ok3)
def mkcamui(s): def mkcamui(s):
f = s.camkids.append f = s.camkids.append
x, y = (19, 100) x, y = (19, 100)
@ -684,6 +718,7 @@ class Player:
maxwidth=205, maxwidth=205,
max_height=40 max_height=40
)) ))
def zoom(s, i): def zoom(s, i):
n = round(s.camz+i*0.05, 2) n = round(s.camz+i*0.05, 2)
if s.camz == 1 and not s.gay: if s.camz == 1 and not s.gay:
@ -698,6 +733,7 @@ class Player:
s.camz = n s.camz = n
otw(s.ztw, text=f'x{round(0.5**(n-1), 2)}' if n != 1 else 'x1.0' if s.gay else 'auto') otw(s.ztw, text=f'x{round(0.5**(n-1), 2)}' if n != 1 else 'x1.0' if s.gay else 'auto')
s.zom() s.zom()
def look(s): def look(s):
s.killui() s.killui()
s.killhd() s.killhd()
@ -709,20 +745,26 @@ class Player:
s.mksnui() s.mksnui()
s.mksnb() s.mksnb()
s.mksni() s.mksni()
def _look(s, x, y): def _look(s, x, y):
o = s.caml or GCT() o = s.caml or GCT()
sk = 0.7*s.camz sk = 0.7*s.camz
s.caml = n = (o[0]+x*sk, o[1]+y*sk, o[2]) s.caml = n = (o[0]+x*sk, o[1]+y*sk, o[2])
0 if s.snma else otw(s.snt, text=str(RND(n))) 0 if s.snma else otw(s.snt, text=str(RND(n)))
s.camp = GCP() s.camp = GCP()
if s.camz != 1: s.gay = True if s.camz != 1:
s.gay = True
s.camz = 1 s.camz = 1
def foc(s): def foc(s):
s.tfoc = tock(0.01, s.focus, repeat=True) s.tfoc = tock(0.01, s.focus, repeat=True)
def focus(s): def focus(s):
SCT(*s.caml) if s.caml else 0 SCT(*s.caml) if s.caml else 0
def zom(s): def zom(s):
if s.camz == 1 and not s.gay: return if s.camz == 1 and not s.gay:
return
z = s.camz z = s.camz
tx, ty, tz = GCT() tx, ty, tz = GCT()
px, py, pz = s.camp px, py, pz = s.camp
@ -730,16 +772,20 @@ class Player:
npy = ty+(py-ty)*z npy = ty+(py-ty)*z
npz = tz+(pz-tz)*z npz = tz+(pz-tz)*z
SCP(npx, npy, npz) SCP(npx, npy, npz)
def fockill(s): def fockill(s):
s.tfoc = None s.tfoc = None
def snsave(s): def snsave(s):
s.snbye() s.snbye()
def snbye(s): def snbye(s):
s.killsn() s.killsn()
s.mkui() s.mkui()
s.mkhd() s.mkhd()
s.fkek(0, 0.1) s.fkek(0, 0.1)
s.pro() s.pro()
def mksns(s): def mksns(s):
x, y = res() x, y = res()
sz = 50 sz = 50
@ -759,6 +805,7 @@ class Player:
)) ))
for i in range(a) for i in range(a)
for j in range(b)] for j in range(b)]
def mksnui(s): def mksnui(s):
f = s.snuikids.append f = s.snuikids.append
f(iw( f(iw(
@ -879,10 +926,13 @@ class Player:
position=(x/2-k, y/2+[k-h, -k+h*0.3][j]), position=(x/2-k, y/2+[k-h, -k+h*0.3][j]),
size=(3, h*1.1) size=(3, h*1.1)
)) ))
def killsnui(s): def killsnui(s):
[_.delete() for _ in s.snuikids] [_.delete() for _ in s.snuikids]
def snhide(s): def snhide(s):
if getattr(s,'snbusy',0): return if getattr(s, 'snbusy', 0):
return
s.snma = not s.snma s.snma = not s.snma
s.snbusy = True s.snbusy = True
if s.snma: if s.snma:
@ -893,6 +943,7 @@ class Player:
obw(s.snbtn, texture=gt('white')) obw(s.snbtn, texture=gt('white'))
s.snanim(36, 7, 1) s.snanim(36, 7, 1)
iw(s.sni, opacity=0) iw(s.sni, opacity=0)
def mksni(s): def mksni(s):
s.sni = iw( s.sni = iw(
parent=s.p, parent=s.p,
@ -903,6 +954,7 @@ class Player:
texture=gt('white') texture=gt('white')
) )
s.snkids.append(s.sni) s.snkids.append(s.sni)
def mksnb(s): def mksnb(s):
s.snbtn = s.bw( s.snbtn = s.bw(
p=s.p, p=s.p,
@ -914,6 +966,7 @@ class Player:
oac=s.snhide oac=s.snhide
) )
s.snkids.append(s.snbtn) s.snkids.append(s.snbtn)
def snanim(s, a, b, i): def snanim(s, a, b, i):
a += (163/35)*i a += (163/35)*i
b += 0.2*i b += 0.2*i
@ -930,11 +983,14 @@ class Player:
obw(s.snbtn, label='Cinema Mode') obw(s.snbtn, label='Cinema Mode')
return return
teck(0.004, Call(s.snanim, a, b, i)) teck(0.004, Call(s.snanim, a, b, i))
def killsn(s): def killsn(s):
s.killsnui() s.killsnui()
[_.delete() for _ in s.snkids] [_.delete() for _ in s.snkids]
def all(s): def all(s):
return s.trash()+s.hdkids+s.snkids return s.trash()+s.hdkids+s.snkids
def sntar(s): def sntar(s):
s.caml = None s.caml = None
otw(s.snt, text='players') otw(s.snt, text='players')
@ -942,6 +998,7 @@ class Player:
s.camz = 1 s.camz = 1
s.gay = False s.gay = False
SCM(False) SCM(False)
def sncancel(s): def sncancel(s):
s.caml = s.camlo s.caml = s.camlo
s.camp = s.campo s.camp = s.campo
@ -950,6 +1007,7 @@ class Player:
SCM(True) SCM(True)
SCP(*s.camp) SCP(*s.camp)
s.snbye() s.snbye()
def cam(s): def cam(s):
if s.camon: if s.camon:
s.camon = False s.camon = False
@ -959,6 +1017,7 @@ class Player:
else: else:
s.camon = True s.camon = True
s.mkcamui() s.mkcamui()
def camr(s): def camr(s):
SCM(False) SCM(False)
s.caml = None s.caml = None
@ -966,27 +1025,35 @@ class Player:
s.camz = 1 s.camz = 1
otw(s.ltw, text='players') otw(s.ltw, text='players')
otw(s.ztw, text='auto') otw(s.ztw, text='auto')
def fcam(s, i=0, a=0.1): def fcam(s, i=0, a=0.1):
if i > 0.4 or i < 0: if i > 0.4 or i < 0:
if a < 0: s.cambg.delete() if a < 0:
s.cambg.delete()
return
if not s.cambg.exists():
return return
if not s.cambg.exists(): return
iw(s.cambg, opacity=i) iw(s.cambg, opacity=i)
iw(s.cambg2, opacity=i) iw(s.cambg2, opacity=i)
teck(0.02, Call(s.fcam, i+a, a)) teck(0.02, Call(s.fcam, i+a, a))
def rloop(s): def rloop(s):
s.loop() s.loop()
s.fixps() s.fixps()
s.hm('Replay', f'Version {Replay.VER} BETA', s.COL12, s.COL13) s.hm('Replay', f'Version {Replay.VER} BETA', s.COL12, s.COL13)
def killui(s): def killui(s):
s.up = s.camon = False s.up = s.camon = False
[_.delete() for _ in s.trash()] [_.delete() for _ in s.trash()]
s.kids.clear() s.kids.clear()
s.camkids.clear() s.camkids.clear()
def trash(s): def trash(s):
return s.kids+s.camkids return s.kids+s.camkids
def kek(s): def kek(s):
if getattr(s,'kekbusy',0): return if getattr(s, 'kekbusy', 0):
return
s.kekbusy = True s.kekbusy = True
if getattr(s, 'tbye', 0) and getattr(s, 'frbro', 0): if getattr(s, 'tbye', 0) and getattr(s, 'frbro', 0):
s.frbro = s.tbye = False s.frbro = s.tbye = False
@ -1003,11 +1070,15 @@ class Player:
s.mkui() s.mkui()
s.pro() s.pro()
teck(0.21, Call(setattr, s, 'kekbusy', 0)) teck(0.21, Call(setattr, s, 'kekbusy', 0))
def fkek(s, i=0, a=0.1): def fkek(s, i=0, a=0.1):
if i > 0.4 or i < 0: return if i > 0.4 or i < 0:
if not s.bg.exists(): return return
if not s.bg.exists():
return
iw(s.bg, opacity=i) iw(s.bg, opacity=i)
teck(0.02, Call(s.fkek, i+a, a)) teck(0.02, Call(s.fkek, i+a, a))
def hm(s, t1, t2, c1, c2): def hm(s, t1, t2, c1, c2):
if getattr(s, 'tbye', 0) and getattr(s, 'frbro', 0): if getattr(s, 'tbye', 0) and getattr(s, 'frbro', 0):
s.frbro = s.tbye = False s.frbro = s.tbye = False
@ -1017,53 +1088,70 @@ class Player:
otw(s.ok3, text=t2, color=c2) otw(s.ok3, text=t2, color=c2)
s.fok() s.fok()
s.okt = tock(1.5, s.unhm) s.okt = tock(1.5, s.unhm)
def unhm(s): def unhm(s):
s.fok(0.7, -0.1) s.fok(0.7, -0.1)
[otw(_, text='') for _ in [s.ok2, s.ok3] if _.exists()] [otw(_, text='') for _ in [s.ok2, s.ok3] if _.exists()]
def fok(s, i=0, a=0.1): def fok(s, i=0, a=0.1):
if i > 0.7 or i < 0: return if i > 0.7 or i < 0:
if not s.ok.exists(): return return
if not s.ok.exists():
return
iw(s.ok, opacity=i) iw(s.ok, opacity=i)
teck(0.02, Call(s.fok, i+a, a)) teck(0.02, Call(s.fok, i+a, a))
def toggle(s, dry=False, shut=False): def toggle(s, dry=False, shut=False):
if not dry: s.ps = not s.ps if not dry:
s.ps = not s.ps
t = cs(getattr(sc, ['PAUSE', 'PLAY'][s.ps]+'_BUTTON')) t = cs(getattr(sc, ['PAUSE', 'PLAY'][s.ps]+'_BUTTON'))
otw(s.tt, text=t) otw(s.tt, text=t)
if not dry: if not dry:
if not shut: s.hm(['Resume','Pause'][s.ps],basename(s.path)+f' of {getsize(s.path)} bytes',s.COL6,s.COL7) if not shut:
s.hm(['Resume', 'Pause'][s.ps], basename(s.path) +
f' of {getsize(s.path)} bytes', s.COL6, s.COL7)
if s.ps: if s.ps:
s.stop() s.stop()
PAUSE() PAUSE()
else: else:
s.play() s.play()
RESUME() RESUME()
def fixps(s): def fixps(s):
if not s.ps: return if not s.ps:
return
s.toggle(shut=True) s.toggle(shut=True)
teck(0.02, Call(s.toggle, shut=True)) teck(0.02, Call(s.toggle, shut=True))
def clock(s): def clock(s):
t = time() t = time()
r = t - s.rt r = t - s.rt
s.rt = t s.rt = t
s.rn += r * s.sp s.rn += r * s.sp
def boost(s, i): def boost(s, i):
n = GET()+i n = GET()+i
SET(n) SET(n)
s.sp = 2**n s.sp = 2**n
h = 'Snail Mode' if s.sp == 0.0625 else 'Slow Motion' if s.sp < 1 else 'Quake Pro' if s.sp == 16 else 'Fast Motion' if s.sp > 1 else 'Normal Speed' h = 'Snail Mode' if s.sp == 0.0625 else 'Slow Motion' if s.sp < 1 else 'Quake Pro' if s.sp == 16 else 'Fast Motion' if s.sp > 1 else 'Normal Speed'
s.hm(h, f'Current exponent: x{s.sp}', s.COL2, s.COL3) s.hm(h, f'Current exponent: x{s.sp}', s.COL2, s.COL3)
def play(s): def play(s):
s.rt = time() s.rt = time()
s.clock() s.clock()
s.ptplay() s.ptplay()
s.clt = tock(s.TICK, s.clock, repeat=True) s.clt = tock(s.TICK, s.clock, repeat=True)
def stop(s): def stop(s):
s.clt = None s.clt = None
s.ptkill() s.ptkill()
def ptkill(s): def ptkill(s):
s.pt = None s.pt = None
def ptplay(s): def ptplay(s):
s.pt = tock(s.TICK, s.pro, repeat=True) s.pt = tock(s.TICK, s.pro, repeat=True)
def seek(s, i): def seek(s, i):
h = ['Forward by', 'Rewind by'][i == -1] h = ['Forward by', 'Rewind by'][i == -1]
i = i * s.sp i = i * s.sp
@ -1079,6 +1167,7 @@ class Player:
s.fixps() s.fixps()
i = abs(round(i, 2)) i = abs(round(i, 2))
s.hm('Seek', h+f" {i} second{['s', ''][i == 1]}", s.COL4, s.COL5) s.hm('Seek', h+f" {i} second{['s', ''][i == 1]}", s.COL4, s.COL5)
def jump(s, p): def jump(s, p):
t = s.ds * p t = s.ds * p
s.st = s.rn-t s.st = s.rn-t
@ -1086,11 +1175,15 @@ class Player:
SEEK(t) SEEK(t)
s.rt = time() s.rt = time()
s.fixps() s.fixps()
def bye(s): def bye(s):
if getattr(s,'frbro',0): s._bye(); return if getattr(s, 'frbro', 0):
s._bye()
return
s.hm('Exit', 'Press again to confirm', s.COL0, s.COL1) s.hm('Exit', 'Press again to confirm', s.COL0, s.COL1)
s.frbro = True s.frbro = True
s.tbye = tock(1.5, Call(setattr, s, 'frbro', False)) s.tbye = tock(1.5, Call(setattr, s, 'frbro', False))
def _bye(s): def _bye(s):
fade(0, time=0.75, endcall=Call(fade, 1, time=0.75)) fade(0, time=0.75, endcall=Call(fade, 1, time=0.75))
gs('deek').play() gs('deek').play()
@ -1099,17 +1192,22 @@ class Player:
s.fockill() s.fockill()
s.tbye = None s.tbye = None
SCM(False) SCM(False)
def pro(s): def pro(s):
t = s.rn-s.st t = s.rn-s.st
if s.rn-s.st >= s.ds: s.loop() if s.rn-s.st >= s.ds:
s.loop()
x, y = s.nbp x, y = s.nbp
p = (t/s.ds)*s.px p = (t/s.ds)*s.px
try: try:
iw(s.nb, position=(x+p, y)) iw(s.nb, position=(x+p, y))
otw(s.ct, text=FOR(t)) otw(s.ct, text=FOR(t))
except ReferenceError: pass except ReferenceError:
pass
def replay(s): def replay(s):
SEEK(-10**10) SEEK(-10**10)
def loop(s): def loop(s):
s.st = s.rn = 0 s.st = s.rn = 0
s.replay() s.replay()
@ -1123,68 +1221,104 @@ class Player:
**k **k
) )
# Tools # Tools
BYE = lambda: app.classic.return_to_main_menu_session_gracefully(reset_ui=False) def BYE(): return app.classic.return_to_main_menu_session_gracefully(reset_ui=False)
BTW = lambda t: (gs('block').play() or 1) and push(t,color=(1,1,0))
GOS = lambda: gsw('overlay_stack')
FOR = lambda t: strftime('%H:%M:%S',gmtime(t)) def BTW(t): return (gs('block').play() or 1) and push(t, color=(1, 1, 0))
SCL = lambda a,b,c=None: ((s:=app.ui_v1.uiscale), a if s is UIS.SMALL else b if s is UIS.MEDIUM else (c or b))[1] def GOS(): return gsw('overlay_stack')
RND = lambda t: type(t)([round(_,1) for _ in t])
def FOR(t): return strftime('%H:%M:%S', gmtime(t))
def SCL(a, b, c=None): return ((s := app.ui_v1.uiscale),
a if s is UIS.SMALL else b if s is UIS.MEDIUM else (c or b))[1]
def RND(t): return type(t)([round(_, 1) for _ in t])
# pybrp # pybrp
Z = lambda _:[0]*_
G_FREQS = lambda:[
def Z(_): return [0]*_
def G_FREQS(): return [
101342, 9667, 3497, 1072, 0, 3793, *Z(2), 2815, 5235, *Z(3), 3570, *Z(3), 101342, 9667, 3497, 1072, 0, 3793, *Z(2), 2815, 5235, *Z(3), 3570, *Z(3),
1383, *Z(3), 2970, *Z(2), 2857, *Z(8), 1199, *Z(30), 1383, *Z(3), 2970, *Z(2), 2857, *Z(8), 1199, *Z(30),
1494, 1974, *Z(12), 1351, *Z(122), 1475, *Z(65) 1494, 1974, *Z(12), 1351, *Z(122), 1475, *Z(65)
] ]
CMD_NAMES=lambda:{0:'BaseTimeStep',1:'StepSceneGraph',2:'AddSceneGraph',3:'RemoveSceneGraph',4:'AddNode',5:'NodeOnCreate',6:'SetForegroundScene',7:'RemoveNode',8:'AddMaterial',9:'RemoveMaterial',10:'AddMaterialComponent',11:'AddTexture',12:'RemoveTexture',13:'AddMesh',14:'RemoveMesh',15:'AddSound',16:'RemoveSound',17:'AddCollisionMesh',18:'RemoveCollisionMesh',19:'ConnectNodeAttribute',20:'NodeMessage',21:'SetNodeAttrFloat',22:'SetNodeAttrInt32',23:'SetNodeAttrBool',24:'SetNodeAttrFloats',25:'SetNodeAttrInt32s',26:'SetNodeAttrString',27:'SetNodeAttrNode',28:'SetNodeAttrNodeNull',29:'SetNodeAttrNodes',30:'SetNodeAttrPlayer',31:'SetNodeAttrPlayerNull',32:'SetNodeAttrMaterials',33:'SetNodeAttrTexture',34:'SetNodeAttrTextureNull',35:'SetNodeAttrTextures',36:'SetNodeAttrSound',37:'SetNodeAttrSoundNull',38:'SetNodeAttrSounds',39:'SetNodeAttrMesh',40:'SetNodeAttrMeshNull',41:'SetNodeAttrMeshes',42:'SetNodeAttrCollisionMesh',43:'SetNodeAttrCollisionMeshNull',44:'SetNodeAttrCollisionMeshes',45:'PlaySoundAtPosition',46:'PlaySound',47:'EmitBGDynamics',48:'EndOfFile',49:'DynamicsCorrection',50:'ScreenMessageBottom',51:'ScreenMessageTop',52:'AddData',53:'RemoveData',54:'CameraShake'}
def CMD_NAMES(): return {0: 'BaseTimeStep', 1: 'StepSceneGraph', 2: 'AddSceneGraph', 3: 'RemoveSceneGraph', 4: 'AddNode', 5: 'NodeOnCreate', 6: 'SetForegroundScene', 7: 'RemoveNode', 8: 'AddMaterial', 9: 'RemoveMaterial', 10: 'AddMaterialComponent', 11: 'AddTexture', 12: 'RemoveTexture', 13: 'AddMesh', 14: 'RemoveMesh', 15: 'AddSound', 16: 'RemoveSound', 17: 'AddCollisionMesh', 18: 'RemoveCollisionMesh', 19: 'ConnectNodeAttribute', 20: 'NodeMessage', 21: 'SetNodeAttrFloat', 22: 'SetNodeAttrInt32', 23: 'SetNodeAttrBool', 24: 'SetNodeAttrFloats', 25: 'SetNodeAttrInt32s', 26: 'SetNodeAttrString', 27: 'SetNodeAttrNode', 28: 'SetNodeAttrNodeNull',
29: 'SetNodeAttrNodes', 30: 'SetNodeAttrPlayer', 31: 'SetNodeAttrPlayerNull', 32: 'SetNodeAttrMaterials', 33: 'SetNodeAttrTexture', 34: 'SetNodeAttrTextureNull', 35: 'SetNodeAttrTextures', 36: 'SetNodeAttrSound', 37: 'SetNodeAttrSoundNull', 38: 'SetNodeAttrSounds', 39: 'SetNodeAttrMesh', 40: 'SetNodeAttrMeshNull', 41: 'SetNodeAttrMeshes', 42: 'SetNodeAttrCollisionMesh', 43: 'SetNodeAttrCollisionMeshNull', 44: 'SetNodeAttrCollisionMeshes', 45: 'PlaySoundAtPosition', 46: 'PlaySound', 47: 'EmitBGDynamics', 48: 'EndOfFile', 49: 'DynamicsCorrection', 50: 'ScreenMessageBottom', 51: 'ScreenMessageTop', 52: 'AddData', 53: 'RemoveData', 54: 'CameraShake'}
class _H: class _H:
class _N: class _N:
def __init__(self): def __init__(self):
self.l, self.r, self.p, self.f = -1, -1, 0, 0 self.l, self.r, self.p, self.f = -1, -1, 0, 0
def __init__(self): def __init__(self):
gf, self.nodes = G_FREQS(), [self._N()for _ in range(511)] gf, self.nodes = G_FREQS(), [self._N()for _ in range(511)]
for i in range(256):self.nodes[i].f=gf[i] for i in range(256):
self.nodes[i].f = gf[i]
nc = 256 nc = 256
while nc < 511: while nc < 511:
s1, s2 = -1, -1 s1, s2 = -1, -1
i = 0 i = 0
while self.nodes[i].p!=0:i+=1 while self.nodes[i].p != 0:
s1=i;i+=1 i += 1
while self.nodes[i].p!=0:i+=1 s1 = i
s2=i;i+=1 i += 1
while self.nodes[i].p != 0:
i += 1
s2 = i
i += 1
while i < nc: while i < nc:
if self.nodes[i].p == 0: if self.nodes[i].p == 0:
if self.nodes[s1].f > self.nodes[s2].f: if self.nodes[s1].f > self.nodes[s2].f:
if self.nodes[i].f<self.nodes[s1].f:s1=i if self.nodes[i].f < self.nodes[s1].f:
elif self.nodes[i].f<self.nodes[s2].f:s2=i s1 = i
elif self.nodes[i].f < self.nodes[s2].f:
s2 = i
i += 1 i += 1
self.nodes[nc].f = self.nodes[s1].f+self.nodes[s2].f self.nodes[nc].f = self.nodes[s1].f+self.nodes[s2].f
self.nodes[s1].p = self.nodes[s2].p = nc-255 self.nodes[s1].p = self.nodes[s2].p = nc-255
self.nodes[nc].r, self.nodes[nc].l = s1, s2 self.nodes[nc].r, self.nodes[nc].l = s1, s2
nc += 1 nc += 1
def decompress(self, src): def decompress(self, src):
if not src:return b'' if not src:
return b''
rem, comp = src[0] & 15, src[0] >> 7 rem, comp = src[0] & 15, src[0] >> 7
if not comp:return src if not comp:
return src
out, ptr, l = bytearray(), src[1:], len(src) out, ptr, l = bytearray(), src[1:], len(src)
bl=((l-1)*8)-rem;bit=0 bl = ((l-1)*8)-rem
bit = 0
while bit < bl: while bit < bl:
m_bit=(ptr[bit>>3]>>(bit&7))&1;bit+=1 m_bit = (ptr[bit >> 3] >> (bit & 7)) & 1
bit += 1
if m_bit: if m_bit:
n = 510 n = 510
while n >= 256: while n >= 256:
if bit>=bl:raise ValueError("Incomplete Huffman code") if bit >= bl:
p_bit=(ptr[bit>>3]>>(bit&7))&1;bit+=1 raise ValueError("Incomplete Huffman code")
p_bit = (ptr[bit >> 3] >> (bit & 7)) & 1
bit += 1
n = self.nodes[n].l if p_bit == 0 else self.nodes[n].r n = self.nodes[n].l if p_bit == 0 else self.nodes[n].r
out.append(n) out.append(n)
else: else:
if bit+8>bl:break if bit+8 > bl:
break
bi, b_in_b = bit >> 3, bit & 7 bi, b_in_b = bit >> 3, bit & 7
val = ptr[bi]if b_in_b == 0 else (ptr[bi] >> b_in_b) | (ptr[bi+1] << (8-b_in_b)) val = ptr[bi]if b_in_b == 0 else (ptr[bi] >> b_in_b) | (ptr[bi+1] << (8-b_in_b))
out.append(val&255);bit+=8 out.append(val & 255)
bit += 8
return bytes(out) return bytes(out)
def GMS(_h, brp_path, par): def GMS(_h, brp_path, par):
total_ms = 0 total_ms = 0
with open(brp_path, 'rb') as f: with open(brp_path, 'rb') as f:
@ -1192,7 +1326,8 @@ def GMS(_h, brp_path, par):
par[1] = f.tell() par[1] = f.tell()
f.seek(6) f.seek(6)
while True: while True:
if par: par[0] = f.tell() if par:
par[0] = f.tell()
b_data = f.read(1) b_data = f.read(1)
if not b_data: if not b_data:
break break
@ -1220,20 +1355,26 @@ def GMS(_h, brp_path, par):
if sub_data and sub_data[0] == 0: if sub_data and sub_data[0] == 0:
total_ms += sub_data[1] total_ms += sub_data[1]
sub_off += 2 + sub_size sub_off += 2 + sub_size
if par: par[0] = par[1] if par:
par[0] = par[1]
return total_ms return total_ms
# brobord collide grass # brobord collide grass
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
def __init__(s): def __init__(s):
from bauiv1lib.ingamemenu import InGameMenuWindow as m from bauiv1lib.ingamemenu import InGameMenuWindow as m
a = '_refresh_in_game'; o = getattr(m,a) a = '_refresh_in_game'
o = getattr(m, a)
setattr(m, a, lambda v, *a, **k: (s.mk(v), o(v, *a, **k))[1]) setattr(m, a, lambda v, *a, **k: (s.mk(v), o(v, *a, **k))[1])
from bauiv1lib.watch import WatchWindow as n from bauiv1lib.watch import WatchWindow as n
b = '__init__'; p = getattr(n,b) b = '__init__'
p = getattr(n, b)
setattr(n, b, lambda v, *a, **k: (p(v, *a, **k), s.mk(v, 1))[0]) setattr(n, b, lambda v, *a, **k: (p(v, *a, **k), s.mk(v, 1))[0])
def mk(s, v, i=0): def mk(s, v, i=0):
if i: if i:
x = v._width/2+SCL(v._scroll_width*-0.5+93, 0)+100 x = v._width/2+SCL(v._scroll_width*-0.5+93, 0)+100
@ -1248,4 +1389,3 @@ class byBordd(Plugin):
size=(140, 50) if i else (90, 35), size=(140, 50) if i else (90, 35),
oac=lambda: Replay(source=s.b) oac=lambda: Replay(source=s.b)
) )

View file

@ -19,8 +19,11 @@ from bascenev1 import (
# ba_meta require api 9 # ba_meta require api 9
# ba_meta export babase.Plugin # ba_meta export babase.Plugin
class byBordd(Plugin): class byBordd(Plugin):
__init__ = lambda s: (setattr(s,'la',None),z(5,s.ear))[1] def __init__(s): return (setattr(s, 'la', None), z(5, s.ear))[1]
def ear(s): def ear(s):
a = gcm() a = gcm()
if a and s.la != a[-1]: if a and s.la != a[-1]:
@ -28,4 +31,3 @@ class byBordd(Plugin):
push(a[-1], (1, 1, 1), True) push(a[-1], (1, 1, 1), True)
s.la = a[-1] s.la = a[-1]
z(0.1, s.ear) z(0.1, s.ear)