diff --git a/assets/src/ba_data/python/ba/_plugin.py b/assets/src/ba_data/python/ba/_plugin.py index b9812980..2aad94b1 100644 --- a/assets/src/ba_data/python/ba/_plugin.py +++ b/assets/src/ba_data/python/ba/_plugin.py @@ -48,13 +48,14 @@ class PluginSubsystem: available=True, ) ) - if class_path not in plugstates: - # Go ahead and enable new plugins by default, but we'll - # inform the user that they need to restart to pick them up. - # they can also disable them in settings so they never load. - plugstates[class_path] = {'enabled': True} - config_changed = True - found_new = True + if _ba.app.config['Auto Enable New Plugins'] is True: + if class_path not in plugstates: + # Go ahead and enable new plugins by default, but we'll + # inform the user that they need to restart to pick them up. + # they can also disable them in settings so they never load. + plugstates[class_path] = {'enabled': True} + config_changed = True + found_new = True plugs.potential_plugins.sort(key=lambda p: p.class_path) diff --git a/assets/src/ba_data/python/bastd/ui/gather/manualtab.py b/assets/src/ba_data/python/bastd/ui/gather/manualtab.py index 17207994..77576c06 100644 --- a/assets/src/ba_data/python/bastd/ui/gather/manualtab.py +++ b/assets/src/ba_data/python/bastd/ui/gather/manualtab.py @@ -257,6 +257,7 @@ class ManualGatherTab(GatherTab): autoselect=True, v_align='center', scale=1.0, + maxwidth=380, size=(420, 60), ) ba.widget(edit=self._join_by_address_text, down_widget=txt) diff --git a/assets/src/ba_data/python/bastd/ui/gather/publictab.py b/assets/src/ba_data/python/bastd/ui/gather/publictab.py index e874af6b..a1e083c3 100644 --- a/assets/src/ba_data/python/bastd/ui/gather/publictab.py +++ b/assets/src/ba_data/python/bastd/ui/gather/publictab.py @@ -571,6 +571,7 @@ class PublicGatherTab(GatherTab): h_align='left', v_align='center', editable=True, + maxwidth=310, description=filter_txt, ) ba.widget(edit=self._filter_text, up_widget=self._join_text) diff --git a/assets/src/ba_data/python/bastd/ui/settings/advanced.py b/assets/src/ba_data/python/bastd/ui/settings/advanced.py index 940cd161..cde5d7b8 100644 --- a/assets/src/ba_data/python/bastd/ui/settings/advanced.py +++ b/assets/src/ba_data/python/bastd/ui/settings/advanced.py @@ -667,12 +667,12 @@ class AdvancedSettingsWindow(ba.Window): appinvite.handle_app_invites_press() def _on_plugins_button_press(self) -> None: - from bastd.ui.settings.plugins import PluginSettingsWindow + from bastd.ui.settings.plugins import PluginWindow self._save_state() ba.containerwidget(edit=self._root_widget, transition='out_left') ba.app.ui.set_main_menu_window( - PluginSettingsWindow( + PluginWindow( origin_widget=self._plugins_button ).get_root_widget() ) diff --git a/assets/src/ba_data/python/bastd/ui/settings/plugins.py b/assets/src/ba_data/python/bastd/ui/settings/plugins.py index a8197551..2a5e4ffe 100644 --- a/assets/src/ba_data/python/bastd/ui/settings/plugins.py +++ b/assets/src/ba_data/python/bastd/ui/settings/plugins.py @@ -1,6 +1,6 @@ # Released under the MIT License. See LICENSE for details. # -"""Plugin settings UI.""" +"""Plugin Window UI.""" from __future__ import annotations @@ -12,7 +12,7 @@ if TYPE_CHECKING: pass -class PluginSettingsWindow(ba.Window): +class PluginWindow(ba.Window): """Window for configuring plugins.""" def __init__( @@ -106,6 +106,27 @@ class PluginSettingsWindow(ba.Window): size=(60, 60), label=ba.charstr(ba.SpecialChar.BACK), ) + settings_button_x = 670 if uiscale is ba.UIScale.SMALL else 570 + self._settings_button = ba.buttonwidget( + parent=self._root_widget, + position=(settings_button_x, self._height - 60), + size=(40, 40), + label='', + on_activate_call=self._open_settings, + ) + + ba.imagewidget( + parent=self._root_widget, + position=(settings_button_x + 3, self._height - 60), + size=(35, 35), + texture=ba.gettexture('settingsIcon'), + ) + + ba.widget( + edit=self._settings_button, + up_widget=self._settings_button, + right_widget=self._settings_button + ) self._scrollwidget = ba.scrollwidget( parent=self._root_widget, @@ -185,6 +206,7 @@ class PluginSettingsWindow(ba.Window): edit=check, up_widget=self._back_button, left_widget=self._back_button, + right_widget=self._settings_button ) if button is not None: ba.widget(edit=button, up_widget=self._back_button) @@ -212,6 +234,18 @@ class PluginSettingsWindow(ba.Window): plugstate['enabled'] = value ba.app.config.commit() + def _open_settings(self) -> None: + # pylint: disable=cyclic-import + from bastd.ui.settings.pluginsettings import PluginSettingsWindow + ba.playsound(ba.getsound('swish')) + + ba.containerwidget( + edit=self._root_widget,transition='out_left' + ) + ba.app.ui.set_main_menu_window( + PluginSettingsWindow(transition='in_right').get_root_widget() + ) + def _save_state(self) -> None: pass diff --git a/assets/src/ba_data/python/bastd/ui/settings/pluginsettings.py b/assets/src/ba_data/python/bastd/ui/settings/pluginsettings.py new file mode 100644 index 00000000..a16b9377 --- /dev/null +++ b/assets/src/ba_data/python/bastd/ui/settings/pluginsettings.py @@ -0,0 +1,169 @@ +# Released under the MIT License. See LICENSE for details. +# +"""Plugin Settings UI.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +import ba + +if TYPE_CHECKING: + pass + +class PluginSettingsWindow(ba.Window): + """Plugin Settings Window""" + + def __init__( + self, + transition: str = 'in_right' + ): + + scale_origin: tuple[float, float] | None + self._transition_out = 'out_right' + scale_origin = None + + uiscale = ba.app.ui.uiscale + width = 470.0 if uiscale is ba.UIScale.SMALL else 470.0 + height = ( + 365.0 + if uiscale is ba.UIScale.SMALL + else 300.0 + if uiscale is ba.UIScale.MEDIUM + else 370.0 + ) + top_extra = 10 if uiscale is ba.UIScale.SMALL else 0 + + super().__init__( + root_widget=ba.containerwidget( + size=(width, height + top_extra), + transition=transition, + toolbar_visibility='menu_minimal', + scale_origin_stack_offset=scale_origin, + scale=( + 2.06 + if uiscale is ba.UIScale.SMALL + else 1.4 + if uiscale is ba.UIScale.MEDIUM + else 1.0 + ), + stack_offset=(0, -25) + if uiscale is ba.UIScale.SMALL + else (0, 0), + ) + ) + + self._back_button = ba.buttonwidget( + parent=self._root_widget, + position=(53, height - 60), + size=(60, 60), + scale=0.8, + autoselect=True, + label=ba.charstr(ba.SpecialChar.BACK), + button_type='backSmall', + on_activate_call=self._do_back + ) + ba.containerwidget( + edit=self._root_widget, cancel_button=self._back_button + ) + + self._title_text = ba.textwidget( + parent=self._root_widget, + position=(0, height - 52), + size=(width, 25), + text=ba.Lstr(resource='pluginSettingsText'), + color=ba.app.ui.title_color, + h_align='center', + v_align='top' + ) + + self._y_position = 170 if uiscale is ba.UIScale.MEDIUM else 205 + self._enable_plugins_button = ba.buttonwidget( + parent=self._root_widget, + position=(65,self._y_position), + size=(350, 60), + autoselect=True, + label=ba.Lstr(resource='pluginsEnableAllText'), + text_scale=1.0, + on_activate_call=self._enable_all_plugins, + ) + + self._y_position -= 70 + self._disable_plugins_button = ba.buttonwidget( + parent=self._root_widget, + position=(65,self._y_position), + size=(350, 60), + autoselect=True, + label=ba.Lstr(resource='pluginsDisableAllText'), + text_scale=1.0, + on_activate_call=self._disable_all_plugins, + ) + + self._y_position -= 70 + self._enable_new_plugins_check_box = ba.checkboxwidget( + parent=self._root_widget, + position=(65, self._y_position), + size=(350, 60), + value=ba.app.config['Auto Enable New Plugins'], + text=ba.Lstr(resource='AutoEnableNewPluginsText'), + scale=1.0, + maxwidth=430, + on_value_change_call=self._update_value + ) + + ba.widget( + edit=self._back_button, + down_widget=self._enable_plugins_button + ) + + ba.widget( + edit=self._disable_plugins_button, + left_widget=self._disable_plugins_button + ) + + ba.widget( + edit=self._enable_new_plugins_check_box, + left_widget=self._enable_new_plugins_check_box, + right_widget=self._enable_new_plugins_check_box, + down_widget=self._enable_new_plugins_check_box + ) + + def _enable_all_plugins(self) -> None: + cfg = ba.app.config + plugs = cfg['Plugins'] + for plug in plugs: + plugs[plug]['enabled'] = True + cfg.apply_and_commit() + + ba.screenmessage( + ba.Lstr(resource='settingsWindowAdvanced.mustRestartText'), + color=(1.0, 0.5, 0.0), + ) + + def _disable_all_plugins(self) -> None: + cfg = ba.app.config + plugs = cfg['Plugins'] + for plug in plugs: + plugs[plug]['enabled'] = False + cfg.apply_and_commit() + + ba.screenmessage( + ba.Lstr(resource='settingsWindowAdvanced.mustRestartText'), + color=(1.0, 0.5, 0.0), + ) + + def _update_value(self, val: bool) -> None: + cfg = ba.app.config + cfg['Auto Enable New Plugins'] = val + cfg.apply_and_commit() + + def _do_back(self) -> None: + # pylint: disable=cyclic-import + from bastd.ui.settings.plugins import PluginWindow + + ba.containerwidget( + edit=self._root_widget, transition=self._transition_out + ) + ba.app.ui.set_main_menu_window( + PluginWindow(transition='in_left').get_root_widget() + )