bauiv1lib package

Library of stuff using the bauiv1 api: windows, custom controls, etc.

Subpackages

Submodules

bauiv1lib.achievements module

Provides a popup window to view achievements.

class bauiv1lib.achievements.AchievementsWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None, auxiliary_style: bool = True)[source]

Bases: MainWindow

Popup window to view achievements.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.appinvite module

UI functionality related to inviting people to try the game.

class bauiv1lib.appinvite.ShowFriendCodeWindow(data: dict[str, Any])[source]

Bases: Window

Window showing a code for sharing with friends.

close() → None[source]

Close the window.

bauiv1lib.appinvite.handle_app_invites_press() → None[source]

(internal)

bauiv1lib.characterpicker module

Provides a picker for characters.

class bauiv1lib.characterpicker.CharacterPicker(parent: Widget, position: tuple[float, float] = (0.0, 0.0), delegate: CharacterPickerDelegate | None = None, scale: float | None = None, offset: tuple[float, float] = (0.0, 0.0), tint_color: Sequence[float] = (1.0, 1.0, 1.0), tint2_color: Sequence[float] = (1.0, 1.0, 1.0), selected_character: str | None = None)[source]

Bases: PopupWindow

Popup window for selecting characters.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

class bauiv1lib.characterpicker.CharacterPickerDelegate[source]

Bases: object

Delegate for character-picker.

on_character_picker_get_more_press() → None[source]

Called when the ‘get more characters’ button is pressed.

on_character_picker_pick(character: str) → None[source]

Called when a character is selected.

bauiv1lib.characterpreviewui module

The profile editor for a character being previewed.

Opened from the lobby of a character preview session (see baclassic._characterpreview): the cloud’s profile editor, aimed at the previewed character rather than at one of the player’s own profiles. Saving hands the edited character back to the session.

class bauiv1lib.characterpreviewui.CharacterPreviewUIController[source]

Bases: TypedDocUIController[Edit | Save, Saved]

DocUI setup for editing a previewed character’s profile.

