mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Small update
This commit is contained in:
@@ -150,15 +150,24 @@ export class AvatarEditorThumbnailsHelper
|
|||||||
|
|
||||||
if(cached) return cached;
|
if(cached) return cached;
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) =>
|
const avatarImage = GetAvatarRenderManager().createAvatarImage(figureString, AvatarScaleType.LARGE, null, null);
|
||||||
{
|
|
||||||
const resetFigure = async (figure: string) =>
|
|
||||||
{
|
|
||||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, { resetFigure, dispose: null, disposed: false });
|
|
||||||
|
|
||||||
if(avatarImage.isPlaceholder()) return;
|
if(avatarImage.isPlaceholder())
|
||||||
|
{
|
||||||
|
avatarImage.dispose();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const texture = avatarImage.processAsTexture(AvatarSetType.HEAD, false);
|
const texture = avatarImage.processAsTexture(AvatarSetType.HEAD, false);
|
||||||
|
|
||||||
|
if(!texture)
|
||||||
|
{
|
||||||
|
avatarImage.dispose();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const sprite = new NitroSprite(texture);
|
const sprite = new NitroSprite(texture);
|
||||||
|
|
||||||
if(isDisabled) sprite.filters = [ AvatarEditorThumbnailsHelper.ALPHA_FILTER ];
|
if(isDisabled) sprite.filters = [ AvatarEditorThumbnailsHelper.ALPHA_FILTER ];
|
||||||
@@ -171,13 +180,9 @@ export class AvatarEditorThumbnailsHelper
|
|||||||
sprite.destroy();
|
sprite.destroy();
|
||||||
avatarImage.dispose();
|
avatarImage.dispose();
|
||||||
|
|
||||||
AvatarEditorThumbnailsHelper.THUMBNAIL_CACHE.set(thumbnailKey, imageUrl);
|
if(imageUrl) AvatarEditorThumbnailsHelper.THUMBNAIL_CACHE.set(thumbnailKey, imageUrl);
|
||||||
|
|
||||||
resolve(imageUrl);
|
return imageUrl;
|
||||||
};
|
|
||||||
|
|
||||||
resetFigure(figureString);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static sortByDrawOrder(a: IFigurePart, b: IFigurePart): number
|
private static sortByDrawOrder(a: IFigurePart, b: IFigurePart): number
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import { NitroEventType } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useEffect, useState } from 'react';
|
import { FC, useEffect, useState } from 'react';
|
||||||
import { AvatarEditorThumbnailsHelper, GetClubMemberLevel, GetConfigurationValue, IAvatarEditorCategoryPartItem } from '../../../api';
|
import { AvatarEditorThumbnailsHelper, GetClubMemberLevel, GetConfigurationValue, IAvatarEditorCategoryPartItem } from '../../../api';
|
||||||
import { LayoutCurrencyIcon, LayoutGridItemProps } from '../../../common';
|
import { LayoutCurrencyIcon, LayoutGridItemProps } from '../../../common';
|
||||||
import { useAvatarEditor } from '../../../hooks';
|
import { useAvatarEditor } from '../../../hooks';
|
||||||
|
import { useNitroEvent } from '../../../hooks/events';
|
||||||
import { InfiniteGrid } from '../../../layout';
|
import { InfiniteGrid } from '../../../layout';
|
||||||
import { AvatarEditorIcon } from '../AvatarEditorIcon';
|
import { AvatarEditorIcon } from '../AvatarEditorIcon';
|
||||||
|
|
||||||
@@ -14,6 +16,7 @@ export const AvatarEditorFigureSetItemView: FC<{
|
|||||||
{
|
{
|
||||||
const { setType = null, partItem = null, isSelected = false, width = '100%', ...rest } = props;
|
const { setType = null, partItem = null, isSelected = false, width = '100%', ...rest } = props;
|
||||||
const [ assetUrl, setAssetUrl ] = useState<string>('');
|
const [ assetUrl, setAssetUrl ] = useState<string>('');
|
||||||
|
const [ retryId, setRetryId ] = useState<number>(0);
|
||||||
const { selectedColorParts = null, getFigureStringWithFace = null } = useAvatarEditor();
|
const { selectedColorParts = null, getFigureStringWithFace = null } = useAvatarEditor();
|
||||||
|
|
||||||
const clubLevel = partItem.partSet?.clubLevel ?? 0;
|
const clubLevel = partItem.partSet?.clubLevel ?? 0;
|
||||||
@@ -21,6 +24,11 @@ export const AvatarEditorFigureSetItemView: FC<{
|
|||||||
const isLocked = isHC && (GetClubMemberLevel() < clubLevel);
|
const isLocked = isHC && (GetClubMemberLevel() < clubLevel);
|
||||||
const isSellableNotOwned = partItem.isSellableNotOwned ?? false;
|
const isSellableNotOwned = partItem.isSellableNotOwned ?? false;
|
||||||
|
|
||||||
|
useNitroEvent(NitroEventType.AVATAR_ASSET_LOADED, () =>
|
||||||
|
{
|
||||||
|
if(!assetUrl || !assetUrl.length) setRetryId(prev => prev + 1);
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
setAssetUrl('');
|
setAssetUrl('');
|
||||||
@@ -54,7 +62,7 @@ export const AvatarEditorFigureSetItemView: FC<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
loadImage();
|
loadImage();
|
||||||
}, [ setType, partItem, selectedColorParts, getFigureStringWithFace, isSellableNotOwned ]);
|
}, [ setType, partItem, selectedColorParts, getFigureStringWithFace, isSellableNotOwned, retryId ]);
|
||||||
|
|
||||||
if(!partItem) return null;
|
if(!partItem) return null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user