More widget updates

This commit is contained in:
Bill 2022-04-29 12:19:08 -04:00
parent 0be763c59b
commit 08804ea5b7
37 changed files with 643 additions and 908 deletions

View File

@ -1,27 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateYoutubeDisplayEvent extends RoomWidgetUpdateEvent
{
public static UPDATE_YOUTUBE_DISPLAY: string = 'RWUEIE_UPDATE_YOUTUBE_DISPLAY';
private _objectId: number;
private _hasControl: boolean;
constructor(objectId: number, hasControl = false)
{
super(RoomWidgetUpdateYoutubeDisplayEvent.UPDATE_YOUTUBE_DISPLAY);
this._objectId = objectId;
this._hasControl = hasControl;
}
public get objectId(): number
{
return this._objectId;
}
public get hasControl(): boolean
{
return this._hasControl;
}
}

View File

@ -25,7 +25,6 @@ export * from './RoomWidgetUpdateRoomObjectEvent';
export * from './RoomWidgetUpdateSongEvent'; export * from './RoomWidgetUpdateSongEvent';
export * from './RoomWidgetUpdateTrophyEvent'; export * from './RoomWidgetUpdateTrophyEvent';
export * from './RoomWidgetUpdateUserDataEvent'; export * from './RoomWidgetUpdateUserDataEvent';
export * from './RoomWidgetUpdateYoutubeDisplayEvent';
export * from './RoomWidgetUseProductBubbleEvent'; export * from './RoomWidgetUseProductBubbleEvent';
export * from './RoomWidgetWordQuizUpdateEvent'; export * from './RoomWidgetWordQuizUpdateEvent';
export * from './UseProductItem'; export * from './UseProductItem';

View File

@ -1,112 +0,0 @@
import { NitroEvent, RoomControllerLevel, RoomEngineDimmerStateEvent, RoomEngineTriggerWidgetEvent, RoomSessionDimmerPresetsEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { GetRoomEngine } from '../..';
import { GetSessionDataManager } from '../../..';
import { RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetDimmerChangeStateMessage, RoomWidgetDimmerPreviewMessage, RoomWidgetDimmerSavePresetMessage, RoomWidgetFurniToWidgetMessage, RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureDimmerWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS: {
const presetsEvent = (event as RoomSessionDimmerPresetsEvent);
const updateEvent = new RoomWidgetUpdateDimmerEvent(RoomWidgetUpdateDimmerEvent.PRESETS);
updateEvent.selectedPresetId = presetsEvent.selectedPresetId;
let i = 0;
while(i < presetsEvent.presetCount)
{
const preset = presetsEvent.getPreset(i);
if(preset) updateEvent.setPresetValues(preset.id, preset.type, preset.color, preset.brightness);
i++;
}
this.container.eventDispatcher.dispatchEvent(updateEvent);
return;
}
case RoomEngineDimmerStateEvent.ROOM_COLOR: {
const stateEvent = (event as RoomEngineDimmerStateEvent);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateDimmerStateEvent(stateEvent.state, stateEvent.presetId, stateEvent.effectId, stateEvent.color, stateEvent.brightness));
return;
}
case RoomEngineTriggerWidgetEvent.REMOVE_DIMMER: {
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateDimmerEvent(RoomWidgetUpdateDimmerEvent.HIDE));
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
case RoomWidgetFurniToWidgetMessage.REQUEST_DIMMER: {
if(this.canOpenWidget()) this.container.roomSession.requestMoodlightSettings();
break;
}
case RoomWidgetDimmerSavePresetMessage.SAVE_PRESET: {
if(this.canOpenWidget())
{
const savePresetMessage = (message as RoomWidgetDimmerSavePresetMessage);
this.container.roomSession.updateMoodlightData(savePresetMessage.presetNumber, savePresetMessage.effectTypeId, savePresetMessage.color, savePresetMessage.brightness, savePresetMessage.apply);
}
break;
}
case RoomWidgetDimmerChangeStateMessage.CHANGE_STATE: {
if(this.canOpenWidget()) this.container.roomSession.toggleMoodlightState();
break;
}
case RoomWidgetDimmerPreviewMessage.PREVIEW_DIMMER_PRESET: {
const roomId = this.container.roomSession.roomId;
const previewMessage = (message as RoomWidgetDimmerPreviewMessage);
GetRoomEngine().updateObjectRoomColor(roomId, previewMessage.color, previewMessage.brightness, previewMessage.bgOnly);
break;
}
}
return null;
}
private canOpenWidget(): boolean
{
return (this.container.roomSession.isRoomOwner || (this.container.roomSession.controllerLevel >= RoomControllerLevel.GUEST) || GetSessionDataManager().isModerator);
}
public get type(): string
{
return RoomWidgetEnum.ROOM_DIMMER;
}
public get eventTypes(): string[]
{
return [
RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS,
RoomEngineDimmerStateEvent.ROOM_COLOR,
RoomEngineTriggerWidgetEvent.REMOVE_DIMMER
];
}
public get messageTypes(): string[]
{
return [
RoomWidgetFurniToWidgetMessage.REQUEST_DIMMER,
RoomWidgetDimmerSavePresetMessage.SAVE_PRESET,
RoomWidgetDimmerChangeStateMessage.CHANGE_STATE,
RoomWidgetDimmerPreviewMessage.PREVIEW_DIMMER_PRESET
];
}
}

View File

@ -1,53 +0,0 @@
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];
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,59 +0,0 @@
import { IMessageEvent, 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 FurnitureRoomLinkHandler extends RoomWidgetHandler
{
private static readonly INTERNALLINK = 'internalLink';
private onRoomInfo(event: IMessageEvent): void
{
//todo
}
public processEvent(event: NitroEvent): void
{
if(!event) return;
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK:
const roomLinkEvent = (event as RoomEngineTriggerWidgetEvent);
const roomEngine = GetRoomEngine();
if(!roomLinkEvent || !roomEngine) return;
const object = roomEngine.getRoomObject(roomLinkEvent.roomId, roomLinkEvent.objectId, roomLinkEvent.category);
if(object)
{
const data = object.model.getValue<any>(RoomObjectVariable.FURNITURE_DATA);
let roomId = data[FurnitureRoomLinkHandler.INTERNALLINK];
if(!roomId || !roomId.length) roomId = object.model.getValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK);
if(roomId && roomId.length) CreateLinkEvent('navigator/goto/' + roomId);
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
return null;
}
public get type(): string
{
return RoomWidgetEnum.ROOM_LINK;
}
public get eventTypes(): string[]
{
return [ RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK ];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,70 +0,0 @@
import { GetYoutubeDisplayStatusMessageComposer, NitroEvent, RoomWidgetEnum, SecurityLevel } from '@nitrots/nitro-renderer';
import { RoomEngineTriggerWidgetEvent } from '@nitrots/nitro-renderer/';
import { RoomWidgetMessage, RoomWidgetUpdateEvent } from '..';
import { GetSessionDataManager, IsOwnerOfFurniture, SendMessageComposer } from '../../..';
import { GetRoomEngine } from '../../GetRoomEngine';
import { RoomWidgetUpdateYoutubeDisplayEvent } from '../events';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureYoutubeDisplayWidgetHandler extends RoomWidgetHandler
{
public static readonly CONTROL_COMMAND_PREVIOUS_VIDEO = 0;
public static readonly CONTROL_COMMAND_NEXT_VIDEO = 1;
public static readonly CONTROL_COMMAND_PAUSE_VIDEO = 2;
public static readonly CONTROL_COMMAND_CONTINUE_VIDEO = 3;
private _lastFurniId: number = -1;
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.OPEN_WIDGET: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category);
if(!roomObject) return;
this._lastFurniId = widgetEvent.objectId;
const hasControl = GetSessionDataManager().hasSecurity(SecurityLevel.EMPLOYEE) || IsOwnerOfFurniture(roomObject);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateYoutubeDisplayEvent(roomObject.id, hasControl));
SendMessageComposer(new GetYoutubeDisplayStatusMessageComposer(this._lastFurniId));
return;
}
case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
if(widgetEvent.objectId !== this._lastFurniId) return;
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateYoutubeDisplayEvent(-1));
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.YOUTUBE;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,8 +1,4 @@
export * from './FurnitureContextMenuWidgetHandler'; export * from './FurnitureContextMenuWidgetHandler';
export * from './FurnitureDimmerWidgetHandler';
export * from './FurnitureInternalLinkHandler';
export * from './FurnitureRoomLinkHandler';
export * from './FurnitureYoutubeDisplayWidgetHandler';
export * from './IRoomWidgetHandler'; export * from './IRoomWidgetHandler';
export * from './IRoomWidgetHandlerManager'; export * from './IRoomWidgetHandlerManager';
export * from './PollWidgetHandler'; export * from './PollWidgetHandler';

