From d548da781ba4b4ca678a006e3c5a1f06951bf1e9 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sat, 13 Jun 2020 19:13:39 -0700 Subject: [PATCH] Added windows debug dlls --- .efrocachemap | 33 +++-- .idea/dictionaries/ericf.xml | 1 + CHANGELOG.md | 1 + Makefile | 18 +-- assets/.asset_manifest_private.json | 9 +- assets/Makefile | 11 +- assets/src/ba_data/python/_ba.py | 2 +- assets/src/ba_data/python/ba/_meta.py | 18 ++- assets/src/ba_data/python/ba/_stats.py | 2 +- .../ba_data/python/bastd/ui/colorpicker.py | 53 ++++--- .../python/bastd/ui/settings/gamepad.py | 13 +- docs/ba_module.md | 2 +- tools/stage_assets | 130 ++++++++++++------ 13 files changed, 175 insertions(+), 118 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 615253c2..d337605a 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -420,7 +420,7 @@ "assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/75/1d/868bb04cf691736035c917d02762", "assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/44/2a/8535b446284235cb503947ece074", "assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/f5/d3/8e941851c4310465646c4167afc1", - "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/d7/12/16632915fdb57dc6e07fc04413cc", + "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/8d/3d/bcd72bb471b185102c2598cd2346", "assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/b8/ed/e18bec56ff1d094aae86517a7854", "assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/49/5f/b29bb65369040892fe6601801637", "assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/bc/59/21bb0b4ef33c733022340c60aebf", @@ -440,7 +440,7 @@ "assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/e3/6f/df2600b658a163f80077bd6c8d78", "assets/build/ba_data/data/languages/italian.json": "https://files.ballistica.net/cache/ba1/a5/ef/b1935b3767692070f070847f40df", "assets/build/ba_data/data/languages/korean.json": "https://files.ballistica.net/cache/ba1/0a/84/bbb6ed2abf66509406f534cbbb52", - "assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/ee/72/7c6705486a19856fb6587f6d03e7", + "assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/8e/3f/41e12b96fc07a623d89153b10c38", "assets/build/ba_data/data/languages/polish.json": "https://files.ballistica.net/cache/ba1/db/eb/324f86a4b714240ae50ffeeed2f8", "assets/build/ba_data/data/languages/portuguese.json": "https://files.ballistica.net/cache/ba1/66/0b/df2cd57be4eb505876d209a673d9", "assets/build/ba_data/data/languages/romanian.json": "https://files.ballistica.net/cache/ba1/f6/d0/335b952306d211d56172b5c72d8c", @@ -4125,23 +4125,26 @@ "assets/build/windows/x64/Lib/zipfile.py": "https://files.ballistica.net/cache/ba1/a6/3c/116c6602b0176d208f3e2a4813de", "assets/build/windows/x64/OpenAL32.dll": "https://files.ballistica.net/cache/ba1/a1/7f/e92ff76218c4b8cfce9bc72d5324", "assets/build/windows/x64/SDL2.dll": "https://files.ballistica.net/cache/ba1/b2/c1/0d3f95340344968b2aac3fc4a979", - "assets/build/windows/x64/VC_redist.x64.exe": "https://files.ballistica.net/cache/ba1/31/1b/07fbd2f6e9bf7eb8741ad9f7d811", "assets/build/windows/x64/libvorbis.dll": "https://files.ballistica.net/cache/ba1/2d/ec/f52561af5804abd5c646e364dea9", "assets/build/windows/x64/libvorbisfile.dll": "https://files.ballistica.net/cache/ba1/8c/2a/ef525f4ae1de3b46a23fbdd0dfde", + "assets/build/windows/x64/msvcp140d.dll": "https://files.ballistica.net/cache/ba1/25/73/87d96678583aabd18407963ac8b0", "assets/build/windows/x64/ogg.dll": "https://files.ballistica.net/cache/ba1/1b/3e/382012f9d092e45f211561e8b5ee", "assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c", "assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb", "assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe", - "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/a7/7ac018279a128aa32a5a416d3eff", - "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/93/4f/4a39906d3f891d93681e69b66d70", - "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/8f/bd/cb7e2f48f7b17f89a5cd832c3554", - "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/0b/b5/70ba3a3c723abde24ecef56a27d9", - "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ea/62/c659150da05f7ddf14bbbf5925a5", - "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/93/2a/1745f2848d2ccc39b22bf7bbacc5", - "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/8a/00/f12aa5d62f2ba41a2f2f44bf8e67", - "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/03/eea3689c697343e58ee8c643ba38", - "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/a7/24/2e46ae146cf830384c81679ee329", - "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/43/e3/b8b60b2cbff091a969a1ea6b8cea", - "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/8b/72/798e5fb6c2b714c471a549aeb577", - "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/06/fc/5987010f8f24bd493fa78f9ca505" + "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/f1/3b/224ab441922e2cd0f95a042eca63", + "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/32/01/1382cb73f9a4484a49ba603429fc", + "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b4/dc/dcbe26dc38ac257f792cf10f0460", + "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/64/16/a4f73103c2db98225fb3c7763ea7", + "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1d/fd/969e660fbbd15177aeb5d79aaad3", + "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/28/dc/1b4b59fcf7e1b3a2fabfb6fa7762", + "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/5f/80/3fc03f524c5ab0ca0f18bef1c994", + "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/72/c7/1b3960aeb864e2d69e7588c2fd70", + "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/13/25/c5ed7e41549396a2a376a547778d", + "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/0d/b7/144275e1c533a0b077d62610ff6b", + "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f5/80/08ff1c67de148ecd203892499a56", + "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d6/03/2fdba74ac6883ff5408b6a165f04" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index a32f3722..c9101d02 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -1568,6 +1568,7 @@ pypaths pysources pytest + pythondirs pythondontwritebytecode pythonhashseed pythonpath diff --git a/CHANGELOG.md b/CHANGELOG.md index aa5d6279..c0737fb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 1.5.4 (20067) - Should now work properly with non-ascii paths on Windows (for real this time). +- Note that Windows game data is now stored under 'Local' appdata instead of 'Roaming'; if you have an old install with data you want to preserve, you may want to move it over manually. - Misc cleanup and minor bug fixes. ### 1.5.3 (20065) diff --git a/Makefile b/Makefile index 28aca96d..47257e12 100644 --- a/Makefile +++ b/Makefile @@ -185,7 +185,7 @@ prefab-mac-server-debug-build: prereqs assets-cmake \ build/prefab/mac-server/debug/ballisticacore_server \ build/prefab/mac-server/debug/config_template.yaml \ build/prefab/mac-server/debug/README.txt - @${STAGE_ASSETS} -cmake-server build/prefab/mac-server/debug/dist + @${STAGE_ASSETS} -cmakeserver build/prefab/mac-server/debug/dist build/prefab/mac-server/debug/ballisticacore_server: \ assets/src/server/ballisticacore_server.py @@ -216,7 +216,7 @@ prefab-mac-server-release-build: prereqs assets-cmake \ build/prefab/mac-server/release/ballisticacore_server \ build/prefab/mac-server/release/config_template.yaml \ build/prefab/mac-server/release/README.txt - @${STAGE_ASSETS} -cmake-server build/prefab/mac-server/release/dist + @${STAGE_ASSETS} -cmakeserver build/prefab/mac-server/release/dist build/prefab/mac-server/release/ballisticacore_server: \ assets/src/server/ballisticacore_server.py @@ -273,7 +273,7 @@ prefab-linux-server-debug-build: prereqs assets-cmake \ build/prefab/linux-server/debug/ballisticacore_server \ build/prefab/linux-server/debug/config_template.yaml \ build/prefab/linux-server/debug/README.txt - @${STAGE_ASSETS} -cmake-server build/prefab/linux-server/debug/dist + @${STAGE_ASSETS} -cmakeserver build/prefab/linux-server/debug/dist build/prefab/linux-server/debug/ballisticacore_server: \ assets/src/server/ballisticacore_server.py @@ -304,7 +304,7 @@ prefab-linux-server-release-build: prereqs assets-cmake \ build/prefab/linux-server/release/ballisticacore_server \ build/prefab/linux-server/release/config_template.yaml \ build/prefab/linux-server/release/README.txt - @${STAGE_ASSETS} -cmake-server build/prefab/linux-server/release/dist + @${STAGE_ASSETS} -cmakeserver build/prefab/linux-server/release/dist build/prefab/linux-server/release/ballisticacore_server: \ assets/src/server/ballisticacore_server.py @@ -333,7 +333,8 @@ prefab-windows-debug: prefab-windows-debug-build prefab-windows-debug-build: prereqs assets-windows-${PREFAB_WINDOWS_PLATFORM} \ build/prefab/windows/debug/BallisticaCore.exe - @${STAGE_ASSETS} -win-$(PREFAB_WINDOWS_PLATFORM) build/prefab/windows/debug + @${STAGE_ASSETS} -win-${PREFAB_WINDOWS_PLATFORM}-Debug \ +build/prefab/windows/debug build/prefab/windows/debug/BallisticaCore.exe: .efrocachemap @tools/snippets efrocache_get $@ @@ -348,7 +349,8 @@ prefab-windows-release: prefab-windows-release-build prefab-windows-release-build: prereqs \ assets-windows-${PREFAB_WINDOWS_PLATFORM} \ build/prefab/windows/release/BallisticaCore.exe - @${STAGE_ASSETS} -win-$(PREFAB_WINDOWS_PLATFORM) build/prefab/windows/release + @${STAGE_ASSETS} -win-${PREFAB_WINDOWS_PLATFORM}-Release \ +build/prefab/windows/release build/prefab/windows/release/BallisticaCore.exe: .efrocachemap @tools/snippets efrocache_get $@ @@ -367,7 +369,7 @@ prefab-windows-server-debug-build: prereqs \ build/prefab/windows-server/debug/ballisticacore_server.py \ build/prefab/windows-server/debug/config_template.yaml \ build/prefab/windows-server/debug/README.txt - @${STAGE_ASSETS} -win-$(PREFAB_WINDOWS_PLATFORM) \ + @${STAGE_ASSETS} -winserver-${PREFAB_WINDOWS_PLATFORM}-Debug \ build/prefab/windows-server/debug/dist build/prefab/windows-server/debug/dist/ballisticacore_headless.exe: .efrocachemap @@ -405,7 +407,7 @@ prefab-windows-server-release-build: prereqs \ build/prefab/windows-server/release/ballisticacore_server.py \ build/prefab/windows-server/release/config_template.yaml \ build/prefab/windows-server/release/README.txt - @${STAGE_ASSETS} -win-$(PREFAB_WINDOWS_PLATFORM) \ + @${STAGE_ASSETS} -winserver-${PREFAB_WINDOWS_PLATFORM}-Release \ build/prefab/windows-server/release/dist build/prefab/windows-server/release/dist/ballisticacore_headless.exe: .efrocachemap diff --git a/assets/.asset_manifest_private.json b/assets/.asset_manifest_private.json index 8da5c579..d782cc5a 100644 --- a/assets/.asset_manifest_private.json +++ b/assets/.asset_manifest_private.json @@ -5663,13 +5663,13 @@ "windows/Win32/Lib/zipfile.py", "windows/Win32/OpenAL32.dll", "windows/Win32/SDL2.dll", - "windows/Win32/VC_redist.x86.exe", "windows/Win32/libvorbis.dll", "windows/Win32/libvorbisfile.dll", "windows/Win32/ogg.dll", "windows/Win32/python.exe", "windows/Win32/python37.dll", "windows/Win32/pythonw.exe", + "windows/Win32/vc_redist.x86.exe", "windows/x64/DLLs/_asyncio.pyd", "windows/x64/DLLs/_bz2.pyd", "windows/x64/DLLs/_ctypes.pyd", @@ -7054,11 +7054,14 @@ "windows/x64/Lib/zipfile.py", "windows/x64/OpenAL32.dll", "windows/x64/SDL2.dll", - "windows/x64/VC_redist.x64.exe", "windows/x64/libvorbis.dll", "windows/x64/libvorbisfile.dll", + "windows/x64/msvcp140d.dll", "windows/x64/ogg.dll", "windows/x64/python.exe", "windows/x64/python37.dll", - "windows/x64/pythonw.exe" + "windows/x64/pythonw.exe", + "windows/x64/vc_redist.x64.exe", + "windows/x64/vcruntime140_1d.dll", + "windows/x64/vcruntime140d.dll" ] \ No newline at end of file diff --git a/assets/Makefile b/assets/Makefile index 56a530a5..96829c3e 100644 --- a/assets/Makefile +++ b/assets/Makefile @@ -20028,13 +20028,13 @@ EXTRAS_TARGETS_WIN_WIN32 = \ build/windows/Win32/Lib/venv/scripts/posix/activate.fish \ build/windows/Win32/OpenAL32.dll \ build/windows/Win32/SDL2.dll \ - build/windows/Win32/VC_redist.x86.exe \ build/windows/Win32/libvorbis.dll \ build/windows/Win32/libvorbisfile.dll \ build/windows/Win32/ogg.dll \ build/windows/Win32/python.exe \ build/windows/Win32/python37.dll \ - build/windows/Win32/pythonw.exe + build/windows/Win32/pythonw.exe \ + build/windows/Win32/vc_redist.x86.exe # Rule to copy src extras to build. $(EXTRAS_TARGETS_WIN_WIN32) : ../.efrocachemap @@ -20090,13 +20090,16 @@ EXTRAS_TARGETS_WIN_X64 = \ build/windows/x64/Lib/venv/scripts/posix/activate.fish \ build/windows/x64/OpenAL32.dll \ build/windows/x64/SDL2.dll \ - build/windows/x64/VC_redist.x64.exe \ build/windows/x64/libvorbis.dll \ build/windows/x64/libvorbisfile.dll \ + build/windows/x64/msvcp140d.dll \ build/windows/x64/ogg.dll \ build/windows/x64/python.exe \ build/windows/x64/python37.dll \ - build/windows/x64/pythonw.exe + build/windows/x64/pythonw.exe \ + build/windows/x64/vc_redist.x64.exe \ + build/windows/x64/vcruntime140_1d.dll \ + build/windows/x64/vcruntime140d.dll # Rule to copy src extras to build. $(EXTRAS_TARGETS_WIN_X64) : ../.efrocachemap diff --git a/assets/src/ba_data/python/_ba.py b/assets/src/ba_data/python/_ba.py index 074c725d..eba2eed8 100644 --- a/assets/src/ba_data/python/_ba.py +++ b/assets/src/ba_data/python/_ba.py @@ -34,7 +34,7 @@ NOTE: This file was autogenerated by gendummymodule; do not edit by hand. """ # (hash we can use to see if this file is out of date) -# SOURCES_HASH=160088015161796037115905411263701036909 +# SOURCES_HASH=30991209163728546136111726610486266810 # I'm sorry Pylint. I know this file saddens you. Be strong. # pylint: disable=useless-suppression diff --git a/assets/src/ba_data/python/ba/_meta.py b/assets/src/ba_data/python/ba/_meta.py index 14669765..49a01a44 100644 --- a/assets/src/ba_data/python/ba/_meta.py +++ b/assets/src/ba_data/python/ba/_meta.py @@ -56,14 +56,13 @@ def start_scan() -> None: app = _ba.app if app.metascan is not None: print('WARNING: meta scan run more than once.') - scriptdirs = [app.python_directory_app, app.python_directory_user] - thread = ScanThread(scriptdirs) + pythondirs = [app.python_directory_app, app.python_directory_user] + thread = ScanThread(pythondirs) thread.start() def handle_scan_results(results: ScanResults) -> None: """Called in the game thread with results of a completed scan.""" - from ba import _lang # Warnings generally only get printed locally for users' benefit # (things like out-of-date scripts being ignored, etc.) @@ -71,13 +70,16 @@ def handle_scan_results(results: ScanResults) -> None: # warnings = results.get('warnings', '') # errors = results.get('errors', '') if results.warnings != '' or results.errors != '': - _ba.screenmessage(_lang.Lstr(resource='scanScriptsErrorText'), + import textwrap + from ba._lang import Lstr + _ba.screenmessage(Lstr(resource='scanScriptsErrorText'), color=(1, 0, 0)) _ba.playsound(_ba.getsound('error')) if results.warnings != '': - _ba.log(results.warnings, to_server=False) + _ba.log(textwrap.indent(results.warnings, 'Warning (meta-scan): '), + to_server=False) if results.errors != '': - _ba.log(results.errors) + _ba.log(textwrap.indent(results.errors, 'Error (meta-scan): ')) class ScanThread(threading.Thread): @@ -124,7 +126,9 @@ class DirectoryScan: 'warnings': warnings from scan; should be printed for local feedback 'errors': errors encountered during scan; should be fully logged """ - self.paths = [pathlib.Path(p) for p in paths] + + # Skip non-existent paths completely. + self.paths = [pathlib.Path(p) for p in paths if os.path.isdir(p)] self.results = ScanResults() def _get_path_module_entries( diff --git a/assets/src/ba_data/python/ba/_stats.py b/assets/src/ba_data/python/ba/_stats.py index 317e8c83..5d94bbe6 100644 --- a/assets/src/ba_data/python/ba/_stats.py +++ b/assets/src/ba_data/python/ba/_stats.py @@ -206,7 +206,7 @@ class PlayerRecord: # Only award this if they're still alive and we can get # a current position for them. our_pos: Optional[ba.Vec3] = None - if self._sessionplayer is not None: + if self._sessionplayer: if self._sessionplayer.activityplayer is not None: try: our_pos = self._sessionplayer.activityplayer.position diff --git a/assets/src/ba_data/python/bastd/ui/colorpicker.py b/assets/src/ba_data/python/bastd/ui/colorpicker.py index c9133de0..8684c340 100644 --- a/assets/src/ba_data/python/bastd/ui/colorpicker.py +++ b/assets/src/ba_data/python/bastd/ui/colorpicker.py @@ -25,13 +25,13 @@ from __future__ import annotations from typing import TYPE_CHECKING import ba -from bastd.ui import popup +from bastd.ui.popup import PopupWindow if TYPE_CHECKING: from typing import Any, Tuple, Sequence, List, Optional -class ColorPicker(popup.PopupWindow): +class ColorPicker(PopupWindow): """A popup UI to select from a set of colors. Passes the color to the delegate's color_picker_selected_color() method. @@ -49,8 +49,7 @@ class ColorPicker(popup.PopupWindow): from ba.internal import have_pro, get_player_colors c_raw = get_player_colors() - if len(c_raw) != 16: - raise ValueError('expected 16 player colors') + assert len(c_raw) == 16 self.colors = [c_raw[0:4], c_raw[4:8], c_raw[8:12], c_raw[12:16]] if scale is None: @@ -66,14 +65,14 @@ class ColorPicker(popup.PopupWindow): self._initial_color = initial_color # Create our _root_widget. - popup.PopupWindow.__init__(self, - position=position, - size=(210, 240), - scale=scale, - focus_position=(10, 10), - focus_size=(190, 220), - bg_color=(0.5, 0.5, 0.5), - offset=offset) + PopupWindow.__init__(self, + position=position, + size=(210, 240), + scale=scale, + focus_position=(10, 10), + focus_size=(190, 220), + bg_color=(0.5, 0.5, 0.5), + offset=offset) rows: List[List[ba.Widget]] = [] closest_dist = 9999.0 closest = (0, 0) @@ -172,7 +171,7 @@ class ColorPicker(popup.PopupWindow): self._transition_out() -class ColorPickerExact(popup.PopupWindow): +class ColorPickerExact(PopupWindow): """ pops up a ui to select from a set of colors. passes the color to the delegate's color_picker_selected_color() method """ @@ -185,11 +184,10 @@ class ColorPickerExact(popup.PopupWindow): offset: Tuple[float, float] = (0.0, 0.0), tag: Any = ''): # pylint: disable=too-many-locals - del parent # unused var + del parent # Unused var. from ba.internal import get_player_colors c_raw = get_player_colors() - if len(c_raw) != 16: - raise ValueError('expected 16 player colors') + assert len(c_raw) == 16 self.colors = [c_raw[0:4], c_raw[4:8], c_raw[8:12], c_raw[12:16]] if scale is None: @@ -207,15 +205,15 @@ class ColorPickerExact(popup.PopupWindow): width = 180.0 height = 240.0 - # creates our _root_widget - popup.PopupWindow.__init__(self, - position=position, - size=(width, height), - scale=scale, - focus_position=(10, 10), - focus_size=(width - 20, height - 20), - bg_color=(0.5, 0.5, 0.5), - offset=offset) + # Creates our _root_widget. + PopupWindow.__init__(self, + position=position, + size=(width, height), + scale=scale, + focus_position=(10, 10), + focus_size=(width - 20, height - 20), + bg_color=(0.5, 0.5, 0.5), + offset=offset) self._swatch = ba.imagewidget(parent=self.root_widget, position=(width * 0.5 - 50, height - 70), size=(100, 70), @@ -264,14 +262,15 @@ class ColorPickerExact(popup.PopupWindow): autoselect=True) ba.containerwidget(edit=self.root_widget, start_button=btn) - # unlike the swatch picker, we stay open and constantly push our - # color to the delegate, so start doing that... + # Unlike the swatch picker, we stay open and constantly push our + # color to the delegate, so start doing that. self._update_for_color() def _update_for_color(self) -> None: if not self.root_widget: return ba.imagewidget(edit=self._swatch, color=self._color) + # We generate these procedurally, so pylint misses them. # FIXME: create static attrs instead. ba.textwidget(edit=self._label_r, text='%.2f' % self._color[0]) 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 8faea5ad..f35abb36 100644 --- a/assets/src/ba_data/python/bastd/ui/settings/gamepad.py +++ b/assets/src/ba_data/python/bastd/ui/settings/gamepad.py @@ -42,13 +42,12 @@ class GamepadSettingsWindow(ba.Window): settings: dict = None): self._input = gamepad - # If this fails, our input device went away or something; - # just return an empty zombie then. - try: - self._name = self._input.name - except Exception: + # If our input-device went away, just return an empty zombie. + if not self._input: return + self._name = self._input.name + self._r = 'configGamepadWindow' self._settings = settings self._transition_out = transition_out @@ -776,8 +775,8 @@ class AwaitGamepadInputWindow(ba.Window): message2: ba.Lstr = None): if message is None: print('AwaitGamepadInputWindow message is None!') - message = ba.Lstr( - value='Press any button...') # Shouldn't get here. + # Shouldn't get here. + message = ba.Lstr(value='Press any button...') self._callback = callback self._input = gamepad self._capture_button = button diff --git a/docs/ba_module.md b/docs/ba_module.md index cc475203..d7a89752 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2020-06-11 for Ballistica version 1.5.3 build 20067

+

last updated on 2020-06-13 for Ballistica version 1.5.4 build 20067

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!


diff --git a/tools/stage_assets b/tools/stage_assets index 6bdc48df..bd893bb2 100755 --- a/tools/stage_assets +++ b/tools/stage_assets @@ -30,10 +30,11 @@ import subprocess from functools import partial from typing import TYPE_CHECKING +from efro.error import CleanError from efrotools.pybuild import PYTHON_VERSION_MAJOR if TYPE_CHECKING: - from typing import Optional + from typing import Optional, List # Suffix for the pyc files we include in stagings. # We're using deterministic opt pyc files; see PEP 552. @@ -53,6 +54,7 @@ class Config: os.path.dirname(sys.argv[0]) + '/../assets/build') self.dst: Optional[str] = None self.win_extras_src: Optional[str] = None + self.win_platform: Optional[str] = None self.include_audio = True self.include_models = True self.include_collide_models = True @@ -66,6 +68,7 @@ class Config: self.include_payload_file = False self.tex_suffix: Optional[str] = None self.is_payload_full = False + self.debug = False def _parse_android_args(self) -> None: # On Android we get nitpicky with what @@ -114,40 +117,53 @@ class Config: elif arg == '-audio': self.include_audio = True + def _parse_win_platform(self, platform: str) -> None: + """Parse sub-args in the windows platform string.""" + winempty, wintype, winplt, wincfg = platform.split('-') + self.win_platform = winplt + assert winempty == '' + self.dst = sys.argv[2] + self.tex_suffix = '.dds' + + if wintype == 'win': + pass + elif wintype == 'winserver': + self.include_textures = False + self.include_audio = False + self.include_models = False + else: + raise RuntimeError(f'Invalid wintype: "{wintype}"') + + if winplt == 'Win32': + self.win_extras_src = os.path.abspath( + os.path.dirname(sys.argv[0]) + + '/../assets/build/windows/Win32') + elif winplt == 'x64': + self.win_extras_src = os.path.abspath( + os.path.dirname(sys.argv[0]) + '/../assets/build/windows/x64') + else: + raise RuntimeError(f'Invalid winplt: "{winplt}"') + + if wincfg == 'Debug': + self.debug = True + elif wincfg == 'Release': + self.debug = False + else: + raise RuntimeError(f'Invalid wincfg: "{wincfg}"') + def parse_args(self) -> None: """Parse args and apply to the cfg.""" - if '-android' in sys.argv: + if len(sys.argv) < 2: + raise RuntimeError('Expected a platform argument.') + platform = sys.argv[1] + if platform == '-android': self._parse_android_args() - elif '-cmake' in sys.argv: + elif platform.startswith('-win'): + self._parse_win_platform(platform) + elif platform == '-cmake': self.dst = sys.argv[2] self.tex_suffix = '.dds' - elif '-win-Win32' in sys.argv: - self.dst = sys.argv[2] - self.tex_suffix = '.dds' - self.win_extras_src = os.path.abspath( - os.path.dirname(sys.argv[0]) + - '/../assets/build/windows/Win32') - elif '-win-x64' in sys.argv: - self.dst = sys.argv[2] - self.tex_suffix = '.dds' - self.win_extras_src = os.path.abspath( - os.path.dirname(sys.argv[0]) + '/../assets/build/windows/x64') - elif '-win-server-Win32' in sys.argv: - self.dst = sys.argv[2] - self.win_extras_src = os.path.abspath( - os.path.dirname(sys.argv[0]) + - '/../assets/build/windows/Win32') - self.include_textures = False - self.include_audio = False - self.include_models = False - elif '-win-server-x64' in sys.argv: - self.dst = sys.argv[2] - self.win_extras_src = os.path.abspath( - os.path.dirname(sys.argv[0]) + '/../assets/build/windows/x64') - self.include_textures = False - self.include_audio = False - self.include_models = False - elif '-cmake-server' in sys.argv: + elif '-cmakeserver' in sys.argv: self.dst = sys.argv[2] self.include_textures = False self.include_audio = False @@ -167,7 +183,7 @@ class Config: self.pylib_src_name = 'pylib-apple' self.tex_suffix = '.pvr' else: - raise Exception('no valid platform set') + raise RuntimeError('No valid platform arg provided.') def md5sum(filename: str) -> str: @@ -226,20 +242,18 @@ def _write_payload_file(assets_root: str, full: bool) -> None: def _sync_windows_extras(cfg: Config) -> None: assert cfg.win_extras_src is not None + assert cfg.win_platform is not None if not os.path.isdir(cfg.win_extras_src): raise Exception('win extras src dir not found: ' + cfg.win_extras_src) # Ok, lets do full syncs on each subdir we find so we # properly delete anything in dst that disappeared from src. # Lastly we'll sync over the remaining top level files. - # It'll technically be possible to orphaned top level - # files in dst, but we should be pulling those into dists - # individually by name anyway so it should be safe. + # Note: technically it'll be possible to leave orphaned top level + # files in dst, so when building packages/etc. we should always start + # from scratch. assert cfg.dst is not None for dirname in ('DLLs', 'Lib'): - # We also need to be more particular about which pyc files we pull - # over. The Python stuff in Extras is also used by some scripts - # so there may be arbitrary non-opt pycs hanging around. _run(f'mkdir -p "{cfg.dst}/{dirname}"') cmd = ('rsync --recursive --update --delete --delete-excluded ' ' --prune-empty-dirs' @@ -251,15 +265,39 @@ def _sync_windows_extras(cfg: Config) -> None: '"' + cfg.dst + '/' + dirname + '/"') _run(cmd) - # Now sync the top level individual files. - cmd = ('rsync --update ' + cfg.win_extras_src + '/*.dll ' + - cfg.win_extras_src + '/*.exe' - ' "' + cfg.dst + '/"') - _run(cmd) + # Now sync the top level individual files that we want. + # (we could technically copy everything over but this keeps staging + # dirs a bit tidier) + toplevelfiles: List[str] = [ + 'libvorbis.dll', 'libvorbisfile.dll', 'ogg.dll', 'OpenAL32.dll', + 'SDL2.dll' + ] + + # Include debug dlls for x64 so folks without msvc can run them. + # (seems win32 doesn't have the same set so ignoring that for now) + if cfg.debug and cfg.win_platform == 'x64': + toplevelfiles += [ + 'msvcp140d.dll', 'vcruntime140d.dll', 'vcruntime140_1d.dll' + ] + + # Include the runtime redistributables in release builds. + if not cfg.debug: + if cfg.win_platform == 'x64': + toplevelfiles.append('vc_redist.x64.exe') + elif cfg.win_platform == 'Win32': + toplevelfiles.append('vc_redist.x86.exe') + else: + raise RuntimeError(f'Invalid win_platform {cfg.win_platform}') + + cmd2 = (['rsync', '--update'] + + [os.path.join(cfg.win_extras_src, f) + for f in toplevelfiles] + [cfg.dst + '/']) + subprocess.run(cmd2, check=True) # If we're running under WSL we won't be able to launch these .exe files # unless they're marked executable, so do that here. - _run(f'chmod +x {cfg.dst}/*.exe') + # Update: gonna try simply setting this flag on the source side. + # _run(f'chmod +x {cfg.dst}/*.exe') def _sync_pylib(cfg: Config) -> None: @@ -339,4 +377,8 @@ def main() -> None: if __name__ == '__main__': - main() + try: + main() + except CleanError as exc: + exc.pretty_print() + sys.exit(1)