mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Make opfor airwing configurable.
This commit is contained in:
parent
270f87f193
commit
0eb8ec70d9
@ -23,6 +23,7 @@ from PySide2.QtWidgets import (
|
|||||||
QCheckBox,
|
QCheckBox,
|
||||||
QHBoxLayout,
|
QHBoxLayout,
|
||||||
QStackedLayout,
|
QStackedLayout,
|
||||||
|
QTabWidget,
|
||||||
)
|
)
|
||||||
|
|
||||||
from game import Game
|
from game import Game
|
||||||
@ -118,14 +119,22 @@ class SquadronConfigurationBox(QGroupBox):
|
|||||||
self.nickname_edit.textChanged.connect(self.on_nickname_changed)
|
self.nickname_edit.textChanged.connect(self.on_nickname_changed)
|
||||||
left_column.addWidget(self.nickname_edit)
|
left_column.addWidget(self.nickname_edit)
|
||||||
|
|
||||||
left_column.addWidget(
|
if squadron.player:
|
||||||
QLabel("Players (one per line, leave empty for an AI-only squadron):")
|
player_label = QLabel(
|
||||||
)
|
"Players (one per line, leave empty for an AI-only squadron):"
|
||||||
players = [p for p in squadron.available_pilots if p.player]
|
)
|
||||||
|
else:
|
||||||
|
player_label = QLabel("Player slots not available for opfor")
|
||||||
|
left_column.addWidget(player_label)
|
||||||
|
|
||||||
|
players = [p for p in squadron.pilot_pool if p.player]
|
||||||
for player in players:
|
for player in players:
|
||||||
squadron.available_pilots.remove(player)
|
squadron.pilot_pool.remove(player)
|
||||||
|
if not squadron.player:
|
||||||
|
players = []
|
||||||
self.player_list = QTextEdit("<br />".join(p.name for p in players))
|
self.player_list = QTextEdit("<br />".join(p.name for p in players))
|
||||||
self.player_list.setAcceptRichText(False)
|
self.player_list.setAcceptRichText(False)
|
||||||
|
self.player_list.setEnabled(squadron.player)
|
||||||
left_column.addWidget(self.player_list)
|
left_column.addWidget(self.player_list)
|
||||||
|
|
||||||
left_column.addStretch()
|
left_column.addStretch()
|
||||||
@ -250,6 +259,27 @@ class AircraftTypeList(QListView):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class AirWingConfigurationTab(QWidget):
|
||||||
|
def __init__(self, air_wing: AirWing) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
layout = QHBoxLayout()
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
type_list = AircraftTypeList(air_wing)
|
||||||
|
type_list.page_index_changed.connect(self.on_aircraft_changed)
|
||||||
|
layout.addWidget(type_list)
|
||||||
|
|
||||||
|
self.squadrons_panel = AircraftSquadronsPanel(air_wing)
|
||||||
|
layout.addLayout(self.squadrons_panel)
|
||||||
|
|
||||||
|
def apply(self) -> None:
|
||||||
|
self.squadrons_panel.apply()
|
||||||
|
|
||||||
|
def on_aircraft_changed(self, index: QModelIndex) -> None:
|
||||||
|
self.squadrons_panel.setCurrentIndex(index)
|
||||||
|
|
||||||
|
|
||||||
class AirWingConfigurationDialog(QDialog):
|
class AirWingConfigurationDialog(QDialog):
|
||||||
"""Dialog window for air wing configuration."""
|
"""Dialog window for air wing configuration."""
|
||||||
|
|
||||||
@ -280,19 +310,17 @@ class AirWingConfigurationDialog(QDialog):
|
|||||||
doc_label.setOpenExternalLinks(True)
|
doc_label.setOpenExternalLinks(True)
|
||||||
layout.addWidget(doc_label)
|
layout.addWidget(doc_label)
|
||||||
|
|
||||||
columns = QHBoxLayout()
|
tab_widget = QTabWidget()
|
||||||
layout.addLayout(columns)
|
layout.addWidget(tab_widget)
|
||||||
|
|
||||||
type_list = AircraftTypeList(game.blue.air_wing)
|
self.tabs = []
|
||||||
type_list.page_index_changed.connect(self.on_aircraft_changed)
|
for coalition in game.coalitions:
|
||||||
columns.addWidget(type_list)
|
coalition_tab = AirWingConfigurationTab(coalition.air_wing)
|
||||||
|
name = "Blue" if coalition.player else "Red"
|
||||||
self.squadrons_panel = AircraftSquadronsPanel(game.blue.air_wing)
|
tab_widget.addTab(coalition_tab, name)
|
||||||
columns.addLayout(self.squadrons_panel)
|
self.tabs.append(coalition_tab)
|
||||||
|
|
||||||
def reject(self) -> None:
|
def reject(self) -> None:
|
||||||
self.squadrons_panel.apply()
|
for tab in self.tabs:
|
||||||
|
tab.apply()
|
||||||
super().reject()
|
super().reject()
|
||||||
|
|
||||||
def on_aircraft_changed(self, index: QModelIndex) -> None:
|
|
||||||
self.squadrons_panel.setCurrentIndex(index)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user