import type { Observable } from "rxjs"; import { Subject } from "rxjs"; import type { RequireOnlyOne } from "../types"; import type { VideoConfig } from "../Events/Ui/PlayVideoEvent"; import { IframeApiContribution } from "./IframeApiContribution"; import type { ButtonDescriptor } from "./Ui/ButtonDescriptor"; import { Popup } from "./Ui/Popup"; import { ActionMessage } from "./Ui/ActionMessage"; import { PlayerMessage } from "./Ui/PlayerMessage"; import { Menu } from "./Ui/Menu"; import type { UIWebsiteCommands } from "./Ui/UIWebsite"; import { RemotePlayer } from "./Players/RemotePlayer"; import type { WorkadventureModalCommands } from "./Ui/Modal"; import type { WorkAdventureButtonActionBarCommands } from "./Ui/ButtonActionBar"; import type { WorkadventureBannerCommands } from "./Ui/Banner"; import { Video } from "./Ui/Video"; interface MenuDescriptor { callback?: (commandDescriptor: string) => void; iframe?: string; allowApi?: boolean; /** * A unique technical key identifying this menu */ key?: string; /** * The "allow" attribute of the iframe tag. */ allow?: string; } export type MenuOptions = RequireOnlyOne; export interface ActionMessageOptions { message: string; type?: "message" | "warning"; callback: () => void; } export interface PlayerMessageOptions { message: string; type?: "message"; callback: () => void; } export declare class ActionsMenuAction { private remotePlayer; private key; private callback; constructor(remotePlayer: RemotePlayer, key: string, callback: () => void); call(): void; remove(): void; } export declare class WorkAdventureUiCommands extends IframeApiContribution { readonly _onRemotePlayerClicked: Subject; readonly onRemotePlayerClicked: Observable; private currentlyClickedRemotePlayer?; constructor(); callbacks: ({ type: "buttonClickedEvent"; callback: (event: { popupId: number; buttonId: number; }) => void; } | { type: "menuItemClicked"; callback: (event: { menuItem: string; }) => void; } | { type: "messageTriggered"; callback: (event: { uuid: string; }) => void; } | { type: "remotePlayerClickedEvent"; callback: (event: { name: string; position: { x: number; y: number; }; playerId: number; variables: Map; userUuid: string; availabilityStatus: string; outlineColor?: number | undefined; chatID?: string | null | undefined; }) => void; } | { type: "actionsMenuActionClickedEvent"; callback: (event: { id: number; actionName: string; }) => void; })[]; /** * Open a popup in front of the game. * {@link https://docs.workadventu.re/map-building/api-ui.md#opening-a-popup | Website documentation} * * @param {string} targetObject Targeted object name * @param {string} message Message to display * @param {ButtonDescriptor[]} buttons Buttons displayed below popup * @returns {Popup} Popup created */ openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup; /** * Add a custom menu item containing the text commandDescriptor in the navbar of the menu. options attribute accepts an object. * {@link https://docs.workadventu.re/map-building/api-ui.md#add-custom-menu | Website documentation} * * @param {string} commandDescriptor Command description * @param {MenuOptions | ((commandDescriptor: string) => void)} options Manu options * @returns {Menu} Menu created */ registerMenuCommand(commandDescriptor: string, options: MenuOptions | ((commandDescriptor: string) => void)): Menu; /** * Retrieves a menu from its key. * Keys are set when the menu is created with `registerMenuCommand` * In addition, the standard menus have the following keys: "settings", "profile", "invite", "credit", "globalMessages", "contact", "report" */ getMenuCommand(key: string): Promise; addActionsMenuKeyToRemotePlayer(id: number, actionKey: string): void; removeActionsMenuKeyFromRemotePlayer(id: number, actionKey: string): void; /** * Display a bubble like in proximity meeting (Draft function). * Todo: enhanced bubble functions behaviors */ displayBubble(): void; /** * Remove a bubble like in proximity meeting. * Todo: enhanced bubble functions behaviors */ removeBubble(): void; /** * Displays a message at the bottom of the screen (that will disappear when space bar is pressed). * {@link https://docs.workadventu.re/map-building/api-ui.md#awaiting-user-confirmation-with-space-bar | Website documentation} * * @param {ActionMessageOptions} actionMessageOptions Action options * @returns {ActionMessage} Trigger action message */ displayActionMessage(actionMessageOptions: ActionMessageOptions): ActionMessage; /** * Displays a player message at the top of the user head (that will disappear when space bar is pressed). * {@link https://docs.workadventu.re/map-building/api-ui.md#awaiting-user-confirmation-with-space-bar | Website documentation} * * @param {PlayerMessageOptions} playerMessageOptions player options * @returns {PlayerMessage} Trigger player message */ displayPlayerMessage(playerMessageOptions: PlayerMessageOptions): PlayerMessage; get website(): UIWebsiteCommands; get modal(): WorkadventureModalCommands; get actionBar(): WorkAdventureButtonActionBarCommands; get banner(): WorkadventureBannerCommands; /** * Plays a video as if the video was a player talking to us. */ playVideo(videoUrl: string, config?: VideoConfig): Promise