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

View File

@ -138,11 +138,14 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
newWindow.document.write(image.outerHTML); newWindow.document.write(image.outerHTML);
return null; return null;
case ':pickall': case ':pickall':
NotificationUtilities.confirm(LocalizeText('room.confirm.pick_all'), () => if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator)
{ {
GetSessionDataManager().sendSpecialCommandMessage(':pickall'); NotificationUtilities.confirm(LocalizeText('room.confirm.pick_all'), () =>
}, {
null, null, null, LocalizeText('generic.alert.title')); GetSessionDataManager().sendSpecialCommandMessage(':pickall');
},
null, null, null, LocalizeText('generic.alert.title'));
}
return null; return null;
case ':furni': case ':furni':
@ -171,8 +174,7 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
case ':client': case ':client':
case ':nitro': case ':nitro':
case ':billsonnn': case ':billsonnn':
// this.container.notificationService.alertWithScrollableMessages([ NotificationUtilities.showNitroAlert();
// '<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');
return null; return null;
case ':settings': case ':settings':
if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator) if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator)

View File

@ -1,4 +1,4 @@
import { NotificationBubbleType } from './NotificationBubbleType'; import { NotificationAlertType } from './NotificationAlertType';
export class NotificationAlertItem export class NotificationAlertItem
{ {
@ -12,7 +12,7 @@ export class NotificationAlertItem
private _title: string; private _title: string;
private _imageUrl: 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; NotificationAlertItem.ITEM_ID += 1;

View File

@ -4,4 +4,5 @@ export class NotificationAlertType
public static MOTD: string = 'motd'; public static MOTD: string = 'motd';
public static MODERATION: string = 'moderation'; public static MODERATION: string = 'moderation';
public static EVENT: string = 'event'; 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)); 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 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')); 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) => const openPage = useCallback(async (link: string) =>
{ {
console.log(link);
try try
{ {
const response = await fetch(link); 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'; import { NotificationDefaultAlertView } from './NotificationDefaultAlertView';
export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) => 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 }; const props = { key: item.id, item, close };
return <NotificationDefaultAlertView { ...props } /> 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 //@ts-ignore
library.add(fas); library.add(fas);
ReactDOM.render( ReactDOM.render(<App />, document.getElementById('root'));
<App />,
document.getElementById('root')
);