A CanvasLayer for displaying UI controls which are overlayed on top of other layers.

We track three types of events:

  1. Cursor movement
  2. Ruler measurement
  3. Map pings

Hierarchy (View Summary)

Properties

_rulerPaths: Container<DisplayObject>

The ruler paths.

A container of cursor interaction elements not bound to stage transforms. Contains cursors elements.

debug: Graphics

A graphics instance used for drawing debugging visualization

doors: Container<DisplayObject>

A container of DoorControl instances

eventMode: string = "passive"
options: { name: string } = ...

Options for this layer instance.

pings: Container<DisplayObject>

A container of pings interaction elements. Contains pings elements.

select: Graphics

The Canvas selection rectangle

Accessors

  • get active(): boolean

    Is this layer currently active

    Returns boolean

  • get hookName(): string

    The name used by hooks to construct their hook string. Note: You should override this getter if hookName should not return the class constructor name.

    Returns string

  • get name(): string

    The canonical name of the CanvasLayer is the name of the constructor that is the immediate child of the defined baseClass for the layer type.

    Returns string

    canvas.lighting.name -> "LightingLayer"
    
  • get ruler(): BaseRuler

    A convenience accessor to the Ruler for the active game user

    Returns BaseRuler

  • get instance(): CanvasLayer

    Return a reference to the active instance of this canvas layer

    Returns CanvasLayer

  • get layerOptions(): object

    Returns object

Methods

  • Parameters

    • options: any

    Returns Promise<void>

  • Internal

    Handle mousemove events on the game canvas to broadcast activity. With SHOW_CURSOR permission enabled, the user's cursor position is transmitted.

    Parameters

    • currentPos: Point

    Returns void

  • Activate the InteractionLayer, deactivating other layers and marking this layer's children as interactive.

    Parameters

    • Optionaloptions: { tool?: string } = {}

      Options which configure layer activation

      • Optionaltool?: string

        A specific tool in the control palette to set as active

    Returns InteractionLayer

    The layer instance, now activated

  • Draw the canvas layer, rendering its internal components and returning a Promise. The Promise resolves to the drawn layer once its contents are successfully rendered.

    Parameters

    • Optionaloptions: object = {}

      Options which configure how the layer is drawn

    Returns Promise<CanvasLayer>

  • Create and draw the Cursor object for a given User.

    Parameters

    • user: documents.User

      The User document for whom to draw the cursor Container

    Returns Cursor

  • Draw the cursors container

    Returns void

  • Draw door control icons to the doors container.

    Returns void

  • Draw a ping at the edge of the viewport, pointing to the location of an off-screen ping.

    Parameters

    • position: Point

      The coordinates of the off-screen ping.

    • Optionaloptions: any = {}

      Additional options to configure how the ping is drawn.

    Returns Promise<boolean>

    A promise which resolves once the Ping has been drawn and animated.

  • Draw a ping on the canvas.

    Parameters

    • position: Point

      The position on the canvas that was pinged.

    • Optionaloptions: any = {}

      Additional options to configure how the ping is drawn.

    Returns Promise<boolean>

    A promise which resolves once the Ping has been drawn and animated.

  • Create and draw the Ruler object for a given User.

    Parameters

    • user: documents.User

      The User document for whom to draw the Ruler

    Returns Promise<BaseRuler>

    The Ruler instance

  • Create and add Ruler instances for every game User.

    Returns Promise<void>

  • Draw the select rectangle given an event originated within the base canvas layer

    Parameters

    Returns void

  • Get the Cursor instance for a specific User ID.

    Parameters

    • userId: string

      The User ID

    Returns null | Cursor

  • Get the Ruler instance for a specific User ID.

    Parameters

    • userId: string

      The User ID

    Returns null | BaseRuler

  • Get the zIndex that should be used for ordering this layer vertically relative to others in the same Container.

    Returns number

  • Handle a broadcast ping.

    Parameters

    • user: documents.User

      The user who pinged.

    • position: Point

      The position on the canvas that was pinged.

    • Optionaldata: PingData = {}

      The broadcast ping data.

    Returns Promise<boolean>

    A promise which resolves once the Ping has been drawn and animated

  • Deconstruct data used in the current layer in preparation to re-draw the canvas

    Parameters

    • Optionaloptions: object = {}

      Options which configure how the layer is deconstructed

    Returns Promise<CanvasLayer>

  • Update the cursor when the user moves to a new position

    Parameters

    • user: documents.User

      The User for whom to update the cursor

    • position: Point

      The new cursor position

    Returns void

  • Update the Ruler for a User given the provided path.

    Parameters

    • user: documents.User

      The User for whom to update the Ruler

    • data: null | { hidden: boolean; path: ElevatedPoint[] }

      The path and hidden state of the Ruler

    Returns Promise<void>

  • Protected

    The inner _activate method which may be defined by each InteractionLayer subclass.

    Returns void

  • Protected

    Does the User have permission to left-click drag on the Canvas?

    Parameters

    • user: User

      The User performing the action.

    • event: FederatedEvent<UIEvent | PixiTouch>

      The event object.

    Returns boolean

  • Protected

    Highlight the objects of this layer.

    Parameters

    • active: boolean

      Should the objects of this layer be highlighted?

    Returns void

  • Protected

    Handle the canvas panning to a new view.

    Returns void

  • Protected

    Handle left mouse-click events which originate from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Handle double left-click events which originate from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Handle right mouse-click events which originate from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Handle double right mouse-click events which originate from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Handle a Copy keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The copy key press event

    Returns boolean

    Was the event handled?

  • Protected

    Handle a Cut keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The cut key press event

    Returns boolean

    Was the event handled?

  • Protected

    Handle a Cycle View keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The cycle-view key press event

    Returns boolean

    Was the event handled?

  • Protected

    Handle a Delete keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The delete key press event

    Returns boolean

    Was the event handled?

  • Protected

    Handle a Dismiss keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The dismiss key press event

    Returns boolean

    Was the event handled?

  • Protected

    Cancel a left-click drag workflow originating from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Conclude a left-click drag workflow originating from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Continue a left-click drag workflow originating from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Start a left-click drag workflow originating from the Canvas stage.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Handle pinging the canvas.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event.

    • origin: Point

      The local canvas coordinates of the mousepress.

    Returns undefined | Promise<boolean>

  • Protected

    Handle mouse-wheel events which occur for this active layer.

    Parameters

    • event: WheelEvent

      The WheelEvent initiated on the document

    Returns void

  • Protected

    Handle a Paste keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The paste key press event

    Returns boolean

    Was the event handled?

  • Protected

    Handle a Select All keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The select-all key press event

    Returns boolean

    Was the event handled?

  • Protected

    Handle a Undo keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The undo key press event

    Returns boolean

    Was the event handled?