dcs-retribution/qt_ui/windows/mission/QPlannedFlightsView.py
Dan Albert ff083942e8 Replace mission planning UI.
Mission planning has been completely redone. Missions are now planned
by right clicking the target area and choosing "New package".

A package can include multiple flights for the same objective. Right
now the automatic flight planner is only fragging single-flight
packages in the same manner that it used to, but that can be improved
now.

The air tasking order (ATO) is now the left bar of the main UI. This
shows every fragged package, and the flights in the selected package.
The info bar that was previously on the left is now a smaller bar at
the bottom of the screen. The old "Mission Planning" button is now
just the "Take Off" button.

The flight plan display no longer shows enemy flight plans. That could
be re-added if needed, probably with a difficulty/cheat option.

Aircraft inventories have been disassociated from the Planner class.
Aircraft inventories are now stored globally in the Game object.

Save games made prior to this update will not be compatible do to the
changes in how aircraft inventories and planned flights are stored.
2020-09-27 13:44:58 -07:00

47 lines
1.6 KiB
Python

from PySide2.QtCore import QItemSelectionModel, QSize
from PySide2.QtGui import QStandardItemModel
from PySide2.QtWidgets import QAbstractItemView, QListView
from qt_ui.models import GameModel
from qt_ui.windows.mission.QFlightItem import QFlightItem
from theater.controlpoint import ControlPoint
class QPlannedFlightsView(QListView):
def __init__(self, game_model: GameModel, cp: ControlPoint) -> None:
super(QPlannedFlightsView, self).__init__()
self.game_model = game_model
self.cp = cp
self.model = QStandardItemModel(self)
self.setModel(self.model)
self.flight_items = []
self.setIconSize(QSize(91, 24))
self.setSelectionBehavior(QAbstractItemView.SelectItems)
self.set_flight_planner()
def setup_content(self):
self.flight_items = []
for package in self.game_model.ato_model.packages:
for flight in package.flights:
if flight.from_cp == self.cp:
item = QFlightItem(flight)
self.model.appendRow(item)
self.flight_items.append(item)
self.set_selected_flight(0)
def set_selected_flight(self, row):
self.selectionModel().clearSelection()
index = self.model.index(row, 0)
if not index.isValid():
index = self.model.index(0, 0)
self.selectionModel().setCurrentIndex(index, QItemSelectionModel.Select)
self.repaint()
def clear_layout(self):
self.model.removeRows(0, self.model.rowCount())
def set_flight_planner(self) -> None:
self.clear_layout()
self.setup_content()