diff --git a/.efrocachemap b/.efrocachemap index bdc22351..82f2a475 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4135,16 +4135,16 @@ "assets/build/windows/x64/vc_redist.x64.exe": "https://files.ballistica.net/cache/ba1/ea/19/8b8787d81abcdce158ba608cd24f", "assets/build/windows/x64/vcruntime140_1d.dll": "https://files.ballistica.net/cache/ba1/11/d8/ff6344b429b00c24d9a1930d4338", "assets/build/windows/x64/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/20/33/0825e11e6518f87ece3009309933", - "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/66/e8/cb2aca94bb37c54803235ca19a75", - "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d2/da/661e79f9cbe9446a073e685f240d", - "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/38/07/ed14ca1cdab132da23bfd1f69f5f", - "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c9/6a/0e233fc907a8461d7641f4740530", - "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b0/4b/eaed2d4f9296da8950707cf64fff", - "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9c/37/835be7a8730d5b1acc009823a781", - "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/03/5e/d126371e7d1d32948e04f0c77d77", - "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c2/57/a7bb77e0dd051cc68d7e4c6d0bde", - "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/bc/35/11f66fbd7cd142e40ad4cc94022b", - "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/c9/cb/0879d2f7acbdd8165f5a7af56264", - "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a2/9f/e82dd87f76005a97ececdfb2a1b2", - "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/14/ca/9de4a3803d3ac23d24591a36e49f" + "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/44/c5/099debe438f2bca2c3dc8d9f048e", + "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c4/7a/f92d78baa6d8137a8150e37c40a8", + "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/35/8b/1d44da11d466aa8e49390048bd3c", + "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/13/b2/6f0da477dd7d4f54fe48647ce44b", + "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d9/11/e50c98eb60cfbe1c5268e33af8b8", + "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3b/e5/ce291661086203e424dce2dcd692", + "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/70/09/d12993418eade4f88e8290d92f2e", + "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/93/8c/8d7097c9b662b6583a145ad34f56", + "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/52/d4/96f341a77b48a1f4adcbc5ca1e40", + "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/af/79/c1be9d5908663f693dc67a24fd5e", + "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/9e/e6/2cc3bc3fe700d8750387032bf43d", + "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/92/8f/99cddfd2549fadedbb6f483bb174" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 167d4c29..7a4cb989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 1.5.22 (20139) +- Button and key names now display correctly again on Android (and are cleaned up on other platforms too). + ### 1.5.21 (20138) - Added a UI subsystem at ba.app.ui (containing globals/functionality that was previously directly under ba.app). And hopefully added a fix for rare state of two main menus appearing on-screen at once. - Added options in the 'Advanced' section to disable camera shake and camera gyroscope motion. diff --git a/assets/src/ba_data/python/_ba.py b/assets/src/ba_data/python/_ba.py index 295c4763..ca9209ab 100644 --- a/assets/src/ba_data/python/_ba.py +++ b/assets/src/ba_data/python/_ba.py @@ -256,6 +256,11 @@ class InputDevice: allows_configuring: bool Whether the input-device can be configured. + has_meaningful_button_names: bool + Whether button names returned by this instance match labels + on the actual device. (Can be used to determine whether to show + them in controls-overlays, etc.) + player: Optional[ba.SessionPlayer] The player associated with this input device. @@ -288,6 +293,7 @@ class InputDevice: """ allows_configuring: bool + has_meaningful_button_names: bool player: Optional[ba.SessionPlayer] client_id: int name: str @@ -316,16 +322,21 @@ class InputDevice: def get_axis_name(self, axis_id: int) -> str: """get_axis_name(axis_id: int) -> str - Given an axis ID, returns the name of the axis on this device. + Given an axis ID, return the name of the axis on this device. + + Can return an empty string if the value is not meaningful to humans. """ return str() - def get_button_name(self, button_id: int) -> str: - """get_button_name(button_id: int) -> str + def get_button_name(self, button_id: int) -> ba.Lstr: + """get_button_name(button_id: int) -> ba.Lstr - Given a button ID, returns the name of the key/button on this device. + Given a button ID, return a human-readable name for that key/button. + + Can return an empty string if the value is not meaningful to humans. """ - return str() + import ba # pylint: disable=cyclic-import + return ba.Lstr(value='') def get_default_player_name(self) -> str: """get_default_player_name() -> str diff --git a/assets/src/ba_data/python/ba/_lang.py b/assets/src/ba_data/python/ba/_lang.py index fcef0708..7afacfbb 100644 --- a/assets/src/ba_data/python/ba/_lang.py +++ b/assets/src/ba_data/python/ba/_lang.py @@ -28,6 +28,7 @@ from typing import TYPE_CHECKING, overload import _ba if TYPE_CHECKING: + import ba from typing import Any, Dict, List, Optional, Tuple, Union, Sequence @@ -192,6 +193,13 @@ class Lstr: def __repr__(self) -> str: return '' + @staticmethod + def from_json(json_string: str) -> ba.Lstr: + """Given a json string, returns a ba.Lstr. Does no data validation.""" + lstr = Lstr(value='') + lstr.args = json.loads(json_string) + return lstr + def setlanguage(language: Optional[str], print_change: bool = True, @@ -203,6 +211,7 @@ def setlanguage(language: Optional[str], Pass None to use OS default language. """ # pylint: disable=too-many-locals + # pylint: disable=too-many-statements # pylint: disable=too-many-branches cfg = _ba.app.config cur_language = cfg.get('Lang', None) @@ -273,6 +282,7 @@ def setlanguage(language: Optional[str], internal_vals.append((value, lfull[value])) internal_vals.append( ('axisText', lfull['configGamepadWindow']['axisText'])) + internal_vals.append(('buttonText', lfull['buttonText'])) lmerged = _ba.app.language_merged assert lmerged is not None random_names = [ diff --git a/assets/src/ba_data/python/ba/_ui.py b/assets/src/ba_data/python/ba/_ui.py index ce4c5a99..5c612bf2 100644 --- a/assets/src/ba_data/python/ba/_ui.py +++ b/assets/src/ba_data/python/ba/_ui.py @@ -103,9 +103,10 @@ class UI: # on the old after a short bit of time and kill it if its still alive. # That will be a bit ugly on screen but at least will un-break things. def _delay_kill() -> None: + import time if existing: print(f'Killing old main_menu_window' - f' when called at: {frameline}') + f' when called at: {frameline} t={time.time():.3f}') existing.delete() _ba.timer(1.0, _delay_kill, timetype=TimeType.REAL) diff --git a/assets/src/ba_data/python/bastd/actor/controlsguide.py b/assets/src/ba_data/python/bastd/actor/controlsguide.py index 374bb7ef..a68a6d7c 100644 --- a/assets/src/ba_data/python/bastd/actor/controlsguide.py +++ b/assets/src/ba_data/python/bastd/actor/controlsguide.py @@ -243,6 +243,13 @@ class ControlsGuide(ba.Actor): # Don't do anything until our delay has passed. ba.timer(delay, ba.WeakCall(self._start_updating)) + @staticmethod + def _meaningful_button_name(device: ba.InputDevice, button: int) -> str: + """Return a flattened string button name; empty for non-meaningful.""" + if not device.has_meaningful_button_names: + return '' + return device.get_button_name(button).evaluate() + def _start_updating(self) -> None: # Ok, our delay has passed. Now lets periodically see if we can fade @@ -284,8 +291,8 @@ class ControlsGuide(ba.Actor): for device in input_devices: for name in ('buttonPunch', 'buttonJump', 'buttonBomb', 'buttonPickUp'): - if device.get_button_name( - get_device_value(device, name)) != '': + if self._meaningful_button_name( + device, get_device_value(device, name)) != '': fade_in = True break if fade_in: @@ -368,20 +375,20 @@ class ControlsGuide(ba.Actor): # Ignore empty values; things like the remote app or # wiimotes can return these. - bname = device.get_button_name( - get_device_value(device, 'buttonPunch')) + bname = self._meaningful_button_name( + device, get_device_value(device, 'buttonPunch')) if bname != '': punch_button_names.add(bname) - bname = device.get_button_name( - get_device_value(device, 'buttonJump')) + bname = self._meaningful_button_name( + device, get_device_value(device, 'buttonJump')) if bname != '': jump_button_names.add(bname) - bname = device.get_button_name( - get_device_value(device, 'buttonBomb')) + bname = self._meaningful_button_name( + device, get_device_value(device, 'buttonBomb')) if bname != '': bomb_button_names.add(bname) - bname = device.get_button_name( - get_device_value(device, 'buttonPickUp')) + bname = self._meaningful_button_name( + device, get_device_value(device, 'buttonPickUp')) if bname != '': pickup_button_names.add(bname) diff --git a/assets/src/ba_data/python/bastd/ui/settings/controls.py b/assets/src/ba_data/python/bastd/ui/settings/controls.py index c20e448a..6337af17 100644 --- a/assets/src/ba_data/python/bastd/ui/settings/controls.py +++ b/assets/src/ba_data/python/bastd/ui/settings/controls.py @@ -64,7 +64,7 @@ class ControlsSettingsWindow(ba.Window): spacing = 50.0 button_width = 350.0 width = 460.0 - height = 135.0 + height = 85.0 space_height = spacing * 0.3 diff --git a/assets/src/ba_data/python/bastd/ui/settings/gamepad.py b/assets/src/ba_data/python/bastd/ui/settings/gamepad.py index 7305ccd1..680a20c1 100644 --- a/assets/src/ba_data/python/bastd/ui/settings/gamepad.py +++ b/assets/src/ba_data/python/bastd/ui/settings/gamepad.py @@ -188,7 +188,7 @@ class GamepadSettingsWindow(ba.Window): size=((160 if self._is_secondary else 180), 60), autoselect=True, label=ba.Lstr(resource='doneText') - if self._is_secondary else ba.Lstr(resource='makeItSoText'), + if self._is_secondary else ba.Lstr(resource='saveText'), scale=0.9, on_activate_call=self._save) ba.containerwidget(edit=self._root_widget, diff --git a/docs/ba_module.md b/docs/ba_module.md index 04166443..6173809a 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2020-07-14 for Ballistica version 1.5.21 build 20138

