bacommon.decui package¶
Common DecUI bits.
- class bacommon.decui.DecUIRequest[source]¶
Bases:
IOMultiType[DecUIRequestTypeID]UI defined by the cloud.
Conceptually similar to web pages, except using app UI.
- classmethod get_type(type_id: DecUIRequestTypeID) type[DecUIRequest][source]¶
Return the subclass for each of our type-ids.
- classmethod get_type_id() DecUIRequestTypeID[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() DecUIRequest[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.decui.DecUIRequestTypeID(*values)[source]¶
Bases:
EnumType ID for each of our subclasses.
- UNKNOWN = 'u'¶
- V1 = 'v1'¶
- class bacommon.decui.DecUIResponse[source]¶
Bases:
IOMultiType[DecUIResponseTypeID]UI defined by the cloud.
Conceptually similar to a basic html response, except using app UI.
- classmethod get_type(type_id: DecUIResponseTypeID) type[DecUIResponse][source]¶
Return the subclass for each of our type-ids.
- classmethod get_type_id() DecUIResponseTypeID[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() DecUIResponse[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.decui.DecUIResponseTypeID(*values)[source]¶
Bases:
EnumType ID for each of our subclasses.
- UNKNOWN = 'u'¶
- V1 = 'v1'¶
- class bacommon.decui.DecUIWebRequest(dec_ui_request: DecUIRequest, locale: Locale, engine_build_number: int)[source]¶
Bases:
objectComplete data sent for dec-ui http requests.
- dec_ui_request: DecUIRequest¶
The wrapped dec-ui request.
- class bacommon.decui.DecUIWebResponse(error: str | None = None, dec_ui_response: DecUIResponse | None = None)[source]¶
Bases:
objectComplete data returned for dec-ui http requests.
- dec_ui_response: DecUIResponse | None = None¶
Dec-ui response. Either this or error should be set; not both.
- class bacommon.decui.UnknownDecUIRequest[source]¶
Bases:
DecUIRequestFallback type for unrecognized UI types.
Will show the client a ‘cannot display this UI’ placeholder request.
- classmethod get_type_id() DecUIRequestTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.decui.UnknownDecUIResponse[source]¶
Bases:
DecUIResponseFallback type for unrecognized UI types.
Will show the client a ‘cannot display this UI’ placeholder response.
- classmethod get_type_id() DecUIResponseTypeID[source]¶
Return the type-id for this subclass.
Submodules¶
bacommon.decui.v1 module¶
Full UIs defined in the cloud - similar to a basic form of html
- class bacommon.decui.v1.Action[source]¶
Bases:
IOMultiType[ActionTypeID]Top level class for our multitype.
- classmethod get_type(type_id: ActionTypeID) type[Action][source]¶
Return the subclass for each of our type-ids.
- classmethod get_type_id() ActionTypeID[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.
- class bacommon.decui.v1.ActionTypeID(*values)[source]¶
Bases:
EnumType ID for each of our subclasses.
- BROWSE = 'b'¶
- LOCAL = 'l'¶
- REPLACE = 'r'¶
- UNKNOWN = 'u'¶
- class bacommon.decui.v1.Browse(request: ~bacommon.decui.v1.Request, default_sound: bool = True, immediate_client_effects: list[~bacommon.clienteffect.Effect] = <factory>, immediate_local_action: str | None = None, immediate_local_action_args: dict | None = None)[source]¶
Bases:
ActionBrowse to a new page in a new window.
- classmethod get_type_id() ActionTypeID[source]¶
Return the type-id for this subclass.
- immediate_local_action: str | None = None¶
Local action to run immediately when the button is pressed. Will be handled by
bauiv1lib.decui.DecUIController.local_action().
- class bacommon.decui.v1.Button(label: str | None = None, action: Action | None = None, size: tuple[float, float] | None = None, color: tuple[float, float, float, float] | None = None, label_color: tuple[float, float, float, float] | None = None, label_flatness: float | None = None, label_scale: float | None = None, label_is_lstr: bool = False, 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[Decoration] | None = None, style: ButtonStyle = ButtonStyle.SQUARE, default: bool = False, selected: bool = False, icon: str | None = None, icon_scale: float | None = None, icon_color: tuple[float, float, float, float] | None = None, depth_range: tuple[float, float] | None = None, debug: bool = False)[source]¶
Bases:
objectA button in our cloud ui.
Note that size, padding, and all decorations are scaled consistently with ‘scale’.
- decorations: list[Decoration] | None = None¶
- label: str | None = None¶
Note that dec-ui accepts only raw
strvalues for text; usebabase.Lstr.evaluate()or whatnot for multi-language support.
- style: ButtonStyle = 'q'¶
- class bacommon.decui.v1.ButtonRow(buttons: list[Button], header_height: float = 0.0, header_scale: float = 1.0, header_decorations_left: list[Decoration] | None = None, header_decorations_center: list[Decoration] | None = None, header_decorations_right: list[Decoration] | None = None, title: str | None = None, title_color: tuple[float, float, float, float] | None = None, title_flatness: float | None = None, title_shadow: float | None = None, title_is_lstr: bool = False, subtitle: str | None = None, subtitle_color: tuple[float, float, float, float] | None = None, subtitle_flatness: float | None = None, subtitle_shadow: float | None = None, subtitle_is_lstr: bool = False, 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:
RowA row consisting of buttons.
- debug: bool = False¶
Draw bounds of the overall row and individual button columns (including padding). The UI will scroll to keep these areas visible in their entirety when changing selection via directional controls, so try to make sure all decorations for a button are within these bounds.
- header_decorations_center: list[Decoration] | None = None¶
- header_decorations_left: list[Decoration] | None = None¶
- header_decorations_right: list[Decoration] | None = None¶
- title: str | None = None¶
Note that dec-ui accepts only raw
strvalues for text; usebabase.Lstr.evaluate()or whatnot for multi-language support.
- class bacommon.decui.v1.ButtonStyle(*values)[source]¶
Bases:
EnumStyles a button can be.
- LARGE = 'l'¶
- LARGER = 'xl'¶
- MEDIUM = 'm'¶
- SMALL = 's'¶
- SQUARE = 'q'¶
- TAB = 't'¶
- class bacommon.decui.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.decui.v1.DecorationTypeID(*values)[source]¶
Bases:
EnumType ID for each of our subclasses.
- DISPLAY_ITEM = 'd'¶
- IMAGE = 'i'¶
- TEXT = 't'¶
- UNKNOWN = 'u'¶
- class bacommon.decui.v1.DisplayItem(wrapper: Wrapper, position: tuple[float, float], size: tuple[float, float], style: DisplayItemStyle = DisplayItemStyle.FULL, text_color: tuple[float, float, float] | None = None, highlight: bool = True, depth_range: tuple[float, float] | None = None, debug: bool = False)[source]¶
Bases:
DecorationDisplayItem decoration.
- classmethod get_type_id() DecorationTypeID[source]¶
Return the type-id for this subclass.
- style: DisplayItemStyle = 'f'¶
- wrapper: Wrapper¶
- class bacommon.decui.v1.DisplayItemStyle(*values)[source]¶
Bases:
EnumStyles a display-item can be drawn in.
- COMPACT = 'c'¶
- FULL = 'f'¶
- class bacommon.decui.v1.HAlign(*values)[source]¶
Bases:
EnumHorizontal alignment.
- CENTER = 'c'¶
- LEFT = 'l'¶
- RIGHT = 'r'¶
- class bacommon.decui.v1.Image(texture: str, position: tuple[float, float], size: tuple[float, float], color: tuple[float, float, float, 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, highlight: bool = True, depth_range: tuple[float, float] | None = None)[source]¶
Bases:
DecorationImage decoration.
- classmethod get_type_id() DecorationTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.decui.v1.Local(close_window: bool = False, default_sound: bool = True, immediate_client_effects: list[~bacommon.clienteffect.Effect] = <factory>, immediate_local_action: str | None = None, immediate_local_action_args: dict | None = None)[source]¶
Bases:
ActionPerform only local actions; no new requests or page changes.
- default_sound: bool = True¶
Plays a swish if closing the window or a click if triggered by a button press.
- classmethod get_type_id() ActionTypeID[source]¶
Return the type-id for this subclass.
- immediate_local_action: str | None = None¶
Local action to run immediately when the button is pressed. Will be handled by
bauiv1lib.decui.DecUIController.local_action().
- class bacommon.decui.v1.Page(title: str, rows: list[Row], center_vertically: bool = False, row_spacing: float = 10.0, simple_culling_v: float = 100.0, title_is_lstr: bool = False, padding_bottom: float = 0.0, padding_left: float = 0.0, padding_top: float = 0.0, padding_right: float = 0.0)[source]¶
Bases:
objectDec-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.
- title: str¶
Note that dec-ui accepts only raw
strvalues for text; usebabase.Lstr.evaluate()or whatnot for multi-language support.
- class bacommon.decui.v1.Replace(request: ~bacommon.decui.v1.Request, default_sound: bool = True, immediate_client_effects: list[~bacommon.clienteffect.Effect] = <factory>, immediate_local_action: str | None = None, immediate_local_action_args: dict | None = None)[source]¶
Bases:
ActionReplace current page with a new one.
Should be used to effectively ‘modify’ existing UIs by replacing them with something slightly different. Things like scroll position and selection will be carried across to the new layout when possible to make for a seamless transition.
- classmethod get_type_id() ActionTypeID[source]¶
Return the type-id for this subclass.
- immediate_local_action: str | None = None¶
Local action to run immediately when the button is pressed. Will be handled by
bauiv1lib.decui.DecUIController.local_action().
- class bacommon.decui.v1.Request(path: str, method: ~bacommon.decui.v1.RequestMethod = RequestMethod.GET, args: dict = <factory>)[source]¶
Bases:
DecUIRequestFull request to dec-ui.
- classmethod get_type_id() DecUIRequestTypeID[source]¶
Return the type-id for this subclass.
- method: RequestMethod = 'g'¶
- class bacommon.decui.v1.RequestMethod(*values)[source]¶
Bases:
EnumTypeof of requests that can be made to dec-ui servers.
- GET = 'g'¶
Fetch some resource. This can be retried and its results can optionally be cached for some amount of time.
- POST = 'p'¶
Change some resource. This cannot be implicitly retried (at least without deduplication), nor can it be cached.
- UNKNOWN = 'u'¶
An unknown request method. This can appear if a newer client is requesting some method from an older server that is not known to the server.
- class bacommon.decui.v1.Response(page: ~bacommon.decui.v1.Page, status: ~bacommon.decui.v1.StatusCode = StatusCode.SUCCESS, client_effects: list[~bacommon.clienteffect.Effect] = <factory>, local_action: str | None = None, local_action_args: dict | None = None, timed_action: ~bacommon.decui.v1.Action | None = None, timed_action_delay: float = 0.0, minimum_engine_build: int | None = None, shared_state_id: str | None = None)[source]¶
Bases:
DecUIResponseFull decui response.
- classmethod get_type_id() DecUIResponseTypeID[source]¶
Return the type-id for this subclass.
- local_action: str | None = None¶
Local action to run after this response is initially received. Will be handled by
bauiv1lib.decui.DecUIController.local_action(). Note that these actions will not re-run if the page is automatically refreshed later (due to window resizing, back navigation, etc).
- minimum_engine_build: int | None = None¶
If provided, error on builds older than this (can be used to gate functionality without bumping entire decui version).
The client maintains some persistent state (such as widget selection) for all pages viewed. The default index for these states is the path of the request. If a server returns a significant variety of responses for a single path, however, (based on args, etc) then it may make sense for the server to provide explicit state ids for those different variations.
- status: StatusCode = 0¶
- class bacommon.decui.v1.Row[source]¶
Bases:
IOMultiType[RowTypeID]Top level class for our multitype.
- classmethod get_type(type_id: RowTypeID) type[Row][source]¶
Return the subclass for each of our type-ids.
- 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.
- class bacommon.decui.v1.RowTypeID(*values)[source]¶
Bases:
EnumType ID for each of our subclasses.
- BUTTON_ROW = 'b'¶
- UNKNOWN = 'u'¶
- class bacommon.decui.v1.StatusCode(*values)[source]¶
Bases:
EnumThe overall result of a request.
- SUCCESS = 0¶
- UNKNOWN_ERROR = 1¶
- class bacommon.decui.v1.Text(text: str, position: tuple[float, float], size: tuple[float, float], scale: float = 1.0, h_align: HAlign = HAlign.CENTER, v_align: VAlign = VAlign.CENTER, color: tuple[float, float, float, float] | None = None, flatness: float | None = None, shadow: float | None = None, is_lstr: bool = False, highlight: bool = True, depth_range: tuple[float, float] | None = None, debug: bool = False)[source]¶
Bases:
DecorationText decoration.
- classmethod get_type_id() DecorationTypeID[source]¶
Return the type-id for this subclass.
- text: str¶
Note that dec-ui accepts only raw
strvalues for text; usebabase.Lstr.evaluate()or whatnot for multi-language support.
- class bacommon.decui.v1.UnknownAction[source]¶
Bases:
ActionAction type we don’t recognize.
- classmethod get_type_id() ActionTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.decui.v1.UnknownDecoration[source]¶
Bases:
DecorationAn 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.