From 67b341cbd6e94c504a0ca69375ef31e25e0b8a61 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 18 Apr 2021 20:57:08 -0700 Subject: [PATCH] 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 --- game/settings.py | 4 ++ qt_ui/windows/newgame/QNewGameWizard.py | 20 +++++++++ qt_ui/windows/settings/QSettingsWindow.py | 54 ++++++++++++++++++----- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/game/settings.py b/game/settings.py index 0e6f968a..cbc6108c 100644 --- a/game/settings.py +++ b/game/settings.py @@ -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 diff --git a/qt_ui/windows/newgame/QNewGameWizard.py b/qt_ui/windows/newgame/QNewGameWizard.py index c3cac473..bfd34a21 100644 --- a/qt_ui/windows/newgame/QNewGameWizard.py +++ b/qt_ui/windows/newgame/QNewGameWizard.py @@ -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) diff --git a/qt_ui/windows/settings/QSettingsWindow.py b/qt_ui/windows/settings/QSettingsWindow.py index 7432c341..d328b74c 100644 --- a/qt_ui/windows/settings/QSettingsWindow.py +++ b/qt_ui/windows/settings/QSettingsWindow.py @@ -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)
" + '' + 'More information.' +) + 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)