mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-31 03:12:35 +01:00
Dimmer updates
This commit is contained in:
parent
88e304227a
commit
4e3af05d1f
@ -1,6 +1,7 @@
|
||||
export class MoodlightFromServer
|
||||
export class RoomDimmerPresetsMessageData
|
||||
{
|
||||
constructor(public id: number,
|
||||
constructor(
|
||||
public id: number,
|
||||
public bgOnly: boolean,
|
||||
public color: string,
|
||||
public brightness: number)
|
@ -9,6 +9,6 @@ export * from './GroupFurniContextMenuInfoMessageEvent';
|
||||
export * from './LoveLockFurniFinishedEvent';
|
||||
export * from './LoveLockFurniFriendConfirmedEvent';
|
||||
export * from './LoveLockFurniStartEvent';
|
||||
export * from './moodlightFromServer';
|
||||
export * from './RoomDimmerPresetsMessageData';
|
||||
export * from './RoomDimmerPresetsMessageEvent';
|
||||
export * from './wall';
|
||||
|
@ -1,33 +1,17 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '../../../../../../core';
|
||||
import { MoodlightFromServer } from '../../../incoming/room/furniture/moodlightFromServer';
|
||||
import { RoomDimmerPresetsMessageData } from '../../../incoming/room/furniture/RoomDimmerPresetsMessageData';
|
||||
|
||||
export class RoomDimmerPresetsMessageParser implements IMessageParser
|
||||
{
|
||||
private _selectedPresetId: number = 0;
|
||||
private _presets: MoodlightFromServer[];
|
||||
private _selectedPresetId: number;
|
||||
private _presets: RoomDimmerPresetsMessageData[];
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._selectedPresetId = 0;
|
||||
this._presets = [];
|
||||
}
|
||||
|
||||
public get presetCount(): number
|
||||
{
|
||||
return this._presets.length;
|
||||
}
|
||||
|
||||
public get selectedPresetId(): number
|
||||
{
|
||||
return this._selectedPresetId;
|
||||
}
|
||||
|
||||
public getPreset(k: number): MoodlightFromServer
|
||||
{
|
||||
if((k < 0) || (k >= this.presetCount)) return null;
|
||||
|
||||
return this._presets[k];
|
||||
}
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._presets = [];
|
||||
@ -44,13 +28,30 @@ export class RoomDimmerPresetsMessageParser implements IMessageParser
|
||||
for(let i = 0; i < totalPresets; i++)
|
||||
{
|
||||
const presetId = wrapper.readInt();
|
||||
const bgOnly = wrapper.readInt() === 2;
|
||||
const bgOnly = (wrapper.readInt() === 2);
|
||||
const color = wrapper.readString();
|
||||
const brightness = wrapper.readInt();
|
||||
|
||||
this._presets.push(new MoodlightFromServer(presetId, bgOnly, color, brightness));
|
||||
this._presets.push(new RoomDimmerPresetsMessageData(presetId, bgOnly, color, brightness));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public getPreset(id: number): RoomDimmerPresetsMessageData
|
||||
{
|
||||
if((id < 0) || (id >= this.presetCount)) return null;
|
||||
|
||||
return this._presets[id];
|
||||
}
|
||||
|
||||
public get presetCount(): number
|
||||
{
|
||||
return this._presets.length;
|
||||
}
|
||||
|
||||
public get selectedPresetId(): number
|
||||
{
|
||||
return this._selectedPresetId;
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ export class RoomSessionDimmerPresetsEvent extends RoomSessionEvent
|
||||
private _selectedPresetId: number = 0;
|
||||
private _presets: RoomSessionDimmerPresetsEventPresetItem[];
|
||||
|
||||
constructor(k: string, _arg_2: IRoomSession)
|
||||
constructor(type: string, session: IRoomSession)
|
||||
{
|
||||
super(k, _arg_2);
|
||||
super(type, session);
|
||||
|
||||
this._presets = [];
|
||||
}
|
||||
@ -26,23 +26,20 @@ export class RoomSessionDimmerPresetsEvent extends RoomSessionEvent
|
||||
return this._selectedPresetId;
|
||||
}
|
||||
|
||||
public set selectedPresetId(k: number)
|
||||
public set selectedPresetId(id: number)
|
||||
{
|
||||
this._selectedPresetId = k;
|
||||
this._selectedPresetId = id;
|
||||
}
|
||||
|
||||
public storePreset(id: number, bgOnly: boolean, color: string, brightness: number): void
|
||||
{
|
||||
const _local_5:RoomSessionDimmerPresetsEventPresetItem = new RoomSessionDimmerPresetsEventPresetItem(id, bgOnly, color, brightness);
|
||||
this._presets[(id - 1)] = _local_5;
|
||||
this._presets[(id - 1)] = new RoomSessionDimmerPresetsEventPresetItem(id, bgOnly, color, brightness);
|
||||
}
|
||||
|
||||
public getPreset(k: number):RoomSessionDimmerPresetsEventPresetItem
|
||||
public getPreset(id: number): RoomSessionDimmerPresetsEventPresetItem
|
||||
{
|
||||
if(((k < 0) || (k >= this._presets.length)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this._presets[k];
|
||||
if((id < 0) || (id >= this._presets.length)) return null;
|
||||
|
||||
return this._presets[id];
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ export class RoomDimmerPresetsHandler extends BaseHandler
|
||||
connection.addMessageEvent(new RoomDimmerPresetsEvent(this.onRoomDimmerPresets.bind(this)));
|
||||
}
|
||||
|
||||
private onRoomDimmerPresets(k: RoomDimmerPresetsEvent): void
|
||||
private onRoomDimmerPresets(event: RoomDimmerPresetsEvent): void
|
||||
{
|
||||
if(!k) return;
|
||||
if(!event) return;
|
||||
|
||||
const parser = k.getParser();
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
@ -25,17 +25,17 @@ export class RoomDimmerPresetsHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
const event = new RoomSessionDimmerPresetsEvent(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, session);
|
||||
const presetEvent = new RoomSessionDimmerPresetsEvent(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, session);
|
||||
|
||||
event.selectedPresetId = parser.selectedPresetId;
|
||||
presetEvent.selectedPresetId = parser.selectedPresetId;
|
||||
|
||||
for(let i = 0; i < parser.presetCount; i++)
|
||||
{
|
||||
const preset = parser.getPreset(i);
|
||||
|
||||
if(preset) event.storePreset(preset.id, preset.bgOnly, preset.color, preset.brightness);
|
||||
if(preset) presetEvent.storePreset(preset.id, preset.bgOnly, preset.color, preset.brightness);
|
||||
}
|
||||
|
||||
this.listener && this.listener.events.dispatchEvent(event);
|
||||
this.listener && this.listener.events.dispatchEvent(presetEvent);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user