From 03c48376c4614410a3b6109be35345bb9dd95f1b Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 17 Apr 2023 19:21:10 -0700 Subject: [PATCH] Disallow squadrons from disabling mission types. After this change, players will always have the final say in what missions a squadron can be assigned to. Squadrons are not able to influence the default auto-assignable missions either because that property is always overridden by the campaign's air wing configuration (the primary and secondary task properties). The `mission-types` field of the squadron definition has been removed since it is no longer capable of influencing anything. I haven't bothered cleaning up the now useless data in all the existing squadrons though. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2785. --- changelog.md | 2 ++ game/squadrons/airwing.py | 2 +- game/squadrons/squadrondef.py | 5 +--- qt_ui/windows/AirWingConfigurationDialog.py | 28 ++++--------------- qt_ui/windows/SquadronDialog.py | 11 ++++---- .../mission/flight/SquadronSelector.py | 2 +- 6 files changed, 16 insertions(+), 34 deletions(-) diff --git a/changelog.md b/changelog.md index fc2d62b6..203ff5fb 100644 --- a/changelog.md +++ b/changelog.md @@ -136,6 +136,8 @@ Saves from 6.x are not compatible with 7.0. * **[Modding]** Updated Community A-4E-C mod version support to 2.1.0 release. * **[Modding]** Add support for VSN F-4B and F-4C mod. * **[Modding]** Aircraft task capabilities and preferred aircraft for each task are now moddable in the aircraft unit yaml files. Each aircraft has a weight per task. Higher weights are given higher preference. +* **[Modding]** The `mission_types` field in squadron files has been removed. Squadron task capability is now determined by airframe, and the auto-assignable list has always been overridden by the campaign settings. +* **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences. ## Fixes diff --git a/game/squadrons/airwing.py b/game/squadrons/airwing.py index 7b0093e4..c8948a66 100644 --- a/game/squadrons/airwing.py +++ b/game/squadrons/airwing.py @@ -2,7 +2,7 @@ from __future__ import annotations import itertools from collections import defaultdict -from typing import Sequence, Iterator, TYPE_CHECKING, Optional +from typing import Iterator, Optional, Sequence, TYPE_CHECKING from game.ato.closestairfields import ObjectiveDistanceCache from game.dcs.aircrafttype import AircraftType diff --git a/game/squadrons/squadrondef.py b/game/squadrons/squadrondef.py index 20e14021..7eff3282 100644 --- a/game/squadrons/squadrondef.py +++ b/game/squadrons/squadrondef.py @@ -1,8 +1,6 @@ from __future__ import annotations -import logging -from collections.abc import Iterable -from dataclasses import dataclass, field +from dataclasses import dataclass from pathlib import Path from typing import Optional, TYPE_CHECKING @@ -38,7 +36,6 @@ class SquadronDef: def capable_of(self, task: FlightType) -> bool: """Returns True if the squadron is capable of performing the given task. - A squadron may be capable of performing a task even if it will not be automatically assigned to it. """ diff --git a/qt_ui/windows/AirWingConfigurationDialog.py b/qt_ui/windows/AirWingConfigurationDialog.py index 2ee19027..97e7686b 100644 --- a/qt_ui/windows/AirWingConfigurationDialog.py +++ b/qt_ui/windows/AirWingConfigurationDialog.py @@ -45,9 +45,6 @@ class QMissionType: self, mission_type: FlightType, allowed: bool, auto_assignable: bool ) -> None: self.flight_type = mission_type - self.allowed_checkbox = QCheckBox() - self.allowed_checkbox.setChecked(allowed) - self.allowed_checkbox.toggled.connect(self.update_auto_assignable) self.auto_assignable_checkbox = QCheckBox() self.auto_assignable_checkbox.setEnabled(allowed) self.auto_assignable_checkbox.setChecked(auto_assignable) @@ -57,10 +54,6 @@ class QMissionType: if not checked: self.auto_assignable_checkbox.setChecked(False) - @property - def allowed(self) -> bool: - return self.allowed_checkbox.isChecked() - @property def auto_assignable(self) -> bool: return self.auto_assignable_checkbox.isChecked() @@ -73,27 +66,20 @@ class MissionTypeControls(QGridLayout): self.mission_types: list[QMissionType] = [] self.addWidget(QLabel("Mission Type"), 0, 0) - self.addWidget(QLabel("Allow"), 0, 1) - self.addWidget(QLabel("Auto-Assign"), 0, 2) + self.addWidget(QLabel("Auto-Assign"), 0, 1) for i, task in enumerate(FlightType): if task is FlightType.FERRY: # Not plannable so just skip it. continue - allowed = task in squadron.mission_types auto_assignable = task in squadron.auto_assignable_mission_types - mission_type = QMissionType(task, allowed, auto_assignable) + mission_type = QMissionType( + task, squadron.capable_of(task), auto_assignable + ) self.mission_types.append(mission_type) self.addWidget(QLabel(task.value), i + 1, 0) - self.addWidget(mission_type.allowed_checkbox, i + 1, 1) - self.addWidget(mission_type.auto_assignable_checkbox, i + 1, 2) - - @property - def allowed_mission_types(self) -> Iterator[FlightType]: - for mission_type in self.mission_types: - if mission_type.allowed: - yield mission_type.flight_type + self.addWidget(mission_type.auto_assignable_checkbox, i + 1, 1) @property def auto_assignable_mission_types(self) -> Iterator[FlightType]: @@ -280,10 +266,6 @@ class SquadronConfigurationBox(QGroupBox): self.squadron.pilot_pool = [ Pilot(n, player=True) for n in player_names ] + self.squadron.pilot_pool - # Set the allowed mission types - self.squadron.set_allowed_mission_types( - set(self.mission_types.allowed_mission_types) - ) # Also update the auto assignable mission types self.squadron.set_auto_assignable_mission_types( set(self.mission_types.auto_assignable_mission_types) diff --git a/qt_ui/windows/SquadronDialog.py b/qt_ui/windows/SquadronDialog.py index 13e8ef82..cdeff5a2 100644 --- a/qt_ui/windows/SquadronDialog.py +++ b/qt_ui/windows/SquadronDialog.py @@ -82,11 +82,12 @@ class AutoAssignedTaskControls(QVBoxLayout): return callback - for task in squadron_model.squadron.mission_types: - checkbox = QCheckBox(text=task.value) - checkbox.setChecked(squadron_model.is_auto_assignable(task)) - checkbox.toggled.connect(make_callback(task)) - self.addWidget(checkbox) + for task in FlightType: + if self.squadron_model.squadron.capable_of(task): + checkbox = QCheckBox(text=task.value) + checkbox.setChecked(squadron_model.is_auto_assignable(task)) + checkbox.toggled.connect(make_callback(task)) + self.addWidget(checkbox) self.addStretch() diff --git a/qt_ui/windows/mission/flight/SquadronSelector.py b/qt_ui/windows/mission/flight/SquadronSelector.py index 64ef6d99..dc495e0b 100644 --- a/qt_ui/windows/mission/flight/SquadronSelector.py +++ b/qt_ui/windows/mission/flight/SquadronSelector.py @@ -48,7 +48,7 @@ class SquadronSelector(QComboBox): return for squadron in self.air_wing.squadrons_for(aircraft): - valid_task = task in squadron.mission_types + valid_task = squadron.capable_of(task) runway_operational = squadron.location.runway_is_operational() if valid_task and squadron.untasked_aircraft and runway_operational: self.addItem(f"{squadron.location}: {squadron}", squadron)