bacommon.docui.routes package¶
Type-safe routes and local-actions layered over doc-ui v2.
The doc-ui wire format is string based (request paths, arg dicts, local-action names). The classes here let first-party code work purely in dataclasses instead; the modules alongside define the routes for individual doc-ui domains and are shared by whichever ends (client and/or server) author or handle that domain’s pages.
- class bacommon.docui.routes.DocUILocalActionBase[source]¶
Bases:
objectA local-action in a doc-ui domain, with args as dataclass fields.
The local-action analogue of
DocUIRoute: each named action a domain’s client-side controller exposes is an@iopreppeddataclass inheriting from that domain’s family class (a direct child of this class).- attach(response: bacommon.docui.v2.Response) None[source]¶
Have a response run this local-action when first received.
- classmethod from_name_and_args(name: str, args: dict) Self[source]¶
Return the local-action in this family matching a name + args.
Should be called on a family class. Raises
DocUIRouteErrorif there is no match.
- 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().
- 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
SWISHfor ones that go somewhere (open a window or popup). A press whose action hasdefault_soundoff plays nothing either way.
- local(*, close_window: bool = False, default_sound: bool = True, sets: Sequence[DocUIStateAssign] | None = None) bacommon.docui.v2.Local[source]¶
Return an action running this local-action immediately.
Any
setsare applied to the pressing page’s state first.
- classmethod press_sound_for_name(name: str) PressSound[source]¶
The press sound for the local-action in this family named so.
Should be called on a family class. Unknown names click.
- class bacommon.docui.routes.DocUIRoute[source]¶
Bases:
objectA page in a doc-ui domain, with its args as dataclass fields.
Doc-ui (v2) requests are a path string plus a dict of args on the wire. A route is a type-safe stand-in for one: each page a domain offers is an
@iopreppeddataclass inheriting from that domain’s family class (itself a direct child of this class). The dataclass’ fields are the page’s args; its path and request-method are given as keywords on its class line (class Foo(FooFamily, path='/foo', method=POST)).Page code never touches the path or args dict directly: authoring goes through the
browse()andreplace()verbs and handling goes throughfrom_request()(generally called on one’s behalf by a controller or request-handler base class).Paths within a family are a closed set; anything variable belongs in args (no
/item/<id>style paths). Routes are keyed on path and method, so a page and the POST that submits it can share a path.- browse(*, default_sound: bool = True, sets: Sequence[DocUIStateAssign] | None = None, state: DocUIState | None = None, layout: bacommon.docui.v2.WindowLayout | None = None, scroll_edge_style: bacommon.docui.v2.ScrollEdgeStyle | None = None) bacommon.docui.v2.Browse[source]¶
Return an action browsing to this route in a new window.
The pressing page’s state goes along with the request, with any
setsapplied to it. Passstateto send some other state entirely; generally what a different page expects. The window opens atlayout, or atget_window_layout()if not given, withscroll_edge_style(or its layout’s default if not given). (Its viewer pane, if any, is up to each page; seeviewer.)
- classmethod from_request(request: bacommon.docui.v2.Request) Self[source]¶
Return the route in this family that a request maps to.
Should be called on a family class. Raises
DocUIRouteErrorif the request does not map to a route in the family.
- classmethod get_method() bacommon.docui.v2.RequestMethod[source]¶
Return the request method for this route.
- 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_neverexhaustiveness) and returnsfamily_members()of it here.
- get_source_request() bacommon.docui.v2.Request | None[source]¶
Return the request we were built from, if we were.
Unlike
request(), which only ever describes the route itself, this carries whatever else rode along with the request (page state, trigger). Something forwarding an incoming route elsewhere as-is wants those to go along too.
- get_state(state_type: type[S]) S | None[source]¶
Return page state that arrived with the request for us.
Only routes built from requests have any, and only when the page the request was fired from had state of this type; anything else gives None. State is always optional input, so callers need a story for that.
- classmethod get_window_layout() bacommon.docui.v2.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.
- replace(*, default_sound: bool = True, sets: Sequence[DocUIStateAssign] | None = None, state: DocUIState | None = None) bacommon.docui.v2.Replace[source]¶
Return an action replacing the current page with this route.
See
browse()forsetsandstate.
- request() bacommon.docui.v2.Request[source]¶
Return the wire request for this route.
- exception bacommon.docui.routes.DocUIRouteError[source]¶
Bases:
ExceptionA request or local-action could not be mapped to a typed form.
- class bacommon.docui.routes.DocUIState[source]¶
Bases:
objectValues belonging to a doc-ui page, as dataclass fields.
Where route args say which page something is, state is what the user is in the middle of on it: the values its input rows show and edit plus anything else it wants handed back (a draft being composed, say). A page declares its state once and the client sends the current values along with every request fired from that page, so individual links need only say what they change.
Subclasses are
@iopreppeddataclasses declaring a globally unique id on their class line (class Foo(DocUIState, state_id='mydomain.foo')). The id rides along with the values so that state arriving at a page expecting some other type reads as no state at all instead of being mis-decoded. Field storage names must not start with an underscore.State is always optional input; a page must be able to make do without any (see
DocUIRoute.get_state).- classmethod assign(field: Callable[[Self], V], value: V) DocUIStateAssign[source]¶
- classmethod assign(field: Callable[[Self], V | None], value: V) DocUIStateAssign
Return an assignment of a value to one of our fields.
For passing as
setswhen creating actions:route.replace(sets=[MyState.assign(lambda s: s.color, c)]). The value is type-checked against the field. (The second overload is what lets a plainEbe assigned to anE | Nonefield: mypy settles the type variable from the value before it looks at the lambda.)
- classmethod assign_locally(*assigns: DocUIStateAssign, default_sound: bool = True) bacommon.docui.v2.Local[source]¶
Return an action assigning values with no request involved.
The values simply go out with whatever the page sends next.
- classmethod assign_on_return(*assigns: DocUIStateAssign, default_sound: bool = True) bacommon.docui.v2.Local[source]¶
Return an action closing the window, handing values back.
For a picker opened in a window of its own: the window closes and the values are assigned into the state of the page returned to (which must hold our state type; the client checks), which then refreshes with them.
- classmethod checkbox_row(field: Callable[[Self], bool], *, label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.CheckboxRow[source]¶
Return a checkbox row editing one of our (bool) fields.
disabledshows it dimmed and not toggleable (still selectable).
- classmethod choice_row(field: Callable[[Self], E], *, choice_label: Callable[[E], LangStrSpec], choices: Sequence[E] | None = None, disabled_choices: Collection[E] = (), label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.ChoiceRow[source]¶
- classmethod choice_row(field: Callable[[Self], E | None], *, choice_label: Callable[[E], LangStrSpec], none_label: LangStrSpec, choices: Sequence[E] | None = None, disabled_choices: Collection[E] = (), label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.ChoiceRow
- classmethod choice_row(field: Callable[[Self], str], *, choices: Sequence[tuple[str, LangStrSpec]], disabled_choices: Collection[str] = (), label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.ChoiceRow
- classmethod choice_row(field: Callable[[Self], str | None], *, choices: Sequence[tuple[str, LangStrSpec]], none_label: LangStrSpec, disabled_choices: Collection[str] = (), label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.ChoiceRow
Return a choice row editing one of our enum or str fields.
For an enum field,
choice_labelgives each option’s display text; write it as amatchending inassert_neverso a new enum member can’t go unlabeled.choicesnarrows/reorders the options shown (default: every member, in definition order).For a str field there is no closed set to be exhaustive over, so
choicesinstead defines the options as(value, label)pairs, in display order;choice_labeldoes not apply. The state’s current value should be among them (a value that isn’t shows as the first option).disabled_choiceslists options to show greyed out and unpickable (enum members, or str values, matching howchoicesare given) – each must be one of the options.disabledinstead disables the whole row: shown dimmed with its menu unopenable (still selectable).A field typed
E | None/str | Nonegets a ‘nothing’ option too, listed first, whose display text isnone_label– required for such fields and not allowed for others. The type checker enforces the required halves of all this via the overloads; what it can’t express (a straynone_labelorchoice_label) is checked here at runtime along with the rest.
- classmethod color_row(field: Callable[[Self], tuple[float, float, float]], *, label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.ColorRow[source]¶
Return a color row editing one of our rgb fields.
The field must be typed
tuple[float, float, float](0-1 components).on_changefires when the picker closes with a changed color, not per intermediate change.disabledshows it dimmed with its picker unopenable (still selectable).
- classmethod decode(data: dict | None) Self | None[source]¶
Return state of this type from its wire form, if that it be.
Returns None for no data, data for some other state type, or data that fails to decode. State comes from clients and is always optional, so none of those are errors.
- classmethod key(field: Callable[[Self], Any]) str[source]¶
Return the wire key for a field, given a lambda fetching it.
MyState.key(lambda s: s.some_field)
- classmethod number_row(field: Callable[[Self], float], *, min_value: float, max_value: float, increment: float, as_percent: bool = False, decimals: int = 0, label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.NumberRow[source]¶
Return a ‘-‘/’+’ number row editing one of our float fields.
on_changefires on each press that changes the value.disabledshows it dimmed and not adjustable (still selectable). Seebacommon.docui.v2.NumberRow.
- classmethod slider_row(field: Callable[[Self], float], *, min_value: float, max_value: float, increment: float, as_percent: bool = False, decimals: int = 2, label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, on_change: bacommon.docui.v2.Action | None = None, on_drag: bacommon.docui.v2.Local | None = None, drag_interval: float = 0.25, drag_delay: float = 0.0, disabled: bool = False, debug: bool = False) bacommon.docui.v2.SliderRow[source]¶
Return a slider row editing one of our float fields.
on_changefires for a settled value (release, or a run of key/controller steps going quiet);on_drag– a local action, built viaMyAction().local()– fires during a drag (key/controller steps included) at the throttled cadencedrag_interval/drag_delaydescribe, reading the live value from the page’s state.disabledshows it dimmed and not adjustable (still selectable). Seebacommon.docui.v2.SliderRow.
- classmethod text_input_row(field: Callable[[Self], str], *, label: LangStrSpec | None = None, title: LangStrSpec | None = None, subtitle: LangStrSpec | None = None, title_align: bacommon.docui.v2.HAlign | None = None, footnote: LangStrSpec | None = None, description: LangStrSpec | None = None, max_chars: int = 64, on_change: bacommon.docui.v2.Action | None = None, on_submit: bacommon.docui.v2.Action | None = None, disabled: bool = False, debug: bool = False) bacommon.docui.v2.TextInputRow[source]¶
Return a text-input row editing one of our (str) fields.
disabledshows it dimmed and not editable (still selectable).
- class bacommon.docui.routes.DocUIStateAssign(state_type: type[DocUIState], key: str, value: Any)[source]¶
Bases:
objectA value to be assigned into a page’s state.
Create these via
DocUIState.assign().- state_type: type[DocUIState]¶
- class bacommon.docui.routes.NoLocalActions[source]¶
Bases:
DocUILocalActionBaseStock local-action family for domains that have none.
Pair with
typing.Neveras the local-action type arg.- 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 bacommon.docui.routes.PressSound(*values)[source]¶
Bases:
EnumWhat a button plays when pressed to run a local-action.
See
get_press_sound().- CLICK = 'click'¶
The standard click, for actions that stay on the page.
- NONE = 'none'¶
Nothing (the action handles any sound itself).
- SWISH = 'swish'¶
The standard ui swish, for actions that go somewhere – open a window or a popup, say – like a browse does.
- bacommon.docui.routes.family_members(alias: Any) tuple[Any, ...][source]¶
Return the classes making up a family’s union alias.
Handles the degenerate single-member case, where the ‘union’ is simply the one class.
- bacommon.docui.routes.validate_page_state(page: bacommon.docui.v2.Page) None[source]¶
Make sure a page’s use of its state hangs together.
Checks that everything referring to the page’s state by key (input rows,
setson actions) names a real field of the state type the page declares. Those are all produced by type-checked calls, but nothing static ties them to the same state type as the page’s, so that part gets checked here. Pages whose state is of no type known to us (third party ones, say) are left alone.
Submodules¶
bacommon.docui.routes.classiccharacterpreview module¶
Routes for the classic character-preview doc-ui domain.
A character being tried out in a game (sent there from its builder page; see the game’s character-preview session): the profile editor for it, as a player who picks the character will see it. Saving changes nothing stored anywhere; it answers with the character as edited for the preview session to carry on with.
- class bacommon.docui.routes.classiccharacterpreview.CharacterPreviewLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for classic character-preview 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 bacommon.docui.routes.classiccharacterpreview.CharacterPreviewRoute[source]¶
Bases:
DocUIRouteFamily class for classic character-preview 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_neverexhaustiveness) and returnsfamily_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 bacommon.docui.routes.classiccharacterpreview.Edit(preview_id: str)[source]¶
Bases:
CharacterPreviewRouteThe profile editor for a previewed character.
The draft being composed rides along as page state (the profile editor’s own:
ProfileDraft).
- class bacommon.docui.routes.classiccharacterpreview.Save(preview_id: str)[source]¶
Bases:
CharacterPreviewRouteSave the editor’s draft; answered with
Saved.
bacommon.docui.routes.classicchest module¶
Routes for the classic chest doc-ui domain.
One chest slot: what’s in it, its prize odds and its unlock wait, with buttons to open it (now, for tokens, or once unlocked) or to watch an ad to cut the wait. Opening answers with the chest’s contents and the open animation as client-effects.
- class bacommon.docui.routes.classicchest.AdWatched(slot: int)[source]¶
Bases:
ChestRouteThe player watched an ad to reduce a chest’s wait.
Answered like
Openif that unlocked it; otherwise with the slot as it now stands.
- class bacommon.docui.routes.classicchest.ChestLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for classic chest 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 bacommon.docui.routes.classicchest.ChestRoute[source]¶
Bases:
DocUIRouteFamily class for classic chest 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_neverexhaustiveness) and returnsfamily_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 bacommon.docui.routes.classicchest.GetTokens[source]¶
Bases:
ChestLocalActionOffer to get more tokens (not enough to open a chest now).
- 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
SWISHfor ones that go somewhere (open a window or popup). A press whose action hasdefault_soundoff plays nothing either way.
- class bacommon.docui.routes.classicchest.Open(slot: int, token_payment: int)[source]¶
Bases:
ChestRouteOpen a chest, paying any tokens its wait currently costs.
Answered with its contents and the open animation.
- class bacommon.docui.routes.classicchest.Root(slot: int, ad_ready: bool = False, open_me: bool = False)[source]¶
Bases:
ChestRouteA chest slot: its chest (if any) and what can be done with it.
The two flags are things only the client knows, so it states them when asking.
- ad_ready: bool = False¶
Whether an ad is ready to show right now (so a ‘watch an ad to reduce the wait’ button can work).
- class bacommon.docui.routes.classicchest.StopReminding(slot: int)[source]¶
Bases:
ChestLocalActionStop reminding about opening chests early; re-show the slot.
bacommon.docui.routes.classichost module¶
Routes for the classic host doc-ui domain.
Pages a game host serves its connected clients over the game
connection (see bacommon.hostui): the defaults classic hosts ship
with. Hosts may serve other routes of their own alongside these.
- class bacommon.docui.routes.classichost.ClassicHostRoute[source]¶
Bases:
DocUIRouteFamily class for classic host 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_neverexhaustiveness) and returnsfamily_members()of it here.
- class bacommon.docui.routes.classichost.KickVote(client_id: int | None = None)[source]¶
Bases:
ClassicHostRouteStart or follow a vote to kick someone.
Clients open this with
client_idset to whoever they chose to kick; without one it shows any vote in progress.
- class bacommon.docui.routes.classichost.KickVoteCast(yes: bool)[source]¶
Bases:
ClassicHostRouteVote in the kick vote in progress.
- class bacommon.docui.routes.classichost.KickVoteStart(client_id: int)[source]¶
Bases:
ClassicHostRouteStart a vote to kick a client.
- class bacommon.docui.routes.classichost.Stats[source]¶
Bases:
ClassicHostRouteWho is in the party and how their connections are doing.
bacommon.docui.routes.classicinbox module¶
Routes for the classic inbox doc-ui domain.
The inbox lists an account’s messages (rewards, notices, tournament results) as cards; responding to one – claiming a reward, accepting or declining – posts back and gets the updated list in return.
- class bacommon.docui.routes.classicinbox.InboxLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for classic inbox 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 bacommon.docui.routes.classicinbox.InboxRoute[source]¶
Bases:
DocUIRouteFamily class for classic inbox 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_neverexhaustiveness) and returnsfamily_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 bacommon.docui.routes.classicinbox.OpenUrl(url: str)[source]¶
Bases:
InboxLocalActionOpen a url in the platform’s browser.
- class bacommon.docui.routes.classicinbox.Respond(entry_id: str, positive: bool = True)[source]¶
Bases:
InboxRouteRespond to one message (claim it, accept or decline it, etc.).
Answered with the updated inbox, with any effects of the response (reward animations, sounds) attached. Shares the inbox’s own path so the client treats the answer as the same page updated (holding its scroll position) rather than a new one.
- class bacommon.docui.routes.classicinbox.Root(debug: bool = False)[source]¶
Bases:
InboxRouteThe inbox: every message, newest first.
- class bacommon.docui.routes.classicinbox.TourneyScores(tournament_id: str)[source]¶
Bases:
InboxLocalActionShow a tournament’s final standings.
- 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
SWISHfor ones that go somewhere (open a window or popup). A press whose action hasdefault_soundoff plays nothing either way.
bacommon.docui.routes.classicleaguepresidency module¶
Routes for the classic league-presidency doc-ui domain.
- class bacommon.docui.routes.classicleaguepresidency.BidState(bid: int = 0)[source]¶
Bases:
DocUIStateThe presidency page’s state: the bid being composed.
Clients that speak page state carry this; older ones carry the same value as the
bidarg on the routes.
- class bacommon.docui.routes.classicleaguepresidency.GetTokens[source]¶
Bases:
LeaguePresidencyLocalActionShow the get-tokens window.
- class bacommon.docui.routes.classicleaguepresidency.LeaguePresidencyLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for classic league-presidency 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 bacommon.docui.routes.classicleaguepresidency.LeaguePresidencyRoute[source]¶
Bases:
DocUIRouteFamily class for classic league-presidency 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_neverexhaustiveness) and returnsfamily_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 bacommon.docui.routes.classicleaguepresidency.Root(bid: int = 0, debug: bool = False, season: str | None = None)[source]¶
Bases:
LeaguePresidencyRouteThe presidency page for the account’s current league.
bacommon.docui.routes.classicstore module¶
Routes for the classic store and inventory doc-ui domains.
The store and inventory are two domains served by a single set of pages (the inventory is essentially the store filtered to owned things plus player-profiles), so they share one route family. Each has its own local-actions.
- class bacommon.docui.routes.classicstore.EditProfile(profile: str)[source]¶
Bases:
InventoryLocalActionOpen the (legacy) profile editor on an existing profile.
- 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
SWISHfor ones that go somewhere (open a window or popup). A press whose action hasdefault_soundoff plays nothing either way.
- class bacommon.docui.routes.classicstore.GetTokens[source]¶
Bases:
StoreLocalActionShow the get-tokens window.
- class bacommon.docui.routes.classicstore.InventoryLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for classic inventory 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 bacommon.docui.routes.classicstore.NewProfile[source]¶
Bases:
InventoryLocalActionOpen the (legacy) profile editor on a new profile.
- 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
SWISHfor ones that go somewhere (open a window or popup). A press whose action hasdefault_soundoff plays nothing either way.
- class bacommon.docui.routes.classicstore.ProfileCharacter[source]¶
Bases:
StoreRoute(Inventory) pick the profile editor’s character.
Opened from the editor, whose
ProfileDraftcomes along as page state; picking one hands it back to the editor (seeassign_on_return()).- 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 bacommon.docui.routes.classicstore.ProfileDelete(profile_name: str)[source]¶
Bases:
StoreRoute(Inventory) delete a stored profile.
- class bacommon.docui.routes.classicstore.ProfileDeleteConfirm(profile_name: str)[source]¶
Bases:
StoreRoute(Inventory) confirm deleting a stored profile.
Replaces the editor’s page in its window; its draft rides along as page state, so cancelling goes back to the editor with it intact.
- 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 bacommon.docui.routes.classicstore.ProfileDraft(color: tuple[float, float, float], highlight: tuple[float, float, float], name: str = '', character: str = '', icon: str = '')[source]¶
Bases:
DocUIStateThe profile editor’s working profile.
Page state for the editor and its save: what the user has composed so far. A request with no draft at all (the first visit) gets one built from the stored profile, or fresh defaults when creating; an empty name, character or icon means the same for that field.
- class bacommon.docui.routes.classicstore.ProfileEdit(profile_name: str | None = None)[source]¶
Bases:
StoreRoute(Inventory) the cloud player-profile editor.
The draft being composed rides along as
ProfileDraftpage state; the route itself only says which stored profile (if any) is being edited.- 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 bacommon.docui.routes.classicstore.ProfileGlobalUpgrade(profile_name: str)[source]¶
Bases:
StoreRoute(Inventory) offer to upgrade a cloud profile to a global one.
Says whether the name can be had and what it costs. Like
ProfileDeleteConfirm, it replaces the editor’s page in its window with the editor’s draft riding along as page state.- 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 bacommon.docui.routes.classicstore.ProfileGlobalUpgradeBuy(profile_name: str, ticket_cost: int)[source]¶
Bases:
StoreRoute(Inventory) upgrade a cloud profile to a global one.
- class bacommon.docui.routes.classicstore.ProfileIcon[source]¶
Bases:
StoreRoute(Inventory) pick the profile editor’s icon.
Works as
ProfileCharacterdoes: the editor’sProfileDraftcomes along as page state and the pick is handed back to it.- 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 bacommon.docui.routes.classicstore.ProfileMigrate(profiles_only: bool = False, debug: bool = False)[source]¶
Bases:
StoreRoute(Inventory) copy the account’s legacy profiles into cloud ones.
Requested by the ‘Converting profiles…’ page the root shows while a migration is due; redirects back to the root afterward (carrying the root’s view arguments along).
- debug: bool = False¶
See
Root.debug.
- profiles_only: bool = False¶
See
Root.profiles_only.
- class bacommon.docui.routes.classicstore.ProfileSave(profile_name: str | None = None)[source]¶
Bases:
StoreRoute(Inventory) save the editor’s draft (its
ProfileDraft).
- class bacommon.docui.routes.classicstore.Purchase(purchase_id: str, debug: bool = False)[source]¶
Bases:
StoreRoutePurchase options for a single item.
- class bacommon.docui.routes.classicstore.PurchaseConfirm(purchase_id: str, purchase_method: PurchaseMethod, debug: bool = False)[source]¶
Bases:
StoreRouteActually purchase an item.
- purchase_method: PurchaseMethod¶
- class bacommon.docui.routes.classicstore.PurchaseMethod(*values)[source]¶
Bases:
EnumHow to purchase something.
- GOLD_PASS = 'g'¶
- PURPLE_TICKETS = 'p'¶
- TICKETS = 'k'¶
- TOKENS = 't'¶
- class bacommon.docui.routes.classicstore.RestorePurchases[source]¶
Bases:
StoreLocalActionKick off a platform purchase-restore.
- class bacommon.docui.routes.classicstore.Root(debug: bool = False, is_refresh: bool = False, legacy_profiles: bool = False, profiles_only: bool = False, unlockreqs: list[str] | None = None)[source]¶
Bases:
StoreRouteThe main store/inventory listing.
- 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.
- is_refresh: bool = False¶
Set on the page’s own refresh button. One-time-use; the server does not carry it into further links.
- legacy_profiles: bool = False¶
(Inventory) the client is showing its locally-spliced legacy profiles; omit cloud profile rows.
- class bacommon.docui.routes.classicstore.ShowCloudProfiles[source]¶
Bases:
InventoryLocalActionSwitch the inventory to cloud profiles.
- class bacommon.docui.routes.classicstore.ShowLegacyProfiles[source]¶
Bases:
InventoryLocalActionSwitch the inventory to the client’s legacy profiles.
- class bacommon.docui.routes.classicstore.SpawnBot(name: str)[source]¶
Bases:
InventoryLocalActionSpawn a character in the main-menu background.
- class bacommon.docui.routes.classicstore.StoreLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for classic store 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 bacommon.docui.routes.classicstore.StoreRoute[source]¶
Bases:
DocUIRouteFamily class for classic store/inventory 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_neverexhaustiveness) and returnsfamily_members()of it here.
bacommon.docui.routes.docuitest module¶
Routes for the doc-ui test domain.
- class bacommon.docui.routes.docuitest.Animation[source]¶
Bases:
TestRouteDecorations animated by keyframe client-effects.
- class bacommon.docui.routes.docuitest.BoundsTests[source]¶
Bases:
TestRouteButton-style bounds tests.
- class bacommon.docui.routes.docuitest.ButtonGrids(debug: bool = False)[source]¶
Bases:
TestRouteGrid button rows: columns, cells, alignment and navigation.
Browse to it at several layouts; grids reflow to fit each width.
- class bacommon.docui.routes.docuitest.CloudMsgTestGet[source]¶
Bases:
TestRouteA page fetched through our cloud connection via GET.
- class bacommon.docui.routes.docuitest.CloudMsgTestPost[source]¶
Bases:
TestRouteA page fetched through our cloud connection via POST.
- class bacommon.docui.routes.docuitest.ControlRowKind(*values)[source]¶
Bases:
EnumKinds of control row (for
NavTest).- BUTTON = 'button'¶
- CHECKBOX = 'checkbox'¶
- CHOICE = 'choice'¶
- COLOR = 'color'¶
- NUMBER = 'number'¶
- SLIDER = 'slider'¶
- TEXT_INPUT = 'text'¶
- class bacommon.docui.routes.docuitest.Depictions(debug: bool = False)[source]¶
Bases:
TestRouteDepiction tests.
- class bacommon.docui.routes.docuitest.DisplayItems(debug: bool = False)[source]¶
Bases:
TestRouteDisplay-item tests.
- class bacommon.docui.routes.docuitest.EmptyPage[source]¶
Bases:
TestRouteA page with nothing on it.
- class bacommon.docui.routes.docuitest.Flavor(*values)[source]¶
Bases:
EnumSomething to pick from on the widgets test page.
- CHOCOLATE = 'c'¶
- MINT = 'm'¶
- STRAWBERRY = 's'¶
- VANILLA = 'v'¶
- class bacommon.docui.routes.docuitest.LiveTimes[source]¶
Bases:
TestRouteTime-varying text (countdowns, elapsed times) that ticks itself.
- class bacommon.docui.routes.docuitest.Names(debug: bool = False)[source]¶
Bases:
TestRouteName depiction tests (basic and capsule forms).
Bases:
TestRouteA button row, then one control row of some kind as the last row.
For checking directional navigation on control rows: down from the last row should reach the toolbars, left should reach the back button, and right from a row’s rightmost control should do nothing.
- class bacommon.docui.routes.docuitest.NinePatch(debug: bool = False)[source]¶
Bases:
TestRoute9-patch image tests (stretched and tile-fit, tinted).
- class bacommon.docui.routes.docuitest.Root(debug: bool = False, test_effects: bool = False, test_action: bool = False)[source]¶
Bases:
TestRouteThe root test page.
- class bacommon.docui.routes.docuitest.Sections(debug: bool = False)[source]¶
Bases:
TestRouteSections: headings, notes, backings and spacing between them.
- 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 bacommon.docui.routes.docuitest.ShowVolume[source]¶
Bases:
TestLocalActionShow the volume slider’s live value (fired while dragging).
- class bacommon.docui.routes.docuitest.Size(*values)[source]¶
Bases:
EnumSomething else to pick from on the widgets test page.
- L = 'l'¶
- M = 'm'¶
- S = 's'¶
- XL = 'x'¶
- class bacommon.docui.routes.docuitest.Slow[source]¶
Bases:
TestRouteA page that takes a while to load.
- class bacommon.docui.routes.docuitest.TestAction(testparam: int)[source]¶
Bases:
TestLocalActionShow a message proving we got here.
- class bacommon.docui.routes.docuitest.TestLocalAction[source]¶
Bases:
DocUILocalActionBaseFamily class for doc-ui test 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 bacommon.docui.routes.docuitest.TestRoute[source]¶
Bases:
DocUIRouteFamily class for doc-ui test 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_neverexhaustiveness) and returnsfamily_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 bacommon.docui.routes.docuitest.TextImages(debug: bool = False)[source]¶
Bases:
TestRouteText-with-images tests.
- class bacommon.docui.routes.docuitest.TextWrapping(debug: bool = False)[source]¶
Bases:
TestRouteTitles, subtitles and footnotes word-wrapped to their columns.
- class bacommon.docui.routes.docuitest.TimedActions(val: int = 5)[source]¶
Bases:
TestRouteA page that counts down via timed-actions and then closes.
- class bacommon.docui.routes.docuitest.Viewers(case: str = '')[source]¶
Bases:
TestRouteLive viewer tests: good cases and bad data, one shown at a time.
The page’s own controls switch cases, and the pane’s style and side (page state), in place.
- case: str = ''¶
Which case the viewer pane shows (a test-page case name; unknown names show the first).
- 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 bacommon.docui.routes.docuitest.WebTestGet[source]¶
Bases:
TestRouteA page fetched from a web server via GET.
- class bacommon.docui.routes.docuitest.WebTestPost[source]¶
Bases:
TestRouteA page fetched from a web server via POST.
- class bacommon.docui.routes.docuitest.WideFit(over: bool = False, wide_over: bool = False, layout: WindowLayout = WindowLayout.WIDE)[source]¶
Bases:
TestRouteA row exactly as big as wide pages get (browse at each layout).
It should fill the page’s height and width with no scrolling, at every ui-scale; with
over/wide_overset it’s a hair taller / wider, which should scroll (at small ui-scale, only on the smallest screens: windows there fill the screen, so the page sizes are minimums).layoutsays which wide layout it’s being shown in (browse at that one): wide and wider pages are the same height everywhere, wide-tall ones depend on the ui-scale and wide-taller ones on the screen too; wider’s width follows the screen, so there’s no width to overflow there.- layout: WindowLayout = 'w'¶
- class bacommon.docui.routes.docuitest.WidgetTestState(plain: bool = False, live: bool = False, checked_disabled: bool = True, unchecked_disabled: bool = False, presses: int = 0, text_short: str = '', text_medium: str = 'Some text', text_long: str = '', text_live: str = '', text_disabled: str = 'Not editable', flavor: Flavor = Flavor.VANILLA, flavor_live: Flavor = Flavor.VANILLA, size: Size = Size.M, size_long: Size = Size.M, topping: Flavor | None = None, difficulty: str = 'normal', region: str | None = None, flavor_disabled: Flavor = Flavor.CHOCOLATE, topping_disabled: Flavor | None = None, difficulty_disabled: str = 'hard', region_disabled: str | None = 'eu', volume: float = 0.5, volume_disabled: float = 0.3, series_length: float = 7.0, series_length_disabled: float = 5.0, tint: tuple[float, float, float] = (0.5, 0.25, 1.0), tint_disabled: tuple[float, float, float] = (1.0, 0.6, 0.1), spacing_top_demo: bool = False, spacing_bottom_demo: bool = False, bands_demo: bool = False)[source]¶
Bases:
DocUIStateState for the widgets test page.
- checked_disabled: bool = True¶
Disabled checkboxes (selectable; not toggleable), one checked and one not.
- difficulty: str = 'normal'¶
Choices over an arbitrary string set (the page defines the options, not an enum); plain and optional.
- flavor_disabled: Flavor = 'c'¶
Disabled choice rows (selectable; menus won’t open), one of each form: enum, optional enum, str, optional str.
- presses: int = 0¶
Nothing shows or edits this directly; it simply rides along (and gets bumped by a button).
- spacing_top_demo: bool = False¶
Checkboxes on rows demonstrating control-row spacing and header / footer bands (they drive nothing).
- tint: tuple[float, float, float] = (0.5, 0.25, 1.0)¶
An rgb color, edited via the color-picker popup.
- class bacommon.docui.routes.docuitest.Widgets(debug: bool = False)[source]¶
Bases:
TestRouteControl rows and page state.
- class bacommon.docui.routes.docuitest.WindowLayouts(debug: bool = False, layout: WindowLayout | None = None, viewer_side: ViewerSide | None = None)[source]¶
Bases:
TestRouteAssorted rows for judging window layouts (browse to it at each).
Control rows, titles and button rows at every alignment, and long rows, which in a narrow column scroll within it.
- layout: WindowLayout | None = None¶
The layout we’re being browsed to at, for the page to name (the browse sets the actual layout; this is just for show).
- viewer_side: ViewerSide | None = None¶
Which side the page’s viewer pane sits on at viewer layouts, or None for a page with no viewer (its rows then span the window). Ignored at other layouts.