From 16bee0e260b63e3f5dd36422dffcbdabe166e7ae Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sat, 1 Feb 2025 17:15:31 -0800 Subject: [PATCH] updated top level controls window to be screen-size-responsive --- .efrocachemap | 76 ++++++++-------- .../python/bauiv1lib/settings/controls.py | 86 +++++++++++-------- 2 files changed, 87 insertions(+), 75 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index c7dc08aa..c1a2cfbc 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -432,7 +432,7 @@ "build/assets/ba_data/audio/zoeOw.ogg": "b2d705c31c9dcc1efdc71394764c3beb", "build/assets/ba_data/audio/zoePickup01.ogg": "e9366dc2d2b8ab8b0c4e2c14c02d0789", "build/assets/ba_data/audio/zoeScream01.ogg": "903e0e45ee9b3373e9d9ce20c814374e", - "build/assets/ba_data/data/langdata.json": "0c39b1e1a3d4ceb9edcb7b28aa4e0d10", + "build/assets/ba_data/data/langdata.json": "25d7a3f3858037a117c9b7b4465397bc", "build/assets/ba_data/data/languages/arabic.json": "d95c590f7db91a9e8b7df4b9b58c8529", "build/assets/ba_data/data/languages/belarussian.json": "009b452aa308bf2b2f7e92d9b78ba5ff", "build/assets/ba_data/data/languages/chinese.json": "a8f1d5549dbbec0600499884028669a1", @@ -452,7 +452,7 @@ "build/assets/ba_data/data/languages/hungarian.json": "7617fcdb97bcb27b64b70204f208702e", "build/assets/ba_data/data/languages/indonesian.json": "6688762f3dac583099f2c529bbb95c5f", "build/assets/ba_data/data/languages/italian.json": "efddc0d1740328da9655e4bc68693ce9", - "build/assets/ba_data/data/languages/korean.json": "360760d72832863e1a3451b0a514cb08", + "build/assets/ba_data/data/languages/korean.json": "86f29885236d8e792341456636087e1d", "build/assets/ba_data/data/languages/malay.json": "b2dd732c51d51aae17156939b2719f06", "build/assets/ba_data/data/languages/persian.json": "6caed8dedf82fd38a6a224cfdcd12d95", "build/assets/ba_data/data/languages/piratespeak.json": "e93ca3bed6c5218e4788021514dbde76", @@ -4171,42 +4171,42 @@ "build/assets/windows/Win32/pythonw.exe": "60f972a154dd6af1b4a67a23bcd89a92", "build/assets/windows/Win32/pythonw_d.exe": "440ba78327698a2706fe7a0eb358dfe8", "build/assets/windows/Win32/vc_redist.x86.exe": "91f13ae4b9f4dee9430a9d9b0c8b2afa", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "a54ebe9e64552f3de963402814e0f4a2", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "6354c156e909d07f3434c931a9656579", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "6e13137a60758d025cee646cf977f0c1", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "51f102a6b3f2908302963fbc54b0d1aa", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "f0ad9435b57e2dbc166b83ee58b225c8", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "94172d7d9f068f084f47aeb2e28930c7", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "d446f9c22f66b97e932877947f5a4ef3", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "f70474f33841dcc10a114d47b21b0b85", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "63714ddf452cda2be929cf515c8fa9a9", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "2f9086ee203152bb51dca29b18756a12", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "64c429638d88729fa152bda696a8b90b", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "f78fe0dcc03f7c5fd5cbb37c4e1e2c44", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "dea88fc657abfdf5de6ca6598fcf6f21", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "7b96bbbf2fcc00701ac530ef62a982e3", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "351e3a2b7b5cc37378b1a422e6d212a7", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "84e4a81bb545b363194311340f9e6139", - "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "5c7b118a1780cbf24c8b4bf6fd30ddb0", - "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "69a28ff5f0d1fb79a012449c90e3c0d0", - "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "5c7b118a1780cbf24c8b4bf6fd30ddb0", - "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "69a28ff5f0d1fb79a012449c90e3c0d0", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "45e58068fbaa0161a925b4b180ab733c", - "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "ffee8b9553e03997aae1c1cb31c4a7bf", - "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "45e58068fbaa0161a925b4b180ab733c", - "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "ffee8b9553e03997aae1c1cb31c4a7bf", - "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "07143cfbe795a2cbaa47a09daf1261b3", - "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "593606fabbdd503bab555d49b7963ad1", - "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "07143cfbe795a2cbaa47a09daf1261b3", - "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "593606fabbdd503bab555d49b7963ad1", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "359152642ae4462b201ccd564f9221d2", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "6a1a556e98dc76b00db6945d774bfeb7", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "b8849bfed37a7bb991746f777493d8f9", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "af1ba8f3b06dbe662c15b7c9b69c9100", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "9c81a5bd112d8851742f2348f83229a5", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "23568511c237cb2572ec913d6e12e12d", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "0631217906ea9644f6703e3186311548", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "9d6b88bbb575f227afdd4354a02d68b7", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "1cf07c7315b13c65ab63d4ce49ea2ead", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "1e60ddbda5246f49561f43c8c28b5851", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "20ba04bf3a299db897b8dfe16b1253e0", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "c5a18d6f5f2aab872ee9cbb6c9f58e6c", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "79f170b5d6ebc32cbd8f696e22a5afde", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "7be75345f21240954beb82d9142766ff", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "bd10a18203b7048f659623b1148315ab", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "3289489f379678a532e47984346e0573", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "54cb80ee3333972cf72249dee3f96d69", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "ed8b04fa8a8214e287948419e6acdca2", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "1b4b9c03ea90a8f2a33a827ca91663fd", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "f710132f05bae39396aa805ef5f43fb7", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "d9232e385c222f4091fdecae184b01dd", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "a46a1feea46ada59b5f80c354961a739", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "4ec2025435142d60efed4c2ae2866b84", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "96c727159866d6edbb569a18e7c74762", + "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "01cf784129e9954688377b0dac5cdedf", + "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "8823eb11175db83561418ef0e8e0c65a", + "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "01cf784129e9954688377b0dac5cdedf", + "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "8823eb11175db83561418ef0e8e0c65a", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "81c53daa1e934076eca6718e862313b2", + "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "e2f76018a99fe4b64f2059aa4ea664a1", + "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "81c53daa1e934076eca6718e862313b2", + "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "e2f76018a99fe4b64f2059aa4ea664a1", + "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "d30dfb98cc42b90ae5066547a7b9f709", + "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "670d6e9cd99533d661f9773f91f56bc4", + "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "d30dfb98cc42b90ae5066547a7b9f709", + "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "670d6e9cd99533d661f9773f91f56bc4", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "5f26b37ef5d713bf65bbb15bdd4f3526", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "00ccf4d5b73d23c4f44126c60e0b22aa", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "a75cd8214712293e0fa58e787969c550", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "270c74133c8a39ddecb5c43a4b5c9862", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "cc13d5c730a7cf24312f0f5bef6aeab0", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "c27c089c49b388d1c4176e3de723d650", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "4503b01a493d4a34ecd1a274b9c87076", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "2e0cbee0393131f0b690715dfa8711d5", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad", "src/ballistica/base/mgen/pyembed/binding_base.inc": "06042d31df0ff9af96b99477162e2a91", diff --git a/src/assets/ba_data/python/bauiv1lib/settings/controls.py b/src/assets/ba_data/python/bauiv1lib/settings/controls.py index 7e49896b..3e6fbf61 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/controls.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/controls.py @@ -33,15 +33,17 @@ class ControlsSettingsWindow(bui.MainWindow): spacing = 50.0 button_width = 350.0 - width = 800.0 if uiscale is bui.UIScale.SMALL else 460.0 - height = 300 if uiscale is bui.UIScale.SMALL else 130.0 + width = 1200.0 if uiscale is bui.UIScale.SMALL else 560.0 + height = 800 if uiscale is bui.UIScale.SMALL else 400.0 - yoffs = -60 if uiscale is bui.UIScale.SMALL else 0 + # yoffs = -60 if uiscale is bui.UIScale.SMALL else 0 space_height = spacing * 0.3 + buttons_height = 0.0 + # FIXME: should create vis settings under platform or - # app-adapter to determine whether to show this stuff; not hard - # code it. + # app-adapter to determine whether to show this stuff; not + # hard-code it. show_gamepads = False platform = app.classic.platform @@ -51,58 +53,70 @@ class ControlsSettingsWindow(bui.MainWindow): ) if platform in ('linux', 'android', 'mac') or non_vr_windows: show_gamepads = True - height += spacing + buttons_height += spacing show_touch = False if bs.have_touchscreen_input(): show_touch = True - height += spacing + buttons_height += spacing show_space_1 = False if show_gamepads or show_touch: show_space_1 = True - height += space_height + buttons_height += space_height show_keyboard = False if bs.getinputdevice('Keyboard', '#1', doraise=False) is not None: show_keyboard = True - height += spacing + buttons_height += spacing show_keyboard_p2 = False if app.env.vr else show_keyboard if show_keyboard_p2: - height += spacing + buttons_height += spacing show_space_2 = False if show_keyboard: show_space_2 = True - height += space_height + buttons_height += space_height if bool(True): show_remote = True - height += spacing + buttons_height += spacing else: show_remote = False - # On windows (outside of oculus/vr), show an option to disable xinput. + # On windows (outside of oculus/vr), show an option to disable + # xinput. show_xinput_toggle = False if platform == 'windows' and not app.env.vr: show_xinput_toggle = True if show_xinput_toggle: - height += spacing + buttons_height += spacing assert bui.app.classic is not None - smallscale = 2.0 + + # Do some fancy math to fill all available screen area up to the + # size of our backing container. This lets us fit to the exact + # screen shape at small ui scale. + screensize = bui.get_virtual_screen_size() + scale = ( + 2.0 + if uiscale is bui.UIScale.SMALL + else 1.4 if uiscale is bui.UIScale.MEDIUM else 1.0 + ) + # Calc screen size in our local container space and clamp to a + # bit smaller than our container size. + # target_width = min(width - 60, screensize[0] / scale) + target_height = min(height - 70, screensize[1] / scale) + + # To get top/left coords, go to the center of our window and + # offset by half the width/height of our target area. + yoffs = 0.5 * height + 0.5 * target_height + 30.0 + super().__init__( root_widget=bui.containerwidget( size=(width, height), - stack_offset=( - (0, -10) if uiscale is bui.UIScale.SMALL else (0, 0) - ), - scale=( - smallscale - if uiscale is bui.UIScale.SMALL - else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0 - ), + scale=scale, toolbar_visibility=( 'menu_minimal' if uiscale is bui.UIScale.SMALL @@ -111,6 +125,8 @@ class ControlsSettingsWindow(bui.MainWindow): ), transition=transition, origin_widget=origin_widget, + # We're affected by screen size only at small ui-scale. + refresh_on_screen_size_changes=uiscale is bui.UIScale.SMALL, ) self._back_button: bui.Widget | None @@ -123,21 +139,15 @@ class ControlsSettingsWindow(bui.MainWindow): self._back_button = btn = bui.buttonwidget( parent=self._root_widget, position=(35, height - 60), - size=(140, 65), + size=(60, 60), scale=0.8, text_scale=1.2, autoselect=True, - label=bui.Lstr(resource='backText'), - button_type='back', + label=bui.charstr(bui.SpecialChar.BACK), + button_type='backSmall', on_activate_call=self.main_window_back, ) bui.containerwidget(edit=self._root_widget, cancel_button=btn) - bui.buttonwidget( - edit=btn, - button_type='backSmall', - size=(60, 60), - label=bui.charstr(bui.SpecialChar.BACK), - ) # We need these vars to exist even if the buttons don't. self._gamepads_button: bui.Widget | None = None @@ -149,17 +159,19 @@ class ControlsSettingsWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, position=( - 0, - height + yoffs - (53 if uiscale is bui.UIScale.SMALL else 50), + width * 0.5, + yoffs - (52 if uiscale is bui.UIScale.SMALL else 32), ), - size=(width, 25), + maxwidth=260, + size=(0, 0), text=bui.Lstr(resource=f'{self._r}.titleText'), color=bui.app.ui_v1.title_color, h_align='center', - v_align='top', + v_align='center', ) - v = height - (85 if uiscale is bui.UIScale.SMALL else 75) + yoffs + # Roughly center the rest of our stuff. + v = height * 0.5 + buttons_height * 0.5 - 10 v -= spacing if show_touch: