diff --git a/.efrocachemap b/.efrocachemap index 926601c1..047a491b 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3936,14 +3936,14 @@ "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/82/81/1ae81275ebe9ab9ab502b7eebb32", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/10/cf/d799dd2e5e833a42330a91a27872", "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f3/66/4b663b0bd3d346168132a3b76e3d", - "build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d8/26/e42cb423191515afb14ed85da586", - "build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/90/5d/b4f96e9882d98e83a7ba33c9db22", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/14/f7/5ad112c496608b9cb82bf33f8bb7", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/46/ca/13bc7ce2e07eeee54c3309c960b7", - "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/79/65/c7a4dcab9c1f5f0b17ded9d2a0ac", - "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/4b/c1/151d5e57bf09762496470bf8c4bb", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0c/e1/2335a8137464182089e57ace0f8e", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/30/a7/af58cca4a647d19fca0a43b11d88", + "build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/21/e9/1430bf257d1263ff0ed36410c332", + "build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/46/7a/caed7137d70eb5bf1696a879fb75", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d5/e5/c6ebd43787923294b2210592290d", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/23/2b/74da96e45034770834c5213cfaf0", + "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/11/f6/ff5475943c5c106266121392faab", + "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/71/d5/009c34dd2016fa879c28c8838405", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/85/c8/19cf729b848e002fdc731decba21", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/bc/7b/c93b714145994b823a708b57b501", "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/e8/bb/5985b1670513fbcd4931383af8a0", "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/69/51/2fd61101ec41e2944db05fa588db", "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/a6/9b/f3c55efe1ae7a8fd3ba35d3f9caa", @@ -3952,12 +3952,12 @@ "build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/83/25/980050d75bbea49a84652209050c", "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/47/aa/e82233695a50974e7e22db4e7146", "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2b/45/7f9fbae208890455fce2fbc172d3", - "build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fc/4c/5d82b9c31124da7a329358fcd553", - "build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ad/71/ed5d6a378aca34d43483aed9dc79", - "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/30/e5/284e85af992a18c1053adc58cdfb", - "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/23/ca/f4cfaabc60d0afa57b6c0f38547f", - "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0e/47/cf7099fc7b7317c2be02861e6978", - "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/74/ef/7f5408bb25f0ebcf17e52ad18442", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9a/04/42c2bf1a43ec9c2c674289f5b963", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a5/5d/06f1fc4de7443709de1acfc00960" + "build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4c/f2/67f1041d8c49e7bdad100dae4ef1", + "build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/80/7b/f57451f57d2434bcb75d48c08a33", + "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c6/ce/1df69a933f207867f8385f491f47", + "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/21/49/0b011f4ce5872c7eaabaa97b890f", + "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/20/6f/2fc08ac6c2b2c3b31572a369deab", + "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1d/bf/ce1ea8ad2fb7bcf58a367ec1e19a", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fb/0b/864980222e52ee6bd5a272b0f742", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bb/6d/401e3cb8d8641df64ffbeac2b02d" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 3e8a2d1d..6d580eac 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -174,12 +174,14 @@ basew bastd batools + bbbb bblk bblu bbot bbtn bcppcompiler bcyn + bdea bdfl bdir belarussian @@ -314,6 +316,7 @@ cheadersline checkarg checkboxwidget + checkchisel checkenv checkfast checkfull @@ -592,6 +595,7 @@ efrocachemap efroemling efrogradle + efrohack efrohome efrosync efrotool @@ -623,6 +627,8 @@ entrytypeselect enumtype enumval + enumvalue + enval envcfg envhash envname @@ -697,6 +703,8 @@ fhashes fhdr fieldattr + fieldname + fieldpath fieldsdict fieldtype fieldtypes @@ -1021,6 +1029,7 @@ inputfiles inputhash inputnode + inputter inputtype inpututils inspectdir @@ -1117,6 +1126,7 @@ leaderboards leady lenglishvalues + lenval levelgametype levelmodule levelname @@ -1413,6 +1423,7 @@ numedit numsound numstr + nval nvcompress nvidia nyko @@ -1424,6 +1435,7 @@ obval occurrances oculus + oenval offsanchor ofval oggenc @@ -1465,6 +1477,8 @@ outhashpath outname outpath + outputter + outvalue ouya overloadsigs packagedir @@ -1829,6 +1843,8 @@ sdtk selectmodule senze + seqtype + seqtypestr serverbuild servercallthread servercallthreadtype @@ -1882,6 +1898,7 @@ shroom shutil simplesubclasses + simpletype sincelaunch singledispatch singledispatchmethod @@ -1951,6 +1968,7 @@ sred sshd sslproto + ssval stackstr standin starscale @@ -1995,6 +2013,7 @@ subdep subdeps subdirs + subfieldpath subfolders subname subpath @@ -2005,6 +2024,7 @@ subprocesses subrepos subsel + subtypestr subval subvalue subvaluetype @@ -2074,6 +2094,7 @@ tempfile tempfilepath templatecb + tenum termcolors termios testbuffer diff --git a/Makefile b/Makefile index 45ba61cf..9ce37bf4 100644 --- a/Makefile +++ b/Makefile @@ -654,17 +654,17 @@ test-full: test # Individual test with extra output enabled. test-assetmanager: - @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -v \ + @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -vv \ tests/test_ba/test_assetmanager.py::test_assetmanager # Individual test with extra output enabled. test-dataclasses: - @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -v \ + @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -vv \ tests/test_efro/test_dataclasses.py # Individual test with extra output enabled. test-entity: - @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -v \ + @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -vv \ tests/test_efro/test_entity.py # Tell make which of these targets don't represent files. diff --git a/assets/src/ba_data/python/ba/__init__.py b/assets/src/ba_data/python/ba/__init__.py index 1cdaf5ff..8e3a6e9f 100644 --- a/assets/src/ba_data/python/ba/__init__.py +++ b/assets/src/ba_data/python/ba/__init__.py @@ -60,8 +60,7 @@ from ba._campaign import Campaign from ba._gameutils import (GameTip, animate, animate_array, show_damage_count, timestring, cameraflash) from ba._general import (WeakCall, Call, existing, Existable, - verify_object_death, storagename, getclass, - enum_by_value) + verify_object_death, storagename, getclass) from ba._keyboard import Keyboard from ba._level import Level from ba._lobby import Lobby, Chooser diff --git a/assets/src/ba_data/python/ba/_general.py b/assets/src/ba_data/python/ba/_general.py index 21cfc361..a617fac3 100644 --- a/assets/src/ba_data/python/ba/_general.py +++ b/assets/src/ba_data/python/ba/_general.py @@ -8,7 +8,6 @@ import types import weakref import random import inspect -from enum import Enum from typing import TYPE_CHECKING, TypeVar, Protocol from efro.terminal import Clr @@ -36,7 +35,6 @@ class Existable(Protocol): ExistableType = TypeVar('ExistableType', bound=Existable) T = TypeVar('T') -ET = TypeVar('ET', bound=Enum) def existing(obj: Optional[ExistableType]) -> Optional[ExistableType]: @@ -399,30 +397,3 @@ def storagename(suffix: str = None) -> str: if suffix is not None: fullpath = f'{fullpath}_{suffix}' return fullpath.replace('.', '_') - - -def enum_by_value(cls: Type[ET], value: Any) -> ET: - """Create an enum from a value. - - Category: General Utility Functions - - This is basically the same as doing 'obj = EnumType(value)' except - that it works around an issue where a reference loop is created - if an exception is thrown due to an invalid value. Since we disable - the cyclic garbage collector for most of the time, such loops can lead - to our objects sticking around longer than we want. - This issue has been submitted to Python as a bug so hopefully we can - remove this eventually if it gets fixed: https://bugs.python.org/issue42248 - """ - - # Note: we don't recreate *ALL* the functionality of the Enum constructor - # such as the _missing_ hook; but this should cover our basic needs. - value2member_map = getattr(cls, '_value2member_map_') - assert value2member_map is not None - try: - out = value2member_map[value] - assert isinstance(out, cls) - return out - except KeyError: - raise ValueError('%r is not a valid %s' % - (value, cls.__name__)) from None diff --git a/assets/src/ba_data/python/bastd/ui/gather/__init__.py b/assets/src/ba_data/python/bastd/ui/gather/__init__.py index 3420f6bf..3d69ce04 100644 --- a/assets/src/ba_data/python/bastd/ui/gather/__init__.py +++ b/assets/src/ba_data/python/bastd/ui/gather/__init__.py @@ -241,6 +241,7 @@ class GatherWindow(ba.Window): ba.print_exception(f'Error saving state for {self}.') def _restore_state(self) -> None: + from efro.util import enum_by_value try: for tab in self._tabs.values(): tab.restore_state() @@ -252,7 +253,7 @@ class GatherWindow(ba.Window): current_tab = self.TabID.ABOUT gather_tab_val = ba.app.config.get('Gather Tab') try: - stored_tab = ba.enum_by_value(self.TabID, gather_tab_val) + stored_tab = enum_by_value(self.TabID, gather_tab_val) if stored_tab in self._tab_row.tabs: current_tab = stored_tab except ValueError: @@ -264,8 +265,8 @@ class GatherWindow(ba.Window): sel = self._tab_container elif isinstance(sel_name, str) and sel_name.startswith('Tab:'): try: - sel_tab_id = ba.enum_by_value(self.TabID, - sel_name.split(':')[-1]) + sel_tab_id = enum_by_value(self.TabID, + sel_name.split(':')[-1]) except ValueError: sel_tab_id = self.TabID.ABOUT sel = self._tab_row.tabs[sel_tab_id].button diff --git a/assets/src/ba_data/python/bastd/ui/store/browser.py b/assets/src/ba_data/python/bastd/ui/store/browser.py index b1bf4585..fe53e28a 100644 --- a/assets/src/ba_data/python/bastd/ui/store/browser.py +++ b/assets/src/ba_data/python/bastd/ui/store/browser.py @@ -1018,6 +1018,7 @@ class StoreBrowserWindow(ba.Window): ba.print_exception(f'Error saving state for {self}.') def _restore_state(self) -> None: + from efro.util import enum_by_value try: sel: Optional[ba.Widget] sel_name = ba.app.ui.window_states.get(self.__class__.__name__, @@ -1025,8 +1026,8 @@ class StoreBrowserWindow(ba.Window): assert isinstance(sel_name, (str, type(None))) try: - current_tab = ba.enum_by_value(self.TabID, - ba.app.config.get('Store Tab')) + current_tab = enum_by_value(self.TabID, + ba.app.config.get('Store Tab')) except ValueError: current_tab = self.TabID.CHARACTERS @@ -1040,8 +1041,8 @@ class StoreBrowserWindow(ba.Window): sel = self._scrollwidget elif isinstance(sel_name, str) and sel_name.startswith('Tab:'): try: - sel_tab_id = ba.enum_by_value(self.TabID, - sel_name.split(':')[-1]) + sel_tab_id = enum_by_value(self.TabID, + sel_name.split(':')[-1]) except ValueError: sel_tab_id = self.TabID.CHARACTERS sel = self._tab_row.tabs[sel_tab_id].button diff --git a/assets/src/ba_data/python/bastd/ui/watch.py b/assets/src/ba_data/python/bastd/ui/watch.py index 7f4ccea3..09d7e26e 100644 --- a/assets/src/ba_data/python/bastd/ui/watch.py +++ b/assets/src/ba_data/python/bastd/ui/watch.py @@ -503,14 +503,15 @@ class WatchWindow(ba.Window): ba.print_exception(f'Error saving state for {self}.') def _restore_state(self) -> None: + from efro.util import enum_by_value try: sel: Optional[ba.Widget] sel_name = ba.app.ui.window_states.get(self.__class__.__name__, {}).get('sel_name') assert isinstance(sel_name, (str, type(None))) try: - current_tab = ba.enum_by_value(self.TabID, - ba.app.config.get('Watch Tab')) + current_tab = enum_by_value(self.TabID, + ba.app.config.get('Watch Tab')) except ValueError: current_tab = self.TabID.MY_REPLAYS self._set_tab(current_tab) @@ -521,8 +522,8 @@ class WatchWindow(ba.Window): sel = self._tab_container elif isinstance(sel_name, str) and sel_name.startswith('Tab:'): try: - sel_tab_id = ba.enum_by_value(self.TabID, - sel_name.split(':')[-1]) + sel_tab_id = enum_by_value(self.TabID, + sel_name.split(':')[-1]) except ValueError: sel_tab_id = self.TabID.MY_REPLAYS sel = self._tab_row.tabs[sel_tab_id].button diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index 5be8849e..1a22fe7a 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -23,7 +23,7 @@ sys.path += [ ] from bacommon.servermanager import ServerConfig, StartServerModeCommand -from efro.dataclasses import dataclass_assign, dataclass_validate +from efro.dataclasses import dataclass_from_dict, dataclass_validate from efro.error import CleanError from efro.terminal import Clr @@ -32,9 +32,11 @@ if TYPE_CHECKING: from types import FrameType from bacommon.servermanager import ServerCommand -VERSION_STR = '1.1.0' +VERSION_STR = '1.1.1' # Version history: +# 1.1.1: +# Switched config reading to use efro.dataclasses.dataclass_from_dict() # 1.1.0: # Added shutdown command # Changed restart to default to immediate=True @@ -274,19 +276,17 @@ class ServerManagerApp: def _load_config(self) -> ServerConfig: user_config_path = 'config.yaml' - # Start with a default config, and if there is a config.yaml, - # assign whatever is contained within. - config = ServerConfig() if os.path.exists(user_config_path): import yaml with open(user_config_path) as infile: - user_config = yaml.safe_load(infile.read()) + user_config_raw = yaml.safe_load(infile.read()) # An empty config file will yield None, and that's ok. - if user_config is not None: - dataclass_assign(config, user_config) + if user_config_raw is not None: + return dataclass_from_dict(ServerConfig, user_config_raw) - return config + # Go with defaults if we weren't able to load anything. + return ServerConfig() def _enable_tab_completion(self, locs: Dict) -> None: """Enable tab-completion on platforms where available (linux/mac).""" diff --git a/ballisticacore-cmake/.idea/dictionaries/ericf.xml b/ballisticacore-cmake/.idea/dictionaries/ericf.xml index 69154db7..52f1a898 100644 --- a/ballisticacore-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticacore-cmake/.idea/dictionaries/ericf.xml @@ -70,6 +70,7 @@ bbbbbb bbbbbbb bcfn + bdea bezanson bgra bigendian @@ -142,6 +143,7 @@ charstr chatmessage checkboxwidget + checkchisel chrono chunksize cjief @@ -246,6 +248,7 @@ echidna edef efro + efrohack efrohome elems elevenbase @@ -258,6 +261,8 @@ endline endtime entrypoint + enumvalue + enval envcfg envs envval @@ -297,6 +302,8 @@ fffffff fffffffffifff fgets + fieldname + fieldpath fifteenbits filterval finishedptr @@ -427,6 +434,7 @@ initguid inittab inputdevice + inputter insta intercollide internalformat @@ -473,6 +481,7 @@ lastvalid leaderboard leaderboards + lenval lgui lhalf libutf @@ -593,6 +602,7 @@ numc numentries numlock + nval nvidia nyffenegger objexists @@ -600,6 +610,7 @@ obstack obvs oculus + oenval oiffsss oldname oooo @@ -630,7 +641,9 @@ ostype ourself ourstanding + outputter outval + outvalue ouya parameteriv passcode @@ -752,6 +765,8 @@ sdl's sdlk seqlen + seqtype + seqtypestr serv serverget serverput @@ -780,6 +795,7 @@ shufflable signsubscale simd + simpletype sisssssssss sixteenbits smoothering @@ -810,6 +826,7 @@ sssssssd sssssssi ssssssssssss + ssval standin startedptr startpos @@ -832,11 +849,13 @@ subargs subclsssing subentities + subfieldpath subitems subpaths subplatform subscale subscr + subtypestr sval symbolification syscalls @@ -849,6 +868,7 @@ teleported teleporting tempvec + tenum testint testnode texel diff --git a/docs/ba_module.md b/docs/ba_module.md index 6127dc86..f45d0019 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2021-01-08 for Ballistica version 1.5.30 build 20266

+

last updated on 2021-01-14 for Ballistica version 1.5.30 build 20267

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!


@@ -86,7 +86,6 @@