mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
Remove some events
This commit is contained in:
parent
d2ed02668b
commit
53b57d72c9
@ -1,15 +1,13 @@
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { AvatarEditorFigureCategory, FigureSetIdsMessageEvent, GetWardrobeMessageComposer, IAvatarFigureContainer, UserFigureComposer, UserWardrobePageEvent } from '@nitrots/nitro-renderer';
|
||||
import { AvatarEditorFigureCategory, FigureSetIdsMessageEvent, GetWardrobeMessageComposer, IAvatarFigureContainer, ILinkEventTracker, UserFigureComposer, UserWardrobePageEvent } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { GetAvatarRenderManager, GetClubMemberLevel, GetConfiguration, GetSessionDataManager, LocalizeText } from '../../api';
|
||||
import { AddEventLinkTracker, GetAvatarRenderManager, GetClubMemberLevel, GetConfiguration, GetSessionDataManager, LocalizeText, RemoveLinkEventTracker } from '../../api';
|
||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
|
||||
import { Button } from '../../common/Button';
|
||||
import { ButtonGroup } from '../../common/ButtonGroup';
|
||||
import { Column } from '../../common/Column';
|
||||
import { Grid } from '../../common/Grid';
|
||||
import { AvatarEditorEvent } from '../../events/avatar-editor';
|
||||
import { CreateMessageHook, SendMessageHook } from '../../hooks';
|
||||
import { useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||
import { AvatarEditorAction } from './common/AvatarEditorAction';
|
||||
import { AvatarEditorUtilities } from './common/AvatarEditorUtilities';
|
||||
import { BodyModel } from './common/BodyModel';
|
||||
@ -44,34 +42,6 @@ export const AvatarEditorView: FC<{}> = props =>
|
||||
|
||||
const maxWardrobeSlots = useMemo(() => GetConfiguration<number>('avatar.wardrobe.max.slots', 10), []);
|
||||
|
||||
const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) =>
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case AvatarEditorEvent.SHOW_EDITOR:
|
||||
setIsVisible(true);
|
||||
setNeedsReset(true);
|
||||
return;
|
||||
case AvatarEditorEvent.HIDE_EDITOR:
|
||||
setIsVisible(false);
|
||||
return;
|
||||
case AvatarEditorEvent.TOGGLE_EDITOR:
|
||||
setIsVisible(prevValue =>
|
||||
{
|
||||
const flag = !prevValue;
|
||||
|
||||
if(flag) setNeedsReset(true);
|
||||
|
||||
return flag;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useUiEvent(AvatarEditorEvent.SHOW_EDITOR, onAvatarEditorEvent);
|
||||
useUiEvent(AvatarEditorEvent.HIDE_EDITOR, onAvatarEditorEvent);
|
||||
useUiEvent(AvatarEditorEvent.TOGGLE_EDITOR, onAvatarEditorEvent);
|
||||
|
||||
const onFigureSetIdsMessageEvent = useCallback((event: FigureSetIdsMessageEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
@ -195,6 +165,45 @@ export const AvatarEditorView: FC<{}> = props =>
|
||||
setFigureData(figures.get(gender));
|
||||
}, [ figures ]);
|
||||
|
||||
const linkReceived = useCallback((url: string) =>
|
||||
{
|
||||
const parts = url.split('/');
|
||||
|
||||
if(parts.length < 2) return;
|
||||
|
||||
switch(parts[1])
|
||||
{
|
||||
case 'show':
|
||||
setIsVisible(true);
|
||||
return;
|
||||
case 'hide':
|
||||
setIsVisible(false);
|
||||
return;
|
||||
case 'toggle':
|
||||
setIsVisible(prevValue =>
|
||||
{
|
||||
const flag = !prevValue;
|
||||
|
||||
if(flag) setNeedsReset(true);
|
||||
|
||||
return flag;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const linkTracker: ILinkEventTracker = {
|
||||
linkReceived,
|
||||
eventUrlPrefix: 'avatar-editor/'
|
||||
};
|
||||
|
||||
AddEventLinkTracker(linkTracker);
|
||||
|
||||
return () => RemoveLinkEventTracker(linkTracker);
|
||||
}, [ linkReceived ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setSavedFigures(new Array(maxWardrobeSlots));
|
||||
|
@ -1,10 +1,8 @@
|
||||
import { InitCameraMessageEvent, IRoomCameraWidgetEffect, RequestCameraConfigurationComposer, RoomCameraWidgetManagerEvent, RoomSessionEvent } from '@nitrots/nitro-renderer';
|
||||
import { ILinkEventTracker, InitCameraMessageEvent, IRoomCameraWidgetEffect, RequestCameraConfigurationComposer, RoomCameraWidgetManagerEvent, RoomSessionEvent } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { GetRoomCameraWidgetManager } from '../../api';
|
||||
import { RoomWidgetCameraEvent } from '../../events/camera/RoomWidgetCameraEvent';
|
||||
import { AddEventLinkTracker, GetRoomCameraWidgetManager, RemoveLinkEventTracker } from '../../api';
|
||||
import { useRoomSessionManagerEvent } from '../../hooks';
|
||||
import { useCameraEvent } from '../../hooks/events/nitro/camera/camera-event';
|
||||
import { useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||
import { CreateMessageHook, SendMessageHook } from '../../hooks/messages/message-event';
|
||||
import { CameraWidgetContextProvider } from './CameraWidgetContext';
|
||||
import { CameraPicture } from './common/CameraPicture';
|
||||
@ -27,30 +25,6 @@ export const CameraWidgetView: FC<{}> = props =>
|
||||
const [ base64Url, setSavedPictureUrl ] = useState<string>(null);
|
||||
const [ price, setPrice ] = useState<{ credits: number, duckets: number, publishDucketPrice: number }>(null);
|
||||
|
||||
const onNitroEvent = useCallback((event: RoomWidgetCameraEvent) =>
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomWidgetCameraEvent.SHOW_CAMERA:
|
||||
setMode(MODE_CAPTURE);
|
||||
return;
|
||||
case RoomWidgetCameraEvent.HIDE_CAMERA:
|
||||
setMode(MODE_NONE);
|
||||
return;
|
||||
case RoomWidgetCameraEvent.TOGGLE_CAMERA:
|
||||
setMode(prevValue =>
|
||||
{
|
||||
if(!prevValue) return MODE_CAPTURE;
|
||||
else return MODE_NONE;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useUiEvent(RoomWidgetCameraEvent.SHOW_CAMERA, onNitroEvent);
|
||||
useUiEvent(RoomWidgetCameraEvent.HIDE_CAMERA, onNitroEvent);
|
||||
useUiEvent(RoomWidgetCameraEvent.TOGGLE_CAMERA, onNitroEvent);
|
||||
|
||||
const onRoomCameraWidgetManagerEvent = useCallback((event: RoomCameraWidgetManagerEvent) =>
|
||||
{
|
||||
setAvailableEffects(Array.from(GetRoomCameraWidgetManager().effects.values()))
|
||||
@ -118,6 +92,42 @@ export const CameraWidgetView: FC<{}> = props =>
|
||||
setMode(MODE_CHECKOUT);
|
||||
}, []);
|
||||
|
||||
const linkReceived = useCallback((url: string) =>
|
||||
{
|
||||
const parts = url.split('/');
|
||||
|
||||
if(parts.length < 2) return;
|
||||
|
||||
switch(parts[1])
|
||||
{
|
||||
case 'show':
|
||||
setMode(MODE_CAPTURE);
|
||||
return;
|
||||
case 'hide':
|
||||
setMode(MODE_NONE);
|
||||
return;
|
||||
case 'toggle':
|
||||
setMode(prevValue =>
|
||||
{
|
||||
if(!prevValue) return MODE_CAPTURE;
|
||||
else return MODE_NONE;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const linkTracker: ILinkEventTracker = {
|
||||
linkReceived,
|
||||
eventUrlPrefix: 'camera/'
|
||||
};
|
||||
|
||||
AddEventLinkTracker(linkTracker);
|
||||
|
||||
return () => RemoveLinkEventTracker(linkTracker);
|
||||
}, [ linkReceived ]);
|
||||
|
||||
if(mode === MODE_NONE) return null;
|
||||
|
||||
return (
|
||||
|
@ -3,7 +3,7 @@ import { FC, useCallback, useState } from 'react';
|
||||
import { CreateLinkEvent, GetRoomSession, GetRoomSessionManager, GetSessionDataManager, GetUserProfile, GoToDesktop, OpenMessengerChat } from '../../api';
|
||||
import { Base, Flex, TransitionAnimationTypes } from '../../common';
|
||||
import { TransitionAnimation } from '../../common/transitions/TransitionAnimation';
|
||||
import { AvatarEditorEvent, FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, NavigatorEvent, RoomWidgetCameraEvent } from '../../events';
|
||||
import { FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, NavigatorEvent } from '../../events';
|
||||
import { AchievementsUIEvent, AchievementsUIUnseenCountEvent } from '../../events/achievements';
|
||||
import { UnseenItemTrackerUpdateEvent } from '../../events/inventory/UnseenItemTrackerUpdateEvent';
|
||||
import { ModToolsEvent } from '../../events/mod-tools/ModToolsEvent';
|
||||
@ -155,10 +155,10 @@ export const ToolbarView: FC<ToolbarViewProps> = props =>
|
||||
dispatchUiEvent(new FriendsEvent(FriendsEvent.TOGGLE_FRIEND_LIST));
|
||||
return;
|
||||
case ToolbarViewItems.CAMERA_ITEM:
|
||||
dispatchUiEvent(new RoomWidgetCameraEvent(RoomWidgetCameraEvent.TOGGLE_CAMERA));
|
||||
CreateLinkEvent('camera/toggle');
|
||||
return;
|
||||
case ToolbarViewItems.CLOTHING_ITEM:
|
||||
dispatchUiEvent(new AvatarEditorEvent(AvatarEditorEvent.TOGGLE_EDITOR));
|
||||
CreateLinkEvent('avatar-editor/toggle');
|
||||
setMeExpanded(false);
|
||||
return;
|
||||
case ToolbarViewItems.MOD_TOOLS_ITEM:
|
||||
|
@ -1,8 +0,0 @@
|
||||
import { NitroEvent } from '@nitrots/nitro-renderer';
|
||||
|
||||
export class AvatarEditorEvent extends NitroEvent
|
||||
{
|
||||
public static SHOW_EDITOR: string = 'AEE_SHOW_EDITOR';
|
||||
public static HIDE_EDITOR: string = 'AEE_HIDE_EDITOR';
|
||||
public static TOGGLE_EDITOR: string = 'AEE_TOGGLE_EDITOR';
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './AvatarEditorEvent';
|
@ -1,8 +0,0 @@
|
||||
import { NitroEvent } from '@nitrots/nitro-renderer';
|
||||
|
||||
export class RoomWidgetCameraEvent extends NitroEvent
|
||||
{
|
||||
public static SHOW_CAMERA: string = 'NE_SHOW_CAMERA';
|
||||
public static HIDE_CAMERA: string = 'NE_HIDE_CAMERA';
|
||||
public static TOGGLE_CAMERA: string = 'NE_TOGGLE_CAMERA';
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './RoomWidgetCameraEvent';
|
@ -1,6 +1,4 @@
|
||||
export * from './achievements';
|
||||
export * from './avatar-editor';
|
||||
export * from './camera';
|
||||
export * from './catalog';
|
||||
export * from './floorplan-editor';
|
||||
export * from './friends';
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { AvatarAction, AvatarExpressionEnum, RoomControllerLevel, RoomObjectCategory } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useMemo, useState } from 'react';
|
||||
import { GetCanStandUp, GetCanUseExpression, GetOwnPosture, GetUserProfile, HasHabboClub, HasHabboVip, IsRidingHorse, LocalizeText, RoomWidgetAvatarExpressionMessage, RoomWidgetChangePostureMessage, RoomWidgetDanceMessage, RoomWidgetMessage, RoomWidgetUpdateDecorateModeEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUserActionMessage } from '../../../../api';
|
||||
import { CreateLinkEvent, GetCanStandUp, GetCanUseExpression, GetOwnPosture, GetUserProfile, HasHabboClub, HasHabboVip, IsRidingHorse, LocalizeText, RoomWidgetAvatarExpressionMessage, RoomWidgetChangePostureMessage, RoomWidgetDanceMessage, RoomWidgetMessage, RoomWidgetUpdateDecorateModeEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUserActionMessage } from '../../../../api';
|
||||
import { Flex } from '../../../../common';
|
||||
import { AvatarEditorEvent } from '../../../../events';
|
||||
import { HelpNameChangeEvent } from '../../../../events/help/HelpNameChangeEvent';
|
||||
import { dispatchUiEvent } from '../../../../hooks';
|
||||
import { CurrencyIcon } from '../../../shared/currency-icon/CurrencyIcon';
|
||||
@ -55,7 +54,7 @@ export const AvatarInfoWidgetOwnAvatarView: FC<AvatarInfoWidgetOwnAvatarViewProp
|
||||
dispatchUiEvent(new HelpNameChangeEvent(HelpNameChangeEvent.INIT));
|
||||
break;
|
||||
case 'change_looks':
|
||||
dispatchUiEvent(new AvatarEditorEvent(AvatarEditorEvent.SHOW_EDITOR));
|
||||
CreateLinkEvent('avatar-editor/show');
|
||||
break;
|
||||
case 'expressions':
|
||||
hideMenu = false;
|
||||
|
Loading…
Reference in New Issue
Block a user