File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1211,6 +1211,22 @@ ArrivalLocation ShipEditorDialogModel::getArrivalLocation() const
12111211 return static_cast <ArrivalLocation>(_arrivalLocation);
12121212}
12131213
1214+ bool ShipEditorDialogModel::arrivalNeedsTarget () const
1215+ {
1216+ return getArrivalLocation () != ArrivalLocation::AT_LOCATION ;
1217+ }
1218+
1219+ bool ShipEditorDialogModel::arrivalNeedsDistance () const
1220+ {
1221+ switch (getArrivalLocation ()) {
1222+ case ArrivalLocation::AT_LOCATION :
1223+ case ArrivalLocation::FROM_DOCK_BAY :
1224+ return false ;
1225+ default :
1226+ return true ;
1227+ }
1228+ }
1229+
12141230int ShipEditorDialogModel::computeArrivalMinDist () const
12151231{
12161232 // Validation only applies when arriving near a ship (not hyperspace or dock bay)
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ class ShipEditorDialogModel : public AbstractDialogModel {
6969 void setArrivalLocation (ArrivalLocation location);
7070 ArrivalLocation getArrivalLocation () const ;
7171
72+ bool arrivalNeedsTarget () const ;
73+ bool arrivalNeedsDistance () const ;
74+
7275 void setArrivalTarget (int targetIndex);
7376 int getArrivalTarget () const ;
7477
Original file line number Diff line number Diff line change @@ -176,6 +176,22 @@ bool WingEditorDialogModel::arrivalNeedsTarget() const
176176 }
177177}
178178
179+ bool WingEditorDialogModel::arrivalNeedsDistance () const
180+ {
181+ const auto w = getCurrentWing ();
182+
183+ if (!w)
184+ return false ;
185+
186+ switch (w->arrival_location ) {
187+ case ArrivalLocation::AT_LOCATION :
188+ case ArrivalLocation::FROM_DOCK_BAY :
189+ return false ;
190+ default :
191+ return true ;
192+ }
193+ }
194+
179195
180196bool WingEditorDialogModel::departureIsDockBay () const
181197{
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class WingEditorDialogModel : public AbstractDialogModel {
3838
3939 bool arrivalIsDockBay () const ;
4040 bool arrivalNeedsTarget () const ;
41+ bool arrivalNeedsDistance () const ;
4142 bool departureIsDockBay () const ;
4243 bool departureNeedsTarget () const ;
4344 int getMaxWaveThreshold () const ;
Original file line number Diff line number Diff line change @@ -422,13 +422,8 @@ void ShipEditorDialog::enableDisable()
422422 ui->restrictDeparturePathsButton ->setEnabled (false );
423423 } else {
424424 ui->arrivalLocationCombo ->setEnabled (_model->getUIEnable ());
425- if (_model->getArrivalLocationIndex ()) {
426- ui->arrivalDistanceEdit ->setEnabled (_model->getUIEnable ());
427- ui->arrivalTargetCombo ->setEnabled (_model->getUIEnable ());
428- } else {
429- ui->arrivalDistanceEdit ->setEnabled (false );
430- ui->arrivalTargetCombo ->setEnabled (false );
431- }
425+ ui->arrivalDistanceEdit ->setEnabled (_model->getUIEnable () && _model->arrivalNeedsDistance ());
426+ ui->arrivalTargetCombo ->setEnabled (_model->getUIEnable () && _model->arrivalNeedsTarget ());
432427 if (_model->getArrivalLocation () == ArrivalLocation::FROM_DOCK_BAY ) {
433428 if (_model->getArrivalTarget () >= 0 ) {
434429 ui->restrictArrivalPathsButton ->setEnabled (_model->getUIEnable ());
Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ void WingEditorDialog::enableOrDisableControls()
197197 const bool arrivalNeedsTarget = _model->arrivalNeedsTarget ();
198198
199199 ui->arrivalTargetCombo ->setEnabled (arrivalEditable && arrivalNeedsTarget);
200- ui->arrivalDistanceSpinBox ->setEnabled (arrivalEditable && arrivalNeedsTarget );
200+ ui->arrivalDistanceSpinBox ->setEnabled (arrivalEditable && _model-> arrivalNeedsDistance () );
201201 ui->restrictArrivalPathsButton ->setEnabled (arrivalEditable && arrivalIsDockBay);
202202 ui->customWarpinButton ->setEnabled (arrivalEditable && !arrivalIsDockBay);
203203
Original file line number Diff line number Diff line change @@ -431,7 +431,9 @@ int ErrorChecker::checkShips() {
431431 error (" Ship \" %s\" has a negative departure delay" , Ships[i].ship_name );
432432 }
433433
434- if (Ships[i].arrival_location != ArrivalLocation::AT_LOCATION && Ships[i].arrival_distance <= 0 ) {
434+ if (Ships[i].arrival_location != ArrivalLocation::AT_LOCATION &&
435+ Ships[i].arrival_location != ArrivalLocation::FROM_DOCK_BAY &&
436+ Ships[i].arrival_distance <= 0 ) {
435437 error (" Arrival distance for ship \" %s\" must be greater than 0" , Ships[i].ship_name );
436438 }
437439
@@ -704,7 +706,9 @@ int ErrorChecker::checkWings() {
704706 error (" Wing \" %s\" has a negative departure delay" , Wings[i].name );
705707 }
706708
707- if (Wings[i].arrival_location != ArrivalLocation::AT_LOCATION && Wings[i].arrival_distance <= 0 ) {
709+ if (Wings[i].arrival_location != ArrivalLocation::AT_LOCATION &&
710+ Wings[i].arrival_location != ArrivalLocation::FROM_DOCK_BAY &&
711+ Wings[i].arrival_distance <= 0 ) {
708712 error (" Arrival distance for wing \" %s\" must be greater than 0" , Wings[i].name );
709713 }
710714
You can’t perform that action at this time.
0 commit comments