mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Allow deleting waypoints.
In almost every case this leaves us with a flight plan we can't reason about, so it gets degraded to `CustomFlightPlan`. The exception is when deleting a target point when there are other target points remaining. This probably gets people using this feature back to what they want though, which is essentially the 2.1 behavior. Fixes https://github.com/Khopa/dcs_liberation/issues/393
This commit is contained in:
parent
a223da8f99
commit
4b7b4bf110
@ -96,6 +96,11 @@ class TotEstimator:
|
|||||||
|
|
||||||
def mission_start_time(self, flight: Flight) -> timedelta:
|
def mission_start_time(self, flight: Flight) -> timedelta:
|
||||||
takeoff_time = self.takeoff_time_for_flight(flight)
|
takeoff_time = self.takeoff_time_for_flight(flight)
|
||||||
|
if takeoff_time is None:
|
||||||
|
# Could not determine takeoff time, probably due to a custom flight
|
||||||
|
# plan. Start immediately.
|
||||||
|
return timedelta()
|
||||||
|
|
||||||
startup_time = self.estimate_startup(flight)
|
startup_time = self.estimate_startup(flight)
|
||||||
ground_ops_time = self.estimate_ground_ops(flight)
|
ground_ops_time = self.estimate_ground_ops(flight)
|
||||||
start_time = takeoff_time - startup_time - ground_ops_time
|
start_time = takeoff_time - startup_time - ground_ops_time
|
||||||
@ -110,13 +115,12 @@ class TotEstimator:
|
|||||||
# Round down so *barely* above zero start times are just zero.
|
# Round down so *barely* above zero start times are just zero.
|
||||||
return timedelta(seconds=math.floor(start_time.total_seconds()))
|
return timedelta(seconds=math.floor(start_time.total_seconds()))
|
||||||
|
|
||||||
def takeoff_time_for_flight(self, flight: Flight) -> timedelta:
|
def takeoff_time_for_flight(self, flight: Flight) -> Optional[timedelta]:
|
||||||
travel_time = self.travel_time_to_rendezvous_or_target(flight)
|
travel_time = self.travel_time_to_rendezvous_or_target(flight)
|
||||||
if travel_time is None:
|
if travel_time is None:
|
||||||
logging.warning("Found no join point or patrol point. Cannot "
|
logging.warning("Found no rendezvous or target point. Cannot "
|
||||||
f"estimate takeoff time takeoff time for {flight}")
|
f"estimate takeoff time takeoff time for {flight}")
|
||||||
# Takeoff immediately.
|
return None
|
||||||
return timedelta()
|
|
||||||
|
|
||||||
from gen.flights.flightplan import FormationFlightPlan
|
from gen.flights.flightplan import FormationFlightPlan
|
||||||
if isinstance(flight.flight_plan, FormationFlightPlan):
|
if isinstance(flight.flight_plan, FormationFlightPlan):
|
||||||
@ -126,7 +130,7 @@ class TotEstimator:
|
|||||||
logging.warning(
|
logging.warning(
|
||||||
"Could not determine the TOT of the join point. Takeoff "
|
"Could not determine the TOT of the join point. Takeoff "
|
||||||
f"time for {flight} will be immediate.")
|
f"time for {flight} will be immediate.")
|
||||||
return timedelta()
|
return None
|
||||||
else:
|
else:
|
||||||
tot_waypoint = flight.flight_plan.tot_waypoint
|
tot_waypoint = flight.flight_plan.tot_waypoint
|
||||||
if tot_waypoint is None:
|
if tot_waypoint is None:
|
||||||
|
|||||||
@ -13,10 +13,12 @@ from PySide2.QtWidgets import (
|
|||||||
|
|
||||||
from game import Game
|
from game import Game
|
||||||
from gen.ato import Package
|
from gen.ato import Package
|
||||||
from gen.flights.flight import Flight, FlightType
|
from gen.flights.flight import Flight, FlightType, FlightWaypoint
|
||||||
from gen.flights.flightplan import (
|
from gen.flights.flightplan import (
|
||||||
|
CustomFlightPlan,
|
||||||
FlightPlanBuilder,
|
FlightPlanBuilder,
|
||||||
PlanningError,
|
PlanningError,
|
||||||
|
StrikeFlightPlan,
|
||||||
)
|
)
|
||||||
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointList import \
|
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointList import \
|
||||||
QFlightWaypointList
|
QFlightWaypointList
|
||||||
@ -97,10 +99,30 @@ class QFlightWaypointTab(QFrame):
|
|||||||
def on_delete_waypoint(self):
|
def on_delete_waypoint(self):
|
||||||
wpt = self.flight_waypoint_list.selectionModel().currentIndex().row()
|
wpt = self.flight_waypoint_list.selectionModel().currentIndex().row()
|
||||||
if wpt > 0:
|
if wpt > 0:
|
||||||
del self.flight.points[wpt-1]
|
self.delete_waypoint(self.flight.flight_plan.waypoints[wpt])
|
||||||
self.flight_waypoint_list.update_list()
|
self.flight_waypoint_list.update_list()
|
||||||
self.on_change()
|
self.on_change()
|
||||||
|
|
||||||
|
def delete_waypoint(self, waypoint: FlightWaypoint) -> None:
|
||||||
|
# Need to degrade to a custom flight plan and remove the waypoint.
|
||||||
|
# If the waypoint is a target waypoint and is not the last target
|
||||||
|
# waypoint, we don't need to degrade.
|
||||||
|
flight_plan = self.flight.flight_plan
|
||||||
|
if isinstance(flight_plan, StrikeFlightPlan):
|
||||||
|
if waypoint in flight_plan.targets and len(flight_plan.targets) > 1:
|
||||||
|
flight_plan.targets.remove(waypoint)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not isinstance(flight_plan, CustomFlightPlan):
|
||||||
|
flight_plan = CustomFlightPlan(
|
||||||
|
package=self.flight.package,
|
||||||
|
flight=self.flight,
|
||||||
|
custom_waypoints=flight_plan.waypoints
|
||||||
|
)
|
||||||
|
|
||||||
|
flight_plan.waypoints.remove(waypoint)
|
||||||
|
self.flight.flight_plan = flight_plan
|
||||||
|
|
||||||
def on_fast_waypoint(self):
|
def on_fast_waypoint(self):
|
||||||
self.subwindow = QPredefinedWaypointSelectionWindow(self.game, self.flight, self.flight_waypoint_list)
|
self.subwindow = QPredefinedWaypointSelectionWindow(self.game, self.flight, self.flight_waypoint_list)
|
||||||
self.subwindow.finished.connect(self.on_change)
|
self.subwindow.finished.connect(self.on_change)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user