Merge branch 'dev' into feature/marketplace

This commit is contained in:
dank074 2022-01-04 01:34:34 -06:00
commit e5e26f106c
15 changed files with 10226 additions and 9540 deletions

2
.env
View File

@ -2,6 +2,6 @@ BROWSER=none
GENERATE_SOURCEMAP=false GENERATE_SOURCEMAP=false
REACT_APP_CONFIG_URLS=/renderer-config.json,/ui-config.json REACT_APP_CONFIG_URLS=/renderer-config.json,/ui-config.json
REACT_APP_SOCKET_URL=wss://ws.nitrots.co:2096 REACT_APP_SOCKET_URL=wss://ws.nitrots.co:2096
REACT_APP_ASSET_URL=https://nitro.nitrots.co REACT_APP_ASSET_URL=https://assets.nitrodev.co
REACT_APP_IMAGE_LIBRARY_URL=https://swf.nitrots.co/c_images/ REACT_APP_IMAGE_LIBRARY_URL=https://swf.nitrots.co/c_images/
REACT_APP_HOF_FURNI_URL=https://swf.nitrots.co/dcr/hof_furni REACT_APP_HOF_FURNI_URL=https://swf.nitrots.co/dcr/hof_furni

7
.env.default Normal file
View File

@ -0,0 +1,7 @@
BROWSER=none
GENERATE_SOURCEMAP=false
REACT_APP_CONFIG_URLS=/renderer-config.json,/ui-config.json
REACT_APP_SOCKET_URL=wss://ws.server.com:2096
REACT_APP_ASSET_URL=https://nitro.server.com
REACT_APP_IMAGE_LIBRARY_URL=https://swf.server.com/c_images/
REACT_APP_HOF_FURNI_URL=https://swf.server.com/dcr/hof_furni

View File

