Add an option to prefer primary tasked aircraft.

We're still using mostly the same aircraft selection as we have before
we added squadrons: the closest aircraft is the best choice.

This adds an option to obey the primary task set by the campaign
designer (can be overridden by players), even if the squadron is farther
away than one that is capable of it as a secondary task.

I don't expect this option to live very long. I'm making it optional for
now to give people a chance to test it, but it'll either replace the old
selection strategy or will be removed.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1892.
This commit is contained in:
Dan Albert
2023-05-04 22:34:23 -07:00
committed by Raffson
parent e95a6bf759
commit f719e1cfe7
8 changed files with 116 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ from game.theater import ConflictTheater, ControlPoint
from qt_ui.delegates import TwoColumnRowDelegate
from qt_ui.errorreporter import report_errors
from qt_ui.models import AtoModel, SquadronModel
from qt_ui.widgets.combos.primarytaskselector import PrimaryTaskSelector
class PilotDelegate(TwoColumnRowDelegate):
@@ -161,8 +162,20 @@ class SquadronDialog(QDialog):
columns = QHBoxLayout()
layout.addLayout(columns)
left_column = QVBoxLayout()
columns.addLayout(left_column)
left_column.addWidget(QLabel("Primary task"))
self.primary_task_selector = PrimaryTaskSelector.for_squadron(
self.squadron_model.squadron
)
self.primary_task_selector.currentIndexChanged.connect(
self.on_task_index_changed
)
left_column.addWidget(self.primary_task_selector)
auto_assigned_tasks = AutoAssignedTaskControls(squadron_model)
columns.addLayout(auto_assigned_tasks)
left_column.addLayout(auto_assigned_tasks)
self.pilot_list = PilotList(squadron_model)
self.pilot_list.selectionModel().selectionChanged.connect(
@@ -298,3 +311,9 @@ class SquadronDialog(QDialog):
index = selected.indexes()[0]
self.reset_ai_toggle_state(index)
self.reset_leave_toggle_state(index)
def on_task_index_changed(self, index: int) -> None:
task = self.primary_task_selector.itemData(index)
if task is None:
raise RuntimeError("Selected task cannot be None")
self.squadron.primary_task = task