fulfill_route(route: bacommon.docui.routes.classiccharacterpreview.AnyCharacterPreviewRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

fulfill_unrouted_request(request: bacommon.docui.v2.Request, error: str) → DocUIResponse[source]

Handle a request that maps to none of our routes.

The default shows error. Controllers fronting a server should generally forward the request as-is here instead; a server is free to grow pages (or arg values) that older clients have no routes for, and those should keep working.

classmethod get_local_action_type() → type[CharacterPreviewLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[CharacterPreviewRoute][source]

Return the family class for the routes we handle.

run_local_action(action: bacommon.docui.routes.classiccharacterpreview.AnyCharacterPreviewLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

bauiv1lib.characterpreviewui.show_character_preview_editor(preview_id: str) → None[source]

Open the profile editor for a previewed character.

For a preview session’s lobby, which runs with no main window up.

bauiv1lib.chestui module

The doc-ui based chest window.

class bauiv1lib.chestui.ChestUIController[source]

Bases: TypedDocUIController[Root | Open | AdWatched, WatchAd | StopReminding | GetTokens]

DocUI setup for a chest slot.

fulfill_route(route: bacommon.docui.routes.classicchest.AnyChestRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

fulfill_unrouted_request(request: bacommon.docui.v2.Request, error: str) → DocUIResponse[source]

Handle a request that maps to none of our routes.

The default shows error. Controllers fronting a server should generally forward the request as-is here instead; a server is free to grow pages (or arg values) that older clients have no routes for, and those should keep working.

classmethod get_local_action_type() → type[ChestLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[ChestRoute][source]

Return the family class for the routes we handle.

run_local_action(action: bacommon.docui.routes.classicchest.AnyChestLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

bauiv1lib.chestui.HIGHLIGHT_TOKEN_PURCHASES_CONFIG_KEY = 'Highlight Potential Token Purchases'

Config key for whether to remind about opening chests early.

bauiv1lib.chestui.show_chest_window(slot: int, origin_widget: Widget | None = None) → None[source]

Pop up a chest slot’s window wherever we are in the nav stack.

bauiv1lib.chestui.slot_route(slot: int) → Root[source]

The root route for a chest slot, with what only we can know.

bauiv1lib.colorpicker module

Provides popup windows for choosing colors.

class bauiv1lib.colorpicker.ColorPicker(parent: Widget, position: tuple[float, float], *, initial_color: Sequence[float] = (1.0, 1.0, 1.0), delegate: Any = None, scale: float | None = None, offset: tuple[float, float] = (0.0, 0.0), tag: Any = '')[source]

Bases: PopupWindow

A popup UI to select from a set of colors.

Passes the color to the delegate’s color_picker_selected_color() method.

get_tag() → Any[source]

Return this popup’s tag.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

class bauiv1lib.colorpicker.ColorPickerExact(parent: Widget, position: tuple[float, float], *, initial_color: Sequence[float] = (1.0, 1.0, 1.0), delegate: Any = None, scale: float | None = None, offset: tuple[float, float] = (0.0, 0.0), tag: Any = '')[source]

Bases: PopupWindow

pops up a ui to select from a set of colors. passes the color to the delegate’s color_picker_selected_color() method

get_tag() → Any[source]

Return this popup’s tag value.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.colorpicker.color_overlay_func(r: float, g: float, b: float, a: float | None = None) → tuple[float, ...][source]

I could NOT come up with a better function name.

Parameters:
  • r – Red.

  • g – Green.

  • b – Blue.

  • a – Alpha. Defaults to None.

Returns:

A brighter color if the provided one is dark,

and a darker one if it’s darker.

Return type:

tuple

bauiv1lib.colorpicker.color_to_hex(r: float, g: float, b: float, a: float | None = 1.0) → str[source]

Converts an rgb1 tuple to a HEX color code.

Parameters:
  • r – Red.

  • g – Green.

  • b – Blue.

  • a – Alpha. Defaults to 1.0.

Returns:

The hexified rgba values.

Return type:

str

bauiv1lib.colorpicker.hex_to_color(hex_color: str) → tuple[source]

Transforms an RGB / RGBA hex code into an rgb1/rgba1 tuple.

Parameters:

hex_color (str) – The HEX color.

Raises:

ValueError – If the provided HEX color isn’t 6 or 8 characters long.

Returns:

The color tuple divided by 255.

Return type:

tuple

bauiv1lib.config module

Functionality for editing config values and applying them to the game.

bauiv1lib.config.CONTROL_HEIGHT = 28.0

Height of a row’s editing widgets.

bauiv1lib.config.CONTROL_X_OFFSET = 230.0

Where a control’s editing widgets begin, measured from the row’s position. Shared so a row keeps its layout when its control is swapped for a different kind.

class bauiv1lib.config.ConfigCheckBox(parent: Widget, configkey: str, position: tuple[float, float], size: tuple[float, float], *, displayname: str | Lstr | LangStr | None = None, scale: float | None = None, maxwidth: float | None = None, autoselect: bool = True, value_change_call: Callable[[Any], Any] | None = None, check_box_id: str | None = None, style: Literal['default', 'right'] | None = None)[source]

Bases: object

A checkbox wired up to control a config value.

It will automatically save and apply the config when its value changes.

widget: Widget

The underlying bui.Widget instance.

class bauiv1lib.config.ConfigNumberEdit(parent: Widget, configkey: str, position: tuple[float, float], *, minval: float = 0.0, maxval: float = 100.0, increment: float = 1.0, callback: Callable[[float], Any] | None = None, xoffset: float = 0.0, displayname: str | Lstr | LangStr | None = None, changesound: bool = True, textscale: float = 1.0, as_percent: bool = False, fallback_value: float = 0.0, f: int = 1, idprefix: str | None = None)[source]

Bases: _NumericConfigControl

A set of controls for editing a numeric config value.

It will automatically save and apply the config when its value changes.

minusbutton: Widget

The button widget used to reduce the value.

plusbutton: Widget

The button widget used to increase the value.

class bauiv1lib.config.ConfigSlider(parent: Widget, configkey: str, position: tuple[float, float], *, minval: float = 0.0, maxval: float = 100.0, increment: float = 1.0, callback: Callable[[float], Any] | None = None, xoffset: float = 0.0, width: float = 200.0, displayname: str | Lstr | LangStr | None = None, textscale: float = 1.0, as_percent: bool = False, fallback_value: float = 0.0, f: int = 1, idprefix: str | None = None, drag_apply_interval: float = 0.25, drag_apply_delay: float = 0.0)[source]

Bases: _NumericConfigControl

A slider for editing a numeric config value.

Same config behavior as ConfigNumberEdit – it reads the value at construction and saves and applies it on change – but driven by a draggable slider rather than a +/- pair. It begins where that pair does, so swapping one for the other leaves the rest of a settings row where it was.

slider: Widget

The underlying slider bui.Widget instance.

bauiv1lib.config.DRAG_APPLY_INTERVAL = 0.25

Default for how often a drag in progress applies its value to the running app. Paced for what accompanies an apply – a sound, a music level shifting – rather than for the cost of the apply itself; those read as busy well before they become expensive. Note this throttles only the apply: whatever a control refreshes cheaply per drag step (its value text, say) is not on this clock. A row wanting a different pace passes its own drag_apply_interval – slower where an apply is audible, faster where it drives something visible on screen.

bauiv1lib.confirm module

Provides ConfirmWindow base class and commonly used derivatives.

class bauiv1lib.confirm.ConfirmWindow(text: str | Lstr | LangStr | None = None, action: Callable[[], Any] | None = None, width: float = 360.0, height: float = 100.0, *, cancel_button: bool = True, cancel_is_selected: bool = False, color: tuple[float, float, float] = (1, 1, 1), text_scale: float = 1.0, ok_text: str | Lstr | LangStr | None = None, cancel_text: str | Lstr | LangStr | None = None, origin_widget: Widget | None = None, permanent_ok_fade: bool = False, scale: float | None = None)[source]

Bases: object

Window for answering simple yes/no questions.

class bauiv1lib.confirm.QuitWindow(quit_type: QuitType | None = None, swish: bool = False, origin_widget: Widget | None = None)[source]

Bases: object

Popup window to confirm quitting.

bauiv1lib.connect module

UI functionality related to master-server connectivity.

class bauiv1lib.connect.ConnectWindow[source]

Bases: Window

Window for preparing to connect to a game.

Shows progress while wrangling credentials, asks for password, or anything else necessary to prepare for a connection.

bauiv1lib.connectivity module

UI functionality related to master-server connectivity.

class bauiv1lib.connectivity.WaitForConnectivityWindow(on_connected: Callable[[], Any], on_cancel: Callable[[], Any] | None)[source]

Bases: Window

Window informing the user that the game is establishing connectivity.

bauiv1lib.connectivity.wait_for_connectivity(on_connected: Callable[[], Any], on_cancel: Callable[[], Any] | None = None) → None[source]

Wait for the engine to establish a master-server connection.

If need be, shows a window to keep the user informed of connectivity state and allows the user to cancel the operation. Note that canceling does not prevent the engine from continuing its attempt to establish connectivity; it simply cancels the operation that is waiting for connectivity.

bauiv1lib.controlpermission module

Asking whether an outside party may control this app.

class bauiv1lib.controlpermission.ControlPermissionWindow(*, on_result: Callable[[bool, bool], None], allow_remember: bool)[source]

Bases: object

Puts a request to control this app in front of the user.

Answers exactly once, whatever happens to the window: dismissing it counts as a refusal, because ‘they walked away’ and ‘they said no’ should not lead to different amounts of access.

bauiv1lib.credits module

Provides a window to display game credits.

class bauiv1lib.credits.CreditsWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

Window for displaying game credits.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.discord module

UI functionality for the Discord window.

class bauiv1lib.discord.DiscordWindow(transition: str = 'in_right', origin_widget: Widget | None = None)[source]

Bases: Window

Window for joining the Discord.

bauiv1lib.docuitest module

Examples/tests for using DocUI to build UIs.

class bauiv1lib.docuitest.TestDocUIV2Controller[source]

Bases: TypedDocUIController[Root | Test2 | Slow | TimedActions | DisplayItems | TextImages | LiveTimes | TextWrapping | Animation | Depictions | Viewers | Names | NinePatch | EmptyPage | BoundsTests | Widgets | NavTest | Sections | ButtonGrids | WindowLayouts | WideFit | WebTestGet | WebTestPost | CloudMsgTestGet | CloudMsgTestPost, TestAction | ShowVolume]

Tests/demonstrations of native (v2 / l-string) docui.

Local pages are authored client-side; the web-test and cloud-msg-test routes fetch equivalent v2 pages from bamaster.

fulfill_route(route: bacommon.docui.routes.docuitest.AnyTestRoute) → DocUIResponse[source]

Fulfill a route (called in a background thread).

classmethod get_local_action_type() → type[bacommon.docui.routes.docuitest.TestLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[bacommon.docui.routes.docuitest.TestRoute][source]

Return the family class for the routes we handle.

run_local_action(action: bacommon.docui.routes.docuitest.AnyTestLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

bauiv1lib.docuitest.show_test_doc_ui_v2_window() → None[source]

Bust out a doc-ui test window built locally on the client.

Test pages authored as language-agnostic v2 documents — text as LangStrSpec values from the badocuiv2testassets package (decoded in the client’s locale at render time), textures/meshes as typed refs, and multi-line labels via wrap-params instead of hand-baked newlines. The Cloud-Msg and Web buttons fetch equivalent v2 pages from bamaster, keeping the full cloud/web resolve -> decode -> render paths exercised.

bauiv1lib.docuitestanimation module

The doc-ui animation test page.

Decorations carrying an anim_id animated by bacommon.clienteffect.KeyframeAnimation effects: a box shakes with growing amplitude while shrinking (step keys, like the chest open), then pops back; a label fades and grows in (linear keys). The effects run when the page arrives and again on ‘Replay’.

bauiv1lib.docuitestanimation.test_page_animation() → bacommon.docui.v2.Response[source]

Testing keyframe animation of decorations.

bauiv1lib.docuitestdepictions module

The doc-ui depictions test page.

Shows each depiction kind as a bacommon.docui.v2.Depiction decoration on a button, then on a disabled button, then fitted into boxes of other shapes and alignments. Hovering, pressing, and selecting the buttons exercises how depictions follow their button’s emphasis; the disabled row, the standard disabled look. The precise-fit rows check the fit exactly: a flat white depiction of a known shape, with a half-black image laid over where it should land (computed here, independently of the native fit), so a correct fit is a plain grey rect and any offset shows as a white or dark fringe. The button-body rows do the same with the white shape as the button’s own body (its depiction).

Characters come from the classic character package’s wrapper (built from its .bchar files), the way game code gets them; names are plain text.

bauiv1lib.docuitestdepictions.test_page_depictions(route: bacommon.docui.routes.docuitest.Depictions) → bacommon.docui.v2.Response[source]

Testing depictions.

bauiv1lib.docuitestgrids module

The doc-ui button grids test page.

meta private:

bauiv1lib.docuitestitems module

The doc-ui display-items test page.

A display-item stays what it always was – show this thing in this style. It turns into plain doc-ui decorations (bacommon.displayitem.DisplayItem.decorations) rather than being derived client-side from the item type. This page is a renderer regression check – every item type and style, drawable with no server and no account.

bauiv1lib.docuitestitems.test_page_display_items(route: bacommon.docui.routes.docuitest.DisplayItems) → bacommon.docui.v2.Response[source]

Testing display-items (v2 mirror of ‘/displayitems’).

bauiv1lib.docuitestlayouts module

Doc-ui test page for judging window layouts.

The root test page browses here at each bacommon.docui.v2.WindowLayout; the page itself is the same either way. It carries the things layouts stress: control rows (label to value distance), titles and short button rows at every alignment, and long rows, which in a narrow column scroll within it.

bauiv1lib.docuitestlayouts.test_page_bounds() → bacommon.docui.v2.Response[source]

Button-style bounds tests (v2 mirror of ‘/boundstests’).

bauiv1lib.docuitestlayouts.test_page_window_layouts(route: bacommon.docui.routes.docuitest.WindowLayouts) → bacommon.docui.v2.Response[source]

Assorted rows for eyeballing a window layout.

bauiv1lib.docuitestlivetimes module

The doc-ui live-times test page.

Text holding a moment in time (bacommon.langstr.LangStrSpecTimeTarget) re-renders itself as time passes: each widget re-evaluates exactly when its visible text is due to change, so a seconds countdown ticks once a second, one showing milliseconds every frame, and one showing only minutes once a minute. Nothing on this page asks the server (or Python) for updates.

Every moment is a fixed offset from when the page was built; the restart button rebuilds it.

bauiv1lib.docuitestlivetimes.test_page_live_times(route: bacommon.docui.routes.docuitest.LiveTimes) → bacommon.docui.v2.Response[source]

Testing time-varying text.

bauiv1lib.docuitestnames module

The doc-ui names test page.

Name depictions in their two forms – basic (colored text) and capsule (text in a rounded capsule, optionally with an icon covering its left end) – fitted into boxes of various shapes and alignments. Builtin circle textures stand in for real capsule and icon art. With debug on, each depiction shows its box (red) and the box it reports covering (blue; what a hit-tested button takes presses over): a capsule’s body should exactly fill the blue box, glow aside.

bauiv1lib.docuitestnames.test_page_names(route: bacommon.docui.routes.docuitest.Names) → bacommon.docui.v2.Response[source]

Testing name depictions.

bauiv1lib.docuitestnav module

Doc-ui test page for navigation between control rows.

bauiv1lib.docuitestnav.test_page_nav(route: bacommon.docui.routes.docuitest.NavTest) → bacommon.docui.v2.Response[source]

A button row, then one control row of the route’s kind, last.

bauiv1lib.docuitestninepatch module

The doc-ui 9-patch test page.

Images drawn as 9-patches (bacommon.docui.v2.ImageNinePatch): striped capsule art whose middle half either stretches or repeats at its ends’ scale (tile-fit), optionally tinted three colors through an rgb tint texture. A 9-patch fills its image’s box exactly, so with debug on each image’s outline (its box) should sit right on the capsule’s edge, with no gap or overhang anywhere.

bauiv1lib.docuitestninepatch.test_page_nine_patch(route: bacommon.docui.routes.docuitest.NinePatch) → bacommon.docui.v2.Response[source]

Testing 9-patch images.

bauiv1lib.docuitestsections module

The doc-ui sections test page.

meta private:

bauiv1lib.docuitestsimple module

Small doc-ui test pages (navigation, slow loads, timed actions).

bauiv1lib.docuitestsimple.test_page_2() → bacommon.docui.v2.Response[source]

More testing (v2 mirror of the v1 ‘/test2’ page).

bauiv1lib.docuitestsimple.test_page_empty() → bacommon.docui.v2.Response[source]

An empty page (v2 mirror of ‘/emptypage’).

bauiv1lib.docuitestsimple.test_page_long() → bacommon.docui.v2.Response[source]

Testing a page that takes a bit of time to load (v2 mirror).

bauiv1lib.docuitestsimple.test_page_timed_actions(route: bacommon.docui.routes.docuitest.TimedActions) → bacommon.docui.v2.Response[source]

Testing timed actions (v2 mirror of ‘/timedactions’).

bauiv1lib.docuitesttextimages module

The doc-ui text-images test page.

A text can carry an image at either end (bacommon.docui.v2.Text.image_left / image_right); the client measures the text and its images as one unit, shrinks that to fit the text’s size box, and aligns it there. This page exercises each part.

The first row’s composition is deliberately far too big for the boxes it is given, so fitting has to both scale and center for it to land – one that already fitted would prove nothing. The debug toggle draws each text’s size box.

bauiv1lib.docuitesttextimages.test_page_text_images(route: bacommon.docui.routes.docuitest.TextImages) → bacommon.docui.v2.Response[source]

Testing text with images fixed to its ends.

bauiv1lib.docuitesttextwrap module

The doc-ui text-wrapping test page.

Row and section titles, subtitles and footnotes word-wrap to their columns: in background prep each is evaluated (ignoring the string’s own wrap hints) and wrapped with the engine’s own text measure at the width and scale its text widget gets, so every line fits and nothing shrinks to fit. Lines break only where the OS’s line-break rules allow, and each line fills as far as it will go before the next starts (so only the last runs short). With debug on, each row’s outline shows its column; text should reach close to its right edge but never past it, and rows grow taller to fit their wrapped text.

The live-time row is the one deliberate exception: time-varying text can’t be wrapped once up front, so its subtitle stays a single line (squished to fit, as unwrapped text always was) and the client logs one ba.ui warning about it.

bauiv1lib.docuitesttextwrap.test_page_text_wrapping(route: bacommon.docui.routes.docuitest.TextWrapping) → bacommon.docui.v2.Response[source]

Testing word-wrapped titles, subtitles and footnotes.

bauiv1lib.docuitestviewers module

Doc-ui test page for live viewers (the page’s viewer pane).

Shows one case at a time in the pane: viewers that should work, empty panes (and no pane at all), and bad data that should show the broken-depiction placeholder (an outlined box with a question mark) and log why, rather than a blank pane. The page’s controls switch the case and the pane’s frame style, background and side in place.

bauiv1lib.docuitestviewers.test_page_viewers(route: bacommon.docui.routes.docuitest.Viewers) → bacommon.docui.v2.Response[source]

Live viewer tests.

bauiv1lib.docuitestwidgets module

Doc-ui test page for control rows and page state.

bauiv1lib.docuitestwidgets.test_page_widgets(route: bacommon.docui.routes.docuitest.Widgets) → bacommon.docui.v2.Response[source]

Control rows, plus a readout of the state each request carried.

bauiv1lib.fileselector module

UI functionality for selecting files.

class bauiv1lib.fileselector.FileSelectorWindow(path: str, callback: Callable[[str | None], Any] | None = None, *, show_base_path: bool = True, valid_file_extensions: Sequence[str] | None = None, allow_folders: bool = False, transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

Window for selecting files.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.getremote module

Provides a popup telling the user about the BSRemote app.

class bauiv1lib.getremote.GetBSRemoteWindow[source]

Bases: PopupWindow

Popup telling the user about BSRemote app.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.gettokens module

UI functionality for purchasing/acquiring currency.

class bauiv1lib.gettokens.GetTokensWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None, auxiliary_style: bool = True)[source]

Bases: MainWindow

Window for purchasing/acquiring classic tickets.

class State(*values)[source]

Bases: Enum

What are we doing?

HAVE_GOLD_PASS = 'have_gold_pass'
LOADING = 'loading'
NOT_SIGNED_IN = 'not_signed_in'
SHOWING_STORE = 'showing_store'
get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

class bauiv1lib.gettokens.TextContents(*values)[source]

Bases: Enum

Some type of text to show.

PRICE = 'price'
bauiv1lib.gettokens.show_get_tokens_prompt(origin_widget: Widget | None = None) → None[source]

Show a ‘not enough tokens’ prompt with an option to purchase more.

Note that the purchase option may not always be available depending on the build of the game.

bauiv1lib.gettokens.show_get_tokens_window(origin_widget: Widget | None = None, toggle: bool = False) → None[source]

Transition to the get-tokens main-window from anywhere.

bauiv1lib.help module

Provides help related ui.

class bauiv1lib.help.HelpWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

A window providing help on how to play.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.hostdocui module

Doc-ui windows showing pages a game host serves (host doc-ui).

A host’s pages arrive over the game connection and the host is untrusted, so before showing one we refuse references outside the host’s package universe, drop client-effects untrusted sources may not run, and drop local-actions entirely. Our own pages (when we’re the host) skip all that. Design: docs/initiatives/host-docui.md.

class bauiv1lib.hostdocui.HostDocUIController[source]

Bases: DocUIController

Fulfills requests for host-served pages.

Our own pages (when we’re the host) arrive as response objects and are trusted; a host’s arrive encoded, and get decoded and vetted here.

fulfill_request(request: DocUIRequest) → DocUIResponse[source]

Handle request fulfillment.

Expected to be overridden by child classes.

Be aware that this will always be called in a background thread.

This method is expected to always return a response, even in the case of errors. Use error_response() to translate error conditions to responses.

The one exception to this rule (no pun intended) is the efro.error.CleanError exception. This can be raised as a quick and dirty way to show custom error messages. The code raise CleanError('Something broke.') will have the same effect as return self.error_response(custom_message='Something broke.').

get_cache_key_extra() → str | None[source]

Extra identity for response caching.

Cached responses are keyed by controller class, request, account and locale. A controller whose instance state changes what it returns for a given request must declare that state here; otherwise two instances differing in it share one cache entry and briefly show each other’s pages.

Return None to opt out of caching entirely, which is the right answer when a response depends on state that cannot be summarized as a string.

get_window_toolbar_visibility() → Literal['menu_full', 'menu_minimal'][source]

Which toolbar our windows show.

Everything by default. Settings-style pages reachable mid-game typically return 'menu_minimal' unless bauiv1.in_main_menu(), as the classic settings windows do.

bauiv1lib.hostdocui.REQUEST_TIMEOUT = 10.0

How long to wait for a host to answer (seconds). Doc-ui windows share only a couple of background workers, so a silent host must not hold one for long.

bauiv1lib.iconpicker module

Provides a picker for icons.

class bauiv1lib.iconpicker.IconPicker(parent: Widget, position: tuple[float, float] = (0.0, 0.0), delegate: IconPickerDelegate | None = None, scale: float | None = None, *, offset: tuple[float, float] = (0.0, 0.0), tint_color: Sequence[float] = (1.0, 1.0, 1.0), tint2_color: Sequence[float] = (1.0, 1.0, 1.0), selected_icon: str | None = None)[source]

Bases: PopupWindow

Picker for icons.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

class bauiv1lib.iconpicker.IconPickerDelegate[source]

Bases: object

Delegate for character-picker.

on_icon_picker_get_more_press() → None[source]

Called when the ‘get more characters’ button is pressed.

on_icon_picker_pick(icon: str) → None[source]

Called when a character is selected.

bauiv1lib.inboxui module

The doc-ui based inbox.

class bauiv1lib.inboxui.InboxUIController[source]

Bases: TypedDocUIController[Root | Respond, OpenUrl | TourneyScores]

DocUI setup for the inbox.

fulfill_route(route: bacommon.docui.routes.classicinbox.AnyInboxRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

fulfill_unrouted_request(request: bacommon.docui.v2.Request, error: str) → DocUIResponse[source]

Handle a request that maps to none of our routes.

The default shows error. Controllers fronting a server should generally forward the request as-is here instead; a server is free to grow pages (or arg values) that older clients have no routes for, and those should keep working.

classmethod get_local_action_type() → type[bacommon.docui.routes.classicinbox.InboxLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[bacommon.docui.routes.classicinbox.InboxRoute][source]

Return the family class for the routes we handle.

run_local_action(action: bacommon.docui.routes.classicinbox.AnyInboxLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

bauiv1lib.inboxui.show_inbox_window(origin_widget: Widget | None = None) → None[source]

Pop up the inbox wherever we are in the nav stack.

bauiv1lib.ingamemenu module

Implements the in-game menu window.

class bauiv1lib.ingamemenu.InGameMenuWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

The menu that can be invoked while in a game.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.inventory module

Provides help related ui.

class bauiv1lib.inventory.InventoryUIController(player_profiles_only: bool = False)[source]

Bases: TypedDocUIController[Root | Purchase | PurchaseConfirm | ProfileEdit | ProfileSave | ProfileDelete | ProfileDeleteConfirm | ProfileCharacter | ProfileIcon | ProfileGlobalUpgrade | ProfileGlobalUpgradeBuy | ProfileMigrate, NewProfile | EditProfile | SpawnBot | ShowLegacyProfiles | ShowCloudProfiles]

DocUI setup for inventory.

Player profiles come in two flavors here. Cloud profiles are stored on the v2 master server and the server renders their rows and editor into the inventory page itself. Legacy profiles are the local-config ones (synced via the v1 account); their rows are spliced in client-side so they work offline. We show cloud profiles by default and switch to legacy when the user asks (show_legacy_profiles) or when the cloud page can’t be fetched.

fulfill_route(route: bacommon.docui.routes.classicstore.AnyStoreRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

fulfill_unrouted_request(request: bacommon.docui.v2.Request, error: str) → DocUIResponse[source]

Handle a request that maps to none of our routes.

The default shows error. Controllers fronting a server should generally forward the request as-is here instead; a server is free to grow pages (or arg values) that older clients have no routes for, and those should keep working.

get_cache_key_extra() → str | None[source]

Extra identity for response caching.

Cached responses are keyed by controller class, request, account and locale. A controller whose instance state changes what it returns for a given request must declare that state here; otherwise two instances differing in it share one cache entry and briefly show each other’s pages.

Return None to opt out of caching entirely, which is the right answer when a response depends on state that cannot be summarized as a string.

classmethod get_local_action_type() → type[bacommon.docui.routes.classicstore.InventoryLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[bacommon.docui.routes.classicstore.StoreRoute][source]

Return the family class for the routes we handle.

restore_window_shared_state(window: DocUIWindow, state: dict) → None[source]

Called when a window shared state is being restored.

run_local_action(action: bacommon.docui.routes.classicstore.AnyInventoryLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

bauiv1lib.kiosk module

UI functionality for running the game in kiosk mode.

class bauiv1lib.kiosk.KioskWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

Kiosk mode window.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

on_main_window_close() → None[source]

Called before transitioning out a main window.

A good opportunity to save window state/etc.

bauiv1lib.mainmenu module

Implements the main menu window.

class bauiv1lib.mainmenu.MainMenuWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

The main menu window.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

get_play_button() → Widget | None[source]

Return the play button.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.meshviewer module

A viewer showing a few meshes, turning.

bauiv1lib.party module

Provides party related UI.

class bauiv1lib.party.PartyWindow(origin: Sequence[float] = (0, 0))[source]

Bases: Window

Party list/chat window.

close() → None[source]

Close the window.

close_with_sound() → None[source]

Close the window and make a lovely sound.

on_chat_message(msg: str) → None[source]

Called when a new chat message comes through.

popup_menu_closing(_popup_window: PopupWindow) → None[source]

Called when the popup is closing.

popup_menu_selected_choice(popup_window: PopupMenuWindow, choice: str) → None[source]

Called when a choice is selected in the popup.

bauiv1lib.partyqueue module

UI related to waiting in line for a party.

class bauiv1lib.partyqueue.PartyQueueWindow(queue_id: str, address: str, port: int)[source]

Bases: Window

Window showing players waiting to join a server.

class Dude(parent: PartyQueueWindow, distance: float, initial_offset: float, is_player: bool, account_id: str, name: str)[source]

Bases: object

Represents a single dude waiting in a server line.

boost(amount: float, smoothing: float) → None[source]

Boost this dude.

set_target_distance(dist: float) → None[source]

Set distance for a dude.

step(smoothing: float) → None[source]

Step this dude.

close() → None[source]

Close the ui.

get_line_bottom() → float[source]

(internal)

get_line_left() → float[source]

(internal)

get_line_width() → float[source]

(internal)

on_account_press(account_id: str | None, origin_widget: Widget) → None[source]

A dude was clicked so we should show his account info.

on_boost_press() → None[source]

Boost was pressed.

on_update_response(response: dict[str, Any] | None) → None[source]

We’ve received a response from an update to the server.

update() → None[source]

Update!

bauiv1lib.passwordprompt module

A minimal password-entry prompt dialog.

class bauiv1lib.passwordprompt.PasswordPromptWindow(*, description: str | Lstr | LangStr | None = None, on_result: Callable[[str | None], None] | None = None)[source]

Bases: object

Small modal overlay window prompting for a password.

Calls on_result exactly once: the entered password on submit or None on cancel (via the cancel button, back press, or an external dismiss()).

dismiss() → None[source]

Externally dismiss the prompt (counts as a cancel). Idempotent.

bauiv1lib.playdocui module

The top level play window, as a doc-ui page.

A client-local doc-ui domain: one centered row of big buttons leading to co-op (a legacy window) and the teams/free-for-all playlist browsers (bauiv1lib.playlist.browserdocui).

Also the first step of gather’s private-party playlist selection, in select mode: just the teams and free-for-all buttons, leading to the playlist browsers’ own select mode.

bauiv1lib.playdocui.AnyPlayLocalAction

alias of Open

bauiv1lib.playdocui.AnyPlayRoute

alias of Root

class bauiv1lib.playdocui.Open(target: Target, select: bool = False)[source]

Bases: PlayLocalAction

Go somewhere.

classmethod get_press_sound() → PressSound[source]

What a button plays when pressed to run this local-action.

Actions that stay on the page click (the default); override to return SWISH for ones that go somewhere (open a window or popup). A press whose action has default_sound off plays nothing either way.

select: bool = False
target: Target
class bauiv1lib.playdocui.PlayController[source]

Bases: TypedDocUIController[Root, Open]

Doc-ui controller for the play page.

fulfill_route(route: AnyPlayRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

classmethod get_local_action_type() → type[PlayLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[PlayRoute][source]

Return the family class for the routes we handle.

get_window_toolbar_visibility() → Literal['menu_full', 'menu_minimal'][source]

Which toolbar our windows show.

Everything by default. Settings-style pages reachable mid-game typically return 'menu_minimal' unless bauiv1.in_main_menu(), as the classic settings windows do.

run_local_action(action: AnyPlayLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

class bauiv1lib.playdocui.PlayLocalAction[source]

Bases: DocUILocalActionBase

Family class for the play local-actions.

classmethod get_action_types() → tuple[type[DocUILocalActionBase], ...][source]

Return all concrete local-actions in this family.

Must be overridden by each family class; see get_route_types().

class bauiv1lib.playdocui.PlayRoute[source]

Bases: DocUIRoute

Family class for the play routes.

classmethod get_route_types() → tuple[type[DocUIRoute], ...][source]

Return all concrete routes in this family.

Must be overridden by each family class. A family generally defines a union alias of its routes (which also gives handlers assert_never exhaustiveness) and returns family_members() of it here.

classmethod get_window_layout() → WindowLayout[source]

The layout windows browsing to this route open with.

browse() uses this unless told otherwise, so a route whose page is best shown at some layout declares it once rather than at every link.

Defaults to WIDE, which is the same size at every ui-scale, so a one-off page (a confirmation, a dialog) never ends up as a big mostly-empty window. LARGE, which grows to fill more of the screen at medium/large ui-scale, is for pages built to use that room (store listings and the like), and they ask for it explicitly.

class bauiv1lib.playdocui.PlaySelectController[source]

Bases: PlayController

The play page as the first step of picking a private-party playlist.

Open it at a Root route with select set. Its own class keeps these windows distinct from the play flow’s for navigation, and it shows a minimal toolbar (as the legacy select flow did): we’re mid-errand for the gather window.

get_window_toolbar_visibility() → Literal['menu_full', 'menu_minimal'][source]

Which toolbar our windows show.

Everything by default. Settings-style pages reachable mid-game typically return 'menu_minimal' unless bauiv1.in_main_menu(), as the classic settings windows do.

class bauiv1lib.playdocui.Root(select: bool = False)[source]

Bases: PlayRoute

The play page.

select: bool = False

Picking a playlist for private-party hosting instead of playing.

class bauiv1lib.playdocui.Target(*values)[source]

Bases: Enum

Where the page’s buttons lead.

COOP = 'coop'
FREE_FOR_ALL = 'ffa'
TEAMS = 'teams'

bauiv1lib.playoptions module

Provides a window for configuring play options.

class bauiv1lib.playoptions.PlayOptionsWindow(*, sessiontype: type[Session], playlist: str, scale_origin: tuple[float, float], delegate: Any = None, select_only: bool = False)[source]

Bases: PopupWindow

A popup window for configuring play options.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.popup module

Popup window/menu related functionality.

class bauiv1lib.popup.PopupMenu(parent: Widget, position: tuple[float, float], choices: Sequence[str], *, button_id: str | None = None, current_choice: str | None = None, on_value_change_call: Callable[[str], Any] | None = None, opening_call: Callable[[], Any] | None = None, closing_call: Callable[[], Any] | None = None, width: float = 100.0, maxwidth: float | None = None, scale: float | None = None, choices_disabled: Sequence[str] | None = None, choices_display: Sequence[Lstr | LangStr] | None = None, button_size: tuple[float, float] = (160.0, 50.0), autoselect: bool = True, transition_delay: float | None = None, transition_type: Literal['in_left', 'scale'] | None = None, better_bg_fit: bool = False)[source]

Bases: object

A complete popup-menu control.

This creates a button and wrangles its pop-up menu.

get_button() → Widget[source]

Return the menu’s button widget.

get_window_widget() → Widget | None[source]

Return the menu’s window widget (or None if nonexistent).

popup_menu_closing(popup_window: PopupWindow) → None[source]

Called when the menu is closing.

popup_menu_selected_choice(popup_window: PopupWindow, choice: str) → None[source]

Called when a choice is selected.

set_choice(choice: str) → None[source]

Set the selected choice.

class bauiv1lib.popup.PopupMenuWindow(position: tuple[float, float], choices: Sequence[str], current_choice: str | None, *, delegate: Any = None, width: float = 230.0, maxwidth: float | None = None, scale: float = 1.0, choices_disabled: Sequence[str] | None = None, choices_display: Sequence[Lstr | LangStr] | None = None)[source]

Bases: PopupWindow

A menu built using popup-window functionality.

Pass None for current_choice for a menu with no current value (a list of things to do rather than values to pick from): nothing is drawn as current and selection starts at the first pickable choice.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

class bauiv1lib.popup.PopupWindow(position: tuple[float, float], size: tuple[float, float], scale: float = 1.0, *, offset: tuple[float, float] = (0, 0), bg_color: tuple[float, float, float] = (0.35, 0.55, 0.15), focus_position: tuple[float, float] = (0, 0), focus_size: tuple[float, float] | None = None, toolbar_visibility: Literal['inherit', 'menu_minimal_no_back', 'menu_store_no_back'] = 'menu_minimal_no_back', edge_buffer_scale: float = 1.0, darken_behind: bool = True)[source]

Bases: object

A transient window that pops up from some position.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.popup.popup_menu_default_scale() → float[source]

Scale popup menus get at the current ui-scale unless told otherwise.

bauiv1lib.qrcode module

Provides functionality for displaying QR codes.

class bauiv1lib.qrcode.QRCodeWindow(origin_widget: Widget, qr_tex: Texture)[source]

Bases: PopupWindow

Popup window that shows a QR code.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.radiogroup module

UI functionality for creating radio groups of buttons.

bauiv1lib.radiogroup.make_radio_group(check_boxes: Sequence[Widget], value_names: Sequence[str], value: str, value_change_call: Callable[[str], Any]) → None[source]

Link the provided check_boxes together into a radio group.

bauiv1lib.report module

UI related to reporting bad behavior/etc.

class bauiv1lib.report.ReportPlayerWindow(account_id: str, origin_widget: Widget)[source]

Bases: Window

Player for reporting naughty players.

close() → None[source]

Close the window.

bauiv1lib.resourcetypeinfo module

Provides a window which shows info about resource types.

class bauiv1lib.resourcetypeinfo.ResourceTypeInfoWindow(resource_type: Literal['tickets', 'tokens', 'trophies', 'xp'], origin_widget: Widget)[source]

Bases: PopupWindow

Popup window providing info about resource types.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.sendinfo module

UI for sending info (codes and such) to the developer.

The send-info page (Advanced settings’ ‘Send Info’) is a client-local doc-ui domain: whatever gets typed goes to the master server, which handles promo codes itself and passes others (old-style codes, share codes) along to the v1 server. The legacy modal window here is only a base for the playlist-import window.

bauiv1lib.sendinfo.AnySendInfoLocalAction

alias of Submit

bauiv1lib.sendinfo.AnySendInfoRoute

alias of Root

class bauiv1lib.sendinfo.Root[source]

Bases: SendInfoRoute

The send-info page.

class bauiv1lib.sendinfo.SendInfoController[source]

Bases: TypedDocUIController[Root, Submit]

Doc-ui controller for the send-info page.

fulfill_route(route: AnySendInfoRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

classmethod get_local_action_type() → type[SendInfoLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[SendInfoRoute][source]

Return the family class for the routes we handle.

get_window_toolbar_visibility() → Literal['menu_full', 'menu_minimal'][source]

Which toolbar our windows show.

Everything by default. Settings-style pages reachable mid-game typically return 'menu_minimal' unless bauiv1.in_main_menu(), as the classic settings windows do.

run_local_action(action: AnySendInfoLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

class bauiv1lib.sendinfo.SendInfoLocalAction[source]

Bases: DocUILocalActionBase

Family class for the send-info local-actions.

classmethod get_action_types() → tuple[type[DocUILocalActionBase], ...][source]

Return all concrete local-actions in this family.

Must be overridden by each family class; see get_route_types().

class bauiv1lib.sendinfo.SendInfoRoute[source]

Bases: DocUIRoute

Family class for the send-info routes.

classmethod get_route_types() → tuple[type[DocUIRoute], ...][source]

Return all concrete routes in this family.

Must be overridden by each family class. A family generally defines a union alias of its routes (which also gives handlers assert_never exhaustiveness) and returns family_members() of it here.

classmethod get_window_layout() → WindowLayout[source]

The layout windows browsing to this route open with.

browse() uses this unless told otherwise, so a route whose page is best shown at some layout declares it once rather than at every link.

Defaults to WIDE, which is the same size at every ui-scale, so a one-off page (a confirmation, a dialog) never ends up as a big mostly-empty window. LARGE, which grows to fill more of the screen at medium/large ui-scale, is for pages built to use that room (store listings and the like), and they ask for it explicitly.

class bauiv1lib.sendinfo.SendInfoState(description: str = '')[source]

Bases: DocUIState

What’s been typed.

description: str = ''
class bauiv1lib.sendinfo.SendInfoWindowLegacyModal(transition: str | None = 'in_scale', origin_widget: Widget | None = None)[source]

Bases: Window

Window for sending info to the developer.

class bauiv1lib.sendinfo.Submit[source]

Bases: SendInfoLocalAction

Send what’s been typed, going back as it goes out.

bauiv1lib.serverdialog module

Dialog window controlled by the master server.

class bauiv1lib.serverdialog.ServerDialogData(dialog_id: str, text: str, subs: list[tuple[str, str]]=<factory>, show_cancel: bool = True, copy_text: str | None = None)[source]

Bases: object

Data for ServerDialog.

copy_text: str | None = None
dialog_id: str
show_cancel: bool = True
subs: list[tuple[str, str]]
text: str
class bauiv1lib.serverdialog.ServerDialogWindow(data: ServerDialogData)[source]

Bases: Window

A dialog window driven by the master-server.

bauiv1lib.store module

Shiny new doc-ui based store.

class bauiv1lib.store.StoreUIController[source]

Bases: TypedDocUIController[Root | Purchase | PurchaseConfirm | ProfileEdit | ProfileSave | ProfileDelete | ProfileDeleteConfirm | ProfileCharacter | ProfileIcon | ProfileGlobalUpgrade | ProfileGlobalUpgradeBuy | ProfileMigrate, GetTokens | RestorePurchases]

DocUI setup for store.

fulfill_route(route: bacommon.docui.routes.classicstore.AnyStoreRoute) → DocUIResponse[source]

Handle fulfillment for a route.

The type-safe equivalent of fulfill_request(); the same rules apply (called in a background thread; should always return a response).

fulfill_unrouted_request(request: bacommon.docui.v2.Request, error: str) → DocUIResponse[source]

Handle a request that maps to none of our routes.

The default shows error. Controllers fronting a server should generally forward the request as-is here instead; a server is free to grow pages (or arg values) that older clients have no routes for, and those should keep working.

classmethod get_local_action_type() → type[bacommon.docui.routes.classicstore.StoreLocalAction][source]

Return the family class for the local-actions we handle.

Domains with no local-actions can leave this as is and pass typing.Never as their local-action type arg.

classmethod get_route_type() → type[bacommon.docui.routes.classicstore.StoreRoute][source]

Return the family class for the routes we handle.

run_local_action(action: bacommon.docui.routes.classicstore.AnyStoreLocalAction, context: DocUILocalAction) → None[source]

Do something locally on behalf of the doc-ui.

The type-safe equivalent of local_action(); the same cautions apply. The original action is passed as context for access to the originating widget and window.

bauiv1lib.tabs module

UI functionality for creating tab style buttons.

class bauiv1lib.tabs.Tab(button: Widget, position: tuple[float, float], size: tuple[float, float])[source]

Bases: object

Info for an individual tab in a TabRow

button: Widget
position: tuple[float, float]
size: tuple[float, float]
class bauiv1lib.tabs.TabRow(parent: bui.Widget, tabdefs: Sequence[tuple[T, bui.Lstr | bui.LangStr]], pos: tuple[float, float], size: tuple[float, float], *, on_select_call: Callable[[T], None] | None = None, idprefix: str | None = None)[source]

Bases: Generic

Encapsulates a row of tab-styled buttons.

Tabs are indexed by id which is an arbitrary user-provided type.

tabs: dict[T, Tab]
update_appearance(selected_tab_id: T) → None[source]

Update appearances to make the provided tab appear selected.

bauiv1lib.teamnamescolors module

Provides a window to customize team names and colors.

class bauiv1lib.teamnamescolors.TeamNamesColorsWindow(scale_origin: tuple[float, float])[source]

Bases: PopupWindow

A popup window for customizing team names and colors.

color_picker_closing(picker: ColorPicker) → None[source]

Called when the color picker is closing.

color_picker_selected_color(picker: ColorPicker, color: Sequence[float]) → None[source]

Called when a color is selected in the color picker.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.template module

Useful starting points for new classes and whatnot.

class bauiv1lib.template.TemplateMainWindow(dummy_data: int, *, transition: str | None = 'in_right', origin_widget: Widget | None = None, auxiliary_style: bool = True)[source]

Bases: MainWindow

An example of a well-behaved main-window.

get_main_window_shared_state_id() → str | None[source]

Provide a custom id for window shared state.

Unlike MainWindowState, which is used to save and restore a single main-window instance, shared-state is intended to hold values that can apply to multiple instances of a window.

By default, shared state uses the window class as an index (so is shared by all windows of the same class), but this method can be overridden to provide more distinct states. For example, a store-page main-window class might want to keep distinct states for different sub-pages it can display instead of having a single state for the whole class.

Note that shared state only persists for the current run of the app.

get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).

bauiv1lib.template.show_template_main_window() → None[source]

Bust out a template-main-window.

bauiv1lib.tournamententry module

Defines a popup window for entering tournaments.

class bauiv1lib.tournamententry.TournamentEntryWindow(tournament_id: str, tournament_activity: bs.Activity | None = None, position: tuple[float, float] = (0.0, 0.0), delegate: Any = None, scale: float | None = None, offset: tuple[float, float] = (0.0, 0.0), on_close_call: Callable[[], Any] | None = None)[source]

Bases: PopupWindow

Popup window for entering tournaments.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.tournamentscores module

Provides a popup for viewing tournament scores.

class bauiv1lib.tournamentscores.TournamentScoresWindow(tournament_id: str, *, position: tuple[float, float] = (0.0, 0.0))[source]

Bases: PopupWindow

Window for viewing tournament scores.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.trophies module

Provides a popup window for viewing trophies.

class bauiv1lib.trophies.TrophiesWindow(position: tuple[float, float], data: dict[str, Any], scale: float | None = None)[source]

Bases: PopupWindow

Popup window for viewing trophies.

on_popup_cancel() → None[source]

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.

bauiv1lib.url module

UI functionality related to URLs.

class bauiv1lib.url.ShowURLWindow(address: str)[source]

Bases: Window

A window presenting a URL to the user visually.

bauiv1lib.utils module

Useful bits to use with UIs.

bauiv1lib.utils.TOOLBAR_SCROLL_FADE = 85.0

How far in from the top/bottom of a full-screen (small ui-scale) scroll area apply_toolbar_scroll_fades() fades content, in the scroll area’s local units. Calibrated against the toolbars, so it assumes the scroll area’s top and bottom sit at the virtual rect’s.

bauiv1lib.utils.apply_toolbar_scroll_fades(scrollwidget: Widget, *, top_fade: float = 85.0, bottom_fade: float = 85.0, left_fade: float = 0.0, right_fade: float = 0.0) → None[source]

Fade a full-screen scroll area’s content out toward the toolbars.

For scroll areas filling the screen at small ui-scale. Content fades into the window backing over top_fade/bottom_fade units in from the top/bottom (zero for none). The sides get nothing by default, as content just scrolls off the screen there; a scroll area with a side edge on screen instead (beside a viewer pane, say) can fade that one over left_fade/right_fade. The scroll area must be a direct child of a window with a backing, with its top and bottom at the virtual rect’s (not extended into screen margins), which the default TOOLBAR_SCROLL_FADE is calibrated against.

bauiv1lib.utils.get_screen_margins(root_scale: float) → tuple[float, float, float, float][source]

Return visible-screen margins outside the virtual rect.

Returns (left, right, bottom, top) distances between the virtual rect edges and the virtual outer rect (true visible area) edges, converted into a window’s local coordinate space via its root container’s root_scale. All values are zero unless the virtual bounds are inset (camera cutouts and such).

Windows that fill the screen at small ui-scale should extend backing elements such as scroll areas outward by these amounts (insetting their content by the same amounts so it stays put) so the backing reaches the true screen edges instead of stopping at the virtual rect. A scroll area using apply_toolbar_scroll_fades() should only do so at its sides, keeping its top and bottom at the virtual rect’s.

bauiv1lib.v2upgrade module

UI for upgrading V1 accounts to V2.

class bauiv1lib.v2upgrade.V2UpgradeWindow(login_name: str, code: str)[source]

Bases: Window

A window presenting a URL to the user visually.

bauiv1lib.v2upgrade.show_what_is_v2_page() → None[source]

Show the webpage describing V2 accounts.

bauiv1lib.watch module

Provides UI functionality for watching replays.

class bauiv1lib.watch.WatchWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None)[source]

Bases: MainWindow

Window for watching replays.

class TabID(*values)[source]

Bases: Enum

Our available tab types.

MY_REPLAYS = 'my_replays'
TEST_TAB = 'test_tab'
get_main_window_state() → MainWindowState[source]

Return a WindowState to recreate this specific window.

Used to gracefully return to a window from another window or ui system.

main_window_should_preserve_selection() → bool[source]

Whether this window should auto-save/restore selection.

If enabled, selection will be stored in the window’s shared state. See get_main_window_shared_state_id() for more info about main-window shared-state.

The default value of None results in a warning to explicitly override this (as the implicit default will change from False to True after api 9 support ends).