Merge branch 'fix/variable-cleanup' of https://git.krews.org/nitro/nitro-renderer into fix/variable-cleanup

This commit is contained in:
Dank074 2021-06-23 03:15:39 -05:00
commit b2b94ca764
31 changed files with 409 additions and 12 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)
{
@ -42,7 +42,8 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
}
else
{
cameraEffect.texture = Texture.from(imagesUrl + effect.name + '.png');
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);
@ -78,8 +79,9 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
}
else
{
const effectSprite = new Sprite(effect.texture);
effectSprite.alpha = selectedEffect.alpha;
const effectSprite = new Sprite(effect.texture);
effectSprite.alpha = selectedEffect.alpha;
effectSprite.blendMode = effect.blendMode;
container.addChild(effectSprite);
}

View File

@ -1,5 +1,5 @@
import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration';
import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, RoomUnitGiveHandItemPetComposer, SellablePetPalettesEvent } from './messages';
import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, RoomUnitGiveHandItemPetComposer, RoomWidgetCameraPublishedEvent, RoomWidgetCameraPurchaseComposer, SellablePetPalettesEvent } from './messages';
import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent';
import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent';
import { CatalogClubGiftsEvent } from './messages/incoming/catalog/CatalogClubGiftsEvent';
@ -49,6 +49,7 @@ import { GroupConfirmMemberRemoveEvent } from './messages/incoming/group/GroupCo
import { GroupInformationEvent } from './messages/incoming/group/GroupInformationEvent';
import { GroupMembersEvent } from './messages/incoming/group/GroupMembersEvent';
import { GroupSettingsEvent } from './messages/incoming/group/GroupSettingsEvent';
import { AuthenticationEvent } from './messages/incoming/handshake/AuthenticationEvent';
import { CallForHelpResultMessageEvent } from './messages/incoming/help/CallForHelpResultMessageEvent';
import { IncomingHeader } from './messages/incoming/IncomingHeader';
import { AchievementEvent } from './messages/incoming/inventory/achievements/AchievementEvent';
@ -120,6 +121,8 @@ import { RoomEnterErrorEvent } from './messages/incoming/room/access/RoomEnterEr
import { RoomEnterEvent } from './messages/incoming/room/access/RoomEnterEvent';
import { RoomForwardEvent } from './messages/incoming/room/access/RoomForwardEvent';
import { BotCommandConfigurationEvent } from './messages/incoming/room/bots/BotCommandConfigurationEvent';
import { RoomWidgetCameraConfigurationEvent } from './messages/incoming/room/camera/RoomWidgetCameraConfigurationEvent';
import { RoomWidgetCameraPurchaseSuccessfulEvent } from './messages/incoming/room/camera/RoomWidgetCameraPurchaseSuccessfulEvent';
import { RoomBannedUsersEvent } from './messages/incoming/room/data/RoomBannedUsersEvent';
import { RoomChatSettingsEvent } from './messages/incoming/room/data/RoomChatSettingsEvent';
import { RoomInfoEvent } from './messages/incoming/room/data/RoomInfoEvent';
@ -261,6 +264,7 @@ import { GroupSaveColorsComposer } from './messages/outgoing/group/GroupSaveColo
import { GroupSaveInformationComposer } from './messages/outgoing/group/GroupSaveInformationComposer';
import { GroupSavePreferencesComposer } from './messages/outgoing/group/GroupSavePreferencesComposer';
import { GroupSettingsComposer } from './messages/outgoing/group/GroupSettingsComposer';
import { AuthenticationMessageComposer } from './messages/outgoing/handshake/AuthenticationMessageComposer';
import { InfoRetrieveBaseMessageComposer } from './messages/outgoing/handshake/InfoRetrieveBaseMessageComposer';
import { SecurityTicketComposer } from './messages/outgoing/handshake/SecurityTicketComposer';
import { RequestBadgesComposer } from './messages/outgoing/inventory/badges/RequestBadgesComposer';
@ -319,6 +323,10 @@ import { RoomStaffPickComposer } from './messages/outgoing/room/action/RoomStaff
import { RoomTakeRightsComposer } from './messages/outgoing/room/action/RoomTakeRightsComposer';
import { RoomUnbanUserComposer } from './messages/outgoing/room/action/RoomUnbanUserComposer';
import { RequestBotCommandConfigurationComposer } from './messages/outgoing/room/bots/RequestBotConfigurationComposer';
import { RoomWidgetCameraConfigurationComposer } from './messages/outgoing/room/camera/RoomWidgetCameraConfigurationComposer';
import { RoomWidgetCameraPublishComposer } from './messages/outgoing/room/camera/RoomWidgetCameraPublishComposer';
import { RoomWidgetCameraRoomPictureComposer } from './messages/outgoing/room/camera/RoomWidgetCameraRoomPictureComposer';
import { RoomWidgetCameraRoomThumbnailComposer } from './messages/outgoing/room/camera/RoomWidgetCameraRoomThumbnailComposer';
import { RoomBannedUsersComposer } from './messages/outgoing/room/data/RoomBannedUsersComposer';
import { RoomInfoComposer } from './messages/outgoing/room/data/RoomInfoComposer';
import { RoomSettingsComposer } from './messages/outgoing/room/data/RoomSettingsComposer';
@ -420,6 +428,9 @@ export class NitroMessages implements IMessageConfiguration
private registerEvents(): void
{
// AUTHENTICATION
this._events.set(IncomingHeader.AUTHENTICATION, AuthenticationEvent);
// AVAILABILITY
this._events.set(IncomingHeader.AVAILABILITY_STATUS, AvailabilityStatusMessageEvent);
this._events.set(IncomingHeader.GENERIC_ERROR, GenericErrorEvent);
@ -446,6 +457,11 @@ export class NitroMessages implements IMessageConfiguration
this._events.set(IncomingHeader.CATALOG_RECEIVE_PET_BREEDS, SellablePetPalettesEvent);
this._events.set(IncomingHeader.CATALOG_APPROVE_NAME_RESULT, CatalogApproveNameResultEvent);
// CAMERA
this._events.set(IncomingHeader.CAMERA_PRICE, RoomWidgetCameraConfigurationEvent);
this._events.set(IncomingHeader.CAMERA_PUBLISHED, RoomWidgetCameraPublishedEvent);
this._events.set(IncomingHeader.CAMERA_PURCHASE_SUCCESSFUL, RoomWidgetCameraPurchaseSuccessfulEvent);
// CLIENT
this._events.set(IncomingHeader.CLIENT_PING, ClientPingEvent);
@ -729,6 +745,9 @@ export class NitroMessages implements IMessageConfiguration
private registerComposers(): void
{
// AUTHENTICATION
this._composers.set(OutgoingHeader.AUTHENTICATION, AuthenticationMessageComposer);
// CATALOG
this._composers.set(OutgoingHeader.CATALOG_MODE, CatalogModeComposer);
this._composers.set(OutgoingHeader.CATALOG_PAGE, CatalogPageComposer);
@ -744,6 +763,13 @@ export class NitroMessages implements IMessageConfiguration
this._composers.set(OutgoingHeader.CATALOG_SELECT_VIP_GIFT, CatalogSelectClubGiftComposer);
this._composers.set(OutgoingHeader.CATALOG_REQUESET_PET_BREEDS, CatalogRequestPetBreedsComposer);
// CAMERA
this._composers.set(OutgoingHeader.CAMERA_PRICE, RoomWidgetCameraConfigurationComposer);
this._composers.set(OutgoingHeader.CAMERA_PUBLISH, RoomWidgetCameraPublishComposer);
this._composers.set(OutgoingHeader.CAMERA_PURCHASE, RoomWidgetCameraPurchaseComposer);
this._composers.set(OutgoingHeader.CAMERA_SAVE, RoomWidgetCameraRoomPictureComposer);
this._composers.set(OutgoingHeader.CAMERA_THUMBNAIL, RoomWidgetCameraRoomThumbnailComposer);
// CLIENT
this._composers.set(OutgoingHeader.CLIENT_PONG, ClientPongComposer);
this._composers.set(OutgoingHeader.RELEASE_VERSION, ClientReleaseVersionComposer);

View File

@ -2,9 +2,12 @@ export class IncomingHeader
{
public static ACHIEVEMENT_LIST = 305;
public static AUTHENTICATED = 2491;
public static AUTHENTICATION = -1;
public static AVAILABILITY_STATUS = 2033;
public static BUILDERS_CLUB_EXPIRED = 1452;
public static CAMERA_PRICE = 3878;
public static CAMERA_PUBLISHED = 2057;
public static CAMERA_PURCHASE_SUCCESSFUL = 2783;
public static CAMERA_THUMBNAIL_SAVED = 3595;
public static CAMERA_URL = 3696;
public static CATALOG_CLUB = 2405;

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
import { AuthenticationParser } from '../../parser/handshake/AuthenticationParser';
export class AuthenticationEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, AuthenticationParser);
}
public getParser(): AuthenticationParser
{
return this.parser as AuthenticationParser;
}
}

