Added ba.app.state val

This commit is contained in:
Eric Froemling 2021-04-19 19:08:44 -07:00
parent 1a0e62a3b8
commit 99dac3af6f
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
5 changed files with 87 additions and 57 deletions

View File

@ -3932,40 +3932,40 @@
"assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450", "assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450",
"assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e", "assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e",
"assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f", "assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f",
"build/prefab/full/linux_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/fb/43/4ee03d93cb600a9d5357ed4a8f79", "build/prefab/full/linux_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/4d/69/2e4c0ba6b6a7f27c9754e6fa2028",
"build/prefab/full/linux_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/4e/46/13900c39fd26bab6f03282f12cec", "build/prefab/full/linux_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/54/e1/f8d826dfbe0ff9f192edc232857c",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/28/33/625c9e921e767b9454c8d37cd56a", "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b1/fd/2258453c18672fd79398b0c2030c",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a0/84/78af1a816be47f63737dbcdd44fa", "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3e/74/9417d078cb0a0eaecdf30e531c4e",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/1c/33/248616c7c2f44cc1806746ad830d", "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/e8/495cc0e784c6b98d33ee8e83f922",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/64/46/9a353218fcc3fc8d49d1b97a67a8", "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7b/73/c72308a21aeb876e4192719f4445",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/71/b6/2b354c0f019f57010292b20ee923", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/11/d4/474b2f2cf46689f7cb7733b66a10",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a1/a5/db3122d4b5ac643a773cd6c66f20", "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0e/d3/e1d791f6a6411c7acfdd72d2c75e",
"build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/3f/02/7e02321ee25135067834f31c6146", "build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/89/f9/7b3ec953d17beaa42560aa09bbdb",
"build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/e7/f5/bcbda2d9ebd4de7ee4ee4035cac6", "build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/57/81/c00fc47949becf3fa7b8fda7737e",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0c/b6/5afdffaf67d325f5173d618d21e5", "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/63/87/4f12518d69e5974124744a99b9cc",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/c3/b5bcc67d79d0d2fd8e6e8ee3a76d", "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/34/16/d383c070bc3ee1692f729d817ba5",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ea/37/d338b766e925f67249c3e59238d8", "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0c/68/d5c5a2e2511e597ab13f0e23f62b",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/ea/69/b6964aea96a7ffe478b5a2da6500", "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/10/3a/e8cca189e72de469661306810f4e",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/85/b1/1597fda81eb5ac71db7b9d6288b8", "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/90/0a/621c8f2bc888e93581b4100ef857",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/40/c3/6a017548a398061ced1f8669faf7", "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2b/24/e9fd7c975d93ce57707b5ddd01f1",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/67/6a/a4d22f68e1bc8ba940567ee22608", "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a6/f8/3bcda19fe1c92de4114b0096a807",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d6/56/c44797e5734c16c58b1d7679fbf0", "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d4/7b/22b7570f138f58ff88b219ff2586",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/9b/1f/9639e9527dcb178424b4f9ac0a39", "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/99/54/0a026dbab2d2e6e44d89f8242f4f",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/ad/a1/aa3966ca129f1be76d70e58389a7", "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/79/63/76dd15496bdedc116a02fc7a5df3",
"build/prefab/lib/linux_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d5/a9/ebdcf3e7aa536f1f1339a6cebc0e", "build/prefab/lib/linux_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/95/48/ad90969b34d9166d32eae56ea9e4",
"build/prefab/lib/linux_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bd/2e/29ac9dcb9cef978ae0230b3d663f", "build/prefab/lib/linux_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b4/5a/0515721b7e4ce334c0fabbeb4376",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/56/27/212fb5cdcf60dc8ebfd66c30f957", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d5/7f/9d46d20545a97b9f3b65ce25880a",
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ec/1f/228af5f4fbf759d0c31821f57032", "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/66/bd/5b9723fab837270b875da9f9d91e",
"build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/29/07/d2c9b0d389b10b8397eb5d62db81", "build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/34/80/166ae132364a8d788ddc66b6b8fe",
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c7/9f/78c5a20694fb80dba8141f0e22bd", "build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/88/14/b63a6887474340f9ea5aecd861c7",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1e/3a/4bbd2dc474279e8ad989d20ae304", "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/01/b8/9b18a2d624f5251c1d3d57a9abb8",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/45/9f/8e53aaea561cf99502e325cccaf8", "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/18/8a/d5f35a9938e4cfc21f26338b487a",
"build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/50/8b/7adf41aae43d70a691cafdeb39b4", "build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2f/c5/891774c681b68e350cca570a7936",
"build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/13/cb/717aecaca7eb3bb679592159efc7", "build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ef/96/a0e88328f90dc079c84bc0791f7f",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e4/57/57c7ec83ecfe22d0e43a067c2acc", "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c6/30/6446116fbb8ab3d97602a90ae99b",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/96/4e/4a089c7256cc6574d3954c79106a", "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/40/75/633d1a8d826ecf7417519e7d39eb",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/34/2c/6d6f5dca8dde7e3825d37d0ebc6a", "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/81/da/43f897aec8a5140ac1ef35b193e9",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b9/ad/9ac77c3fa1da834865daeaca50ee", "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/94/90/fefc90daa043e388604ea79ef4f0",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/90/23/d17be669d1095577a9534dcb0865", "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/12/cb/521fa56c5954c40be151704fd77e",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/df/18/8fcc18af7c1aca22a91ecf3b2dbd" "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/a7/da3c0ac70e103a8a3a31b50bc41e"
} }