View File

@ -1,11 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetDimmerChangeStateMessage extends RoomWidgetMessage
{
public static CHANGE_STATE: string = 'RWCDSM_CHANGE_STATE';
constructor()
{
super(RoomWidgetDimmerChangeStateMessage.CHANGE_STATE);
}
}

View File

@ -1,34 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetDimmerPreviewMessage extends RoomWidgetMessage
{
public static PREVIEW_DIMMER_PRESET: string = 'RWDPM_PREVIEW_DIMMER_PRESET';
private _color: number;
private _brightness: number;
private _bgOnly: boolean;
constructor(color: number, brightness: number, bgOnly: boolean)
{
super(RoomWidgetDimmerPreviewMessage.PREVIEW_DIMMER_PRESET);
this._color = color;
this._brightness = brightness;
this._bgOnly = bgOnly;
}
public get color(): number
{
return this._color;
}
public get brightness(): number
{
return this._brightness;
}
public get bgOnly(): boolean
{
return this._bgOnly;
}
}

View File

@ -1,48 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetDimmerSavePresetMessage extends RoomWidgetMessage
{
public static SAVE_PRESET: string = 'RWSDPM_SAVE_PRESET';
private _presetNumber: number;
private _effectTypeId: number;
private _color: number;
private _brightness: number;
private _apply: boolean;
constructor(presetNumber: number, effectTypeId: number, color: number, brightness: number, apply: boolean)
{
super(RoomWidgetDimmerSavePresetMessage.SAVE_PRESET);
this._presetNumber = presetNumber;
this._effectTypeId = effectTypeId;
this._color = color;
this._brightness = brightness;
this._apply = apply;
}
public get presetNumber(): number
{
return this._presetNumber;
}
public get effectTypeId(): number
{
return this._effectTypeId;
}
public get color(): number
{
return this._color;
}
public get brightness(): number
{
return this._brightness;
}
public get apply(): boolean
{
return this._apply;
}
}

View File

@ -4,13 +4,9 @@ export class RoomWidgetFurniToWidgetMessage extends RoomWidgetMessage
{ {
public static REQUEST_TEASER: string = 'RWFWM_MESSAGE_REQUEST_TEASER'; public static REQUEST_TEASER: string = 'RWFWM_MESSAGE_REQUEST_TEASER';
public static REQUEST_ECOTRONBOX: string = 'RWFWM_MESSAGE_REQUEST_ECOTRONBOX'; public static REQUEST_ECOTRONBOX: string = 'RWFWM_MESSAGE_REQUEST_ECOTRONBOX';
public static REQUEST_DIMMER: string = 'RWFWM_MESSAGE_REQUEST_DIMMER';
public static REQUEST_PLACEHOLDER: string = 'RWFWM_MESSAGE_REQUEST_PLACEHOLDER'; public static REQUEST_PLACEHOLDER: string = 'RWFWM_MESSAGE_REQUEST_PLACEHOLDER';
public static REQUEST_CLOTHING_CHANGE: string = 'RWFWM_MESSAGE_REQUEST_CLOTHING_CHANGE'; public static REQUEST_CLOTHING_CHANGE: string = 'RWFWM_MESSAGE_REQUEST_CLOTHING_CHANGE';
public static REQUEST_PLAYLIST_EDITOR: string = 'RWFWM_MESSAGE_REQUEST_PLAYLIST_EDITOR'; public static REQUEST_PLAYLIST_EDITOR: string = 'RWFWM_MESSAGE_REQUEST_PLAYLIST_EDITOR';
public static REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING: string = 'RWFWM_WIDGET_MESSAGE_REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING';
public static REQUEST_ACHIEVEMENT_RESOLUTION_FAILED: string = 'RWFWM_WIDGET_MESSAGE_REQUEST_ACHIEVEMENT_RESOLUTION_FAILED';
public static REQUEST_BADGE_DISPLAY_ENGRAVING: string = 'RWFWM_WIDGET_MESSAGE_REQUEST_BADGE_DISPLAY_ENGRAVING';
private _objectId: number; private _objectId: number;
private _category: number; private _category: number;

View File

@ -6,9 +6,6 @@ export * from './RoomWidgetChatSelectAvatarMessage';
export * from './RoomWidgetChatTypingMessage'; export * from './RoomWidgetChatTypingMessage';
export * from './RoomWidgetCreditFurniRedeemMessage'; export * from './RoomWidgetCreditFurniRedeemMessage';
export * from './RoomWidgetDanceMessage'; export * from './RoomWidgetDanceMessage';
export * from './RoomWidgetDimmerChangeStateMessage';
export * from './RoomWidgetDimmerPreviewMessage';
export * from './RoomWidgetDimmerSavePresetMessage';
export * from './RoomWidgetFurniActionMessage'; export * from './RoomWidgetFurniActionMessage';
export * from './RoomWidgetFurniToWidgetMessage'; export * from './RoomWidgetFurniToWidgetMessage';
export * from './RoomWidgetMessage'; export * from './RoomWidgetMessage';

View File

@ -1 +1,3 @@
export * from './DimmerFurnitureWidgetPresetItem';
export * from './MannequinUtilities'; export * from './MannequinUtilities';
export * from './YoutubeVideoPlaybackStateEnum';

View File

@ -1,6 +1,6 @@
import { RoomEngineEvent, RoomEngineObjectEvent, RoomEngineRoomAdEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomId, RoomObjectVariable, RoomSessionChatEvent, RoomSessionDanceEvent, RoomSessionDimmerPresetsEvent, RoomSessionErrorMessageEvent, RoomSessionEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionPollEvent, RoomSessionUserBadgesEvent, RoomSessionUserFigureUpdateEvent, RoomSessionWordQuizEvent, RoomZoomEvent } from '@nitrots/nitro-renderer'; import { RoomEngineEvent, RoomEngineObjectEvent, RoomEngineRoomAdEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomId, RoomSessionChatEvent, RoomSessionDanceEvent, RoomSessionDimmerPresetsEvent, RoomSessionErrorMessageEvent, RoomSessionEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionPollEvent, RoomSessionUserBadgesEvent, RoomSessionUserFigureUpdateEvent, RoomSessionWordQuizEvent, RoomZoomEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback } from 'react'; import { FC, useCallback } from 'react';
import { GetRoomEngine, GetSessionDataManager, LocalizeText, NotificationAlertType, NotificationUtilities, RoomWidgetFurniToWidgetMessage, RoomWidgetUpdateRoomEngineEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../api'; import { GetRoomEngine, LocalizeText, NotificationAlertType, NotificationUtilities, RoomWidgetFurniToWidgetMessage, RoomWidgetUpdateRoomEngineEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../api';
import { DispatchUiEvent, UseRoomEngineEvent, UseRoomSessionManagerEvent } from '../../../hooks'; import { DispatchUiEvent, UseRoomEngineEvent, UseRoomSessionManagerEvent } from '../../../hooks';
import { useRoomContext } from '../RoomContext'; import { useRoomContext } from '../RoomContext';
import { AvatarInfoWidgetView } from './avatar-info/AvatarInfoWidgetView'; import { AvatarInfoWidgetView } from './avatar-info/AvatarInfoWidgetView';
@ -73,9 +73,6 @@ export const RoomWidgetsView: FC<{}> = props =>
case RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX: case RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX:
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_ECOTRONBOX, objectId, category, event.roomId)); widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_ECOTRONBOX, objectId, category, event.roomId));
break; break;
case RoomEngineTriggerWidgetEvent.REQUEST_DIMMER:
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_DIMMER, objectId, category, event.roomId));
break;
case RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER: case RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER:
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_PLACEHOLDER, objectId, category, event.roomId)); widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_PLACEHOLDER, objectId, category, event.roomId));
break; break;
@ -85,35 +82,12 @@ export const RoomWidgetsView: FC<{}> = props =>
case RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR: case RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR:
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_PLAYLIST_EDITOR, objectId, category, event.roomId)); widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_PLAYLIST_EDITOR, objectId, category, event.roomId));
break; break;
case RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING:
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, objectId, category, event.roomId));
break;
case RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING:
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_BADGE_DISPLAY_ENGRAVING, objectId, category, event.roomId));
break;
case RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED: {
const roomObject = GetRoomEngine().getRoomObject(event.roomId, objectId, category);
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
if(ownerId === GetSessionDataManager().userId)
{
widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, objectId, category, event.roomId));
}
break;
}
case RoomEngineTriggerWidgetEvent.OPEN_WIDGET: case RoomEngineTriggerWidgetEvent.OPEN_WIDGET:
case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET: case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET:
case RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU: case RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU:
case RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU: case RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU:
case RoomEngineTriggerWidgetEvent.REMOVE_DIMMER:
case RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY: case RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY:
case RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM: case RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM:
case RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR:
case RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING:
case RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY:
case RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY:
case RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK:
case RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK:
widgetHandler.processEvent(event); widgetHandler.processEvent(event);
break; break;
case RoomEngineRoomAdEvent.FURNI_CLICK: case RoomEngineRoomAdEvent.FURNI_CLICK:
@ -143,26 +117,15 @@ export const RoomWidgetsView: FC<{}> = props =>
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TEASER, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TEASER, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_CLICK, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_CLICK, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_DOUBLE_CLICK, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_DOUBLE_CLICK, onRoomEngineObjectEvent);
UseRoomEngineEvent(RoomEngineRoomAdEvent.TOOLTIP_SHOW, onRoomEngineObjectEvent); UseRoomEngineEvent(RoomEngineRoomAdEvent.TOOLTIP_SHOW, onRoomEngineObjectEvent);

