Widget updates

This commit is contained in:
Bill 2021-06-17 13:23:34 -04:00
parent 261c622ba9
commit d29a502e3f
92 changed files with 1864 additions and 1052 deletions

View File

@ -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) {}
}

View File

@ -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<number>(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;
}

View File

@ -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<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM))
{
furnitureInfoData.extraParam = model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM);
}
const dataFormat = model.getValue<number>(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<number>(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<number>(RoomObjectVariable.FURNITURE_EXPIRY_TIME);
const expiryTimestamp = model.getValue<number>(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<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
furnitureInfoData.ownerName = model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME);
furnitureInfoData.usagePolicy = model.getValue<number>(RoomObjectVariable.FURNITURE_USAGE_POLICY);
const guildId = model.getValue<number>(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;
}

View File

@ -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;
}

View File

@ -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<number>(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);
}

View File

@ -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<number>(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;
}

View File

@ -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<number>(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<number>(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));
}

View File

@ -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[] = []) {}
}

View File

@ -1,9 +0,0 @@
export class RoomObjectNameData
{
constructor(
public objectId: number,
public category: number,
public id: number,
public name: string,
public type: number) {}
}

View File

@ -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) {}
}

View File

@ -1,21 +1,11 @@
export * from './CanManipulateFurniture'; export * from './CanManipulateFurniture';
export * from './FurnitureInfoData';
export * from './GetBotInfoData';
export * from './GetFurnitureDataForProductOffer'; export * from './GetFurnitureDataForProductOffer';
export * from './GetFurnitureInfoData';
export * from './GetObjectInfo';
export * from './GetObjectName';
export * from './GetProductDataForLocalization'; export * from './GetProductDataForLocalization';
export * from './GetRentableBotInfoData';
export * from './GetRoomSession'; export * from './GetRoomSession';
export * from './GetRoomSessionManager'; export * from './GetRoomSessionManager';
export * from './GetSessionDataManager'; export * from './GetSessionDataManager';
export * from './GetUserInfoData';
export * from './IsOwnerOfFurniture'; export * from './IsOwnerOfFurniture';
export * from './ProcessFurniAction'; export * from './ProcessFurniAction';
export * from './ProcessUserAction'; export * from './ProcessUserAction';
export * from './RentableBotInfoData';
export * from './RoomObjectNameData';
export * from './SendChatTypingMessage'; export * from './SendChatTypingMessage';
export * from './StartRoomSession'; export * from './StartRoomSession';
export * from './UserInfoData';

View File

@ -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 SHOW_CAMERA: string = 'NE_SHOW_CAMERA';
public static HIDE_CAMERA: string = 'NE_HIDE_CAMERA'; public static HIDE_CAMERA: string = 'NE_HIDE_CAMERA';
public static TOGGLE_CAMERA: string = 'NE_TOGGLE_CAMERA'; public static TOGGLE_CAMERA: string = 'NE_TOGGLE_CAMERA';
constructor(type: string)
{
super(type);
}
} }

View File

@ -0,0 +1 @@
export * from './configuration-event';

View File

@ -0,0 +1 @@
export * from './configuration';

View File

@ -0,0 +1,4 @@
export * from './core';
export * from './event-dispatcher.base';
export * from './nitro';
export * from './ui';

View File

@ -0,0 +1 @@
export * from './avatar-event';

View File

@ -0,0 +1 @@
export * from './camera-event';

View File

@ -0,0 +1 @@
export * from './communication-event';

View File

@ -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';

View File

@ -0,0 +1 @@
export * from './localization-event';

View File

@ -0,0 +1 @@
export * from './room-engine-event';

View File

@ -0,0 +1,2 @@
export * from './room-session-manager-event';
export * from './session-data-manager-event';

View File

@ -0,0 +1 @@
export * from './ui-event';

View File

@ -0,0 +1 @@
export * from './message-event';

View File

