Add :nitro command

This commit is contained in:
Bill 2022-03-21 03:57:00 -04:00
parent c853d5a415
commit 337de8e2f4
12 changed files with 76 additions and 22 deletions

View File

@ -1,11 +1,13 @@
import { ConfigurationEvent, HabboWebTools, LegacyExternalInterface, Nitro, NitroCommunicationDemoEvent, NitroEvent, NitroLocalizationEvent, NitroVersion, RoomEngineEvent, WebGL } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { GetCommunication, GetConfiguration, GetNitroInstance } from './api';
import { GetCommunication, GetConfiguration, GetNitroInstance, GetUIVersion } from './api';
import { Base, TransitionAnimation, TransitionAnimationTypes } from './common';
import { LoadingView } from './components/loading/LoadingView';
import { MainView } from './components/main/MainView';
import { DispatchUiEvent, UseConfigurationEvent, UseLocalizationEvent, UseMainEvent, UseRoomEngineEvent } from './hooks';
NitroVersion.UI_VERSION = GetUIVersion();
export const App: FC<{}> = props =>
{
const [ isReady, setIsReady ] = useState(false);
@ -16,11 +18,7 @@ export const App: FC<{}> = props =>
//@ts-ignore
if(!NitroConfig) throw new Error('NitroConfig is not defined!');
if(!GetNitroInstance())
{
NitroVersion.UI_VERSION = '2.0.0';
Nitro.bootstrap();
}
if(!GetNitroInstance()) Nitro.bootstrap();
const getPreloadAssetUrls = useCallback(() =>
{

View File

@ -0,0 +1,3 @@
import { NitroVersion } from '@nitrots/nitro-renderer';
export const GetRendererVersion = () => NitroVersion.RENDERER_VERSION;

1
src/api/GetUIVersion.ts Normal file
View File

@ -0,0 +1 @@
export const GetUIVersion = () => '2.0.0';

View File

@ -1,6 +1,8 @@
export * from './common';
export * from './core';
export * from './friends';
export * from './GetRendererVersion';
export * from './GetUIVersion';
export * from './groups';
export * from './navigator';
export * from './nitro';

View File

@ -138,11 +138,14 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
newWindow.document.write(image.outerHTML);
return null;
case ':pickall':
if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator)
{
NotificationUtilities.confirm(LocalizeText('room.confirm.pick_all'), () =>
{
GetSessionDataManager().sendSpecialCommandMessage(':pickall');
},
null, null, null, LocalizeText('generic.alert.title'));
}
return null;
case ':furni':
@ -171,8 +174,7 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
case ':client':
case ':nitro':
case ':billsonnn':
// this.container.notificationService.alertWithScrollableMessages([
// '<div class="d-flex flex-column justify-content-center align-items-center"><div class="nitro-info-box"></div><b>Version: ' + Nitro.RELEASE_VERSION + '</b><br />This client is powered by Nitro HTML5<br /><br /><div class="d-flex"><a class="btn btn-primary" href="https://discord.gg/66UR68FPgy" target="_blank">Discord</a><a class="btn btn-primary" href="https://git.krews.org/nitro" target="_blank">Git</a></div><br /></div>'], 'Nitro HTML5');
NotificationUtilities.showNitroAlert();
return null;
case ':settings':
if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator)

View File

@ -1,4 +1,4 @@
import { NotificationBubbleType } from './NotificationBubbleType';
import { NotificationAlertType } from './NotificationAlertType';
export class NotificationAlertItem
{
@ -12,7 +12,7 @@ export class NotificationAlertItem
private _title: string;
private _imageUrl: string;
constructor(messages: string[], alertType: string = NotificationBubbleType.INFO, clickUrl: string = null, clickUrlText: string = null, title: string = null, imageUrl: string = null)
constructor(messages: string[], alertType: string = NotificationAlertType.DEFAULT, clickUrl: string = null, clickUrlText: string = null, title: string = null, imageUrl: string = null)
{
NotificationAlertItem.ITEM_ID += 1;

View File

@ -4,4 +4,5 @@ export class NotificationAlertType
public static MOTD: string = 'motd';
public static MODERATION: string = 'moderation';
public static EVENT: string = 'event';
public static NITRO: string = 'nitro';
}

View File

@ -130,6 +130,11 @@ export class NotificationUtilities
DispatchUiEvent(new NotificationAlertEvent([ this.cleanText(message) ], type, clickUrl, clickUrlText, title, imageUrl));
}
public static showNitroAlert(): void
{
DispatchUiEvent(new NotificationAlertEvent(null, NotificationAlertType.NITRO));
}
public static showModeratorMessage(message: string, url: string = null, showHabboWay: boolean = true): void
{
this.simpleAlert(message, NotificationAlertType.MODERATION, url, LocalizeText('mod.alert.link'), LocalizeText('mod.alert.title'));

View File

@ -14,7 +14,6 @@ export const NitropediaView: FC<{}> = props =>
const openPage = useCallback(async (link: string) =>
{
console.log(link);
try
{
const response = await fetch(link);

View File

@ -1,4 +1,5 @@
import { NotificationAlertItem } from '../../../../api';
import { NotificationAlertItem, NotificationAlertType } from '../../../../api';
import { NitroSystemAlertView } from './NitroSystemAlertView';
import { NotificationDefaultAlertView } from './NotificationDefaultAlertView';
export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) =>
@ -7,5 +8,11 @@ export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) =
const props = { key: item.id, item, close };
switch(item.alertType)
{
case NotificationAlertType.NITRO:
return <NitroSystemAlertView { ...props } />
default:
return <NotificationDefaultAlertView { ...props } />
}
}

View File

@ -0,0 +1,39 @@
import { FC } from 'react';
import { GetRendererVersion, GetUIVersion, NotificationAlertItem } from '../../../../api';
import { Button, Column, Flex, Grid, LayoutNotificationAlertView, LayoutNotificationAlertViewProps, Text } from '../../../../common';
interface NotificationDefaultAlertViewProps extends LayoutNotificationAlertViewProps
{
item: NotificationAlertItem;
}
export const NitroSystemAlertView: FC<NotificationDefaultAlertViewProps> = props =>
{
const { title = 'Nitro', close = null, ...rest } = props;
return (
<LayoutNotificationAlertView title={ title } close={ close } { ...rest }>
<Grid>
<Column center size={ 5 }>
<object data="https://assets.nitrodev.co/logos/nitro-n-dark.svg" width="100" height="100">&nbsp;</object>
</Column>
<Column size={ 7 }>
<Column alignItems="center" gap={ 0 }>
<Text bold fontSize={ 4 }>Nitro React</Text>
<Text>v{ GetUIVersion() }</Text>
</Column>
<Column alignItems="center">
<Text><b>Renderer:</b> v{ GetRendererVersion() }</Text>
<Column fullWidth gap={ 1 }>
<Button fullWidth variant="success" onClick={ event => window.open('https://nitrots.co/discord') }>Discord</Button>
<Flex gap={ 1 }>
<Button fullWidth onClick={ event => window.open('https://git.krews.org/nitro/nitro-react') }>Git</Button>
<Button fullWidth onClick={ event => window.open('https://git.krews.org/nitro/nitro-react/-/issues') }>Bug Report</Button>
</Flex>
</Column>
</Column>
</Column>
</Grid>
</LayoutNotificationAlertView>
);
}

View File

@ -8,7 +8,4 @@ import './index.scss';
//@ts-ignore
library.add(fas);
ReactDOM.render(
<App />,
document.getElementById('root')
);
ReactDOM.render(<App />, document.getElementById('root'));