mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
@@ -14,7 +14,9 @@ from PySide2.QtWidgets import (
|
||||
QVBoxLayout,
|
||||
)
|
||||
|
||||
from game.ato.flightplans.custom import CustomFlightPlan
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.squadrons import Pilot, Squadron
|
||||
from game.theater import ConflictTheater, ControlPoint
|
||||
from qt_ui.delegates import TwoColumnRowDelegate
|
||||
@@ -96,7 +98,8 @@ class SquadronDestinationComboBox(QComboBox):
|
||||
|
||||
room = squadron.location.unclaimed_parking()
|
||||
self.addItem(
|
||||
f"Remain at {squadron.location} (room for {room} more aircraft)", None
|
||||
f"Remain at {squadron.location} (room for {room} more aircraft)",
|
||||
squadron.location,
|
||||
)
|
||||
selected_index: Optional[int] = None
|
||||
for idx, destination in enumerate(sorted(self.iter_destinations(), key=str), 1):
|
||||
@@ -117,7 +120,7 @@ class SquadronDestinationComboBox(QComboBox):
|
||||
def iter_destinations(self) -> Iterator[ControlPoint]:
|
||||
size = self.squadron.expected_size_next_turn
|
||||
for control_point in self.theater.control_points_for(self.squadron.player):
|
||||
if control_point == self:
|
||||
if control_point == self.squadron.location:
|
||||
continue
|
||||
if not control_point.can_operate(self.squadron.aircraft):
|
||||
continue
|
||||
@@ -188,11 +191,25 @@ class SquadronDialog(QDialog):
|
||||
def squadron(self) -> Squadron:
|
||||
return self.squadron_model.squadron
|
||||
|
||||
def _instant_relocate(self, destination: ControlPoint) -> None:
|
||||
self.squadron.relocate_to(destination)
|
||||
for _, f in self.squadron.flight_db.objects.items():
|
||||
if f.squadron == self.squadron:
|
||||
if isinstance(f.flight_plan, CustomFlightPlan):
|
||||
for wpt in f.flight_plan.waypoints:
|
||||
if wpt.waypoint_type == FlightWaypointType.LANDING_POINT:
|
||||
wpt.control_point = destination
|
||||
wpt.position = wpt.control_point.position
|
||||
break
|
||||
f.recreate_flight_plan()
|
||||
|
||||
def on_destination_changed(self, index: int) -> None:
|
||||
with report_errors("Could not change squadron destination", self):
|
||||
destination = self.transfer_destination.itemData(index)
|
||||
if destination is None:
|
||||
if destination is self.squadron.location:
|
||||
self.squadron.cancel_relocation()
|
||||
elif self.ato_model.game.settings.enable_transfer_cheat:
|
||||
self._instant_relocate(destination)
|
||||
else:
|
||||
self.squadron.plan_relocation(destination)
|
||||
self.ato_model.replace_from_game(player=True)
|
||||
|
||||
Reference in New Issue
Block a user