diff --git a/src/nitro/communication/messages/incoming/room/furniture/moodlightFromServer.ts b/src/nitro/communication/messages/incoming/room/furniture/moodlightFromServer.ts index 0aedc1f9..30ad4262 100644 --- a/src/nitro/communication/messages/incoming/room/furniture/moodlightFromServer.ts +++ b/src/nitro/communication/messages/incoming/room/furniture/moodlightFromServer.ts @@ -1,64 +1,8 @@ export class MoodlightFromServer { - private readonly _id: number = 0; - private _type: number = 0; - private _color: number = 0; - private _intensity: number = 0; - private _isParsed: boolean = false; - private _htmlColor: string = null; - - constructor(k: number) - { - this._id = k; - } - - public parsed(): void - { - this._isParsed = true; - } - - public get id(): number - { - return this._id; - } - - public get type(): number - { - return this._type; - } - - public set type(k: number) - { - if(!this._isParsed) this._type = k; - } - - public get color(): number - { - return this._color; - } - - public set color(k: number) - { - if(!this._isParsed) this._color = k; - } - - public get intensity(): number - { - return this._intensity; - } - - public set intensity(k: number) - { - if(!this._isParsed) this._intensity = k; - } - - public set htmlColor(color: string) - { - this._htmlColor = color; - } - - public get htmlColor(): string - { - return this._htmlColor; - } + constructor(public id: number, + public bgOnly: boolean, + public color: string, + public brightness: number) + {} } diff --git a/src/nitro/communication/messages/parser/room/furniture/RoomDimmerPresetsMessageParser.ts b/src/nitro/communication/messages/parser/room/furniture/RoomDimmerPresetsMessageParser.ts index f44a8a28..8d3c9106 100644 --- a/src/nitro/communication/messages/parser/room/furniture/RoomDimmerPresetsMessageParser.ts +++ b/src/nitro/communication/messages/parser/room/furniture/RoomDimmerPresetsMessageParser.ts @@ -35,33 +35,20 @@ export class RoomDimmerPresetsMessageParser implements IMessageParser return true; } - public parse(k: IMessageDataWrapper): boolean + public parse(wrapper: IMessageDataWrapper): boolean { - const totalPresets = k.readInt(); + const totalPresets = wrapper.readInt(); - this._selectedPresetId = k.readInt(); + this._selectedPresetId = wrapper.readInt(); - let _local_3 = 0; - - while(_local_3 < totalPresets) + for(let i = 0; i < totalPresets; i++) { - const presetId = k.readInt(); - const isBackGroundOnly = k.readInt(); // Background only? 2: 1 - const color = k.readString(); - const colorForSWF = parseInt(color.substr(1), 16); - const intensity = k.readInt(); + const presetId = wrapper.readInt(); + const bgOnly = wrapper.readInt() === 2; + const color = wrapper.readString(); + const brightness = wrapper.readInt(); - const _local_9 = new MoodlightFromServer(presetId); - - _local_9.type = isBackGroundOnly; - _local_9.color = colorForSWF; - _local_9.intensity = intensity; - - _local_9.parsed(); - _local_9.htmlColor = color; - this._presets.push(_local_9); - - _local_3++; + this._presets.push(new MoodlightFromServer(presetId, bgOnly, color, brightness)); } return true; diff --git a/src/nitro/session/events/RoomSessionDimmerPresetsEvent.ts b/src/nitro/session/events/RoomSessionDimmerPresetsEvent.ts index dc6ccf9f..299bdc4c 100644 --- a/src/nitro/session/events/RoomSessionDimmerPresetsEvent.ts +++ b/src/nitro/session/events/RoomSessionDimmerPresetsEvent.ts @@ -31,10 +31,10 @@ export class RoomSessionDimmerPresetsEvent extends RoomSessionEvent this._selectedPresetId = k; } - public storePreset(k: number, _arg_2: number, _arg_3: number, _arg_4: number): void + public storePreset(id: number, bgOnly: boolean, color: string, brightness: number): void { - const _local_5:RoomSessionDimmerPresetsEventPresetItem = new RoomSessionDimmerPresetsEventPresetItem(k, _arg_2, _arg_3, _arg_4); - this._presets[(k - 1)] = _local_5; + const _local_5:RoomSessionDimmerPresetsEventPresetItem = new RoomSessionDimmerPresetsEventPresetItem(id, bgOnly, color, brightness); + this._presets[(id - 1)] = _local_5; } public getPreset(k: number):RoomSessionDimmerPresetsEventPresetItem diff --git a/src/nitro/session/events/RoomSessionDimmerPresetsEventPresetItem.ts b/src/nitro/session/events/RoomSessionDimmerPresetsEventPresetItem.ts index 8bccc4c3..b311143f 100644 --- a/src/nitro/session/events/RoomSessionDimmerPresetsEventPresetItem.ts +++ b/src/nitro/session/events/RoomSessionDimmerPresetsEventPresetItem.ts @@ -1,16 +1,16 @@ export class RoomSessionDimmerPresetsEventPresetItem { private _id: number; - private _type: number; - private _color: number; - private _light: number; + private _bgOnly: boolean; + private _color: string; + private _brightness: number; - constructor(k: number, _arg_2: number, _arg_3: number, _arg_4: number) + constructor(id: number, bgOnly: boolean, color: string, brightness: number) { - this._id = k; - this._type = _arg_2; - this._color = _arg_3; - this._light = _arg_4; + this._id = id; + this._bgOnly = bgOnly; + this._color = color; + this._brightness = brightness; } public get id(): number @@ -18,18 +18,18 @@ return this._id; } - public get type(): number + public get bgOnly(): boolean { - return this._type; + return this._bgOnly; } - public get color(): number + public get color(): string { return this._color; } - public get light(): number + public get brightness(): number { - return this._light; + return this._brightness; } } diff --git a/src/nitro/session/handler/RoomDimmerPresetsHandler.ts b/src/nitro/session/handler/RoomDimmerPresetsHandler.ts index 3a087bdf..672052b0 100644 --- a/src/nitro/session/handler/RoomDimmerPresetsHandler.ts +++ b/src/nitro/session/handler/RoomDimmerPresetsHandler.ts @@ -29,18 +29,11 @@ export class RoomDimmerPresetsHandler extends BaseHandler event.selectedPresetId = parser.selectedPresetId; - let i = 0; - - while(i < parser.presetCount) + for(let i = 0; i < parser.presetCount; i++) { const preset = parser.getPreset(i); - if(preset) - { - event.storePreset(preset.id, preset.type, preset.color, preset.intensity); - } - - i++; + if(preset) event.storePreset(preset.id, preset.bgOnly, preset.color, preset.brightness); } this.listener && this.listener.events.dispatchEvent(event);