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

HUDPinnedShapes

Extends:

BaseHUDPart → HUDPinnedShapes

Manages the pinned shapes on the left side of the screen

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

element: *

public

handles: Array<{ key: string, definition: ShapeDefinition, amountLabel: HTMLElement, lastRenderedValue: string, element: HTMLElement, detector?: ClickDetector, infoDetector?: ClickDetector, throughputOnly?: boolean }>

Store handles to the currently rendered elements, so we can update them more convenient.

public

Store a list of pinned shapes

Method Summary

Public Methods
public

createElements(parent: *)

public

deserialize(data: {shapes: Array<string>}): string

Deserializes the pinned shapes

public

Finds the current goal for the given key.

public

Initializes the hud component

public

Pins a new shape

public

Returns whether a given shape is currently pinned

public

Requests to pin a new shape

public

Rerenders the whole component

public

serialize(): {"shapes": *}

Serializes the pinned shapes

public

Unpins a shape

public

update()

Updates all amount labels

public

Updates all shapes after an upgrade has been purchased and removes the unused ones

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 Constructors

public constructor() source

Override:

BaseHUDPart#constructor

Public Members

public element: * source

public handles: Array<{ key: string, definition: ShapeDefinition, amountLabel: HTMLElement, lastRenderedValue: string, element: HTMLElement, detector?: ClickDetector, infoDetector?: ClickDetector, throughputOnly?: boolean }> source

Store handles to the currently rendered elements, so we can update them more convenient. Also allows for cleaning up handles.

public pinnedShapes: Array<string> source

Store a list of pinned shapes

Public Methods

public createElements(parent: *) source

Should create all require elements

Override:

BaseHUDPart#createElements

Params:

NameTypeAttributeDescription
parent *

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

Deserializes the pinned shapes

Params:

NameTypeAttributeDescription
data {shapes: Array<string>}

Return:

string

public findGoalValueForShape(key: string): * source

Finds the current goal for the given key. If the key is the story goal, returns the story goal. If its the blueprint shape, no goal is returned. Otherwise it's searched for upgrades.

Params:

NameTypeAttributeDescription
key string

Return:

*

public initialize() source

Initializes the hud component

Override:

BaseHUDPart#initialize

public internalPinShape(param0: object) source

Pins a new shape

Params:

NameTypeAttributeDescription
param0 object
param0.key string
param0.canUnpin boolean=
param0.className string=
param0.throughputOnly boolean=

public isShapePinned(key: string): * source

Returns whether a given shape is currently pinned

Params:

NameTypeAttributeDescription
key string

Return:

*

public pinNewShape(definition: ShapeDefinition) source

Requests to pin a new shape

Params:

NameTypeAttributeDescription
definition ShapeDefinition

public rerenderFull() source

Rerenders the whole component

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

Serializes the pinned shapes

Return:

{"shapes": *}

public unpinShape(key: string) source

Unpins a shape

Params:

NameTypeAttributeDescription
key string

public update() source

Updates all amount labels

Override:

BaseHUDPart#update

public updateShapesAfterUpgrade() source

Updates all shapes after an upgrade has been purchased and removes the unused ones