From 5a77f0bc524919fcb83b1f0f94ae378a87b4422d Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Tue, 5 May 2020 16:32:41 -0700 Subject: [PATCH] Various bug fixes and cleanup --- .efrocachemap | 24 +++++++++---------- .idea/dictionaries/ericf.xml | 2 ++ assets/src/ba_data/python/ba/_servermode.py | 6 ++--- .../python/bastd/game/targetpractice.py | 4 ++-- .../ba_data/python/bastd/ui/profile/edit.py | 4 ++-- .../src/ba_data/python/bastd/ui/store/item.py | 7 +++--- assets/src/server/ballisticacore_server.py | 18 +++++++------- docs/ba_module.md | 2 +- tools/snippets | 16 +++++++++++-- 9 files changed, 50 insertions(+), 33 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index ec706517..20e10897 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4132,16 +4132,16 @@ "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/a2/5b/8598da1884bbe060f495d0273d7d", - "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/83/95/5e30fd47e6befa8f9a370a52be21", - "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/60/3a/1edfbfc7adcbda3f6734f9282756", - "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/34/a1/f7d0bf6b709a757418825a1cc24f", - "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/59/e9/8a29cf17f4434f783fab73afc349", - "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/71/9d/02c9e2ba7c91941991552228c66c", - "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/9b/35/42e8f879ac5b07ba2d8caee897dc", - "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/3f/3e/20eb6ac1043ac0417c2b7728f7bd", - "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/b9/75/6b1523ec9b0d510870b4695a6613", - "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/7d/04/b882bbfd0197248bca49016356c1", - "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/13/50/1fb612a251431229703317bd81e5", - "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ec/3c/ce84db1040251fb5a11b0c7dfd7b" + "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b8/70/d087e1b445f7d19c02e9ff22d6ba", + "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9c/5b/258ebaafc23ffafdee40992f4422", + "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d6/e4/0c24f8930d7952fdf667b3046dac", + "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7a/a4/648b4505563f6f870c80df784dd2", + "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b2/60/a67366b88128c1743f0e4bdc7844", + "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/db/89/4ea43a8120df7d3d60aab0902a7a", + "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/60/1a/1463ba7cddddd3796c27a8250875", + "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/0c/ae/b4500e7fc1dd9f2e515dfc6d7b2f", + "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/26/36/dd35f9f8ba7708ecaa3176e38dd8", + "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/37/cc/4fb23e54b6058cb3a9fbf8862387", + "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/06/5a/40efd122998130779a70bcc7aa68", + "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/3f/15/f046cab19964f6e60159ee7eaba2" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index ef3a872b..faa11098 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -307,6 +307,7 @@ clrend clrgrn clrhdr + clrnames clrred cmathmodule cmds @@ -1614,6 +1615,7 @@ sharedobjs shiftdelay shiftposition + shortname shouldn showpoints showstats diff --git a/assets/src/ba_data/python/ba/_servermode.py b/assets/src/ba_data/python/ba/_servermode.py index ce11850a..acdabadc 100644 --- a/assets/src/ba_data/python/ba/_servermode.py +++ b/assets/src/ba_data/python/ba/_servermode.py @@ -215,14 +215,14 @@ class ServerController: else: addr = data['address'] port = data['port'] - show_addr = os.environ.get('BA_VERBOSE_ACCESS_CHECK', '0') == '1' + show_addr = os.environ.get('BA_ACCESS_CHECK_VERBOSE', '0') == '1' if show_addr: addrstr = f' {addr}' poststr = '' else: addrstr = '' poststr = ( - '\nSet environment variable BA_VERBOSE_ACCESS_CHECK=1' + '\nSet environment variable BA_ACCESS_CHECK_VERBOSE=1' ' for more info.') if data['accessible']: print(f'{Clr.SBLU}Master server access check of{addrstr}' @@ -314,7 +314,7 @@ class ServerController: if self._first_run: curtimestr = time.strftime('%c') - print(f'{Clr.SBLU}BallisticaCore {app.version}' + print(f'{Clr.BLD}{Clr.BLU}BallisticaCore {app.version}' f' ({app.build_number})' f' entering server-mode {curtimestr}{Clr.RST}') diff --git a/assets/src/ba_data/python/bastd/game/targetpractice.py b/assets/src/ba_data/python/bastd/game/targetpractice.py index e0304a99..e6c7be7e 100644 --- a/assets/src/ba_data/python/bastd/game/targetpractice.py +++ b/assets/src/ba_data/python/bastd/game/targetpractice.py @@ -238,7 +238,7 @@ class Target(ba.Actor): }) loc2 = ba.newnode('locator', attrs={ - 'shape': 'circle_outline', + 'shape': 'circleOutline', 'position': position, 'color': (0, 1, 0), 'opacity': 0.3, @@ -247,7 +247,7 @@ class Target(ba.Actor): }) loc3 = ba.newnode('locator', attrs={ - 'shape': 'circle_outline', + 'shape': 'circleOutline', 'position': position, 'color': (0, 1, 0), 'opacity': 0.1, diff --git a/assets/src/ba_data/python/bastd/ui/profile/edit.py b/assets/src/ba_data/python/bastd/ui/profile/edit.py index 7d7a6e45..128c6fdf 100644 --- a/assets/src/ba_data/python/bastd/ui/profile/edit.py +++ b/assets/src/ba_data/python/bastd/ui/profile/edit.py @@ -669,10 +669,10 @@ class EditProfileWindow(ba.Window): 'name': new_name, 'profile': { 'character': self._spazzes[self._icon_index], - 'color': self._color, + 'color': list(self._color), 'global': self._global, 'icon': self._icon, - 'highlight': self._highlight + 'highlight': list(self._highlight) } }) diff --git a/assets/src/ba_data/python/bastd/ui/store/item.py b/assets/src/ba_data/python/bastd/ui/store/item.py index 795e1018..1ff38c67 100644 --- a/assets/src/ba_data/python/bastd/ui/store/item.py +++ b/assets/src/ba_data/python/bastd/ui/store/item.py @@ -293,8 +293,8 @@ def instantiate_store_item_display(item_name: str, total_worth_price: Optional[str] if total_worth_item is not None: price = _ba.get_price(total_worth_item) - assert price is not None - total_worth_price = get_clean_price(price) + total_worth_price = (get_clean_price(price) + if price is not None else '??') else: total_worth_price = None @@ -339,7 +339,8 @@ def instantiate_store_item_display(item_name: str, draw_controller=btn, color=backing_color, texture=b_square_texture)) - # hack - gotta draw two transparent versions to avoid z issues + + # Hack - gotta draw two transparent versions to avoid z issues. for mod in model_opaque, model_transparent: extra_images.append( ba.imagewidget(parent=parent_widget, diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index a73ebf7b..8a8907d5 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -105,9 +105,11 @@ class ServerManagerApp: # Print basic usage info in interactive mode. if sys.stdin.isatty(): - print(f'{Clr.SMAG}BallisticaCore server manager {VERSION_STR}' - f' starting up...\n' - f'Use the "mgr" object to make live server adjustments.\n' + print(f'{Clr.CYN}{Clr.BLD}BallisticaCore server' + f' manager {VERSION_STR}' + f' starting up...{Clr.RST}\n' + f'{Clr.CYN}Use the "mgr" object to make' + f' live server adjustments.\n' f'Type "help(mgr)" for more information.{Clr.RST}') # Python will handle SIGINT for us (as KeyboardInterrupt) but we @@ -267,7 +269,7 @@ class ServerManagerApp: # slight behavior tweaks. Hmm; should this be an argument instead? os.environ['BA_SERVER_WRAPPER_MANAGED'] = '1' - print(f'{Clr.SMAG}Launching server child-process...{Clr.RST}') + print(f'{Clr.CYN}Launching server child-process...{Clr.RST}') binary_name = ('ballisticacore_headless.exe' if os.name == 'nt' else './ballisticacore_headless') self._process = subprocess.Popen([binary_name, '-cfgdir', 'ba_root'], @@ -355,7 +357,7 @@ class ServerManagerApp: if (self._restart_minutes is not None and sincelaunch > (self._restart_minutes * 60.0) and not self._process_sent_auto_restart): - print(f'{Clr.SMAG}restart_minutes ({self._restart_minutes})' + print(f'{Clr.CYN}restart_minutes ({self._restart_minutes})' f' elapsed; requesting child-process' f' soft restart...{Clr.RST}') self.restart() @@ -364,7 +366,7 @@ class ServerManagerApp: # Watch for the process exiting. code: Optional[int] = self._process.poll() if code is not None: - print(f'{Clr.SMAG}Server process exited' + print(f'{Clr.CYN}Server process exited' f' with code {code}.{Clr.RST}') time.sleep(1.0) # Keep things from moving too fast. self._reset_process_vars() @@ -383,7 +385,7 @@ class ServerManagerApp: if self._process is None: return - print(f'{Clr.SMAG}Stopping server process...{Clr.RST}') + print(f'{Clr.CYN}Stopping server process...{Clr.RST}') # First, ask it nicely to die and give it a moment. # If that doesn't work, bring down the hammer. @@ -393,7 +395,7 @@ class ServerManagerApp: except subprocess.TimeoutExpired: self._process.kill() self._reset_process_vars() - print(f'{Clr.SMAG}Server process stopped.{Clr.RST}') + print(f'{Clr.CYN}Server process stopped.{Clr.RST}') def main() -> None: diff --git a/docs/ba_module.md b/docs/ba_module.md index d1f28296..f03611d1 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2020-05-03 for Ballistica version 1.5.0 build 20001

+

last updated on 2020-05-05 for Ballistica version 1.5.0 build 20002

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/snippets b/tools/snippets index ed32b564..af25fb0f 100755 --- a/tools/snippets +++ b/tools/snippets @@ -526,11 +526,23 @@ def filter_server_config() -> None: def printcolors() -> None: """Print all colors available in efro.terminals.TerminalColor.""" - from efro.terminal import TerminalColor + from efro.error import CleanError + from efro.terminal import TerminalColor, Clr + + if Clr.RED == '': + raise CleanError('Efro color terminal output is disabled.') + + clrnames = {getattr(Clr, s): s for s in dir(Clr) if s.isupper()} + + # Print everything in Clr (since that's what users should be using + # but do it in the order of TerminalColor (since Clr is just a class + # so is unordered) for value in TerminalColor: if value is TerminalColor.RESET: continue - print(f'{value.name}: {value.value}' + shortname = f'Clr.{clrnames[value.value]}' + longname = f'({value.name})' + print(f'{shortname:<12} {longname:<20} {value.value}' f'The quick brown fox jumps over the lazy dog.' f'{TerminalColor.RESET.value}')