mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix custom waypoint addition/removal.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2063.
This commit is contained in:
parent
01f872c960
commit
be67d6dbc6
@ -71,10 +71,11 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
|||||||
pos = FrontLineConflictDescription.frontline_position(
|
pos = FrontLineConflictDescription.frontline_position(
|
||||||
front_line, self.game.theater
|
front_line, self.game.theater
|
||||||
)[0]
|
)[0]
|
||||||
|
wptname = f"Frontline {front_line.name} [CAS]"
|
||||||
wpt = FlightWaypoint(
|
wpt = FlightWaypoint(
|
||||||
FlightWaypointType.CUSTOM, pos, Distance.from_meters(800)
|
wptname, FlightWaypointType.CUSTOM, pos, Distance.from_meters(800)
|
||||||
)
|
)
|
||||||
wpt.name = f"Frontline {front_line.name} [CAS]"
|
|
||||||
wpt.alt_type = "RADIO"
|
wpt.alt_type = "RADIO"
|
||||||
wpt.pretty_name = wpt.name
|
wpt.pretty_name = wpt.name
|
||||||
wpt.description = "Frontline"
|
wpt.description = "Frontline"
|
||||||
@ -90,12 +91,12 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
|||||||
ground_object, BuildingGroundObject
|
ground_object, BuildingGroundObject
|
||||||
):
|
):
|
||||||
wpt = FlightWaypoint(
|
wpt = FlightWaypoint(
|
||||||
|
ground_object.waypoint_name,
|
||||||
FlightWaypointType.CUSTOM,
|
FlightWaypointType.CUSTOM,
|
||||||
ground_object.position,
|
ground_object.position,
|
||||||
Distance.from_meters(0),
|
Distance.from_meters(0),
|
||||||
)
|
)
|
||||||
wpt.alt_type = "RADIO"
|
wpt.alt_type = "RADIO"
|
||||||
wpt.name = ground_object.waypoint_name
|
|
||||||
wpt.pretty_name = wpt.name
|
wpt.pretty_name = wpt.name
|
||||||
wpt.obj_name = ground_object.obj_name
|
wpt.obj_name = ground_object.obj_name
|
||||||
wpt.targets.append(ground_object)
|
wpt.targets.append(ground_object)
|
||||||
@ -116,13 +117,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
|||||||
):
|
):
|
||||||
for g in ground_object.groups:
|
for g in ground_object.groups:
|
||||||
for j, u in enumerate(g.units):
|
for j, u in enumerate(g.units):
|
||||||
wpt = FlightWaypoint(
|
wptname = (
|
||||||
FlightWaypointType.CUSTOM,
|
|
||||||
u.position,
|
|
||||||
Distance.from_meters(0),
|
|
||||||
)
|
|
||||||
wpt.alt_type = "RADIO"
|
|
||||||
wpt.name = wpt.name = (
|
|
||||||
"["
|
"["
|
||||||
+ str(ground_object.obj_name)
|
+ str(ground_object.obj_name)
|
||||||
+ "] : "
|
+ "] : "
|
||||||
@ -130,7 +125,14 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
|||||||
+ " #"
|
+ " #"
|
||||||
+ str(j)
|
+ str(j)
|
||||||
)
|
)
|
||||||
wpt.pretty_name = wpt.name
|
wpt = FlightWaypoint(
|
||||||
|
wptname,
|
||||||
|
FlightWaypointType.CUSTOM,
|
||||||
|
u.position,
|
||||||
|
Distance.from_meters(0),
|
||||||
|
)
|
||||||
|
wpt.alt_type = "RADIO"
|
||||||
|
wpt.pretty_name = wptname
|
||||||
wpt.targets.append(u)
|
wpt.targets.append(u)
|
||||||
wpt.obj_name = ground_object.obj_name
|
wpt.obj_name = ground_object.obj_name
|
||||||
wpt.waypoint_type = FlightWaypointType.CUSTOM
|
wpt.waypoint_type = FlightWaypointType.CUSTOM
|
||||||
@ -146,10 +148,12 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
|||||||
self.include_friendly and cp.captured
|
self.include_friendly and cp.captured
|
||||||
):
|
):
|
||||||
wpt = FlightWaypoint(
|
wpt = FlightWaypoint(
|
||||||
FlightWaypointType.CUSTOM, cp.position, Distance.from_meters(0)
|
cp.name,
|
||||||
|
FlightWaypointType.CUSTOM,
|
||||||
|
cp.position,
|
||||||
|
Distance.from_meters(0),
|
||||||
)
|
)
|
||||||
wpt.alt_type = "RADIO"
|
wpt.alt_type = "RADIO"
|
||||||
wpt.name = cp.name
|
|
||||||
if cp.captured:
|
if cp.captured:
|
||||||
wpt.description = (
|
wpt.description = (
|
||||||
"Position of " + cp.name + " [Friendly Airbase]"
|
"Position of " + cp.name + " [Friendly Airbase]"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import Iterable, List, Optional
|
from typing import Iterable, List, Optional, Any
|
||||||
|
|
||||||
from PySide2.QtCore import Signal
|
from PySide2.QtCore import Signal
|
||||||
from PySide2.QtWidgets import (
|
from PySide2.QtWidgets import (
|
||||||
@ -13,7 +13,8 @@ from PySide2.QtWidgets import (
|
|||||||
|
|
||||||
from game import Game
|
from game import Game
|
||||||
from game.ato.flight import Flight
|
from game.ato.flight import Flight
|
||||||
from game.ato.flightplans.custom import CustomFlightPlan
|
from game.ato.flightplans.custom import CustomFlightPlan, CustomLayout
|
||||||
|
from game.ato.flightplans.flightplan import FlightPlan
|
||||||
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
|
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
|
||||||
from game.ato.flightplans.formationattack import FormationAttackFlightPlan
|
from game.ato.flightplans.formationattack import FormationAttackFlightPlan
|
||||||
from game.ato.flightplans.planningerror import PlanningError
|
from game.ato.flightplans.planningerror import PlanningError
|
||||||
@ -113,7 +114,7 @@ class QFlightWaypointTab(QFrame):
|
|||||||
|
|
||||||
self.degrade_to_custom_flight_plan()
|
self.degrade_to_custom_flight_plan()
|
||||||
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
||||||
self.flight.flight_plan.custom_waypoints.remove(waypoint)
|
self.flight.flight_plan.layout.custom_waypoints.remove(waypoint)
|
||||||
|
|
||||||
def on_fast_waypoint(self):
|
def on_fast_waypoint(self):
|
||||||
self.subwindow = QPredefinedWaypointSelectionWindow(
|
self.subwindow = QPredefinedWaypointSelectionWindow(
|
||||||
@ -127,7 +128,7 @@ class QFlightWaypointTab(QFrame):
|
|||||||
return
|
return
|
||||||
self.degrade_to_custom_flight_plan()
|
self.degrade_to_custom_flight_plan()
|
||||||
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
||||||
self.flight.flight_plan.custom_waypoints.extend(waypoints)
|
self.flight.flight_plan.layout.custom_waypoints.extend(waypoints)
|
||||||
self.flight_waypoint_list.update_list()
|
self.flight_waypoint_list.update_list()
|
||||||
self.on_change()
|
self.on_change()
|
||||||
|
|
||||||
@ -135,15 +136,14 @@ class QFlightWaypointTab(QFrame):
|
|||||||
rtb = self.planner.generate_rtb_waypoint(self.flight, self.flight.from_cp)
|
rtb = self.planner.generate_rtb_waypoint(self.flight, self.flight.from_cp)
|
||||||
self.degrade_to_custom_flight_plan()
|
self.degrade_to_custom_flight_plan()
|
||||||
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
||||||
self.flight.flight_plan.custom_waypoints.append(rtb)
|
self.flight.flight_plan.layout.custom_waypoints.append(rtb)
|
||||||
self.flight_waypoint_list.update_list()
|
self.flight_waypoint_list.update_list()
|
||||||
self.on_change()
|
self.on_change()
|
||||||
|
|
||||||
def degrade_to_custom_flight_plan(self) -> None:
|
def degrade_to_custom_flight_plan(self) -> None:
|
||||||
if not isinstance(self.flight.flight_plan, CustomFlightPlan):
|
if not isinstance(self.flight.flight_plan, CustomFlightPlan):
|
||||||
self.flight.flight_plan = CustomFlightPlan(
|
self.flight.flight_plan: FlightPlan[Any] = CustomFlightPlan(
|
||||||
flight=self.flight,
|
self, CustomLayout(custom_waypoints=self.flight.flight_plan.waypoints)
|
||||||
waypoints=self.flight.flight_plan.waypoints,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def confirm_recreate(self, task: FlightType) -> None:
|
def confirm_recreate(self, task: FlightType) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user