mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add option to limit squadron sizes and begin full.
Adding temporarily as an option to make sure it's not a terrible idea, but the old mode will probably go away. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1583. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2808.
This commit is contained in:
@@ -238,6 +238,15 @@ def parse_args() -> argparse.Namespace:
|
||||
"--auto-procurement", action="store_true", help="Automate bluefor procurement."
|
||||
)
|
||||
|
||||
new_game.add_argument(
|
||||
"--use-new-squadron-rules",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Limit the number of aircraft per squadron and begin the campaign with "
|
||||
"them at full strength."
|
||||
),
|
||||
)
|
||||
|
||||
new_game.add_argument(
|
||||
"--inverted", action="store_true", help="Invert the campaign."
|
||||
)
|
||||
@@ -280,6 +289,7 @@ def create_game(
|
||||
start_date: datetime,
|
||||
restrict_weapons_by_date: bool,
|
||||
advanced_iads: bool,
|
||||
use_new_squadron_rules: bool,
|
||||
) -> Game:
|
||||
first_start = liberation_install.init()
|
||||
if first_start:
|
||||
@@ -312,6 +322,7 @@ def create_game(
|
||||
enable_base_capture_cheat=cheats,
|
||||
enable_transfer_cheat=cheats,
|
||||
restrict_weapons_by_date=restrict_weapons_by_date,
|
||||
enable_squadron_aircraft_limits=use_new_squadron_rules,
|
||||
),
|
||||
GeneratorSettings(
|
||||
start_date=start_date,
|
||||
@@ -346,7 +357,7 @@ def create_game(
|
||||
),
|
||||
)
|
||||
game = generator.generate()
|
||||
game.begin_turn_0()
|
||||
game.begin_turn_0(squadrons_start_full=use_new_squadron_rules)
|
||||
return game
|
||||
|
||||
|
||||
@@ -438,6 +449,7 @@ def main():
|
||||
args.date,
|
||||
args.restrict_weapons_by_date,
|
||||
args.advanced_iads,
|
||||
args.use_new_squadron_rules,
|
||||
)
|
||||
if args.subcommand == "lint-weapons":
|
||||
lint_weapon_data_for_aircraft(AircraftType.named(args.aircraft))
|
||||
|
||||
@@ -28,10 +28,12 @@ from PySide2.QtWidgets import (
|
||||
QGridLayout,
|
||||
QToolButton,
|
||||
QMessageBox,
|
||||
QSpinBox,
|
||||
)
|
||||
|
||||
from game import Game
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.campaignloader.campaignairwingconfig import DEFAULT_SQUADRON_SIZE
|
||||
from game.coalition import Coalition
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.squadrons import AirWing, Pilot, Squadron
|
||||
@@ -167,6 +169,25 @@ class SquadronLiverySelector(QComboBox):
|
||||
self.addItem("No available liveries (using DCS default)")
|
||||
self.setEnabled(False)
|
||||
|
||||
class SquadronSizeSpinner(QSpinBox):
|
||||
def __init__(self, starting_size: int, parent: QWidget | None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
# Disable text editing, which wouldn't work in the first place, but also
|
||||
# obnoxiously selects the text on change (highlighting it) and leaves a flashing
|
||||
# cursor in the middle of the element when clicked.
|
||||
self.lineEdit().setEnabled(False)
|
||||
|
||||
self.setMinimum(1)
|
||||
self.setValue(starting_size)
|
||||
|
||||
# def sizeHint(self) -> QSize:
|
||||
# # The default size hinting fails to deal with label width, and will truncate
|
||||
# # "Paused".
|
||||
# size = super().sizeHint()
|
||||
# size.setWidth(86)
|
||||
# return size
|
||||
|
||||
|
||||
class SquadronConfigurationBox(QGroupBox):
|
||||
remove_squadron_signal = Signal(Squadron)
|
||||
@@ -211,9 +232,20 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
self.livery_selector = SquadronLiverySelector(squadron)
|
||||
left_column.addWidget(self.livery_selector)
|
||||
|
||||
left_column.addWidget(QLabel("Primary task:"))
|
||||
task_and_size_row = QHBoxLayout()
|
||||
left_column.addLayout(task_and_size_row)
|
||||
|
||||
size_column = QVBoxLayout()
|
||||
task_and_size_row.addLayout(size_column)
|
||||
size_column.addWidget(QLabel("Max size:"))
|
||||
self.max_size_selector = SquadronSizeSpinner(self.squadron.max_size, self)
|
||||
size_column.addWidget(self.max_size_selector)
|
||||
|
||||
task_column = QVBoxLayout()
|
||||
task_and_size_row.addLayout(task_column)
|
||||
task_column.addWidget(QLabel("Primary task:"))
|
||||
self.primary_task_selector = PrimaryTaskSelector.for_squadron(self.squadron)
|
||||
left_column.addWidget(self.primary_task_selector)
|
||||
task_column.addWidget(self.primary_task_selector)
|
||||
|
||||
left_column.addWidget(QLabel("Base:"))
|
||||
self.base_selector = SquadronBaseSelector(
|
||||
@@ -268,6 +300,7 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
self.name_edit.setText(self.squadron.name)
|
||||
self.nickname_edit.setText(self.squadron.nickname)
|
||||
self.primary_task_selector.setCurrentText(self.squadron.primary_task.value)
|
||||
self.max_size_selector.setValue(self.squadron.max_size)
|
||||
self.base_selector.setCurrentText(self.squadron.location.name)
|
||||
self.player_list.setText(
|
||||
"<br />".join(p.name for p in self.claim_players_from_squadron())
|
||||
@@ -292,6 +325,7 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
squadron = Squadron.create_from(
|
||||
selected_def,
|
||||
self.squadron.primary_task,
|
||||
self.squadron.max_size,
|
||||
self.squadron.location,
|
||||
self.coalition,
|
||||
self.game,
|
||||
@@ -338,6 +372,7 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
def apply(self) -> Squadron:
|
||||
self.squadron.name = self.name_edit.text()
|
||||
self.squadron.nickname = self.nickname_edit.text()
|
||||
self.squadron.max_size = self.max_size_selector.value()
|
||||
if (primary_task := self.primary_task_selector.selected_task) is not None:
|
||||
self.squadron.primary_task = primary_task
|
||||
else:
|
||||
@@ -606,7 +641,12 @@ class AirWingConfigurationTab(QWidget):
|
||||
)
|
||||
|
||||
squadron = Squadron.create_from(
|
||||
squadron_def, selected_task, selected_base, self.coalition, self.game
|
||||
squadron_def,
|
||||
selected_task,
|
||||
DEFAULT_SQUADRON_SIZE,
|
||||
selected_base,
|
||||
self.coalition,
|
||||
self.game,
|
||||
)
|
||||
|
||||
# Add Squadron
|
||||
|
||||
@@ -94,6 +94,7 @@ FRONTLINE = f"{Settings.automate_front_line_reinforcements=}".split("=")[0].spli
|
||||
AIRCRAFT = f"{Settings.automate_aircraft_reinforcements=}".split("=")[0].split(".")[1]
|
||||
MISSION_LENGTH = f"{Settings.desired_player_mission_duration=}".split("=")[0].split(".")[1]
|
||||
SUPER_CARRIER = f"{Settings.supercarrier=}".split("=")[0].split(".")[1]
|
||||
SQN_AC_LIMITS = f"{Settings.enable_squadron_aircraft_limits=}".split("=")[0].split(".")[1]
|
||||
# fmt: on
|
||||
|
||||
|
||||
@@ -159,6 +160,7 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
settings.desired_player_mission_duration = timedelta(
|
||||
minutes=self.field(MISSION_LENGTH)
|
||||
)
|
||||
settings.enable_squadron_aircraft_limits = self.field("use_new_squadron_rules")
|
||||
settings.automate_aircraft_reinforcements = self.field(AIRCRAFT)
|
||||
settings.supercarrier = self.field(SUPER_CARRIER)
|
||||
settings.perf_culling = (
|
||||
@@ -233,7 +235,9 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
if herc in g.blue.air_wing.squadrons or herc in g.red.air_wing.squadrons:
|
||||
g.settings.set_plugin_option("herculescargo", True)
|
||||
|
||||
self.generatedGame.begin_turn_0()
|
||||
self.generatedGame.begin_turn_0(
|
||||
squadrons_start_full=settings.enable_squadron_aircraft_limits
|
||||
)
|
||||
|
||||
super(NewGameWizard, self).accept()
|
||||
|
||||
@@ -735,6 +739,16 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage):
|
||||
self.registerField("enemy_starting_money", self.enemy_budget.starting_money)
|
||||
economy_layout.addLayout(self.enemy_budget)
|
||||
|
||||
new_squadron_rules = QtWidgets.QCheckBox("Enable new squadron rules")
|
||||
self.registerField("use_new_squadron_rules", new_squadron_rules)
|
||||
economy_layout.addWidget(new_squadron_rules)
|
||||
economy_layout.addWidget(
|
||||
QLabel(
|
||||
"With new squadron rules enabled, squadrons will not be able to exceed a maximum number of aircraft "
|
||||
"(configurable), and the campaign will begin with all squadrons at full strength."
|
||||
)
|
||||
)
|
||||
|
||||
assist_group = QtWidgets.QGroupBox("Player assists")
|
||||
layout.addWidget(assist_group)
|
||||
assist_layout = QtWidgets.QGridLayout()
|
||||
|
||||
Reference in New Issue
Block a user