This commit is contained in:
Bill 2021-08-07 22:03:59 -04:00
parent d2cf15c471
commit 3ae4faf668
5 changed files with 24 additions and 17 deletions

View File

@ -2,5 +2,4 @@ import { Sprite as SpriteBase } from '@pixi/sprite';
export class NitroSprite extends SpriteBase
{
public name: string;
}

View File

@ -5,6 +5,7 @@ import { BatchRenderer, Renderer } from '@pixi/core';
import { Extract } from '@pixi/extract';
import { InteractionManager } from '@pixi/interaction';
import { AppLoaderPlugin, Loader } from '@pixi/loaders';
import '@pixi/mixin-get-child-by-name';
import { ParticleRenderer } from '@pixi/particle-container';
import { Prepare } from '@pixi/prepare';
import { TilingSpriteRenderer } from '@pixi/sprite-tiling';

View File

@ -32,4 +32,12 @@ export class RenderRoomMessageComposer implements IMessageComposer<ConstructorPa
this._data.push(binaryData.byteLength, binaryData.buffer);
}
public assignBase64(base64: string):void
{
const base64Data = base64.split(',')[1];
const binaryData = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0));
this._data.push(binaryData.byteLength, binaryData.buffer);
}
}

View File

@ -93,7 +93,8 @@ export interface IRoomEngine extends INitroManager
processRoomObjectPlacement(placementSource: string, id: number, category: number, typeId: number, legacyString?: string, stuffData?: IObjectData, state?: number, frameNumber?: number, posture?: string): boolean;
dispatchMouseEvent(canvasId: number, x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean, buttonDown: boolean): void;
createTextureFromRoom(roomId: number, canvasId?: number, bounds?: Rectangle): RenderTexture;
saveTextureAsScreenshot(texture: RenderTexture, saveAsThumbnail?: boolean): void
saveTextureAsScreenshot(texture: RenderTexture, saveAsThumbnail?: boolean): void;
saveBase64AsScreenshot(base64: string, saveAsThumbnail?: boolean): void;
modifyRoomObjectData(objectId: number, objectCategory: number, colorHex: string, text: string): boolean;
deleteRoomObject(objectId: number, objectCategory: number): boolean;
sessionDataManager: ISessionDataManager;

View File

@ -3316,21 +3316,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
if(!displayObject) return null;
let index = (displayObject.children.length - 1);
while(index >= 0)
{
const child = (displayObject.getChildAt(index) as NitroSprite);
if(child)
{
if(child.name === RoomEngine.OVERLAY) return child;
}
index--;
}
return null;
return ((displayObject.getChildByName(RoomEngine.OVERLAY) as NitroSprite) || null);
}
private removeOverlayIconSprite(k: NitroSprite, _arg_2: string): boolean
@ -3502,6 +3488,18 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
this._communication.connection.send(composer);
}
public saveBase64AsScreenshot(base64: string, saveAsThumbnail: boolean = false): void
{
let composer: RenderRoomMessageComposer = null;
if(saveAsThumbnail) composer = new RenderRoomThumbnailMessageComposer();
else composer = new RenderRoomMessageComposer();
composer.assignBase64(base64);
this._communication.connection.send(composer);
}
public objectsInitialized(k: string): void
{
const roomId = this.getRoomIdFromString(k);