Add feature flag for new ground unit recruitment.

This is going to render most campaigns unusable because they won't have
any places to spawn ground units, so flagging off for now.

https://github.com/Khopa/dcs_liberation/issues/986
This commit is contained in:
Dan Albert 2021-04-18 20:57:08 -07:00
parent eff5b94db7
commit 67b341cbd6
3 changed files with 67 additions and 11 deletions

View File

@ -33,6 +33,10 @@ class Settings:
disable_legacy_aewc: bool = False
generate_dark_kneeboard: bool = False
#: Feature flag for new ground unit behavior. Old campaigns are sufficiently broken
#: that we need to implement this conditionally for the time being.
enable_new_ground_unit_recruitment: bool = False
# Performance oriented
perf_red_alert_state: bool = True
perf_smoke_gen: bool = True

View File

@ -18,6 +18,9 @@ from qt_ui.windows.newgame.QCampaignList import (
QCampaignList,
load_campaigns,
)
from qt_ui.windows.settings.QSettingsWindow import (
NEW_GROUND_UNIT_RECRUITMENT_BEHAVIOR_LABEL,
)
jinja_env = Environment(
loader=FileSystemLoader("resources/ui/templates"),
@ -84,6 +87,9 @@ class NewGameWizard(QtWidgets.QWizard):
),
automate_aircraft_reinforcements=self.field("automate_aircraft_purchases"),
supercarrier=self.field("supercarrier"),
enable_new_ground_unit_recruitment=self.field(
"new_ground_unit_recruitment"
),
)
generator_settings = GeneratorSettings(
start_date=start_date,
@ -519,6 +525,20 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage):
self.registerField("automate_aircraft_purchases", aircraft)
assist_layout.addWidget(aircraft, 2, 1, Qt.AlignRight)
flags_group = QtWidgets.QGroupBox("Feature flags")
layout.addWidget(flags_group)
flags_layout = QtWidgets.QGridLayout()
flags_group.setLayout(flags_layout)
new_ground_unit_recruitment_label = QtWidgets.QLabel(
NEW_GROUND_UNIT_RECRUITMENT_BEHAVIOR_LABEL
)
new_ground_unit_recruitment_label.setOpenExternalLinks(True)
flags_layout.addWidget(new_ground_unit_recruitment_label, 0, 0)
new_ground_unit_recruitment = QtWidgets.QCheckBox()
self.registerField("new_ground_unit_recruitment", new_ground_unit_recruitment)
flags_layout.addWidget(new_ground_unit_recruitment, 0, 1, Qt.AlignRight)
self.setLayout(layout)

View File

@ -1,22 +1,22 @@
import logging
from typing import Callable
from PySide2.QtCore import QSize, Qt, QItemSelectionModel, QPoint
from PySide2.QtGui import QStandardItemModel, QStandardItem
from PySide2.QtCore import QItemSelectionModel, QPoint, QSize, Qt
from PySide2.QtGui import QStandardItem, QStandardItemModel
from PySide2.QtWidgets import (
QLabel,
QAbstractItemView,
QCheckBox,
QComboBox,
QDialog,
QGridLayout,
QListView,
QStackedLayout,
QComboBox,
QWidget,
QAbstractItemView,
QPushButton,
QGroupBox,
QCheckBox,
QVBoxLayout,
QLabel,
QListView,
QPushButton,
QSpinBox,
QStackedLayout,
QVBoxLayout,
QWidget,
)
from dcs.forcedoptions import ForcedOptions
@ -77,6 +77,17 @@ class CheatSettingsBox(QGroupBox):
START_TYPE_TOOLTIP = "Selects the start type used for AI aircraft."
NEW_GROUND_UNIT_RECRUITMENT_TOOLTIP = (
"If checked, the new ground unit recruitment behavior will be used. Ground "
"units may only be purchased at factories or off-map spawns and must "
"travel to the front line."
)
NEW_GROUND_UNIT_RECRUITMENT_BEHAVIOR_LABEL = (
"Enable new ground unit recruitment behavior (WIP)<br />"
'<a href="https://github.com/Khopa/dcs_liberation/issues/986">'
'<span style="color:#FFFFFF;">More information.</span></a>'
)
class StartTypeComboBox(QComboBox):
def __init__(self, settings: Settings) -> None:
@ -367,6 +378,27 @@ class QSettingsWindow(QDialog):
general_layout.addWidget(old_awac_label, 1, 0)
general_layout.addWidget(old_awac, 1, 1, Qt.AlignRight)
def set_new_ground_unit_recruitment(value: bool) -> None:
self.game.settings.enable_new_ground_unit_recruitment = value
new_ground_unit_recruitment_behavior_label = QLabel(
NEW_GROUND_UNIT_RECRUITMENT_BEHAVIOR_LABEL
)
new_ground_unit_recruitment_behavior_label.setToolTip(
NEW_GROUND_UNIT_RECRUITMENT_TOOLTIP
)
new_ground_unit_recruitment_behavior_label.setOpenExternalLinks(True)
new_ground_unit_recruitment = QCheckBox()
new_ground_unit_recruitment.setToolTip(NEW_GROUND_UNIT_RECRUITMENT_TOOLTIP)
new_ground_unit_recruitment.setChecked(
self.game.settings.enable_new_ground_unit_recruitment
)
new_ground_unit_recruitment.toggled.connect(set_new_ground_unit_recruitment)
general_layout.addWidget(new_ground_unit_recruitment_behavior_label, 2, 0)
general_layout.addWidget(new_ground_unit_recruitment, 2, 1, Qt.AlignRight)
automation = QGroupBox("HQ Automation")
campaign_layout.addWidget(automation)