mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
89 lines
2.9 KiB
Python
89 lines
2.9 KiB
Python
from PySide2.QtCore import Qt
|
|
from PySide2.QtWidgets import QDialog, QLabel, QHBoxLayout, QVBoxLayout, QPushButton, QCheckBox
|
|
|
|
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
|
|
|
|
PREDEFINED_WAYPOINT_CATEGORIES = [
|
|
"Frontline (CAS AREA)",
|
|
"Building",
|
|
"Units",
|
|
"Airbase"
|
|
]
|
|
|
|
|
|
class QPredefinedWaypointSelectionWindow(QDialog):
|
|
|
|
|
|
def __init__(self, game: Game, flight: Flight, flight_waypoint_list):
|
|
super(QPredefinedWaypointSelectionWindow, self).__init__()
|
|
self.game = game
|
|
self.flight = flight
|
|
self.setWindowFlags(Qt.WindowStaysOnTopHint)
|
|
self.setMinimumSize(400, 250)
|
|
self.setModal(True)
|
|
self.setWindowTitle("Add Predefined Waypoint")
|
|
self.setWindowIcon(EVENT_ICONS["strike"])
|
|
self.flight_waypoint_list = flight_waypoint_list
|
|
|
|
self.wpt_selection_box = QPredefinedWaypointSelectionComboBox(self.game)
|
|
self.wpt_selection_box.setMinimumWidth(200)
|
|
self.wpt_selection_box.currentTextChanged.connect(self.on_select_wpt_changed)
|
|
self.selected_waypoints = []
|
|
self.wpt_info = QFlightWaypointInfoBox()
|
|
|
|
self.add_button = QPushButton("Add")
|
|
self.add_button.clicked.connect(self.add_waypoint)
|
|
|
|
self.include_all = QCheckBox()
|
|
self.include_all.stateChanged.connect(self.on_select_wpt_changed)
|
|
self.include_all.setChecked(True)
|
|
|
|
self.init_ui()
|
|
self.on_select_wpt_changed()
|
|
print("DONE")
|
|
|
|
|
|
def init_ui(self):
|
|
layout = QVBoxLayout()
|
|
|
|
wpt_layout = QHBoxLayout()
|
|
wpt_layout.addWidget(QLabel("Waypoint : "))
|
|
wpt_layout.addWidget(self.wpt_selection_box)
|
|
wpt_layout.addStretch()
|
|
|
|
include_all = QHBoxLayout()
|
|
include_all.addWidget(QLabel("Include all objects from the same location : "))
|
|
include_all.addWidget(self.include_all)
|
|
include_all.addStretch()
|
|
|
|
layout.addLayout(wpt_layout)
|
|
layout.addWidget(self.wpt_info)
|
|
layout.addLayout(include_all)
|
|
layout.addStretch()
|
|
layout.addWidget(self.add_button)
|
|
|
|
self.setLayout(layout)
|
|
|
|
def on_select_wpt_changed(self):
|
|
self.selected_waypoints = self.wpt_selection_box.get_selected_waypoints(self.include_all.isChecked())
|
|
if self.selected_waypoints is None or len(self.selected_waypoints) <= 0:
|
|
self.add_button.setDisabled(True)
|
|
else:
|
|
self.wpt_info.set_flight_waypoint(self.selected_waypoints[0])
|
|
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.close()
|
|
|
|
|
|
|