diff --git a/plugins/utilities/mood_light.py b/plugins/utilities/mood_light.py index bebcbdf..c7036a1 100644 --- a/plugins/utilities/mood_light.py +++ b/plugins/utilities/mood_light.py @@ -14,184 +14,154 @@ from time import sleep if TYPE_CHECKING: from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union +class SettingWindow(ba.Window): + def __init__(self): + global Ldefault,Udefault + Ldefault=5 + Udefault=20 + + def increase_limit(self): + global Ldefault,Udefault + try: + if Udefault>=29 and self.selected=="upper": + ba.textwidget(edit=self.warn_text,text="Careful!You risk get blind beyond this point") + elif self.selected=="lower" and Ldefault>=-20: + ba.textwidget(edit=self.warn_text,text="") + + if self.selected=="lower": + Ldefault += 1 + ba.textwidget(edit=self.lower_text,text=str(Ldefault)) + elif self.selected=="upper": + Udefault+=1 + ba.textwidget(edit=self.upper_text,text=str(Udefault)) + except AttributeError: + ba.textwidget(edit=self.warn_text,text="Click on number to select it") + + def decrease_limit(self): + global Ldefault,Udefault + try: + if Ldefault<=-19 and self.selected == "lower": + ba.textwidget(edit=self.warn_text,text="DON'T BE AFRAID OF DARK,IT'S A PLACE WHERE YOU CAN HIDE") + elif (self.selected == "upper" and Udefault >=30) or (self.selected== "lower" and Ldefault>=-20): + ba.textwidget(edit=self.warn_text,text="") + + + if self.selected=="lower": + Ldefault -= 1 + ba.textwidget(edit=self.lower_text,text=str(Ldefault)) + elif self.selected=="upper": + Udefault -=1 + ba.textwidget(edit=self.upper_text,text=str(Udefault)) + except AttributeError: + ba.textwidget(edit=self.warn_text,text="Click on number to select it") + + def on_text_click(self,selected): + self.selected=selected + if selected=="upper": + ba.textwidget(edit=self.upper_text,color=(0,0,1)) + ba.textwidget(edit=self.lower_text,color=(1,1,1)) + elif selected=="lower": + ba.textwidget(edit=self.lower_text,color=(0,0,1)) + ba.textwidget(edit=self.upper_text,color=(1,1,1)) + else: + ba.screenmessage("this should't happen from on_text_click") + + def draw_ui(self): + self.uiscale=ba.app.ui.uiscale + + super().__init__( + root_widget=ba.containerwidget( + size=(800, 800), + on_outside_click_call=self.close, + transition="in_right",)) + + increase_button=ba.buttonwidget( + parent=self._root_widget, + position=(250,100), + size=(50,50), + label="+", + scale=2, + on_activate_call=self.increase_limit) + + decrease_button=ba.buttonwidget( + parent=self._root_widget, + position=(100,100), + size=(50,50), + scale=2, + label="-", + on_activate_call=self.decrease_limit) + + + self.lower_text=ba.textwidget( + parent=self._root_widget, + size=(200,100), + scale=2, + position=(100,300), + h_align="center", + v_align="center", + maxwidth=400.0, + text=str(Ldefault), + click_activate=True, + selectable=True) + + self.upper_text=ba.textwidget( + parent=self._root_widget, + size=(200,100), + scale=2, + position=(500,300), + h_align="center", + v_align="center", + maxwidth=400.0, + text=str(Udefault), + click_activate=True, + selectable=True) + + 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")) + + + self.warn_text=ba.textwidget( + parent=self._root_widget, + text="", + size=(400,100), + position=(200,500), + h_align="center", + v_align="center", + maxwidth=600) + + close_button=ba.buttonwidget( + parent=self._root_widget, + position=(700,650), + size=(100,100), + label=ba.Lstr(resource="cancelText"), + on_activate_call=self.close, + color=(0.8,0.2,0.2)) + ba.containerwidget(edit=self._root_widget, cancel_button=close_button) + + def close(self): + ba.screenmessage("closed") + ba.containerwidget(edit=self._root_widget, transition="out_right") + + + + + + + + + # ba_meta export plugin - -class ColorSchemeWindow(ba.Window): - def __init__(self, default_colors=((0.41, 0.39, 0.5), (0.5, 0.7, 0.25))): - self._default_colors = default_colors - self._color, self._highlight = ba.app.config.get("ColorScheme", (None, None)) - - self._last_color = self._color - self._last_highlight = self._highlight - - # Let's set the game's default colorscheme before opening the Window. - # Otherwise the colors in the Window are tinted as per the already - # applied custom colorscheme thereby making it impossible to visually - # differentiate between different colors. - # A hack to let players select any RGB color value through the UI, - # otherwise this is limited only to pro accounts. - ba.app.accounts_v1.have_pro = lambda: True - - self.draw_ui() - - def draw_ui(self): - # Most of the stuff here for drawing the UI is referred from the - # game's bastd/ui/profile/edit.py, and so there could be some - # cruft here due to my oversight. - uiscale = ba.app.ui.uiscale - self._width = width = 480.0 if uiscale is ba.UIScale.SMALL else 380.0 - self._x_inset = x_inset = 40.0 if uiscale is ba.UIScale.SMALL else 0.0 - self._height = height = ( - 275.0 - if uiscale is ba.UIScale.SMALL - else 288.0 - if uiscale is ba.UIScale.MEDIUM - else 300.0 - ) - spacing = 40 - self._base_scale = ( - 2.05 - if uiscale is ba.UIScale.SMALL - else 1.5 - if uiscale is ba.UIScale.MEDIUM - else 1.0 - ) - top_extra = 15 - - super().__init__( - root_widget=ba.containerwidget( - size=(width, height + top_extra), - on_outside_click_call=self.cancel_on_outside_click, - transition="in_right", - scale=self._base_scale, - stack_offset=(0, 15) if uiscale is ba.UIScale.SMALL else (0, 0), - ) - ) - - cancel_button = ba.buttonwidget( - parent=self._root_widget, - position=(52 + x_inset, height - 60), - size=(155, 60), - scale=0.8, - autoselect=True, - label=ba.Lstr(resource="cancelText"), - on_activate_call=self._cancel, - ) - ba.containerwidget(edit=self._root_widget, cancel_button=cancel_button) - - save_button = ba.buttonwidget( - parent=self._root_widget, - position=(width - (177 + x_inset), height - 110), - size=(155, 60), - autoselect=True, - scale=0.8, - label=ba.Lstr(resource="saveText"), - ) - ba.widget(edit=save_button, left_widget=cancel_button) - ba.buttonwidget(edit=save_button, on_activate_call=self.save) - ba.widget(edit=cancel_button, right_widget=save_button) - ba.containerwidget(edit=self._root_widget, start_button=save_button) - - reset_button = ba.buttonwidget( - parent=self._root_widget, - position=(width - (177 + x_inset), height - 60), - size=(155, 60), - color=(0.2, 0.5, 0.6), - autoselect=True, - scale=0.8, - label=ba.Lstr(resource="settingsWindowAdvanced.resetText"), - ) - ba.widget(edit=reset_button, left_widget=reset_button) - ba.buttonwidget(edit=reset_button, on_activate_call=self.reset) - ba.widget(edit=cancel_button, right_widget=reset_button) - ba.containerwidget(edit=self._root_widget, start_button=reset_button) - - v = height - 65.0 - v -= spacing * 3.0 - b_size = 80 - b_offs = 75 - - - ba.textwidget( - parent=self._root_widget, - h_align="center", - v_align="center", - position=(self._width * 0.5 - b_offs, v - 65), - size=(0, 0), - draw_controller=self._color_button, - text=ba.Lstr(resource="editProfileWindow.colorText"), - scale=0.7, - color=ba.app.ui.title_color, - maxwidth=120, - ) - - self._highlight_button = ba.buttonwidget( - parent=self._root_widget, - autoselect=True, - position=(self._width * 0.5 + b_offs - b_size * 0.5, v - 50), - size=(b_size, b_size), - color=self._last_highlight or self._default_colors[1], - label="", - button_type="square", - ) - - ba.buttonwidget( - edit=self._highlight_button, - on_activate_call=ba.Call(self._pick_color, "highlight"), - ) - ba.textwidget( - parent=self._root_widget, - h_align="center", - v_align="center", - position=(self._width * 0.5 + b_offs, v - 65), - size=(0, 0), - draw_controller=self._highlight_button, - text=ba.Lstr(resource="editProfileWindow.highlightText"), - scale=0.7, - color=ba.app.ui.title_color, - maxwidth=120, - ) - - def cancel_on_outside_click(self): - ba.playsound(ba.getsound("swish")) - self._cancel() - - def _cancel(self): - if self._last_color and self._last_highlight: - colorscheme = ColorScheme(self._last_color, self._last_highlight) - colorscheme.apply() - # Good idea to revert this back now so we do not break anything else. - ba.app.accounts_v1.have_pro = original_have_pro - ba.containerwidget(edit=self._root_widget, transition="out_right") - - def reset(self, transition_out=True): - if transition_out: - ba.playsound(ba.getsound("gunCocking")) - ba.app.config["ColorScheme"] = (None, None) - # Good idea to revert this back now so we do not break anything else. - ba.app.accounts_v1.have_pro = original_have_pro - ba.app.config.commit() - ba.containerwidget(edit=self._root_widget, transition="out_right") - - def save(self, transition_out=True): - if transition_out: - ba.playsound(ba.getsound("gunCocking")) - colorscheme = ColorScheme( - self._color or self._default_colors[0], - self._highlight or self._default_colors[1], - ) - ba.containerwidget(edit=self._root_widget, transition="out_right") - - - - - - - -class UwUuser(ba.Plugin): +class moodlight(ba.Plugin): Map._old_init = Map.__init__ - def on_plugin_manager_prompt(self): - ColorSchemeWindow() + + def on_app_running(self): + try: + SettingWindow().draw_ui() + except Exception as err: + ba.screenmessage(str(err)) +# def on_plugin_manager_prompt(self): +# SettingWindow() + def _new_init(self, vr_overlay_offset: Optional[Sequence[float]] = None) -> None: self._old_init(vr_overlay_offset) in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession) @@ -199,13 +169,12 @@ class UwUuser(ba.Plugin): gnode = _ba.getactivity().globalsnode - lowerlimit=5 - upperlimit=20 + def changetint(): ba.animate_array(gnode, 'tint', 3, { 0.0: gnode.tint, - 1.0: (random.randrange(lowerlimit,upperlimit)/10, random.randrange(lowerlimit,upperlimit)/10, random.randrange(lowerlimit, upperlimit)/10) + 1.0: (random.randrange(Ldefault,Udefault)/10, random.randrange(Ldefault,Udefault)/10, random.randrange(Ldefault,Udefault)/10) }) _ba.timer(0.3, changetint, repeat= True)