mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Fixed some UI tracebacks and code
Regarding the plugin manager being closed before loading completely. Had to check widget.exists() before performing any action. And about the spinners, I made a function to safely control it because it was also tracebacking if you delete it before it tries to hide itself. And for the code, I cleaned some indents.
This commit is contained in:
parent
6e3f11db25
commit
f2f14563d4
1 changed files with 79 additions and 68 deletions
|
|
@ -850,12 +850,13 @@ class ChangelogWindow(popup.PopupWindow):
|
||||||
self._transition_out = 'out_scale'
|
self._transition_out = 'out_scale'
|
||||||
transition = 'in_scale'
|
transition = 'in_scale'
|
||||||
|
|
||||||
self._root_widget = bui.containerwidget(size=(width, height),
|
self._root_widget = bui.containerwidget(
|
||||||
|
size=(width, height),
|
||||||
on_outside_click_call=self._back,
|
on_outside_click_call=self._back,
|
||||||
transition=transition,
|
transition=transition,
|
||||||
scale=(1.5 if _uiscale is babase.UIScale.SMALL else 1.5
|
scale=(1.5 if _uiscale is babase.UIScale.SMALL else 1.5 if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
scale_origin_stack_offset=self.scale_origin
|
||||||
scale_origin_stack_offset=self.scale_origin)
|
)
|
||||||
|
|
||||||
bui.textwidget(parent=self._root_widget,
|
bui.textwidget(parent=self._root_widget,
|
||||||
position=(width * 0.49, height * 0.87), size=(0, 0),
|
position=(width * 0.49, height * 0.87), size=(0, 0),
|
||||||
|
|
@ -928,12 +929,14 @@ class AuthorsWindow(popup.PopupWindow):
|
||||||
self._transition_out = 'out_scale'
|
self._transition_out = 'out_scale'
|
||||||
transition = 'in_scale'
|
transition = 'in_scale'
|
||||||
|
|
||||||
self._root_widget = bui.containerwidget(size=(width, height),
|
self._root_widget = bui.containerwidget(
|
||||||
|
size=(width, height),
|
||||||
on_outside_click_call=self._back,
|
on_outside_click_call=self._back,
|
||||||
transition=transition,
|
transition=transition,
|
||||||
scale=(1.5 if _uiscale is babase.UIScale.SMALL else 1.5
|
scale=(1.5 if _uiscale is babase.UIScale.SMALL else 1.5
|
||||||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||||
scale_origin_stack_offset=self.scale_origin)
|
scale_origin_stack_offset=self.scale_origin
|
||||||
|
)
|
||||||
|
|
||||||
pos = height * 0.9
|
pos = height * 0.9
|
||||||
bui.textwidget(parent=self._root_widget,
|
bui.textwidget(parent=self._root_widget,
|
||||||
|
|
@ -1030,12 +1033,14 @@ class PluginWindow(popup.PopupWindow):
|
||||||
self._transition_out = 'out_scale'
|
self._transition_out = 'out_scale'
|
||||||
transition = 'in_scale'
|
transition = 'in_scale'
|
||||||
|
|
||||||
self._root_widget = bui.containerwidget(size=(width, height),
|
self._root_widget = bui.containerwidget(
|
||||||
|
size=(width, height),
|
||||||
on_outside_click_call=self._cancel,
|
on_outside_click_call=self._cancel,
|
||||||
transition=transition,
|
transition=transition,
|
||||||
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
||||||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||||
scale_origin_stack_offset=self.scale_origin)
|
scale_origin_stack_offset=self.scale_origin
|
||||||
|
)
|
||||||
|
|
||||||
pos = height * 0.8
|
pos = height * 0.8
|
||||||
plug_name = self.plugin.name.replace('_', ' ').title()
|
plug_name = self.plugin.name.replace('_', ' ').title()
|
||||||
|
|
@ -1146,9 +1151,11 @@ class PluginWindow(popup.PopupWindow):
|
||||||
text_scale=1,
|
text_scale=1,
|
||||||
label=button3_label)
|
label=button3_label)
|
||||||
|
|
||||||
bui.containerwidget(edit=self._root_widget,
|
bui.containerwidget(
|
||||||
|
edit=self._root_widget,
|
||||||
on_cancel_call=self._cancel,
|
on_cancel_call=self._cancel,
|
||||||
selected_child=selected_btn)
|
selected_child=selected_btn
|
||||||
|
)
|
||||||
|
|
||||||
open_pos_x = (390 if _uiscale is babase.UIScale.SMALL else
|
open_pos_x = (390 if _uiscale is babase.UIScale.SMALL else
|
||||||
450 if _uiscale is babase.UIScale.MEDIUM else 440)
|
450 if _uiscale is babase.UIScale.MEDIUM else 440)
|
||||||
|
|
@ -1474,13 +1481,15 @@ class PluginSourcesWindow(popup.PopupWindow):
|
||||||
b_textcolor = (0.75, 0.7, 0.8)
|
b_textcolor = (0.75, 0.7, 0.8)
|
||||||
self._transition_out = 'out_scale'
|
self._transition_out = 'out_scale'
|
||||||
transition = 'in_scale'
|
transition = 'in_scale'
|
||||||
self._root_widget = bui.containerwidget(size=(400, 340),
|
self._root_widget = bui.containerwidget(
|
||||||
|
size=(400, 340),
|
||||||
on_outside_click_call=self._ok,
|
on_outside_click_call=self._ok,
|
||||||
transition=transition,
|
transition=transition,
|
||||||
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
||||||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||||
scale_origin_stack_offset=self.scale_origin,
|
scale_origin_stack_offset=self.scale_origin,
|
||||||
on_cancel_call=self._ok)
|
on_cancel_call=self._ok
|
||||||
|
)
|
||||||
|
|
||||||
bui.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
|
|
@ -1667,7 +1676,7 @@ class PluginCategoryWindow(popup.PopupMenuWindow):
|
||||||
|
|
||||||
|
|
||||||
class PluginManagerWindow(bui.MainWindow):
|
class PluginManagerWindow(bui.MainWindow):
|
||||||
def __init__(self, transition: str = "in_right", origin_widget: bui.Widget = None):
|
def __init__(self, transition: str = "in_right", origin_widget: bui.widget = None):
|
||||||
self.plugin_manager = PluginManager()
|
self.plugin_manager = PluginManager()
|
||||||
self.category_selection_button = None
|
self.category_selection_button = None
|
||||||
self.selected_category = 'All'
|
self.selected_category = 'All'
|
||||||
|
|
@ -1760,11 +1769,10 @@ class PluginManagerWindow(bui.MainWindow):
|
||||||
size=48,
|
size=48,
|
||||||
)
|
)
|
||||||
|
|
||||||
def spin(self, show=False):
|
def spin(self,show=False):
|
||||||
w = self._loading_spinner
|
w = self._loading_spinner
|
||||||
p = self._root_widget
|
p = self._root_widget
|
||||||
bui.spinnerwidget(w, visible=show) if w.exists(
|
bui.spinnerwidget(w,visible=show) if w.exists() and p.exists() and not p.transitioning_out else None
|
||||||
) and p.exists() and not p.transitioning_out else None
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def exception_handler(self):
|
def exception_handler(self):
|
||||||
|
|
@ -1863,7 +1871,7 @@ class PluginManagerWindow(bui.MainWindow):
|
||||||
button_type="square",
|
button_type="square",
|
||||||
textcolor=b_textcolor,
|
textcolor=b_textcolor,
|
||||||
text_scale=0.6)
|
text_scale=0.6)
|
||||||
bui.buttonwidget(b, on_activate_call=lambda: self.show_categories_window(source=b)),
|
bui.buttonwidget(b,on_activate_call=lambda: self.show_categories_window(source=b)),
|
||||||
else:
|
else:
|
||||||
b = self.category_selection_button
|
b = self.category_selection_button
|
||||||
bui.buttonwidget(
|
bui.buttonwidget(
|
||||||
|
|
@ -2047,8 +2055,7 @@ class PluginManagerWindow(bui.MainWindow):
|
||||||
self._last_filter_text = search_term
|
self._last_filter_text = search_term
|
||||||
self._last_filter_plugins = plugins
|
self._last_filter_plugins = plugins
|
||||||
|
|
||||||
if not self._columnwidget.exists():
|
if not self._columnwidget.exists(): return
|
||||||
return
|
|
||||||
|
|
||||||
if category == 'Installed':
|
if category == 'Installed':
|
||||||
plugin_names_to_draw = tuple(
|
plugin_names_to_draw = tuple(
|
||||||
|
|
@ -2110,7 +2117,7 @@ class PluginManagerWindow(bui.MainWindow):
|
||||||
def show_plugin_window(self, plugin):
|
def show_plugin_window(self, plugin):
|
||||||
PluginWindow(plugin, self._root_widget, lambda: self.draw_plugin_name(plugin))
|
PluginWindow(plugin, self._root_widget, lambda: self.draw_plugin_name(plugin))
|
||||||
|
|
||||||
def show_categories_window(self, source):
|
def show_categories_window(self,source):
|
||||||
PluginCategoryWindow(
|
PluginCategoryWindow(
|
||||||
self.plugin_manager.categories.keys(),
|
self.plugin_manager.categories.keys(),
|
||||||
self.selected_category,
|
self.selected_category,
|
||||||
|
|
@ -2182,15 +2189,18 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
|
||||||
transition = 'in_scale'
|
transition = 'in_scale'
|
||||||
button_size = (32 * s, 32 * s)
|
button_size = (32 * s, 32 * s)
|
||||||
# index = await self._plugin_manager.get_index()
|
# index = await self._plugin_manager.get_index()
|
||||||
self._root_widget = bui.containerwidget(size=(width, height),
|
self._root_widget = bui.containerwidget(
|
||||||
|
size=(width, height),
|
||||||
on_outside_click_call=self._ok,
|
on_outside_click_call=self._ok,
|
||||||
transition=transition,
|
transition=transition,
|
||||||
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
||||||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||||
scale_origin_stack_offset=self.scale_origin)
|
scale_origin_stack_offset=self.scale_origin
|
||||||
|
)
|
||||||
pos = height * 0.9
|
pos = height * 0.9
|
||||||
setting_title = "Settings"
|
setting_title = "Settings"
|
||||||
bui.textwidget(parent=self._root_widget,
|
bui.textwidget(
|
||||||
|
parent=self._root_widget,
|
||||||
position=(width * 0.49, pos),
|
position=(width * 0.49, pos),
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
h_align='center',
|
h_align='center',
|
||||||
|
|
@ -2198,7 +2208,8 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
|
||||||
text=setting_title,
|
text=setting_title,
|
||||||
scale=text_scale,
|
scale=text_scale,
|
||||||
color=bui.app.ui_v1.title_color,
|
color=bui.app.ui_v1.title_color,
|
||||||
maxwidth=width * 0.9)
|
maxwidth=width * 0.9
|
||||||
|
)
|
||||||
|
|
||||||
pos -= 20
|
pos -= 20
|
||||||
self._changelog_button = b = bui.buttonwidget(parent=self._root_widget,
|
self._changelog_button = b = bui.buttonwidget(parent=self._root_widget,
|
||||||
|
|
@ -2208,7 +2219,7 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
|
||||||
textcolor=b_text_color,
|
textcolor=b_text_color,
|
||||||
button_type='square',
|
button_type='square',
|
||||||
label='')
|
label='')
|
||||||
bui.buttonwidget(b, on_activate_call=lambda: ChangelogWindow(b))
|
bui.buttonwidget(b,on_activate_call=lambda:ChangelogWindow(b))
|
||||||
bui.textwidget(parent=self._root_widget,
|
bui.textwidget(parent=self._root_widget,
|
||||||
position=((width * 0.2) - button_size[0] / 2, pos),
|
position=((width * 0.2) - button_size[0] / 2, pos),
|
||||||
size=(70, 30),
|
size=(70, 30),
|
||||||
|
|
@ -2392,7 +2403,7 @@ class NewAllSettingsWindow(AllSettingsWindow):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
transition: str | None = 'in_right',
|
transition: str | None = 'in_right',
|
||||||
origin_widget: bui.Widget | None = None,
|
origin_widget: bui.widget | None = None,
|
||||||
):
|
):
|
||||||
# pylint: disable=too-many-statements
|
# pylint: disable=too-many-statements
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
|
|
@ -2468,7 +2479,7 @@ class NewAllSettingsWindow(AllSettingsWindow):
|
||||||
x_offs4 -= x_dif
|
x_offs4 -= x_dif
|
||||||
|
|
||||||
def _b_title(
|
def _b_title(
|
||||||
x: float, y: float, button: bui.Widget, text: str | bui.Lstr
|
x: float, y: float, button: bui.widget, text: str | bui.Lstr
|
||||||
) -> None:
|
) -> None:
|
||||||
bui.textwidget(
|
bui.textwidget(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
|
|
@ -2627,7 +2638,7 @@ class NewAllSettingsWindow(AllSettingsWindow):
|
||||||
sel_name = bui.app.ui_v1.window_states.get(type(self), {}).get(
|
sel_name = bui.app.ui_v1.window_states.get(type(self), {}).get(
|
||||||
'sel_name'
|
'sel_name'
|
||||||
)
|
)
|
||||||
sel: bui.Widget | None
|
sel: bui.widget | None
|
||||||
if sel_name == 'Controllers':
|
if sel_name == 'Controllers':
|
||||||
sel = self._controllers_button
|
sel = self._controllers_button
|
||||||
elif sel_name == 'Graphics':
|
elif sel_name == 'Graphics':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue