From 86d1d8ceba6c47a585af36e9fc96ede6f038e60a Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 1 Mar 2022 00:09:02 -0500 Subject: [PATCH] Update infostand --- .../infostand/InfoStandWidgetBotView.tsx | 57 +++++ .../furni => }/InfoStandWidgetFurniView.tsx | 237 ++++++++++-------- .../infostand/InfoStandWidgetPetView.tsx | 85 +++++++ .../InfoStandWidgetRentableBotView.tsx | 89 +++++++ .../InfoStandWidgetUserRelationshipsView.tsx | 47 ++++ .../infostand/InfoStandWidgetUserView.tsx | 177 +++++++++++++ .../infostand/InfoStandWidgetView.scss | 2 +- .../widgets/infostand/InfoStandWidgetView.tsx | 15 +- .../views/base/InfoStandBaseView.tsx | 20 -- .../views/base/InfoStandBaseView.types.ts | 7 - .../views/bot/InfoStandWidgetBotView.tsx | 44 ---- .../views/bot/InfoStandWidgetBotView.types.ts | 7 - .../furni/InfoStandWidgetFurniView.types.ts | 7 - .../views/pet/InfoStandWidgetPetView.tsx | 55 ---- .../views/pet/InfoStandWidgetPetView.types.ts | 7 - .../InfoStandWidgetRentableBotView.tsx | 70 ------ .../InfoStandWidgetRentableBotView.types.ts | 7 - .../views/user/InfoStandWidgetUserView.tsx | 159 ------------ .../user/InfoStandWidgetUserView.types.ts | 7 - 19 files changed, 601 insertions(+), 498 deletions(-) create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx rename src/views/room/widgets/infostand/{views/furni => }/InfoStandWidgetFurniView.tsx (53%) create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx delete mode 100644 src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx delete mode 100644 src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx delete mode 100644 src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx delete mode 100644 src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx delete mode 100644 src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx delete mode 100644 src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts diff --git a/src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx new file mode 100644 index 00000000..dac8f179 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx @@ -0,0 +1,57 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FC } from 'react'; +import { LocalizeText, RoomWidgetUpdateInfostandUserEvent } from '../../../../api'; +import { Column, Flex, Text } from '../../../../common'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; + +interface InfoStandWidgetBotViewProps +{ + botData: RoomWidgetUpdateInfostandUserEvent; + close: () => void; +} + +export const InfoStandWidgetBotView: FC = props => +{ + const { botData = null, close = null } = props; + + if(!botData) return null; + + return ( + + + + + { botData.name } + + +
+
+ + + + + + + { (botData.badges.length > 0) && botData.badges.map(result => + { + return ; + }) } + + +
+
+ + { botData.motto } + + { (botData.carryItem > 0) && + +
+ + { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + botData.carryItem) ]) } + +
} +
+
+ ); +} diff --git a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx similarity index 53% rename from src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx rename to src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx index d848327d..eae29e55 100644 --- a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx @@ -1,14 +1,20 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { CrackableDataType, GroupInformationComposer, GroupInformationEvent, RoomControllerLevel, RoomObjectCategory, RoomObjectVariable, RoomWidgetEnumItemExtradataParameter, RoomWidgetFurniInfoUsagePolicyEnum, SetObjectDataMessageComposer, StringDataType } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateLinkEvent, GetGroupInformation, GetRoomEngine, LocalizeText, RoomWidgetFurniActionMessage } from '../../../../../../api'; -import { CreateMessageHook, SendMessageHook } from '../../../../../../hooks'; -import { UserProfileIconView } from '../../../../../../layout'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { LimitedEditionCompactPlateView } from '../../../../../shared/limited-edition/LimitedEditionCompactPlateView'; -import { RarityLevelView } from '../../../../../shared/rarity-level/RarityLevelView'; -import { useRoomContext } from '../../../../context/RoomContext'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetFurniViewProps } from './InfoStandWidgetFurniView.types'; +import { CreateLinkEvent, GetGroupInformation, GetRoomEngine, LocalizeText, RoomWidgetFurniActionMessage, RoomWidgetUpdateInfostandFurniEvent } from '../../../../api'; +import { Button, Column, Flex, Text } from '../../../../common'; +import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { UserProfileIconView } from '../../../../layout'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { LimitedEditionCompactPlateView } from '../../../shared/limited-edition/LimitedEditionCompactPlateView'; +import { RarityLevelView } from '../../../shared/rarity-level/RarityLevelView'; +import { useRoomContext } from '../../context/RoomContext'; + +interface InfoStandWidgetFurniViewProps +{ + furniData: RoomWidgetUpdateInfostandFurniEvent; + close: () => void; +} const PICKUP_MODE_NONE: number = 0; const PICKUP_MODE_EJECT: number = 1; @@ -117,19 +123,22 @@ export const InfoStandWidgetFurniView: FC = props if(furniData.isStickie) pickupMode = PICKUP_MODE_NONE; - setPickupMode(pickupMode); - setCanMove(canMove); - setCanRotate(canRotate); - setCanUse(canUse); - setFurniKeys(furniKeyss); - setFurniValues(furniValuess); - setCustomKeys(customKeyss); - setCustomValues(customValuess); - setIsCrackable(isCrackable); - setCrackableHits(crackableHits); - setCrackableTarget(crackableTarget); - setGodMode(godMode); - setGroupName(null); + BatchUpdates(() => + { + setPickupMode(pickupMode); + setCanMove(canMove); + setCanRotate(canRotate); + setCanUse(canUse); + setFurniKeys(furniKeyss); + setFurniValues(furniValuess); + setCustomKeys(customKeyss); + setCustomValues(customValuess); + setIsCrackable(isCrackable); + setCrackableHits(crackableHits); + setCrackableTarget(crackableTarget); + setGodMode(godMode); + setGroupName(null); + }); if(furniData.groupId) SendMessageHook(new GroupInformationComposer(furniData.groupId, false)); }, [ roomSession, furniData ]); @@ -247,97 +256,125 @@ export const InfoStandWidgetFurniView: FC = props if(!furniData) return null; return ( - <> - -
- { furniData.stuffData.isUnique && -
- -
} - { (furniData.stuffData.rarityLevel > -1) && -
- -
} - { furniData.image && furniData.image.src.length && - } -
-
-
{ furniData.description }
-
-
- -
{ LocalizeText('furni.owner', [ 'name' ], [ furniData.ownerName ]) }
-
- { (furniData.purchaseOfferId > 0) && } - { isCrackable && - <> -
-
{ LocalizeText('infostand.crackable_furni.hits_remaining', [ 'hits', 'target' ], [ crackableHits.toString(), crackableTarget.toString() ]) }
- } - { furniData.groupId > 0 && - <> -
-
GetGroupInformation(furniData.groupId) }> - -
{ groupName }
-
- } - { godMode && - <> -
-
ID: { furniData.id }
- { (furniKeys.length > 0) && + + + + + + { furniData.name } + + +
+
+ + + { furniData.stuffData.isUnique && +
+ +
} + { (furniData.stuffData.rarityLevel > -1) && +
+ +
} + { furniData.image && furniData.image.src.length && + } +
+
+
+ + { furniData.description } +
+
+ + + + + { LocalizeText('furni.owner', [ 'name' ], [ furniData.ownerName ]) } + + + { (furniData.purchaseOfferId > 0) && + + processButtonAction('buy_one') }> + { LocalizeText('infostand.button.buy') } + + } + + + { isCrackable && + <> +
+ { LocalizeText('infostand.crackable_furni.hits_remaining', [ 'hits', 'target' ], [ crackableHits.toString(), crackableTarget.toString() ]) } + } + { furniData.groupId > 0 && + <> +
+ GetGroupInformation(furniData.groupId) }> + + { groupName } + + } + { godMode && + <> +
+ ID: { furniData.id } + { (furniKeys.length > 0) && + <> +
+ + { furniKeys.map((key, index) => + { + return ( + + { key } + onFurniSettingChange(index, event.target.value) }/> + ); + }) } + + } + } + { (customKeys.length > 0) && <>
- { furniKeys.map((key, index) => - { - return ( -
-
{ key }
- onFurniSettingChange(index, event.target.value) }/> -
); - }) } + + { customKeys.map((key, index) => + { + return ( + + { key } + onCustomVariableChange(index, event.target.value) }/> + ); + }) } + } - } - { (customKeys.length > 0) && - <> -
- { customKeys.map((key, index) => - { - return ( -
-
{ key }
- onCustomVariableChange(index, event.target.value) }/> -
); - }) } - } -
-
+ + + + { canMove && - } + } { canRotate && - } + } { canUse && - } + } { (pickupMode !== PICKUP_MODE_NONE) && - } + } { ((furniKeys.length > 0 && furniValues.length > 0) && (furniKeys.length === furniValues.length)) && - } + } { ((customKeys.length > 0 && customValues.length > 0) && (customKeys.length === customValues.length)) && - } -
- + } + + ); } diff --git a/src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx new file mode 100644 index 00000000..1b6f14d1 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx @@ -0,0 +1,85 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FC } from 'react'; +import { LocalizeText, RoomWidgetUpdateInfostandPetEvent } from '../../../../api'; +import { Base, Column, Flex, Text } from '../../../../common'; +import { UserProfileIconView } from '../../../../layout'; +import { PetImageView } from '../../../shared/pet-image/PetImageView'; + +interface InfoStandWidgetPetViewProps +{ + petData: RoomWidgetUpdateInfostandPetEvent; + close: () => void; +} + +export const InfoStandWidgetPetView: FC = props => +{ + const { petData = null, close = null } = props; + + if(!petData) return null; + + return ( + + + + + { petData.name } + + + { LocalizeText(`pet.breed.${ petData.petType }.${ petData.petBreed }`) } +
+
+ + + + + + + { LocalizeText('pet.level', [ 'level', 'maxlevel' ], [ petData.level.toString(), petData.maximumLevel.toString() ]) } + + { LocalizeText('infostand.pet.text.happiness') } + + + { petData.happyness + '/' + petData.maximumHappyness } + + + + + + { LocalizeText('infostand.pet.text.experience') } + + + { petData.experience + '/' + petData.levelExperienceGoal } + + + + + + { LocalizeText('infostand.pet.text.energy') } + + + { petData.energy + '/' + petData.maximumEnergy } + + + + + + +
+
+ + { LocalizeText('infostand.text.petrespect', [ 'count' ], [ petData.respect.toString() ]) } + { LocalizeText('pet.age', [ 'age' ], [ petData.age.toString() ]) } +
+
+ + + + + { LocalizeText('infostand.text.petowner', [ 'name' ], [ petData.ownerName ]) } + + + +
+
+ ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx new file mode 100644 index 00000000..d3847d31 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx @@ -0,0 +1,89 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { BotRemoveComposer } from '@nitrots/nitro-renderer'; +import { FC, useMemo } from 'react'; +import { LocalizeText, RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../api'; +import { Button, Column, Flex, Text } from '../../../../common'; +import { SendMessageHook } from '../../../../hooks'; +import { UserProfileIconView } from '../../../../layout'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { BotSkillsEnum } from '../avatar-info/common/BotSkillsEnum'; + +interface InfoStandWidgetRentableBotViewProps +{ + rentableBotData: RoomWidgetUpdateInfostandRentableBotEvent; + close: () => void; +} + +export const InfoStandWidgetRentableBotView: FC = props => +{ + const { rentableBotData = null, close = null } = props; + + const canPickup = useMemo(() => + { + if(rentableBotData.botSkills.indexOf(BotSkillsEnum.NO_PICK_UP) >= 0) return false; + + if(!rentableBotData.amIOwner && !rentableBotData.amIAnyRoomController) return false; + + return true; + }, [ rentableBotData ]); + + const pickupBot = () => SendMessageHook(new BotRemoveComposer(rentableBotData.webID)); + + if(!rentableBotData) return; + + return ( + + + + + + { rentableBotData.name } + + +
+
+ + + + + + + { (rentableBotData.badges.length > 0) && rentableBotData.badges.map(result => + { + return ; + }) } + + +
+
+ + + { rentableBotData.motto } + +
+
+ + + + + { LocalizeText('infostand.text.botowner', [ 'name' ], [ rentableBotData.ownerName ]) } + + + { (rentableBotData.carryItem > 0) && + <> +
+ + { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + rentableBotData.carryItem) ]) } + + } +
+
+
+ { canPickup && + + + } +
+ ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx new file mode 100644 index 00000000..dea72734 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx @@ -0,0 +1,47 @@ +import { RelationshipStatusEnum, RelationshipStatusInfoMessageParser } from '@nitrots/nitro-renderer'; +import { FC } from 'react'; +import { GetUserProfile, LocalizeText } from '../../../../api'; +import { Flex, Text } from '../../../../common'; + +interface InfoStandWidgetUserRelationshipsViewProps +{ + relationships: RelationshipStatusInfoMessageParser; +} + +interface InfoStandWidgetUserRelationshipsRelationshipViewProps +{ + type: number; +} + +export const InfoStandWidgetUserRelationshipsView: FC = props => +{ + const { relationships = null } = props; + + const RelationshipComponent = ({ type }: InfoStandWidgetUserRelationshipsRelationshipViewProps) => + { + const relationshipInfo = (relationships && relationships.relationshipStatusMap.hasKey(type)) ? relationships.relationshipStatusMap.getValue(type) : null; + + if(!relationshipInfo || !relationshipInfo.friendCount) return null; + + const relationshipName = RelationshipStatusEnum.RELATIONSHIP_NAMES[type].toLocaleLowerCase(); + + return ( + + + + GetUserProfile(relationshipInfo.randomFriendId) }>{ relationshipInfo.randomFriendName } + { (relationshipInfo.friendCount > 1) && + { ' ' + LocalizeText(`extendedprofile.relstatus.others.${ relationshipName }`, [ 'count' ], [ (relationshipInfo.friendCount - 1).toString() ]) } } + + + ); + } + + return ( + <> + + + + + ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx new file mode 100644 index 00000000..f2faaaae --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx @@ -0,0 +1,177 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomSessionUserBadgesEvent, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; +import { FC, FocusEvent, KeyboardEvent, useCallback, useEffect, useState } from 'react'; +import { GetConfiguration, GetGroupInformation, LocalizeText, RoomWidgetChangeMottoMessage, RoomWidgetUpdateInfostandUserEvent } from '../../../../api'; +import { Column, Text } from '../../../../common'; +import { Base } from '../../../../common/Base'; +import { Flex } from '../../../../common/Flex'; +import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { CreateEventDispatcherHook } from '../../../../hooks/events'; +import { UserProfileIconView } from '../../../../layout'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { useRoomContext } from '../../context/RoomContext'; +import { InfoStandWidgetUserRelationshipsView } from './InfoStandWidgetUserRelationshipsView'; + +interface InfoStandWidgetUserViewProps +{ + userData: RoomWidgetUpdateInfostandUserEvent; + close: () => void; +} + +export const InfoStandWidgetUserView: FC = props => +{ + const { userData = null, close = null } = props; + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const [ badges, setBadges ] = useState([]); + const [ motto, setMotto ] = useState(null); + const [ isEditingMotto, setIsEditingMotto ] = useState(false); + const [ userRelationships, setUserRelationships ] = useState(null); + + const maxBadgeCount = GetConfiguration('user.badges.max.slots', 5); + + const saveMotto = (motto: string) => + { + if(motto.length > 38) return; + + widgetHandler.processWidgetMessage(new RoomWidgetChangeMottoMessage(motto)); + + setIsEditingMotto(false); + } + + const onMottoBlur = (event: FocusEvent) => saveMotto(event.target.value); + + const onMottoKeyDown = (event: KeyboardEvent) => + { + event.stopPropagation(); + + switch(event.key) + { + case 'Enter': + saveMotto((event.target as HTMLInputElement).value); + return; + } + } + + const onRoomSessionUserBadgesEvent = useCallback((event: RoomSessionUserBadgesEvent) => + { + if(!userData || (userData.webID !== event.userId)) return; + + setBadges(event.badges); + }, [ userData ]); + + CreateEventDispatcherHook(RoomSessionUserBadgesEvent.RSUBE_BADGES, eventDispatcher, onRoomSessionUserBadgesEvent); + + const onUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) => + { + const parser = event.getParser(); + + if(!userData || (userData.webID !== parser.userId)) return; + + setUserRelationships(parser); + }, [ userData ]); + + CreateMessageHook(RelationshipStatusInfoEvent, onUserRelationshipsEvent); + + useEffect(() => + { + BatchUpdates(() => + { + setBadges(userData.badges); + setIsEditingMotto(false); + setMotto(userData.motto); + }); + + SendMessageHook(new UserRelationshipsComposer(userData.webID)); + + return () => + { + setBadges([]); + setUserRelationships(null); + } + }, [ userData ]); + + if(!userData) return null; + + return ( + + + + + + + { userData.name } + + + +
+
+ + + + + + + + + { badges[0] && } + + 0) } className="badge-image" onClick={ event => GetGroupInformation(userData.groupId) }> + { userData.groupId > 0 && + } + + + + + { badges[1] && } + + + { badges[2] && } + + + + + { badges[3] && } + + + { badges[4] && } + + + + +
+
+ + + { (userData.type !== RoomWidgetUpdateInfostandUserEvent.OWN_USER) && + { motto } } + { userData.type === RoomWidgetUpdateInfostandUserEvent.OWN_USER && + + + { !isEditingMotto && + setIsEditingMotto(true) }>{ motto } } + { isEditingMotto && + setMotto(event.target.value) } onBlur={ onMottoBlur } onKeyDown={ onMottoKeyDown } autoFocus={ true } /> } + } + +
+
+ + + { LocalizeText('infostand.text.achievement_score') + ' ' + userData.achievementScore } + + { (userData.carryItem > 0) && + <> +
+ + { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + userData.carryItem) ]) } + + } +
+ + + +
+
+ ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.scss b/src/views/room/widgets/infostand/InfoStandWidgetView.scss index 53ad09d5..2e57c0c0 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.scss +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.scss @@ -4,6 +4,7 @@ bottom: $toolbar-height + 10px; pointer-events: none; z-index: $infostand-zindex; + color: $white; .nitro-infostand { position: relative; @@ -28,7 +29,6 @@ width: 100%; max-width: 68px; border-radius: $border-radius; - margin-right: 5px; &.pet { max-width: 75px; diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx index 4f240121..ef76d03d 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx @@ -1,12 +1,13 @@ import { FC, useCallback, useState } from 'react'; import { RoomWidgetRoomObjectMessage, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; +import { Column } from '../../../../common'; import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; import { useRoomContext } from '../../context/RoomContext'; -import { InfoStandWidgetBotView } from './views/bot/InfoStandWidgetBotView'; -import { InfoStandWidgetFurniView } from './views/furni/InfoStandWidgetFurniView'; -import { InfoStandWidgetPetView } from './views/pet/InfoStandWidgetPetView'; -import { InfoStandWidgetRentableBotView } from './views/rentable-bot/InfoStandWidgetRentableBotView'; -import { InfoStandWidgetUserView } from './views/user/InfoStandWidgetUserView'; +import { InfoStandWidgetBotView } from './InfoStandWidgetBotView'; +import { InfoStandWidgetFurniView } from './InfoStandWidgetFurniView'; +import { InfoStandWidgetPetView } from './InfoStandWidgetPetView'; +import { InfoStandWidgetRentableBotView } from './InfoStandWidgetRentableBotView'; +import { InfoStandWidgetUserView } from './InfoStandWidgetUserView'; export const InfoStandWidgetView: FC<{}> = props => { @@ -116,8 +117,8 @@ export const InfoStandWidgetView: FC<{}> = props => if(!infoStandEvent) return null; return ( -
+ { getInfostandView() } -
+ ); } diff --git a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx b/src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx deleted file mode 100644 index 19569bd0..00000000 --- a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { FC } from 'react'; -import { InfoStandBaseViewProps } from './InfoStandBaseView.types'; - -export const InfoStandBaseView: FC = props => -{ - const { headerText = null, onCloseClick = null, children = null } = props; - - return ( -
-
-
-
{ headerText }
- -
-
- { children } -
-
- ); -} diff --git a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts b/src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts deleted file mode 100644 index bb775875..00000000 --- a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { MouseEvent, ReactNode } from 'react'; - -export interface InfoStandBaseViewProps -{ - headerText: ReactNode; - onCloseClick: (event: MouseEvent) => void; -} diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx deleted file mode 100644 index 682f801c..00000000 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetBotViewProps } from './InfoStandWidgetBotView.types'; - -export const InfoStandWidgetBotView: FC = props => -{ - const { botData = null, close = null } = props; - - const processButtonAction = useCallback((action: string) => - { - if(!action || (action === '')) return; - - }, []); - - if(!botData) return null; - - return ( - -
-
- -
-
- { (botData.badges.length > 0) && botData.badges.map(result => - { - return ; - }) } -
-
-
-
{ botData.motto }
- { (botData.carryItem > 0) && - <> -
-
- { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + botData.carryItem) ]) } -
- } -
- ); -} diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts deleted file mode 100644 index 6691eec4..00000000 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api'; - -export interface InfoStandWidgetBotViewProps -{ - botData: RoomWidgetUpdateInfostandUserEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts b/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts deleted file mode 100644 index c4a77f9c..00000000 --- a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandFurniEvent } from '../../../../../../api'; - -export interface InfoStandWidgetFurniViewProps -{ - furniData: RoomWidgetUpdateInfostandFurniEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx b/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx deleted file mode 100644 index a2482ced..00000000 --- a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { FC } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { UserProfileIconView } from '../../../../../../layout'; -import { PetImageView } from '../../../../../shared/pet-image/PetImageView'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetPetViewProps } from './InfoStandWidgetPetView.types'; - -export const InfoStandWidgetPetView: FC = props => -{ - const { petData = null, close = null } = props; - - if(!petData) return null; - - return ( - { petData.name }
{ LocalizeText('pet.breed.' + petData.petType + '.' + petData.petBreed) } } onCloseClick={ close }> -
-
- -
-
-
{ LocalizeText('pet.level', ['level', 'maxlevel'], [petData.level.toString(), petData.maximumLevel.toString()]) }
-
-
{ LocalizeText('infostand.pet.text.happiness') }
-
-
{ petData.happyness + '/' + petData.maximumHappyness }
-
-
-
-
-
{ LocalizeText('infostand.pet.text.experience') }
-
-
{ petData.experience + '/' + petData.levelExperienceGoal }
-
-
-
-
-
{ LocalizeText('infostand.pet.text.energy') }
-
-
{ petData.energy + '/' + petData.maximumEnergy }
-
-
-
-
-
-
-
{ LocalizeText('infostand.text.petrespect', ['count'], [petData.respect.toString()]) }
-
{ LocalizeText('pet.age', ['age'], [petData.age.toString()]) }
-
-
- -
{ LocalizeText('infostand.text.petowner', ['name'], [petData.ownerName]) }
-
- - ); -} diff --git a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts b/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts deleted file mode 100644 index 46d61195..00000000 --- a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandPetEvent } from '../../../../../../api'; - -export interface InfoStandWidgetPetViewProps -{ - petData: RoomWidgetUpdateInfostandPetEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx deleted file mode 100644 index e4214850..00000000 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { BotRemoveComposer } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useMemo } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { SendMessageHook } from '../../../../../../hooks'; -import { UserProfileIconView } from '../../../../../../layout'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { BotSkillsEnum } from '../../../avatar-info/common/BotSkillsEnum'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetRentableBotViewProps } from './InfoStandWidgetRentableBotView.types'; - -export const InfoStandWidgetRentableBotView: FC = props => -{ - const { rentableBotData = null, close = null } = props; - - const canPickup = useMemo(() => - { - if(rentableBotData.botSkills.indexOf(BotSkillsEnum.NO_PICK_UP) >= 0) return false; - - if(!rentableBotData.amIOwner && !rentableBotData.amIAnyRoomController) return false; - - return true; - }, [ rentableBotData ]); - - const pickupBot = useCallback(() => - { - SendMessageHook(new BotRemoveComposer(rentableBotData.webID)); - }, [ rentableBotData ]); - - if(!rentableBotData) return; - - return ( - <> - -
-
- -
-
- { (rentableBotData.badges.length > 0) && rentableBotData.badges.map(result => - { - return ; - }) } -
-
-
-
{ rentableBotData.motto }
-
-
- -
{ LocalizeText('infostand.text.botowner', [ 'name' ], [ rentableBotData.ownerName ]) }
-
- { (rentableBotData.carryItem > 0) && - <> -
-
- { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + rentableBotData.carryItem) ]) } -
- } -
- { canPickup && -
- -
} - - ); -} diff --git a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts deleted file mode 100644 index d3480bd1..00000000 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../../../api'; - -export interface InfoStandWidgetRentableBotViewProps -{ - rentableBotData: RoomWidgetUpdateInfostandRentableBotEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx deleted file mode 100644 index 44e90e40..00000000 --- a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomSessionUserBadgesEvent, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; -import classNames from 'classnames'; -import { FC, FocusEvent, KeyboardEvent, useCallback, useEffect, useState } from 'react'; -import { GetGroupInformation, LocalizeText, RoomWidgetChangeMottoMessage, RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api'; -import { Base } from '../../../../../../common/Base'; -import { Flex } from '../../../../../../common/Flex'; -import { RelationshipsContainerView } from '../../../../../../components/user-profile/views/RelationshipsContainerView'; -import { CreateMessageHook, SendMessageHook } from '../../../../../../hooks'; -import { CreateEventDispatcherHook } from '../../../../../../hooks/events'; -import { UserProfileIconView } from '../../../../../../layout'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { useRoomContext } from '../../../../context/RoomContext'; -import { InfoStandWidgetUserViewProps } from './InfoStandWidgetUserView.types'; - -export const InfoStandWidgetUserView: FC = props => -{ - const { userData = null, close = null } = props; - const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); - const [ badges, setBadges ] = useState([]); - const [ motto, setMotto ] = useState(null); - const [ isEditingMotto, setIsEditingMotto ] = useState(false); - const [ userRelationships, setUserRelationships ] = useState(null); - - const saveMotto = useCallback((motto: string) => - { - if(motto.length > 38) return; - - widgetHandler.processWidgetMessage(new RoomWidgetChangeMottoMessage(motto)); - - setIsEditingMotto(false); - }, [ widgetHandler ]); - - const onMottoBlur = useCallback((event: FocusEvent) => - { - saveMotto(event.target.value); - }, [ saveMotto ]); - - const onMottoKeyDown = useCallback((event: KeyboardEvent) => - { - event.stopPropagation(); - - switch(event.key) - { - case 'Enter': - saveMotto((event.target as HTMLInputElement).value); - return; - } - }, [ saveMotto ]); - - const onRoomSessionUserBadgesEvent = useCallback((event: RoomSessionUserBadgesEvent) => - { - if(!userData || (userData.webID !== event.userId)) return; - - setBadges(event.badges); - }, [ userData ]); - - CreateEventDispatcherHook(RoomSessionUserBadgesEvent.RSUBE_BADGES, eventDispatcher, onRoomSessionUserBadgesEvent); - - const onUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) => - { - const parser = event.getParser(); - - if(userData && userData.webID === parser.userId) - setUserRelationships(parser); - }, [userData]); - - CreateMessageHook(RelationshipStatusInfoEvent, onUserRelationshipsEvent); - - useEffect(() => - { - setBadges(userData.badges); - setIsEditingMotto(false); - setMotto(userData.motto); - SendMessageHook(new UserRelationshipsComposer(userData.webID)); - - return () => - { - setBadges([]); - setUserRelationships(null); - } - }, [ userData ]); - - if(!userData) return null; - - return ( - -
- - - - { userData.name } - - - -
- -
- -
-
- -
- { badges[0] && } -
-
0 }) } onClick={ () => GetGroupInformation(userData.groupId) }> - { userData.groupId > 0 && } -
-
- -
- { badges[1] && } -
-
- { badges[2] && } -
-
- -
- { badges[3] && } -
-
- { badges[4] && } -
-
-
-
-
-
- { (userData.type !== RoomWidgetUpdateInfostandUserEvent.OWN_USER) && -
{ motto }
} - { userData.type === RoomWidgetUpdateInfostandUserEvent.OWN_USER && - - - - { !isEditingMotto && -
setIsEditingMotto(true) }>{ motto }
} - { isEditingMotto && - setMotto(event.target.value) } onBlur={ onMottoBlur } onKeyDown={ onMottoKeyDown } autoFocus={ true } /> } - -
} -
-
-
- { LocalizeText('infostand.text.achievement_score') + ' ' + userData.achievementScore } -
- { (userData.carryItem > 0) && - <> -
-
- { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + userData.carryItem) ]) } -
- - } - -
-
); -} diff --git a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts deleted file mode 100644 index df69165b..00000000 --- a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api'; - -export interface InfoStandWidgetUserViewProps -{ - userData: RoomWidgetUpdateInfostandUserEvent; - close: () => void; -}