View File

@ -0,0 +1 @@
export * from './AuthenticationEvent';

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent';
import { RoomWidgetCameraConfigurationParser } from '../../../parser/room/camera/RoomWidgetCameraConfigurationParser';
export class RoomWidgetCameraConfigurationEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, RoomWidgetCameraConfigurationParser);
}
public getParser(): RoomWidgetCameraConfigurationParser
{
return this.parser as RoomWidgetCameraConfigurationParser;
}
}

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent';
import { RoomWidgetCameraPublishedParser } from '../../../parser/room/camera/RoomWidgetCameraPublishedParser';
export class RoomWidgetCameraPublishedEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, RoomWidgetCameraPublishedParser);
}
public getParser(): RoomWidgetCameraPublishedParser
{
return this.parser as RoomWidgetCameraPublishedParser;
}
}

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent';
import { RoomWidgetCameraPurchaseSuccessfulParser } from '../../../parser/room/camera/RoomWidgetCameraPurchaseSuccessfulParser';
export class RoomWidgetCameraPurchaseSuccessfulEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, RoomWidgetCameraPurchaseSuccessfulParser);
}
public getParser(): RoomWidgetCameraPurchaseSuccessfulParser
{
return this.parser as RoomWidgetCameraPurchaseSuccessfulParser;
}
}

