mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Added possibility to setup parking slot type for players' flight.
This commit is contained in:
parent
adf1f8db8c
commit
27e3cf8ac5
@ -330,15 +330,31 @@ class AircraftConflictGenerator:
|
||||
|
||||
def generate_planned_flight(self, cp, country, flight:Flight):
|
||||
try:
|
||||
group = self._generate_at_airport(
|
||||
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
||||
side=country,
|
||||
unit_type=flight.unit_type,
|
||||
count=flight.count,
|
||||
client_count=0,
|
||||
airport=self.m.terrain.airport_by_id(cp.at.id),
|
||||
start_type=StartType.Runway)
|
||||
if flight.start_type == "In Flight" or flight.client_count == 0:
|
||||
group = self._generate_group(
|
||||
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
||||
side=country,
|
||||
unit_type=flight.unit_type,
|
||||
count=flight.count,
|
||||
client_count=0,
|
||||
at=cp.position)
|
||||
else:
|
||||
st = StartType.Runway
|
||||
if flight.start_type == "Cold":
|
||||
st = StartType.Cold
|
||||
elif flight.start_type == "Warm":
|
||||
st = StartType.Warm
|
||||
|
||||
group = self._generate_at_airport(
|
||||
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
||||
side=country,
|
||||
unit_type=flight.unit_type,
|
||||
count=flight.count,
|
||||
client_count=0,
|
||||
airport=self.m.terrain.airport_by_id(cp.at.id),
|
||||
start_type=st)
|
||||
except Exception:
|
||||
# Generated when there is no place on Runway or on Parking Slots
|
||||
group = self._generate_group(
|
||||
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
||||
side=country,
|
||||
@ -348,6 +364,7 @@ class AircraftConflictGenerator:
|
||||
at=cp.position)
|
||||
group.points[0].alt = 1500
|
||||
group.points[0].ETA = flight.scheduled_in * 60
|
||||
|
||||
return group
|
||||
|
||||
def setup_group_as_intercept_flight(self, group, flight):
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
from dcs.mission import StartType
|
||||
from dcs.unittype import UnitType
|
||||
|
||||
from game import db
|
||||
@ -51,6 +52,7 @@ class Flight:
|
||||
use_custom_loadout = False
|
||||
loadout = {}
|
||||
preset_loadout_name = ""
|
||||
start_type = "Runway"
|
||||
|
||||
# How long before this flight should take off
|
||||
scheduled_in = 0
|
||||
@ -63,6 +65,7 @@ class Flight:
|
||||
self.points = []
|
||||
self.targets = []
|
||||
self.loadout = {}
|
||||
self.start_type = "Runway"
|
||||
|
||||
def __repr__(self):
|
||||
return self.flight_type.name + " | " + str(self.count) + "x" + db.unit_type_name(self.unit_type) \
|
||||
|
||||
@ -15,7 +15,7 @@ class QMissionPlanning(QDialog):
|
||||
super(QMissionPlanning, self).__init__()
|
||||
self.game = game
|
||||
self.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||
self.setMinimumSize(750, 350)
|
||||
self.setMinimumSize(750, 420)
|
||||
self.setModal(True)
|
||||
self.setWindowTitle("Mission Preparation")
|
||||
self.setWindowIcon(EVENT_ICONS[StrikeEvent])
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
from PySide2.QtCore import Signal
|
||||
from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QSpinBox, QGridLayout
|
||||
|
||||
|
||||
class QFlightSlotEditor(QGroupBox):
|
||||
|
||||
changed = Signal()
|
||||
|
||||
def __init__(self, flight, game):
|
||||
super(QFlightSlotEditor, self).__init__("Slots")
|
||||
self.flight = flight
|
||||
self.game = game
|
||||
|
||||
layout = QGridLayout()
|
||||
|
||||
self.aircraft_count = QLabel("Aircraft count :")
|
||||
@ -38,11 +40,13 @@ class QFlightSlotEditor(QGroupBox):
|
||||
|
||||
def _changed_aircraft_count(self):
|
||||
self.flight.count = int(self.aircraft_count_spinner.value())
|
||||
self.changed.emit()
|
||||
# TODO check if enough aircraft are available
|
||||
|
||||
def _changed_client_count(self):
|
||||
self.flight.client_count = int(self.client_count_spinner.value())
|
||||
self._cap_client_count()
|
||||
self.changed.emit()
|
||||
|
||||
def _cap_client_count(self):
|
||||
if self.flight.client_count > self.flight.count:
|
||||
|
||||
33
qt_ui/windows/mission/flight/settings/QFlightStartType.py
Normal file
33
qt_ui/windows/mission/flight/settings/QFlightStartType.py
Normal file
@ -0,0 +1,33 @@
|
||||
from PySide2.QtWidgets import QGroupBox, QHBoxLayout, QComboBox, QLabel
|
||||
from dcs.mission import StartType
|
||||
|
||||
from gen.flights.flight import Flight
|
||||
|
||||
|
||||
class QFlightStartType(QGroupBox):
|
||||
|
||||
def __init__(self, flight:Flight):
|
||||
super(QFlightStartType, self).__init__()
|
||||
|
||||
self.flight = flight
|
||||
|
||||
self.layout = QHBoxLayout()
|
||||
self.start_type_label = QLabel("Start type : ")
|
||||
self.start_type = QComboBox()
|
||||
|
||||
for i, st in enumerate([b for b in ["Cold", "Warm", "Runway", "In Flight"]]):
|
||||
self.start_type.addItem(st, st)
|
||||
if flight.start_type == st:
|
||||
self.start_type.setCurrentIndex(i)
|
||||
|
||||
self.start_type.currentTextChanged.connect(self._on_start_type_selected)
|
||||
self.layout.addWidget(self.start_type_label)
|
||||
self.layout.addWidget(self.start_type)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def _on_start_type_selected(self):
|
||||
selected = self.start_type.currentData()
|
||||
self.flight.start_type = selected
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ from gen.flights.flight import Flight
|
||||
from game import Game
|
||||
from qt_ui.windows.mission.flight.settings.QFlightDepartureEditor import QFlightDepartureEditor
|
||||
from qt_ui.windows.mission.flight.settings.QFlightSlotEditor import QFlightSlotEditor
|
||||
from qt_ui.windows.mission.flight.settings.QFlightStartType import QFlightStartType
|
||||
from qt_ui.windows.mission.flight.settings.QFlightTypeTaskInfo import QFlightTypeTaskInfo
|
||||
|
||||
|
||||
@ -20,10 +21,15 @@ class QGeneralFlightSettingsTab(QFrame):
|
||||
self.flight_info = QFlightTypeTaskInfo(self.flight)
|
||||
self.flight_departure = QFlightDepartureEditor(self.flight)
|
||||
self.flight_slots = QFlightSlotEditor(self.flight, self.game)
|
||||
self.flight_start_type = QFlightStartType(self.flight)
|
||||
layout.addWidget(self.flight_info, 0, 0)
|
||||
layout.addWidget(self.flight_departure, 1, 0)
|
||||
layout.addWidget(self.flight_slots, 2, 0)
|
||||
layout.addWidget(self.flight_start_type, 3, 0)
|
||||
vstretch = QVBoxLayout()
|
||||
vstretch.addStretch()
|
||||
layout.addLayout(vstretch, 3, 0)
|
||||
self.setLayout(layout)
|
||||
|
||||
self.flight_start_type.setEnabled(self.flight.client_count > 0)
|
||||
self.flight_slots.changed.connect(lambda: self.flight_start_type.setEnabled(self.flight.client_count > 0))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user