Room Widget Camera updates

This commit is contained in:
MyNameIsBatman 2021-06-20 06:39:31 -03:00
parent 09e90a8c93
commit 191cb16a8d
4 changed files with 22 additions and 7 deletions

View File

@ -6,4 +6,5 @@ export interface IRoomCameraWidgetEffect
minLevel: number;
texture: Texture;
colorMatrix: number[];
blendMode: number;
}

View File

@ -5,7 +5,7 @@ import { IRoomCameraWidgetSelectedEffect } from './IRoomCameraWidgetSelectedEffe
export interface IRoomCameraWidgetManager
{
init(): void;
applyEffects(image: HTMLImageElement, selectedEffects: IRoomCameraWidgetSelectedEffect[]): HTMLImageElement;
applyEffects(image: HTMLImageElement, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): HTMLImageElement;
events: IEventDispatcher;
effects: Map<string, IRoomCameraWidgetEffect>;
isLoaded: boolean;

View File

@ -7,13 +7,15 @@ export class RoomCameraWidgetEffect implements IRoomCameraWidgetEffect
private _minLevel: number = -1;
private _texture: Texture = null;
private _colorMatrix: number[] = null;
private _blendMode: number = null;
constructor(name: string, minLevel: number = -1, texture: Texture = null, colorMatrix: number[] = null)
constructor(name: string, minLevel: number = -1, texture: Texture = null, colorMatrix: number[] = null, blendMode: number = null)
{
this._name = name;
this._minLevel = minLevel;
this._texture = texture;
this._colorMatrix = colorMatrix;
this._blendMode = blendMode;
}
public get name(): string
@ -41,6 +43,16 @@ export class RoomCameraWidgetEffect implements IRoomCameraWidgetEffect
this._colorMatrix = colorMatrix;
}
public get blendMode(): number
{
return this._blendMode;
}
public set blendMode(blendMode: number)
{
this._blendMode = blendMode;
}
public get minLevel(): number
{
return this._minLevel;

View File

@ -28,7 +28,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
this._isLoaded = true;
const imagesUrl = Nitro.instance.getConfiguration<string>('image.library.url') + 'Habbo-Stories/';
const effects = Nitro.instance.getConfiguration<{ name: string, colorMatrix?: number[], minLevel: number, enabled: boolean }[]>('camera.available.effects');
const effects = Nitro.instance.getConfiguration<{ name: string, colorMatrix?: number[], minLevel: number, blendMode?: number, enabled: boolean }[]>('camera.available.effects');
for(const effect of effects)
{
@ -43,6 +43,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
else
{
cameraEffect.texture = Texture.from(imagesUrl + effect.name + '.png');
cameraEffect.blendMode = effect.blendMode;
}
this._effects.set(cameraEffect.name, cameraEffect);
@ -51,7 +52,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
this.events.dispatchEvent(new RoomCameraWidgetManagerEvent(RoomCameraWidgetManagerEvent.INITIALIZED));
}
public applyEffects(image: HTMLImageElement, selectedEffects: IRoomCameraWidgetSelectedEffect[]): HTMLImageElement
public applyEffects(image: HTMLImageElement, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): HTMLImageElement
{
const container = new Container();
const texture = Texture.from(image);
@ -80,6 +81,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
{
const effectSprite = new Sprite(effect.texture);
effectSprite.alpha = selectedEffect.alpha;
effectSprite.blendMode = effect.blendMode;
container.addChild(effectSprite);
}