View File

@ -2,11 +2,10 @@ import { NitroEvent } from '@nitrots/nitro-renderer';
import classNames from 'classnames'; import classNames from 'classnames';
import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { FC, useCallback, useEffect, useMemo, useState } from 'react';
import ReactSlider from 'react-slider'; import ReactSlider from 'react-slider';
import { ColorUtils, GetConfiguration, LocalizeText, RoomWidgetDimmerChangeStateMessage, RoomWidgetDimmerPreviewMessage, RoomWidgetDimmerSavePresetMessage, RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent } from '../../../../../api'; import { ColorUtils, DimmerFurnitureWidgetPresetItem, GetConfiguration, LocalizeText, RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent } from '../../../../api';
import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, Text } from '../../../../../common'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, Text } from '../../../../common';
import { UseEventDispatcherHook } from '../../../../../hooks'; import { UseEventDispatcherHook, useFurnitureDimmerWidget } from '../../../../hooks';
import { useRoomContext } from '../../../RoomContext'; import { useRoomContext } from '../../RoomContext';
import { DimmerFurnitureWidgetPresetItem } from './DimmerFurnitureWidgetPresetItem';
const AVAILABLE_COLORS: number[] = [ 7665141, 21495, 15161822, 15353138, 15923281, 8581961, 0 ]; const AVAILABLE_COLORS: number[] = [ 7665141, 21495, 15161822, 15353138, 15923281, 8581961, 0 ];
const HTML_COLORS: string[] = [ '#74F5F5', '#0053F7', '#E759DE', '#EA4532', '#F2F851', '#82F349', '#000000' ]; const HTML_COLORS: string[] = [ '#74F5F5', '#0053F7', '#E759DE', '#EA4532', '#F2F851', '#82F349', '#000000' ];
@ -26,6 +25,7 @@ export const FurnitureDimmerView: FC<{}> = props =>
const [ selectedEffectId, setSelectedEffectId ] = useState(0); const [ selectedEffectId, setSelectedEffectId ] = useState(0);
const [ selectedColor, setSelectedColor ] = useState(0); const [ selectedColor, setSelectedColor ] = useState(0);
const [ selectedBrightness, setSelectedBrightness ] = useState(0); const [ selectedBrightness, setSelectedBrightness ] = useState(0);
const { savePreset = null, changeState = null, previewDimmer = null } = useFurnitureDimmerWidget();
const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const onNitroEvent = useCallback((event: NitroEvent) => const onNitroEvent = useCallback((event: NitroEvent) =>
@ -85,15 +85,12 @@ export const FurnitureDimmerView: FC<{}> = props =>
const close = useCallback(() => const close = useCallback(() =>
{ {
widgetHandler.processWidgetMessage(new RoomWidgetDimmerPreviewMessage(color, brightness, (effectId === 2))); previewDimmer(color, brightness, (effectId === 2));
setIsVisible(false); setIsVisible(false);
}, [ widgetHandler, color, brightness, effectId ]); }, [ color, brightness, effectId, previewDimmer ]);
const toggleState = useCallback(() => const toggleState = () => changeState();
{
widgetHandler.processWidgetMessage(new RoomWidgetDimmerChangeStateMessage());
}, [ widgetHandler ]);
const applyChanges = useCallback(() => const applyChanges = useCallback(() =>
{ {
@ -116,8 +113,8 @@ export const FurnitureDimmerView: FC<{}> = props =>
return newValue; return newValue;
}); });
widgetHandler.processWidgetMessage(new RoomWidgetDimmerSavePresetMessage(preset.id, selectedEffectId, selectedColor, selectedBrightness, true)); savePreset(preset.id, selectedEffectId, selectedColor, selectedBrightness, true);
}, [ widgetHandler, dimmerState, selectedPresetId, presets, selectedEffectId, selectedColor, selectedBrightness ]); }, [ dimmerState, selectedPresetId, presets, selectedEffectId, selectedColor, selectedBrightness, savePreset ]);
const scaledBrightness = useCallback((value: number) => const scaledBrightness = useCallback((value: number) =>
{ {
@ -130,8 +127,8 @@ export const FurnitureDimmerView: FC<{}> = props =>
{ {
if((dimmerState === 0) && (lastDimmerState === 0)) return; if((dimmerState === 0) && (lastDimmerState === 0)) return;
widgetHandler.processWidgetMessage(new RoomWidgetDimmerPreviewMessage(selectedColor, selectedBrightness, (selectedEffectId === 2))); previewDimmer(selectedColor, selectedBrightness, (selectedEffectId === 2));
}, [ widgetHandler, dimmerState, lastDimmerState, selectedColor, selectedBrightness, selectedEffectId ]); }, [ dimmerState, lastDimmerState, selectedColor, selectedBrightness, selectedEffectId, previewDimmer ]);
if(!isVisible) return null; if(!isVisible) return null;

View File

@ -0,0 +1,60 @@
import { RoomObjectCategory } from '@nitrots/nitro-renderer';
import { FC } from 'react';
import { LocalizeText } from '../../../../api';
import { Column, Flex, Text } from '../../../../common';
import { useFurnitureHighScoreWidget } from '../../../../hooks';
import { ContextMenuHeaderView } from '../context-menu/ContextMenuHeaderView';
import { ContextMenuListView } from '../context-menu/ContextMenuListView';
import { ObjectLocationView } from '../object-location/ObjectLocationView';
export const FurnitureHighScoreView: FC<{}> = props =>
{
const { stuffDatas = null, getScoreType = null, getClearType = null } = useFurnitureHighScoreWidget();
if(!stuffDatas || !stuffDatas.size) return null;
return (
<>
{ Array.from(stuffDatas.entries()).map(([ objectId, stuffData ], index) =>
{
return (
<ObjectLocationView key={ index } objectId={ objectId } category={ RoomObjectCategory.FLOOR }>
<Column className="nitro-widget-high-score nitro-context-menu" gap={ 0 }>
<ContextMenuHeaderView>
{ LocalizeText('high.score.display.caption', [ 'scoretype', 'cleartype' ], [ LocalizeText(`high.score.display.scoretype.${ getScoreType(stuffData.scoreType) }`), LocalizeText(`high.score.display.cleartype.${ getClearType(stuffData.clearType) }`) ]) }
</ContextMenuHeaderView>
<ContextMenuListView overflow="hidden" gap={ 1 } className="h-100">
<Column gap={ 1 }>
<Flex alignItems="center">
<Text center bold variant="white" className="col-8">
{ LocalizeText('high.score.display.users.header') }
</Text>
<Text center bold variant="white" className="col-4">
{ LocalizeText('high.score.display.score.header') }
</Text>
</Flex>
<hr className="m-0" />
</Column>
<Column overflow="auto" gap={ 1 } className="overflow-y-scroll">
{ stuffData.entries.map((entry, index) =>
{
return (
<Flex key={ index } alignItems="center">
<Text center variant="white" className="col-8">
{ entry.users.join(', ') }
</Text>
<Text center variant="white" className="col-4">
{ entry.score }
</Text>
</Flex>
);
}) }
</Column>
</ContextMenuListView>
</Column>
</ObjectLocationView>
);
}) }
</>
);
}

View File

@ -0,0 +1,9 @@
import { FC } from 'react';
import { useFurnitureInternalLinkWidget } from '../../../../hooks';
export const FurnitureInternalLinkView: FC<{}> = props =>
{
const {} = useFurnitureInternalLinkWidget();
return null;
}

View File

@ -0,0 +1,9 @@
import { FC } from 'react';
import { useFurnitureRoomLinkWidget } from '../../../../hooks';
export const FurnitureRoomLinkView: FC<{}> = props =>
{
const {} = useFurnitureRoomLinkWidget();
return null;
}

View File

@ -248,8 +248,65 @@
} }
} }
} }
} }
@import "./high-score/FurnitureHighScoreView"; .nitro-widget-high-score {
@import "./youtube-tv/FurnitureYoutubeDisplayView"; width: 250px;
max-width: 250px;
height: 200px;
}
.youtube-tv-widget {
width: 600px;
height: 380px;
.youtube-video-container {
//min-height: 366px;
.empty-video {
background-color: black;
color: white;
width: 100%;
height: 100%;
text-align: center;
}
.youtubeContainer {
position: relative;
width: 100%;
height: 100%;
//height: 0;
//padding-bottom: 56.25%;
overflow: hidden;
margin-bottom: 50px;
}
.youtubeContainer iframe {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
}
.playlist-container {
overflow-y: hidden;
margin-right: -10px;
color: black;
height: 100%;
.playlist-controls {
width: 100%;
.icon {
margin-right: 10px;
margin-bottom: 10px;
}
}
.playlist-grid {
height: 100%;
width: 100%;
}
}
}

View File

@ -1,39 +1,43 @@
import { FC } from 'react'; import { FC } from 'react';
import { Base } from '../../../../common'; import { Base } from '../../../../common';
import { FurnitureContextMenuView } from './context-menu/FurnitureContextMenuView'; import { FurnitureContextMenuView } from './context-menu/FurnitureContextMenuView';
import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView';
import { FurnitureBackgroundColorView } from './FurnitureBackgroundColorView'; import { FurnitureBackgroundColorView } from './FurnitureBackgroundColorView';
import { FurnitureBadgeDisplayView } from './FurnitureBadgeDisplayView'; import { FurnitureBadgeDisplayView } from './FurnitureBadgeDisplayView';
import { FurnitureCustomStackHeightView } from './FurnitureCustomStackHeightView'; import { FurnitureCustomStackHeightView } from './FurnitureCustomStackHeightView';
import { FurnitureDimmerView } from './FurnitureDimmerView';
import { FurnitureExchangeCreditView } from './FurnitureExchangeCreditView'; import { FurnitureExchangeCreditView } from './FurnitureExchangeCreditView';
import { FurnitureExternalImageView } from './FurnitureExternalImageView'; import { FurnitureExternalImageView } from './FurnitureExternalImageView';
import { FurnitureFriendFurniView } from './FurnitureFriendFurniView'; import { FurnitureFriendFurniView } from './FurnitureFriendFurniView';
import { FurnitureGiftOpeningView } from './FurnitureGiftOpeningView'; import { FurnitureGiftOpeningView } from './FurnitureGiftOpeningView';
import { FurnitureHighScoreView } from './FurnitureHighScoreView';
import { FurnitureInternalLinkView } from './FurnitureInternalLinkView';
import { FurnitureManipulationMenuView } from './FurnitureManipulationMenuView'; import { FurnitureManipulationMenuView } from './FurnitureManipulationMenuView';
import { FurnitureMannequinView } from './FurnitureMannequinView'; import { FurnitureMannequinView } from './FurnitureMannequinView';
import { FurnitureRoomLinkView } from './FurnitureRoomLinkView';
import { FurnitureStickieView } from './FurnitureStickieView'; import { FurnitureStickieView } from './FurnitureStickieView';
import { FurnitureTrophyView } from './FurnitureTrophyView'; import { FurnitureTrophyView } from './FurnitureTrophyView';
import { FurnitureHighScoreView } from './high-score/FurnitureHighScoreView'; import { FurnitureYoutubeDisplayView } from './FurnitureYoutubeDisplayView';
import { FurnitureYoutubeDisplayView } from './youtube-tv/FurnitureYoutubeDisplayView';
export const FurnitureWidgetsView: FC<{}> = props => export const FurnitureWidgetsView: FC<{}> = props =>
{ {
return ( return (
<Base fit position="absolute" className="nitro-room-widgets top-0 start-0"> <Base fit position="absolute" className="nitro-room-widgets top-0 start-0">
<FurnitureBackgroundColorView /> <FurnitureBackgroundColorView />
<FurnitureContextMenuView /> <FurnitureBadgeDisplayView />
<FurnitureCustomStackHeightView /> <FurnitureCustomStackHeightView />
<FurnitureDimmerView /> <FurnitureDimmerView />
<FurnitureExchangeCreditView />
<FurnitureExternalImageView />
<FurnitureFriendFurniView /> <FurnitureFriendFurniView />
<FurnitureGiftOpeningView /> <FurnitureGiftOpeningView />
<FurnitureExchangeCreditView />
<FurnitureHighScoreView /> <FurnitureHighScoreView />
<FurnitureInternalLinkView />
<FurnitureManipulationMenuView /> <FurnitureManipulationMenuView />
<FurnitureMannequinView /> <FurnitureMannequinView />
<FurnitureRoomLinkView />
<FurnitureStickieView /> <FurnitureStickieView />
<FurnitureTrophyView /> <FurnitureTrophyView />
<FurnitureBadgeDisplayView /> <FurnitureContextMenuView />
<FurnitureExternalImageView />
<FurnitureYoutubeDisplayView /> <FurnitureYoutubeDisplayView />
</Base> </Base>
); );

View File

@ -0,0 +1,104 @@
import { FC, useCallback, useEffect, useState } from 'react';
import YouTube, { Options } from 'react-youtube';
import { YouTubePlayer } from 'youtube-player/dist/types';
import { LocalizeText, YoutubeVideoPlaybackStateEnum } from '../../../../api';
import { Grid, LayoutGridItem, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common';
import { useFurnitureYoutubeWidget } from '../../../../hooks';
export const FurnitureYoutubeDisplayView: FC<{}> = props =>
{
const [ player, setPlayer ] = useState<any>(null);
const { objectId = -1, videoId = null, videoStart = 0, videoEnd = 0, currentVideoState = null, selectedVideo = null, playlists = [], close = null, previous = null, next = null, pause = null, play = null, selectVideo = null } = useFurnitureYoutubeWidget();
const onStateChange = useCallback((event: { target: YouTubePlayer; data: number }) =>
{
setPlayer(event.target);
if(objectId === -1) return;
switch(event.target.getPlayerState())
{
case -1:
case 1:
if(currentVideoState === 2)
{
//event.target.pauseVideo();
}
if(currentVideoState !== 1) play();
return;
case 2:
if(currentVideoState !== 2) pause();
}
}, [ objectId, currentVideoState, play, pause ]);
useEffect(() =>
{
if((currentVideoState === null) || !player) return;
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING))
{
player.playVideo();
return;
}
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PAUSED) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PAUSED))
{
player.pauseVideo();
return;
}
}, [ currentVideoState, player ]);
if(objectId === -1) return null;
const youtubeOptions: Options = {
height: '375',
width: '500',
playerVars: {
autoplay: 1,
disablekb: 1,
controls: 0,
origin: window.origin,
modestbranding: 1,
start: videoStart,
end: videoEnd
}
}
return (
<NitroCardView className="youtube-tv-widget">
<NitroCardHeaderView headerText={ '' } onCloseClick={ close } />
<NitroCardContentView>
<div className="row w-100 h-100">
<div className="youtube-video-container col-9">
{ (videoId && videoId.length > 0) &&
<YouTube videoId={ videoId } opts={ youtubeOptions } onReady={ event => setPlayer(event.target) } onStateChange={ onStateChange } containerClassName={ 'youtubeContainer' } />
}
{ (!videoId || videoId.length === 0) &&
<div className="empty-video w-100 h-100 justify-content-center align-items-center d-flex">{ LocalizeText('widget.furni.video_viewer.no_videos') }</div>
}
</div>
<div className="playlist-container col-3">
<span className="playlist-controls justify-content-center d-flex">
<i className="icon icon-youtube-prev cursor-pointer" onClick={ previous } />
<i className="icon icon-youtube-next cursor-pointer" onClick={ next } />
</span>
<div className="mb-1">{ LocalizeText('widget.furni.video_viewer.playlists') }</div>
<Grid columnCount={ 1 } className="playlist-grid">
{ playlists && playlists.map((entry, index) =>
{
return (
<LayoutGridItem key={ index } onClick={ event => selectVideo(entry.video) } itemActive={ (entry.video === selectedVideo) }>
<b>{ entry.title }</b> - { entry.description }
</LayoutGridItem>
)
}) }
</Grid>
</div>
</div>
</NitroCardContentView>
</NitroCardView>
)
}

