Skip to content

Commit

Permalink
Update lighting only one when setting control values
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-wilke committed Jan 3, 2021
1 parent a319301 commit a87fee9
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public LightSourcePanel() {
setLayout(this.createLayout());
this.setupChangedListeners();
}
@Override
public void bind(IMapObject mapObject) {
super.bind(mapObject);
this.updateLighting();
}

@Override
protected void clearControls() {
Expand Down Expand Up @@ -74,19 +79,32 @@ private void setupChangedListeners() {
}
}));
this.setup(this.spinnerIntensity, MapObjectProperty.LIGHT_INTENSITY);
this.spinnerIntensity.addChangeListener(m -> Game.world().environment().updateLighting(getDataSource().getBoundingBox()));
this.spinnerIntensity.addChangeListener(m -> this.updateLighting());

this.setup(this.comboBoxLightShape, MapObjectProperty.LIGHT_SHAPE);
this.comboBoxLightShape.addActionListener(m -> Game.world().environment().updateLighting(getDataSource().getBoundingBox()));
this.comboBoxLightShape.addActionListener(m -> this.updateLighting());

this.setup(this.checkBoxIsActive, MapObjectProperty.LIGHT_ACTIVE);
this.checkBoxIsActive.addActionListener(m -> Game.world().environment().updateLighting(getDataSource().getBoundingBox()));
this.checkBoxIsActive.addActionListener(m -> this.updateLighting());

this.setup(this.offsetX, MapObjectProperty.LIGHT_FOCUSOFFSETX);
this.offsetX.addChangeListener(m -> Game.world().environment().updateLighting(getDataSource().getBoundingBox()));
this.offsetX.addChangeListener(m -> this.updateLighting());

this.setup(this.offsetY, MapObjectProperty.LIGHT_FOCUSOFFSETY);
this.offsetY.addChangeListener(m -> Game.world().environment().updateLighting(getDataSource().getBoundingBox()));
this.offsetY.addChangeListener(m -> this.updateLighting());
}

private void updateLighting() {
if (this.isFocussing) {
return;
}

final IMapObject datasource = getDataSource();
if (datasource == null) {
return;
}

Game.world().environment().updateLighting(getDataSource().getBoundingBox());
}

private LayoutManager createLayout() {
Expand Down

0 comments on commit a87fee9

Please sign in to comment.