diff --git a/src/api/navigator/RoomSettingsData.ts b/src/api/navigator/RoomSettingsData.ts index 84cce5ae..18852ab3 100644 --- a/src/api/navigator/RoomSettingsData.ts +++ b/src/api/navigator/RoomSettingsData.ts @@ -1,4 +1,4 @@ -import { RoomSettingsParser } from '@nitrots/nitro-renderer'; +import { RoomSettingsDataParser } from '@nitrots/nitro-renderer'; export class RoomSettingsData { @@ -36,41 +36,43 @@ export class RoomSettingsData public bannedUsers: any[]; public selectedUserToUnban: number; - constructor(parser: RoomSettingsParser) + constructor(parser: RoomSettingsDataParser) { if(!parser) throw new Error('invalid_parser'); - this.roomId = parser.roomId; - this.roomName = parser.name; - this.roomOriginalName = parser.name; - this.roomDescription = parser.description; - this.categoryId = parser.categoryId; - this.userCount = parser.userCount; - this.tags = parser.tags; - this.tradeState = parser.tradeMode; - this.allowWalkthrough = parser.allowWalkthrough; + const data = parser.data; - this.lockState = parser.state; - this.originalLockState = parser.state; + this.roomId = data.roomId; + this.roomName = data.name; + this.roomOriginalName = data.name; + this.roomDescription = data.description; + this.categoryId = data.categoryId; + this.userCount = data.maximumVisitorsLimit; + this.tags = data.tags; + this.tradeState = data.tradeMode; + this.allowWalkthrough = data.allowWalkThrough; + + this.lockState = data.doorMode; + this.originalLockState = data.doorMode; this.password = null; this.confirmPassword = null; - this.allowPets = parser.allowPets; - this.allowPetsEat = parser.allowPetsEat; + this.allowPets = data.allowPets; + this.allowPetsEat = data.allowFoodConsume; this.usersWithRights = new Map(); - this.hideWalls = parser.hideWalls; - this.wallThickness = parser.thicknessWall; - this.floorThickness = parser.thicknessFloor; - this.chatBubbleMode = parser.chatSettings.mode; - this.chatBubbleWeight = parser.chatSettings.weight; - this.chatBubbleSpeed = parser.chatSettings.speed; - this.chatFloodProtection = parser.chatSettings.protection; - this.chatDistance = parser.chatSettings.distance; + this.hideWalls = data.hideWalls; + this.wallThickness = data.wallThickness; + this.floorThickness = data.floorThickness; + this.chatBubbleMode = data.chatSettings.mode; + this.chatBubbleWeight = data.chatSettings.weight; + this.chatBubbleSpeed = data.chatSettings.speed; + this.chatFloodProtection = data.chatSettings.protection; + this.chatDistance = data.chatSettings.distance; - this.muteState = parser.moderationSettings.allowMute; - this.kickState = parser.moderationSettings.allowKick; - this.banState = parser.moderationSettings.allowBan; + this.muteState = data.roomModerationSettings.allowMute; + this.kickState = data.roomModerationSettings.allowKick; + this.banState = data.roomModerationSettings.allowBan; this.bannedUsers = []; } } diff --git a/src/api/navigator/TryVisitRoom.ts b/src/api/navigator/TryVisitRoom.ts index 94d8e6fc..81138d6c 100644 --- a/src/api/navigator/TryVisitRoom.ts +++ b/src/api/navigator/TryVisitRoom.ts @@ -1,7 +1,7 @@ -import { RoomInfoComposer } from '@nitrots/nitro-renderer'; +import { GetGuestRoomMessageComposer } from '@nitrots/nitro-renderer'; import { SendMessageComposer } from '../nitro'; export function TryVisitRoom(roomId: number): void { - SendMessageComposer(new RoomInfoComposer(roomId, false, true)); + SendMessageComposer(new GetGuestRoomMessageComposer(roomId, false, true)); } diff --git a/src/api/utils/PlaySound.ts b/src/api/utils/PlaySound.ts index 94c50ee9..70f6aad7 100644 --- a/src/api/utils/PlaySound.ts +++ b/src/api/utils/PlaySound.ts @@ -1,5 +1,4 @@ -import { MouseEventType } from '@nitrots/nitro-renderer'; -import { NitroSoundEvent } from '@nitrots/nitro-renderer/src/nitro/events/NitroSoundEvent'; +import { MouseEventType, NitroSoundEvent } from '@nitrots/nitro-renderer'; import { DispatchMainEvent } from '../../hooks'; let canPlaySound = false; diff --git a/src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx b/src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx new file mode 100644 index 00000000..3cf0cc70 --- /dev/null +++ b/src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx @@ -0,0 +1,97 @@ +import { GetRoomAdPurchaseInfoComposer, GetUserEventCatsMessageComposer, PurchaseRoomAdMessageComposer, RoomAdPurchaseInfoEvent, RoomEntryData, UserEventCatsEvent } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { Base, Button, Column, Text } from '../../../../../common'; +import { UseMessageEventHook } from '../../../../../hooks'; +import { CatalogLayoutProps } from './CatalogLayout.types'; + +export const CatalogLayoutRoomAdsView: FC = props => +{ + const { page = null } = props; + const [ eventName, setEventName ] = useState(''); + const [ eventDesc, setEventDesc ] = useState(''); + const [ roomId, setRoomId ] = useState(-1); + const [ availableRooms, setAvailableRooms ] = useState([]); + const [ extended, setExtended ] = useState(false); + const [ categoryId, setCategoryId ] = useState(1); + const [ categories, setCategories ] = useState(null); + + const onRoomAdPurchaseInfoEvent = (event: RoomAdPurchaseInfoEvent) => + { + const parser = event.getParser(); + + if(!parser) return; + + setAvailableRooms(parser.rooms); + } + + UseMessageEventHook(RoomAdPurchaseInfoEvent, onRoomAdPurchaseInfoEvent); + + const purchaseAd = useCallback(() => + { + const pageId = page.pageId; + const offerId = page.offers.length >= 1 ? page.offers[0].offerId : -1; + const flatId = roomId; + const name = eventName; + const desc = eventDesc; + const catId = categoryId; + + SendMessageComposer(new PurchaseRoomAdMessageComposer(pageId, offerId, flatId, name, extended, desc, catId)) + }, [ categoryId, eventDesc, eventName, extended, page.offers, page.pageId, roomId ]); + + + const onUserEventCatsEvent = (event: UserEventCatsEvent) => + { + const parser = event.getParser(); + + setCategories(parser.categories); + } + + UseMessageEventHook(UserEventCatsEvent, onUserEventCatsEvent); + + useEffect(() => + { + SendMessageComposer(new GetRoomAdPurchaseInfoComposer()); + // TODO: someone needs to fix this for morningstar + SendMessageComposer(new GetUserEventCatsMessageComposer()); + }, []); + + return (<> + { LocalizeText('roomad.catalog_header') } + + { LocalizeText('roomad.catalog_text') } + + + + + + { LocalizeText('roomad.catalog_name') } + setEventName(event.target.value) } /> + + + < Text bold>{ LocalizeText('roomad.catalog_description') } +