View File

@ -1,6 +0,0 @@
.nitro-widget-high-score
{
width: 250px;
max-width: 250px;
height: 200px;
}

View File

@ -1,107 +0,0 @@
import { HighScoreDataType, ObjectDataFactory, RoomEngineTriggerWidgetEvent, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { GetRoomEngine, LocalizeText } from '../../../../../api';
import { Column, Flex, Text } from '../../../../../common';
import { UseRoomEngineEvent } from '../../../../../hooks';
import { useRoomContext } from '../../../RoomContext';
import { ContextMenuHeaderView } from '../../context-menu/ContextMenuHeaderView';
import { ContextMenuListView } from '../../context-menu/ContextMenuListView';
import { ObjectLocationView } from '../../object-location/ObjectLocationView';
const SCORE_TYPES = [ 'perteam', 'mostwins', 'classic' ];
const CLEAR_TYPES = [ 'alltime', 'daily', 'weekly', 'monthly' ];
export const FurnitureHighScoreView: FC<{}> = props =>
{
const [ stuffDatas, setStuffDatas ] = useState<Map<number, HighScoreDataType>>(new Map());
const { roomSession = null } = useRoomContext();
const onRoomEngineTriggerWidgetEvent = useCallback((event: RoomEngineTriggerWidgetEvent) =>
{
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY: {
const object = GetRoomEngine().getRoomObject(roomSession.roomId, event.objectId, event.category);
if(!object) return;
const formatKey = object.model.getValue<number>(RoomObjectVariable.FURNITURE_DATA_FORMAT);
const stuffData = (ObjectDataFactory.getData(formatKey) as HighScoreDataType);
stuffData.initializeFromRoomObjectModel(object.model);
setStuffDatas(prevValue =>
{
const newValue = new Map(prevValue);
newValue.set(object.id, stuffData);
return newValue;
});
return;
}
case RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY:
if(event.roomId !== roomSession.roomId) return;
setStuffDatas(prevValue =>
{
const newValue = new Map(prevValue);
newValue.delete(event.objectId);
return newValue;
});
return;
}
}, [ roomSession ]);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineTriggerWidgetEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineTriggerWidgetEvent);
if(!stuffDatas.size) return null;
return (
<>
{ Array.from(stuffDatas.entries()).map(([ objectId, stuffData ], index) =>
{
return (
<ObjectLocationView key={ index } objectId={ objectId } category={ RoomObjectCategory.FLOOR }>
<Column className="nitro-widget-high-score nitro-context-menu" gap={ 0 }>
<ContextMenuHeaderView>
{ LocalizeText('high.score.display.caption', [ 'scoretype', 'cleartype' ], [ LocalizeText(`high.score.display.scoretype.${ SCORE_TYPES[stuffData.scoreType] }`), LocalizeText(`high.score.display.cleartype.${ CLEAR_TYPES[stuffData.clearType] }`) ]) }
</ContextMenuHeaderView>
<ContextMenuListView overflow="hidden" gap={ 1 } className="h-100">
<Column gap={ 1 }>
<Flex alignItems="center">
<Text center bold variant="white" className="col-8">
{ LocalizeText('high.score.display.users.header') }
</Text>
<Text center bold variant="white" className="col-4">
{ LocalizeText('high.score.display.score.header') }
</Text>
</Flex>
<hr className="m-0" />
</Column>
<Column overflow="auto" gap={ 1 } className="overflow-y-scroll">
{ stuffData.entries.map((entry, index) =>
{
return (
<Flex key={ index } alignItems="center">
<Text center variant="white" className="col-8">
{ entry.users.join(', ') }
</Text>
<Text center variant="white" className="col-4">
{ entry.score }
</Text>
</Flex>
);
}) }
</Column>
</ContextMenuListView>
</Column>
</ObjectLocationView>
);
}) }
</>
);
}

