Load custom campaigns from the user directory.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1311
This commit is contained in:
Dan Albert 2021-10-17 16:48:19 -07:00
parent bbeb80fc48
commit fd49d213c2
2 changed files with 12 additions and 5 deletions

View File

@ -18,6 +18,7 @@ Saves from 4.x are not compatible with 5.0.
* **[Campaign AI]** Transport aircraft will now be bought only if necessary at control points which can produce ground units and are capable to operate transport aircraft.
* **[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.
* **[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.

View File

@ -24,7 +24,7 @@ from game.theater import (
from game.version import CAMPAIGN_FORMAT_VERSION
from .campaignairwingconfig import CampaignAirWingConfig
from .mizcampaignloader import MizCampaignLoader
from .. import persistency
PERF_FRIENDLY = 0
PERF_MEDIUM = 1
@ -141,10 +141,16 @@ class Campaign:
return True
@staticmethod
def iter_campaign_defs() -> Iterator[Path]:
campaign_dir = Path("resources/campaigns")
yield from campaign_dir.glob("*.json")
yield from campaign_dir.glob("*.yaml")
def iter_campaigns_in_dir(path: Path) -> Iterator[Path]:
yield from path.glob("*.yaml")
yield from path.glob("*.json")
@classmethod
def iter_campaign_defs(cls) -> Iterator[Path]:
yield from cls.iter_campaigns_in_dir(
Path(persistency.base_path()) / "Liberation/Campaigns"
)
yield from cls.iter_campaigns_in_dir(Path("resources/campaigns"))
@classmethod
def load_each(cls) -> Iterator[Campaign]: