Fix sims going out-of-date on stage activeness change

This commit is contained in:
SiboVG 2023-01-16 03:25:36 +01:00
parent be7813b23d
commit 993cd3169a
2 changed files with 18 additions and 4 deletions

View File

@ -476,11 +476,23 @@ public class Rocket extends ComponentAssembly {
* @param ids IDs of the flight configurations to update, or null to update all.
* @see #fireComponentChangeEvent(ComponentChangeEvent)
*/
public void fireComponentChangeEvent(int type, FlightConfigurationId[] ids) {
public void fireComponentChangeEvent(int type, final FlightConfigurationId[] ids) {
fireComponentChangeEvent(new ComponentChangeEvent(this, type), ids);
}
protected void fireComponentChangeEvent(ComponentChangeEvent cce, FlightConfigurationId[] ids) {
/**
* Fires a ComponentChangeEvent of the given type. The source of the event is set to
* this rocket.
*
* @param type Type of event
* @param id ID of the flight configurations to update, or null to update all.
* @see #fireComponentChangeEvent(ComponentChangeEvent)
*/
public void fireComponentChangeEvent(int type, FlightConfigurationId id) {
fireComponentChangeEvent(type, new FlightConfigurationId[]{ id });
}
protected void fireComponentChangeEvent(ComponentChangeEvent cce, final FlightConfigurationId[] ids) {
if (!this.eventsEnabled) {
return;
}

View File

@ -96,8 +96,10 @@ public class StageSelector extends JPanel implements StateChangeListener {
setEnabled(true);
putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.Toggle.ttip"));
}
rocket.getSelectedConfiguration().toggleStage(stage.getStageNumber());
rocket.fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE | ComponentChangeEvent.MOTOR_CHANGE );
FlightConfiguration config = rocket.getSelectedConfiguration();
config.toggleStage(stage.getStageNumber());
rocket.fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE | ComponentChangeEvent.MOTOR_CHANGE,
config.getFlightConfigurationID());
}
}