View File

@ -1,54 +0,0 @@
.youtube-tv-widget {
width: 600px;
height: 380px;
.youtube-video-container {
//min-height: 366px;
.empty-video {
background-color: black;
color: white;
width: 100%;
height: 100%;
text-align: center;
}
.youtubeContainer {
position: relative;
width: 100%;
height: 100%;
//height: 0;
//padding-bottom: 56.25%;
overflow: hidden;
margin-bottom: 50px;
}
.youtubeContainer iframe {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
}
.playlist-container {
overflow-y: hidden;
margin-right: -10px;
color: black;
height: 100%;
.playlist-controls {
width: 100%;
.icon {
margin-right: 10px;
margin-bottom: 10px;
}
}
.playlist-grid {
height: 100%;
width: 100%;
}
}
}

View File

@ -1,239 +0,0 @@
import { ControlYoutubeDisplayPlaybackMessageComposer, SetYoutubeDisplayPlaylistMessageComposer, YoutubeControlVideoMessageEvent, YoutubeDisplayPlaylist, YoutubeDisplayPlaylistsEvent, YoutubeDisplayVideoMessageEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useMemo, useState } from 'react';
import YouTube, { Options } from 'react-youtube';
import { FurnitureYoutubeDisplayWidgetHandler, LocalizeText, RoomWidgetUpdateYoutubeDisplayEvent, SendMessageComposer } from '../../../../../api';
import { Grid, LayoutGridItem, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../common';
import { UseEventDispatcherHook, UseMessageEventHook } from '../../../../../hooks';
import { useRoomContext } from '../../../RoomContext';
import { YoutubeVideoPlaybackStateEnum } from './utils/YoutubeVideoPlaybackStateEnum';
export const FurnitureYoutubeDisplayView: FC<{}> = props =>
{
const [ objectId, setObjectId ] = useState(-1);
const [ videoId, setVideoId ] = useState<string>(null);
const [ videoStart, setVideoStart ] = useState<number>(null);
const [ videoEnd, setVideoEnd ] = useState<number>(null);
const [ currentVideoState, setCurrentVideoState ] = useState(-1);
const [ selectedItem, setSelectedItem ] = useState<string>(null);
const [ playlists, setPlaylists ] = useState<YoutubeDisplayPlaylist[]>(null);
const [ hasControl, setHasControl ] = useState(false);
const [ player, setPlayer ] = useState<any>(null);
const { eventDispatcher = null } = useRoomContext();
const onRoomWidgetUpdateYoutubeDisplayEvent = useCallback((event: RoomWidgetUpdateYoutubeDisplayEvent) =>
{
switch(event.type)
{
case RoomWidgetUpdateYoutubeDisplayEvent.UPDATE_YOUTUBE_DISPLAY: {
setObjectId(event.objectId);
setHasControl(event.hasControl);
}
}
}, []);
const close = useCallback(() =>
{
setObjectId(-1);
setSelectedItem(null);
setPlaylists(null);
setHasControl(false);
setVideoId(null);
setVideoEnd(null);
setVideoStart(null);
setCurrentVideoState(-1);
}, []);
UseEventDispatcherHook(RoomWidgetUpdateYoutubeDisplayEvent.UPDATE_YOUTUBE_DISPLAY, eventDispatcher, onRoomWidgetUpdateYoutubeDisplayEvent);
const onVideo = useCallback((event: YoutubeDisplayVideoMessageEvent) =>
{
if(objectId === -1) return;
const parser = event.getParser();
if(objectId !== parser.furniId) return;
setVideoId(parser.videoId);
setVideoStart(parser.startAtSeconds);
setVideoEnd(parser.endAtSeconds);
setCurrentVideoState(parser.state);
}, [ objectId ]);
const onPlaylists = useCallback((event: YoutubeDisplayPlaylistsEvent) =>
{
if(objectId === -1) return;
const parser = event.getParser();
if(objectId !== parser.furniId) return;
setPlaylists(parser.playlists);
setSelectedItem(parser.selectedPlaylistId);
setVideoId(null);
setCurrentVideoState(-1);
setVideoEnd(null);
setVideoStart(null);
}, [ objectId ]);
const onControlVideo = useCallback((event: YoutubeControlVideoMessageEvent) =>
{
if(objectId === -1) return;
const parser = event.getParser();
if(objectId !== parser.furniId) return;
switch(parser.commandId)
{
case 1:
setCurrentVideoState(YoutubeVideoPlaybackStateEnum.PLAYING);
if(player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING)
player.playVideo();
break;
case 2:
setCurrentVideoState(YoutubeVideoPlaybackStateEnum.PAUSED);
if(player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PAUSED)
player.pauseVideo();
break;
}
}, [ objectId, player ]);
UseMessageEventHook(YoutubeDisplayVideoMessageEvent, onVideo);
UseMessageEventHook(YoutubeDisplayPlaylistsEvent, onPlaylists);
UseMessageEventHook(YoutubeControlVideoMessageEvent, onControlVideo);
const processAction = useCallback((action: string) =>
{
switch(action)
{
case 'playlist_prev':
SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_PREVIOUS_VIDEO));
break;
case 'playlist_next':
SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_NEXT_VIDEO));
break;
case 'video_pause':
if(hasControl && videoId && videoId.length)
{
SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_PAUSE_VIDEO));
}
break;
case 'video_play':
if(hasControl && videoId && videoId.length)
{
SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_CONTINUE_VIDEO));
}
break;
default:
if(selectedItem === action)
{
setSelectedItem(null);
SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, ''));
return;
}
SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, action));
setSelectedItem(action);
}
}, [ hasControl, objectId, selectedItem, videoId ]);
const onReady = useCallback((event: any) =>
{
setPlayer(event.target);
}, []);
const onStateChange = useCallback((event: any) =>
{
setPlayer(event.target);
if(objectId)
{
switch(event.target.getPlayerState())
{
case -1:
case 1:
if(currentVideoState === 2)
{
//event.target.pauseVideo();
}
if(currentVideoState !== 1)
{
processAction('video_play');
}
return;
case 2:
if(currentVideoState !== 2)
{
processAction('video_pause');
}
}
}
}, [ currentVideoState, objectId, processAction ]);
const getYoutubeOpts = useMemo( () =>
{
if(!videoStart && !videoEnd)
{
return {
height: '375',
width: '500',
playerVars: {
autoplay: 1,
disablekb: 1,
controls: 0,
origin: window.origin,
modestbranding: 1
}
}
}
return {
height: '375',
width: '500',
playerVars: {
autoplay: 1,
disablekb: 1,
controls: 0,
origin: window.origin,
modestbranding: 1,
start: videoStart,
end: videoEnd
}
}
}, [ videoEnd, videoStart ]);
if((objectId === -1)) return null;
return (
<NitroCardView className="youtube-tv-widget">
<NitroCardHeaderView headerText={ '' } onCloseClick={ close } />
<NitroCardContentView>
<div className="row w-100 h-100">
<div className="youtube-video-container col-9">
{ (videoId && videoId.length > 0) &&
<YouTube videoId={ videoId } opts={ getYoutubeOpts as Options } onReady={ onReady } onStateChange={ onStateChange } containerClassName={ 'youtubeContainer' } />
}
{ (!videoId || videoId.length === 0) &&
<div className="empty-video w-100 h-100 justify-content-center align-items-center d-flex">{ LocalizeText('widget.furni.video_viewer.no_videos') }</div>
}
</div>
<div className="playlist-container col-3">
<span className="playlist-controls justify-content-center d-flex">
<i className="icon icon-youtube-prev cursor-pointer" onClick={ () => processAction('playlist_prev') } />
<i className="icon icon-youtube-next cursor-pointer" onClick={ () => processAction('playlist_next') } />
</span>
<div className="mb-1">{ LocalizeText('widget.furni.video_viewer.playlists') }</div>
<Grid columnCount={ 1 } className="playlist-grid">
{ playlists && playlists.map((entry, index) =>
{
return (
<LayoutGridItem key={ index } onClick={ () => processAction(entry.video) } itemActive={ entry.video === selectedItem }>
<b>{ entry.title }</b> - { entry.description }
</LayoutGridItem>
)
}) }
</Grid>
</div>
</div>
</NitroCardContentView>
</NitroCardView>
)
}

