From 06f0e18f6d3824cb7a605c8f8c78ad8fbd54d643 Mon Sep 17 00:00:00 2001 From: Vishal Date: Thu, 9 May 2024 02:00:26 +0530 Subject: [PATCH 1/4] Deleted moddingtools.py --- .../python/bauiv1lib/settings/moddingtools.py | 211 ------------------ 1 file changed, 211 deletions(-) delete mode 100644 src/assets/ba_data/python/bauiv1lib/settings/moddingtools.py diff --git a/src/assets/ba_data/python/bauiv1lib/settings/moddingtools.py b/src/assets/ba_data/python/bauiv1lib/settings/moddingtools.py deleted file mode 100644 index e2874a4a..00000000 --- a/src/assets/ba_data/python/bauiv1lib/settings/moddingtools.py +++ /dev/null @@ -1,211 +0,0 @@ -# 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 - - -class ModdingToolsWindow(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 = 100.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 = 'settingsModdingTools' - - 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.moddingToolsText'), - 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, - ) - - 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, - ) From 48d7fabcad0e81ac5233f31341d6b5590c2140a2 Mon Sep 17 00:00:00 2001 From: Vishal Date: Thu, 9 May 2024 02:01:40 +0530 Subject: [PATCH 2/4] Editing advanced.py and adding devtools.py --- .../python/bauiv1lib/settings/advanced.py | 137 +++++------ .../python/bauiv1lib/settings/devtools.py | 225 ++++++++++++++++++ 2 files changed, 286 insertions(+), 76 deletions(-) create mode 100644 src/assets/ba_data/python/bauiv1lib/settings/devtools.py diff --git a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py index 2a6ccc4d..3fe0b185 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py @@ -1,7 +1,7 @@ # Released under the MIT License. See LICENSE for details. # -# pylint: disable=too-many-lines """UI functionality for advanced settings.""" +# pylint: disable=too-many-lines from __future__ import annotations @@ -91,7 +91,7 @@ class AdvancedSettingsWindow(bui.Window): 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 = 912.0 + self._sub_height = 808.0 if self._show_always_use_internal_keyboard: self._sub_height += 62 @@ -109,7 +109,7 @@ class AdvancedSettingsWindow(bui.Window): if self._do_net_test_button: self._sub_height += self._extra_button_spacing 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' @@ -191,10 +191,10 @@ class AdvancedSettingsWindow(bui.Window): from bauiv1lib.settings import nettesting as _unused4 from bauiv1lib import appinvite as _unused5 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.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: if self._complete_langs_list is not None: @@ -289,16 +289,33 @@ class AdvancedSettingsWindow(bui.Window): 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 bui.textwidget( parent=self._subcontainer, - position=(70, v + 10), + position=(200, v + 10), size=(0, 0), text=bui.Lstr(resource=f'{self._r}.languageText'), maxwidth=150, - scale=1.2, + scale=0.95, color=bui.app.ui_v1.title_color, - h_align='left', + h_align='right', v_align='center', ) @@ -377,7 +394,7 @@ class AdvancedSettingsWindow(bui.Window): bui.textwidget( parent=self._subcontainer, - position=(90, v + 10), + position=(self._sub_width * 0.5, v + 10), size=(0, 0), text=bui.Lstr( resource=f'{self._r}.helpTranslateText', @@ -388,7 +405,7 @@ class AdvancedSettingsWindow(bui.Window): flatness=1.0, scale=0.65, color=(0.4, 0.9, 0.4, 0.8), - h_align='left', + h_align='center', v_align='center', ) v -= self._spacing * 1.9 @@ -419,7 +436,7 @@ class AdvancedSettingsWindow(bui.Window): maxwidth=400.0, ) self._update_lang_status() - v -= 50 + v -= 40 lang_inform = plus.get_v1_account_misc_val('langInform', False) @@ -466,19 +483,6 @@ class AdvancedSettingsWindow(bui.Window): 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 self._show_demos_when_idle_check_box = ConfigCheckBox( parent=self._subcontainer, @@ -490,19 +494,6 @@ class AdvancedSettingsWindow(bui.Window): 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 self._disable_camera_shake_check_box = ConfigCheckBox( parent=self._subcontainer, @@ -581,14 +572,14 @@ class AdvancedSettingsWindow(bui.Window): v -= self._spacing * 2.0 - self._modding_tools_button = bui.buttonwidget( + self._dev_tools_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=f'{self._r}.moddingToolsText'), + label=bui.Lstr(resource=f'{self._r}.devToolsText'), 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: @@ -684,17 +675,6 @@ class AdvancedSettingsWindow(bui.Window): 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(): 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: 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() bui.containerwidget(edit=self._root_widget, transition='out_left') assert bui.app.classic is not None @@ -782,9 +770,9 @@ class AdvancedSettingsWindow(bui.Window): 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 - 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. 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') assert bui.app.classic is not None bui.app.ui_v1.set_main_menu_window( - ModdingToolsWindow( - origin_widget=self._modding_tools_button + DevToolsWindow( + origin_widget=self._dev_tools_button ).get_root_widget(), from_window=self._root_widget, ) - def _on_send_info_press(self) -> None: - from bauiv1lib.sendinfo import SendInfoWindow + def _on_promo_code_press(self) -> None: + 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. if not self._root_widget or self._root_widget.transitioning_out: @@ -810,12 +799,17 @@ class AdvancedSettingsWindow(bui.Window): plus = bui.app.plus 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() bui.containerwidget(edit=self._root_widget, transition='out_left') assert bui.app.classic is not None bui.app.ui_v1.set_main_menu_window( - SendInfoWindow( - origin_widget=self._send_info_button + PromoCodeWindow( + origin_widget=self._promo_code_button ).get_root_widget(), from_window=self._root_widget, ) @@ -846,16 +840,14 @@ class AdvancedSettingsWindow(bui.Window): sel_name = 'VRTest' elif sel == self._net_test_button: sel_name = 'NetTest' - elif sel == self._send_info_button: - sel_name = 'SendInfo' + elif sel == self._promo_code_button: + sel_name = 'PromoCode' elif sel == self._benchmarks_button: sel_name = 'Benchmarks' elif sel == self._kick_idle_players_check_box.widget: sel_name = 'KickIdlePlayers' elif sel == self._show_demos_when_idle_check_box.widget: 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: sel_name = 'ShowPing' elif sel == self._disable_camera_shake_check_box.widget: @@ -882,14 +874,12 @@ class AdvancedSettingsWindow(bui.Window): sel_name = 'ShowUserMods' elif sel == self._plugins_button: sel_name = 'Plugins' - elif sel == self._modding_tools_button: - sel_name = 'ModdingTools' + elif sel == self._dev_tools_button: + sel_name = 'DevTools' elif sel == self._modding_guide_button: sel_name = 'ModdingGuide' elif sel == self._language_inform_checkbox: sel_name = 'LangInform' - elif sel == self._show_dev_console_button_check_box.widget: - sel_name = 'ShowDevConsole' else: raise ValueError(f'unrecognized selection \'{sel}\'') elif sel == self._back_button: @@ -904,7 +894,6 @@ class AdvancedSettingsWindow(bui.Window): def _restore_state(self) -> None: # pylint: disable=too-many-branches - # pylint: disable=too-many-statements try: assert bui.app.classic is not None 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 elif sel_name == 'NetTest': sel = self._net_test_button - elif sel_name == 'SendInfo': - sel = self._send_info_button + elif sel_name == 'PromoCode': + sel = self._promo_code_button elif sel_name == 'Benchmarks': sel = self._benchmarks_button elif sel_name == 'KickIdlePlayers': sel = self._kick_idle_players_check_box.widget elif sel_name == 'ShowDemosWhenIdle': 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': sel = self._show_game_ping_check_box.widget elif sel_name == 'DisableCameraShake': @@ -954,14 +941,12 @@ class AdvancedSettingsWindow(bui.Window): sel = self._show_user_mods_button elif sel_name == 'Plugins': sel = self._plugins_button - elif sel_name == 'ModdingTools': - sel = self._modding_tools_button + elif sel_name == 'DevTools': + sel = self._dev_tools_button elif sel_name == 'ModdingGuide': sel = self._modding_guide_button elif sel_name == 'LangInform': sel = self._language_inform_checkbox - elif sel_name == 'ShowDevConsole': - sel = self._show_dev_console_button_check_box.widget else: sel = None if sel is not None: diff --git a/src/assets/ba_data/python/bauiv1lib/settings/devtools.py b/src/assets/ba_data/python/bauiv1lib/settings/devtools.py new file mode 100644 index 00000000..5a3d96ab --- /dev/null +++ b/src/assets/ba_data/python/bauiv1lib/settings/devtools.py @@ -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, + ) From 9e2843f663900a841c0d3bc90675bd9234de1a08 Mon Sep 17 00:00:00 2001 From: Vishal Date: Thu, 9 May 2024 02:08:59 +0530 Subject: [PATCH 3/4] Updating to latest --- .../python/bauiv1lib/settings/advanced.py | 113 ++++++++++-------- 1 file changed, 64 insertions(+), 49 deletions(-) diff --git a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py index 3fe0b185..d27e655a 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py @@ -1,7 +1,7 @@ # Released under the MIT License. See LICENSE for details. # -"""UI functionality for advanced settings.""" # pylint: disable=too-many-lines +"""UI functionality for advanced settings.""" from __future__ import annotations @@ -91,7 +91,7 @@ class AdvancedSettingsWindow(bui.Window): 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 = 808.0 + self._sub_height = 912.0 if self._show_always_use_internal_keyboard: self._sub_height += 62 @@ -191,7 +191,7 @@ class AdvancedSettingsWindow(bui.Window): from bauiv1lib.settings import nettesting as _unused4 from bauiv1lib import appinvite as _unused5 from bauiv1lib import account as _unused6 - from bauiv1lib import promocode as _unused7 + from bauiv1lib import sendinfo as _unused7 from bauiv1lib import debug as _unused8 from bauiv1lib.settings import plugins as _unused9 from bauiv1lib.settings import devtools as _unused10 @@ -289,33 +289,16 @@ class AdvancedSettingsWindow(bui.Window): 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 bui.textwidget( parent=self._subcontainer, - position=(200, v + 10), + position=(70, v + 10), size=(0, 0), text=bui.Lstr(resource=f'{self._r}.languageText'), maxwidth=150, - scale=0.95, + scale=1.2, color=bui.app.ui_v1.title_color, - h_align='right', + h_align='left', v_align='center', ) @@ -394,7 +377,7 @@ class AdvancedSettingsWindow(bui.Window): bui.textwidget( parent=self._subcontainer, - position=(self._sub_width * 0.5, v + 10), + position=(90, v + 10), size=(0, 0), text=bui.Lstr( resource=f'{self._r}.helpTranslateText', @@ -405,7 +388,7 @@ class AdvancedSettingsWindow(bui.Window): flatness=1.0, scale=0.65, color=(0.4, 0.9, 0.4, 0.8), - h_align='center', + h_align='left', v_align='center', ) v -= self._spacing * 1.9 @@ -436,7 +419,7 @@ class AdvancedSettingsWindow(bui.Window): maxwidth=400.0, ) self._update_lang_status() - v -= 40 + v -= 50 lang_inform = plus.get_v1_account_misc_val('langInform', False) @@ -483,6 +466,19 @@ class AdvancedSettingsWindow(bui.Window): 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 self._show_demos_when_idle_check_box = ConfigCheckBox( parent=self._subcontainer, @@ -494,6 +490,19 @@ class AdvancedSettingsWindow(bui.Window): 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 self._disable_camera_shake_check_box = ConfigCheckBox( parent=self._subcontainer, @@ -675,6 +684,17 @@ class AdvancedSettingsWindow(bui.Window): 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(): bui.widget(edit=child, show_buffer_bottom=30, show_buffer_top=20) @@ -727,14 +747,6 @@ class AdvancedSettingsWindow(bui.Window): if not self._root_widget or self._root_widget.transitioning_out: 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() bui.containerwidget(edit=self._root_widget, transition='out_left') assert bui.app.classic is not None @@ -788,9 +800,8 @@ class AdvancedSettingsWindow(bui.Window): from_window=self._root_widget, ) - def _on_promo_code_press(self) -> None: - from bauiv1lib.promocode import PromoCodeWindow - from bauiv1lib.account import show_sign_in_prompt + def _on_send_info_press(self) -> None: + from bauiv1lib.sendinfo import SendInfoWindow # no-op if our underlying widget is dead or on its way out. if not self._root_widget or self._root_widget.transitioning_out: @@ -799,17 +810,12 @@ class AdvancedSettingsWindow(bui.Window): plus = bui.app.plus 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() bui.containerwidget(edit=self._root_widget, transition='out_left') assert bui.app.classic is not None bui.app.ui_v1.set_main_menu_window( - PromoCodeWindow( - origin_widget=self._promo_code_button + SendInfoWindow( + origin_widget=self._send_info_button ).get_root_widget(), from_window=self._root_widget, ) @@ -840,14 +846,16 @@ class AdvancedSettingsWindow(bui.Window): sel_name = 'VRTest' elif sel == self._net_test_button: sel_name = 'NetTest' - elif sel == self._promo_code_button: - sel_name = 'PromoCode' + elif sel == self._send_info_button: + sel_name = 'SendInfo' elif sel == self._benchmarks_button: sel_name = 'Benchmarks' elif sel == self._kick_idle_players_check_box.widget: sel_name = 'KickIdlePlayers' elif sel == self._show_demos_when_idle_check_box.widget: 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: sel_name = 'ShowPing' elif sel == self._disable_camera_shake_check_box.widget: @@ -880,6 +888,8 @@ class AdvancedSettingsWindow(bui.Window): sel_name = 'ModdingGuide' elif sel == self._language_inform_checkbox: sel_name = 'LangInform' + elif sel == self._show_dev_console_button_check_box.widget: + sel_name = 'ShowDevConsole' else: raise ValueError(f'unrecognized selection \'{sel}\'') elif sel == self._back_button: @@ -894,6 +904,7 @@ class AdvancedSettingsWindow(bui.Window): def _restore_state(self) -> None: # pylint: disable=too-many-branches + # pylint: disable=too-many-statements try: assert bui.app.classic is not None sel_name = bui.app.ui_v1.window_states.get(type(self), {}).get( @@ -909,14 +920,16 @@ class AdvancedSettingsWindow(bui.Window): sel = self._vr_test_button elif sel_name == 'NetTest': sel = self._net_test_button - elif sel_name == 'PromoCode': - sel = self._promo_code_button + elif sel_name == 'SendInfo': + sel = self._send_info_button elif sel_name == 'Benchmarks': sel = self._benchmarks_button elif sel_name == 'KickIdlePlayers': sel = self._kick_idle_players_check_box.widget elif sel_name == 'ShowDemosWhenIdle': 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': sel = self._show_game_ping_check_box.widget elif sel_name == 'DisableCameraShake': @@ -947,6 +960,8 @@ class AdvancedSettingsWindow(bui.Window): sel = self._modding_guide_button elif sel_name == 'LangInform': sel = self._language_inform_checkbox + elif sel_name == 'ShowDevConsole': + sel = self._show_dev_console_button_check_box.widget else: sel = None if sel is not None: @@ -993,4 +1008,4 @@ class AdvancedSettingsWindow(bui.Window): bui.app.ui_v1.set_main_menu_window( AllSettingsWindow(transition='in_left').get_root_widget(), from_window=self._root_widget, - ) + ) \ No newline at end of file From 9209172b5ed4357d54e796c57c2e217efbccb0ed Mon Sep 17 00:00:00 2001 From: Vishal Date: Thu, 9 May 2024 02:13:54 +0530 Subject: [PATCH 4/4] Update advanced.py --- src/assets/ba_data/python/bauiv1lib/settings/advanced.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py index d27e655a..da7fbf6f 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py @@ -1008,4 +1008,4 @@ class AdvancedSettingsWindow(bui.Window): bui.app.ui_v1.set_main_menu_window( AllSettingsWindow(transition='in_left').get_root_widget(), from_window=self._root_widget, - ) \ No newline at end of file + )