Cleaning Up

This commit is contained in:
Vishal 2025-08-04 02:35:20 +05:30 committed by GitHub
parent 0bffcc0a67
commit 2a5273bfcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -858,11 +858,17 @@ class ChangelogWindow(popup.PopupWindow):
scale_origin_stack_offset=self.scale_origin scale_origin_stack_offset=self.scale_origin
) )
bui.textwidget(parent=self._root_widget, bui.textwidget(
position=(width * 0.49, height * 0.87), size=(0, 0), parent=self._root_widget,
h_align='center', v_align='center', text='ChangeLog', position=(width * 0.49, height * 0.87),
scale=text_scale * 1.25, color=bui.app.ui_v1.title_color, size=(0, 0),
maxwidth=width * 0.9) h_align='center',
v_align='center',
text='ChangeLog',
scale=text_scale * 1.25,
color=bui.app.ui_v1.title_color,
maxwidth=width * 0.9
)
back_button = bui.buttonwidget( back_button = bui.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
@ -871,7 +877,8 @@ class ChangelogWindow(popup.PopupWindow):
scale=0.8, scale=0.8,
label=babase.charstr(babase.SpecialChar.BACK), label=babase.charstr(babase.SpecialChar.BACK),
button_type='backSmall', button_type='backSmall',
on_activate_call=self._back) on_activate_call=self._back
)
bui.containerwidget(edit=self._root_widget, cancel_button=back_button) bui.containerwidget(edit=self._root_widget, cancel_button=back_button)
@ -886,12 +893,17 @@ class ChangelogWindow(popup.PopupWindow):
h_align = 'center' h_align = 'center'
extra = 1 extra = 1
bui.textwidget(parent=self._root_widget, bui.textwidget(
position=(width * 0.49, height * 0.72), size=(0, 0), parent=self._root_widget,
h_align='center', v_align='center', position=(width * 0.49, height * 0.72),
size=(0, 0),
h_align='center',
v_align='center',
text=PLUGIN_MANAGER_VERSION + released_on, text=PLUGIN_MANAGER_VERSION + released_on,
scale=text_scale * 0.9, color=color, scale=text_scale * 0.9,
maxwidth=width * 0.9) color=color,
maxwidth=width * 0.9
)
bui.buttonwidget( bui.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
@ -900,15 +912,22 @@ class ChangelogWindow(popup.PopupWindow):
scale=0.8, scale=0.8,
label='Full ChangeLog', label='Full ChangeLog',
button_type='square', button_type='square',
on_activate_call=lambda: bui.open_url(REPOSITORY_URL + '/blob/main/CHANGELOG.md')) on_activate_call=lambda: bui.open_url(REPOSITORY_URL + '/blob/main/CHANGELOG.md')
)
loop_height = height * 0.62 loop_height = height * 0.62
for log in logs: for log in logs:
bui.textwidget(parent=self._root_widget, bui.textwidget(
position=(width * 0.5 * extra, loop_height), size=(0, 0), parent=self._root_widget,
h_align=h_align, v_align='top', text=log, position=(width * 0.5 * extra, loop_height),
scale=text_scale, color=color, size=(0, 0),
maxwidth=width * 0.9) h_align=h_align,
v_align='top',
text=log,
scale=text_scale,
color=color,
maxwidth=width * 0.9
)
loop_height -= 35 loop_height -= 35
def _back(self) -> None: def _back(self) -> None:
@ -939,11 +958,17 @@ class AuthorsWindow(popup.PopupWindow):
) )
pos = height * 0.9 pos = height * 0.9
bui.textwidget(parent=self._root_widget, bui.textwidget(
position=(width * 0.49, pos), size=(0, 0), parent=self._root_widget,
h_align='center', v_align='center', text='Authors', position=(width * 0.49, pos),
scale=text_scale * 1.25, color=color, size=(0, 0),
maxwidth=width * 0.9) h_align='center',
v_align='center',
text='Authors',
scale=text_scale * 1.25,
color=color,
maxwidth=width * 0.9
)
back_button = bui.buttonwidget( back_button = bui.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
@ -952,24 +977,30 @@ class AuthorsWindow(popup.PopupWindow):
scale=0.8, scale=0.8,
label=babase.charstr(babase.SpecialChar.BACK), label=babase.charstr(babase.SpecialChar.BACK),
button_type='backSmall', button_type='backSmall',
on_activate_call=self._back) on_activate_call=self._back
)
bui.containerwidget(edit=self._root_widget, cancel_button=back_button) bui.containerwidget(edit=self._root_widget, cancel_button=back_button)
self._scrollwidget = bui.scrollwidget(parent=self._root_widget, self._scrollwidget = bui.scrollwidget(
parent=self._root_widget,
size=(width * 0.8, height * 0.75), size=(width * 0.8, height * 0.75),
position=(width * 0.1, height * 0.1)) position=(width * 0.1, height * 0.1)
self._columnwidget = bui.columnwidget(parent=self._scrollwidget, )
self._columnwidget = bui.columnwidget(
parent=self._scrollwidget,
border=1, border=1,
left_border=-15, left_border=-15,
margin=0) margin=0
)
for author in self.authors_info: for author in self.authors_info:
for key, value in author.items(): for key, value in author.items():
text = f"{key.title()}: {value if value != '' else 'Not Provided'}" text = f"{key.title()}: {value if value != '' else 'Not Provided'}"
if key == 'name': if key == 'name':
text = value text = value
bui.textwidget(parent=self._columnwidget, bui.textwidget(
parent=self._columnwidget,
size=(width * 0.8, 35 if key == 'name' else 30), size=(width * 0.8, 35 if key == 'name' else 30),
color=color if key == 'name' else (0.75, 0.7, 0.8), color=color if key == 'name' else (0.75, 0.7, 0.8),
scale=( scale=(
@ -979,12 +1010,15 @@ class AuthorsWindow(popup.PopupWindow):
text=text, text=text,
h_align='center', h_align='center',
v_align='center', v_align='center',
maxwidth=420) maxwidth=420
bui.textwidget(parent=self._columnwidget, )
bui.textwidget(
parent=self._columnwidget,
size=(width * 0.8, 30), size=(width * 0.8, 30),
always_highlight=True, always_highlight=True,
h_align='center', h_align='center',
v_align='center') v_align='center'
)
def _back(self) -> None: def _back(self) -> None:
bui.getsound('swish').play() bui.getsound('swish').play()
@ -1045,23 +1079,30 @@ class PluginWindow(popup.PopupWindow):
pos = height * 0.8 pos = height * 0.8
plug_name = self.plugin.name.replace('_', ' ').title() plug_name = self.plugin.name.replace('_', ' ').title()
plugin_title = f"{plug_name} (v{self.plugin.latest_compatible_version.number})" plugin_title = f"{plug_name} (v{self.plugin.latest_compatible_version.number})"
bui.textwidget(parent=self._root_widget, bui.textwidget(
position=(width * 0.49, pos), size=(0, 0), parent=self._root_widget,
h_align='center', v_align='center', text=plugin_title, position=(width * 0.49, pos),
scale=text_scale * 1.25, color=color, size=(0, 0),
maxwidth=width * 0.9) h_align='center',
v_align='center',
text=plugin_title,
scale=text_scale * 1.25,
color=color,
maxwidth=width * 0.9
)
pos -= 25 pos -= 25
# Author # Author
text = 'by ' + ', '.join([author["name"] for author in self.plugin.info["authors"]]) text = 'by ' + ', '.join([author["name"] for author in self.plugin.info["authors"]])
author_text_control_btn = bui.buttonwidget(parent=self._root_widget, author_text_control_btn = bui.buttonwidget(
position=(width * 0.49 - parent=self._root_widget,
(len(text)*14/2), pos - 10), position=(width * 0.49 - (len(text)*14/2), pos - 10),
size=(len(text)*14, 20), size=(len(text)*14, 20),
label='', label='',
texture=bui.gettexture("empty"), texture=bui.gettexture("empty"),
on_activate_call=lambda: on_activate_call=lambda: AuthorsWindow(self.plugin.info["authors"], self._root_widget)
AuthorsWindow(self.plugin.info["authors"], self._root_widget)) )
bui.textwidget(parent=self._root_widget, bui.textwidget(
parent=self._root_widget,
position=(width * 0.49 - (len(text)*14/2), pos - 10), position=(width * 0.49 - (len(text)*14/2), pos - 10),
size=(len(text)*14, 20), size=(len(text)*14, 20),
h_align='center', h_align='center',
@ -1074,12 +1115,17 @@ class PluginWindow(popup.PopupWindow):
) )
pos -= 60 pos -= 60
# Info # Info
bui.textwidget(parent=self._root_widget, bui.textwidget(
position=(width * 0.49, pos), size=(0, 0), parent=self._root_widget,
h_align='center', v_align='center', position=(width * 0.49, pos),
size=(0, 0),
h_align='center',
v_align='center',
text=self.get_description(), text=self.get_description(),
scale=text_scale * 0.6, color=color, scale=text_scale * 0.6,
maxwidth=width * 0.95) color=color,
maxwidth=width * 0.95
)
b1_color = None b1_color = None
b2_color = (0.8, 0.15, 0.35) b2_color = (0.8, 0.15, 0.35)
b3_color = (0.2, 0.8, 0.3) b3_color = (0.2, 0.8, 0.3)
@ -1113,22 +1159,24 @@ class PluginWindow(popup.PopupWindow):
button1_action = self.install button1_action = self.install
if to_draw_button1: if to_draw_button1:
selected_btn = bui.buttonwidget(parent=self._root_widget, selected_btn = bui.buttonwidget(
parent=self._root_widget,
position=( position=(
width * ( width * (0.1 if self.plugin.is_installed and has_update else
0.1 if self.plugin.is_installed and has_update else 0.25 if self.plugin.is_installed else 0.4), pos
0.25 if self.plugin.is_installed else ),
0.4), pos),
size=button_size, size=button_size,
on_activate_call=button1_action, on_activate_call=button1_action,
color=b1_color, color=b1_color,
textcolor=b_text_color, textcolor=b_text_color,
button_type='square', button_type='square',
text_scale=1, text_scale=1,
label=button1_label) label=button1_label
)
if self.plugin.is_installed: if self.plugin.is_installed:
selected_btn = bui.buttonwidget(parent=self._root_widget, selected_btn = bui.buttonwidget(
parent=self._root_widget,
position=( position=(
width * (0.4 if has_update or not to_draw_button1 else 0.55), pos), width * (0.4 if has_update or not to_draw_button1 else 0.55), pos),
size=button_size, size=button_size,
@ -1137,10 +1185,12 @@ class PluginWindow(popup.PopupWindow):
textcolor=b_text_color, textcolor=b_text_color,
button_type='square', button_type='square',
text_scale=1, text_scale=1,
label=button2_label) label=button2_label
)
if has_update: if has_update:
selected_btn = bui.buttonwidget(parent=self._root_widget, selected_btn = bui.buttonwidget(
parent=self._root_widget,
position=(width * 0.7, pos), position=(width * 0.7, pos),
size=button_size, size=button_size,
on_activate_call=button3_action, on_activate_call=button3_action,
@ -1149,7 +1199,8 @@ class PluginWindow(popup.PopupWindow):
autoselect=True, autoselect=True,
button_type='square', button_type='square',
text_scale=1, text_scale=1,
label=button3_label) label=button3_label
)
bui.containerwidget( bui.containerwidget(
edit=self._root_widget, edit=self._root_widget,
@ -1161,28 +1212,34 @@ class PluginWindow(popup.PopupWindow):
450 if _uiscale is babase.UIScale.MEDIUM else 440) 450 if _uiscale is babase.UIScale.MEDIUM else 440)
open_pos_y = (100 if _uiscale is babase.UIScale.SMALL else open_pos_y = (100 if _uiscale is babase.UIScale.SMALL else
110 if _uiscale is babase.UIScale.MEDIUM else 120) 110 if _uiscale is babase.UIScale.MEDIUM else 120)
open_button = bui.buttonwidget(parent=self._root_widget, open_button = bui.buttonwidget(
parent=self._root_widget,
autoselect=True, autoselect=True,
position=(open_pos_x, open_pos_y), position=(open_pos_x, open_pos_y),
size=(40, 40), size=(40, 40),
button_type="square", button_type="square",
label="", label="",
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
on_activate_call=lambda: bui.open_url(self.plugin.view_url)) on_activate_call=lambda: bui.open_url(self.plugin.view_url)
bui.imagewidget(parent=self._root_widget, )
bui.imagewidget(
parent=self._root_widget,
position=(open_pos_x, open_pos_y), position=(open_pos_x, open_pos_y),
size=(40, 40), size=(40, 40),
color=(0.8, 0.95, 1), color=(0.8, 0.95, 1),
texture=bui.gettexture("file"), texture=bui.gettexture("file"),
draw_controller=open_button) draw_controller=open_button
bui.textwidget(parent=self._root_widget, )
bui.textwidget(
parent=self._root_widget,
position=(open_pos_x-3, open_pos_y+12), position=(open_pos_x-3, open_pos_y+12),
text="Source", text="Source",
size=(10, 10), size=(10, 10),
draw_controller=open_button, draw_controller=open_button,
color=(1, 1, 1, 1), color=(1, 1, 1, 1),
rotate=25, rotate=25,
scale=0.45) scale=0.45
)
# Below snippet handles the tutorial button in the plugin window # Below snippet handles the tutorial button in the plugin window
tutorial_url = self.plugin.info["external_url"] tutorial_url = self.plugin.info["external_url"]
@ -1197,52 +1254,62 @@ class PluginWindow(popup.PopupWindow):
500 if _uiscale is babase.UIScale.MEDIUM else 490) 500 if _uiscale is babase.UIScale.MEDIUM else 490)
open_pos_y = (100 if _uiscale is babase.UIScale.SMALL else open_pos_y = (100 if _uiscale is babase.UIScale.SMALL else
110 if _uiscale is babase.UIScale.MEDIUM else 120) 110 if _uiscale is babase.UIScale.MEDIUM else 120)
open_button = bui.buttonwidget(parent=self._root_widget, open_button = bui.buttonwidget(
parent=self._root_widget,
autoselect=True, autoselect=True,
position=(open_pos_x, open_pos_y), position=(open_pos_x, open_pos_y),
size=(40, 40), size=(40, 40),
button_type="square", button_type="square",
label="", label="",
color=(0.6, 0.53, 0.63), color=(0.6, 0.53, 0.63),
on_activate_call=tutorial_confirm_window
)
on_activate_call=tutorial_confirm_window) bui.imagewidget(
parent=self._root_widget,
bui.imagewidget(parent=self._root_widget,
position=(open_pos_x, open_pos_y), position=(open_pos_x, open_pos_y),
size=(40, 40), size=(40, 40),
color=(0.8, 0.95, 1), color=(0.8, 0.95, 1),
texture=bui.gettexture("frameInset"), texture=bui.gettexture("frameInset"),
draw_controller=open_button) draw_controller=open_button
bui.textwidget(parent=self._root_widget, )
bui.textwidget(
parent=self._root_widget,
position=(open_pos_x - 3, open_pos_y + 12), position=(open_pos_x - 3, open_pos_y + 12),
text="Tutorial", text="Tutorial",
size=(10, 10), size=(10, 10),
draw_controller=open_button, draw_controller=open_button,
color=(1, 1, 1, 1), color=(1, 1, 1, 1),
rotate=25, rotate=25,
scale=0.45) scale=0.45
)
if to_draw_button4: if to_draw_button4:
settings_pos_x = (60 if _uiscale is babase.UIScale.SMALL else settings_pos_x = (60 if _uiscale is babase.UIScale.SMALL else
60 if _uiscale is babase.UIScale.MEDIUM else 60) 60 if _uiscale is babase.UIScale.MEDIUM else 60)
settings_pos_y = (100 if _uiscale is babase.UIScale.SMALL else settings_pos_y = (100 if _uiscale is babase.UIScale.SMALL else
110 if _uiscale is babase.UIScale.MEDIUM else 120) 110 if _uiscale is babase.UIScale.MEDIUM else 120)
settings_button = bui.buttonwidget(parent=self._root_widget, settings_button = bui.buttonwidget(
parent=self._root_widget,
autoselect=True, autoselect=True,
position=(settings_pos_x, settings_pos_y), position=(settings_pos_x, settings_pos_y),
size=(40, 40), size=(40, 40),
button_type="square", button_type="square",
label="", label="",
color=(0, 0.75, 0.75),) color=(0, 0.75, 0.75)
)
bui.buttonwidget( bui.buttonwidget(
edit=settings_button, edit=settings_button,
on_activate_call=babase.Call(self.settings, settings_button),) on_activate_call=babase.Call(self.settings, settings_button)
bui.imagewidget(parent=self._root_widget, )
bui.imagewidget(
parent=self._root_widget,
position=(settings_pos_x, settings_pos_y), position=(settings_pos_x, settings_pos_y),
size=(40, 40), size=(40, 40),
color=(0.8, 0.95, 1), color=(0.8, 0.95, 1),
texture=bui.gettexture("settingsIcon"), texture=bui.gettexture("settingsIcon"),
draw_controller=settings_button) draw_controller=settings_button
)
def _ok(self) -> None: def _ok(self) -> None:
bui.containerwidget(edit=self._root_widget, transition='out_scale') bui.containerwidget(edit=self._root_widget, transition='out_scale')
@ -1511,29 +1578,40 @@ class PluginSourcesWindow(popup.PopupWindow):
40 if _uiscale is babase.UIScale.MEDIUM else 60) 40 if _uiscale is babase.UIScale.MEDIUM else 60)
scroll_pos_y = 105 scroll_pos_y = 105
self._scrollwidget = bui.scrollwidget(parent=self._root_widget, self._scrollwidget = bui.scrollwidget(
parent=self._root_widget,
size=(scroll_size_x, scroll_size_y), size=(scroll_size_x, scroll_size_y),
position=(scroll_pos_x, scroll_pos_y)) position=(scroll_pos_x, scroll_pos_y)
self._columnwidget = bui.columnwidget(parent=self._scrollwidget, )
border=1, self._columnwidget = bui.columnwidget(
margin=0) parent=self._scrollwidget,
border=1, margin=0
)
delete_source_button_position_pos_x = 360 delete_source_button_position_pos_x = 360
delete_source_button_position_pos_y = 110 delete_source_button_position_pos_y = 110
delete_source_button = bui.buttonwidget(parent=self._root_widget, delete_source_button = bui.buttonwidget(
position=(delete_source_button_position_pos_x, parent=self._root_widget,
delete_source_button_position_pos_y), position=(
size=(25, 25), label="", delete_source_button_position_pos_x, delete_source_button_position_pos_y
),
size=(25, 25),
label="",
on_activate_call=self.delete_selected_source, on_activate_call=self.delete_selected_source,
button_type="square", button_type="square",
color=(0.6, 0, 0)) color=(0.6, 0, 0)
)
bui.imagewidget(parent=self._root_widget, bui.imagewidget(
position=(delete_source_button_position_pos_x + 2, parent=self._root_widget,
delete_source_button_position_pos_y), position=(
size=(25, 25), color=(5, 2, 2), delete_source_button_position_pos_x + 2, delete_source_button_position_pos_y
),
size=(25, 25),
color=(5, 2, 2),
texture=bui.gettexture("crossOut"), texture=bui.gettexture("crossOut"),
draw_controller=delete_source_button) draw_controller=delete_source_button
)
warning_pos_x = (43 if _uiscale is babase.UIScale.SMALL else warning_pos_x = (43 if _uiscale is babase.UIScale.SMALL else
35 if _uiscale is babase.UIScale.MEDIUM else 35 if _uiscale is babase.UIScale.MEDIUM else
@ -1551,7 +1629,8 @@ class PluginSourcesWindow(popup.PopupWindow):
maxwidth=400, maxwidth=400,
) )
self._add_source_widget = bui.textwidget(parent=self._root_widget, self._add_source_widget = bui.textwidget(
parent=self._root_widget,
size=(335, 50), size=(335, 50),
position=(21, 22), position=(21, 22),
h_align='left', h_align='left',
@ -1559,9 +1638,11 @@ class PluginSourcesWindow(popup.PopupWindow):
editable=True, editable=True,
scale=0.75, scale=0.75,
maxwidth=215, maxwidth=215,
description="Add Source") description="Add Source"
)
bui.buttonwidget(parent=self._root_widget, bui.buttonwidget(
parent=self._root_widget,
position=(330, 28), position=(330, 28),
size=(37, 37), size=(37, 37),
on_activate_call=lambda: loop.create_task(self.add_source()), on_activate_call=lambda: loop.create_task(self.add_source()),
@ -1570,7 +1651,8 @@ class PluginSourcesWindow(popup.PopupWindow):
button_type="square", button_type="square",
color=(0, 0.9, 0), color=(0, 0.9, 0),
textcolor=b_textcolor, textcolor=b_textcolor,
text_scale=1) text_scale=1
)
self.draw_sources() self.draw_sources()
@ -1580,7 +1662,8 @@ class PluginSourcesWindow(popup.PopupWindow):
color = (1, 1, 1) color = (1, 1, 1)
for custom_source in babase.app.config["Community Plugin Manager"]["Custom Sources"]: for custom_source in babase.app.config["Community Plugin Manager"]["Custom Sources"]:
bui.textwidget(parent=self._columnwidget, bui.textwidget(
parent=self._columnwidget,
selectable=True, selectable=True,
color=color, color=color,
text=custom_source, text=custom_source,
@ -1588,7 +1671,8 @@ class PluginSourcesWindow(popup.PopupWindow):
h_align='left', h_align='left',
v_align='center', v_align='center',
scale=0.75, scale=0.75,
maxwidth=260) maxwidth=260
)
def select_source(self, source): def select_source(self, source):
self.selected_source = source self.selected_source = source
@ -1651,13 +1735,16 @@ class PluginCategoryWindow(popup.PopupMenuWindow):
1.65 if _uiscale is babase.UIScale.MEDIUM else 1.23), 1.65 if _uiscale is babase.UIScale.MEDIUM else 1.23),
choices=choices, choices=choices,
current_choice=current_choice, current_choice=current_choice,
delegate=self) delegate=self
)
self._update_custom_sources_widget() self._update_custom_sources_widget()
def _update_custom_sources_widget(self): def _update_custom_sources_widget(self):
bui.textwidget(edit=self._columnwidget.get_children()[-1], bui.textwidget(
edit=self._columnwidget.get_children()[-1],
color=(0.5, 0.5, 0.5), color=(0.5, 0.5, 0.5),
on_activate_call=self.show_sources_window) on_activate_call=self.show_sources_window
)
def popup_menu_selected_choice(self, window, choice): def popup_menu_selected_choice(self, window, choice):
@ -1730,7 +1817,8 @@ class PluginManagerWindow(bui.MainWindow):
scale=0.8, scale=0.8,
label=babase.charstr(babase.SpecialChar.BACK), label=babase.charstr(babase.SpecialChar.BACK),
button_type='backSmall', button_type='backSmall',
on_activate_call=self.main_window_back) on_activate_call=self.main_window_back
)
bui.containerwidget(edit=self._root_widget, cancel_button=back_button) bui.containerwidget(edit=self._root_widget, cancel_button=back_button)
@ -1841,19 +1929,16 @@ class PluginManagerWindow(bui.MainWindow):
b_textcolor = (0.8, 0.8, 0.85) b_textcolor = (0.8, 0.8, 0.85)
if self.alphabet_order_selection_button is None: if self.alphabet_order_selection_button is None:
self.alphabet_order_selection_button = bui.buttonwidget(parent=self._root_widget, self.alphabet_order_selection_button = bui.buttonwidget(
parent=self._root_widget,
size=(40, 30), size=(40, 30),
position=( position=(category_pos_x - 47, category_pos_y),
category_pos_x - 47, label='Z - A' if self.selected_alphabet_order == 'z_a' else 'A - Z',
category_pos_y), on_activate_call=lambda: loop.create_task(self._on_order_button_press()),
label=(
'Z - A' if self.selected_alphabet_order == 'z_a'
else 'A - Z'),
on_activate_call=(
lambda: loop.create_task(self._on_order_button_press())),
button_type="square", button_type="square",
textcolor=b_textcolor, textcolor=b_textcolor,
text_scale=0.6) text_scale=0.6
)
else: else:
b = self.alphabet_order_selection_button b = self.alphabet_order_selection_button
bui.buttonwidget( bui.buttonwidget(
@ -1864,15 +1949,16 @@ class PluginManagerWindow(bui.MainWindow):
label = f"Category: {post_label}" label = f"Category: {post_label}"
if self.category_selection_button is None: if self.category_selection_button is None:
self.category_selection_button = b = bui.buttonwidget(parent=self._root_widget, self.category_selection_button = b = bui.buttonwidget(
position=(category_pos_x, parent=self._root_widget,
category_pos_y), position=(category_pos_x, category_pos_y),
size=b_size, size=b_size,
label=label, label=label,
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(edit=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(
@ -2214,15 +2300,17 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
) )
pos -= 20 pos -= 20
self._changelog_button = b = bui.buttonwidget(parent=self._root_widget, self._changelog_button = b = bui.buttonwidget(
position=((width * 0.2) - button_size[0] / 2 - 5, parent=self._root_widget,
pos), position=((width * 0.2) - button_size[0] / 2 - 5, pos),
size=(80, 30), size=(80, 30),
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),
scale=0.6, scale=0.6,
@ -2232,7 +2320,8 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
color=b_text_color, color=b_text_color,
draw_controller=self._changelog_button, draw_controller=self._changelog_button,
) )
self._save_button = bui.buttonwidget(parent=self._root_widget, self._save_button = bui.buttonwidget(
parent=self._root_widget,
position=((width * 0.82) - button_size[0] / 2, pos), position=((width * 0.82) - button_size[0] / 2, pos),
size=(73, 35), size=(73, 35),
on_activate_call=self.save_settings_button, on_activate_call=self.save_settings_button,
@ -2241,11 +2330,13 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
text_scale=1, text_scale=1,
scale=0, scale=0,
selectable=False, selectable=False,
label="Save") label="Save"
)
pos -= 40 pos -= 40
for setting, value in self.settings.items(): for setting, value in self.settings.items():
bui.checkboxwidget(parent=self._root_widget, bui.checkboxwidget(
parent=self._root_widget,
position=(width * 0.1, pos), position=(width * 0.1, pos),
size=(170, 30), size=(170, 30),
text=setting, text=setting,
@ -2253,11 +2344,13 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
on_value_change_call=babase.Call(self.toggle_setting, setting), on_value_change_call=babase.Call(self.toggle_setting, setting),
maxwidth=500, maxwidth=500,
textcolor=(0.9, 0.9, 0.9), textcolor=(0.9, 0.9, 0.9),
scale=text_scale * 0.8) scale=text_scale * 0.8
)
pos -= 34 * text_scale pos -= 34 * text_scale
pos = height - 200 pos = height - 200
bui.textwidget(parent=self._root_widget, bui.textwidget(
parent=self._root_widget,
position=(width * 0.49, pos-5), position=(width * 0.49, pos-5),
size=(0, 0), size=(0, 0),
h_align='center', h_align='center',
@ -2265,7 +2358,8 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
text='Contribute to plugins or to this community plugin manager!', text='Contribute to plugins or to this community plugin manager!',
scale=text_scale * 0.65, scale=text_scale * 0.65,
color=color, color=color,
maxwidth=width * 0.95) maxwidth=width * 0.95
)
pos -= 75 pos -= 75
try: try:
@ -2273,7 +2367,8 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
except urllib.error.URLError: except urllib.error.URLError:
plugin_manager_update_available = False plugin_manager_update_available = False
discord_width = (width * 0.20) if plugin_manager_update_available else (width * 0.31) discord_width = (width * 0.20) if plugin_manager_update_available else (width * 0.31)
self.discord_button = bui.buttonwidget(parent=self._root_widget, self.discord_button = bui.buttonwidget(
parent=self._root_widget,
position=(discord_width - button_size[0] / 2, pos), position=(discord_width - button_size[0] / 2, pos),
size=button_size, size=button_size,
on_activate_call=lambda: bui.open_url(DISCORD_URL), on_activate_call=lambda: bui.open_url(DISCORD_URL),
@ -2281,17 +2376,21 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
color=discord_bg_color, color=discord_bg_color,
button_type='square', button_type='square',
text_scale=1, text_scale=1,
label="") label=""
)
bui.imagewidget(parent=self._root_widget, bui.imagewidget(
parent=self._root_widget,
position=(discord_width+0.5 - button_size[0] / 2, pos), position=(discord_width+0.5 - button_size[0] / 2, pos),
size=button_size, size=button_size,
texture=bui.gettexture("discordLogo"), texture=bui.gettexture("discordLogo"),
color=discord_fg_color, color=discord_fg_color,
draw_controller=self.discord_button) draw_controller=self.discord_button
)
github_width = (width * 0.49) if plugin_manager_update_available else (width * 0.65) github_width = (width * 0.49) if plugin_manager_update_available else (width * 0.65)
self.github_button = bui.buttonwidget(parent=self._root_widget, self.github_button = bui.buttonwidget(
parent=self._root_widget,
position=(github_width - button_size[0] / 2, pos), position=(github_width - button_size[0] / 2, pos),
size=button_size, size=button_size,
on_activate_call=lambda: bui.open_url(REPOSITORY_URL), on_activate_call=lambda: bui.open_url(REPOSITORY_URL),
@ -2299,14 +2398,17 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
color=github_bg_color, color=github_bg_color,
button_type='square', button_type='square',
text_scale=1, text_scale=1,
label='') label=''
)
bui.imagewidget(parent=self._root_widget, bui.imagewidget(
parent=self._root_widget,
position=(github_width + 0.5 - button_size[0] / 2, pos), position=(github_width + 0.5 - button_size[0] / 2, pos),
size=button_size, size=button_size,
texture=bui.gettexture("githubLogo"), texture=bui.gettexture("githubLogo"),
color=(1, 1, 1), color=(1, 1, 1),
draw_controller=self.github_button) draw_controller=self.github_button
)
bui.containerwidget(edit=self._root_widget, on_cancel_call=self._ok) bui.containerwidget(edit=self._root_widget, on_cancel_call=self._ok)
@ -2318,22 +2420,19 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
text_color = (0.75, 0.2, 0.2) text_color = (0.75, 0.2, 0.2)
button_size = (95 * s, 32 * s) button_size = (95 * s, 32 * s)
update_button_label = f'Update to v{plugin_manager_update_available[0]}' update_button_label = f'Update to v{plugin_manager_update_available[0]}'
self._update_button = bui.buttonwidget(parent=self._root_widget, self._update_button = bui.buttonwidget(
position=((width * 0.77) - button_size[0] / 2, parent=self._root_widget,
pos), position=((width * 0.77) - button_size[0] / 2, pos),
size=button_size, size=button_size,
on_activate_call=lambda: on_activate_call=lambda: loop.create_task(self.update(*plugin_manager_update_available)),
loop.create_task(
self.update(
*plugin_manager_update_available
)
),
textcolor=b_text_color, textcolor=b_text_color,
button_type='square', button_type='square',
text_scale=1, text_scale=1,
color=(0, 0.7, 0), color=(0, 0.7, 0),
label=update_button_label) label=update_button_label
self._restart_to_reload_changes_text = bui.textwidget(parent=self._root_widget, )
self._restart_to_reload_changes_text = bui.textwidget(
parent=self._root_widget,
position=(width * 0.79, pos + 20), position=(width * 0.79, pos + 20),
size=(0, 0), size=(0, 0),
h_align='center', h_align='center',
@ -2341,11 +2440,13 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
text='', text='',
scale=text_scale * 0.65, scale=text_scale * 0.65,
color=(0, 0.8, 0), color=(0, 0.8, 0),
maxwidth=width * 0.9) maxwidth=width * 0.9
)
else: else:
text_color = (0, 0.8, 0) text_color = (0, 0.8, 0)
pos -= 25 pos -= 25
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',
@ -2353,9 +2454,11 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
text=f'Plugin Manager v{PLUGIN_MANAGER_VERSION}', text=f'Plugin Manager v{PLUGIN_MANAGER_VERSION}',
scale=text_scale * 0.8, scale=text_scale * 0.8,
color=text_color, color=text_color,
maxwidth=width * 0.9) maxwidth=width * 0.9
)
pos -= 25 pos -= 25
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',
@ -2363,16 +2466,19 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
text=f'API Version: {_app_api_version}', text=f'API Version: {_app_api_version}',
scale=text_scale * 0.7, scale=text_scale * 0.7,
color=(0.4, 0.8, 1), color=(0.4, 0.8, 1),
maxwidth=width * 0.95) maxwidth=width * 0.95
)
pos = height * 0.1 pos = height * 0.1
def toggle_setting(self, setting, set_value): def toggle_setting(self, setting, set_value):
self.settings[setting] = set_value self.settings[setting] = set_value
check = self.settings == babase.app.config["Community Plugin Manager"]["Settings"] check = self.settings == babase.app.config["Community Plugin Manager"]["Settings"]
bui.buttonwidget(edit=self._save_button, bui.buttonwidget(
edit=self._save_button,
scale=0 if check else 1, scale=0 if check else 1,
selectable=(not check)) selectable=(not check)
)
def save_settings_button(self): def save_settings_button(self):
babase.app.config["Community Plugin Manager"]["Settings"] = self.settings.copy() babase.app.config["Community Plugin Manager"]["Settings"] = self.settings.copy()
@ -2390,8 +2496,10 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
else: else:
bui.screenmessage("Plugin manager update successful", color=(0, 1, 0)) bui.screenmessage("Plugin manager update successful", color=(0, 1, 0))
bui.getsound('shieldUp').play() bui.getsound('shieldUp').play()
bui.textwidget(edit=self._restart_to_reload_changes_text, bui.textwidget(
text='Update Applied!\nRestart game to reload changes.') edit=self._restart_to_reload_changes_text,
text='Update Applied!\nRestart game to reload changes.'
)
self._update_button.delete() self._update_button.delete()
def _ok(self) -> None: def _ok(self) -> None: