Merge branch 'dev' into clubgift-notification

This commit is contained in:
oshawott 2022-03-16 18:44:19 +11:00 committed by dank074
commit 75271eda7b
10 changed files with 90 additions and 44 deletions

View File

@ -0,0 +1,9 @@
import { GetRoomSession, GetRoomSessionManager, GoToDesktop } from '.';
export const VisitDesktop = () =>
{
if(!GetRoomSession()) return;
GoToDesktop();
GetRoomSessionManager().removeSession(-1);
}

View File

@ -18,3 +18,4 @@ export * from './IsOwnerOfFloorFurniture';
export * from './IsOwnerOfFurniture';
export * from './IsRidingHorse';
export * from './StartRoomSession';
export * from './VisitDesktop';

View File

@ -1,20 +1,21 @@
import { FC } from 'react';
import { GetRoomEngine, GetSessionDataManager } from '../../api';
import { GetConfiguration, GetRoomEngine, GetSessionDataManager } from '../../api';
import { Base, Column, Flex, LayoutImage } from '../../common';
import { CalendarItemState } from './common/CalendarItemState';
import { ICalendarItem } from './common/ICalendarItem';
interface CalendarItemViewProps
{
itemId: number;
state: number;
active?: boolean;
productName?: string;
product?: ICalendarItem;
onClick: (itemId: number) => void;
}
export const CalendarItemView: FC<CalendarItemViewProps> = props =>
{
const { itemId = -1, state = null, productName = null, active = false, onClick = null } = props;
const { itemId = -1, state = null, product = null, active = false, onClick = null } = props;
const getFurnitureIcon = (name: string) =>
{
@ -37,8 +38,8 @@ export const CalendarItemView: FC<CalendarItemViewProps> = props =>
{ (state === CalendarItemState.STATE_UNLOCKED) &&
<Flex center className="campaign-spritesheet unlocked-bg">
<Flex center className="campaign-spritesheet campaign-opened">
{ productName &&
<LayoutImage imageUrl={ getFurnitureIcon(productName) } /> }
{ product &&
<LayoutImage imageUrl={ product.customImage ? GetConfiguration<string>('image.library.url') + product.customImage : getFurnitureIcon(product.productName) } /> }
</Flex>
</Flex> }
{ (state !== CalendarItemState.STATE_UNLOCKED) &&

View File

@ -3,12 +3,13 @@ import { GetSessionDataManager, LocalizeText } from '../../api';
import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common';
import { CalendarItemView } from './CalendarItemView';
import { CalendarItemState } from './common/CalendarItemState';
import { ICalendarItem } from './common/ICalendarItem';
interface CalendarViewProps
{
close(): void;
openPackage(id: number, asStaff: boolean): void;
receivedProducts: Map<number, string>;
receivedProducts: Map<number, ICalendarItem>;
campaignName: string;
currentDay: number;
numDays: number;
@ -128,7 +129,7 @@ export const CalendarView: FC<CalendarViewProps> = props =>
return (
<Column key={ i } overflow="hidden">
<CalendarItemView itemId={ day } state={ getDayState(day) } active={ (selectedDay === day) } productName={ receivedProducts.has(day) ? receivedProducts.get(day) : null } onClick={ onClickItem } />
<CalendarItemView itemId={ day } state={ getDayState(day) } active={ (selectedDay === day) } product={ receivedProducts.has(day) ? receivedProducts.get(day) : null } onClick={ onClickItem } />
</Column>
);
}) }
@ -138,28 +139,6 @@ export const CalendarView: FC<CalendarViewProps> = props =>
<Base pointer className="campaign-spritesheet next" onClick={ onClickNext } />
</Flex>
</Flex>
{/* <Grid fullHeight alignItems="center" gap={ 1 }>
<Column fullHeight center size={ 1 }>
<Base pointer className="campaign-spritesheet prev" onClick={ onClickPrev } />
</Column>
<Column fullHeight size={ 10 }>
<Grid fullHeight columnCount={ TOTAL_SHOWN_ITEMS } gap={ 1 }>
{ [...Array(TOTAL_SHOWN_ITEMS)].map((e, i) =>
{
const day = (index + i);
return (
<Column key={ i } overflow="hidden">
<CalendarItemView itemId={ day } state={ getDayState(day) } active={ (selectedDay === day) } productName={ receivedProducts.has(day) ? receivedProducts.get(day) : null } onClick={ onClickItem } />
</Column>
);
}) }
</Grid>
</Column>
<Column fullHeight center size={ 1 }>
<Base pointer className="campaign-spritesheet next" onClick={ onClickNext } />
</Column>
</Grid> */}
</NitroCardContentView>
</NitroCardView>
)

View File

@ -3,12 +3,13 @@ import { FC, useCallback, useEffect, useState } from 'react';
import { AddEventLinkTracker, RemoveLinkEventTracker, SendMessageComposer } from '../../api';
import { BatchUpdates, UseMessageEventHook } from '../../hooks';
import { CalendarView } from './CalendarView';
import { CalendarItem } from './common/CalendarItem';
export const CampaignView: FC<{}> = props =>
{
const [ calendarData, setCalendarData ] = useState<CampaignCalendarData>(null);
const [ lastOpenAttempt, setLastOpenAttempt ] = useState<number>(-1);
const [ receivedProducts, setReceivedProducts ] = useState<Map<number, string>>(new Map());
const [ receivedProducts, setReceivedProducts ] = useState<Map<number, CalendarItem>>(new Map());
const [ isCalendarOpen, setCalendarOpen ] = useState(false);
const onCampaignCalendarDataMessageEvent = useCallback((event: CampaignCalendarDataMessageEvent) =>
@ -44,7 +45,7 @@ export const CampaignView: FC<{}> = props =>
setReceivedProducts(prev =>
{
const copy = new Map(prev);
copy.set(lastAttempt, parser.furnitureClassName);
copy.set(lastAttempt, new CalendarItem(parser.productName, parser.customImage,parser.furnitureClassName));
return copy;
});

View File

@ -0,0 +1,30 @@
import { ICalendarItem } from './ICalendarItem';
export class CalendarItem implements ICalendarItem
{
private _productName: string;
private _customImage: string;
private _furnitureClassName: string;
constructor(productName: string, customImage: string, furnitureClassName: string)
{
this._productName = productName;
this._customImage = customImage;
this._furnitureClassName = furnitureClassName;
}
public get productName(): string
{
return this._productName;
}
public get customImage(): string
{
return this._customImage;
}
public get furnitureClassName(): string
{
return this._furnitureClassName;
}
}

View File

@ -0,0 +1,6 @@
export interface ICalendarItem
{
readonly productName: string;
readonly customImage: string;
readonly furnitureClassName: string;
}

View File

@ -55,7 +55,6 @@ export const CatalogView: FC<{}> = props =>
setActiveNodes([]);
setSearchResult(null);
setFrontPageItems([]);
setIsVisible(true);
});
}, []);

View File

@ -1,6 +1,6 @@
import { GenericErrorEvent, GetGuestRoomResultEvent, LegacyExternalInterface, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomSettingsUpdatedEvent, UserInfoEvent } from '@nitrots/nitro-renderer';
import { CantConnectMessageParser, GenericErrorEvent, GetGuestRoomResultEvent, LegacyExternalInterface, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEnterErrorEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomSettingsUpdatedEvent, UserInfoEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback } from 'react';
import { CreateRoomSession, GetSessionDataManager, SendMessageComposer } from '../../api';
import { CreateRoomSession, GetSessionDataManager, LocalizeText, NotificationAlertType, NotificationUtilities, SendMessageComposer, VisitDesktop } from '../../api';
import { UpdateDoorStateEvent } from '../../events';
import { DispatchUiEvent, UseMessageEventHook } from '../../hooks';
import { useNavigatorContext } from './NavigatorContext';
@ -194,6 +194,33 @@ export const NavigatorMessageHandler: FC<{}> = props =>
SendMessageComposer(new RoomInfoComposer(parser.roomId, false, false));
}, []);
const onRoomEnterErrorEvent = useCallback((event: RoomEnterErrorEvent) =>
{
const parser = event.getParser();
switch(parser.reason)
{
case CantConnectMessageParser.REASON_FULL:
NotificationUtilities.simpleAlert(LocalizeText('navigator.guestroomfull.text'), NotificationAlertType.DEFAULT, null, null, LocalizeText('navigator.guestroomfull.title'));
break;
case CantConnectMessageParser.REASON_QUEUE_ERROR:
NotificationUtilities.simpleAlert(LocalizeText(`room.queue.error.${ parser.parameter }`), NotificationAlertType.DEFAULT, null, null, LocalizeText('room.queue.error.title'));
break;
case CantConnectMessageParser.REASON_BANNED:
NotificationUtilities.simpleAlert(LocalizeText('navigator.banned.text'), NotificationAlertType.DEFAULT, null, null, LocalizeText('navigator.banned.title'));
break;
default:
NotificationUtilities.simpleAlert(LocalizeText('room.queue.error.title'), NotificationAlertType.DEFAULT, null, null, LocalizeText('room.queue.error.title'));
break;
}
VisitDesktop();
}, []);
UseMessageEventHook(UserInfoEvent, onUserInfoEvent);
UseMessageEventHook(RoomForwardEvent, onRoomForwardEvent);
UseMessageEventHook(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent);
@ -208,6 +235,7 @@ export const NavigatorMessageHandler: FC<{}> = props =>
UseMessageEventHook(RoomCreatedEvent, onRoomCreatedEvent);
UseMessageEventHook(NavigatorHomeRoomEvent, onNavigatorHomeRoomEvent);
UseMessageEventHook(RoomSettingsUpdatedEvent, onRoomSettingsUpdatedEvent);
UseMessageEventHook(RoomEnterErrorEvent, onRoomEnterErrorEvent);
return null;
}

View File

@ -1,6 +1,6 @@
import { Dispose, DropBounce, EaseOut, FigureUpdateEvent, JumpBy, Motions, NitroToolbarAnimateIconEvent, PerkAllowancesMessageEvent, PerkEnum, Queue, UserInfoDataParser, UserInfoEvent, Wait } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { CreateLinkEvent, GetRoomSession, GetRoomSessionManager, GetSessionDataManager, GetUserProfile, GoToDesktop, OpenMessengerChat } from '../../api';
import { CreateLinkEvent, GetSessionDataManager, GetUserProfile, OpenMessengerChat, VisitDesktop } from '../../api';
import { Base, Flex, LayoutAvatarImageView, LayoutItemCountView, TransitionAnimation, TransitionAnimationTypes } from '../../common';
import { AchievementsUIEvent, AchievementsUIUnseenCountEvent, FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, ModToolsEvent, NavigatorEvent, UnseenItemTrackerUpdateEvent, UserSettingsUIEvent } from '../../events';
import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks';
@ -178,14 +178,6 @@ export const ToolbarView: FC<ToolbarViewProps> = props =>
}
}, []);
const visitDesktop = useCallback(() =>
{
if(!GetRoomSession()) return;
GoToDesktop();
GetRoomSessionManager().removeSession(-1);
}, []);
return (
<>
<TransitionAnimation type={ TransitionAnimationTypes.FADE_IN } inProp={ isMeExpanded } timeout={ 300 }>
@ -200,7 +192,7 @@ export const ToolbarView: FC<ToolbarViewProps> = props =>
<LayoutItemCountView count={ unseenAchievementCount } /> }
</Flex>
{ isInRoom &&
<Base pointer className="navigation-item icon icon-habbo" onClick={ visitDesktop } /> }
<Base pointer className="navigation-item icon icon-habbo" onClick={ event => VisitDesktop() } /> }
{ !isInRoom &&
<Base pointer className="navigation-item icon icon-house" onClick={ event => CreateLinkEvent('navigator/goto/home') } /> }
<Base pointer className="navigation-item icon icon-rooms" onClick={ event => handleToolbarItemClick(ToolbarViewItems.NAVIGATOR_ITEM) } />