diff --git a/src/views/shared/badge-image/BadgeImageView.tsx b/src/views/shared/badge-image/BadgeImageView.tsx index 2ca3259f..84f8fb4d 100644 --- a/src/views/shared/badge-image/BadgeImageView.tsx +++ b/src/views/shared/badge-image/BadgeImageView.tsx @@ -1,9 +1,19 @@ import { BadgeImageReadyEvent, NitroSprite, TextureUtils } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import { FC, useEffect, useMemo, useState } from 'react'; import { GetSessionDataManager, LocalizeBadgeDescription, LocalizeBadgeName, LocalizeText } from '../../../api'; +import { BaseProps } from '../../../common/Base'; import { NitroLayoutBase } from '../../../layout/base'; import { BadgeInformationView } from './badge-info/BadgeInformationView'; -import { BadgeImageViewProps } from './BadgeImageView.types'; + +export interface BadgeImageViewProps extends BaseProps +{ + badgeCode: string; + isGroup?: boolean; + showInfo?: boolean; + customTitle?: string; + isGrayscale?: boolean; + scale?: number; +} export const BadgeImageView: FC = props => { @@ -48,26 +58,26 @@ export const BadgeImageView: FC = props => return newStyle; }, [ style, badgeUrl ]); - const onBadgeImageReadyEvent = useCallback((event: BadgeImageReadyEvent) => - { - if(event.badgeId !== badgeCode) return; - - const nitroSprite = new NitroSprite(event.image); - setBadgeUrl(TextureUtils.generateImageUrl(nitroSprite)); - - if(isListening) - { - GetSessionDataManager().events.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); - setIsListening(false); - } - }, [ badgeCode, isListening ]); - useEffect(() => { if(!badgeCode || !badgeCode.length) return; const existing = (isGroup) ? GetSessionDataManager().loadGroupBadgeImage(badgeCode) : GetSessionDataManager().loadBadgeImage(badgeCode); + const onBadgeImageReadyEvent = (event: BadgeImageReadyEvent) => + { + if(event.badgeId !== badgeCode) return; + + const nitroSprite = new NitroSprite(event.image); + setBadgeUrl(TextureUtils.generateImageUrl(nitroSprite)); + + if(isListening) + { + GetSessionDataManager().events.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); + setIsListening(false); + } + } + if(!existing) { GetSessionDataManager().events.addEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); @@ -86,9 +96,7 @@ export const BadgeImageView: FC = props => GetSessionDataManager().events.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, onBadgeImageReadyEvent); } }); - }, [ badgeCode ]); - - const url = `url('${ badgeUrl }')`; + }, [ badgeCode, isGroup, isListening ]); return ( diff --git a/src/views/shared/badge-image/BadgeImageView.types.ts b/src/views/shared/badge-image/BadgeImageView.types.ts deleted file mode 100644 index 0fe7726c..00000000 --- a/src/views/shared/badge-image/BadgeImageView.types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { NitroLayoutBaseProps } from '../../../layout/base'; - -export interface BadgeImageViewProps extends NitroLayoutBaseProps -{ - badgeCode: string; - isGroup?: boolean; - showInfo?: boolean; - customTitle?: string; - isGrayscale?: boolean; - scale?: number; -} diff --git a/src/views/shared/pet-image/PetImageView.tsx b/src/views/shared/pet-image/PetImageView.tsx index ee8e44f2..8db94d62 100644 --- a/src/views/shared/pet-image/PetImageView.tsx +++ b/src/views/shared/pet-image/PetImageView.tsx @@ -17,6 +17,7 @@ export const PetImageView: FC = props => let petPaletteId = paletteId; let petColor = color; let petCustomParts = customParts; + let petHeadOnly = headOnly; if(figure && figure.length) { @@ -28,6 +29,8 @@ export const PetImageView: FC = props => petCustomParts = petFigureData.customParts; } + if(petTypeId === 16) petHeadOnly = false; + const imageResult = GetRoomEngine().getRoomObjectPetImage(petTypeId, petPaletteId, petColor, new Vector3d((direction * 45)), 64, { imageReady: (id, texture, image) => { @@ -40,7 +43,7 @@ export const PetImageView: FC = props => { } - }, headOnly, 0, petCustomParts, posture); + }, petHeadOnly, 0, petCustomParts, posture); if(imageResult) {