mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add a preferred_start_date for campaigns.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1079
This commit is contained in:
parent
b174e668f4
commit
d5eaa4d091
@ -19,6 +19,7 @@ Saves from 4.x are not compatible with 5.0.
|
||||
* **[Campaign AI]** Aircraft will now only be automatically purchased or assigned at appropriate bases. Naval aircraft will default to only operating from carriers, Harriers will default to LHAs and shore bases, helicopters will operate from anywhere. This can be customized per-squadron.
|
||||
* **[Engine]** Support for DCS 2.7.5.10869 and newer, including support for F-16 CBU-105s.
|
||||
* **[Modding]** Can now install custom campaigns to <DCS saved games>/Liberation/Campaigns instead of the Liberation install directory.
|
||||
* **[Modding]** Campaigns can now define a default start date.
|
||||
* **[Mission Generation]** EWRs are now also headed towards the center of the conflict
|
||||
* **[Mission Generation]** FACs can now use FC3 compatible laser codes. Note that this setting is global, not per FAC.
|
||||
* **[Modding]** Campaigns now specify the squadrons that are present in the campaign, their roles, and their starting bases. Players can customize this at game start but the campaign will choose the defaults.
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
from collections import Iterator
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Tuple, Dict, Any
|
||||
from typing import Optional, Tuple, Dict, Any
|
||||
|
||||
from packaging.version import Version
|
||||
import yaml
|
||||
@ -46,6 +47,7 @@ class Campaign:
|
||||
|
||||
recommended_player_faction: str
|
||||
recommended_enemy_faction: str
|
||||
recommended_start_date: Optional[datetime.date]
|
||||
performance: int
|
||||
data: Dict[str, Any]
|
||||
path: Path
|
||||
@ -67,6 +69,23 @@ class Campaign:
|
||||
f"Non-string campaign version in {path}. Parse may be incorrect."
|
||||
)
|
||||
version = Version(str(version_field))
|
||||
|
||||
start_date_raw = data.get("recommended_start_date")
|
||||
|
||||
# YAML automatically parses dates, but while we still support JSON campaigns we
|
||||
# need to be able to handle parsing dates from strings ourselves as well.
|
||||
start_date: Optional[datetime.date]
|
||||
if isinstance(start_date_raw, str):
|
||||
start_date = datetime.date.fromisoformat(start_date_raw)
|
||||
elif isinstance(start_date_raw, datetime.date):
|
||||
start_date = start_date_raw
|
||||
elif start_date_raw is None:
|
||||
start_date = None
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f"Invalid value for recommended_start_date in {path}: {start_date_raw}"
|
||||
)
|
||||
|
||||
return cls(
|
||||
data["name"],
|
||||
f"Terrain_{sanitized_theater}",
|
||||
@ -75,6 +94,7 @@ class Campaign:
|
||||
(version.major, version.minor),
|
||||
data.get("recommended_player_faction", "USA 2005"),
|
||||
data.get("recommended_enemy_faction", "Russia 1990"),
|
||||
start_date,
|
||||
data.get("performance", 0),
|
||||
data,
|
||||
path,
|
||||
|
||||
@ -115,7 +115,12 @@ VERSION = _build_version_string()
|
||||
#: * You can now add "Invisible FARP" static to FOB to add helicopter slots
|
||||
#:
|
||||
#: Version 9.0
|
||||
#: * Campaign files now define the initial squadron layouts. See TODO.
|
||||
#: * Campaign files now define the initial squadron layouts. See
|
||||
#: https://github.com/dcs-liberation/dcs_liberation/wiki/Custom-Campaigns.
|
||||
#: * CV and LHA control points now get their names from the group name in the campaign
|
||||
#: miz.
|
||||
CAMPAIGN_FORMAT_VERSION = (9, 0)
|
||||
#:
|
||||
#: Version 9.1
|
||||
#: * Campaign files can optionally define a start date with
|
||||
#: `recommended_start_date: YYYY-MM-DD`.
|
||||
CAMPAIGN_FORMAT_VERSION = (9, 1)
|
||||
|
||||
@ -380,6 +380,14 @@ class TheaterConfiguration(QtWidgets.QWizardPage):
|
||||
template_perf.render({"performance": campaign.performance})
|
||||
)
|
||||
|
||||
if (start_date := campaign.recommended_start_date) is not None:
|
||||
self.calendar.setSelectedDate(
|
||||
QDate(start_date.year, start_date.month, start_date.day)
|
||||
)
|
||||
timePeriodPreset.setChecked(False)
|
||||
else:
|
||||
timePeriodPreset.setChecked(True)
|
||||
|
||||
self.campaignList.selectionModel().setCurrentIndex(
|
||||
self.campaignList.indexAt(QPoint(1, 1)), QItemSelectionModel.Rows
|
||||
)
|
||||
|
||||
@ -3,9 +3,12 @@ name: Caucasus - Black Sea
|
||||
theater: Caucasus
|
||||
authors: Colonel Panic
|
||||
description: <p>A medium sized theater with bases along the coast of the Black Sea.</p>
|
||||
recommended_player_faction: USA 2005
|
||||
recommended_enemy_faction: Russia 2010
|
||||
recommended_start_date: 2004-01-07
|
||||
miz: black_sea.miz
|
||||
performance: 2
|
||||
version: "9.0"
|
||||
version: "9.1"
|
||||
squadrons:
|
||||
# Anapa-Vityazevo
|
||||
12:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user