diff --git a/src/api/nitro/room/widgets/events/RoomWidgetUpdateDecorateModeEvent.ts b/src/api/nitro/room/widgets/events/RoomWidgetUpdateDecorateModeEvent.ts
new file mode 100644
index 00000000..212e371c
--- /dev/null
+++ b/src/api/nitro/room/widgets/events/RoomWidgetUpdateDecorateModeEvent.ts
@@ -0,0 +1,20 @@
+import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
+
+export class RoomWidgetUpdateDecorateModeEvent extends RoomWidgetUpdateEvent
+{
+ public static UPDATE_DECORATE: string = 'RWUDME_UPDATE_DECORATE';
+
+ private _isDecorating: boolean;
+
+ constructor(isDecorating: boolean)
+ {
+ super(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE);
+
+ this._isDecorating = isDecorating;
+ }
+
+ public get isDecorating(): boolean
+ {
+ return this._isDecorating;
+ }
+}
diff --git a/src/api/nitro/room/widgets/events/index.ts b/src/api/nitro/room/widgets/events/index.ts
index f612d85b..775d210e 100644
--- a/src/api/nitro/room/widgets/events/index.ts
+++ b/src/api/nitro/room/widgets/events/index.ts
@@ -14,6 +14,7 @@ export * from './RoomWidgetUpdateChatInputContentEvent';
export * from './RoomWidgetUpdateCreditFurniEvent';
export * from './RoomWidgetUpdateCustomStackHeightEvent';
export * from './RoomWidgetUpdateDanceStatusEvent';
+export * from './RoomWidgetUpdateDecorateModeEvent';
export * from './RoomWidgetUpdateDimmerEvent';
export * from './RoomWidgetUpdateDimmerStateEvent';
export * from './RoomWidgetUpdateEvent';
diff --git a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx
index d949cfaa..a12d17bc 100644
--- a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx
+++ b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx
@@ -1,6 +1,6 @@
import { RoomEnterEffect, RoomObjectCategory } from '@nitrots/nitro-renderer';
import { FC, useCallback, useMemo, useState } from 'react';
-import { GetRoomSession, GetSessionDataManager, RoomWidgetObjectNameEvent, RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectMessage, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateDanceStatusEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRentableBotChatEvent, RoomWidgetUseProductBubbleEvent, UseProductItem } from '../../../../api';
+import { GetRoomSession, GetSessionDataManager, RoomWidgetObjectNameEvent, RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectMessage, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateDanceStatusEvent, RoomWidgetUpdateDecorateModeEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRentableBotChatEvent, RoomWidgetUseProductBubbleEvent, UseProductItem } from '../../../../api';
import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base';
import { useRoomContext } from '../../context/RoomContext';
import { AvatarInfoWidgetAvatarView } from './views/avatar/AvatarInfoWidgetAvatarView';
@@ -264,6 +264,13 @@ export const AvatarInfoWidgetView: FC<{}> = props =>
// useUiEvent(FriendEnteredRoomEvent.ENTERED, onFriendEnteredRoomEvent);
+ const onRoomWidgetUpdateDecorateModeEvent = useCallback((event: RoomWidgetUpdateDecorateModeEvent) =>
+ {
+ setIsDecorating(event.isDecorating);
+ }, []);
+
+ CreateEventDispatcherHook(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE, eventDispatcher, onRoomWidgetUpdateDecorateModeEvent);
+
const decorateView = useMemo(() =>
{
GetRoomSession().isDecorating = isDecorating;
@@ -274,7 +281,7 @@ export const AvatarInfoWidgetView: FC<{}> = props =>
const userName = GetSessionDataManager().userName;
const roomIndex = GetRoomSession().ownRoomIndex;
- return ;
+ return ;
}, [ isDecorating ]);
const currentView = useMemo(() =>
@@ -316,7 +323,7 @@ export const AvatarInfoWidgetView: FC<{}> = props =>
{
if(RoomEnterEffect.isRunning()) return null;
- return ;
+ return ;
}
return ;
diff --git a/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.tsx b/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.tsx
index 5a365394..95b752b0 100644
--- a/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.tsx
+++ b/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.tsx
@@ -1,6 +1,7 @@
import { RoomObjectCategory } from '@nitrots/nitro-renderer';
-import { FC } from 'react';
-import { LocalizeText } from '../../../../../../api';
+import { FC, useCallback } from 'react';
+import { LocalizeText, RoomWidgetUpdateDecorateModeEvent } from '../../../../../../api';
+import { useRoomContext } from '../../../../context/RoomContext';
import { ContextMenuView } from '../../../context-menu/ContextMenuView';
import { ContextMenuListItemView } from '../../../context-menu/views/list-item/ContextMenuListItemView';
import { ContextMenuListView } from '../../../context-menu/views/list/ContextMenuListView';
@@ -8,12 +9,18 @@ import { AvatarInfoWidgetDecorateViewProps } from './AvatarInfoWidgetDecorateVie
export const AvatarInfoWidgetDecorateView: FC = props =>
{
- const { userId = -1, userName = '', roomIndex = -1, setIsDecorating = null } = props;
+ const { userId = -1, userName = '', roomIndex = -1 } = props;
+ const { eventDispatcher = null } = useRoomContext();
+
+ const stopDecorating = useCallback(() =>
+ {
+ eventDispatcher.dispatchEvent(new RoomWidgetUpdateDecorateModeEvent(false));
+ }, [ eventDispatcher ]);
return (
- setIsDecorating(false) }>
+
{ LocalizeText('widget.avatar.stop_decorating') }
diff --git a/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.types.ts b/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.types.ts
index 2440f17a..86c19e35 100644
--- a/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.types.ts
+++ b/src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.types.ts
@@ -1,9 +1,7 @@
-import { Dispatch, SetStateAction } from 'react';
export interface AvatarInfoWidgetDecorateViewProps
{
userId: number;
userName: string;
roomIndex: number;
- setIsDecorating: Dispatch>;
}
diff --git a/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.tsx b/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.tsx
index c5555ec3..1fa8c8e0 100644
--- a/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.tsx
+++ b/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.tsx
@@ -1,6 +1,6 @@
import { AvatarAction, AvatarExpressionEnum, RoomObjectCategory, UserProfileComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
-import { GetCanStandUp, GetCanUseExpression, GetOwnPosture, HasHabboClub, HasHabboVip, IsRidingHorse, LocalizeText, RoomWidgetAvatarExpressionMessage, RoomWidgetChangePostureMessage, RoomWidgetDanceMessage, RoomWidgetMessage, RoomWidgetUserActionMessage } from '../../../../../../api';
+import { GetCanStandUp, GetCanUseExpression, GetOwnPosture, HasHabboClub, HasHabboVip, IsRidingHorse, LocalizeText, RoomWidgetAvatarExpressionMessage, RoomWidgetChangePostureMessage, RoomWidgetDanceMessage, RoomWidgetMessage, RoomWidgetUpdateDecorateModeEvent, RoomWidgetUserActionMessage } from '../../../../../../api';
import { AvatarEditorEvent } from '../../../../../../events';
import { dispatchUiEvent, SendMessageHook } from '../../../../../../hooks';
import { CurrencyIcon } from '../../../../../shared/currency-icon/CurrencyIcon';
@@ -18,9 +18,9 @@ const MODE_SIGNS = 4;
export const AvatarInfoWidgetOwnAvatarView: FC = props =>
{
- const { userData = null, isDancing = false, setIsDecorating = null, close = null } = props;
+ const { userData = null, isDancing = false, close = null } = props;
const [ mode, setMode ] = useState((isDancing && HasHabboClub()) ? MODE_CLUB_DANCES : MODE_NORMAL);
- const { roomSession = null, widgetHandler = null } = useRoomContext();
+ const { roomSession = null, eventDispatcher = null, widgetHandler = null } = useRoomContext();
const processAction = useCallback((name: string) =>
{
@@ -40,7 +40,7 @@ export const AvatarInfoWidgetOwnAvatarView: FC
{
diff --git a/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.types.ts b/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.types.ts
index e462efa6..00db768e 100644
--- a/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.types.ts
+++ b/src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.types.ts
@@ -1,10 +1,8 @@
-import { Dispatch, SetStateAction } from 'react';
import { RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api';
export interface AvatarInfoWidgetOwnAvatarViewProps
{
userData: RoomWidgetUpdateInfostandUserEvent;
isDancing: boolean;
- setIsDecorating: Dispatch>;
close: () => void;
}
diff --git a/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx b/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx
index d7b60d69..33752c8f 100644
--- a/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx
+++ b/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx
@@ -1,36 +1,17 @@
import { RoomObjectOperationType } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
-import { ProcessRoomObjectOperation, RoomWidgetRoomObjectUpdateEvent } from '../../../../../api';
+import { ProcessRoomObjectOperation, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateDecorateModeEvent } from '../../../../../api';
+import { BatchUpdates } from '../../../../../hooks';
import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base';
import { useRoomContext } from '../../../context/RoomContext';
import { ObjectLocationView } from '../../object-location/ObjectLocationView';
export const FurnitureManipulationMenuView: FC<{}> = props =>
{
- const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ isVisible, setIsVisible ] = useState(false);
const [ objectId, setObjectId ] = useState(-1);
const [ objectType, setObjectType ] = useState(-1);
-
- const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) =>
- {
- switch(event.type)
- {
- case RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION: {
- setIsVisible(true);
- setObjectId(event.id);
- setObjectType(event.category);
- return;
- }
- case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: {
- return;
- }
- case RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED: {
- setIsVisible(false);
- return;
- }
- }
- }, []);
+ const { roomSession = null, eventDispatcher = null, widgetHandler = null } = useRoomContext();
const rotateFurniture = useCallback(() =>
{
@@ -42,22 +23,87 @@ export const FurnitureManipulationMenuView: FC<{}> = props =>
ProcessRoomObjectOperation(objectId, objectType, RoomObjectOperationType.OBJECT_MOVE);
}, [ objectId, objectType ]);
- useEffect(() =>
+ const pickupFurniture = useCallback(() =>
{
- if(!isVisible) return;
+ ProcessRoomObjectOperation(objectId, objectType, RoomObjectOperationType.OBJECT_PICKUP);
+ }, [ objectId, objectType ]);
- moveFurniture();
- }, [ isVisible, moveFurniture ]);
+ const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) =>
+ {
+ switch(event.type)
+ {
+ case RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION: {
+ BatchUpdates(() =>
+ {
+ setIsVisible(true);
+ setObjectId(event.id);
+ setObjectType(event.category);
+ });
+ return;
+ }
+ case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: {
+ if(event.id === objectId)
+ {
+ BatchUpdates(() =>
+ {
+ setIsVisible(false);
+ setObjectId(-1);
+ setObjectType(-1);
+ });
+ }
+ return;
+ }
+ case RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED: {
+ BatchUpdates(() =>
+ {
+ setIsVisible(false);
+ setObjectId(-1);
+ setObjectType(-1);
+ });
+ return;
+ }
+ }
+ }, [ objectId ]);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent);
+ const onRoomWidgetUpdateDecorateModeEvent = useCallback((event: RoomWidgetUpdateDecorateModeEvent) =>
+ {
+ if(event.isDecorating) return;
+
+ moveFurniture();
+
+ BatchUpdates(() =>
+ {
+ setIsVisible(false);
+ setObjectId(-1);
+ setObjectType(-1);
+ });
+ }, [ moveFurniture ]);
+
+ CreateEventDispatcherHook(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE, eventDispatcher, onRoomWidgetUpdateDecorateModeEvent);
+
+ useEffect(() =>
+ {
+ if(!isVisible)
+ {
+ eventDispatcher.dispatchEvent(new RoomWidgetUpdateDecorateModeEvent(false));
+
+ return;
+ }
+
+ eventDispatcher.dispatchEvent(new RoomWidgetUpdateDecorateModeEvent(true));
+
+ moveFurniture();
+ }, [ eventDispatcher, isVisible, moveFurniture ]);
+
if(!isVisible) return null;
return (
-