+

last updated on 2020-07-15 for Ballistica version 1.5.22 build 20140

This page documents the Python classes and functions in the 'ba' module, which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please let me know. Happy modding!


@@ -2872,7 +2872,7 @@ Results for a completed game.

Category: Gameplay Classes

Attributes:

-
allows_configuring, client_id, id, instance_number, is_controller_app, is_remote_client, name, player, unique_identifier
+
allows_configuring, client_id, has_meaningful_button_names, id, instance_number, is_controller_app, is_remote_client, name, player, unique_identifier

allows_configuring

bool

@@ -2885,6 +2885,13 @@ Results for a completed game.

This is only meaningful for remote client inputs; for all local devices this will be -1.

+
+

has_meaningful_button_names

+

bool

+

Whether button names returned by this instance match labels +on the actual device. (Can be used to determine whether to show +them in controls-overlays, etc.)

+

id

int

@@ -2946,13 +2953,17 @@ prefs, etc.

get_axis_name()

get_axis_name(axis_id: int) -> str

-

Given an axis ID, returns the name of the axis on this device.

+

Given an axis ID, return the name of the axis on this device.

+ +

Can return an empty string if the value is not meaningful to humans.

get_button_name()

-

get_button_name(button_id: int) -> str

+

get_button_name(button_id: int) -> ba.Lstr

-

Given a button ID, returns the name of the key/button on this device.

+

Given a button ID, return a human-readable name for that key/button.

+ +

Can return an empty string if the value is not meaningful to humans.

@@ -3273,7 +3284,7 @@ needs a chooser.

Methods:

-
<constructor>, evaluate(), is_flat_value()
+
<constructor>, evaluate(), from_json(), is_flat_value()

<constructor>

ba.Lstr(*args: Any, **keywds: Any)

@@ -3300,6 +3311,12 @@ the resource nor the fallback resource is found ('resource' mode only).

You should avoid doing this as much as possible and instead pass and store Lstr values.

+
+

from_json()

+

from_json(json_string: str) -> ba.Lstr

+ +

Given a json string, returns a ba.Lstr. Does no data validation.

+

is_flat_value()

is_flat_value(self) -> bool