mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Update share_replays
This commit is contained in:
parent
06d63d907a
commit
c98906f049
2 changed files with 65 additions and 60 deletions
|
|
@ -63,6 +63,7 @@
|
|||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.3.2": null,
|
||||
"1.3.1": {
|
||||
"api_version": 7,
|
||||
"commit_sha": "d511c15",
|
||||
|
|
@ -162,6 +163,7 @@
|
|||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.0.1": null,
|
||||
"1.0.0": {
|
||||
"api_version": 7,
|
||||
"commit_sha": "2fda676",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
|
||||
"""
|
||||
Plugin by LoupGarou a.k.a Loup/Soup
|
||||
Discord →ʟօʊքɢǟʀօʊ#3063
|
||||
|
|
@ -12,7 +13,7 @@ Message me in discord if you find some bug
|
|||
Use this code for your experiments or plugin but please dont rename this plugin and distribute with your name,don't do that,its bad'
|
||||
"""
|
||||
|
||||
# ba_meta require api 7
|
||||
# ba_meta require api 8
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING, cast
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -21,19 +22,21 @@ if TYPE_CHECKING:
|
|||
from os import listdir, mkdir, path, sep, remove
|
||||
from shutil import copy, copytree
|
||||
|
||||
import ba
|
||||
import _ba
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import _babase
|
||||
from enum import Enum
|
||||
from bastd.ui.tabs import TabRow
|
||||
from bastd.ui.confirm import ConfirmWindow
|
||||
from bastd.ui.watch import WatchWindow
|
||||
from bastd.ui.popup import PopupWindow
|
||||
from bauiv1lib.tabs import TabRow
|
||||
from bauiv1lib.confirm import ConfirmWindow
|
||||
from bauiv1lib.watch import WatchWindow
|
||||
from bauiv1lib.popup import PopupWindow
|
||||
|
||||
|
||||
title = "SHARE REPLAY"
|
||||
internal_dir = _ba.get_replays_dir()+sep
|
||||
external_dir = path.join(_ba.env()["python_directory_user"], "replays"+sep)
|
||||
uiscale = ba.app.ui.uiscale
|
||||
internal_dir = _babase.get_replays_dir()+sep
|
||||
external_dir = path.join(_babase.env()["python_directory_user"], "replays"+sep)
|
||||
uiscale = bui.app.ui_v1.uiscale
|
||||
|
||||
# colors
|
||||
pink = (1, 0.2, 0.8)
|
||||
|
|
@ -45,12 +48,12 @@ b_color = (0.6, 0.53, 0.63)
|
|||
b_textcolor = (0.75, 0.7, 0.8)
|
||||
|
||||
|
||||
def Print(*args, color=None, top=None):
|
||||
def Print(*args, color=None):
|
||||
out = ""
|
||||
for arg in args:
|
||||
a = str(arg)
|
||||
out += a
|
||||
ba.screenmessage(out, color=color, top=top)
|
||||
bui.screenmessage(out, color=color)
|
||||
|
||||
|
||||
def cprint(*args):
|
||||
|
|
@ -58,7 +61,7 @@ def cprint(*args):
|
|||
for arg in args:
|
||||
a = str(arg)
|
||||
out += a
|
||||
_ba.chatmessage(out)
|
||||
bs.chatmessage(out)
|
||||
|
||||
|
||||
if not path.exists(external_dir):
|
||||
|
|
@ -103,10 +106,10 @@ class CommonUtilities:
|
|||
return
|
||||
elif tab_id == MyTabId.INTERNAL:
|
||||
copy(internal_dir+selected_replay, external_dir+selected_replay)
|
||||
Print(selected_replay[0:-4]+" exported", top=True, color=pink)
|
||||
Print(selected_replay[0:-4]+" exported", color=pink)
|
||||
else:
|
||||
copy(external_dir+selected_replay, internal_dir+selected_replay)
|
||||
Print(selected_replay[0:-4]+" imported", top=True, color=green)
|
||||
Print(selected_replay[0:-4]+" imported", color=green)
|
||||
|
||||
def delete_replay(self, selected_replay, tab_id, cls_inst):
|
||||
if selected_replay is None:
|
||||
|
|
@ -119,7 +122,7 @@ class CommonUtilities:
|
|||
elif tab_id == MyTabId.EXTERNAL:
|
||||
remove(external_dir+selected_replay)
|
||||
cls_inst.on_tab_select(tab_id) # updating the tab
|
||||
Print(selected_replay[0:-4]+" was deleted", top=True, color=red)
|
||||
Print(selected_replay[0:-4]+" was deleted", color=red)
|
||||
ConfirmWindow(text=f"Delete \"{selected_replay.split('.')[0]}\" \nfrom {'internal directory' if tab_id==MyTabId.INTERNAL else 'external directory'}?",
|
||||
action=do_it, cancel_is_selected=True)
|
||||
|
||||
|
|
@ -137,16 +140,16 @@ class Help(PopupWindow):
|
|||
def __init__(self):
|
||||
self.width = 1200
|
||||
self.height = 250
|
||||
self.root_widget = ba.Window(ba.containerwidget(
|
||||
self.root_widget = bui.Window(bui.containerwidget(
|
||||
size=(self.width, self.height), on_outside_click_call=self.close, transition="in_right")).get_root_widget()
|
||||
|
||||
ba.containerwidget(edit=self.root_widget, on_outside_click_call=self.close)
|
||||
ba.textwidget(parent=self.root_widget, position=(0, self.height * 0.7), corner_scale=1.2, color=green,
|
||||
bui.containerwidget(edit=self.root_widget, on_outside_click_call=self.close)
|
||||
bui.textwidget(parent=self.root_widget, position=(0, self.height * 0.7), corner_scale=1.2, color=green,
|
||||
text=f"»Replays are exported to\n {external_dir}\n»Copy replays to the above folder to be able to import them into the game\n»I would love to hear from you,meet me on discord\n -LoupGarou(author)")
|
||||
|
||||
def close(self):
|
||||
ba.playsound(ba.getsound('swish'))
|
||||
ba.containerwidget(edit=self.root_widget, transition="out_right",)
|
||||
bui.getsound('swish').play()
|
||||
bui.containerwidget(edit=self.root_widget, transition="out_right",)
|
||||
|
||||
|
||||
class ShareTabUi(WatchWindow):
|
||||
|
|
@ -155,7 +158,7 @@ class ShareTabUi(WatchWindow):
|
|||
self.selected_replay = None
|
||||
|
||||
if root_widget is None:
|
||||
self.root = ba.Window(ba.containerwidget(
|
||||
self.root = bui.Window(bui.containerwidget(
|
||||
size=(1000, 600), on_outside_click_call=self.close, transition="in_right")).get_root_widget()
|
||||
|
||||
else:
|
||||
|
|
@ -166,8 +169,8 @@ class ShareTabUi(WatchWindow):
|
|||
def on_select_text(self, widget, name):
|
||||
existing_widgets = self.scroll2.get_children()
|
||||
for i in existing_widgets:
|
||||
ba.textwidget(edit=i, color=(1, 1, 1))
|
||||
ba.textwidget(edit=widget, color=(1.0, 1, 0.4))
|
||||
bui.textwidget(edit=i, color=(1, 1, 1))
|
||||
bui.textwidget(edit=widget, color=(1.0, 1, 0.4))
|
||||
self.selected_replay = name
|
||||
|
||||
def on_tab_select(self, tab_id):
|
||||
|
|
@ -177,10 +180,10 @@ class ShareTabUi(WatchWindow):
|
|||
|
||||
if tab_id == MyTabId.INTERNAL:
|
||||
dir_list = listdir(internal_dir)
|
||||
ba.buttonwidget(edit=self.share_button, label="Export\nReplay")
|
||||
bui.buttonwidget(edit=self.share_button, label="Export\nReplay")
|
||||
else:
|
||||
dir_list = listdir(external_dir)
|
||||
ba.buttonwidget(edit=self.share_button, label="Import\nReplay")
|
||||
bui.buttonwidget(edit=self.share_button, label="Import\nReplay")
|
||||
|
||||
self.tab_row.update_appearance(tab_id)
|
||||
dir_list = sorted(dir_list)
|
||||
|
|
@ -192,7 +195,7 @@ class ShareTabUi(WatchWindow):
|
|||
for i in dir_list: # making textwidgets for all replays
|
||||
height -= 50
|
||||
a = i
|
||||
i = ba.textwidget(
|
||||
i = bui.textwidget(
|
||||
parent=self.scroll2,
|
||||
size=(self._my_replays_scroll_width/t_scale, 30),
|
||||
text=i.split(".")[0],
|
||||
|
|
@ -202,18 +205,18 @@ class ShareTabUi(WatchWindow):
|
|||
corner_scale=t_scale,
|
||||
click_activate=True,
|
||||
always_highlight=True,)
|
||||
ba.textwidget(edit=i, on_activate_call=ba.Call(self.on_select_text, i, a))
|
||||
bui.textwidget(edit=i, on_activate_call=babase.Call(self.on_select_text, i, a))
|
||||
|
||||
def draw_ui(self):
|
||||
self._r = 'watchWindow'
|
||||
x_inset = 100 if uiscale is ba.UIScale.SMALL else 0
|
||||
x_inset = 100 if uiscale is babase.UIScale.SMALL else 0
|
||||
scroll_buffer_h = 130 + 2 * x_inset
|
||||
self._width = 1240 if uiscale is ba.UIScale.SMALL else 1040
|
||||
self._width = 1240 if uiscale is babase.UIScale.SMALL else 1040
|
||||
self._height = (
|
||||
578
|
||||
if uiscale is ba.UIScale.SMALL
|
||||
if uiscale is babase.UIScale.SMALL
|
||||
else 670
|
||||
if uiscale is ba.UIScale.MEDIUM
|
||||
if uiscale is babase.UIScale.MEDIUM
|
||||
else 800)
|
||||
self._scroll_width = self._width - scroll_buffer_h
|
||||
self._scroll_height = self._height - 180
|
||||
|
|
@ -222,49 +225,49 @@ class ShareTabUi(WatchWindow):
|
|||
c_height = self._scroll_height - 20
|
||||
sub_scroll_height = c_height - 63
|
||||
self._my_replays_scroll_width = sub_scroll_width = (
|
||||
680 if uiscale is ba.UIScale.SMALL else 640
|
||||
680 if uiscale is babase.UIScale.SMALL else 640
|
||||
)
|
||||
|
||||
v = c_height - 30
|
||||
b_width = 140 if uiscale is ba.UIScale.SMALL else 178
|
||||
b_width = 140 if uiscale is babase.UIScale.SMALL else 178
|
||||
b_height = (
|
||||
107
|
||||
if uiscale is ba.UIScale.SMALL
|
||||
if uiscale is babase.UIScale.SMALL
|
||||
else 142
|
||||
if uiscale is ba.UIScale.MEDIUM
|
||||
if uiscale is babase.UIScale.MEDIUM
|
||||
else 190
|
||||
)
|
||||
b_space_extra = (
|
||||
0
|
||||
if uiscale is ba.UIScale.SMALL
|
||||
if uiscale is babase.UIScale.SMALL
|
||||
else -2
|
||||
if uiscale is ba.UIScale.MEDIUM
|
||||
if uiscale is babase.UIScale.MEDIUM
|
||||
else -5
|
||||
)
|
||||
|
||||
b_color = (0.6, 0.53, 0.63)
|
||||
b_textcolor = (0.75, 0.7, 0.8)
|
||||
btnv = (c_height - (48
|
||||
if uiscale is ba.UIScale.SMALL
|
||||
if uiscale is babase.UIScale.SMALL
|
||||
else 45
|
||||
if uiscale is ba.UIScale.MEDIUM
|
||||
if uiscale is babase.UIScale.MEDIUM
|
||||
else 40) - b_height)
|
||||
btnh = 40 if uiscale is ba.UIScale.SMALL else 40
|
||||
smlh = 190 if uiscale is ba.UIScale.SMALL else 225
|
||||
tscl = 1.0 if uiscale is ba.UIScale.SMALL else 1.2
|
||||
btnh = 40 if uiscale is babase.UIScale.SMALL else 40
|
||||
smlh = 190 if uiscale is babase.UIScale.SMALL else 225
|
||||
tscl = 1.0 if uiscale is babase.UIScale.SMALL else 1.2
|
||||
|
||||
stab_width = 500
|
||||
stab_height = 300
|
||||
stab_h = smlh
|
||||
|
||||
v -= sub_scroll_height + 23
|
||||
scroll = ba.scrollwidget(
|
||||
scroll = bui.scrollwidget(
|
||||
parent=self.root,
|
||||
position=(smlh, v),
|
||||
size=(sub_scroll_width, sub_scroll_height),
|
||||
)
|
||||
|
||||
self.scroll2 = ba.columnwidget(parent=scroll,
|
||||
self.scroll2 = bui.columnwidget(parent=scroll,
|
||||
size=(sub_scroll_width, sub_scroll_height))
|
||||
|
||||
tabdefs = [(MyTabId.INTERNAL, 'INTERNAL'), (MyTabId.EXTERNAL, "EXTERNAL")]
|
||||
|
|
@ -275,7 +278,7 @@ class ShareTabUi(WatchWindow):
|
|||
helpbtn_v = stab_h+stab_width+helpbtn_space+120
|
||||
helpbtn_h = sub_scroll_height+helpbtn_space
|
||||
|
||||
ba.buttonwidget(
|
||||
bui.buttonwidget(
|
||||
parent=self.root,
|
||||
position=(helpbtn_v, helpbtn_h),
|
||||
size=(35, 35),
|
||||
|
|
@ -287,7 +290,7 @@ class ShareTabUi(WatchWindow):
|
|||
on_activate_call=Help)
|
||||
|
||||
def call_copy(): return CommonUtils._copy(self.selected_replay, self.tab_id)
|
||||
self.share_button = ba.buttonwidget(
|
||||
self.share_button = bui.buttonwidget(
|
||||
parent=self.root,
|
||||
size=(b_width, b_height),
|
||||
position=(btnh, btnv),
|
||||
|
|
@ -299,7 +302,7 @@ class ShareTabUi(WatchWindow):
|
|||
on_activate_call=call_copy)
|
||||
|
||||
btnv -= b_height + b_space_extra
|
||||
sync_button = ba.buttonwidget(
|
||||
sync_button = bui.buttonwidget(
|
||||
parent=self.root,
|
||||
size=(b_width, b_height),
|
||||
position=(btnh, btnv),
|
||||
|
|
@ -312,12 +315,12 @@ class ShareTabUi(WatchWindow):
|
|||
|
||||
btnv -= b_height + b_space_extra
|
||||
def call_delete(): return CommonUtils.delete_replay(self.selected_replay, self.tab_id, self)
|
||||
delete_replay_button = ba.buttonwidget(
|
||||
delete_replay_button = bui.buttonwidget(
|
||||
parent=self.root,
|
||||
size=(b_width, b_height),
|
||||
position=(btnh, btnv),
|
||||
button_type="square",
|
||||
label=ba.Lstr(resource=self._r + '.deleteReplayButtonText'),
|
||||
label=babase.Lstr(resource=self._r + '.deleteReplayButtonText'),
|
||||
text_scale=tscl,
|
||||
color=b_color,
|
||||
textcolor=b_textcolor,
|
||||
|
|
@ -326,13 +329,13 @@ class ShareTabUi(WatchWindow):
|
|||
self.on_tab_select(MyTabId.INTERNAL)
|
||||
|
||||
def close(self):
|
||||
ba.playsound(ba.getsound('swish'))
|
||||
ba.containerwidget(edit=self.root, transition="out_right",)
|
||||
bui.getsound('swish').play()
|
||||
bui.containerwidget(edit=self.root, transition="out_right",)
|
||||
|
||||
|
||||
# ++++++++++++++++for keyboard navigation++++++++++++++++
|
||||
|
||||
# ba.widget(edit=self.enable_button, up_widget=decrease_button, down_widget=self.lower_text,left_widget=save_button, right_widget=save_button)
|
||||
# bui.widget(edit=self.enable_button, up_widget=decrease_button, down_widget=self.lower_text,left_widget=save_button, right_widget=save_button)
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -341,7 +344,7 @@ class ShareTab(WatchWindow):
|
|||
@override(WatchWindow)
|
||||
def __init__(self,
|
||||
transition: str | None = 'in_right',
|
||||
origin_widget: ba.Widget | None = None,
|
||||
origin_widget: bui.Widget | None = None,
|
||||
oldmethod=None):
|
||||
self.my_tab_container = None
|
||||
self._old___init__(transition, origin_widget)
|
||||
|
|
@ -349,11 +352,11 @@ class ShareTab(WatchWindow):
|
|||
self._tab_row.tabs[self.TabID.MY_REPLAYS].button.delete() # deleting old tab button
|
||||
|
||||
tabdefs = [(self.TabID.MY_REPLAYS,
|
||||
ba.Lstr(resource=self._r + '.myReplaysText'),),
|
||||
babase.Lstr(resource=self._r + '.myReplaysText'),),
|
||||
(MyTabId.SHARE_REPLAYS, "Share Replays"),]
|
||||
|
||||
uiscale = ba.app.ui.uiscale
|
||||
x_inset = 100 if uiscale is ba.UIScale.SMALL else 0
|
||||
uiscale = bui.app.ui_v1.uiscale
|
||||
x_inset = 100 if uiscale is babase.UIScale.SMALL else 0
|
||||
tab_buffer_h = 750 + 2 * x_inset
|
||||
self._tab_row = TabRow(
|
||||
self._root_widget,
|
||||
|
|
@ -378,10 +381,10 @@ class ShareTab(WatchWindow):
|
|||
c_height = self._scroll_height - 20
|
||||
sub_scroll_height = c_height - 63
|
||||
self._my_replays_scroll_width = sub_scroll_width = (
|
||||
680 if uiscale is ba.UIScale.SMALL else 640
|
||||
680 if uiscale is babase.UIScale.SMALL else 640
|
||||
)
|
||||
|
||||
self.my_tab_container = ba.containerwidget(
|
||||
self.my_tab_container = bui.containerwidget(
|
||||
parent=self._root_widget,
|
||||
position=(scroll_left,
|
||||
scroll_bottom + (self._scroll_height - c_height) * 0.5,),
|
||||
|
|
@ -395,7 +398,7 @@ class ShareTab(WatchWindow):
|
|||
|
||||
# ba_meta export plugin
|
||||
|
||||
class Loup(ba.Plugin):
|
||||
class Loup(babase.Plugin):
|
||||
def on_app_running(self):
|
||||
WatchWindow.__init__ = ShareTab.__init__
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue