mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Simplify flight startup time calls.
We can always estimate a startup time now. Remove the nullability from the result, cleanup the callsites, and eliminate TotEstimator.mission_start_time since it no longer does anything useful.
This commit is contained in:
@@ -16,7 +16,6 @@ from game.ato.airtaaskingorder import AirTaskingOrder
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.package import Package
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from game.game import Game
|
||||
from game.server import EventStream
|
||||
from game.sim.gameupdateevents import GameUpdateEvents
|
||||
@@ -136,11 +135,11 @@ class PackageModel(QAbstractListModel):
|
||||
return flight
|
||||
return None
|
||||
|
||||
def text_for_flight(self, flight: Flight) -> str:
|
||||
@staticmethod
|
||||
def text_for_flight(flight: Flight) -> str:
|
||||
"""Returns the text that should be displayed for the flight."""
|
||||
estimator = TotEstimator(self.package)
|
||||
delay = datetime.timedelta(
|
||||
seconds=int(estimator.mission_start_time(flight).total_seconds())
|
||||
seconds=int(flight.flight_plan.startup_time().total_seconds())
|
||||
)
|
||||
origin = flight.from_cp.name
|
||||
return f"{flight} from {origin} in {delay}"
|
||||
|
||||
@@ -13,9 +13,9 @@ import qt_ui.uiconstants as CONST
|
||||
from game import Game, persistency
|
||||
from game.game import TurnState
|
||||
from game.ato.package import Package
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from game.profiling import logged_duration
|
||||
from game.utils import meters
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.simcontroller import SimController
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
@@ -168,9 +168,8 @@ class QTopPanel(QFrame):
|
||||
for package in self.game_model.ato_model.ato.packages:
|
||||
if not package.flights:
|
||||
continue
|
||||
estimator = TotEstimator(package)
|
||||
for flight in package.flights:
|
||||
if estimator.mission_start_time(flight).total_seconds() < 0:
|
||||
if flight.flight_plan.startup_time().total_seconds() < 0:
|
||||
packages.append(package)
|
||||
break
|
||||
return packages
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from PySide2.QtGui import QStandardItem, QIcon
|
||||
from PySide2.QtGui import QIcon, QStandardItem
|
||||
|
||||
from game.ato.package import Package
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from game.ato.package import Package
|
||||
from qt_ui.uiconstants import AIRCRAFT_ICONS
|
||||
|
||||
|
||||
@@ -17,6 +16,4 @@ class QFlightItem(QStandardItem):
|
||||
icon = QIcon((AIRCRAFT_ICONS[self.flight.unit_type.dcs_id]))
|
||||
self.setIcon(icon)
|
||||
self.setEditable(False)
|
||||
estimator = TotEstimator(self.package)
|
||||
delay = estimator.mission_start_time(flight)
|
||||
self.setText(f"{flight} in {delay}")
|
||||
self.setText(f"{flight} in {flight.flight_plan.startup_time()}")
|
||||
|
||||
@@ -4,10 +4,9 @@ from PySide2.QtCore import QItemSelectionModel, QSize
|
||||
from PySide2.QtGui import QStandardItemModel
|
||||
from PySide2.QtWidgets import QAbstractItemView, QListView
|
||||
|
||||
from game.theater.controlpoint import ControlPoint
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.windows.mission.QFlightItem import QFlightItem
|
||||
from game.theater.controlpoint import ControlPoint
|
||||
from game.ato.traveltime import TotEstimator
|
||||
|
||||
|
||||
class QPlannedFlightsView(QListView):
|
||||
@@ -52,4 +51,4 @@ class QPlannedFlightsView(QListView):
|
||||
|
||||
@staticmethod
|
||||
def mission_start_for_flight(flight_item: QFlightItem) -> timedelta:
|
||||
return TotEstimator(flight_item.package).mission_start_time(flight_item.flight)
|
||||
return flight_item.flight.flight_plan.startup_time()
|
||||
|
||||
@@ -5,7 +5,6 @@ from PySide2.QtWidgets import QGroupBox, QLabel, QMessageBox, QVBoxLayout
|
||||
from game import Game
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flightplans.planningerror import PlanningError
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from qt_ui.models import PackageModel
|
||||
from qt_ui.widgets.QLabeledWidget import QLabeledWidget
|
||||
from qt_ui.widgets.combos.QArrivalAirfieldSelector import QArrivalAirfieldSelector
|
||||
@@ -58,9 +57,7 @@ class FlightAirfieldDisplay(QGroupBox):
|
||||
# handler may be called for a flight whose package has been canceled, which
|
||||
# is an invalid state for calling anything in TotEstimator.
|
||||
return
|
||||
estimator = TotEstimator(self.package_model.package)
|
||||
delay = estimator.mission_start_time(self.flight)
|
||||
self.departure_time.setText(f"At T+{delay}")
|
||||
self.departure_time.setText(f"At T+{self.flight.flight_plan.startup_time()}")
|
||||
|
||||
def set_divert(self, index: int) -> None:
|
||||
old_divert = self.flight.divert
|
||||
|
||||
Reference in New Issue
Block a user