use of megamek.common.verifier.TestAero.Quarters in project megameklab by MegaMek.
the class DropshipStructureTab method quartersChanged.
@Override
public void quartersChanged(int officer, int standard, int secondclass, int steerage) {
EnumMap<TestAero.Quarters, Integer> sizes = new EnumMap<>(TestAero.Quarters.class);
for (Bay bay : getSmallCraft().getTransportBays()) {
Quarters q = TestAero.Quarters.getQuartersForBay(bay);
if (null != q) {
sizes.merge(q, (int) bay.getCapacity(), Integer::sum);
}
}
if (sizes.getOrDefault(TestAero.Quarters.FIRST_CLASS, 0) != officer) {
setQuarters(TestAero.Quarters.FIRST_CLASS, officer);
}
if (sizes.getOrDefault(TestAero.Quarters.STANDARD, 0) != standard) {
setQuarters(TestAero.Quarters.STANDARD, standard);
}
if (sizes.getOrDefault(TestAero.Quarters.SECOND_CLASS, 0) != secondclass) {
setQuarters(TestAero.Quarters.SECOND_CLASS, secondclass);
}
if (sizes.getOrDefault(TestAero.Quarters.STEERAGE, 0) != steerage) {
setQuarters(TestAero.Quarters.STEERAGE, steerage);
}
panCrew.setFromEntity(getSmallCraft());
refreshSummary();
refresh.refreshStatus();
refresh.refreshPreview();
}
use of megamek.common.verifier.TestAero.Quarters in project megameklab by MegaMek.
the class AerospaceCrewView method setFromEntity.
public void setFromEntity(SmallCraft sc) {
int minGunners = TestSmallCraft.requiredGunners(sc);
int minBase = TestSmallCraft.minimumBaseCrew(sc);
int nonBay = sc.getNCrew() - sc.getBayPersonnel();
((SpinnerNumberModel) spnBaseCrew.getModel()).setMinimum(minBase);
((SpinnerNumberModel) spnGunners.getModel()).setMinimum(minGunners);
ignoreChangeEvents = true;
spnOfficers.setValue(sc.getNOfficers());
spnBaseCrew.setValue(nonBay - sc.getNGunners());
spnGunners.setValue(sc.getNGunners());
lblTotalCrew.setText(String.valueOf(nonBay));
lblBayPersonnel.setText(String.valueOf(sc.getBayPersonnel()));
spnPassengers.setValue(sc.getNPassenger());
spnMarines.setValue(sc.getNMarines());
if (techManager.isLegal(BattleArmor.getConstructionTechAdvancement(EntityWeightClass.WEIGHT_MEDIUM))) {
spnBAMarines.setValue(sc.getNBattleArmor());
lblBAMarines.setVisible(true);
spnBAMarines.setVisible(true);
} else {
spnBAMarines.setValue(0);
lblBAMarines.setVisible(false);
spnBAMarines.setVisible(false);
}
EnumMap<TestAero.Quarters, Integer> sizes = new EnumMap<>(TestAero.Quarters.class);
for (Bay bay : sc.getTransportBays()) {
Quarters q = TestAero.Quarters.getQuartersForBay(bay);
if (null != q) {
sizes.merge(q, (int) bay.getCapacity(), Integer::sum);
}
}
spnQuartersFirstClass.setValue(sizes.getOrDefault(TestAero.Quarters.FIRST_CLASS, 0));
spnQuartersStandard.setValue(sizes.getOrDefault(TestAero.Quarters.STANDARD, 0));
spnQuartersSecondClass.setValue(sizes.getOrDefault(TestAero.Quarters.SECOND_CLASS, 0));
spnQuartersSteerage.setValue(sizes.getOrDefault(TestAero.Quarters.STEERAGE, 0));
spnLifeBoats.setValue(sc.getLifeBoats());
spnEscapePods.setValue(sc.getEscapePods());
ignoreChangeEvents = false;
// If we do not meet the minimum, set the values and trigger an event that will update the vessel.
if (sc.getNGunners() < minGunners) {
spnGunners.setValue(minGunners);
}
if (nonBay - sc.getNGunners() < minBase) {
spnBaseCrew.setValue(minBase);
}
}
Aggregations