View File

@ -53,12 +53,12 @@ export const RoomToolsWidgetView: FC<{}> = props =>
{ {
const parser = event.getParser(); const parser = event.getParser();
if(!parser.roomEnter) return; if(!parser.roomEnter || (parser.data.roomId !== roomSession.roomId)) return;
if(roomName !== parser.data.roomName) setRoomName(parser.data.roomName); if(roomName !== parser.data.roomName) setRoomName(parser.data.roomName);
if(roomOwner !== parser.data.ownerName) setRoomOwner(parser.data.ownerName); if(roomOwner !== parser.data.ownerName) setRoomOwner(parser.data.ownerName);
if(roomTags !== parser.data.tags) setRoomTags(parser.data.tags); if(roomTags !== parser.data.tags) setRoomTags(parser.data.tags);
}, [ roomName, roomOwner, roomTags ]); }, [ roomSession, roomName, roomOwner, roomTags ]);
UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent);

View File

@ -124,7 +124,7 @@ export const UserSettingsView: FC<{}> = props =>
DispatchUiEvent(userSettings); DispatchUiEvent(userSettings);
}, [ userSettings ]); }, [ userSettings ]);
if(!isVisible) return null; if(!isVisible || !userSettings) return null;
return ( return (
<NitroCardView uniqueKey="user-settings" className="user-settings-window" theme="primary-slim"> <NitroCardView uniqueKey="user-settings" className="user-settings-window" theme="primary-slim">

View File

@ -1,7 +1,7 @@
import { EventDispatcher, IRoomSession, RoomEngineEvent, RoomGeometry, RoomId, RoomSessionEvent, RoomVariableEnum, Vector3d } from '@nitrots/nitro-renderer'; import { EventDispatcher, IRoomSession, RoomEngineEvent, RoomGeometry, RoomId, RoomSessionEvent, RoomVariableEnum, Vector3d } from '@nitrots/nitro-renderer';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { useBetween } from 'use-between'; import { useBetween } from 'use-between';
import { FurnitureContextMenuWidgetHandler, FurnitureDimmerWidgetHandler, FurnitureInternalLinkHandler, FurnitureRoomLinkHandler, FurnitureYoutubeDisplayWidgetHandler, GetNitroInstance, GetRoomEngine, GetRoomSession, InitializeRoomInstanceRenderingCanvas, IRoomWidgetHandlerManager, PollWidgetHandler, RoomWidgetAvatarInfoHandler, RoomWidgetChatHandler, RoomWidgetChatInputHandler, RoomWidgetHandlerManager, RoomWidgetInfostandHandler, SetActiveRoomId, StartRoomSession, WordQuizWidgetHandler } from '../../api'; import { FurnitureContextMenuWidgetHandler, GetNitroInstance, GetRoomEngine, GetRoomSession, InitializeRoomInstanceRenderingCanvas, IRoomWidgetHandlerManager, PollWidgetHandler, RoomWidgetAvatarInfoHandler, RoomWidgetChatHandler, RoomWidgetChatInputHandler, RoomWidgetHandlerManager, RoomWidgetInfostandHandler, SetActiveRoomId, StartRoomSession, WordQuizWidgetHandler } from '../../api';
import { UseRoomEngineEvent, UseRoomSessionManagerEvent } from '../events'; import { UseRoomEngineEvent, UseRoomSessionManagerEvent } from '../events';
const useRoomState = () => const useRoomState = () =>
@ -85,10 +85,6 @@ const useRoomState = () =>
widgetHandlerManager.registerHandler(new WordQuizWidgetHandler()); widgetHandlerManager.registerHandler(new WordQuizWidgetHandler());
widgetHandlerManager.registerHandler(new PollWidgetHandler()); widgetHandlerManager.registerHandler(new PollWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureContextMenuWidgetHandler()); widgetHandlerManager.registerHandler(new FurnitureContextMenuWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureDimmerWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureYoutubeDisplayWidgetHandler());
widgetHandlerManager.registerHandler(new FurnitureInternalLinkHandler());
widgetHandlerManager.registerHandler(new FurnitureRoomLinkHandler());
setWidgetHandler(widgetHandlerManager); setWidgetHandler(widgetHandlerManager);

View File

@ -1,11 +1,16 @@
export * from './useFurnitureBackgroundColorWidget'; export * from './useFurnitureBackgroundColorWidget';
export * from './useFurnitureBadgeDisplayWidget'; export * from './useFurnitureBadgeDisplayWidget';
export * from './useFurnitureDimmerWidget';
export * from './useFurnitureExchangeWidget'; export * from './useFurnitureExchangeWidget';
export * from './useFurnitureExternalImageWidget'; export * from './useFurnitureExternalImageWidget';
export * from './useFurnitureFriendFurniWidget'; export * from './useFurnitureFriendFurniWidget';
export * from './useFurnitureHighScoreWidget';
export * from './useFurnitureInternalLinkWidget';
export * from './useFurnitureManipulationWidget'; export * from './useFurnitureManipulationWidget';
export * from './useFurnitureMannequinWidget'; export * from './useFurnitureMannequinWidget';
export * from './useFurniturePresentWidget'; export * from './useFurniturePresentWidget';
export * from './useFurnitureRoomLinkWidget';
export * from './useFurnitureStackHeightWidget'; export * from './useFurnitureStackHeightWidget';
export * from './useFurnitureStickieWidget'; export * from './useFurnitureStickieWidget';
export * from './useFurnitureTrophyWidget'; export * from './useFurnitureTrophyWidget';
export * from './useFurnitureYoutubeWidget';

View File

@ -1,6 +1,6 @@
import { RoomEngineTriggerWidgetEvent, StringDataType } from '@nitrots/nitro-renderer'; import { RoomEngineTriggerWidgetEvent, RoomObjectVariable, StringDataType } from '@nitrots/nitro-renderer';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import { GetRoomEngine, LocalizeBadgeDescription, LocalizeBadgeName } from '../../../../api'; import { GetRoomEngine, GetSessionDataManager, LocalizeBadgeDescription, LocalizeBadgeName, LocalizeText, NotificationUtilities } from '../../../../api';
import { UseRoomEngineEvent } from '../../../events'; import { UseRoomEngineEvent } from '../../../events';
import { useFurniRemovedEvent } from '../../useFurniRemovedEvent'; import { useFurniRemovedEvent } from '../../useFurniRemovedEvent';
@ -44,8 +44,21 @@ const useFurnitureBadgeDisplayWidgetState = () =>
setSenderName(stringStuff.getValue(3)); setSenderName(stringStuff.getValue(3));
}, []); }, []);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onRoomEngineTriggerWidgetEvent); UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onRoomEngineTriggerWidgetEvent);
UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onRoomEngineTriggerWidgetEvent); UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onRoomEngineTriggerWidgetEvent);
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, event =>
{
const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category);
if(!roomObject) return;
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
if(ownerId !== GetSessionDataManager().userId) return;
NotificationUtilities.simpleAlert(`${ LocalizeText('resolution.failed.subtitle') } ${ LocalizeText('resolution.failed.text') }`, null, null, null, LocalizeText('resolution.failed.title'));
});
useFurniRemovedEvent(((objectId !== -1) && (category !== -1)), event => useFurniRemovedEvent(((objectId !== -1) && (category !== -1)), event =>
{ {

View File

@ -0,0 +1,71 @@
import { RoomControllerLevel, RoomEngineDimmerStateEvent, RoomEngineTriggerWidgetEvent, RoomSessionDimmerPresetsEvent } from '@nitrots/nitro-renderer';
import { GetRoomEngine, GetSessionDataManager, RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent } from '../../../../api';
import { UseRoomEngineEvent, UseRoomSessionManagerEvent } from '../../../events';
import { useRoom } from '../../useRoom';
const useFurnitureDimmerWidgetState = () =>
{
const { roomSession = null, widgetHandler = null } = useRoom();
const canOpenWidget = () => (roomSession.isRoomOwner || (roomSession.controllerLevel >= RoomControllerLevel.GUEST) || GetSessionDataManager().isModerator);
const savePreset = (presetNumber: number, effectTypeId: number, color: number, brightness: number, apply: boolean) =>
{
if(!canOpenWidget()) return;
roomSession.updateMoodlightData(presetNumber, effectTypeId, color, brightness, apply);
}
const changeState = () =>
{
if(!canOpenWidget()) return;
roomSession.toggleMoodlightState();
}
const previewDimmer = (color: number, brightness: number, bgOnly: boolean) =>
{
GetRoomEngine().updateObjectRoomColor(roomSession.roomId, color, brightness, bgOnly);
}
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, event =>
{
if(!canOpenWidget()) return;
roomSession.requestMoodlightSettings();
});
UseRoomEngineEvent<RoomEngineDimmerStateEvent>(RoomEngineDimmerStateEvent.ROOM_COLOR, event =>
{
widgetHandler.eventDispatcher.dispatchEvent(new RoomWidgetUpdateDimmerStateEvent(event.state, event.presetId, event.effectId, event.color, event.brightness));
});
UseRoomSessionManagerEvent<RoomSessionDimmerPresetsEvent>(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, event =>
{
const updateEvent = new RoomWidgetUpdateDimmerEvent(RoomWidgetUpdateDimmerEvent.PRESETS);
updateEvent.selectedPresetId = event.selectedPresetId;
let i = 0;
while(i < event.presetCount)
{
const preset = event.getPreset(i);
if(preset) updateEvent.setPresetValues(preset.id, preset.type, preset.color, preset.brightness);
i++;
}
widgetHandler.eventDispatcher.dispatchEvent(updateEvent);
});
UseRoomEngineEvent<RoomEngineDimmerStateEvent>(RoomEngineDimmerStateEvent.ROOM_COLOR, event =>
{
widgetHandler.eventDispatcher.dispatchEvent(new RoomWidgetUpdateDimmerEvent(RoomWidgetUpdateDimmerEvent.HIDE));
});
return { savePreset, changeState, previewDimmer };
}
export const useFurnitureDimmerWidget = useFurnitureDimmerWidgetState;

View File

@ -0,0 +1,56 @@
import { HighScoreDataType, ObjectDataFactory, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer';
import { useState } from 'react';
import { GetRoomEngine } from '../../../../api';
import { UseRoomEngineEvent } from '../../../events';
import { useRoom } from '../../useRoom';
const SCORE_TYPES = [ 'perteam', 'mostwins', 'classic' ];
const CLEAR_TYPES = [ 'alltime', 'daily', 'weekly', 'monthly' ];
const useFurnitureHighScoreWidgetState = () =>
{
const [ stuffDatas, setStuffDatas ] = useState<Map<number, HighScoreDataType>>(new Map());
const { roomSession = null, widgetHandler = null } = useRoom();
const getScoreType = (type: number) => SCORE_TYPES[type];
const getClearType = (type: number) => CLEAR_TYPES[type];
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, event =>
{
const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category);
if(!roomObject) return;
const formatKey = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_DATA_FORMAT);
const stuffData = (ObjectDataFactory.getData(formatKey) as HighScoreDataType);
stuffData.initializeFromRoomObjectModel(roomObject.model);
setStuffDatas(prevValue =>
{
const newValue = new Map(prevValue);
newValue.set(roomObject.id, stuffData);
return newValue;
});
});
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, event =>
{
if(event.roomId !== roomSession.roomId) return;
setStuffDatas(prevValue =>
{
const newValue = new Map(prevValue);
newValue.delete(event.objectId);
return newValue;
});
});
return { stuffDatas, getScoreType, getClearType };
}
export const useFurnitureHighScoreWidget = useFurnitureHighScoreWidgetState;

