bacommon.cloudui package

Common CloudUI bits.

class bacommon.cloudui.CloudUIPage[source]

Bases: IOMultiType[CloudUIPageTypeID]

UI defined by the cloud.

Conceptually similar to a basic html page, except using app UI.

classmethod get_type(type_id: CloudUIPageTypeID) type[CloudUIPage][source]

Return the subclass for each of our type-ids.

classmethod get_type_id() CloudUIPageTypeID[source]

Return the type-id for this subclass.

classmethod get_type_id_storage_name() str[source]

Return the key used to store type id in serialized data.

The default is an obscure value so that it does not conflict with members of individual type attrs, but in some cases one might prefer to serialize it to something simpler like ‘type’ by overriding this call. One just needs to make sure that no encompassed types serialize anything to ‘type’ themself.

classmethod get_unknown_type_fallback() CloudUIPage[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

class bacommon.cloudui.CloudUIPageTypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

UNKNOWN = 'u'
V1 = 'v1'
class bacommon.cloudui.UnknownCloudUIPage[source]

Bases: CloudUIPage

Fallback type for unrecognized UI types.

Will show the client a ‘cannot display this UI’ placeholder page.

classmethod get_type_id() CloudUIPageTypeID[source]

Return the type-id for this subclass.

Submodules

bacommon.cloudui.v1 module

Full UIs defined in the cloud - similar to a basic form of html

class bacommon.cloudui.v1.Button(label: str | None = None, size: tuple[float, float] | None = None, color: tuple[float, float, float] | None = None, opacity: float | None = None, text_color: tuple[float, float, float, float] | None = None, text_flatness: float | None = None, text_scale: float | None = None, texture: str | None = None, scale: float = 1.0, padding_left: float = 0.0, padding_top: float = 0.0, padding_right: float = 0.0, padding_bottom: float = 0.0, decorations: list[~bacommon.cloudui.v1.Decoration] = <factory>, debug: bool = False)[source]

Bases: object

A button in our cloud ui.

color: tuple[float, float, float] | None = None
debug: bool = False
decorations: list[Decoration]
label: str | None = None

Note that cloud-ui accepts only raw str values for text; use babase.Lstr.evaluate() or whatnot for multi-language support.

opacity: float | None = None
padding_bottom: float = 0.0
padding_left: float = 0.0
padding_right: float = 0.0
padding_top: float = 0.0
scale: float = 1.0
size: tuple[float, float] | None = None
text_color: tuple[float, float, float, float] | None = None
text_flatness: float | None = None
text_scale: float | None = None
texture: str | None = None
class bacommon.cloudui.v1.Decoration[source]

Bases: IOMultiType[DecorationTypeID]

Top level class for our multitype.

classmethod get_type(type_id: DecorationTypeID) type[Decoration][source]

Return a specific subclass given a type-id.

classmethod get_type_id() DecorationTypeID[source]

Return the type-id for this subclass.

classmethod get_type_id_storage_name() str[source]

Return the key used to store type id in serialized data.

The default is an obscure value so that it does not conflict with members of individual type attrs, but in some cases one might prefer to serialize it to something simpler like ‘type’ by overriding this call. One just needs to make sure that no encompassed types serialize anything to ‘type’ themself.

classmethod get_unknown_type_fallback() Decoration[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

class bacommon.cloudui.v1.DecorationTypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

IMAGE = 'i'
TEXT = 't'
UNKNOWN = 'u'
class bacommon.cloudui.v1.HAlign(*values)[source]

Bases: Enum

Horizontal alignment.

CENTER = 'c'
LEFT = 'l'
RIGHT = 'r'
class bacommon.cloudui.v1.Image(texture: str, position: tuple[float, float], size: tuple[float, float], color: tuple[float, float, float] | None = None, opacity: float | None = None, h_align: HAlign = HAlign.CENTER, v_align: VAlign = VAlign.CENTER, tint_texture: str | None = None, tint_color: tuple[float, float, float] | None = None, tint2_color: tuple[float, float, float] | None = None, mask_texture: str | None = None, mesh_opaque: str | None = None, mesh_transparent: str | None = None)[source]

Bases: Decoration

Image decoration.

color: tuple[float, float, float] | None = None
classmethod get_type_id() DecorationTypeID[source]

Return the type-id for this subclass.

h_align: HAlign = 'c'
mask_texture: str | None = None
mesh_opaque: str | None = None
mesh_transparent: str | None = None
opacity: float | None = None
position: tuple[float, float]
size: tuple[float, float]
texture: str
tint2_color: tuple[float, float, float] | None = None
tint_color: tuple[float, float, float] | None = None
tint_texture: str | None = None
v_align: VAlign = 'c'
class bacommon.cloudui.v1.Page(title: str, rows: list[Row], center_vertically: bool = False, simple_culling_v: float = 100.0)[source]

Bases: CloudUIPage

Cloud-UI page version 1.

center_vertically: bool = False

If True, content smaller than the available height will be centered vertically. This can look natural for certain types of content such as confirmation dialogs.

classmethod get_type_id() CloudUIPageTypeID[source]

Return the type-id for this subclass.

rows: list[Row]
simple_culling_v: float = 100.0

If things disappear when scrolling up and down, turn this up.

title: str

Note that cloud-ui accepts only raw str values for text; use babase.Lstr.evaluate() or whatnot for multi-language support.

class bacommon.cloudui.v1.Row(buttons: list[Button], title: str | None = None, title_color: tuple[float, float, float, float] | None = None, title_flatness: float | None = None, title_shadow: float | None = None, subtitle: str | None = None, subtitle_color: tuple[float, float, float, float] | None = None, subtitle_flatness: float | None = None, subtitle_shadow: float | None = None, button_spacing: float = 5.0, padding_left: float = 10.0, padding_right: float = 10.0, padding_top: float = 10.0, padding_bottom: float = 10.0, center_content: bool = False, center_title: bool = False, simple_culling_h: float = 100.0, debug: bool = False)[source]

Bases: object

A row in our cloud ui.

button_spacing: float = 5.0
buttons: list[Button]
center_content: bool = False
center_title: bool = False
debug: bool = False
padding_bottom: float = 10.0
padding_left: float = 10.0
padding_right: float = 10.0
padding_top: float = 10.0
simple_culling_h: float = 100.0

If things disappear when scrolling left/right, turn this up.

subtitle: str | None = None
subtitle_color: tuple[float, float, float, float] | None = None
subtitle_flatness: float | None = None
subtitle_shadow: float | None = None
title: str | None = None

Note that cloud-ui accepts only raw str values for text; use babase.Lstr.evaluate() or whatnot for multi-language support.

title_color: tuple[float, float, float, float] | None = None
title_flatness: float | None = None
title_shadow: float | None = None
class bacommon.cloudui.v1.Text(text: str, position: tuple[float, float], max_width: float, max_height: float = 32.0, scale: float = 1.0, h_align: HAlign = HAlign.CENTER, v_align: VAlign = VAlign.CENTER, flatness: float | None = None, shadow: float | None = None, debug: bool = False)[source]

Bases: Decoration

Text decoration.

debug: bool = False

Show max-width/height bounds; useful during development.

flatness: float | None = None
classmethod get_type_id() DecorationTypeID[source]

Return the type-id for this subclass.

h_align: HAlign = 'c'
max_height: float = 32.0
max_width: float
position: tuple[float, float]
scale: float = 1.0
shadow: float | None = None
text: str

Note that cloud-ui accepts only raw str values for text; use babase.Lstr.evaluate() or whatnot for multi-language support.

v_align: VAlign = 'c'
class bacommon.cloudui.v1.UnknownDecoration[source]

Bases: Decoration

An unknown decoration.

In practice these should never show up since the master-server generates these on the fly for the client and so should not send clients one they can’t digest.

classmethod get_type_id() DecorationTypeID[source]

Return the type-id for this subclass.

class bacommon.cloudui.v1.VAlign(*values)[source]

Bases: Enum

Vertical alignment.

BOTTOM = 'b'
CENTER = 'c'
TOP = 't'