Merge branch 'async-booting' of https://github.com/billsonnn/nitro-react into async-booting

This commit is contained in:
dank074 2023-07-20 20:55:39 -05:00
commit 5e9cd11d71
5 changed files with 884 additions and 783 deletions

View File

@ -10,9 +10,7 @@ NitroVersion.UI_VERSION = GetUIVersion();
export const App: FC<{}> = props =>
{
const [ isReady, setIsReady ] = useState(false);
const [ isError, setIsError ] = useState(false);
const [ message, setMessage ] = useState('Getting Ready');
const [ percent, setPercent ] = useState(0);
const [ imageRendering, setImageRendering ] = useState<boolean>(true);
useEffect(() =>
@ -53,7 +51,7 @@ export const App: FC<{}> = props =>
return (
<Base fit overflow="hidden" className={ imageRendering && 'image-rendering-pixelated' }>
{ (!isReady || isError) &&
{ !isReady &&
<LoadingView isError={ false } message={ message } percent={ 0 } showPercent={ false } /> }
{ isReady && <MainView /> }
<Base id="draggable-windows-container" />

View File

@ -24,36 +24,6 @@ export const NitroCardView: FC<NitroCardViewProps> = props =>
return newClassNames;
}, [ theme, classNames ]);
/* useEffect(() =>
{
if(!uniqueKey || !elementRef || !elementRef.current) return;
const localStorage = GetLocalStorage<WindowSaveOptions>(`nitro.windows.${ uniqueKey }`);
const element = elementRef.current;
if(localStorage && localStorage.size)
{
//element.style.width = `${ localStorage.size.width }px`;
//element.style.height = `${ localStorage.size.height }px`;
}
const observer = new ResizeObserver(event =>
{
const newStorage = { ...GetLocalStorage<Partial<WindowSaveOptions>>(`nitro.windows.${ uniqueKey }`) } as WindowSaveOptions;
newStorage.size = { width: element.offsetWidth, height: element.offsetHeight };
SetLocalStorage<WindowSaveOptions>(`nitro.windows.${ uniqueKey }`, newStorage);
});
observer.observe(element);
return () =>
{
observer.disconnect();
}
}, [ uniqueKey ]); */
return (
<NitroCardContextProvider value={ { theme } }>
<DraggableWindow uniqueKey={ uniqueKey } handleSelector={ handleSelector } windowPosition={ windowPosition } disableDrag={ disableDrag }>

View File

@ -205,13 +205,7 @@ const useRoomState = () =>
const height = Math.floor(window.innerHeight);
const renderer = nitroInstance.application.renderer;
if(renderer)
{
renderer.view.style.width = `${ width }px`;
renderer.view.style.height = `${ height }px`;
//renderer.resolution = window.devicePixelRatio;
renderer.resize(width, height);
}
if(renderer) renderer.resize(width, height);
const displayObject = roomEngine.getRoomInstanceDisplay(roomId, canvasId, width, height, RoomGeometry.SCALE_ZOOMED_IN);
const canvas = GetRoomEngine().getRoomInstanceRenderingCanvas(roomId, canvasId);
@ -267,9 +261,6 @@ const useRoomState = () =>
const width = Math.floor(window.innerWidth);
const height = Math.floor(window.innerHeight);
renderer.view.style.width = `${ width }px`;
renderer.view.style.height = `${ height }px`;
//renderer.resolution = window.devicePixelRatio;
renderer.resize(width, height);
background.width = width;

View File

@ -1,9 +1,8 @@
import { FigureUpdateEvent, RoomUnitChatStyleComposer, UserInfoDataParser, UserInfoEvent, UserSettingsEvent } from '@nitrots/nitro-renderer';
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { useBetween } from 'use-between';
import { GetLocalStorage, GetSessionDataManager, SendMessageComposer } from '../../api';
import { GetSessionDataManager, SendMessageComposer } from '../../api';
import { useMessageEvent } from '../events';
import { useLocalStorage } from '../useLocalStorage';
const useSessionInfoState = () =>
{
@ -12,7 +11,6 @@ const useSessionInfoState = () =>
const [ chatStyleId, setChatStyleId ] = useState<number>(0);
const [ userRespectRemaining, setUserRespectRemaining ] = useState<number>(0);
const [ petRespectRemaining, setPetRespectRemaining ] = useState<number>(0);
const [ screenSize, setScreenSize ] = useLocalStorage('nitro.screensize', { width: window.innerWidth, height: window.innerHeight });
const updateChatStyleId = (styleId: number) =>
{
@ -59,34 +57,6 @@ const useSessionInfoState = () =>
setChatStyleId(parser.chatType);
});
useEffect(() =>
{
const currentScreenSize = <{ width: number, height: number }>GetLocalStorage('nitro.screensize');
if(currentScreenSize && ((currentScreenSize.width !== window.innerWidth) || (currentScreenSize.height !== window.innerHeight)))
{
let i = window.localStorage.length;
while(i > 0)
{
const key = window.localStorage.key(i);
if(key && key.startsWith('nitro.window')) window.localStorage.removeItem(key);
i--;
}
}
const onResize = (event: UIEvent) => setScreenSize({ width: window.innerWidth, height: window.innerHeight });
window.addEventListener('resize', onResize);
return () =>
{
window.removeEventListener('resize', onResize);
}
}, [ setScreenSize ]);
return { userInfo, userFigure, chatStyleId, userRespectRemaining, petRespectRemaining, respectUser, respectPet, updateChatStyleId };
}

1588
yarn.lock

File diff suppressed because it is too large Load Diff