View File

@ -19,6 +19,7 @@
- Fixed a potential crash-on-exit due to statically allocated colliders/caches in `ode_collision_trimesh.cpp` getting torn down while in use - Fixed a potential crash-on-exit due to statically allocated colliders/caches in `ode_collision_trimesh.cpp` getting torn down while in use
- Better randomization for player free-for-all starting locations - Better randomization for player free-for-all starting locations
- Plugins can now register to be called for pause, resume, and shutdown events in addition to launch - Plugins can now register to be called for pause, resume, and shutdown events in addition to launch
- Added ba.app.state holding the overall state of the app (running, paused, etc)
### 1.5.29 (20246) ### 1.5.29 (20246)
- Exposed ba method/class initing in public C++ layer. - Exposed ba method/class initing in public C++ layer.

View File

@ -3,6 +3,7 @@
"""Functionality related to the high level state of the app.""" """Functionality related to the high level state of the app."""
from __future__ import annotations from __future__ import annotations
from enum import Enum
import random import random
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -32,8 +33,16 @@ class App:
Note that properties not documented here should be considered internal Note that properties not documented here should be considered internal
and subject to change without warning. and subject to change without warning.
""" """
# pylint: disable=too-many-public-methods # pylint: disable=too-many-public-methods
class State(Enum):
"""High level state the app can be in."""
LAUNCHING = 0
RUNNING = 1
PAUSED = 2
SHUTTING_DOWN = 3
@property @property
def build_number(self) -> int: def build_number(self) -> int:
"""Integer build number. """Integer build number.
@ -172,6 +181,8 @@ class App:
""" """
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
self.state = self.State.LAUNCHING
# Config. # Config.
self.config_file_healthy = False self.config_file_healthy = False
@ -199,7 +210,6 @@ class App:
self.tips: List[str] = [] self.tips: List[str] = []
self.stress_test_reset_timer: Optional[ba.Timer] = None self.stress_test_reset_timer: Optional[ba.Timer] = None
self.did_weak_call_warning = False self.did_weak_call_warning = False
self.ran_on_app_launch = False
self.log_have_new = False self.log_have_new = False
self.log_upload_timer_started = False self.log_upload_timer_started = False
@ -374,11 +384,31 @@ class App:
self.accounts.on_app_launch() self.accounts.on_app_launch()
self.plugins.on_app_launch() self.plugins.on_app_launch()
self.ran_on_app_launch = True self.state = self.State.RUNNING
# from ba._dependency import test_depset # from ba._dependency import test_depset
# test_depset() # test_depset()
def on_app_pause(self) -> None:
"""Called when the app goes to a suspended state."""
self.state = self.State.PAUSED
self.plugins.on_app_pause()
def on_app_resume(self) -> None:
"""Run when the app resumes from a suspended state."""
self.state = self.State.RUNNING
self.fg_state += 1
self.accounts.on_app_resume()
self.music.on_app_resume()
self.plugins.on_app_resume()
def on_app_shutdown(self) -> None:
"""(internal)"""
self.state = self.State.SHUTTING_DOWN
self.music.on_app_shutdown()
self.plugins.on_app_shutdown()
def read_config(self) -> None: def read_config(self) -> None:
"""(internal)""" """(internal)"""
from ba import _appconfig from ba import _appconfig
@ -482,18 +512,6 @@ class App:
else: else:
self.main_menu_resume_callbacks.append(call) self.main_menu_resume_callbacks.append(call)
def on_app_pause(self) -> None:
"""Called when the app goes to a suspended state."""
self.plugins.on_app_pause()
def on_app_resume(self) -> None:
"""Run when the app resumes from a suspended state."""
self.fg_state += 1
self.accounts.on_app_resume()
self.music.on_app_resume()
self.plugins.on_app_resume()
def launch_coop_game(self, def launch_coop_game(self,
game: str, game: str,
force: bool = False, force: bool = False,
@ -542,11 +560,6 @@ class App:
_ba.fade_screen(False, endcall=_fade_end) _ba.fade_screen(False, endcall=_fade_end)
return True return True
def on_app_shutdown(self) -> None:
"""(internal)"""
self.music.on_app_shutdown()
self.plugins.on_app_shutdown()
def handle_deep_link(self, url: str) -> None: def handle_deep_link(self, url: str) -> None:
"""Handle a deep link URL.""" """Handle a deep link URL."""
from ba._language import Lstr from ba._language import Lstr

View File

@ -124,7 +124,7 @@ class Plugin:
"""Called when the app is being launched.""" """Called when the app is being launched."""
def on_app_pause(self) -> None: def on_app_pause(self) -> None:
"""Сalled after pausing game activity.""" """Called after pausing game activity."""
def on_app_resume(self) -> None: def on_app_resume(self) -> None:
"""Called after the game continues.""" """Called after the game continues."""

View File

@ -227,6 +227,10 @@
<li><a href="#class_ba_WidgetNotFoundError">ba.WidgetNotFoundError</a></li> <li><a href="#class_ba_WidgetNotFoundError">ba.WidgetNotFoundError</a></li>
</ul> </ul>
</ul> </ul>
<h4><a name="class_category_Misc_Classes">Misc Classes</a></h4>
<ul>
<li><a href="#class_ba_App_State">ba.App.State</a></li>
</ul>
<h4><a name="class_category_Protocols">Protocols</a></h4> <h4><a name="class_category_Protocols">Protocols</a></h4>
<ul> <ul>
<li><a href="#class_ba_Existable">ba.Existable</a></li> <li><a href="#class_ba_Existable">ba.Existable</a></li>
@ -1014,6 +1018,18 @@ to resume.</p>
</dd> </dd>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_App_State">ba.App.State</a></strong></h3>
<p>Inherits from: <a href="https://docs.python.org/3/library/enum.html#enum.Enum">enum.Enum</a></p>
<p>High level state the app can be in.</p>
<h3>Values:</h3>
<ul>
<li>LAUNCHING</li>
<li>RUNNING</li>
<li>PAUSED</li>
<li>SHUTTING_DOWN</li>
</ul>
<hr>
<h2><strong><a name="class_ba_AppConfig">ba.AppConfig</a></strong></h3> <h2><strong><a name="class_ba_AppConfig">ba.AppConfig</a></strong></h3>
<p>Inherits from: builtins.dict</p> <p>Inherits from: builtins.dict</p>
<p>A special dict that holds the game's persistent configuration values.</p> <p>A special dict that holds the game's persistent configuration values.</p>
@ -4804,7 +4820,7 @@ the type-checker properly identifies the returned value as one.</p>
<dt><h4><a name="method_ba_Plugin__on_app_pause">on_app_pause()</a></dt></h4><dd> <dt><h4><a name="method_ba_Plugin__on_app_pause">on_app_pause()</a></dt></h4><dd>
<p><span>on_app_pause(self) -&gt; None</span></p> <p><span>on_app_pause(self) -&gt; None</span></p>
<p>Сalled after pausing game activity.</p> <p>Called after pausing game activity.</p>
</dd> </dd>
<dt><h4><a name="method_ba_Plugin__on_app_resume">on_app_resume()</a></dt></h4><dd> <dt><h4><a name="method_ba_Plugin__on_app_resume">on_app_resume()</a></dt></h4><dd>