diff --git a/qt_ui/windows/newgame/QCampaignList.py b/qt_ui/windows/newgame/QCampaignList.py index 6f981694..7c9e7cec 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 Any, Dict, List +from typing import Any, Dict, List, Union from PySide2 import QtGui from PySide2.QtCore import QItemSelectionModel @@ -14,6 +14,10 @@ from PySide2.QtWidgets import QAbstractItemView, QListView import qt_ui.uiconstants as CONST from game.theater import ConflictTheater +PERF_FRIENDLY = 0 +PERF_MEDIUM = 1 +PERF_HARD = 2 +PERF_NASA = 3 @dataclass(frozen=True) class Campaign: @@ -21,6 +25,9 @@ class Campaign: icon_name: str authors: str description: str + recommended_player_faction: str + recommended_enemy_faction: str + performance: Union[PERF_FRIENDLY, PERF_MEDIUM, PERF_HARD, PERF_NASA] data: Dict[str, Any] path: Path @@ -35,6 +42,9 @@ class Campaign: f"Terrain_{sanitized_theater}", data.get("authors", "???"), data.get("description", ""), + data.get("recommended_player_faction", "USA 2005"), + data.get("recommended_enemy_faction", "Russia 1990"), + data.get("performance", 0), data, path ) diff --git a/qt_ui/windows/newgame/QNewGameWizard.py b/qt_ui/windows/newgame/QNewGameWizard.py index 705675d4..a1bb2a27 100644 --- a/qt_ui/windows/newgame/QNewGameWizard.py +++ b/qt_ui/windows/newgame/QNewGameWizard.py @@ -39,9 +39,10 @@ class NewGameWizard(QtWidgets.QWizard): self.campaigns = load_campaigns() + self.faction_selection_page = FactionSelection() self.addPage(IntroPage()) - self.addPage(FactionSelection()) - self.addPage(TheaterConfiguration(self.campaigns)) + self.addPage(TheaterConfiguration(self.campaigns, self.faction_selection_page)) + self.addPage(self.faction_selection_page) self.addPage(GeneratorOptions()) self.addPage(DifficultyAndAutomationOptions()) self.addPage(ConclusionPage()) @@ -195,6 +196,24 @@ class FactionSelection(QtWidgets.QWizardPage): self.blueFactionSelect.activated.connect(self.updateUnitRecap) self.redFactionSelect.activated.connect(self.updateUnitRecap) + + def setDefaultFactions(self, campaign:Campaign): + """ Set default faction for selected campaign """ + + self.blueFactionSelect.clear() + self.redFactionSelect.clear() + + for f in db.FACTIONS: + self.blueFactionSelect.addItem(f) + + for i, r in enumerate(db.FACTIONS): + self.redFactionSelect.addItem(r) + if r == campaign.recommended_enemy_faction: + self.redFactionSelect.setCurrentIndex(i) + if r == campaign.recommended_player_faction: + self.blueFactionSelect.setCurrentIndex(i) + + def updateUnitRecap(self): red_faction = db.FACTIONS[self.redFactionSelect.currentText()] @@ -233,9 +252,11 @@ class FactionSelection(QtWidgets.QWizardPage): class TheaterConfiguration(QtWidgets.QWizardPage): - def __init__(self, campaigns: List[Campaign], parent=None) -> None: + def __init__(self, campaigns: List[Campaign], faction_selection: FactionSelection, parent=None) -> None: super().__init__(parent) + self.faction_selection = faction_selection + self.setTitle("Theater configuration") self.setSubTitle("\nChoose a terrain and time period for this game.") self.setPixmap(QtWidgets.QWizard.LogoPixmap, @@ -258,6 +279,7 @@ class TheaterConfiguration(QtWidgets.QWizardPage): campaign = campaignList.campaigns[index] self.setField("selectedCampaign", campaign) self.campaignMapDescription.setText(template.render({"campaign": campaign})) + self.faction_selection.setDefaultFactions(campaign) campaignList.selectionModel().setCurrentIndex(campaignList.indexAt(QPoint(1, 1)), QItemSelectionModel.Rows) campaignList.selectionModel().selectionChanged.connect(on_campaign_selected) diff --git a/resources/campaigns/battle_of_britain.json b/resources/campaigns/battle_of_britain.json index e4ab5896..2220bd07 100644 --- a/resources/campaigns/battle_of_britain.json +++ b/resources/campaigns/battle_of_britain.json @@ -2,6 +2,8 @@ "name": "The Channel - Battle of Britain", "theater": "The Channel", "authors": "Khopa", + "recommended_player_faction": "United Kingdom 1944", + "recommended_enemy_faction": "Germany 1942", "description": "
Experience the Battle of Britain on the Channel map !
Note: It is not possible to cross the channel to capture enemy bases yet, but you can consider you won if you manage to destroy all the ennemy targets
", "miz": "battle_of_britain.miz" } \ No newline at end of file diff --git a/resources/campaigns/desert_war.json b/resources/campaigns/desert_war.json index 5cd60c84..b268c8f9 100644 --- a/resources/campaigns/desert_war.json +++ b/resources/campaigns/desert_war.json @@ -2,6 +2,8 @@ "name": "Persian Gulf - Desert War", "theater": "Persian Gulf", "authors": "Khopa", + "recommended_player_faction": "USA 2005", + "recommended_enemy_faction": "Iran 2015", "description": "This is a simple scenario in the Desert near Dubai and Abu-Dhabi. Progress from Liwa airbase to Al-Minhad.
This scenario shouldn't require too much performance.
", "miz": "desert_war.miz" } \ No newline at end of file diff --git a/resources/campaigns/dunkirk.json b/resources/campaigns/dunkirk.json index 8ccbe8ba..7c9a8f76 100644 --- a/resources/campaigns/dunkirk.json +++ b/resources/campaigns/dunkirk.json @@ -2,6 +2,8 @@ "name": "The Channel - Dunkirk", "theater": "The Channel", "authors": "Khopa", + "recommended_player_faction": "Allies 1944", + "recommended_enemy_faction": "Germany 1942", "description": "In this scenario, your forces starts in Dunkirk and can be supported by the airfields on the other side of the Channel.
If you select the inverted configuration, you can play a German invasion of England.
Note: B-17 should be operated from Manston airfield
", "miz": "dunkirk.miz" } \ No newline at end of file diff --git a/resources/campaigns/emirates.json b/resources/campaigns/emirates.json index 6579d3e8..d2e7fc26 100644 --- a/resources/campaigns/emirates.json +++ b/resources/campaigns/emirates.json @@ -2,6 +2,8 @@ "name": "Persian Gulf - Emirates", "theater": "Persian Gulf", "authors": "Khopa", + "recommended_player_faction": "USA 2005", + "recommended_enemy_faction": "Iran 2015", "description": "In this scenario, you can play an invasion of the Emirates and Oman, where your forces starts in Fujairah.
Note: Fujairah airfield has very few slots for aircrafts, so it recommended to operate from carriers at the start of the campaign. Thus, a carrier-capable faction is recommended.
", "miz": "emirates.miz" } \ No newline at end of file diff --git a/resources/campaigns/golan_heights.json b/resources/campaigns/golan_heights.json index 01973830..33757de3 100644 --- a/resources/campaigns/golan_heights.json +++ b/resources/campaigns/golan_heights.json @@ -2,6 +2,8 @@ "name": "Syria - Battle for Golan Heights", "theater": "Syria", "authors": "Khopa", + "recommended_player_faction": "Israel 2000", + "recommended_enemy_faction": "Syria 2011", "description": "In this scenario, you start in Israel and the conflict is focused around the golan heights, an historically disputed territory.
You can use the inverted configuration to start on the Syrian side.
If this scenario is too heavy, try the lite version.
In this scenario, you start in Israel and the conflict is focused around the golan heights, an historically disputed territory.
This scenario is designed to be performance friendly.
In this scenario, you start from Jordan, and have to fight your way through eastern Syria.
", "miz": "inherent_resolve.miz" } \ No newline at end of file diff --git a/resources/campaigns/invasion_from_turkey.json b/resources/campaigns/invasion_from_turkey.json index f259a1e4..b1b86a8d 100644 --- a/resources/campaigns/invasion_from_turkey.json +++ b/resources/campaigns/invasion_from_turkey.json @@ -2,6 +2,8 @@ "name": "Syria - Invasion from Turkey", "theater": "Syria", "authors": "Khopa", + "recommended_player_faction": "Turkey 2005", + "recommended_enemy_faction": "Insurgents (Hard)", "description": "In this scenario, you start from Turkey and have to invade territories in northern Syria.
", "miz": "invasion_from_turkey.miz" } \ No newline at end of file diff --git a/resources/campaigns/invasion_of_iran.json b/resources/campaigns/invasion_of_iran.json index 8a8d475f..5adfb17a 100644 --- a/resources/campaigns/invasion_of_iran.json +++ b/resources/campaigns/invasion_of_iran.json @@ -2,6 +2,8 @@ "name": "Persian Gulf - Invasion of Iran", "theater": "Persian Gulf", "authors": "Khopa", + "recommended_player_faction": "USA 2005", + "recommended_enemy_faction": "Iran 2015", "description": "In this scenario, you start in Bandar Abbas, and must invade Iran.
", "miz": "invasion_of_iran.miz" } \ No newline at end of file diff --git a/resources/campaigns/invasion_of_iran_[lite].json b/resources/campaigns/invasion_of_iran_[lite].json index 684c9cc9..f3100887 100644 --- a/resources/campaigns/invasion_of_iran_[lite].json +++ b/resources/campaigns/invasion_of_iran_[lite].json @@ -2,6 +2,8 @@ "name": "Persian Gulf - Invasion of Iran [Lite]", "theater": "Persian Gulf", "authors": "Khopa", + "recommended_player_faction": "USA 2005", + "recommended_enemy_faction": "Iran 2015", "description": "This is lighter version of the invasion of Iran scenario.
", "miz": "invasion_of_iran_lite.miz" } \ No newline at end of file diff --git a/resources/campaigns/normandy.json b/resources/campaigns/normandy.json index caf3b123..2ee32ae0 100644 --- a/resources/campaigns/normandy.json +++ b/resources/campaigns/normandy.json @@ -2,6 +2,9 @@ "name": "Normandy - Normandy", "theater": "Normandy", "authors": "Khopa", + "recommended_player_faction": "Allies 1944", + "recommended_enemy_faction": "Germany 1944", + "performance": 3, "description": "Normandy 1944 D-Day scenario.
", "miz":"normandy.miz" } \ No newline at end of file diff --git a/resources/campaigns/normandy_small.json b/resources/campaigns/normandy_small.json index 9aa63e78..f7a99b97 100644 --- a/resources/campaigns/normandy_small.json +++ b/resources/campaigns/normandy_small.json @@ -2,6 +2,8 @@ "name": "Normandy - Normandy Small", "theater": "Normandy", "authors": "Khopa", + "recommended_player_faction": "Allies 1944", + "recommended_enemy_faction": "Germany 1944", "description": "A lighter version of the Normandy 1944 D-Day scenario.
", "miz": "normandy_small.miz" } \ No newline at end of file diff --git a/resources/campaigns/russia_small.json b/resources/campaigns/russia_small.json index 490ebf93..3d9c34f0 100644 --- a/resources/campaigns/russia_small.json +++ b/resources/campaigns/russia_small.json @@ -2,6 +2,9 @@ "name": "Caucasus - Russia Small", "theater": "Caucasus", "authors": "Khopa", + "recommended_player_faction": "Russia 2010", + "recommended_enemy_faction": "USA 1990", + "performance": "heavy", "description": "A small theater in Russia, progress from Mozdok to Maykop.
This scenario is pretty simple, it is ideal if you want to run a short campaign. If your PC is not powerful, this is also the less performance heavy scenario.
", "miz": "russia_small.miz" } \ No newline at end of file diff --git a/resources/campaigns/syrian_civil_war.json b/resources/campaigns/syrian_civil_war.json index 77f879fe..a4ec32a8 100644 --- a/resources/campaigns/syrian_civil_war.json +++ b/resources/campaigns/syrian_civil_war.json @@ -2,6 +2,8 @@ "name": "Syria - Syrian Civil War", "theater": "Syria", "authors": "Khopa", + "recommended_player_faction": "Russia 2010", + "recommended_enemy_faction": "Insurgents (Hard)", "description": "This scenario can be used to simulate parts of the Syrian Civil War.
You start on the coast with an airbase in Latakia, and ground forces in Tartus.
This scenario can also be used to simulate a western invasion of Syria.
In inverted configuration you start in Aleppo.