mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-31 11:12:35 +01:00
Dimmer updates
This commit is contained in:
parent
4e3af05d1f
commit
17968b7265
@ -2,8 +2,8 @@
|
|||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
public id: number,
|
public id: number,
|
||||||
public bgOnly: boolean,
|
public type: number,
|
||||||
public color: string,
|
public color: number,
|
||||||
public brightness: number)
|
public brightness: number)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@ export class RoomDimmerPresetsMessageParser implements IMessageParser
|
|||||||
for(let i = 0; i < totalPresets; i++)
|
for(let i = 0; i < totalPresets; i++)
|
||||||
{
|
{
|
||||||
const presetId = wrapper.readInt();
|
const presetId = wrapper.readInt();
|
||||||
const bgOnly = (wrapper.readInt() === 2);
|
const type = wrapper.readInt();
|
||||||
const color = wrapper.readString();
|
const color = parseInt(wrapper.readString().substr(1), 16);
|
||||||
const brightness = wrapper.readInt();
|
const brightness = wrapper.readInt();
|
||||||
|
|
||||||
this._presets.push(new RoomDimmerPresetsMessageData(presetId, bgOnly, color, brightness));
|
this._presets.push(new RoomDimmerPresetsMessageData(presetId, type, color, brightness));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -84,6 +84,8 @@ export class FurnitureRoomDimmerLogic extends FurnitureLogic
|
|||||||
{
|
{
|
||||||
if(!data) return;
|
if(!data) return;
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
const parts = data.split(',');
|
const parts = data.split(',');
|
||||||
|
|
||||||
if(parts.length >= 5)
|
if(parts.length >= 5)
|
||||||
@ -122,21 +124,21 @@ export class FurnitureRoomDimmerLogic extends FurnitureLogic
|
|||||||
{
|
{
|
||||||
super.update(time);
|
super.update(time);
|
||||||
|
|
||||||
if(this.object && this.object.model)
|
// if(this.object && this.object.model)
|
||||||
{
|
// {
|
||||||
const realRoomObject = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT);
|
// const realRoomObject = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT);
|
||||||
|
|
||||||
if(realRoomObject === 1)
|
// if(realRoomObject === 1)
|
||||||
{
|
// {
|
||||||
const data = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA);
|
// const data = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA);
|
||||||
|
|
||||||
if(data && data.length > 0)
|
// if(data && data.length > 0)
|
||||||
{
|
// {
|
||||||
this.object.model.setValue(RoomObjectVariable.FURNITURE_DATA, '');
|
// this.object.model.setValue(RoomObjectVariable.FURNITURE_DATA, '');
|
||||||
|
|
||||||
this.processDimmerData(data);
|
// this.processDimmerData(data);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,18 @@ export class RoomSessionDimmerPresetsEvent extends RoomSessionEvent
|
|||||||
this._presets = [];
|
this._presets = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public storePreset(id: number, type: number, color: number, brightness: number): void
|
||||||
|
{
|
||||||
|
this._presets[(id - 1)] = new RoomSessionDimmerPresetsEventPresetItem(id, type, color, brightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getPreset(id: number): RoomSessionDimmerPresetsEventPresetItem
|
||||||
|
{
|
||||||
|
if((id < 0) || (id >= this._presets.length)) return null;
|
||||||
|
|
||||||
|
return this._presets[id];
|
||||||
|
}
|
||||||
|
|
||||||
public get presetCount(): number
|
public get presetCount(): number
|
||||||
{
|
{
|
||||||
return this._presets.length;
|
return this._presets.length;
|
||||||
@ -30,16 +42,4 @@ export class RoomSessionDimmerPresetsEvent extends RoomSessionEvent
|
|||||||
{
|
{
|
||||||
this._selectedPresetId = id;
|
this._selectedPresetId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public storePreset(id: number, bgOnly: boolean, color: string, brightness: number): void
|
|
||||||
{
|
|
||||||
this._presets[(id - 1)] = new RoomSessionDimmerPresetsEventPresetItem(id, bgOnly, color, brightness);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getPreset(id: number): RoomSessionDimmerPresetsEventPresetItem
|
|
||||||
{
|
|
||||||
if((id < 0) || (id >= this._presets.length)) return null;
|
|
||||||
|
|
||||||
return this._presets[id];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
export class RoomSessionDimmerPresetsEventPresetItem
|
export class RoomSessionDimmerPresetsEventPresetItem
|
||||||
{
|
{
|
||||||
private _id: number;
|
private _id: number;
|
||||||
private _bgOnly: boolean;
|
private _type: number;
|
||||||
private _color: string;
|
private _color: number;
|
||||||
private _brightness: number;
|
private _brightness: number;
|
||||||
|
|
||||||
constructor(id: number, bgOnly: boolean, color: string, brightness: number)
|
constructor(id: number, type: number, color: number, brightness: number)
|
||||||
{
|
{
|
||||||
this._id = id;
|
this._id = id;
|
||||||
this._bgOnly = bgOnly;
|
this._type = type;
|
||||||
this._color = color;
|
this._color = color;
|
||||||
this._brightness = brightness;
|
this._brightness = brightness;
|
||||||
}
|
}
|
||||||
@ -18,12 +18,12 @@
|
|||||||
return this._id;
|
return this._id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get bgOnly(): boolean
|
public get type(): number
|
||||||
{
|
{
|
||||||
return this._bgOnly;
|
return this._type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get color(): string
|
public get color(): number
|
||||||
{
|
{
|
||||||
return this._color;
|
return this._color;
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,15 @@ export class RoomDimmerPresetsHandler extends BaseHandler
|
|||||||
|
|
||||||
presetEvent.selectedPresetId = parser.selectedPresetId;
|
presetEvent.selectedPresetId = parser.selectedPresetId;
|
||||||
|
|
||||||
for(let i = 0; i < parser.presetCount; i++)
|
let i = 0;
|
||||||
|
|
||||||
|
while(i < parser.presetCount)
|
||||||
{
|
{
|
||||||
const preset = parser.getPreset(i);
|
const preset = parser.getPreset(i);
|
||||||
|
|
||||||
if(preset) presetEvent.storePreset(preset.id, preset.bgOnly, preset.color, preset.brightness);
|
if(preset) presetEvent.storePreset(preset.id, preset.type, preset.color, preset.brightness);
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listener && this.listener.events.dispatchEvent(presetEvent);
|
this.listener && this.listener.events.dispatchEvent(presetEvent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user