mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add date-based loadout restriction.
Follow up work: * Data entry. I plan to do the air-to-air missiles in the near term. I covered some variants of the AIM-120, AIM-7, and AIM-9 here, but there are variants of those weapons for each mounting rack that need to be done still, as well as all the non-US weapons. * Arbitrary start dates. https://github.com/Khopa/dcs_liberation/issues/490
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
import inspect
|
||||
|
||||
from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QSpinBox, QGridLayout, QVBoxLayout, QSizePolicy
|
||||
from PySide2.QtWidgets import (
|
||||
QGridLayout,
|
||||
QGroupBox,
|
||||
QLabel,
|
||||
QSizePolicy,
|
||||
QVBoxLayout,
|
||||
)
|
||||
|
||||
from game import Game
|
||||
from game.data.weapons import Pylon
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.windows.mission.flight.payload.QPylonEditor import QPylonEditor
|
||||
|
||||
|
||||
class QLoadoutEditor(QGroupBox):
|
||||
|
||||
def __init__(self, flight, game):
|
||||
super(QLoadoutEditor, self).__init__("Use custom loadout")
|
||||
def __init__(self, flight: Flight, game: Game) -> None:
|
||||
super().__init__("Use custom loadout")
|
||||
self.flight = flight
|
||||
self.game = game
|
||||
self.setCheckable(True)
|
||||
@@ -25,7 +31,7 @@ class QLoadoutEditor(QGroupBox):
|
||||
label.setSizePolicy(
|
||||
QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
||||
layout.addWidget(label, i, 0)
|
||||
layout.addWidget(QPylonEditor(flight, pylon), i, 1)
|
||||
layout.addWidget(QPylonEditor(game, flight, pylon), i, 1)
|
||||
|
||||
hboxLayout.addLayout(layout)
|
||||
hboxLayout.addStretch()
|
||||
|
||||
@@ -4,13 +4,14 @@ from typing import Optional
|
||||
|
||||
from PySide2.QtWidgets import QComboBox
|
||||
|
||||
from game import Game
|
||||
from game.data.weapons import Pylon, Weapon
|
||||
from gen.flights.flight import Flight
|
||||
|
||||
|
||||
class QPylonEditor(QComboBox):
|
||||
|
||||
def __init__(self, flight: Flight, pylon: Pylon) -> None:
|
||||
def __init__(self, game: Game, flight: Flight, pylon: Pylon) -> None:
|
||||
super().__init__()
|
||||
self.flight = flight
|
||||
self.pylon = pylon
|
||||
@@ -18,7 +19,11 @@ class QPylonEditor(QComboBox):
|
||||
current = self.flight.loadout.get(self.pylon.number)
|
||||
|
||||
self.addItem("None", None)
|
||||
allowed = sorted(pylon.allowed, key=operator.attrgetter("name"))
|
||||
if game.settings.restrict_weapons_by_date:
|
||||
weapons = pylon.available_on(game.date)
|
||||
else:
|
||||
weapons = pylon.allowed
|
||||
allowed = sorted(weapons, key=operator.attrgetter("name"))
|
||||
for i, weapon in enumerate(allowed):
|
||||
self.addItem(weapon.name, weapon)
|
||||
if current == weapon:
|
||||
|
||||
@@ -248,6 +248,30 @@ class QSettingsWindow(QDialog):
|
||||
campaign_layout.setAlignment(Qt.AlignTop)
|
||||
self.campaign_management_page.setLayout(campaign_layout)
|
||||
|
||||
general = QGroupBox("General")
|
||||
campaign_layout.addWidget(general)
|
||||
|
||||
general_layout = QGridLayout()
|
||||
general.setLayout(general_layout)
|
||||
|
||||
def set_restict_weapons_by_date(value: bool) -> None:
|
||||
self.game.settings.restrict_weapons_by_date = value
|
||||
|
||||
restrict_weapons = QCheckBox()
|
||||
restrict_weapons.setChecked(self.game.settings.restrict_weapons_by_date)
|
||||
restrict_weapons.toggled.connect(set_restict_weapons_by_date)
|
||||
|
||||
tooltip_text = (
|
||||
"Restricts weapon availability based on the campaign date. Data is "
|
||||
"extremely incomplete so does not affect all weapons."
|
||||
)
|
||||
restrict_weapons.setToolTip(tooltip_text)
|
||||
restrict_weapons_label = QLabel("Restrict weapons by date (WIP)")
|
||||
restrict_weapons_label.setToolTip(tooltip_text)
|
||||
|
||||
general_layout.addWidget(restrict_weapons_label, 0, 0)
|
||||
general_layout.addWidget(restrict_weapons, 0, 1, Qt.AlignRight)
|
||||
|
||||
automation = QGroupBox("HQ Automation")
|
||||
campaign_layout.addWidget(automation)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user