2022-07-19 02:48:54 +02:00
|
|
|
import { RoomEngineObjectEvent, RoomEngineRoomAdEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomId, RoomSessionErrorMessageEvent, RoomZoomEvent } from '@nitrots/nitro-renderer';
|
|
|
|
import { FC } from 'react';
|
|
|
|
import { DispatchUiEvent, GetRoomEngine, LocalizeText, NotificationAlertType, NotificationUtilities, RoomWidgetUpdateRoomObjectEvent } from '../../../api';
|
|
|
|
import { useRoom, useRoomEngineEvent, useRoomSessionManagerEvent } from '../../../hooks';
|
2021-06-17 19:23:34 +02:00
|
|
|
import { AvatarInfoWidgetView } from './avatar-info/AvatarInfoWidgetView';
|
|
|
|
import { ChatInputView } from './chat-input/ChatInputView';
|
|
|
|
import { ChatWidgetView } from './chat/ChatWidgetView';
|
2021-08-11 02:47:16 +02:00
|
|
|
import { FurniChooserWidgetView } from './choosers/FurniChooserWidgetView';
|
|
|
|
import { UserChooserWidgetView } from './choosers/UserChooserWidgetView';
|
2021-08-13 10:05:46 +02:00
|
|
|
import { DoorbellWidgetView } from './doorbell/DoorbellWidgetView';
|
2021-11-19 18:31:43 +01:00
|
|
|
import { FriendRequestWidgetView } from './friend-request/FriendRequestWidgetView';
|
2021-06-17 19:23:34 +02:00
|
|
|
import { FurnitureWidgetsView } from './furniture/FurnitureWidgetsView';
|
2021-07-03 22:08:05 +02:00
|
|
|
import { RoomThumbnailWidgetView } from './room-thumbnail/RoomThumbnailWidgetView';
|
2021-06-30 19:08:24 +02:00
|
|
|
import { RoomToolsWidgetView } from './room-tools/RoomToolsWidgetView';
|
2021-11-16 04:12:05 +01:00
|
|
|
import { WordQuizWidgetView } from './word-quiz/WordQuizWidgetView';
|
2021-11-17 09:48:41 +01:00
|
|
|
|
|
|
|
export const RoomWidgetsView: FC<{}> = props =>
|
2021-06-17 19:23:34 +02:00
|
|
|
{
|
2022-07-19 02:48:54 +02:00
|
|
|
const { roomSession = null } = useRoom();
|
|
|
|
|
|
|
|
useRoomEngineEvent<RoomZoomEvent>(RoomZoomEvent.ROOM_ZOOM, event => GetRoomEngine().setRoomInstanceRenderingCanvasScale(event.roomId, 1, event.level, null, null, false, event.asDelta));
|
|
|
|
|
|
|
|
useRoomEngineEvent<RoomEngineObjectEvent>(
|
|
|
|
[
|
|
|
|
RoomEngineTriggerWidgetEvent.REQUEST_TEASER,
|
|
|
|
RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX,
|
|
|
|
RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE,
|
|
|
|
RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR,
|
|
|
|
RoomEngineTriggerWidgetEvent.OPEN_WIDGET,
|
|
|
|
RoomEngineTriggerWidgetEvent.CLOSE_WIDGET,
|
|
|
|
RoomEngineRoomAdEvent.FURNI_CLICK,
|
|
|
|
RoomEngineRoomAdEvent.FURNI_DOUBLE_CLICK,
|
|
|
|
RoomEngineRoomAdEvent.TOOLTIP_SHOW,
|
|
|
|
RoomEngineRoomAdEvent.TOOLTIP_HIDE,
|
|
|
|
], event =>
|
2021-07-13 19:30:20 +02:00
|
|
|
{
|
2022-07-19 02:48:54 +02:00
|
|
|
if(!roomSession) return;
|
2021-09-16 01:52:01 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
const objectId = event.objectId;
|
|
|
|
const category = event.category;
|
2021-09-16 01:52:01 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
let updateEvent: RoomWidgetUpdateRoomObjectEvent = null;
|
2021-09-16 01:52:01 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
switch(event.type)
|
2022-04-18 02:46:39 +02:00
|
|
|
{
|
2022-07-19 02:48:54 +02:00
|
|
|
case RoomEngineTriggerWidgetEvent.REQUEST_TEASER:
|
|
|
|
//widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_TEASER, objectId, category, event.roomId));
|
|
|
|
break;
|
|
|
|
case RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX:
|
|
|
|
//widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_ECOTRONBOX, objectId, category, event.roomId));
|
|
|
|
break;
|
|
|
|
case RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER:
|
|
|
|
//widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_PLACEHOLDER, objectId, category, event.roomId));
|
|
|
|
break;
|
|
|
|
case RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE:
|
|
|
|
//widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_CLOTHING_CHANGE, objectId, category, event.roomId));
|
|
|
|
break;
|
|
|
|
case RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR:
|
|
|
|
//widgetHandler.processWidgetMessage(new RoomWidgetFurniToWidgetMessage(RoomWidgetFurniToWidgetMessage.REQUEST_PLAYLIST_EDITOR, objectId, category, event.roomId));
|
|
|
|
break;
|
|
|
|
case RoomEngineTriggerWidgetEvent.OPEN_WIDGET:
|
|
|
|
case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET:
|
|
|
|
case RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM:
|
|
|
|
//widgetHandler.processEvent(event);
|
|
|
|
break;
|
|
|
|
case RoomEngineRoomAdEvent.FURNI_CLICK:
|
|
|
|
case RoomEngineRoomAdEvent.FURNI_DOUBLE_CLICK:
|
|
|
|
//handleRoomAdClick(event);
|
|
|
|
break;
|
|
|
|
case RoomEngineRoomAdEvent.TOOLTIP_SHOW:
|
|
|
|
case RoomEngineRoomAdEvent.TOOLTIP_HIDE:
|
|
|
|
//handleRoomAdTooltip(event);
|
|
|
|
break;
|
2022-04-18 02:46:39 +02:00
|
|
|
}
|
2021-06-17 19:23:34 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
if(!updateEvent) return;
|
|
|
|
|
|
|
|
let dispatchEvent = true;
|
2021-07-13 19:30:20 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
if(RoomId.isRoomPreviewerId(updateEvent.roomId)) return;
|
2021-06-17 19:23:34 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
if(updateEvent instanceof RoomWidgetUpdateRoomObjectEvent) dispatchEvent = (!RoomId.isRoomPreviewerId(updateEvent.roomId));
|
2021-06-17 19:23:34 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
if(dispatchEvent) DispatchUiEvent(updateEvent);
|
|
|
|
});
|
|
|
|
|
|
|
|
useRoomSessionManagerEvent<RoomSessionErrorMessageEvent>(
|
|
|
|
[
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_KICKED,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_MAX_PETS,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT,
|
|
|
|
RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED,
|
|
|
|
], event =>
|
2021-06-17 19:23:34 +02:00
|
|
|
{
|
2022-07-19 02:48:54 +02:00
|
|
|
let errorTitle = LocalizeText('error.title');
|
|
|
|
let errorMessage: string = '';
|
2021-09-30 06:47:03 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
switch(event.type)
|
|
|
|
{
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_MAX_PETS:
|
|
|
|
errorMessage = LocalizeText('room.error.max_pets');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS:
|
|
|
|
errorMessage = LocalizeText('room.error.max_own_pets');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_KICKED:
|
|
|
|
errorMessage = LocalizeText('room.error.kicked');
|
|
|
|
errorTitle = LocalizeText('generic.alert.title');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL:
|
|
|
|
errorMessage = LocalizeText('room.error.pets.forbidden_in_hotel');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT:
|
|
|
|
errorMessage = LocalizeText('room.error.pets.forbidden_in_flat');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET:
|
|
|
|
errorMessage = LocalizeText('room.error.pets.no_free_tiles');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET:
|
|
|
|
errorMessage = LocalizeText('room.error.pets.selected_tile_not_free');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL:
|
|
|
|
errorMessage = LocalizeText('room.error.bots.forbidden_in_hotel');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT:
|
|
|
|
errorMessage = LocalizeText('room.error.bots.forbidden_in_flat');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED:
|
|
|
|
errorMessage = LocalizeText('room.error.max_bots');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT:
|
|
|
|
errorMessage = LocalizeText('room.error.bots.selected_tile_not_free');
|
|
|
|
break;
|
|
|
|
case RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED:
|
|
|
|
errorMessage = LocalizeText('room.error.bots.name.not.accepted');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2021-06-17 19:23:34 +02:00
|
|
|
|
2022-07-19 02:48:54 +02:00
|
|
|
NotificationUtilities.simpleAlert(errorMessage, NotificationAlertType.DEFAULT, null, null, errorTitle);
|
|
|
|
});
|
2021-06-17 19:23:34 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<AvatarInfoWidgetView />
|
|
|
|
<ChatWidgetView />
|
|
|
|
<ChatInputView />
|
2021-08-13 10:05:46 +02:00
|
|
|
<DoorbellWidgetView />
|
2021-06-17 19:23:34 +02:00
|
|
|
<FurnitureWidgetsView />
|
2021-06-30 19:08:24 +02:00
|
|
|
<RoomToolsWidgetView />
|
2021-07-03 22:08:05 +02:00
|
|
|
<RoomThumbnailWidgetView />
|
2021-08-11 02:47:16 +02:00
|
|
|
<FurniChooserWidgetView />
|
|
|
|
<UserChooserWidgetView />
|
2021-11-16 04:12:05 +01:00
|
|
|
<WordQuizWidgetView />
|
2021-11-19 18:31:43 +01:00
|
|
|
<FriendRequestWidgetView />
|
2021-06-17 19:23:34 +02:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|