mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix custom waypoints.
Like with deleting waypoints, these will degrade the flight plan to the 2.1 behavior. Ascend/descend points aren't in use any more, so I removed those.
This commit is contained in:
@@ -44,7 +44,6 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
||||
i = 0
|
||||
|
||||
def add_model_item(i, model, name, wpt):
|
||||
print(name)
|
||||
item = QStandardItem(name)
|
||||
model.setItem(i, 0, item)
|
||||
self.wpts.append(wpt)
|
||||
@@ -79,7 +78,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
||||
0
|
||||
)
|
||||
wpt.alt_type = "RADIO"
|
||||
wpt.name = wpt.name = "[" + str(ground_object.obj_name) + "] : " + ground_object.category + " #" + str(ground_object.object_id)
|
||||
wpt.name = ground_object.waypoint_name
|
||||
wpt.pretty_name = wpt.name
|
||||
wpt.obj_name = ground_object.obj_name
|
||||
wpt.targets.append(ground_object)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
from typing import Iterable, List, Optional
|
||||
|
||||
from PySide2.QtCore import Signal
|
||||
from PySide2.QtWidgets import (
|
||||
@@ -39,8 +39,6 @@ class QFlightWaypointTab(QFrame):
|
||||
self.planner = FlightPlanBuilder(self.game, package, is_player=True)
|
||||
|
||||
self.flight_waypoint_list: Optional[QFlightWaypointList] = None
|
||||
self.ascend_waypoint: Optional[QPushButton] = None
|
||||
self.descend_waypoint: Optional[QPushButton] = None
|
||||
self.rtb_waypoint: Optional[QPushButton] = None
|
||||
self.delete_selected: Optional[QPushButton] = None
|
||||
self.open_fast_waypoint_button: Optional[QPushButton] = None
|
||||
@@ -74,14 +72,6 @@ class QFlightWaypointTab(QFrame):
|
||||
rlayout.addWidget(QLabel("<strong>Advanced : </strong>"))
|
||||
rlayout.addWidget(QLabel("<small>Do not use for AI flights</small>"))
|
||||
|
||||
self.ascend_waypoint = QPushButton("Add Ascend Waypoint")
|
||||
self.ascend_waypoint.clicked.connect(self.on_ascend_waypoint)
|
||||
rlayout.addWidget(self.ascend_waypoint)
|
||||
|
||||
self.descend_waypoint = QPushButton("Add Descend Waypoint")
|
||||
self.descend_waypoint.clicked.connect(self.on_descend_waypoint)
|
||||
rlayout.addWidget(self.descend_waypoint)
|
||||
|
||||
self.rtb_waypoint = QPushButton("Add RTB Waypoint")
|
||||
self.rtb_waypoint.clicked.connect(self.on_rtb_waypoint)
|
||||
rlayout.addWidget(self.rtb_waypoint)
|
||||
@@ -107,47 +97,43 @@ class QFlightWaypointTab(QFrame):
|
||||
# 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)
|
||||
if isinstance(self.flight.flight_plan, StrikeFlightPlan):
|
||||
is_target = waypoint in self.flight.flight_plan.targets
|
||||
if is_target and len(self.flight.flight_plan.targets) > 1:
|
||||
self.flight.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
|
||||
self.degrade_to_custom_flight_plan()
|
||||
self.flight.flight_plan.waypoints.remove(waypoint)
|
||||
|
||||
def on_fast_waypoint(self):
|
||||
self.subwindow = QPredefinedWaypointSelectionWindow(self.game, self.flight, self.flight_waypoint_list)
|
||||
self.subwindow.finished.connect(self.on_change)
|
||||
self.subwindow.waypoints_added.connect(self.on_waypoints_added)
|
||||
self.subwindow.show()
|
||||
|
||||
def on_ascend_waypoint(self):
|
||||
ascend = self.planner.generate_ascend_point(self.flight,
|
||||
self.flight.from_cp)
|
||||
self.flight.points.append(ascend)
|
||||
def on_waypoints_added(self, waypoints: Iterable[FlightWaypoint]) -> None:
|
||||
if not waypoints:
|
||||
return
|
||||
self.degrade_to_custom_flight_plan()
|
||||
self.flight.flight_plan.waypoints.extend(waypoints)
|
||||
self.flight_waypoint_list.update_list()
|
||||
self.on_change()
|
||||
|
||||
def on_rtb_waypoint(self):
|
||||
rtb = self.planner.generate_rtb_waypoint(self.flight,
|
||||
self.flight.from_cp)
|
||||
self.flight.points.append(rtb)
|
||||
self.degrade_to_custom_flight_plan()
|
||||
self.flight.flight_plan.waypoints.append(rtb)
|
||||
self.flight_waypoint_list.update_list()
|
||||
self.on_change()
|
||||
|
||||
def on_descend_waypoint(self):
|
||||
descend = self.planner.generate_descend_point(self.flight,
|
||||
self.flight.from_cp)
|
||||
self.flight.points.append(descend)
|
||||
self.flight_waypoint_list.update_list()
|
||||
self.on_change()
|
||||
def degrade_to_custom_flight_plan(self) -> None:
|
||||
if not isinstance(self.flight.flight_plan, CustomFlightPlan):
|
||||
self.flight.flight_plan = CustomFlightPlan(
|
||||
package=self.flight.package,
|
||||
flight=self.flight,
|
||||
custom_waypoints=self.flight.flight_plan.waypoints
|
||||
)
|
||||
|
||||
def confirm_recreate(self, task: FlightType) -> None:
|
||||
result = QMessageBox.question(
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
from PySide2.QtCore import Qt
|
||||
from PySide2.QtWidgets import QDialog, QLabel, QHBoxLayout, QVBoxLayout, QPushButton, QCheckBox
|
||||
from PySide2.QtCore import Qt, Signal
|
||||
from PySide2.QtWidgets import (
|
||||
QCheckBox,
|
||||
QDialog,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
)
|
||||
|
||||
from game import Game
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.combos.QPredefinedWaypointSelectionComboBox import QPredefinedWaypointSelectionComboBox
|
||||
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointInfoBox import QFlightWaypointInfoBox
|
||||
from qt_ui.widgets.combos.QPredefinedWaypointSelectionComboBox import \
|
||||
QPredefinedWaypointSelectionComboBox
|
||||
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointInfoBox import \
|
||||
QFlightWaypointInfoBox
|
||||
|
||||
PREDEFINED_WAYPOINT_CATEGORIES = [
|
||||
"Frontline (CAS AREA)",
|
||||
@@ -17,6 +26,8 @@ PREDEFINED_WAYPOINT_CATEGORIES = [
|
||||
|
||||
class QPredefinedWaypointSelectionWindow(QDialog):
|
||||
|
||||
# List of FlightWaypoint
|
||||
waypoints_added = Signal(list)
|
||||
|
||||
def __init__(self, game: Game, flight: Flight, flight_waypoint_list):
|
||||
super(QPredefinedWaypointSelectionWindow, self).__init__()
|
||||
@@ -44,7 +55,6 @@ class QPredefinedWaypointSelectionWindow(QDialog):
|
||||
|
||||
self.init_ui()
|
||||
self.on_select_wpt_changed()
|
||||
print("DONE")
|
||||
|
||||
|
||||
def init_ui(self):
|
||||
@@ -77,12 +87,5 @@ class QPredefinedWaypointSelectionWindow(QDialog):
|
||||
self.add_button.setDisabled(False)
|
||||
|
||||
def add_waypoint(self):
|
||||
|
||||
for wpt in self.selected_waypoints:
|
||||
self.flight.points.append(wpt)
|
||||
|
||||
self.flight_waypoint_list.update_list()
|
||||
self.waypoints_added.emit(self.selected_waypoints)
|
||||
self.close()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user