mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Merge remote-tracking branch 'remotes/dcs-retribution/dcs-retribution/dev' into pretense-generator
This commit is contained in:
@@ -44,9 +44,7 @@ class Dialog:
|
||||
@classmethod
|
||||
def open_edit_package_dialog(cls, package_model: PackageModel):
|
||||
"""Opens the dialog to edit the given package."""
|
||||
cls.edit_package_dialog = QEditPackageDialog(
|
||||
cls.game_model, cls.game_model.ato_model, package_model
|
||||
)
|
||||
cls.edit_package_dialog = QEditPackageDialog(cls.game_model, package_model)
|
||||
cls.edit_package_dialog.show()
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -475,6 +475,11 @@ class QPackagePanel(QGroupBox):
|
||||
return
|
||||
self.package_list.delete_package(index)
|
||||
|
||||
def enable_buttons(self, enabled: bool) -> None:
|
||||
self.edit_button.setEnabled(enabled)
|
||||
self.clone_button.setEnabled(enabled)
|
||||
self.delete_button.setEnabled(enabled)
|
||||
|
||||
|
||||
class QAirTaskingOrderPanel(QSplitter):
|
||||
"""A split panel for displaying the packages and flights of an ATO.
|
||||
@@ -511,8 +516,10 @@ class QAirTaskingOrderPanel(QSplitter):
|
||||
"""Sets the newly selected flight for display in the bottom panel."""
|
||||
index = self.package_panel.package_list.currentIndex()
|
||||
if index.isValid():
|
||||
self.package_panel.enable_buttons(True)
|
||||
self.flight_panel.set_package(self.ato_model.get_package_model(index))
|
||||
else:
|
||||
self.package_panel.enable_buttons(False)
|
||||
self.flight_panel.set_package(None)
|
||||
|
||||
def on_ato_changed(self) -> None:
|
||||
@@ -525,6 +532,9 @@ class QAirTaskingOrderPanel(QSplitter):
|
||||
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.enable_buttons(False)
|
||||
self.package_panel.current_changed.connect(self.on_package_change)
|
||||
self.flight_panel.flight_list.set_package(None)
|
||||
events = GameUpdateEvents().deselect_flight()
|
||||
EventStream.put_nowait(events)
|
||||
self.game_model.is_ownfor = not opfor
|
||||
|
||||
@@ -525,7 +525,6 @@ class AircraftSquadronsPage(QWidget):
|
||||
scrolling_area.setHorizontalScrollBarPolicy(
|
||||
Qt.ScrollBarPolicy.ScrollBarAlwaysOff
|
||||
)
|
||||
scrolling_area.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
|
||||
scrolling_area.setWidgetResizable(True)
|
||||
scrolling_area.setWidget(scrolling_widget)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ from qt_ui.models import AirWingModel, AtoModel, GameModel, SquadronModel
|
||||
from qt_ui.simcontroller import SimController
|
||||
from qt_ui.windows.AirWingConfigurationDialog import AirWingConfigurationDialog
|
||||
from qt_ui.windows.SquadronDialog import SquadronDialog
|
||||
from qt_ui.windows.newgame.WizardPages.QFactionSelection import QFactionUnits
|
||||
|
||||
|
||||
class SquadronDelegate(TwoColumnRowDelegate):
|
||||
@@ -238,6 +239,8 @@ class AirWingTabs(QTabWidget):
|
||||
def __init__(self, game_model: GameModel) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.game_model = game_model
|
||||
|
||||
self.addTab(
|
||||
SquadronList(
|
||||
game_model.ato_model,
|
||||
@@ -260,18 +263,33 @@ class AirWingTabs(QTabWidget):
|
||||
|
||||
if game_model.game.settings.enable_air_wing_adjustments:
|
||||
pb = QPushButton("Open Air Wing Config Dialog")
|
||||
pb.clicked.connect(lambda _: self.open_awcd(game_model))
|
||||
pb.clicked.connect(self.open_awcd)
|
||||
pb.setMaximumWidth(300)
|
||||
layout = QHBoxLayout()
|
||||
layout.addWidget(pb)
|
||||
w = QWidget(layout=layout)
|
||||
self.addTab(w, "Cheats")
|
||||
|
||||
def open_awcd(self, gm: GameModel):
|
||||
AirWingConfigurationDialog(gm.game, True, self).exec_()
|
||||
self.addTab(
|
||||
QFactionUnits(
|
||||
game_model.game.coalition_for(True).faction,
|
||||
self,
|
||||
),
|
||||
"Faction OWNFOR",
|
||||
)
|
||||
self.addTab(
|
||||
QFactionUnits(
|
||||
game_model.game.coalition_for(False).faction,
|
||||
self,
|
||||
),
|
||||
"Faction OPFOR",
|
||||
)
|
||||
|
||||
def open_awcd(self):
|
||||
AirWingConfigurationDialog(self.game_model.game, True, self).exec_()
|
||||
events = GameUpdateEvents().begin_new_turn()
|
||||
EventStream.put_nowait(events)
|
||||
gm.ato_model.on_sim_update(events)
|
||||
self.game_model.ato_model.on_sim_update(events)
|
||||
|
||||
|
||||
class AirWingDialog(QDialog):
|
||||
|
||||
@@ -23,7 +23,7 @@ from game.radio.radios import RadioFrequency
|
||||
from game.server import EventStream
|
||||
from game.sim import GameUpdateEvents
|
||||
from game.theater.missiontarget import MissionTarget
|
||||
from qt_ui.models import AtoModel, GameModel, PackageModel
|
||||
from qt_ui.models import GameModel, PackageModel
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.QFrequencyWidget import QFrequencyWidget
|
||||
from qt_ui.widgets.ato import QFlightList
|
||||
@@ -333,11 +333,9 @@ class QEditPackageDialog(QPackageDialog):
|
||||
Changes to existing packages occur immediately.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, game_model: GameModel, model: AtoModel, package: PackageModel
|
||||
) -> None:
|
||||
super().__init__(game_model, package)
|
||||
self.ato_model = model
|
||||
def __init__(self, gm: GameModel, package: PackageModel) -> None:
|
||||
super().__init__(gm, package)
|
||||
self.ato_model = gm.ato_model if gm.is_ownfor else gm.red_ato_model
|
||||
|
||||
self.delete_button = QPushButton("Delete package")
|
||||
self.delete_button.setProperty("style", "btn-danger")
|
||||
|
||||
@@ -41,12 +41,12 @@ class FlightMemberSelector(QSpinBox):
|
||||
def __init__(self, flight: Flight, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.flight = flight
|
||||
self.setMinimum(0)
|
||||
self.setMaximum(flight.count - 1)
|
||||
self.setMinimum(1)
|
||||
self.setMaximum(flight.count)
|
||||
|
||||
@property
|
||||
def selected_member(self) -> FlightMember:
|
||||
return self.flight.roster.members[self.value()]
|
||||
return self.flight.roster.members[self.value() - 1]
|
||||
|
||||
|
||||
class DcsFuelSelector(QHBoxLayout):
|
||||
@@ -237,7 +237,7 @@ class QFlightPayloadTab(QFrame):
|
||||
self.payload_editor.set_flight_member(member)
|
||||
self.weapon_laser_code_selector.set_flight_member(member)
|
||||
self.own_laser_code_info.set_flight_member(member)
|
||||
if self.member_selector.value() != 0:
|
||||
if self.member_selector.value() != 1:
|
||||
self.loadout_selector.setDisabled(
|
||||
self.flight.use_same_loadout_for_all_members
|
||||
)
|
||||
|
||||
@@ -103,6 +103,7 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
f100_supersabre=self.field("f100_supersabre"),
|
||||
f104_starfighter=self.field("f104_starfighter"),
|
||||
f105_thunderchief=self.field("f105_thunderchief"),
|
||||
f106_deltadart=self.field("f106_deltadart"),
|
||||
hercules=self.field("hercules"),
|
||||
irondome=self.field("irondome"),
|
||||
uh_60l=self.field("uh_60l"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from copy import deepcopy
|
||||
from typing import Union
|
||||
from typing import Union, Callable, Set, Optional
|
||||
|
||||
from PySide6 import QtWidgets, QtGui
|
||||
from PySide6.QtCore import Qt
|
||||
@@ -12,9 +12,16 @@ from PySide6.QtWidgets import (
|
||||
QCheckBox,
|
||||
QLabel,
|
||||
QTextBrowser,
|
||||
QPushButton,
|
||||
QComboBox,
|
||||
QHBoxLayout,
|
||||
)
|
||||
|
||||
from game.ato import FlightType
|
||||
from game.campaignloader import Campaign
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.dcs.groundunittype import GroundUnitType
|
||||
from game.dcs.unittype import UnitType
|
||||
from game.factions import Faction, FACTIONS
|
||||
from qt_ui.windows.newgame.jinja_env import jinja_env
|
||||
|
||||
@@ -29,7 +36,13 @@ class QFactionUnits(QScrollArea):
|
||||
self.faction = faction
|
||||
self._create_checkboxes()
|
||||
|
||||
def _add_checkboxes(self, units: set, counter: int, grid: QGridLayout) -> int:
|
||||
def _add_checkboxes(
|
||||
self,
|
||||
units: set,
|
||||
counter: int,
|
||||
grid: QGridLayout,
|
||||
combo_layout: Optional[QHBoxLayout] = None,
|
||||
) -> int:
|
||||
counter += 1
|
||||
for i, v in enumerate(sorted(units, key=lambda x: str(x)), counter):
|
||||
cb = QCheckBox(str(v))
|
||||
@@ -37,6 +50,9 @@ class QFactionUnits(QScrollArea):
|
||||
self.checkboxes[str(v)] = cb
|
||||
grid.addWidget(cb, i, 1)
|
||||
counter += 1
|
||||
if combo_layout:
|
||||
counter += 1
|
||||
grid.addLayout(combo_layout, counter, 1)
|
||||
counter += 1
|
||||
return counter
|
||||
|
||||
@@ -44,18 +60,47 @@ class QFactionUnits(QScrollArea):
|
||||
counter = 0
|
||||
self.checkboxes: dict[str, QCheckBox] = {}
|
||||
grid = QGridLayout()
|
||||
grid.setColumnStretch(1, 1)
|
||||
if len(self.faction.aircraft) > 0:
|
||||
self.add_ac_combo = QComboBox()
|
||||
hbox = self._create_aircraft_combobox(
|
||||
self.add_ac_combo,
|
||||
lambda: self._on_add_ac(self.faction.aircraft, self.add_ac_combo),
|
||||
self._aircraft_predicate,
|
||||
)
|
||||
grid.addWidget(QLabel("<strong>Aircraft:</strong>"), counter, 0)
|
||||
counter = self._add_checkboxes(self.faction.aircraft, counter, grid)
|
||||
counter = self._add_checkboxes(self.faction.aircraft, counter, grid, hbox)
|
||||
if len(self.faction.awacs) > 0:
|
||||
self.add_awacs_combo = QComboBox()
|
||||
hbox = self._create_aircraft_combobox(
|
||||
self.add_awacs_combo,
|
||||
lambda: self._on_add_ac(self.faction.awacs, self.add_awacs_combo),
|
||||
self._awacs_predicate,
|
||||
)
|
||||
grid.addWidget(QLabel("<strong>AWACS:</strong>"), counter, 0)
|
||||
counter = self._add_checkboxes(self.faction.awacs, counter, grid)
|
||||
counter = self._add_checkboxes(self.faction.awacs, counter, grid, hbox)
|
||||
if len(self.faction.tankers) > 0:
|
||||
self.add_tanker_combo = QComboBox()
|
||||
hbox = self._create_aircraft_combobox(
|
||||
self.add_tanker_combo,
|
||||
lambda: self._on_add_ac(self.faction.tankers, self.add_tanker_combo),
|
||||
self._tanker_predicate,
|
||||
)
|
||||
grid.addWidget(QLabel("<strong>Tankers:</strong>"), counter, 0)
|
||||
counter = self._add_checkboxes(self.faction.tankers, counter, grid)
|
||||
counter = self._add_checkboxes(self.faction.tankers, counter, grid, hbox)
|
||||
if len(self.faction.frontline_units) > 0:
|
||||
self.add_frontline_combo = QComboBox()
|
||||
hbox = self._create_unit_combobox(
|
||||
self.add_frontline_combo,
|
||||
lambda: self._on_add_unit(
|
||||
self.faction.frontline_units, self.add_frontline_combo
|
||||
),
|
||||
self.faction.frontline_units,
|
||||
)
|
||||
grid.addWidget(QLabel("<strong>Frontlines vehicles:</strong>"), counter, 0)
|
||||
counter = self._add_checkboxes(self.faction.frontline_units, counter, grid)
|
||||
counter = self._add_checkboxes(
|
||||
self.faction.frontline_units, counter, grid, hbox
|
||||
)
|
||||
if len(self.faction.artillery_units) > 0:
|
||||
grid.addWidget(QLabel("<strong>Artillery units:</strong>"), counter, 0)
|
||||
counter = self._add_checkboxes(self.faction.artillery_units, counter, grid)
|
||||
@@ -82,6 +127,76 @@ class QFactionUnits(QScrollArea):
|
||||
|
||||
self.content.setLayout(grid)
|
||||
|
||||
def _aircraft_predicate(self, ac: AircraftType):
|
||||
if (
|
||||
FlightType.AEWC not in ac.task_priorities
|
||||
and FlightType.REFUELING not in ac.task_priorities
|
||||
):
|
||||
self.add_ac_combo.addItem(ac.variant_id, ac)
|
||||
|
||||
def _awacs_predicate(self, ac: AircraftType):
|
||||
if FlightType.AEWC in ac.task_priorities:
|
||||
self.add_awacs_combo.addItem(ac.variant_id, ac)
|
||||
|
||||
def _tanker_predicate(self, ac: AircraftType):
|
||||
if FlightType.REFUELING in ac.task_priorities:
|
||||
self.add_tanker_combo.addItem(ac.variant_id, ac)
|
||||
|
||||
def _create_aircraft_combobox(
|
||||
self, cb: QComboBox, callback: Callable, predicate: Callable
|
||||
):
|
||||
for ac_dcs in sorted(AircraftType.each_dcs_type(), key=lambda x: x.id):
|
||||
if (
|
||||
ac_dcs not in self.faction.country.planes
|
||||
and ac_dcs not in self.faction.country.helicopters
|
||||
):
|
||||
continue
|
||||
for ac in AircraftType.for_dcs_type(ac_dcs):
|
||||
if ac in self.faction.aircraft:
|
||||
continue
|
||||
predicate(ac)
|
||||
add_ac = QPushButton("+")
|
||||
add_ac.setStyleSheet("QPushButton{ font-weight: bold; }")
|
||||
add_ac.setFixedWidth(50)
|
||||
add_ac.clicked.connect(callback)
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addWidget(cb)
|
||||
hbox.addWidget(add_ac)
|
||||
return hbox
|
||||
|
||||
def _create_unit_combobox(
|
||||
self, cb: QComboBox, callback: Callable, units: Set[GroundUnitType]
|
||||
):
|
||||
for dcs_unit in sorted(GroundUnitType.each_dcs_type(), key=lambda x: x.id):
|
||||
if dcs_unit not in self.faction.country.vehicles:
|
||||
continue
|
||||
for unit in GroundUnitType.for_dcs_type(dcs_unit):
|
||||
if unit in units:
|
||||
continue
|
||||
cb.addItem(unit.variant_id, unit)
|
||||
add_unit = QPushButton("+")
|
||||
add_unit.setStyleSheet("QPushButton{ font-weight: bold; }")
|
||||
add_unit.setFixedWidth(50)
|
||||
add_unit.clicked.connect(callback)
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addWidget(cb)
|
||||
hbox.addWidget(add_unit)
|
||||
return hbox
|
||||
|
||||
def _on_add_unit(self, units: Set[UnitType], cb: QComboBox):
|
||||
units.add(cb.currentData())
|
||||
if self.faction.__dict__.get("accessible_units"):
|
||||
# invalidate the cached property
|
||||
del self.faction.__dict__["accessible_units"]
|
||||
self.updateFaction(self.faction)
|
||||
|
||||
def _on_add_ac(self, aircraft: Set[AircraftType], cb: QComboBox):
|
||||
aircraft.add(cb.currentData())
|
||||
if self.faction.__dict__.get("all_aircrafts"):
|
||||
# invalidate the cached property
|
||||
del self.faction.__dict__["all_aircrafts"]
|
||||
self.updateFaction(self.faction)
|
||||
|
||||
def updateFaction(self, faction: Faction):
|
||||
self.faction = faction
|
||||
self.content = QWidget()
|
||||
|
||||
@@ -122,6 +122,8 @@ class GeneratorOptions(QtWidgets.QWizardPage):
|
||||
self.registerField("f104_starfighter", self.f104_starfighter)
|
||||
self.f105_thunderchief = QtWidgets.QCheckBox()
|
||||
self.registerField("f105_thunderchief", self.f105_thunderchief)
|
||||
self.f106_deltadart = QtWidgets.QCheckBox()
|
||||
self.registerField("f106_deltadart", self.f106_deltadart)
|
||||
self.jas39_gripen = QtWidgets.QCheckBox()
|
||||
self.registerField("jas39_gripen", self.jas39_gripen)
|
||||
self.super_etendard = QtWidgets.QCheckBox()
|
||||
@@ -161,6 +163,7 @@ class GeneratorOptions(QtWidgets.QWizardPage):
|
||||
("F-100 Super Sabre (v2.7.18.30765 patch 20.10.22)", self.f100_supersabre),
|
||||
("F-104 Starfighter (v2.7.11.222.01)", self.f104_starfighter),
|
||||
("F-105 Thunderchief (v2.7.12.23x)", self.f105_thunderchief),
|
||||
("F-106 Delta Dart (v2.9.4.101)", self.f106_deltadart),
|
||||
("F-15D Baz (v1.0)", self.f15d_baz),
|
||||
("F-15I Ra'am (v1.0 by IDF Mods Project)", self.f_15_idf),
|
||||
("F-16I Sufa & F-16D (v3.6 by IDF Mods Project)", self.f_16_idf),
|
||||
@@ -234,6 +237,7 @@ class GeneratorOptions(QtWidgets.QWizardPage):
|
||||
self.f100_supersabre.setChecked(s.get("f100_supersabre", False))
|
||||
self.f104_starfighter.setChecked(s.get("f104_starfighter", False))
|
||||
self.f105_thunderchief.setChecked(s.get("f105_thunderchief", False))
|
||||
self.f106_deltadart.setChecked(s.get("f106_deltadart", False))
|
||||
self.jas39_gripen.setChecked(s.get("jas39_gripen", False))
|
||||
self.super_etendard.setChecked(s.get("super_etendard", False))
|
||||
self.su30_flanker_h.setChecked(s.get("su30_flanker_h", False))
|
||||
|
||||
Reference in New Issue
Block a user