mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Add files via upload
This commit is contained in:
parent
1d5387d6dc
commit
083e60aa65
1 changed files with 155 additions and 44 deletions
|
|
@ -15,7 +15,6 @@ from bastd.ui.popup import PopupWindow
|
||||||
# mod by ʟօʊքɢǟʀօʊ
|
# mod by ʟօʊքɢǟʀօʊ
|
||||||
# export replays to mods folder and share with your friends or have a backup
|
# export replays to mods folder and share with your friends or have a backup
|
||||||
|
|
||||||
|
|
||||||
def Print(*args, color=None, top=None):
|
def Print(*args, color=None, top=None):
|
||||||
out = ""
|
out = ""
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
|
@ -23,7 +22,6 @@ def Print(*args, color=None, top=None):
|
||||||
out += a
|
out += a
|
||||||
ba.screenmessage(out, color=color, top=top)
|
ba.screenmessage(out, color=color, top=top)
|
||||||
|
|
||||||
|
|
||||||
def cprint(*args):
|
def cprint(*args):
|
||||||
out = ""
|
out = ""
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
|
@ -31,24 +29,27 @@ def cprint(*args):
|
||||||
out += a
|
out += a
|
||||||
_ba.chatmessage(out)
|
_ba.chatmessage(out)
|
||||||
|
|
||||||
|
title="SHARE REPLAY"
|
||||||
internal_dir = path.join("ba_data", "..", "..", "..", "files", "bombsquad_config", "replays" + sep)
|
internal_dir = path.join("ba_data", "..", "..", "..", "files", "bombsquad_config", "replays" + sep)
|
||||||
external_dir = path.join(_ba.env()["python_directory_user"], "replays"+sep)
|
external_dir = path.join(_ba.env()["python_directory_user"], "replays"+sep)
|
||||||
|
|
||||||
|
|
||||||
# colors
|
# colors
|
||||||
pink = (1, 0.2, 0.8)
|
pink = (1, 0.2, 0.8)
|
||||||
green = (0.4, 1, 0.4)
|
green = (0.4, 1, 0.4)
|
||||||
red = (1, 0, 0)
|
red = (1, 0, 0)
|
||||||
|
blue=(0.26, 0.65,0.94)
|
||||||
|
|
||||||
if not path.exists(external_dir):
|
if not path.exists(external_dir):
|
||||||
mkdir(external_dir)
|
mkdir(external_dir)
|
||||||
Print("You are ready to share replays", color=pink)
|
Print("You are ready to share replays", color=pink)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Help(PopupWindow):
|
class Help(PopupWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
uiscale = ba.app.ui.uiscale
|
uiscale = ba.app.ui.uiscale
|
||||||
self.width = 800
|
self.width = 1000
|
||||||
self.height = 300
|
self.height = 300
|
||||||
|
|
||||||
PopupWindow.__init__(self,
|
PopupWindow.__init__(self,
|
||||||
|
|
@ -58,7 +59,24 @@ class Help(PopupWindow):
|
||||||
|
|
||||||
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.6),
|
ba.textwidget(parent=self.root_widget, position=(0, self.height * 0.6),
|
||||||
text=f"•Replays are exported to\n {external_dir}\n•Importing replay and other features comming in v1.2")
|
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")
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
ba.playsound(ba.getsound('swish'))
|
||||||
|
ba.containerwidget(edit=self.root_widget, transition="out_right",)
|
||||||
|
|
||||||
|
class SyncConfirmation(PopupWindow):
|
||||||
|
def __init__(self):
|
||||||
|
uiscale = ba.app.ui.uiscale
|
||||||
|
self.width = 1000#h-hhhhhhhhhhh-----to completeh-hh-hhhhh-
|
||||||
|
self.height = 300
|
||||||
|
PopupWindow.__init__(self,
|
||||||
|
position=(0.0, 0.0),
|
||||||
|
size=(self.width, self.height),
|
||||||
|
scale=1.2,)
|
||||||
|
ba.containerwidget(edit=self.root_widget, on_outside_click_call=self.close)
|
||||||
|
ba.buttonwidget(parent=self.root_widget,label="cancel",size=e)
|
||||||
|
ba.buttonwidget(parent=self.root_widget,label="continue")
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
ba.playsound(ba.getsound('swish'))
|
ba.playsound(ba.getsound('swish'))
|
||||||
|
|
@ -67,17 +85,56 @@ class Help(PopupWindow):
|
||||||
|
|
||||||
class SettingWindow():
|
class SettingWindow():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
global internal
|
||||||
self.draw_ui()
|
self.draw_ui()
|
||||||
self.selected_widget = None
|
|
||||||
self.selected_name = None
|
self.selected_name = None
|
||||||
|
internal=True
|
||||||
def on_select_text(self, widget, name):
|
self.on_tab_select(internal)
|
||||||
if self.selected_widget is not None:
|
|
||||||
ba.textwidget(edit=self.selected_widget, color=(1, 1, 1))
|
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, 1, 0))
|
ba.textwidget(edit=widget, color=(1, 1, 0))
|
||||||
self.selected_name = name
|
self.selected_name=name
|
||||||
self.selected_widget = widget
|
|
||||||
|
|
||||||
|
def on_tab_select(self,_internal):
|
||||||
|
global internal
|
||||||
|
internal=_internal
|
||||||
|
if internal==True:
|
||||||
|
dir_list=listdir(internal_dir)
|
||||||
|
ba.buttonwidget(edit=self.share_button,label="Export",icon=ba.gettexture("upButton"),)
|
||||||
|
sel=self.internal_tab
|
||||||
|
unsel=self.external_tab
|
||||||
|
else:
|
||||||
|
dir_list=listdir(external_dir)
|
||||||
|
ba.buttonwidget(edit=self.share_button,label="Import",icon=ba.gettexture("downButton"),)
|
||||||
|
sel= self.external_tab
|
||||||
|
unsel= self.internal_tab
|
||||||
|
|
||||||
|
ba.buttonwidget(edit=sel,texture=ba.gettexture("circleShadow"))
|
||||||
|
ba.buttonwidget(edit=unsel,texture=ba.gettexture("nub"))
|
||||||
|
|
||||||
|
dir_list=sorted(dir_list)
|
||||||
|
existing_widgets=self.scroll2.get_children()
|
||||||
|
if existing_widgets:
|
||||||
|
for i in existing_widgets:
|
||||||
|
i.delete()
|
||||||
|
height = 900
|
||||||
|
for i in dir_list:
|
||||||
|
height -= 40
|
||||||
|
a = i
|
||||||
|
i = ba.textwidget(
|
||||||
|
parent=self.scroll2,
|
||||||
|
size=(500, 50),
|
||||||
|
text=i.split(".")[0],
|
||||||
|
position=(10, height),
|
||||||
|
selectable=True,
|
||||||
|
max_chars=40,
|
||||||
|
click_activate=True,)
|
||||||
|
ba.textwidget(edit=i, on_activate_call=ba.Call(self.on_select_text, i , a))
|
||||||
|
|
||||||
def draw_ui(self):
|
def draw_ui(self):
|
||||||
self.uiscale = ba.app.ui.uiscale
|
self.uiscale = ba.app.ui.uiscale
|
||||||
self.root = ba.Window(ba.containerwidget(
|
self.root = ba.Window(ba.containerwidget(
|
||||||
|
|
@ -91,28 +148,71 @@ class SettingWindow():
|
||||||
selectable=False,
|
selectable=False,
|
||||||
h_align="center",
|
h_align="center",
|
||||||
v_align="center",
|
v_align="center",
|
||||||
text="ShareReplay",
|
text=title,
|
||||||
color=green)
|
color=green)
|
||||||
|
|
||||||
ba.buttonwidget(
|
ba.buttonwidget(
|
||||||
parent=self.root,
|
parent=self.root,
|
||||||
position=(400, 580),
|
position=(450, 580),
|
||||||
size=(35, 35),
|
size=(35, 35),
|
||||||
texture=ba.gettexture("achievementEmpty"),
|
texture=ba.gettexture("achievementEmpty"),
|
||||||
label="",
|
label="",
|
||||||
on_activate_call=Help)
|
on_activate_call=Help)
|
||||||
|
|
||||||
ba.buttonwidget(
|
internal_tab_pos=85,400
|
||||||
|
internal_tab_size=120,80
|
||||||
|
external_tab_pos=85,300
|
||||||
|
external_tab_size=120,80
|
||||||
|
|
||||||
|
self.internal_tab=ba.buttonwidget(
|
||||||
parent=self.root,
|
parent=self.root,
|
||||||
position=(770, 460),
|
position=internal_tab_pos,
|
||||||
size=(90, 70),
|
size=internal_tab_size,
|
||||||
|
button_type="square",
|
||||||
|
label="internal",
|
||||||
|
text_scale=2,
|
||||||
|
color=blue,
|
||||||
|
texture=ba.gettexture("circleShadow"))
|
||||||
|
|
||||||
|
self.external_tab=ba.buttonwidget(
|
||||||
|
parent=self.root,
|
||||||
|
position=external_tab_pos,
|
||||||
|
size=external_tab_size,
|
||||||
|
button_type="square",
|
||||||
|
label="external",
|
||||||
|
text_scale=2,
|
||||||
|
color=blue,
|
||||||
|
texture=ba.gettexture("nub"))
|
||||||
|
|
||||||
|
ba.buttonwidget(edit=self.internal_tab,on_activate_call=ba.Call(self.on_tab_select,True))
|
||||||
|
ba.buttonwidget(edit=self.external_tab,on_activate_call=ba.Call(self.on_tab_select,False))
|
||||||
|
|
||||||
|
|
||||||
|
self.share_button=ba.buttonwidget(
|
||||||
|
parent=self.root,
|
||||||
|
position=(720, 400),
|
||||||
|
size=(110, 50),
|
||||||
scale=1.5,
|
scale=1.5,
|
||||||
|
button_type="square",
|
||||||
label="EXPORT",
|
label="EXPORT",
|
||||||
on_activate_call=self.export)
|
text_scale=2,
|
||||||
|
icon=ba.gettexture("upButton"),
|
||||||
|
on_activate_call=self.share)
|
||||||
|
|
||||||
|
sync_button=ba.buttonwidget(
|
||||||
|
parent=self.root,
|
||||||
|
position=(720, 300),
|
||||||
|
size=(110, 50),
|
||||||
|
scale=1.5,
|
||||||
|
button_type="square",
|
||||||
|
label="SYNC",
|
||||||
|
text_scale=2,
|
||||||
|
icon=ba.gettexture("ouyaYButton"),
|
||||||
|
on_activate_call=self.sync)
|
||||||
|
|
||||||
self.close_button = ba.buttonwidget(
|
self.close_button = ba.buttonwidget(
|
||||||
parent=self.root,
|
parent=self.root,
|
||||||
position=(820, 590),
|
position=(800, 590),
|
||||||
size=(35, 35),
|
size=(35, 35),
|
||||||
texture=ba.gettexture("crossOut"),
|
texture=ba.gettexture("crossOut"),
|
||||||
label="",
|
label="",
|
||||||
|
|
@ -124,33 +224,41 @@ class SettingWindow():
|
||||||
scroll = ba.scrollwidget(
|
scroll = ba.scrollwidget(
|
||||||
parent=self.root,
|
parent=self.root,
|
||||||
size=(500, 400),
|
size=(500, 400),
|
||||||
position=(200, 150))
|
position=(200, 100),)
|
||||||
self.scroll = ba.columnwidget(parent=scroll, size=(
|
self.scroll2 = ba.columnwidget(parent=scroll, size=(
|
||||||
500, 900), selection_loops_to_parent=True, single_depth=True)
|
500, 900))
|
||||||
|
|
||||||
height = 900
|
def share(self):
|
||||||
for i in listdir(internal_dir):
|
|
||||||
height -= 40
|
|
||||||
a = i
|
|
||||||
i = ba.textwidget(
|
|
||||||
parent=self.scroll,
|
|
||||||
size=(500, 50),
|
|
||||||
text=i.split(".")[0],
|
|
||||||
position=(10, height),
|
|
||||||
selectable=True,
|
|
||||||
max_chars=40,
|
|
||||||
click_activate=True,)
|
|
||||||
|
|
||||||
ba.textwidget(edit=i, on_activate_call=ba.Call(self.on_select_text, i, a))
|
|
||||||
|
|
||||||
def export(self):
|
|
||||||
if self.selected_name is None:
|
if self.selected_name is None:
|
||||||
Print("Select a replay", color=red)
|
Print("Select a replay", color=red)
|
||||||
return
|
return
|
||||||
copy(internal_dir+"/"+self.selected_name, external_dir+"/"+self.selected_name)
|
if internal:self.export()
|
||||||
|
else:self.importx()
|
||||||
|
|
||||||
# image={"texture":ba.gettexture("bombColor"),"tint_texture":None,"tint_color":None,"tint2_color":None})
|
# image={"texture":ba.gettexture("bombColor"),"tint_texture":None,"tint_color":None,"tint2_color":None})
|
||||||
|
|
||||||
|
def sync(self):
|
||||||
|
internal_list=listdir(internal_dir)
|
||||||
|
external_list=listdir(external_dir)
|
||||||
|
for i in internal_list:
|
||||||
|
copy(internal_dir+sep+i, external_dir+sep+i)
|
||||||
|
for i in external_list:
|
||||||
|
if i in internal_list:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
copy(external_dir+sep+i, internal_dir+sep+i)
|
||||||
|
Print("Synced all replays",color=pink)
|
||||||
|
|
||||||
|
def export(self):
|
||||||
|
copy(internal_dir+self.selected_name, external_dir+self.selected_name)
|
||||||
|
cprint(internal_dir+self.selected_name)
|
||||||
Print(self.selected_name[0:-4]+" exported", top=True, color=pink)
|
Print(self.selected_name[0:-4]+" exported", top=True, color=pink)
|
||||||
|
|
||||||
|
def importx(self):
|
||||||
|
copy(external_dir+self.selected_name, internal_dir+self.selected_name)
|
||||||
|
cprint(external_dir+self.selected_name)
|
||||||
|
Print(self.selected_name[0:-4]+" imported", top=True, color=green)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
ba.playsound(ba.getsound('swish'))
|
ba.playsound(ba.getsound('swish'))
|
||||||
ba.containerwidget(edit=self.root, transition="out_right",)
|
ba.containerwidget(edit=self.root, transition="out_right",)
|
||||||
|
|
@ -175,7 +283,7 @@ def new_init(self, transition="in_right", origin_widget=None):
|
||||||
color=green,
|
color=green,
|
||||||
icon=ba.gettexture('usersButton'),
|
icon=ba.gettexture('usersButton'),
|
||||||
iconscale=1.5,
|
iconscale=1.5,
|
||||||
label="SHARE REPLAY",
|
label=title,
|
||||||
on_activate_call=SettingWindow)
|
on_activate_call=SettingWindow)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -190,3 +298,6 @@ class Loup(ba.Plugin):
|
||||||
|
|
||||||
def show_settings_ui(self, button):
|
def show_settings_ui(self, button):
|
||||||
SettingWindow()
|
SettingWindow()
|
||||||
|
|
||||||
|
def on_plugin_manager_prompt(self):
|
||||||
|
SettingWindow()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue