UI improvements

This commit is contained in:
Loup 2022-11-19 08:44:56 +05:30 committed by GitHub
parent 7b14938478
commit bc15767e5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,23 +29,26 @@ def cprint(*args):
out += a out += a
_ba.chatmessage(out) _ba.chatmessage(out)
title="SHARE REPLAY" 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)
tab_sel_texture=ba.gettexture("buttonSquare")
tab_unsel_texture=ba.gettexture("chestIconEmpty")
# 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) blue=(0.26, 0.65,0.94)
blue_highlight= (0.4, 0.7,1)
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
@ -67,7 +68,6 @@ class Help(PopupWindow):
ba.playsound(ba.getsound('swish')) ba.playsound(ba.getsound('swish'))
ba.containerwidget(edit=self.root_widget, transition="out_right",) ba.containerwidget(edit=self.root_widget, transition="out_right",)
class SyncConfirmation(PopupWindow): class SyncConfirmation(PopupWindow):
def __init__(self): def __init__(self):
uiscale = ba.app.ui.uiscale uiscale = ba.app.ui.uiscale
@ -77,13 +77,14 @@ class SyncConfirmation(PopupWindow):
position=(0.0, 0.0), position=(0.0, 0.0),
size=(self.width, self.height), size=(self.width, self.height),
scale=1.2,) scale=1.2,)
ba.containerwidget(edit=self.root_widget, on_outside_click_call=self.close)
ba.textwidget(parent=self.root_widget, position=(30, self.height * 0.8), ba.textwidget(parent=self.root_widget, position=(30, self.height * 0.8),
text=" Are you sure you want to continue\n\nWARNING:replays with same name in mods folder\n will be overwritten") text=" Are you sure you want to continue\n\nWARNING:replays with same name in mods folder\n will be overwritten")
ba.buttonwidget(parent=self.root_widget, label="CANCEL", size=(200, 80), cancel=ba.buttonwidget(parent=self.root_widget,label=ba.Lstr(resource='cancelText'),size=(200,80),position=(80,50),on_activate_call=self.close)
color=red, position=(80, 50), on_activate_call=self.close)
ba.buttonwidget(parent=self.root_widget, label="continue", size=(200, 80), ba.buttonwidget(parent=self.root_widget,label=ba.Lstr(resource='okText'),size=(200,80),position=(300,50),color=green,on_activate_call=SettingWindow.sync)
position=(300, 50), on_activate_call=SettingWindow.sync)
ba.containerwidget(edit=self.root_widget, on_outside_click_call=self.close,cancel_button=cancel)
def close(self): def close(self):
ba.playsound(ba.getsound('swish')) ba.playsound(ba.getsound('swish'))
@ -94,6 +95,7 @@ class SettingWindow():
def __init__(self): def __init__(self):
global internal global internal
self.draw_ui() self.draw_ui()
ba.containerwidget(edit=self.root,cancel_button=self.close_button)
self.selected_name = None self.selected_name = None
internal=True internal=True
self.on_tab_select(internal) self.on_tab_select(internal)
@ -105,6 +107,7 @@ class SettingWindow():
ba.textwidget(edit=widget, color=(1, 1, 0)) ba.textwidget(edit=widget, color=(1, 1, 0))
self.selected_name=name self.selected_name=name
def on_tab_select(self,_internal): def on_tab_select(self,_internal):
global internal global internal
internal=_internal internal=_internal
@ -115,13 +118,12 @@ class SettingWindow():
unsel=self.external_tab unsel=self.external_tab
else: else:
dir_list=listdir(external_dir) dir_list=listdir(external_dir)
ba.buttonwidget(edit=self.share_button, label="IMPORT", ba.buttonwidget(edit=self.share_button,label="IMPORT",icon=ba.gettexture("downButton"),)
icon=ba.gettexture("downButton"),)
sel= self.external_tab sel= self.external_tab
unsel= self.internal_tab unsel= self.internal_tab
ba.buttonwidget(edit=sel, texture=ba.gettexture("circleShadow")) ba.buttonwidget(edit=sel,texture=tab_sel_texture,color=blue,size=(120,80))
ba.buttonwidget(edit=unsel, texture=ba.gettexture("nub")) ba.buttonwidget(edit=unsel,texture=tab_unsel_texture,color=blue,size=(120,100))
dir_list=sorted(dir_list) dir_list=sorted(dir_list)
existing_widgets=self.scroll2.get_children() existing_widgets=self.scroll2.get_children()
@ -147,10 +149,19 @@ class SettingWindow():
self.root = ba.Window(ba.containerwidget( self.root = ba.Window(ba.containerwidget(
size=(900, 670), on_outside_click_call=self.close, transition="in_right")).get_root_widget() size=(900, 670), on_outside_click_call=self.close, transition="in_right")).get_root_widget()
self.close_button = ba.buttonwidget(
parent=self.root,
position=(90, 560),
button_type='backSmall',
size=(60, 60),
label=ba.charstr(ba.SpecialChar.BACK),
scale=1.5,
on_activate_call=self.close)
ba.textwidget( ba.textwidget(
parent=self.root, parent=self.root,
size=(200, 100), size=(200, 100),
position=(150, 550), position=(350, 550),
scale=2, scale=2,
selectable=False, selectable=False,
h_align="center", h_align="center",
@ -160,7 +171,7 @@ class SettingWindow():
ba.buttonwidget( ba.buttonwidget(
parent=self.root, parent=self.root,
position=(450, 580), position=(650, 580),
size=(35, 35), size=(35, 35),
texture=ba.gettexture("achievementEmpty"), texture=ba.gettexture("achievementEmpty"),
label="", label="",
@ -178,8 +189,8 @@ class SettingWindow():
button_type="square", button_type="square",
label="INTERNAL", label="INTERNAL",
text_scale=2, text_scale=2,
color=blue, color=blue_highlight,
texture=ba.gettexture("circleShadow")) texture=tab_sel_texture)
self.external_tab=ba.buttonwidget( self.external_tab=ba.buttonwidget(
parent=self.root, parent=self.root,
@ -189,11 +200,12 @@ class SettingWindow():
label="EXTERNAL", label="EXTERNAL",
text_scale=2, text_scale=2,
color=blue, color=blue,
texture=ba.gettexture("nub")) texture=tab_unsel_texture)
ba.buttonwidget(edit=self.internal_tab,on_activate_call=ba.Call(self.on_tab_select,True)) 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)) ba.buttonwidget(edit=self.external_tab,on_activate_call=ba.Call(self.on_tab_select,False))
self.share_button=ba.buttonwidget( self.share_button=ba.buttonwidget(
parent=self.root, parent=self.root,
position=(720, 400), position=(720, 400),
@ -216,17 +228,6 @@ class SettingWindow():
icon=ba.gettexture("ouyaYButton"), icon=ba.gettexture("ouyaYButton"),
on_activate_call=SyncConfirmation) on_activate_call=SyncConfirmation)
self.close_button = ba.buttonwidget(
parent=self.root,
position=(800, 590),
size=(35, 35),
texture=ba.gettexture("crossOut"),
label="",
scale=2,
color=(1, 0.2, 0.2),
extra_touch_border_scale=3,
on_activate_call=self.close)
scroll = ba.scrollwidget( scroll = ba.scrollwidget(
parent=self.root, parent=self.root,
size=(500, 400), size=(500, 400),
@ -238,10 +239,8 @@ class SettingWindow():
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
if internal: if internal:self.export()
self.export() else:self.importx()
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})