View File

@ -0,0 +1,27 @@
import { RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer';
import { CreateLinkEvent, GetRoomEngine } from '../../../../api';
import { UseRoomEngineEvent } from '../../../events';
const INTERNALLINK = 'internalLink';
const useFurnitureInternalLinkWidgetState = () =>
{
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, event =>
{
const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category);
if(!roomObject) return;
const data = roomObject.model.getValue<any>(RoomObjectVariable.FURNITURE_DATA);
let link = data[INTERNALLINK];
if(!link || !link.length) link = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK);
if(link && link.length) CreateLinkEvent(link);
});
return {};
}
export const useFurnitureInternalLinkWidget = useFurnitureInternalLinkWidgetState;

View File

@ -0,0 +1,58 @@
import { GetGuestRoomResultEvent, RoomEngineTriggerWidgetEvent, RoomInfoComposer, RoomObjectVariable } from '@nitrots/nitro-renderer';
import { useEffect, useState } from 'react';
import { GetCommunication, GetRoomEngine, SendMessageComposer } from '../../../../api';
import { UseRoomEngineEvent } from '../../../events';
const INTERNALLINK = 'internalLink';
const useFurnitureRoomLinkWidgetState = () =>
{
const [ roomIdToEnter, setRoomIdToEnter ] = useState(0);
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, event =>
{
const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category);
if(!roomObject) return;
const data = roomObject.model.getValue<any>(RoomObjectVariable.FURNITURE_DATA);
let roomId = data[INTERNALLINK];
if(!roomId || !roomId.length) roomId = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK);
if(!roomId || !roomId.length) return;
roomId = parseInt(roomId, 10);
if(roomId === NaN) return;
setRoomIdToEnter(roomId);
SendMessageComposer(new RoomInfoComposer(roomId, false, false));
});
useEffect(() =>
{
if(!roomIdToEnter) return;
const onGetGuestRoomResultEvent = (event: GetGuestRoomResultEvent) =>
{
const parser = event.getParser();
if(parser.data.roomId !== roomIdToEnter) return;
setRoomIdToEnter(0);
}
const event = new GetGuestRoomResultEvent(onGetGuestRoomResultEvent);
GetCommunication().registerMessageEvent(event);
return () => GetCommunication().removeMessageEvent(event);
}, [ roomIdToEnter ]);
return {};
}
export const useFurnitureRoomLinkWidget = useFurnitureRoomLinkWidgetState;