@ -2,6 +2,15 @@ $nitro-card-header-height: 33px;
$nitro-card-tabs-height: 33px; $nitro-card-tabs-height: 33px;
$nitro-card-top-height: $nitro-card-header-height + $nitro-card-tabs-height; $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 { .nitro-card-responsive {
position: absolute; position: absolute;
top: 0; top: 0;
@ -10,15 +19,6 @@ $nitro-card-top-height: $nitro-card-header-height + $nitro-card-tabs-height;
height: 100%; height: 100%;
pointer-events: none; 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) { @include media-breakpoint-down(lg) {
.draggable-window { .draggable-window {

View File

@ -1,8 +1,8 @@
import { Nitro, RoomSessionEvent } from 'nitro-renderer'; import { Nitro, RoomSessionEvent } from 'nitro-renderer';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event';
import { TransitionAnimation } from '../../transitions/TransitionAnimation'; import { TransitionAnimation } from '../../layout/transitions/TransitionAnimation';
import { TransitionAnimationTypes } from '../../transitions/TransitionAnimation.types'; import { TransitionAnimationTypes } from '../../layout/transitions/TransitionAnimation.types';
import { AvatarEditorView } from '../avatar-editor/AvatarEditorView'; import { AvatarEditorView } from '../avatar-editor/AvatarEditorView';
import { CatalogView } from '../catalog/CatalogView'; import { CatalogView } from '../catalog/CatalogView';
import { FriendListView } from '../friend-list/FriendListView'; import { FriendListView } from '../friend-list/FriendListView';

View File

@ -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;
}

View File

@ -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 { 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 { SetActiveRoomId } from '../../api/nitro/room/SetActiveRoomId';
import { CanManipulateFurniture } from '../../api/nitro/session/CanManipulateFurniture';
import { GetRoomSession } from '../../api/nitro/session/GetRoomSession'; import { GetRoomSession } from '../../api/nitro/session/GetRoomSession';
import { StartRoomSession } from '../../api/nitro/session/StartRoomSession'; import { StartRoomSession } from '../../api/nitro/session/StartRoomSession';
import { useRoomEngineEvent } from '../../hooks/events/nitro/room/room-engine-event'; import { useRoomEngineEvent } from '../../hooks/events/nitro/room/room-engine-event';
import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-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 { RoomView } from '../room/RoomView';
import { RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectUpdateEvent } from '../room/widgets/events';
import { RoomHostViewProps } from './RoomHostView.types'; import { RoomHostViewProps } from './RoomHostView.types';
export const RoomHostView: FC<RoomHostViewProps> = props => export const RoomHostView: FC<RoomHostViewProps> = props =>
{ {
const [ roomSession, setRoomSession ] = useState<IRoomSession>(null); const [ roomSession, setRoomSession ] = useState<IRoomSession>(null);
const [ eventDispatcher, setEventDispatcher ] = useState<IEventDispatcher>(null);
const onRoomEngineEvent = useCallback((event: RoomEngineEvent) => const onRoomEngineEvent = useCallback((event: RoomEngineEvent) =>
{ {
@ -35,147 +29,49 @@ export const RoomHostView: FC<RoomHostViewProps> = props =>
case RoomEngineEvent.DISPOSED: case RoomEngineEvent.DISPOSED:
setRoomSession(null); setRoomSession(null);
return; 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) => useRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent);
{ useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent);
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 ]);
const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => const onRoomSessionEvent = useCallback((event: RoomSessionEvent) =>
{ {
switch(event.type) switch(event.type)
{ {
case RoomSessionEvent.CREATED: case RoomSessionEvent.CREATED:
setEventDispatcher(prevValue =>
{
if(prevValue) prevValue.removeAllListeners();
return new EventDispatcher();
});
StartRoomSession(event.session); StartRoomSession(event.session);
return; return;
case RoomSessionEvent.ENDED: case RoomSessionEvent.ENDED:
setRoomSession(null); setRoomSession(null);
setEventDispatcher(prevValue =>
{
if(prevValue) prevValue.removeAllListeners();
return null;
});
return; 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.CREATED, onRoomSessionEvent);
useRoomSessionManagerEvent(RoomSessionEvent.ENDED, 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 ( return (
<div className="nitro-room-host w-100 h-100"> <div className="nitro-room-host w-100 h-100">
<RoomErrorHandler /> <RoomView roomSession={ roomSession } />
<RoomView events={ eventDispatcher } roomSession={ roomSession } />
</div> </div>
); );
} }

View File

@ -1,34 +1,42 @@
import { Nitro, RoomGeometry, RoomVariableEnum, Vector3d } from 'nitro-renderer'; import { EventDispatcher, Nitro, RoomEngineEvent, RoomEngineObjectEvent, RoomGeometry, RoomId, RoomObjectCategory, RoomObjectOperationType, RoomVariableEnum, Vector3d } from 'nitro-renderer';
import { useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
import { CanManipulateFurniture, IsFurnitureSelectionDisabled, ProcessRoomObjectOperation } from '../../api';
import { DispatchMouseEvent } from '../../api/nitro/room/DispatchMouseEvent'; import { DispatchMouseEvent } from '../../api/nitro/room/DispatchMouseEvent';
import { WindowResizeEvent } from '../../api/nitro/room/DispatchResizeEvent'; import { WindowResizeEvent } from '../../api/nitro/room/DispatchResizeEvent';
import { DispatchTouchEvent } from '../../api/nitro/room/DispatchTouchEvent'; import { DispatchTouchEvent } from '../../api/nitro/room/DispatchTouchEvent';
import { GetRoomEngine } from '../../api/nitro/room/GetRoomEngine'; 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 { RoomViewProps } from './RoomView.types';
import { AvatarInfoWidgetView } from './widgets/avatar-info/AvatarInfoWidgetView'; import { RoomWidgetsView } from './widgets/RoomWidgetsView';
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';
export function RoomView(props: RoomViewProps): JSX.Element export const RoomView: FC<RoomViewProps> = props =>
{ {
const { roomSession = null, events = null } = props; const { roomSession = null } = props;
const [ roomCanvas, setRoomCanvas ] = useState<HTMLCanvasElement>(null); const [ roomCanvas, setRoomCanvas ] = useState<HTMLCanvasElement>(null);
const [ widgetHandler, setWidgetHandler ] = useState<IRoomWidgetHandlerManager>(null);
useEffect(() => useEffect(() =>
{ {
if(!roomSession || !events) if(!roomSession)
{ {
window.onresize = null; window.onresize = null;
setRoomCanvas(null); setRoomCanvas(null);
setWidgetHandler(null);
return; return;
} }
const widgetHandlerManager = new RoomWidgetHandlerManager(roomSession, new EventDispatcher());
widgetHandlerManager.registerHandler(new RoomWidgetInfostandHandler());
setWidgetHandler(widgetHandlerManager);
Nitro.instance.renderer.resize(window.innerWidth, window.innerHeight); Nitro.instance.renderer.resize(window.innerWidth, window.innerHeight);
const canvasId = 1; const canvasId = 1;
@ -82,24 +90,124 @@ export function RoomView(props: RoomViewProps): JSX.Element
window.onresize = event => WindowResizeEvent(roomSession.roomId, canvasId); window.onresize = event => WindowResizeEvent(roomSession.roomId, canvasId);
setRoomCanvas(canvas); 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; if(!roomSession) return null;
return ( return (
<div className="nitro-room w-100 h-100"> <RoomContextProvider value={ { roomSession, eventDispatcher: (widgetHandler && widgetHandler.eventDispatcher), widgetHandler } }>
{ roomSession && <div id="room-view" className="nitro-room-container"></div> } <div className="nitro-room w-100 h-100">
{ roomSession && events && roomCanvas && <div id="room-view" className="nitro-room-container"></div>
createPortal(props.children, document.getElementById('room-view').appendChild(roomCanvas)) && { roomCanvas && createPortal(null, document.getElementById('room-view').appendChild(roomCanvas)) }
<> { widgetHandler && <RoomWidgetsView /> }
<AvatarInfoWidgetView events={ events } /> </div>
<CameraWidgetView /> </RoomContextProvider>
<ChatWidgetView />
<ChatInputView />
<FurnitureWidgetsView events={ events } />
<InfoStandWidgetView events={ events } />
</> }
</div>
); );
} }

View File

@ -1,8 +1,7 @@
import { IEventDispatcher, IRoomSession } from 'nitro-renderer'; import { IRoomSession } from 'nitro-renderer';
import { IProps } from '../../utils/IProps'; import { IProps } from '../../utils/IProps';
export interface RoomViewProps extends IProps export interface RoomViewProps extends IProps
{ {
events: IEventDispatcher;
roomSession: IRoomSession; roomSession: IRoomSession;
} }

View File

@ -0,0 +1,15 @@
import { createContext, FC, useContext } from 'react';
import { IRoomContext, RoomContextProps } from './RoomContext.types';
const RoomContext = createContext<IRoomContext>({
roomSession: null,
eventDispatcher: null,
widgetHandler: null
});
export const RoomContextProvider: FC<RoomContextProps> = props =>
{
return <RoomContext.Provider value={ props.value }>{ props.children }</RoomContext.Provider>
}
export const useRoomContext = () => useContext(RoomContext);

View File

@ -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<IRoomContext>
{
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,4 @@
import { NitroEvent } from 'nitro-renderer';
export class RoomWidgetUpdateEvent extends NitroEvent
{}

View File

@ -0,0 +1,4 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateInfostandEvent extends RoomWidgetUpdateEvent
{}

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent';
export class RoomWidgetUpdateInfostandPetEvent extends RoomWidgetUpdateInfostandEvent
{
}

View File

@ -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[] = [];
}

View File

@ -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;
}

View File

@ -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';

View File

@ -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[];
}

View File

@ -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;
}

View File

@ -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[];
}

View File

@ -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<string, IRoomWidgetHandler[]> = new Map();
private _messageMap: Map<string, IRoomWidgetHandler[]> = 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;
}
}

View File

@ -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<number>(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<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM))
{
event.extraParam = model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM);
}
const dataFormat = model.getValue<number>(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<number>(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<number>(RoomObjectVariable.FURNITURE_EXPIRY_TIME);
const expiryTimestamp = model.getValue<number>(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<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
event.ownerName = model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME);
event.usagePolicy = model.getValue<number>(RoomObjectVariable.FURNITURE_USAGE_POLICY);
const guildId = model.getValue<number>(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<number>(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<number>(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<number>(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<number>(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
];
}
}

View File

@ -0,0 +1,5 @@
export * from './IRoomWidgetHandler';
export * from './IRoomWidgetHandlerManager';
export * from './RoomWidgetHandler';
export * from './RoomWidgetHandlerManager';
export * from './RoomWidgetInfostandHandler';

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,14 @@
export class RoomWidgetMessage
{
private _type: string;
constructor(type: string)
{
this._type = type;
}
public get type(): string
{
return this._type;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,5 @@
export * from './RoomWidgetChangeMottoMessage';
export * from './RoomWidgetFurniActionMessage';
export * from './RoomWidgetMessage';
export * from './RoomWidgetRoomObjectMessage';
export * from './RoomWidgetUserActionMessage';

View File

@ -3,3 +3,4 @@
@import './chat-input/ChatInputView'; @import './chat-input/ChatInputView';
@import './furniture/FurnitureWidgets'; @import './furniture/FurnitureWidgets';
@import './infostand/InfoStandWidgetView'; @import './infostand/InfoStandWidgetView';
@import './object-location/ObjectLocationView';

View File

@ -1,6 +1,5 @@
import { IEventDispatcher } from 'nitro-renderer'; export interface RoomWidgetViewProps
{}
export interface RoomWidgetProps export interface RoomWidgetProps
{ {}
events: IEventDispatcher;
}

View File

@ -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<RoomWidgetViewProps> = 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 (
<>
<AvatarInfoWidgetView />
<CameraWidgetView />
<ChatWidgetView />
<ChatInputView />
<FurnitureWidgetsView />
<InfoStandWidgetView />
</>
);
}

View File

@ -1,86 +1,135 @@
import { RoomObjectCategory } from 'nitro-renderer'; import { RoomObjectCategory } from 'nitro-renderer';
import { FC, useCallback, useState } from 'react'; import { FC, useCallback, useState } from 'react';
import { GetObjectName, RoomObjectNameData } from '../../../../api';
import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; 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 { AvatarInfoWidgetViewProps } from './AvatarInfoWidgetView.types';
import { AvatarInfoWidgetNameView } from './views/name/AvatarInfoWidgetNameView'; import { AvatarInfoWidgetNameView } from './views/name/AvatarInfoWidgetNameView';
export const AvatarInfoWidgetView: FC<AvatarInfoWidgetViewProps> = props => export const AvatarInfoWidgetView: FC<AvatarInfoWidgetViewProps> = props =>
{ {
const { events = null } = props; const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ names, setNames ] = useState<RoomObjectNameData[]>([]); const [ name, setName ] = useState<RoomWidgetObjectNameEvent>(null);
const [ infoStandEvent, setInfoStandEvent ] = useState<RoomWidgetUpdateInfostandEvent>(null);
const [ isGameMode, setGameMode ] = useState(false); const [ isGameMode, setGameMode ] = useState(false);
const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => const onRoomWidgetUpdateEvent = useCallback((event: RoomWidgetUpdateEvent) =>
{ {
switch(event.type) switch(event.type)
{ {
case RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER: { case RoomWidgetRoomEngineUpdateEvent.NORMAL_MODE: {
if(isGameMode) return; 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) return;
{ }
setNames(prevValue => 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; 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;
}
return value; else if(prevValue instanceof RoomWidgetUpdateInfostandPetEvent)
}); {
// room index
}
break;
}
return [ ...existing, nameData ] 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; return;
} }
case RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT: { case RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT: {
if(isGameMode) return; const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent);
setNames(prevValue => setName(null);
{
return prevValue.filter(value =>
{
if(value.objectId === event.id) return null;
return value;
});
});
return; 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) => CreateEventDispatcherHook(RoomWidgetRoomEngineUpdateEvent.NORMAL_MODE, eventDispatcher, onRoomWidgetUpdateEvent);
{ CreateEventDispatcherHook(RoomWidgetRoomEngineUpdateEvent.GAME_MODE, eventDispatcher, onRoomWidgetUpdateEvent);
switch(event.type) CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_ADDED, eventDispatcher, onRoomWidgetUpdateEvent);
{ CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent);
case RoomWidgetRoomEngineUpdateEvent.RWREUE_NORMAL_MODE: CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent);
setGameMode(false); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OVER, eventDispatcher, onRoomWidgetUpdateEvent);
break; CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_ROLL_OUT, eventDispatcher, onRoomWidgetUpdateEvent);
case RoomWidgetRoomEngineUpdateEvent.RWREUE_GAME_MODE: CreateEventDispatcherHook(RoomWidgetObjectNameEvent.TYPE, eventDispatcher, onRoomWidgetUpdateEvent);
setGameMode(true); CreateEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateEvent);
break; CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateEvent);
} CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateEvent);
}, []); CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateEvent);
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);
return ( return (
<> <>
{ names && (names.length > 0) && names.map((data, index) => { name && <AvatarInfoWidgetNameView event={ name } /> }
{
return <AvatarInfoWidgetNameView key={ index } nameData={ data } />
}) }
</> </>
) )
} }

View File

@ -4,13 +4,12 @@ import { AvatarInfoWidgetNameViewProps } from './AvatarInfoWidgetNameView.types'
export const AvatarInfoWidgetNameView: FC<AvatarInfoWidgetNameViewProps> = props => export const AvatarInfoWidgetNameView: FC<AvatarInfoWidgetNameViewProps> = props =>
{ {
const { nameData = null } = props; const { event = null } = props;
const { objectId = -1, category = -1, id = -1, name = '', type = '' } = nameData;
return ( return (
<ObjectLocationView objectId={ objectId } category={ category }> <ObjectLocationView objectId={ event.roomIndex } category={ event.category }>
<div className="d-flex justify-content-center align-items-center bg-dark border border-dark"> <div className="d-flex justify-content-center align-items-center bg-dark border border-dark">
{ name } { event.name }
</div> </div>
</ObjectLocationView> </ObjectLocationView>
); );

View File

@ -1,6 +1,6 @@
import { RoomObjectNameData } from '../../../../../../api'; import { RoomWidgetObjectNameEvent } from '../../../../events';
export interface AvatarInfoWidgetNameViewProps export interface AvatarInfoWidgetNameViewProps
{ {
nameData: RoomObjectNameData; event: RoomWidgetObjectNameEvent;
} }

View File

@ -4,12 +4,14 @@ import { GetRoomCameraWidgetManager } from '../../../../api';
import { RoomWidgetCameraEvent } from '../../../../events/room-widgets/camera/RoomWidgetCameraEvent'; import { RoomWidgetCameraEvent } from '../../../../events/room-widgets/camera/RoomWidgetCameraEvent';
import { useCameraEvent } from '../../../../hooks/events/nitro/camera/camera-event'; import { useCameraEvent } from '../../../../hooks/events/nitro/camera/camera-event';
import { useUiEvent } from '../../../../hooks/events/ui/ui-event'; import { useUiEvent } from '../../../../hooks/events/ui/ui-event';
import { useRoomContext } from '../../context/RoomContext';
import { CameraWidgetViewProps } from './CameraWidgetView.types'; import { CameraWidgetViewProps } from './CameraWidgetView.types';
import { CameraWidgetCaptureView } from './views/capture/CameraWidgetCaptureView'; import { CameraWidgetCaptureView } from './views/capture/CameraWidgetCaptureView';
import { CameraWidgetEditorView } from './views/editor/CameraWidgetEditorView'; import { CameraWidgetEditorView } from './views/editor/CameraWidgetEditorView';
export const CameraWidgetView: FC<CameraWidgetViewProps> = props => export const CameraWidgetView: FC<CameraWidgetViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ effectsReady, setEffectsReady ] = useState(false); const [ effectsReady, setEffectsReady ] = useState(false);
const [ isCaptureVisible, setIsCaptureVisible ] = useState(false); const [ isCaptureVisible, setIsCaptureVisible ] = useState(false);
const [ isEditorVisible, setIsEditorVisible ] = useState(false); const [ isEditorVisible, setIsEditorVisible ] = useState(false);

View File

@ -1,2 +1,4 @@
export interface CameraWidgetViewProps import { RoomWidgetProps } from '../RoomWidgets.types';
export interface CameraWidgetViewProps extends RoomWidgetProps
{} {}

View File

@ -4,12 +4,14 @@ import { GetRoomSession } from '../../../../api';
import { SendChatTypingMessage } from '../../../../api/nitro/session/SendChatTypingMessage'; import { SendChatTypingMessage } from '../../../../api/nitro/session/SendChatTypingMessage';
import { GetConfiguration } from '../../../../utils/GetConfiguration'; import { GetConfiguration } from '../../../../utils/GetConfiguration';
import { LocalizeText } from '../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../utils/LocalizeText';
import { useRoomContext } from '../../context/RoomContext';
import { ChatInputMessageType, ChatInputViewProps } from './ChatInputView.types'; import { ChatInputMessageType, ChatInputViewProps } from './ChatInputView.types';
let lastContent = ''; let lastContent = '';
export const ChatInputView: FC<ChatInputViewProps> = props => export const ChatInputView: FC<ChatInputViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ chatValue, setChatValue ] = useState<string>(''); const [ chatValue, setChatValue ] = useState<string>('');
const [ selectedUsername, setSelectedUsername ] = useState(''); const [ selectedUsername, setSelectedUsername ] = useState('');
const [ isTyping, setIsTyping ] = useState(false); const [ isTyping, setIsTyping ] = useState(false);

View File

@ -1,4 +1,6 @@
export interface ChatInputViewProps import { RoomWidgetProps } from '../RoomWidgets.types';
export interface ChatInputViewProps extends RoomWidgetProps
{ {
} }

View File

@ -2,6 +2,7 @@ import { RoomObjectCategory, RoomSessionChatEvent } from 'nitro-renderer';
import { useCallback, useEffect, useRef, useState } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react';
import { GetRoomEngine, GetRoomSession } from '../../../../api'; import { GetRoomEngine, GetRoomSession } from '../../../../api';
import { useRoomSessionManagerEvent } from '../../../../hooks/events/nitro/session/room-session-manager-event'; import { useRoomSessionManagerEvent } from '../../../../hooks/events/nitro/session/room-session-manager-event';
import { useRoomContext } from '../../context/RoomContext';
import { ChatWidgetViewProps } from './ChatWidgetView.types'; import { ChatWidgetViewProps } from './ChatWidgetView.types';
import { ChatWidgetMessageView } from './message/ChatWidgetMessageView'; import { ChatWidgetMessageView } from './message/ChatWidgetMessageView';
import { ChatBubbleMessage } from './utils/ChatBubbleMessage'; import { ChatBubbleMessage } from './utils/ChatBubbleMessage';
@ -9,7 +10,7 @@ import { GetBubbleLocation } from './utils/ChatWidgetUtilities';
export function ChatWidgetView(props: ChatWidgetViewProps): JSX.Element export function ChatWidgetView(props: ChatWidgetViewProps): JSX.Element
{ {
const {} = props; const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ chatMessages, setChatMessages ] = useState<ChatBubbleMessage[]>([]); const [ chatMessages, setChatMessages ] = useState<ChatBubbleMessage[]>([]);
const elementRef = useRef<HTMLDivElement>(); const elementRef = useRef<HTMLDivElement>();

View File

@ -1,4 +1,6 @@
export interface ChatWidgetViewProps import { RoomWidgetProps } from '../RoomWidgets.types';
export interface ChatWidgetViewProps extends RoomWidgetProps
{ {
} }

View File

@ -1,3 +1,4 @@
import { FC } from 'react';
import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView'; import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView';
import { FurnitureEngravingLockView } from './engraving-lock/FurnitureEngravingLockView'; import { FurnitureEngravingLockView } from './engraving-lock/FurnitureEngravingLockView';
import { FurnitureExchangeCreditView } from './exchange-credit/FurnitureExchangeCreditView'; import { FurnitureExchangeCreditView } from './exchange-credit/FurnitureExchangeCreditView';
@ -9,21 +10,19 @@ import { FurniturePresentView } from './present/FurniturePresentView';
import { FurnitureStickieView } from './stickie/FurnitureStickieView'; import { FurnitureStickieView } from './stickie/FurnitureStickieView';
import { FurnitureTrophyView } from './trophy/FurnitureTrophyView'; import { FurnitureTrophyView } from './trophy/FurnitureTrophyView';
export function FurnitureWidgetsView(props: FurnitureWidgetsViewProps): JSX.Element export const FurnitureWidgetsView: FC<FurnitureWidgetsViewProps> = props =>
{ {
const { events } = props;
return ( return (
<div className="position-absolute nitro-room-widgets t-0 l-0"> <div className="position-absolute nitro-room-widgets t-0 l-0">
<FurnitureDimmerView events={ events } /> <FurnitureDimmerView />
<FurnitureEngravingLockView events={ events } /> <FurnitureEngravingLockView />
<FurnitureExchangeCreditView events={ events } /> <FurnitureExchangeCreditView />
<FurnitureHighScoreView events={ events } /> <FurnitureHighScoreView />
<FurnitureManipulationMenuView events={ events } /> <FurnitureManipulationMenuView />
<FurnitureMannequinView events={ events } /> <FurnitureMannequinView />
<FurniturePresentView events={ events } /> <FurniturePresentView />
<FurnitureStickieView events={ events } /> <FurnitureStickieView />
<FurnitureTrophyView events={ events } /> <FurnitureTrophyView />
</div> </div>
); );
} }

View File

@ -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 { 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 { NitroCardContentView } from '../../../../../layout/card/content/NitroCardContentView';
import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCardHeaderView'; import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCardHeaderView';
import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { NitroCardView } from '../../../../../layout/card/NitroCardView';
import { LocalizeText } from '../../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../../utils/LocalizeText';
import { RoomWidgetDimmerStateUpdateEvent } from '../../events/RoomWidgetDimmerStateUpdateEvent'; import { useRoomContext } from '../../../context/RoomContext';
import { RoomWidgetDimmerUpdateEvent } from '../../events/RoomWidgetDimmerUpdateEvent';
import { RoomWidgetRoomObjectUpdateEvent } from '../../events/RoomWidgetRoomObjectUpdateEvent';
import { FurnitureDimmerData } from './FurnitureDimmerData'; import { FurnitureDimmerData } from './FurnitureDimmerData';
import { FurnitureDimmerViewProps } from './FurnitureDimmerView.types'; import { FurnitureDimmerViewProps } from './FurnitureDimmerView.types';
export const FurnitureDimmerView: FC<FurnitureDimmerViewProps> = props => export const FurnitureDimmerView: FC<FurnitureDimmerViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ dimmerData, setDimmerData ] = useState<FurnitureDimmerData>(null); const [ dimmerData, setDimmerData ] = useState<FurnitureDimmerData>(null);
const onNitroEvent = useCallback((event: NitroEvent) => // const onNitroEvent = useCallback((event: NitroEvent) =>
{ // {
switch(event.type) // switch(event.type)
{ // {
case RoomEngineTriggerWidgetEvent.REQUEST_DIMMER: { // case RoomEngineTriggerWidgetEvent.REQUEST_DIMMER: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent); // 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<string[]>(RoomObjectVariable.FURNITURE_DATA); // const data = roomObject.model.getValue<string[]>(RoomObjectVariable.FURNITURE_DATA);
console.log('data', data); // console.log('data', data);
setDimmerData(new FurnitureDimmerData(widgetEvent.objectId, widgetEvent.category, false)); // setDimmerData(new FurnitureDimmerData(widgetEvent.objectId, widgetEvent.category, false));
return; // return;
} // }
case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: { // case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: {
const widgetEvent = (event as RoomWidgetRoomObjectUpdateEvent); // const widgetEvent = (event as RoomWidgetRoomObjectUpdateEvent);
setDimmerData(prevState => // setDimmerData(prevState =>
{ // {
if(!prevState || (widgetEvent.id !== prevState.objectId) || (widgetEvent.category !== prevState.category)) return prevState; // if(!prevState || (widgetEvent.id !== prevState.objectId) || (widgetEvent.category !== prevState.category)) return prevState;
return null; // return null;
}); // });
return; // return;
} // }
case RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS: { // case RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS: {
const widgetEvent = (event as RoomWidgetDimmerUpdateEvent); // const widgetEvent = (event as RoomWidgetDimmerUpdateEvent);
console.log(widgetEvent); // console.log(widgetEvent);
return; // return;
} // }
case RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE: { // case RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE: {
const widgetEvent = (event as RoomWidgetDimmerStateUpdateEvent); // const widgetEvent = (event as RoomWidgetDimmerStateUpdateEvent);
console.log(widgetEvent); // console.log(widgetEvent);
return; // return;
} // }
} // }
}, []); // }, []);
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onNitroEvent); // useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onNitroEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); // CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent);
CreateEventDispatcherHook(RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS, props.events, onNitroEvent); // CreateEventDispatcherHook(RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS, props.events, onNitroEvent);
CreateEventDispatcherHook(RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE, props.events, onNitroEvent); // CreateEventDispatcherHook(RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE, props.events, onNitroEvent);
const processAction = useCallback((type: string, value: string = null) => const processAction = useCallback((type: string, value: string = null) =>
{ {

View File

@ -11,12 +11,14 @@ import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCard
import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { NitroCardView } from '../../../../../layout/card/NitroCardView';
import { LocalizeText } from '../../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../../utils/LocalizeText';
import { AvatarImageView } from '../../../../avatar-image/AvatarImageView'; 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 { FurnitureEngravingLockData } from './FurnitureEngravingLockData';
import { FurnitureEngravingLockViewProps } from './FurnitureEngravingLockView.types'; import { FurnitureEngravingLockViewProps } from './FurnitureEngravingLockView.types';
export const FurnitureEngravingLockView: FC<FurnitureEngravingLockViewProps> = props => export const FurnitureEngravingLockView: FC<FurnitureEngravingLockViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ engravingLockData, setEngravingLockData ] = useState<FurnitureEngravingLockData>(null); const [ engravingLockData, setEngravingLockData ] = useState<FurnitureEngravingLockData>(null);
const [ engravingStage, setEngravingStage ] = useState(0); const [ engravingStage, setEngravingStage ] = useState(0);
@ -57,7 +59,7 @@ export const FurnitureEngravingLockView: FC<FurnitureEngravingLockViewProps> = p
}; };
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onNitroEvent); 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) => const onLoveLockFurniStartEvent = useCallback((event: LoveLockFurniStartEvent) =>
{ {
@ -70,16 +72,9 @@ export const FurnitureEngravingLockView: FC<FurnitureEngravingLockViewProps> = p
else else
setEngravingStage(2); setEngravingStage(2);
}, [ engravingStage ]);
const onLoveLockDoneEvent = useCallback((event: LoveLockFurniFinishedEvent | LoveLockFurniFriendConfirmedEvent) =>
{
processAction('close_request');
}, []); }, []);
CreateMessageHook(LoveLockFurniStartEvent, onLoveLockFurniStartEvent); CreateMessageHook(LoveLockFurniStartEvent, onLoveLockFurniStartEvent);
CreateMessageHook(LoveLockFurniFinishedEvent, onLoveLockDoneEvent);
CreateMessageHook(LoveLockFurniFriendConfirmedEvent, onLoveLockDoneEvent);
const processAction = useCallback((type: string, value: string = null) => const processAction = useCallback((type: string, value: string = null) =>
{ {
@ -102,6 +97,14 @@ export const FurnitureEngravingLockView: FC<FurnitureEngravingLockViewProps> = p
} }
}, [ engravingLockData ]); }, [ engravingLockData ]);
const onLoveLockDoneEvent = useCallback((event: LoveLockFurniFinishedEvent | LoveLockFurniFriendConfirmedEvent) =>
{
processAction('close_request');
}, [ processAction ]);
CreateMessageHook(LoveLockFurniFinishedEvent, onLoveLockDoneEvent);
CreateMessageHook(LoveLockFurniFriendConfirmedEvent, onLoveLockDoneEvent);
return ( return (
<> <>
{ engravingStage > 0 && <NitroCardView className="nitro-engraving-lock"> { engravingStage > 0 && <NitroCardView className="nitro-engraving-lock">

View File

@ -6,12 +6,14 @@ import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-
import { NitroCardContentView, NitroCardHeaderView } from '../../../../../layout'; import { NitroCardContentView, NitroCardHeaderView } from '../../../../../layout';
import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { NitroCardView } from '../../../../../layout/card/NitroCardView';
import { LocalizeText } from '../../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../../utils/LocalizeText';
import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; import { useRoomContext } from '../../../context/RoomContext';
import { RoomWidgetRoomObjectUpdateEvent } from '../../../events';
import { FurnitureExchangeCreditData } from './FurnitureExchangeCreditData'; import { FurnitureExchangeCreditData } from './FurnitureExchangeCreditData';
import { FurnitureExchangeCreditProps } from './FurnitureExchangeCreditView.types'; import { FurnitureExchangeCreditProps } from './FurnitureExchangeCreditView.types';
export const FurnitureExchangeCreditView: FC<FurnitureExchangeCreditProps> = props => export const FurnitureExchangeCreditView: FC<FurnitureExchangeCreditProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ exchangeCreditData, setExchangeCreditData ] = useState<FurnitureExchangeCreditData>(null); const [ exchangeCreditData, setExchangeCreditData ] = useState<FurnitureExchangeCreditData>(null);
const onNitroEvent = useCallback((event: NitroEvent) => const onNitroEvent = useCallback((event: NitroEvent) =>
@ -45,7 +47,7 @@ export const FurnitureExchangeCreditView: FC<FurnitureExchangeCreditProps> = pro
}, []); }, []);
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, onNitroEvent); 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) => const processAction = useCallback((type: string, value: string = null) =>
{ {

View File

@ -1,10 +1,13 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent } from 'nitro-renderer'; import { NitroEvent, RoomEngineTriggerWidgetEvent } from 'nitro-renderer';
import { FC } from 'react'; import { FC } from 'react';
import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event';
import { useRoomContext } from '../../../context/RoomContext';
import { FurnitureHighScoreViewProps } from './FurnitureHighScoreView.types'; import { FurnitureHighScoreViewProps } from './FurnitureHighScoreView.types';
export const FurnitureHighScoreView: FC<FurnitureHighScoreViewProps> = props => export const FurnitureHighScoreView: FC<FurnitureHighScoreViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const onNitroEvent = (event: NitroEvent) => const onNitroEvent = (event: NitroEvent) =>
{ {
console.log(event); console.log(event);

View File

@ -2,13 +2,14 @@ import { RoomObjectOperationType } from 'nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { ProcessRoomObjectOperation } from '../../../../../api'; import { ProcessRoomObjectOperation } from '../../../../../api';
import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; 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 { ObjectLocationView } from '../../object-location/ObjectLocationView';
import { FurnitureManipulationMenuViewProps } from './FurnitureManipulationMenuView.types'; import { FurnitureManipulationMenuViewProps } from './FurnitureManipulationMenuView.types';
export const FurnitureManipulationMenuView: FC<FurnitureManipulationMenuViewProps> = props => export const FurnitureManipulationMenuView: FC<FurnitureManipulationMenuViewProps> = props =>
{ {
const { events = null } = props; const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ isVisible, setIsVisible ] = useState(false); const [ isVisible, setIsVisible ] = useState(false);
const [ objectId, setObjectId ] = useState(-1); const [ objectId, setObjectId ] = useState(-1);
const [ objectType, setObjectType ] = useState(-1); const [ objectType, setObjectType ] = useState(-1);
@ -27,7 +28,6 @@ export const FurnitureManipulationMenuView: FC<FurnitureManipulationMenuViewProp
return; return;
} }
case RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED: { case RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED: {
console.log('tru')
setIsVisible(false); setIsVisible(false);
return; return;
} }
@ -51,8 +51,8 @@ export const FurnitureManipulationMenuView: FC<FurnitureManipulationMenuViewProp
moveFurniture(); moveFurniture();
}, [ isVisible, moveFurniture ]); }, [ isVisible, moveFurniture ]);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION, events, onRoomWidgetRoomObjectUpdateEvent); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_REQUEST_MANIPULATION, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, events, onRoomWidgetRoomObjectUpdateEvent); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent);
if(!isVisible) return null; if(!isVisible) return null;

