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.chest module

Provides chest related ui.

class bauiv1lib.chest.ChestWindow(index: int, transition: str | None = 'in_right', origin_widget: Widget | None = None, auxiliary_style: bool = True)[source]

Bases: MainWindow

Allows viewing and performing operations on a chest.

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.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)[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)[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: DocUIController

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

Local pages are authored client-side; the /cloudmsgtest/* and /webtest/* paths fetch equivalent v2 pages from bamaster.

fulfill_request(request: DocUIRequest) DocUIResponse[source]

Fulfill a v2 request (called in a background thread).

local_action(action: DocUILocalAction) None[source]

Do something locally on behalf of the doc-ui.

Controller classes can override this to expose named actions that can be triggered by doc-ui button presses, responses, etc.

Of course controllers can also perform arbitrary local actions alongside their normal request fulfillment; this is simply a way to do so without needing to provide actual ui pages alongside.

Be very careful and focused with what you expose here, especially if your doc-ui pages are coming from untrusted sources. Generally things like launching or joining games are good candidates for local actions.

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.docuitestframes module

The doc-ui frames test page.

Frames come in two flavors and this page shows them side by side: a plain one, which just places its children, and a sized one, which measures them, centers them, and shrinks them to fit its box.

The composition is deliberately far too big for the box it is given, so the sized version has to both scale and center for it to land – a combo that already fitted would prove nothing. The debug toggle draws every bound involved: the item’s box in cyan, the extent the children occupy in magenta, and each child’s own bounds in their usual colors.

See docs/initiatives/docui-frames.md.

bauiv1lib.docuitestframes.test_page_frames(request: bacommon.docui.v2.Request) bacommon.docui.v2.Response[source]

Testing frames, with and without size-to-fit.

bauiv1lib.docuitestitems module

The doc-ui display-items test page.

A display-item stays what it always was – show this thing in this style. What changes is what that turns into: the depiction now comes as a Frame rather than being derived client-side from the item type.

This page began as an A/B of the two, which is how their equivalence was established. The client no longer draws the legacy decoration at all, so what is left is a renderer regression check – every item type and style, drawable with no server and no account.

See docs/initiatives/docui-frames.md.

bauiv1lib.docuitestitems.test_page_display_items(request: bacommon.docui.v2.Request) bacommon.docui.v2.Response[source]

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

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.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.inbox module

Provides a popup window to view achievements.

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

Bases: MainWindow

Popup window to show account messages.

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.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: DocUIController

DocUI setup for inventory.

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.

local_action(action: DocUILocalAction) None[source]

Do something locally on behalf of the doc-ui.

Controller classes can override this to expose named actions that can be triggered by doc-ui button presses, responses, etc.

Of course controllers can also perform arbitrary local actions alongside their normal request fulfillment; this is simply a way to do so without needing to provide actual ui pages alongside.

Be very careful and focused with what you expose here, especially if your doc-ui pages are coming from untrusted sources. Generally things like launching or joining games are good candidates for local actions.

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

Called when a window shared state is being restored.

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.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.play module

Provides the top level play window.

class bauiv1lib.play.PlayWindow(transition: str | None = 'in_right', origin_widget: Widget | None = None, playlist_select_context: PlaylistSelectContext | None = None)[source]

Bases: MainWindow

Window for selecting overall play type.

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.play.PlaylistSelectContext[source]

Bases: object

For using PlayWindow to select a playlist instead of running game.

back_state: MainWindowState | None = None

bauiv1lib.playoptions module

Provides a window for configuring play options.

class bauiv1lib.playoptions.PlayOptionsWindow(*, sessiontype: type[bs.Session], playlist: str, scale_origin: tuple[float, float], delegate: Any = None, playlist_select_context: PlaylistSelectContext | None = None)[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 = 230.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)[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, *, 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.

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.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 functionality for entering promo codes.

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

Bases: MainWindow

Window for sending info to the developer.

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.sendinfo.SendInfoWindowLegacyModal(transition: str | None = 'in_scale', origin_widget: Widget | None = None)[source]

Bases: Window

Window for sending info to the developer.

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: DocUIController

DocUI setup for store.

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.').

local_action(action: DocUILocalAction) None[source]

Do something locally on behalf of the doc-ui.

Controller classes can override this to expose named actions that can be triggered by doc-ui button presses, responses, etc.

Of course controllers can also perform arbitrary local actions alongside their normal request fulfillment; this is simply a way to do so without needing to provide actual ui pages alongside.

Be very careful and focused with what you expose here, especially if your doc-ui pages are coming from untrusted sources. Generally things like launching or joining games are good candidates for local actions.

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.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.

bauiv1lib.utils.scroll_fade_bottom(container: Widget, scrollleft: float, scrollbottom: float, scrollwidth: float, scrollheight: float, *, center: bool = False, yscale: float = 1.0, yoffs_extra: float = 0.0) None[source]

Make content appear to fade towards the bottom of a scroll area.

This works by drawing background-texture-ish soft shapes obscuring the edge of the scroll area. The most opaque part of the shapes lands on the bottom edge of the provided scroll rect; use yoffs_extra to nudge them up or down from there (e.g. to center them on a note below the scroll area).

bauiv1lib.utils.scroll_fade_top(container: Widget, scrollleft: float, scrollbottom: float, scrollwidth: float, scrollheight: float, *, yscale: float = 1.0, yoffs_extra: float = 0.0) None[source]

Make content appear to fade towards the top of a scroll area.

This works by drawing background-texture-ish soft shapes obscuring the edge of the scroll area. The most opaque part of the shapes lands on the top edge of the provided scroll rect; use yoffs_extra to nudge them up or down from there (e.g. to center them on a title above the scroll area).

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).