Skip to content

UiIntro ​

The UiIntro class manages the game's main menu / intro screen. It handles player name input, server selection, connection flow, ad display, canvas rendering toggle, leaderboard data fetching, and party invitation deep linking.

UiIntro private ​

Extends UiComponent.

Properties ​

NameTypeDescription
uiUiCurrent Ui instance. Inherited from UiComponent.
componentElemHTMLElementThe pre-existing .hud-intro DOM element (not created from template).
adMedrecElemHTMLElementThe .ad-unit-medrec ad container.
adLeaderboardElemHTMLElementThe .ad-unit-leaderboard ad container.
nameInputElemHTMLInputElementThe .hud-intro-name player name text input. Persisted via localStorage.
serverElemHTMLSelectElementThe .hud-intro-server server selection dropdown.
submitElemHTMLElementThe .hud-intro-play play/submit button.
errorElemHTMLElementThe .hud-intro-error error message display element.
canvasInputElemHTMLInputElementThe .hud-intro-canvas checkbox for forcing canvas rendering.
leaderboardCategoryInputElemHTMLSelectElementThe .hud-intro-leaderboard-category dropdown (score/wave).
leaderboardTimeInputElemHTMLSelectElementThe .hud-intro-leaderboard-time dropdown (time frame).
leaderboardPartiesElemHTMLElementThe .hud-intro-leaderboard-parties container for leaderboard entries.
connectingbooleanWhether a connection attempt is currently in progress.
connectionTimernumber \| undefinedTimeout ID for the 5-second connection timeout.
partyShareKeystring \| undefinedShare key extracted from the URL hash for party invitations.
reconnectKeystring \| undefinedKey for reconnection, if applicable.

Methods ​

constructor() ​

ts
function constructor(ui: Ui): void

Initializes the intro screen by querying the pre-existing .hud-intro element (bypasses template creation), restores the player name and canvas preference from localStorage, conditionally creates a leaderboard ad unit if the viewport height is ≥ 820px, binds input event listeners, and registers network handlers for connect, error, and enterWorld. Calls checkForPartyInvitation().

hide() ​

ts
function hide(): void

Overrides UiComponent.hide(). Clears the ad unit containers' HTML before hiding.

onNameInputKeyUp() ​

ts
function onNameInputKeyUp(event: KeyboardEvent): void

Handles keyup on the name input. Triggers the play button click when Enter is pressed.

onSubmitClick() ​

ts
function onSubmitClick(event: MouseEvent): void

Initiates the connection flow: saves the player name to localStorage, sets a 5-second connection timeout (shows an anti-virus error message on timeout), displays a loading spinner, sets the nickname and server ID options, and calls network.connect().

onCanvasInputChange() ​

ts
function onCanvasInputChange(event: Event): void

Handles the canvas checkbox change. Persists the forceCanvas preference to localStorage and reloads the page.

onConnectionStart() ​

ts
function onConnectionStart(): void

Handles the network connect event. Sends the enterWorld request with the player's display name.

onConnectionError() ​

ts
function onConnectionError(): void

Handles the network error event. Resets the connecting state, clears the timeout, restores the play button text, and displays an error message.

onEnterWorld() ​

ts
function onEnterWorld(data: { allowed: boolean }): void

Handles the enter world response. If allowed, hides the intro screen. If not allowed, shows a "server full" error.

onFetchLeaderboardData() ​

ts
function onFetchLeaderboardData(): void

Fetches leaderboard data from /leaderboard/data via browser-request, filtering by category (score/wave) and time frame. Sanitizes player names with xss and renders the results into the leaderboard parties container.

checkForPartyInvitation() ​

ts
function checkForPartyInvitation(): void

Parses the URL hash for a party invitation in the format #/<serverId>/<shareKey>. If found, auto-selects the server, disables the server dropdown, stores the share key, and registers an enter world handler that sends a JoinPartyByShareKey RPC.