mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-22 22:30:52 +01:00
Update events
This commit is contained in:
parent
ead1cb6c0a
commit
37225d3261
@ -12,15 +12,17 @@ export function CreateEventDispatcherHook(type: string, eventDispatcher: IEventD
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const eventListener = (event: NitroEvent) => handlerRef.current(event);
|
||||
console.log('register', type);
|
||||
|
||||
eventDispatcher.addEventListener(type, eventListener);
|
||||
eventDispatcher.addEventListener(type, handlerRef.current);
|
||||
|
||||
return () =>
|
||||
{
|
||||
eventDispatcher.removeEventListener(type, eventListener);
|
||||
console.log('unregister', type);
|
||||
|
||||
eventDispatcher.removeEventListener(type, handlerRef.current);
|
||||
}
|
||||
}, [ type, eventDispatcher ]);
|
||||
}, [ type, eventDispatcher, handler ]);
|
||||
}
|
||||
|
||||
export function DispatchEventHook(eventDispatcher: IEventDispatcher, event: NitroEvent): void
|
||||
|
@ -0,0 +1,7 @@
|
||||
import { Nitro, NitroEvent } from 'nitro-renderer';
|
||||
import { CreateEventDispatcherHook } from '../../event-dispatcher.base';
|
||||
|
||||
export function useRoomSessionManagerEvent(type: string, handler: (event: NitroEvent) => void): void
|
||||
{
|
||||
CreateEventDispatcherHook(type, Nitro.instance.roomSessionManager.events, handler);
|
||||
}
|
16
src/hooks/messages/message-event.tsx
Normal file
16
src/hooks/messages/message-event.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from 'nitro-renderer';
|
||||
import { Nitro } from 'nitro-renderer/src/nitro/Nitro';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export function CreateMessageHook(event: IMessageEvent)
|
||||
{
|
||||
useEffect(() =>
|
||||
{
|
||||
Nitro.instance.communication.registerMessageEvent(event);
|
||||
|
||||
return () =>
|
||||
{
|
||||
Nitro.instance.communication.removeMessageEvent(event);
|
||||
}
|
||||
});
|
||||
}
|
@ -1,11 +1,102 @@
|
||||
import { Nitro } from 'nitro-renderer/src/nitro/Nitro';
|
||||
import { Nitro, RoomBackgroundColorEvent, RoomEngineDimmerStateEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomEngineTriggerWidgetEvent, RoomObjectHSLColorEnabledEvent, RoomObjectWidgetRequestEvent, RoomSessionChatEvent, RoomSessionDanceEvent, RoomSessionDimmerPresetsEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionEvent, RoomSessionFriendRequestEvent, RoomSessionPresentEvent, RoomSessionUserBadgesEvent, RoomZoomEvent } from 'nitro-renderer';
|
||||
import { useEffect } from 'react';
|
||||
import { useRoomEngineEvent } from '../../hooks/events/nitro/room/room-engine-event';
|
||||
import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event';
|
||||
import { HotelView } from '../hotel-view/HotelView';
|
||||
import { ToolbarView } from '../toolbar/ToolbarView';
|
||||
import { MainViewProps } from './MainView.types';
|
||||
|
||||
export function MainView(props: MainViewProps): JSX.Element
|
||||
{
|
||||
const onInterstitialEvent = (event: RoomEngineEvent) =>
|
||||
{
|
||||
console.log(event);
|
||||
};
|
||||
|
||||
const onRoomEngineEvent = (event: RoomEngineEvent) =>
|
||||
{
|
||||
console.log(event);
|
||||
};
|
||||
|
||||
const onRoomEngineObjectEvent = (event: RoomEngineObjectEvent) =>
|
||||
{
|
||||
console.log(event);
|
||||
};
|
||||
|
||||
const onRoomSessionEvent = (event: RoomSessionEvent) =>
|
||||
{
|
||||
console.log(event);
|
||||
}
|
||||
|
||||
const onRoomSessionErrorMessageEvent = (event: RoomSessionErrorMessageEvent) =>
|
||||
{
|
||||
console.log(event);
|
||||
}
|
||||
|
||||
useRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, onInterstitialEvent);
|
||||
useRoomEngineEvent(RoomEngineEvent.OBJECTS_INITIALIZED, onInterstitialEvent);
|
||||
useRoomEngineEvent(RoomEngineEvent.NORMAL_MODE, onInterstitialEvent);
|
||||
useRoomEngineEvent(RoomEngineEvent.GAME_MODE, onInterstitialEvent);
|
||||
|
||||
useRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent);
|
||||
useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent);
|
||||
useRoomEngineEvent(RoomZoomEvent.ROOM_ZOOM, onRoomEngineEvent);
|
||||
useRoomEngineEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, onRoomEngineEvent);
|
||||
useRoomEngineEvent(RoomBackgroundColorEvent.ROOM_COLOR, onRoomEngineEvent);
|
||||
useRoomEngineEvent(RoomEngineDimmerStateEvent.ROOM_COLOR, onRoomEngineEvent);
|
||||
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.REMOVED, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MOVE, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_ROTATE, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_ENTER, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_LEAVE, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomObjectWidgetRequestEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent);
|
||||
|
||||
useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionEvent.STARTED, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionEvent.ROOM_DATA, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionChatEvent.FLOOD_EVENT, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionDanceEvent.RSDE_DANCE, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionDoorbellEvent.DOORBELL, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionDimmerPresetsEvent.RSDPE_PRESETS, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionFriendRequestEvent.RSFRE_FRIEND_REQUEST, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, onRoomSessionEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_KICKED, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_PETS, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT, onRoomSessionErrorMessageEvent);
|
||||
useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED, onRoomSessionErrorMessageEvent);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
Nitro.instance.communication.connection.onReady();
|
||||
|
Loading…
Reference in New Issue
Block a user