mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
[ci] auto-format
This commit is contained in:
parent
6e9d698b59
commit
ec116b3506
1 changed files with 147 additions and 147 deletions
|
|
@ -18,7 +18,7 @@ from typing import TYPE_CHECKING, cast
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union
|
from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union
|
||||||
|
|
||||||
from os import listdir, mkdir, path, sep,remove
|
from os import listdir, mkdir, path, sep, remove
|
||||||
from shutil import copy, copytree
|
from shutil import copy, copytree
|
||||||
|
|
||||||
import ba
|
import ba
|
||||||
|
|
@ -44,6 +44,7 @@ blue_highlight = (0.4, 0.7, 1)
|
||||||
b_color = (0.6, 0.53, 0.63)
|
b_color = (0.6, 0.53, 0.63)
|
||||||
b_textcolor = (0.75, 0.7, 0.8)
|
b_textcolor = (0.75, 0.7, 0.8)
|
||||||
|
|
||||||
|
|
||||||
def Print(*args, color=None, top=None):
|
def Print(*args, color=None, top=None):
|
||||||
out = ""
|
out = ""
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
|
@ -65,7 +66,6 @@ if not path.exists(external_dir):
|
||||||
Print("You are ready to share replays", color=pink)
|
Print("You are ready to share replays", color=pink)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def override(cls: ClassType) -> Callable[[MethodType], MethodType]:
|
def override(cls: ClassType) -> Callable[[MethodType], MethodType]:
|
||||||
def decorator(newfunc: MethodType) -> MethodType:
|
def decorator(newfunc: MethodType) -> MethodType:
|
||||||
funcname = newfunc.__code__.co_name
|
funcname = newfunc.__code__.co_name
|
||||||
|
|
@ -97,32 +97,33 @@ class CommonUtilities:
|
||||||
copy(external_dir+sep+i, internal_dir+sep+i)
|
copy(external_dir+sep+i, internal_dir+sep+i)
|
||||||
Print("Synced all replays", color=pink)
|
Print("Synced all replays", color=pink)
|
||||||
|
|
||||||
def _copy(self, selected_replay,tab_id):
|
def _copy(self, selected_replay, tab_id):
|
||||||
if selected_replay is None:
|
if selected_replay is None:
|
||||||
Print("Select a replay", color=red)
|
Print("Select a replay", color=red)
|
||||||
return
|
return
|
||||||
elif tab_id==MyTabId.INTERNAL:
|
elif tab_id == MyTabId.INTERNAL:
|
||||||
copy(internal_dir+selected_replay, external_dir+selected_replay)
|
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", top=True, color=pink)
|
||||||
else:
|
else:
|
||||||
copy(external_dir+selected_replay, internal_dir+selected_replay)
|
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", top=True, color=green)
|
||||||
|
|
||||||
def delete_replay(self,selected_replay,tab_id,cls_inst):
|
def delete_replay(self, selected_replay, tab_id, cls_inst):
|
||||||
if selected_replay is None:
|
if selected_replay is None:
|
||||||
Print("Select a replay", color=red)
|
Print("Select a replay", color=red)
|
||||||
return
|
return
|
||||||
|
|
||||||
def do_it():
|
def do_it():
|
||||||
if tab_id==MyTabId.INTERNAL:
|
if tab_id == MyTabId.INTERNAL:
|
||||||
remove(internal_dir+selected_replay)
|
remove(internal_dir+selected_replay)
|
||||||
elif tab_id==MyTabId.EXTERNAL:
|
elif tab_id == MyTabId.EXTERNAL:
|
||||||
remove(external_dir+selected_replay)
|
remove(external_dir+selected_replay)
|
||||||
cls_inst.on_tab_select(tab_id) #updating the tab
|
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", top=True, color=red)
|
||||||
ConfirmWindow(text=f"Delete \"{selected_replay.split('.')[0]}\" \nfrom {'internal directory' if tab_id==MyTabId.INTERNAL else 'external directory'}?",
|
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)
|
action=do_it, cancel_is_selected=True)
|
||||||
|
|
||||||
|
|
||||||
CommonUtils = CommonUtilities()
|
CommonUtils = CommonUtilities()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -131,15 +132,16 @@ class MyTabId(Enum):
|
||||||
EXTERNAL = "external"
|
EXTERNAL = "external"
|
||||||
SHARE_REPLAYS = "share_replay"
|
SHARE_REPLAYS = "share_replay"
|
||||||
|
|
||||||
|
|
||||||
class Help(PopupWindow):
|
class Help(PopupWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.width = 1200
|
self.width = 1200
|
||||||
self.height = 250
|
self.height = 250
|
||||||
self.root_widget = ba.Window(ba.containerwidget(
|
self.root_widget = ba.Window(ba.containerwidget(
|
||||||
size=(self.width, self.height), on_outside_click_call=self.close, transition="in_right")).get_root_widget()
|
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.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,
|
ba.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)")
|
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):
|
def close(self):
|
||||||
|
|
@ -158,9 +160,8 @@ class ShareTabUi(WatchWindow):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.root = root_widget
|
self.root = root_widget
|
||||||
|
|
||||||
self.draw_ui()
|
self.draw_ui()
|
||||||
|
|
||||||
|
|
||||||
def on_select_text(self, widget, name):
|
def on_select_text(self, widget, name):
|
||||||
existing_widgets = self.scroll2.get_children()
|
existing_widgets = self.scroll2.get_children()
|
||||||
|
|
@ -173,22 +174,22 @@ class ShareTabUi(WatchWindow):
|
||||||
self.selected_replay = None
|
self.selected_replay = None
|
||||||
self.tab_id = tab_id
|
self.tab_id = tab_id
|
||||||
t_scale = 1.6
|
t_scale = 1.6
|
||||||
|
|
||||||
if tab_id == MyTabId.INTERNAL:
|
if tab_id == MyTabId.INTERNAL:
|
||||||
dir_list = listdir(internal_dir)
|
dir_list = listdir(internal_dir)
|
||||||
ba.buttonwidget(edit=self.share_button, label="Export\nReplay")
|
ba.buttonwidget(edit=self.share_button, label="Export\nReplay")
|
||||||
else:
|
else:
|
||||||
dir_list = listdir(external_dir)
|
dir_list = listdir(external_dir)
|
||||||
ba.buttonwidget(edit=self.share_button, label="Import\nReplay")
|
ba.buttonwidget(edit=self.share_button, label="Import\nReplay")
|
||||||
|
|
||||||
self.tab_row.update_appearance(tab_id)
|
self.tab_row.update_appearance(tab_id)
|
||||||
dir_list = sorted(dir_list)
|
dir_list = sorted(dir_list)
|
||||||
existing_widgets = self.scroll2.get_children()
|
existing_widgets = self.scroll2.get_children()
|
||||||
if existing_widgets:# deleting textwidgets from old tab
|
if existing_widgets: # deleting textwidgets from old tab
|
||||||
for i in existing_widgets:
|
for i in existing_widgets:
|
||||||
i.delete()
|
i.delete()
|
||||||
height = 900
|
height = 900
|
||||||
for i in dir_list:# making textwidgets for all replays
|
for i in dir_list: # making textwidgets for all replays
|
||||||
height -= 50
|
height -= 50
|
||||||
a = i
|
a = i
|
||||||
i = ba.textwidget(
|
i = ba.textwidget(
|
||||||
|
|
@ -202,128 +203,127 @@ class ShareTabUi(WatchWindow):
|
||||||
click_activate=True,
|
click_activate=True,
|
||||||
always_highlight=True,)
|
always_highlight=True,)
|
||||||
ba.textwidget(edit=i, on_activate_call=ba.Call(self.on_select_text, i, a))
|
ba.textwidget(edit=i, on_activate_call=ba.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
|
|
||||||
scroll_buffer_h = 130 + 2 * x_inset
|
|
||||||
self._width = 1240 if uiscale is ba.UIScale.SMALL else 1040
|
|
||||||
self._height = (
|
|
||||||
578
|
|
||||||
if uiscale is ba.UIScale.SMALL
|
|
||||||
else 670
|
|
||||||
if uiscale is ba.UIScale.MEDIUM
|
|
||||||
else 800)
|
|
||||||
self._scroll_width = self._width - scroll_buffer_h
|
|
||||||
self._scroll_height = self._height - 180
|
|
||||||
#
|
|
||||||
c_width = self._scroll_width
|
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
v = c_height - 30
|
def draw_ui(self):
|
||||||
b_width = 140 if uiscale is ba.UIScale.SMALL else 178
|
self._r = 'watchWindow'
|
||||||
b_height = (
|
x_inset = 100 if uiscale is ba.UIScale.SMALL else 0
|
||||||
107
|
scroll_buffer_h = 130 + 2 * x_inset
|
||||||
if uiscale is ba.UIScale.SMALL
|
self._width = 1240 if uiscale is ba.UIScale.SMALL else 1040
|
||||||
else 142
|
self._height = (
|
||||||
if uiscale is ba.UIScale.MEDIUM
|
578
|
||||||
else 190
|
if uiscale is ba.UIScale.SMALL
|
||||||
)
|
else 670
|
||||||
b_space_extra = (
|
if uiscale is ba.UIScale.MEDIUM
|
||||||
0
|
else 800)
|
||||||
if uiscale is ba.UIScale.SMALL
|
self._scroll_width = self._width - scroll_buffer_h
|
||||||
else -2
|
self._scroll_height = self._height - 180
|
||||||
if uiscale is ba.UIScale.MEDIUM
|
#
|
||||||
else -5
|
c_width = self._scroll_width
|
||||||
)
|
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
|
||||||
|
)
|
||||||
|
|
||||||
b_color = (0.6, 0.53, 0.63)
|
v = c_height - 30
|
||||||
b_textcolor = (0.75, 0.7, 0.8)
|
b_width = 140 if uiscale is ba.UIScale.SMALL else 178
|
||||||
btnv = (c_height- (48
|
b_height = (
|
||||||
if uiscale is ba.UIScale.SMALL
|
107
|
||||||
else 45
|
if uiscale is ba.UIScale.SMALL
|
||||||
if uiscale is ba.UIScale.MEDIUM
|
else 142
|
||||||
else 40) - b_height)
|
if uiscale is ba.UIScale.MEDIUM
|
||||||
btnh = 40 if uiscale is ba.UIScale.SMALL else 40
|
else 190
|
||||||
smlh = 190 if uiscale is ba.UIScale.SMALL else 225
|
)
|
||||||
tscl = 1.0 if uiscale is ba.UIScale.SMALL else 1.2
|
b_space_extra = (
|
||||||
|
0
|
||||||
stab_width=500
|
if uiscale is ba.UIScale.SMALL
|
||||||
stab_height=300
|
else -2
|
||||||
stab_h=smlh
|
if uiscale is ba.UIScale.MEDIUM
|
||||||
|
else -5
|
||||||
v -= sub_scroll_height + 23
|
)
|
||||||
scroll = ba.scrollwidget(
|
|
||||||
parent=self.root,
|
|
||||||
position=(smlh, v),
|
|
||||||
size=(sub_scroll_width, sub_scroll_height),
|
|
||||||
)
|
|
||||||
|
|
||||||
self.scroll2 = ba.columnwidget(parent=scroll,
|
|
||||||
size=(sub_scroll_width, sub_scroll_height))
|
|
||||||
|
|
||||||
tabdefs = [(MyTabId.INTERNAL, 'INTERNAL'), (MyTabId.EXTERNAL, "EXTERNAL")]
|
|
||||||
self.tab_row = TabRow(self.root, tabdefs, pos=(stab_h,sub_scroll_height),
|
|
||||||
size=(stab_width,stab_height), on_select_call=self.on_tab_select)
|
|
||||||
|
|
||||||
helpbtn_space=20
|
|
||||||
helpbtn_v=stab_h+stab_width+helpbtn_space+120
|
|
||||||
helpbtn_h=sub_scroll_height+helpbtn_space
|
|
||||||
|
|
||||||
ba.buttonwidget(
|
|
||||||
parent=self.root,
|
|
||||||
position=(helpbtn_v ,helpbtn_h ),
|
|
||||||
size=(35, 35),
|
|
||||||
button_type="square",
|
|
||||||
label="?",
|
|
||||||
text_scale=1.5,
|
|
||||||
color=b_color,
|
|
||||||
textcolor=b_textcolor,
|
|
||||||
on_activate_call=Help)
|
|
||||||
|
|
||||||
call_copy=lambda:CommonUtils._copy(self.selected_replay,self.tab_id)
|
|
||||||
self.share_button = ba.buttonwidget(
|
|
||||||
parent=self.root,
|
|
||||||
size=(b_width, b_height),
|
|
||||||
position=(btnh, btnv),
|
|
||||||
button_type="square",
|
|
||||||
label="Export\nReplay",
|
|
||||||
text_scale=tscl,
|
|
||||||
color=b_color,
|
|
||||||
textcolor=b_textcolor,
|
|
||||||
on_activate_call=call_copy)
|
|
||||||
|
|
||||||
btnv -= b_height + b_space_extra
|
|
||||||
sync_button = ba.buttonwidget(
|
|
||||||
parent=self.root,
|
|
||||||
size=(b_width, b_height),
|
|
||||||
position=(btnh, btnv),
|
|
||||||
button_type="square",
|
|
||||||
label="Sync\nReplay",
|
|
||||||
text_scale=tscl,
|
|
||||||
color=b_color,
|
|
||||||
textcolor=b_textcolor,
|
|
||||||
on_activate_call=CommonUtils.sync_confirmation)
|
|
||||||
|
|
||||||
btnv -= b_height + b_space_extra
|
|
||||||
call_delete = lambda:CommonUtils.delete_replay(self.selected_replay,self.tab_id,self)
|
|
||||||
delete_replay_button = ba.buttonwidget(
|
|
||||||
parent=self.root,
|
|
||||||
size=(b_width, b_height),
|
|
||||||
position=(btnh, btnv),
|
|
||||||
button_type="square",
|
|
||||||
label=ba.Lstr(resource=self._r + '.deleteReplayButtonText'),
|
|
||||||
text_scale=tscl,
|
|
||||||
color=b_color,
|
|
||||||
textcolor=b_textcolor,
|
|
||||||
on_activate_call=call_delete)
|
|
||||||
|
|
||||||
|
b_color = (0.6, 0.53, 0.63)
|
||||||
self.on_tab_select(MyTabId.INTERNAL)
|
b_textcolor = (0.75, 0.7, 0.8)
|
||||||
|
btnv = (c_height - (48
|
||||||
|
if uiscale is ba.UIScale.SMALL
|
||||||
|
else 45
|
||||||
|
if uiscale is ba.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
|
||||||
|
|
||||||
|
stab_width = 500
|
||||||
|
stab_height = 300
|
||||||
|
stab_h = smlh
|
||||||
|
|
||||||
|
v -= sub_scroll_height + 23
|
||||||
|
scroll = ba.scrollwidget(
|
||||||
|
parent=self.root,
|
||||||
|
position=(smlh, v),
|
||||||
|
size=(sub_scroll_width, sub_scroll_height),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.scroll2 = ba.columnwidget(parent=scroll,
|
||||||
|
size=(sub_scroll_width, sub_scroll_height))
|
||||||
|
|
||||||
|
tabdefs = [(MyTabId.INTERNAL, 'INTERNAL'), (MyTabId.EXTERNAL, "EXTERNAL")]
|
||||||
|
self.tab_row = TabRow(self.root, tabdefs, pos=(stab_h, sub_scroll_height),
|
||||||
|
size=(stab_width, stab_height), on_select_call=self.on_tab_select)
|
||||||
|
|
||||||
|
helpbtn_space = 20
|
||||||
|
helpbtn_v = stab_h+stab_width+helpbtn_space+120
|
||||||
|
helpbtn_h = sub_scroll_height+helpbtn_space
|
||||||
|
|
||||||
|
ba.buttonwidget(
|
||||||
|
parent=self.root,
|
||||||
|
position=(helpbtn_v, helpbtn_h),
|
||||||
|
size=(35, 35),
|
||||||
|
button_type="square",
|
||||||
|
label="?",
|
||||||
|
text_scale=1.5,
|
||||||
|
color=b_color,
|
||||||
|
textcolor=b_textcolor,
|
||||||
|
on_activate_call=Help)
|
||||||
|
|
||||||
|
def call_copy(): return CommonUtils._copy(self.selected_replay, self.tab_id)
|
||||||
|
self.share_button = ba.buttonwidget(
|
||||||
|
parent=self.root,
|
||||||
|
size=(b_width, b_height),
|
||||||
|
position=(btnh, btnv),
|
||||||
|
button_type="square",
|
||||||
|
label="Export\nReplay",
|
||||||
|
text_scale=tscl,
|
||||||
|
color=b_color,
|
||||||
|
textcolor=b_textcolor,
|
||||||
|
on_activate_call=call_copy)
|
||||||
|
|
||||||
|
btnv -= b_height + b_space_extra
|
||||||
|
sync_button = ba.buttonwidget(
|
||||||
|
parent=self.root,
|
||||||
|
size=(b_width, b_height),
|
||||||
|
position=(btnh, btnv),
|
||||||
|
button_type="square",
|
||||||
|
label="Sync\nReplay",
|
||||||
|
text_scale=tscl,
|
||||||
|
color=b_color,
|
||||||
|
textcolor=b_textcolor,
|
||||||
|
on_activate_call=CommonUtils.sync_confirmation)
|
||||||
|
|
||||||
|
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(
|
||||||
|
parent=self.root,
|
||||||
|
size=(b_width, b_height),
|
||||||
|
position=(btnh, btnv),
|
||||||
|
button_type="square",
|
||||||
|
label=ba.Lstr(resource=self._r + '.deleteReplayButtonText'),
|
||||||
|
text_scale=tscl,
|
||||||
|
color=b_color,
|
||||||
|
textcolor=b_textcolor,
|
||||||
|
on_activate_call=call_delete)
|
||||||
|
|
||||||
|
self.on_tab_select(MyTabId.INTERNAL)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
ba.playsound(ba.getsound('swish'))
|
ba.playsound(ba.getsound('swish'))
|
||||||
|
|
@ -403,4 +403,4 @@ class Loup(ba.Plugin):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def show_settings_ui(self, button):
|
def show_settings_ui(self, button):
|
||||||
Print("Open share replay tab in replay window to share your replays",color=blue)
|
Print("Open share replay tab in replay window to share your replays", color=blue)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue