From ce032f20506bba6c3b4878085c0549e34906db8d Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sun, 19 Sep 2021 13:55:10 -0500 Subject: [PATCH] Added thai language --- .efrocachemap | 63 +++++++++---------- .idea/dictionaries/ericf.xml | 1 + assets/.asset_manifest_private.json | 1 + assets/.asset_manifest_public.json | 2 + assets/Makefile | 3 + assets/src/ba_data/python/ba/_app.py | 37 ----------- assets/src/ba_data/python/ba/_asyncio.py | 71 ++++++++++++++++++++++ assets/src/ba_data/python/ba/_hooks.py | 13 ++++ assets/src/ba_data/python/ba/_language.py | 3 +- src/ballistica/ballistica.cc | 2 +- src/ballistica/game/game.cc | 2 +- src/ballistica/python/python.cc | 2 +- src/ballistica/python/python.h | 2 +- src/meta/bameta/python_embedded/binding.py | 2 +- tools/batools/pcommand.py | 2 + 15 files changed, 132 insertions(+), 74 deletions(-) create mode 100644 assets/src/ba_data/python/ba/_asyncio.py diff --git a/.efrocachemap b/.efrocachemap index af28416e..30c50ad1 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -420,7 +420,7 @@ "assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/14/f1/4f2995d78fc20dd79dfb39c5d554", "assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/57/ac/6ed0caecd25dc23688debed24c45", "assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/32/08/38dac4a79ab2acee76a75d32a310", - "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/99/a3/f019f03a07f8e2d93871447d09c2", + "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/b0/83/53fee9d568b89a46f2df33401ed6", "assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/0f/0e/7184059414320d32104463e41038", "assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/e2/58/c2c5964370df118c51528dc4bfa2", "assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/d8/b8/a38187a1dfba81a42ddfbf2932be", @@ -429,11 +429,11 @@ "assets/build/ba_data/data/languages/czech.json": "https://files.ballistica.net/cache/ba1/b6/67/633c424cc32e5c4afbd188d3a908", "assets/build/ba_data/data/languages/danish.json": "https://files.ballistica.net/cache/ba1/3f/46/e4da3c1d2b0ebf916df55c608b28", "assets/build/ba_data/data/languages/dutch.json": "https://files.ballistica.net/cache/ba1/d1/07/37b7adc3dbec7328d26c5325f212", - "assets/build/ba_data/data/languages/english.json": "https://files.ballistica.net/cache/ba1/b6/e8/5b89a8e607a1eec8e4c86374b7de", + "assets/build/ba_data/data/languages/english.json": "https://files.ballistica.net/cache/ba1/6f/82/a29452c726dc179fc33286a90922", "assets/build/ba_data/data/languages/esperanto.json": "https://files.ballistica.net/cache/ba1/6e/fd/685a4e1da031474d47a1d9eb2731", "assets/build/ba_data/data/languages/french.json": "https://files.ballistica.net/cache/ba1/16/53/1535cc28a789efb7372de01bd7fb", "assets/build/ba_data/data/languages/german.json": "https://files.ballistica.net/cache/ba1/2f/47/3f7ef1eb62055dd5e6f7b7ec648c", - "assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/27/42/24f6e3191209db8422b923ceee2d", + "assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/0a/ec/f6665a696238275c806e7a0b1d0d", "assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/ff/08/0d32d1babc60fdebd39def8b51da", "assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/63/f0/cc8dd75a100f7d58000a361ca160", "assets/build/ba_data/data/languages/hungarian.json": "https://files.ballistica.net/cache/ba1/cf/2b/23acc62ab35c4763a9cfe23495dc", @@ -442,13 +442,14 @@ "assets/build/ba_data/data/languages/korean.json": "https://files.ballistica.net/cache/ba1/26/8d/bf9cc8db2cc71b69e789898e1093", "assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/d8/b7/9098f0cb25088d233541490e3e68", "assets/build/ba_data/data/languages/polish.json": "https://files.ballistica.net/cache/ba1/2e/17/fb3e7ed77fa54427b434b1791793", - "assets/build/ba_data/data/languages/portuguese.json": "https://files.ballistica.net/cache/ba1/6c/04/a528a4df9364ad4f0261cbc83f0a", + "assets/build/ba_data/data/languages/portuguese.json": "https://files.ballistica.net/cache/ba1/fe/6d/751277bc6b704d4f2a54cf1a9cfa", "assets/build/ba_data/data/languages/romanian.json": "https://files.ballistica.net/cache/ba1/82/12/57bf144e12be229a9b70da9c45cb", "assets/build/ba_data/data/languages/russian.json": "https://files.ballistica.net/cache/ba1/bb/67/bdf5e720897c0eb966acdbab4274", "assets/build/ba_data/data/languages/serbian.json": "https://files.ballistica.net/cache/ba1/0d/19/4ed63932f5476d97068171906135", "assets/build/ba_data/data/languages/slovak.json": "https://files.ballistica.net/cache/ba1/97/ec/384ca27db2fdc711514273726935", "assets/build/ba_data/data/languages/spanish.json": "https://files.ballistica.net/cache/ba1/42/8a/31ee9bf7d90ad1c7a613ab91e4f3", "assets/build/ba_data/data/languages/swedish.json": "https://files.ballistica.net/cache/ba1/50/9f/be006ba19be6a69a57837eb6dca0", + "assets/build/ba_data/data/languages/thai.json": "https://files.ballistica.net/cache/ba1/7f/21/a683b2ea2a9ebc6df81b5faa586a", "assets/build/ba_data/data/languages/turkish.json": "https://files.ballistica.net/cache/ba1/a4/d9/93b754bae8c86791f6d8d3b600e1", "assets/build/ba_data/data/languages/ukrainian.json": "https://files.ballistica.net/cache/ba1/c3/61/d5bcf2bcad50104b26d22d3365a4", "assets/build/ba_data/data/languages/venetian.json": "https://files.ballistica.net/cache/ba1/4b/da/7e444f86c768aee70779a0f7a28f", @@ -3936,26 +3937,26 @@ "assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e", "assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/72/82/86956fae909ac2fe2a1abd84a361", "ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a", - "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/80/2d/f3018b6ba46d9278456e5e72c6da", + "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/11/56/91edee26ca9624941cfa5b800711", "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/74/1d/fc9e33e565475daaac80da5252f0", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b9/f7/d37785aeaa937eb9bfa56751bbb5", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c2/b0/20a9a462d1701f47ce6a8fc61709", - "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c4/a0/ed587e31756c462a5fd4638c5eea", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/61/be/99fd74e9a331ce2c3ad926ad77fc", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/78/e2/bce7116eebed3691a6ff58d4bc54", + "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/04/71/9325a193cfbe7da47a7c7f94ebe1", "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/7b/ac1a200be0f37078af0991faca3b", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/75/a9/164b2353457af90f482d896416a6", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/56/28/39af6142476ae8038d29e4429acf", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/cd/bd/5e04a66185f8ff83c0497ae1a303", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c3/2b/998d74da453f011b5493cbfcd8fe", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/50/51/2cce21971cbc6097e55be2c86fc6", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a6/0a/13a6e25b8568994f762bbce3fcd0", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ff/63/1617dfd7111b677405093003b155", - "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/af/dc/cd5951e9bdb49dbdbb1ef2e5ac1e", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/76/d2/7a0ce7df6b84cbc0cce6d2d99d82", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/34/74/8a9e2c2c66c6b59a7da226a8157d", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/41/0c/0d0e2377a6311cfea648afc32a70", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f1/4c/2edd29fca8144dcaa6b9d91eb480", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/1c/29/6a1592c4224fc7f5287113e86a87", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/27/2b/462de7463d2a6a5cb401352c6946", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3a/b9/0e46794d391cc9e9f3fac544ed49", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/a2/5da76344c31c4c8e943a56f8e5f8", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/53/e4/d1ac8975b8e0a541128f7a6c66ae", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/02/e2/65829a6d47ad9bfa5d41d08e1c97", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b2/0d/efb0ad546c078a38f8081b52e9c7", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/48/b2/f84775fd3a3062b0b57c522d8089", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/46/cc/0b0194a60c85d83312b5a56ec9d9", + "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b2/8b/5cf5de24316b6f58956f722db868", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/10/b6/c6ee48d8f08c5ed96f9ca178379b", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d2/e6/78abc63f12b3c39100f79633cb22", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/16/ac/87ba32912d227e31b0d8532109b2", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/56/45/c4e65995536cec438e0270b9b911", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/a7/f1/ec2b457b078b1b96dc056aae30c7", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/2a/5a/4eec69d53dfb3ef6c18c03d2f473", "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0e/ec/7864925a34d1ac2424c57cd86953", "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/80/90/bcdcade80c14a94051b50eb4d5e0", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b0/63/c8c7122ded855fcb1bb9260eae98", @@ -3972,14 +3973,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6f/a8/7384b203ae56c2504057748c7e86", "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/11/56/f3aeecacfa0acfbbb4032f98e75c", "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7b/1a/6dc287f1258a427068467e8d5238", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/26/97/9cc82b4426e737c4508a8c774a1c", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/ee/a1/cc9608fd17dfaf1e84673c0d60e3", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/3f/68/0b3cb367952f61918b2acbb66b37", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/93/74/c2031b257f962b8e099858cb8d19", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/12/ea/895877b2335975715730f71740a2", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/70/b6/e68e4f7303af5b1c115005ffa8c1", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/cc/22/f75baf7caf4cc0ecee48e1c5e23c", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/60/6f/b3d81d9ff6c06a971958f06e081c", - "src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/fc/b5/62133319c6df8567aecfd29b1204", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/07/60/5242b82fbcc8ffb69e93802b9b27", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/07/78/105d0bc438f8fb23f7cc02ba0b4c", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/c5/3f/ee71637551395c36f7d14bccb7c4", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/54/5a/ed52f47776a8be311cc532d986ea", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/90/d2/0944e4e3fe19a80fe006248ded8b", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/70/c8/a3a65b4e3027d4cd9710f9dcdd7a", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/0b/47/bfe080496d98dac040b3552edb2d", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/fe/37/c82d017d3b9442bf9148fffd0c5b", + "src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/6c/63/2b8cbb65a0e1daa45d59e9f87e9a", "src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/c0/2f/a8b50faad086fba4fe936e863c20" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 188c2973..0d05bfb2 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -701,6 +701,7 @@ etype eval'ed evalpydata + evals evel eventid ewww diff --git a/assets/.asset_manifest_private.json b/assets/.asset_manifest_private.json index b3e2dea5..f0f2231f 100644 --- a/assets/.asset_manifest_private.json +++ b/assets/.asset_manifest_private.json @@ -449,6 +449,7 @@ "ba_data/data/languages/slovak.json", "ba_data/data/languages/spanish.json", "ba_data/data/languages/swedish.json", + "ba_data/data/languages/thai.json", "ba_data/data/languages/turkish.json", "ba_data/data/languages/ukrainian.json", "ba_data/data/languages/venetian.json", diff --git a/assets/.asset_manifest_public.json b/assets/.asset_manifest_public.json index 8da644d2..e5d60eee 100644 --- a/assets/.asset_manifest_public.json +++ b/assets/.asset_manifest_public.json @@ -14,6 +14,7 @@ "ba_data/python/ba/__pycache__/_appmode.cpython-38.opt-1.pyc", "ba_data/python/ba/__pycache__/_apputils.cpython-38.opt-1.pyc", "ba_data/python/ba/__pycache__/_assetmanager.cpython-38.opt-1.pyc", + "ba_data/python/ba/__pycache__/_asyncio.cpython-38.opt-1.pyc", "ba_data/python/ba/__pycache__/_benchmark.cpython-38.opt-1.pyc", "ba_data/python/ba/__pycache__/_campaign.cpython-38.opt-1.pyc", "ba_data/python/ba/__pycache__/_collision.cpython-38.opt-1.pyc", @@ -75,6 +76,7 @@ "ba_data/python/ba/_appmode.py", "ba_data/python/ba/_apputils.py", "ba_data/python/ba/_assetmanager.py", + "ba_data/python/ba/_asyncio.py", "ba_data/python/ba/_benchmark.py", "ba_data/python/ba/_campaign.py", "ba_data/python/ba/_collision.py", diff --git a/assets/Makefile b/assets/Makefile index fc65156b..b269201c 100644 --- a/assets/Makefile +++ b/assets/Makefile @@ -145,6 +145,7 @@ SCRIPT_TARGETS_PY_PUBLIC = \ build/ba_data/python/ba/_appmode.py \ build/ba_data/python/ba/_apputils.py \ build/ba_data/python/ba/_assetmanager.py \ + build/ba_data/python/ba/_asyncio.py \ build/ba_data/python/ba/_benchmark.py \ build/ba_data/python/ba/_campaign.py \ build/ba_data/python/ba/_collision.py \ @@ -390,6 +391,7 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ build/ba_data/python/ba/__pycache__/_appmode.cpython-38.opt-1.pyc \ build/ba_data/python/ba/__pycache__/_apputils.cpython-38.opt-1.pyc \ build/ba_data/python/ba/__pycache__/_assetmanager.cpython-38.opt-1.pyc \ + build/ba_data/python/ba/__pycache__/_asyncio.cpython-38.opt-1.pyc \ build/ba_data/python/ba/__pycache__/_benchmark.cpython-38.opt-1.pyc \ build/ba_data/python/ba/__pycache__/_campaign.cpython-38.opt-1.pyc \ build/ba_data/python/ba/__pycache__/_collision.cpython-38.opt-1.pyc \ @@ -4757,6 +4759,7 @@ DATA_TARGETS = \ build/ba_data/data/languages/slovak.json \ build/ba_data/data/languages/spanish.json \ build/ba_data/data/languages/swedish.json \ + build/ba_data/data/languages/thai.json \ build/ba_data/data/languages/turkish.json \ build/ba_data/data/languages/ukrainian.json \ build/ba_data/data/languages/venetian.json \ diff --git a/assets/src/ba_data/python/ba/_app.py b/assets/src/ba_data/python/ba/_app.py index ed034150..7e5c2e61 100644 --- a/assets/src/ba_data/python/ba/_app.py +++ b/assets/src/ba_data/python/ba/_app.py @@ -5,7 +5,6 @@ from __future__ import annotations from enum import Enum import random -import asyncio from typing import TYPE_CHECKING import _ba @@ -294,8 +293,6 @@ class App: from bastd.actor import spazappearance from ba._generated.enums import TimeType - self._setup_asyncio() - cfg = self.config self.delegate = appdelegate.AppDelegate() @@ -590,37 +587,3 @@ class App: print('HTTPS TEST SUCCESS', len(val)) except Exception as exc: print('HTTPS TEST FAIL:', exc) - - def _setup_asyncio(self) -> None: - # from ba._generated.enums import TimeType - - if bool(True): - return - - try: - asyncio.get_running_loop() - print('Found running asyncio loop; unexpected.') - except RuntimeError: - pass - loop = asyncio.new_event_loop() - print('MADE', loop) - asyncio.set_event_loop(loop) - print('NOW LOOP IS', loop) - print('policy is', asyncio.get_event_loop_policy()) - print('RUNNING IS NOW', asyncio.get_running_loop()) - - # def run_cycle() -> None: - # loop.call_soon(loop.stop) - # loop.run_forever() - - # self._asyncio_timer = _ba.Timer(1.0 / 5.0, - # run_cycle, - # timetype=TimeType.REAL, - # repeat=True) - async def _atest() -> None: - print('TASK STARTING') - await asyncio.sleep(2.0) - print('TASK ENDING') - - asyncio.run(_atest()) - #asyncio.create_task(_atest()) diff --git a/assets/src/ba_data/python/ba/_asyncio.py b/assets/src/ba_data/python/ba/_asyncio.py new file mode 100644 index 00000000..76206e6f --- /dev/null +++ b/assets/src/ba_data/python/ba/_asyncio.py @@ -0,0 +1,71 @@ +# Released under the MIT License. See LICENSE for details. +# +"""Asyncio related functionality. + +Exploring the idea of allowing Python coroutines to run gracefully +besides our internal event loop. They could prove useful for networking +operations or possibly game logic. +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING +import asyncio + +if TYPE_CHECKING: + from typing import Optional + import ba + +# Our timer and event loop for the ballistica game thread. +_asyncio_timer: Optional[ba.Timer] = None +_asyncio_event_loop: Optional[asyncio.AbstractEventLoop] = None + + +def setup_asyncio() -> None: + """Setup asyncio functionality for our game thread.""" + # pylint: disable=global-statement + + import _ba + from ba._generated.enums import TimeType + + assert _ba.in_game_thread() + + # Create our event-loop. We don't expect there to be one + # running on this thread before we do. + try: + asyncio.get_running_loop() + print('Found running asyncio loop; unexpected.') + except RuntimeError: + pass + + global _asyncio_event_loop # pylint: disable=invalid-name + _asyncio_event_loop = asyncio.new_event_loop() + + # Ideally we should integrate asyncio into our C++ Thread class's + # low level event loop so that asyncio timers/sockets/etc. could + # be true first-class citizens. For now, though, we can explicitly + # pump an asyncio loop periodically which gets us a decent + # approximation of that, which should be good enough for + # all but extremely time sensitive uses. + # See https://stackoverflow.com/questions/29782377/ + # is-it-possible-to-run-only-a-single-step-of-the-asyncio-event-loop + def run_cycle() -> None: + assert _asyncio_event_loop is not None + _asyncio_event_loop.call_soon(_asyncio_event_loop.stop) + _asyncio_event_loop.run_forever() + + global _asyncio_timer # pylint: disable=invalid-name + _asyncio_timer = _ba.Timer(1.0 / 30.0, + run_cycle, + timetype=TimeType.REAL, + repeat=True) + + async def aio_test() -> None: + print('TEST AIO TASK STARTING') + assert _asyncio_event_loop is not None + assert asyncio.get_running_loop() is _asyncio_event_loop + await asyncio.sleep(2.0) + print('TEST AIO TASK ENDING') + + if bool(False): + _asyncio_event_loop.create_task(aio_test()) diff --git a/assets/src/ba_data/python/ba/_hooks.py b/assets/src/ba_data/python/ba/_hooks.py index 169a648f..44afb7c9 100644 --- a/assets/src/ba_data/python/ba/_hooks.py +++ b/assets/src/ba_data/python/ba/_hooks.py @@ -22,6 +22,19 @@ if TYPE_CHECKING: import ba +def finish_bootstrapping() -> None: + """Do final bootstrapping related bits.""" + from ba._asyncio import setup_asyncio + assert _ba.in_game_thread() + + # Kick off our asyncio event handling, allowing us to use coroutines + # in our game thread alongside our internal event handling. + setup_asyncio() + + # Ok, bootstrapping is done; time to get the show started. + _ba.app.on_app_launch() + + def reset_to_main_menu() -> None: """Reset the game to the main menu gracefully.""" _ba.app.return_to_main_menu_session_gracefully() diff --git a/assets/src/ba_data/python/ba/_language.py b/assets/src/ba_data/python/ba/_language.py index 75487688..51ac7cbd 100644 --- a/assets/src/ba_data/python/ba/_language.py +++ b/assets/src/ba_data/python/ba/_language.py @@ -37,7 +37,7 @@ class LanguageSubsystem: # We don't yet support full unicode display on windows or linux :-(. if (language in { 'Chinese', 'ChineseTraditional', 'Persian', 'Korean', 'Arabic', - 'Hindi', 'Vietnamese' + 'Hindi', 'Vietnamese', 'Thai' } and not _ba.can_display_full_unicode()): return False return True @@ -79,6 +79,7 @@ class LanguageSubsystem: 'ar': 'Arabic', 'zh': 'Chinese', 'tr': 'Turkish', + 'th': 'Thai', 'id': 'Indonesian', 'sr': 'Serbian', 'uk': 'Ukrainian', diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index a1adbc75..6d97a0db 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -21,7 +21,7 @@ namespace ballistica { // These are set automatically via script; don't modify them here. -const int kAppBuildNumber = 20392; +const int kAppBuildNumber = 20393; const char* kAppVersion = "1.6.5"; // Our standalone globals. diff --git a/src/ballistica/game/game.cc b/src/ballistica/game/game.cc index 72d57abe..6bf8cefa 100644 --- a/src/ballistica/game/game.cc +++ b/src/ballistica/game/game.cc @@ -315,7 +315,7 @@ void Game::RunAppLaunchCommands() { { // Run this in the UI context. ScopedSetContext cp(GetUIContext()); - g_python->obj(Python::ObjID::kOnAppLaunchCall).Call(); + g_python->obj(Python::ObjID::kFinishBootstrappingCall).Call(); } ran_app_launch_commands_ = true; diff --git a/src/ballistica/python/python.cc b/src/ballistica/python/python.cc index 0a38c00e..5ed6f336 100644 --- a/src/ballistica/python/python.cc +++ b/src/ballistica/python/python.cc @@ -939,12 +939,12 @@ void Python::Reset(bool do_init) { // Inits our _ba module and runs Py_Initialize(). AppInternalPyInitialize(&config); + // Grab __main__ in case we need to use it later. PyObject* m; BA_PRECONDITION(m = PyImport_AddModule("__main__")); BA_PRECONDITION(main_dict_ = PyModule_GetDict(m)); const char* ver = Py_GetVersion(); - if (strncmp(ver, "3.8", 3) != 0) { throw Exception("We require Python 3.8.x; instead found " + std::string(ver)); diff --git a/src/ballistica/python/python.h b/src/ballistica/python/python.h index 876f05f4..fd551202 100644 --- a/src/ballistica/python/python.h +++ b/src/ballistica/python/python.h @@ -280,7 +280,7 @@ class Python { kCallClass, kGarbageCollectSessionEndCall, kConfig, - kOnAppLaunchCall, + kFinishBootstrappingCall, kClientInfoQueryResponseCall, kResetToMainMenuCall, kSetConfigFullscreenOnCall, diff --git a/src/meta/bameta/python_embedded/binding.py b/src/meta/bameta/python_embedded/binding.py index 71b2439c..5e113e5e 100644 --- a/src/meta/bameta/python_embedded/binding.py +++ b/src/meta/bameta/python_embedded/binding.py @@ -97,7 +97,7 @@ def get_binding_values() -> Tuple[Any, ...]: ba.OutOfBoundsMessage, # kOutOfBoundsMessageClass ba.PickUpMessage, # kPickUpMessageClass ba.DropMessage, # kDropMessageClass - ba.app.on_app_launch, # kOnAppLaunchCall + _hooks.finish_bootstrapping, # kFinishBootstrappingCall _input.get_device_value, # kGetDeviceValueCall _input.get_last_player_name_from_input_device, # kGetLastPlayerNameFromInputDeviceCall copy.deepcopy, # kDeepCopyCall diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index 87dc1d98..47eb4bb7 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -201,7 +201,9 @@ def get_master_asset_src_dir() -> None: # Also compare repo name to split version of itself to # see if we're outside of core (filtering will cause mismatch if so). + # pylint: disable=useless-suppression # pylint: disable=simplifiable-condition + # pylint: disable=condition-evals-to-constant if ('origin/master' in output.splitlines()[0] and 'ballistica' + 'core' == 'ballisticacore'):