Home Reference Source
import {HUDWaypoints} from 'shapez.io/js/game/hud/parts/waypoints.js'
public class | source

HUDWaypoints

Extends:

BaseHUDPart → HUDWaypoints

Member Summary

Public Members
public

Stores a cache from a shape short key to its canvas representation

public

Store cached text widths

public

compassBuffer: {"canvas": *, "context": *}

public
public

Stores at how much opacity the markers should be rendered on the map.

public
public
public
public
public

waypointSprites: {"regular": *, "wires": *}

public
public

Method Summary

Public Methods
public

addWaypoint(label: string, position: Vector)

Adds a new waypoint at the given location with the given label

public

createElements(parent: HTMLElement)

Creates the overview of waypoints

public

Deletes a waypoint from the list

public

deserialize(data: {waypoints: Array<Waypoint>}): string

Deserializes the waypoints

public

Draws the waypoints on the map

public

findCurrentIntersectedWaypoint(): Waypoint | null

Finds the currently intersected waypoint on the map overview under the cursor.

public

Returns how big the text should be rendered

public

Returns how long a text will be rendered

public

getWaypointCanvas(waypoint: Waypoint): HTMLCanvasElement

Gets the canvas for a given waypoint

public

Returns the label for a given waypoint

public

getWaypointScreenParams(waypoint: Waypoint): { screenBounds: Rectangle item: BaseItem|null, text: string }

Returns the screen space bounds of the given waypoint or null if it couldn't be determined. Also returns wheter its a shape or not

public

Returns the scale for rendering waypoints

public

Initializes everything

public

Returns if a waypoint is deletable

public

Moves the camera to a given waypoint

public

onMouseDown(pos: Vector, button: enumMouseButton): *

Mouse-Down handler

public

renameWaypoint(waypoint: Waypoint, label: string)

Renames a waypoint with the given label

public

Requests to save a marker at the current camera position.

public

Re-renders the waypoint list to account for changes

public

Rerenders the compass

public

serialize(): {"waypoints": *}

Serializes the waypoints

public

Sort waypoints by name

public

update()

Called every frame to update stuff

Inherited Summary

From class BaseHUDPart
public
public

root: *

public

Cleans up the hud element, if overridden make sure to call super.cleanup

public

Cleans up all click detectors

public

close()

Should close the element, in case its supported

public

closeOnBackgroundClick(element: HTMLElement, closeMethod: function)

Closes this element when its background is clicked

public

createElements(parent: HTMLElement)

Should create all require elements

public

draw(parameters: DrawParameters)

Should draw the hud

public

Should draw any overlays (screen space)

public

Forwards the game speed keybindings so you can toggle pause / Fastforward in the building tooltip and such

public

Forwards the map movement keybindings so you can move the map with the arrow keys

public

Should initialize the element, called after the elements have been created

public

Should return true if this overlay is open and currently blocking any user interaction

public

Registers a new click detector

public

Should return false if the game should be paused

public

Should return true if the widget has a modal dialog opened and thus the game does not need to update / redraw

public

trackClicks(element: Element, handler: function, args: import("../../core/click_detector").ClickDetectorConstructorArgs=)

Helper method to construct a new click detector

public

update()

Should update any required logic

Public Members

public cachedKeyToCanvas: {} source

Stores a cache from a shape short key to its canvas representation

public cachedTextWidths: Object<string, number> source

Store cached text widths

public compassBuffer: {"canvas": *, "context": *} source

public currentCompassOpacity: number source

public currentMarkerOpacity: number source

Stores at how much opacity the markers should be rendered on the map. This is interpolated over multiple frames so we have some sort of fade effect

public directionIndicatorSprite: * source

public domAttach: * source

public dummyBuffer: * source

public hintElement: * source

public waypointSprites: {"regular": *, "wires": *} source

public waypoints: * source

public waypointsListElement: * source

Public Methods

public addWaypoint(label: string, position: Vector) source

Adds a new waypoint at the given location with the given label

Params:

NameTypeAttributeDescription
label string
position Vector

public createElements(parent: HTMLElement) source

Creates the overview of waypoints

Override:

BaseHUDPart#createElements

Params:

NameTypeAttributeDescription
parent HTMLElement

public deleteWaypoint(waypoint: Waypoint) source

Deletes a waypoint from the list

Params:

NameTypeAttributeDescription
waypoint Waypoint

public deserialize(data: {waypoints: Array<Waypoint>}): string source

Deserializes the waypoints

Params:

NameTypeAttributeDescription
data {waypoints: Array<Waypoint>}

Return:

string

public drawOverlays(parameters: DrawParameters) source

Draws the waypoints on the map

Override:

BaseHUDPart#drawOverlays

Params:

NameTypeAttributeDescription
parameters DrawParameters

public findCurrentIntersectedWaypoint(): Waypoint | null source

Finds the currently intersected waypoint on the map overview under the cursor.

Return:

Waypoint | null

public getTextScale(): * source

Returns how big the text should be rendered

Return:

*

public getTextWidth(text: string): number source

Returns how long a text will be rendered

Params:

NameTypeAttributeDescription
text string

Return:

number

public getWaypointCanvas(waypoint: Waypoint): HTMLCanvasElement source

Gets the canvas for a given waypoint

Params:

NameTypeAttributeDescription
waypoint Waypoint

Return:

HTMLCanvasElement

public getWaypointLabel(waypoint: Waypoint): string source

Returns the label for a given waypoint

Params:

NameTypeAttributeDescription
waypoint Waypoint

Return:

string

public getWaypointScreenParams(waypoint: Waypoint): { screenBounds: Rectangle item: BaseItem|null, text: string } source

Returns the screen space bounds of the given waypoint or null if it couldn't be determined. Also returns wheter its a shape or not

Params:

NameTypeAttributeDescription
waypoint Waypoint

Return:

{ screenBounds: Rectangle item: BaseItem|null, text: string }

public getWaypointUiScale(): * source

Returns the scale for rendering waypoints

Return:

*

public initialize() source

Initializes everything

Override:

BaseHUDPart#initialize

public isWaypointDeletable(waypoint: Waypoint): boolean source

Returns if a waypoint is deletable

Params:

NameTypeAttributeDescription
waypoint Waypoint

Return:

boolean

public moveToWaypoint(waypoint: Waypoint) source

Moves the camera to a given waypoint

Params:

NameTypeAttributeDescription
waypoint Waypoint

public onMouseDown(pos: Vector, button: enumMouseButton): * source

Mouse-Down handler

Params:

NameTypeAttributeDescription
pos Vector
button enumMouseButton

Return:

*

public renameWaypoint(waypoint: Waypoint, label: string) source

Renames a waypoint with the given label

Params:

NameTypeAttributeDescription
waypoint Waypoint
label string

public requestSaveMarker(param0: object) source

Requests to save a marker at the current camera position. If worldPos is set, uses that position instead.

Params:

NameTypeAttributeDescription
param0 object
param0.worldPos Vector=

Override the world pos, otherwise it is the camera position

param0.waypoint Waypoint=

Waypoint to be edited. If omitted, create new

public rerenderWaypointList() source

Re-renders the waypoint list to account for changes

public rerenderWaypointsCompass() source

Rerenders the compass

public serialize(): {"waypoints": *} source

Serializes the waypoints

Return:

{"waypoints": *}

public sortWaypoints() source

Sort waypoints by name

public update() source

Called every frame to update stuff

Override:

BaseHUDPart#update