mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-08 08:45:43 +08:00
Editing advanced.py and adding devtools.py
This commit is contained in:
parent
06f0e18f6d
commit
48d7fabcad
@ -1,7 +1,7 @@
|
|||||||
# Released under the MIT License. See LICENSE for details.
|
# Released under the MIT License. See LICENSE for details.
|
||||||
#
|
#
|
||||||
# pylint: disable=too-many-lines
|
|
||||||
"""UI functionality for advanced settings."""
|
"""UI functionality for advanced settings."""
|
||||||
|
# pylint: disable=too-many-lines
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
self._scroll_width = self._width - (100 + 2 * x_inset)
|
self._scroll_width = self._width - (100 + 2 * x_inset)
|
||||||
self._scroll_height = self._height - 115.0
|
self._scroll_height = self._height - 115.0
|
||||||
self._sub_width = self._scroll_width * 0.95
|
self._sub_width = self._scroll_width * 0.95
|
||||||
self._sub_height = 912.0
|
self._sub_height = 808.0
|
||||||
|
|
||||||
if self._show_always_use_internal_keyboard:
|
if self._show_always_use_internal_keyboard:
|
||||||
self._sub_height += 62
|
self._sub_height += 62
|
||||||
@ -109,7 +109,7 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
if self._do_net_test_button:
|
if self._do_net_test_button:
|
||||||
self._sub_height += self._extra_button_spacing
|
self._sub_height += self._extra_button_spacing
|
||||||
self._sub_height += self._spacing * 2.0 # plugins
|
self._sub_height += self._spacing * 2.0 # plugins
|
||||||
self._sub_height += self._spacing * 2.0 # modding tools
|
self._sub_height += self._spacing * 2.0 # dev tools
|
||||||
|
|
||||||
self._r = 'settingsWindowAdvanced'
|
self._r = 'settingsWindowAdvanced'
|
||||||
|
|
||||||
@ -191,10 +191,10 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
from bauiv1lib.settings import nettesting as _unused4
|
from bauiv1lib.settings import nettesting as _unused4
|
||||||
from bauiv1lib import appinvite as _unused5
|
from bauiv1lib import appinvite as _unused5
|
||||||
from bauiv1lib import account as _unused6
|
from bauiv1lib import account as _unused6
|
||||||
from bauiv1lib import sendinfo as _unused7
|
from bauiv1lib import promocode as _unused7
|
||||||
from bauiv1lib import debug as _unused8
|
from bauiv1lib import debug as _unused8
|
||||||
from bauiv1lib.settings import plugins as _unused9
|
from bauiv1lib.settings import plugins as _unused9
|
||||||
from bauiv1lib.settings import moddingtools as _unused10
|
from bauiv1lib.settings import devtools as _unused10
|
||||||
|
|
||||||
def _update_lang_status(self) -> None:
|
def _update_lang_status(self) -> None:
|
||||||
if self._complete_langs_list is not None:
|
if self._complete_langs_list is not None:
|
||||||
@ -289,16 +289,33 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
|
|
||||||
this_button_width = 410
|
this_button_width = 410
|
||||||
|
|
||||||
|
self._promo_code_button = bui.buttonwidget(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(self._sub_width / 2 - this_button_width / 2, v - 14),
|
||||||
|
size=(this_button_width, 60),
|
||||||
|
autoselect=True,
|
||||||
|
label=bui.Lstr(resource=f'{self._r}.enterPromoCodeText'),
|
||||||
|
text_scale=1.0,
|
||||||
|
on_activate_call=self._on_promo_code_press,
|
||||||
|
)
|
||||||
|
if self._back_button is not None:
|
||||||
|
bui.widget(
|
||||||
|
edit=self._promo_code_button,
|
||||||
|
up_widget=self._back_button,
|
||||||
|
left_widget=self._back_button,
|
||||||
|
)
|
||||||
|
v -= self._extra_button_spacing * 0.8
|
||||||
|
|
||||||
assert bui.app.classic is not None
|
assert bui.app.classic is not None
|
||||||
bui.textwidget(
|
bui.textwidget(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
position=(70, v + 10),
|
position=(200, v + 10),
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
text=bui.Lstr(resource=f'{self._r}.languageText'),
|
text=bui.Lstr(resource=f'{self._r}.languageText'),
|
||||||
maxwidth=150,
|
maxwidth=150,
|
||||||
scale=1.2,
|
scale=0.95,
|
||||||
color=bui.app.ui_v1.title_color,
|
color=bui.app.ui_v1.title_color,
|
||||||
h_align='left',
|
h_align='right',
|
||||||
v_align='center',
|
v_align='center',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -377,7 +394,7 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
|
|
||||||
bui.textwidget(
|
bui.textwidget(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
position=(90, v + 10),
|
position=(self._sub_width * 0.5, v + 10),
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
text=bui.Lstr(
|
text=bui.Lstr(
|
||||||
resource=f'{self._r}.helpTranslateText',
|
resource=f'{self._r}.helpTranslateText',
|
||||||
@ -388,7 +405,7 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
flatness=1.0,
|
flatness=1.0,
|
||||||
scale=0.65,
|
scale=0.65,
|
||||||
color=(0.4, 0.9, 0.4, 0.8),
|
color=(0.4, 0.9, 0.4, 0.8),
|
||||||
h_align='left',
|
h_align='center',
|
||||||
v_align='center',
|
v_align='center',
|
||||||
)
|
)
|
||||||
v -= self._spacing * 1.9
|
v -= self._spacing * 1.9
|
||||||
@ -419,7 +436,7 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
maxwidth=400.0,
|
maxwidth=400.0,
|
||||||
)
|
)
|
||||||
self._update_lang_status()
|
self._update_lang_status()
|
||||||
v -= 50
|
v -= 40
|
||||||
|
|
||||||
lang_inform = plus.get_v1_account_misc_val('langInform', False)
|
lang_inform = plus.get_v1_account_misc_val('langInform', False)
|
||||||
|
|
||||||
@ -466,19 +483,6 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
maxwidth=430,
|
maxwidth=430,
|
||||||
)
|
)
|
||||||
|
|
||||||
v -= 42
|
|
||||||
self._show_dev_console_button_check_box = ConfigCheckBox(
|
|
||||||
parent=self._subcontainer,
|
|
||||||
position=(50, v),
|
|
||||||
size=(self._sub_width - 100, 30),
|
|
||||||
configkey='Show Dev Console Button',
|
|
||||||
displayname=bui.Lstr(
|
|
||||||
resource=f'{self._r}.showDevConsoleButtonText'
|
|
||||||
),
|
|
||||||
scale=1.0,
|
|
||||||
maxwidth=430,
|
|
||||||
)
|
|
||||||
|
|
||||||
v -= 42
|
v -= 42
|
||||||
self._show_demos_when_idle_check_box = ConfigCheckBox(
|
self._show_demos_when_idle_check_box = ConfigCheckBox(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
@ -490,19 +494,6 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
maxwidth=430,
|
maxwidth=430,
|
||||||
)
|
)
|
||||||
|
|
||||||
v -= 42
|
|
||||||
self._show_deprecated_login_types_check_box = ConfigCheckBox(
|
|
||||||
parent=self._subcontainer,
|
|
||||||
position=(50, v),
|
|
||||||
size=(self._sub_width - 100, 30),
|
|
||||||
configkey='Show Deprecated Login Types',
|
|
||||||
displayname=bui.Lstr(
|
|
||||||
resource=f'{self._r}.showDeprecatedLoginTypesText'
|
|
||||||
),
|
|
||||||
scale=1.0,
|
|
||||||
maxwidth=430,
|
|
||||||
)
|
|
||||||
|
|
||||||
v -= 42
|
v -= 42
|
||||||
self._disable_camera_shake_check_box = ConfigCheckBox(
|
self._disable_camera_shake_check_box = ConfigCheckBox(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
@ -581,14 +572,14 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
|
|
||||||
v -= self._spacing * 2.0
|
v -= self._spacing * 2.0
|
||||||
|
|
||||||
self._modding_tools_button = bui.buttonwidget(
|
self._dev_tools_button = bui.buttonwidget(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
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(resource=f'{self._r}.moddingToolsText'),
|
label=bui.Lstr(resource=f'{self._r}.devToolsText'),
|
||||||
text_scale=1.0,
|
text_scale=1.0,
|
||||||
on_activate_call=self._on_modding_tools_button_press,
|
on_activate_call=self._on_dev_tools_button_press,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._show_always_use_internal_keyboard:
|
if self._show_always_use_internal_keyboard:
|
||||||
@ -684,17 +675,6 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
on_activate_call=self._on_benchmark_press,
|
on_activate_call=self._on_benchmark_press,
|
||||||
)
|
)
|
||||||
|
|
||||||
v -= 100
|
|
||||||
self._send_info_button = bui.buttonwidget(
|
|
||||||
parent=self._subcontainer,
|
|
||||||
position=(self._sub_width / 2 - this_button_width / 2, v - 14),
|
|
||||||
size=(this_button_width, 60),
|
|
||||||
autoselect=True,
|
|
||||||
label=bui.Lstr(resource=f'{self._r}.sendInfoText'),
|
|
||||||
text_scale=1.0,
|
|
||||||
on_activate_call=self._on_send_info_press,
|
|
||||||
)
|
|
||||||
|
|
||||||
for child in self._subcontainer.get_children():
|
for child in self._subcontainer.get_children():
|
||||||
bui.widget(edit=child, show_buffer_bottom=30, show_buffer_top=20)
|
bui.widget(edit=child, show_buffer_bottom=30, show_buffer_top=20)
|
||||||
|
|
||||||
@ -747,6 +727,14 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
if not self._root_widget or self._root_widget.transitioning_out:
|
if not self._root_widget or self._root_widget.transitioning_out:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Net-testing requires a signed in v1 account.
|
||||||
|
if plus.get_v1_account_state() != 'signed_in':
|
||||||
|
bui.screenmessage(
|
||||||
|
bui.Lstr(resource='notSignedInErrorText'), color=(1, 0, 0)
|
||||||
|
)
|
||||||
|
bui.getsound('error').play()
|
||||||
|
return
|
||||||
|
|
||||||
self._save_state()
|
self._save_state()
|
||||||
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
|
||||||
@ -782,9 +770,9 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
from_window=self._root_widget,
|
from_window=self._root_widget,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _on_modding_tools_button_press(self) -> None:
|
def _on_dev_tools_button_press(self) -> None:
|
||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
from bauiv1lib.settings.moddingtools import ModdingToolsWindow
|
from bauiv1lib.settings.devtools import DevToolsWindow
|
||||||
|
|
||||||
# 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.
|
||||||
if not self._root_widget or self._root_widget.transitioning_out:
|
if not self._root_widget or self._root_widget.transitioning_out:
|
||||||
@ -794,14 +782,15 @@ 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(
|
DevToolsWindow(
|
||||||
origin_widget=self._modding_tools_button
|
origin_widget=self._dev_tools_button
|
||||||
).get_root_widget(),
|
).get_root_widget(),
|
||||||
from_window=self._root_widget,
|
from_window=self._root_widget,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _on_send_info_press(self) -> None:
|
def _on_promo_code_press(self) -> None:
|
||||||
from bauiv1lib.sendinfo import SendInfoWindow
|
from bauiv1lib.promocode import PromoCodeWindow
|
||||||
|
from bauiv1lib.account import show_sign_in_prompt
|
||||||
|
|
||||||
# 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.
|
||||||
if not self._root_widget or self._root_widget.transitioning_out:
|
if not self._root_widget or self._root_widget.transitioning_out:
|
||||||
@ -810,12 +799,17 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
plus = bui.app.plus
|
plus = bui.app.plus
|
||||||
assert plus is not None
|
assert plus is not None
|
||||||
|
|
||||||
|
# We have to be logged in for promo-codes to work.
|
||||||
|
if plus.get_v1_account_state() != 'signed_in':
|
||||||
|
show_sign_in_prompt()
|
||||||
|
return
|
||||||
|
|
||||||
self._save_state()
|
self._save_state()
|
||||||
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(
|
||||||
SendInfoWindow(
|
PromoCodeWindow(
|
||||||
origin_widget=self._send_info_button
|
origin_widget=self._promo_code_button
|
||||||
).get_root_widget(),
|
).get_root_widget(),
|
||||||
from_window=self._root_widget,
|
from_window=self._root_widget,
|
||||||
)
|
)
|
||||||
@ -846,16 +840,14 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
sel_name = 'VRTest'
|
sel_name = 'VRTest'
|
||||||
elif sel == self._net_test_button:
|
elif sel == self._net_test_button:
|
||||||
sel_name = 'NetTest'
|
sel_name = 'NetTest'
|
||||||
elif sel == self._send_info_button:
|
elif sel == self._promo_code_button:
|
||||||
sel_name = 'SendInfo'
|
sel_name = 'PromoCode'
|
||||||
elif sel == self._benchmarks_button:
|
elif sel == self._benchmarks_button:
|
||||||
sel_name = 'Benchmarks'
|
sel_name = 'Benchmarks'
|
||||||
elif sel == self._kick_idle_players_check_box.widget:
|
elif sel == self._kick_idle_players_check_box.widget:
|
||||||
sel_name = 'KickIdlePlayers'
|
sel_name = 'KickIdlePlayers'
|
||||||
elif sel == self._show_demos_when_idle_check_box.widget:
|
elif sel == self._show_demos_when_idle_check_box.widget:
|
||||||
sel_name = 'ShowDemosWhenIdle'
|
sel_name = 'ShowDemosWhenIdle'
|
||||||
elif sel == self._show_deprecated_login_types_check_box.widget:
|
|
||||||
sel_name = 'ShowDeprecatedLoginTypes'
|
|
||||||
elif sel == self._show_game_ping_check_box.widget:
|
elif sel == self._show_game_ping_check_box.widget:
|
||||||
sel_name = 'ShowPing'
|
sel_name = 'ShowPing'
|
||||||
elif sel == self._disable_camera_shake_check_box.widget:
|
elif sel == self._disable_camera_shake_check_box.widget:
|
||||||
@ -882,14 +874,12 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
sel_name = 'ShowUserMods'
|
sel_name = 'ShowUserMods'
|
||||||
elif sel == self._plugins_button:
|
elif sel == self._plugins_button:
|
||||||
sel_name = 'Plugins'
|
sel_name = 'Plugins'
|
||||||
elif sel == self._modding_tools_button:
|
elif sel == self._dev_tools_button:
|
||||||
sel_name = 'ModdingTools'
|
sel_name = 'DevTools'
|
||||||
elif sel == self._modding_guide_button:
|
elif sel == self._modding_guide_button:
|
||||||
sel_name = 'ModdingGuide'
|
sel_name = 'ModdingGuide'
|
||||||
elif sel == self._language_inform_checkbox:
|
elif sel == self._language_inform_checkbox:
|
||||||
sel_name = 'LangInform'
|
sel_name = 'LangInform'
|
||||||
elif sel == self._show_dev_console_button_check_box.widget:
|
|
||||||
sel_name = 'ShowDevConsole'
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'unrecognized selection \'{sel}\'')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
elif sel == self._back_button:
|
elif sel == self._back_button:
|
||||||
@ -904,7 +894,6 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
|
|
||||||
def _restore_state(self) -> None:
|
def _restore_state(self) -> None:
|
||||||
# pylint: disable=too-many-branches
|
# pylint: disable=too-many-branches
|
||||||
# pylint: disable=too-many-statements
|
|
||||||
try:
|
try:
|
||||||
assert bui.app.classic is not None
|
assert bui.app.classic is not None
|
||||||
sel_name = bui.app.ui_v1.window_states.get(type(self), {}).get(
|
sel_name = bui.app.ui_v1.window_states.get(type(self), {}).get(
|
||||||
@ -920,16 +909,14 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
sel = self._vr_test_button
|
sel = self._vr_test_button
|
||||||
elif sel_name == 'NetTest':
|
elif sel_name == 'NetTest':
|
||||||
sel = self._net_test_button
|
sel = self._net_test_button
|
||||||
elif sel_name == 'SendInfo':
|
elif sel_name == 'PromoCode':
|
||||||
sel = self._send_info_button
|
sel = self._promo_code_button
|
||||||
elif sel_name == 'Benchmarks':
|
elif sel_name == 'Benchmarks':
|
||||||
sel = self._benchmarks_button
|
sel = self._benchmarks_button
|
||||||
elif sel_name == 'KickIdlePlayers':
|
elif sel_name == 'KickIdlePlayers':
|
||||||
sel = self._kick_idle_players_check_box.widget
|
sel = self._kick_idle_players_check_box.widget
|
||||||
elif sel_name == 'ShowDemosWhenIdle':
|
elif sel_name == 'ShowDemosWhenIdle':
|
||||||
sel = self._show_demos_when_idle_check_box.widget
|
sel = self._show_demos_when_idle_check_box.widget
|
||||||
elif sel_name == 'ShowDeprecatedLoginTypes':
|
|
||||||
sel = self._show_deprecated_login_types_check_box.widget
|
|
||||||
elif sel_name == 'ShowPing':
|
elif sel_name == 'ShowPing':
|
||||||
sel = self._show_game_ping_check_box.widget
|
sel = self._show_game_ping_check_box.widget
|
||||||
elif sel_name == 'DisableCameraShake':
|
elif sel_name == 'DisableCameraShake':
|
||||||
@ -954,14 +941,12 @@ class AdvancedSettingsWindow(bui.Window):
|
|||||||
sel = self._show_user_mods_button
|
sel = self._show_user_mods_button
|
||||||
elif sel_name == 'Plugins':
|
elif sel_name == 'Plugins':
|
||||||
sel = self._plugins_button
|
sel = self._plugins_button
|
||||||
elif sel_name == 'ModdingTools':
|
elif sel_name == 'DevTools':
|
||||||
sel = self._modding_tools_button
|
sel = self._dev_tools_button
|
||||||
elif sel_name == 'ModdingGuide':
|
elif sel_name == 'ModdingGuide':
|
||||||
sel = self._modding_guide_button
|
sel = self._modding_guide_button
|
||||||
elif sel_name == 'LangInform':
|
elif sel_name == 'LangInform':
|
||||||
sel = self._language_inform_checkbox
|
sel = self._language_inform_checkbox
|
||||||
elif sel_name == 'ShowDevConsole':
|
|
||||||
sel = self._show_dev_console_button_check_box.widget
|
|
||||||
else:
|
else:
|
||||||
sel = None
|
sel = None
|
||||||
if sel is not None:
|
if sel is not None:
|
||||||
|
|||||||
225
src/assets/ba_data/python/bauiv1lib/settings/devtools.py
Normal file
225
src/assets/ba_data/python/bauiv1lib/settings/devtools.py
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
# Released under the MIT License. See LICENSE for details.
|
||||||
|
#
|
||||||
|
"""UI functionality for Modding Tools."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import babase
|
||||||
|
import bauiv1 as bui
|
||||||
|
from bauiv1lib.popup import PopupMenu
|
||||||
|
from bauiv1lib.confirm import ConfirmWindow
|
||||||
|
from bauiv1lib.config import ConfigCheckBox
|
||||||
|
|
||||||
|
|
||||||
|
class DevToolsWindow(bui.Window):
|
||||||
|
"""Window for accessing modding tools."""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
transition: str = 'in_right',
|
||||||
|
origin_widget: bui.Widget | None = None,
|
||||||
|
):
|
||||||
|
|
||||||
|
app = bui.app
|
||||||
|
assert app.classic is not None
|
||||||
|
|
||||||
|
# If they provided an origin-widget, scale up from that.
|
||||||
|
scale_origin: tuple[float, float] | None
|
||||||
|
if origin_widget is not None:
|
||||||
|
self._transition_out = 'out_scale'
|
||||||
|
scale_origin = origin_widget.get_screen_space_center()
|
||||||
|
transition = 'in_scale'
|
||||||
|
else:
|
||||||
|
self._transition_out = 'out_right'
|
||||||
|
scale_origin = None
|
||||||
|
|
||||||
|
uiscale = app.ui_v1.uiscale
|
||||||
|
self._width = 970.0 if uiscale is bui.UIScale.SMALL else 670.0
|
||||||
|
x_inset = 150 if uiscale is bui.UIScale.SMALL else 0
|
||||||
|
self._height = (
|
||||||
|
390.0
|
||||||
|
if uiscale is bui.UIScale.SMALL
|
||||||
|
else 450.0 if uiscale is bui.UIScale.MEDIUM else 520.0
|
||||||
|
)
|
||||||
|
|
||||||
|
self._spacing = 32
|
||||||
|
top_extra = 10 if uiscale is bui.UIScale.SMALL else 0
|
||||||
|
|
||||||
|
self._scroll_width = self._width - (100 + 2 * x_inset)
|
||||||
|
self._scroll_height = self._height - 115.0
|
||||||
|
self._sub_width = self._scroll_width * 0.95
|
||||||
|
self._sub_height = 350.0
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
root_widget=bui.containerwidget(
|
||||||
|
size=(self._width, self._height + top_extra),
|
||||||
|
transition=transition,
|
||||||
|
toolbar_visibility='menu_minimal',
|
||||||
|
scale_origin_stack_offset=scale_origin,
|
||||||
|
scale=(
|
||||||
|
2.06
|
||||||
|
if uiscale is bui.UIScale.SMALL
|
||||||
|
else 1.4 if uiscale is bui.UIScale.MEDIUM else 1.0
|
||||||
|
),
|
||||||
|
stack_offset=(
|
||||||
|
(0, -25) if uiscale is bui.UIScale.SMALL else (0, 0)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self._r = 'settingsDevTools'
|
||||||
|
|
||||||
|
if app.ui_v1.use_toolbars and uiscale is bui.UIScale.SMALL:
|
||||||
|
bui.containerwidget(
|
||||||
|
edit=self._root_widget, on_cancel_call=self._do_back
|
||||||
|
)
|
||||||
|
self._back_button = None
|
||||||
|
else:
|
||||||
|
self._back_button = bui.buttonwidget(
|
||||||
|
parent=self._root_widget,
|
||||||
|
position=(53 + x_inset, self._height - 60),
|
||||||
|
size=(140, 60),
|
||||||
|
scale=0.8,
|
||||||
|
autoselect=True,
|
||||||
|
label=bui.Lstr(resource='backText'),
|
||||||
|
button_type='back',
|
||||||
|
on_activate_call=self._do_back,
|
||||||
|
)
|
||||||
|
bui.containerwidget(
|
||||||
|
edit=self._root_widget, cancel_button=self._back_button
|
||||||
|
)
|
||||||
|
|
||||||
|
self._title_text = bui.textwidget(
|
||||||
|
parent=self._root_widget,
|
||||||
|
position=(0, self._height - 52),
|
||||||
|
size=(self._width, 25),
|
||||||
|
text=bui.Lstr(resource='settingsWindowAdvanced.devToolsText'),
|
||||||
|
color=app.ui_v1.title_color,
|
||||||
|
h_align='center',
|
||||||
|
v_align='top',
|
||||||
|
)
|
||||||
|
|
||||||
|
if self._back_button is not None:
|
||||||
|
bui.buttonwidget(
|
||||||
|
edit=self._back_button,
|
||||||
|
button_type='backSmall',
|
||||||
|
size=(60, 60),
|
||||||
|
label=bui.charstr(bui.SpecialChar.BACK),
|
||||||
|
)
|
||||||
|
|
||||||
|
self._scrollwidget = bui.scrollwidget(
|
||||||
|
parent=self._root_widget,
|
||||||
|
position=(50 + x_inset, 50),
|
||||||
|
simple_culling_v=20.0,
|
||||||
|
highlight=False,
|
||||||
|
size=(self._scroll_width, self._scroll_height),
|
||||||
|
selection_loops_to_parent=True,
|
||||||
|
)
|
||||||
|
bui.widget(edit=self._scrollwidget, right_widget=self._scrollwidget)
|
||||||
|
self._subcontainer = bui.containerwidget(
|
||||||
|
parent=self._scrollwidget,
|
||||||
|
size=(self._sub_width, self._sub_height),
|
||||||
|
background=False,
|
||||||
|
selection_loops_to_parent=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
v = self._sub_height - 35
|
||||||
|
this_button_width = 410
|
||||||
|
|
||||||
|
v -= self._spacing * 1.2
|
||||||
|
self._create_user_system_scripts_button = bui.buttonwidget(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(self._sub_width / 2 - this_button_width / 2, v - 10),
|
||||||
|
size=(this_button_width, 60),
|
||||||
|
autoselect=True,
|
||||||
|
label=bui.Lstr(resource='userSystemScriptsCreateText'),
|
||||||
|
text_scale=1.0,
|
||||||
|
on_activate_call=babase.modutils.create_user_system_scripts,
|
||||||
|
)
|
||||||
|
|
||||||
|
v -= self._spacing * 2.5
|
||||||
|
self._delete_user_system_scripts_button = bui.buttonwidget(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(self._sub_width / 2 - this_button_width / 2, v - 10),
|
||||||
|
size=(this_button_width, 60),
|
||||||
|
autoselect=True,
|
||||||
|
label=bui.Lstr(resource='userSystemScriptsDeleteText'),
|
||||||
|
text_scale=1.0,
|
||||||
|
on_activate_call=lambda: ConfirmWindow(
|
||||||
|
action=babase.modutils.delete_user_system_scripts,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
v -= self._spacing * 2.5
|
||||||
|
bui.textwidget(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(170, v + 10),
|
||||||
|
size=(0, 0),
|
||||||
|
text=bui.Lstr(
|
||||||
|
value='$(S) :',
|
||||||
|
subs=[('$(S)', bui.Lstr(resource='uiScaleText'))],
|
||||||
|
),
|
||||||
|
color=app.ui_v1.title_color,
|
||||||
|
h_align='center',
|
||||||
|
v_align='center',
|
||||||
|
)
|
||||||
|
|
||||||
|
PopupMenu(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(230, v - 20),
|
||||||
|
button_size=(200.0, 60.0),
|
||||||
|
width=100.0,
|
||||||
|
choices=[
|
||||||
|
'auto',
|
||||||
|
'small',
|
||||||
|
'medium',
|
||||||
|
'large',
|
||||||
|
],
|
||||||
|
choices_display=[
|
||||||
|
bui.Lstr(resource='autoText'),
|
||||||
|
bui.Lstr(resource='sizeSmallText'),
|
||||||
|
bui.Lstr(resource='sizeMediumText'),
|
||||||
|
bui.Lstr(resource='sizeLargeText'),
|
||||||
|
],
|
||||||
|
current_choice=app.config.get('UI Scale', 'auto'),
|
||||||
|
on_value_change_call=self._set_uiscale,
|
||||||
|
)
|
||||||
|
|
||||||
|
v -= self._spacing * 2.5
|
||||||
|
self._show_dev_console_button_check_box = ConfigCheckBox(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(50, v),
|
||||||
|
size=(self._sub_width - 100, 30),
|
||||||
|
configkey='Show Dev Console Button',
|
||||||
|
displayname=bui.Lstr(
|
||||||
|
resource='settingsWindowAdvanced.showDevConsoleButtonText'
|
||||||
|
),
|
||||||
|
scale=1.0,
|
||||||
|
maxwidth=430,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _set_uiscale(self, val: str) -> None:
|
||||||
|
cfg = bui.app.config
|
||||||
|
cfg['UI Scale'] = val
|
||||||
|
cfg.apply_and_commit()
|
||||||
|
if bui.app.ui_v1.uiscale.name != val.upper():
|
||||||
|
bui.screenmessage(
|
||||||
|
bui.Lstr(resource='settingsWindowAdvanced.mustRestartText'),
|
||||||
|
color=(1.0, 0.5, 0.0),
|
||||||
|
)
|
||||||
|
|
||||||
|
def _do_back(self) -> None:
|
||||||
|
from bauiv1lib.settings.advanced import AdvancedSettingsWindow
|
||||||
|
|
||||||
|
# no-op if our underlying widget is dead or on its way out.
|
||||||
|
if not self._root_widget or self._root_widget.transitioning_out:
|
||||||
|
return
|
||||||
|
|
||||||
|
bui.containerwidget(
|
||||||
|
edit=self._root_widget, transition=self._transition_out
|
||||||
|
)
|
||||||
|
assert bui.app.classic is not None
|
||||||
|
bui.app.ui_v1.set_main_menu_window(
|
||||||
|
AdvancedSettingsWindow(transition='in_left').get_root_widget(),
|
||||||
|
from_window=self._root_widget,
|
||||||
|
)
|
||||||
Loading…
x
Reference in New Issue
Block a user