View File

@ -0,0 +1,3 @@
export * from './RoomWidgetCameraConfigurationEvent';
export * from './RoomWidgetCameraPublishedEvent';
export * from './RoomWidgetCameraPurchaseSuccessfulEvent';

View File

@ -1,5 +1,6 @@
export * from './access';
export * from './bots';
export * from './camera';
export * from './data';
export * from './engine';
export * from './furniture';

View File

@ -1,11 +1,14 @@
export class OutgoingHeader
{
public static ACHIEVEMENT_LIST = 219;
public static AUTHENTICATION = -1;
public static BOT_CONFIGURATION = 1986;
public static BOT_PICKUP = 3323;
public static BOT_PLACE = 1592;
public static BOT_SKILL_SAVE = 2624;
public static CAMERA_PRICE = 796;
public static CAMERA_PUBLISH = 2068;
public static CAMERA_PURCHASE = 2408;
public static CAMERA_SAVE = 3226;
public static CAMERA_THUMBNAIL = 1982;
public static CATALOG_CLUB = 3285;

View File

@ -0,0 +1,32 @@
import { IMessageComposer } from '../../../../../core/communication/messages/IMessageComposer';
export class AuthenticationMessageComposer implements IMessageComposer<string[]>
{
private _type: string;
private _data: string[];
constructor(type: string, keys: string[], values: string[])
{
this._type = type;
if(keys.length !== values.length) return;
this._data = [];
for(let i = 0; i < keys.length; i++)
{
this._data.push(keys[i]);
this._data.push(values[i]);
}
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -1,2 +1,3 @@
export * from './AuthenticationMessageComposer';
export * from './InfoRetrieveBaseMessageComposer';
export * from './SecurityTicketComposer';

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../../core/communication/messages/IMessageComposer';
export class RoomWidgetCameraConfigurationComposer implements IMessageComposer<ConstructorParameters<typeof RoomWidgetCameraConfigurationComposer>>
{
private _data: ConstructorParameters<typeof RoomWidgetCameraConfigurationComposer>;
constructor()
{
this._data = [];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../../core/communication/messages/IMessageComposer';
export class RoomWidgetCameraPublishComposer implements IMessageComposer<ConstructorParameters<typeof RoomWidgetCameraPublishComposer>>
{
private _data: ConstructorParameters<typeof RoomWidgetCameraPublishComposer>;
constructor()
{
this._data = [];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../../core/communication/messages/IMessageComposer';
export class RoomWidgetCameraPurchaseComposer implements IMessageComposer<ConstructorParameters<typeof RoomWidgetCameraPurchaseComposer>>
{
private _data: ConstructorParameters<typeof RoomWidgetCameraPurchaseComposer>;
constructor()
{
this._data = [];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../../core/communication/messages/IMessageComposer';
export class RoomWidgetCameraRoomPictureComposer implements IMessageComposer<ConstructorParameters<typeof RoomWidgetCameraRoomPictureComposer>>
{
private _data: ConstructorParameters<typeof RoomWidgetCameraRoomPictureComposer>;
constructor(unknownFloat: number, image: number[])
{
this._data = [ unknownFloat, image ];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../../core/communication/messages/IMessageComposer';
export class RoomWidgetCameraRoomThumbnailComposer implements IMessageComposer<ConstructorParameters<typeof RoomWidgetCameraRoomThumbnailComposer>>
{
private _data: ConstructorParameters<typeof RoomWidgetCameraRoomThumbnailComposer>;
constructor(unknownFloat: number, image: number[])
{
this._data = [ unknownFloat, image ];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -0,0 +1,5 @@
export * from './RoomWidgetCameraConfigurationComposer';
export * from './RoomWidgetCameraPublishComposer';
export * from './RoomWidgetCameraPurchaseComposer';
export * from './RoomWidgetCameraRoomPictureComposer';
export * from './RoomWidgetCameraRoomThumbnailComposer';

View File

@ -1,6 +1,7 @@
export * from './access';
export * from './action';
export * from './bots';
export * from './camera';
export * from './data';
export * from './engine';
export * from './furniture';

View File

@ -0,0 +1,27 @@
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
export class AuthenticationParser implements IMessageParser
{
private _sso: string;
public flush(): boolean
{
this._sso = null;
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._sso = wrapper.readString();
return true;
}
public get sso(): string
{
return this._sso;
}
}

View File

@ -0,0 +1 @@
export * from './AuthenticationParser';

View File

@ -5,7 +5,7 @@ export class ModtoolRoomInfoParser implements IMessageParser
{
private _id: number;
private _playerAmount: number;
private _owner: boolean;
private _ownerInRoom: boolean;
private _ownerId: number;
private _ownerName: string;
private _bool: boolean;
@ -26,7 +26,7 @@ export class ModtoolRoomInfoParser implements IMessageParser
this._id = wrapper.readInt();
this._playerAmount = wrapper.readInt();
this._owner = wrapper.readBoolean();
this._ownerInRoom = wrapper.readBoolean();
this._ownerId = wrapper.readInt();
this._ownerName = wrapper.readString();
this._bool = wrapper.readBoolean();
@ -47,9 +47,9 @@ export class ModtoolRoomInfoParser implements IMessageParser
return this._playerAmount;
}
public get owner(): boolean
public get ownerInRoom(): boolean
{
return this._owner;
return this._ownerInRoom;
}
public get ownerId(): number

View File

@ -0,0 +1,44 @@
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser';
export class RoomWidgetCameraConfigurationParser implements IMessageParser
{
private _credits: number;
private _points: number;
private _pointsType: number;
public flush(): boolean
{
this._credits = 0;
this._points = 0;
this._pointsType = 0;
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._credits = wrapper.readInt();
this._points = wrapper.readInt();
this._pointsType = wrapper.readInt();
return true;
}
public get credits(): number
{
return this._credits;
}
public get points(): number
{
return this._points;
}
public get pointsType(): number
{
return this._pointsType;
}
}

View File

@ -0,0 +1,44 @@
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser';
export class RoomWidgetCameraPublishedParser implements IMessageParser
{
private _wasSuccessful: boolean;
private _cooldownSeconds: number;
private _extraDataId: number;
public flush(): boolean
{
this._wasSuccessful = false;
this._cooldownSeconds = 0;
this._extraDataId = 0;
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._wasSuccessful = wrapper.readBoolean();
this._cooldownSeconds = wrapper.readInt();
this._extraDataId = wrapper.readInt();
return true;
}
public get wasSuccessful(): boolean
{
return this._wasSuccessful;
}
public get cooldownSeconds(): number
{
return this._cooldownSeconds;
}
public get extraDataId(): number
{
return this._extraDataId;
}
}

View File

@ -0,0 +1,17 @@
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser';
export class RoomWidgetCameraPurchaseSuccessfulParser implements IMessageParser
{
public flush(): boolean
{
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
return true;
}
}

View File

@ -0,0 +1,3 @@
export * from './RoomWidgetCameraConfigurationParser';
export * from './RoomWidgetCameraPublishedParser';
export * from './RoomWidgetCameraPurchaseSuccessfulParser';

View File

@ -1,5 +1,6 @@
export * from './access';
export * from './bots';
export * from './camera';
export * from './data';
export * from './engine';
export * from './furniture';