diff --git a/game/dcs/aircrafttype.py b/game/dcs/aircrafttype.py index 1ed162b0..7232f1a1 100644 --- a/game/dcs/aircrafttype.py +++ b/game/dcs/aircrafttype.py @@ -95,6 +95,7 @@ class AircraftType(UnitType[FlyingType]): carrier_capable: bool lha_capable: bool always_keeps_gun: bool + max_group_size: int intra_flight_radio: Optional[Radio] channel_allocator: Optional[RadioChannelAllocator] channel_namer: Type[ChannelNamer] @@ -142,6 +143,12 @@ class AircraftType(UnitType[FlyingType]): def channel_name(self, radio_id: int, channel_id: int) -> str: return self.channel_namer.channel_name(radio_id, channel_id) + def __setstate__(self, state: dict[str, Any]) -> None: + # Update any existing models with new data on load. + updated = AircraftType.named(state["name"]) + state.update(updated.__dict__) + self.__dict__.update(state) + @classmethod def register(cls, aircraft_type: AircraftType) -> None: cls._by_name[aircraft_type.name] = aircraft_type @@ -206,6 +213,7 @@ class AircraftType(UnitType[FlyingType]): carrier_capable=data.get("carrier_capable", False), lha_capable=data.get("lha_capable", False), always_keeps_gun=data.get("always_keeps_gun", False), + max_group_size=data.get("max_group_size", aircraft.group_size_max), intra_flight_radio=radio_config.intra_flight, channel_allocator=radio_config.channel_allocator, channel_namer=radio_config.channel_namer, diff --git a/qt_ui/windows/mission/flight/QFlightCreator.py b/qt_ui/windows/mission/flight/QFlightCreator.py index 0e8293a1..1faac790 100644 --- a/qt_ui/windows/mission/flight/QFlightCreator.py +++ b/qt_ui/windows/mission/flight/QFlightCreator.py @@ -1,4 +1,3 @@ -import logging from typing import Optional, Type from PySide2.QtCore import Qt, Signal @@ -260,7 +259,12 @@ class QFlightCreator(QDialog): ) def update_max_size(self, available: int) -> None: - self.flight_size_spinner.setMaximum(min(available, 4)) + aircraft = self.aircraft_selector.currentData() + if aircraft is None: + self.flight_size_spinner.setMaximum(0) + return + + self.flight_size_spinner.setMaximum(min(available, aircraft.max_group_size)) + if self.flight_size_spinner.maximum() >= 2: - if self.flight_size_spinner.value() < 2: - self.flight_size_spinner.setValue(2) + self.flight_size_spinner.setValue(2) diff --git a/resources/units/aircraft/A-50.yaml b/resources/units/aircraft/A-50.yaml index b7de7170..0f4af5d9 100644 --- a/resources/units/aircraft/A-50.yaml +++ b/resources/units/aircraft/A-50.yaml @@ -1,4 +1,5 @@ description: The A-50 is an AWACS plane. +max_group_size: 1 price: 50 variants: A-50: null diff --git a/resources/units/aircraft/E-2C.yaml b/resources/units/aircraft/E-2C.yaml index dcc0b9fc..8cd9a2f1 100644 --- a/resources/units/aircraft/E-2C.yaml +++ b/resources/units/aircraft/E-2C.yaml @@ -1,5 +1,7 @@ carrier_capable: true -description: The Northrop Grumman E-2 Hawkeye is an American all-weather, carrier-capable +max_group_size: 1 +description: + The Northrop Grumman E-2 Hawkeye is an American all-weather, carrier-capable tactical airborne early warning (AEW) aircraft. introduced: 1973 manufacturer: Northrop Grumman diff --git a/resources/units/aircraft/E-3A.yaml b/resources/units/aircraft/E-3A.yaml index 8d51bdda..af277724 100644 --- a/resources/units/aircraft/E-3A.yaml +++ b/resources/units/aircraft/E-3A.yaml @@ -1,4 +1,5 @@ description: The E-3A is a AWACS aicraft. price: 50 +max_group_size: 1 variants: E-3A: null diff --git a/resources/units/aircraft/IL-78M.yaml b/resources/units/aircraft/IL-78M.yaml index a07be082..2cddc0f0 100644 --- a/resources/units/aircraft/IL-78M.yaml +++ b/resources/units/aircraft/IL-78M.yaml @@ -1,3 +1,4 @@ price: 20 +max_group_size: 1 variants: IL-78M: null diff --git a/resources/units/aircraft/KC-135.yaml b/resources/units/aircraft/KC-135.yaml index 3aa3f31a..91db8626 100644 --- a/resources/units/aircraft/KC-135.yaml +++ b/resources/units/aircraft/KC-135.yaml @@ -1,6 +1,9 @@ -description: The Boeing KC-135 Stratotanker is a military aerial refueling aircraft - that was developed from the Boeing 367-80 prototype, alongside the Boeing 707 airliner. +description: + The Boeing KC-135 Stratotanker is a military aerial refueling aircraft that + was developed from the Boeing 367-80 prototype, alongside the Boeing 707 + airliner. introduced: 1957 +max_group_size: 1 manufacturer: Beoing origin: USA price: 25 diff --git a/resources/units/aircraft/S-3B.yaml b/resources/units/aircraft/S-3B.yaml index ddcd4f65..e457bdaa 100644 --- a/resources/units/aircraft/S-3B.yaml +++ b/resources/units/aircraft/S-3B.yaml @@ -1,5 +1,6 @@ carrier_capable: true -description: The Lockheed S-3 Viking is a 4-crew, twin-engine turbofan-powered jet +description: + The Lockheed S-3 Viking is a 4-crew, twin-engine turbofan-powered jet aircraft that was used by the U.S. Navy (USN) primarily for anti-submarine warfare. In the late 1990s, the S-3B's mission focus shifted to surface warfare and aerial refueling. The Viking also provided electronic warfare and surface surveillance @@ -14,6 +15,7 @@ introduced: 1984 manufacturer: Lockheed origin: USA price: 10 +max_group_size: 1 role: Carrier-based Attack variants: S-3B Viking: {}