Merge branch 'navigator-packets' into @update/room-widgets

This commit is contained in:
Bill 2022-06-18 00:53:52 -04:00
commit 0121945c6a
12 changed files with 212 additions and 95 deletions

View File

@ -1,4 +1,4 @@
import { RoomSettingsParser } from '@nitrots/nitro-renderer'; import { RoomSettingsDataParser } from '@nitrots/nitro-renderer';
export class RoomSettingsData export class RoomSettingsData
{ {
@ -36,41 +36,43 @@ export class RoomSettingsData
public bannedUsers: any[]; public bannedUsers: any[];
public selectedUserToUnban: number; public selectedUserToUnban: number;
constructor(parser: RoomSettingsParser) constructor(parser: RoomSettingsDataParser)
{ {
if(!parser) throw new Error('invalid_parser'); if(!parser) throw new Error('invalid_parser');
this.roomId = parser.roomId; const data = parser.data;
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;
this.lockState = parser.state; this.roomId = data.roomId;
this.originalLockState = parser.state; 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.password = null;
this.confirmPassword = null; this.confirmPassword = null;
this.allowPets = parser.allowPets; this.allowPets = data.allowPets;
this.allowPetsEat = parser.allowPetsEat; this.allowPetsEat = data.allowFoodConsume;
this.usersWithRights = new Map<number, string>(); this.usersWithRights = new Map<number, string>();
this.hideWalls = parser.hideWalls; this.hideWalls = data.hideWalls;
this.wallThickness = parser.thicknessWall; this.wallThickness = data.wallThickness;
this.floorThickness = parser.thicknessFloor; this.floorThickness = data.floorThickness;
this.chatBubbleMode = parser.chatSettings.mode; this.chatBubbleMode = data.chatSettings.mode;
this.chatBubbleWeight = parser.chatSettings.weight; this.chatBubbleWeight = data.chatSettings.weight;
this.chatBubbleSpeed = parser.chatSettings.speed; this.chatBubbleSpeed = data.chatSettings.speed;
this.chatFloodProtection = parser.chatSettings.protection; this.chatFloodProtection = data.chatSettings.protection;
this.chatDistance = parser.chatSettings.distance; this.chatDistance = data.chatSettings.distance;
this.muteState = parser.moderationSettings.allowMute; this.muteState = data.roomModerationSettings.allowMute;
this.kickState = parser.moderationSettings.allowKick; this.kickState = data.roomModerationSettings.allowKick;
this.banState = parser.moderationSettings.allowBan; this.banState = data.roomModerationSettings.allowBan;
this.bannedUsers = []; this.bannedUsers = [];
} }
} }

View File

@ -1,7 +1,7 @@
import { RoomInfoComposer } from '@nitrots/nitro-renderer'; import { GetGuestRoomMessageComposer } from '@nitrots/nitro-renderer';
import { SendMessageComposer } from '../nitro'; import { SendMessageComposer } from '../nitro';
export function TryVisitRoom(roomId: number): void export function TryVisitRoom(roomId: number): void
{ {
SendMessageComposer(new RoomInfoComposer(roomId, false, true)); SendMessageComposer(new GetGuestRoomMessageComposer(roomId, false, true));
} }

View File

@ -1,5 +1,4 @@
import { MouseEventType } from '@nitrots/nitro-renderer'; import { MouseEventType, NitroSoundEvent } from '@nitrots/nitro-renderer';
import { NitroSoundEvent } from '@nitrots/nitro-renderer/src/nitro/events/NitroSoundEvent';
import { DispatchMainEvent } from '../../hooks'; import { DispatchMainEvent } from '../../hooks';
let canPlaySound = false; let canPlaySound = false;

View File

@ -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<CatalogLayoutProps> = props =>
{
const { page = null } = props;
const [ eventName, setEventName ] = useState<string>('');
const [ eventDesc, setEventDesc ] = useState<string>('');
const [ roomId, setRoomId ] = useState<number>(-1);
const [ availableRooms, setAvailableRooms ] = useState<RoomEntryData[]>([]);
const [ extended, setExtended ] = useState<boolean>(false);
const [ categoryId, setCategoryId ] = useState<number>(1);
const [ categories, setCategories ] = useState<INavigatorCategory[]>(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 (<>
<Text bold center>{ LocalizeText('roomad.catalog_header') }</Text>
<Column size={ 12 } overflow="hidden" className="text-black">
<Base>{ LocalizeText('roomad.catalog_text') }</Base>
<Base className="bg-muted rounded p-1">
<Column gap={ 2 }>
<select className="form-select form-select-sm" value={ categoryId } onChange={ event => setCategoryId(parseInt(event.target.value)) }>
{ categories && categories.map((cat, index) => <option key={ index } value={ cat.id }>{ cat.name }</option>) }
</select>
</Column>
<Column gap={ 1 }>
<Text bold>{ LocalizeText('roomad.catalog_name') }</Text>
<input type="text" className="form-control form-control-sm" maxLength={ 64 } value={ eventName } onChange={ event => setEventName(event.target.value) } />
</Column>
<Column gap={ 1 }>
< Text bold>{ LocalizeText('roomad.catalog_description') }</Text>
<textarea className="form-control form-control-sm" maxLength={ 64 } value={ eventDesc } onChange={ event => setEventDesc(event.target.value) }/>
</Column>
<Column gap={ 1 }>
<Text bold>{ LocalizeText('roomad.catalog_roomname') }</Text>
<select className="form-select form-select-sm" value={ roomId } onChange={ event => setRoomId(parseInt(event.target.value)) }>
<option value={ -1 } disabled>{ LocalizeText('roomad.catalog_roomname') }</option>
{ availableRooms && availableRooms.map((room, index) => <option key={ index } value={ room.roomId }>{ room.roomName }</option>) }
</select>
</Column>
<Column gap={ 1 }>
<Button onClick={ purchaseAd }>{ LocalizeText('buy') }</Button>
</Column>
</Base>
</Column>
</>
);
}
interface INavigatorCategory {
id: number;
name: string;
visible: boolean;
}

View File

@ -8,6 +8,7 @@ import { CatalogLayouGuildFrontpageView } from './CatalogLayoutGuildFrontpageVie
import { CatalogLayoutInfoLoyaltyView } from './CatalogLayoutInfoLoyaltyView'; import { CatalogLayoutInfoLoyaltyView } from './CatalogLayoutInfoLoyaltyView';
import { CatalogLayoutPets2View } from './CatalogLayoutPets2View'; import { CatalogLayoutPets2View } from './CatalogLayoutPets2View';
import { CatalogLayoutPets3View } from './CatalogLayoutPets3View'; import { CatalogLayoutPets3View } from './CatalogLayoutPets3View';
import { CatalogLayoutRoomAdsView } from './CatalogLayoutRoomAdsView';
import { CatalogLayoutRoomBundleView } from './CatalogLayoutRoomBundleView'; import { CatalogLayoutRoomBundleView } from './CatalogLayoutRoomBundleView';
import { CatalogLayoutSingleBundleView } from './CatalogLayoutSingleBundleView'; import { CatalogLayoutSingleBundleView } from './CatalogLayoutSingleBundleView';
import { CatalogLayoutSpacesView } from './CatalogLayoutSpacesView'; import { CatalogLayoutSpacesView } from './CatalogLayoutSpacesView';
@ -63,6 +64,8 @@ export const GetCatalogLayout = (page: ICatalogPage, hideNavigation: () => void)
return <CatalogLayoutInfoLoyaltyView { ...layoutProps } />; return <CatalogLayoutInfoLoyaltyView { ...layoutProps } />;
case 'badge_display': case 'badge_display':
return <CatalogLayoutBadgeDisplayView { ...layoutProps } />; return <CatalogLayoutBadgeDisplayView { ...layoutProps } />;
case 'roomads':
return <CatalogLayoutRoomAdsView { ...layoutProps } />;
//case 'default_3x3_color_grouping': //case 'default_3x3_color_grouping':
//return <CatalogLayoutColorGroupingView { ...layoutProps } />; //return <CatalogLayoutColorGroupingView { ...layoutProps } />;
case 'bots': case 'bots':

View File

@ -1,4 +1,4 @@
import { NavigatorCategoryDataParser, NavigatorSearchResultSet, NavigatorTopLevelContext, RoomDataParser } from '@nitrots/nitro-renderer'; import { NavigatorCategoryDataParser, NavigatorEventCategoryDataParser, NavigatorSearchResultSet, NavigatorTopLevelContext, RoomDataParser } from '@nitrots/nitro-renderer';
import { createContext, Dispatch, FC, ProviderProps, SetStateAction, useContext } from 'react'; import { createContext, Dispatch, FC, ProviderProps, SetStateAction, useContext } from 'react';
import { INavigatorData } from '../../api'; import { INavigatorData } from '../../api';
@ -6,6 +6,8 @@ interface INavigatorContext
{ {
categories: NavigatorCategoryDataParser[]; categories: NavigatorCategoryDataParser[];
setCategories: Dispatch<SetStateAction<NavigatorCategoryDataParser[]>>; setCategories: Dispatch<SetStateAction<NavigatorCategoryDataParser[]>>;
eventCategories: NavigatorEventCategoryDataParser[];
setEventCategories: Dispatch<SetStateAction<NavigatorEventCategoryDataParser[]>>;
topLevelContext: NavigatorTopLevelContext; topLevelContext: NavigatorTopLevelContext;
setTopLevelContext: Dispatch<SetStateAction<NavigatorTopLevelContext>>; setTopLevelContext: Dispatch<SetStateAction<NavigatorTopLevelContext>>;
topLevelContexts: NavigatorTopLevelContext[]; topLevelContexts: NavigatorTopLevelContext[];
@ -22,6 +24,8 @@ const NavigatorContext = createContext<INavigatorContext>({
categories: null, categories: null,
setCategories: null, setCategories: null,
topLevelContext: null, topLevelContext: null,
setEventCategories: null,
eventCategories: null,
setTopLevelContext: null, setTopLevelContext: null,
topLevelContexts: null, topLevelContexts: null,
setTopLevelContexts: null, setTopLevelContexts: null,

View File

@ -1,4 +1,4 @@
import { CanCreateRoomEventEvent, CantConnectMessageParser, FollowFriendMessageComposer, GenericErrorEvent, GetGuestRoomResultEvent, HabboWebTools, LegacyExternalInterface, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorOpenRoomCreatorEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEnterErrorEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomScoreEvent, RoomSettingsUpdatedEvent, SecurityLevel, UserInfoEvent, UserPermissionsEvent } from '@nitrots/nitro-renderer'; import { CanCreateRoomEventEvent, CantConnectMessageParser, DoorbellMessageEvent, FlatAccessDeniedMessageEvent, FlatCreatedEvent, FollowFriendMessageComposer, GenericErrorEvent, GetGuestRoomMessageComposer, GetGuestRoomResultEvent, GetUserEventCatsMessageComposer, GetUserFlatCatsMessageComposer, HabboWebTools, LegacyExternalInterface, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorOpenRoomCreatorEvent, NavigatorSearchEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomEnterErrorEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomScoreEvent, RoomSettingsUpdatedEvent, SecurityLevel, UserEventCatsEvent, UserFlatCatsEvent, UserInfoEvent, UserPermissionsEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback } from 'react'; import { FC, useCallback } from 'react';
import { CreateLinkEvent, CreateRoomSession, DoorStateType, GetConfiguration, GetSessionDataManager, LocalizeText, NotificationAlertType, NotificationUtilities, SendMessageComposer, TryVisitRoom, VisitDesktop } from '../../api'; import { CreateLinkEvent, CreateRoomSession, DoorStateType, GetConfiguration, GetSessionDataManager, LocalizeText, NotificationAlertType, NotificationUtilities, SendMessageComposer, TryVisitRoom, VisitDesktop } from '../../api';
import { UseMessageEventHook } from '../../hooks'; import { UseMessageEventHook } from '../../hooks';
@ -6,13 +6,13 @@ import { useNavigatorContext } from './NavigatorContext';
export const NavigatorMessageHandler: FC<{}> = props => export const NavigatorMessageHandler: FC<{}> = props =>
{ {
const { setCategories = null, setTopLevelContext = null, topLevelContexts = null, setTopLevelContexts = null, setNavigatorData = null, setDoorData = null, setSearchResult = null } = useNavigatorContext(); const { setCategories = null, setEventCategories = null, setTopLevelContext = null, topLevelContexts = null, setTopLevelContexts = null, setNavigatorData = null, setDoorData = null, setSearchResult = null } = useNavigatorContext();
const onRoomSettingsUpdatedEvent = useCallback((event: RoomSettingsUpdatedEvent) => const onRoomSettingsUpdatedEvent = useCallback((event: RoomSettingsUpdatedEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
SendMessageComposer(new RoomInfoComposer(parser.roomId, false, false)); SendMessageComposer(new GetGuestRoomMessageComposer(parser.roomId, false, false));
}, []); }, []);
UseMessageEventHook(RoomSettingsUpdatedEvent, onRoomSettingsUpdatedEvent); UseMessageEventHook(RoomSettingsUpdatedEvent, onRoomSettingsUpdatedEvent);
@ -30,13 +30,13 @@ export const NavigatorMessageHandler: FC<{}> = props =>
NotificationUtilities.simpleAlert(LocalizeText(`navigator.cannotcreateevent.error.${ parser.errorCode }`), null, null, null, LocalizeText('navigator.cannotcreateevent.title')); NotificationUtilities.simpleAlert(LocalizeText(`navigator.cannotcreateevent.error.${ parser.errorCode }`), null, null, null, LocalizeText('navigator.cannotcreateevent.title'));
}, []); }, []);
UseMessageEventHook(CanCreateRoomEventEvent, onCanCreateRoomEventEvent); UseMessageEventHook(CanCreateRoomEventEvent, onCanCreateRoomEventEvent);
const onUserInfoEvent = useCallback((event: UserInfoEvent) => const onUserInfoEvent = useCallback((event: UserInfoEvent) =>
{ {
SendMessageComposer(new NavigatorCategoriesComposer()); SendMessageComposer(new GetUserFlatCatsMessageComposer());
SendMessageComposer(new NavigatorSettingsComposer()); SendMessageComposer(new GetUserEventCatsMessageComposer());
}, []); }, []);
const onUserPermissionsEvent = useCallback((event: UserPermissionsEvent) => const onUserPermissionsEvent = useCallback((event: UserPermissionsEvent) =>
@ -80,7 +80,7 @@ export const NavigatorMessageHandler: FC<{}> = props =>
// close room settings // close room settings
// close room filter // close room filter
SendMessageComposer(new RoomInfoComposer(parser.roomId, true, false)); SendMessageComposer(new GetGuestRoomMessageComposer(parser.roomId, true, false));
if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'navigator', 'private', [ parser.roomId ]); if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'navigator', 'private', [ parser.roomId ]);
}, [ setNavigatorData ]); }, [ setNavigatorData ]);
@ -92,7 +92,7 @@ export const NavigatorMessageHandler: FC<{}> = props =>
if(parser.roomEnter) if(parser.roomEnter)
{ {
setDoorData({ roomInfo: null, state: DoorStateType.NONE }); setDoorData({ roomInfo: null, state: DoorStateType.NONE });
setNavigatorData(prevValue => setNavigatorData(prevValue =>
{ {
const newValue = { ...prevValue }; const newValue = { ...prevValue };
@ -181,7 +181,7 @@ export const NavigatorMessageHandler: FC<{}> = props =>
}); });
}, [ setNavigatorData ]); }, [ setNavigatorData ]);
const onRoomDoorbellEvent = useCallback((event: RoomDoorbellEvent) => const onRoomDoorbellEvent = useCallback((event: DoorbellMessageEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
@ -215,7 +215,7 @@ export const NavigatorMessageHandler: FC<{}> = props =>
} }
}, [ setDoorData ]); }, [ setDoorData ]);
const onRoomDoorbellRejectedEvent = useCallback((event: RoomDoorbellRejectedEvent) => const onRoomDoorbellRejectedEvent = useCallback((event: FlatAccessDeniedMessageEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
@ -242,9 +242,9 @@ export const NavigatorMessageHandler: FC<{}> = props =>
setDoorData(prevValue => setDoorData(prevValue =>
{ {
const newValue = { ...prevValue }; const newValue = { ...prevValue };
newValue.state = DoorStateType.STATE_WRONG_PASSWORD; newValue.state = DoorStateType.STATE_WRONG_PASSWORD;
return newValue; return newValue;
}); });
return; return;
@ -310,14 +310,22 @@ export const NavigatorMessageHandler: FC<{}> = props =>
setSearchResult(parser.result); setSearchResult(parser.result);
}, [ topLevelContexts, setTopLevelContext, setSearchResult ]); }, [ topLevelContexts, setTopLevelContext, setSearchResult ]);
const onNavigatorCategoriesEvent = useCallback((event: NavigatorCategoriesEvent) => const onNavigatorCategoriesEvent = useCallback((event: UserFlatCatsEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
setCategories(parser.categories); setCategories(parser.categories);
}, [ setCategories ]); }, [ setCategories ]);
const onRoomCreatedEvent = useCallback((event: RoomCreatedEvent) => const onNavigatorEventCategoriesEvent = (event: UserEventCatsEvent) =>
{
const parser = event.getParser();
setEventCategories(parser.categories);
console.log(parser);
}
const onRoomCreatedEvent = useCallback((event: FlatCreatedEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
@ -421,14 +429,15 @@ export const NavigatorMessageHandler: FC<{}> = props =>
UseMessageEventHook(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent); UseMessageEventHook(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent);
UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent);
UseMessageEventHook(RoomScoreEvent, onRoomScoreEvent); UseMessageEventHook(RoomScoreEvent, onRoomScoreEvent);
UseMessageEventHook(RoomDoorbellEvent, onRoomDoorbellEvent); UseMessageEventHook(DoorbellMessageEvent, onRoomDoorbellEvent);
UseMessageEventHook(RoomDoorbellAcceptedEvent, onRoomDoorbellAcceptedEvent); UseMessageEventHook(RoomDoorbellAcceptedEvent, onRoomDoorbellAcceptedEvent);
UseMessageEventHook(RoomDoorbellRejectedEvent, onRoomDoorbellRejectedEvent); UseMessageEventHook(FlatAccessDeniedMessageEvent, onRoomDoorbellRejectedEvent);
UseMessageEventHook(GenericErrorEvent, onGenericErrorEvent); UseMessageEventHook(GenericErrorEvent, onGenericErrorEvent);
UseMessageEventHook(NavigatorMetadataEvent, onNavigatorMetadataEvent); UseMessageEventHook(NavigatorMetadataEvent, onNavigatorMetadataEvent);
UseMessageEventHook(NavigatorSearchEvent, onNavigatorSearchEvent); UseMessageEventHook(NavigatorSearchEvent, onNavigatorSearchEvent);
UseMessageEventHook(NavigatorCategoriesEvent, onNavigatorCategoriesEvent); UseMessageEventHook(UserFlatCatsEvent, onNavigatorCategoriesEvent);
UseMessageEventHook(RoomCreatedEvent, onRoomCreatedEvent); UseMessageEventHook(UserEventCatsEvent, onNavigatorEventCategoriesEvent);
UseMessageEventHook(FlatCreatedEvent, onRoomCreatedEvent);
UseMessageEventHook(NavigatorHomeRoomEvent, onNavigatorHomeRoomEvent); UseMessageEventHook(NavigatorHomeRoomEvent, onNavigatorHomeRoomEvent);
UseMessageEventHook(RoomEnterErrorEvent, onRoomEnterErrorEvent); UseMessageEventHook(RoomEnterErrorEvent, onRoomEnterErrorEvent);
UseMessageEventHook(NavigatorOpenRoomCreatorEvent, onRoomCreatorEvent); UseMessageEventHook(NavigatorOpenRoomCreatorEvent, onRoomCreatorEvent);

View File

@ -1,5 +1,5 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ConvertGlobalRoomIdMessageComposer, HabboWebTools, ILinkEventTracker, LegacyExternalInterface, NavigatorCategoryDataParser, NavigatorInitComposer, NavigatorSearchComposer, NavigatorSearchResultSet, NavigatorTopLevelContext, RoomDataParser, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { ConvertGlobalRoomIdMessageComposer, HabboWebTools, ILinkEventTracker, LegacyExternalInterface, NavigatorCategoryDataParser, NavigatorEventCategoryDataParser, NavigatorInitComposer, NavigatorSearchComposer, NavigatorSearchResultSet, NavigatorTopLevelContext, RoomDataParser, RoomSessionEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useRef, useState } from 'react'; import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { AddEventLinkTracker, DoorStateType, LocalizeText, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api'; import { AddEventLinkTracker, DoorStateType, LocalizeText, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api';
import { Base, Column, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { Base, Column, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
@ -25,6 +25,7 @@ export const NavigatorView: FC<{}> = props =>
const [ needsInit, setNeedsInit ] = useState(true); const [ needsInit, setNeedsInit ] = useState(true);
const [ needsSearch, setNeedsSearch ] = useState(false); const [ needsSearch, setNeedsSearch ] = useState(false);
const [ categories, setCategories ] = useState<NavigatorCategoryDataParser[]>(null); const [ categories, setCategories ] = useState<NavigatorCategoryDataParser[]>(null);
const [ eventCategories, setEventCategories ] = useState<NavigatorEventCategoryDataParser[]>(null);
const [ topLevelContext, setTopLevelContext ] = useState<NavigatorTopLevelContext>(null); const [ topLevelContext, setTopLevelContext ] = useState<NavigatorTopLevelContext>(null);
const [ topLevelContexts, setTopLevelContexts ] = useState<NavigatorTopLevelContext[]>(null); const [ topLevelContexts, setTopLevelContexts ] = useState<NavigatorTopLevelContext[]>(null);
const [ navigatorData, setNavigatorData ] = useSharedNavigatorData(); const [ navigatorData, setNavigatorData ] = useSharedNavigatorData();
@ -59,7 +60,7 @@ export const NavigatorView: FC<{}> = props =>
if(!isReady) if(!isReady)
{ {
setNeedsSearch(true); setNeedsSearch(true);
return; return;
} }
@ -80,7 +81,7 @@ export const NavigatorView: FC<{}> = props =>
} }
if(!topLevelContext) return; if(!topLevelContext) return;
sendSearch('', topLevelContext.code); sendSearch('', topLevelContext.code);
}, [ isReady, searchResult, topLevelContext, sendSearch ]); }, [ isReady, searchResult, topLevelContext, sendSearch ]);
@ -154,7 +155,7 @@ export const NavigatorView: FC<{}> = props =>
setNeedsSearch(true); setNeedsSearch(true);
} }
return; return;
} }
}, [ isVisible, navigatorData ]); }, [ isVisible, navigatorData ]);
useEffect(() => useEffect(() =>
@ -207,7 +208,7 @@ export const NavigatorView: FC<{}> = props =>
}, []); }, []);
return ( return (
<NavigatorContextProvider value={ { categories, setCategories, topLevelContext, setTopLevelContext, topLevelContexts, setTopLevelContexts, navigatorData, setNavigatorData, doorData, setDoorData, searchResult, setSearchResult } }> <NavigatorContextProvider value={ { categories, setCategories, eventCategories, setEventCategories, topLevelContext, setTopLevelContext, topLevelContexts, setTopLevelContexts, navigatorData, setNavigatorData, doorData, setDoorData, searchResult, setSearchResult } }>
<NavigatorMessageHandler /> <NavigatorMessageHandler />
{ isVisible && { isVisible &&
<NitroCardView uniqueKey="navigator" className="nitro-navigator"> <NitroCardView uniqueKey="navigator" className="nitro-navigator">

View File

@ -1,5 +1,5 @@
/* eslint-disable no-template-curly-in-string */ /* eslint-disable no-template-curly-in-string */
import { HabboClubLevelEnum, RoomCreateComposer } from '@nitrots/nitro-renderer'; import { CreateFlatMessageComposer, HabboClubLevelEnum } from '@nitrots/nitro-renderer';
import { FC, useEffect, useState } from 'react'; import { FC, useEffect, useState } from 'react';
import { GetClubMemberLevel, GetConfiguration, IRoomModel, LocalizeText, SendMessageComposer } from '../../../api'; import { GetClubMemberLevel, GetConfiguration, IRoomModel, LocalizeText, SendMessageComposer } from '../../../api';
import { Button, Column, Flex, Grid, LayoutCurrencyIcon, LayoutGridItem, Text } from '../../../common'; import { Button, Column, Flex, Grid, LayoutCurrencyIcon, LayoutGridItem, Text } from '../../../common';
@ -30,7 +30,7 @@ export const NavigatorRoomCreatorView: FC<{}> = props =>
const createRoom = () => const createRoom = () =>
{ {
SendMessageComposer(new RoomCreateComposer(name, description, 'model_' + selectedModelName, Number(category), Number(visitorsCount), tradesSetting)); SendMessageComposer(new CreateFlatMessageComposer(name, description, 'model_' + selectedModelName, Number(category), Number(visitorsCount), tradesSetting));
}; };
useEffect(() => useEffect(() =>
@ -54,7 +54,7 @@ export const NavigatorRoomCreatorView: FC<{}> = props =>
useEffect(() => useEffect(() =>
{ {
const models = GetConfiguration<IRoomModel[]>('navigator.room.models'); const models = GetConfiguration<IRoomModel[]>('navigator.room.models');
if(models && models.length) if(models && models.length)
{ {
setRoomModels(models); setRoomModels(models);

View File

@ -1,5 +1,5 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { RoomMuteComposer, RoomSettingsComposer, RoomStaffPickComposer, SecurityLevel, UserHomeRoomComposer } from '@nitrots/nitro-renderer'; import { RoomMuteComposer, RoomSettingsComposer, SecurityLevel, ToggleStaffPickMessageComposer, UpdateHomeRoomMessageComposer } from '@nitrots/nitro-renderer';
import classNames from 'classnames'; import classNames from 'classnames';
import { FC, useEffect, useState } from 'react'; import { FC, useEffect, useState } from 'react';
import { CreateLinkEvent, GetGroupInformation, GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../../api'; import { CreateLinkEvent, GetGroupInformation, GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../../api';
@ -32,7 +32,7 @@ export const NavigatorRoomInfoView: FC<NavigatorRoomInfoViewProps> = props =>
default: return false; default: return false;
} }
} }
const processAction = (action: string, value?: string) => const processAction = (action: string, value?: string) =>
{ {
if(!navigatorData || !navigatorData.enteredGuestRoom) return; if(!navigatorData || !navigatorData.enteredGuestRoom) return;
@ -47,7 +47,7 @@ export const NavigatorRoomInfoView: FC<NavigatorRoomInfoViewProps> = props =>
newRoomId = navigatorData.enteredGuestRoom.roomId; newRoomId = navigatorData.enteredGuestRoom.roomId;
} }
if(newRoomId > 0) SendMessageComposer(new UserHomeRoomComposer(newRoomId)); if(newRoomId > 0) SendMessageComposer(new UpdateHomeRoomMessageComposer(newRoomId));
return; return;
case 'navigator_search_tag': case 'navigator_search_tag':
return; return;
@ -65,7 +65,7 @@ export const NavigatorRoomInfoView: FC<NavigatorRoomInfoViewProps> = props =>
return; return;
case 'toggle_pick': case 'toggle_pick':
setIsRoomPicked(value => !value); setIsRoomPicked(value => !value);
SendMessageComposer(new RoomStaffPickComposer(navigatorData.enteredGuestRoom.roomId)); SendMessageComposer(new ToggleStaffPickMessageComposer(navigatorData.enteredGuestRoom.roomId));
return; return;
case 'toggle_mute': case 'toggle_mute':
setIsRoomMuted(value => !value); setIsRoomMuted(value => !value);
@ -78,7 +78,7 @@ export const NavigatorRoomInfoView: FC<NavigatorRoomInfoViewProps> = props =>
onCloseClick(); onCloseClick();
return; return;
} }
} }
useEffect(() => useEffect(() =>
@ -86,12 +86,12 @@ export const NavigatorRoomInfoView: FC<NavigatorRoomInfoViewProps> = props =>
if(!navigatorData) return; if(!navigatorData) return;
setIsRoomPicked(navigatorData.currentRoomIsStaffPick); setIsRoomPicked(navigatorData.currentRoomIsStaffPick);
if(navigatorData.enteredGuestRoom) setIsRoomMuted(navigatorData.enteredGuestRoom.allInRoomMuted); if(navigatorData.enteredGuestRoom) setIsRoomMuted(navigatorData.enteredGuestRoom.allInRoomMuted);
}, [ navigatorData ]); }, [ navigatorData ]);
if(!navigatorData.enteredGuestRoom) return null; if(!navigatorData.enteredGuestRoom) return null;
return ( return (
<NitroCardView className="nitro-room-info" theme="primary-slim"> <NitroCardView className="nitro-room-info" theme="primary-slim">
<NitroCardHeaderView headerText={ LocalizeText('navigator.roomsettings.roominfo') } onCloseClick={ () => processAction('close') } /> <NitroCardHeaderView headerText={ LocalizeText('navigator.roomsettings.roominfo') } onCloseClick={ () => processAction('close') } />
@ -164,7 +164,7 @@ export const NavigatorRoomInfoView: FC<NavigatorRoomInfoViewProps> = props =>
</> } </> }
</Column> </Column>
</> } </> }
</NitroCardContentView> </NitroCardContentView>
</NitroCardView> </NitroCardView>
); );