@ -1,8 +1,8 @@
{ {
"socket.url": "wss://ws.nitrots.co:2096", "socket.url": "wss://ws.nitrots.co:2096",
"asset.url": "https://nitro.nitrots.co", "asset.url": "",
"image.library.url": "https://swf.nitrots.co/c_images/", "image.library.url": "",
"hof.furni.url": "https://swf.nitrots.co/dcr/hof_furni", "hof.furni.url": "",
"images.url": "${asset.url}/images", "images.url": "${asset.url}/images",
"gamedata.url": "${asset.url}/gamedata", "gamedata.url": "${asset.url}/gamedata",
"sounds.url": "${asset.url}/sounds/%sample%.mp3", "sounds.url": "${asset.url}/sounds/%sample%.mp3",
@ -21,9 +21,7 @@
"pet.asset.url": "${asset.url}/bundled/pet/%libname%.nitro", "pet.asset.url": "${asset.url}/bundled/pet/%libname%.nitro",
"generic.asset.url": "${asset.url}/bundled/generic/%libname%.nitro", "generic.asset.url": "${asset.url}/bundled/generic/%libname%.nitro",
"badge.asset.url": "${image.library.url}album1584/%badgename%.gif", "badge.asset.url": "${image.library.url}album1584/%badgename%.gif",
"badge.asset.group.url": "https://cdn.ironhotel.biz/group-badge/%badgedata%.gif", "badge.asset.grouparts.url": "${image.library.url}Badgeparts/badgepart_%part%.png",
"badge.asset.group.external.url": "",
"badge.asset.grouparts.url": "https://cdn.ironhotel.biz/static_iron_active/c_images/Badgeparts/badgepart_%part%.png",
"furni.rotation.bounce.steps": 20, "furni.rotation.bounce.steps": 20,
"furni.rotation.bounce.height": 0.0625, "furni.rotation.bounce.height": 0.0625,
"enable.avatar.arrow": false, "enable.avatar.arrow": false,
@ -102,6 +100,7 @@
], ],
"preload.assets.urls": [ "preload.assets.urls": [
"${asset.url}/bundled/generic/avatar_additions.nitro", "${asset.url}/bundled/generic/avatar_additions.nitro",
"${asset.url}/bundled/generic/floor_editor.nitro",
"${images.url}/loading_icon.png", "${images.url}/loading_icon.png",
"${images.url}/clear_icon.png", "${images.url}/clear_icon.png",
"${images.url}/big_arrow.png" "${images.url}/big_arrow.png"

View File

@ -127,6 +127,7 @@ export const App: FC<{}> = props =>
return ( return (
<div className="nitro-app overflow-hidden"> <div className="nitro-app overflow-hidden">
<div id="nitro-alerts-container" /> <div id="nitro-alerts-container" />
<div id="nitro-confirms-container" />
{ (!isReady || isError) && <LoadingView isError={ isError } message={ message } /> } { (!isReady || isError) && <LoadingView isError={ isError } message={ message } /> }
<TransitionAnimation type={ TransitionAnimationTypes.FADE_IN } inProp={ (isReady && !isError) }> <TransitionAnimation type={ TransitionAnimationTypes.FADE_IN } inProp={ (isReady && !isError) }>
<MainView /> <MainView />

View File

@ -1,9 +1,10 @@
import { AvatarExpressionEnum, HabboClubLevelEnum, NitroEvent, RoomControllerLevel, RoomSessionChatEvent, RoomSettingsComposer, RoomWidgetEnum, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer'; import { AvatarExpressionEnum, HabboClubLevelEnum, NitroEvent, RoomControllerLevel, RoomSessionChatEvent, RoomSettingsComposer, RoomWidgetEnum, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer';
import { GetConfiguration, GetNitroInstance } from '../../..'; import { GetConfiguration, GetNitroInstance } from '../../..';
import { GetRoomEngine, GetSessionDataManager } from '../../../..'; import { GetRoomEngine, GetSessionDataManager, LocalizeText } from '../../../..';
import { FloorplanEditorEvent } from '../../../../../events/floorplan-editor/FloorplanEditorEvent'; import { FloorplanEditorEvent } from '../../../../../events/floorplan-editor/FloorplanEditorEvent';
import { dispatchUiEvent } from '../../../../../hooks'; import { dispatchUiEvent } from '../../../../../hooks';
import { SendMessageHook } from '../../../../../hooks/messages'; import { SendMessageHook } from '../../../../../hooks/messages';
import { NotificationUtilities } from '../../../../../views/notification-center/common/NotificationUtilities';
import { RoomWidgetFloodControlEvent, RoomWidgetUpdateEvent } from '../events'; import { RoomWidgetFloodControlEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetChatMessage, RoomWidgetChatSelectAvatarMessage, RoomWidgetChatTypingMessage, RoomWidgetMessage, RoomWidgetRequestWidgetMessage } from '../messages'; import { RoomWidgetChatMessage, RoomWidgetChatSelectAvatarMessage, RoomWidgetChatTypingMessage, RoomWidgetMessage, RoomWidgetRequestWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler'; import { RoomWidgetHandler } from './RoomWidgetHandler';
@ -127,10 +128,11 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
newWindow.document.write(image.outerHTML); newWindow.document.write(image.outerHTML);
return null; return null;
case ':pickall': case ':pickall':
// this.container.notificationService.alertWithConfirm('${room.confirm.pick_all}', '${generic.alert.title}', () => NotificationUtilities.confirm(LocalizeText('room.confirm.pick_all'), () =>
// { {
// GetSessionDataManager().sendSpecialCommandMessage(':pickall'); GetSessionDataManager().sendSpecialCommandMessage(':pickall');
// }); },
null, null, null, LocalizeText('generic.alert.title'));
return null; return null;
case ':furni': case ':furni':

View File

@ -0,0 +1,62 @@
import { NitroEvent } from '@nitrots/nitro-renderer';
export class NotificationConfirmEvent extends NitroEvent
{
public static CONFIRM: string = 'NCE_CONFIRM';
private _confirmType: string;
private _message: string;
private _onConfirm: Function;
private _onCancel: Function;
private _confirmText: string;
private _cancelText: string;
private _title: string;
constructor(confirmType: string, message: string, onConfirm: Function, onCancel: Function, confirmText: string, cancelText: string, title: string)
{
super(NotificationConfirmEvent.CONFIRM);
this._confirmType = confirmType;
this._message = message;
this._onConfirm = onConfirm;
this._onCancel = onCancel;
this._confirmText = confirmText;
this._cancelText = cancelText;
this._title = title;
}
public get confirmType(): string
{
return this._confirmType;
}
public get message(): string
{
return this._message;
}
public get onConfirm(): Function
{
return this._onConfirm;
}
public get onCancel(): Function
{
return this._onCancel;
}
public get confirmText(): string
{
return this._confirmText;
}
public get cancelText(): string
{
return this._cancelText;
}
public get title(): string
{
return this._title;
}
}

View File

@ -2,3 +2,4 @@ export * from './NotificationAlertEvent';
export * from './NotificationBubbleEvent'; export * from './NotificationBubbleEvent';
export * from './NotificationCenterAlertEvent'; export * from './NotificationCenterAlertEvent';
export * from './NotificationCenterEvent'; export * from './NotificationCenterEvent';
export * from './NotificationConfirmEvent';

View File

@ -1,20 +1,23 @@
import { FC, ReactNode, useCallback, useMemo, useState } from 'react'; import { FC, ReactNode, useCallback, useMemo, useState } from 'react';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
import { NotificationAlertEvent } from '../../events'; import { NotificationAlertEvent, NotificationConfirmEvent } from '../../events';
import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent'; import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent';
import { useUiEvent } from '../../hooks/events'; import { useUiEvent } from '../../hooks/events';
import { NotificationAlertItem } from './common/NotificationAlertItem'; import { NotificationAlertItem } from './common/NotificationAlertItem';
import { NotificationBubbleItem } from './common/NotificationBubbleItem'; import { NotificationBubbleItem } from './common/NotificationBubbleItem';
import { NotificationBubbleType } from './common/NotificationBubbleType'; import { NotificationBubbleType } from './common/NotificationBubbleType';
import { NotificationConfirmItem } from './common/NotificationConfirmItem';
import { NotificationCenterMessageHandler } from './NotificationCenterMessageHandler'; import { NotificationCenterMessageHandler } from './NotificationCenterMessageHandler';
import { NotificationCenterViewProps } from './NotificationCenterView.types'; import { NotificationCenterViewProps } from './NotificationCenterView.types';
import { GetAlertLayout } from './views/alert-layouts/GetAlertLayout'; import { GetAlertLayout } from './views/alert-layouts/GetAlertLayout';
import { GetBubbleLayout } from './views/bubble-layouts/GetBubbleLayout'; import { GetBubbleLayout } from './views/bubble-layouts/GetBubbleLayout';
import { GetConfirmLayout } from './views/confirm-layouts/GetConfirmLayout';
export const NotificationCenterView: FC<NotificationCenterViewProps> = props => export const NotificationCenterView: FC<NotificationCenterViewProps> = props =>
{ {
const [ alerts, setAlerts ] = useState<NotificationAlertItem[]>([]); const [ alerts, setAlerts ] = useState<NotificationAlertItem[]>([]);
const [ bubbleAlerts, setBubbleAlerts ] = useState<NotificationBubbleItem[]>([]); const [ bubbleAlerts, setBubbleAlerts ] = useState<NotificationBubbleItem[]>([]);
const [ confirms, setConfirms ] = useState<NotificationConfirmItem[]>([]);
const onNotificationAlertEvent = useCallback((event: NotificationAlertEvent) => const onNotificationAlertEvent = useCallback((event: NotificationAlertEvent) =>
{ {
@ -36,6 +39,15 @@ export const NotificationCenterView: FC<NotificationCenterViewProps> = props =>
useUiEvent(NotificationBubbleEvent.NEW_BUBBLE, onNotificationBubbleEvent); useUiEvent(NotificationBubbleEvent.NEW_BUBBLE, onNotificationBubbleEvent);
const onNotificationConfirmEvent = useCallback((event: NotificationConfirmEvent) =>
{
const confirmItem = new NotificationConfirmItem(event.type, event.message, event.onConfirm, event.onCancel, event.confirmText, event.cancelText, event.title);
setConfirms(prevValue => [ confirmItem, ...prevValue ]);
}, []);
useUiEvent(NotificationConfirmEvent.CONFIRM, onNotificationConfirmEvent);
const closeAlert = useCallback((alert: NotificationAlertItem) => const closeAlert = useCallback((alert: NotificationAlertItem) =>
{ {
setAlerts(prevValue => setAlerts(prevValue =>
@ -62,6 +74,19 @@ export const NotificationCenterView: FC<NotificationCenterViewProps> = props =>
}) })
}, []); }, []);
const closeConfirm = useCallback((item: NotificationConfirmItem) =>
{
setConfirms(prevValue =>
{
const newConfirms = [ ...prevValue ];
const index = newConfirms.findIndex(value => (item === value));
if(index >= 0) newConfirms.splice(index, 1);
return newConfirms;
})
}, []);
const getAlerts = useMemo(() => const getAlerts = useMemo(() =>
{ {
if(!alerts || !alerts.length) return null; if(!alerts || !alerts.length) return null;
@ -101,6 +126,22 @@ export const NotificationCenterView: FC<NotificationCenterViewProps> = props =>
return elements; return elements;
}, [ bubbleAlerts, closeBubbleAlert ]); }, [ bubbleAlerts, closeBubbleAlert ]);
const getConfirms = useMemo(() =>
{
if(!confirms || !confirms.length) return null;
const elements: ReactNode[] = [];
for(const confirm of confirms)
{
const element = GetConfirmLayout(confirm, () => closeConfirm(confirm));
elements.push(element);
}
return elements;
}, [ confirms, closeConfirm ]);
return ( return (
<> <>
<NotificationCenterMessageHandler /> <NotificationCenterMessageHandler />
@ -108,6 +149,7 @@ export const NotificationCenterView: FC<NotificationCenterViewProps> = props =>
{ getBubbleAlerts } { getBubbleAlerts }
</div> </div>
{ createPortal(getAlerts, document.getElementById('nitro-alerts-container')) } { createPortal(getAlerts, document.getElementById('nitro-alerts-container')) }
{ createPortal(getConfirms, document.getElementById('nitro-confirms-container')) }
</> </>
); );
} }

View File

@ -0,0 +1,67 @@
export class NotificationConfirmItem
{
private static ITEM_ID: number = -1;
private _id: number;
private _confirmType: string;
private _message: string;
private _onConfirm: Function;
private _onCancel: Function;
private _confirmText: string;
private _cancelText: string;
private _title: string;
constructor(confirmType: string, message: string, onConfirm: Function, onCancel: Function, confirmText: string, cancelText: string, title: string)
{
NotificationConfirmItem.ITEM_ID += 1;
this._id = NotificationConfirmItem.ITEM_ID;
this._confirmType = confirmType;
this._message = message;
this._onConfirm = onConfirm;
this._onCancel = onCancel;
this._confirmText = confirmText;
this._cancelText = cancelText;
this._title = title;
}
public get id(): number
{
return this._id;
}
public get confirmType(): string
{
return this._confirmType;
}
public get message(): string
{
return this._message;
}
public get onConfirm(): Function
{
return this._onConfirm;
}
public get onCancel(): Function
{
return this._onCancel;
}
public get confirmText(): string
{
return this._confirmText;
}
public get cancelText(): string
{
return this._cancelText;
}
public get title(): string
{
return this._title;
}
}

View File

@ -0,0 +1,4 @@
export class NotificationConfirmType
{
public static DEFAULT: string = 'default';
}

View File

@ -1,6 +1,6 @@
import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer'; import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer';
import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '../../../api'; import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '../../../api';
import { NotificationAlertEvent } from '../../../events'; import { NotificationAlertEvent, NotificationConfirmEvent } from '../../../events';
import { NotificationBubbleEvent } from '../../../events/notification-center/NotificationBubbleEvent'; import { NotificationBubbleEvent } from '../../../events/notification-center/NotificationBubbleEvent';
import { dispatchUiEvent } from '../../../hooks'; import { dispatchUiEvent } from '../../../hooks';
import { CatalogPageName } from '../../catalog/common/CatalogPageName'; import { CatalogPageName } from '../../catalog/common/CatalogPageName';
@ -112,6 +112,17 @@ export class NotificationUtilities
dispatchUiEvent(new NotificationAlertEvent(messages, NotificationAlertType.MOTD, null, null, LocalizeText('notifications.motd.title'))); dispatchUiEvent(new NotificationAlertEvent(messages, NotificationAlertType.MOTD, null, null, LocalizeText('notifications.motd.title')));
} }
public static confirm(message: string, onConfirm: Function, onCancel: Function, confirmText: string = null, cancelText: string = null, title: string = null, type: string = null): void
{
if(!confirmText || !confirmText.length) confirmText = LocalizeText('generic.confirm');
if(!cancelText || !cancelText.length) cancelText = LocalizeText('generic.cancel');
if(!title || !title.length) title = LocalizeText('notifications.broadcast.title');
dispatchUiEvent(new NotificationConfirmEvent(type, this.cleanText(message), onConfirm, onCancel, confirmText, cancelText, title));
}
public static simpleAlert(message: string, type: string, clickUrl: string = null, clickUrlText: string = null, title: string = null, imageUrl: string = null): void public static simpleAlert(message: string, type: string, clickUrl: string = null, clickUrlText: string = null, title: string = null, imageUrl: string = null): void
{ {
if(!title || !title.length) title = LocalizeText('notifications.broadcast.title'); if(!title || !title.length) title = LocalizeText('notifications.broadcast.title');

View File

@ -0,0 +1,15 @@
import { NotificationConfirmItem } from '../../common/NotificationConfirmItem';
import { NotificationDefaultConfirmView } from './default/NotificationDefaultConfirmView';
export const GetConfirmLayout = (item: NotificationConfirmItem, close: () => void) =>
{
if(!item) return null;
const props = { key: item.id, item, close };
switch(item.confirmType)
{
default:
return <NotificationDefaultConfirmView { ...props } />
}
}

View File

@ -0,0 +1,7 @@
import { NotificationConfirmItem } from '../../common/NotificationConfirmItem';
export interface NotificationConfirmLayoutViewProps
{
item: NotificationConfirmItem;
close: () => void;
}

View File

@ -0,0 +1,38 @@
import { DetailsHTMLAttributes, FC } from 'react';
import { NotificationAlertView } from '../../../../../layout';
import { NotificationConfirmLayoutViewProps } from '../NotificationConfirmLayoutView.types';
export interface NotificationDefaultConfirmViewProps extends NotificationConfirmLayoutViewProps, DetailsHTMLAttributes<HTMLDivElement>
{
}
export const NotificationDefaultConfirmView: FC<NotificationDefaultConfirmViewProps> = props =>
{
const { item = null, close = null, ...rest } = props;
const { message = null, onConfirm = null, onCancel = null, confirmText = null, cancelText = null, title = null } = item;
const confirm = () =>
{
if(onConfirm) onConfirm();
close();
}
const cancel = () =>
{
if(onCancel) onCancel();
close();
}
return (
<NotificationAlertView title={ title } close={ close } { ...rest }>
{ message }
<div className="d-flex justify-content-between align-items-center">
<button type="button" className="btn btn-danger" onClick={ cancel }>{ cancelText }</button>
<button type="button" className="btn btn-primary" onClick={ confirm }>{ confirmText }</button>
</div>
</NotificationAlertView>
);
}

19482
yarn.lock

File diff suppressed because it is too large Load Diff