Only search active stages in substitutor
This commit is contained in:
parent
5fe03ed9f2
commit
813f0d5fc6
@ -13,6 +13,7 @@ import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.plugin.Plugin;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
@ -56,23 +57,19 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
||||
// First iterate over each stage and store the designations of each motor
|
||||
List<List<String>> list = new ArrayList<List<String>>();
|
||||
List<String> currentList = Collections.emptyList();
|
||||
|
||||
Iterator<RocketComponent> iterator = rocket.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RocketComponent c = iterator.next();
|
||||
|
||||
|
||||
FlightConfiguration config = rocket.getFlightConfiguration(fcid);
|
||||
for (RocketComponent c : rocket) {
|
||||
if (c instanceof AxialStage) {
|
||||
|
||||
currentList = new ArrayList<String>();
|
||||
currentList = new ArrayList<>();
|
||||
list.add(currentList);
|
||||
|
||||
} else if (c instanceof MotorMount) {
|
||||
|
||||
MotorMount mount = (MotorMount) c;
|
||||
MotorConfiguration inst = mount.getMotorConfig(fcid);
|
||||
Motor motor = inst.getMotor();
|
||||
|
||||
if (mount.isMotorMount() && motor != null) {
|
||||
if (mount.isMotorMount() && config.isComponentActive(mount) && motor != null) {
|
||||
String designation = motor.getDesignation(inst.getEjectionDelay());
|
||||
|
||||
for (int i = 0; i < mount.getMotorCount(); i++) {
|
||||
@ -80,7 +77,6 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
||||
motorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,11 +95,8 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
||||
Collections.sort(stage);
|
||||
for (String current : stage) {
|
||||
if (current.equals(previous)) {
|
||||
|
||||
count++;
|
||||
|
||||
} else {
|
||||
|
||||
if (previous != null) {
|
||||
String s = "";
|
||||
if (count > 1) {
|
||||
@ -117,10 +110,8 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
||||
else
|
||||
stageName = stageName + "," + s;
|
||||
}
|
||||
|
||||
previous = current;
|
||||
count = 1;
|
||||
|
||||
}
|
||||
}
|
||||
if (previous != null) {
|
||||
@ -136,14 +127,13 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
||||
else
|
||||
stageName = stageName + "," + s;
|
||||
}
|
||||
|
||||
stages.add(stageName);
|
||||
}
|
||||
|
||||
name = "";
|
||||
for (int i = 0; i < stages.size(); i++) {
|
||||
String s = stages.get(i);
|
||||
if (s.equals(""))
|
||||
if (s.equals("") && config.isStageActive(i))
|
||||
s = trans.get("Rocket.motorCount.noStageMotors");
|
||||
if (i == 0)
|
||||
name = name + s;
|
||||
|
@ -7,6 +7,7 @@ import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||
import net.sf.openrocket.plugin.Plugin;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
@ -56,6 +57,7 @@ public class MotorManufacturerSubstitutor implements RocketSubstitutor {
|
||||
List<List<String>> list = new ArrayList<>();
|
||||
List<String> currentList = Collections.emptyList();
|
||||
|
||||
FlightConfiguration config = rocket.getFlightConfiguration(fcid);
|
||||
for (RocketComponent c : rocket) {
|
||||
if (c instanceof AxialStage) {
|
||||
currentList = new ArrayList<>();
|
||||
@ -66,7 +68,7 @@ public class MotorManufacturerSubstitutor implements RocketSubstitutor {
|
||||
MotorConfiguration inst = mount.getMotorConfig(fcid);
|
||||
Motor motor = inst.getMotor();
|
||||
|
||||
if (mount.isMotorMount() && motor instanceof ThrustCurveMotor) {
|
||||
if (mount.isMotorMount() && config.isComponentActive(mount) && motor instanceof ThrustCurveMotor) {
|
||||
String manufacturer = ((ThrustCurveMotor) motor).getManufacturer().getDisplayName();
|
||||
|
||||
for (int i = 0; i < mount.getMotorCount(); i++) {
|
||||
@ -131,7 +133,7 @@ public class MotorManufacturerSubstitutor implements RocketSubstitutor {
|
||||
manufacturers = "";
|
||||
for (int i = 0; i < stages.size(); i++) {
|
||||
String s = stages.get(i);
|
||||
if (s.equals(""))
|
||||
if (s.equals("") && config.isStageActive(i))
|
||||
s = trans.get("Rocket.motorCount.noStageMotors");
|
||||
if (i == 0)
|
||||
manufacturers = manufacturers + s;
|
||||
|
@ -584,6 +584,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
public void testCopy() throws NoSuchFieldException, IllegalAccessException {
|
||||
Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||
FlightConfiguration original = rocket.getSelectedConfiguration();
|
||||
original.setName("[{motors}] - [{manufacturers}]");
|
||||
original.setOnlyStage(0);
|
||||
|
||||
// vvvv Test Target vvvv
|
||||
|
Loading…
x
Reference in New Issue
Block a user