mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-18 21:36:27 +01:00
Add :nitro command
This commit is contained in:
parent
c853d5a415
commit
337de8e2f4
10
src/App.tsx
10
src/App.tsx
@ -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(() =>
|
||||
{
|
||||
|
3
src/api/GetRendererVersion.ts
Normal file
3
src/api/GetRendererVersion.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { NitroVersion } from '@nitrots/nitro-renderer';
|
||||
|
||||
export const GetRendererVersion = () => NitroVersion.RENDERER_VERSION;
|
1
src/api/GetUIVersion.ts
Normal file
1
src/api/GetUIVersion.ts
Normal file
@ -0,0 +1 @@
|
||||
export const GetUIVersion = () => '2.0.0';
|
@ -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';
|
||||
|
@ -138,11 +138,14 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
|
||||
newWindow.document.write(image.outerHTML);
|
||||
return null;
|
||||
case ':pickall':
|
||||
NotificationUtilities.confirm(LocalizeText('room.confirm.pick_all'), () =>
|
||||
{
|
||||
GetSessionDataManager().sendSpecialCommandMessage(':pickall');
|
||||
},
|
||||
null, null, null, LocalizeText('generic.alert.title'));
|
||||
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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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'));
|
||||
|
@ -14,7 +14,6 @@ export const NitropediaView: FC<{}> = props =>
|
||||
|
||||
const openPage = useCallback(async (link: string) =>
|
||||
{
|
||||
console.log(link);
|
||||
try
|
||||
{
|
||||
const response = await fetch(link);
|
||||
|
@ -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 };
|
||||
|
||||
return <NotificationDefaultAlertView { ...props } />
|
||||
switch(item.alertType)
|
||||
{
|
||||
case NotificationAlertType.NITRO:
|
||||
return <NitroSystemAlertView { ...props } />
|
||||
default:
|
||||
return <NotificationDefaultAlertView { ...props } />
|
||||
}
|
||||
}
|
||||
|
@ -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"> </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>
|
||||
);
|
||||
}
|
@ -8,7 +8,4 @@ import './index.scss';
|
||||
//@ts-ignore
|
||||
library.add(fas);
|
||||
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
document.getElementById('root')
|
||||
);
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
Loading…
Reference in New Issue
Block a user