Options
All
  • Public
  • Public/Protected
  • All
Menu

The Chat Bubble Class This application displays a temporary message sent from a particular Token in the active Scene. The message is displayed on the HUD layer just above the Token.

Hierarchy

  • ChatBubbles

Index

Constructors

Properties

template: string
bubbles: any

Track active Chat Bubbles

Accessors

  • get container(): jQuery
  • A reference to the chat bubbles HTML container in which rendered bubbles should live

    Returns jQuery

Methods

  • broadcast(token: TokenDocument, message: string, options?: (new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean) => HTMLOptionElement)): Promise<any>
  • Create a chat bubble message for a certain token which is synchronized for display across all connected clients.

    Parameters

    • token: TokenDocument

      The speaking Token Document

    • message: string

      The spoken message text

    • options: (new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean) => HTMLOptionElement) = {}
        • new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement
        • Parameters

          • Optional text: string
          • Optional value: string
          • Optional defaultSelected: boolean
          • Optional selected: boolean

          Returns HTMLOptionElement

    Returns Promise<any>

    A promise which resolves with the created bubble HTML, or null

  • say(token: Token, message: string, [options]?: (new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean) => HTMLOptionElement)): Promise<any>
  • Speak a message as a particular Token, displaying it as a chat bubble

    Parameters

    • token: Token

      The speaking Token

    • message: string

      The spoken message text

    • [options]: (new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean) => HTMLOptionElement) = {}

      Options which affect the bubble appearance

        • new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement
        • Parameters

          • Optional text: string
          • Optional value: string
          • Optional defaultSelected: boolean
          • Optional selected: boolean

          Returns HTMLOptionElement

    Returns Promise<any>

    A Promise which resolves to the created bubble HTML element, or null

  • _getDuration(html: jQuery): number
  • Determine the length of time for which to display a chat bubble. Research suggests that average reading speed is 200 words per minute. Since these are short-form messages, we multiply reading speed by 1.5. Clamp the result between 1 second (minimum) and 20 seconds (maximum)

    Parameters

    • html: jQuery

      The HTML message

    Returns number

    The number of milliseconds for which to display the message

  • _clearBubble(token: Token): Promise<any>
  • Clear any existing chat bubble for a certain Token

    Parameters

    Returns Promise<any>

  • _renderHTML(data: any): Promise<string>
  • Render the HTML template for the chat bubble

    Parameters

    • data: any

      Template data

    Returns Promise<string>

    The rendered HTML

  • _getMessageDimensions(message: string): any
  • Before displaying the chat message, determine it's constrained and unconstrained dimensions

    Parameters

    • message: string

      The message content

    Returns any

    The rendered message dimensions

  • _setPosition(token: Token, html: JQuery, dimensions: Rectangle): void
  • Assign styling parameters to the chat bubble, toggling either a left or right display (randomly)

    Parameters

    • token: Token

      The speaking Token

    • html: JQuery

      Chat bubble content

    • dimensions: Rectangle

      Positioning data

    Returns void

  • _activateSocketListeners(socket: Socket): void
  • Activate Socket event listeners which apply to the ChatBubbles UI.

    internal

    Parameters

    • socket: Socket

      The active web socket connection

    Returns void