mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Warn for new squadron rules with old campaigns.
It's not feasible to actually check the parking limits because we can't identify parking limits for carriers until the theater is populated. Doing so is expensive (and depends on other NGW inputs). Instead, compare against the version of the campaign and guess. A new (minor) campaign version has been introduced which makes this required to improve the UI hint. Campaigns that are compatible with the new rules should update their version to advertise support. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2909.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import textwrap
|
||||
from datetime import datetime, timedelta
|
||||
from typing import List
|
||||
|
||||
@@ -40,7 +41,6 @@ jinja_env = Environment(
|
||||
lstrip_blocks=True,
|
||||
)
|
||||
|
||||
|
||||
"""
|
||||
Possible time periods for new games
|
||||
|
||||
@@ -87,6 +87,10 @@ TIME_PERIODS = {
|
||||
}
|
||||
|
||||
|
||||
def wrap_label_text(text: str, width: int = 100) -> str:
|
||||
return "<br />".join(textwrap.wrap(text, width=width))
|
||||
|
||||
|
||||
class NewGameWizard(QtWidgets.QWizard):
|
||||
def __init__(self, parent=None):
|
||||
super(NewGameWizard, self).__init__(parent)
|
||||
@@ -115,7 +119,9 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
self.addPage(self.theater_page)
|
||||
self.addPage(self.faction_selection_page)
|
||||
self.addPage(GeneratorOptions(default_settings, mod_settings))
|
||||
self.difficulty_page = DifficultyAndAutomationOptions(default_settings)
|
||||
self.difficulty_page = DifficultyAndAutomationOptions(
|
||||
default_settings, self.theater_page.campaignList.selected_campaign
|
||||
)
|
||||
self.plugins_page = PluginsPage(self.lua_plugin_manager)
|
||||
|
||||
# Update difficulty page on campaign select
|
||||
@@ -573,8 +579,39 @@ class BudgetInputs(QtWidgets.QGridLayout):
|
||||
self.addWidget(self.starting_money, 1, 1)
|
||||
|
||||
|
||||
class NewSquadronRulesWarning(QLabel):
|
||||
def __init__(
|
||||
self, campaign: Campaign | None, parent: QWidget | None = None
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
self.set_campaign(campaign)
|
||||
|
||||
def set_campaign(self, campaign: Campaign | None) -> None:
|
||||
if campaign is None:
|
||||
self.setText("No campaign selected")
|
||||
return
|
||||
if campaign.version >= (10, 9):
|
||||
text = f"{campaign.name} is compatible with the new squadron rules."
|
||||
elif campaign.version >= (10, 7):
|
||||
text = (
|
||||
f"{campaign.name} has been updated since the new squadron rules were "
|
||||
"introduced, but support for those rules was still optional. You may "
|
||||
"need to remove, resize, or relocate squadrons before beginning the "
|
||||
"game."
|
||||
)
|
||||
else:
|
||||
text = (
|
||||
f"{campaign.name} has not been updated since the new squadron rules. "
|
||||
"Were introduced. You may need to remove, resize, or relocate "
|
||||
"squadrons before beginning the game."
|
||||
)
|
||||
self.setText(wrap_label_text(text))
|
||||
|
||||
|
||||
class DifficultyAndAutomationOptions(QtWidgets.QWizardPage):
|
||||
def __init__(self, default_settings: Settings, parent=None) -> None:
|
||||
def __init__(
|
||||
self, default_settings: Settings, current_campaign: Campaign | None, parent=None
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTitle("Difficulty and automation options")
|
||||
@@ -615,10 +652,15 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage):
|
||||
new_squadron_rules.setChecked(default_settings.enable_squadron_aircraft_limits)
|
||||
self.registerField("use_new_squadron_rules", new_squadron_rules)
|
||||
economy_layout.addWidget(new_squadron_rules)
|
||||
self.new_squadron_rules_warning = NewSquadronRulesWarning(current_campaign)
|
||||
economy_layout.addWidget(self.new_squadron_rules_warning)
|
||||
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."
|
||||
wrap_label_text(
|
||||
"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."
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -656,6 +698,7 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage):
|
||||
self.enemy_income.spinner.setValue(
|
||||
int(campaign.recommended_enemy_income_multiplier * 10)
|
||||
)
|
||||
self.new_squadron_rules_warning.set_campaign(campaign)
|
||||
|
||||
|
||||
class PluginOptionCheckbox(QCheckBox):
|
||||
|
||||
Reference in New Issue
Block a user