Fixing up a few stuff

This commit is contained in:
Vishal 2024-03-02 14:14:58 +05:30 committed by GitHub
parent 002c317f49
commit ce089fed71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 15 deletions

View File

@ -136,8 +136,16 @@ def create_user_system_scripts() -> None:
path = f'{env.python_directory_user}/sys/{env.version}' path = f'{env.python_directory_user}/sys/{env.version}'
pathtmp = path + '_tmp' pathtmp = path + '_tmp'
if os.path.exists(path): if os.path.exists(path):
print('Delete Existing User Scripts and try again.') print('Delete Existing User Scripts,'
_babase.screenmessage('Delete Existing User Scripts and try again.') f'Restart {_babase.appname()} and try again.')
_babase.screenmessage(
'Delete Existing User Scripts,',
color=(1, 0, 0)
)
_babase.screenmessage(
f'Restart {_babase.appname()} and try again.',
color=(1, 0, 0)
)
return return
if os.path.exists(pathtmp): if os.path.exists(pathtmp):
shutil.rmtree(pathtmp) shutil.rmtree(pathtmp)
@ -161,7 +169,7 @@ def create_user_system_scripts() -> None:
f"'\nRestart {_babase.appname()} to use them." f"'\nRestart {_babase.appname()} to use them."
f' (use babase.quit() to exit the game)' f' (use babase.quit() to exit the game)'
) )
_babase.screenmessage('Created User System Scripts') _babase.screenmessage('Created User System Scripts', color=(0, 1, 0))
if app.classic is not None and app.classic.platform == 'android': if app.classic is not None and app.classic.platform == 'android':
print( print(
'Note: the new files may not be visible via ' 'Note: the new files may not be visible via '
@ -186,9 +194,10 @@ def delete_user_system_scripts() -> None:
f'Restart {_babase.appname()} to use internal' f'Restart {_babase.appname()} to use internal'
f' scripts. (use babase.quit() to exit the game)' f' scripts. (use babase.quit() to exit the game)'
) )
_babase.screenmessage('Deleted User System Scripts') _babase.screenmessage('Deleted User System Scripts', color=(0, 1, 0))
else: else:
print(f"User system scripts not found at '{path}'.") print(f"User system scripts not found at '{path}'.")
_babase.screenmessage('User Scripts Not Found', color=(1, 0, 0))
# If the sys path is empty, kill it. # If the sys path is empty, kill it.
dpath = env.python_directory_user + '/sys' dpath = env.python_directory_user + '/sys'

View File

@ -1,6 +1,7 @@
# Released under the MIT License. See LICENSE for details. # Released under the MIT License. See LICENSE for details.
# #
"""UI functionality for advanced settings.""" """UI functionality for advanced settings."""
# pylint: disable=too-many-lines
from __future__ import annotations from __future__ import annotations
@ -585,7 +586,7 @@ class AdvancedSettingsWindow(bui.Window):
position=(self._sub_width / 2 - this_button_width / 2, v - 10), position=(self._sub_width / 2 - this_button_width / 2, v - 10),
size=(this_button_width, 60), size=(this_button_width, 60),
autoselect=True, autoselect=True,
label=bui.Lstr(value='Modding Tools'), label=bui.Lstr(resource=f'{self._r}.moddingToolsText'),
text_scale=1.0, text_scale=1.0,
on_activate_call=self._on_modding_tools_button_press, on_activate_call=self._on_modding_tools_button_press,
) )
@ -779,6 +780,7 @@ class AdvancedSettingsWindow(bui.Window):
) )
def _on_modding_tools_button_press(self) -> None: def _on_modding_tools_button_press(self) -> None:
# pylint: disable=cyclic-import
from bauiv1lib.settings.moddingtools import ModdingToolsWindow from bauiv1lib.settings.moddingtools import ModdingToolsWindow
# no-op if our underlying widget is dead or on its way out. # no-op if our underlying widget is dead or on its way out.
@ -789,7 +791,9 @@ class AdvancedSettingsWindow(bui.Window):
bui.containerwidget(edit=self._root_widget, transition='out_left') bui.containerwidget(edit=self._root_widget, transition='out_left')
assert bui.app.classic is not None assert bui.app.classic is not None
bui.app.ui_v1.set_main_menu_window( bui.app.ui_v1.set_main_menu_window(
ModdingToolsWindow(origin_widget=self._modding_tools_button).get_root_widget(), ModdingToolsWindow(
origin_widget=self._modding_tools_button
).get_root_widget(),
from_window=self._root_widget, from_window=self._root_widget,
) )
@ -836,6 +840,7 @@ class AdvancedSettingsWindow(bui.Window):
def _save_state(self) -> None: def _save_state(self) -> None:
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
# pylint: disable=too-many-statements
try: try:
sel = self._root_widget.get_selected_child() sel = self._root_widget.get_selected_child()
if sel == self._scrollwidget: if sel == self._scrollwidget:

View File

@ -95,8 +95,7 @@ class ModdingToolsWindow(bui.Window):
parent=self._root_widget, parent=self._root_widget,
position=(0, self._height - 52), position=(0, self._height - 52),
size=(self._width, 25), size=(self._width, 25),
# text=bui.Lstr(resource=f'{self._r}.titleText'), text=bui.Lstr(resource='moddingToolsTitleText'),
text=bui.Lstr(value='Modding Tools'),
color=app.ui_v1.title_color, color=app.ui_v1.title_color,
h_align='center', h_align='center',
v_align='top', v_align='top',
@ -135,7 +134,7 @@ class ModdingToolsWindow(bui.Window):
position=(self._sub_width / 2 - this_button_width / 2, v - 10), position=(self._sub_width / 2 - this_button_width / 2, v - 10),
size=(this_button_width, 60), size=(this_button_width, 60),
autoselect=True, autoselect=True,
label=bui.Lstr(value='Create User System Scripts'), label=bui.Lstr(resource='createUserSystemScriptsText'),
text_scale=1.0, text_scale=1.0,
on_activate_call=babase.modutils.create_user_system_scripts, on_activate_call=babase.modutils.create_user_system_scripts,
) )
@ -146,7 +145,7 @@ class ModdingToolsWindow(bui.Window):
position=(self._sub_width / 2 - this_button_width / 2, v - 10), position=(self._sub_width / 2 - this_button_width / 2, v - 10),
size=(this_button_width, 60), size=(this_button_width, 60),
autoselect=True, autoselect=True,
label=bui.Lstr(value='Delete User System Scripts'), label=bui.Lstr(resource='deleteUserSystemScriptsText'),
text_scale=1.0, text_scale=1.0,
on_activate_call=lambda: ConfirmWindow( on_activate_call=lambda: ConfirmWindow(
action=babase.modutils.delete_user_system_scripts, action=babase.modutils.delete_user_system_scripts,
@ -170,10 +169,10 @@ class ModdingToolsWindow(bui.Window):
button_size=(200.0, 60.0), button_size=(200.0, 60.0),
choices=['auto','small', 'medium', 'large',], choices=['auto','small', 'medium', 'large',],
choices_display=[ choices_display=[
bui.Lstr(value='autoText'), bui.Lstr(resource='autoText'),
bui.Lstr(value='smallText'), bui.Lstr(resource='smallText'),
bui.Lstr(value='mediumText'), bui.Lstr(resource='mediumText'),
bui.Lstr(value='largeText'), bui.Lstr(resource='largeText'),
], ],
current_choice=app.config.get('UI Scale', 'auto'), current_choice=app.config.get('UI Scale', 'auto'),
on_value_change_call=self._set_uiscale, on_value_change_call=self._set_uiscale,