add internal link widget handler

This commit is contained in:
dank074 2022-03-16 21:17:12 -05:00
parent 34b8f855e4
commit b35ca4b23e
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,54 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { CreateLinkEvent } from '../../../CreateLinkEvent';
import { GetRoomEngine } from '../../GetRoomEngine';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureInternalLinkHandler extends RoomWidgetHandler
{
private static readonly INTERNALLINK = 'internalLink';
public processEvent(event: NitroEvent): void
{
if(!event) return;
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK:
const linkEvent = event as RoomEngineTriggerWidgetEvent;
const roomEngine = GetRoomEngine();
if(!linkEvent || !roomEngine) return;
const object = roomEngine.getRoomObject(linkEvent.roomId, linkEvent.objectId, linkEvent.category);
if(object)
{
let data = object.model.getValue<any>(RoomObjectVariable.FURNITURE_DATA);
let link = data[FurnitureInternalLinkHandler.INTERNALLINK];
console.log(link);
if(!link || !link.length) link = object.model.getValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK);
if(link && link.length) CreateLinkEvent(link);
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
return null;
}
public get type(): string
{
return RoomWidgetEnum.INTERNAL_LINK;
}
public get eventTypes(): string[]
{
return [RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,6 +1,7 @@
import { EventDispatcher, IRoomSession, NitroRectangle, RoomGeometry, RoomVariableEnum, Vector3d } from '@nitrots/nitro-renderer'; import { EventDispatcher, IRoomSession, NitroRectangle, RoomGeometry, RoomVariableEnum, Vector3d } from '@nitrots/nitro-renderer';
import { FC, useEffect, useRef, useState } from 'react'; import { FC, useEffect, useRef, useState } from 'react';
import { DispatchMouseEvent, DispatchTouchEvent, DoorbellWidgetHandler, FriendRequestHandler, FurniChooserWidgetHandler, FurnitureContextMenuWidgetHandler, FurnitureCreditWidgetHandler, FurnitureCustomStackHeightWidgetHandler, FurnitureDimmerWidgetHandler, FurnitureExternalImageWidgetHandler, FurnitureMannequinWidgetHandler, FurniturePresentWidgetHandler, FurnitureYoutubeDisplayWidgetHandler, GetNitroInstance, GetRoomEngine, InitializeRoomInstanceRenderingCanvas, IRoomWidgetHandlerManager, PollWidgetHandler, RoomWidgetAvatarInfoHandler, RoomWidgetChatHandler, RoomWidgetChatInputHandler, RoomWidgetHandlerManager, RoomWidgetInfostandHandler, RoomWidgetRoomToolsHandler, RoomWidgetUpdateRoomViewEvent, UserChooserWidgetHandler, WordQuizWidgetHandler } from '../../api'; import { DispatchMouseEvent, DispatchTouchEvent, DoorbellWidgetHandler, FriendRequestHandler, FurniChooserWidgetHandler, FurnitureContextMenuWidgetHandler, FurnitureCreditWidgetHandler, FurnitureCustomStackHeightWidgetHandler, FurnitureDimmerWidgetHandler, FurnitureExternalImageWidgetHandler, FurnitureMannequinWidgetHandler, FurniturePresentWidgetHandler, FurnitureYoutubeDisplayWidgetHandler, GetNitroInstance, GetRoomEngine, InitializeRoomInstanceRenderingCanvas, IRoomWidgetHandlerManager, PollWidgetHandler, RoomWidgetAvatarInfoHandler, RoomWidgetChatHandler, RoomWidgetChatInputHandler, RoomWidgetHandlerManager, RoomWidgetInfostandHandler, RoomWidgetRoomToolsHandler, RoomWidgetUpdateRoomViewEvent, UserChooserWidgetHandler, WordQuizWidgetHandler } from '../../api';
import { FurnitureInternalLinkHandler } from '../../api/nitro/room/widgets/handlers/FurnitureInternalLinkHandler';
import { Base } from '../../common'; import { Base } from '../../common';
import { RoomColorView } from './RoomColorView'; import { RoomColorView } from './RoomColorView';
import { RoomContextProvider } from './RoomContext'; import { RoomContextProvider } from './RoomContext';
@ -52,6 +53,7 @@ export const RoomView: FC<RoomViewProps> = props =>
widgetHandlerManager.registerHandler(new FurnitureDimmerWidgetHandler()); widgetHandlerManager.registerHandler(new FurnitureDimmerWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureYoutubeDisplayWidgetHandler()); widgetHandlerManager.registerHandler(new FurnitureYoutubeDisplayWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureMannequinWidgetHandler()); widgetHandlerManager.registerHandler(new FurnitureMannequinWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureInternalLinkHandler());
setWidgetHandler(widgetHandlerManager); setWidgetHandler(widgetHandlerManager);