mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Don't degrade flight-plan when adding waypoints
This commit is contained in:
parent
bcf8ee9d42
commit
7158a5e60d
@ -90,6 +90,7 @@ class Builder(IBuilder[AewcFlightPlan, PatrollingLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> AewcFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> AewcFlightPlan:
|
||||||
|
|||||||
@ -49,6 +49,7 @@ class AirAssaultLayout(FormationAttackLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
class AirAssaultFlightPlan(FormationAttackFlightPlan, UiZoneDisplay):
|
class AirAssaultFlightPlan(FormationAttackFlightPlan, UiZoneDisplay):
|
||||||
@ -187,6 +188,7 @@ class Builder(FormationAttackBuilder[AirAssaultFlightPlan, AirAssaultLayout]):
|
|||||||
join=builder.join(ingress.position),
|
join=builder.join(ingress.position),
|
||||||
split=builder.split(self.flight.arrival.position),
|
split=builder.split(self.flight.arrival.position),
|
||||||
refuel=None,
|
refuel=None,
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> AirAssaultFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> AirAssaultFlightPlan:
|
||||||
|
|||||||
@ -92,6 +92,7 @@ class AirliftLayout(StandardLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
class AirliftFlightPlan(StandardFlightPlan[AirliftLayout]):
|
class AirliftFlightPlan(StandardFlightPlan[AirliftLayout]):
|
||||||
@ -246,6 +247,7 @@ class Builder(IBuilder[AirliftFlightPlan, AirliftLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> AirliftFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> AirliftFlightPlan:
|
||||||
|
|||||||
@ -64,6 +64,7 @@ class Builder(CapBuilder[BarCapFlightPlan, PatrollingLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> BarCapFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> BarCapFlightPlan:
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class CasLayout(PatrollingLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
class CasFlightPlan(PatrollingFlightPlan[CasLayout], UiZoneDisplay):
|
class CasFlightPlan(PatrollingFlightPlan[CasLayout], UiZoneDisplay):
|
||||||
@ -167,6 +168,7 @@ class Builder(IBuilder[CasFlightPlan, CasLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> CasFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> CasFlightPlan:
|
||||||
|
|||||||
@ -17,8 +17,6 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CustomLayout(Layout):
|
class CustomLayout(Layout):
|
||||||
custom_waypoints: list[FlightWaypoint]
|
|
||||||
|
|
||||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||||
yield self.departure
|
yield self.departure
|
||||||
yield from self.custom_waypoints
|
yield from self.custom_waypoints
|
||||||
|
|||||||
@ -103,6 +103,7 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> EscortFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> EscortFlightPlan:
|
||||||
|
|||||||
@ -24,6 +24,7 @@ class FerryLayout(StandardLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
class FerryFlightPlan(StandardFlightPlan[FerryLayout]):
|
class FerryFlightPlan(StandardFlightPlan[FerryLayout]):
|
||||||
@ -80,6 +81,7 @@ class Builder(IBuilder[FerryFlightPlan, FerryLayout]):
|
|||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
nav_from=[],
|
nav_from=[],
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> FerryFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> FerryFlightPlan:
|
||||||
|
|||||||
@ -34,6 +34,7 @@ if TYPE_CHECKING:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Layout(ABC):
|
class Layout(ABC):
|
||||||
departure: FlightWaypoint
|
departure: FlightWaypoint
|
||||||
|
custom_waypoints: list[FlightWaypoint]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def waypoints(self) -> list[FlightWaypoint]:
|
def waypoints(self) -> list[FlightWaypoint]:
|
||||||
|
|||||||
@ -157,6 +157,7 @@ class FormationAttackLayout(FormationLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
FlightPlanT = TypeVar("FlightPlanT", bound=FlightPlan[FormationAttackLayout])
|
FlightPlanT = TypeVar("FlightPlanT", bound=FlightPlan[FormationAttackLayout])
|
||||||
@ -244,6 +245,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _build_refuel(self, builder: WaypointBuilder) -> Optional[FlightWaypoint]:
|
def _build_refuel(self, builder: WaypointBuilder) -> Optional[FlightWaypoint]:
|
||||||
|
|||||||
@ -119,6 +119,7 @@ class Builder(IBuilder[PackageRefuelingFlightPlan, PatrollingLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> PackageRefuelingFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> PackageRefuelingFlightPlan:
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class PatrollingLayout(StandardLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
LayoutT = TypeVar("LayoutT", bound=PatrollingLayout)
|
LayoutT = TypeVar("LayoutT", bound=PatrollingLayout)
|
||||||
|
|||||||
@ -27,6 +27,7 @@ class RtbLayout(StandardLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
class RtbFlightPlan(StandardFlightPlan[RtbLayout]):
|
class RtbFlightPlan(StandardFlightPlan[RtbLayout]):
|
||||||
@ -91,6 +92,7 @@ class Builder(IBuilder[RtbFlightPlan, RtbLayout]):
|
|||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
nav_from=[],
|
nav_from=[],
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> RtbFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> RtbFlightPlan:
|
||||||
|
|||||||
@ -70,6 +70,9 @@ class StandardLayout(Layout, ABC):
|
|||||||
elif waypoint in self.nav_from:
|
elif waypoint in self.nav_from:
|
||||||
self.nav_from.remove(waypoint)
|
self.nav_from.remove(waypoint)
|
||||||
return True
|
return True
|
||||||
|
elif waypoint in self.custom_waypoints:
|
||||||
|
self.custom_waypoints.remove(waypoint)
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@ class SweepLayout(LoiterLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
|
|
||||||
class SweepFlightPlan(LoiterFlightPlan):
|
class SweepFlightPlan(LoiterFlightPlan):
|
||||||
@ -124,6 +125,7 @@ class Builder(IBuilder[SweepFlightPlan, SweepLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _hold_point(self) -> Point:
|
def _hold_point(self) -> Point:
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class TarCapLayout(PatrollingLayout):
|
|||||||
if self.divert is not None:
|
if self.divert is not None:
|
||||||
yield self.divert
|
yield self.divert
|
||||||
yield self.bullseye
|
yield self.bullseye
|
||||||
|
yield from self.custom_waypoints
|
||||||
|
|
||||||
def delete_waypoint(self, waypoint: FlightWaypoint) -> bool:
|
def delete_waypoint(self, waypoint: FlightWaypoint) -> bool:
|
||||||
if waypoint == self.refuel:
|
if waypoint == self.refuel:
|
||||||
@ -128,6 +129,7 @@ class Builder(CapBuilder[TarCapFlightPlan, TarCapLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> TarCapFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> TarCapFlightPlan:
|
||||||
|
|||||||
@ -79,6 +79,7 @@ class Builder(IBuilder[TheaterRefuelingFlightPlan, PatrollingLayout]):
|
|||||||
arrival=builder.land(self.flight.arrival),
|
arrival=builder.land(self.flight.arrival),
|
||||||
divert=builder.divert(self.flight.divert),
|
divert=builder.divert(self.flight.divert),
|
||||||
bullseye=builder.bullseye(),
|
bullseye=builder.bullseye(),
|
||||||
|
custom_waypoints=list(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, dump_debug_info: bool = False) -> TheaterRefuelingFlightPlan:
|
def build(self, dump_debug_info: bool = False) -> TheaterRefuelingFlightPlan:
|
||||||
|
|||||||
@ -108,6 +108,7 @@ class Migrator:
|
|||||||
layout = f.flight_plan.layout
|
layout = f.flight_plan.layout
|
||||||
try_set_attr(layout, "nav_to", [])
|
try_set_attr(layout, "nav_to", [])
|
||||||
try_set_attr(layout, "nav_from", [])
|
try_set_attr(layout, "nav_from", [])
|
||||||
|
try_set_attr(layout, "custom_waypoints", [])
|
||||||
if f.flight_type == FlightType.CAS:
|
if f.flight_type == FlightType.CAS:
|
||||||
try_set_attr(layout, "ingress", None)
|
try_set_attr(layout, "ingress", None)
|
||||||
if isinstance(layout, FormationLayout):
|
if isinstance(layout, FormationLayout):
|
||||||
|
|||||||
@ -162,9 +162,9 @@ class QFlightWaypointTab(QFrame):
|
|||||||
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
||||||
self.flight.flight_plan.layout.custom_waypoints.remove(waypoint)
|
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(
|
result = QMessageBox.warning(
|
||||||
self,
|
parent if parent else self,
|
||||||
"Degrade flight-plan?",
|
"Degrade flight-plan?",
|
||||||
"Deleting the selected waypoint(s) will require degradation to a custom 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.<br><br>"
|
"A custom flight-plan will no longer respect the TOTs of the package.<br><br>"
|
||||||
@ -184,12 +184,6 @@ class QFlightWaypointTab(QFrame):
|
|||||||
def on_waypoints_added(self, waypoints: Iterable[FlightWaypoint]) -> None:
|
def on_waypoints_added(self, waypoints: Iterable[FlightWaypoint]) -> None:
|
||||||
if not waypoints:
|
if not waypoints:
|
||||||
return
|
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.flight.flight_plan.layout.custom_waypoints.extend(waypoints)
|
||||||
self.add_rows(len(list(waypoints)))
|
self.add_rows(len(list(waypoints)))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user