View File

@ -0,0 +1,136 @@
import { ControlYoutubeDisplayPlaybackMessageComposer, GetYoutubeDisplayStatusMessageComposer, RoomEngineTriggerWidgetEvent, SecurityLevel, SetYoutubeDisplayPlaylistMessageComposer, YoutubeControlVideoMessageEvent, YoutubeDisplayPlaylist, YoutubeDisplayPlaylistsEvent, YoutubeDisplayVideoMessageEvent } from '@nitrots/nitro-renderer';
import { useCallback, useState } from 'react';
import { GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture, SendMessageComposer, YoutubeVideoPlaybackStateEnum } from '../../../../api';
import { UseRoomEngineEvent } from '../../../events';
import { UseMessageEventHook } from '../../../messages';
import { useFurniRemovedEvent } from '../../useFurniRemovedEvent';
const CONTROL_COMMAND_PREVIOUS_VIDEO = 0;
const CONTROL_COMMAND_NEXT_VIDEO = 1;
const CONTROL_COMMAND_PAUSE_VIDEO = 2;
const CONTROL_COMMAND_CONTINUE_VIDEO = 3;
const useFurnitureYoutubeWidgetState = () =>
{
const [ objectId, setObjectId ] = useState(-1);
const [ category, setCategory ] = useState(-1);
const [ videoId, setVideoId ] = useState<string>(null);
const [ videoStart, setVideoStart ] = useState<number>(null);
const [ videoEnd, setVideoEnd ] = useState<number>(null);
const [ currentVideoState, setCurrentVideoState ] = useState(-1);
const [ selectedVideo, setSelectedVideo ] = useState<string>(null);
const [ playlists, setPlaylists ] = useState<YoutubeDisplayPlaylist[]>(null);
const [ hasControl, setHasControl ] = useState(false);
const close = () =>
{
setObjectId(-1);
setCategory(-1);
setVideoId(null);
setVideoStart(null);
setVideoEnd(null);
setCurrentVideoState(-1);
setSelectedVideo(null);
setPlaylists(null);
setHasControl(false);
}
const previous = () => SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, CONTROL_COMMAND_PREVIOUS_VIDEO));
const next = () => SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, CONTROL_COMMAND_NEXT_VIDEO));
const pause = () => (hasControl && videoId && videoId.length) && SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, CONTROL_COMMAND_PAUSE_VIDEO));
const play = () => (hasControl && videoId && videoId.length) && SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, CONTROL_COMMAND_CONTINUE_VIDEO));
const selectVideo = (video: string) =>
{
if(selectedVideo === video)
{
setSelectedVideo(null);
SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, ''));
return;
}
setSelectedVideo(video);
SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, video));
}
UseRoomEngineEvent<RoomEngineTriggerWidgetEvent>(RoomEngineTriggerWidgetEvent.REQUEST_YOUTUBE, event =>
{
const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category);
console.log(roomObject);
if(!roomObject) return;
setObjectId(event.objectId);
setCategory(event.category);
setHasControl(GetSessionDataManager().hasSecurity(SecurityLevel.EMPLOYEE) || IsOwnerOfFurniture(roomObject));
console.log('??')
SendMessageComposer(new GetYoutubeDisplayStatusMessageComposer(event.objectId));
});
useFurniRemovedEvent(((objectId !== -1) && (category !== -1)), event =>
{
if((event.id !== objectId) || (event.category !== category)) return;
close();
});
const onYoutubeDisplayVideoMessageEvent = useCallback((event: YoutubeDisplayVideoMessageEvent) =>
{
const parser = event.getParser();
if((objectId === -1) || (objectId !== parser.furniId)) return;
setVideoId(parser.videoId);
setVideoStart(parser.startAtSeconds);
setVideoEnd(parser.endAtSeconds);
setCurrentVideoState(parser.state);
}, [ objectId ]);
UseMessageEventHook(YoutubeDisplayVideoMessageEvent, onYoutubeDisplayVideoMessageEvent);
const onYoutubeDisplayPlaylistsEvent = useCallback((event: YoutubeDisplayPlaylistsEvent) =>
{
const parser = event.getParser();
if((objectId === -1) || (objectId !== parser.furniId)) return;
setPlaylists(parser.playlists);
setSelectedVideo(parser.selectedPlaylistId);
setVideoId(null);
setCurrentVideoState(-1);
setVideoEnd(null);
setVideoStart(null);
}, [ objectId ]);
UseMessageEventHook(YoutubeDisplayPlaylistsEvent, onYoutubeDisplayPlaylistsEvent);
const onYoutubeControlVideoMessageEvent = useCallback((event: YoutubeControlVideoMessageEvent) =>
{
const parser = event.getParser();
if((objectId === -1) || (objectId !== parser.furniId)) return;
switch(parser.commandId)
{
case 1:
setCurrentVideoState(YoutubeVideoPlaybackStateEnum.PLAYING);
break;
case 2:
setCurrentVideoState(YoutubeVideoPlaybackStateEnum.PAUSED);
break;
}
}, [ objectId ]);
UseMessageEventHook(YoutubeControlVideoMessageEvent, onYoutubeControlVideoMessageEvent);
return { objectId, videoId, videoStart, videoEnd, currentVideoState, selectedVideo, playlists, close, previous, next, pause, play, selectVideo };
}
export const useFurnitureYoutubeWidget = useFurnitureYoutubeWidgetState;