Don't allow operating on broken runways.

Doesn't allow helos or harriers to do it either even though they should
be able to because we don't currently support ground spawns, which would
be needed to prevent those aircraft from using the runway. Even then, I
don't know if they can be forced to *land* vertically.

Fixes https://github.com/Khopa/dcs_liberation/issues/432
This commit is contained in:
Dan Albert
2020-11-25 18:48:07 -08:00
parent a1b64bc72d
commit 2bd673a531
11 changed files with 54 additions and 37 deletions

View File

@@ -20,9 +20,8 @@ class QBaseMenuTabs(QTabWidget):
self.intel = QIntelInfo(cp, game_model.game)
self.addTab(self.intel, "Intel")
else:
if cp.has_runway():
self.airfield_command = QAirfieldCommand(cp, game_model)
self.addTab(self.airfield_command, "Airfield Command")
self.airfield_command = QAirfieldCommand(cp, game_model)
self.addTab(self.airfield_command, "Airfield Command")
if cp.is_carrier:
self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game)

View File

@@ -5,6 +5,7 @@ from PySide2.QtWidgets import (
QGroupBox,
QHBoxLayout,
QLabel,
QLayout,
QPushButton,
QSizePolicy,
QSpacerItem,
@@ -45,7 +46,8 @@ class QRecruitBehaviour:
def budget(self, value: int) -> None:
self.game_model.game.budget = value
def add_purchase_row(self, unit_type, layout, row):
def add_purchase_row(self, unit_type: Type[UnitType], layout: QLayout,
row: int, disabled: bool = False) -> int:
exist = QGroupBox()
exist.setProperty("style", "buy-box")
exist.setMaximumHeight(36)
@@ -80,6 +82,7 @@ class QRecruitBehaviour:
buy = QPushButton("+")
buy.setProperty("style", "btn-buy")
buy.setDisabled(disabled)
buy.setMinimumSize(16, 16)
buy.setMaximumSize(16, 16)
buy.clicked.connect(lambda: self.buy(unit_type))
@@ -87,6 +90,7 @@ class QRecruitBehaviour:
sell = QPushButton("-")
sell.setProperty("style", "btn-sell")
sell.setDisabled(disabled)
sell.setMinimumSize(16, 16)
sell.setMaximumSize(16, 16)
sell.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))

View File

@@ -1,5 +1,5 @@
import logging
from typing import Optional, Set
from typing import Optional, Set, Type
from PySide2.QtCore import Qt
from PySide2.QtWidgets import (
@@ -13,7 +13,7 @@ from PySide2.QtWidgets import (
QWidget,
)
from dcs.task import CAP, CAS
from dcs.unittype import UnitType
from dcs.unittype import FlyingType, UnitType
from game import db
from game.theater import ControlPoint
@@ -51,12 +51,14 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
task_box_layout = QGridLayout()
row = 0
unit_types: Set[UnitType] = set()
unit_types: Set[Type[FlyingType]] = set()
for task in tasks:
units = db.find_unittype(task, self.game_model.game.player_name)
if not units:
continue
for unit in units:
if not issubclass(unit, FlyingType):
continue
if self.cp.is_carrier and unit not in db.CARRIER_CAPABLE:
continue
if self.cp.is_lha and unit not in db.LHA_CAPABLE:
@@ -65,7 +67,9 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
sorted_units = sorted(unit_types, key=lambda u: db.unit_type_name_2(u))
for unit_type in sorted_units:
row = self.add_purchase_row(unit_type, task_box_layout, row)
row = self.add_purchase_row(
unit_type, task_box_layout, row,
disabled=not self.cp.can_operate(unit_type))
stretch = QVBoxLayout()
stretch.addStretch()
task_box_layout.addLayout(stretch, row, 0)