View File

@ -1,4 +1,4 @@
import { RoomBannedUsersComposer, RoomDataParser, RoomSettingsEvent, SaveRoomSettingsComposer } from '@nitrots/nitro-renderer'; import { RoomBannedUsersComposer, RoomDataParser, RoomSettingsDataEvent, SaveRoomSettingsComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react'; import { FC, useCallback, useState } from 'react';
import { IRoomData, LocalizeText, SendMessageComposer } from '../../../../api'; import { IRoomData, LocalizeText, SendMessageComposer } from '../../../../api';
import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../common'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../common';
@ -22,46 +22,48 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
const [ roomData, setRoomData ] = useState<IRoomData>(null); const [ roomData, setRoomData ] = useState<IRoomData>(null);
const [ currentTab, setCurrentTab ] = useState(TABS[0]); const [ currentTab, setCurrentTab ] = useState(TABS[0]);
const onRoomSettingsEvent = useCallback((event: RoomSettingsEvent) => const onRoomSettingsEvent = useCallback((event: RoomSettingsDataEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
if(!parser) return; if(!parser) return;
const data = parser.data;
setRoomData({ setRoomData({
roomId: parser.roomId, roomId: data.roomId,
roomName: parser.name, roomName: data.name,
roomDescription: parser.description, roomDescription: data.description,
categoryId: parser.categoryId, categoryId: data.categoryId,
userCount: parser.userCount, userCount: data.maximumVisitorsLimit,
tags: parser.tags, tags: data.tags,
tradeState: parser.tradeMode, tradeState: data.tradeMode,
allowWalkthrough: parser.allowWalkthrough, allowWalkthrough: data.allowWalkThrough,
lockState: parser.state, lockState: data.doorMode,
password: null, password: null,
allowPets: parser.allowPets, allowPets: data.allowPets,
allowPetsEat: parser.allowPetsEat, allowPetsEat: data.allowFoodConsume,
hideWalls: parser.hideWalls, hideWalls: data.hideWalls,
wallThickness: parser.thicknessWall, wallThickness: data.wallThickness,
floorThickness: parser.thicknessFloor, floorThickness: data.floorThickness,
chatSettings: { chatSettings: {
mode: parser.chatSettings.mode, mode: data.chatSettings.mode,
weight: parser.chatSettings.weight, weight: data.chatSettings.weight,
speed: parser.chatSettings.speed, speed: data.chatSettings.speed,
distance: parser.chatSettings.distance, distance: data.chatSettings.distance,
protection: parser.chatSettings.protection protection: data.chatSettings.protection
}, },
moderationSettings: { moderationSettings: {
allowMute: parser.moderationSettings.allowMute, allowMute: data.roomModerationSettings.allowMute,
allowKick: parser.moderationSettings.allowKick, allowKick: data.roomModerationSettings.allowKick,
allowBan: parser.moderationSettings.allowBan allowBan: data.roomModerationSettings.allowBan
} }
}); });
SendMessageComposer(new RoomBannedUsersComposer(parser.roomId)); SendMessageComposer(new RoomBannedUsersComposer(data.roomId));
}, []); }, []);
UseMessageEventHook(RoomSettingsEvent, onRoomSettingsEvent); UseMessageEventHook(RoomSettingsDataEvent, onRoomSettingsEvent);
const close = () => const close = () =>
{ {
@ -86,7 +88,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
case 'category': case 'category':
newValue.categoryId = Number(value); newValue.categoryId = Number(value);
break; break;
case 'max_visitors': case 'max_visitors':
newValue.userCount = Number(value); newValue.userCount = Number(value);
break; break;
case 'trade_state': case 'trade_state':
@ -176,7 +178,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
} }
if(!roomData) return null; if(!roomData) return null;
return ( return (
<NitroCardView uniqueKey="nitro-room-settings" className="nitro-room-settings"> <NitroCardView uniqueKey="nitro-room-settings" className="nitro-room-settings">
<NitroCardHeaderView headerText={ LocalizeText('navigator.roomsettings') } onCloseClick={ close } /> <NitroCardHeaderView headerText={ LocalizeText('navigator.roomsettings') } onCloseClick={ close } />

View File

@ -1,4 +1,4 @@
import { GetGuestRoomResultEvent, RoomLikeRoomComposer } from '@nitrots/nitro-renderer'; import { GetGuestRoomResultEvent, RateFlatMessageComposer } from '@nitrots/nitro-renderer';
import classNames from 'classnames'; import classNames from 'classnames';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { CreateLinkEvent, GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../api'; import { CreateLinkEvent, GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../api';
@ -41,7 +41,7 @@ export const RoomToolsWidgetView: FC<{}> = props =>
CreateLinkEvent('chat-history/toggle'); CreateLinkEvent('chat-history/toggle');
return; return;
case 'like_room': case 'like_room':
SendMessageComposer(new RoomLikeRoomComposer(1)); SendMessageComposer(new RateFlatMessageComposer(1));
return; return;
case 'toggle_room_link': case 'toggle_room_link':
CreateLinkEvent('navigator/toggle-room-link'); CreateLinkEvent('navigator/toggle-room-link');