diff --git a/qt_ui/main.py b/qt_ui/main.py index 6d92993f..65c0153b 100644 --- a/qt_ui/main.py +++ b/qt_ui/main.py @@ -128,7 +128,7 @@ def parse_args() -> argparse.Namespace: def create_game(campaign_path: Path, blue: str, red: str, supercarrier: bool) -> Game: campaign = Campaign.from_json(campaign_path) - generator = GameGenerator(blue, red, campaign.theater, + generator = GameGenerator(blue, red, campaign.load_theater(), Settings(supercarrier=supercarrier), start_date=datetime.today(), starting_budget=650, diff --git a/qt_ui/windows/newgame/QCampaignList.py b/qt_ui/windows/newgame/QCampaignList.py index 86ce0461..6f981694 100644 --- a/qt_ui/windows/newgame/QCampaignList.py +++ b/qt_ui/windows/newgame/QCampaignList.py @@ -4,7 +4,7 @@ import json import logging from dataclasses import dataclass from pathlib import Path -from typing import List +from typing import Any, Dict, List from PySide2 import QtGui from PySide2.QtCore import QItemSelectionModel @@ -21,7 +21,8 @@ class Campaign: icon_name: str authors: str description: str - theater: ConflictTheater + data: Dict[str, Any] + path: Path @classmethod def from_json(cls, path: Path) -> Campaign: @@ -29,10 +30,17 @@ class Campaign: data = json.load(campaign_file) sanitized_theater = data["theater"].replace(" ", "") - return cls(data["name"], f"Terrain_{sanitized_theater}", - data.get("authors", "???"), - data.get("description", ""), - ConflictTheater.from_json(path.parent, data)) + return cls( + data["name"], + f"Terrain_{sanitized_theater}", + data.get("authors", "???"), + data.get("description", ""), + data, + path + ) + + def load_theater(self) -> ConflictTheater: + return ConflictTheater.from_json(self.path.parent, self.data) def load_campaigns() -> List[Campaign]: diff --git a/qt_ui/windows/newgame/QNewGameWizard.py b/qt_ui/windows/newgame/QNewGameWizard.py index 5a96acd5..2b0c7004 100644 --- a/qt_ui/windows/newgame/QNewGameWizard.py +++ b/qt_ui/windows/newgame/QNewGameWizard.py @@ -58,7 +58,7 @@ class NewGameWizard(QtWidgets.QWizard): if selectedCampaign is None: selectedCampaign = self.campaigns[0] - conflictTheater = selectedCampaign.theater + conflictTheater = selectedCampaign.load_theater() timePeriod = db.TIME_PERIODS[list(db.TIME_PERIODS.keys())[self.field("timePeriod")]] midGame = self.field("midGame") diff --git a/resources/ui/templates/campaigntemplate_EN.j2 b/resources/ui/templates/campaigntemplate_EN.j2 index 88a210fb..5d721dcc 100644 --- a/resources/ui/templates/campaigntemplate_EN.j2 +++ b/resources/ui/templates/campaigntemplate_EN.j2 @@ -1,7 +1,3 @@ Author(s): {{ campaign.authors }} -
-
-Number of control points: {{ campaign.theater.controlpoints|length }} -
{{ campaign.description|safe }} diff --git a/resources/ui/templates/campaigntemplate_FR.j2 b/resources/ui/templates/campaigntemplate_FR.j2 index 60170f2e..e71616f7 100644 --- a/resources/ui/templates/campaigntemplate_FR.j2 +++ b/resources/ui/templates/campaigntemplate_FR.j2 @@ -1,7 +1,3 @@ Auteur(s) : {{ campaign.authors }} -
-
-Nombre de points : {{ campaign.theater.controlpoints|length }} -
{{ campaign.description|safe }}