diff --git a/changelog.md b/changelog.md index 10d47a4a..5ec716fb 100644 --- a/changelog.md +++ b/changelog.md @@ -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 /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. diff --git a/game/campaignloader/campaign.py b/game/campaignloader/campaign.py index 29cc45b7..76184df4 100644 --- a/game/campaignloader/campaign.py +++ b/game/campaignloader/campaign.py @@ -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]: