From feae4d4542783a93f892aaa1d71cff89c22d6f18 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 14 Jan 2025 18:50:09 -0500 Subject: [PATCH] Update IGetImageListener --- packages/api/src/nitro/room/IGetImageListener.ts | 4 ++-- packages/api/src/utils/ColorChannelType.ts | 9 +++++++++ packages/api/src/utils/index.ts | 1 + packages/assets/src/AssetManager.ts | 1 - packages/room/src/ImageResult.ts | 8 +++++--- packages/room/src/RoomEngine.ts | 4 ++-- 6 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 packages/api/src/utils/ColorChannelType.ts diff --git a/packages/api/src/nitro/room/IGetImageListener.ts b/packages/api/src/nitro/room/IGetImageListener.ts index 54b585f8..9d77c994 100644 --- a/packages/api/src/nitro/room/IGetImageListener.ts +++ b/packages/api/src/nitro/room/IGetImageListener.ts @@ -1,7 +1,7 @@ -import { Texture } from 'pixi.js'; +import { IImageResult } from './IImageResult'; export interface IGetImageListener { - imageReady(id: number, texture: Texture, image?: HTMLImageElement): void; + imageReady(result: IImageResult): void; imageFailed(id: number): void; } diff --git a/packages/api/src/utils/ColorChannelType.ts b/packages/api/src/utils/ColorChannelType.ts new file mode 100644 index 00000000..b85d1774 --- /dev/null +++ b/packages/api/src/utils/ColorChannelType.ts @@ -0,0 +1,9 @@ +export class ColorChannelType +{ + public static CHANNELS_EQUAL: string = 'CHANNELS_EQUAL'; + public static CHANNELS_UNIQUE: string = 'CHANNELS_UNIQUE'; + public static CHANNELS_RED: string = 'CHANNELS_RED'; + public static CHANNELS_GREEN: string = 'CHANNELS_GREEN'; + public static CHANNELS_BLUE: string = 'CHANNELS_BLUE'; + public static CHANNELS_DESATURATED: string = 'CHANNELS_DESATURATED'; +} diff --git a/packages/api/src/utils/index.ts b/packages/api/src/utils/index.ts index 15828e4e..2ac19b06 100644 --- a/packages/api/src/utils/index.ts +++ b/packages/api/src/utils/index.ts @@ -1,3 +1,4 @@ +export * from './ColorChannelType'; export * from './IAdvancedMap'; export * from './IBinaryReader'; export * from './IBinaryWriter'; diff --git a/packages/assets/src/AssetManager.ts b/packages/assets/src/AssetManager.ts index 6ceccfdd..bf9e998e 100644 --- a/packages/assets/src/AssetManager.ts +++ b/packages/assets/src/AssetManager.ts @@ -1,6 +1,5 @@ import { IAssetData, IAssetManager, IGraphicAsset, IGraphicAssetCollection } from '@nitrots/api'; import { NitroBundle, NitroLogger } from '@nitrots/utils'; -import '@pixi/gif'; import { Assets, Spritesheet, SpritesheetData, Texture } from 'pixi.js'; import { GraphicAssetCollection } from './GraphicAssetCollection'; diff --git a/packages/room/src/ImageResult.ts b/packages/room/src/ImageResult.ts index 26ac1f4f..1e0c2285 100644 --- a/packages/room/src/ImageResult.ts +++ b/packages/room/src/ImageResult.ts @@ -4,9 +4,11 @@ import { Texture } from 'pixi.js'; export class ImageResult implements IImageResult { - public id: number = 0; - public data: Texture = null; - public image: HTMLImageElement = null; + constructor( + public id: number = 0, + public data: Texture = null, + public image: HTMLImageElement = null) + {} public async getImage(): Promise { diff --git a/packages/room/src/RoomEngine.ts b/packages/room/src/RoomEngine.ts index 2b13eda4..934d6cce 100644 --- a/packages/room/src/RoomEngine.ts +++ b/packages/room/src/RoomEngine.ts @@ -2519,7 +2519,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService { if(!listener) continue; - listener.imageReady(id, null, image); + listener.imageReady(new ImageResult(id, null, image)); } } } @@ -2980,7 +2980,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService { if(!imageListener) continue; - if(texture) imageListener.imageReady(objectId, texture); + if(texture) imageListener.imageReady(new ImageResult(objectId, texture)); else imageListener.imageFailed(objectId); } }