diff --git a/game/ato/flightplans/aewc.py b/game/ato/flightplans/aewc.py index 8e4885a9..bdcdf59b 100644 --- a/game/ato/flightplans/aewc.py +++ b/game/ato/flightplans/aewc.py @@ -90,6 +90,7 @@ class Builder(IBuilder[AewcFlightPlan, PatrollingLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> AewcFlightPlan: diff --git a/game/ato/flightplans/airassault.py b/game/ato/flightplans/airassault.py index ec4b72c0..f03943a8 100644 --- a/game/ato/flightplans/airassault.py +++ b/game/ato/flightplans/airassault.py @@ -49,6 +49,7 @@ class AirAssaultLayout(FormationAttackLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints class AirAssaultFlightPlan(FormationAttackFlightPlan, UiZoneDisplay): @@ -187,6 +188,7 @@ class Builder(FormationAttackBuilder[AirAssaultFlightPlan, AirAssaultLayout]): join=builder.join(ingress.position), split=builder.split(self.flight.arrival.position), refuel=None, + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> AirAssaultFlightPlan: diff --git a/game/ato/flightplans/airlift.py b/game/ato/flightplans/airlift.py index 17692ac1..0e673b80 100644 --- a/game/ato/flightplans/airlift.py +++ b/game/ato/flightplans/airlift.py @@ -92,6 +92,7 @@ class AirliftLayout(StandardLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints class AirliftFlightPlan(StandardFlightPlan[AirliftLayout]): @@ -246,6 +247,7 @@ class Builder(IBuilder[AirliftFlightPlan, AirliftLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> AirliftFlightPlan: diff --git a/game/ato/flightplans/barcap.py b/game/ato/flightplans/barcap.py index 1fdf10c1..1f2bd973 100644 --- a/game/ato/flightplans/barcap.py +++ b/game/ato/flightplans/barcap.py @@ -64,6 +64,7 @@ class Builder(CapBuilder[BarCapFlightPlan, PatrollingLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> BarCapFlightPlan: diff --git a/game/ato/flightplans/cas.py b/game/ato/flightplans/cas.py index 1ca58e2e..217264bc 100644 --- a/game/ato/flightplans/cas.py +++ b/game/ato/flightplans/cas.py @@ -37,6 +37,7 @@ class CasLayout(PatrollingLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints class CasFlightPlan(PatrollingFlightPlan[CasLayout], UiZoneDisplay): @@ -167,6 +168,7 @@ class Builder(IBuilder[CasFlightPlan, CasLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> CasFlightPlan: diff --git a/game/ato/flightplans/custom.py b/game/ato/flightplans/custom.py index 41e01fa2..a0191ea8 100644 --- a/game/ato/flightplans/custom.py +++ b/game/ato/flightplans/custom.py @@ -17,8 +17,6 @@ if TYPE_CHECKING: @dataclass class CustomLayout(Layout): - custom_waypoints: list[FlightWaypoint] - def iter_waypoints(self) -> Iterator[FlightWaypoint]: yield self.departure yield from self.custom_waypoints diff --git a/game/ato/flightplans/escort.py b/game/ato/flightplans/escort.py index 794f5cf1..ee73d5d8 100644 --- a/game/ato/flightplans/escort.py +++ b/game/ato/flightplans/escort.py @@ -103,6 +103,7 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> EscortFlightPlan: diff --git a/game/ato/flightplans/ferry.py b/game/ato/flightplans/ferry.py index 331b9352..eebb0e05 100644 --- a/game/ato/flightplans/ferry.py +++ b/game/ato/flightplans/ferry.py @@ -24,6 +24,7 @@ class FerryLayout(StandardLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints class FerryFlightPlan(StandardFlightPlan[FerryLayout]): @@ -80,6 +81,7 @@ class Builder(IBuilder[FerryFlightPlan, FerryLayout]): divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), nav_from=[], + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> FerryFlightPlan: diff --git a/game/ato/flightplans/flightplan.py b/game/ato/flightplans/flightplan.py index 196ab3f1..ed582353 100644 --- a/game/ato/flightplans/flightplan.py +++ b/game/ato/flightplans/flightplan.py @@ -34,6 +34,7 @@ if TYPE_CHECKING: @dataclass class Layout(ABC): departure: FlightWaypoint + custom_waypoints: list[FlightWaypoint] @property def waypoints(self) -> list[FlightWaypoint]: diff --git a/game/ato/flightplans/formationattack.py b/game/ato/flightplans/formationattack.py index ae759815..3faae11c 100644 --- a/game/ato/flightplans/formationattack.py +++ b/game/ato/flightplans/formationattack.py @@ -157,6 +157,7 @@ class FormationAttackLayout(FormationLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints FlightPlanT = TypeVar("FlightPlanT", bound=FlightPlan[FormationAttackLayout]) @@ -244,6 +245,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def _build_refuel(self, builder: WaypointBuilder) -> Optional[FlightWaypoint]: diff --git a/game/ato/flightplans/packagerefueling.py b/game/ato/flightplans/packagerefueling.py index 670d9b57..a28a907a 100644 --- a/game/ato/flightplans/packagerefueling.py +++ b/game/ato/flightplans/packagerefueling.py @@ -119,6 +119,7 @@ class Builder(IBuilder[PackageRefuelingFlightPlan, PatrollingLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> PackageRefuelingFlightPlan: diff --git a/game/ato/flightplans/patrolling.py b/game/ato/flightplans/patrolling.py index f81a4005..600550e7 100644 --- a/game/ato/flightplans/patrolling.py +++ b/game/ato/flightplans/patrolling.py @@ -31,6 +31,7 @@ class PatrollingLayout(StandardLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints LayoutT = TypeVar("LayoutT", bound=PatrollingLayout) diff --git a/game/ato/flightplans/rtb.py b/game/ato/flightplans/rtb.py index 3e1d48db..7b430f8a 100644 --- a/game/ato/flightplans/rtb.py +++ b/game/ato/flightplans/rtb.py @@ -27,6 +27,7 @@ class RtbLayout(StandardLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints class RtbFlightPlan(StandardFlightPlan[RtbLayout]): @@ -91,6 +92,7 @@ class Builder(IBuilder[RtbFlightPlan, RtbLayout]): divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), nav_from=[], + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> RtbFlightPlan: diff --git a/game/ato/flightplans/standard.py b/game/ato/flightplans/standard.py index 4bdfbdd9..1235fd60 100644 --- a/game/ato/flightplans/standard.py +++ b/game/ato/flightplans/standard.py @@ -70,6 +70,9 @@ class StandardLayout(Layout, ABC): elif waypoint in self.nav_from: self.nav_from.remove(waypoint) return True + elif waypoint in self.custom_waypoints: + self.custom_waypoints.remove(waypoint) + return True return False diff --git a/game/ato/flightplans/sweep.py b/game/ato/flightplans/sweep.py index 9229519b..4f8b5cfc 100644 --- a/game/ato/flightplans/sweep.py +++ b/game/ato/flightplans/sweep.py @@ -35,6 +35,7 @@ class SweepLayout(LoiterLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints class SweepFlightPlan(LoiterFlightPlan): @@ -124,6 +125,7 @@ class Builder(IBuilder[SweepFlightPlan, SweepLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def _hold_point(self) -> Point: diff --git a/game/ato/flightplans/tarcap.py b/game/ato/flightplans/tarcap.py index 4b1c4cd0..d7805ac3 100644 --- a/game/ato/flightplans/tarcap.py +++ b/game/ato/flightplans/tarcap.py @@ -31,6 +31,7 @@ class TarCapLayout(PatrollingLayout): if self.divert is not None: yield self.divert yield self.bullseye + yield from self.custom_waypoints def delete_waypoint(self, waypoint: FlightWaypoint) -> bool: if waypoint == self.refuel: @@ -128,6 +129,7 @@ class Builder(CapBuilder[TarCapFlightPlan, TarCapLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> TarCapFlightPlan: diff --git a/game/ato/flightplans/theaterrefueling.py b/game/ato/flightplans/theaterrefueling.py index 7f3e8ccc..76d34ab0 100644 --- a/game/ato/flightplans/theaterrefueling.py +++ b/game/ato/flightplans/theaterrefueling.py @@ -79,6 +79,7 @@ class Builder(IBuilder[TheaterRefuelingFlightPlan, PatrollingLayout]): arrival=builder.land(self.flight.arrival), divert=builder.divert(self.flight.divert), bullseye=builder.bullseye(), + custom_waypoints=list(), ) def build(self, dump_debug_info: bool = False) -> TheaterRefuelingFlightPlan: diff --git a/game/migrator.py b/game/migrator.py index 7d4e2cd2..52f85444 100644 --- a/game/migrator.py +++ b/game/migrator.py @@ -108,6 +108,7 @@ class Migrator: layout = f.flight_plan.layout try_set_attr(layout, "nav_to", []) try_set_attr(layout, "nav_from", []) + try_set_attr(layout, "custom_waypoints", []) if f.flight_type == FlightType.CAS: try_set_attr(layout, "ingress", None) if isinstance(layout, FormationLayout): diff --git a/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py b/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py index c6ce59e0..f4b21ee7 100644 --- a/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py +++ b/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py @@ -162,9 +162,9 @@ class QFlightWaypointTab(QFrame): assert isinstance(self.flight.flight_plan, CustomFlightPlan) self.flight.flight_plan.layout.custom_waypoints.remove(waypoint) - def confirm_degrade(self) -> bool: + def confirm_degrade(self, parent: Optional[QWidget] = None) -> bool: result = QMessageBox.warning( - self, + parent if parent else self, "Degrade flight-plan?", "Deleting the selected waypoint(s) will require degradation to a custom flight-plan. " "A custom flight-plan will no longer respect the TOTs of the package.

" @@ -184,12 +184,6 @@ class QFlightWaypointTab(QFrame): def on_waypoints_added(self, waypoints: Iterable[FlightWaypoint]) -> None: if not waypoints: return - if not self.flight.flight_plan.is_custom: - confirmed = self.confirm_degrade() - if not confirmed: - return - self.degrade_to_custom_flight_plan() - assert isinstance(self.flight.flight_plan, CustomFlightPlan) self.flight.flight_plan.layout.custom_waypoints.extend(waypoints) self.add_rows(len(list(waypoints)))