Add UI for TOT offset adjustment.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2912.
This commit is contained in:
Dan Albert 2023-05-25 22:19:19 -07:00 committed by Raffson
parent 7a57bd3ee0
commit 0acf970443
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 60 additions and 7 deletions

View File

@ -131,6 +131,15 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions
* **[Mission Generation]** Kneeboard STRIKE coordinates would sometimes get clipped when not fitting.
* **[UI]** Fix exception when trying to add a waypoints to a flightplan.
# 7.1.0
## Features/Improvements
* **[Mission Planning]** Per-flight TOT offsets can now be set in the flight details UI. This allows individual flights to be scheduled ahead of or behind the rest of the package.
## Fixes
# Liberation:
# 7.0.0

View File

@ -1,6 +1,16 @@
import logging
from datetime import timedelta
from PySide2.QtWidgets import QGroupBox, QLabel, QMessageBox, QVBoxLayout
from PySide2.QtCore import QTime
from PySide2.QtWidgets import (
QGroupBox,
QLabel,
QMessageBox,
QVBoxLayout,
QTimeEdit,
QHBoxLayout,
QCheckBox,
)
from game import Game
from game.ato.flight import Flight
@ -10,9 +20,9 @@ from qt_ui.widgets.QLabeledWidget import QLabeledWidget
from qt_ui.widgets.combos.QArrivalAirfieldSelector import QArrivalAirfieldSelector
class FlightAirfieldDisplay(QGroupBox):
class FlightPlanPropertiesGroup(QGroupBox):
def __init__(self, game: Game, package_model: PackageModel, flight: Flight) -> None:
super().__init__("Departure/Arrival")
super().__init__("Flight plan properties")
self.game = game
self.package_model = package_model
self.flight = flight
@ -28,6 +38,31 @@ class FlightAirfieldDisplay(QGroupBox):
self.package_model.tot_changed.connect(self.update_departure_time)
self.update_departure_time()
tot_offset_layout = QHBoxLayout()
layout.addLayout(tot_offset_layout)
delay = int(self.flight.flight_plan.tot_offset.total_seconds())
negative = delay < 0
if negative:
delay = -delay
hours = delay // 3600
minutes = delay // 60 % 60
seconds = delay % 60
tot_offset_layout.addWidget(QLabel("TOT Offset (minutes:seconds)"))
tot_offset_layout.addStretch()
negative_offset_checkbox = QCheckBox("Ahead of package")
negative_offset_checkbox.setChecked(negative)
negative_offset_checkbox.toggled.connect(self.toggle_negative_offset)
tot_offset_layout.addWidget(negative_offset_checkbox)
self.tot_offset_spinner = QTimeEdit(QTime(hours, minutes, seconds))
self.tot_offset_spinner.setMaximumTime(QTime(59, 0))
self.tot_offset_spinner.setDisplayFormat("mm:ss")
self.tot_offset_spinner.timeChanged.connect(self.set_tot_offset)
self.tot_offset_spinner.setToolTip("Flight TOT offset from package TOT")
tot_offset_layout.addWidget(self.tot_offset_spinner)
layout.addWidget(
QLabel(
"Determined based on the package TOT. Edit the "
@ -74,3 +109,13 @@ class FlightAirfieldDisplay(QGroupBox):
QMessageBox.critical(
self, "Could not update flight plan", str(ex), QMessageBox.Ok
)
def set_tot_offset(self, offset: QTime) -> None:
self.flight.flight_plan.tot_offset = timedelta(
hours=offset.hour(), minutes=offset.minute(), seconds=offset.second()
)
self.update_departure_time()
def toggle_negative_offset(self) -> None:
self.flight.flight_plan.tot_offset = -self.flight.flight_plan.tot_offset
self.update_departure_time()

View File

@ -1,11 +1,10 @@
from PySide2.QtCore import Signal
from PySide2.QtWidgets import QFrame, QGridLayout, QVBoxLayout
from game import Game
from game.ato.flight import Flight
from qt_ui.models import PackageModel, GameModel
from qt_ui.windows.mission.flight.settings.FlightAirfieldDisplay import (
FlightAirfieldDisplay,
from qt_ui.windows.mission.flight.settings.FlightPlanPropertiesGroup import (
FlightPlanPropertiesGroup,
)
from qt_ui.windows.mission.flight.settings.QCommsEditor import QCommsEditor
from qt_ui.windows.mission.flight.settings.QCustomName import QFlightCustomName
@ -25,7 +24,7 @@ class QGeneralFlightSettingsTab(QFrame):
widgets = [
QFlightTypeTaskInfo(flight),
QCommsEditor(flight, game),
FlightAirfieldDisplay(game.game, package_model, flight),
FlightPlanPropertiesGroup(game.game, package_model, flight),
QFlightSlotEditor(package_model, flight, game.game),
QFlightStartType(package_model, flight),
QFlightCustomName(flight),