mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Deepcopy of waypoints for cloned flights
This commit is contained in:
parent
9a55b4de1c
commit
b2315efb6c
@ -1,8 +1,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from copy import deepcopy
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Literal, TYPE_CHECKING
|
from typing import Literal, TYPE_CHECKING, Any, Dict, Optional
|
||||||
|
|
||||||
from dcs import Point
|
from dcs import Point
|
||||||
|
|
||||||
@ -56,3 +57,17 @@ class FlightWaypoint:
|
|||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return hash(id(self))
|
return hash(id(self))
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo: Optional[Dict[int, Any]] = None) -> FlightWaypoint:
|
||||||
|
obj = FlightWaypoint(self.name, self.waypoint_type, self.position)
|
||||||
|
for attr in dir(self):
|
||||||
|
if attr == "control_point":
|
||||||
|
obj.control_point = self.control_point
|
||||||
|
elif attr == "targets":
|
||||||
|
obj.targets = self.targets
|
||||||
|
elif "__" in attr or attr not in obj.__dataclass_fields__:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
attr_copy = deepcopy(getattr(self, attr))
|
||||||
|
setattr(obj, attr, attr_copy)
|
||||||
|
return obj
|
||||||
|
|||||||
@ -235,6 +235,7 @@ class Package(RadioFrequencyContainer):
|
|||||||
clone.time_over_target = deepcopy(package.time_over_target)
|
clone.time_over_target = deepcopy(package.time_over_target)
|
||||||
for f in package.flights:
|
for f in package.flights:
|
||||||
cf = Flight.clone_flight(f)
|
cf = Flight.clone_flight(f)
|
||||||
|
cf.flight_plan.layout = deepcopy(f.flight_plan.layout)
|
||||||
cf.package = clone
|
cf.package = clone
|
||||||
clone.add_flight(cf)
|
clone.add_flight(cf)
|
||||||
return clone
|
return clone
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
"""Widgets for displaying air tasking orders."""
|
"""Widgets for displaying air tasking orders."""
|
||||||
import logging
|
import logging
|
||||||
|
from copy import deepcopy
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from PySide6.QtCore import (
|
from PySide6.QtCore import (
|
||||||
@ -143,6 +144,7 @@ class QFlightList(QListView):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
self.package_model.add_flight(clone)
|
self.package_model.add_flight(clone)
|
||||||
|
clone.flight_plan.layout = deepcopy(flight.flight_plan.layout)
|
||||||
EventStream.put_nowait(GameUpdateEvents().new_flight(clone))
|
EventStream.put_nowait(GameUpdateEvents().new_flight(clone))
|
||||||
|
|
||||||
def cancel_or_abort_flight(self, index: QModelIndex) -> None:
|
def cancel_or_abort_flight(self, index: QModelIndex) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user