View File

@ -10,12 +10,15 @@ import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCard
import { NitroCardView } from '../../../../../layout/card/NitroCardView'; import { NitroCardView } from '../../../../../layout/card/NitroCardView';
import { LocalizeText } from '../../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../../utils/LocalizeText';
import { AvatarImageView } from '../../../../avatar-image/AvatarImageView'; import { AvatarImageView } from '../../../../avatar-image/AvatarImageView';
import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; import { useRoomContext } from '../../../context/RoomContext';
import { RoomWidgetRoomObjectUpdateEvent } from '../../../events';
import { FurnitureMannequinData } from './FurnitureMannequinData'; import { FurnitureMannequinData } from './FurnitureMannequinData';
import { FurnitureMannequinViewMode, FurnitureMannequinViewProps } from './FurnitureMannequinView.types'; import { FurnitureMannequinViewMode, FurnitureMannequinViewProps } from './FurnitureMannequinView.types';
export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props => export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const parts = [ const parts = [
AvatarFigurePartType.CHEST_ACCESSORY, AvatarFigurePartType.CHEST_ACCESSORY,
AvatarFigurePartType.COAT_CHEST, AvatarFigurePartType.COAT_CHEST,
@ -77,7 +80,7 @@ export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
}, []); }, []);
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onNitroEvent); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onNitroEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent);
const loadMannequinFigure = useCallback((figureContainer: IAvatarFigureContainer) => const loadMannequinFigure = useCallback((figureContainer: IAvatarFigureContainer) =>
{ {

View File

@ -1,10 +1,13 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent } from 'nitro-renderer'; import { NitroEvent, RoomEngineTriggerWidgetEvent } from 'nitro-renderer';
import { FC } from 'react'; import { FC } from 'react';
import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event';
import { useRoomContext } from '../../../context/RoomContext';
import { FurniturePresentViewProps } from './FurniturePresentView.types'; import { FurniturePresentViewProps } from './FurniturePresentView.types';
export const FurniturePresentView: FC<FurniturePresentViewProps> = props => export const FurniturePresentView: FC<FurniturePresentViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const onNitroEvent = (event: NitroEvent) => const onNitroEvent = (event: NitroEvent) =>
{ {
console.log(event); console.log(event);

View File

@ -5,13 +5,15 @@ import { DraggableWindow } from '../../../../../hooks/draggable-window/Draggable
import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base';
import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event';
import { ColorUtils } from '../../../../../utils/ColorUtils'; import { ColorUtils } from '../../../../../utils/ColorUtils';
import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; import { useRoomContext } from '../../../context/RoomContext';
import { RoomWidgetRoomObjectUpdateEvent } from '../../../events';
import { FurnitureStickieData } from './FurnitureStickieData'; import { FurnitureStickieData } from './FurnitureStickieData';
import { getStickieColorName, STICKIE_COLORS } from './FurnitureStickieUtils'; import { getStickieColorName, STICKIE_COLORS } from './FurnitureStickieUtils';
import { FurnitureStickieViewProps } from './FurnitureStickieView.types'; import { FurnitureStickieViewProps } from './FurnitureStickieView.types';
export const FurnitureStickieView: FC<FurnitureStickieViewProps> = props => export const FurnitureStickieView: FC<FurnitureStickieViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ stickieData, setStickieData ] = useState<FurnitureStickieData>(null); const [ stickieData, setStickieData ] = useState<FurnitureStickieData>(null);
const onNitroEvent = useCallback((event: NitroEvent) => const onNitroEvent = useCallback((event: NitroEvent) =>
@ -60,7 +62,7 @@ export const FurnitureStickieView: FC<FurnitureStickieViewProps> = props =>
}, []); }, []);
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onNitroEvent); 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) => const processAction = useCallback((type: string, value: string = null) =>
{ {

View File

@ -5,12 +5,14 @@ import { DraggableWindow } from '../../../../../hooks/draggable-window/Draggable
import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base';
import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event';
import { LocalizeText } from '../../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../../utils/LocalizeText';
import { RoomWidgetRoomObjectUpdateEvent } from '../../events'; import { useRoomContext } from '../../../context/RoomContext';
import { RoomWidgetRoomObjectUpdateEvent } from '../../../events';
import { FurnitureTrophyData } from './FurnitureTrophyData'; import { FurnitureTrophyData } from './FurnitureTrophyData';
import { FurnitureTrophyViewProps } from './FurnitureTrophyView.types'; import { FurnitureTrophyViewProps } from './FurnitureTrophyView.types';
export const FurnitureTrophyView: FC<FurnitureTrophyViewProps> = props => export const FurnitureTrophyView: FC<FurnitureTrophyViewProps> = props =>
{ {
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ trophyData, setTrophyData ] = useState<FurnitureTrophyData>(null); const [ trophyData, setTrophyData ] = useState<FurnitureTrophyData>(null);
const onNitroEvent = useCallback((event: NitroEvent) => const onNitroEvent = useCallback((event: NitroEvent) =>
@ -55,7 +57,7 @@ export const FurnitureTrophyView: FC<FurnitureTrophyViewProps> = props =>
}, []); }, []);
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onNitroEvent); 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) => const processAction = useCallback((type: string, value: string = null) =>
{ {

View File

@ -7,10 +7,11 @@
.nitro-infostand { .nitro-infostand {
position: relative; position: relative;
min-width: 200px; min-width: 170px;
max-width: 200px; max-width: 170px;
z-index: $infostand-zindex; z-index: $infostand-zindex;
pointer-events: auto; pointer-events: auto;
box-shadow: inset 0 2px 0 rgba($white, .15), 0 1px 1px rgba($black, .1);
.avatar-image { .avatar-image {
position: relative; position: relative;

View File

@ -1,9 +1,8 @@
import { RoomSessionUserBadgesEvent } from 'nitro-renderer';
import { FC, useCallback, useState } from 'react'; import { FC, useCallback, useState } from 'react';
import { FurnitureInfoData, GetObjectInfo, RentableBotInfoData, UserInfoData } from '../../../../api';
import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base';
import { useRoomSessionManagerEvent } from '../../../../hooks/events/nitro/session/room-session-manager-event'; import { useRoomContext } from '../../context/RoomContext';
import { RoomWidgetRoomObjectUpdateEvent } from '../events'; import { RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../../events';
import { RoomWidgetRoomObjectMessage } from '../../messages';
import { InfoStandWidgetViewProps } from './InfoStandWidgetView.types'; import { InfoStandWidgetViewProps } from './InfoStandWidgetView.types';
import { InfoStandWidgetBotView } from './views/bot/InfoStandWidgetBotView'; import { InfoStandWidgetBotView } from './views/bot/InfoStandWidgetBotView';
import { InfoStandWidgetFurniView } from './views/furni/InfoStandWidgetFurniView'; import { InfoStandWidgetFurniView } from './views/furni/InfoStandWidgetFurniView';
@ -12,98 +11,108 @@ import { InfoStandWidgetUserView } from './views/user/InfoStandWidgetUserView';
export const InfoStandWidgetView: FC<InfoStandWidgetViewProps> = props => export const InfoStandWidgetView: FC<InfoStandWidgetViewProps> = props =>
{ {
const { events = null } = props; const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const [ objectInfo, setObjectInfo ] = useState<FurnitureInfoData | UserInfoData | RentableBotInfoData>(null); const [ infoStandEvent, setInfoStandEvent ] = useState<RoomWidgetUpdateInfostandEvent>(null);
const closeInfostand = useCallback(() => 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) 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: case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED:
if(objectInfo instanceof FurnitureInfoData) case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED: {
{ const roomObjectEvent = (event as RoomWidgetRoomObjectUpdateEvent);
if(objectInfo.id === event.id) remove = true;
}
break;
case RoomWidgetRoomObjectUpdateEvent.USER_REMOVED:
if(objectInfo instanceof UserInfoData)
{
if(objectInfo.userRoomId === event.id) remove = true;
}
else if(objectInfo instanceof RentableBotInfoData) setInfoStandEvent(prevValue =>
{ {
if(objectInfo.userRoomId === event.id) remove = true; switch(event.type)
} {
break; 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(); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, eventDispatcher, onRoomWidgetUpdateEvent);
}, [ objectInfo, closeInfostand ]); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, events, objectSelectedHandler); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_DESELECTED, events, objectDeselectedHandler); CreateEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, events, objectRemovedHandler); CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, events, objectRemovedHandler); CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateEvent);
CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateEvent);
const onRoomSessionUserBadgesEvent = useCallback((event: RoomSessionUserBadgesEvent) => CreateEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateEvent);
{
console.log(event);
}, []);
useRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, onRoomSessionUserBadgesEvent);
const getInfostandView = useCallback(() => const getInfostandView = useCallback(() =>
{ {
if(objectInfo instanceof FurnitureInfoData) if(!infoStandEvent) return null;
{
return <InfoStandWidgetFurniView furnitureInfoData={ objectInfo } close={ closeInfostand } />;
}
else if(objectInfo instanceof UserInfoData) switch(infoStandEvent.type)
{ {
switch(objectInfo.type) case RoomWidgetUpdateInfostandFurniEvent.FURNI:
{ return <InfoStandWidgetFurniView furniData={ (infoStandEvent as RoomWidgetUpdateInfostandFurniEvent) } close={ closeInfostand } />;
case UserInfoData.OWN_USER: case RoomWidgetUpdateInfostandUserEvent.OWN_USER:
case UserInfoData.PEER: case RoomWidgetUpdateInfostandUserEvent.PEER:
return <InfoStandWidgetUserView userInfoData={ objectInfo } close={ closeInfostand } />; return <InfoStandWidgetUserView userData={ (infoStandEvent as RoomWidgetUpdateInfostandUserEvent) } close={ closeInfostand } />;
case UserInfoData.BOT: case RoomWidgetUpdateInfostandUserEvent.BOT:
return <InfoStandWidgetBotView botInfoData={ objectInfo } close={ closeInfostand } />; return <InfoStandWidgetBotView botData={ (infoStandEvent as RoomWidgetUpdateInfostandUserEvent) } close={ closeInfostand } />;
} case RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT:
} return <InfoStandWidgetRentableBotView rentableBotData={ (infoStandEvent as RoomWidgetUpdateInfostandRentableBotEvent) } close={ closeInfostand } />;
else if(objectInfo instanceof RentableBotInfoData)
{
return <InfoStandWidgetRentableBotView rentableBotInfoData={ objectInfo } close={ closeInfostand } />;
} }
return null; return null;
}, [ objectInfo, closeInfostand ]); }, [ infoStandEvent, closeInfostand ]);
if(!objectInfo) return null; if(!infoStandEvent) return null;
return ( return (
<div className="d-flex flex-column align-items-end nitro-infostand-container"> <div className="d-flex flex-column align-items-end nitro-infostand-container">

View File

@ -3,7 +3,7 @@ import { InfoStandWidgetBotViewProps } from './InfoStandWidgetBotView.types';
export const InfoStandWidgetBotView: FC<InfoStandWidgetBotViewProps> = props => export const InfoStandWidgetBotView: FC<InfoStandWidgetBotViewProps> = props =>
{ {
const { botInfoData = null } = props; const { botData = null, close = null } = props;
return null; return null;
} }

View File

@ -1,7 +1,7 @@
import { UserInfoData } from '../../../../../../api'; import { RoomWidgetUpdateInfostandUserEvent } from '../../../../events';
export interface InfoStandWidgetBotViewProps export interface InfoStandWidgetBotViewProps
{ {
botInfoData: UserInfoData; botData: RoomWidgetUpdateInfostandUserEvent;
close: () => void; close: () => void;
} }

View File

@ -1,8 +1,6 @@
import { CrackableDataType, RoomControllerLevel, RoomWidgetEnumItemExtradataParameter, RoomWidgetFurniInfoUsagePolicyEnum, StringDataType } from 'nitro-renderer'; import { CrackableDataType, RoomControllerLevel, RoomWidgetEnumItemExtradataParameter, RoomWidgetFurniInfoUsagePolicyEnum, StringDataType } from 'nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { FurniAction, ProcessFurniAction } from '../../../../../../api'; import { FurniAction, ProcessFurniAction } from '../../../../../../api';
import { NitroCardContentView, NitroCardView } from '../../../../../../layout';
import { NitroCardSimpleHeaderView } from '../../../../../../layout/card/simple-header';
import { LocalizeText } from '../../../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../../../utils/LocalizeText';
import { BadgeImageView } from '../../../../../badge-image/BadgeImageView'; import { BadgeImageView } from '../../../../../badge-image/BadgeImageView';
import { LimitedEditionCompactPlateView } from '../../../../../limited-edition/compact-plate/LimitedEditionCompactPlateView'; import { LimitedEditionCompactPlateView } from '../../../../../limited-edition/compact-plate/LimitedEditionCompactPlateView';
@ -14,7 +12,7 @@ const PICKUP_MODE_FULL: number = 2;
export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props => export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props =>
{ {
const { furnitureInfoData = null, close = null } = props; const { furniData = null, close = null } = props;
const [ pickupMode, setPickupMode ] = useState(0); const [ pickupMode, setPickupMode ] = useState(0);
const [ canMove, setCanMove ] = useState(false); const [ canMove, setCanMove ] = useState(false);
const [ canRotate, setCanRotate ] = useState(false); const [ canRotate, setCanRotate ] = useState(false);
@ -27,25 +25,25 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
useEffect(() => useEffect(() =>
{ {
const isValidController = (furnitureInfoData.roomControllerLevel >= RoomControllerLevel.GUEST); const isValidController = (furniData.roomControllerLevel >= RoomControllerLevel.GUEST);
let godMode = false; let godMode = false;
if(isValidController || furnitureInfoData.isOwner || furnitureInfoData.isRoomOwner || furnitureInfoData.isAnyRoomController) if(isValidController || furniData.isOwner || furniData.isRoomOwner || furniData.isAnyRoomController)
{ {
setCanMove(true); 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); setCanUse(true);
setIsCrackable(true); setIsCrackable(true);
@ -55,7 +53,7 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
if(godMode) if(godMode)
{ {
const extraParam = furnitureInfoData.extraParam.substr(RoomWidgetEnumItemExtradataParameter.BRANDING_OPTIONS.length); const extraParam = furniData.extraParam.substr(RoomWidgetEnumItemExtradataParameter.BRANDING_OPTIONS.length);
if(extraParam) if(extraParam)
{ {
@ -83,18 +81,18 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
setPickupMode(PICKUP_MODE_NONE); setPickupMode(PICKUP_MODE_NONE);
if(furnitureInfoData.isOwner || furnitureInfoData.isAnyRoomController) if(furniData.isOwner || furniData.isAnyRoomController)
{ {
setPickupMode(PICKUP_MODE_FULL); 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); setPickupMode(PICKUP_MODE_EJECT);
} }
else if(furnitureInfoData.isStickie) setPickupMode(PICKUP_MODE_NONE); else if(furniData.isStickie) setPickupMode(PICKUP_MODE_NONE);
}, [ furnitureInfoData ]); }, [ furniData ]);
const openFurniGroupInfo = useCallback(() => const openFurniGroupInfo = useCallback(() =>
{ {
@ -131,30 +129,33 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
if(!messageType) return; if(!messageType) return;
ProcessFurniAction(messageType, furnitureInfoData.id, furnitureInfoData.category, furnitureInfoData.purchaseOfferId, objectData); ProcessFurniAction(messageType, furniData.id, furniData.category, furniData.purchaseOfferId, objectData);
}, [ furnitureInfoData, pickupMode ]); }, [ furniData, pickupMode ]);
if(!furnitureInfoData) return null; if(!furniData) return null;
return ( return (
<> <>
<NitroCardView className="nitro-infostand" simple={ true }> <div className="d-flex flex-column bg-dark nitro-card nitro-infostand rounded">
<NitroCardSimpleHeaderView headerText={ furnitureInfoData.name } onCloseClick={ close } /> <div className="container-fluid content-area">
<NitroCardContentView> <div className="d-flex justify-content-between align-items-center">
<div className="">{ furniData.name }</div>
<i className="fas fa-times cursor-pointer" onClick={ close }></i>
</div>
<div className="w-100"> <div className="w-100">
{ furnitureInfoData.stuffData.isUnique && { furniData.stuffData.isUnique &&
<LimitedEditionCompactPlateView uniqueNumber={ furnitureInfoData.stuffData.uniqueNumber } uniqueSeries={ furnitureInfoData.stuffData.uniqueSeries } /> } <LimitedEditionCompactPlateView uniqueNumber={ furniData.stuffData.uniqueNumber } uniqueSeries={ furniData.stuffData.uniqueSeries } /> }
{ furnitureInfoData.image.src.length && { furniData.image.src.length &&
<img className="d-block mx-auto" src={ furnitureInfoData.image.src } alt="" /> } <img className="d-block mx-auto" src={ furniData.image.src } alt="" /> }
</div> </div>
<div className="d-flex flex-column mt-2"> <div className="d-flex flex-column mt-2">
<p className="badge badge-secondary mb-0 text-wrap">{ furnitureInfoData.description }</p> <p className="badge badge-secondary mb-0 text-wrap">{ furniData.description }</p>
<p className="badge badge-secondary mt-2 mb-0 text-wrap">{ LocalizeText('furni.owner', [ 'name' ], [ furnitureInfoData.ownerName ]) }</p> <p className="badge badge-secondary mt-2 mb-0 text-wrap">{ LocalizeText('furni.owner', [ 'name' ], [ furniData.ownerName ]) }</p>
{ isCrackable && { isCrackable &&
<p className="badge badge-secondary mt-2 mb-0 text-wrap">{ LocalizeText('infostand.crackable_furni.hits_remaining', ['hits', 'target'], [ crackableHits.toString(), crackableTarget.toString() ]) }</p> } <p className="badge badge-secondary mt-2 mb-0 text-wrap">{ LocalizeText('infostand.crackable_furni.hits_remaining', ['hits', 'target'], [ crackableHits.toString(), crackableTarget.toString() ]) }</p> }
{ (furnitureInfoData.groupId > 0) && { (furniData.groupId > 0) &&
<div className="badge badge-secondary mt-2 mb-0" onClick={ openFurniGroupInfo }> <div className="badge badge-secondary mt-2 mb-0" onClick={ openFurniGroupInfo }>
<BadgeImageView badgeCode={ (furnitureInfoData.stuffData as StringDataType).getValue(2) } /> <BadgeImageView badgeCode={ (furniData.stuffData as StringDataType).getValue(2) } />
</div> } </div> }
</div> </div>
{/* <div className="mt-3" *ngIf="((furniSettingsKeys.length && furniSettingsValues.length) && (furniSettingsKeys.length === furniSettingsValues.length))"> {/* <div className="mt-3" *ngIf="((furniSettingsKeys.length && furniSettingsValues.length) && (furniSettingsKeys.length === furniSettingsValues.length))">
@ -163,17 +164,17 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
<input type="text" className="form-control rounded mb-2" [(ngModel)]="furniSettingsValues[i]"> <input type="text" className="form-control rounded mb-2" [(ngModel)]="furniSettingsValues[i]">
</ng-container> </ng-container>
</div> */} </div> */}
</NitroCardContentView> </div>
</NitroCardView> </div>
<div className="button-container btn-group mt-2"> <div className="button-container mt-2">
{ canMove && { canMove &&
<button type="button" className="btn btn-dark" onClick={ event => processButtonAction('move') }>{ LocalizeText('infostand.button.move') }</button> } <button type="button" className="btn btn-sm btn-dark" onClick={ event => processButtonAction('move') }>{ LocalizeText('infostand.button.move') }</button> }
{ canRotate && { canRotate &&
<button type="button" className="btn btn-dark" onClick={ event => processButtonAction('rotate') }>{ LocalizeText('infostand.button.rotate') }</button> } <button type="button" className="btn btn-sm btn-dark ms-1" onClick={ event => processButtonAction('rotate') }>{ LocalizeText('infostand.button.rotate') }</button> }
{ (pickupMode !== PICKUP_MODE_NONE) && { (pickupMode !== PICKUP_MODE_NONE) &&
<button type="button" className="btn btn-dark" onClick={ event => processButtonAction('pickup') }>{ LocalizeText((pickupMode === PICKUP_MODE_EJECT) ? 'infostand.button.eject' : 'infostand.button.pickup') }</button> } <button type="button" className="btn btn-sm btn-dark ms-1" onClick={ event => processButtonAction('pickup') }>{ LocalizeText((pickupMode === PICKUP_MODE_EJECT) ? 'infostand.button.eject' : 'infostand.button.pickup') }</button> }
{ canUse && { canUse &&
<button type="button" className="btn btn-dark" onClick={ event => processButtonAction('use') }>{ LocalizeText('infostand.button.use') }</button> } <button type="button" className="btn btn-sm btn-dark ms-1" onClick={ event => processButtonAction('use') }>{ LocalizeText('infostand.button.use') }</button> }
{/* <button *ngIf="((furniSettingsKeys.length && furniSettingsValues.length) && (furniSettingsKeys.length === furniSettingsValues.length))" className="btn btn-primary" (click)="processButtonAction('save_branding_configuration')">{{ 'save' | translate }}</button> */} {/* <button *ngIf="((furniSettingsKeys.length && furniSettingsValues.length) && (furniSettingsKeys.length === furniSettingsValues.length))" className="btn btn-primary" (click)="processButtonAction('save_branding_configuration')">{{ 'save' | translate }}</button> */}
</div> </div>
</> </>

View File

@ -1,7 +1,7 @@
import { FurnitureInfoData } from '../../../../../../api'; import { RoomWidgetUpdateInfostandFurniEvent } from '../../../../events';
export interface InfoStandWidgetFurniViewProps export interface InfoStandWidgetFurniViewProps
{ {
furnitureInfoData: FurnitureInfoData; furniData: RoomWidgetUpdateInfostandFurniEvent;
close: () => void; close: () => void;
} }

View File

@ -3,7 +3,7 @@ import { InfoStandWidgetRentableBotViewProps } from './InfoStandWidgetRentableBo
export const InfoStandWidgetRentableBotView: FC<InfoStandWidgetRentableBotViewProps> = props => export const InfoStandWidgetRentableBotView: FC<InfoStandWidgetRentableBotViewProps> = props =>
{ {
const { rentableBotInfoData = null, close = null } = props; const { rentableBotData = null, close = null } = props;
return null; return null;
} }

View File

@ -1,7 +1,7 @@
import { RentableBotInfoData } from '../../../../../../api'; import { RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../events';
export interface InfoStandWidgetRentableBotViewProps export interface InfoStandWidgetRentableBotViewProps
{ {
rentableBotInfoData: RentableBotInfoData; rentableBotData: RoomWidgetUpdateInfostandRentableBotEvent;
close: () => void; close: () => void;
} }

View File

@ -3,7 +3,7 @@ import { InfoStandWidgetUserViewProps } from './InfoStandWidgetUserView.types';
export const InfoStandWidgetUserView: FC<InfoStandWidgetUserViewProps> = props => export const InfoStandWidgetUserView: FC<InfoStandWidgetUserViewProps> = props =>
{ {
const { userInfoData = null, close = null } = props; const { userData = null, close = null } = props;
return null; return null;
} }

View File

@ -1,7 +1,7 @@
import { UserInfoData } from '../../../../../../api'; import { RoomWidgetUpdateInfostandUserEvent } from '../../../../events';
export interface InfoStandWidgetUserViewProps export interface InfoStandWidgetUserViewProps
{ {
userInfoData: UserInfoData; userData: RoomWidgetUpdateInfostandUserEvent;
close: () => void; close: () => void;
} }

View File

@ -0,0 +1,2 @@
.object-location {
}

View File

@ -9,18 +9,25 @@ export const ObjectLocationView: FC<ObjectLocationViewProps> = props =>
const [ pos, setPos ] = useState<{ x: number, y: number }>({ x: -1, y: -1}); const [ pos, setPos ] = useState<{ x: number, y: number }>({ x: -1, y: -1});
const elementRef = useRef<HTMLDivElement>(); const elementRef = useRef<HTMLDivElement>();
const updatePosition = useCallback(() => const getObjectLocation = useCallback(() =>
{ {
const roomSession = GetRoomSession(); const roomSession = GetRoomSession();
const objectBounds = GetRoomEngine().getRoomObjectBoundingRectangle(roomSession.roomId, objectId, category, 1); 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({ setPos({
x: Math.round(((objectBounds.left + (objectBounds.width / 2)) - (elementRef.current.offsetWidth / 2))), x: Math.round(((bounds.left + (bounds.width / 2)) - (elementRef.current.offsetWidth / 2))),
y: Math.round((objectBounds.top - elementRef.current.offsetHeight) + 10) y: Math.round((bounds.top - elementRef.current.offsetHeight) + 10)
}); });
}, [ objectId, category ]); }, [ getObjectLocation ]);
useEffect(() => useEffect(() =>
{ {
@ -33,7 +40,7 @@ export const ObjectLocationView: FC<ObjectLocationViewProps> = props =>
}, [ updatePosition ]); }, [ updatePosition ]);
return ( return (
<div ref={ elementRef } className={ 'position-absolute ' + (pos.x > -1 ? 'visible' : 'invisible') } style={ { left: pos.x, top: pos.y } }> <div ref={ elementRef } className={ 'object-location position-absolute ' + (pos.x > -1 ? 'visible' : 'invisible') } style={ { left: pos.x, top: pos.y } }>
{ children } { children }
</div> </div>
); );

View File

@ -1,12 +1,11 @@
import { UserInfoEvent } from 'nitro-renderer/src/nitro/communication/messages/incoming/user/data/UserInfoEvent'; 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 { UserInfoDataParser } from 'nitro-renderer/src/nitro/communication/messages/parser/user/data/UserInfoDataParser';
import { FC, useCallback, useState } from 'react'; import { FC, useCallback, useState } from 'react';
import { AvatarEditorEvent, CatalogEvent, FriendListEvent, InventoryEvent, NavigatorEvent } from '../../events'; import { AvatarEditorEvent, CatalogEvent, FriendListEvent, InventoryEvent, NavigatorEvent, RoomWidgetCameraEvent } from '../../events';
import { RoomWidgetCameraEvent } from '../../events/room-widgets/camera/RoomWidgetCameraEvent';
import { dispatchUiEvent } from '../../hooks/events/ui/ui-event'; import { dispatchUiEvent } from '../../hooks/events/ui/ui-event';
import { CreateMessageHook } from '../../hooks/messages/message-event'; import { CreateMessageHook } from '../../hooks/messages/message-event';
import { TransitionAnimation } from '../../transitions/TransitionAnimation'; import { TransitionAnimation } from '../../layout/transitions/TransitionAnimation';
import { TransitionAnimationTypes } from '../../transitions/TransitionAnimation.types'; import { TransitionAnimationTypes } from '../../layout/transitions/TransitionAnimation.types';
import { AvatarImageView } from '../avatar-image/AvatarImageView'; import { AvatarImageView } from '../avatar-image/AvatarImageView';
import { ToolbarMeView } from './me/ToolbarMeView'; import { ToolbarMeView } from './me/ToolbarMeView';
import { ToolbarViewItems, ToolbarViewProps } from './ToolbarView.types'; import { ToolbarViewItems, ToolbarViewProps } from './ToolbarView.types';