use of de.gurkenlabs.litiengine.graphics.particles.xml.ParticleType in project litiengine by gurkenlabs.
the class EmitterPropertyPanel method setupChangedListeners.
private void setupChangedListeners() {
this.btnSelectColor.addActionListener(a -> {
if (table.getSelectedRow() == -1) {
return;
}
ParticleColor color = colors.get(table.getSelectedRow());
Color result = ColorChooser.showRgbDialog(Resources.get("panel_selectEmitterColor"), color.toColor());
if (result == null) {
return;
}
ParticleColor c = new ParticleColor(result);
colors.set(table.getSelectedRow(), c);
model.setValueAt(c, table.getSelectedRow(), 1);
if (getDataSource() != null) {
String commaSeperated = ArrayUtilities.getCommaSeparatedString(colors);
this.getDataSource().setCustomProperty(MapObjectProperty.Emitter.COLORS, commaSeperated);
}
});
this.btnRemoveColor.addActionListener(a -> {
for (int removeIndex = 0; removeIndex < colors.size(); removeIndex++) {
if (removeIndex == table.getSelectedRow()) {
colors.remove(removeIndex);
break;
}
}
if (table.getSelectedRow() != -1) {
model.removeRow(table.getSelectedRow());
}
});
this.btnAddColor.addActionListener(a -> {
ParticleColor c = new ParticleColor();
colors.add(c);
model.addRow(new Object[] { null, c.toString() });
});
this.comboBoxParticleType.addActionListener(new MapObjectPropertyActionListener(m -> {
ParticleType particleType = (ParticleType) this.comboBoxParticleType.getSelectedItem();
this.updateTabbedGroup();
this.txt.setEnabled(particleType == ParticleType.TEXT);
m.setCustomProperty(MapObjectProperty.Emitter.PARTICLETYPE, particleType.toString());
}));
this.comboBoxCollisionType.addActionListener(new MapObjectPropertyActionListener(m -> {
m.setCustomProperty(MapObjectProperty.Particle.COLLISIONTYPE, this.comboBoxCollisionType.getSelectedItem().toString());
}));
this.comboBoxSprite.addActionListener(new MapObjectPropertyActionListener(m -> {
String sprite = this.comboBoxSprite.getSelectedItem().toString();
m.setCustomProperty(MapObjectProperty.Particle.SPRITE, sprite);
}));
this.spinnerSpawnRate.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.SPAWNRATE, this.spinnerSpawnRate));
this.spinnerSpawnAmount.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.SPAWNAMOUNT, this.spinnerSpawnAmount));
this.spinnerUpdateRate.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.UPDATERATE, this.spinnerUpdateRate));
this.spinnerTTL.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.TIMETOLIVE, this.spinnerTTL));
this.spinnerMaxParticles.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.MAXPARTICLES, this.spinnerMaxParticles));
this.spinnerMinDeltaX.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINDELTAX, this.spinnerMinDeltaX));
this.spinnerMaxDeltaX.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXDELTAX, this.spinnerMaxDeltaX));
this.spinnerMinDeltaY.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINDELTAY, this.spinnerMinDeltaY));
this.spinnerMaxDeltaY.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXDELTAY, this.spinnerMaxDeltaY));
this.spinnerMinGravityX.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINGRAVITYX, this.spinnerMinGravityX));
this.spinnerMaxGravityX.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXGRAVITYX, this.spinnerMaxGravityX));
this.spinnerMinGravityY.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINGRAVITYY, this.spinnerMinGravityY));
this.spinnerMaxGravityY.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXGRAVITYY, this.spinnerMaxGravityY));
this.spinnerMinStartWidth.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINSTARTWIDTH, this.spinnerMinStartWidth));
this.spinnerMaxStartWidth.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXSTARTWIDTH, this.spinnerMaxStartWidth));
this.spinnerMinStartHeight.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINSTARTHEIGHT, this.spinnerMinStartHeight));
this.spinnerMaxStartHeight.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXSTARTHEIGHT, this.spinnerMaxStartHeight));
this.spinnerMinDeltaWidth.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINDELTAWIDTH, this.spinnerMinDeltaWidth));
this.spinnerMaxDeltaWidth.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXDELTAWIDTH, this.spinnerMaxDeltaWidth));
this.spinnerMinDeltaHeight.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINDELTAHEIGHT, this.spinnerMinDeltaHeight));
this.spinnerMaxDeltaHeight.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXDELTAHEIGHT, this.spinnerMaxDeltaHeight));
this.spinnerMinParticleTTL.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINTTL, this.spinnerMinParticleTTL));
this.spinnerMaxParticleTTL.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXTTL, this.spinnerMaxParticleTTL));
this.spinnerMinStartX.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINX, this.spinnerMinStartX));
this.spinnerMaxStartX.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXX, this.spinnerMaxStartX));
this.spinnerMinStartY.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MINY, this.spinnerMinStartY));
this.spinnerMaxStartY.addChangeListener(new SpinnerListener(MapObjectProperty.Particle.MAXY, this.spinnerMaxStartY));
this.spinnerColorDeviation.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.COLORDEVIATION, this.spinnerColorDeviation));
this.spinnerAlphaDeviation.addChangeListener(new SpinnerListener(MapObjectProperty.Emitter.ALPHADEVIATION, this.spinnerAlphaDeviation));
this.txt.addActionListener(new MapObjectPropertyActionListener(m -> m.setCustomProperty(MapObjectProperty.Particle.TEXT, this.txt.getText())));
}
use of de.gurkenlabs.litiengine.graphics.particles.xml.ParticleType in project litiengine by gurkenlabs.
the class EmitterPropertyPanel method setControlValues.
@Override
protected void setControlValues(IMapObject mapObject) {
ParticleType type = mapObject.getCustomPropertyEnum(MapObjectProperty.Emitter.PARTICLETYPE, ParticleType.class, ParticleType.RECTANGLE);
this.comboBoxParticleType.setSelectedItem(type);
this.updateTabbedGroup();
this.comboBoxSprite.setSelectedItem(mapObject.getCustomProperty(MapObjectProperty.Particle.SPRITE));
this.comboBoxCollisionType.setSelectedItem(mapObject.getCustomPropertyEnum(MapObjectProperty.Particle.COLLISIONTYPE, CollisionType.class, CollisionType.NONE));
// TODO: implement this
this.comboBoxSpriteType.setSelectedIndex(0);
this.spinnerSpawnRate.setValue(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.SPAWNRATE));
this.spinnerSpawnAmount.setValue(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.SPAWNAMOUNT, Emitter.DEFAULT_SPAWNAMOUNT));
this.spinnerUpdateRate.setValue(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.UPDATERATE));
this.spinnerTTL.setValue(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.TIMETOLIVE));
this.spinnerMaxParticles.setValue(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.MAXPARTICLES, Emitter.DEFAULT_MAXPARTICLES));
// TODO: implement this
this.spinnerColorDeviation.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Emitter.COLORDEVIATION));
this.spinnerAlphaDeviation.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Emitter.ALPHADEVIATION));
this.spinnerMinDeltaX.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINDELTAX, -PARTICLEDELTA_DEFAULT_VALUE));
this.spinnerMaxDeltaX.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXDELTAX, PARTICLEDELTA_DEFAULT_VALUE));
this.spinnerMinDeltaY.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINDELTAY, -PARTICLEDELTA_DEFAULT_VALUE));
this.spinnerMaxDeltaY.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXDELTAY, PARTICLEDELTA_DEFAULT_VALUE));
this.spinnerMinGravityX.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINGRAVITYX));
this.spinnerMaxGravityX.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXGRAVITYX));
this.spinnerMinGravityY.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINGRAVITYY));
this.spinnerMaxGravityY.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXGRAVITYY));
this.spinnerMinStartWidth.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINSTARTWIDTH, 1));
this.spinnerMaxStartWidth.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXSTARTWIDTH, 1));
this.spinnerMinStartHeight.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINSTARTHEIGHT, 1));
this.spinnerMaxStartHeight.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXSTARTHEIGHT, 1));
this.spinnerMinDeltaWidth.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINDELTAWIDTH));
this.spinnerMaxDeltaWidth.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXDELTAWIDTH));
this.spinnerMinDeltaHeight.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINDELTAHEIGHT));
this.spinnerMaxDeltaHeight.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXDELTAHEIGHT));
this.spinnerMinParticleTTL.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINTTL, PARTICLEMINTTL_DEFAULT_VALUE));
this.spinnerMaxParticleTTL.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXTTL));
this.spinnerMinStartX.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINX));
this.spinnerMaxStartX.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXX));
this.spinnerMinStartY.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MINY));
this.spinnerMaxStartY.setValue(mapObject.getCustomPropertyDouble(MapObjectProperty.Particle.MAXY));
this.txt.setText(mapObject.getCustomProperty(MapObjectProperty.Particle.TEXT));
this.rdbtnRandomDeltaX.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.DELTAX_RANDOM, true));
this.rdbtnRandomDeltaY.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.DELTAY_RANDOM, true));
this.rdbtnRandomGravityX.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.GRAVITYX_RANDOM));
this.rdbtnRandomGravityY.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.GRAVITYY_RANDOM));
this.rdbtnRandomStartWidth.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.STARTWIDTH_RANDOM));
this.rdbtnRandomStartHeight.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.STARTHEIGHT_RANDOM));
this.rdbtnRandomDeltaWidth.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.DELTAWIDTH_RANDOM));
this.rdbtnRandomDeltaHeight.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.DELTAHEIGHT_RANDOM));
this.rdbtnRandomParticleTTL.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.TTL_RANDOM));
this.rdbtnRandomStartX.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.X_RANDOM));
this.rdbtnRandomStartY.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.Y_RANDOM));
this.model.setRowCount(0);
for (ParticleColor color : EmitterMapObjectLoader.getColors(mapObject)) {
this.colors.add(color);
this.model.addRow(new Object[] { null, color.toString() });
}
}
Aggregations