mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-22 22:30:52 +01:00
Merge branch 'pet-training' of https://github.com/oobjectt/nitro-react into oobjectt-pet-training
This commit is contained in:
commit
ca0363096c
@ -10,6 +10,7 @@ import { UserChooserWidgetView } from './choosers/UserChooserWidgetView';
|
|||||||
import { DoorbellWidgetView } from './doorbell/DoorbellWidgetView';
|
import { DoorbellWidgetView } from './doorbell/DoorbellWidgetView';
|
||||||
import { FriendRequestWidgetView } from './friend-request/FriendRequestWidgetView';
|
import { FriendRequestWidgetView } from './friend-request/FriendRequestWidgetView';
|
||||||
import { FurnitureWidgetsView } from './furniture/FurnitureWidgetsView';
|
import { FurnitureWidgetsView } from './furniture/FurnitureWidgetsView';
|
||||||
|
import { PetTrainingPanelWidgetView } from './pet-training/PetTrainingPanelWidgetView';
|
||||||
import { RoomFilterWordsWidgetView } from './room-filter-words/RoomFilterWordsWidgetView';
|
import { RoomFilterWordsWidgetView } from './room-filter-words/RoomFilterWordsWidgetView';
|
||||||
import { RoomThumbnailWidgetView } from './room-thumbnail/RoomThumbnailWidgetView';
|
import { RoomThumbnailWidgetView } from './room-thumbnail/RoomThumbnailWidgetView';
|
||||||
import { RoomToolsWidgetView } from './room-tools/RoomToolsWidgetView';
|
import { RoomToolsWidgetView } from './room-tools/RoomToolsWidgetView';
|
||||||
@ -165,6 +166,7 @@ export const RoomWidgetsView: FC<{}> = props =>
|
|||||||
<UserChooserWidgetView />
|
<UserChooserWidgetView />
|
||||||
<WordQuizWidgetView />
|
<WordQuizWidgetView />
|
||||||
<FriendRequestWidgetView />
|
<FriendRequestWidgetView />
|
||||||
|
<PetTrainingPanelWidgetView />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export const InfoStandWidgetPetView: FC<InfoStandWidgetPetViewProps> = props =>
|
|||||||
CreateLinkEvent('catalog/open/' + GetConfiguration('catalog.links')['pets.buy_food']);
|
CreateLinkEvent('catalog/open/' + GetConfiguration('catalog.links')['pets.buy_food']);
|
||||||
break;
|
break;
|
||||||
case 'train':
|
case 'train':
|
||||||
// not coded
|
roomSession?.requestPetCommands(avatarInfo.id);
|
||||||
break;
|
break;
|
||||||
case 'treat':
|
case 'treat':
|
||||||
SendMessageComposer(new PetRespectComposer(avatarInfo.id));
|
SendMessageComposer(new PetRespectComposer(avatarInfo.id));
|
||||||
|
@ -60,7 +60,7 @@ export const AvatarInfoWidgetOwnPetView: FC<AvatarInfoWidgetOwnPetViewProps> = p
|
|||||||
SendMessageComposer(new RoomUnitGiveHandItemPetComposer(avatarInfo.id));
|
SendMessageComposer(new RoomUnitGiveHandItemPetComposer(avatarInfo.id));
|
||||||
break;
|
break;
|
||||||
case 'train':
|
case 'train':
|
||||||
//this.widget._Str_23877();
|
roomSession.requestPetCommands(avatarInfo.id);
|
||||||
break;
|
break;
|
||||||
case 'pick_up':
|
case 'pick_up':
|
||||||
roomSession.pickupPet(avatarInfo.id);
|
roomSession.pickupPet(avatarInfo.id);
|
||||||
|
@ -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>(DesktopViewEvent, event =>
|
||||||
|
{
|
||||||
|
setPetTrainInformation(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
useMessageEvent<PetTrainingPanelMessageEvent>(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 (
|
||||||
|
<NitroCardView uniqueKey="user-settings" className="user-settings-window no-resize" theme="primary-slim">
|
||||||
|
<NitroCardHeaderView headerText={ LocalizeText('widgets.pet.commands.title') } onCloseClick={ () => setPetTrainInformation(null) } />
|
||||||
|
<NitroCardContentView className="text-black">
|
||||||
|
<Flex alignItems="center" justifyContent="center" gap={ 2 }>
|
||||||
|
<Grid columnCount={ 2 }>
|
||||||
|
<Column fullWidth overflow="hidden" className="body-image pet p-1">
|
||||||
|
<LayoutPetImageView figure={ (avatarInfo as AvatarInfoPet)?.petFigure } posture={ (avatarInfo as AvatarInfoPet)?.posture } direction={ 2 } />
|
||||||
|
</Column>
|
||||||
|
<Text variant="black" small wrap>{ (avatarInfo as AvatarInfoPet)?.name }</Text>
|
||||||
|
</Grid>
|
||||||
|
</Flex>
|
||||||
|
<Grid columnCount={ 2 }>
|
||||||
|
{
|
||||||
|
(petTrainInformation.commands && petTrainInformation.commands.length > 0) && petTrainInformation.commands.map((command, index) =>
|
||||||
|
<Button key={ index } disabled={ !petTrainInformation.enabledCommands.includes(command) } onClick={ () => processPetAction((avatarInfo as AvatarInfoPet)?.name, LocalizeText(`pet.command.${ command }`)) }>{ LocalizeText(`pet.command.${ command }`) }</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Grid>
|
||||||
|
</NitroCardContentView>
|
||||||
|
</NitroCardView>
|
||||||
|
);
|
||||||
|
};
|
@ -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 { useEffect, useState } from 'react';
|
||||||
import { AvatarInfoFurni, AvatarInfoName, AvatarInfoPet, AvatarInfoRentableBot, AvatarInfoUser, AvatarInfoUtilities, CanManipulateFurniture, FurniCategory, GetRoomEngine, GetSessionDataManager, IAvatarInfo, IsOwnerOfFurniture, RoomWidgetUpdateRoomObjectEvent, UseProductItem } from '../../../api';
|
import { AvatarInfoFurni, AvatarInfoName, AvatarInfoPet, AvatarInfoRentableBot, AvatarInfoUser, AvatarInfoUtilities, CanManipulateFurniture, FurniCategory, GetRoomEngine, GetSessionDataManager, IAvatarInfo, IsOwnerOfFurniture, RoomWidgetUpdateRoomObjectEvent, UseProductItem } from '../../../api';
|
||||||
import { useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../../events';
|
import { useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../../events';
|
||||||
@ -14,6 +14,7 @@ const useAvatarInfoWidgetState = () =>
|
|||||||
const [ nameBubbles, setNameBubbles ] = useState<AvatarInfoName[]>([]);
|
const [ nameBubbles, setNameBubbles ] = useState<AvatarInfoName[]>([]);
|
||||||
const [ productBubbles, setProductBubbles ] = useState<UseProductItem[]>([]);
|
const [ productBubbles, setProductBubbles ] = useState<UseProductItem[]>([]);
|
||||||
const [ confirmingProduct, setConfirmingProduct ] = useState<UseProductItem>(null);
|
const [ confirmingProduct, setConfirmingProduct ] = useState<UseProductItem>(null);
|
||||||
|
const [ petTrainInformation, setPetTrainInformation ] = useState<PetTrainingMessageParser>(null);
|
||||||
const [ pendingPetId, setPendingPetId ] = useState<number>(-1);
|
const [ pendingPetId, setPendingPetId ] = useState<number>(-1);
|
||||||
const [ isDecorating, setIsDecorating ] = useState(false);
|
const [ isDecorating, setIsDecorating ] = useState(false);
|
||||||
const { friends = [] } = useFriends();
|
const { friends = [] } = useFriends();
|
||||||
@ -65,6 +66,7 @@ const useAvatarInfoWidgetState = () =>
|
|||||||
const getObjectInfo = (objectId: number, category: number) =>
|
const getObjectInfo = (objectId: number, category: number) =>
|
||||||
{
|
{
|
||||||
let info: IAvatarInfo = null;
|
let info: IAvatarInfo = null;
|
||||||
|
setPetTrainInformation(null);
|
||||||
|
|
||||||
switch(category)
|
switch(category)
|
||||||
{
|
{
|
||||||
@ -272,6 +274,7 @@ const useAvatarInfoWidgetState = () =>
|
|||||||
useObjectDeselectedEvent(event =>
|
useObjectDeselectedEvent(event =>
|
||||||
{
|
{
|
||||||
setAvatarInfo(null);
|
setAvatarInfo(null);
|
||||||
|
setPetTrainInformation(null);
|
||||||
setProductBubbles([]);
|
setProductBubbles([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -349,7 +352,7 @@ const useAvatarInfoWidgetState = () =>
|
|||||||
roomSession.isDecorating = isDecorating;
|
roomSession.isDecorating = isDecorating;
|
||||||
}, [ roomSession, 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;
|
export const useAvatarInfoWidget = useAvatarInfoWidgetState;
|
||||||
|
Loading…
Reference in New Issue
Block a user