Bombsquad-Ballistica-Modded.../dist/ba_data/python/bacommon/app.py

180 lines
5.4 KiB
Python
Raw Normal View History

2023-09-30 17:21:33 +05:30
# Released under the MIT License. See LICENSE for details.
#
2025-04-06 17:17:13 +05:30
"""Common high level values/functionality related to Ballistica apps."""
2023-09-30 17:21:33 +05:30
from __future__ import annotations
from enum import Enum
2023-12-21 15:55:50 +05:30
from dataclasses import dataclass
from typing import TYPE_CHECKING, Annotated
from efro.dataclassio import ioprepped, IOAttrs
2023-09-30 17:21:33 +05:30
2025-04-06 17:17:13 +05:30
from bacommon.locale import Locale
2023-09-30 17:21:33 +05:30
if TYPE_CHECKING:
pass
2023-12-21 15:55:50 +05:30
class AppInterfaceIdiom(Enum):
2024-05-19 18:25:43 +05:30
"""A general form-factor or method of experiencing a Ballistica app.
2023-12-21 15:55:50 +05:30
2025-04-06 17:17:13 +05:30
Note that it may be possible for a running app to switch idioms (for
2023-12-21 15:55:50 +05:30
instance if a mobile device or computer is connected to a TV).
"""
2025-04-06 17:17:13 +05:30
#: Small screen; assumed to have touch as primary input.
PHONE = 'phn'
#: Medium size screen; assumed to have touch as primary input.
TABLET = 'tab'
#: Medium size screen; assumed to have game controller as primary
#: input.
HANDHELD = 'hnd'
#: Large screen with high amount of detail visible; assumed to have
#: keyboard/mouse as primary input.
DESKTOP = 'dsk'
#: Large screen with medium amount of detail visible; assumed to have
#: game controller as primary input.
2023-12-21 15:55:50 +05:30
TV = 'tv'
2025-04-06 17:17:13 +05:30
#: Displayed over or in place of of the real world on a headset;
#: assumed to have hand tracking or spacial controllers as primary
#: input.
XR_HEADSET = 'xrh'
#: Displayed over or instead of the real world on a screen; assumed
#: to have device movement augmented by physical or touchscreen
#: controls as primary input.
XR_SCREEN = 'xrs'
2023-12-21 15:55:50 +05:30
2023-09-30 17:21:33 +05:30
class AppExperience(Enum):
2025-04-06 17:17:13 +05:30
"""A particular experience provided by a Ballistica app.
2023-09-30 17:21:33 +05:30
2025-02-09 00:17:58 +05:30
This is one metric used to isolate different playerbases from each
other where there might be no technical barriers doing so. For
2024-05-19 18:25:43 +05:30
example, a casual one-hand-playable phone game and an augmented
2023-12-21 15:55:50 +05:30
reality tabletop game may both use the same scene-versions and
networking-protocols and whatnot, but it would make no sense to
2024-05-19 18:25:43 +05:30
allow players of one to join servers of the other. AppExperience can
2023-12-21 15:55:50 +05:30
be used to keep these player bases separate.
Generally a single Ballistica app targets a single AppExperience.
This is not a technical requirement, however. A single app may
support multiple experiences, or there may be multiple apps
targeting one experience. Cloud components such as leagues are
generally associated with an AppExperience so that they are only
2025-04-06 17:17:13 +05:30
visible to client apps designed for that play style, and the same is
true for games joinable over the local network, bluetooth, etc.
2023-09-30 17:21:33 +05:30
"""
2025-04-06 17:17:13 +05:30
#: An experience that is supported everywhere. Used for the default
#: empty AppMode when starting the app, etc.
EMPTY = 'empt'
2023-09-30 17:21:33 +05:30
2025-04-06 17:17:13 +05:30
#: The traditional BombSquad experience - multiple players using
#: game controllers (or touch screen equivalents) in a single arena
#: small enough for all action to be viewed on a single screen.
MELEE = 'mlee'
2023-09-30 17:21:33 +05:30
2025-04-06 17:17:13 +05:30
#: The traditional BombSquad Remote experience; buttons on a
#: touch-screen allowing a mobile device to be used as a game
#: controller.
REMOTE = 'rmt'
2023-12-21 15:55:50 +05:30
class AppArchitecture(Enum):
2025-04-06 17:17:13 +05:30
"""Processor architecture an app can be running on."""
2023-12-21 15:55:50 +05:30
ARM = 'arm'
ARM64 = 'arm64'
X86 = 'x86'
2025-04-06 17:17:13 +05:30
X86_64 = 'x64'
2023-12-21 15:55:50 +05:30
class AppPlatform(Enum):
2025-04-06 17:17:13 +05:30
"""Overall platform a build can target.
2023-12-21 15:55:50 +05:30
2025-02-09 00:17:58 +05:30
Each distinct flavor of an app has a unique combination of
AppPlatform and AppVariant. Generally platform describes a set of
hardware, while variant describes a destination or purpose for the
build.
2023-12-21 15:55:50 +05:30
"""
MAC = 'mac'
2025-04-06 17:17:13 +05:30
WINDOWS = 'win'
LINUX = 'lin'
ANDROID = 'andr'
2023-12-21 15:55:50 +05:30
IOS = 'ios'
TVOS = 'tvos'
class AppVariant(Enum):
"""A unique Ballistica build type within a single platform.
2025-02-09 00:17:58 +05:30
Each distinct flavor of an app has a unique combination of
AppPlatform and AppVariant. Generally platform describes a set of
hardware, while variant describes a destination or purpose for the
build.
2023-12-21 15:55:50 +05:30
"""
2025-04-06 17:17:13 +05:30
#: Default builds.
GENERIC = 'gen'
2023-12-21 15:55:50 +05:30
2025-04-06 17:17:13 +05:30
#: Builds intended for public testing (may have some extra checks
#: or logging enabled).
TEST = 'tst'
2023-12-21 15:55:50 +05:30
# Various stores.
2025-04-06 17:17:13 +05:30
AMAZON_APPSTORE = 'amzn'
GOOGLE_PLAY = 'gpl'
APPLE_APP_STORE = 'appl'
WINDOWS_STORE = 'wins'
STEAM = 'stm'
2023-12-21 15:55:50 +05:30
META = 'meta'
2025-04-06 17:17:13 +05:30
EPIC_GAMES_STORE = 'epic'
2023-12-21 15:55:50 +05:30
# Other.
2025-04-06 17:17:13 +05:30
ARCADE = 'arcd'
2023-12-21 15:55:50 +05:30
DEMO = 'demo'
2025-04-06 17:17:13 +05:30
class AppName(Enum):
"""A predefined Ballistica app name.
This encompasses official or well-known apps. Other app projects
should set this to CUSTOM and provide a 'name_custom' value.
"""
BOMBSQUAD = 'bs'
CUSTOM = 'c'
2023-12-21 15:55:50 +05:30
@ioprepped
@dataclass
class AppInstanceInfo:
2025-04-06 17:17:13 +05:30
"""General info about an individual running ballistica app."""
2023-12-21 15:55:50 +05:30
2025-04-06 17:17:13 +05:30
name: Annotated[str, IOAttrs('name')]
name_custom: Annotated[
str | None, IOAttrs('namc', soft_default=None, store_default=False)
]
2024-05-19 18:25:43 +05:30
2025-04-06 17:17:13 +05:30
engine_version: Annotated[str, IOAttrs('evrs')]
engine_build: Annotated[int, IOAttrs('ebld')]
2023-12-21 15:55:50 +05:30
2025-04-06 17:17:13 +05:30
platform: Annotated[AppPlatform, IOAttrs('plat')]
variant: Annotated[AppVariant, IOAttrs('vrnt')]
architecture: Annotated[AppArchitecture, IOAttrs('arch')]
os_version: Annotated[str | None, IOAttrs('osvr')]
2023-12-21 15:55:50 +05:30
2025-04-06 17:17:13 +05:30
interface_idiom: Annotated[AppInterfaceIdiom, IOAttrs('intf')]
locale: Annotated[Locale, IOAttrs('loc')]
2023-12-21 15:55:50 +05:30
2025-04-06 17:17:13 +05:30
#: OS-specific string describing the device running the app.
device: Annotated[str | None, IOAttrs('devc')]