mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Quality of life improvements
This commit is contained in:
parent
8868902bb7
commit
cd9658c4dd
1 changed files with 90 additions and 64 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
# ba_meta require api 7
|
# ba_meta require api 7
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import TYPE_CHECKING, cast
|
from typing import TYPE_CHECKING, cast
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union
|
||||||
|
|
||||||
import ba,_ba
|
import ba,_ba
|
||||||
import random
|
import random
|
||||||
|
|
@ -9,14 +11,31 @@ from bastd import mainmenu
|
||||||
from bastd.ui.party import PartyWindow
|
from bastd.ui.party import PartyWindow
|
||||||
from bastd.gameutils import SharedObjects
|
from bastd.gameutils import SharedObjects
|
||||||
from time import sleep
|
from time import sleep
|
||||||
if TYPE_CHECKING:
|
|
||||||
from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union
|
|
||||||
|
|
||||||
# mood light plugin by ʟօʊքɢǟʀօʊ
|
"""mood light plugin by ʟօʊքɢǟʀօʊ
|
||||||
|
type ml in chat or use plugin manager to open settings"""
|
||||||
|
|
||||||
|
def Print(*args):
|
||||||
|
out=" ".join(args)
|
||||||
|
ba.screenmessage(out)
|
||||||
|
|
||||||
def Print(arg1, arg2="", arg3=""):
|
def cprint(*args):
|
||||||
ba.screenmessage(str(arg1)+str(arg2)+str(arg3))
|
out="\n".join(args)
|
||||||
|
_ba.chatmessage(out)
|
||||||
|
#
|
||||||
|
#class printerr:#for debugging
|
||||||
|
# #def __init__(self):
|
||||||
|
# global errcounter
|
||||||
|
# errcounter=1
|
||||||
|
# def __enter__(self):
|
||||||
|
# _ba.chatmessage("executing")
|
||||||
|
#
|
||||||
|
# def __exit__(self, exc_type, exc_value, exc_tb):
|
||||||
|
# cprint(exc_type, exc_value, exc_tb)
|
||||||
|
# if not(exc_type==None):
|
||||||
|
# cprint(exc_type, exc_value, exc_tb)
|
||||||
|
# else:
|
||||||
|
# cprint("Executed sucessfully","No error")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -32,6 +51,7 @@ try:
|
||||||
except:
|
except:
|
||||||
ba.app.config["moodlightEnabled"]=True
|
ba.app.config["moodlightEnabled"]=True
|
||||||
ba.app.config.commit()
|
ba.app.config.commit()
|
||||||
|
loop=True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -98,6 +118,7 @@ class SettingWindow(ba.Window):
|
||||||
size=(200, 100),
|
size=(200, 100),
|
||||||
position=(150, 550),
|
position=(150, 550),
|
||||||
scale=2,
|
scale=2,
|
||||||
|
selectable=False,
|
||||||
h_align="center",
|
h_align="center",
|
||||||
v_align="center",
|
v_align="center",
|
||||||
text="Mood light settings",
|
text="Mood light settings",
|
||||||
|
|
@ -111,24 +132,26 @@ class SettingWindow(ba.Window):
|
||||||
color=(1,0,0) if loop else (0,1,0),
|
color=(1,0,0) if loop else (0,1,0),
|
||||||
label="DISABLE" if loop else "ENABLE",
|
label="DISABLE" if loop else "ENABLE",
|
||||||
on_activate_call=self.on_enableButton_press)
|
on_activate_call=self.on_enableButton_press)
|
||||||
|
|
||||||
increase_button = ba.buttonwidget(
|
|
||||||
|
save_button = ba.buttonwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(600, 100),
|
position=(520, 470),
|
||||||
size=(5, 1),
|
size=(90, 70),
|
||||||
scale=3.5,
|
scale=1.5,
|
||||||
extra_touch_border_scale=2.5,
|
label="SAVE",
|
||||||
icon=ba.gettexture("upButton"),
|
on_activate_call=self.save_settings)
|
||||||
on_activate_call=self.increase_limit)
|
|
||||||
|
self.close_button = ba.buttonwidget(
|
||||||
decrease_button = ba.buttonwidget(
|
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=(100, 100),
|
position=(550, 590),
|
||||||
size=(5, 1),
|
size=(35, 35),
|
||||||
scale=3.5,
|
icon=ba.gettexture("crossOut"),
|
||||||
extra_touch_border_scale=2.5,
|
icon_color=(1, 0.2, 0.2),
|
||||||
icon=ba.gettexture("downButton"),
|
scale=2,
|
||||||
on_activate_call=self.decrease_limit)
|
color=(1, 0.2, 0.2),
|
||||||
|
extra_touch_border_scale=5,
|
||||||
|
on_activate_call=self.close)
|
||||||
|
|
||||||
self.lower_text = ba.textwidget(
|
self.lower_text = ba.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
|
|
@ -169,6 +192,24 @@ class SettingWindow(ba.Window):
|
||||||
h_align="center",
|
h_align="center",
|
||||||
v_align="center",
|
v_align="center",
|
||||||
text="Limit brightness")
|
text="Limit brightness")
|
||||||
|
|
||||||
|
decrease_button = ba.buttonwidget(
|
||||||
|
parent=self._root_widget,
|
||||||
|
position=(100, 100),
|
||||||
|
size=(5, 1),
|
||||||
|
scale=3.5,
|
||||||
|
extra_touch_border_scale=2.5,
|
||||||
|
icon=ba.gettexture("downButton"),
|
||||||
|
on_activate_call=self.decrease_limit)
|
||||||
|
|
||||||
|
increase_button = ba.buttonwidget(
|
||||||
|
parent=self._root_widget,
|
||||||
|
position=(600, 100),
|
||||||
|
size=(5, 1),
|
||||||
|
scale=3.5,
|
||||||
|
extra_touch_border_scale=2.5,
|
||||||
|
icon=ba.gettexture("upButton"),
|
||||||
|
on_activate_call=self.increase_limit)
|
||||||
|
|
||||||
self.warn_text = ba.textwidget(
|
self.warn_text = ba.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
|
|
@ -177,27 +218,18 @@ class SettingWindow(ba.Window):
|
||||||
position=(150, 300),
|
position=(150, 300),
|
||||||
h_align="center",
|
h_align="center",
|
||||||
v_align="center",
|
v_align="center",
|
||||||
maxwidth=600)
|
maxwidth=600)
|
||||||
|
|
||||||
self.close_button = ba.buttonwidget(
|
|
||||||
parent=self._root_widget,
|
|
||||||
position=(550, 590),
|
|
||||||
size=(35, 35),
|
|
||||||
icon=ba.gettexture("crossOut"),
|
|
||||||
icon_color=(1, 0.2, 0.2),
|
|
||||||
scale=2,
|
|
||||||
color=(1, 0.2, 0.2),
|
|
||||||
extra_touch_border_scale=5,
|
|
||||||
on_activate_call=self.close)
|
|
||||||
|
|
||||||
save_button = ba.buttonwidget(
|
|
||||||
parent=self._root_widget,
|
|
||||||
position=(520, 470),
|
|
||||||
size=(90, 70),
|
|
||||||
scale=1.5,
|
|
||||||
label="SAVE",
|
|
||||||
on_activate_call=self.save_settings)
|
|
||||||
|
|
||||||
|
#++++++++++++++++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)
|
||||||
|
ba.widget(edit=save_button,up_widget=self.close_button,down_widget=self.upper_text,left_widget=self.enable_button,right_widget=self.enable_button)
|
||||||
|
ba.widget(edit=self.close_button,up_widget=increase_button,down_widget=save_button,left_widget=self.enable_button,right_widget=save_button)
|
||||||
|
ba.widget(edit=self.lower_text,up_widget=self.enable_button,down_widget=decrease_button,left_widget=self.upper_text,right_widget=self.upper_text)
|
||||||
|
ba.widget(edit=self.upper_text,up_widget=save_button,down_widget=increase_button,left_widget=self.lower_text,right_widget=self.lower_text)
|
||||||
|
ba.widget(edit=decrease_button,up_widget=self.lower_text,down_widget=self.enable_button,left_widget=increase_button,right_widget=increase_button)
|
||||||
|
ba.widget(edit=increase_button,up_widget=self.upper_text,down_widget=self.close_button,left_widget=decrease_button,right_widget=decrease_button)
|
||||||
|
#--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
ba.textwidget(edit=self.upper_text, on_activate_call=ba.Call(self.on_text_click, "upper"))
|
ba.textwidget(edit=self.upper_text, on_activate_call=ba.Call(self.on_text_click, "upper"))
|
||||||
ba.textwidget(edit=self.lower_text, on_activate_call=ba.Call(self.on_text_click, "lower"))
|
ba.textwidget(edit=self.lower_text, on_activate_call=ba.Call(self.on_text_click, "lower"))
|
||||||
|
|
||||||
|
|
@ -210,9 +242,9 @@ class SettingWindow(ba.Window):
|
||||||
color=(0,1,0)
|
color=(0,1,0)
|
||||||
elif not loop:
|
elif not loop:
|
||||||
loop=True
|
loop=True
|
||||||
label="DISABLE"
|
label="DISABLE"
|
||||||
color=(1,0,0)
|
color=(1,0,0)
|
||||||
|
Print("Restart level to enable")
|
||||||
ba.app.config["moodlightEnabled"]=loop
|
ba.app.config["moodlightEnabled"]=loop
|
||||||
ba.app.config.commit()
|
ba.app.config.commit()
|
||||||
ba.buttonwidget(edit=self.enable_button,label=label,color=color)
|
ba.buttonwidget(edit=self.enable_button,label=label,color=color)
|
||||||
|
|
@ -226,39 +258,33 @@ class SettingWindow(ba.Window):
|
||||||
def close(self):
|
def close(self):
|
||||||
ba.containerwidget(edit=self._root_widget, transition="out_right",)
|
ba.containerwidget(edit=self._root_widget, transition="out_right",)
|
||||||
|
|
||||||
Map._old_init = Map.__init__
|
|
||||||
|
|
||||||
def new_chat_message(msg: Union[str, ba.Lstr], clients:Sequence[int] = None, sender_override: str = None):
|
def new_chat_message(msg: Union[str, ba.Lstr], clients:Sequence[int] = None, sender_override: str = None):
|
||||||
old_fcm(msg, clients, sender_override)
|
old_fcm(msg, clients, sender_override)
|
||||||
if msg == 'ml':
|
if msg == 'ml':
|
||||||
try:
|
try:
|
||||||
Ldefault, Udefault=ba.app.config.get("moodlightingSettings")
|
Ldefault, Udefault=ba.app.config.get("moodlightingSettings")
|
||||||
SettingWindow()
|
SettingWindow()
|
||||||
_ba.chatmessage("Mood light settings opened")
|
cprint("Mood light settings opened")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
Print(err)
|
Print(err)
|
||||||
|
|
||||||
old_fcm = _ba.chatmessage
|
old_fcm = _ba.chatmessage
|
||||||
_ba.chatmessage = new_chat_message
|
_ba.chatmessage = new_chat_message
|
||||||
|
_ba.set_party_icon_always_visible(True)
|
||||||
|
Map._old_init = Map.__init__
|
||||||
|
|
||||||
# ba_meta export plugin
|
# ba_meta export plugin
|
||||||
|
|
||||||
|
|
||||||
class moodlight(ba.Plugin):
|
class moodlight(ba.Plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_app_running(self):
|
def on_app_running(self):
|
||||||
try:
|
|
||||||
_ba.show_progress_bar()
|
_ba.show_progress_bar()
|
||||||
|
|
||||||
pass
|
|
||||||
except Exception as err:
|
|
||||||
Print(err)
|
|
||||||
|
|
||||||
def on_plugin_manager_prompt(self):#called by plugin manager
|
def on_plugin_manager_prompt(self):#called by plugin manager
|
||||||
SettingWindow()
|
SettingWindow()
|
||||||
|
|
||||||
def _new_init(self, vr_overlay_offset: Optional[Sequence[float]] = None) -> None:
|
def _new_init(self, vr_overlay_offset: Optional[Sequence[float]] = None) -> None:
|
||||||
self._old_init(vr_overlay_offset)
|
self._old_init(vr_overlay_offset)
|
||||||
in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession)
|
in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession)
|
||||||
|
|
@ -269,7 +295,7 @@ class moodlight(ba.Plugin):
|
||||||
default_tint=(1.100000023841858, 1.0, 0.8999999761581421)
|
default_tint=(1.100000023841858, 1.0, 0.8999999761581421)
|
||||||
transition_duration=1.0#for future improvements
|
transition_duration=1.0#for future improvements
|
||||||
|
|
||||||
def changetint():
|
def changetint():
|
||||||
if loop:
|
if loop:
|
||||||
Range = (random.randrange(Ldefault, Udefault)/10, random.randrange(Ldefault,
|
Range = (random.randrange(Ldefault, Udefault)/10, random.randrange(Ldefault,
|
||||||
Udefault)/10, random.randrange(Ldefault, Udefault)/10)
|
Udefault)/10, random.randrange(Ldefault, Udefault)/10)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue