mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add arrival/divert airfield selection.
Breaks save compat because it adds new fields to `Flight` that have no constant default. Removing all of our other save compat at the same time. Note that player flights with a divert point will have a nav point for their actual landing point. This is because we place the divert point last, and DCS won't let us have a land point anywhere but the final waypoint. It would allow a LandingReFuAr point, but they're only generated for player flights anyway so it doesn't really matter. Fixes https://github.com/Khopa/dcs_liberation/issues/342
This commit is contained in:
47
qt_ui/widgets/combos/QArrivalAirfieldSelector.py
Normal file
47
qt_ui/widgets/combos/QArrivalAirfieldSelector.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""Combo box for selecting a departure airfield."""
|
||||
from typing import Iterable
|
||||
|
||||
from PySide2.QtWidgets import QComboBox
|
||||
from dcs.planes import PlaneType
|
||||
|
||||
from game import db
|
||||
from game.theater.controlpoint import ControlPoint
|
||||
|
||||
|
||||
class QArrivalAirfieldSelector(QComboBox):
|
||||
"""A combo box for selecting a flight's arrival or divert airfield.
|
||||
|
||||
The combo box will automatically be populated with all airfields the given
|
||||
aircraft type is able to land at.
|
||||
"""
|
||||
|
||||
def __init__(self, destinations: Iterable[ControlPoint],
|
||||
aircraft: PlaneType, optional_text: str) -> None:
|
||||
super().__init__()
|
||||
self.destinations = list(destinations)
|
||||
self.aircraft = aircraft
|
||||
self.optional_text = optional_text
|
||||
self.rebuild_selector()
|
||||
self.setCurrentIndex(0)
|
||||
|
||||
def change_aircraft(self, aircraft: PlaneType) -> None:
|
||||
if self.aircraft == aircraft:
|
||||
return
|
||||
self.aircraft = aircraft
|
||||
self.rebuild_selector()
|
||||
|
||||
def valid_destination(self, destination: ControlPoint) -> bool:
|
||||
if destination.is_carrier and self.aircraft not in db.CARRIER_CAPABLE:
|
||||
return False
|
||||
if destination.is_lha and self.aircraft not in db.LHA_CAPABLE:
|
||||
return False
|
||||
return True
|
||||
|
||||
def rebuild_selector(self) -> None:
|
||||
self.clear()
|
||||
for destination in self.destinations:
|
||||
if self.valid_destination(destination):
|
||||
self.addItem(destination.name, destination)
|
||||
self.model().sort(0)
|
||||
self.insertItem(0, self.optional_text, None)
|
||||
self.update()
|
||||
@@ -373,6 +373,10 @@ class QLiberationMap(QGraphicsView):
|
||||
FlightWaypointType.TARGET_SHIP,
|
||||
)
|
||||
for idx, point in enumerate(flight.flight_plan.waypoints[1:]):
|
||||
if point.waypoint_type == FlightWaypointType.DIVERT:
|
||||
# Don't clutter the map showing divert points.
|
||||
continue
|
||||
|
||||
new_pos = self._transform_point(Point(point.x, point.y))
|
||||
self.draw_flight_path(scene, prev_pos, new_pos, is_player,
|
||||
selected)
|
||||
@@ -386,7 +390,6 @@ class QLiberationMap(QGraphicsView):
|
||||
self.draw_waypoint_info(scene, idx + 1, point, new_pos,
|
||||
flight.flight_plan)
|
||||
prev_pos = tuple(new_pos)
|
||||
self.draw_flight_path(scene, prev_pos, pos, is_player, selected)
|
||||
|
||||
def draw_waypoint(self, scene: QGraphicsScene, position: Tuple[int, int],
|
||||
player: bool, selected: bool) -> None:
|
||||
|
||||
Reference in New Issue
Block a user