diff --git a/package.json b/package.json index 057bdeaf..2f50499b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "eslint": "eslint src --ext .ts,.tsx" }, "dependencies": { - "@nitrots/nitro-renderer": "^1.6.6", "@tanstack/react-virtual": "^3.0.0-alpha.0", "react": "^18.2.0", "react-bootstrap": "^2.2.2", diff --git a/src/App.tsx b/src/App.tsx index 072b05dd..4d4bb9c8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,120 +1,41 @@ -import { ConfigurationEvent, GetAssetManager, HabboWebTools, LegacyExternalInterface, Nitro, NitroCommunicationDemoEvent, NitroConfiguration, NitroEvent, NitroLocalizationEvent, NitroVersion, RoomEngineEvent } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useEffect, useState } from 'react'; -import { GetCommunication, GetConfiguration, GetNitroInstance, GetUIVersion } from './api'; -import { Base, TransitionAnimation, TransitionAnimationTypes } from './common'; +import { Nitro, NitroLogger, NitroVersion } from '@nitrots/nitro-renderer'; +import { FC, useEffect, useState } from 'react'; +import { GetNitroInstance, GetUIVersion } from './api'; +import { Base } from './common'; import { LoadingView } from './components/loading/LoadingView'; import { MainView } from './components/main/MainView'; -import { useConfigurationEvent, useLocalizationEvent, useMainEvent, useRoomEngineEvent } from './hooks'; NitroVersion.UI_VERSION = GetUIVersion(); export const App: FC<{}> = props => { const [ isReady, setIsReady ] = useState(false); - const [ isError, setIsError ] = useState(false); const [ message, setMessage ] = useState('Getting Ready'); - const [ percent, setPercent ] = useState(0); const [ imageRendering, setImageRendering ] = useState(true); - if(!GetNitroInstance()) - { - //@ts-ignore - if(!NitroConfig) throw new Error('NitroConfig is not defined!'); - - Nitro.bootstrap(); - } - - const handler = useCallback(async (event: NitroEvent) => - { - switch(event.type) - { - case ConfigurationEvent.LOADED: - GetNitroInstance().localization.init(); - setPercent(prevValue => (prevValue + 20)); - return; - case ConfigurationEvent.FAILED: - setIsError(true); - setMessage('Configuration Failed'); - return; - case Nitro.WEBGL_UNAVAILABLE: - setIsError(true); - setMessage('WebGL Required'); - return; - case Nitro.WEBGL_CONTEXT_LOST: - setIsError(true); - setMessage('WebGL Context Lost - Reloading'); - - setTimeout(() => window.location.reload(), 1500); - return; - case NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING: - setPercent(prevValue => (prevValue + 20)); - return; - case NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED: - setIsError(true); - setMessage('Handshake Failed'); - return; - case NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED: - setPercent(prevValue => (prevValue + 20)); - - GetNitroInstance().init(); - - if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'authentication', 'authok', []); - return; - case NitroCommunicationDemoEvent.CONNECTION_ERROR: - setIsError(true); - setMessage('Connection Error'); - return; - case NitroCommunicationDemoEvent.CONNECTION_CLOSED: - //if(GetNitroInstance().roomEngine) GetNitroInstance().roomEngine.dispose(); - //setIsError(true); - setMessage('Connection Error'); - - HabboWebTools.send(-1, 'client.init.handshake.fail'); - return; - case RoomEngineEvent.ENGINE_INITIALIZED: - setPercent(prevValue => (prevValue + 20)); - - setTimeout(() => setIsReady(true), 300); - return; - case NitroLocalizationEvent.LOADED: { - const assetUrls = GetConfiguration('preload.assets.urls'); - const urls: string[] = []; - - if(assetUrls && assetUrls.length) for(const url of assetUrls) urls.push(NitroConfiguration.interpolate(url)); - - const status = await GetAssetManager().downloadAssets(urls); - - if(status) - { - GetCommunication().init(); - - setPercent(prevValue => (prevValue + 20)) - } - else - { - setIsError(true); - setMessage('Assets Failed'); - } - return; - } - } - }, []); - - useMainEvent(Nitro.WEBGL_UNAVAILABLE, handler); - useMainEvent(Nitro.WEBGL_CONTEXT_LOST, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, handler); - useRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, handler); - useLocalizationEvent(NitroLocalizationEvent.LOADED, handler); - useConfigurationEvent(ConfigurationEvent.LOADED, handler); - useConfigurationEvent(ConfigurationEvent.FAILED, handler); - useEffect(() => { - GetNitroInstance().core.configuration.init(); + (async () => + { + try + { + //@ts-ignore + if(!NitroConfig) throw new Error('NitroConfig is not defined!'); + + Nitro.bootstrap(); + await GetNitroInstance().init(); + + setIsReady(true); + + // handle socket close + //canvas.addEventListener('webglcontextlost', () => instance.events.dispatchEvent(new NitroEvent(Nitro.WEBGL_CONTEXT_LOST))); + } + + catch(err) + { + NitroLogger.error(err); + } + })(); const resize = (event: UIEvent) => setImageRendering(!(window.devicePixelRatio % 1)); @@ -130,11 +51,9 @@ export const App: FC<{}> = props => return ( - { (!isReady || isError) && - } - - - + { !isReady && + } + { isReady && } ); diff --git a/src/api/avatar/AvatarEditorGridPartItem.ts b/src/api/avatar/AvatarEditorGridPartItem.ts index a3b16616..740d93f5 100644 --- a/src/api/avatar/AvatarEditorGridPartItem.ts +++ b/src/api/avatar/AvatarEditorGridPartItem.ts @@ -189,7 +189,7 @@ export class AvatarEditorGridPartItem implements IAvatarImageListener return container; } - private updateThumbVisualization(): void + private async updateThumbVisualization(): Promise { if(!this._isInitalized) return; @@ -212,7 +212,7 @@ export class AvatarEditorGridPartItem implements IAvatarImageListener if(this._isDisabled) this.setAlpha(container, 0.2); - this._imageUrl = TextureUtils.generateImageUrl(container); + this._imageUrl = await TextureUtils.generateImageUrl(container); if(this.notify) this.notify(); } diff --git a/src/api/index.ts b/src/api/index.ts index af964444..a0649a16 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,3 +1,5 @@ +export * from './GetRendererVersion'; +export * from './GetUIVersion'; export * from './achievements'; export * from './avatar'; export * from './camera'; @@ -6,8 +8,6 @@ export * from './catalog'; export * from './chat-history'; export * from './events'; export * from './friends'; -export * from './GetRendererVersion'; -export * from './GetUIVersion'; export * from './groups'; export * from './guide-tool'; export * from './hc-center'; @@ -18,7 +18,6 @@ export * from './navigator'; export * from './nitro'; export * from './nitro/avatar'; export * from './nitro/camera'; -export * from './nitro/core'; export * from './nitro/room'; export * from './nitro/session'; export * from './notification'; diff --git a/src/api/nitro/core/GetConfigurationManager.ts b/src/api/nitro/GetConfigurationManager.ts similarity index 57% rename from src/api/nitro/core/GetConfigurationManager.ts rename to src/api/nitro/GetConfigurationManager.ts index 66ce153f..94cb983e 100644 --- a/src/api/nitro/core/GetConfigurationManager.ts +++ b/src/api/nitro/GetConfigurationManager.ts @@ -1,7 +1,7 @@ import { IConfigurationManager } from '@nitrots/nitro-renderer'; -import { GetNitroCore } from './GetNitroCore'; +import { GetNitroInstance } from './GetNitroInstance'; export function GetConfigurationManager(): IConfigurationManager { - return GetNitroCore().configuration; + return GetNitroInstance().configuration; } diff --git a/src/api/nitro/core/GetNitroCore.ts b/src/api/nitro/core/GetNitroCore.ts deleted file mode 100644 index ef34b663..00000000 --- a/src/api/nitro/core/GetNitroCore.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { INitroCore } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '..'; - -export function GetNitroCore(): INitroCore -{ - return GetNitroInstance().core; -} diff --git a/src/api/nitro/core/index.ts b/src/api/nitro/core/index.ts deleted file mode 100644 index 3322c9cb..00000000 --- a/src/api/nitro/core/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './GetConfigurationManager'; -export * from './GetNitroCore'; diff --git a/src/api/nitro/index.ts b/src/api/nitro/index.ts index c43e958d..54546885 100644 --- a/src/api/nitro/index.ts +++ b/src/api/nitro/index.ts @@ -1,15 +1,15 @@ export * from './AddLinkEventTracker'; -export * from './avatar'; -export * from './camera'; -export * from './core'; export * from './CreateLinkEvent'; export * from './GetCommunication'; export * from './GetConfiguration'; +export * from './GetConfigurationManager'; export * from './GetConnection'; export * from './GetLocalization'; export * from './GetNitroInstance'; export * from './OpenUrl'; export * from './RemoveLinkEventTracker'; -export * from './room'; export * from './SendMessageComposer'; +export * from './avatar'; +export * from './camera'; +export * from './room'; export * from './session'; diff --git a/src/api/nitro/session/GetRoomSessionManager.ts b/src/api/nitro/session/GetRoomSessionManager.ts index 579342dc..726c520a 100644 --- a/src/api/nitro/session/GetRoomSessionManager.ts +++ b/src/api/nitro/session/GetRoomSessionManager.ts @@ -1,7 +1,7 @@ import { IRoomSessionManager } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../GetNitroInstance'; +import { GetRoomEngine } from '../room'; export function GetRoomSessionManager(): IRoomSessionManager { - return GetNitroInstance().roomSessionManager; + return GetRoomEngine().roomSessionManager; } diff --git a/src/api/room/widgets/AvatarInfoFurni.ts b/src/api/room/widgets/AvatarInfoFurni.ts index 3380282a..47743e97 100644 --- a/src/api/room/widgets/AvatarInfoFurni.ts +++ b/src/api/room/widgets/AvatarInfoFurni.ts @@ -9,7 +9,6 @@ export class AvatarInfoFurni implements IAvatarInfo 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; diff --git a/src/api/room/widgets/AvatarInfoUtilities.ts b/src/api/room/widgets/AvatarInfoUtilities.ts index 7c489448..a084aca9 100644 --- a/src/api/room/widgets/AvatarInfoUtilities.ts +++ b/src/api/room/widgets/AvatarInfoUtilities.ts @@ -1,4 +1,4 @@ -import { GetTickerTime, IFurnitureData, IRoomModerationSettings, IRoomPetData, IRoomUserData, ObjectDataFactory, PetFigureData, PetType, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomTradingLevelEnum, RoomWidgetEnumItemExtradataParameter, Vector3d } from '@nitrots/nitro-renderer'; +import { GetTickerTime, IFurnitureData, IRoomModerationSettings, IRoomPetData, IRoomUserData, ObjectDataFactory, PetFigureData, PetType, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomTradingLevelEnum, RoomWidgetEnumItemExtradataParameter } from '@nitrots/nitro-renderer'; import { GetRoomEngine, GetRoomSession, GetSessionDataManager, IsOwnerOfFurniture } from '../../nitro'; import { LocalizeText } from '../../utils'; import { AvatarInfoFurni } from './AvatarInfoFurni'; @@ -72,24 +72,20 @@ export class AvatarInfoUtilities public static getFurniInfo(objectId: number, category: number): AvatarInfoFurni { const roomSession = GetRoomSession(); + const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category); + + if(!roomObject) return null; + const furniInfo = new AvatarInfoFurni(AvatarInfoFurni.FURNI); furniInfo.id = objectId; furniInfo.category = category; - const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category); - - if(!roomObject) return; - const model = roomObject.model; - if(model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM)) - { - furniInfo.extraParam = model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM); - } + if(model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM)) furniInfo.extraParam = model.getValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM); - const dataFormat = model.getValue(RoomObjectVariable.FURNITURE_DATA_FORMAT); - const objectData = ObjectDataFactory.getData(dataFormat); + const objectData = ObjectDataFactory.getData(model.getValue(RoomObjectVariable.FURNITURE_DATA_FORMAT)); objectData.initializeFromRoomObjectModel(model); @@ -141,14 +137,14 @@ export class AvatarInfoUtilities furniInfo.expiration = ((expiryTime < 0) ? expiryTime : Math.max(0, (expiryTime - ((GetTickerTime() - expiryTimestamp) / 1000)))); - let roomObjectImage = GetRoomEngine().getRoomObjectImage(roomSession.roomId, objectId, category, new Vector3d(180), 64, null); + /* let roomObjectImage = GetRoomEngine().getRoomObjectImage(roomSession.roomId, objectId, category, new Vector3d(180), 64, null); if(!roomObjectImage.data || (roomObjectImage.data.width > 140) || (roomObjectImage.data.height > 200)) { roomObjectImage = GetRoomEngine().getRoomObjectImage(roomSession.roomId, objectId, category, new Vector3d(180), 1, null); } - furniInfo.image = roomObjectImage.getImage(); + furniInfo.image = roomObjectImage.getImage(); */ furniInfo.isWallItem = (category === RoomObjectCategory.WALL); furniInfo.isRoomOwner = roomSession.isRoomOwner; furniInfo.roomControllerLevel = roomSession.controllerLevel; @@ -159,11 +155,7 @@ export class AvatarInfoUtilities const guildId = model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID); - if(guildId !== 0) - { - furniInfo.groupId = guildId; - //this.container.connection.send(new GroupInformationComposer(guildId, false)); - } + if(guildId !== 0) furniInfo.groupId = guildId; if(IsOwnerOfFurniture(roomObject)) furniInfo.isOwner = true; @@ -174,11 +166,7 @@ export class AvatarInfoUtilities { const roomSession = GetRoomSession(); - let userInfoType = AvatarInfoUser.OWN_USER; - - if(userData.webID !== GetSessionDataManager().userId) userInfoType = AvatarInfoUser.PEER; - - const userInfo = new AvatarInfoUser(userInfoType); + const userInfo = new AvatarInfoUser((userData.webID === GetSessionDataManager().userId) ? AvatarInfoUser.OWN_USER : AvatarInfoUser.PEER); userInfo.isSpectatorMode = roomSession.isSpectator; userInfo.name = userData.name; @@ -192,7 +180,7 @@ export class AvatarInfoUtilities if(roomObject) userInfo.carryItem = (roomObject.model.getValue(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0); - if(userInfoType === AvatarInfoUser.OWN_USER) userInfo.allowNameChange = GetSessionDataManager().canChangeName; + if(userInfo.type === AvatarInfoUser.OWN_USER) userInfo.allowNameChange = GetSessionDataManager().canChangeName; userInfo.amIOwner = roomSession.isRoomOwner; userInfo.isGuildRoom = roomSession.isGuildRoom; @@ -200,14 +188,11 @@ export class AvatarInfoUtilities userInfo.amIAnyRoomController = GetSessionDataManager().isModerator; userInfo.isAmbassador = GetSessionDataManager().isAmbassador; - if(userInfoType === AvatarInfoUser.PEER) + if(userInfo.type === AvatarInfoUser.PEER) { if(roomObject) { - const flatControl = roomObject.model.getValue(RoomObjectVariable.FIGURE_FLAT_CONTROL); - - if(flatControl !== null) userInfo.targetRoomControllerLevel = flatControl; - + userInfo.targetRoomControllerLevel = roomObject.model.getValue(RoomObjectVariable.FIGURE_FLAT_CONTROL); userInfo.canBeMuted = this.canBeMuted(userInfo); userInfo.canBeKicked = this.canBeKicked(userInfo); userInfo.canBeBanned = this.canBeBanned(userInfo); @@ -234,7 +219,7 @@ export class AvatarInfoUtilities userInfo.canTrade = (roomController || targetController); break; } - case RoomTradingLevelEnum.NO_TRADING: + case RoomTradingLevelEnum.FREE_TRADING: userInfo.canTrade = true; break; default: diff --git a/src/api/room/widgets/ChatBubbleUtilities.ts b/src/api/room/widgets/ChatBubbleUtilities.ts new file mode 100644 index 00000000..f12ae07d --- /dev/null +++ b/src/api/room/widgets/ChatBubbleUtilities.ts @@ -0,0 +1,70 @@ +import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, PetFigureData, TextureUtils, Vector3d } from '@nitrots/nitro-renderer'; +import { GetAvatarRenderManager, GetRoomEngine } from '../../nitro'; + +export class ChatBubbleUtilities +{ + public static AVATAR_COLOR_CACHE: Map = new Map(); + public static AVATAR_IMAGE_CACHE: Map = new Map(); + public static PET_IMAGE_CACHE: Map = new Map(); + + private static placeHolderImageUrl: string = ''; + + public static async setFigureImage(figure: string): Promise + { + const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, { + resetFigure: figure => this.setFigureImage(figure), + dispose: () => + {}, + disposed: false + }); + + if(!avatarImage) return null; + + const isPlaceholder = avatarImage.isPlaceholder(); + + if(isPlaceholder && this.placeHolderImageUrl?.length) return this.placeHolderImageUrl; + + figure = avatarImage.getFigure().getFigureString(); + + const image = await avatarImage.getCroppedImage(AvatarSetType.HEAD); + const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST); + + if(isPlaceholder) this.placeHolderImageUrl = image.src; + + this.AVATAR_COLOR_CACHE.set(figure, ((color && color.rgb) || 16777215)); + this.AVATAR_IMAGE_CACHE.set(figure, image.src); + + avatarImage.dispose(); + + return image.src; + } + + public static async getUserImage(figure: string): Promise + { + let existing = this.AVATAR_IMAGE_CACHE.get(figure); + + if(!existing) existing = await this.setFigureImage(figure); + + return existing; + } + + public static async getPetImage(figure: string, direction: number, _arg_3: boolean, scale: number = 64, posture: string = null) + { + let existing = this.PET_IMAGE_CACHE.get((figure + posture)); + + if(existing) return existing; + + const figureData = new PetFigureData(figure); + const typeId = figureData.typeId; + const image = GetRoomEngine().getRoomObjectPetImage(typeId, figureData.paletteId, figureData.color, new Vector3d((direction * 45)), scale, null, false, 0, figureData.customParts, posture); + + if(image) + { + existing = await TextureUtils.generateImageUrl(image.data); + + this.PET_IMAGE_CACHE.set((figure + posture), existing); + } + + return existing; + } +} diff --git a/src/api/room/widgets/index.ts b/src/api/room/widgets/index.ts index c43d6aaa..6c50c838 100644 --- a/src/api/room/widgets/index.ts +++ b/src/api/room/widgets/index.ts @@ -6,6 +6,7 @@ export * from './AvatarInfoUser'; export * from './AvatarInfoUtilities'; export * from './BotSkillsEnum'; export * from './ChatBubbleMessage'; +export * from './ChatBubbleUtilities'; export * from './ChatMessageTypeEnum'; export * from './DimmerFurnitureWidgetPresetItem'; export * from './DoChatsOverlap'; diff --git a/src/common/card/NitroCardView.tsx b/src/common/card/NitroCardView.tsx index 46c4126b..3caa6bfd 100644 --- a/src/common/card/NitroCardView.tsx +++ b/src/common/card/NitroCardView.tsx @@ -24,36 +24,6 @@ export const NitroCardView: FC = props => return newClassNames; }, [ theme, classNames ]); - /* useEffect(() => - { - if(!uniqueKey || !elementRef || !elementRef.current) return; - - const localStorage = GetLocalStorage(`nitro.windows.${ uniqueKey }`); - const element = elementRef.current; - - if(localStorage && localStorage.size) - { - //element.style.width = `${ localStorage.size.width }px`; - //element.style.height = `${ localStorage.size.height }px`; - } - - const observer = new ResizeObserver(event => - { - const newStorage = { ...GetLocalStorage>(`nitro.windows.${ uniqueKey }`) } as WindowSaveOptions; - - newStorage.size = { width: element.offsetWidth, height: element.offsetHeight }; - - SetLocalStorage(`nitro.windows.${ uniqueKey }`, newStorage); - }); - - observer.observe(element); - - return () => - { - observer.disconnect(); - } - }, [ uniqueKey ]); */ - return ( diff --git a/src/common/index.scss b/src/common/index.scss index bc4a01b0..8539aa53 100644 --- a/src/common/index.scss +++ b/src/common/index.scss @@ -280,7 +280,8 @@ } } -.furni-image { +.furni-image, +.room-object-image { position: relative; width: 100%; height: 100%; diff --git a/src/common/layout/LayoutAvatarImageView.tsx b/src/common/layout/LayoutAvatarImageView.tsx index d127bd99..3dd49822 100644 --- a/src/common/layout/LayoutAvatarImageView.tsx +++ b/src/common/layout/LayoutAvatarImageView.tsx @@ -68,11 +68,14 @@ export const LayoutAvatarImageView: FC = props => avatarImage.setDirection(setType, direction); - const image = avatarImage.getCroppedImage(setType); + (async () => + { + const image = await avatarImage.getCroppedImage(setType); - if(image) setAvatarUrl(image.src); + if(image) setAvatarUrl(image.src); - avatarImage.dispose(); + avatarImage.dispose(); + })(); }, [ figure, gender, direction, headOnly, randomValue ]); useEffect(() => diff --git a/src/common/layout/LayoutBadgeImageView.tsx b/src/common/layout/LayoutBadgeImageView.tsx index a469429b..caee47a7 100644 --- a/src/common/layout/LayoutBadgeImageView.tsx +++ b/src/common/layout/LayoutBadgeImageView.tsx @@ -1,4 +1,4 @@ -import { BadgeImageReadyEvent, NitroSprite, TextureUtils } from '@nitrots/nitro-renderer'; +import { BadgeImageReadyEvent, NitroEventDispatcher, NitroSprite, TextureUtils } from '@nitrots/nitro-renderer'; import { CSSProperties, FC, useEffect, useMemo, useState } from 'react'; import { GetConfiguration, GetSessionDataManager, LocalizeBadgeDescription, LocalizeBadgeName, LocalizeText } from '../../api'; import { Base, BaseProps } from '../Base'; @@ -37,7 +37,7 @@ export const LayoutBadgeImageView: FC = props => if(imageElement) { - newStyle.backgroundImage = `url(${ (isGroup) ? imageElement.src : GetConfiguration('badge.asset.url').replace('%badgename%', badgeCode.toString())})`; + newStyle.backgroundImage = `url(${ (isGroup) ? imageElement.src : GetConfiguration('badge.asset.url').replace('%badgename%', badgeCode.toString()) })`; newStyle.width = imageElement.width; newStyle.height = imageElement.height; @@ -55,7 +55,7 @@ export const LayoutBadgeImageView: FC = props => if(Object.keys(style).length) newStyle = { ...newStyle, ...style }; return newStyle; - }, [ imageElement, scale, style ]); + }, [ badgeCode, isGroup, imageElement, scale, style ]); useEffect(() => { @@ -63,31 +63,34 @@ export const LayoutBadgeImageView: FC = props => let didSetBadge = false; - const onBadgeImageReadyEvent = (event: BadgeImageReadyEvent) => + const onBadgeImageReadyEvent = async (event: BadgeImageReadyEvent) => { if(event.badgeId !== badgeCode) return; - const element = TextureUtils.generateImage(new NitroSprite(event.image)); + const element = await TextureUtils.generateImage(new NitroSprite(event.image)); element.onload = () => setImageElement(element); didSetBadge = true; - GetSessionDataManager().events.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); + NitroEventDispatcher.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); } - GetSessionDataManager().events.addEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); + NitroEventDispatcher.addEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); const texture = isGroup ? GetSessionDataManager().getGroupBadgeImage(badgeCode) : GetSessionDataManager().getBadgeImage(badgeCode); if(texture && !didSetBadge) { - const element = TextureUtils.generateImage(new NitroSprite(texture)); + (async () => + { + const element = await TextureUtils.generateImage(new NitroSprite(texture)); - element.onload = () => setImageElement(element); + element.onload = () => setImageElement(element); + })(); } - return () => GetSessionDataManager().events.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); + return () => NitroEventDispatcher.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); }, [ badgeCode, isGroup ]); return ( diff --git a/src/common/layout/LayoutFurniImageView.tsx b/src/common/layout/LayoutFurniImageView.tsx index ef8696c5..708d6d67 100644 --- a/src/common/layout/LayoutFurniImageView.tsx +++ b/src/common/layout/LayoutFurniImageView.tsx @@ -46,15 +46,7 @@ export const LayoutFurniImageView: FC = props => let imageResult: ImageResult = null; const listener: IGetImageListener = { - imageReady: (id, texture, image) => - { - if(!image && texture) - { - image = TextureUtils.generateImage(texture); - } - - image.onload = () => setImageElement(image); - }, + imageReady: async (id, texture, image) => setImageElement(await TextureUtils.generateImage(texture)), imageFailed: null }; @@ -68,12 +60,9 @@ export const LayoutFurniImageView: FC = props => break; } - if(imageResult) - { - const image = imageResult.getImage(); + if(!imageResult) return; - image.onload = () => setImageElement(image); - } + (async () => setImageElement(await TextureUtils.generateImage(imageResult.data)))(); }, [ productType, productClassId, direction, extraData ]); if(!imageElement) return null; diff --git a/src/common/layout/LayoutMiniCameraView.tsx b/src/common/layout/LayoutMiniCameraView.tsx index 31b361c7..8dfbd7b8 100644 --- a/src/common/layout/LayoutMiniCameraView.tsx +++ b/src/common/layout/LayoutMiniCameraView.tsx @@ -6,7 +6,7 @@ import { DraggableWindow } from '../draggable-window'; interface LayoutMiniCameraViewProps { roomId: number; - textureReceiver: (texture: NitroRenderTexture) => void; + textureReceiver: (texture: NitroRenderTexture) => Promise; onClose: () => void; } diff --git a/src/common/layout/LayoutPetImageView.tsx b/src/common/layout/LayoutPetImageView.tsx index 27d43ded..69fe6afd 100644 --- a/src/common/layout/LayoutPetImageView.tsx +++ b/src/common/layout/LayoutPetImageView.tsx @@ -68,7 +68,7 @@ export const LayoutPetImageView: FC = props => if(petTypeId === 16) petHeadOnly = false; const imageResult = GetRoomEngine().getRoomObjectPetImage(petTypeId, petPaletteId, petColor1, new Vector3d((direction * 45)), 64, { - imageReady: (id, texture, image) => + imageReady: async (id, texture, image) => { if(isDisposed.current) return; @@ -81,7 +81,7 @@ export const LayoutPetImageView: FC = props => else if(texture) { - setPetUrl(TextureUtils.generateImageUrl(texture)); + setPetUrl(await TextureUtils.generateImageUrl(texture)); setWidth(texture.width); setHeight(texture.height); } @@ -94,14 +94,17 @@ export const LayoutPetImageView: FC = props => if(imageResult) { - const image = imageResult.getImage(); - - if(image) + (async () => { - setPetUrl(image.src); - setWidth(image.width); - setHeight(image.height); - } + const image = await imageResult.getImage(); + + if(image) + { + setPetUrl(image.src); + setWidth(image.width); + setHeight(image.height); + } + })(); } }, [ figure, typeId, paletteId, petColor, customParts, posture, headOnly, direction ]); diff --git a/src/common/layout/LayoutRoomObjectImageView.tsx b/src/common/layout/LayoutRoomObjectImageView.tsx new file mode 100644 index 00000000..083a9efc --- /dev/null +++ b/src/common/layout/LayoutRoomObjectImageView.tsx @@ -0,0 +1,61 @@ +import { TextureUtils, Vector3d } from '@nitrots/nitro-renderer'; +import { CSSProperties, FC, useEffect, useMemo, useState } from 'react'; +import { BaseProps } from '..'; +import { GetRoomEngine } from '../../api'; +import { Base } from '../Base'; + +interface LayoutRoomObjectImageViewProps extends BaseProps +{ + roomId: number; + objectId: number; + category: number; + direction?: number; + scale?: number; +} + +export const LayoutRoomObjectImageView: FC = props => +{ + const { roomId = -1, objectId = 1, category = -1, direction = 2, scale = 1, style = {}, ...rest } = props; + const [ imageElement, setImageElement ] = useState(null); + + const getStyle = useMemo(() => + { + let newStyle: CSSProperties = {}; + + if(imageElement?.src?.length) + { + newStyle.backgroundImage = `url('${ imageElement.src }')`; + newStyle.width = imageElement.width; + newStyle.height = imageElement.height; + } + + if(scale !== 1) + { + newStyle.transform = `scale(${ scale })`; + + if(!(scale % 1)) newStyle.imageRendering = 'pixelated'; + } + + if(Object.keys(style).length) newStyle = { ...newStyle, ...style }; + + return newStyle; + }, [ imageElement, scale, style ]); + + useEffect(() => + { + const imageResult = GetRoomEngine().getRoomObjectImage(roomId, objectId, category, new Vector3d(direction * 45), 64, { + imageReady: async (id, texture, image) => setImageElement(await TextureUtils.generateImage(texture)), + imageFailed: null + }); + + // needs (roomObjectImage.data.width > 140) || (roomObjectImage.data.height > 200) scale 1 + + if(!imageResult) return; + + (async () => setImageElement(await TextureUtils.generateImage(imageResult.data)))(); + }, [ roomId, objectId, category, direction, scale ]); + + if(!imageElement) return null; + + return ; +} diff --git a/src/common/layout/LayoutRoomPreviewerView.tsx b/src/common/layout/LayoutRoomPreviewerView.tsx index 69fbea84..023e53aa 100644 --- a/src/common/layout/LayoutRoomPreviewerView.tsx +++ b/src/common/layout/LayoutRoomPreviewerView.tsx @@ -26,7 +26,7 @@ export const LayoutRoomPreviewerView: FC = props = { if(!roomPreviewer) return; - const update = (time: number) => + const update = async (time: number) => { if(!roomPreviewer || !renderingCanvas || !elementRef.current) return; @@ -34,7 +34,7 @@ export const LayoutRoomPreviewerView: FC = props = if(!renderingCanvas.canvasUpdated) return; - elementRef.current.style.backgroundImage = `url(${ TextureUtils.generateImageUrl(renderingCanvas.master) })`; + elementRef.current.style.backgroundImage = `url(${ await TextureUtils.generateImageUrl(renderingCanvas.master) })`; } if(!renderingCanvas) diff --git a/src/common/layout/index.ts b/src/common/layout/index.ts index 3c4238e1..cbb05685 100644 --- a/src/common/layout/index.ts +++ b/src/common/layout/index.ts @@ -16,8 +16,9 @@ export * from './LayoutNotificationBubbleView'; export * from './LayoutPetImageView'; export * from './LayoutProgressBar'; export * from './LayoutRarityLevelView'; +export * from './LayoutRoomObjectImageView'; export * from './LayoutRoomPreviewerView'; export * from './LayoutRoomThumbnailView'; export * from './LayoutTrophyView'; -export * from './limited-edition'; export * from './UserProfileIconView'; +export * from './limited-edition'; diff --git a/src/common/utils/CreateTransitionToIcon.ts b/src/common/utils/CreateTransitionToIcon.ts index dbc59029..5359dad2 100644 --- a/src/common/utils/CreateTransitionToIcon.ts +++ b/src/common/utils/CreateTransitionToIcon.ts @@ -1,5 +1,4 @@ -import { NitroToolbarAnimateIconEvent } from '@nitrots/nitro-renderer'; -import { GetRoomEngine } from '../../api'; +import { NitroEventDispatcher, NitroToolbarAnimateIconEvent } from '@nitrots/nitro-renderer'; export const CreateTransitionToIcon = (image: HTMLImageElement, fromElement: HTMLElement, icon: string) => { @@ -10,5 +9,5 @@ export const CreateTransitionToIcon = (image: HTMLImageElement, fromElement: HTM event.iconName = icon; - GetRoomEngine().events.dispatchEvent(event); + NitroEventDispatcher.dispatchEvent(event); } diff --git a/src/components/avatar-editor/views/AvatarEditorWardrobeView.tsx b/src/components/avatar-editor/views/AvatarEditorWardrobeView.tsx index 9811ab88..83083529 100644 --- a/src/components/avatar-editor/views/AvatarEditorWardrobeView.tsx +++ b/src/components/avatar-editor/views/AvatarEditorWardrobeView.tsx @@ -62,7 +62,7 @@ export const AvatarEditorWardrobeView: FC = props { figureContainer && - } + } ); diff --git a/src/components/camera/CameraWidgetView.tsx b/src/components/camera/CameraWidgetView.tsx index 00ab0a87..930ccea4 100644 --- a/src/components/camera/CameraWidgetView.tsx +++ b/src/components/camera/CameraWidgetView.tsx @@ -1,7 +1,7 @@ import { ILinkEventTracker, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; import { AddEventLinkTracker, RemoveLinkEventTracker } from '../../api'; -import { useCamera, useRoomSessionManagerEvent } from '../../hooks'; +import { useCamera, useNitroEvent } from '../../hooks'; import { CameraWidgetCaptureView } from './views/CameraWidgetCaptureView'; import { CameraWidgetCheckoutView } from './views/CameraWidgetCheckoutView'; import { CameraWidgetEditorView } from './views/editor/CameraWidgetEditorView'; @@ -49,7 +49,7 @@ export const CameraWidgetView: FC<{}> = props => setMode(MODE_CHECKOUT); } - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, event => setMode(MODE_NONE)); + useNitroEvent(RoomSessionEvent.ENDED, event => setMode(MODE_NONE)); useEffect(() => { diff --git a/src/components/camera/views/CameraWidgetCaptureView.tsx b/src/components/camera/views/CameraWidgetCaptureView.tsx index 308bb830..75aeaae6 100644 --- a/src/components/camera/views/CameraWidgetCaptureView.tsx +++ b/src/components/camera/views/CameraWidgetCaptureView.tsx @@ -32,7 +32,7 @@ export const CameraWidgetCaptureView: FC = props = return new NitroRectangle(Math.floor(frameBounds.x), Math.floor(frameBounds.y), Math.floor(frameBounds.width), Math.floor(frameBounds.height)); } - const takePicture = () => + const takePicture = async () => { if(selectedPictureIndex > -1) { @@ -52,7 +52,7 @@ export const CameraWidgetCaptureView: FC = props = } PlaySound(SoundNames.CAMERA_SHUTTER); - clone.push(new CameraPicture(texture, TextureUtils.generateImageUrl(texture))); + clone.push(new CameraPicture(texture, await TextureUtils.generateImageUrl(texture))); setCameraRoll(clone); } diff --git a/src/components/camera/views/editor/CameraWidgetEditorView.tsx b/src/components/camera/views/editor/CameraWidgetEditorView.tsx index d7dfbf7a..fd085b77 100644 --- a/src/components/camera/views/editor/CameraWidgetEditorView.tsx +++ b/src/components/camera/views/editor/CameraWidgetEditorView.tsx @@ -26,6 +26,7 @@ export const CameraWidgetEditorView: FC = props => const [ selectedEffects, setSelectedEffects ] = useState([]); const [ effectsThumbnails, setEffectsThumbnails ] = useState([]); const [ isZoomed, setIsZoomed ] = useState(false); + const [ currentPictureUrl, setCurrentPictureUrl ] = useState(''); const getColorMatrixEffects = useMemo(() => { @@ -83,11 +84,6 @@ export const CameraWidgetEditorView: FC = props => }); }, [ getCurrentEffectIndex, setSelectedEffects ]); - const getCurrentPictureUrl = useMemo(() => - { - return GetRoomCameraWidgetManager().applyEffects(picture.texture, selectedEffects, isZoomed).src; - }, [ picture, selectedEffects, isZoomed ]); - const processAction = useCallback((type: string, effectName: string = null) => { switch(type) @@ -99,7 +95,7 @@ export const CameraWidgetEditorView: FC = props => onCancel(); return; case 'checkout': - onCheckout(getCurrentPictureUrl); + onCheckout(currentPictureUrl); return; case 'change_tab': setCurrentTab(String(effectName)); @@ -143,32 +139,50 @@ export const CameraWidgetEditorView: FC = props => setSelectedEffects([]); return; case 'download': { - const image = new Image(); + (async () => + { + const image = new Image(); - image.src = getCurrentPictureUrl - - const newWindow = window.open(''); - newWindow.document.write(image.outerHTML); + image.src = currentPictureUrl + + const newWindow = window.open(''); + newWindow.document.write(image.outerHTML); + })(); return; } case 'zoom': setIsZoomed(!isZoomed); return; } - }, [ isZoomed, availableEffects, selectedEffectName, getCurrentPictureUrl, getSelectedEffectIndex, onCancel, onCheckout, onClose, setIsZoomed, setSelectedEffects ]); + }, [ isZoomed, availableEffects, selectedEffectName, currentPictureUrl, getSelectedEffectIndex, onCancel, onCheckout, onClose, setIsZoomed, setSelectedEffects ]); useEffect(() => { - const thumbnails: CameraPictureThumbnail[] = []; - - for(const effect of availableEffects) + (async () => { - thumbnails.push(new CameraPictureThumbnail(effect.name, GetRoomCameraWidgetManager().applyEffects(picture.texture, [ new RoomCameraWidgetSelectedEffect(effect, 1) ], false).src)); - } + const thumbnails: CameraPictureThumbnail[] = []; + + for await (const effect of availableEffects) + { + const image = await GetRoomCameraWidgetManager().applyEffects(picture.texture, [ new RoomCameraWidgetSelectedEffect(effect, 1) ], false); - setEffectsThumbnails(thumbnails); + thumbnails.push(new CameraPictureThumbnail(effect.name, image.src)); + } + + setEffectsThumbnails(thumbnails); + })(); }, [ picture, availableEffects ]); + useEffect(() => + { + (async () => + { + const imageUrl = await GetRoomCameraWidgetManager().applyEffects(picture.texture, selectedEffects, isZoomed); + + setCurrentPictureUrl(imageUrl.src); + })(); + }, [ picture, selectedEffects, isZoomed ]); + return ( processAction('close') } /> @@ -185,7 +199,7 @@ export const CameraWidgetEditorView: FC = props => - + { selectedEffectName && { LocalizeText('camera.effect.name.' + selectedEffectName) } diff --git a/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx b/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx index 1eb673f1..6ebd4c4c 100644 --- a/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx +++ b/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx @@ -1,6 +1,5 @@ -import { NitroToolbarAnimateIconEvent, TextureUtils, ToolbarIconEnum } from '@nitrots/nitro-renderer'; +import { NitroEventDispatcher, NitroToolbarAnimateIconEvent, TextureUtils, ToolbarIconEnum } from '@nitrots/nitro-renderer'; import { FC, useRef } from 'react'; -import { GetRoomEngine } from '../../../../api'; import { LayoutRoomPreviewerView, LayoutRoomPreviewerViewProps } from '../../../../common'; import { CatalogPurchasedEvent } from '../../../../events'; import { useUiEvent } from '../../../../hooks'; @@ -17,21 +16,24 @@ export const CatalogRoomPreviewerView: FC = props const renderTexture = roomPreviewer.getRoomObjectCurrentImage(); if(!renderTexture) return; + + (async () => + { + const image = await TextureUtils.generateImage(renderTexture); - const image = TextureUtils.generateImage(renderTexture); + if(!image) return; - if(!image) return; + const bounds = elementRef.current.getBoundingClientRect(); - const bounds = elementRef.current.getBoundingClientRect(); + const x = (bounds.x + (bounds.width / 2)); + const y = (bounds.y + (bounds.height / 2)); - const x = (bounds.x + (bounds.width / 2)); - const y = (bounds.y + (bounds.height / 2)); + const animateEvent = new NitroToolbarAnimateIconEvent(image, x, y); - const animateEvent = new NitroToolbarAnimateIconEvent(image, x, y); + animateEvent.iconName = ToolbarIconEnum.INVENTORY; - animateEvent.iconName = ToolbarIconEnum.INVENTORY; - - GetRoomEngine().events.dispatchEvent(animateEvent); + NitroEventDispatcher.dispatchEvent(animateEvent); + })(); }); return ( diff --git a/src/components/catalog/views/page/common/CatalogSearchView.tsx b/src/components/catalog/views/page/common/CatalogSearchView.tsx index 69fb7892..73c148c6 100644 --- a/src/components/catalog/views/page/common/CatalogSearchView.tsx +++ b/src/components/catalog/views/page/common/CatalogSearchView.tsx @@ -23,9 +23,7 @@ export const CatalogSearchView: FC<{}> = props => const timeout = setTimeout(() => { - const furnitureDatas = GetSessionDataManager().getAllFurnitureData({ - loadFurnitureData: null - }); + const furnitureDatas = GetSessionDataManager().getAllFurnitureData(); if(!furnitureDatas || !furnitureDatas.length) return; diff --git a/src/components/floorplan-editor/FloorplanEditorView.tsx b/src/components/floorplan-editor/FloorplanEditorView.tsx index 995e8f73..6f2bcc82 100644 --- a/src/components/floorplan-editor/FloorplanEditorView.tsx +++ b/src/components/floorplan-editor/FloorplanEditorView.tsx @@ -2,12 +2,12 @@ import { FloorHeightMapEvent, ILinkEventTracker, NitroPoint, RoomEngineEvent, Ro import { FC, useEffect, useState } from 'react'; import { AddEventLinkTracker, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { Button, ButtonGroup, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; -import { useMessageEvent, useRoomEngineEvent } from '../../hooks'; +import { useMessageEvent, useNitroEvent } from '../../hooks'; +import { FloorplanEditorContextProvider } from './FloorplanEditorContext'; import { FloorplanEditor } from './common/FloorplanEditor'; import { IFloorplanSettings } from './common/IFloorplanSettings'; import { IVisualizationSettings } from './common/IVisualizationSettings'; import { convertNumbersForSaving, convertSettingToNumber } from './common/Utils'; -import { FloorplanEditorContextProvider } from './FloorplanEditorContext'; import { FloorplanCanvasView } from './views/FloorplanCanvasView'; import { FloorplanImportExportView } from './views/FloorplanImportExportView'; import { FloorplanOptionsView } from './views/FloorplanOptionsView'; @@ -54,7 +54,7 @@ export const FloorplanEditorView: FC<{}> = props => FloorplanEditor.instance.renderTiles(); } - useRoomEngineEvent(RoomEngineEvent.DISPOSED, event => setIsVisible(false)); + useNitroEvent(RoomEngineEvent.DISPOSED, event => setIsVisible(false)); useMessageEvent(FloorHeightMapEvent, event => { @@ -135,11 +135,6 @@ export const FloorplanEditorView: FC<{}> = props => return () => RemoveLinkEventTracker(linkTracker); }, []); - useEffect(() => - { - FloorplanEditor.instance.initialize(); - }, []); - return ( { isVisible && diff --git a/src/components/floorplan-editor/common/FloorplanEditor.ts b/src/components/floorplan-editor/common/FloorplanEditor.ts index 6fb0b08b..7e92800b 100644 --- a/src/components/floorplan-editor/common/FloorplanEditor.ts +++ b/src/components/floorplan-editor/common/FloorplanEditor.ts @@ -1,10 +1,11 @@ -import { GetAssetManager, IGraphicAssetCollection, NitroPoint, NitroTilemap, PixiApplicationProxy, PixiInteractionEventProxy, POINT_STRUCT_SIZE } from '@nitrots/nitro-renderer'; +import { NitroPoint } from '@nitrots/nitro-renderer'; import { ActionSettings } from './ActionSettings'; import { FloorAction, HEIGHT_SCHEME, MAX_NUM_TILE_PER_AXIS, TILE_SIZE } from './Constants'; +import { imageBase64, spritesheet } from './FloorplanResource'; import { Tile } from './Tile'; -import { getScreenPositionForTile, getTileFromScreenPosition } from './Utils'; +import { getScreenPositionForTile } from './Utils'; -export class FloorplanEditor extends PixiApplicationProxy +export class FloorplanEditor { private static _INSTANCE: FloorplanEditor = null; @@ -14,160 +15,105 @@ export class FloorplanEditor extends PixiApplicationProxy private _tilemap: Tile[][]; private _width: number; private _height: number; - private _isHolding: boolean; + private _isPointerDown: boolean; private _doorLocation: NitroPoint; private _lastUsedTile: NitroPoint; - private _tilemapRenderer: NitroTilemap; + private _renderer: CanvasRenderingContext2D; private _actionSettings: ActionSettings; - private _isInitialized: boolean; - private _assetCollection: IGraphicAssetCollection; + private _image: HTMLImageElement; constructor() { const width = TILE_SIZE * MAX_NUM_TILE_PER_AXIS + 20; const height = (TILE_SIZE * MAX_NUM_TILE_PER_AXIS) / 2 + 100; - super({ - width: width, - height: height, - backgroundColor: 0x000000, - antialias: true, - autoDensity: true, - resolution: 1, - sharedLoader: true, - sharedTicker: true - }); + const canvas = document.createElement('canvas'); + + canvas.height = height; + canvas.width = width; + + this._renderer = canvas.getContext('2d'); + + this._image = new Image(); + + this._image.src = imageBase64; this._tilemap = []; this._doorLocation = new NitroPoint(0, 0); this._width = 0; this._height = 0; - this._isHolding = false; + this._isPointerDown = false; this._lastUsedTile = new NitroPoint(-1, -1); this._actionSettings = new ActionSettings(); } - public initialize(): void + public onPointerRelease(): void { - if(this._isInitialized) return; + this._isPointerDown = false; + } - const collection = GetAssetManager().getCollection('floor_editor'); + public onPointerDown(event: PointerEvent): void + { + if(event.button === 2) return; - if(!collection) return; + const location = new NitroPoint(event.offsetX, event.offsetY); - this._assetCollection = collection; - this._tilemapRenderer = new NitroTilemap(collection.baseTexture); - - this.registerEventListeners(); - - this.stage.addChild(this._tilemapRenderer); + this._isPointerDown = true; - this._isInitialized = true; + this.tileHitDetection(location, true); } - private registerEventListeners(): void + public onPointerMove(event: PointerEvent): void { - //this._tilemapRenderer.interactive = true; - - const tempPoint = new NitroPoint(); - // @ts-ignore - this._tilemapRenderer.containsPoint = (position) => - { - this._tilemapRenderer.worldTransform.applyInverse(position, tempPoint); - return this.tileHitDetection(tempPoint, false); - }; - - this._tilemapRenderer.on('pointerup', () => - { - this._isHolding = false; - }); - - this._tilemapRenderer.on('pointerout', () => - { - this._isHolding = false; - }); - - this._tilemapRenderer.on('pointerdown', (event: PixiInteractionEventProxy) => - { - if(!(event.data.originalEvent instanceof PointerEvent) && !(event.data.originalEvent instanceof TouchEvent)) return; - - const pointerEvent = event.data.originalEvent; - if((pointerEvent instanceof MouseEvent) && pointerEvent.button === 2) return; - - - const location = event.data.global; - this.tileHitDetection(location, true); - }); - - this._tilemapRenderer.on('click', (event: PixiInteractionEventProxy) => - { - if(!(event.data.originalEvent instanceof PointerEvent)) return; - - const pointerEvent = event.data.originalEvent; - if(pointerEvent.button === 2) return; - - const location = event.data.global; - this.tileHitDetection(location, true, true); - }); + if(!this._isPointerDown) return; + + const location = new NitroPoint(event.offsetX, event.offsetY); + this.tileHitDetection(location, false); } - private tileHitDetection(tempPoint: NitroPoint, setHolding: boolean, isClick: boolean = false): boolean + private tileHitDetection(tempPoint: NitroPoint, isClick: boolean = false): boolean { - // @ts-ignore - const buffer = this._tilemapRenderer.pointsBuf; - const bufSize = POINT_STRUCT_SIZE; + const mousePositionX = Math.floor(tempPoint.x); + const mousePositionY = Math.floor(tempPoint.y); - const len = buffer.length; + const width = TILE_SIZE; + const height = TILE_SIZE / 2; - if(setHolding) + for(let y = 0; y < this._tilemap.length; y++) { - this._isHolding = true; - } - - for(let j = 0; j < len; j += bufSize) - { - const bufIndex = j + bufSize; - const data = buffer.slice(j, bufIndex); - - const width = TILE_SIZE; - const height = TILE_SIZE / 2; - - const mousePositionX = Math.floor(tempPoint.x); - const mousePositionY = Math.floor(tempPoint.y); - - const tileStartX = data[2]; - const tileStartY = data[3]; - - const centreX = tileStartX + (width / 2); - const centreY = tileStartY + (height / 2); - - const dx = Math.abs(mousePositionX - centreX); - const dy = Math.abs(mousePositionY - centreY); - - const solution = (dx / (width * 0.5) + dy / (height * 0.5) <= 1);//todo: improve this - if(solution) + for(let x = 0; x < this.tilemap[y].length; x++) { - if(this._isHolding) + const [ tileStartX, tileStartY ] = getScreenPositionForTile(x, y); + + const centreX = tileStartX + (width / 2); + const centreY = tileStartY + (height / 2); + + const dx = Math.abs(mousePositionX - centreX); + const dy = Math.abs(mousePositionY - centreY); + + const solution = (dx / (width * 0.5) + dy / (height * 0.5) <= 1);//todo: improve this + + if(solution) { - const [ realX, realY ] = getTileFromScreenPosition(tileStartX, tileStartY); - - if(isClick) + if(this._isPointerDown) { - this.onClick(realX, realY); - } + if(isClick) + { + this.onClick(x, y); + } - else if(this._lastUsedTile.x !== realX || this._lastUsedTile.y !== realY) - { - this._lastUsedTile.x = realX; - this._lastUsedTile.y = realY; - this.onClick(realX, realY); - } + else if(this._lastUsedTile.x !== x || this._lastUsedTile.y !== y) + { + this._lastUsedTile.x = x; + this._lastUsedTile.y = y; + this.onClick(x, y); + } + } + return true; } - return true; } - } return false; } @@ -230,7 +176,7 @@ export class FloorplanEditor extends PixiApplicationProxy public renderTiles(): void { - this.tilemapRenderer.clear(); + this.clearCanvas(); for(let y = 0; y < this._tilemap.length; y++) { @@ -246,8 +192,10 @@ export class FloorplanEditor extends PixiApplicationProxy //if((tile.height === 'x') || tile.height === 'X') continue; const [ positionX, positionY ] = getScreenPositionForTile(x, y); - - this._tilemapRenderer.tile(this._assetCollection.getTexture(`floor_editor_${ assetName }`), positionX, positionY); + + const asset = spritesheet.frames[assetName]; + + this.renderer.drawImage(this._image, asset.frame.x, asset.frame.y, asset.frame.w, asset.frame.h, positionX, positionY, asset.frame.w, asset.frame.h); } } } @@ -372,20 +320,24 @@ export class FloorplanEditor extends PixiApplicationProxy public clear(): void { - this._tilemapRenderer.interactive = false; this._tilemap = []; this._doorLocation.set(-1, -1); this._width = 0; this._height = 0; - this._isHolding = false; + this._isPointerDown = false; this._lastUsedTile.set(-1, -1); this._actionSettings.clear(); - this._tilemapRenderer.clear(); + this.clearCanvas(); } - public get tilemapRenderer(): NitroTilemap + public clearCanvas(): void { - return this._tilemapRenderer; + this.renderer.clearRect(0, 0, this._renderer.canvas.width, this._renderer.canvas.height); + } + + public get renderer(): CanvasRenderingContext2D + { + return this._renderer; } public get tilemap(): Tile[][] diff --git a/src/components/floorplan-editor/common/FloorplanResource.ts b/src/components/floorplan-editor/common/FloorplanResource.ts new file mode 100644 index 00000000..8faf30b0 --- /dev/null +++ b/src/components/floorplan-editor/common/FloorplanResource.ts @@ -0,0 +1,227 @@ +export const imageBase64 = + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAAC+CAMAAADnThrbAAAAYFBMVEUAAAAiIiIAZf8A6P8A/5MZ/wCb/wD/tQD/MgD/AHr/APxDXocAkf8A/+oA/2hE/wDy/wD/iQD/BwD/AKXWAP////8AvP8A/78A/z1w/wD/4AD/XgD/ACP/ANGqAP8QEBBSz3qJAAAAAXRSTlMAQObYZgAAAAlwSFlzAAALEwAACxMBAJqcGAAABJxJREFUeNrt1tuOszoMBeDpD7QFBloKDGf6/m+51UTj1PUhN1uWOup3vSQLkSzn6+vV4fAV9X9lLIcdDv/+xWKHw/d3PPPzE8k8Rj1osceoBz3z4yiZ31HauN9R2rjfUcq451HSuOdR0rjnUcK411HcuNdR3LjXUcw4btTrOG7U6zhu1Ms4adTzOGnU8zhpVBh30Eb5cQ/fKp/5UR1+51l9mfU/Mz6NxvfMuEGMu9G49f/y8vzLz4Ikif/8qopnhiF6FhNHP9aVo2cGR71lCZAvbAXkzADE/kgQvooqhM8MCNuMCUFLtiJoZiBI5ycsvD4qFs4MLLTNElFYjJUoZAYRPAsSlV/5lcpnBhU8C6y+zPqfGZ9G43tm3CDG3Wjc+p9N/Z7PgjSN//y6jmfGMXoWU0c/1rWjZ0ZHvWUpkC9sDeTMCMT+SBG+imqEz4wI24wpQUu2JmhmJEjnpyy8PmoWzowstM1SUViMtShkRhE8C1KVX/m1ymdGFTwLrL7M+p8Zn0bje2bcIMbdaNz6n039ns+CLIv//Mslnpmm6FnMHP1YXxw9MznqLcuAfGEvQM5MQOyPDOGr6ILwmQlhmzEjaMleCJqZCNL5GQuvjwsLZyYW2maZKCzGiyhkJhE8CzKVX/kXlc9MKngWWH2Z9T8zPo3G98y4QYy70bj1P5v6PZ8Fx2P851+v8cw8R8/i0dGP9dXRM7Oj3rIjkC/sFciZGYj9cUT4KroifGZG2GY8ErRkrwTNzATp/CMLr48rC2dmFtpmR1FYjFdRyMwieBYcVX7lX1U+M6vgWWD1Zdb/zPg0Gt8z4wYx7kbj1v9s6vd8FpxO8Z/fNPHMskTP4snRj3Xj6JnFUW/ZCcgXtgFyZgFif5wQvooahM8sCNuMJ4KWbEPQzEKQzj+x8PpoWDizsNA2O4nCYmxEIbOI4FlwUvmV36h8ZlHBs8Dqy6z/mfFpNL5nxg1i3I3Grf/Z1O/5LDif4z//dotn1jV6Fs+Ofqxvjp5ZHfWWnYF8YW9AzqxA7I8zwlfRDeEzK8I245mgJXsjaGYlSOefWXh93Fg4s7LQNjuLwmK8iUJmFcGz4KzyK/+m8plVBc8Cqy+z/mfGp9H4nhk3iHE3Grf+Z1O/57Mgz+M/v23jmW2LnsXc0Y916+iZzVFvWQ7kC9sCObMBsT9yhK+iFuEzG8I2Y07Qkm0JmtkI0vk5C6+PloUzGwtts1wUFmMrCplNBM+CXOVXfqvymU0FzwKrL7P+Z8an0fieGTeIcTcat/5nU7/ns6Ao4j+/6+KZfY+excLRj3Xn6JndUW9ZAeQL2wE5swOxPwqEr6IO4TM7wjZjQdCS7Qia2QnS+QULr4+OhTM7C22zQhQWYycKmV0Ez4JC5Vd+p/KZXQXPAqsvs/5nxqfR+J4ZN4hxNxq3/mdTv+ezoCzjP7/v45n7PXoWS0c/1r2jZ+6OestKIF/YHsiZOxD7o0T4KuoRPnNH2GYsCVqyPUEzd4J0fsnC66Nn4cydhbZZKQqLsReFzF0Ez4JS5Vd+r/KZuwqeBVZfZv3PjE+j8T0zbhDjbjRu/b+0PP8DZwi9QurvbfwAAAAASUVORK5CYII='; + +export const spritesheet = { + frames: { + '0': { + frame: { x: 1, y: 1, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '1': { + frame: { x: 37, y: 1, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '2': { + frame: { x: 73, y: 1, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '3': { + frame: { x: 1, y: 20, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '4': { + frame: { x: 37, y: 20, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '5': { + frame: { x: 73, y: 20, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '6': { + frame: { x: 1, y: 39, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '7': { + frame: { x: 37, y: 39, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '8': { + frame: { x: 73, y: 39, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + '9': { + frame: { x: 1, y: 58, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'a': { + frame: { x: 37, y: 58, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'b': { + frame: { x: 73, y: 58, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'c': { + frame: { x: 1, y: 77, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'd': { + frame: { x: 37, y: 77, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'e': { + frame: { x: 73, y: 77, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'f': { + frame: { x: 1, y: 96, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'g': { + frame: { x: 37, y: 96, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'h': { + frame: { x: 73, y: 96, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'i': { + frame: { x: 1, y: 115, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'j': { + frame: { x: 37, y: 115, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'k': { + frame: { x: 73, y: 115, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'l': { + frame: { x: 1, y: 134, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'm': { + frame: { x: 37, y: 134, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'n': { + frame: { x: 73, y: 134, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'o': { + frame: { x: 1, y: 153, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'p': { + frame: { x: 37, y: 153, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'q': { + frame: { x: 73, y: 153, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'r_blocked': { + frame: { x: 1, y: 172, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'r_door': { + frame: { x: 37, y: 172, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + 'x': { + frame: { x: 73, y: 172, w: 34, h: 17 }, + rotated: false, + trimmed: false, + spriteSourceSize: { x: 0, y: 0, w: 34, h: 17 }, + sourceSize: { w: 34, h: 17 }, + }, + }, + meta: { + app: 'https://www.codeandweb.com/texturepacker', + version: '1.0', + image: 'tiles.png', + format: 'RGBA8888', + size: { w: 108, h: 190 }, + scale: '1', + smartupdate: + '$TexturePacker:SmartUpdate:6d0f8373580629749f786a0b0f6c6bb9:96dff9df69bdc6938cf02f254bbe028b:accbe1e7e294ded8391337fc1c446319$', + }, +}; diff --git a/src/components/floorplan-editor/views/FloorplanCanvasView.tsx b/src/components/floorplan-editor/views/FloorplanCanvasView.tsx index 6db052e4..8b9b8102 100644 --- a/src/components/floorplan-editor/views/FloorplanCanvasView.tsx +++ b/src/components/floorplan-editor/views/FloorplanCanvasView.tsx @@ -4,8 +4,8 @@ import { FaArrowDown, FaArrowLeft, FaArrowRight, FaArrowUp } from 'react-icons/f import { SendMessageComposer } from '../../../api'; import { Base, Button, Column, ColumnProps, Flex, Grid } from '../../../common'; import { useMessageEvent } from '../../../hooks'; -import { FloorplanEditor } from '../common/FloorplanEditor'; import { useFloorplanEditorContext } from '../FloorplanEditorContext'; +import { FloorplanEditor } from '../common/FloorplanEditor'; export const FloorplanCanvasView: FC = props => { @@ -32,7 +32,7 @@ export const FloorplanCanvasView: FC = props => setOccupiedTilesReceived(true); - elementRef.current.scrollTo((FloorplanEditor.instance.view.width / 3), 0); + elementRef.current.scrollTo((FloorplanEditor.instance.renderer.canvas.width / 3), 0); }); useMessageEvent(RoomEntryTileMessageEvent, event => @@ -86,6 +86,25 @@ export const FloorplanCanvasView: FC = props => } } + const onPointerEvent = (event: PointerEvent) => + { + event.preventDefault(); + + switch(event.type) + { + case 'pointerout': + case 'pointerup': + FloorplanEditor.instance.onPointerRelease(); + break; + case 'pointerdown': + FloorplanEditor.instance.onPointerDown(event); + break; + case 'pointermove': + FloorplanEditor.instance.onPointerMove(event); + break; + } + } + useEffect(() => { return () => @@ -116,11 +135,34 @@ export const FloorplanCanvasView: FC = props => SendMessageComposer(new GetRoomEntryTileMessageComposer()); SendMessageComposer(new GetOccupiedTilesMessageComposer()); - FloorplanEditor.instance.tilemapRenderer.interactive = true; + const currentElement = elementRef.current; - if(!elementRef.current) return; + if(!currentElement) return; - elementRef.current.appendChild(FloorplanEditor.instance.renderer.view); + + currentElement.appendChild(FloorplanEditor.instance.renderer.canvas); + + currentElement.addEventListener('pointerup', onPointerEvent); + + currentElement.addEventListener('pointerout', onPointerEvent); + + currentElement.addEventListener('pointerdown', onPointerEvent); + + currentElement.addEventListener('pointermove', onPointerEvent); + + return () => + { + if(currentElement) + { + currentElement.removeEventListener('pointerup', onPointerEvent); + + currentElement.removeEventListener('pointerout', onPointerEvent); + + currentElement.removeEventListener('pointerdown', onPointerEvent); + + currentElement.removeEventListener('pointermove', onPointerEvent); + } + } }, []); return ( diff --git a/src/components/hotel-view/HotelView.tsx b/src/components/hotel-view/HotelView.tsx index d78c941d..3e535c61 100644 --- a/src/components/hotel-view/HotelView.tsx +++ b/src/components/hotel-view/HotelView.tsx @@ -2,7 +2,7 @@ import { NitroConfiguration, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useState } from 'react'; import { GetConfiguration } from '../../api'; import { LayoutAvatarImageView } from '../../common'; -import { useRoomSessionManagerEvent, useSessionInfo } from '../../hooks'; +import { useNitroEvent, useSessionInfo } from '../../hooks'; import { WidgetSlotView } from './views/widgets/WidgetSlotView'; const widgetSlotCount = 7; @@ -12,7 +12,7 @@ export const HotelView: FC<{}> = props => const [ isVisible, setIsVisible ] = useState(true); const { userFigure = null } = useSessionInfo(); - useRoomSessionManagerEvent([ + useNitroEvent([ RoomSessionEvent.CREATED, RoomSessionEvent.ENDED ], event => { diff --git a/src/components/inventory/InventoryView.tsx b/src/components/inventory/InventoryView.tsx index 8a3410a8..11aec167 100644 --- a/src/components/inventory/InventoryView.tsx +++ b/src/components/inventory/InventoryView.tsx @@ -1,8 +1,8 @@ import { BadgePointLimitsEvent, ILinkEventTracker, IRoomSession, RoomEngineObjectEvent, RoomEngineObjectPlacedEvent, RoomPreviewer, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { AddEventLinkTracker, GetLocalization, GetRoomEngine, isObjectMoverRequested, LocalizeText, RemoveLinkEventTracker, setObjectMoverRequested, UnseenItemCategory } from '../../api'; +import { AddEventLinkTracker, GetLocalization, GetRoomEngine, LocalizeText, RemoveLinkEventTracker, UnseenItemCategory, isObjectMoverRequested, setObjectMoverRequested } from '../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; -import { useInventoryTrade, useInventoryUnseenTracker, useMessageEvent, useRoomEngineEvent, useRoomSessionManagerEvent } from '../../hooks'; +import { useInventoryTrade, useInventoryUnseenTracker, useMessageEvent, useNitroEvent } from '../../hooks'; import { InventoryBadgeView } from './views/badge/InventoryBadgeView'; import { InventoryBotView } from './views/bot/InventoryBotView'; import { InventoryFurnitureView } from './views/furniture/InventoryFurnitureView'; @@ -32,7 +32,7 @@ export const InventoryView: FC<{}> = props => setIsVisible(false); } - useRoomEngineEvent(RoomEngineObjectEvent.PLACED, event => + useNitroEvent(RoomEngineObjectEvent.PLACED, event => { if(!isObjectMoverRequested()) return; @@ -41,7 +41,7 @@ export const InventoryView: FC<{}> = props => if(!event.placedInRoom) setIsVisible(true); }); - useRoomSessionManagerEvent([ + useNitroEvent([ RoomSessionEvent.CREATED, RoomSessionEvent.ENDED ], event => diff --git a/src/components/loading/LoadingView.tsx b/src/components/loading/LoadingView.tsx index ee3a0369..84b74c44 100644 --- a/src/components/loading/LoadingView.tsx +++ b/src/components/loading/LoadingView.tsx @@ -6,18 +6,19 @@ interface LoadingViewProps isError: boolean; message: string; percent: number; + showPercent?: boolean; } export const LoadingView: FC = props => { - const { isError = false, message = '', percent = 0 } = props; + const { isError = false, message = '', percent = 0, showPercent = true } = props; return ( - + { showPercent && { isError && (message && message.length) ? { message } : @@ -27,7 +28,7 @@ export const LoadingView: FC = props => } - + } diff --git a/src/components/main/MainView.tsx b/src/components/main/MainView.tsx index da7003dc..b85c2e2f 100644 --- a/src/components/main/MainView.tsx +++ b/src/components/main/MainView.tsx @@ -2,7 +2,7 @@ import { HabboWebTools, ILinkEventTracker, RoomSessionEvent } from '@nitrots/nit import { FC, useEffect, useState } from 'react'; import { AddEventLinkTracker, GetCommunication, RemoveLinkEventTracker } from '../../api'; import { Base, TransitionAnimation, TransitionAnimationTypes } from '../../common'; -import { useRoomSessionManagerEvent } from '../../hooks'; +import { useNitroEvent } from '../../hooks'; import { AchievementsView } from '../achievements/AchievementsView'; import { AvatarEditorView } from '../avatar-editor/AvatarEditorView'; import { CameraWidgetView } from '../camera/CameraWidgetView'; @@ -33,14 +33,14 @@ export const MainView: FC<{}> = props => const [ isReady, setIsReady ] = useState(false); const [ landingViewVisible, setLandingViewVisible ] = useState(true); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, event => setLandingViewVisible(false)); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, event => setLandingViewVisible(event.openLandingView)); + useNitroEvent(RoomSessionEvent.CREATED, event => setLandingViewVisible(false)); + useNitroEvent(RoomSessionEvent.ENDED, event => setLandingViewVisible(event.openLandingView)); useEffect(() => { setIsReady(true); - GetCommunication().connection.onReady(); + GetCommunication().connection.ready(); }, []); useEffect(() => diff --git a/src/components/mod-tools/ModToolsView.tsx b/src/components/mod-tools/ModToolsView.tsx index cfb9d35a..588ffce2 100644 --- a/src/components/mod-tools/ModToolsView.tsx +++ b/src/components/mod-tools/ModToolsView.tsx @@ -2,7 +2,7 @@ import { ILinkEventTracker, RoomEngineEvent, RoomId, RoomObjectCategory, RoomObj import { FC, useEffect, useRef, useState } from 'react'; import { AddEventLinkTracker, CreateLinkEvent, GetRoomSession, ISelectedUser, RemoveLinkEventTracker } from '../../api'; import { Base, Button, DraggableWindowPosition, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; -import { useModTools, useObjectSelectedEvent, useRoomEngineEvent } from '../../hooks'; +import { useModTools, useNitroEvent, useObjectSelectedEvent } from '../../hooks'; import { ModToolsChatlogView } from './views/room/ModToolsChatlogView'; import { ModToolsRoomView } from './views/room/ModToolsRoomView'; import { ModToolsTicketsView } from './views/tickets/ModToolsTicketsView'; @@ -18,7 +18,7 @@ export const ModToolsView: FC<{}> = props => const { openRooms = [], openRoomChatlogs = [], openUserChatlogs = [], openUserInfos = [], openRoomInfo = null, closeRoomInfo = null, toggleRoomInfo = null, openRoomChatlog = null, closeRoomChatlog = null, toggleRoomChatlog = null, openUserInfo = null, closeUserInfo = null, toggleUserInfo = null, openUserChatlog = null, closeUserChatlog = null, toggleUserChatlog = null } = useModTools(); const elementRef = useRef(null); - useRoomEngineEvent([ + useNitroEvent([ RoomEngineEvent.INITIALIZED, RoomEngineEvent.DISPOSED ], event => diff --git a/src/components/navigator/NavigatorView.tsx b/src/components/navigator/NavigatorView.tsx index aefe50ba..97131d8b 100644 --- a/src/components/navigator/NavigatorView.tsx +++ b/src/components/navigator/NavigatorView.tsx @@ -3,7 +3,7 @@ import { FC, useCallback, useEffect, useRef, useState } from 'react'; import { FaPlus } from 'react-icons/fa'; import { AddEventLinkTracker, LocalizeText, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api'; import { Base, Column, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; -import { useNavigator, useRoomSessionManagerEvent } from '../../hooks'; +import { useNavigator, useNitroEvent } from '../../hooks'; import { NavigatorDoorStateView } from './views/NavigatorDoorStateView'; import { NavigatorRoomCreatorView } from './views/NavigatorRoomCreatorView'; import { NavigatorRoomInfoView } from './views/NavigatorRoomInfoView'; @@ -26,7 +26,7 @@ export const NavigatorView: FC<{}> = props => const pendingSearch = useRef<{ value: string, code: string }>(null); const elementRef = useRef(); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, event => + useNitroEvent(RoomSessionEvent.CREATED, event => { setIsVisible(false); setCreatorOpen(false); diff --git a/src/components/room/widgets/RoomWidgetsView.tsx b/src/components/room/widgets/RoomWidgetsView.tsx index c2202995..6de7856c 100644 --- a/src/components/room/widgets/RoomWidgetsView.tsx +++ b/src/components/room/widgets/RoomWidgetsView.tsx @@ -1,7 +1,7 @@ import { RoomEngineObjectEvent, RoomEngineRoomAdEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomId, RoomSessionErrorMessageEvent, RoomZoomEvent } from '@nitrots/nitro-renderer'; import { FC } from 'react'; import { DispatchUiEvent, GetRoomEngine, LocalizeText, NotificationAlertType, RoomWidgetUpdateRoomObjectEvent } from '../../../api'; -import { useNotification, useRoom, useRoomEngineEvent, useRoomSessionManagerEvent } from '../../../hooks'; +import { useNitroEvent, useNotification, useRoom } from '../../../hooks'; import { AvatarInfoWidgetView } from './avatar-info/AvatarInfoWidgetView'; import { ChatInputView } from './chat-input/ChatInputView'; import { ChatWidgetView } from './chat/ChatWidgetView'; @@ -21,9 +21,9 @@ export const RoomWidgetsView: FC<{}> = props => const { roomSession = null } = useRoom(); const { simpleAlert = null } = useNotification(); - useRoomEngineEvent(RoomZoomEvent.ROOM_ZOOM, event => GetRoomEngine().setRoomInstanceRenderingCanvasScale(event.roomId, 1, event.level, null, null, false, event.asDelta)); + useNitroEvent(RoomZoomEvent.ROOM_ZOOM, event => GetRoomEngine().setRoomInstanceRenderingCanvasScale(event.roomId, 1, event.level, null, null, false, event.asDelta)); - useRoomEngineEvent( + useNitroEvent( [ RoomEngineTriggerWidgetEvent.REQUEST_TEASER, RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, @@ -87,7 +87,7 @@ export const RoomWidgetsView: FC<{}> = props => if(dispatchEvent) DispatchUiEvent(updateEvent); }); - useRoomSessionManagerEvent( + useNitroEvent( [ RoomSessionErrorMessageEvent.RSEME_KICKED, RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, diff --git a/src/components/room/widgets/avatar-info/AvatarInfoWidgetView.tsx b/src/components/room/widgets/avatar-info/AvatarInfoWidgetView.tsx index 5a0acf1d..adf22120 100644 --- a/src/components/room/widgets/avatar-info/AvatarInfoWidgetView.tsx +++ b/src/components/room/widgets/avatar-info/AvatarInfoWidgetView.tsx @@ -2,7 +2,7 @@ import { RoomEngineEvent, RoomEnterEffect, RoomSessionDanceEvent } from '@nitrot import { FC, useState } from 'react'; import { AvatarInfoFurni, AvatarInfoPet, AvatarInfoRentableBot, AvatarInfoUser, GetConfiguration, GetSessionDataManager, RoomWidgetUpdateRentableBotChatEvent } from '../../../../api'; import { Column } from '../../../../common'; -import { useAvatarInfoWidget, useRoom, useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../../../../hooks'; +import { useAvatarInfoWidget, useNitroEvent, useRoom, useUiEvent } from '../../../../hooks'; import { AvatarInfoPetTrainingPanelView } from './AvatarInfoPetTrainingPanelView'; import { AvatarInfoRentableBotChatView } from './AvatarInfoRentableBotChatView'; import { AvatarInfoUseProductConfirmView } from './AvatarInfoUseProductConfirmView'; @@ -29,17 +29,17 @@ export const AvatarInfoWidgetView: FC<{}> = props => const { avatarInfo = null, setAvatarInfo = null, activeNameBubble = null, setActiveNameBubble = null, nameBubbles = [], removeNameBubble = null, productBubbles = [], confirmingProduct = null, updateConfirmingProduct = null, removeProductBubble = null, isDecorating = false, setIsDecorating = null } = useAvatarInfoWidget(); const { roomSession = null } = useRoom(); - useRoomEngineEvent(RoomEngineEvent.NORMAL_MODE, event => + useNitroEvent(RoomEngineEvent.NORMAL_MODE, event => { if(isGameMode) setGameMode(false); }); - useRoomEngineEvent(RoomEngineEvent.GAME_MODE, event => + useNitroEvent(RoomEngineEvent.GAME_MODE, event => { if(!isGameMode) setGameMode(true); }); - useRoomSessionManagerEvent(RoomSessionDanceEvent.RSDE_DANCE, event => + useNitroEvent(RoomSessionDanceEvent.RSDE_DANCE, event => { if(event.roomIndex !== roomSession.ownRoomIndex) return; diff --git a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetFurniView.tsx b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetFurniView.tsx index aa4b388c..f5648128 100644 --- a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetFurniView.tsx +++ b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetFurniView.tsx @@ -2,8 +2,8 @@ import { CrackableDataType, GroupInformationComposer, GroupInformationEvent, Now import { FC, useCallback, useEffect, useState } from 'react'; import { FaTimes } from 'react-icons/fa'; import { AvatarInfoFurni, CreateLinkEvent, GetGroupInformation, GetNitroInstance, GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../../api'; -import { Base, Button, Column, Flex, LayoutBadgeImageView, LayoutLimitedEditionCompactPlateView, LayoutRarityLevelView, Text, UserProfileIconView } from '../../../../../common'; -import { useMessageEvent, useRoom, useSoundEvent } from '../../../../../hooks'; +import { Base, Button, Column, Flex, LayoutBadgeImageView, LayoutLimitedEditionCompactPlateView, LayoutRarityLevelView, LayoutRoomObjectImageView, Text, UserProfileIconView } from '../../../../../common'; +import { useMessageEvent, useNitroEvent, useRoom } from '../../../../../hooks'; interface InfoStandWidgetFurniViewProps { @@ -40,12 +40,12 @@ export const InfoStandWidgetFurniView: FC = props const [ songName, setSongName ] = useState(''); const [ songCreator, setSongCreator ] = useState(''); - useSoundEvent(NowPlayingEvent.NPE_SONG_CHANGED, event => + useNitroEvent(NowPlayingEvent.NPE_SONG_CHANGED, event => { setSongId(event.id); }, (isJukeBox || isSongDisk)); - useSoundEvent(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, event => + useNitroEvent(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, event => { if(event.id !== songId) return; @@ -347,8 +347,9 @@ export const InfoStandWidgetFurniView: FC = props
} - { avatarInfo.image && avatarInfo.image.src.length && - } + + +
diff --git a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx index 5f2641c0..8c759121 100644 --- a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx +++ b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx @@ -3,7 +3,7 @@ import { Dispatch, FC, FocusEvent, KeyboardEvent, SetStateAction, useEffect, use import { FaPencilAlt, FaTimes } from 'react-icons/fa'; import { AvatarInfoUser, CloneObject, GetConfiguration, GetGroupInformation, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../../../../api'; import { Column, Flex, LayoutAvatarImageView, LayoutBadgeImageView, Text, UserProfileIconView } from '../../../../../common'; -import { useMessageEvent, useRoom, useRoomSessionManagerEvent } from '../../../../../hooks'; +import { useMessageEvent, useNitroEvent, useRoom } from '../../../../../hooks'; import { InfoStandWidgetUserRelationshipsView } from './InfoStandWidgetUserRelationshipsView'; import { InfoStandWidgetUserTagsView } from './InfoStandWidgetUserTagsView'; @@ -45,7 +45,7 @@ export const InfoStandWidgetUserView: FC = props = } } - useRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, event => + useNitroEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, event => { if(!avatarInfo || (avatarInfo.webID !== event.userId)) return; @@ -63,7 +63,7 @@ export const InfoStandWidgetUserView: FC = props = }); }); - useRoomSessionManagerEvent(RoomSessionUserFigureUpdateEvent.USER_FIGURE, event => + useNitroEvent(RoomSessionUserFigureUpdateEvent.USER_FIGURE, event => { if(!avatarInfo || (avatarInfo.roomIndex !== event.roomIndex)) return; @@ -79,7 +79,7 @@ export const InfoStandWidgetUserView: FC = props = }); }); - useRoomSessionManagerEvent(RoomSessionFavoriteGroupUpdateEvent.FAVOURITE_GROUP_UPDATE, event => + useNitroEvent(RoomSessionFavoriteGroupUpdateEvent.FAVOURITE_GROUP_UPDATE, event => { if(!avatarInfo || (avatarInfo.roomIndex !== event.roomIndex)) return; diff --git a/src/components/room/widgets/furniture/FurnitureDimmerView.tsx b/src/components/room/widgets/furniture/FurnitureDimmerView.tsx index 1cf53baa..1cb1a3e1 100644 --- a/src/components/room/widgets/furniture/FurnitureDimmerView.tsx +++ b/src/components/room/widgets/furniture/FurnitureDimmerView.tsx @@ -2,8 +2,8 @@ import { RoomEngineTriggerWidgetEvent } from '@nitrots/nitro-renderer'; import { FC, useEffect, useMemo, useState } from 'react'; import ReactSlider from 'react-slider'; import { ColorUtils, FurnitureDimmerUtilities, GetConfiguration, LocalizeText } from '../../../../api'; -import { Base, Button, classNames, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, Text } from '../../../../common'; -import { useFurnitureDimmerWidget, useRoomEngineEvent } from '../../../../hooks'; +import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, Text, classNames } from '../../../../common'; +import { useFurnitureDimmerWidget, useNitroEvent } from '../../../../hooks'; export const FurnitureDimmerView: FC<{}> = props => { @@ -17,7 +17,7 @@ export const FurnitureDimmerView: FC<{}> = props => setIsVisible(false); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, event => setIsVisible(false)); + useNitroEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, event => setIsVisible(false)); useEffect(() => { diff --git a/src/components/room/widgets/mysterybox/MysteryBoxExtensionView.tsx b/src/components/room/widgets/mysterybox/MysteryBoxExtensionView.tsx index 83ae06cf..3f698262 100644 --- a/src/components/room/widgets/mysterybox/MysteryBoxExtensionView.tsx +++ b/src/components/room/widgets/mysterybox/MysteryBoxExtensionView.tsx @@ -3,7 +3,7 @@ import { FC, useState } from 'react'; import { FaChevronDown, FaChevronUp } from 'react-icons/fa'; import { ColorUtils, LocalizeText } from '../../../../api'; import { Base, Column, Flex, LayoutGridItem, Text } from '../../../../common'; -import { useSessionDataManagerEvent } from '../../../../hooks'; +import { useNitroEvent } from '../../../../hooks'; const colorMap = { 'purple': 9452386, @@ -22,7 +22,7 @@ export const MysteryBoxExtensionView: FC<{}> = props => const [ keyColor, setKeyColor ] = useState(''); const [ boxColor, setBoxColor ] = useState(''); - useSessionDataManagerEvent(MysteryBoxKeysUpdateEvent.MYSTERY_BOX_KEYS_UPDATE, event => + useNitroEvent(MysteryBoxKeysUpdateEvent.MYSTERY_BOX_KEYS_UPDATE, event => { setKeyColor(event.keyColor); setBoxColor(event.boxColor); diff --git a/src/components/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx b/src/components/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx index 055e7341..5476de6d 100644 --- a/src/components/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx +++ b/src/components/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx @@ -29,9 +29,9 @@ export const RoomThumbnailWidgetView: FC<{}> = props => } }); - const receiveTexture = (texture: NitroRenderTexture) => + const receiveTexture = async (texture: NitroRenderTexture) => { - GetRoomEngine().saveTextureAsScreenshot(texture, true); + await GetRoomEngine().saveTextureAsScreenshot(texture, true); setIsVisible(false); } diff --git a/src/components/toolbar/ToolbarView.tsx b/src/components/toolbar/ToolbarView.tsx index 0efab76f..0526baba 100644 --- a/src/components/toolbar/ToolbarView.tsx +++ b/src/components/toolbar/ToolbarView.tsx @@ -2,7 +2,7 @@ import { Dispose, DropBounce, EaseOut, JumpBy, Motions, NitroToolbarAnimateIconE import { FC, useState } from 'react'; import { CreateLinkEvent, GetConfiguration, GetSessionDataManager, MessengerIconState, OpenMessengerChat, VisitDesktop } from '../../api'; import { Base, Flex, LayoutAvatarImageView, LayoutItemCountView, TransitionAnimation, TransitionAnimationTypes } from '../../common'; -import { useAchievements, useFriends, useInventoryUnseenTracker, useMessageEvent, useMessenger, useRoomEngineEvent, useSessionInfo } from '../../hooks'; +import { useAchievements, useFriends, useInventoryUnseenTracker, useMessageEvent, useMessenger, useNitroEvent, useSessionInfo } from '../../hooks'; import { ToolbarMeView } from './ToolbarMeView'; export const ToolbarView: FC<{ isInRoom: boolean }> = props => @@ -24,7 +24,7 @@ export const ToolbarView: FC<{ isInRoom: boolean }> = props => setUseGuideTool(parser.isAllowed(PerkEnum.USE_GUIDE_TOOL)); }); - useRoomEngineEvent(NitroToolbarAnimateIconEvent.ANIMATE_ICON, event => + useNitroEvent(NitroToolbarAnimateIconEvent.ANIMATE_ICON, event => { const animationIconToToolbar = (iconName: string, image: HTMLImageElement, x: number, y: number) => { diff --git a/src/components/user-profile/UserProfileView.tsx b/src/components/user-profile/UserProfileView.tsx index 6327c293..71773367 100644 --- a/src/components/user-profile/UserProfileView.tsx +++ b/src/components/user-profile/UserProfileView.tsx @@ -2,7 +2,7 @@ import { ExtendedProfileChangedMessageEvent, RelationshipStatusInfoEvent, Relati import { FC, useState } from 'react'; import { CreateLinkEvent, GetRoomSession, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api'; import { Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; -import { useMessageEvent, useRoomEngineEvent } from '../../hooks'; +import { useMessageEvent, useNitroEvent } from '../../hooks'; import { BadgesContainerView } from './views/BadgesContainerView'; import { FriendsContainerView } from './views/FriendsContainerView'; import { GroupsContainerView } from './views/GroupsContainerView'; @@ -78,7 +78,7 @@ export const UserProfileView: FC<{}> = props => GetUserProfile(parser.userId); }); - useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, event => + useNitroEvent(RoomEngineObjectEvent.SELECTED, event => { if(!userProfile) return; diff --git a/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx b/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx index 824d7ae8..8ef5914b 100644 --- a/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx +++ b/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx @@ -8,7 +8,7 @@ import { WiredConditionBaseView } from './WiredConditionBaseView'; export const WiredConditionUserCountInRoomView: FC<{}> = props => { const [ min, setMin ] = useState(1); - const [ max, setMax ] = useState(1); + const [ max, setMax ] = useState(0); const { trigger = null, setIntParams = null } = useWired(); const save = () => setIntParams([ min, max ]); @@ -23,7 +23,7 @@ export const WiredConditionUserCountInRoomView: FC<{}> = props => else { setMin(1); - setMax(1); + setMax(0); } }, [ trigger ]); @@ -42,8 +42,8 @@ export const WiredConditionUserCountInRoomView: FC<{}> = props => { LocalizeText('wiredfurni.params.usercountmax', [ 'value' ], [ max.toString() ]) } setMax(event) } />
diff --git a/src/hooks/camera/useCamera.ts b/src/hooks/camera/useCamera.ts index e2449c80..475b5b0d 100644 --- a/src/hooks/camera/useCamera.ts +++ b/src/hooks/camera/useCamera.ts @@ -2,7 +2,7 @@ import { InitCameraMessageEvent, IRoomCameraWidgetEffect, RequestCameraConfigura import { useEffect, useState } from 'react'; import { useBetween } from 'use-between'; import { CameraPicture, GetRoomCameraWidgetManager, SendMessageComposer } from '../../api'; -import { useCameraEvent, useMessageEvent } from '../events'; +import { useMessageEvent, useNitroEvent } from '../events'; const useCameraState = () => { @@ -12,7 +12,7 @@ const useCameraState = () => const [ myLevel, setMyLevel ] = useState(10); const [ price, setPrice ] = useState<{ credits: number, duckets: number, publishDucketPrice: number }>(null); - useCameraEvent(RoomCameraWidgetManagerEvent.INITIALIZED, event => + useNitroEvent(RoomCameraWidgetManagerEvent.INITIALIZED, event => { setAvailableEffects(Array.from(GetRoomCameraWidgetManager().effects.values())); }); diff --git a/src/hooks/catalog/useCatalog.ts b/src/hooks/catalog/useCatalog.ts index 6572baa6..30099f9b 100644 --- a/src/hooks/catalog/useCatalog.ts +++ b/src/hooks/catalog/useCatalog.ts @@ -2,8 +2,8 @@ import { BuildersClubFurniCountMessageEvent, BuildersClubPlaceRoomItemMessageCom import { useCallback, useEffect, useRef, useState } from 'react'; import { useBetween } from 'use-between'; import { BuilderFurniPlaceableStatus, CatalogNode, CatalogPage, CatalogPetPalette, CatalogType, CreateLinkEvent, DispatchUiEvent, FurniCategory, GetFurnitureData, GetProductDataForLocalization, GetRoomEngine, GetRoomSession, GiftWrappingConfiguration, ICatalogNode, ICatalogOptions, ICatalogPage, IPageLocalization, IProduct, IPurchasableOffer, IPurchaseOptions, LocalizeText, NotificationAlertType, Offer, PageLocalization, PlacedObjectPurchaseData, PlaySound, Product, ProductTypeEnum, RequestedPage, SearchResult, SendMessageComposer, SoundNames } from '../../api'; -import { CatalogPurchasedEvent, CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent, InventoryFurniAddedEvent } from '../../events'; -import { useMessageEvent, useRoomEngineEvent, useUiEvent } from '../events'; +import { CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent, CatalogPurchasedEvent, InventoryFurniAddedEvent } from '../../events'; +import { useMessageEvent, useNitroEvent, useUiEvent } from '../events'; import { useNotification } from '../notification'; import { useCatalogPlaceMultipleItems } from './useCatalogPlaceMultipleItems'; import { useCatalogSkipPurchaseConfirmation } from './useCatalogSkipPurchaseConfirmation'; @@ -685,7 +685,7 @@ const useCatalogState = () => useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, event => PlaySound(SoundNames.CREDITS)); - useRoomEngineEvent(RoomEngineObjectPlacedEvent.PLACED, event => + useNitroEvent(RoomEngineObjectPlacedEvent.PLACED, event => { if(!objectMoverRequested || (event.type !== RoomEngineObjectPlacedEvent.PLACED)) return; diff --git a/src/hooks/chat-history/useChatHistory.ts b/src/hooks/chat-history/useChatHistory.ts index a2f3c346..b8545a0c 100644 --- a/src/hooks/chat-history/useChatHistory.ts +++ b/src/hooks/chat-history/useChatHistory.ts @@ -2,7 +2,7 @@ import { GetGuestRoomResultEvent, NewConsoleMessageEvent, RoomInviteEvent, RoomS import { useState } from 'react'; import { useBetween } from 'use-between'; import { ChatEntryType, ChatHistoryCurrentDate, IChatEntry, IRoomHistoryEntry, MessengerHistoryCurrentDate } from '../../api'; -import { useMessageEvent, useRoomSessionManagerEvent } from '../events'; +import { useMessageEvent, useNitroEvent } from '../events'; const CHAT_HISTORY_MAX = 1000; const ROOM_HISTORY_MAX = 10; @@ -64,7 +64,7 @@ const useChatHistoryState = () => }); } - useRoomSessionManagerEvent(RoomSessionEvent.STARTED, event => setNeedsRoomInsert(true)); + useNitroEvent(RoomSessionEvent.STARTED, event => setNeedsRoomInsert(true)); useMessageEvent(GetGuestRoomResultEvent, event => { diff --git a/src/hooks/events/core/index.ts b/src/hooks/events/core/index.ts deleted file mode 100644 index b69a57e3..00000000 --- a/src/hooks/events/core/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './useCommunicationEvent'; -export * from './useConfigurationEvent'; diff --git a/src/hooks/events/core/useCommunicationEvent.tsx b/src/hooks/events/core/useCommunicationEvent.tsx deleted file mode 100644 index 83d6ed5c..00000000 --- a/src/hooks/events/core/useCommunicationEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetCommunication } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useCommunicationEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetCommunication().events, handler); diff --git a/src/hooks/events/core/useConfigurationEvent.tsx b/src/hooks/events/core/useConfigurationEvent.tsx deleted file mode 100644 index 617e9a23..00000000 --- a/src/hooks/events/core/useConfigurationEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetConfigurationManager } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useConfigurationEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetConfigurationManager().events, handler); diff --git a/src/hooks/events/index.ts b/src/hooks/events/index.ts index cafd7933..6d9903b6 100644 --- a/src/hooks/events/index.ts +++ b/src/hooks/events/index.ts @@ -1,5 +1,4 @@ -export * from './core'; -export * from './nitro'; export * from './useEventDispatcher'; export * from './useMessageEvent'; +export * from './useNitroEvent'; export * from './useUiEvent'; diff --git a/src/hooks/events/nitro/index.ts b/src/hooks/events/nitro/index.ts deleted file mode 100644 index 2248da9e..00000000 --- a/src/hooks/events/nitro/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './useAvatarEvent'; -export * from './useCameraEvent'; -export * from './useLocalizationEvent'; -export * from './useMainEvent'; -export * from './useRoomEngineEvent'; -export * from './useRoomSessionManagerEvent'; -export * from './useSessionDataManagerEvent'; -export * from './useSoundEvent'; diff --git a/src/hooks/events/nitro/useAvatarEvent.tsx b/src/hooks/events/nitro/useAvatarEvent.tsx deleted file mode 100644 index 9212a688..00000000 --- a/src/hooks/events/nitro/useAvatarEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetAvatarRenderManager } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useAvatarEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetAvatarRenderManager().events, handler); diff --git a/src/hooks/events/nitro/useCameraEvent.tsx b/src/hooks/events/nitro/useCameraEvent.tsx deleted file mode 100644 index 42bee39e..00000000 --- a/src/hooks/events/nitro/useCameraEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useCameraEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetNitroInstance().cameraManager.events, handler); diff --git a/src/hooks/events/nitro/useLocalizationEvent.tsx b/src/hooks/events/nitro/useLocalizationEvent.tsx deleted file mode 100644 index 0dccbdc6..00000000 --- a/src/hooks/events/nitro/useLocalizationEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useLocalizationEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetNitroInstance().localization.events, handler); diff --git a/src/hooks/events/nitro/useMainEvent.tsx b/src/hooks/events/nitro/useMainEvent.tsx deleted file mode 100644 index 8a2ad8b9..00000000 --- a/src/hooks/events/nitro/useMainEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useMainEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetNitroInstance().events, handler); diff --git a/src/hooks/events/nitro/useRoomEngineEvent.tsx b/src/hooks/events/nitro/useRoomEngineEvent.tsx deleted file mode 100644 index 6d2d4199..00000000 --- a/src/hooks/events/nitro/useRoomEngineEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetRoomEngine } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useRoomEngineEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetRoomEngine().events, handler); diff --git a/src/hooks/events/nitro/useRoomSessionManagerEvent.tsx b/src/hooks/events/nitro/useRoomSessionManagerEvent.tsx deleted file mode 100644 index 5cccb98c..00000000 --- a/src/hooks/events/nitro/useRoomSessionManagerEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetRoomSessionManager } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useRoomSessionManagerEvent = (type: string | string[], handler: (event: T) => void) => useEventDispatcher(type, GetRoomSessionManager().events, handler); diff --git a/src/hooks/events/nitro/useSessionDataManagerEvent.tsx b/src/hooks/events/nitro/useSessionDataManagerEvent.tsx deleted file mode 100644 index fa49271a..00000000 --- a/src/hooks/events/nitro/useSessionDataManagerEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetSessionDataManager } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useSessionDataManagerEvent = (type: string | string, handler: (event: T) => void) => useEventDispatcher(type, GetSessionDataManager().events, handler); diff --git a/src/hooks/events/nitro/useSoundEvent.tsx b/src/hooks/events/nitro/useSoundEvent.tsx deleted file mode 100644 index 4bfbd5d8..00000000 --- a/src/hooks/events/nitro/useSoundEvent.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../api'; -import { useEventDispatcher } from '../useEventDispatcher'; - -export const useSoundEvent = (type: string | string[], handler: (event: T) => void, enabled = true) => useEventDispatcher(type, GetNitroInstance().soundManager.events, handler, enabled); diff --git a/src/hooks/events/useNitroEvent.tsx b/src/hooks/events/useNitroEvent.tsx new file mode 100644 index 00000000..14a0499c --- /dev/null +++ b/src/hooks/events/useNitroEvent.tsx @@ -0,0 +1,4 @@ +import { NitroEvent, NitroEventDispatcher } from '@nitrots/nitro-renderer'; +import { useEventDispatcher } from './useEventDispatcher'; + +export const useNitroEvent = (type: string | string[], handler: (event: T) => void, enabled = true) => useEventDispatcher(type, NitroEventDispatcher, handler, enabled); diff --git a/src/hooks/index.ts b/src/hooks/index.ts index a5515749..377fa9ec 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,10 +1,9 @@ +export * from './UseMountEffect'; export * from './achievements'; export * from './camera'; export * from './catalog'; export * from './chat-history'; export * from './events'; -export * from './events/core'; -export * from './events/nitro'; export * from './friends'; export * from './game-center'; export * from './groups'; @@ -17,6 +16,5 @@ export * from './purse'; export * from './rooms'; export * from './session'; export * from './useLocalStorage'; -export * from './UseMountEffect'; export * from './useSharedVisibility'; export * from './wired'; diff --git a/src/hooks/notification/useNotification.ts b/src/hooks/notification/useNotification.ts index 0089b867..7818d85d 100644 --- a/src/hooks/notification/useNotification.ts +++ b/src/hooks/notification/useNotification.ts @@ -258,7 +258,7 @@ const useNotificationState = () => simpleAlert( LocalizeText(('opening.hours.' + (parser.userThrowOutAtClose ? 'disconnected' : 'closed')), [ 'h', 'm' ], [ getTimeZeroPadded(parser.openHour), getTimeZeroPadded(parser.openMinute) ]), NotificationAlertType.DEFAULT, null, null, LocalizeText('opening.hours.title')); }); - useMessageEvent(PetReceivedMessageEvent, event => + useMessageEvent(PetReceivedMessageEvent, async event => { const parser = event.getParser(); @@ -268,7 +268,7 @@ const useNotificationState = () => const imageResult = GetRoomEngine().getRoomObjectPetImage(parser.pet.typeId, parser.pet.paletteId, parseInt(parser.pet.color, 16), new Vector3d(45 * 3), 64, null, true); - if(imageResult) imageUrl = imageResult.getImage().src; + if(imageResult) imageUrl = (await imageResult.getImage())?.src; showSingleBubble(text, NotificationBubbleType.PETLEVEL, imageUrl); }); @@ -284,7 +284,7 @@ const useNotificationState = () => setAlerts(prevValue => [ alertItem, ...prevValue ]); }); - useMessageEvent(PetLevelNotificationEvent, event => + useMessageEvent(PetLevelNotificationEvent, async event => { const parser = event.getParser(); @@ -292,7 +292,7 @@ const useNotificationState = () => const imageResult = GetRoomEngine().getRoomObjectPetImage(parser.figureData.typeId, parser.figureData.paletteId, parseInt(parser.figureData.color, 16), new Vector3d(45 * 3), 64, null, true); - if(imageResult) imageUrl = imageResult.getImage().src; + if(imageResult) imageUrl = (await imageResult.getImage())?.src; showSingleBubble(LocalizeText('notifications.text.petlevel', [ 'pet_name', 'level' ], [ parser.petName, parser.level.toString() ]), NotificationBubbleType.PETLEVEL, imageUrl); }); diff --git a/src/hooks/rooms/useRoom.ts b/src/hooks/rooms/useRoom.ts index af1c12ac..55bac4f2 100644 --- a/src/hooks/rooms/useRoom.ts +++ b/src/hooks/rooms/useRoom.ts @@ -2,7 +2,7 @@ import { AdjustmentFilter, ColorConverter, IRoomSession, NitroContainer, NitroSp import { useEffect, useState } from 'react'; import { useBetween } from 'use-between'; import { CanManipulateFurniture, DispatchUiEvent, GetNitroInstance, GetRoomEngine, GetRoomSession, InitializeRoomInstanceRenderingCanvas, IsFurnitureSelectionDisabled, ProcessRoomObjectOperation, RoomWidgetUpdateBackgroundColorPreviewEvent, RoomWidgetUpdateRoomObjectEvent, SetActiveRoomId, StartRoomSession } from '../../api'; -import { useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../events'; +import { useNitroEvent, useUiEvent } from '../events'; const useRoomState = () => { @@ -51,7 +51,7 @@ const useRoomState = () => roomBackground.tint = originalRoomBackgroundColor; }); - useRoomEngineEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, event => + useNitroEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, event => { if(RoomId.isRoomPreviewerId(event.roomId)) return; @@ -59,7 +59,7 @@ const useRoomState = () => else updateRoomBackgroundColor(0, 0, 0, true); }); - useRoomEngineEvent(RoomBackgroundColorEvent.ROOM_COLOR, event => + useNitroEvent(RoomBackgroundColorEvent.ROOM_COLOR, event => { if(RoomId.isRoomPreviewerId(event.roomId)) return; @@ -75,7 +75,7 @@ const useRoomState = () => updateRoomFilter(ColorConverter.hslToRGB(((ColorConverter.rgbToHSL(color) & 0xFFFF00) + brightness))); }); - useRoomEngineEvent([ + useNitroEvent([ RoomEngineEvent.INITIALIZED, RoomEngineEvent.DISPOSED ], event => @@ -98,7 +98,7 @@ const useRoomState = () => } }); - useRoomSessionManagerEvent([ + useNitroEvent([ RoomSessionEvent.CREATED, RoomSessionEvent.ENDED ], event => @@ -114,7 +114,7 @@ const useRoomState = () => } }); - useRoomEngineEvent([ + useNitroEvent([ RoomEngineObjectEvent.SELECTED, RoomEngineObjectEvent.DESELECTED, RoomEngineObjectEvent.ADDED, @@ -205,13 +205,7 @@ const useRoomState = () => const height = Math.floor(window.innerHeight); const renderer = nitroInstance.application.renderer; - if(renderer) - { - renderer.view.style.width = `${ width }px`; - renderer.view.style.height = `${ height }px`; - renderer.resolution = window.devicePixelRatio; - renderer.resize(width, height); - } + if(renderer) renderer.resize(width, height); const displayObject = roomEngine.getRoomInstanceDisplay(roomId, canvasId, width, height, RoomGeometry.SCALE_ZOOMED_IN); const canvas = GetRoomEngine().getRoomInstanceRenderingCanvas(roomId, canvasId); @@ -267,9 +261,6 @@ const useRoomState = () => const width = Math.floor(window.innerWidth); const height = Math.floor(window.innerHeight); - renderer.view.style.width = `${ width }px`; - renderer.view.style.height = `${ height }px`; - renderer.resolution = window.devicePixelRatio; renderer.resize(width, height); background.width = width; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureBackgroundColorWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureBackgroundColorWidget.ts index 273a0372..d27ad639 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureBackgroundColorWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureBackgroundColorWidget.ts @@ -1,7 +1,7 @@ import { ApplyTonerComposer, ColorConverter, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { CanManipulateFurniture, ColorUtils, DispatchUiEvent, GetRoomEngine, RoomWidgetUpdateBackgroundColorPreviewEvent, SendMessageComposer } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; import { useRoom } from '../../useRoom'; @@ -30,7 +30,7 @@ const useFurnitureBackgroundColorWidgetState = () => setColor(0); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, event => { if(!CanManipulateFurniture(roomSession, event.objectId, event.category)) return; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureBadgeDisplayWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureBadgeDisplayWidget.ts index 5ef2bfc4..39500188 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureBadgeDisplayWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureBadgeDisplayWidget.ts @@ -1,7 +1,7 @@ import { RoomEngineTriggerWidgetEvent, RoomObjectVariable, StringDataType } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, GetSessionDataManager, LocalizeBadgeDescription, LocalizeBadgeName, LocalizeText } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useNotification } from '../../../notification'; import { useFurniRemovedEvent } from '../../engine'; @@ -27,7 +27,7 @@ const useFurnitureBadgeDisplayWidgetState = () => setSenderName(''); } - useRoomEngineEvent([ + useNitroEvent([ RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING ], event => @@ -49,7 +49,7 @@ const useFurnitureBadgeDisplayWidgetState = () => setSenderName(stringStuff.getValue(3)); }); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureContextMenuWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureContextMenuWidget.ts index 74aecb96..9e5310d6 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureContextMenuWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureContextMenuWidget.ts @@ -1,7 +1,7 @@ import { ContextMenuEnum, GroupFurniContextMenuInfoMessageEvent, GroupFurniContextMenuInfoMessageParser, RoomEngineTriggerWidgetEvent, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, IsOwnerOfFurniture, TryJoinGroup, TryVisitRoom } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; import { useRoom } from '../../useRoom'; export const MONSTERPLANT_SEED_CONFIRMATION: string = 'MONSTERPLANT_SEED_CONFIRMATION'; @@ -75,7 +75,7 @@ const useFurnitureContextMenuWidgetState = () => onClose(); } - useRoomEngineEvent([ + useNitroEvent([ RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts index fc73c7d7..9c4aa9cc 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts @@ -1,7 +1,7 @@ import { CraftableProductsEvent, CraftComposer, CraftingRecipeEvent, CraftingRecipeIngredientParser, CraftingRecipesAvailableEvent, CraftingResultEvent, GetCraftableProductsComposer, GetCraftingRecipeComposer, RoomEngineTriggerWidgetEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { GetRoomEngine, ICraftingIngredient, ICraftingRecipe, LocalizeText, SendMessageComposer } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; import { useInventoryFurni } from '../../../inventory'; import { useNotification } from './../../../notification'; @@ -49,7 +49,7 @@ const useFurnitureCraftingWidgetState = () => if(!cache) SendMessageComposer(new GetCraftingRecipeComposer(recipe.name)); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, event => { if (event.widget !== RoomWidgetEnum.CRAFTING) return; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureDimmerWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureDimmerWidget.ts index 6ac8f89f..d56a38ec 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureDimmerWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureDimmerWidget.ts @@ -1,7 +1,7 @@ import { RoomControllerLevel, RoomEngineDimmerStateEvent, RoomEngineTriggerWidgetEvent, RoomId, RoomSessionDimmerPresetsEvent } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { DimmerFurnitureWidgetPresetItem, FurnitureDimmerUtilities, GetSessionDataManager } from '../../../../api'; -import { useRoomEngineEvent, useRoomSessionManagerEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useRoom } from '../../useRoom'; const useFurnitureDimmerWidgetState = () => @@ -56,14 +56,14 @@ const useFurnitureDimmerWidgetState = () => FurnitureDimmerUtilities.savePreset(preset.id, selectedEffectId, selectedColor, selectedBrightness, true); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, event => { if(!canOpenWidget()) return; roomSession.requestMoodlightSettings(); }); - useRoomSessionManagerEvent(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, event => + useNitroEvent(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, event => { const presets: DimmerFurnitureWidgetPresetItem[] = []; @@ -82,7 +82,7 @@ const useFurnitureDimmerWidgetState = () => setSelectedPresetId(event.selectedPresetId); }); - useRoomEngineEvent(RoomEngineDimmerStateEvent.ROOM_COLOR, event => + useNitroEvent(RoomEngineDimmerStateEvent.ROOM_COLOR, event => { if(RoomId.isRoomPreviewerId(event.roomId)) return; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureExchangeWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureExchangeWidget.ts index 0dbb3d4f..875d946b 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureExchangeWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureExchangeWidget.ts @@ -1,7 +1,7 @@ import { FurnitureExchangeComposer, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, GetRoomSession, IsOwnerOfFurniture } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const useFurnitureExchangeWidgetState = () => @@ -24,7 +24,7 @@ const useFurnitureExchangeWidgetState = () => onClose(); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureExternalImageWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureExternalImageWidget.ts index a628eb03..78e3d03e 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureExternalImageWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureExternalImageWidget.ts @@ -1,7 +1,7 @@ import { RoomEngineTriggerWidgetEvent, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, IPhotoData } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; import { useRoom } from '../../useRoom'; @@ -21,7 +21,7 @@ const useFurnitureExternalImageWidgetState = () => setCurrentPhotos([]); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_EXTERNAL_IMAGE, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_EXTERNAL_IMAGE, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); const roomTotalImages = GetRoomEngine().getRoomObjects(roomSession?.roomId, RoomObjectCategory.WALL); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureFriendFurniWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureFriendFurniWidget.ts index e658189d..e1aa5758 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureFriendFurniWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureFriendFurniWidget.ts @@ -1,7 +1,7 @@ import { FriendFurniConfirmLockMessageComposer, LoveLockFurniFinishedEvent, LoveLockFurniFriendConfirmedEvent, LoveLockFurniStartEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, GetRoomSession } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const useFurnitureFriendFurniWidgetState = () => @@ -42,7 +42,7 @@ const useFurnitureFriendFurniWidgetState = () => useMessageEvent(LoveLockFurniFinishedEvent, event => onClose()); useMessageEvent(LoveLockFurniFriendConfirmedEvent, event => onClose()); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureHighScoreWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureHighScoreWidget.ts index 0d986d51..a339b244 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureHighScoreWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureHighScoreWidget.ts @@ -1,7 +1,7 @@ import { HighScoreDataType, ObjectDataFactory, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useRoom } from '../../useRoom'; const SCORE_TYPES = [ 'perteam', 'mostwins', 'classic' ]; @@ -15,7 +15,7 @@ const useFurnitureHighScoreWidgetState = () => const getScoreType = (type: number) => SCORE_TYPES[type]; const getClearType = (type: number) => CLEAR_TYPES[type]; - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); @@ -36,7 +36,7 @@ const useFurnitureHighScoreWidgetState = () => }); }); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, event => { if(event.roomId !== roomSession.roomId) return; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureInternalLinkWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureInternalLinkWidget.ts index c1b68801..ab364b94 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureInternalLinkWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureInternalLinkWidget.ts @@ -1,12 +1,12 @@ import { RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { CreateLinkEvent, GetRoomEngine } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; const INTERNALLINK = 'internalLink'; const useFurnitureInternalLinkWidgetState = () => { - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureMannequinWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureMannequinWidget.ts index 60429757..e69fe4a4 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureMannequinWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureMannequinWidget.ts @@ -1,7 +1,7 @@ import { FurnitureMannequinSaveLookComposer, FurnitureMannequinSaveNameComposer, FurnitureMultiStateComposer, HabboClubLevelEnum, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetAvatarRenderManager, GetRoomEngine, MannequinUtilities, SendMessageComposer } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const useFurnitureMannequinWidgetState = () => @@ -47,7 +47,7 @@ const useFurnitureMannequinWidgetState = () => SendMessageComposer(new FurnitureMannequinSaveNameComposer(objectId, name)); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurniturePlaylistEditorWidget.ts b/src/hooks/rooms/widgets/furniture/useFurniturePlaylistEditorWidget.ts index 05607f0d..851447e1 100644 --- a/src/hooks/rooms/widgets/furniture/useFurniturePlaylistEditorWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurniturePlaylistEditorWidget.ts @@ -1,7 +1,7 @@ import { AddJukeboxDiskComposer, AdvancedMap, FurnitureListAddOrUpdateEvent, FurnitureListEvent, FurnitureListRemovedEvent, FurnitureMultiStateComposer, IAdvancedMap, IMessageEvent, ISongInfo, NotifyPlayedSongEvent, NowPlayingEvent, PlayListStatusEvent, RemoveJukeboxDiskComposer, RoomControllerLevel, RoomEngineTriggerWidgetEvent, SongDiskInventoryReceivedEvent } from '@nitrots/nitro-renderer'; import { useCallback, useState } from 'react'; import { GetNitroInstance, GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture, LocalizeText, NotificationAlertType, NotificationBubbleType, SendMessageComposer } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent, useSoundEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; import { useNotification } from '../../../notification'; import { useFurniRemovedEvent } from '../../engine'; import { useRoom } from '../../useRoom'; @@ -28,7 +28,7 @@ const useFurniturePlaylistEditorWidgetState = () => const togglePlayPause = useCallback((furniId: number, position: number) => SendMessageComposer(new FurnitureMultiStateComposer(furniId, position)), []); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); @@ -56,27 +56,27 @@ const useFurniturePlaylistEditorWidgetState = () => onClose(); }); - useSoundEvent(NowPlayingEvent.NPE_SONG_CHANGED, event => + useNitroEvent(NowPlayingEvent.NPE_SONG_CHANGED, event => { setCurrentPlayingIndex(event.position); }); - useSoundEvent(NotifyPlayedSongEvent.NOTIFY_PLAYED_SONG, event => + useNitroEvent(NotifyPlayedSongEvent.NOTIFY_PLAYED_SONG, event => { showSingleBubble(LocalizeText('soundmachine.notification.playing', [ 'songname', 'songauthor' ], [ event.name, event.creator ]), NotificationBubbleType.SOUNDMACHINE) }); - useSoundEvent(SongDiskInventoryReceivedEvent.SDIR_SONG_DISK_INVENTORY_RECEIVENT_EVENT, event => + useNitroEvent(SongDiskInventoryReceivedEvent.SDIR_SONG_DISK_INVENTORY_RECEIVENT_EVENT, event => { setDiskInventory(GetNitroInstance().soundManager.musicController?.songDiskInventory.clone()); }); - useSoundEvent(PlayListStatusEvent.PLUE_PLAY_LIST_UPDATED, event => + useNitroEvent(PlayListStatusEvent.PLUE_PLAY_LIST_UPDATED, event => { setPlaylist(GetNitroInstance().soundManager.musicController?.getRoomItemPlaylist()?.entries.concat()) }); - useSoundEvent(PlayListStatusEvent.PLUE_PLAY_LIST_FULL, event => + useNitroEvent(PlayListStatusEvent.PLUE_PLAY_LIST_FULL, event => { simpleAlert(LocalizeText('playlist.editor.alert.playlist.full'), NotificationAlertType.ALERT, '', '', LocalizeText('playlist.editor.alert.playlist.full.title')); }); diff --git a/src/hooks/rooms/widgets/furniture/useFurniturePresentWidget.ts b/src/hooks/rooms/widgets/furniture/useFurniturePresentWidget.ts index 8342b512..8e329294 100644 --- a/src/hooks/rooms/widgets/furniture/useFurniturePresentWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurniturePresentWidget.ts @@ -2,7 +2,7 @@ import { IFurnitureData, IGetImageListener, PetFigureData, RoomEngineTriggerWidg import { useMemo, useState } from 'react'; import { useRoom } from '../../..'; import { GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture, LocalizeText, ProductTypeEnum } from '../../../../api'; -import { useRoomEngineEvent, useRoomSessionManagerEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const FLOOR: string = 'floor'; @@ -51,21 +51,25 @@ const useFurniturePresentWidgetState = () => const imageListener: IGetImageListener = useMemo(() => { + // async fix image return { imageReady: (id, texture, image) => { - if(!image && texture) + (async () => { - image = TextureUtils.generateImage(texture); - } + if(!image && texture) + { + image = await TextureUtils.generateImage(texture); + } - setImageUrl(image.src); + setImageUrl(image.src); + })(); }, imageFailed: null } }, []); - useRoomSessionManagerEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, event => + useNitroEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, event => { let furniData: IFurnitureData = null; @@ -165,16 +169,22 @@ const useFurniturePresentWidgetState = () => { const petFigureData = new PetFigureData(petfigureString); - const petImage = GetRoomEngine().getRoomObjectPetImage(petFigureData.typeId, petFigureData.paletteId, petFigureData.color, new Vector3d(90), 64, imageListener, true, 0, petFigureData.customParts); + (async () => + { + const petImage = GetRoomEngine().getRoomObjectPetImage(petFigureData.typeId, petFigureData.paletteId, petFigureData.color, new Vector3d(90), 64, imageListener, true, 0, petFigureData.customParts); - if(petImage) setImageUrl(petImage.getImage().src); + if(petImage) setImageUrl((await petImage.getImage()).src); + })(); } } else { - const furniImage = GetRoomEngine().getFurnitureFloorImage(event.classId, new Vector3d(90), 64, imageListener); + (async () => + { + const furniImage = GetRoomEngine().getFurnitureFloorImage(event.classId, new Vector3d(90), 64, imageListener); - if(furniImage) setImageUrl(furniImage.getImage().src); + if(furniImage) setImageUrl((await furniImage.getImage()).src); + })(); } const productData = GetSessionDataManager().getProductData(event.productCode); @@ -193,7 +203,7 @@ const useFurniturePresentWidgetState = () => setPlacedInRoom(event.placedInRoom); }); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureRoomLinkWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureRoomLinkWidget.ts index aa21127d..639c1af1 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureRoomLinkWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureRoomLinkWidget.ts @@ -1,7 +1,7 @@ import { GetGuestRoomMessageComposer, GetGuestRoomResultEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, SendMessageComposer } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; const INTERNALLINK = 'internalLink'; @@ -9,7 +9,7 @@ const useFurnitureRoomLinkWidgetState = () => { const [ roomIdToEnter, setRoomIdToEnter ] = useState(0); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureStackHeightWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureStackHeightWidget.ts index 3f8c851d..4cfd94a0 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureStackHeightWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureStackHeightWidget.ts @@ -1,7 +1,7 @@ import { FurnitureStackHeightComposer, FurnitureStackHeightEvent, RoomEngineTriggerWidgetEvent } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { CanManipulateFurniture, GetRoomEngine, GetRoomSession, SendMessageComposer } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const MAX_HEIGHT: number = 40; @@ -43,7 +43,7 @@ const useFurnitureStackHeightWidgetState = () => updateHeight(parser.height, true); }); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STACK_HEIGHT, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_STACK_HEIGHT, event => { if(!CanManipulateFurniture(GetRoomSession(), event.objectId, event.category)) return; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureStickieWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureStickieWidget.ts index 7cc15975..db095fdc 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureStickieWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureStickieWidget.ts @@ -1,7 +1,7 @@ import { RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, GetRoomSession, GetSessionDataManager, IsOwnerOfFurniture } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const useFurnitureStickieWidgetState = () => @@ -41,7 +41,7 @@ const useFurnitureStickieWidgetState = () => const trash = () => GetRoomEngine().deleteRoomObject(objectId, category); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureTrophyWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureTrophyWidget.ts index d5a1e331..11e956b8 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureTrophyWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureTrophyWidget.ts @@ -1,7 +1,7 @@ import { RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine } from '../../../../api'; -import { useRoomEngineEvent } from '../../../events'; +import { useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const useFurnitureTrophyWidgetState = () => @@ -23,7 +23,7 @@ const useFurnitureTrophyWidgetState = () => setMessage(''); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, event => { const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureYoutubeWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureYoutubeWidget.ts index 79548e78..c67a0a98 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureYoutubeWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureYoutubeWidget.ts @@ -1,7 +1,7 @@ import { ControlYoutubeDisplayPlaybackMessageComposer, GetYoutubeDisplayStatusMessageComposer, RoomEngineTriggerWidgetEvent, RoomId, SecurityLevel, SetYoutubeDisplayPlaylistMessageComposer, YoutubeControlVideoMessageEvent, YoutubeDisplayPlaylist, YoutubeDisplayPlaylistsEvent, YoutubeDisplayVideoMessageEvent } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture, SendMessageComposer, YoutubeVideoPlaybackStateEnum } from '../../../../api'; -import { useMessageEvent, useRoomEngineEvent } from '../../../events'; +import { useMessageEvent, useNitroEvent } from '../../../events'; import { useFurniRemovedEvent } from '../../engine'; const CONTROL_COMMAND_PREVIOUS_VIDEO = 0; @@ -56,7 +56,7 @@ const useFurnitureYoutubeWidgetState = () => SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, video)); } - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_YOUTUBE, event => + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_YOUTUBE, event => { if(RoomId.isRoomPreviewerId(event.roomId)) return; diff --git a/src/hooks/rooms/widgets/useAvatarInfoWidget.ts b/src/hooks/rooms/widgets/useAvatarInfoWidget.ts index 9545362a..82061e91 100644 --- a/src/hooks/rooms/widgets/useAvatarInfoWidget.ts +++ b/src/hooks/rooms/widgets/useAvatarInfoWidget.ts @@ -1,7 +1,7 @@ import { RoomEngineObjectEvent, RoomEngineUseProductEvent, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionPetInfoUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserDataUpdateEvent } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { AvatarInfoFurni, AvatarInfoName, AvatarInfoPet, AvatarInfoRentableBot, AvatarInfoUser, AvatarInfoUtilities, CanManipulateFurniture, FurniCategory, GetRoomEngine, GetSessionDataManager, IAvatarInfo, IsOwnerOfFurniture, RoomWidgetUpdateRoomObjectEvent, UseProductItem } from '../../../api'; -import { useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../../events'; +import { useNitroEvent, useUiEvent } from '../../events'; import { useFriends } from '../../friends'; import { useWired } from '../../wired'; import { useObjectDeselectedEvent, useObjectRollOutEvent, useObjectRollOverEvent, useObjectSelectedEvent } from '../engine'; @@ -113,7 +113,7 @@ const useAvatarInfoWidgetState = () => // roomSession.userDataManager.requestPetInfo(petData.id); } - useRoomSessionManagerEvent(RoomSessionUserDataUpdateEvent.USER_DATA_UPDATED, event => + useNitroEvent(RoomSessionUserDataUpdateEvent.USER_DATA_UPDATED, event => { if(!event.addedUsers.length) return; @@ -148,7 +148,7 @@ const useAvatarInfoWidgetState = () => }); }); - useRoomSessionManagerEvent(RoomSessionPetInfoUpdateEvent.PET_INFO, event => + useNitroEvent(RoomSessionPetInfoUpdateEvent.PET_INFO, event => { const petData = event.petInfo; @@ -164,7 +164,7 @@ const useAvatarInfoWidgetState = () => setPendingPetId(-1); }); - useRoomSessionManagerEvent(RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE, event => + useNitroEvent(RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE, event => { /* var _local_2:Boolean; var _local_3:Boolean; @@ -188,12 +188,12 @@ const useAvatarInfoWidgetState = () => this._container.events.dispatchEvent(_local_7); */ }); - useRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY, event => + useNitroEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY, event => { // this._Str_23199((k as RoomEngineUseProductEvent).inventoryStripId, (k as RoomEngineUseProductEvent).furnitureTypeId); }); - useRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, event => + useNitroEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, event => { const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, event.objectId, RoomObjectCategory.FLOOR); @@ -257,7 +257,7 @@ const useAvatarInfoWidgetState = () => if(useProductBubbles.length) setProductBubbles(useProductBubbles); }); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, event => + useNitroEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, event => { if(!CanManipulateFurniture(roomSession, event.objectId, event.category)) return; diff --git a/src/hooks/rooms/widgets/useChatInputWidget.ts b/src/hooks/rooms/widgets/useChatInputWidget.ts index 5b11ecf7..3cf988e2 100644 --- a/src/hooks/rooms/widgets/useChatInputWidget.ts +++ b/src/hooks/rooms/widgets/useChatInputWidget.ts @@ -1,7 +1,7 @@ -import { AvatarExpressionEnum, GetTicker, HabboClubLevelEnum, RoomControllerLevel, RoomEngineObjectEvent, RoomObjectCategory, RoomRotatingEffect, RoomSessionChatEvent, RoomSettingsComposer, RoomShakingEffect, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer'; +import { AvatarExpressionEnum, GetTicker, HabboClubLevelEnum, NitroEventDispatcher, RoomControllerLevel, RoomEngineObjectEvent, RoomObjectCategory, RoomRotatingEffect, RoomSessionChatEvent, RoomSettingsComposer, RoomShakingEffect, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { ChatMessageTypeEnum, CreateLinkEvent, GetClubMemberLevel, GetConfiguration, GetRoomEngine, GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../../api'; -import { useRoomEngineEvent, useRoomSessionManagerEvent } from '../../events'; +import { useNitroEvent } from '../../events'; import { useNotification } from '../../notification'; import { useObjectSelectedEvent } from '../engine'; import { useRoom } from '../useRoom'; @@ -104,22 +104,25 @@ const useChatInputWidgetState = () => return null; case ':iddqd': case ':flip': - GetRoomEngine().events.dispatchEvent(new RoomZoomEvent(roomSession.roomId, -1, true)); + NitroEventDispatcher.dispatchEvent(new RoomZoomEvent(roomSession.roomId, -1, true)); return null; case ':zoom': - GetRoomEngine().events.dispatchEvent(new RoomZoomEvent(roomSession.roomId, parseFloat(secondPart), false)); + NitroEventDispatcher.dispatchEvent(new RoomZoomEvent(roomSession.roomId, parseFloat(secondPart), false)); return null; case ':screenshot': const texture = GetRoomEngine().createTextureFromRoom(roomSession.roomId, 1); - const image = new Image(); + (async () => + { + const image = new Image(); - image.src = TextureUtils.generateImageUrl(texture); - - const newWindow = window.open(''); - newWindow.document.write(image.outerHTML); + image.src = await TextureUtils.generateImageUrl(texture); + + const newWindow = window.open(''); + newWindow.document.write(image.outerHTML); + })(); return null; case ':pickall': if(roomSession.isRoomOwner || GetSessionDataManager().isModerator) @@ -188,7 +191,7 @@ const useChatInputWidgetState = () => } } - useRoomSessionManagerEvent(RoomSessionChatEvent.FLOOD_EVENT, event => + useNitroEvent(RoomSessionChatEvent.FLOOD_EVENT, event => { setFloodBlocked(true); setFloodBlockedSeconds(parseFloat(event.message)); @@ -205,7 +208,7 @@ const useChatInputWidgetState = () => setSelectedUsername(userData.name); }); - useRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, event => setSelectedUsername('')); + useNitroEvent(RoomEngineObjectEvent.DESELECTED, event => setSelectedUsername('')); useEffect(() => { diff --git a/src/hooks/rooms/widgets/useChatWidget.ts b/src/hooks/rooms/widgets/useChatWidget.ts index 0edfb5f0..22e6f6f6 100644 --- a/src/hooks/rooms/widgets/useChatWidget.ts +++ b/src/hooks/rooms/widgets/useChatWidget.ts @@ -1,14 +1,10 @@ -import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, GetGuestRoomResultEvent, NitroPoint, PetFigureData, RoomChatSettings, RoomChatSettingsEvent, RoomDragEvent, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionChatEvent, RoomUserData, SystemChatStyleEnum, TextureUtils, Vector3d } from '@nitrots/nitro-renderer'; +import { GetGuestRoomResultEvent, NitroPoint, PetFigureData, RoomChatSettings, RoomChatSettingsEvent, RoomDragEvent, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionChatEvent, RoomUserData, SystemChatStyleEnum } from '@nitrots/nitro-renderer'; import { useEffect, useMemo, useRef, useState } from 'react'; -import { ChatBubbleMessage, ChatEntryType, ChatHistoryCurrentDate, GetAvatarRenderManager, GetConfiguration, GetRoomEngine, GetRoomObjectScreenLocation, IRoomChatSettings, LocalizeText, PlaySound, RoomChatFormatter } from '../../../api'; -import { useMessageEvent, useRoomEngineEvent, useRoomSessionManagerEvent } from '../../events'; +import { ChatBubbleMessage, ChatBubbleUtilities, ChatEntryType, ChatHistoryCurrentDate, GetConfiguration, GetRoomEngine, GetRoomObjectScreenLocation, IRoomChatSettings, LocalizeText, PlaySound, RoomChatFormatter } from '../../../api'; +import { useMessageEvent, useNitroEvent } from '../../events'; import { useRoom } from '../useRoom'; import { useChatHistory } from './../../chat-history'; -const avatarColorCache: Map = new Map(); -const avatarImageCache: Map = new Map(); -const petImageCache: Map = new Map(); - const useChatWidgetState = () => { const [ chatMessages, setChatMessages ] = useState([]); @@ -38,64 +34,7 @@ const useChatWidgetState = () => } }, [ chatSettings ]); - const setFigureImage = (figure: string) => - { - const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, { - resetFigure: figure => - { - if(isDisposed.current) return; - - setFigureImage(figure); - }, - dispose: () => - {}, - disposed: false - }); - - if(!avatarImage) return; - - const image = avatarImage.getCroppedImage(AvatarSetType.HEAD); - const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST); - - avatarColorCache.set(figure, ((color && color.rgb) || 16777215)); - - avatarImage.dispose(); - - avatarImageCache.set(figure, image.src); - - return image.src; - } - - const getUserImage = (figure: string) => - { - let existing = avatarImageCache.get(figure); - - if(!existing) existing = setFigureImage(figure); - - return existing; - } - - const getPetImage = (figure: string, direction: number, _arg_3: boolean, scale: number = 64, posture: string = null) => - { - let existing = petImageCache.get((figure + posture)); - - if(existing) return existing; - - const figureData = new PetFigureData(figure); - const typeId = figureData.typeId; - const image = GetRoomEngine().getRoomObjectPetImage(typeId, figureData.paletteId, figureData.color, new Vector3d((direction * 45)), scale, null, false, 0, figureData.customParts, posture); - - if(image) - { - existing = TextureUtils.generateImageUrl(image.data); - - petImageCache.set((figure + posture), existing); - } - - return existing; - } - - useRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, event => + useNitroEvent(RoomSessionChatEvent.CHAT_EVENT, async event => { const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, event.objectId, RoomObjectCategory.UNIT); const bubbleLocation = roomObject ? GetRoomObjectScreenLocation(roomSession.roomId, roomObject?.id, RoomObjectCategory.UNIT) : new NitroPoint(); @@ -119,11 +58,11 @@ const useChatWidgetState = () => switch(userType) { case RoomObjectType.PET: - imageUrl = getPetImage(figure, 2, true, 64, roomObject.model.getValue(RoomObjectVariable.FIGURE_POSTURE)); + imageUrl = await ChatBubbleUtilities.getPetImage(figure, 2, true, 64, roomObject.model.getValue(RoomObjectVariable.FIGURE_POSTURE)); petType = new PetFigureData(figure).typeId; break; case RoomObjectType.USER: - imageUrl = getUserImage(figure); + imageUrl = await ChatBubbleUtilities.getUserImage(figure); break; case RoomObjectType.RENTABLE_BOT: case RoomObjectType.BOT: @@ -131,7 +70,7 @@ const useChatWidgetState = () => break; } - avatarColor = avatarColorCache.get(figure); + avatarColor = ChatBubbleUtilities.AVATAR_COLOR_CACHE.get(figure); username = userData.name; } @@ -211,7 +150,7 @@ const useChatWidgetState = () => addChatEntry({ id: -1, webId: userData.webID, entityId: userData.roomIndex, name: username, imageUrl, style: styleId, chatType: chatType, entityType: userData.type, message: formattedText, timestamp: ChatHistoryCurrentDate(), type: ChatEntryType.TYPE_CHAT, roomId: roomSession.roomId, color }); }); - useRoomEngineEvent(RoomDragEvent.ROOM_DRAG, event => + useNitroEvent(RoomDragEvent.ROOM_DRAG, event => { if(!chatMessages.length || (event.roomId !== roomSession.roomId)) return; diff --git a/src/hooks/rooms/widgets/useDoorbellWidget.ts b/src/hooks/rooms/widgets/useDoorbellWidget.ts index 4ae5142d..7cf50510 100644 --- a/src/hooks/rooms/widgets/useDoorbellWidget.ts +++ b/src/hooks/rooms/widgets/useDoorbellWidget.ts @@ -1,7 +1,7 @@ import { RoomSessionDoorbellEvent } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomSession } from '../../../api'; -import { useRoomSessionManagerEvent } from '../../events'; +import { useNitroEvent } from '../../events'; const useDoorbellWidgetState = () => { @@ -34,9 +34,9 @@ const useDoorbellWidgetState = () => removeUser(userName); } - useRoomSessionManagerEvent(RoomSessionDoorbellEvent.DOORBELL, event => addUser(event.userName)); - useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, event => removeUser(event.userName)); - useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, event => removeUser(event.userName)); + useNitroEvent(RoomSessionDoorbellEvent.DOORBELL, event => addUser(event.userName)); + useNitroEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, event => removeUser(event.userName)); + useNitroEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, event => removeUser(event.userName)); return { users, addUser, removeUser, answer }; } diff --git a/src/hooks/rooms/widgets/usePetPackageWidget.ts b/src/hooks/rooms/widgets/usePetPackageWidget.ts index 55b0c3a8..1ab09712 100644 --- a/src/hooks/rooms/widgets/usePetPackageWidget.ts +++ b/src/hooks/rooms/widgets/usePetPackageWidget.ts @@ -1,7 +1,7 @@ import { OpenPetPackageMessageComposer, RoomObjectCategory, RoomSessionPetPackageEvent } from '@nitrots/nitro-renderer'; import { useState } from 'react'; import { GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../api'; -import { useRoomSessionManagerEvent } from '../../events'; +import { useNitroEvent } from '../../events'; const usePetPackageWidgetState = () => { @@ -49,7 +49,7 @@ const usePetPackageWidgetState = () => } } - useRoomSessionManagerEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_REQUESTED, event => + useNitroEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_REQUESTED, event => { if (!event) return; @@ -60,7 +60,7 @@ const usePetPackageWidgetState = () => setIsVisible(true); }); - useRoomSessionManagerEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_RESULT, event => + useNitroEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_RESULT, event => { if (!event) return; diff --git a/src/hooks/rooms/widgets/usePollWidget.ts b/src/hooks/rooms/widgets/usePollWidget.ts index 138a56e8..61323782 100644 --- a/src/hooks/rooms/widgets/usePollWidget.ts +++ b/src/hooks/rooms/widgets/usePollWidget.ts @@ -1,6 +1,6 @@ import { RoomSessionPollEvent } from '@nitrots/nitro-renderer'; import { DispatchUiEvent, RoomWidgetPollUpdateEvent } from '../../../api'; -import { useRoomSessionManagerEvent } from '../../events'; +import { useNitroEvent } from '../../events'; import { useRoom } from '../useRoom'; const usePollWidgetState = () => @@ -13,7 +13,7 @@ const usePollWidgetState = () => const answerPoll = (pollId: number, questionId: number, answers: string[]) => roomSession.sendPollAnswerMessage(pollId, questionId, answers); - useRoomSessionManagerEvent(RoomSessionPollEvent.OFFER, event => + useNitroEvent(RoomSessionPollEvent.OFFER, event => { const pollEvent = new RoomWidgetPollUpdateEvent(RoomWidgetPollUpdateEvent.OFFER, event.id); @@ -23,7 +23,7 @@ const usePollWidgetState = () => DispatchUiEvent(pollEvent); }); - useRoomSessionManagerEvent(RoomSessionPollEvent.ERROR, event => + useNitroEvent(RoomSessionPollEvent.ERROR, event => { const pollEvent = new RoomWidgetPollUpdateEvent(RoomWidgetPollUpdateEvent.ERROR, event.id); @@ -33,7 +33,7 @@ const usePollWidgetState = () => DispatchUiEvent(pollEvent); }); - useRoomSessionManagerEvent(RoomSessionPollEvent.CONTENT, event => + useNitroEvent(RoomSessionPollEvent.CONTENT, event => { const pollEvent = new RoomWidgetPollUpdateEvent(RoomWidgetPollUpdateEvent.CONTENT, event.id); diff --git a/src/hooks/rooms/widgets/useWordQuizWidget.ts b/src/hooks/rooms/widgets/useWordQuizWidget.ts index 3c5f5ac9..9be0d221 100644 --- a/src/hooks/rooms/widgets/useWordQuizWidget.ts +++ b/src/hooks/rooms/widgets/useWordQuizWidget.ts @@ -1,7 +1,7 @@ import { AvatarAction, IQuestion, RoomSessionWordQuizEvent } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { GetRoomEngine, VoteValue } from '../../../api'; -import { useRoomSessionManagerEvent } from '../../events'; +import { useNitroEvent } from '../../events'; import { useRoom } from '../useRoom'; import { usePollWidget } from './usePollWidget'; @@ -34,7 +34,7 @@ const useWordQuizWidgetState = () => setAnswerSent(true); } - useRoomSessionManagerEvent(RoomSessionWordQuizEvent.ANSWERED, event => + useNitroEvent(RoomSessionWordQuizEvent.ANSWERED, event => { const userData = roomSession.userDataManager.getUserData(event.userId); @@ -59,7 +59,7 @@ const useWordQuizWidgetState = () => GetRoomEngine().updateRoomObjectUserGesture(roomSession.roomId, userData.roomIndex, AvatarAction.getGestureId((event.value === '0') ? AvatarAction.GESTURE_SAD : AvatarAction.GESTURE_SMILE)); }); - useRoomSessionManagerEvent(RoomSessionWordQuizEvent.FINISHED, event => + useNitroEvent(RoomSessionWordQuizEvent.FINISHED, event => { if(question && (question.id === event.questionId)) { @@ -77,7 +77,7 @@ const useWordQuizWidgetState = () => setUserAnswers(new Map()); }); - useRoomSessionManagerEvent(RoomSessionWordQuizEvent.QUESTION, event => + useNitroEvent(RoomSessionWordQuizEvent.QUESTION, event => { setPollId(event.id); setQuestion(event.question); diff --git a/src/hooks/session/useSessionInfo.ts b/src/hooks/session/useSessionInfo.ts index 6f480fea..911e4d0c 100644 --- a/src/hooks/session/useSessionInfo.ts +++ b/src/hooks/session/useSessionInfo.ts @@ -1,9 +1,8 @@ import { FigureUpdateEvent, RoomUnitChatStyleComposer, UserInfoDataParser, UserInfoEvent, UserSettingsEvent } from '@nitrots/nitro-renderer'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { useBetween } from 'use-between'; -import { GetLocalStorage, GetSessionDataManager, SendMessageComposer } from '../../api'; +import { GetSessionDataManager, SendMessageComposer } from '../../api'; import { useMessageEvent } from '../events'; -import { useLocalStorage } from '../useLocalStorage'; const useSessionInfoState = () => { @@ -12,7 +11,6 @@ const useSessionInfoState = () => const [ chatStyleId, setChatStyleId ] = useState(0); const [ userRespectRemaining, setUserRespectRemaining ] = useState(0); const [ petRespectRemaining, setPetRespectRemaining ] = useState(0); - const [ screenSize, setScreenSize ] = useLocalStorage('nitro.screensize', { width: window.innerWidth, height: window.innerHeight }); const updateChatStyleId = (styleId: number) => { @@ -59,34 +57,6 @@ const useSessionInfoState = () => setChatStyleId(parser.chatType); }); - useEffect(() => - { - const currentScreenSize = <{ width: number, height: number }>GetLocalStorage('nitro.screensize'); - - if(currentScreenSize && ((currentScreenSize.width !== window.innerWidth) || (currentScreenSize.height !== window.innerHeight))) - { - let i = window.localStorage.length; - - while(i > 0) - { - const key = window.localStorage.key(i); - - if(key && key.startsWith('nitro.window')) window.localStorage.removeItem(key); - - i--; - } - } - - const onResize = (event: UIEvent) => setScreenSize({ width: window.innerWidth, height: window.innerHeight }); - - window.addEventListener('resize', onResize); - - return () => - { - window.removeEventListener('resize', onResize); - } - }, [ setScreenSize ]); - return { userInfo, userFigure, chatStyleId, userRespectRemaining, petRespectRemaining, respectUser, respectPet, updateChatStyleId }; } diff --git a/src/hooks/wired/useWired.ts b/src/hooks/wired/useWired.ts index c4628f45..5a6cb65b 100644 --- a/src/hooks/wired/useWired.ts +++ b/src/hooks/wired/useWired.ts @@ -1,4 +1,4 @@ -import { ConditionDefinition, Triggerable, TriggerDefinition, UpdateActionMessageComposer, UpdateConditionMessageComposer, UpdateTriggerMessageComposer, WiredActionDefinition, WiredFurniActionEvent, WiredFurniConditionEvent, WiredFurniTriggerEvent, WiredSaveSuccessEvent } from '@nitrots/nitro-renderer'; +import { ConditionDefinition, OpenMessageComposer, Triggerable, TriggerDefinition, UpdateActionMessageComposer, UpdateConditionMessageComposer, UpdateTriggerMessageComposer, WiredActionDefinition, WiredFurniActionEvent, WiredFurniConditionEvent, WiredFurniTriggerEvent, WiredOpenEvent, WiredSaveSuccessEvent } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { useBetween } from 'use-between'; import { IsOwnerOfFloorFurniture, LocalizeText, SendMessageComposer, WiredFurniType, WiredSelectionVisualizer } from '../../api'; @@ -80,6 +80,13 @@ const useWiredState = () => }); } + useMessageEvent(WiredOpenEvent, event => + { + const parser = event.getParser(); + + SendMessageComposer(new OpenMessageComposer(parser.stuffId)); + }); + useMessageEvent(WiredSaveSuccessEvent, event => { const parser = event.getParser(); diff --git a/yarn.lock b/yarn.lock index d5ed53db..19ae4c6d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -417,47 +417,6 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" -"@nitrots/nitro-renderer@^1.6.6": - version "1.6.6" - resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.6.6.tgz#c6e572720113e9bdd5b797795772c34761778a42" - integrity sha512-VMxn4gAV49G1nnOrtL6koLnJglHdp83zILcKe8DTZsZXX6GOGU2wST1sSnHvdcH28KpesqrCP5dyJGKC/0ylYQ== - dependencies: - "@pixi/app" "~6.5.0" - "@pixi/basis" "~6.5.0" - "@pixi/canvas-display" "~6.5.0" - "@pixi/canvas-extract" "~6.5.0" - "@pixi/canvas-renderer" "~6.5.0" - "@pixi/constants" "~6.5.0" - "@pixi/core" "~6.5.0" - "@pixi/display" "~6.5.0" - "@pixi/events" "~6.5.0" - "@pixi/extensions" "~6.5.0" - "@pixi/extract" "~6.5.0" - "@pixi/filter-alpha" "~6.5.0" - "@pixi/filter-color-matrix" "~6.5.0" - "@pixi/graphics" "~6.5.0" - "@pixi/graphics-extras" "~6.5.0" - "@pixi/interaction" "~6.5.0" - "@pixi/loaders" "~6.5.0" - "@pixi/math" "~6.5.0" - "@pixi/math-extras" "~6.5.0" - "@pixi/mixin-cache-as-bitmap" "~6.5.0" - "@pixi/mixin-get-child-by-name" "~6.5.0" - "@pixi/mixin-get-global-position" "~6.5.0" - "@pixi/polyfill" "~6.5.0" - "@pixi/runner" "~6.5.0" - "@pixi/settings" "~6.5.0" - "@pixi/sprite" "~6.5.0" - "@pixi/sprite-tiling" "~6.5.0" - "@pixi/spritesheet" "~6.5.0" - "@pixi/text" "~6.5.0" - "@pixi/ticker" "~6.5.0" - "@pixi/tilemap" "^3.2.2" - "@pixi/utils" "~6.5.0" - gifuct-js "^2.1.2" - howler "^2.2.3" - pako "^2.0.4" - "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -479,176 +438,6 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@pixi/app@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/app/-/app-6.5.10.tgz#4877929bd53595484c1d334e4cda43bb9d27eca1" - integrity sha512-VsNHLajZ5Dbc/Zrj7iWmIl3eu6Fec+afjW/NXXezD8Sp3nTDF0bv5F+GDgN/zSc2gqIvPHyundImT7hQGBDghg== - -"@pixi/basis@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/basis/-/basis-6.5.10.tgz#17955c2b3c34bf9e143ca13d69fc1618f6e7c027" - integrity sha512-FPhp93S/v8mrebosS1lleEkVCgaQDKMn0ml5jKofoW5wqYF2dLst0evUhMYQ/oZiauxaGrBpULv55d5kPFYoBQ== - -"@pixi/canvas-display@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/canvas-display/-/canvas-display-6.5.10.tgz#995a932da869fa999131b72c5914398f235fdd9c" - integrity sha512-pT0uhEoy24ei/5JwCYgpf+4A5vP8X5zFICJJOm2bE0k/veLc/nIpHj8SL3jG4CDmYGNAntVodEy+/E23HfzZxQ== - -"@pixi/canvas-extract@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/canvas-extract/-/canvas-extract-6.5.10.tgz#33a486f3b79f547795a8ac25d841d0389b3a5152" - integrity sha512-HEgZYvomZx3slLUDbX/tyn2+x8PprFUI5FdRHIN72uED34O09RrbvtQgymrCJCs/aZg+cxd85LRdmNIBn/LyLA== - -"@pixi/canvas-renderer@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/canvas-renderer/-/canvas-renderer-6.5.10.tgz#3f035bc2ab91d4804b6885c086aeda4946845c65" - integrity sha512-DzRJLtjt4fuxMj8kgwBxJgmdf3hmuzC8nTElEHbDH07FbVJSwD9GzNIxFli82jrKUo1nyMBoI4bUU+D+MOhAFw== - -"@pixi/constants@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/constants/-/constants-6.5.10.tgz#ac0a9c55db0d3dadcd85aa31a251db493c3bd80b" - integrity sha512-PUF2Y9YISRu5eVrVVHhHCWpc/KmxQTg3UH8rIUs8UI9dCK41/wsPd3pEahzf7H47v7x1HCohVZcFO3XQc1bUDw== - -"@pixi/core@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/core/-/core-6.5.10.tgz#b92207164526fa4a6d285ccd13cb62bdee50b493" - integrity sha512-Gdzp5ENypyglvsh5Gv3teUZnZnmizo4xOsL+QqmWALdFlJXJwLJMVhKVThV/q/095XR6i4Ou54oshn+m4EkuFw== - dependencies: - "@types/offscreencanvas" "^2019.6.4" - -"@pixi/display@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/display/-/display-6.5.10.tgz#3ebe4c56556086160087946d5437808b6fadae08" - integrity sha512-NxFdDDxlbH5fQkzGHraLGoTMucW9pVgXqQm13TSmkA3NWIi/SItHL4qT2SI8nmclT9Vid1VDEBCJFAbdeuQw1Q== - -"@pixi/events@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/events/-/events-6.5.10.tgz#b02007a6309c2c995f885f65c7c4a8244b4fd38f" - integrity sha512-LRKZ4tkilgTKRI4hmYEBhEzUbDMOf9YBnBPXDJgfe08k5/taVPVvEhMn4cs5UKTf9ALxTF+EOzrg8n2+kfMuJA== - -"@pixi/extensions@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/extensions/-/extensions-6.5.10.tgz#5909d0b3f3c5ecfdc74efe5db2869a64a9cecb8c" - integrity sha512-EIUGza+E+sCy3dupuIjvRK/WyVyfSzHb5XsxRaxNrPwvG1iIUIqNqZ3owLYCo4h17fJWrj/yXVufNNtUKQccWQ== - -"@pixi/extract@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/extract/-/extract-6.5.10.tgz#0d198b437aecb1bc358b59a70a268c816e6ca810" - integrity sha512-hXFIc4EGs14GFfXAjT1+6mzopzCMWeXeai38/Yod3vuBXkkp8+ksen6kE09vTnB9l1IpcIaCM+XZEokuqoGX2A== - -"@pixi/filter-alpha@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/filter-alpha/-/filter-alpha-6.5.10.tgz#0eada7e25bc896e89e173ac318a617d09e280bea" - integrity sha512-GWHLJvY0QOIDRjVx0hdUff6nl/PePQg84i8XXPmANrvA+gJ/eSRTQRmQcdgInQfawENADB/oRqpcCct6IAcKpQ== - -"@pixi/filter-color-matrix@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/filter-color-matrix/-/filter-color-matrix-6.5.10.tgz#5410e85b194631096725ba256d54ec5d7de4e5f0" - integrity sha512-C2S44/EoWTrhqedLWOZTq9GZV5loEq1+MhyK9AUzEubWGMHhou1Juhn2mRZ7R6flKPCRQNKrXpStUwCAouud3Q== - -"@pixi/graphics-extras@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/graphics-extras/-/graphics-extras-6.5.10.tgz#ee0133233e7adbcb1d026d662c38a37408fbe486" - integrity sha512-PgaOKubX+3GobTqDtTRnF50AqA+z06kr/WNWXoT5/fcWMcW5rwcUpsL00R9ZTi37ohoZUMjAyfLUr7sIUQpzdA== - -"@pixi/graphics@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/graphics/-/graphics-6.5.10.tgz#7a5a5d263a612629b8df59479b99ce938353ced2" - integrity sha512-KPHGJ910fi8bRQQ+VcTIgrK+bKIm8yAQaZKPqMtm14HzHPGcES6HkgeNY1sd7m8J4aS9btm5wOSyFu0p5IzTpA== - -"@pixi/interaction@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/interaction/-/interaction-6.5.10.tgz#c477d42206f3a2ed11bf06f3147bcd3906a872fa" - integrity sha512-v809pJmXA2B9dV/vdrDMUqJT+fBB/ARZli2YRmI2dPbEbkaYr8FNmxCAJnwT8o+ymTx044Ie820hn9tVrtMtfA== - -"@pixi/loaders@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/loaders/-/loaders-6.5.10.tgz#7d7bdc1686eae2842e4d701abd4b480f9fcd5930" - integrity sha512-AuK7mXBmyVsDFL9DDFPB8sqP8fwQ2NOktvu98bQuJl0/p/UeK/0OAQnF3wcf3FeBv5YGXfNHL21c2DCisjKfTg== - -"@pixi/math-extras@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/math-extras/-/math-extras-6.5.10.tgz#907338a877dbd371df0a161ef13afa5a43fcac67" - integrity sha512-TG2zzvdV0F7FmZtsjSrW12ub+QUZadBRCQZt0IaxTl6VBhysBaYhPILC5YpfGhim1uuF1L8W0LLWaGLI8T3VNg== - -"@pixi/math@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/math/-/math-6.5.10.tgz#0d9b9e12a7e9a920306e1425901348b9c7f054ad" - integrity sha512-fxeu7ykVbMGxGV2S3qRTupHToeo1hdWBm8ihyURn3BMqJZe2SkZEECPd5RyvIuuNUtjRnmhkZRnF3Jsz2S+L0g== - -"@pixi/mixin-cache-as-bitmap@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/mixin-cache-as-bitmap/-/mixin-cache-as-bitmap-6.5.10.tgz#5f8a7ee6620c9734bcce091508004a4a818f13e9" - integrity sha512-HV4qPZt8R7uuPZf1XE5S0e3jbN4+/EqgAIkueIyK3Em+0IO1rCmIbzzYxFPxkElMUu5VvN1r4hXK846z9ITnhw== - -"@pixi/mixin-get-child-by-name@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/mixin-get-child-by-name/-/mixin-get-child-by-name-6.5.10.tgz#2fa1002998381be562ec0aa35b44d866d2d435e3" - integrity sha512-YYd9wjnI/4aKY0H5Ij413UppVZn3YE1No2CZrNevV6WbhylsJucowY3hJihtl9mxkpwtaUIyWMjmphkbOinbzA== - -"@pixi/mixin-get-global-position@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/mixin-get-global-position/-/mixin-get-global-position-6.5.10.tgz#963395e60c58bc2631f7eb4c4fd479dedbf7a1ec" - integrity sha512-A83gTZP9CdQAyrAvOZl1P707Q0QvIC0V8UnBAMd4GxuhMOXJtXVPCdmfPVXUrfoywgnH+/Bgimq5xhsXTf8Hzg== - -"@pixi/polyfill@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/polyfill/-/polyfill-6.5.10.tgz#4a74cf5c709e429f2220b840944ce3215a871aa5" - integrity sha512-KDTWyr285VvPM8GGTVIZAhmxGrOlTznUGK/9kWS3GtrogwLWn41S/86Yej1gYvotVyUomCcOok33Jzahb+vX1w== - dependencies: - object-assign "^4.1.1" - promise-polyfill "^8.2.0" - -"@pixi/runner@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/runner/-/runner-6.5.10.tgz#a103dcb70025f13523995b80728077c8071f5ba7" - integrity sha512-4HiHp6diCmigJT/DSbnqQP62OfWKmZB7zPWMdV1AEdr4YT1QxzXAW1wHg7dkoEfyTHqZKl0tm/zcqKq/iH7tMA== - -"@pixi/settings@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/settings/-/settings-6.5.10.tgz#11de6bd63b8a1182cd3bd7ea3df698de92d18e9a" - integrity sha512-ypAS5L7pQ2Qb88yQK72bXtc7sD8OrtLWNXdZ/gnw5kwSWCFaOSoqhKqJCXrR5DQtN98+RQefwbEAmMvqobhFyw== - -"@pixi/sprite-tiling@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/sprite-tiling/-/sprite-tiling-6.5.10.tgz#b4d692a49145f174e399dc2c7ed6b290f5f73a9a" - integrity sha512-lDFcPuwExrdJhli+WmjPivChjeCG6NiRl36iQ8n2zVi/MYVv9qfKCA6IdU7HBWk1AZdsg6KUTpwfmVLUI+qz3w== - -"@pixi/sprite@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/sprite/-/sprite-6.5.10.tgz#2acdf87f8f12e5bf6077117b5e383c07d6803e52" - integrity sha512-UiK+8LgM9XQ/SBDKjRgZ8WggdOSlFRXqiWjEZVmNkiyU8HvXeFzWPRhpc8RR1zDwAUhZWKtMhF8X/ba9m+z2lg== - -"@pixi/spritesheet@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/spritesheet/-/spritesheet-6.5.10.tgz#c725d85206eec0ea36d60ff3ff138c01a9201bb0" - integrity sha512-7uOZ1cYyYtPb0ZEgXV1SZ8ujtluZNY0TL5z3+Qc8cgGGZK/MaWG7N6Wf+uR4BR2x8FLNwcyN5IjbQDKCpblrmg== - -"@pixi/text@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/text/-/text-6.5.10.tgz#5e6f62343d9148d29a861836ac81c8f5fe7b36d0" - integrity sha512-ikwkonLJ+6QmEVW8Ji9fS5CjrKNbU4mHzYuwRQas/VJQuSWgd0myCcaw6ZbF1oSfQe70HgbNOR0sH8Q3Com0qg== - -"@pixi/ticker@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/ticker/-/ticker-6.5.10.tgz#e9d47bb7fe32600d7febe0487c2afb8a3c7abc70" - integrity sha512-UqX1XYtzqFSirmTOy8QAK4Ccg4KkIZztrBdRPKwFSOEiKAJoGDCSBmyQBo/9aYQKGObbNnrJ7Hxv3/ucg3/1GA== - -"@pixi/tilemap@^3.2.2": - version "3.2.2" - resolved "https://registry.yarnpkg.com/@pixi/tilemap/-/tilemap-3.2.2.tgz#8327e5d7007a90be640a0b1eb9943a1e405b57e4" - integrity sha512-svdmMyJP63vdae3t66tCmE8IWeO/6lD1xXU+5gzfxqxJS5seTp2bm8mQok2c8PF0O6l/NYlLz6BRklOuEuHboQ== - -"@pixi/utils@~6.5.0": - version "6.5.10" - resolved "https://registry.yarnpkg.com/@pixi/utils/-/utils-6.5.10.tgz#05969e4e86ebfdf023de25d53b8270f04ba0c5a6" - integrity sha512-4f4qDMmAz9IoSAe08G2LAxUcEtG9jSdudfsMQT2MG+OpfToirboE6cNoO0KnLCvLzDVE/mfisiQ9uJbVA9Ssdw== - dependencies: - "@types/earcut" "^2.1.0" - earcut "^2.2.4" - eventemitter3 "^3.1.0" - url "^0.11.0" - "@popperjs/core@^2.11.6": version "2.11.8" resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" @@ -703,11 +492,6 @@ "@babel/runtime" "^7.16.7" "@reach/observe-rect" "^1.1.0" -"@types/earcut@^2.1.0": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@types/earcut/-/earcut-2.1.1.tgz#573a0af609f17005c751f6f4ffec49cfe358ea51" - integrity sha512-w8oigUCDjElRHRRrMvn/spybSMyX8MTkKA5Dv+tS1IE/TgmNZPqUYtvYBXGY8cieSE66gm+szeK+bnbxC2xHTQ== - "@types/json-schema@^7.0.9": version "7.0.12" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb" @@ -723,11 +507,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.19.tgz#cb03fca8910fdeb7595b755126a8a78144714eea" integrity sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA== -"@types/offscreencanvas@^2019.6.4": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - "@types/prop-types@*": version "15.7.5" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" @@ -1232,11 +1011,6 @@ dom-helpers@^5.0.1, dom-helpers@^5.2.0, dom-helpers@^5.2.1: "@babel/runtime" "^7.8.7" csstype "^3.0.2" -earcut@^2.2.4: - version "2.2.4" - resolved "https://registry.yarnpkg.com/earcut/-/earcut-2.2.4.tgz#6d02fd4d68160c114825d06890a92ecaae60343a" - integrity sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ== - electron-to-chromium@^1.4.431: version "1.4.467" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.467.tgz#b0660bf644baff7eedea33b8c742fb53ec60e3c2" @@ -1547,11 +1321,6 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -eventemitter3@^3.1.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7" - integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q== - fast-deep-equal@3.1.3, fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -1680,13 +1449,6 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" -gifuct-js@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/gifuct-js/-/gifuct-js-2.1.2.tgz#06152437ba30ec914db8398bd838bd0fbc8a6ecd" - integrity sha512-rI2asw77u0mGgwhV3qA+OEgYqaDn5UNqgs+Bx0FGwSpuqfYn+Ir6RQY5ENNQ8SbIiG/m5gVa7CD5RriO4f4Lsg== - dependencies: - js-binary-schema-parser "^2.0.3" - glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -1802,11 +1564,6 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -howler@^2.2.3: - version "2.2.3" - resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.3.tgz#a2eff9b08b586798e7a2ee17a602a90df28715da" - integrity sha512-QM0FFkw0LRX1PR8pNzJVAY25JhIWvbKMBFM4gqk+QdV+kPXOhleWGCB6AiAF/goGjIHK2e/nIElplvjQwhr0jg== - ignore@^5.2.0: version "5.2.4" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" @@ -1996,11 +1753,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -js-binary-schema-parser@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/js-binary-schema-parser/-/js-binary-schema-parser-2.0.3.tgz#3d7848748e8586e63b34e8911b643f59cfb6396e" - integrity sha512-xezGJmOb4lk/M1ZZLTR/jaBHQ4gG/lqQnJqdIv4721DMggsa1bDVlHXNeHYogaIEHD9vCRv0fcL4hMA+Coarkg== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -2273,11 +2025,6 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" -pako@^2.0.4: - version "2.1.0" - resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" - integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== - parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -2334,11 +2081,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -promise-polyfill@^8.2.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.3.0.tgz#9284810268138d103807b11f4e23d5e945a4db63" - integrity sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg== - prop-types-extra@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/prop-types-extra/-/prop-types-extra-1.1.1.tgz#58c3b74cbfbb95d304625975aa2f0848329a010b" @@ -2365,23 +2107,11 @@ prop-types@^15.6.2, prop-types@^15.8.1: object-assign "^4.1.1" react-is "^16.13.1" -punycode@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== - punycode@^2.1.0: version "2.3.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== -qs@^6.11.0: - version "6.11.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.2.tgz#64bea51f12c1f5da1bc01496f48ffcff7c69d7d9" - integrity sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA== - dependencies: - side-channel "^1.0.4" - queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -2836,14 +2566,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -url@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/url/-/url-0.11.1.tgz#26f90f615427eca1b9f4d6a28288c147e2302a32" - integrity sha512-rWS3H04/+mzzJkv0eZ7vEDGiQbgquI1fGfOad6zKvgYQi1SzMmhl7c/DdRGxhaWrVH6z0qWITo8rpnxK/RfEhA== - dependencies: - punycode "^1.4.1" - qs "^6.11.0" - use-between@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/use-between/-/use-between-1.3.5.tgz#8f9db513414d204e0046c5692828e209cec4d564"