From 74c9f675827b3a4dd9489fa14d2c5d28cc43621c Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 29 Nov 2022 11:50:18 -0800 Subject: [PATCH] more work on v2 and google play --- .efrocachemap | 138 ++++----- .idea/dictionaries/ericf.xml | 7 + CHANGELOG.md | 9 +- assets/src/ba_data/python/._ba_sources_hash | 2 +- assets/src/ba_data/python/_ba.py | 50 ++-- assets/src/ba_data/python/_bainternal.py | 1 - assets/src/ba_data/python/ba/__init__.py | 6 +- assets/src/ba_data/python/ba/_accountv1.py | 3 + assets/src/ba_data/python/ba/_accountv2.py | 167 ++++++++++- assets/src/ba_data/python/ba/_app.py | 30 +- assets/src/ba_data/python/ba/_apputils.py | 51 +++- assets/src/ba_data/python/ba/_bootstrap.py | 5 +- assets/src/ba_data/python/ba/_cloud.py | 6 + assets/src/ba_data/python/ba/_coopgame.py | 52 +--- assets/src/ba_data/python/ba/_hooks.py | 4 +- assets/src/ba_data/python/ba/_internal.py | 2 - assets/src/ba_data/python/ba/_login.py | 20 +- assets/src/ba_data/python/ba/internal.py | 4 + .../python/bastd/activity/coopscore.py | 271 +++++++----------- .../src/ba_data/python/bastd/game/football.py | 3 - .../ba_data/python/bastd/game/onslaught.py | 3 - .../ba_data/python/bastd/game/runaround.py | 3 - .../ba_data/python/bastd/game/thelaststand.py | 3 - .../python/bastd/ui/account/settings.py | 197 ++++++++----- .../ba_data/python/bastd/ui/configerror.py | 6 +- .../.idea/dictionaries/ericf.xml | 7 + src/ballistica/app/app_flavor.cc | 49 +++- src/ballistica/app/app_flavor.h | 16 +- src/ballistica/ballistica.cc | 2 +- src/ballistica/core/object.cc | 6 +- src/ballistica/core/object.h | 4 +- src/ballistica/core/thread.cc | 45 ++- src/ballistica/core/thread.h | 7 +- src/ballistica/graphics/gl/gl_sys.h | 2 +- src/ballistica/input/input.cc | 44 +++ src/ballistica/input/input.h | 2 +- .../platform/apple/platform_apple.h | 2 - src/ballistica/platform/platform.cc | 12 +- src/ballistica/platform/platform.h | 7 +- .../python/methods/python_methods_app.cc | 38 ++- .../python/methods/python_methods_system.cc | 54 +++- tools/bacommon/login.py | 10 + tools/batools/project.py | 6 +- tools/efro/error.py | 9 + tools/efro/message/_message.py | 14 + tools/efro/message/_sender.py | 59 ++-- tools/efrotools/pcommand.py | 7 + 47 files changed, 925 insertions(+), 520 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 769e3cdf..4fb93651 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -420,41 +420,41 @@ "assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/60/ad/38269b7f1c7dc20cb9a506cd0681", "assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/72/85/d6fc4d16b7081d91fba2850b5b10", "assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/e9/ae/1d674d0c086eaa0bd1c3b1db0505", - "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/89/ec/d472036fbb09f310891761beb39a", + "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/b1/c3/2d8b079670d84bde0558f6454f1f", "assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/b0/05/e530acaba539f040ce61e22561dc", "assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/61/03/89070ca765e06da3a419a579f503", - "assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/1f/7f/af259ba9b41556e5e667ad4c646d", - "assets/build/ba_data/data/languages/chinesetraditional.json": "https://files.ballistica.net/cache/ba1/3c/22/78a56fc40426ab19ad4e76924b78", + "assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/05/87/d3e03edbc59eb7e7da7ef8b17134", + "assets/build/ba_data/data/languages/chinesetraditional.json": "https://files.ballistica.net/cache/ba1/12/12/b39bec3a244399223b45f084e0b2", "assets/build/ba_data/data/languages/croatian.json": "https://files.ballistica.net/cache/ba1/c9/73/01a1343af814131b1ee96af0b687", - "assets/build/ba_data/data/languages/czech.json": "https://files.ballistica.net/cache/ba1/61/20/01291c2cb72b22f204730c0d7574", + "assets/build/ba_data/data/languages/czech.json": "https://files.ballistica.net/cache/ba1/cb/df/f2d54d3146a159c678a47d3ff01b", "assets/build/ba_data/data/languages/danish.json": "https://files.ballistica.net/cache/ba1/6a/fa/fcf4a804beaff927b0f12c179eaa", "assets/build/ba_data/data/languages/dutch.json": "https://files.ballistica.net/cache/ba1/68/93/da8e9874f41a786edf52ba4ccaad", - "assets/build/ba_data/data/languages/english.json": "https://files.ballistica.net/cache/ba1/a0/1d/5fbc922d01521142c2a347b1b024", - "assets/build/ba_data/data/languages/esperanto.json": "https://files.ballistica.net/cache/ba1/4c/c7/0184b8178869d1a3827a1bfcd5bb", - "assets/build/ba_data/data/languages/filipino.json": "https://files.ballistica.net/cache/ba1/c7/2e/e0520f58206da01b829e02ff4576", - "assets/build/ba_data/data/languages/french.json": "https://files.ballistica.net/cache/ba1/e8/84/6c9f123e9a0d82fc595c8f55ac7c", - "assets/build/ba_data/data/languages/german.json": "https://files.ballistica.net/cache/ba1/8a/09/3e0fa9e44913b53f4dab195d3fae", - "assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/5f/51/c15d74d2fe4e88ee1e3db0986500", - "assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/aa/da/dfc8d710af960d7300c7090faeab", - "assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/09/55/b50104638f60636af2263877bb7f", - "assets/build/ba_data/data/languages/hungarian.json": "https://files.ballistica.net/cache/ba1/d8/f2/aa16bc336bd7660cc86c3264bfc4", - "assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/3a/6b/34714586cb4e9f1b12f8ae54cac8", - "assets/build/ba_data/data/languages/italian.json": "https://files.ballistica.net/cache/ba1/12/62/862228b229057877e89fb195d41d", + "assets/build/ba_data/data/languages/english.json": "https://files.ballistica.net/cache/ba1/74/1d/04985b013519340632a0f5eb6d81", + "assets/build/ba_data/data/languages/esperanto.json": "https://files.ballistica.net/cache/ba1/ac/f5/c0922a99e40dfc9f5e026d43b533", + "assets/build/ba_data/data/languages/filipino.json": "https://files.ballistica.net/cache/ba1/86/26/060476f46994c035ae0d52640657", + "assets/build/ba_data/data/languages/french.json": "https://files.ballistica.net/cache/ba1/c7/cf/35a6ebc876c7476b72547a914d07", + "assets/build/ba_data/data/languages/german.json": "https://files.ballistica.net/cache/ba1/06/58/071d6f7bbb5e93a3e074dbd323ae", + "assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/a3/f7/b12c68a8c1ecabbf7b8c41452986", + "assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/ae/89/47486b987d14f58b6cf2d665ce4b", + "assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/9f/df/469e166c6a0d42bca4baae3a6cb6", + "assets/build/ba_data/data/languages/hungarian.json": "https://files.ballistica.net/cache/ba1/b2/81/53c8cd7617d649403e539c3a6171", + "assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/26/57/b9443fccbc90602a5ace74935365", + "assets/build/ba_data/data/languages/italian.json": "https://files.ballistica.net/cache/ba1/5f/b2/b9301d67bef699a092a4c04dd522", "assets/build/ba_data/data/languages/korean.json": "https://files.ballistica.net/cache/ba1/7c/38/d4a44c481757d355836f292ede48", - "assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/10/13/1228836444f7557211f0058ef9bd", - "assets/build/ba_data/data/languages/polish.json": "https://files.ballistica.net/cache/ba1/19/e9/59c891b1fb85f3ba9f19283c233d", - "assets/build/ba_data/data/languages/portuguese.json": "https://files.ballistica.net/cache/ba1/61/5b/847c03407d1c3a85866833323676", + "assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/cd/ed/4d6d0778d256ccc0ff2e27b970c6", + "assets/build/ba_data/data/languages/polish.json": "https://files.ballistica.net/cache/ba1/67/93/372c2a2428a830056e9ba22bbf95", + "assets/build/ba_data/data/languages/portuguese.json": "https://files.ballistica.net/cache/ba1/01/6f/516598d76c29b2fa45ff351426dc", "assets/build/ba_data/data/languages/romanian.json": "https://files.ballistica.net/cache/ba1/d7/06/9d70642d0a4d1e3b1c2149d7a17c", - "assets/build/ba_data/data/languages/russian.json": "https://files.ballistica.net/cache/ba1/34/ed/b97350983272e4b23bf140d7a5f4", + "assets/build/ba_data/data/languages/russian.json": "https://files.ballistica.net/cache/ba1/05/fb/a05a110238d0da5f902d06e5daa7", "assets/build/ba_data/data/languages/serbian.json": "https://files.ballistica.net/cache/ba1/4e/91/6f2a9a3ce733908e91377a6ddb9a", - "assets/build/ba_data/data/languages/slovak.json": "https://files.ballistica.net/cache/ba1/f9/4b/d9f01814224066856695452ef57c", - "assets/build/ba_data/data/languages/spanish.json": "https://files.ballistica.net/cache/ba1/ce/be/2f06c3436871fd464ff3a62597d9", + "assets/build/ba_data/data/languages/slovak.json": "https://files.ballistica.net/cache/ba1/20/a9/163d189884edf802636bf291e432", + "assets/build/ba_data/data/languages/spanish.json": "https://files.ballistica.net/cache/ba1/c9/48/63093604be4e04447974b9e6337d", "assets/build/ba_data/data/languages/swedish.json": "https://files.ballistica.net/cache/ba1/91/0a/35c4baf539d5951fc03a794c0e0b", - "assets/build/ba_data/data/languages/tamil.json": "https://files.ballistica.net/cache/ba1/64/22/7bc899ecbec52cf978a1faf1c127", + "assets/build/ba_data/data/languages/tamil.json": "https://files.ballistica.net/cache/ba1/2b/25/aa93983666b88d1c584f06b742b0", "assets/build/ba_data/data/languages/thai.json": "https://files.ballistica.net/cache/ba1/f7/df/7ba5f99c5c2c4c86fc0503fcf0b7", - "assets/build/ba_data/data/languages/turkish.json": "https://files.ballistica.net/cache/ba1/ee/08/1f77c7c320d8d8504a11ee495db3", - "assets/build/ba_data/data/languages/ukrainian.json": "https://files.ballistica.net/cache/ba1/f3/92/fd7ee5fa8a92fcc8fd2219a88a2f", - "assets/build/ba_data/data/languages/venetian.json": "https://files.ballistica.net/cache/ba1/2e/86/10d3e39d35014d039cc9ea886ca7", + "assets/build/ba_data/data/languages/turkish.json": "https://files.ballistica.net/cache/ba1/bb/f5/0eb74375f3c9ea827b73c67f4a25", + "assets/build/ba_data/data/languages/ukrainian.json": "https://files.ballistica.net/cache/ba1/1b/83/844f9e6f4e9e47a2d788d3faa9d2", + "assets/build/ba_data/data/languages/venetian.json": "https://files.ballistica.net/cache/ba1/17/15/973f4101bf2264173bd1c1729426", "assets/build/ba_data/data/languages/vietnamese.json": "https://files.ballistica.net/cache/ba1/1f/ae/abe3f105b3c4b51f6b7942773305", "assets/build/ba_data/data/maps/big_g.json": "https://files.ballistica.net/cache/ba1/47/0a/a617cc85d927b576c4e6fc1091ed", "assets/build/ba_data/data/maps/bridgit.json": "https://files.ballistica.net/cache/ba1/03/4b/57ee9b42854b26f23f81bd8c58ef", @@ -4003,50 +4003,50 @@ "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/1c/77/ac670a5118abdf8a7687af0e159b", "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/bd/82/98ea775b22a1113323a1ddf12b6a", - "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/e1/0d/0a431edcdee394a4e4d5b18608d7", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e8/94/162a944636170ac881d3f3dfd805", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f8/96/fea047474c276064176b65f7e48a", - "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/12/eb/226aba01e295a807614c64c44d40", - "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/23/71/f60c8e90699d887979c4ad26a2e2", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8d/80/05e3d712c67d0fcde0e8605d0be7", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7f/05/498a538fd28fcd1de964c046b8f2", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d1/6e/01e46632d17db0597d1aef3394d1", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/aa/12/7992a25feae2b0bf2c8fe2023187", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/99/a9/2b251e46b2e9e4ef143a0308d9f3", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6a/93/faee77acd35111d083998df65aaa", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/25/c1/9b6efb09c364beae30a40510bfcf", - "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/18/76/3f8e144f6727ee8f5f5f4b0b6ddc", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3c/e8/02284ba36b4de9ca68cdd7c3e689", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/15/cf/c02041bdc6fa5d0042408e591dcf", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/62/98/ee64d80a6332d7d9fc57a2605a2d", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/54/e6/c4c75d29a7c19c34ba5876c4c350", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/69/3c/96b8690702f596182a305b5b4489", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/b4/b4/81668b3afad33372276a46545aae", - "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c3/1a/ae199ada4bf5a649f73fe1663868", - "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a2/4f/2cf4047fdbac4a661ca99d4aedb8", - "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/06/f5/b0fdcf55008fc53e1660f7bc841f", - "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2c/af/159cc0021a3751da19f4d6832602", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cc/4d/0586cbf47105ba1224a445cd72f4", - "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f8/33/ae7f84447a19e465c134355b359e", - "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/40/eb/004a4ea3094210114fd739cb9fcb", - "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/45/ed/36918bf061396d6e1f9814afce8c", - "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8f/28/7c06af16187bf2db92cf99763f4e", - "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/44/69/aeba19cb88e6b57c4ab9325f5877", - "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/69/4e/b8354e50de6f2afb45b342919868", - "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/70/65/f35430e7328bc7ac30de3960dfc7", - "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d8/47/c89b62ea5a71854b303f9e85e5d7", - "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f2/19/280f6773b3563e012ad6bfad33dc", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1e/17/e5ef6ce0e41360a43c63ef9c0974", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cd/78/1adf82e5c3e456d2ea2d4290c61c", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/6b/5f/c5dc0b2a2809bc1d3ea57fb985d0", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/56/ee/49a4a2d7940fd239a66c04657c90", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/39/72/fb9b3400c5d128ad156818ede03d", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/22/65/550d27a960822b8846c0c0a440be", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/33/3b/9b38515580edd4616f9955f7e33c", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/fe/1a/80ddcd73df9985ab768e617a6c2b", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/1d/27/0d69901bb721f986fdbfc490100f", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/e9/59/ab5278ceeae3656f91c6d3c68c83", + "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0f/f4/4a4f1087d2bb778d9be504442270", + "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/0e/10/5c509346d44b89ddd12aec7ec7de", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cd/9f/a6f5274ff94f95e902cca445a510", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/04/2a/263e10497930fa6159e5352b7370", + "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/59/62/28c8370b93d43d1c13acfbddee57", + "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/d8/4e/ad0d3316f74e82ffde5c7b976fc2", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/4a/41/08aa8c9e197e7cc75b6e8d97dc55", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/81/6b/e7bc7863fc9c6b6a241d93f7d4e3", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ec/44/094cd342e6a8eb2f1671f680a5e8", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/fc/f9/b44862de39500fc85a3b3960a132", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/78/7d/c4f86fc89838006fa2bacf4fa9a8", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d7/40/0d31b629247be2c16ee042ee9165", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/1f/39/781ca02803724b5a84a197d3d264", + "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/39/f9/a085edd64d394ce0f4fee7f857e9", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fe/60/82caae9fc89ce89688ea5013e5c9", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9c/e9/3fb7c6b71287d2b3c3ab5f11f6c3", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/c4/df/b58bf2cf14619d257ca145242cdd", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b5/f9/d5ee77a243aee14ad0cd0f5e53e5", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/b8/bc/71febcf1ffd431bd80936d313b73", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/5d/ff/c36c1a0d0713aca6aa0f640de48b", + "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2f/98/0f10aa690341351b047d9dc3fe65", + "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/14/aa/d9e350323ed97ca2c87667c569bb", + "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/64/a9/03eb8d0e32bf35b10941eb8ca082", + "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/52/2a/31fb94be0f4f5e9ded5a100e298d", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a0/dc/5479a3f5499236fd0b72cbec5c9b", + "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/41/6b/175b26bc4b4429aac713d4cc3c20", + "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e0/5c/5a5c6cbd883cba37f31d991722fe", + "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/81/bb/51740409b1cf442d8beed60f759c", + "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a2/7d/c630ea8a7975c3502cbd3ee6716f", + "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/44/66/a2d065477f9677a2b869c5ebc0a9", + "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8d/5e/335032c7fc26a8026db29b0bb1f0", + "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/26/94/73a12ae50fe3750547ce218f3857", + "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9a/77/a3607ad916ab9d0327cdd61800c5", + "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9d/ac/b2dd3b8a8b231210f19b0ec30299", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a6/cd/4b2cb9cbb7a617e408006f2eba7e", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9e/f7/cadeae6e408cabe57d9e1cf782d6", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/0a/c3/b0d1aa43e3e66de3c213b7fda5f1", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/3f/39/fb44f0b1907cc8a9def711f90488", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/56/d5/e469a881eacc313ac6ca5e48c450", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/81/f9/ffcebd4dc6f76392516644b04978", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/75/e2/2e4066c5bc8e429723169e8d0ca2", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/9c/b9/1702985e444ba529f8adcb933039", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/76/ab/cb3cfe64a3a8b976fc15166a7878", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/81/c4/b3845fc3fabd2bd3d997685e63f7", "src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/25/77/8093dfffddaa80cd513ddaa61867", "src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/2d/4f/f4fe67827f36cd59cd5193333a02", "src/ballistica/generated/python_embedded/bootstrap_monolithic.inc": "https://files.ballistica.net/cache/ba1/ef/c1/aa5f1aa10af89f5c0b1e616355fd" diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 89615536..32534d60 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -73,6 +73,7 @@ allsettings allteams allwarnings + alogins aman amazonaws aname @@ -374,6 +375,7 @@ certifi cfconfig cfenv + cfgdict cfgdir cfgkey cfgkeys @@ -2513,6 +2515,7 @@ svne svvv swht + swidth swiftc swip swipsound @@ -2549,6 +2552,9 @@ targs tasklabel tbegin + tbfile + tbfiles + tbpath tbtcolor tbtn tbttxt @@ -2860,6 +2866,7 @@ webpages weeeird whatevs + whatisv wheee whos widgetdeathtime diff --git a/CHANGELOG.md b/CHANGELOG.md index 42606cb3..ab19ed4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ -### 1.7.14 (build 20934, api 7, 2022-11-16) +### 1.7.14 (build 20942, api 7, 2022-11-29) - Android Google Play logins now provide V2 accounts with access to all V2 features such as a globally-unique account tag, cloud-console, and workspaces. They should still retain their V1 data as well. - V2 accounts now have a 'Manage Account' button in the app account window which will sign you into a browser with your current account. - Removed Google App Invite functionality which has been deprecated for a while now. Google Play users can still get tickets by sharing the app via codes (same as other platforms). - Updated Android root-detection library to the latest version. Please holler if you are getting new false 'your device is rooted' errors when trying to play tournaments or anything like that. - Removed a few obsolete internal functions: `_ba.is_ouya_build()`, `_ba.android_media_scan_file()`. - Renaming some methods/data to disambiguate 'login' vs 'sign-in', both in the app and on ballistica.net. Those two terms are somewhat ambiguous and interchangeable in English and can either be a verb or a noun. I'd like to keep things clear in Ballistica by always using 'sign-in' for the verb form and 'login' for the noun. For example: 'You can now sign in to your account using your Google Play login'. -- WARNING: There are currently some rough edges with Google Play V2 accounts; for example Google Play achievements and leaderboards UIs are not currently showing up. I will be cleaning all of this up before the official 1.7.14 release. +- Fixed the 'your config is broken' dialog that shows on desktop builds if the game's config file is corrupt and can't be read. It should let you edit the config or replace it with a default. +- `ba.printobjects()` is now `ba.ls_objects()`. It technically logs and doesn't print so the former name was a bit misleading. +- Added `ba.ls_input_devices()` to dump debug info about the current set of input devices. Can be helpful to diagnose mysterious devices joining games unintentionally and things like that. +- Added 'raw' bool arg to `ba.pushcall()`. Passing True for it disables context save/restore and thread checks. +- Added `ba.internal.dump_tracebacks()` which can be used to dump the stack state of all Python threads after some delay. Useful for debugging deadlock; just call right before said deadlock occurs. Results will be logged on the next app launch if they cannot be immediately. +- Fixed a low level event-loop issue that in some cases was preventing the Android version from properly pausing/resuming the app or managing connections while in the background. If you look at the devices section on ballistica.net you should now see your device disappear when you background the app and reappear when you foreground it. Please holler if not. ### 1.7.13 (build 20919, api 7, 2022-11-03) - Android target-sdk has been updated to 33 (Android 13). Please holler if anything seems broken or is behaving differently than before on Android. diff --git a/assets/src/ba_data/python/._ba_sources_hash b/assets/src/ba_data/python/._ba_sources_hash index bb72bb71..3c92f5a5 100644 --- a/assets/src/ba_data/python/._ba_sources_hash +++ b/assets/src/ba_data/python/._ba_sources_hash @@ -1 +1 @@ -136821726394202151644063370854718971574 \ No newline at end of file +199621046220623727886241861967391185247 \ No newline at end of file diff --git a/assets/src/ba_data/python/_ba.py b/assets/src/ba_data/python/_ba.py index 671c8d6d..f4a79295 100644 --- a/assets/src/ba_data/python/_ba.py +++ b/assets/src/ba_data/python/_ba.py @@ -2429,12 +2429,42 @@ def lock_all_input() -> None: return None +def login_adapter_back_end_active_change(login_type: str, active: bool) -> None: + + """(internal)""" + return None + + def login_adapter_get_sign_in_token(login_type: str, attempt_id: int) -> None: """(internal)""" return None +def ls_input_devices() -> None: + + """Print debugging info about game objects. + + Category: **General Utility Functions** + + This call only functions in debug builds of the game. + It prints various info about the current object count, etc. + """ + return None + + +def ls_objects() -> None: + + """Log debugging info about C++ level objects. + + Category: **General Utility Functions** + + This call only functions in debug builds of the game. + It prints various info about the current object count, etc. + """ + return None + + def mac_music_app_get_library_source() -> None: """(internal)""" @@ -2653,32 +2683,17 @@ def printnodes() -> None: return None -def printobjects() -> None: - - """Print debugging info about game objects. - - Category: **General Utility Functions** - - This call only functions in debug builds of the game. - It prints various info about the current object count, etc. - """ - return None - - def pushcall( call: Callable, from_other_thread: bool = False, suppress_other_thread_warning: bool = False, other_thread_use_fg_context: bool = False, + raw: bool = False, ) -> None: - """Pushes a call onto the event loop to be run during the next cycle. - + """Push a call to the logic event-loop. Category: **General Utility Functions** - This can be handy for calls that are disallowed from within other - callbacks, etc. - This call expects to be used in the logic thread, and will automatically save and restore the ba.Context to behave seamlessly. @@ -2687,6 +2702,7 @@ def pushcall( the call will always run in the UI context on the logic thread or whichever context is in the foreground if other_thread_use_fg_context is True. + Passing raw=True will disable thread checks and context sets/restores. """ return None diff --git a/assets/src/ba_data/python/_bainternal.py b/assets/src/ba_data/python/_bainternal.py index d1bf8109..99fd8ee4 100644 --- a/assets/src/ba_data/python/_bainternal.py +++ b/assets/src/ba_data/python/_bainternal.py @@ -252,7 +252,6 @@ def submit_score( name: Any, score: int | None, callback: Callable, - friend_callback: Callable | None, order: str = 'increasing', tournament_id: str | None = None, score_type: str = 'points', diff --git a/assets/src/ba_data/python/ba/__init__.py b/assets/src/ba_data/python/ba/__init__.py index 290d8482..82738c9e 100644 --- a/assets/src/ba_data/python/ba/__init__.py +++ b/assets/src/ba_data/python/ba/__init__.py @@ -43,7 +43,8 @@ from _ba import ( newnode, playsound, printnodes, - printobjects, + ls_objects, + ls_input_devices, pushcall, quit, rowwidget, @@ -316,7 +317,8 @@ __all__ = [ 'print_error', 'print_exception', 'printnodes', - 'printobjects', + 'ls_objects', + 'ls_input_devices', 'pushcall', 'quit', 'rowwidget', diff --git a/assets/src/ba_data/python/ba/_accountv1.py b/assets/src/ba_data/python/ba/_accountv1.py index c2b81164..7f946097 100644 --- a/assets/src/ba_data/python/ba/_accountv1.py +++ b/assets/src/ba_data/python/ba/_accountv1.py @@ -48,6 +48,9 @@ class AccountV1Subsystem: _ba.pushcall(do_auto_sign_in) + def on_app_pause(self) -> None: + """Should be called when app is pausing.""" + def on_app_resume(self) -> None: """Should be called when the app is resumed.""" diff --git a/assets/src/ba_data/python/ba/_accountv2.py b/assets/src/ba_data/python/ba/_accountv2.py index 32870fe0..372f9dad 100644 --- a/assets/src/ba_data/python/ba/_accountv2.py +++ b/assets/src/ba_data/python/ba/_accountv2.py @@ -4,8 +4,11 @@ from __future__ import annotations +import hashlib +import logging from typing import TYPE_CHECKING +from efro.call import tpartial import _ba if TYPE_CHECKING: @@ -15,6 +18,9 @@ if TYPE_CHECKING: from ba._login import LoginAdapter +DEBUG_LOG = False + + class AccountV2Subsystem: """Subsystem for modern account handling in the app. @@ -37,7 +43,8 @@ class AccountV2Subsystem: self.login_adapters: dict[LoginType, LoginAdapter] = {} self._implicit_signed_in_adapter: LoginAdapter | None = None - self._auto_signed_in = False + self._implicit_state_changed = False + self._can_do_auto_sign_in = True if _ba.app.platform == 'android' and _ba.app.subplatform == 'google': from ba._login import LoginAdapterGPGS @@ -127,7 +134,7 @@ class AccountV2Subsystem: def on_implicit_sign_in( self, login_type: LoginType, login_id: str, display_name: str ) -> None: - """An implicit login happened.""" + """An implicit sign-in happened (called by native layer).""" from ba._login import LoginAdapter with _ba.Context('ui'): @@ -138,7 +145,7 @@ class AccountV2Subsystem: ) def on_implicit_sign_out(self, login_type: LoginType) -> None: - """An implicit logout happened.""" + """An implicit sign-out happened (called by native layer).""" with _ba.Context('ui'): self.login_adapters[login_type].set_implicit_login_state(None) @@ -153,6 +160,12 @@ class AccountV2Subsystem: self._initial_login_completed = True _ba.app.on_initial_login_completed() + @staticmethod + def _hashstr(val: str) -> str: + md5 = hashlib.md5() + md5.update(val.encode()) + return md5.hexdigest() + def on_implicit_login_state_changed( self, login_type: LoginType, @@ -160,18 +173,66 @@ class AccountV2Subsystem: ) -> None: """Called when implicit login state changes. - Logins that tend to sign themselves in/out in the background are - considered implicit. We may choose to honor or ignore their states, - allowing the user to opt for other login types even if the default - implicit one can't be explicitly logged out or otherwise controlled. + Login systems that tend to sign themselves in/out in the + background are considered implicit. We may choose to honor or + ignore their states, allowing the user to opt for other login + types even if the default implicit one can't be explicitly + logged out or otherwise controlled. """ assert _ba.in_logic_thread() + cfg = _ba.app.config + cfgkey = 'ImplicitLoginStates' + cfgdict = _ba.app.config.setdefault(cfgkey, {}) + # Store which (if any) adapter is currently implicitly signed in. + # Making the assumption there will only ever be one implicit + # adapter at a time; may need to update this if that changes. + prev_state = cfgdict.get(login_type.value) if state is None: self._implicit_signed_in_adapter = None + new_state = cfgdict[login_type.value] = None else: self._implicit_signed_in_adapter = self.login_adapters[login_type] + new_state = cfgdict[login_type.value] = self._hashstr( + state.login_id + ) + + # Special case: if the user is already signed in but not with + # this implicit login, we may want to let them know that the + # 'Welcome back FOO' they likely just saw is not actually + # accurate. + if bool(False): + if ( + self.primary is not None + and not self.login_adapters[login_type].is_back_end_active() + ): + _ba.timer( + 2.0, + tpartial( + _ba.screenmessage, + 'Warning: Ignoring your' + ' Google Play Games account.\n' + 'If you want to use it,' + ' sign out of your current account.', + (1, 0.5, 0), + ), + ) + + cfg.commit() + + # We want to respond any time the implicit state changes; + # generally this means the user has explicitly signed in/out or + # switched accounts within that back-end. + if prev_state != new_state: + if DEBUG_LOG: + logging.debug( + 'AccountV2: Implicit state changed (%s -> %s);' + ' will update app sign-in state accordingly.', + prev_state, + new_state, + ) + self._implicit_state_changed = True # We may want to auto-sign-in based on this new state. self._update_auto_sign_in() @@ -187,12 +248,58 @@ class AccountV2Subsystem: def _update_auto_sign_in(self) -> None: from ba._internal import get_v1_account_state - # We attempt auto-sign-in only once. - if self._auto_signed_in: + # If implicit state has changed, try to respond. + if self._implicit_state_changed: + if self._implicit_signed_in_adapter is None: + # If implicit back-end is signed out, follow suit + # immediately; no need to wait for network connectivity. + if DEBUG_LOG: + logging.debug( + 'AccountV2: Signing out as result' + ' of implicit state change...', + ) + _ba.app.accounts_v2.set_primary_credentials(None) + self._implicit_state_changed = False + + # Once we've made a move here we don't want to + # do any more automatic ones. + self._can_do_auto_sign_in = False + + else: + # Ok; we've got a new implicit state. If we've got + # connectivity, let's attempt to sign in with it. + # Consider this an 'explicit' sign in because the + # implicit-login state change presumably was triggered + # by some user action (signing in, signing out, or + # switching accounts via the back-end). + # NOTE: should test case where we don't have + # connectivity here. + if _ba.app.cloud.is_connected(): + if DEBUG_LOG: + logging.debug( + 'AccountV2: Signing in as result' + ' of implicit state change...', + ) + self._implicit_signed_in_adapter.sign_in( + self._on_explicit_sign_in_completed + ) + self._implicit_state_changed = False + + # Once we've made a move here we don't want to + # do any more automatic ones. + self._can_do_auto_sign_in = False + + if not self._can_do_auto_sign_in: return # If we're not currently signed in, we have connectivity, and - # we have an available implicit adapter, do an auto-sign-in. + # we have an available implicit login, auto-sign-in with it. + # The implicit-state-change logic above should keep things + # mostly in-sync, but due to connectivity or other issues that + # might not always be the case. We prefer to keep people signed + # in as a rule, even if there are corner cases where this might + # not be what they want (A user signing out and then restarting + # may be auto-signed back in). connected = _ba.app.cloud.is_connected() signed_in_v1 = get_v1_account_state() == 'signed_in' signed_in_v2 = _ba.app.accounts_v2.have_primary_credentials() @@ -202,14 +309,44 @@ class AccountV2Subsystem: and not signed_in_v2 and self._implicit_signed_in_adapter is not None ): - self._auto_signed_in = True # Only attempt this once - self._implicit_signed_in_adapter.sign_in(self._on_sign_in_completed) + if DEBUG_LOG: + logging.debug( + 'AccountV2: Signing in due to on-launch-auto-sign-in...', + ) + self._can_do_auto_sign_in = False # Only ATTEMPT once + self._implicit_signed_in_adapter.sign_in( + self._on_implicit_sign_in_completed + ) - def _on_sign_in_completed( + def _on_explicit_sign_in_completed( self, adapter: LoginAdapter, result: LoginAdapter.SignInResult | Exception, ) -> None: + """A sign-in has completed that the user asked for explicitly.""" + from ba._language import Lstr + + del adapter # Unused. + + # Make some noise on errors. + # (May want to make this more descriptive). + if isinstance(result, Exception): + with _ba.Context('ui'): + _ba.screenmessage( + Lstr(resource='errorText'), + color=(1, 1, 0), + ) + _ba.playsound(_ba.getsound('error')) + return + + _ba.app.accounts_v2.set_primary_credentials(result.credentials) + + def _on_implicit_sign_in_completed( + self, + adapter: LoginAdapter, + result: LoginAdapter.SignInResult | Exception, + ) -> None: + """A sign-in has completed that the user didn't ask for explicitly.""" from ba._internal import get_v1_account_state del adapter # Unused. @@ -219,7 +356,9 @@ class AccountV2Subsystem: return # If we're still connected and still not signed in, - # plug in the credentials we got. + # plug in the credentials we got. We want to be extra cautious + # in case the user has since explicitly signed in since we + # kicked off. connected = _ba.app.cloud.is_connected() signed_in_v1 = get_v1_account_state() == 'signed_in' signed_in_v2 = _ba.app.accounts_v2.have_primary_credentials() diff --git a/assets/src/ba_data/python/ba/_app.py b/assets/src/ba_data/python/ba/_app.py index 46ac8e6f..89a6184f 100644 --- a/assets/src/ba_data/python/ba/_app.py +++ b/assets/src/ba_data/python/ba/_app.py @@ -354,6 +354,7 @@ class App: from bastd import maps as stdmaps from bastd.actor import spazappearance from ba._generated.enums import TimeType + from ba._apputils import log_dumped_tracebacks assert _ba.in_logic_thread() @@ -407,9 +408,9 @@ class App: # overwrite a broken one or whatnot and wipe out data. if not self.config_file_healthy: if self.platform in ('mac', 'linux', 'windows'): - from bastd.ui import configerror + from bastd.ui.configerror import ConfigErrorWindow - configerror.ConfigErrorWindow() + _ba.pushcall(ConfigErrorWindow) return # For now on other systems we just overwrite the bum config. @@ -459,6 +460,9 @@ class App: 'on_app_launch found state %s; expected LAUNCHING.', self.state ) + # If any traceback dumps happened last run, log and clear them. + log_dumped_tracebacks() + self._launch_completed = True self._update_state() @@ -483,8 +487,21 @@ class App: assert _ba.in_logic_thread() if self._app_paused: - self.state = self.State.PAUSED + # Entering paused state: + if self.state is not self.State.PAUSED: + self.state = self.State.PAUSED + self.cloud.on_app_pause() + self.accounts_v1.on_app_pause() + self.plugins.on_app_pause() else: + # Leaving paused state: + if self.state is self.State.PAUSED: + self.fg_state += 1 + self.cloud.on_app_resume() + self.accounts_v1.on_app_resume() + self.music.on_app_resume() + self.plugins.on_app_resume() + if self._initial_login_completed and self._meta_scan_completed: self.state = self.State.RUNNING if not self._called_on_app_running: @@ -498,19 +515,16 @@ class App: def on_app_pause(self) -> None: """Called when the app goes to a suspended state.""" + assert not self._app_paused # Should avoid redundant calls. self._app_paused = True self._update_state() - self.plugins.on_app_pause() def on_app_resume(self) -> None: """Run when the app resumes from a suspended state.""" + assert self._app_paused # Should avoid redundant calls. self._app_paused = False self._update_state() - self.fg_state += 1 - self.accounts_v1.on_app_resume() - self.music.on_app_resume() - self.plugins.on_app_resume() def on_app_shutdown(self) -> None: """(internal)""" diff --git a/assets/src/ba_data/python/ba/_apputils.py b/assets/src/ba_data/python/ba/_apputils.py index 166b4d33..9633b078 100644 --- a/assets/src/ba_data/python/ba/_apputils.py +++ b/assets/src/ba_data/python/ba/_apputils.py @@ -5,12 +5,13 @@ from __future__ import annotations import gc import os +import logging from typing import TYPE_CHECKING import _ba if TYPE_CHECKING: - from typing import Any + from typing import Any, TextIO import ba @@ -260,3 +261,51 @@ def print_corrupt_file_error() -> None: _ba.timer( 2.0, Call(_ba.playsound, _ba.getsound('error')), timetype=TimeType.REAL ) + + +_tbfiles: list[TextIO] = [] + + +def dump_tracebacks(delay: float) -> None: + """Dump a traceback of all Python threads after a delay in seconds. + + Can be used for debugging deadlock situations. Will dump to a preset + file location in the app config dir. Will attempt to log and clear + the results after dumping. It will be done at next launch otherwise, + or can be done explicitly via log_dumped_tracebacks(). + + Do not use this call during regular operation of the app; it is only + intended for debugging as it can leak file descriptors/etc. + """ + # pylint: disable=consider-using-with + import faulthandler + from ba._generated.enums import TimeType + + tbpath = os.path.join(os.path.dirname(_ba.app.config_file_path), '_tbdump') + + # faulthandler needs the raw file descriptor to still be valid when + # it fires, so stuff this into a global var to make sure it doesn't get + # cleaned up. + tbfile = open(tbpath, 'w', encoding='utf-8') + _tbfiles.append(tbfile) + + faulthandler.dump_traceback_later(delay, file=tbfile) + + # Attempt to log shortly after dumping. + with _ba.Context('ui'): + _ba.timer(delay + 1.0, log_dumped_tracebacks, timetype=TimeType.REAL) + + +def log_dumped_tracebacks() -> None: + """If a traceback dump exists, log it and clear it. No-op otherwise.""" + + try: + tbpath = os.path.join( + os.path.dirname(_ba.app.config_file_path), '_tbdump' + ) + if os.path.exists(tbpath): + with open(tbpath, 'r', encoding='utf-8') as infile: + logging.info('Dumped tracebacks:\n%s', infile.read()) + os.unlink(tbpath) + except Exception: + logging.exception('Error logging dumped tracebacks.') diff --git a/assets/src/ba_data/python/ba/_bootstrap.py b/assets/src/ba_data/python/ba/_bootstrap.py index 02f8cbf1..c13e457a 100644 --- a/assets/src/ba_data/python/ba/_bootstrap.py +++ b/assets/src/ba_data/python/ba/_bootstrap.py @@ -47,7 +47,7 @@ def bootstrap() -> None: # Give a soft warning if we're being used with a different binary # version than we expect. - expected_build = 20934 + expected_build = 20942 running_build: int = env['build_number'] if running_build != expected_build: print( @@ -120,7 +120,8 @@ def bootstrap() -> None: import __main__ # Clear out the standard quit/exit messages since they don't - # work for us. + # work in our embedded situation (should revisit this once we're + # usable from a standard interpreter). del __main__.__builtins__.quit del __main__.__builtins__.exit diff --git a/assets/src/ba_data/python/ba/_cloud.py b/assets/src/ba_data/python/ba/_cloud.py index 19202b55..785e68c7 100644 --- a/assets/src/ba_data/python/ba/_cloud.py +++ b/assets/src/ba_data/python/ba/_cloud.py @@ -33,6 +33,12 @@ class CloudSubsystem: """ return False # Needs to be overridden + def on_app_pause(self) -> None: + """Should be called when the app pauses.""" + + def on_app_resume(self) -> None: + """Should be called when the app resumes.""" + def on_connectivity_changed(self, connected: bool) -> None: """Called when cloud connectivity state changes.""" if DEBUG_LOG: diff --git a/assets/src/ba_data/python/ba/_coopgame.py b/assets/src/ba_data/python/ba/_coopgame.py index 0df8beb2..6fedc3ca 100644 --- a/assets/src/ba_data/python/ba/_coopgame.py +++ b/assets/src/ba_data/python/ba/_coopgame.py @@ -11,7 +11,7 @@ from ba._gameactivity import GameActivity from ba._general import WeakCall if TYPE_CHECKING: - from typing import Any, Sequence + from typing import Sequence from bastd.actor.playerspaz import PlayerSpaz import ba @@ -56,56 +56,6 @@ class CoopGameActivity(GameActivity[PlayerType, TeamType]): # Preload achievement images in case we get some. _ba.timer(2.0, WeakCall(self._preload_achievements)) - def _show_standard_scores_to_beat_ui( - self, scores: list[dict[str, Any]] - ) -> None: - from efro.util import asserttype - from ba._gameutils import timestring, animate - from ba._nodeactor import NodeActor - from ba._generated.enums import TimeFormat - - display_type = self.get_score_type() - if scores is not None: - - # Sort by originating date so that the most recent is first. - scores.sort(reverse=True, key=lambda s: asserttype(s['time'], int)) - - # Now make a display for the most recent challenge. - for score in scores: - if score['type'] == 'score_challenge': - tval = ( - score['player'] - + ': ' - + timestring( - int(score['value']) * 10, - timeformat=TimeFormat.MILLISECONDS, - ).evaluate() - if display_type == 'time' - else str(score['value']) - ) - hattach = 'center' if display_type == 'time' else 'left' - halign = 'center' if display_type == 'time' else 'left' - pos = (20, -70) if display_type == 'time' else (20, -130) - txt = NodeActor( - _ba.newnode( - 'text', - attrs={ - 'v_attach': 'top', - 'h_attach': hattach, - 'h_align': halign, - 'color': (0.7, 0.4, 1, 1), - 'shadow': 0.5, - 'flatness': 1.0, - 'position': pos, - 'scale': 0.6, - 'text': tval, - }, - ) - ).autoretain() - assert txt.node is not None - animate(txt.node, 'scale', {1.0: 0.0, 1.1: 0.7, 1.2: 0.6}) - break - # FIXME: this is now redundant with activityutils.getscoreconfig(); # need to kill this. def get_score_type(self) -> str: diff --git a/assets/src/ba_data/python/ba/_hooks.py b/assets/src/ba_data/python/ba/_hooks.py index 21d453b5..9d020aa6 100644 --- a/assets/src/ba_data/python/ba/_hooks.py +++ b/assets/src/ba_data/python/ba/_hooks.py @@ -461,12 +461,12 @@ def login_adapter_get_sign_in_token_response( ) -> None: """Login adapter do-sign-in completed.""" from bacommon.login import LoginType - from ba._login import LoginAdapterGPGS + from ba._login import LoginAdapterNative login_type = LoginType(login_type_str) attempt_id = int(attempt_id_str) result = None if result_str == '' else result_str with _ba.Context('ui'): adapter = _ba.app.accounts_v2.login_adapters[login_type] - assert isinstance(adapter, LoginAdapterGPGS) + assert isinstance(adapter, LoginAdapterNative) adapter.on_sign_in_complete(attempt_id=attempt_id, result=result) diff --git a/assets/src/ba_data/python/ba/_internal.py b/assets/src/ba_data/python/ba/_internal.py index 4d6ab704..4fb62ba2 100644 --- a/assets/src/ba_data/python/ba/_internal.py +++ b/assets/src/ba_data/python/ba/_internal.py @@ -104,7 +104,6 @@ def submit_score( name: Any, score: int | None, callback: Callable, - friend_callback: Callable | None, order: str = 'increasing', tournament_id: str | None = None, score_type: str = 'points', @@ -125,7 +124,6 @@ def submit_score( name=name, score=score, callback=callback, - friend_callback=friend_callback, order=order, tournament_id=tournament_id, score_type=score_type, diff --git a/assets/src/ba_data/python/ba/_login.py b/assets/src/ba_data/python/ba/_login.py index 2ec91382..6e95216e 100644 --- a/assets/src/ba_data/python/ba/_login.py +++ b/assets/src/ba_data/python/ba/_login.py @@ -102,6 +102,9 @@ class LoginAdapter: # (possibly) push it to the app for handling. self._update_implicit_login_state() + # This might affect whether we consider that back-end as 'active'. + self._update_back_end_active() + def set_active_logins(self, logins: dict[LoginType, str]) -> None: """Keep the adapter informed of actively used logins. @@ -116,7 +119,7 @@ class LoginAdapter: logging.debug( 'LoginAdapter: %s adapter got active logins %s.', self.login_type.name, - logins, + {k: v[:4] + '...' + v[-4:] for k, v in logins.items()}, ) self._active_login_id = logins.get(self.login_type) @@ -229,6 +232,10 @@ class LoginAdapter: # Kick off the process by fetching a sign-in token. self.get_sign_in_token(completion_cb=_got_sign_in_token_result) + def is_back_end_active(self) -> bool: + """Is this adapter's back-end currently active?""" + return self._back_end_active + def get_sign_in_token( self, completion_cb: Callable[[str | None], None] ) -> None: @@ -289,8 +296,8 @@ class LoginAdapter: self._back_end_active = is_active -class LoginAdapterGPGS(LoginAdapter): - """Google Play Game Services adapter.""" +class LoginAdapterNative(LoginAdapter): + """A login adapter that does its work in the native layer.""" def __init__(self) -> None: super().__init__(LoginType.GPGS) @@ -308,6 +315,9 @@ class LoginAdapterGPGS(LoginAdapter): self._sign_in_attempt_num += 1 _ba.login_adapter_get_sign_in_token(self.login_type.value, attempt_id) + def on_back_end_active_change(self, active: bool) -> None: + _ba.login_adapter_back_end_active_change(self.login_type.value, active) + def on_sign_in_complete(self, attempt_id: int, result: str | None) -> None: """Called by the native layer on a completed attempt.""" assert _ba.in_logic_thread() @@ -316,3 +326,7 @@ class LoginAdapterGPGS(LoginAdapter): return callback = self._sign_in_attempts.pop(attempt_id) callback(result) + + +class LoginAdapterGPGS(LoginAdapterNative): + """Google Play Game Services adapter.""" diff --git a/assets/src/ba_data/python/ba/internal.py b/assets/src/ba_data/python/ba/internal.py index e96cb0aa..c688faf1 100644 --- a/assets/src/ba_data/python/ba/internal.py +++ b/assets/src/ba_data/python/ba/internal.py @@ -100,6 +100,8 @@ from ba._apputils import ( is_browser_likely_available, get_remote_app_name, should_submit_debug_info, + dump_tracebacks, + log_dumped_tracebacks, ) from ba._benchmark import ( run_gpu_benchmark, @@ -330,4 +332,6 @@ __all__ = [ 'sign_out_v1', 'sign_in_v1', 'mark_config_dirty', + 'dump_tracebacks', + 'log_dumped_tracebacks', ] diff --git a/assets/src/ba_data/python/bastd/activity/coopscore.py b/assets/src/ba_data/python/bastd/activity/coopscore.py index 5c32fdeb..63864605 100644 --- a/assets/src/ba_data/python/bastd/activity/coopscore.py +++ b/assets/src/ba_data/python/bastd/activity/coopscore.py @@ -116,7 +116,6 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): self._newly_complete: bool | None = None self._is_more_levels: bool | None = None self._next_level_name: str | None = None - self._show_friend_scores: bool | None = None self._show_info: dict[str, Any] | None = None self._name_str: str | None = None self._friends_loading_status: ba.Actor | None = None @@ -177,12 +176,6 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): .replace(' ', '_') ) - # If game-center/etc scores are available we show our friends' - # scores. Otherwise we show our local high scores. - self._show_friend_scores = ba.internal.game_service_has_leaderboard( - self._game_name_str, self._game_config_str - ) - try: self._old_best_rank = self._campaign.getlevel( self._level_name @@ -366,21 +359,6 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): ba.internal.set_ui_input_device(None) # Menu is up for grabs. - if self._show_friend_scores: - ba.buttonwidget( - parent=rootc, - color=(0.45, 0.4, 0.5), - position=(h_offs - 520, v_offs + 480), - size=(300, 60), - label=ba.Lstr(resource='topFriendsText'), - on_activate_call=ba.WeakCall(self._ui_gc), - transition_delay=delay + 0.5, - icon=self._game_service_leaderboards_texture, - icon_color=self._game_service_icon_color, - autoselect=True, - selectable=can_select_extra_buttons, - ) - if self._have_achievements and self._account_has_achievements: ba.buttonwidget( parent=rootc, @@ -773,18 +751,6 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): [p.name for p in self._playerinfos] ) - if self._show_friend_scores: - self._friends_loading_status = Text( - ba.Lstr( - value='${A}...', - subs=[('${A}', ba.Lstr(resource='loadingText'))], - ), - position=(-405, 150 + 30), - color=(1, 1, 1, 0.4), - transition=Text.Transition.FADE_IN, - scale=0.7, - transition_delay=2.0, - ) self._score_loading_status = Text( ba.Lstr( value='${A}...', @@ -850,8 +816,6 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): # We expect this only in kiosk mode; complain otherwise. if not (ba.app.demo_mode or ba.app.arcade_mode): print('got not-signed-in at score-submit; unexpected') - if self._show_friend_scores: - ba.pushcall(ba.WeakCall(self._got_friend_score_results, None)) ba.pushcall(ba.WeakCall(self._got_score_results, None)) else: assert self._game_name_str is not None @@ -862,9 +826,6 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): name_str, self._score, ba.WeakCall(self._got_score_results), - ba.WeakCall(self._got_friend_score_results) - if self._show_friend_scores - else None, order=self._score_order, tournament_id=self.session.tournament_id, score_type=self._score_type, @@ -899,138 +860,118 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]): assert txt.node txt.node.client_only = True - # If we have no friend scores, display local best scores. - if self._show_friend_scores: + ts_height = 300 + ts_h_offs = -480 + v_offs = 40 + Text( + ba.Lstr(resource='yourBestScoresText') + if self._score_type == 'points' + else ba.Lstr(resource='yourBestTimesText'), + maxwidth=210, + position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20), + transition=Text.Transition.IN_RIGHT, + v_align=Text.VAlign.CENTER, + scale=1.2, + transition_delay=1.8, + ).autoretain() - # Host has a button, so we need client-only text. - ts_height = 300 - ts_h_offs = -480 - v_offs = 40 - txt = Text( - ba.Lstr(resource='topFriendsText'), - maxwidth=210, - position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20), - transition=Text.Transition.IN_RIGHT, - v_align=Text.VAlign.CENTER, - scale=1.2, - transition_delay=1.8, - ).autoretain() - assert txt.node - txt.node.client_only = True - else: + display_scores = list(our_high_scores) + display_count = 5 - ts_height = 300 - ts_h_offs = -480 - v_offs = 40 - Text( - ba.Lstr(resource='yourBestScoresText') - if self._score_type == 'points' - else ba.Lstr(resource='yourBestTimesText'), - maxwidth=210, - position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20), - transition=Text.Transition.IN_RIGHT, - v_align=Text.VAlign.CENTER, - scale=1.2, - transition_delay=1.8, - ).autoretain() + while len(display_scores) < display_count: + display_scores.append((0, None)) - display_scores = list(our_high_scores) - display_count = 5 - - while len(display_scores) < display_count: - display_scores.append((0, None)) - - showed_ours = False - h_offs_extra = 85 if self._score_type == 'points' else 130 - v_offs_extra = 20 - v_offs_names = 0 - scale = 1.0 - p_count = len(self._playerinfos) - h_offs_extra -= 75 - if p_count > 1: - h_offs_extra -= 20 - if p_count == 2: - scale = 0.9 - elif p_count == 3: - scale = 0.65 - elif p_count == 4: - scale = 0.5 - times: list[tuple[float, float]] = [] - for i in range(display_count): - times.insert( - random.randrange(0, len(times) + 1), - (1.9 + i * 0.05, 2.3 + i * 0.05), - ) - for i in range(display_count): - try: - if display_scores[i][1] is None: - name_str = '-' - else: - # noinspection PyUnresolvedReferences - name_str = ', '.join( - [p['name'] for p in display_scores[i][1]['players']] - ) - except Exception: - ba.print_exception( - f'Error calcing name_str for {display_scores}' - ) + showed_ours = False + h_offs_extra = 85 if self._score_type == 'points' else 130 + v_offs_extra = 20 + v_offs_names = 0 + scale = 1.0 + p_count = len(self._playerinfos) + h_offs_extra -= 75 + if p_count > 1: + h_offs_extra -= 20 + if p_count == 2: + scale = 0.9 + elif p_count == 3: + scale = 0.65 + elif p_count == 4: + scale = 0.5 + times: list[tuple[float, float]] = [] + for i in range(display_count): + times.insert( + random.randrange(0, len(times) + 1), + (1.9 + i * 0.05, 2.3 + i * 0.05), + ) + for i in range(display_count): + try: + if display_scores[i][1] is None: name_str = '-' - if display_scores[i] == our_score and not showed_ours: - flash = True - color0 = (0.6, 0.4, 0.1, 1.0) - color1 = (0.6, 0.6, 0.6, 1.0) - tdelay1 = 3.7 - tdelay2 = 3.7 - showed_ours = True else: - flash = False - color0 = (0.6, 0.4, 0.1, 1.0) - color1 = (0.6, 0.6, 0.6, 1.0) - tdelay1 = times[i][0] - tdelay2 = times[i][1] - Text( - str(display_scores[i][0]) - if self._score_type == 'points' - else ba.timestring( - display_scores[i][0] * 10, - timeformat=ba.TimeFormat.MILLISECONDS, - suppress_format_warning=True, - ), - position=( - ts_h_offs + 20 + h_offs_extra, - v_offs_extra - + ts_height / 2 - + -ts_height * (i + 1) / 10 - + v_offs - + 11.0, - ), - h_align=Text.HAlign.RIGHT, - v_align=Text.VAlign.CENTER, - color=color0, - flash=flash, - transition=Text.Transition.IN_RIGHT, - transition_delay=tdelay1, - ).autoretain() + # noinspection PyUnresolvedReferences + name_str = ', '.join( + [p['name'] for p in display_scores[i][1]['players']] + ) + except Exception: + ba.print_exception( + f'Error calcing name_str for {display_scores}' + ) + name_str = '-' + if display_scores[i] == our_score and not showed_ours: + flash = True + color0 = (0.6, 0.4, 0.1, 1.0) + color1 = (0.6, 0.6, 0.6, 1.0) + tdelay1 = 3.7 + tdelay2 = 3.7 + showed_ours = True + else: + flash = False + color0 = (0.6, 0.4, 0.1, 1.0) + color1 = (0.6, 0.6, 0.6, 1.0) + tdelay1 = times[i][0] + tdelay2 = times[i][1] + Text( + str(display_scores[i][0]) + if self._score_type == 'points' + else ba.timestring( + display_scores[i][0] * 10, + timeformat=ba.TimeFormat.MILLISECONDS, + suppress_format_warning=True, + ), + position=( + ts_h_offs + 20 + h_offs_extra, + v_offs_extra + + ts_height / 2 + + -ts_height * (i + 1) / 10 + + v_offs + + 11.0, + ), + h_align=Text.HAlign.RIGHT, + v_align=Text.VAlign.CENTER, + color=color0, + flash=flash, + transition=Text.Transition.IN_RIGHT, + transition_delay=tdelay1, + ).autoretain() - Text( - ba.Lstr(value=name_str), - position=( - ts_h_offs + 35 + h_offs_extra, - v_offs_extra - + ts_height / 2 - + -ts_height * (i + 1) / 10 - + v_offs_names - + v_offs - + 11.0, - ), - maxwidth=80.0 + 100.0 * len(self._playerinfos), - v_align=Text.VAlign.CENTER, - color=color1, - flash=flash, - scale=scale, - transition=Text.Transition.IN_RIGHT, - transition_delay=tdelay2, - ).autoretain() + Text( + ba.Lstr(value=name_str), + position=( + ts_h_offs + 35 + h_offs_extra, + v_offs_extra + + ts_height / 2 + + -ts_height * (i + 1) / 10 + + v_offs_names + + v_offs + + 11.0, + ), + maxwidth=80.0 + 100.0 * len(self._playerinfos), + v_align=Text.VAlign.CENTER, + color=color1, + flash=flash, + scale=scale, + transition=Text.Transition.IN_RIGHT, + transition_delay=tdelay2, + ).autoretain() # Show achievements for this level. ts_height = -150 diff --git a/assets/src/ba_data/python/bastd/game/football.py b/assets/src/ba_data/python/bastd/game/football.py index a88583e4..a8d87771 100644 --- a/assets/src/ba_data/python/bastd/game/football.py +++ b/assets/src/ba_data/python/bastd/game/football.py @@ -616,9 +616,6 @@ class FootballCoopGame(ba.CoopGameActivity[Player, Team]): for bottype in self._bot_types_initial: self._spawn_bot(bottype) - def _on_got_scores_to_beat(self, scores: list[dict[str, Any]]) -> None: - self._show_standard_scores_to_beat_ui(scores) - def _on_bot_spawn(self, spaz: SpazBot) -> None: # We want to move to the left by default. spaz.target_point_default = ba.Vec3(0, 0, 0) diff --git a/assets/src/ba_data/python/bastd/game/onslaught.py b/assets/src/ba_data/python/bastd/game/onslaught.py index 90aa87be..bf275137 100644 --- a/assets/src/ba_data/python/bastd/game/onslaught.py +++ b/assets/src/ba_data/python/bastd/game/onslaught.py @@ -682,9 +682,6 @@ class OnslaughtGame(ba.CoopGameActivity[Player, Team]): self._bots = SpazBotSet() ba.timer(4.0, self._start_updating_waves) - def _on_got_scores_to_beat(self, scores: list[dict[str, Any]]) -> None: - self._show_standard_scores_to_beat_ui(scores) - def _get_dist_grp_totals(self, grps: list[Any]) -> tuple[int, int]: totalpts = 0 totaldudes = 0 diff --git a/assets/src/ba_data/python/bastd/game/runaround.py b/assets/src/ba_data/python/bastd/game/runaround.py index d8f5e4b4..379ae8e3 100644 --- a/assets/src/ba_data/python/bastd/game/runaround.py +++ b/assets/src/ba_data/python/bastd/game/runaround.py @@ -684,9 +684,6 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]): }, ) - def _on_got_scores_to_beat(self, scores: list[dict[str, Any]]) -> None: - self._show_standard_scores_to_beat_ui(scores) - def _update_waves(self) -> None: # pylint: disable=too-many-branches diff --git a/assets/src/ba_data/python/bastd/game/thelaststand.py b/assets/src/ba_data/python/bastd/game/thelaststand.py index 2040e5c2..62e98c91 100644 --- a/assets/src/ba_data/python/bastd/game/thelaststand.py +++ b/assets/src/ba_data/python/bastd/game/thelaststand.py @@ -326,9 +326,6 @@ class TheLastStandGame(ba.CoopGameActivity[Player, Team]): else: super().handlemessage(msg) - def _on_got_scores_to_beat(self, scores: list[dict[str, Any]]) -> None: - self._show_standard_scores_to_beat_ui(scores) - def end_game(self) -> None: # Tell our bots to celebrate just to rub it in. self._bots.final_celebrate() diff --git a/assets/src/ba_data/python/bastd/ui/account/settings.py b/assets/src/ba_data/python/bastd/ui/account/settings.py index 0f7f59ab..cd65942a 100644 --- a/assets/src/ba_data/python/bastd/ui/account/settings.py +++ b/assets/src/ba_data/python/bastd/ui/account/settings.py @@ -37,6 +37,8 @@ class AccountSettingsWindow(ba.Window): self._close_once_signed_in = close_once_signed_in ba.set_analytics_screen('Account Window') + self._explicitly_signed_out_of_gpgs = False + # If they provided an origin-widget, scale up from that. scale_origin: tuple[float, float] | None if origin_widget is not None: @@ -104,7 +106,7 @@ class AccountSettingsWindow(ba.Window): # Legacy v1 device accounts are currently always available # (though we need to start phasing them out at some point). - self._show_sign_in_buttons.append('Local') + self._show_sign_in_buttons.append('Device') top_extra = 15 if uiscale is ba.UIScale.SMALL else 0 super().__init__( @@ -229,17 +231,22 @@ class AccountSettingsWindow(ba.Window): # pylint: disable=cyclic-import from bastd.ui import confirm + primary_v2_account = ba.app.accounts_v2.primary + v1_state = ba.internal.get_v1_account_state() - account_type = ( + v1_account_type = ( ba.internal.get_v1_account_type() if v1_state == 'signed_in' else 'unknown' ) - is_google = account_type == 'Google Play' - - show_local_signed_in_as = False - local_signed_in_as_space = 50.0 + # We expose GPGS-specific functionality only if it is 'active' + # (meaning the current GPGS player matches one of our account's + # logins). + gpgs_adapter = ba.app.accounts_v2.login_adapters.get(LoginType.GPGS) + is_gpgs = ( + False if gpgs_adapter is None else gpgs_adapter.is_back_end_active() + ) show_signed_in_as = self._signed_in signed_in_as_space = 95.0 @@ -257,23 +264,25 @@ class AccountSettingsWindow(ba.Window): and self._signing_in_adapter is None and 'Google Play' in self._show_sign_in_buttons ) - show_device_sign_in_button = ( - v1_state == 'signed_out' - and self._signing_in_adapter is None - and 'Local' in self._show_sign_in_buttons - ) show_v2_proxy_sign_in_button = ( v1_state == 'signed_out' and self._signing_in_adapter is None and 'V2Proxy' in self._show_sign_in_buttons ) + show_device_sign_in_button = ( + v1_state == 'signed_out' + and self._signing_in_adapter is None + and 'Device' in self._show_sign_in_buttons + ) sign_in_button_space = 70.0 - show_game_service_button = self._signed_in and account_type in [ + show_game_service_button = self._signed_in and v1_account_type in [ 'Game Center' ] game_service_button_space = 60.0 + show_what_is_v2 = self._signed_in and v1_account_type == 'V2' + show_linked_accounts_text = ( self._signed_in and ba.internal.get_v1_account_misc_read_val( @@ -282,7 +291,7 @@ class AccountSettingsWindow(ba.Window): ) linked_accounts_text_space = 60.0 - show_achievements_button = self._signed_in and account_type in ( + show_achievements_button = self._signed_in and v1_account_type in ( 'Google Play', 'Local', 'V2', @@ -294,7 +303,7 @@ class AccountSettingsWindow(ba.Window): ) achievements_text_space = 27.0 - show_leaderboards_button = self._signed_in and is_google + show_leaderboards_button = self._signed_in and is_gpgs leaderboards_button_space = 60.0 show_campaign_progress = self._signed_in @@ -306,7 +315,9 @@ class AccountSettingsWindow(ba.Window): show_reset_progress_button = False reset_progress_button_space = 70.0 - show_manage_v2_account_button = self._signed_in and account_type == 'V2' + show_manage_v2_account_button = ( + self._signed_in and v1_account_type == 'V2' + ) manage_v2_account_button_space = 100.0 show_player_profiles_button = self._signed_in @@ -325,7 +336,7 @@ class AccountSettingsWindow(ba.Window): show_unlink_accounts_button = show_link_accounts_button unlink_accounts_button_space = 90.0 - show_sign_out_button = self._signed_in and account_type in [ + show_sign_out_button = self._signed_in and v1_account_type in [ 'Local', 'Google Play', 'V2', @@ -337,15 +348,13 @@ class AccountSettingsWindow(ba.Window): # to be verified. show_cancel_sign_in_button = self._signing_in_adapter is not None or ( ba.app.accounts_v2.have_primary_credentials() - and ba.app.accounts_v2.primary is None + and primary_v2_account is None ) cancel_sign_in_button_space = 70.0 if self._subcontainer is not None: self._subcontainer.delete() self._sub_height = 60.0 - if show_local_signed_in_as: - self._sub_height += local_signed_in_as_space if show_signed_in_as: self._sub_height += signed_in_as_space if show_signing_in_text: @@ -398,27 +407,8 @@ class AccountSettingsWindow(ba.Window): first_selectable = None v = self._sub_height - 10.0 - if show_local_signed_in_as: - v -= local_signed_in_as_space * 0.6 - ba.textwidget( - parent=self._subcontainer, - position=(self._sub_width * 0.5, v), - size=(0, 0), - text=ba.Lstr( - resource='accountSettingsWindow.deviceSpecificAccountText', - subs=[ - ('${NAME}', ba.internal.get_v1_account_display_string()) - ], - ), - scale=0.7, - color=(0.5, 0.5, 0.6), - maxwidth=self._sub_width * 0.9, - flatness=1.0, - h_align='center', - v_align='center', - ) - v -= local_signed_in_as_space * 0.4 - + self._account_name_what_is_text: ba.Widget | None + self._account_name_what_is_y = 0.0 self._account_name_text: ba.Widget | None if show_signed_in_as: v -= signed_in_as_space * 0.2 @@ -437,7 +427,7 @@ class AccountSettingsWindow(ba.Window): h_align='center', v_align='center', ) - v -= signed_in_as_space * 0.4 + v -= signed_in_as_space * 0.5 self._account_name_text = ba.textwidget( parent=self._subcontainer, position=(self._sub_width * 0.5, v), @@ -449,10 +439,39 @@ class AccountSettingsWindow(ba.Window): h_align='center', v_align='center', ) + + if show_what_is_v2: + self._account_name_what_is_y = v - 23.0 + self._account_name_what_is_text = ba.textwidget( + parent=self._subcontainer, + position=(0.0, self._account_name_what_is_y), + size=(200.0, 60), + text=ba.Lstr( + value='${WHAT} -->', + subs=[('${WHAT}', ba.Lstr(resource='whatIsThisText'))], + ), + scale=0.6, + color=(0.3, 0.7, 0.05), + maxwidth=200.0, + h_align='right', + v_align='center', + autoselect=True, + selectable=True, + on_activate_call=ba.WeakCall(self._on_what_is_v2_press), + click_activate=True, + ) + if first_selectable is None: + first_selectable = self._account_name_what_is_text + else: + self._account_name_what_is_text = None + self._refresh_account_name_text() + v -= signed_in_as_space * 0.4 + else: self._account_name_text = None + self._account_name_what_is_text = None if self._back_button is None: bbtn = ba.internal.get_special_widget('back_button') @@ -709,12 +728,12 @@ class AccountSettingsWindow(ba.Window): if show_game_service_button: button_width = 300 v -= game_service_button_space * 0.85 - account_type = ba.internal.get_v1_account_type() - if account_type == 'Game Center': - account_type_name = ba.Lstr(resource='gameCenterText') + v1_account_type = ba.internal.get_v1_account_type() + if v1_account_type == 'Game Center': + v1_account_type_name = ba.Lstr(resource='gameCenterText') else: raise ValueError( - "unknown account type: '" + str(account_type) + "'" + "unknown account type: '" + str(v1_account_type) + "'" ) self._game_service_button = btn = ba.buttonwidget( parent=self._subcontainer, @@ -724,7 +743,7 @@ class AccountSettingsWindow(ba.Window): autoselect=True, on_activate_call=ba.internal.show_online_score_ui, size=(button_width, 50), - label=account_type_name, + label=v1_account_type_name, ) if first_selectable is None: first_selectable = btn @@ -767,11 +786,15 @@ class AccountSettingsWindow(ba.Window): autoselect=True, icon=ba.gettexture( 'googlePlayAchievementsIcon' - if is_google + if is_gpgs else 'achievementsIcon' ), - icon_color=(0.8, 0.95, 0.7) if is_google else (0.85, 0.8, 0.9), - on_activate_call=self._on_achievements_press, + icon_color=(0.8, 0.95, 0.7) if is_gpgs else (0.85, 0.8, 0.9), + on_activate_call=( + self._on_custom_achievements_press + if is_gpgs + else self._on_achievements_press + ), size=(button_width, 50), label='', ) @@ -1044,33 +1067,25 @@ class AccountSettingsWindow(ba.Window): ) self._needs_refresh = False + def _on_custom_achievements_press(self) -> None: + ba.timer( + 0.15, + ba.Call(ba.internal.show_online_score_ui, 'achievements'), + timetype=ba.TimeType.REAL, + ) + def _on_achievements_press(self) -> None: # pylint: disable=cyclic-import from bastd.ui import achievements - account_state = ba.internal.get_v1_account_state() - account_type = ( - ba.internal.get_v1_account_type() - if account_state == 'signed_in' - else 'unknown' + assert self._achievements_button is not None + achievements.AchievementsWindow( + position=self._achievements_button.get_screen_space_center() ) - # for google play we use the built-in UI; otherwise pop up our own - if account_type == 'Google Play': - ba.timer( - 0.15, - ba.Call(ba.internal.show_online_score_ui, 'achievements'), - timetype=ba.TimeType.REAL, - ) - elif account_type != 'unknown': - assert self._achievements_button is not None - achievements.AchievementsWindow( - position=self._achievements_button.get_screen_space_center() - ) - else: - print( - 'ERROR: unknown account type in on_achievements_press:', - account_type, - ) + + def _on_what_is_v2_press(self) -> None: + bamasteraddr = ba.internal.get_master_server_address(version=2) + ba.open_url(f'{bamasteraddr}/whatisv2') def _on_manage_account_press(self) -> None: ba.screenmessage(ba.Lstr(resource='oneMomentText')) @@ -1195,6 +1210,7 @@ class AccountSettingsWindow(ba.Window): ) def _refresh_account_name_text(self) -> None: + if self._account_name_text is None: return try: @@ -1202,7 +1218,20 @@ class AccountSettingsWindow(ba.Window): except Exception: ba.print_exception() name_str = '??' + ba.textwidget(edit=self._account_name_text, text=name_str) + if self._account_name_what_is_text is not None: + swidth = ba.internal.get_string_width( + name_str, suppress_warning=True + ) + # Eww; number-fudging. Need to recalibrate this if + # account name scaling changes. + x = self._sub_width * 0.5 - swidth * 0.75 - 170 + + ba.textwidget( + edit=self._account_name_what_is_text, + position=(x, self._account_name_what_is_y), + ) def _refresh_achievements(self) -> None: if ( @@ -1263,6 +1292,11 @@ class AccountSettingsWindow(ba.Window): def _sign_out_press(self) -> None: if ba.app.accounts_v2.have_primary_credentials(): + if ( + ba.app.accounts_v2.primary is not None + and LoginType.GPGS in ba.app.accounts_v2.primary.logins + ): + self._explicitly_signed_out_of_gpgs = True ba.app.accounts_v2.set_primary_credentials(None) else: ba.internal.sign_out_v1() @@ -1334,6 +1368,27 @@ class AccountSettingsWindow(ba.Window): # when finished. ba.app.accounts_v2.set_primary_credentials(result.credentials) + # Special case - if the user has explicitly logged out and + # logged in again with GPGS via this button, warn them that + # they need to use the app if they want to switch to a + # different GPGS account. + if ( + self._explicitly_signed_out_of_gpgs + and adapter.login_type is LoginType.GPGS + ): + # Delay this slightly so it hopefully pops up after + # credentials go through and the account name shows up. + ba.timer( + 1.5, + ba.Call( + ba.screenmessage, + ba.Lstr( + resource=self._r + + '.googlePlayGamesAccountSwitchText' + ), + ), + ) + # Speed any UI updates along. self._needs_refresh = True ba.timer(0.1, ba.WeakCall(self._update), timetype=ba.TimeType.REAL) diff --git a/assets/src/ba_data/python/bastd/ui/configerror.py b/assets/src/ba_data/python/bastd/ui/configerror.py index 129e5eaa..3165bfc3 100644 --- a/assets/src/ba_data/python/bastd/ui/configerror.py +++ b/assets/src/ba_data/python/bastd/ui/configerror.py @@ -20,12 +20,12 @@ class ConfigErrorWindow(ba.Window): self._config_file_path = ba.app.config_file_path width = 800 super().__init__( - ba.containerwidget(size=(width, 300), transition='in_right') + ba.containerwidget(size=(width, 400), transition='in_right') ) padding = 20 ba.textwidget( parent=self._root_widget, - position=(padding, 220), + position=(padding, 220 + 60), size=(width - 2 * padding, 100 - 2 * padding), h_align='center', v_align='top', @@ -41,7 +41,7 @@ class ConfigErrorWindow(ba.Window): ) ba.textwidget( parent=self._root_widget, - position=(padding, 198), + position=(padding, 198 + 60), size=(width - 2 * padding, 100 - 2 * padding), h_align='center', v_align='top', diff --git a/ballisticacore-cmake/.idea/dictionaries/ericf.xml b/ballisticacore-cmake/.idea/dictionaries/ericf.xml index 60593a9f..de0fbb15 100644 --- a/ballisticacore-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticacore-cmake/.idea/dictionaries/ericf.xml @@ -48,6 +48,7 @@ allobjs allocs allwarnings + alogins alot alphaimg alphapixels @@ -217,6 +218,7 @@ cend centiseconds certifi + cfgdict cfgdir cfgpath changeme @@ -1334,6 +1336,7 @@ subtypestr successmsg sval + swidth swiftc symbolification syscalls @@ -1345,6 +1348,9 @@ targs tasklabel tbegin + tbfile + tbfiles + tbpath tcls tdels tdiff @@ -1508,6 +1514,7 @@ weeeird welp whaaaaaaa + whatisv wheee wheeee wiimote diff --git a/src/ballistica/app/app_flavor.cc b/src/ballistica/app/app_flavor.cc index d238d854..d6a2b1ed 100644 --- a/src/ballistica/app/app_flavor.cc +++ b/src/ballistica/app/app_flavor.cc @@ -156,7 +156,6 @@ void AppFlavor::UpdatePauseResume() { void AppFlavor::OnPause() { assert(InMainThread()); - // Avoid reading gyro values for a short time to avoid hitches when restored. g_graphics->SetGyroEnabled(false); // IMPORTANT: Any on-pause related stuff that threads need to do must @@ -234,20 +233,59 @@ void AppFlavor::SetProductPrice(const std::string& product, void AppFlavor::PauseApp() { assert(InMainThread()); + millisecs_t start_time{Platform::GetCurrentMilliseconds()}; + + // Apple mentioned 5 seconds to run stuff once backgrounded or + // they bring down the hammer. Let's aim to stay under 2. + millisecs_t max_duration{2000}; + Platform::DebugLog("PauseApp@" + std::to_string(Platform::GetCurrentMilliseconds())); assert(!sys_paused_app_); sys_paused_app_ = true; UpdatePauseResume(); + + // We assume that the OS will completely suspend our process the moment + // we return from this call (though this is not technically true on all + // platforms). So we want to spin and wait for threads to actually + // process the pause message. + size_t running_thread_count{}; + while (std::abs(Platform::GetCurrentMilliseconds() - start_time) + < max_duration) { + // If/when we get to a point with no threads waiting to be paused, + // we're good to go. + auto threads{Thread::GetStillPausingThreads()}; + running_thread_count = threads.size(); + if (running_thread_count == 0) { + Log(LogLevel::kDebug, + "PauseApp() completed in " + + std::to_string(Platform::GetCurrentMilliseconds() - start_time) + + "ms."); + return; + } + } + + // If we made it here, we timed out. Complain. + Log(LogLevel::kError, + std::string("PauseApp() took too long; ") + + std::to_string(running_thread_count) + + " threads not yet paused after " + + std::to_string(Platform::GetCurrentMilliseconds() - start_time) + + " ms."); } void AppFlavor::ResumeApp() { assert(InMainThread()); + millisecs_t start_time{Platform::GetCurrentMilliseconds()}; Platform::DebugLog("ResumeApp@" + std::to_string(Platform::GetCurrentMilliseconds())); assert(sys_paused_app_); sys_paused_app_ = false; UpdatePauseResume(); + Log(LogLevel::kDebug, + "ResumeApp() completed in " + + std::to_string(Platform::GetCurrentMilliseconds() - start_time) + + "ms."); } void AppFlavor::DidFinishRenderingFrame(FrameDef* frame) {} @@ -265,6 +303,7 @@ void AppFlavor::PrimeEventPump() { #pragma mark Push-Calls +// FIXME - move this call to Platform. void AppFlavor::PushShowOnlineScoreUICall(const std::string& show, const std::string& game, const std::string& game_version) { @@ -316,14 +355,6 @@ void AppFlavor::PushOpenURLCall(const std::string& url) { thread()->PushCall([url] { g_platform->OpenURL(url); }); } -void AppFlavor::PushGetFriendScoresCall(const std::string& game, - const std::string& game_version, - void* data) { - thread()->PushCall([game, game_version, data] { - g_platform->GetFriendScores(game, game_version, data); - }); -} - void AppFlavor::PushSubmitScoreCall(const std::string& game, const std::string& game_version, int64_t score) { diff --git a/src/ballistica/app/app_flavor.h b/src/ballistica/app/app_flavor.h index fb1f013a..c0693b48 100644 --- a/src/ballistica/app/app_flavor.h +++ b/src/ballistica/app/app_flavor.h @@ -43,16 +43,17 @@ class AppFlavor { /// Should process any pending OS events, etc. virtual auto RunEvents() -> void; - // These should be called by the window, view-controller, sdl, - // or whatever is driving the app. They must be called from the main thread. - - /// Should be called on mobile when the app is backgrounded. - /// Pauses threads, closes network sockets, etc. + /// Put the app into a paused state. Should be called from the main + /// thread. Pauses work, closes network sockets, etc. + /// Corresponds to being backgrounded on mobile, etc. + /// It is assumed that, as soon as this call returns, all work is + /// finished and all threads can be suspended by the OS without any + /// negative side effects. auto PauseApp() -> void; auto paused() const -> bool { return actually_paused_; } - /// Should be called on mobile when the app is foregrounded. + /// Resume the app; corresponds to returning to foreground on mobile/etc. /// Spins threads back up, re-opens network sockets, etc. auto ResumeApp() -> void; @@ -101,9 +102,6 @@ class AppFlavor { auto PushShowOnlineScoreUICall(const std::string& show, const std::string& game, const std::string& game_version) -> void; - auto PushGetFriendScoresCall(const std::string& game, - const std::string& game_version, void* data) - -> void; auto PushSubmitScoreCall(const std::string& game, const std::string& game_version, int64_t score) -> void; diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index 6fa5faad..afac0d1b 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -32,7 +32,7 @@ namespace ballistica { // These are set automatically via script; don't modify them here. -const int kAppBuildNumber = 20934; +const int kAppBuildNumber = 20942; const char* kAppVersion = "1.7.14"; // Our standalone globals. diff --git a/src/ballistica/core/object.cc b/src/ballistica/core/object.cc index ee3280ee..6efc0098 100644 --- a/src/ballistica/core/object.cc +++ b/src/ballistica/core/object.cc @@ -11,7 +11,7 @@ namespace ballistica { -void Object::PrintObjects() { +void Object::LsObjects() { #if BA_DEBUG_BUILD std::string s; { @@ -47,7 +47,7 @@ void Object::PrintObjects() { for (auto&& i : obj_map) { sorted.emplace_back(i.second, i.first); } - std::sort(sorted.begin(), sorted.end()); + std::sort(sorted.rbegin(), sorted.rend()); for (auto&& i : sorted) { s += "\n " + std::to_string(i.first) + ": " + i.second; } @@ -56,7 +56,7 @@ void Object::PrintObjects() { } Log(LogLevel::kInfo, s); #else - Log(LogLevel::kInfo, "PrintObjects() only functions in debug builds."); + Log(LogLevel::kInfo, "LsObjects() only functions in debug builds."); #endif // BA_DEBUG_BUILD } diff --git a/src/ballistica/core/object.h b/src/ballistica/core/object.h index 6847e43b..5cb03e1b 100644 --- a/src/ballistica/core/object.h +++ b/src/ballistica/core/object.h @@ -21,8 +21,8 @@ class Object { Object(); virtual ~Object(); - /// Prints a tally of object types and counts (debug build only). - static void PrintObjects(); + /// Logs a tally of ba::Object types and counts (debug build only). + static void LsObjects(); // Object classes can provide descriptive names for themselves; // these are used for debugging and other purposes. diff --git a/src/ballistica/core/thread.cc b/src/ballistica/core/thread.cc index de2b5985..b9032ff3 100644 --- a/src/ballistica/core/thread.cc +++ b/src/ballistica/core/thread.cc @@ -91,7 +91,7 @@ auto Thread::RunAssetsThreadP(void* data) -> void* { return nullptr; } -void Thread::SetPaused(bool paused) { +void Thread::PushSetPaused(bool paused) { // Can be toggled from the main thread only. assert(std::this_thread::get_id() == g_app->main_thread_id); PushThreadMessage(ThreadMessage(paused ? ThreadMessage::Type::kPause @@ -101,13 +101,24 @@ void Thread::SetPaused(bool paused) { void Thread::WaitForNextEvent(bool single_cycle) { // If we're running a single cycle we never stop to wait. if (single_cycle) { + // Need to revisit this if we ever do single-cycle for + // the gil-holding thread so we don't starve other Python threads. + assert(!acquires_python_gil_); return; } - // We also never wait if we have pending runnables. - // (we run all existing runnables in each loop cycle, but one of those - // may have enqueued more). - if (has_pending_runnables()) { + // We also never wait if we have pending runnables; we wan't to run + // things as soon as we can. We chew through all runnables at the end + // of the loop so it might seem like there should never be any here, + // but runnables can add other runnables that won't get processed until + // the next time through. + // BUG FIX: We now skip this if we're paused since we don't run runnables + // in that case. This was preventing us from releasing the GIL while paused + // (and I assume causing us to spin full-speed through the loop; ugh). + // NOTE: It is theoretically possible for a runnable to add another runnable + // each time through the loop which would effectively starve the GIL as + // well; do we need to worry about that case? + if (has_pending_runnables() && !paused_) { return; } @@ -479,9 +490,6 @@ void Thread::PushThreadMessage(const ThreadMessage& t) { // Plop the data on to the list; we're assuming the mutex is locked. thread_messages_.push_back(t); - // Keep our own count; apparently size() on an stl list involves iterating. - // FIXME: Actually I don't think this is the case anymore; should check. - // Debugging: show message count states. if (explicit_bool(false)) { static int one_off = 0; @@ -525,13 +533,29 @@ void Thread::PushThreadMessage(const ThreadMessage& t) { thread_message_cv_.notify_all(); } -void Thread::SetThreadsPaused(bool paused) { +auto Thread::SetThreadsPaused(bool paused) -> void { + assert(std::this_thread::get_id() == g_app->main_thread_id); g_app->threads_paused = paused; for (auto&& i : g_app->pausable_threads) { - i->SetPaused(paused); + i->PushSetPaused(paused); } } +auto Thread::GetStillPausingThreads() -> std::vector { + std::vector threads; + assert(std::this_thread::get_id() == g_app->main_thread_id); + + // Only return results if an actual pause is in effect. + if (g_app->threads_paused) { + for (auto&& i : g_app->pausable_threads) { + if (!i->paused()) { + threads.push_back(i); + } + } + } + return threads; +} + auto Thread::AreThreadsPaused() -> bool { return g_app->threads_paused; } auto Thread::NewTimer(millisecs_t length, bool repeat, @@ -553,6 +577,7 @@ auto Thread::GetCurrentThreadName() -> std::string { } } + // Ask pthread for the thread name if we don't have one. // FIXME - move this to platform. #if BA_OSTYPE_MACOS || BA_OSTYPE_IOS_TVOS || BA_OSTYPE_LINUX std::string name = "unknown (sys-name="; diff --git a/src/ballistica/core/thread.h b/src/ballistica/core/thread.h index d5a63d01..7f16500f 100644 --- a/src/ballistica/core/thread.h +++ b/src/ballistica/core/thread.h @@ -45,7 +45,8 @@ class Thread { void SetAcquiresPythonGIL(); - void SetPaused(bool paused); + void PushSetPaused(bool paused); + auto thread_id() const -> std::thread::id { return thread_id_; } // Needed in rare cases where we jump physical threads. @@ -97,6 +98,10 @@ class Thread { /// the app through a flood of packets. auto CheckPushSafety() -> bool; + static auto GetStillPausingThreads() -> std::vector; + + auto paused() { return paused_; } + private: struct ThreadMessage { enum class Type { kShutdown = 999, kRunnable, kPause, kResume }; diff --git a/src/ballistica/graphics/gl/gl_sys.h b/src/ballistica/graphics/gl/gl_sys.h index 8ffa9ad8..154e0ce7 100644 --- a/src/ballistica/graphics/gl/gl_sys.h +++ b/src/ballistica/graphics/gl/gl_sys.h @@ -61,9 +61,9 @@ #if BA_OSTYPE_MACOS #if BA_XCODE_BUILD #include +#include #include #endif // BA_XCODE_BUILD -#include #endif // BA_OSTYPE_MACOS #endif // BA_OSTYPE_IOS_TVOS || BA_OSTYPE_ANDROID diff --git a/src/ballistica/input/input.cc b/src/ballistica/input/input.cc index bebef567..a6a1b289 100644 --- a/src/ballistica/input/input.cc +++ b/src/ballistica/input/input.cc @@ -1818,4 +1818,48 @@ auto Input::GetKeyName(int keycode) -> std::string { #pragma clang diagnostic pop #endif // BA_SDL2_BUILD || BA_MINSDL_BUILD +auto Input::LsInputDevices() -> void { + BA_PRECONDITION(InLogicThread()); + + std::string out; + + std::string ind{" "}; + int index{0}; + for (auto& device : input_devices_) { + if (index != 0) { + out += "\n"; + } + out += std::to_string(index + 1) + ":\n"; + out += ind + "name: " + device->GetDeviceName() + "\n"; + out += ind + "index: " + std::to_string(device->index()) + "\n"; + out += (ind + "is-controller: " + std::to_string(device->IsController()) + + "\n"); + out += (ind + "is-sdl-controller: " + + std::to_string(device->IsSDLController()) + "\n"); + out += (ind + "is-touch-screen: " + std::to_string(device->IsTouchScreen()) + + "\n"); + out += (ind + "is-remote-control: " + + std::to_string(device->IsRemoteControl()) + "\n"); + out += (ind + "is-test-input: " + std::to_string(device->IsTestInput()) + + "\n"); + out += + (ind + "is-keyboard: " + std::to_string(device->IsKeyboard()) + "\n"); + out += (ind + "is-mfi-controller: " + + std::to_string(device->IsMFiController()) + "\n"); + out += (ind + "is-local: " + std::to_string(device->IsLocal()) + "\n"); + out += (ind + "is-ui-only: " + std::to_string(device->IsUIOnly()) + "\n"); + out += (ind + "is-remote-app: " + std::to_string(device->IsRemoteApp()) + + "\n"); + + out += ind + "attached-to: " + + (device->GetRemotePlayer() != nullptr ? "remote-player" + : device->GetPlayer() != nullptr ? "local-player" + : "nothing"); + + ++index; + } + + Log(LogLevel::kInfo, out); +} + } // namespace ballistica diff --git a/src/ballistica/input/input.h b/src/ballistica/input/input.h index 1ece106a..3c3659c7 100644 --- a/src/ballistica/input/input.h +++ b/src/ballistica/input/input.h @@ -126,6 +126,7 @@ class Input { auto PushTouchEvent(const TouchEvent& touch_event) -> void; auto PushDestroyKeyboardInputDevices() -> void; auto PushCreateKeyboardInputDevices() -> void; + auto LsInputDevices() -> void; /// Roughly how long in milliseconds have all input devices been idle. auto input_idle_time() const { return input_idle_time_; } @@ -170,7 +171,6 @@ class Input { bool have_non_touch_inputs_{}; float cursor_pos_x_{}; float cursor_pos_y_{}; - // millisecs_t last_input_time_{}; millisecs_t last_click_time_{}; millisecs_t double_click_time_{200}; millisecs_t last_mouse_move_time_{}; diff --git a/src/ballistica/platform/apple/platform_apple.h b/src/ballistica/platform/apple/platform_apple.h index 6aa86d56..5c819577 100644 --- a/src/ballistica/platform/apple/platform_apple.h +++ b/src/ballistica/platform/apple/platform_apple.h @@ -37,8 +37,6 @@ class PlatformApple : public Platform { const std::vector& widths, float scale) -> void* override; auto GetTextTextureData(void* tex) -> uint8_t* override; - auto GetFriendScores(const std::string& game, const std::string& game_version, - void* py_callback) -> void override; auto SubmitScore(const std::string& game, const std::string& version, int64_t score) -> void override; auto ReportAchievement(const std::string& achievement) -> void override; diff --git a/src/ballistica/platform/platform.cc b/src/ballistica/platform/platform.cc index 04adb2dc..31abfccb 100644 --- a/src/ballistica/platform/platform.cc +++ b/src/ballistica/platform/platform.cc @@ -196,6 +196,11 @@ auto Platform::LoginAdapterGetSignInToken(const std::string& login_type, }); } +auto Platform::LoginAdapterBackEndActiveChange(const std::string& login_type, + bool active) -> void { + // Default is no-op. +} + auto Platform::GetDeviceV1AccountUUIDPrefix() -> std::string { Log(LogLevel::kError, "GetDeviceV1AccountUUIDPrefix() unimplemented"); return "u"; @@ -862,13 +867,6 @@ auto Platform::ConvertIncomingLeaderboardScore( return score; } -void Platform::GetFriendScores(const std::string& game, - const std::string& game_version, void* data) { - // As a default, just fail gracefully. - Log(LogLevel::kError, "FIXME: GetFriendScores unimplemented"); - g_logic->PushFriendScoreSetCall(FriendScoreSet(false, data)); -} - void Platform::SubmitScore(const std::string& game, const std::string& version, int64_t score) { Log(LogLevel::kError, "FIXME: SubmitScore() unimplemented"); diff --git a/src/ballistica/platform/platform.h b/src/ballistica/platform/platform.h index 8edcade4..27b03ded 100644 --- a/src/ballistica/platform/platform.h +++ b/src/ballistica/platform/platform.h @@ -339,6 +339,10 @@ class Platform { /// Called when a Python LoginAdapter is requesting an explicit sign-in. virtual auto LoginAdapterGetSignInToken(const std::string& login_type, int attempt_id) -> void; + /// Called when a Python LoginAdapter is informing us that a back-end is + /// active/inactive. + virtual auto LoginAdapterBackEndActiveChange(const std::string& login_type, + bool active) -> void; #pragma mark MUSIC PLAYBACK ---------------------------------------------------- @@ -368,9 +372,6 @@ class Platform { virtual auto ConvertIncomingLeaderboardScore( const std::string& leaderboard_id, int score) -> int; - virtual auto GetFriendScores(const std::string& game, - const std::string& game_version, - void* py_callback) -> void; virtual auto SubmitScore(const std::string& game, const std::string& version, int64_t score) -> void; virtual auto ReportAchievement(const std::string& achievement) -> void; diff --git a/src/ballistica/python/methods/python_methods_app.cc b/src/ballistica/python/methods/python_methods_app.cc index d2460ea9..2de0a6dc 100644 --- a/src/ballistica/python/methods/python_methods_app.cc +++ b/src/ballistica/python/methods/python_methods_app.cc @@ -6,6 +6,7 @@ #include "ballistica/app/app_flavor.h" #include "ballistica/assets/component/texture.h" #include "ballistica/core/logging.h" +#include "ballistica/core/thread.h" #include "ballistica/graphics/graphics.h" #include "ballistica/logic/connection/connection_set.h" #include "ballistica/logic/host_activity.h" @@ -308,18 +309,29 @@ auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { int from_other_thread{}; int suppress_warning{}; int other_thread_use_fg_context{}; - static const char* kwlist[] = {"call", "from_other_thread", + int raw{0}; + static const char* kwlist[] = {"call", + "from_other_thread", "suppress_other_thread_warning", - "other_thread_use_fg_context", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|ppp", + "other_thread_use_fg_context", + "raw", + nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|pppp", const_cast(kwlist), &call_obj, &from_other_thread, &suppress_warning, - &other_thread_use_fg_context)) { + &other_thread_use_fg_context, &raw)) { return nullptr; } - // The from-other-thread case is basically a different call. - if (from_other_thread) { + // 'raw' mode does no thread checking and no context saves/restores. + if (raw) { + Py_INCREF(call_obj); + g_logic->thread()->PushCall([call_obj] { + assert(InLogicThread()); + + PythonRef(call_obj, PythonRef::kSteal).Call(); + }); + } else if (from_other_thread) { // Warn the user not to use this from the logic thread since it doesnt // save/restore context. if (!suppress_warning && InLogicThread()) { @@ -1132,15 +1144,12 @@ auto PythonMethodsApp::GetMethods() -> std::vector { {"pushcall", (PyCFunction)PyPushCall, METH_VARARGS | METH_KEYWORDS, "pushcall(call: Callable, from_other_thread: bool = False,\n" " suppress_other_thread_warning: bool = False,\n" - " other_thread_use_fg_context: bool = False) -> None\n" - "\n" - "Pushes a call onto the event loop to be run during the next cycle.\n" + " other_thread_use_fg_context: bool = False,\n" + " raw: bool = False) -> None\n" "\n" + "Push a call to the logic event-loop.\n" "Category: **General Utility Functions**\n" "\n" - "This can be handy for calls that are disallowed from within other\n" - "callbacks, etc.\n" - "\n" "This call expects to be used in the logic thread, and will " "automatically\n" "save and restore the ba.Context to behave seamlessly.\n" @@ -1149,8 +1158,9 @@ auto PythonMethodsApp::GetMethods() -> std::vector { "however, you can pass 'from_other_thread' as True. In this case\n" "the call will always run in the UI context on the logic thread\n" "or whichever context is in the foreground if\n" - "other_thread_use_fg_context is True."}, - + "other_thread_use_fg_context is True.\n" + "Passing raw=True will disable thread checks and context" + " sets/restores."}, {"getactivity", (PyCFunction)PyGetActivity, METH_VARARGS | METH_KEYWORDS, "getactivity(doraise: bool = True) -> \n" diff --git a/src/ballistica/python/methods/python_methods_system.cc b/src/ballistica/python/methods/python_methods_system.cc index b4a161b0..1d9f879b 100644 --- a/src/ballistica/python/methods/python_methods_system.cc +++ b/src/ballistica/python/methods/python_methods_system.cc @@ -638,6 +638,22 @@ auto PyLoginAdapterGetSignInToken(PyObject* self, PyObject* args, BA_PYTHON_CATCH; } +auto PyLoginAdapterBackEndActiveChange(PyObject* self, PyObject* args, + PyObject* keywds) -> PyObject* { + BA_PYTHON_TRY; + const char* login_type; + int active; + static const char* kwlist[] = {"login_type", "active", nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "sp", + const_cast(kwlist), &login_type, + &active)) { + return nullptr; + } + g_platform->LoginAdapterBackEndActiveChange(login_type, active); + Py_RETURN_NONE; + BA_PYTHON_CATCH; +} + auto PySetInternalLanguageKeys(PyObject* self, PyObject* args) -> PyObject* { BA_PYTHON_TRY; PyObject* list_obj; @@ -715,10 +731,18 @@ auto PyAndroidShowWifiSettings(PyObject* self, PyObject* args, PyObject* keywds) BA_PYTHON_CATCH; } -auto PyPrintObjects(PyObject* self, PyObject* args, PyObject* keywds) +auto PyLsObjects(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - Object::PrintObjects(); + Object::LsObjects(); + Py_RETURN_NONE; + BA_PYTHON_CATCH; +} + +auto PyLsInputDevices(PyObject* self, PyObject* args, PyObject* keywds) + -> PyObject* { + BA_PYTHON_TRY; + g_input->LsInputDevices(); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -756,6 +780,7 @@ auto PythonMethodsSystem::GetMethods() -> std::vector { "\n" "If this returns False, UIs should not show 'copy to clipboard'\n" "buttons, etc."}, + {"clipboard_has_text", (PyCFunction)PyClipboardHasText, METH_NOARGS, "clipboard_has_text() -> bool\n" "\n" @@ -765,6 +790,7 @@ auto PythonMethodsSystem::GetMethods() -> std::vector { "\n" "This will return False if no system clipboard is available; no need\n" " to call ba.clipboard_is_supported() separately."}, + {"clipboard_set_text", (PyCFunction)PyClipboardSetText, METH_VARARGS | METH_KEYWORDS, "clipboard_set_text(value: str) -> None\n" @@ -775,6 +801,7 @@ auto PythonMethodsSystem::GetMethods() -> std::vector { "\n" "Ensure that ba.clipboard_is_supported() returns True before adding\n" " buttons/etc. that make use of this functionality."}, + {"clipboard_get_text", (PyCFunction)PyClipboardGetText, METH_NOARGS, "clipboard_get_text() -> str\n" "\n" @@ -784,9 +811,20 @@ auto PythonMethodsSystem::GetMethods() -> std::vector { "\n" "Ensure that ba.clipboard_has_text() returns True before calling\n" " this function."}, - {"printobjects", (PyCFunction)PyPrintObjects, + + {"ls_objects", (PyCFunction)PyLsObjects, METH_VARARGS | METH_KEYWORDS, + "ls_objects() -> None\n" + "\n" + "Log debugging info about C++ level objects.\n" + "\n" + "Category: **General Utility Functions**\n" + "\n" + "This call only functions in debug builds of the game.\n" + "It prints various info about the current object count, etc."}, + + {"ls_input_devices", (PyCFunction)PyLsInputDevices, METH_VARARGS | METH_KEYWORDS, - "printobjects() -> None\n" + "ls_input_devices() -> None\n" "\n" "Print debugging info about game objects.\n" "\n" @@ -859,6 +897,14 @@ auto PythonMethodsSystem::GetMethods() -> std::vector { "\n" "(internal)"}, + {"login_adapter_back_end_active_change", + (PyCFunction)PyLoginAdapterBackEndActiveChange, + METH_VARARGS | METH_KEYWORDS, + "login_adapter_back_end_active_change(login_type: str, active: bool)" + " -> None\n" + "\n" + "(internal)"}, + {"submit_analytics_counts", (PyCFunction)PySubmitAnalyticsCounts, METH_VARARGS | METH_KEYWORDS, "submit_analytics_counts() -> None\n" diff --git a/tools/bacommon/login.py b/tools/bacommon/login.py index 957997da..c8ec0057 100644 --- a/tools/bacommon/login.py +++ b/tools/bacommon/login.py @@ -19,3 +19,13 @@ class LoginType(Enum): # Google Play Game Services GPGS = 'gpgs' + + @property + def displayname(self) -> str: + """Human readable name for this value.""" + cls = type(self) + match self: + case cls.EMAIL: + return 'Email/Password' + case cls.GPGS: + return 'Google Play Games' diff --git a/tools/batools/project.py b/tools/batools/project.py index 48c4d561..f4d82d7f 100755 --- a/tools/batools/project.py +++ b/tools/batools/project.py @@ -729,8 +729,10 @@ class Updater: def _check_misc(self) -> None: # Misc sanity checks. - if not self._public: - # Make sure we're set to prod master server. + + # Make sure we're set to prod master server. + # (but ONLY when checking; still want to be able to run updates). + if not self._public and self._check: with open( 'src/ballistica/internal/master_server_config.h', encoding='utf-8', diff --git a/tools/efro/error.py b/tools/efro/error.py index d3353708..456fc6f9 100644 --- a/tools/efro/error.py +++ b/tools/efro/error.py @@ -80,6 +80,15 @@ class IntegrityError(ValueError): """Data has been tampered with or corrupted in some form.""" +class AuthenticationError(Exception): + """Authentication has failed for some operation. + + This can be raised if server-side-verification does not match + client-supplied credentials, if an invalid password is supplied + for a sign-in attempt, etc. + """ + + def is_urllib_communication_error(exc: BaseException, url: str | None) -> bool: """Is the provided exception from urllib a communication-related error? diff --git a/tools/efro/message/_message.py b/tools/efro/message/_message.py index 9343a396..0697ad53 100644 --- a/tools/efro/message/_message.py +++ b/tools/efro/message/_message.py @@ -43,6 +43,20 @@ class SysResponse: users of the api never see them. """ + def set_local_exception(self, exc: Exception) -> None: + """Attach a local exception to facilitate better logging/handling. + + Be aware that this data does not get serialized and only + exists on the local object. + """ + setattr(self, '_sr_local_exception', exc) + + def get_local_exception(self) -> Exception | None: + """Fetch a local attached exception.""" + value = getattr(self, '_sr_local_exception', None) + assert isinstance(value, Exception | None) + return value + # Some standard response types: diff --git a/tools/efro/message/_sender.py b/tools/efro/message/_sender.py index bd9e94db..ee439e01 100644 --- a/tools/efro/message/_sender.py +++ b/tools/efro/message/_sender.py @@ -6,7 +6,6 @@ Supports static typing for message types and possible return types. from __future__ import annotations -import logging from typing import TYPE_CHECKING from efro.error import CleanError, RemoteError, CommunicationError @@ -158,17 +157,18 @@ class MessageSender: bound_obj, msg_encoded ) except Exception as exc: - # Any error in the raw send call gets recorded as either - # a local or communication error. - return ErrorSysResponse( - error_message=f'Error in MessageSender @send_method' - f' ({type(exc)}): {exc}', + response = ErrorSysResponse( + error_message='Error in MessageSender @send_method.', error_type=( ErrorSysResponse.ErrorType.COMMUNICATION if isinstance(exc, CommunicationError) else ErrorSysResponse.ErrorType.LOCAL ), ) + # Can include the actual exception since we'll be looking at + # this locally; might be helpful. + response.set_local_exception(exc) + return response return self._decode_raw_response(bound_obj, message, response_encoded) async def fetch_raw_response_async( @@ -193,17 +193,18 @@ class MessageSender: bound_obj, msg_encoded ) except Exception as exc: - # Any error in the raw send call gets recorded as either - # a local or communication error. - return ErrorSysResponse( - error_message=f'Error in MessageSender @send_async_method' - f' ({type(exc)}): {exc}', + response = ErrorSysResponse( + error_message='Error in MessageSender @send_async_method.', error_type=( ErrorSysResponse.ErrorType.COMMUNICATION if isinstance(exc, CommunicationError) else ErrorSysResponse.ErrorType.LOCAL ), ) + # Can include the actual exception since we'll be looking at + # this locally; might be helpful. + response.set_local_exception(exc) + return response return self._decode_raw_response(bound_obj, message, response_encoded) def unpack_raw_response( @@ -250,18 +251,14 @@ class MessageSender: self._decode_filter_call( bound_obj, message, response_dict, response ) - except Exception: - # If we got to this point, we successfully communicated - # with the other end so errors represent protocol mismatches - # or other invalid data. For now let's just log it but perhaps - # we'd want to somehow embed it in the ErrorSysResponse to be - # available directly to the user later. - logging.exception('Error decoding raw response') + except Exception as exc: response = ErrorSysResponse( - error_message='Error decoding raw response;' - ' see log for details.', + error_message='Error decoding raw response.', error_type=ErrorSysResponse.ErrorType.LOCAL, ) + # Since we'll be looking at this locally, we can include + # extra info for logging/etc. + response.set_local_exception(exc) return response def _unpack_raw_response( @@ -282,16 +279,24 @@ class MessageSender: # Some error occurred. Raise a local Exception for it. if isinstance(raw_response, ErrorSysResponse): + # Errors that happened locally can attach their exceptions + # here for extra logging goodness. + local_exception = raw_response.get_local_exception() + if ( raw_response.error_type is ErrorSysResponse.ErrorType.COMMUNICATION ): - raise CommunicationError(raw_response.error_message) + raise CommunicationError( + raw_response.error_message + ) from local_exception # If something went wrong on *our* end of the connection, # don't say it was a remote error. if raw_response.error_type is ErrorSysResponse.ErrorType.LOCAL: - raise RuntimeError(raw_response.error_message) + raise RuntimeError( + raw_response.error_message + ) from local_exception # If they want to support clean errors, do those. if ( @@ -299,14 +304,18 @@ class MessageSender: and raw_response.error_type is ErrorSysResponse.ErrorType.REMOTE_CLEAN ): - raise CleanError(raw_response.error_message) + raise CleanError( + raw_response.error_message + ) from local_exception if ( self.protocol.forward_communication_errors and raw_response.error_type is ErrorSysResponse.ErrorType.REMOTE_COMMUNICATION ): - raise CommunicationError(raw_response.error_message) + raise CommunicationError( + raw_response.error_message + ) from local_exception # Everything else gets lumped in as a remote error. raise RemoteError( @@ -316,7 +325,7 @@ class MessageSender: if self._peer_desc_call is None else self._peer_desc_call(bound_obj) ), - ) + ) from local_exception assert isinstance(raw_response, Response) return raw_response diff --git a/tools/efrotools/pcommand.py b/tools/efrotools/pcommand.py index 8a5a66a1..7e8c2ede 100644 --- a/tools/efrotools/pcommand.py +++ b/tools/efrotools/pcommand.py @@ -162,6 +162,13 @@ def _spelling(words: list[str]) -> None: print(f'Modified {num_modded_dictionaries} dictionaries.') +def pur() -> None: + """Run pur using project's Python version.""" + import subprocess + + subprocess.run([sys.executable, '-m', 'pur'] + sys.argv[2:], check=True) + + def spelling_all() -> None: """Add all misspellings from a pycharm run.""" import subprocess