diff --git a/src/components/room/widgets/RoomWidgetsView.tsx b/src/components/room/widgets/RoomWidgetsView.tsx index 8f1bd8a6..59e9cfbf 100644 --- a/src/components/room/widgets/RoomWidgetsView.tsx +++ b/src/components/room/widgets/RoomWidgetsView.tsx @@ -10,6 +10,7 @@ import { UserChooserWidgetView } from './choosers/UserChooserWidgetView'; import { DoorbellWidgetView } from './doorbell/DoorbellWidgetView'; import { FriendRequestWidgetView } from './friend-request/FriendRequestWidgetView'; import { FurnitureWidgetsView } from './furniture/FurnitureWidgetsView'; +import { PetTrainingPanelWidgetView } from './pet-training/PetTrainingPanelWidgetView'; import { RoomFilterWordsWidgetView } from './room-filter-words/RoomFilterWordsWidgetView'; import { RoomThumbnailWidgetView } from './room-thumbnail/RoomThumbnailWidgetView'; import { RoomToolsWidgetView } from './room-tools/RoomToolsWidgetView'; @@ -165,6 +166,7 @@ export const RoomWidgetsView: FC<{}> = props => + ); } diff --git a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetPetView.tsx b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetPetView.tsx index 88908d59..b8109ee9 100644 --- a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetPetView.tsx +++ b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetPetView.tsx @@ -57,7 +57,7 @@ export const InfoStandWidgetPetView: FC = props => CreateLinkEvent('catalog/open/' + GetConfiguration('catalog.links')['pets.buy_food']); break; case 'train': - // not coded + roomSession?.requestPetCommands(avatarInfo.id); break; case 'treat': SendMessageComposer(new PetRespectComposer(avatarInfo.id)); diff --git a/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetOwnPetView.tsx b/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetOwnPetView.tsx index af889c12..cdd4bba4 100644 --- a/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetOwnPetView.tsx +++ b/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetOwnPetView.tsx @@ -60,7 +60,7 @@ export const AvatarInfoWidgetOwnPetView: FC = p SendMessageComposer(new RoomUnitGiveHandItemPetComposer(avatarInfo.id)); break; case 'train': - //this.widget._Str_23877(); + roomSession.requestPetCommands(avatarInfo.id); break; case 'pick_up': roomSession.pickupPet(avatarInfo.id); diff --git a/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx b/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx new file mode 100644 index 00000000..22d95cc0 --- /dev/null +++ b/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx @@ -0,0 +1,58 @@ +import { DesktopViewEvent, PetTrainingPanelMessageEvent } from '@nitrots/nitro-renderer'; +import { FC } from 'react'; +import { AvatarInfoPet, LocalizeText } from '../../../../api'; +import { Button, Column, Flex, Grid, LayoutPetImageView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; +import { useAvatarInfoWidget, useMessageEvent, useRoom, useSessionInfo } from '../../../../hooks'; + +export const PetTrainingPanelWidgetView: FC<{}> = props => +{ + const { avatarInfo = null, petTrainInformation = null, setPetTrainInformation = null } = useAvatarInfoWidget(); + const { chatStyleId = 0 } = useSessionInfo(); + const { roomSession = null } = useRoom(); + + useMessageEvent(DesktopViewEvent, event => + { + setPetTrainInformation(null); + }); + + useMessageEvent(PetTrainingPanelMessageEvent, event => + { + const parser = event.getParser(); + + if (!parser) return; + + setPetTrainInformation(parser); + }); + + const processPetAction = (petName: string, commandName: string) => + { + if (!petName || !commandName) return; + + roomSession?.sendChatMessage(`${ petName } ${ commandName }`, chatStyleId); + } + + if(!petTrainInformation) return null; + + return ( + + setPetTrainInformation(null) } /> + + + + + + + { (avatarInfo as AvatarInfoPet)?.name } + + + + { + (petTrainInformation.commands && petTrainInformation.commands.length > 0) && petTrainInformation.commands.map((command, index) => + + ) + } + + + + ); +}; diff --git a/src/hooks/rooms/widgets/useAvatarInfoWidget.ts b/src/hooks/rooms/widgets/useAvatarInfoWidget.ts index 9545362a..afe46658 100644 --- a/src/hooks/rooms/widgets/useAvatarInfoWidget.ts +++ b/src/hooks/rooms/widgets/useAvatarInfoWidget.ts @@ -1,4 +1,4 @@ -import { RoomEngineObjectEvent, RoomEngineUseProductEvent, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionPetInfoUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserDataUpdateEvent } from '@nitrots/nitro-renderer'; +import { PetTrainingMessageParser, RoomEngineObjectEvent, RoomEngineUseProductEvent, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionPetInfoUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserDataUpdateEvent } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { AvatarInfoFurni, AvatarInfoName, AvatarInfoPet, AvatarInfoRentableBot, AvatarInfoUser, AvatarInfoUtilities, CanManipulateFurniture, FurniCategory, GetRoomEngine, GetSessionDataManager, IAvatarInfo, IsOwnerOfFurniture, RoomWidgetUpdateRoomObjectEvent, UseProductItem } from '../../../api'; import { useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../../events'; @@ -14,6 +14,7 @@ const useAvatarInfoWidgetState = () => const [ nameBubbles, setNameBubbles ] = useState([]); const [ productBubbles, setProductBubbles ] = useState([]); const [ confirmingProduct, setConfirmingProduct ] = useState(null); + const [ petTrainInformation, setPetTrainInformation ] = useState(null); const [ pendingPetId, setPendingPetId ] = useState(-1); const [ isDecorating, setIsDecorating ] = useState(false); const { friends = [] } = useFriends(); @@ -65,6 +66,7 @@ const useAvatarInfoWidgetState = () => const getObjectInfo = (objectId: number, category: number) => { let info: IAvatarInfo = null; + setPetTrainInformation(null); switch(category) { @@ -272,6 +274,7 @@ const useAvatarInfoWidgetState = () => useObjectDeselectedEvent(event => { setAvatarInfo(null); + setPetTrainInformation(null); setProductBubbles([]); }); @@ -349,7 +352,7 @@ const useAvatarInfoWidgetState = () => roomSession.isDecorating = isDecorating; }, [ roomSession, isDecorating ]); - return { avatarInfo, setAvatarInfo, activeNameBubble, setActiveNameBubble, nameBubbles, productBubbles, confirmingProduct, isDecorating, setIsDecorating, removeNameBubble, removeProductBubble, updateConfirmingProduct, getObjectName }; + return { avatarInfo, setAvatarInfo, activeNameBubble, setActiveNameBubble, nameBubbles, productBubbles, confirmingProduct, petTrainInformation, setPetTrainInformation, isDecorating, setIsDecorating, removeNameBubble, removeProductBubble, updateConfirmingProduct, getObjectName }; } export const useAvatarInfoWidget = useAvatarInfoWidgetState;