From d29a502e3f0e9b168a492187deaf0f9ba9d65abe Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 17 Jun 2021 13:23:34 -0400 Subject: [PATCH] Widget updates --- src/api/nitro/session/FurnitureInfoData.ts | 31 - src/api/nitro/session/GetBotInfoData.ts | 30 - src/api/nitro/session/GetFurnitureInfoData.ts | 115 ---- src/api/nitro/session/GetObjectInfo.ts | 38 -- src/api/nitro/session/GetObjectName.ts | 61 -- .../nitro/session/GetRentableBotInfoData.ts | 31 - src/api/nitro/session/GetUserInfoData.ts | 188 ------ src/api/nitro/session/RentableBotInfoData.ts | 17 - src/api/nitro/session/RoomObjectNameData.ts | 9 - src/api/nitro/session/UserInfoData.ts | 40 -- src/api/nitro/session/index.ts | 10 - .../camera/RoomWidgetCameraEvent.ts | 9 +- src/hooks/events/core/configuration/index.ts | 1 + src/hooks/events/core/index.ts | 1 + src/hooks/events/index.ts | 4 + src/hooks/events/nitro/avatar/index.ts | 1 + src/hooks/events/nitro/camera/index.ts | 1 + src/hooks/events/nitro/communication/index.ts | 1 + src/hooks/events/nitro/index.ts | 7 + src/hooks/events/nitro/localization/index.ts | 1 + src/hooks/events/nitro/room/index.ts | 1 + src/hooks/events/nitro/session/index.ts | 2 + src/hooks/events/ui/index.ts | 1 + src/hooks/messages/index.ts | 1 + src/layout/card/NitroCardView.scss | 18 +- .../transitions/TransitionAnimation.tsx | 0 .../transitions/TransitionAnimation.types.ts | 0 .../transitions/TransitionAnimationStyles.ts | 0 src/views/main/MainView.tsx | 4 +- .../room-error-handler/RoomErrorHandler.tsx | 26 - src/views/room-host/RoomHostView.tsx | 150 +---- src/views/room/RoomView.tsx | 158 ++++- src/views/room/RoomView.types.ts | 3 +- src/views/room/context/RoomContext.tsx | 15 + src/views/room/context/RoomContext.types.ts | 15 + .../room/events/RoomWidgetObjectNameEvent.ts | 48 ++ .../events/RoomWidgetRoomEngineUpdateEvent.ts | 21 + .../events/RoomWidgetRoomObjectUpdateEvent.ts | 42 ++ .../room/events/RoomWidgetUpdateEvent.ts | 4 + .../events/RoomWidgetUpdateInfostandEvent.ts | 4 + .../RoomWidgetUpdateInfostandFurniEvent.ts | 33 + .../RoomWidgetUpdateInfostandPetEvent.ts | 5 + ...omWidgetUpdateInfostandRentableBotEvent.ts | 20 + .../RoomWidgetUpdateInfostandUserEvent.ts | 44 ++ src/views/room/events/index.ts | 9 + src/views/room/handlers/IRoomWidgetHandler.ts | 13 + .../handlers/IRoomWidgetHandlerManager.ts | 12 + src/views/room/handlers/RoomWidgetHandler.ts | 38 ++ .../room/handlers/RoomWidgetHandlerManager.ts | 114 ++++ .../handlers/RoomWidgetInfostandHandler.ts | 564 ++++++++++++++++++ src/views/room/handlers/index.ts | 5 + .../messages/RoomWidgetChangeMottoMessage.ts | 20 + .../messages/RoomWidgetFurniActionMessage.ts | 47 ++ src/views/room/messages/RoomWidgetMessage.ts | 14 + .../messages/RoomWidgetRoomObjectMessage.ts | 31 + .../messages/RoomWidgetUserActionMessage.ts | 65 ++ src/views/room/messages/index.ts | 5 + src/views/room/widgets/RoomWidgets.scss | 1 + src/views/room/widgets/RoomWidgets.types.ts | 7 +- src/views/room/widgets/RoomWidgetsView.tsx | 112 ++++ .../avatar-info/AvatarInfoWidgetView.tsx | 157 +++-- .../views/name/AvatarInfoWidgetNameView.tsx | 7 +- .../name/AvatarInfoWidgetNameView.types.ts | 4 +- .../room/widgets/camera/CameraWidgetView.tsx | 2 + .../widgets/camera/CameraWidgetView.types.ts | 4 +- .../room/widgets/chat-input/ChatInputView.tsx | 2 + .../widgets/chat-input/ChatInputView.types.ts | 4 +- .../room/widgets/chat/ChatWidgetView.tsx | 3 +- .../room/widgets/chat/ChatWidgetView.types.ts | 4 +- .../furniture/FurnitureWidgetsView.tsx | 23 +- .../furniture/dimmer/FurnitureDimmerView.tsx | 87 ++- .../FurnitureEngravingLockView.tsx | 21 +- .../FurnitureExchangeCreditView.tsx | 6 +- .../high-score/FurnitureHighScoreView.tsx | 3 + .../FurnitureManipulationMenuView.tsx | 10 +- .../mannequin/FurnitureMannequinView.tsx | 7 +- .../present/FurniturePresentView.tsx | 3 + .../stickie/FurnitureStickieView.tsx | 6 +- .../furniture/trophy/FurnitureTrophyView.tsx | 6 +- .../infostand/InfoStandWidgetView.scss | 5 +- .../widgets/infostand/InfoStandWidgetView.tsx | 159 ++--- .../views/bot/InfoStandWidgetBotView.tsx | 2 +- .../views/bot/InfoStandWidgetBotView.types.ts | 4 +- .../views/furni/InfoStandWidgetFurniView.tsx | 75 +-- .../furni/InfoStandWidgetFurniView.types.ts | 4 +- .../InfoStandWidgetRentableBotView.tsx | 2 +- .../InfoStandWidgetRentableBotView.types.ts | 4 +- .../views/user/InfoStandWidgetUserView.tsx | 2 +- .../user/InfoStandWidgetUserView.types.ts | 4 +- .../object-location/ObjectLocationView.scss | 2 + .../object-location/ObjectLocationView.tsx | 19 +- src/views/toolbar/ToolbarView.tsx | 7 +- 92 files changed, 1864 insertions(+), 1052 deletions(-) delete mode 100644 src/api/nitro/session/FurnitureInfoData.ts delete mode 100644 src/api/nitro/session/GetBotInfoData.ts delete mode 100644 src/api/nitro/session/GetFurnitureInfoData.ts delete mode 100644 src/api/nitro/session/GetObjectInfo.ts delete mode 100644 src/api/nitro/session/GetObjectName.ts delete mode 100644 src/api/nitro/session/GetRentableBotInfoData.ts delete mode 100644 src/api/nitro/session/GetUserInfoData.ts delete mode 100644 src/api/nitro/session/RentableBotInfoData.ts delete mode 100644 src/api/nitro/session/RoomObjectNameData.ts delete mode 100644 src/api/nitro/session/UserInfoData.ts create mode 100644 src/hooks/events/core/configuration/index.ts create mode 100644 src/hooks/events/core/index.ts create mode 100644 src/hooks/events/index.ts create mode 100644 src/hooks/events/nitro/avatar/index.ts create mode 100644 src/hooks/events/nitro/camera/index.ts create mode 100644 src/hooks/events/nitro/communication/index.ts create mode 100644 src/hooks/events/nitro/index.ts create mode 100644 src/hooks/events/nitro/localization/index.ts create mode 100644 src/hooks/events/nitro/room/index.ts create mode 100644 src/hooks/events/nitro/session/index.ts create mode 100644 src/hooks/events/ui/index.ts create mode 100644 src/hooks/messages/index.ts rename src/{ => layout}/transitions/TransitionAnimation.tsx (100%) rename src/{ => layout}/transitions/TransitionAnimation.types.ts (100%) rename src/{ => layout}/transitions/TransitionAnimationStyles.ts (100%) delete mode 100644 src/views/room-error-handler/RoomErrorHandler.tsx create mode 100644 src/views/room/context/RoomContext.tsx create mode 100644 src/views/room/context/RoomContext.types.ts create mode 100644 src/views/room/events/RoomWidgetObjectNameEvent.ts create mode 100644 src/views/room/events/RoomWidgetRoomEngineUpdateEvent.ts create mode 100644 src/views/room/events/RoomWidgetRoomObjectUpdateEvent.ts create mode 100644 src/views/room/events/RoomWidgetUpdateEvent.ts create mode 100644 src/views/room/events/RoomWidgetUpdateInfostandEvent.ts create mode 100644 src/views/room/events/RoomWidgetUpdateInfostandFurniEvent.ts create mode 100644 src/views/room/events/RoomWidgetUpdateInfostandPetEvent.ts create mode 100644 src/views/room/events/RoomWidgetUpdateInfostandRentableBotEvent.ts create mode 100644 src/views/room/events/RoomWidgetUpdateInfostandUserEvent.ts create mode 100644 src/views/room/events/index.ts create mode 100644 src/views/room/handlers/IRoomWidgetHandler.ts create mode 100644 src/views/room/handlers/IRoomWidgetHandlerManager.ts create mode 100644 src/views/room/handlers/RoomWidgetHandler.ts create mode 100644 src/views/room/handlers/RoomWidgetHandlerManager.ts create mode 100644 src/views/room/handlers/RoomWidgetInfostandHandler.ts create mode 100644 src/views/room/handlers/index.ts create mode 100644 src/views/room/messages/RoomWidgetChangeMottoMessage.ts create mode 100644 src/views/room/messages/RoomWidgetFurniActionMessage.ts create mode 100644 src/views/room/messages/RoomWidgetMessage.ts create mode 100644 src/views/room/messages/RoomWidgetRoomObjectMessage.ts create mode 100644 src/views/room/messages/RoomWidgetUserActionMessage.ts create mode 100644 src/views/room/messages/index.ts create mode 100644 src/views/room/widgets/RoomWidgetsView.tsx create mode 100644 src/views/room/widgets/object-location/ObjectLocationView.scss diff --git a/src/api/nitro/session/FurnitureInfoData.ts b/src/api/nitro/session/FurnitureInfoData.ts deleted file mode 100644 index 7b1e033b..00000000 --- a/src/api/nitro/session/FurnitureInfoData.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IObjectData } from 'nitro-renderer'; - -export class FurnitureInfoData -{ - constructor( - public id: number = 0, - public category: number = 0, - public name: string = '', - public description: string = '', - public image: HTMLImageElement = null, - public isWallItem: boolean = false, - public isStickie: boolean = false, - public isRoomOwner: boolean = false, - public roomControllerLevel: number = 0, - public isAnyRoomController: boolean = false, - public expiration: number = -1, - public purchaseCatalogPageId: number = -1, - public purchaseOfferId: number = -1, - public extraParam: string = '', - public isOwner: boolean = false, - public stuffData: IObjectData = null, - public groupId: number = 0, - public ownerId: number = 0, - public ownerName: string = '', - public usagePolicy: number = 0, - public rentCatalogPageId: number = -1, - public rentOfferId: number = -1, - public purchaseCouldBeUsedForBuyout: boolean = false, - public rentCouldBeUsedForBuyout: boolean = false, - public availableForBuildersClub: boolean = false) {} -} diff --git a/src/api/nitro/session/GetBotInfoData.ts b/src/api/nitro/session/GetBotInfoData.ts deleted file mode 100644 index 48693973..00000000 --- a/src/api/nitro/session/GetBotInfoData.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { RoomObjectVariable, RoomUserData } from 'nitro-renderer'; -import { GetRoomEngine } from '../room'; -import { GetRoomSession } from './GetRoomSession'; -import { GetSessionDataManager } from './GetSessionDataManager'; -import { UserInfoData } from './UserInfoData'; - -export function GetBotInfoData(roomId: number, objectId: number, category: number, userData: RoomUserData): UserInfoData -{ - const userInfoData = new UserInfoData(UserInfoData.BOT); - - userInfoData.name = userData.name; - userInfoData.motto = userData.custom; - userInfoData.webID = userData.webID; - userInfoData.userRoomId = objectId; - userInfoData.userType = userData.type; - - const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, category); - - if(roomObject) userInfoData.carryItem = roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT); - - userInfoData.amIOwner = GetRoomSession().isRoomOwner; - userInfoData.isGuildRoom = GetRoomSession().isGuildRoom; - userInfoData.roomControllerLevel = GetRoomSession().controllerLevel; - userInfoData.amIAnyRoomController = GetSessionDataManager().isModerator; - userInfoData.isAmbassador = GetSessionDataManager().isAmbassador; - userInfoData.badges = [ 'BOT' ]; - userInfoData.figure = userData.figure; - - return userInfoData; -} diff --git a/src/api/nitro/session/GetFurnitureInfoData.ts b/src/api/nitro/session/GetFurnitureInfoData.ts deleted file mode 100644 index 8ac717e9..00000000 --- a/src/api/nitro/session/GetFurnitureInfoData.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { IFurnitureData, Nitro, ObjectDataFactory, RoomObjectCategory, RoomObjectVariable, RoomWidgetEnumItemExtradataParameter, Vector3d } from 'nitro-renderer'; -import { GetRoomEngine } from '../room'; -import { FurnitureInfoData } from './FurnitureInfoData'; -import { GetRoomSession } from './GetRoomSession'; -import { GetSessionDataManager } from './GetSessionDataManager'; -import { IsOwnerOfFurniture } from './IsOwnerOfFurniture'; - -export function GetFurnitureInfoData(roomId: number, objectId: number, category: number): FurnitureInfoData -{ - const furnitureInfoData = new FurnitureInfoData(); - - furnitureInfoData.id = objectId; - furnitureInfoData.category = category; - - const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, category); - - if(!roomObject) return null; - - const model = roomObject.model; - - if(model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM)) - { - furnitureInfoData.extraParam = model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM); - } - - const dataFormat = model.getValue(RoomObjectVariable.FURNITURE_DATA_FORMAT); - const objectData = ObjectDataFactory.getData(dataFormat); - - objectData.initializeFromRoomObjectModel(model); - - furnitureInfoData.stuffData = objectData; - - const objectType = roomObject.type; - - if(objectType.indexOf('poster') === 0) - { - const posterId = parseInt(objectType.replace('poster', '')); - - furnitureInfoData.name = (('${poster_' + posterId) + '_name}'); - furnitureInfoData.description = (('${poster_' + posterId) + '_desc}'); - } - else - { - const typeId = model.getValue(RoomObjectVariable.FURNITURE_TYPE_ID); - - let furnitureData: IFurnitureData = null; - - if(category === RoomObjectCategory.FLOOR) - { - furnitureData = GetSessionDataManager().getFloorItemData(typeId); - } - - else if(category === RoomObjectCategory.WALL) - { - furnitureData = GetSessionDataManager().getWallItemData(typeId); - } - - if(furnitureData) - { - furnitureInfoData.name = furnitureData.name; - furnitureInfoData.description = furnitureData.description; - furnitureInfoData.purchaseOfferId = furnitureData.purchaseOfferId; - furnitureInfoData.purchaseCouldBeUsedForBuyout = furnitureData.purchaseCouldBeUsedForBuyout; - furnitureInfoData.rentOfferId = furnitureData.rentOfferId; - furnitureInfoData.rentCouldBeUsedForBuyout = furnitureData.rentCouldBeUsedForBuyout; - furnitureInfoData.availableForBuildersClub = furnitureData.availableForBuildersClub; - - // if(this._container.wiredService && (k.category === RoomObjectCategory.FLOOR)) - // { - // this._container.wiredService.selectFurniture(roomObject.id, furnitureData.name); - // } - } - } - - if(objectType.indexOf('post_it') > -1) furnitureInfoData.isStickie = true; - - const expiryTime = model.getValue(RoomObjectVariable.FURNITURE_EXPIRY_TIME); - const expiryTimestamp = model.getValue(RoomObjectVariable.FURNITURE_EXPIRTY_TIMESTAMP); - - furnitureInfoData.expiration = ((expiryTime < 0) ? expiryTime : Math.max(0, (expiryTime - ((Nitro.instance.time - expiryTimestamp) / 1000)))); - - let roomObjectImage = GetRoomEngine().getRoomObjectImage(roomId, objectId, category, new Vector3d(180), 64, null); - - if(!roomObjectImage.data || (roomObjectImage.data.width > 140) || (roomObjectImage.data.height > 200)) - { - roomObjectImage = GetRoomEngine().getRoomObjectImage(roomId, objectId, category, new Vector3d(180), 1, null); - } - - if(roomObjectImage && roomObjectImage.data) - { - const image = Nitro.instance.renderer.extract.image(roomObjectImage.data); - - if(image) furnitureInfoData.image = image; - } - - furnitureInfoData.isWallItem = (category === RoomObjectCategory.WALL); - furnitureInfoData.isRoomOwner = GetRoomSession().isRoomOwner; - furnitureInfoData.roomControllerLevel = GetRoomSession().controllerLevel; - furnitureInfoData.isAnyRoomController = GetSessionDataManager().isModerator; - furnitureInfoData.ownerId = model.getValue(RoomObjectVariable.FURNITURE_OWNER_ID); - furnitureInfoData.ownerName = model.getValue(RoomObjectVariable.FURNITURE_OWNER_NAME); - furnitureInfoData.usagePolicy = model.getValue(RoomObjectVariable.FURNITURE_USAGE_POLICY); - - const guildId = model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID); - - if(guildId !== 0) - { - furnitureInfoData.groupId = guildId; - //this.container.connection.send(new _Str_2863(guildId, false)); - } - - if(IsOwnerOfFurniture(roomObject)) furnitureInfoData.isOwner = true; - - return furnitureInfoData; -} diff --git a/src/api/nitro/session/GetObjectInfo.ts b/src/api/nitro/session/GetObjectInfo.ts deleted file mode 100644 index 46b09706..00000000 --- a/src/api/nitro/session/GetObjectInfo.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { RoomObjectCategory, RoomObjectType } from 'nitro-renderer'; -import { FurnitureInfoData } from './FurnitureInfoData'; -import { GetBotInfoData } from './GetBotInfoData'; -import { GetFurnitureInfoData } from './GetFurnitureInfoData'; -import { GetRentableBotInfoData } from './GetRentableBotInfoData'; -import { GetRoomSession } from './GetRoomSession'; -import { GetUserInfoData } from './GetUserInfoData'; -import { RentableBotInfoData } from './RentableBotInfoData'; -import { UserInfoData } from './UserInfoData'; - -export function GetObjectInfo(roomId: number, objectId: number, category: number): FurnitureInfoData | UserInfoData | RentableBotInfoData -{ - switch(category) - { - case RoomObjectCategory.FLOOR: - case RoomObjectCategory.WALL: - return GetFurnitureInfoData(roomId, objectId, category); - case RoomObjectCategory.UNIT: - const userData = GetRoomSession().userDataManager.getUserDataByIndex(objectId); - - if(!userData) return null; - - switch(userData.type) - { - case RoomObjectType.PET: - GetRoomSession().userDataManager.requestPetInfo(userData.webID); - return null; - case RoomObjectType.USER: - return GetUserInfoData(roomId, objectId, category, userData); - case RoomObjectType.BOT: - return GetBotInfoData(roomId, objectId, category, userData); - case RoomObjectType.RENTABLE_BOT: - return GetRentableBotInfoData(roomId, objectId, category, userData); - } - } - - return null; -} diff --git a/src/api/nitro/session/GetObjectName.ts b/src/api/nitro/session/GetObjectName.ts deleted file mode 100644 index dc47cc02..00000000 --- a/src/api/nitro/session/GetObjectName.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { IFurnitureData, RoomObjectCategory, RoomObjectVariable } from 'nitro-renderer'; -import { GetRoomEngine } from '../room'; -import { GetRoomSession } from './GetRoomSession'; -import { GetSessionDataManager } from './GetSessionDataManager'; -import { RoomObjectNameData } from './RoomObjectNameData'; - -export function GetObjectName(roomId: number, objectId: number, category: number): RoomObjectNameData -{ - let id = -1; - let name: string = null; - let type = 0; - - switch(category) - { - case RoomObjectCategory.FLOOR: - case RoomObjectCategory.WALL: - const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, category); - - if(!roomObject) return; - - if(roomObject.type.indexOf('poster') === 0) - { - name = ('${poster_' + parseInt(roomObject.type.replace('poster', '')) + '_name}'); - } - else - { - let furniData: IFurnitureData = null; - - const typeId = roomObject.model.getValue(RoomObjectVariable.FURNITURE_TYPE_ID); - - if(category === RoomObjectCategory.FLOOR) - { - furniData = GetSessionDataManager().getFloorItemData(typeId); - } - - else if(category === RoomObjectCategory.WALL) - { - furniData = GetSessionDataManager().getWallItemData(typeId); - } - - if(!furniData) return; - - id = furniData.id; - name = furniData.name; - } - break; - case RoomObjectCategory.UNIT: - const userData = GetRoomSession().userDataManager.getUserDataByIndex(objectId); - - if(!userData) return; - - id = userData.webID; - name = userData.name; - type = userData.type; - break; - } - - if(!name) return null; - - return new RoomObjectNameData(objectId, category, id, name, type); -} diff --git a/src/api/nitro/session/GetRentableBotInfoData.ts b/src/api/nitro/session/GetRentableBotInfoData.ts deleted file mode 100644 index f7fb3a12..00000000 --- a/src/api/nitro/session/GetRentableBotInfoData.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { RoomObjectVariable, RoomUserData } from 'nitro-renderer'; -import { GetRoomEngine } from '../room'; -import { GetRoomSession } from './GetRoomSession'; -import { GetSessionDataManager } from './GetSessionDataManager'; -import { RentableBotInfoData } from './RentableBotInfoData'; -import { UserInfoData } from './UserInfoData'; - -export function GetRentableBotInfoData(roomId: number, objectId: number, category: number, userData: RoomUserData): RentableBotInfoData -{ - const rentBotInfoData = new RentableBotInfoData(UserInfoData.BOT); - - rentBotInfoData.name = userData.name; - rentBotInfoData.motto = userData.custom; - rentBotInfoData.webID = userData.webID; - rentBotInfoData.userRoomId = objectId; - rentBotInfoData.ownerId = userData.ownerId; - rentBotInfoData.ownerName = userData.ownerName; - rentBotInfoData.botSkills = userData.botSkills; - - const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, category); - - if(roomObject) rentBotInfoData.carryItem = roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT); - - rentBotInfoData.amIOwner = GetRoomSession().isRoomOwner; - rentBotInfoData.roomControllerLevel = GetRoomSession().controllerLevel; - rentBotInfoData.amIAnyRoomController = GetSessionDataManager().isModerator; - rentBotInfoData.badges = [ 'BOT' ]; - rentBotInfoData.figure = userData.figure; - - return rentBotInfoData; -} diff --git a/src/api/nitro/session/GetUserInfoData.ts b/src/api/nitro/session/GetUserInfoData.ts deleted file mode 100644 index 85b32c85..00000000 --- a/src/api/nitro/session/GetUserInfoData.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { RoomControllerLevel, RoomModerationParser, RoomObjectType, RoomObjectVariable, RoomTradingLevelEnum, RoomUserData } from 'nitro-renderer'; -import { GetRoomEngine } from '../room'; -import { GetRoomSession } from './GetRoomSession'; -import { GetSessionDataManager } from './GetSessionDataManager'; -import { UserInfoData } from './UserInfoData'; - -export const _Str_18400: number = 0; -export const _Str_14161: number = 2; -export const _Str_13798: number = 3; - -export function GetUserInfoData(roomId: number, objectId: number, category: number, userData: RoomUserData): UserInfoData -{ - let userDataType = UserInfoData.OWN_USER; - - if(userData.webID !== GetSessionDataManager().userId) userDataType = UserInfoData.PEER; - - const userInfoData = new UserInfoData(userDataType); - - userInfoData.isSpectatorMode = GetRoomSession().isSpectator; - userInfoData.name = userData.name; - userInfoData.motto = userData.custom; - userInfoData.achievementScore = userData.activityPoints; - userInfoData.webID = userData.webID; - userInfoData.userRoomId = objectId; - userInfoData.userType = RoomObjectType.USER; - - const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, category); - - if(roomObject) userInfoData.carryItem = roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT); - - if(userDataType === UserInfoData.OWN_USER) - { - userInfoData.realName = GetSessionDataManager().realName; - userInfoData.allowNameChange = GetSessionDataManager().canChangeName; - } - - userInfoData.amIOwner = GetRoomSession().isRoomOwner; - userInfoData.isGuildRoom = GetRoomSession().isGuildRoom; - userInfoData.roomControllerLevel = GetRoomSession().controllerLevel; - userInfoData.amIAnyRoomController = GetSessionDataManager().isModerator; - userInfoData.isAmbassador = GetSessionDataManager().isAmbassador; - - if(userDataType === UserInfoData.PEER) - { - // userInfoData.canBeAskedAsFriend = this._container.friendService.canBeAskedForAFriend(userData.webID); - - // const friend = this._container.friendService.getFriend(userData.webID); - - // if(friend) - // { - // userInfoData.realName = friend.realName; - // userInfoData.isFriend = true; - // } - - if(roomObject) - { - const flatControl = roomObject.model.getValue(RoomObjectVariable.FIGURE_FLAT_CONTROL); - - if(flatControl !== null) userInfoData.targetRoomControllerLevel = flatControl; - - userInfoData.canBeMuted = canBeMuted(userInfoData); - userInfoData.canBeKicked = canBeKicked(userInfoData); - userInfoData.canBeBanned = canBeBanned(userInfoData); - } - - userInfoData.isIgnored = GetSessionDataManager().isUserIgnored(userData.name); - userInfoData.respectLeft = GetSessionDataManager().respectsLeft; - - const isShuttingDown = GetSessionDataManager().isSystemShutdown; - const tradeMode = GetRoomSession().tradeMode; - - if(isShuttingDown) - { - userInfoData.canTrade = false; - } - else - { - switch(tradeMode) - { - case RoomTradingLevelEnum._Str_14475: { - const roomController = ((userInfoData.roomControllerLevel !== RoomControllerLevel.NONE) && (userInfoData.roomControllerLevel !== RoomControllerLevel.GUILD_MEMBER)); - const targetController = ((userInfoData.targetRoomControllerLevel !== RoomControllerLevel.NONE) && (userInfoData.targetRoomControllerLevel !== RoomControllerLevel.GUILD_MEMBER)); - - userInfoData.canTrade = (roomController || targetController); - break; - } - case RoomTradingLevelEnum._Str_9173: - userInfoData.canTrade = true; - break; - default: - userInfoData.canTrade = false; - break; - } - } - - userInfoData.canTradeReason = _Str_18400; - - if(isShuttingDown) userInfoData.canTradeReason = _Str_14161; - - if(tradeMode !== RoomTradingLevelEnum._Str_9173) userInfoData.canTradeReason = _Str_13798; - - // const _local_12 = GetSessionDataManager().userId; - // _local_13 = GetSessionDataManager()._Str_18437(_local_12); - // this._Str_16287(_local_12, _local_13); - } - - userInfoData.groupId = parseInt(userData.guildId); - //event._Str_5235 = GetSessionDataManager()._Str_17173(int(userData._Str_4592)); - userInfoData.groupName = userData.groupName; - userInfoData.badges = GetRoomSession().userDataManager.getUserBadges(userData.webID); - userInfoData.figure = userData.figure; - //var _local_8:Array = GetSessionDataManager()._Str_18437(userData.webID); - //this._Str_16287(userData._Str_2394, _local_8); - //this._container._Str_8097._Str_14387(userData.webID); - //this._container.connection.send(new _Str_8049(userData._Str_2394)); - - return userInfoData; -} - -function checkGuildSetting(userInfoData: UserInfoData): boolean -{ - if(userInfoData.isGuildRoom) return (userInfoData.roomControllerLevel >= RoomControllerLevel.GUILD_ADMIN); - - return (userInfoData.roomControllerLevel >= RoomControllerLevel.GUEST); -} - -function canBeMuted(userInfoData: UserInfoData): boolean -{ - const checkSetting = function(userInfoData: UserInfoData, moderation: RoomModerationParser) - { - switch(moderation.allowMute) - { - case RoomModerationParser._Str_5047: - return checkGuildSetting(userInfoData); - default: - return (userInfoData.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER); - } - } - - return isValidSetting(userInfoData, checkSetting); -} - -function canBeKicked(userInfoData: UserInfoData): boolean -{ - const checkSetting = function(userInfoData: UserInfoData, moderation: RoomModerationParser) - { - switch(moderation.allowKick) - { - case RoomModerationParser._Str_11537: - return true; - case RoomModerationParser._Str_5047: - return checkGuildSetting(userInfoData); - default: - return (userInfoData.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER); - } - } - - return isValidSetting(userInfoData, checkSetting); -} - -function canBeBanned(userInfoData: UserInfoData): boolean -{ - const checkSetting = function(userInfoData: UserInfoData, moderation: RoomModerationParser) - { - switch(moderation.allowBan) - { - case RoomModerationParser._Str_5047: - return checkGuildSetting(userInfoData); - default: - return (userInfoData.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER); - } - } - - return isValidSetting(userInfoData, checkSetting); -} - -function isValidSetting(userInfoData: UserInfoData, checkSetting: (userInfoData: UserInfoData, moderation: RoomModerationParser) => boolean): boolean -{ - if(!GetRoomSession()._Str_7411) return false; - - const moderation = GetRoomSession().moderationSettings; - - let flag = false; - - if(moderation) flag = checkSetting(userInfoData, moderation); - - return (flag && (userInfoData.roomControllerLevel < RoomControllerLevel.ROOM_OWNER)); -} diff --git a/src/api/nitro/session/RentableBotInfoData.ts b/src/api/nitro/session/RentableBotInfoData.ts deleted file mode 100644 index 8d34d605..00000000 --- a/src/api/nitro/session/RentableBotInfoData.ts +++ /dev/null @@ -1,17 +0,0 @@ -export class RentableBotInfoData -{ - constructor( - public name: string = '', - public motto: string = '', - public webID: number = 0, - public figure: string = '', - public badges: string[] = [], - public carryItem: number = 0, - public userRoomId: number = 0, - public amIOwner: boolean = false, - public amIAnyRoomController: boolean = false, - public roomControllerLevel: number = 0, - public ownerId: number = -1, - public ownerName: string = '', - public botSkills: number[] = []) {} -} diff --git a/src/api/nitro/session/RoomObjectNameData.ts b/src/api/nitro/session/RoomObjectNameData.ts deleted file mode 100644 index ae8e352c..00000000 --- a/src/api/nitro/session/RoomObjectNameData.ts +++ /dev/null @@ -1,9 +0,0 @@ -export class RoomObjectNameData -{ - constructor( - public objectId: number, - public category: number, - public id: number, - public name: string, - public type: number) {} -} diff --git a/src/api/nitro/session/UserInfoData.ts b/src/api/nitro/session/UserInfoData.ts deleted file mode 100644 index 5b84a1ce..00000000 --- a/src/api/nitro/session/UserInfoData.ts +++ /dev/null @@ -1,40 +0,0 @@ -export class UserInfoData -{ - public static OWN_USER: string = 'UID_OWN_USER'; - public static PEER: string = 'UID_PEER'; - public static BOT: string = 'UID_BOT'; - - constructor( - public type: string, - public name: string = '', - public motto: string = '', - public achievementScore: number = 0, - public webID: number = 0, - public xp: number = 0, - public userType: number = -1, - public figure: string = '', - public badges: string[] = [], - public groupId: number = 0, - public groupName: string = '', - public groupBadgeId: string = '', - public carryItem: number = 0, - public userRoomId: number = 0, - public isSpectatorMode: boolean = false, - public realName: string = '', - public allowNameChange: boolean = false, - public amIOwner: boolean = false, - public amIAnyRoomController: boolean = false, - public roomControllerLevel: number = 0, - public canBeAskedAsFriend: boolean = false, - public canBeKicked: boolean = false, - public canBeBanned: boolean = false, - public canBeMuted: boolean = false, - public respectLeft: number = 0, - public isIgnored: boolean = false, - public isGuildRoom: boolean = false, - public canTrade: boolean = false, - public canTradeReason: number = 0, - public targetRoomControllerLevel: number = 0, - public isFriend: boolean = false, - public isAmbassador: boolean = false) {} -} diff --git a/src/api/nitro/session/index.ts b/src/api/nitro/session/index.ts index 5340d167..cb94de8b 100644 --- a/src/api/nitro/session/index.ts +++ b/src/api/nitro/session/index.ts @@ -1,21 +1,11 @@ export * from './CanManipulateFurniture'; -export * from './FurnitureInfoData'; -export * from './GetBotInfoData'; export * from './GetFurnitureDataForProductOffer'; -export * from './GetFurnitureInfoData'; -export * from './GetObjectInfo'; -export * from './GetObjectName'; export * from './GetProductDataForLocalization'; -export * from './GetRentableBotInfoData'; export * from './GetRoomSession'; export * from './GetRoomSessionManager'; export * from './GetSessionDataManager'; -export * from './GetUserInfoData'; export * from './IsOwnerOfFurniture'; export * from './ProcessFurniAction'; export * from './ProcessUserAction'; -export * from './RentableBotInfoData'; -export * from './RoomObjectNameData'; export * from './SendChatTypingMessage'; export * from './StartRoomSession'; -export * from './UserInfoData'; diff --git a/src/events/room-widgets/camera/RoomWidgetCameraEvent.ts b/src/events/room-widgets/camera/RoomWidgetCameraEvent.ts index 0eb6b4f0..6fdbbd0a 100644 --- a/src/events/room-widgets/camera/RoomWidgetCameraEvent.ts +++ b/src/events/room-widgets/camera/RoomWidgetCameraEvent.ts @@ -1,13 +1,8 @@ -import { NitroEvent } from 'nitro-renderer'; +import { RoomWidgetUpdateEvent } from '../../../views/room/events/RoomWidgetUpdateEvent'; -export class RoomWidgetCameraEvent extends NitroEvent +export class RoomWidgetCameraEvent extends RoomWidgetUpdateEvent { public static SHOW_CAMERA: string = 'NE_SHOW_CAMERA'; public static HIDE_CAMERA: string = 'NE_HIDE_CAMERA'; public static TOGGLE_CAMERA: string = 'NE_TOGGLE_CAMERA'; - - constructor(type: string) - { - super(type); - } } diff --git a/src/hooks/events/core/configuration/index.ts b/src/hooks/events/core/configuration/index.ts new file mode 100644 index 00000000..30fa7b1b --- /dev/null +++ b/src/hooks/events/core/configuration/index.ts @@ -0,0 +1 @@ +export * from './configuration-event'; diff --git a/src/hooks/events/core/index.ts b/src/hooks/events/core/index.ts new file mode 100644 index 00000000..75a11149 --- /dev/null +++ b/src/hooks/events/core/index.ts @@ -0,0 +1 @@ +export * from './configuration'; diff --git a/src/hooks/events/index.ts b/src/hooks/events/index.ts new file mode 100644 index 00000000..03d926d1 --- /dev/null +++ b/src/hooks/events/index.ts @@ -0,0 +1,4 @@ +export * from './core'; +export * from './event-dispatcher.base'; +export * from './nitro'; +export * from './ui'; diff --git a/src/hooks/events/nitro/avatar/index.ts b/src/hooks/events/nitro/avatar/index.ts new file mode 100644 index 00000000..57f80c88 --- /dev/null +++ b/src/hooks/events/nitro/avatar/index.ts @@ -0,0 +1 @@ +export * from './avatar-event'; diff --git a/src/hooks/events/nitro/camera/index.ts b/src/hooks/events/nitro/camera/index.ts new file mode 100644 index 00000000..76bf31e0 --- /dev/null +++ b/src/hooks/events/nitro/camera/index.ts @@ -0,0 +1 @@ +export * from './camera-event'; diff --git a/src/hooks/events/nitro/communication/index.ts b/src/hooks/events/nitro/communication/index.ts new file mode 100644 index 00000000..e4f0035e --- /dev/null +++ b/src/hooks/events/nitro/communication/index.ts @@ -0,0 +1 @@ +export * from './communication-event'; diff --git a/src/hooks/events/nitro/index.ts b/src/hooks/events/nitro/index.ts new file mode 100644 index 00000000..8bf15d27 --- /dev/null +++ b/src/hooks/events/nitro/index.ts @@ -0,0 +1,7 @@ +export * from './avatar'; +export * from './camera'; +export * from './communication'; +export * from './localization'; +export * from './main-event'; +export * from './room'; +export * from './session'; diff --git a/src/hooks/events/nitro/localization/index.ts b/src/hooks/events/nitro/localization/index.ts new file mode 100644 index 00000000..246da118 --- /dev/null +++ b/src/hooks/events/nitro/localization/index.ts @@ -0,0 +1 @@ +export * from './localization-event'; diff --git a/src/hooks/events/nitro/room/index.ts b/src/hooks/events/nitro/room/index.ts new file mode 100644 index 00000000..126d5c40 --- /dev/null +++ b/src/hooks/events/nitro/room/index.ts @@ -0,0 +1 @@ +export * from './room-engine-event'; diff --git a/src/hooks/events/nitro/session/index.ts b/src/hooks/events/nitro/session/index.ts new file mode 100644 index 00000000..9c12e690 --- /dev/null +++ b/src/hooks/events/nitro/session/index.ts @@ -0,0 +1,2 @@ +export * from './room-session-manager-event'; +export * from './session-data-manager-event'; diff --git a/src/hooks/events/ui/index.ts b/src/hooks/events/ui/index.ts new file mode 100644 index 00000000..4c0daa08 --- /dev/null +++ b/src/hooks/events/ui/index.ts @@ -0,0 +1 @@ +export * from './ui-event'; diff --git a/src/hooks/messages/index.ts b/src/hooks/messages/index.ts new file mode 100644 index 00000000..bd1eb301 --- /dev/null +++ b/src/hooks/messages/index.ts @@ -0,0 +1 @@ +export * from './message-event'; diff --git a/src/layout/card/NitroCardView.scss b/src/layout/card/NitroCardView.scss index 0aa465e5..a0f7cb28 100644 --- a/src/layout/card/NitroCardView.scss +++ b/src/layout/card/NitroCardView.scss @@ -2,6 +2,15 @@ $nitro-card-header-height: 33px; $nitro-card-tabs-height: 33px; $nitro-card-top-height: $nitro-card-header-height + $nitro-card-tabs-height; +.nitro-card { + pointer-events: all; + + @import './content/NitroCardContentView'; + @import './header/NitroCardHeaderView'; + @import './simple-header/NitroCardSimpleHeaderView'; + @import './tabs/NitroCardTabsView'; +} + .nitro-card-responsive { position: absolute; top: 0; @@ -10,15 +19,6 @@ $nitro-card-top-height: $nitro-card-header-height + $nitro-card-tabs-height; height: 100%; pointer-events: none; - .nitro-card { - pointer-events: all; - - @import './content/NitroCardContentView'; - @import './header/NitroCardHeaderView'; - @import './simple-header/NitroCardSimpleHeaderView'; - @import './tabs/NitroCardTabsView'; - } - @include media-breakpoint-down(lg) { .draggable-window { diff --git a/src/transitions/TransitionAnimation.tsx b/src/layout/transitions/TransitionAnimation.tsx similarity index 100% rename from src/transitions/TransitionAnimation.tsx rename to src/layout/transitions/TransitionAnimation.tsx diff --git a/src/transitions/TransitionAnimation.types.ts b/src/layout/transitions/TransitionAnimation.types.ts similarity index 100% rename from src/transitions/TransitionAnimation.types.ts rename to src/layout/transitions/TransitionAnimation.types.ts diff --git a/src/transitions/TransitionAnimationStyles.ts b/src/layout/transitions/TransitionAnimationStyles.ts similarity index 100% rename from src/transitions/TransitionAnimationStyles.ts rename to src/layout/transitions/TransitionAnimationStyles.ts diff --git a/src/views/main/MainView.tsx b/src/views/main/MainView.tsx index a9e603cb..ecf77d91 100644 --- a/src/views/main/MainView.tsx +++ b/src/views/main/MainView.tsx @@ -1,8 +1,8 @@ import { Nitro, RoomSessionEvent } from 'nitro-renderer'; import { useCallback, useEffect, useState } from 'react'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; -import { TransitionAnimation } from '../../transitions/TransitionAnimation'; -import { TransitionAnimationTypes } from '../../transitions/TransitionAnimation.types'; +import { TransitionAnimation } from '../../layout/transitions/TransitionAnimation'; +import { TransitionAnimationTypes } from '../../layout/transitions/TransitionAnimation.types'; import { AvatarEditorView } from '../avatar-editor/AvatarEditorView'; import { CatalogView } from '../catalog/CatalogView'; import { FriendListView } from '../friend-list/FriendListView'; diff --git a/src/views/room-error-handler/RoomErrorHandler.tsx b/src/views/room-error-handler/RoomErrorHandler.tsx deleted file mode 100644 index 9665f054..00000000 --- a/src/views/room-error-handler/RoomErrorHandler.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { RoomSessionErrorMessageEvent } from 'nitro-renderer'; -import { useCallback } from 'react'; -import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; - -export function RoomErrorHandler(): JSX.Element -{ - const onRoomSessionErrorMessageEvent = useCallback((event: RoomSessionErrorMessageEvent) => - { - console.log(event); - }, []); - - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_KICKED, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_PETS, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED, onRoomSessionErrorMessageEvent); - - return null; -} diff --git a/src/views/room-host/RoomHostView.tsx b/src/views/room-host/RoomHostView.tsx index e3066a29..96facf6c 100644 --- a/src/views/room-host/RoomHostView.tsx +++ b/src/views/room-host/RoomHostView.tsx @@ -1,22 +1,16 @@ -import { EventDispatcher, IEventDispatcher, IRoomSession, RoomBackgroundColorEvent, RoomEngineDimmerStateEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomId, RoomObjectCategory, RoomObjectHSLColorEnabledEvent, RoomObjectOperationType, RoomSessionEvent, RoomZoomEvent } from 'nitro-renderer'; +import { IRoomSession, RoomEngineEvent, RoomId, RoomSessionErrorMessageEvent, RoomSessionEvent } from 'nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { IsFurnitureSelectionDisabled } from '../../api/nitro/room/IsFurnitureSelectionDisabled'; -import { ProcessRoomObjectOperation } from '../../api/nitro/room/ProcessRoomObjectOperation'; import { SetActiveRoomId } from '../../api/nitro/room/SetActiveRoomId'; -import { CanManipulateFurniture } from '../../api/nitro/session/CanManipulateFurniture'; import { GetRoomSession } from '../../api/nitro/session/GetRoomSession'; import { StartRoomSession } from '../../api/nitro/session/StartRoomSession'; import { useRoomEngineEvent } from '../../hooks/events/nitro/room/room-engine-event'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; -import { RoomErrorHandler } from '../room-error-handler/RoomErrorHandler'; import { RoomView } from '../room/RoomView'; -import { RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectUpdateEvent } from '../room/widgets/events'; import { RoomHostViewProps } from './RoomHostView.types'; export const RoomHostView: FC = props => { const [ roomSession, setRoomSession ] = useState(null); - const [ eventDispatcher, setEventDispatcher ] = useState(null); const onRoomEngineEvent = useCallback((event: RoomEngineEvent) => { @@ -35,147 +29,49 @@ export const RoomHostView: FC = props => case RoomEngineEvent.DISPOSED: setRoomSession(null); return; - case RoomEngineEvent.NORMAL_MODE: - eventDispatcher.dispatchEvent(new RoomWidgetRoomEngineUpdateEvent(RoomWidgetRoomEngineUpdateEvent.RWREUE_NORMAL_MODE, event.roomId)); - return; - case RoomEngineEvent.GAME_MODE: - eventDispatcher.dispatchEvent(new RoomWidgetRoomEngineUpdateEvent(RoomWidgetRoomEngineUpdateEvent.RWREUE_GAME_MODE, event.roomId)); - return; } - }, [ eventDispatcher ]); + }, []); - const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) => - { - if(!roomSession || !eventDispatcher) return; - - const objectId = event.objectId; - const category = event.category; - - let updateEvent: RoomWidgetRoomObjectUpdateEvent = null; - - switch(event.type) - { - case RoomEngineObjectEvent.SELECTED: - if(!IsFurnitureSelectionDisabled(event)) updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, objectId, category, event.roomId); - break; - case RoomEngineObjectEvent.DESELECTED: - updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, objectId, category, event.roomId); - break; - case RoomEngineObjectEvent.ADDED: { - let addedEventType: string = null; - - switch(category) - { - case RoomObjectCategory.FLOOR: - case RoomObjectCategory.WALL: - addedEventType = RoomWidgetRoomObjectUpdateEvent.FURNI_ADDED; - break; - case RoomObjectCategory.UNIT: - addedEventType = RoomWidgetRoomObjectUpdateEvent.USER_ADDED; - break; - } - - if(addedEventType) updateEvent = new RoomWidgetRoomObjectUpdateEvent(addedEventType, objectId, category, event.roomId); - break; - } - case RoomEngineObjectEvent.REMOVED: { - let removedEventType: string = null; - - switch(category) - { - case RoomObjectCategory.FLOOR: - case RoomObjectCategory.WALL: - removedEventType = RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED; - break; - case RoomObjectCategory.UNIT: - removedEventType = RoomWidgetRoomObjectUpdateEvent.USER_REMOVED; - break; - } - - if(removedEventType) updateEvent = new RoomWidgetRoomObjectUpdateEvent(removedEventType, objectId, category, event.roomId); - break; - } - case RoomEngineObjectEvent.MOUSE_ENTER: - updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER, objectId, category, event.roomId); - break; - case RoomEngineObjectEvent.MOUSE_LEAVE: - updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT, objectId, category, event.roomId); - break; - case RoomEngineObjectEvent.REQUEST_MOVE: - if(CanManipulateFurniture(roomSession, objectId, category)) ProcessRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_MOVE); - break; - case RoomEngineObjectEvent.REQUEST_ROTATE: - if(CanManipulateFurniture(roomSession, objectId, category)) ProcessRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_ROTATE_POSITIVE); - break; - case RoomEngineObjectEvent.REQUEST_MANIPULATION: - if(CanManipulateFurniture(roomSession, objectId, category)) updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION, objectId, category, event.roomId); - break; - } - - if(updateEvent) - { - let dispatchEvent = true; - - if(updateEvent instanceof RoomWidgetRoomObjectUpdateEvent) dispatchEvent = (!RoomId.isRoomPreviewerId(updateEvent.roomId)); - - if(dispatchEvent) eventDispatcher.dispatchEvent(updateEvent); - } - }, [ roomSession, eventDispatcher ]); + useRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent); + useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { switch(event.type) { case RoomSessionEvent.CREATED: - setEventDispatcher(prevValue => - { - if(prevValue) prevValue.removeAllListeners(); - - return new EventDispatcher(); - }); StartRoomSession(event.session); return; case RoomSessionEvent.ENDED: setRoomSession(null); - setEventDispatcher(prevValue => - { - if(prevValue) prevValue.removeAllListeners(); - - return null; - }); return; } }, []); - useRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.OBJECTS_INITIALIZED, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.NORMAL_MODE, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.GAME_MODE, onRoomEngineEvent); - useRoomEngineEvent(RoomZoomEvent.ROOM_ZOOM, onRoomEngineEvent); - useRoomEngineEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, onRoomEngineEvent); - useRoomEngineEvent(RoomBackgroundColorEvent.ROOM_COLOR, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineDimmerStateEvent.ROOM_COLOR, onRoomEngineEvent); - - useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REMOVED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MOVE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_ROTATE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_ENTER, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_LEAVE, onRoomEngineObjectEvent); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + const onRoomSessionErrorMessageEvent = useCallback((event: RoomSessionErrorMessageEvent) => + { + console.log(event); + }, []); + + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_KICKED, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_PETS, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT, onRoomSessionErrorMessageEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED, onRoomSessionErrorMessageEvent); + return (
- - +
); } diff --git a/src/views/room/RoomView.tsx b/src/views/room/RoomView.tsx index 0d44f6e3..19500aff 100644 --- a/src/views/room/RoomView.tsx +++ b/src/views/room/RoomView.tsx @@ -1,34 +1,42 @@ -import { Nitro, RoomGeometry, RoomVariableEnum, Vector3d } from 'nitro-renderer'; -import { useEffect, useState } from 'react'; +import { EventDispatcher, Nitro, RoomEngineEvent, RoomEngineObjectEvent, RoomGeometry, RoomId, RoomObjectCategory, RoomObjectOperationType, RoomVariableEnum, Vector3d } from 'nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; import { createPortal } from 'react-dom'; +import { CanManipulateFurniture, IsFurnitureSelectionDisabled, ProcessRoomObjectOperation } from '../../api'; import { DispatchMouseEvent } from '../../api/nitro/room/DispatchMouseEvent'; import { WindowResizeEvent } from '../../api/nitro/room/DispatchResizeEvent'; import { DispatchTouchEvent } from '../../api/nitro/room/DispatchTouchEvent'; import { GetRoomEngine } from '../../api/nitro/room/GetRoomEngine'; +import { useRoomEngineEvent } from '../../hooks/events'; +import { RoomContextProvider } from './context/RoomContext'; +import { RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectUpdateEvent } from './events'; +import { IRoomWidgetHandlerManager, RoomWidgetHandlerManager, RoomWidgetInfostandHandler } from './handlers'; import { RoomViewProps } from './RoomView.types'; -import { AvatarInfoWidgetView } from './widgets/avatar-info/AvatarInfoWidgetView'; -import { CameraWidgetView } from './widgets/camera/CameraWidgetView'; -import { ChatInputView } from './widgets/chat-input/ChatInputView'; -import { ChatWidgetView } from './widgets/chat/ChatWidgetView'; -import { FurnitureWidgetsView } from './widgets/furniture/FurnitureWidgetsView'; -import { InfoStandWidgetView } from './widgets/infostand/InfoStandWidgetView'; +import { RoomWidgetsView } from './widgets/RoomWidgetsView'; -export function RoomView(props: RoomViewProps): JSX.Element +export const RoomView: FC = props => { - const { roomSession = null, events = null } = props; + const { roomSession = null } = props; const [ roomCanvas, setRoomCanvas ] = useState(null); + const [ widgetHandler, setWidgetHandler ] = useState(null); useEffect(() => { - if(!roomSession || !events) + if(!roomSession) { window.onresize = null; setRoomCanvas(null); + setWidgetHandler(null); return; } + const widgetHandlerManager = new RoomWidgetHandlerManager(roomSession, new EventDispatcher()); + + widgetHandlerManager.registerHandler(new RoomWidgetInfostandHandler()); + + setWidgetHandler(widgetHandlerManager); + Nitro.instance.renderer.resize(window.innerWidth, window.innerHeight); const canvasId = 1; @@ -82,24 +90,124 @@ export function RoomView(props: RoomViewProps): JSX.Element window.onresize = event => WindowResizeEvent(roomSession.roomId, canvasId); setRoomCanvas(canvas); + }, [ roomSession ]); - }, [ roomSession, events ]); + const onRoomEngineEvent = useCallback((event: RoomEngineEvent) => + { + if(!widgetHandler || RoomId.isRoomPreviewerId(event.roomId)) return; + + switch(event.type) + { + case RoomEngineEvent.NORMAL_MODE: + widgetHandler.eventDispatcher.dispatchEvent(new RoomWidgetRoomEngineUpdateEvent(RoomWidgetRoomEngineUpdateEvent.NORMAL_MODE, event.roomId)); + return; + case RoomEngineEvent.GAME_MODE: + widgetHandler.eventDispatcher.dispatchEvent(new RoomWidgetRoomEngineUpdateEvent(RoomWidgetRoomEngineUpdateEvent.GAME_MODE, event.roomId)); + return; + } + }, [ widgetHandler ]); + + useRoomEngineEvent(RoomEngineEvent.NORMAL_MODE, onRoomEngineEvent); + useRoomEngineEvent(RoomEngineEvent.GAME_MODE, onRoomEngineEvent); + + const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) => + { + if(!roomSession || !widgetHandler) return; + + const objectId = event.objectId; + const category = event.category; + + let updateEvent: RoomWidgetRoomObjectUpdateEvent = null; + + switch(event.type) + { + case RoomEngineObjectEvent.SELECTED: + if(!IsFurnitureSelectionDisabled(event)) updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, objectId, category, event.roomId); + break; + case RoomEngineObjectEvent.DESELECTED: + updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, objectId, category, event.roomId); + break; + case RoomEngineObjectEvent.ADDED: { + let addedEventType: string = null; + + switch(category) + { + case RoomObjectCategory.FLOOR: + case RoomObjectCategory.WALL: + addedEventType = RoomWidgetRoomObjectUpdateEvent.FURNI_ADDED; + break; + case RoomObjectCategory.UNIT: + addedEventType = RoomWidgetRoomObjectUpdateEvent.USER_ADDED; + break; + } + + if(addedEventType) updateEvent = new RoomWidgetRoomObjectUpdateEvent(addedEventType, objectId, category, event.roomId); + break; + } + case RoomEngineObjectEvent.REMOVED: { + let removedEventType: string = null; + + switch(category) + { + case RoomObjectCategory.FLOOR: + case RoomObjectCategory.WALL: + removedEventType = RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED; + break; + case RoomObjectCategory.UNIT: + removedEventType = RoomWidgetRoomObjectUpdateEvent.USER_REMOVED; + break; + } + + if(removedEventType) updateEvent = new RoomWidgetRoomObjectUpdateEvent(removedEventType, objectId, category, event.roomId); + break; + } + case RoomEngineObjectEvent.MOUSE_ENTER: + updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER, objectId, category, event.roomId); + break; + case RoomEngineObjectEvent.MOUSE_LEAVE: + updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT, objectId, category, event.roomId); + break; + case RoomEngineObjectEvent.REQUEST_MOVE: + if(CanManipulateFurniture(roomSession, objectId, category)) ProcessRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_MOVE); + break; + case RoomEngineObjectEvent.REQUEST_ROTATE: + if(CanManipulateFurniture(roomSession, objectId, category)) ProcessRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_ROTATE_POSITIVE); + break; + case RoomEngineObjectEvent.REQUEST_MANIPULATION: + if(CanManipulateFurniture(roomSession, objectId, category)) updateEvent = new RoomWidgetRoomObjectUpdateEvent(RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION, objectId, category, event.roomId); + break; + } + + if(updateEvent) + { + let dispatchEvent = true; + + if(updateEvent instanceof RoomWidgetRoomObjectUpdateEvent) dispatchEvent = (!RoomId.isRoomPreviewerId(updateEvent.roomId)); + + if(dispatchEvent) widgetHandler.eventDispatcher.dispatchEvent(updateEvent); + } + }, [ roomSession, widgetHandler ]); + + useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.REMOVED, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_ENTER, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_LEAVE, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MOVE, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_ROTATE, onRoomEngineObjectEvent); + useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, onRoomEngineObjectEvent); if(!roomSession) return null; return ( -
- { roomSession &&
} - { roomSession && events && roomCanvas && - createPortal(props.children, document.getElementById('room-view').appendChild(roomCanvas)) && - <> - - - - - - - } -
+ +
+
+ { roomCanvas && createPortal(null, document.getElementById('room-view').appendChild(roomCanvas)) } + { widgetHandler && } +
+
); } diff --git a/src/views/room/RoomView.types.ts b/src/views/room/RoomView.types.ts index 0935833b..c41da637 100644 --- a/src/views/room/RoomView.types.ts +++ b/src/views/room/RoomView.types.ts @@ -1,8 +1,7 @@ -import { IEventDispatcher, IRoomSession } from 'nitro-renderer'; +import { IRoomSession } from 'nitro-renderer'; import { IProps } from '../../utils/IProps'; export interface RoomViewProps extends IProps { - events: IEventDispatcher; roomSession: IRoomSession; } diff --git a/src/views/room/context/RoomContext.tsx b/src/views/room/context/RoomContext.tsx new file mode 100644 index 00000000..40e2417a --- /dev/null +++ b/src/views/room/context/RoomContext.tsx @@ -0,0 +1,15 @@ +import { createContext, FC, useContext } from 'react'; +import { IRoomContext, RoomContextProps } from './RoomContext.types'; + +const RoomContext = createContext({ + roomSession: null, + eventDispatcher: null, + widgetHandler: null +}); + +export const RoomContextProvider: FC = props => +{ + return { props.children } +} + +export const useRoomContext = () => useContext(RoomContext); diff --git a/src/views/room/context/RoomContext.types.ts b/src/views/room/context/RoomContext.types.ts new file mode 100644 index 00000000..b9aade0c --- /dev/null +++ b/src/views/room/context/RoomContext.types.ts @@ -0,0 +1,15 @@ +import { IEventDispatcher, IRoomSession } from 'nitro-renderer'; +import { ProviderProps } from 'react'; +import { IRoomWidgetHandlerManager } from '../handlers'; + +export interface IRoomContext +{ + roomSession: IRoomSession; + eventDispatcher: IEventDispatcher; + widgetHandler: IRoomWidgetHandlerManager; +} + +export interface RoomContextProps extends ProviderProps +{ + +} diff --git a/src/views/room/events/RoomWidgetObjectNameEvent.ts b/src/views/room/events/RoomWidgetObjectNameEvent.ts new file mode 100644 index 00000000..2a3773e4 --- /dev/null +++ b/src/views/room/events/RoomWidgetObjectNameEvent.ts @@ -0,0 +1,48 @@ +import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent'; + +export class RoomWidgetObjectNameEvent extends RoomWidgetUpdateEvent +{ + public static TYPE: string = 'RWONE_TYPE'; + + private _roomIndex: number; + private _category: number; + private _id: number; + private _name: string; + private _userType: number; + + constructor(roomIndex: number, category: number, id: number, name: string, userType: number) + { + super(RoomWidgetObjectNameEvent.TYPE); + + this._roomIndex = roomIndex; + this._category = category; + this._id = id; + this._name = name; + this._userType = userType; + } + + public get roomIndex(): number + { + return this._roomIndex; + } + + public get category(): number + { + return this._category; + } + + public get id(): number + { + return this._id; + } + + public get name(): string + { + return this._name; + } + + public get userType(): number + { + return this._userType; + } +} diff --git a/src/views/room/events/RoomWidgetRoomEngineUpdateEvent.ts b/src/views/room/events/RoomWidgetRoomEngineUpdateEvent.ts new file mode 100644 index 00000000..c7e433a2 --- /dev/null +++ b/src/views/room/events/RoomWidgetRoomEngineUpdateEvent.ts @@ -0,0 +1,21 @@ +import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent'; + +export class RoomWidgetRoomEngineUpdateEvent extends RoomWidgetUpdateEvent +{ + public static GAME_MODE: string = 'RWREUE_GAME_MODE'; + public static NORMAL_MODE: string = 'RWREUE_NORMAL_MODE'; + + private _roomId: number = 0; + + constructor(type: string, roomId: number) + { + super(type); + + this._roomId = roomId; + } + + public get roomId(): number + { + return this._roomId; + } +} diff --git a/src/views/room/events/RoomWidgetRoomObjectUpdateEvent.ts b/src/views/room/events/RoomWidgetRoomObjectUpdateEvent.ts new file mode 100644 index 00000000..8c63ab4c --- /dev/null +++ b/src/views/room/events/RoomWidgetRoomObjectUpdateEvent.ts @@ -0,0 +1,42 @@ +import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent'; + +export class RoomWidgetRoomObjectUpdateEvent extends RoomWidgetUpdateEvent +{ + public static OBJECT_SELECTED: string = 'RWROUE_OBJECT_SELECTED'; + public static OBJECT_DESELECTED: string = 'RWROUE_OBJECT_DESELECTED'; + public static USER_REMOVED: string = 'RWROUE_USER_REMOVED'; + public static FURNI_REMOVED: string = 'RWROUE_FURNI_REMOVED'; + public static FURNI_ADDED: string = 'RWROUE_FURNI_ADDED'; + public static USER_ADDED: string = 'RWROUE_USER_ADDED'; + public static OBJECT_ROLL_OVER: string = 'RWROUE_OBJECT_ROLL_OVER'; + public static OBJECT_ROLL_OUT: string = 'RWROUE_OBJECT_ROLL_OUT'; + public static OBJECT_REQUEST_MANIPULATION: string = 'RWROUE_OBJECT_REQUEST_MANIPULATION'; + + private _id: number; + private _category: number; + private _roomId: number; + + constructor(type: string, id: number, category: number, roomId: number) + { + super(type); + + this._id = id; + this._category = category; + this._roomId = roomId; + } + + public get id(): number + { + return this._id; + } + + public get category(): number + { + return this._category; + } + + public get roomId(): number + { + return this._roomId; + } +} diff --git a/src/views/room/events/RoomWidgetUpdateEvent.ts b/src/views/room/events/RoomWidgetUpdateEvent.ts new file mode 100644 index 00000000..a4a0540a --- /dev/null +++ b/src/views/room/events/RoomWidgetUpdateEvent.ts @@ -0,0 +1,4 @@ +import { NitroEvent } from 'nitro-renderer'; + +export class RoomWidgetUpdateEvent extends NitroEvent +{} diff --git a/src/views/room/events/RoomWidgetUpdateInfostandEvent.ts b/src/views/room/events/RoomWidgetUpdateInfostandEvent.ts new file mode 100644 index 00000000..0e383daa --- /dev/null +++ b/src/views/room/events/RoomWidgetUpdateInfostandEvent.ts @@ -0,0 +1,4 @@ +import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent'; + +export class RoomWidgetUpdateInfostandEvent extends RoomWidgetUpdateEvent +{} diff --git a/src/views/room/events/RoomWidgetUpdateInfostandFurniEvent.ts b/src/views/room/events/RoomWidgetUpdateInfostandFurniEvent.ts new file mode 100644 index 00000000..1eaa0bc4 --- /dev/null +++ b/src/views/room/events/RoomWidgetUpdateInfostandFurniEvent.ts @@ -0,0 +1,33 @@ +import { IObjectData } from 'nitro-renderer'; +import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent'; + +export class RoomWidgetUpdateInfostandFurniEvent extends RoomWidgetUpdateInfostandEvent +{ + public static FURNI: string = 'RWUIFE_FURNI'; + + public id: number = 0; + public category: number = 0; + public name: string = ''; + public description: string = ''; + public image: HTMLImageElement = null; + public isWallItem: boolean = false; + public isStickie: boolean = false; + public isRoomOwner: boolean = false; + public roomControllerLevel: number = 0; + public isAnyRoomController: boolean = false; + public expiration: number = -1; + public purchaseCatalogPageId: number = -1; + public purchaseOfferId: number = -1; + public extraParam: string = ''; + public isOwner: boolean = false; + public stuffData: IObjectData = null; + public groupId: number = 0; + public ownerId: number = 0; + public ownerName: string = ''; + public usagePolicy: number = 0; + public rentCatalogPageId: number = -1; + public rentOfferId: number = -1; + public purchaseCouldBeUsedForBuyout: boolean = false; + public rentCouldBeUsedForBuyout: boolean = false; + public availableForBuildersClub: boolean = false; +} diff --git a/src/views/room/events/RoomWidgetUpdateInfostandPetEvent.ts b/src/views/room/events/RoomWidgetUpdateInfostandPetEvent.ts new file mode 100644 index 00000000..45d65407 --- /dev/null +++ b/src/views/room/events/RoomWidgetUpdateInfostandPetEvent.ts @@ -0,0 +1,5 @@ +import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent'; + +export class RoomWidgetUpdateInfostandPetEvent extends RoomWidgetUpdateInfostandEvent +{ +} diff --git a/src/views/room/events/RoomWidgetUpdateInfostandRentableBotEvent.ts b/src/views/room/events/RoomWidgetUpdateInfostandRentableBotEvent.ts new file mode 100644 index 00000000..a44f77f5 --- /dev/null +++ b/src/views/room/events/RoomWidgetUpdateInfostandRentableBotEvent.ts @@ -0,0 +1,20 @@ +import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent'; + +export class RoomWidgetUpdateInfostandRentableBotEvent extends RoomWidgetUpdateInfostandEvent +{ + public static RENTABLE_BOT: string = 'RWUIRBE_RENTABLE_BOT'; + + public name: string = ''; + public motto: string = ''; + public webID: number = 0; + public figure: string = ''; + public badges: string[] = []; + public carryItem: number = 0; + public roomIndex: number = 0; + public amIOwner: boolean = false; + public amIAnyRoomController: boolean = false; + public roomControllerLevel: number = 0; + public ownerId: number = -1; + public ownerName: string = ''; + public botSkills: number[] = []; +} diff --git a/src/views/room/events/RoomWidgetUpdateInfostandUserEvent.ts b/src/views/room/events/RoomWidgetUpdateInfostandUserEvent.ts new file mode 100644 index 00000000..6171b20a --- /dev/null +++ b/src/views/room/events/RoomWidgetUpdateInfostandUserEvent.ts @@ -0,0 +1,44 @@ +import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent'; + +export class RoomWidgetUpdateInfostandUserEvent extends RoomWidgetUpdateInfostandEvent +{ + public static OWN_USER: string = 'RWUIUE_OWN_USER'; + public static PEER: string = 'RWUIUE_PEER'; + public static BOT: string = 'RWUIUE_BOT'; + public static TRADE_REASON_OK: number = 0; + public static TRADE_REASON_SHUTDOWN: number = 2; + public static TRADE_REASON_NO_TRADING: number = 3; + public static DEFAULT_BOT_BADGE_ID: string = 'BOT'; + + public name: string = ''; + public motto: string = ''; + public achievementScore: number = 0; + public webID: number = 0; + public xp: number = 0; + public userType: number = -1; + public figure: string = ''; + public badges: string[] = []; + public groupId: number = 0; + public groupName: string = ''; + public groupBadgeId: string = ''; + public carryItem: number = 0; + public roomIndex: number = 0; + public isSpectatorMode: boolean = false; + public realName: string = ''; + public allowNameChange: boolean = false; + public amIOwner: boolean = false; + public amIAnyRoomController: boolean = false; + public roomControllerLevel: number = 0; + public canBeAskedAsFriend: boolean = false; + public canBeKicked: boolean = false; + public canBeBanned: boolean = false; + public canBeMuted: boolean = false; + public respectLeft: number = 0; + public isIgnored: boolean = false; + public isGuildRoom: boolean = false; + public canTrade: boolean = false; + public canTradeReason: number = 0; + public targetRoomControllerLevel: number = 0; + public isFriend: boolean = false; + public isAmbassador: boolean = false; +} diff --git a/src/views/room/events/index.ts b/src/views/room/events/index.ts new file mode 100644 index 00000000..f55e5067 --- /dev/null +++ b/src/views/room/events/index.ts @@ -0,0 +1,9 @@ +export * from './RoomWidgetObjectNameEvent'; +export * from './RoomWidgetRoomEngineUpdateEvent'; +export * from './RoomWidgetRoomObjectUpdateEvent'; +export * from './RoomWidgetUpdateEvent'; +export * from './RoomWidgetUpdateInfostandEvent'; +export * from './RoomWidgetUpdateInfostandFurniEvent'; +export * from './RoomWidgetUpdateInfostandPetEvent'; +export * from './RoomWidgetUpdateInfostandRentableBotEvent'; +export * from './RoomWidgetUpdateInfostandUserEvent'; diff --git a/src/views/room/handlers/IRoomWidgetHandler.ts b/src/views/room/handlers/IRoomWidgetHandler.ts new file mode 100644 index 00000000..2043192e --- /dev/null +++ b/src/views/room/handlers/IRoomWidgetHandler.ts @@ -0,0 +1,13 @@ +import { IEventDispatcher, IRoomSession, NitroEvent } from 'nitro-renderer'; +import { RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetMessage } from '../messages'; + +export interface IRoomWidgetHandler +{ + processEvent: (event: NitroEvent) => void; + processWidgetMessage: (message: RoomWidgetMessage) => RoomWidgetUpdateEvent; + roomSession: IRoomSession; + eventDispatcher: IEventDispatcher; + eventTypes: string[]; + messageTypes: string[]; +} diff --git a/src/views/room/handlers/IRoomWidgetHandlerManager.ts b/src/views/room/handlers/IRoomWidgetHandlerManager.ts new file mode 100644 index 00000000..654c34e3 --- /dev/null +++ b/src/views/room/handlers/IRoomWidgetHandlerManager.ts @@ -0,0 +1,12 @@ +import { IEventDispatcher, NitroEvent } from 'nitro-renderer'; +import { RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetMessage } from '../messages'; +import { IRoomWidgetHandler } from './IRoomWidgetHandler'; + +export interface IRoomWidgetHandlerManager +{ + registerHandler(handler: IRoomWidgetHandler): void; + processEvent(event: NitroEvent): void; + processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent; + eventDispatcher: IEventDispatcher; +} diff --git a/src/views/room/handlers/RoomWidgetHandler.ts b/src/views/room/handlers/RoomWidgetHandler.ts new file mode 100644 index 00000000..29e73af0 --- /dev/null +++ b/src/views/room/handlers/RoomWidgetHandler.ts @@ -0,0 +1,38 @@ +import { IEventDispatcher, IRoomSession, NitroEvent } from 'nitro-renderer'; +import { RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetMessage } from '../messages'; +import { IRoomWidgetHandler } from './IRoomWidgetHandler'; + +export abstract class RoomWidgetHandler implements IRoomWidgetHandler +{ + private _roomSession: IRoomSession = null; + private _eventDispatcher: IEventDispatcher = null; + + public abstract processEvent(event: NitroEvent): void; + + public abstract processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent; + + public get roomSession(): IRoomSession + { + return this._roomSession; + } + + public set roomSession(roomSession: IRoomSession) + { + this._roomSession = roomSession; + } + + public get eventDispatcher(): IEventDispatcher + { + return this._eventDispatcher; + } + + public set eventDispatcher(eventDispatcher: IEventDispatcher) + { + this._eventDispatcher = eventDispatcher; + } + + public abstract get eventTypes(): string[]; + + public abstract get messageTypes(): string[]; +} diff --git a/src/views/room/handlers/RoomWidgetHandlerManager.ts b/src/views/room/handlers/RoomWidgetHandlerManager.ts new file mode 100644 index 00000000..9648c9f1 --- /dev/null +++ b/src/views/room/handlers/RoomWidgetHandlerManager.ts @@ -0,0 +1,114 @@ +import { IEventDispatcher, IRoomSession, NitroEvent } from 'nitro-renderer'; +import { RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetMessage } from '../messages'; +import { IRoomWidgetHandler } from './IRoomWidgetHandler'; +import { IRoomWidgetHandlerManager } from './IRoomWidgetHandlerManager'; + +export class RoomWidgetHandlerManager implements IRoomWidgetHandlerManager +{ + private _roomSession: IRoomSession; + private _eventDispatcher: IEventDispatcher; + private _handlers: IRoomWidgetHandler[] = []; + private _eventMap: Map = new Map(); + private _messageMap: Map = new Map(); + + constructor(roomSession: IRoomSession, eventDispatcher: IEventDispatcher) + { + this._roomSession = roomSession; + this._eventDispatcher = eventDispatcher; + } + + public registerHandler(handler: IRoomWidgetHandler): void + { + const eventTypes = handler.eventTypes; + + if(eventTypes && eventTypes.length) + { + for(const name of eventTypes) + { + if(!name) continue; + + let events = this._eventMap.get(name); + + if(!events) + { + events = []; + + this._eventMap.set(name, events); + } + + events.push(handler); + } + } + + const messageTypes = handler.messageTypes; + + if(messageTypes && messageTypes.length) + { + for(const name of messageTypes) + { + if(!name) continue; + + let messages = this._messageMap.get(name); + + if(!messages) + { + messages = []; + + this._messageMap.set(name, messages); + } + + messages.push(handler); + } + } + + handler.roomSession = this._roomSession; + handler.eventDispatcher = this._eventDispatcher; + + this._handlers.push(handler); + } + + public processEvent(event: NitroEvent): void + { + const handlers = this._messageMap.get(event.type); + + if(!handlers || !handlers.length) return null; + + for(const handler of handlers) + { + if(!handler) continue; + + handler.processEvent(event); + } + } + + public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent + { + const handlers = this._messageMap.get(message.type); + + if(!handlers || !handlers.length) return null; + + for(const handler of handlers) + { + if(!handler) continue; + + const update = handler.processWidgetMessage(message); + + if(!update) continue; + + return update; + } + + return null; + } + + public get roomSession(): IRoomSession + { + return this._roomSession; + } + + public get eventDispatcher(): IEventDispatcher + { + return this._eventDispatcher; + } +} diff --git a/src/views/room/handlers/RoomWidgetInfostandHandler.ts b/src/views/room/handlers/RoomWidgetInfostandHandler.ts new file mode 100644 index 00000000..d525253d --- /dev/null +++ b/src/views/room/handlers/RoomWidgetInfostandHandler.ts @@ -0,0 +1,564 @@ +import { IFurnitureData, Nitro, NitroEvent, ObjectDataFactory, RoomControllerLevel, RoomModerationParser, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomTradingLevelEnum, RoomUserData, RoomWidgetEnumItemExtradataParameter, Vector3d } from 'nitro-renderer'; +import { GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture } from '../../../api'; +import { LocalizeText } from '../../../utils/LocalizeText'; +import { RoomWidgetObjectNameEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../events'; +import { RoomWidgetChangeMottoMessage, RoomWidgetFurniActionMessage, RoomWidgetMessage, RoomWidgetRoomObjectMessage, RoomWidgetUserActionMessage } from '../messages'; +import { RoomWidgetHandler } from './RoomWidgetHandler'; + +export class RoomWidgetInfostandHandler extends RoomWidgetHandler +{ + public processEvent(event: NitroEvent): void + { + return; + } + + public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent + { + let userId = 0; + let userData: RoomUserData = null; + let objectId = 0; + let category = 0; + + if(message instanceof RoomWidgetUserActionMessage) + { + userId = message.userId; + + const petMessages = [ + RoomWidgetUserActionMessage.REQUEST_PET_UPDATE, + RoomWidgetUserActionMessage.RESPECT_PET, + RoomWidgetUserActionMessage.PICKUP_PET, + RoomWidgetUserActionMessage.MOUNT_PET, + RoomWidgetUserActionMessage.TOGGLE_PET_RIDING_PERMISSION, + RoomWidgetUserActionMessage.TOGGLE_PET_BREEDING_PERMISSION, + RoomWidgetUserActionMessage.DISMOUNT_PET, + RoomWidgetUserActionMessage.SADDLE_OFF, + RoomWidgetUserActionMessage.GIVE_CARRY_ITEM_TO_PET, + RoomWidgetUserActionMessage.GIVE_WATER_TO_PET, + RoomWidgetUserActionMessage.GIVE_LIGHT_TO_PET, + RoomWidgetUserActionMessage.TREAT_PET + ]; + + if(petMessages.indexOf(message.type) >= 0) + { + userData = this.roomSession.userDataManager.getPetData(userId); + } + else + { + userData = this.roomSession.userDataManager.getUserData(userId); + } + + if(!userData) return null; + } + + else if(message instanceof RoomWidgetFurniActionMessage) + { + objectId = message.furniId; + category = message.furniCategory; + } + + switch(message.type) + { + case RoomWidgetRoomObjectMessage.GET_OBJECT_NAME: + return this.processObjectNameMessage((message as RoomWidgetRoomObjectMessage)); + case RoomWidgetRoomObjectMessage.GET_OBJECT_INFO: + return this.processObjectInfoMessage((message as RoomWidgetRoomObjectMessage)); + + } + + return null; + } + + private processObjectNameMessage(message: RoomWidgetRoomObjectMessage): RoomWidgetUpdateEvent + { + let id = -1; + let name: string = null; + let userType = 0; + + switch(message.category) + { + case RoomObjectCategory.FLOOR: + case RoomObjectCategory.WALL: { + const roomObject = GetRoomEngine().getRoomObject(this.roomSession.roomId, message.id, message.category); + + if(!roomObject) break; + + if(roomObject.type.indexOf('poster') === 0) + { + name = LocalizeText('${poster_' + parseInt(roomObject.type.replace('poster', '')) + '_name}'); + } + else + { + let furniData: IFurnitureData = null; + + const typeId = roomObject.model.getValue(RoomObjectVariable.FURNITURE_TYPE_ID); + + if(message.category === RoomObjectCategory.FLOOR) + { + furniData = GetSessionDataManager().getFloorItemData(typeId); + } + + else if(message.category === RoomObjectCategory.WALL) + { + furniData = GetSessionDataManager().getWallItemData(typeId); + } + + if(!furniData) break; + + id = furniData.id; + name = furniData.name; + } + break; + } + case RoomObjectCategory.UNIT: { + const userData = this.roomSession.userDataManager.getUserDataByIndex(message.id); + + if(!userData) break; + + id = userData.webID; + name = userData.name; + userType = userData.type; + break; + } + } + + if(name) this.eventDispatcher.dispatchEvent(new RoomWidgetObjectNameEvent(message.id, message.category, id, name, userType)); + + return null; + } + + private processObjectInfoMessage(message: RoomWidgetRoomObjectMessage): RoomWidgetUpdateEvent + { + const roomId = this.roomSession.roomId; + + switch(message.category) + { + case RoomObjectCategory.FLOOR: + case RoomObjectCategory.WALL: + this.processFurniInfoMessage(message, roomId); + break; + case RoomObjectCategory.UNIT: { + const userData = this.roomSession.userDataManager.getUserDataByIndex(message.id); + + if(!userData) break; + + switch(userData.type) + { + case RoomObjectType.PET: + this.roomSession.userDataManager.requestPetInfo(userData.webID); + break; + case RoomObjectType.USER: + this.processUserInfoMessage(message, roomId, userData); + break; + case RoomObjectType.BOT: + this.processBotInfoMessage(message, roomId, userData); + break; + case RoomObjectType.RENTABLE_BOT: + this.processRentableBotInfoMessage(message, roomId, userData); + break; + } + } + + } + + return null; + } + + private processFurniInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number): void + { + const event = new RoomWidgetUpdateInfostandFurniEvent(RoomWidgetUpdateInfostandFurniEvent.FURNI); + + event.id = message.id; + event.category = message.category; + + const roomObject = GetRoomEngine().getRoomObject(roomId, message.id, message.category); + + if(!roomObject) return; + + const model = roomObject.model; + + if(model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM)) + { + event.extraParam = model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM); + } + + const dataFormat = model.getValue(RoomObjectVariable.FURNITURE_DATA_FORMAT); + const objectData = ObjectDataFactory.getData(dataFormat); + + objectData.initializeFromRoomObjectModel(model); + + event.stuffData = objectData; + + const objectType = roomObject.type; + + if(objectType.indexOf('poster') === 0) + { + const posterId = parseInt(objectType.replace('poster', '')); + + event.name = LocalizeText(('${poster_' + posterId) + '_name}'); + event.description = LocalizeText(('${poster_' + posterId) + '_desc}'); + } + else + { + const typeId = model.getValue(RoomObjectVariable.FURNITURE_TYPE_ID); + + let furnitureData: IFurnitureData = null; + + if(message.category === RoomObjectCategory.FLOOR) + { + furnitureData = GetSessionDataManager().getFloorItemData(typeId); + } + + else if(message.category === RoomObjectCategory.WALL) + { + furnitureData = GetSessionDataManager().getWallItemData(typeId); + } + + if(furnitureData) + { + event.name = furnitureData.name; + event.description = furnitureData.description; + event.purchaseOfferId = furnitureData.purchaseOfferId; + event.purchaseCouldBeUsedForBuyout = furnitureData.purchaseCouldBeUsedForBuyout; + event.rentOfferId = furnitureData.rentOfferId; + event.rentCouldBeUsedForBuyout = furnitureData.rentCouldBeUsedForBuyout; + event.availableForBuildersClub = furnitureData.availableForBuildersClub; + + // if(this._container.wiredService && (k.category === RoomObjectCategory.FLOOR)) + // { + // this._container.wiredService.selectFurniture(roomObject.id, furnitureData.name); + // } + } + } + + if(objectType.indexOf('post_it') > -1) event.isStickie = true; + + const expiryTime = model.getValue(RoomObjectVariable.FURNITURE_EXPIRY_TIME); + const expiryTimestamp = model.getValue(RoomObjectVariable.FURNITURE_EXPIRTY_TIMESTAMP); + + event.expiration = ((expiryTime < 0) ? expiryTime : Math.max(0, (expiryTime - ((Nitro.instance.time - expiryTimestamp) / 1000)))); + + let roomObjectImage = GetRoomEngine().getRoomObjectImage(roomId, message.id, message.category, new Vector3d(180), 64, null); + + if(!roomObjectImage.data || (roomObjectImage.data.width > 140) || (roomObjectImage.data.height > 200)) + { + roomObjectImage = GetRoomEngine().getRoomObjectImage(roomId, message.id, message.category, new Vector3d(180), 1, null); + } + + if(roomObjectImage && roomObjectImage.data) + { + const image = Nitro.instance.renderer.extract.image(roomObjectImage.data); + + if(image) event.image = image; + } + + event.isWallItem = (message.category === RoomObjectCategory.WALL); + event.isRoomOwner = this.roomSession.isRoomOwner; + event.roomControllerLevel = this.roomSession.controllerLevel; + event.isAnyRoomController = GetSessionDataManager().isModerator; + event.ownerId = model.getValue(RoomObjectVariable.FURNITURE_OWNER_ID); + event.ownerName = model.getValue(RoomObjectVariable.FURNITURE_OWNER_NAME); + event.usagePolicy = model.getValue(RoomObjectVariable.FURNITURE_USAGE_POLICY); + + const guildId = model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID); + + if(guildId !== 0) + { + event.groupId = guildId; + //this.container.connection.send(new _Str_2863(guildId, false)); + } + + if(IsOwnerOfFurniture(roomObject)) event.isOwner = true; + + this.eventDispatcher.dispatchEvent(event); + } + + private processUserInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number, userData: RoomUserData): void + { + let eventType = RoomWidgetUpdateInfostandUserEvent.OWN_USER; + + if(userData.webID !== GetSessionDataManager().userId) eventType = RoomWidgetUpdateInfostandUserEvent.PEER; + + const event = new RoomWidgetUpdateInfostandUserEvent(eventType); + + event.isSpectatorMode = this.roomSession.isSpectator; + event.name = userData.name; + event.motto = userData.custom; + event.achievementScore = userData.activityPoints; + event.webID = userData.webID; + event.roomIndex = userData.roomIndex; + event.userType = RoomObjectType.USER; + + const roomObject = GetRoomEngine().getRoomObject(roomId, userData.roomIndex, message.category); + + if(roomObject) event.carryItem = (roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0); + + if(eventType === RoomWidgetUpdateInfostandUserEvent.OWN_USER) + { + event.realName = GetSessionDataManager().realName; + event.allowNameChange = GetSessionDataManager().canChangeName; + } + + event.amIOwner = this.roomSession.isRoomOwner; + event.isGuildRoom = this.roomSession.isGuildRoom; + event.roomControllerLevel = this.roomSession.controllerLevel; + event.amIAnyRoomController = GetSessionDataManager().isModerator; + event.isAmbassador = GetSessionDataManager().isAmbassador; + + if(eventType === RoomWidgetUpdateInfostandUserEvent.PEER) + { + // userInfoData.canBeAskedAsFriend = this._container.friendService.canBeAskedForAFriend(userData.webID); + + // const friend = this._container.friendService.getFriend(userData.webID); + + // if(friend) + // { + // userInfoData.realName = friend.realName; + // userInfoData.isFriend = true; + // } + + if(roomObject) + { + const flatControl = roomObject.model.getValue(RoomObjectVariable.FIGURE_FLAT_CONTROL); + + if(flatControl !== null) event.targetRoomControllerLevel = flatControl; + + event.canBeMuted = this.canBeMuted(event); + event.canBeKicked = this.canBeKicked(event); + event.canBeBanned = this.canBeBanned(event); + } + + event.isIgnored = GetSessionDataManager().isUserIgnored(userData.name); + event.respectLeft = GetSessionDataManager().respectsLeft; + + const isShuttingDown = GetSessionDataManager().isSystemShutdown; + const tradeMode = this.roomSession.tradeMode; + + if(isShuttingDown) + { + event.canTrade = false; + } + else + { + switch(tradeMode) + { + case RoomTradingLevelEnum._Str_14475: { + const roomController = ((event.roomControllerLevel !== RoomControllerLevel.NONE) && (event.roomControllerLevel !== RoomControllerLevel.GUILD_MEMBER)); + const targetController = ((event.targetRoomControllerLevel !== RoomControllerLevel.NONE) && (event.targetRoomControllerLevel !== RoomControllerLevel.GUILD_MEMBER)); + + event.canTrade = (roomController || targetController); + break; + } + case RoomTradingLevelEnum._Str_9173: + event.canTrade = true; + break; + default: + event.canTrade = false; + break; + } + } + + event.canTradeReason = RoomWidgetUpdateInfostandUserEvent.TRADE_REASON_OK; + + if(isShuttingDown) event.canTradeReason = RoomWidgetUpdateInfostandUserEvent.TRADE_REASON_SHUTDOWN; + + if(tradeMode !== RoomTradingLevelEnum._Str_9173) event.canTradeReason = RoomWidgetUpdateInfostandUserEvent.TRADE_REASON_NO_TRADING; + + // const _local_12 = GetSessionDataManager().userId; + // _local_13 = GetSessionDataManager()._Str_18437(_local_12); + // this._Str_16287(_local_12, _local_13); + } + + event.groupId = parseInt(userData.guildId); + //event._Str_5235 = GetSessionDataManager()._Str_17173(int(userData._Str_4592)); + event.groupName = userData.groupName; + event.badges = this.roomSession.userDataManager.getUserBadges(userData.webID); + event.figure = userData.figure; + //var _local_8:Array = GetSessionDataManager()._Str_18437(userData.webID); + //this._Str_16287(userData._Str_2394, _local_8); + //this._container._Str_8097._Str_14387(userData.webID); + //this._container.connection.send(new _Str_8049(userData._Str_2394)); + + this.eventDispatcher.dispatchEvent(event); + } + + private processBotInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number, userData: RoomUserData): void + { + const event = new RoomWidgetUpdateInfostandUserEvent(RoomWidgetUpdateInfostandUserEvent.BOT); + + event.name = userData.name; + event.motto = userData.custom; + event.webID = userData.webID; + event.roomIndex = userData.roomIndex; + event.userType = userData.type; + + const roomObject = GetRoomEngine().getRoomObject(roomId, userData.roomIndex, message.category); + + if(roomObject) event.carryItem = (roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0); + + event.amIOwner = this.roomSession.isRoomOwner; + event.isGuildRoom = this.roomSession.isGuildRoom; + event.roomControllerLevel = this.roomSession.controllerLevel; + event.amIAnyRoomController = GetSessionDataManager().isModerator; + event.isAmbassador = GetSessionDataManager().isAmbassador; + event.badges = [ RoomWidgetUpdateInfostandUserEvent.DEFAULT_BOT_BADGE_ID ]; + event.figure = userData.figure; + + this.eventDispatcher.dispatchEvent(event); + } + + private processRentableBotInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number, userData: RoomUserData): void + { + const event = new RoomWidgetUpdateInfostandRentableBotEvent(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT); + + event.name = userData.name; + event.motto = userData.custom; + event.webID = userData.webID; + event.roomIndex = userData.roomIndex; + event.ownerId = userData.ownerId; + event.ownerName = userData.ownerName; + event.botSkills = userData.botSkills; + + const roomObject = GetRoomEngine().getRoomObject(roomId, userData.roomIndex, message.category); + + if(roomObject) event.carryItem = (roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0); + + event.amIOwner = this.roomSession.isRoomOwner; + event.roomControllerLevel = this.roomSession.controllerLevel; + event.amIAnyRoomController = GetSessionDataManager().isModerator; + event.badges = [ RoomWidgetUpdateInfostandUserEvent.DEFAULT_BOT_BADGE_ID ]; + event.figure = userData.figure; + + this.eventDispatcher.dispatchEvent(event); + } + + private checkGuildSetting(event: RoomWidgetUpdateInfostandUserEvent): boolean + { + if(event.isGuildRoom) return (event.roomControllerLevel >= RoomControllerLevel.GUILD_ADMIN); + + return (event.roomControllerLevel >= RoomControllerLevel.GUEST); + } + + private canBeMuted(event: RoomWidgetUpdateInfostandUserEvent): boolean + { + const checkSetting = (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationParser) => + { + switch(moderation.allowMute) + { + case RoomModerationParser._Str_5047: + return this.checkGuildSetting(event); + default: + return (event.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER); + } + } + + return this.isValidSetting(event, checkSetting); + } + + private canBeKicked(event: RoomWidgetUpdateInfostandUserEvent): boolean + { + const checkSetting = (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationParser) => + { + switch(moderation.allowKick) + { + case RoomModerationParser._Str_11537: + return true; + case RoomModerationParser._Str_5047: + return this.checkGuildSetting(event); + default: + return (event.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER); + } + } + + return this.isValidSetting(event, checkSetting); + } + + private canBeBanned(event: RoomWidgetUpdateInfostandUserEvent): boolean + { + const checkSetting = (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationParser) => + { + switch(moderation.allowBan) + { + case RoomModerationParser._Str_5047: + return this.checkGuildSetting(event); + default: + return (event.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER); + } + } + + return this.isValidSetting(event, checkSetting); + } + + private isValidSetting(event: RoomWidgetUpdateInfostandUserEvent, checkSetting: (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationParser) => boolean): boolean + { + if(!this.roomSession._Str_7411) return false; + + const moderation = this.roomSession.moderationSettings; + + let flag = false; + + if(moderation) flag = checkSetting(event, moderation); + + return (flag && (event.roomControllerLevel < RoomControllerLevel.ROOM_OWNER)); + } + + public get eventTypes(): string[] + { + return [ + + ]; + } + + public get messageTypes(): string[] + { + return [ + RoomWidgetRoomObjectMessage.GET_OBJECT_INFO, + RoomWidgetRoomObjectMessage.GET_OBJECT_NAME, + RoomWidgetUserActionMessage.SEND_FRIEND_REQUEST, + RoomWidgetUserActionMessage.RESPECT_USER, + RoomWidgetUserActionMessage.WHISPER_USER, + RoomWidgetUserActionMessage.IGNORE_USER, + RoomWidgetUserActionMessage.UNIGNORE_USER, + RoomWidgetUserActionMessage.KICK_USER, + RoomWidgetUserActionMessage.BAN_USER_DAY, + RoomWidgetUserActionMessage.BAN_USER_HOUR, + RoomWidgetUserActionMessage.BAN_USER_PERM, + RoomWidgetUserActionMessage.MUTE_USER_2MIN, + RoomWidgetUserActionMessage.MUTE_USER_5MIN, + RoomWidgetUserActionMessage.MUTE_USER_10MIN, + RoomWidgetUserActionMessage.GIVE_RIGHTS, + RoomWidgetUserActionMessage.TAKE_RIGHTS, + RoomWidgetUserActionMessage.START_TRADING, + RoomWidgetUserActionMessage.OPEN_HOME_PAGE, + RoomWidgetUserActionMessage.PASS_CARRY_ITEM, + RoomWidgetUserActionMessage.GIVE_CARRY_ITEM_TO_PET, + RoomWidgetUserActionMessage.DROP_CARRY_ITEM, + RoomWidgetUserActionMessage.REPORT, + RoomWidgetUserActionMessage.PICKUP_PET, + RoomWidgetUserActionMessage.MOUNT_PET, + RoomWidgetUserActionMessage.TOGGLE_PET_RIDING_PERMISSION, + RoomWidgetUserActionMessage.TOGGLE_PET_BREEDING_PERMISSION, + RoomWidgetUserActionMessage.DISMOUNT_PET, + RoomWidgetUserActionMessage.SADDLE_OFF, + RoomWidgetUserActionMessage.TRAIN_PET, + RoomWidgetUserActionMessage.RESPECT_PET, + RoomWidgetUserActionMessage.REQUEST_PET_UPDATE, + RoomWidgetUserActionMessage.GIVE_LIGHT_TO_PET, + RoomWidgetUserActionMessage.GIVE_WATER_TO_PET, + RoomWidgetUserActionMessage.TREAT_PET, + RoomWidgetUserActionMessage.REPORT_CFH_OTHER, + RoomWidgetUserActionMessage.AMBASSADOR_ALERT_USER, + RoomWidgetUserActionMessage.AMBASSADOR_KICK_USER, + RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_2MIN, + RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_10MIN, + RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_60MIN, + RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_18HOUR, + RoomWidgetChangeMottoMessage.CHANGE_MOTTO, + RoomWidgetFurniActionMessage.MOVE, + RoomWidgetFurniActionMessage.ROTATE, + RoomWidgetFurniActionMessage.EJECT, + RoomWidgetFurniActionMessage.PICKUP, + RoomWidgetFurniActionMessage.USE, + RoomWidgetFurniActionMessage.SAVE_STUFF_DATA + ]; + } +} diff --git a/src/views/room/handlers/index.ts b/src/views/room/handlers/index.ts new file mode 100644 index 00000000..14a8f6f5 --- /dev/null +++ b/src/views/room/handlers/index.ts @@ -0,0 +1,5 @@ +export * from './IRoomWidgetHandler'; +export * from './IRoomWidgetHandlerManager'; +export * from './RoomWidgetHandler'; +export * from './RoomWidgetHandlerManager'; +export * from './RoomWidgetInfostandHandler'; diff --git a/src/views/room/messages/RoomWidgetChangeMottoMessage.ts b/src/views/room/messages/RoomWidgetChangeMottoMessage.ts new file mode 100644 index 00000000..2905ea30 --- /dev/null +++ b/src/views/room/messages/RoomWidgetChangeMottoMessage.ts @@ -0,0 +1,20 @@ +import { RoomWidgetMessage } from './RoomWidgetMessage'; + +export class RoomWidgetChangeMottoMessage extends RoomWidgetMessage +{ + public static CHANGE_MOTTO: string = 'RWCMM_CHANGE_MOTTO'; + + private _motto: string; + + constructor(type: string, motto: string) + { + super(type); + + this._motto = motto; + } + + public get motto(): string + { + return this._motto; + } +} diff --git a/src/views/room/messages/RoomWidgetFurniActionMessage.ts b/src/views/room/messages/RoomWidgetFurniActionMessage.ts new file mode 100644 index 00000000..d658d7d9 --- /dev/null +++ b/src/views/room/messages/RoomWidgetFurniActionMessage.ts @@ -0,0 +1,47 @@ +import { RoomWidgetMessage } from './RoomWidgetMessage'; + +export class RoomWidgetFurniActionMessage extends RoomWidgetMessage +{ + public static ROTATE: string = 'RWFAM_ROTATE'; + public static MOVE: string = 'RWFAM_MOVE'; + public static PICKUP: string = 'RWFAM_PICKUP'; + public static EJECT: string = 'RWFAM_EJECT'; + public static USE: string = 'RWFAM_USE'; + public static OPEN_WELCOME_GIFT: string = 'RWFAM_OPEN_WELCOME_GIFT'; + public static SAVE_STUFF_DATA: string = 'RWFAM_SAVE_STUFF_DATA'; + + private _furniId: number; + private _furniCategory: number; + private _offerId: number; + private _objectData: string; + + constructor(type: string, id: number, category: number, offerId: number =- 1, objectData: string = null) + { + super(type); + + this._furniId = id; + this._furniCategory = category; + this._offerId = offerId; + this._objectData = objectData; + } + + public get furniId(): number + { + return this._furniId; + } + + public get furniCategory(): number + { + return this._furniCategory; + } + + public get objectData(): string + { + return this._objectData; + } + + public get offerId(): number + { + return this._offerId; + } +} diff --git a/src/views/room/messages/RoomWidgetMessage.ts b/src/views/room/messages/RoomWidgetMessage.ts new file mode 100644 index 00000000..b57c4855 --- /dev/null +++ b/src/views/room/messages/RoomWidgetMessage.ts @@ -0,0 +1,14 @@ +export class RoomWidgetMessage +{ + private _type: string; + + constructor(type: string) + { + this._type = type; + } + + public get type(): string + { + return this._type; + } +} diff --git a/src/views/room/messages/RoomWidgetRoomObjectMessage.ts b/src/views/room/messages/RoomWidgetRoomObjectMessage.ts new file mode 100644 index 00000000..cc82b85c --- /dev/null +++ b/src/views/room/messages/RoomWidgetRoomObjectMessage.ts @@ -0,0 +1,31 @@ +import { RoomWidgetMessage } from './RoomWidgetMessage'; + +export class RoomWidgetRoomObjectMessage extends RoomWidgetMessage +{ + public static GET_OBJECT_INFO: string = 'RWROM_GET_OBJECT_INFO'; + public static GET_OBJECT_NAME: string = 'RWROM_GET_OBJECT_NAME'; + public static SELECT_OBJECT: string = 'RWROM_SELECT_OBJECT'; + public static GET_OWN_CHARACTER_INFO: string = 'RWROM_GET_OWN_CHARACTER_INFO'; + public static GET_AVATAR_LIST: string = 'RWROM_GET_AVATAR_LIST'; + + private _id: number; + private _category: number; + + constructor(type: string, id: number, category: number) + { + super(type); + + this._id = id; + this._category = category; + } + + public get id(): number + { + return this._id; + } + + public get category(): number + { + return this._category; + } +} diff --git a/src/views/room/messages/RoomWidgetUserActionMessage.ts b/src/views/room/messages/RoomWidgetUserActionMessage.ts new file mode 100644 index 00000000..540ad958 --- /dev/null +++ b/src/views/room/messages/RoomWidgetUserActionMessage.ts @@ -0,0 +1,65 @@ +import { RoomWidgetMessage } from './RoomWidgetMessage'; + +export class RoomWidgetUserActionMessage extends RoomWidgetMessage +{ + public static WHISPER_USER: string = 'RWUAM_WHISPER_USER'; + public static IGNORE_USER: string = 'RWUAM_IGNORE_USER'; + public static IGNORE_USER_BUBBLE: string = 'RWUAM_IGNORE_USER_BUBBLE'; + public static UNIGNORE_USER: string = 'RWUAM_UNIGNORE_USER'; + public static KICK_USER: string = 'RWUAM_KICK_USER'; + public static BAN_USER_HOUR: string = 'RWUAM_BAN_USER_HOUR'; + public static BAN_USER_DAY: string = 'RWUAM_BAN_USER_DAY'; + public static BAN_USER_PERM: string = 'RWUAM_BAN_USER_PERM'; + public static MUTE_USER_2MIN: string = 'RWUAM_MUTE_USER_2MIN'; + public static MUTE_USER_5MIN: string = 'RWUAM_MUTE_USER_5MIN'; + public static MUTE_USER_10MIN: string = 'RWUAM_MUTE_USER_10MIN'; + public static SEND_FRIEND_REQUEST: string = 'RWUAM_SEND_FRIEND_REQUEST'; + public static RESPECT_USER: string = 'RWUAM_RESPECT_USER'; + public static GIVE_RIGHTS: string = 'RWUAM_GIVE_RIGHTS'; + public static TAKE_RIGHTS: string = 'RWUAM_TAKE_RIGHTS'; + public static START_TRADING: string = 'RWUAM_START_TRADING'; + public static OPEN_HOME_PAGE: string = 'RWUAM_OPEN_HOME_PAGE'; + public static REPORT: string = 'RWUAM_REPORT'; + public static PICKUP_PET: string = 'RWUAM_PICKUP_PET'; + public static MOUNT_PET: string = 'RWUAM_MOUNT_PET'; + public static TOGGLE_PET_RIDING_PERMISSION: string = 'RWUAM_TOGGLE_PET_RIDING_PERMISSION'; + public static TOGGLE_PET_BREEDING_PERMISSION: string = 'RWUAM_TOGGLE_PET_BREEDING_PERMISSION'; + public static DISMOUNT_PET: string = 'RWUAM_DISMOUNT_PET'; + public static SADDLE_OFF: string = 'RWUAM_SADDLE_OFF'; + public static TRAIN_PET: string = 'RWUAM_TRAIN_PET'; + public static RESPECT_PET: string = ' RWUAM_RESPECT_PET'; + public static TREAT_PET: string = 'RWUAM_TREAT_PET'; + public static REQUEST_PET_UPDATE: string = 'RWUAM_REQUEST_PET_UPDATE'; + public static START_NAME_CHANGE: string = 'RWUAM_START_NAME_CHANGE'; + public static PASS_CARRY_ITEM: string = 'RWUAM_PASS_CARRY_ITEM'; + public static DROP_CARRY_ITEM: string = 'RWUAM_DROP_CARRY_ITEM'; + public static GIVE_CARRY_ITEM_TO_PET: string = 'RWUAM_GIVE_CARRY_ITEM_TO_PET'; + public static GIVE_WATER_TO_PET: string = 'RWUAM_GIVE_WATER_TO_PET'; + public static GIVE_LIGHT_TO_PET: string = 'RWUAM_GIVE_LIGHT_TO_PET'; + public static REQUEST_BREED_PET: string = 'RWUAM_REQUEST_BREED_PET'; + public static HARVEST_PET: string = 'RWUAM_HARVEST_PET'; + public static REVIVE_PET: string = 'RWUAM_REVIVE_PET'; + public static COMPOST_PLANT: string = 'RWUAM_COMPOST_PLANT'; + public static GET_BOT_INFO: string = 'RWUAM_GET_BOT_INFO'; + public static REPORT_CFH_OTHER: string = 'RWUAM_REPORT_CFH_OTHER'; + public static AMBASSADOR_ALERT_USER: string = 'RWUAM_AMBASSADOR_ALERT_USER'; + public static AMBASSADOR_KICK_USER: string = 'RWUAM_AMBASSADOR_KICK_USER'; + public static AMBASSADOR_MUTE_USER_2MIN: string = 'RWUAM_AMBASSADOR_MUTE_2MIN'; + public static AMBASSADOR_MUTE_USER_10MIN: string = 'RWUAM_AMBASSADOR_MUTE_10MIN'; + public static AMBASSADOR_MUTE_USER_60MIN: string = 'RWUAM_AMBASSADOR_MUTE_60MIN'; + public static AMBASSADOR_MUTE_USER_18HOUR: string = 'RWUAM_AMBASSADOR_MUTE_18HOUR'; + + private _userId: number; + + constructor(type: string, userId: number) + { + super(type); + + this._userId = userId; + } + + public get userId(): number + { + return this._userId; + } +} diff --git a/src/views/room/messages/index.ts b/src/views/room/messages/index.ts new file mode 100644 index 00000000..cf9d00e6 --- /dev/null +++ b/src/views/room/messages/index.ts @@ -0,0 +1,5 @@ +export * from './RoomWidgetChangeMottoMessage'; +export * from './RoomWidgetFurniActionMessage'; +export * from './RoomWidgetMessage'; +export * from './RoomWidgetRoomObjectMessage'; +export * from './RoomWidgetUserActionMessage'; diff --git a/src/views/room/widgets/RoomWidgets.scss b/src/views/room/widgets/RoomWidgets.scss index 764fc5cb..91ce4b4f 100644 --- a/src/views/room/widgets/RoomWidgets.scss +++ b/src/views/room/widgets/RoomWidgets.scss @@ -3,3 +3,4 @@ @import './chat-input/ChatInputView'; @import './furniture/FurnitureWidgets'; @import './infostand/InfoStandWidgetView'; +@import './object-location/ObjectLocationView'; diff --git a/src/views/room/widgets/RoomWidgets.types.ts b/src/views/room/widgets/RoomWidgets.types.ts index fd270bb3..199fc363 100644 --- a/src/views/room/widgets/RoomWidgets.types.ts +++ b/src/views/room/widgets/RoomWidgets.types.ts @@ -1,6 +1,5 @@ -import { IEventDispatcher } from 'nitro-renderer'; +export interface RoomWidgetViewProps +{} export interface RoomWidgetProps -{ - events: IEventDispatcher; -} +{} diff --git a/src/views/room/widgets/RoomWidgetsView.tsx b/src/views/room/widgets/RoomWidgetsView.tsx new file mode 100644 index 00000000..f27f1fe4 --- /dev/null +++ b/src/views/room/widgets/RoomWidgetsView.tsx @@ -0,0 +1,112 @@ +import { RoomSessionChatEvent, RoomSessionDanceEvent, RoomSessionDimmerPresetsEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionEvent, RoomSessionFriendRequestEvent, RoomSessionPresentEvent, RoomSessionUserBadgesEvent } from 'nitro-renderer'; +import { FC, useCallback } from 'react'; +import { useRoomSessionManagerEvent } from '../../../hooks/events'; +import { LocalizeText } from '../../../utils/LocalizeText'; +import { useRoomContext } from '../context/RoomContext'; +import { AvatarInfoWidgetView } from './avatar-info/AvatarInfoWidgetView'; +import { CameraWidgetView } from './camera/CameraWidgetView'; +import { ChatInputView } from './chat-input/ChatInputView'; +import { ChatWidgetView } from './chat/ChatWidgetView'; +import { FurnitureWidgetsView } from './furniture/FurnitureWidgetsView'; +import { InfoStandWidgetView } from './infostand/InfoStandWidgetView'; +import { RoomWidgetViewProps } from './RoomWidgets.types'; + +export const RoomWidgetsView: FC = props => +{ + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + + const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => + { + if(!widgetHandler) return; + + widgetHandler.processEvent(event); + }, [ widgetHandler ]); + + useRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionChatEvent.FLOOD_EVENT, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionDanceEvent.RSDE_DANCE, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionDoorbellEvent.DOORBELL, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionDimmerPresetsEvent.RSDPE_PRESETS, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionFriendRequestEvent.RSFRE_FRIEND_REQUEST, onRoomSessionEvent); + useRoomSessionManagerEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, onRoomSessionEvent); + + const onRoomErrorEvent = useCallback((event: RoomSessionEvent) => + { + if(!event) return; + + let errorTitle = LocalizeText('error.title'); + let errorMessage: string = ''; + + switch(event.type) + { + case RoomSessionErrorMessageEvent.RSEME_MAX_PETS: + errorMessage = LocalizeText('room.error.max_pets'); + break; + case RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS: + errorMessage = LocalizeText('room.error.max_own_pets'); + break; + case RoomSessionErrorMessageEvent.RSEME_KICKED: + errorMessage = LocalizeText('room.error.kicked'); + errorTitle = LocalizeText('generic.alert.title'); + break; + case RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL: + errorMessage = LocalizeText('room.error.pets.forbidden_in_hotel'); + break; + case RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT: + errorMessage = LocalizeText('room.error.pets.forbidden_in_flat'); + break; + case RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET: + errorMessage = LocalizeText('room.error.pets.no_free_tiles'); + break; + case RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET: + errorMessage = LocalizeText('room.error.pets.selected_tile_not_free'); + break; + case RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL: + errorMessage = LocalizeText('room.error.bots.forbidden_in_hotel'); + break; + case RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT: + errorMessage = LocalizeText('room.error.bots.forbidden_in_flat'); + break; + case RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED: + errorMessage = LocalizeText('room.error.max_bots'); + break; + case RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT: + errorMessage = LocalizeText('room.error.bots.selected_tile_not_free'); + break; + case RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED: + errorMessage = LocalizeText('room.error.bots.name.not.accepted'); + break; + default: + return; + } + }, []); + + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_KICKED, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_PETS, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT, onRoomErrorEvent); + useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED, onRoomErrorEvent); + + if(!widgetHandler) return null; + + return ( + <> + + + + + + + + ); +} diff --git a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx index 61d859a0..21c33678 100644 --- a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx +++ b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx @@ -1,86 +1,135 @@ import { RoomObjectCategory } from 'nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { GetObjectName, RoomObjectNameData } from '../../../../api'; import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; -import { RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectUpdateEvent } from '../events'; +import { useRoomContext } from '../../context/RoomContext'; +import { RoomWidgetObjectNameEvent, RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../../events'; +import { RoomWidgetRoomObjectMessage } from '../../messages'; import { AvatarInfoWidgetViewProps } from './AvatarInfoWidgetView.types'; import { AvatarInfoWidgetNameView } from './views/name/AvatarInfoWidgetNameView'; export const AvatarInfoWidgetView: FC = props => { - const { events = null } = props; - const [ names, setNames ] = useState([]); + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const [ name, setName ] = useState(null); + const [ infoStandEvent, setInfoStandEvent ] = useState(null); const [ isGameMode, setGameMode ] = useState(false); - const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => + const onRoomWidgetUpdateEvent = useCallback((event: RoomWidgetUpdateEvent) => { switch(event.type) { - case RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER: { - if(isGameMode) return; + case RoomWidgetRoomEngineUpdateEvent.NORMAL_MODE: { + const roomEngineEvent = (event as RoomWidgetRoomEngineUpdateEvent); - if(event.category !== RoomObjectCategory.UNIT) return; + setGameMode(false); + return; + } + case RoomWidgetRoomEngineUpdateEvent.GAME_MODE: { + const roomEngineEvent = (event as RoomWidgetRoomEngineUpdateEvent); - const nameData = GetObjectName(event.roomId, event.id, event.category); + setGameMode(true); + return; + } + case RoomWidgetRoomObjectUpdateEvent.USER_ADDED: { + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); - if(nameData) - { - setNames(prevValue => + return; + } + case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: + case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED: { + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); + + setName(prevValue => + { + if(!prevValue || (roomObjectEvent.id === prevValue.id)) return null; + + return prevValue; + }) + + setInfoStandEvent(prevValue => + { + if(!prevValue) return null; + + switch(event.type) { - const existing = prevValue.filter(value => + case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: + if(prevValue instanceof RoomWidgetUpdateInfostandFurniEvent) { - if(value.objectId === nameData.id) return null; - - return value; - }); - - return [ ...existing, nameData ] - }); - } + if(prevValue.id === roomObjectEvent.id) return null; + } + break; + case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED: + if(prevValue instanceof RoomWidgetUpdateInfostandUserEvent || prevValue instanceof RoomWidgetUpdateInfostandRentableBotEvent) + { + if(prevValue.webID === roomObjectEvent.id) return null; + } + + else if(prevValue instanceof RoomWidgetUpdateInfostandPetEvent) + { + // room index + } + break; + } + + return prevValue; + }); + + return; + } + case RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER: { + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); + + widgetHandler.processWidgetMessage(new RoomWidgetRoomObjectMessage(RoomWidgetRoomObjectMessage.GET_OBJECT_NAME, roomObjectEvent.id, roomObjectEvent.category)); return; } case RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT: { - if(isGameMode) return; - - setNames(prevValue => - { - return prevValue.filter(value => - { - if(value.objectId === event.id) return null; + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); - return value; - }); - }); + setName(null); return; } + case RoomWidgetObjectNameEvent.TYPE: { + const objectNameEvent = (event as RoomWidgetObjectNameEvent); + + if(objectNameEvent.category !== RoomObjectCategory.UNIT) return; + + setName(objectNameEvent); + + return; + } + case RoomWidgetUpdateInfostandFurniEvent.FURNI: + case RoomWidgetUpdateInfostandUserEvent.OWN_USER: + case RoomWidgetUpdateInfostandUserEvent.PEER: + case RoomWidgetUpdateInfostandUserEvent.BOT: + case RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT: { + const infostandEvent = (event as RoomWidgetUpdateInfostandFurniEvent); + + setInfoStandEvent(infostandEvent); + return; + } + default: + console.log(event); + return; } - }, [ isGameMode ]); + }, [ widgetHandler ]); - const onRoomWidgetRoomEngineUpdateEvent = useCallback((event: RoomWidgetRoomEngineUpdateEvent) => - { - switch(event.type) - { - case RoomWidgetRoomEngineUpdateEvent.RWREUE_NORMAL_MODE: - setGameMode(false); - break; - case RoomWidgetRoomEngineUpdateEvent.RWREUE_GAME_MODE: - setGameMode(true); - break; - } - }, []); - - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER, events, onRoomWidgetRoomObjectUpdateEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT, events, onRoomWidgetRoomObjectUpdateEvent); - - CreateEventDispatcherHook(RoomWidgetRoomEngineUpdateEvent.RWREUE_NORMAL_MODE, events, onRoomWidgetRoomEngineUpdateEvent); - CreateEventDispatcherHook(RoomWidgetRoomEngineUpdateEvent.RWREUE_GAME_MODE, events, onRoomWidgetRoomEngineUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomEngineUpdateEvent.NORMAL_MODE, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomEngineUpdateEvent.GAME_MODE, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_ADDED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetObjectNameEvent.TYPE, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateEvent); return ( <> - { names && (names.length > 0) && names.map((data, index) => - { - return - }) } + { name && } ) } diff --git a/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.tsx b/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.tsx index 7c6830e9..9a968995 100644 --- a/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.tsx +++ b/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.tsx @@ -4,13 +4,12 @@ import { AvatarInfoWidgetNameViewProps } from './AvatarInfoWidgetNameView.types' export const AvatarInfoWidgetNameView: FC = props => { - const { nameData = null } = props; - const { objectId = -1, category = -1, id = -1, name = '', type = '' } = nameData; + const { event = null } = props; return ( - +
- { name } + { event.name }
); diff --git a/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.types.ts b/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.types.ts index 7a5bea98..aa506777 100644 --- a/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.types.ts +++ b/src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.types.ts @@ -1,6 +1,6 @@ -import { RoomObjectNameData } from '../../../../../../api'; +import { RoomWidgetObjectNameEvent } from '../../../../events'; export interface AvatarInfoWidgetNameViewProps { - nameData: RoomObjectNameData; + event: RoomWidgetObjectNameEvent; } diff --git a/src/views/room/widgets/camera/CameraWidgetView.tsx b/src/views/room/widgets/camera/CameraWidgetView.tsx index 4068a542..5133fa5e 100644 --- a/src/views/room/widgets/camera/CameraWidgetView.tsx +++ b/src/views/room/widgets/camera/CameraWidgetView.tsx @@ -4,12 +4,14 @@ import { GetRoomCameraWidgetManager } from '../../../../api'; import { RoomWidgetCameraEvent } from '../../../../events/room-widgets/camera/RoomWidgetCameraEvent'; import { useCameraEvent } from '../../../../hooks/events/nitro/camera/camera-event'; import { useUiEvent } from '../../../../hooks/events/ui/ui-event'; +import { useRoomContext } from '../../context/RoomContext'; import { CameraWidgetViewProps } from './CameraWidgetView.types'; import { CameraWidgetCaptureView } from './views/capture/CameraWidgetCaptureView'; import { CameraWidgetEditorView } from './views/editor/CameraWidgetEditorView'; export const CameraWidgetView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ effectsReady, setEffectsReady ] = useState(false); const [ isCaptureVisible, setIsCaptureVisible ] = useState(false); const [ isEditorVisible, setIsEditorVisible ] = useState(false); diff --git a/src/views/room/widgets/camera/CameraWidgetView.types.ts b/src/views/room/widgets/camera/CameraWidgetView.types.ts index e97e9b69..dc1096c2 100644 --- a/src/views/room/widgets/camera/CameraWidgetView.types.ts +++ b/src/views/room/widgets/camera/CameraWidgetView.types.ts @@ -1,2 +1,4 @@ -export interface CameraWidgetViewProps +import { RoomWidgetProps } from '../RoomWidgets.types'; + +export interface CameraWidgetViewProps extends RoomWidgetProps {} diff --git a/src/views/room/widgets/chat-input/ChatInputView.tsx b/src/views/room/widgets/chat-input/ChatInputView.tsx index b26fcf3c..1f0c542b 100644 --- a/src/views/room/widgets/chat-input/ChatInputView.tsx +++ b/src/views/room/widgets/chat-input/ChatInputView.tsx @@ -4,12 +4,14 @@ import { GetRoomSession } from '../../../../api'; import { SendChatTypingMessage } from '../../../../api/nitro/session/SendChatTypingMessage'; import { GetConfiguration } from '../../../../utils/GetConfiguration'; import { LocalizeText } from '../../../../utils/LocalizeText'; +import { useRoomContext } from '../../context/RoomContext'; import { ChatInputMessageType, ChatInputViewProps } from './ChatInputView.types'; let lastContent = ''; export const ChatInputView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ chatValue, setChatValue ] = useState(''); const [ selectedUsername, setSelectedUsername ] = useState(''); const [ isTyping, setIsTyping ] = useState(false); diff --git a/src/views/room/widgets/chat-input/ChatInputView.types.ts b/src/views/room/widgets/chat-input/ChatInputView.types.ts index 4c21deb6..563b9d4f 100644 --- a/src/views/room/widgets/chat-input/ChatInputView.types.ts +++ b/src/views/room/widgets/chat-input/ChatInputView.types.ts @@ -1,4 +1,6 @@ -export interface ChatInputViewProps +import { RoomWidgetProps } from '../RoomWidgets.types'; + +export interface ChatInputViewProps extends RoomWidgetProps { } diff --git a/src/views/room/widgets/chat/ChatWidgetView.tsx b/src/views/room/widgets/chat/ChatWidgetView.tsx index 5584bbba..27ce0cc3 100644 --- a/src/views/room/widgets/chat/ChatWidgetView.tsx +++ b/src/views/room/widgets/chat/ChatWidgetView.tsx @@ -2,6 +2,7 @@ import { RoomObjectCategory, RoomSessionChatEvent } from 'nitro-renderer'; import { useCallback, useEffect, useRef, useState } from 'react'; import { GetRoomEngine, GetRoomSession } from '../../../../api'; import { useRoomSessionManagerEvent } from '../../../../hooks/events/nitro/session/room-session-manager-event'; +import { useRoomContext } from '../../context/RoomContext'; import { ChatWidgetViewProps } from './ChatWidgetView.types'; import { ChatWidgetMessageView } from './message/ChatWidgetMessageView'; import { ChatBubbleMessage } from './utils/ChatBubbleMessage'; @@ -9,7 +10,7 @@ import { GetBubbleLocation } from './utils/ChatWidgetUtilities'; export function ChatWidgetView(props: ChatWidgetViewProps): JSX.Element { - const {} = props; + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ chatMessages, setChatMessages ] = useState([]); const elementRef = useRef(); diff --git a/src/views/room/widgets/chat/ChatWidgetView.types.ts b/src/views/room/widgets/chat/ChatWidgetView.types.ts index a4efc070..8f5535be 100644 --- a/src/views/room/widgets/chat/ChatWidgetView.types.ts +++ b/src/views/room/widgets/chat/ChatWidgetView.types.ts @@ -1,4 +1,6 @@ -export interface ChatWidgetViewProps +import { RoomWidgetProps } from '../RoomWidgets.types'; + +export interface ChatWidgetViewProps extends RoomWidgetProps { } diff --git a/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx b/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx index 39e0a655..d752d8a9 100644 --- a/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx +++ b/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx @@ -1,3 +1,4 @@ +import { FC } from 'react'; import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView'; import { FurnitureEngravingLockView } from './engraving-lock/FurnitureEngravingLockView'; import { FurnitureExchangeCreditView } from './exchange-credit/FurnitureExchangeCreditView'; @@ -9,21 +10,19 @@ import { FurniturePresentView } from './present/FurniturePresentView'; import { FurnitureStickieView } from './stickie/FurnitureStickieView'; import { FurnitureTrophyView } from './trophy/FurnitureTrophyView'; -export function FurnitureWidgetsView(props: FurnitureWidgetsViewProps): JSX.Element +export const FurnitureWidgetsView: FC = props => { - const { events } = props; - return (
- - - - - - - - - + + + + + + + + +
); } diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx index cc146908..782eef32 100644 --- a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx @@ -1,72 +1,65 @@ -import { RoomEngineTriggerWidgetEvent } from 'nitro-renderer/src/nitro/room/events/RoomEngineTriggerWidgetEvent'; -import { RoomObjectVariable } from 'nitro-renderer/src/nitro/room/object/RoomObjectVariable'; import { FC, useCallback, useState } from 'react'; -import { NitroEvent } from '../../../../../../../nitro-renderer/src/core/events/NitroEvent'; -import { GetRoomEngine } from '../../../../../api/nitro/room/GetRoomEngine'; -import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; -import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { NitroCardContentView } from '../../../../../layout/card/content/NitroCardContentView'; import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCardHeaderView'; import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { LocalizeText } from '../../../../../utils/LocalizeText'; -import { RoomWidgetDimmerStateUpdateEvent } from '../../events/RoomWidgetDimmerStateUpdateEvent'; -import { RoomWidgetDimmerUpdateEvent } from '../../events/RoomWidgetDimmerUpdateEvent'; -import { RoomWidgetRoomObjectUpdateEvent } from '../../events/RoomWidgetRoomObjectUpdateEvent'; +import { useRoomContext } from '../../../context/RoomContext'; import { FurnitureDimmerData } from './FurnitureDimmerData'; import { FurnitureDimmerViewProps } from './FurnitureDimmerView.types'; export const FurnitureDimmerView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ dimmerData, setDimmerData ] = useState(null); - const onNitroEvent = useCallback((event: NitroEvent) => - { - switch(event.type) - { - case RoomEngineTriggerWidgetEvent.REQUEST_DIMMER: { - const widgetEvent = (event as RoomEngineTriggerWidgetEvent); + // const onNitroEvent = useCallback((event: NitroEvent) => + // { + // switch(event.type) + // { + // case RoomEngineTriggerWidgetEvent.REQUEST_DIMMER: { + // const widgetEvent = (event as RoomEngineTriggerWidgetEvent); - const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category); + // const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category); - if(!roomObject) return; + // if(!roomObject) return; - const data = roomObject.model.getValue(RoomObjectVariable.FURNITURE_DATA); + // const data = roomObject.model.getValue(RoomObjectVariable.FURNITURE_DATA); - console.log('data', data); + // console.log('data', data); - setDimmerData(new FurnitureDimmerData(widgetEvent.objectId, widgetEvent.category, false)); - return; - } - case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: { - const widgetEvent = (event as RoomWidgetRoomObjectUpdateEvent); + // setDimmerData(new FurnitureDimmerData(widgetEvent.objectId, widgetEvent.category, false)); + // return; + // } + // case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: { + // const widgetEvent = (event as RoomWidgetRoomObjectUpdateEvent); - setDimmerData(prevState => - { - if(!prevState || (widgetEvent.id !== prevState.objectId) || (widgetEvent.category !== prevState.category)) return prevState; + // setDimmerData(prevState => + // { + // if(!prevState || (widgetEvent.id !== prevState.objectId) || (widgetEvent.category !== prevState.category)) return prevState; - return null; - }); - return; - } - case RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS: { - const widgetEvent = (event as RoomWidgetDimmerUpdateEvent); + // return null; + // }); + // return; + // } + // case RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS: { + // const widgetEvent = (event as RoomWidgetDimmerUpdateEvent); - console.log(widgetEvent); - return; - } - case RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE: { - const widgetEvent = (event as RoomWidgetDimmerStateUpdateEvent); + // console.log(widgetEvent); + // return; + // } + // case RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE: { + // const widgetEvent = (event as RoomWidgetDimmerStateUpdateEvent); - console.log(widgetEvent); - return; - } - } - }, []); + // console.log(widgetEvent); + // return; + // } + // } + // }, []); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS, props.events, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE, props.events, onNitroEvent); + // useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onNitroEvent); + // CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + // CreateEventDispatcherHook(RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS, props.events, onNitroEvent); + // CreateEventDispatcherHook(RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE, props.events, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx b/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx index 1a991a3b..df2662ed 100644 --- a/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx +++ b/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx @@ -11,12 +11,14 @@ import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCard import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { LocalizeText } from '../../../../../utils/LocalizeText'; import { AvatarImageView } from '../../../../avatar-image/AvatarImageView'; -import { RoomWidgetRoomObjectUpdateEvent } from '../../events/RoomWidgetRoomObjectUpdateEvent'; +import { useRoomContext } from '../../../context/RoomContext'; +import { RoomWidgetRoomObjectUpdateEvent } from '../../../events'; import { FurnitureEngravingLockData } from './FurnitureEngravingLockData'; import { FurnitureEngravingLockViewProps } from './FurnitureEngravingLockView.types'; export const FurnitureEngravingLockView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ engravingLockData, setEngravingLockData ] = useState(null); const [ engravingStage, setEngravingStage ] = useState(0); @@ -57,7 +59,7 @@ export const FurnitureEngravingLockView: FC = p }; useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); const onLoveLockFurniStartEvent = useCallback((event: LoveLockFurniStartEvent) => { @@ -70,16 +72,9 @@ export const FurnitureEngravingLockView: FC = p else setEngravingStage(2); - }, [ engravingStage ]); - - const onLoveLockDoneEvent = useCallback((event: LoveLockFurniFinishedEvent | LoveLockFurniFriendConfirmedEvent) => - { - processAction('close_request'); }, []); CreateMessageHook(LoveLockFurniStartEvent, onLoveLockFurniStartEvent); - CreateMessageHook(LoveLockFurniFinishedEvent, onLoveLockDoneEvent); - CreateMessageHook(LoveLockFurniFriendConfirmedEvent, onLoveLockDoneEvent); const processAction = useCallback((type: string, value: string = null) => { @@ -102,6 +97,14 @@ export const FurnitureEngravingLockView: FC = p } }, [ engravingLockData ]); + const onLoveLockDoneEvent = useCallback((event: LoveLockFurniFinishedEvent | LoveLockFurniFriendConfirmedEvent) => + { + processAction('close_request'); + }, [ processAction ]); + + CreateMessageHook(LoveLockFurniFinishedEvent, onLoveLockDoneEvent); + CreateMessageHook(LoveLockFurniFriendConfirmedEvent, onLoveLockDoneEvent); + return ( <> { engravingStage > 0 && diff --git a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx index 2055134e..c883f689 100644 --- a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx +++ b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx @@ -6,12 +6,14 @@ import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room- import { NitroCardContentView, NitroCardHeaderView } from '../../../../../layout'; import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { LocalizeText } from '../../../../../utils/LocalizeText'; -import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; +import { useRoomContext } from '../../../context/RoomContext'; +import { RoomWidgetRoomObjectUpdateEvent } from '../../../events'; import { FurnitureExchangeCreditData } from './FurnitureExchangeCreditData'; import { FurnitureExchangeCreditProps } from './FurnitureExchangeCreditView.types'; export const FurnitureExchangeCreditView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ exchangeCreditData, setExchangeCreditData ] = useState(null); const onNitroEvent = useCallback((event: NitroEvent) => @@ -45,7 +47,7 @@ export const FurnitureExchangeCreditView: FC = pro }, []); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx b/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx index 222d39a4..c8e715c0 100644 --- a/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx +++ b/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx @@ -1,10 +1,13 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent } from 'nitro-renderer'; import { FC } from 'react'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; +import { useRoomContext } from '../../../context/RoomContext'; import { FurnitureHighScoreViewProps } from './FurnitureHighScoreView.types'; export const FurnitureHighScoreView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const onNitroEvent = (event: NitroEvent) => { console.log(event); diff --git a/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx b/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx index 1b1d447a..cee946ec 100644 --- a/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx +++ b/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx @@ -2,13 +2,14 @@ import { RoomObjectOperationType } from 'nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { ProcessRoomObjectOperation } from '../../../../../api'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; -import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; +import { useRoomContext } from '../../../context/RoomContext'; +import { RoomWidgetRoomObjectUpdateEvent } from '../../../events'; import { ObjectLocationView } from '../../object-location/ObjectLocationView'; import { FurnitureManipulationMenuViewProps } from './FurnitureManipulationMenuView.types'; export const FurnitureManipulationMenuView: FC = props => { - const { events = null } = props; + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ isVisible, setIsVisible ] = useState(false); const [ objectId, setObjectId ] = useState(-1); const [ objectType, setObjectType ] = useState(-1); @@ -27,7 +28,6 @@ export const FurnitureManipulationMenuView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const parts = [ AvatarFigurePartType.CHEST_ACCESSORY, AvatarFigurePartType.COAT_CHEST, @@ -77,7 +80,7 @@ export const FurnitureMannequinView: FC = props => }, []); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); const loadMannequinFigure = useCallback((figureContainer: IAvatarFigureContainer) => { diff --git a/src/views/room/widgets/furniture/present/FurniturePresentView.tsx b/src/views/room/widgets/furniture/present/FurniturePresentView.tsx index 97714245..7e5fedfc 100644 --- a/src/views/room/widgets/furniture/present/FurniturePresentView.tsx +++ b/src/views/room/widgets/furniture/present/FurniturePresentView.tsx @@ -1,10 +1,13 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent } from 'nitro-renderer'; import { FC } from 'react'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; +import { useRoomContext } from '../../../context/RoomContext'; import { FurniturePresentViewProps } from './FurniturePresentView.types'; export const FurniturePresentView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const onNitroEvent = (event: NitroEvent) => { console.log(event); diff --git a/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx b/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx index cdac016d..bce1339c 100644 --- a/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx +++ b/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx @@ -5,13 +5,15 @@ import { DraggableWindow } from '../../../../../hooks/draggable-window/Draggable import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { ColorUtils } from '../../../../../utils/ColorUtils'; -import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; +import { useRoomContext } from '../../../context/RoomContext'; +import { RoomWidgetRoomObjectUpdateEvent } from '../../../events'; import { FurnitureStickieData } from './FurnitureStickieData'; import { getStickieColorName, STICKIE_COLORS } from './FurnitureStickieUtils'; import { FurnitureStickieViewProps } from './FurnitureStickieView.types'; export const FurnitureStickieView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ stickieData, setStickieData ] = useState(null); const onNitroEvent = useCallback((event: NitroEvent) => @@ -60,7 +62,7 @@ export const FurnitureStickieView: FC = props => }, []); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx b/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx index 95446b44..737e854f 100644 --- a/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx +++ b/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx @@ -5,12 +5,14 @@ import { DraggableWindow } from '../../../../../hooks/draggable-window/Draggable import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { LocalizeText } from '../../../../../utils/LocalizeText'; -import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; +import { useRoomContext } from '../../../context/RoomContext'; +import { RoomWidgetRoomObjectUpdateEvent } from '../../../events'; import { FurnitureTrophyData } from './FurnitureTrophyData'; import { FurnitureTrophyViewProps } from './FurnitureTrophyView.types'; export const FurnitureTrophyView: FC = props => { + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ trophyData, setTrophyData ] = useState(null); const onNitroEvent = useCallback((event: NitroEvent) => @@ -55,7 +57,7 @@ export const FurnitureTrophyView: FC = props => }, []); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, widgetHandler.eventDispatcher, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.scss b/src/views/room/widgets/infostand/InfoStandWidgetView.scss index f22f5907..10aa49d4 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.scss +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.scss @@ -7,10 +7,11 @@ .nitro-infostand { position: relative; - min-width: 200px; - max-width: 200px; + min-width: 170px; + max-width: 170px; z-index: $infostand-zindex; pointer-events: auto; + box-shadow: inset 0 2px 0 rgba($white, .15), 0 1px 1px rgba($black, .1); .avatar-image { position: relative; diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx index e76d6341..6234eceb 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx @@ -1,9 +1,8 @@ -import { RoomSessionUserBadgesEvent } from 'nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { FurnitureInfoData, GetObjectInfo, RentableBotInfoData, UserInfoData } from '../../../../api'; import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; -import { useRoomSessionManagerEvent } from '../../../../hooks/events/nitro/session/room-session-manager-event'; -import { RoomWidgetRoomObjectUpdateEvent } from '../events'; +import { useRoomContext } from '../../context/RoomContext'; +import { RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../../events'; +import { RoomWidgetRoomObjectMessage } from '../../messages'; import { InfoStandWidgetViewProps } from './InfoStandWidgetView.types'; import { InfoStandWidgetBotView } from './views/bot/InfoStandWidgetBotView'; import { InfoStandWidgetFurniView } from './views/furni/InfoStandWidgetFurniView'; @@ -12,98 +11,108 @@ import { InfoStandWidgetUserView } from './views/user/InfoStandWidgetUserView'; export const InfoStandWidgetView: FC = props => { - const { events = null } = props; - const [ objectInfo, setObjectInfo ] = useState(null); + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const [ infoStandEvent, setInfoStandEvent ] = useState(null); const closeInfostand = useCallback(() => { - setObjectInfo(null); + setInfoStandEvent(null); }, []); - const objectSelectedHandler = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => + const onRoomWidgetUpdateEvent = useCallback((event: RoomWidgetUpdateEvent) => { - const objectInfo = GetObjectInfo(event.roomId, event.id, event.category); - - if(!objectInfo) return; - - setObjectInfo(objectInfo); - }, []); - - const objectDeselectedHandler = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => - { - closeInfostand(); - }, [ closeInfostand ]); - - const objectRemovedHandler = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => - { - if(!objectInfo) return; - - let remove = false; - switch(event.type) { + case RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED: { + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); + + widgetHandler.processWidgetMessage(new RoomWidgetRoomObjectMessage(RoomWidgetRoomObjectMessage.GET_OBJECT_INFO, roomObjectEvent.id, roomObjectEvent.category)); + return; + } + case RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED: { + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); + + closeInfostand(); + return; + } case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: - if(objectInfo instanceof FurnitureInfoData) - { - if(objectInfo.id === event.id) remove = true; - } - break; - case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED: - if(objectInfo instanceof UserInfoData) - { - if(objectInfo.userRoomId === event.id) remove = true; - } + case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED: { + const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent); - else if(objectInfo instanceof RentableBotInfoData) - { - if(objectInfo.userRoomId === event.id) remove = true; - } - break; + setInfoStandEvent(prevValue => + { + switch(event.type) + { + case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: + if(prevValue instanceof RoomWidgetUpdateInfostandFurniEvent) + { + if(prevValue.id === roomObjectEvent.id) return null; + } + break; + case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED: + if(prevValue instanceof RoomWidgetUpdateInfostandUserEvent || prevValue instanceof RoomWidgetUpdateInfostandRentableBotEvent) + { + if(prevValue.webID === roomObjectEvent.id) return null; + } + + else if(prevValue instanceof RoomWidgetUpdateInfostandPetEvent) + { + // room index + } + break; + } + + return prevValue; + }); + return; + } + case RoomWidgetUpdateInfostandFurniEvent.FURNI: + case RoomWidgetUpdateInfostandUserEvent.OWN_USER: + case RoomWidgetUpdateInfostandUserEvent.PEER: + case RoomWidgetUpdateInfostandUserEvent.BOT: + case RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT: { + const infostandEvent = (event as RoomWidgetUpdateInfostandFurniEvent); + + setInfoStandEvent(infostandEvent); + return; + } + default: + console.log(event); + return; } + }, [ widgetHandler, closeInfostand ]); - if(remove) closeInfostand(); - }, [ objectInfo, closeInfostand ]); - - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, events, objectSelectedHandler); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, events, objectDeselectedHandler); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, events, objectRemovedHandler); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, events, objectRemovedHandler); - - const onRoomSessionUserBadgesEvent = useCallback((event: RoomSessionUserBadgesEvent) => - { - console.log(event); - }, []); - - useRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, onRoomSessionUserBadgesEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateEvent); + CreateEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateEvent); const getInfostandView = useCallback(() => { - if(objectInfo instanceof FurnitureInfoData) - { - return ; - } + if(!infoStandEvent) return null; - else if(objectInfo instanceof UserInfoData) + switch(infoStandEvent.type) { - switch(objectInfo.type) - { - case UserInfoData.OWN_USER: - case UserInfoData.PEER: - return ; - case UserInfoData.BOT: - return ; - } - } - - else if(objectInfo instanceof RentableBotInfoData) - { - return ; + case RoomWidgetUpdateInfostandFurniEvent.FURNI: + return ; + case RoomWidgetUpdateInfostandUserEvent.OWN_USER: + case RoomWidgetUpdateInfostandUserEvent.PEER: + return ; + case RoomWidgetUpdateInfostandUserEvent.BOT: + return ; + case RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT: + return ; } return null; - }, [ objectInfo, closeInfostand ]); + }, [ infoStandEvent, closeInfostand ]); - if(!objectInfo) return null; + if(!infoStandEvent) return null; return (
diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx index 604ab2d6..435d5472 100644 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx +++ b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx @@ -3,7 +3,7 @@ import { InfoStandWidgetBotViewProps } from './InfoStandWidgetBotView.types'; export const InfoStandWidgetBotView: FC = props => { - const { botInfoData = null } = props; + const { botData = null, close = null } = props; return null; } diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts index 81dacad3..2718a25a 100644 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts +++ b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts @@ -1,7 +1,7 @@ -import { UserInfoData } from '../../../../../../api'; +import { RoomWidgetUpdateInfostandUserEvent } from '../../../../events'; export interface InfoStandWidgetBotViewProps { - botInfoData: UserInfoData; + botData: RoomWidgetUpdateInfostandUserEvent; close: () => void; } diff --git a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx b/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx index 6d85eabf..fa025081 100644 --- a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx +++ b/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx @@ -1,8 +1,6 @@ import { CrackableDataType, RoomControllerLevel, RoomWidgetEnumItemExtradataParameter, RoomWidgetFurniInfoUsagePolicyEnum, StringDataType } from 'nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { FurniAction, ProcessFurniAction } from '../../../../../../api'; -import { NitroCardContentView, NitroCardView } from '../../../../../../layout'; -import { NitroCardSimpleHeaderView } from '../../../../../../layout/card/simple-header'; import { LocalizeText } from '../../../../../../utils/LocalizeText'; import { BadgeImageView } from '../../../../../badge-image/BadgeImageView'; import { LimitedEditionCompactPlateView } from '../../../../../limited-edition/compact-plate/LimitedEditionCompactPlateView'; @@ -14,7 +12,7 @@ const PICKUP_MODE_FULL: number = 2; export const InfoStandWidgetFurniView: FC = props => { - const { furnitureInfoData = null, close = null } = props; + const { furniData = null, close = null } = props; const [ pickupMode, setPickupMode ] = useState(0); const [ canMove, setCanMove ] = useState(false); const [ canRotate, setCanRotate ] = useState(false); @@ -27,25 +25,25 @@ export const InfoStandWidgetFurniView: FC = props useEffect(() => { - const isValidController = (furnitureInfoData.roomControllerLevel >= RoomControllerLevel.GUEST); + const isValidController = (furniData.roomControllerLevel >= RoomControllerLevel.GUEST); let godMode = false; - if(isValidController || furnitureInfoData.isOwner || furnitureInfoData.isRoomOwner || furnitureInfoData.isAnyRoomController) + if(isValidController || furniData.isOwner || furniData.isRoomOwner || furniData.isAnyRoomController) { setCanMove(true); - setCanRotate(!furnitureInfoData.isWallItem); + setCanRotate(!furniData.isWallItem); - if(furnitureInfoData.roomControllerLevel >= RoomControllerLevel.MODERATOR) godMode = true; + if(furniData.roomControllerLevel >= RoomControllerLevel.MODERATOR) godMode = true; } - if((((furnitureInfoData.usagePolicy === RoomWidgetFurniInfoUsagePolicyEnum._Str_18353) || ((furnitureInfoData.usagePolicy === RoomWidgetFurniInfoUsagePolicyEnum._Str_18194) && isValidController)) || ((furnitureInfoData.extraParam === RoomWidgetEnumItemExtradataParameter.JUKEBOX) && isValidController)) || ((furnitureInfoData.extraParam === RoomWidgetEnumItemExtradataParameter.USABLE_PRODUCT) && isValidController)) setCanUse(true); + if((((furniData.usagePolicy === RoomWidgetFurniInfoUsagePolicyEnum._Str_18353) || ((furniData.usagePolicy === RoomWidgetFurniInfoUsagePolicyEnum._Str_18194) && isValidController)) || ((furniData.extraParam === RoomWidgetEnumItemExtradataParameter.JUKEBOX) && isValidController)) || ((furniData.extraParam === RoomWidgetEnumItemExtradataParameter.USABLE_PRODUCT) && isValidController)) setCanUse(true); - if(furnitureInfoData.extraParam) + if(furniData.extraParam) { - if(furnitureInfoData.extraParam === RoomWidgetEnumItemExtradataParameter.CRACKABLE_FURNI) + if(furniData.extraParam === RoomWidgetEnumItemExtradataParameter.CRACKABLE_FURNI) { - const stuffData = (furnitureInfoData.stuffData as CrackableDataType); + const stuffData = (furniData.stuffData as CrackableDataType); setCanUse(true); setIsCrackable(true); @@ -55,7 +53,7 @@ export const InfoStandWidgetFurniView: FC = props if(godMode) { - const extraParam = furnitureInfoData.extraParam.substr(RoomWidgetEnumItemExtradataParameter.BRANDING_OPTIONS.length); + const extraParam = furniData.extraParam.substr(RoomWidgetEnumItemExtradataParameter.BRANDING_OPTIONS.length); if(extraParam) { @@ -83,18 +81,18 @@ export const InfoStandWidgetFurniView: FC = props setPickupMode(PICKUP_MODE_NONE); - if(furnitureInfoData.isOwner || furnitureInfoData.isAnyRoomController) + if(furniData.isOwner || furniData.isAnyRoomController) { setPickupMode(PICKUP_MODE_FULL); } - else if(furnitureInfoData.isRoomOwner || (furnitureInfoData.roomControllerLevel >= RoomControllerLevel.GUILD_ADMIN)) + else if(furniData.isRoomOwner || (furniData.roomControllerLevel >= RoomControllerLevel.GUILD_ADMIN)) { setPickupMode(PICKUP_MODE_EJECT); } - else if(furnitureInfoData.isStickie) setPickupMode(PICKUP_MODE_NONE); - }, [ furnitureInfoData ]); + else if(furniData.isStickie) setPickupMode(PICKUP_MODE_NONE); + }, [ furniData ]); const openFurniGroupInfo = useCallback(() => { @@ -131,30 +129,33 @@ export const InfoStandWidgetFurniView: FC = props if(!messageType) return; - ProcessFurniAction(messageType, furnitureInfoData.id, furnitureInfoData.category, furnitureInfoData.purchaseOfferId, objectData); - }, [ furnitureInfoData, pickupMode ]); + ProcessFurniAction(messageType, furniData.id, furniData.category, furniData.purchaseOfferId, objectData); + }, [ furniData, pickupMode ]); - if(!furnitureInfoData) return null; + if(!furniData) return null; return ( <> - - - +
+
+
+
{ furniData.name }
+ +
- { furnitureInfoData.stuffData.isUnique && - } - { furnitureInfoData.image.src.length && - } + { furniData.stuffData.isUnique && + } + { furniData.image.src.length && + }
-

{ furnitureInfoData.description }

-

{ LocalizeText('furni.owner', [ 'name' ], [ furnitureInfoData.ownerName ]) }

+

{ furniData.description }

+

{ LocalizeText('furni.owner', [ 'name' ], [ furniData.ownerName ]) }

{ isCrackable &&

{ LocalizeText('infostand.crackable_furni.hits_remaining', ['hits', 'target'], [ crackableHits.toString(), crackableTarget.toString() ]) }

} - { (furnitureInfoData.groupId > 0) && + { (furniData.groupId > 0) &&
- +
}
{/*
@@ -163,17 +164,17 @@ export const InfoStandWidgetFurniView: FC = props
*/} - - -
+
+
+
{ canMove && - } + } { canRotate && - } + } { (pickupMode !== PICKUP_MODE_NONE) && - } + } { canUse && - } + } {/* */}
diff --git a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts b/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts index 85f8dc8a..1c07d7d8 100644 --- a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts +++ b/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts @@ -1,7 +1,7 @@ -import { FurnitureInfoData } from '../../../../../../api'; +import { RoomWidgetUpdateInfostandFurniEvent } from '../../../../events'; export interface InfoStandWidgetFurniViewProps { - furnitureInfoData: FurnitureInfoData; + furniData: RoomWidgetUpdateInfostandFurniEvent; 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 index cdc43f6e..6540969c 100644 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx +++ b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx @@ -3,7 +3,7 @@ import { InfoStandWidgetRentableBotViewProps } from './InfoStandWidgetRentableBo export const InfoStandWidgetRentableBotView: FC = props => { - const { rentableBotInfoData = null, close = null } = props; + const { rentableBotData = null, close = null } = props; return null; } 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 index 09850215..26a73091 100644 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts +++ b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts @@ -1,7 +1,7 @@ -import { RentableBotInfoData } from '../../../../../../api'; +import { RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../events'; export interface InfoStandWidgetRentableBotViewProps { - rentableBotInfoData: RentableBotInfoData; + 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 index 5cd4c3bd..018b1c3e 100644 --- a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx +++ b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx @@ -3,7 +3,7 @@ import { InfoStandWidgetUserViewProps } from './InfoStandWidgetUserView.types'; export const InfoStandWidgetUserView: FC = props => { - const { userInfoData = null, close = null } = props; + const { userData = null, close = null } = props; return null; } diff --git a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts index 5a181589..3784f4e4 100644 --- a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts +++ b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts @@ -1,7 +1,7 @@ -import { UserInfoData } from '../../../../../../api'; +import { RoomWidgetUpdateInfostandUserEvent } from '../../../../events'; export interface InfoStandWidgetUserViewProps { - userInfoData: UserInfoData; + userData: RoomWidgetUpdateInfostandUserEvent; close: () => void; } diff --git a/src/views/room/widgets/object-location/ObjectLocationView.scss b/src/views/room/widgets/object-location/ObjectLocationView.scss new file mode 100644 index 00000000..ab82f870 --- /dev/null +++ b/src/views/room/widgets/object-location/ObjectLocationView.scss @@ -0,0 +1,2 @@ +.object-location { +} diff --git a/src/views/room/widgets/object-location/ObjectLocationView.tsx b/src/views/room/widgets/object-location/ObjectLocationView.tsx index 8fd41a41..c5f2b142 100644 --- a/src/views/room/widgets/object-location/ObjectLocationView.tsx +++ b/src/views/room/widgets/object-location/ObjectLocationView.tsx @@ -9,18 +9,25 @@ export const ObjectLocationView: FC = props => const [ pos, setPos ] = useState<{ x: number, y: number }>({ x: -1, y: -1}); const elementRef = useRef(); - const updatePosition = useCallback(() => + const getObjectLocation = useCallback(() => { const roomSession = GetRoomSession(); const objectBounds = GetRoomEngine().getRoomObjectBoundingRectangle(roomSession.roomId, objectId, category, 1); - if(!objectBounds || !elementRef.current) return; + return objectBounds; + }, [ objectId, category ]); + + const updatePosition = useCallback(() => + { + const bounds = getObjectLocation(); + + if(!bounds || !elementRef.current) return; setPos({ - x: Math.round(((objectBounds.left + (objectBounds.width / 2)) - (elementRef.current.offsetWidth / 2))), - y: Math.round((objectBounds.top - elementRef.current.offsetHeight) + 10) + x: Math.round(((bounds.left + (bounds.width / 2)) - (elementRef.current.offsetWidth / 2))), + y: Math.round((bounds.top - elementRef.current.offsetHeight) + 10) }); - }, [ objectId, category ]); + }, [ getObjectLocation ]); useEffect(() => { @@ -33,7 +40,7 @@ export const ObjectLocationView: FC = props => }, [ updatePosition ]); return ( -
-1 ? 'visible' : 'invisible') } style={ { left: pos.x, top: pos.y } }> +
-1 ? 'visible' : 'invisible') } style={ { left: pos.x, top: pos.y } }> { children }
); diff --git a/src/views/toolbar/ToolbarView.tsx b/src/views/toolbar/ToolbarView.tsx index fa8ccedb..f58c6327 100644 --- a/src/views/toolbar/ToolbarView.tsx +++ b/src/views/toolbar/ToolbarView.tsx @@ -1,12 +1,11 @@ import { UserInfoEvent } from 'nitro-renderer/src/nitro/communication/messages/incoming/user/data/UserInfoEvent'; import { UserInfoDataParser } from 'nitro-renderer/src/nitro/communication/messages/parser/user/data/UserInfoDataParser'; import { FC, useCallback, useState } from 'react'; -import { AvatarEditorEvent, CatalogEvent, FriendListEvent, InventoryEvent, NavigatorEvent } from '../../events'; -import { RoomWidgetCameraEvent } from '../../events/room-widgets/camera/RoomWidgetCameraEvent'; +import { AvatarEditorEvent, CatalogEvent, FriendListEvent, InventoryEvent, NavigatorEvent, RoomWidgetCameraEvent } from '../../events'; import { dispatchUiEvent } from '../../hooks/events/ui/ui-event'; import { CreateMessageHook } from '../../hooks/messages/message-event'; -import { TransitionAnimation } from '../../transitions/TransitionAnimation'; -import { TransitionAnimationTypes } from '../../transitions/TransitionAnimation.types'; +import { TransitionAnimation } from '../../layout/transitions/TransitionAnimation'; +import { TransitionAnimationTypes } from '../../layout/transitions/TransitionAnimation.types'; import { AvatarImageView } from '../avatar-image/AvatarImageView'; import { ToolbarMeView } from './me/ToolbarMeView'; import { ToolbarViewItems, ToolbarViewProps } from './ToolbarView.types';