Skip to content

Commit

Permalink
youngest in back ability
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Ski committed Dec 1, 2023
1 parent 3852a43 commit 0a1100a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class EmConfigModuleWrapper extends ModuleWrapper<EmConfigModule> {
CheckboxWithZoom continuousBox;
CheckboxWithZoom alignedBox;
CheckboxWithZoom immortalBox;
CheckboxWithZoom youngestInBackBox;

boolean lockListeners = false;

Expand All @@ -47,6 +48,7 @@ protected void configureSlots() {
continuousBox = new CheckboxWithZoom("continuous", VisUI.getSkin());
alignedBox = new CheckboxWithZoom("aligned", VisUI.getSkin());
immortalBox = new CheckboxWithZoom("immortal", VisUI.getSkin());
youngestInBackBox = new CheckboxWithZoom("youngestInBackBox", VisUI.getSkin());

Table form = new Table();

Expand All @@ -61,6 +63,8 @@ protected void configureSlots() {
form.add(alignedBox).left().padLeft(3);
form.row();
form.add(immortalBox).left().padLeft(3);
form.row();
form.add(youngestInBackBox).left().padLeft(3);

contentWrapper.add(form).left();
contentWrapper.add().expandX();
Expand Down Expand Up @@ -103,6 +107,12 @@ public void changed(ChangeEvent event, Actor actor) {
fromUIToData();
}
});
youngestInBackBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
fromUIToData();
}
});
}

@Override
Expand All @@ -119,6 +129,8 @@ public void fromUIToData() {
module.getUserValue().continuous = continuousBox.isChecked();
module.getUserValue().aligned = alignedBox.isChecked();
module.getUserValue().immortal = immortalBox.isChecked();
module.getUserValue().youngestInBack = youngestInBackBox.isChecked();

}
}

Expand All @@ -130,6 +142,7 @@ public void fromDataToUI() {
continuousBox.setChecked(module.getUserValue().continuous);
alignedBox.setChecked(module.getUserValue().aligned);
immortalBox.setChecked(module.getUserValue().immortal);
youngestInBackBox.setChecked(module.getUserValue().youngestInBack);
lockListeners = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void update (float delta) {
isAdditive = emitterModule.isAdditive();
isBlendAdd = emitterModule.isBlendAdd();
isImmortal = emitterModule.isImmortal();
boolean youngestInBack = emitterModule.isYoungestInBack();

if (delayTimer > 0) {
delayTimer -= delta;
Expand Down Expand Up @@ -185,7 +186,11 @@ public void update (float delta) {
Particle particle = particlePool.obtain();
if (emitterGraph.getParticleModule() != null) {
particle.init(this);
activeParticles.add(particle);
if (youngestInBack) {
activeParticles.add(particle);
} else {
activeParticles.insert(0, particle);
}
}
}
particlesToEmmit -= count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void init () {
userValue.isBlendAdd = false;
userValue.aligned = false;
userValue.immortal = false;
userValue.youngestInBack = true;
}

@Override
Expand All @@ -65,6 +66,7 @@ public void write(Json json) {
json.writeValue("continuous", getUserValue().continuous);
json.writeValue("aligned", getUserValue().aligned);
json.writeValue("immortal", getUserValue().immortal);
json.writeValue("youngestInFront", getUserValue().youngestInBack);
}

@Override
Expand All @@ -76,6 +78,7 @@ public void read (Json json, JsonValue jsonData) {
getUserValue().continuous = jsonData.getBoolean("continuous");
getUserValue().aligned = jsonData.getBoolean("aligned");
getUserValue().immortal = jsonData.getBoolean("immortal", false);
getUserValue().youngestInBack = jsonData.getBoolean("youngestInFront", true);

if(outputValue != null) {
outputValue.set(getUserValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ public boolean isAdditive() {
return config.additive;
}

public boolean isYoungestInBack() {
fetchInputSlotValue(CONFIG);

if(config.isEmpty()) return true;

return config.youngestInBack;
}


public boolean isBlendAdd () {
fetchInputSlotValue(CONFIG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class EmConfigValue extends Value {
public boolean additive = true;
public boolean isBlendAdd = false;
public boolean immortal = false;
public boolean youngestInBack = true;

@Override
public void set(Value value) {
Expand All @@ -37,5 +38,6 @@ public void set(EmConfigValue from) {
this.additive = from.additive;
this.isBlendAdd = from.isBlendAdd;
this.immortal = from.immortal;
this.youngestInBack = from.youngestInBack;
}
}

0 comments on commit 0a1100a

Please sign in to comment.