Babysteps towards full OPFOR control

This commit is contained in:
Raffson
2024-05-11 23:04:36 +02:00
parent b61f625828
commit f203a5cf7a
11 changed files with 73 additions and 37 deletions

View File

@@ -23,12 +23,14 @@ from PySide6.QtWidgets import (
QSplitter,
QVBoxLayout,
QMessageBox,
QCheckBox,
)
from game.ato.flight import Flight
from game.ato.package import Package
from game.server import EventStream
from game.sim import GameUpdateEvents
from .QLabeledWidget import QLabeledWidget
from ..delegates import TwoColumnRowDelegate
from ..models import AtoModel, GameModel, NullListModel, PackageModel
@@ -484,8 +486,20 @@ class QAirTaskingOrderPanel(QSplitter):
def __init__(self, game_model: GameModel) -> None:
super().__init__(Qt.Orientation.Vertical)
self.game_model = game_model
self.ato_model = game_model.ato_model
# ATO
self.red_ato_checkbox = QCheckBox()
self.red_ato_checkbox.toggled.connect(self.on_ato_changed)
self.red_ato_labeled = QLabeledWidget(
"Show/Plan OPFOR's ATO: ", self.red_ato_checkbox
)
self.ato_group_box = QGroupBox("ATO")
self.ato_group_box.setLayout(self.red_ato_labeled)
self.addWidget(self.ato_group_box)
self.package_panel = QPackagePanel(game_model, self.ato_model)
self.package_panel.current_changed.connect(self.on_package_change)
self.addWidget(self.package_panel)
@@ -500,3 +514,17 @@ class QAirTaskingOrderPanel(QSplitter):
self.flight_panel.set_package(self.ato_model.get_package_model(index))
else:
self.flight_panel.set_package(None)
def on_ato_changed(self) -> None:
opfor = self.red_ato_checkbox.isChecked()
ato_model = (
self.game_model.red_ato_model if opfor else self.game_model.ato_model
)
ato_model.layoutChanged.connect(self.package_panel.on_current_changed)
self.ato_model = ato_model
self.package_panel.ato_model = ato_model
self.package_panel.package_list.ato_model = ato_model
self.package_panel.package_list.setModel(ato_model)
self.package_panel.current_changed.connect(self.on_package_change)
self.flight_panel.flight_list.set_package(None)
self.game_model.is_ownfor = not opfor

View File

@@ -11,12 +11,16 @@ class QFlightTypeComboBox(QComboBox):
"""Combo box for selecting a flight task type."""
def __init__(
self, theater: ConflictTheater, target: MissionTarget, settings: Settings
self,
theater: ConflictTheater,
target: MissionTarget,
settings: Settings,
is_ownfor: bool,
) -> None:
super().__init__()
self.theater = theater
self.target = target
for mission_type in self.target.mission_types(for_player=True):
for mission_type in self.target.mission_types(for_player=is_ownfor):
if mission_type == FlightType.AIR_ASSAULT and not settings.plugin_option(
"ctld"
):