Improved campaign selection screen in new game wizard.

This commit is contained in:
Khopa 2020-11-08 23:24:10 +01:00
parent 61253e4d4d
commit 5946fc7404
27 changed files with 54 additions and 178 deletions

View File

@ -20,6 +20,7 @@ class Campaign:
name: str
icon_name: str
authors: str
description: str
theater: ConflictTheater
@classmethod
@ -29,7 +30,7 @@ class Campaign:
sanitized_theater = data["theater"].replace(" ", "")
return cls(data["name"], f"Terrain_{sanitized_theater}", data.get("authors", "???"),
ConflictTheater.from_json(data))
data.get("description", ""), ConflictTheater.from_json(data))
def load_campaigns() -> List[Campaign]:

View File

@ -17,6 +17,16 @@ from qt_ui.windows.newgame.QCampaignList import (
)
from theater.start_generator import GameGenerator
jinja_env = Environment(
loader=FileSystemLoader("resources/ui/templates"),
autoescape=select_autoescape(
disabled_extensions=("",),
default_for_string=True,
default=True,
),
trim_blocks=True,
lstrip_blocks=True,
)
class NewGameWizard(QtWidgets.QWizard):
def __init__(self, parent=None):
@ -177,17 +187,7 @@ class FactionSelection(QtWidgets.QWizardPage):
red_faction = db.FACTIONS[self.redFactionSelect.currentText()]
blue_faction = db.FACTIONS[self.blueFactionSelect.currentText()]
env = Environment(
loader=FileSystemLoader("resources/ui/templates"),
autoescape=select_autoescape(
disabled_extensions=("",),
default_for_string=True,
default=True,
),
trim_blocks=True,
lstrip_blocks=True,
)
template = env.get_template("factiontemplate_EN.j2")
template = jinja_env.get_template("factiontemplate_EN.j2")
blue_faction_txt = template.render({"faction": blue_faction})
red_faction_txt = template.render({"faction": red_faction})
@ -235,10 +235,16 @@ class TheaterConfiguration(QtWidgets.QWizardPage):
campaignList = QCampaignList(campaigns)
self.registerField("selectedCampaign", campaignList)
# Faction description
self.campaignMapDescription = QTextEdit("")
self.campaignMapDescription.setReadOnly(True)
def on_campaign_selected():
template = jinja_env.get_template("campaigntemplate_EN.j2")
index = campaignList.selectionModel().currentIndex().row()
campaign = campaignList.campaigns[index]
self.setField("selectedCampaign", campaign)
self.campaignMapDescription.setText(template.render({"campaign": campaign}))
campaignList.selectionModel().setCurrentIndex(campaignList.indexAt(QPoint(1, 1)), QItemSelectionModel.Rows)
campaignList.selectionModel().selectionChanged.connect(on_campaign_selected)
@ -274,8 +280,9 @@ class TheaterConfiguration(QtWidgets.QWizardPage):
layout = QtWidgets.QGridLayout()
layout.setColumnMinimumWidth(0, 20)
layout.addWidget(campaignList, 0, 0, 3, 1)
layout.addWidget(mapSettingsGroup, 0, 1, 1, 1)
layout.addWidget(timeGroup, 1, 1, 1, 1)
layout.addWidget(self.campaignMapDescription, 0, 1, 1, 1)
layout.addWidget(mapSettingsGroup, 1, 1, 1, 1)
layout.addWidget(timeGroup, 2, 1, 1, 1)
self.setLayout(layout)

View File

@ -2,7 +2,7 @@
"name": "The Channel - Battle of Britain",
"theater": "The Channel",
"authors": "Khopa",
"description": "",
"description": "<p>Experience the Battle of Britain on the Channel map !<br/></p><p><strong>Note:</strong> 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</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Persian Gulf - Desert War",
"theater": "Persian Gulf",
"authors": "Khopa",
"description": "",
"description": "<p>This is a simple scenario in the Desert near Dubai and Abu-Dhabi. Progress from Liwa airbase to Al-Minhad.</p><p>This scenario shouldn't require too much performance.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "The Channel - Dunkirk",
"theater": "The Channel",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario, your forces starts in Dunkirk and can be supported by the airfields on the other side of the Channel.</p><p>If you select the inverted configuration, you can play a German invasion of England.</p><p><strong>Note:</strong> B-17 should be operated from Manston airfield</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Persian Gulf - Emirates",
"theater": "Persian Gulf",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario, you can play an invasion of the Emirates and Oman, where your forces starts in Fujairah.</p><p><strong>Note:</strong> 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.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Caucasus - Full Map",
"theater": "Caucasus",
"authors": "george",
"description": "Full Caucasus Map",
"description": "<p>Full map of the Caucasus</p><p><strong>Note:</strong> This scenario is heavy on performance, enabling \"culling\" in settings is highly recommended.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Syria - Golan heights battle",
"theater": "Syria",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario, you start in Israel and the conflict is focused around the golan heights, an historically disputed territory.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Syria - Inherent Resolve",
"theater": "Syria",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario, you start from Jordan, and have to fight your way through eastern Syria.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Syria - Invasion from Turkey",
"theater": "Syria",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario, you start from Turkey and have to invade territories in northern Syria.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Persian Gulf - Invasion of Iran",
"theater": "Persian Gulf",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario, you start in Bandar Abbas, and must invade Iran.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Persian Gulf - Invasion of Iran [Lite]",
"theater": "Persian Gulf",
"authors": "Khopa",
"description": "",
"description": "<p>This is lighter version of the invasion of Iran scenario.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Normandy - Normandy",
"theater": "Normandy",
"authors": "Khopa",
"description": "",
"description": "<p>Normandy 1944 D-Day scenario.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Normandy - Normandy Small",
"theater": "Normandy",
"authors": "Khopa",
"description": "",
"description": "<p>A lighter version of the Normandy 1944 D-Day scenario.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Caucasus - North Caucasus",
"theater": "Caucasus",
"authors": "Khopa",
"description": "",
"description": "<p>In this scenario you will have to fight in the moutain of Caucasus</p><p><strong>Note:</strong> Running CAS in the moutains can be a bit difficult.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Nevada - North Nevada",
"theater": "Nevada",
"authors": "Khopa",
"description": "",
"description": "<p>A scenario taking place in the NTTR. Here you can simulate a red flag exercise.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -1,143 +0,0 @@
{
"name": "Persian Gulf - Full",
"theater": "Persian Gulf",
"authors": "Khopa",
"description": "Full persian gulf map. For performance reason, please enable 'culling' in settings when playing this map. Known issues : Islands can only be captured through cheating.",
"player_points": [
{
"type": "carrier",
"id": 1001,
"x": 59514.324335475,
"y": 28165.517980635
},
{
"type": "lha",
"id": 1002,
"x": -27500.813952358,
"y": -147000.65947136
}
],
"enemy_points": [
{
"type": "airbase",
"id": "Ras Al Khaimah",
"size": 1000,
"importance": 1.2
},
{
"type": "airbase",
"id": "Khasab",
"size": 600,
"importance": 1.2
},
{
"type": "airbase",
"id": "Qeshm Island",
"radials": [
270,
315,
0,
45,
90,
135,
180
],
"size": 600,
"importance": 1.1
},
{
"type": "airbase",
"id": "Havadarya",
"radials": [
225,
270,
315,
0,
45
],
"size": 1000,
"importance": 1.4
},
{
"type": "airbase",
"id": "Bandar Abbas Intl",
"size": 2000,
"importance": 1.4
},
{
"type": "airbase",
"id": "Bandar Lengeh",
"radials": [
270,
315,
0,
45
],
"size": 600,
"importance": 1.4
},
{
"type": "airbase",
"id": "Shiraz International Airport",
"size": 2000,
"importance": 1.4,
"captured_invert": true
},
{
"type": "airbase",
"id": "Jiroft Airport",
"size": 2000,
"importance": 1.4
},
{
"type": "airbase",
"id": "Kerman Airport",
"size": 2000,
"importance": 1.4
},
{
"type": "airbase",
"id": "Lar Airbase",
"size": 1000,
"importance": 1.4
}
],
"links": [
[
"Khasab",
"Ras Al Khaimah"
],
[
"Bandar Lengeh",
"Lar Airbase"
],
[
"Havadarya",
"Lar Airbase"
],
[
"Bandar Abbas Intl",
"Havadarya"
],
[
"Bandar Abbas Intl",
"Jiroft Airport"
],
[
"Lar Airbase",
"Shiraz International Airport"
],
[
"Kerman Airport",
"Shiraz International Airport"
],
[
"Jiroft Airport",
"Kerman Airport"
],
[
"Kerman Airport",
"Lar Airbase"
]
]
}

View File

@ -2,7 +2,7 @@
"name": "Caucasus - Russia Small",
"theater": "Caucasus",
"authors": "Khopa",
"description": "",
"description": "<p>A small theater in Russia, progress from Mozdok to Maykop.</p><p>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.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Syria - Full Map",
"theater": "Syria",
"authors": "Khopa",
"description": "",
"description": "<p>Full map of Syria</p><p><strong>Note:</strong> This scenario is heavy on performance, enabling \"culling\" in settings is highly recommended.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Syria - Syrian Civil War",
"theater": "Syria",
"authors": "Khopa",
"description": "",
"description": "<p>This scenario can be used to simulate parts of the Syrian Civil War.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -2,7 +2,7 @@
"name": "Caucasus - Western Georgia",
"theater": "Caucasus",
"authors": "Khopa",
"description": "",
"description": "<p>A medium sized theater in the south west of the Caucasus map. Shouldn't be too hard on performance.</p>",
"player_points": [
{
"type": "airbase",

View File

@ -62,6 +62,7 @@
"Ticonderoga_class"
],
"requirements": {
"MB-339A/PAN by Frecce Tricolori Virtuali": "http://www.freccetricolorivirtuali.net/",
"Community A-4E": "https://heclak.github.io/community-a4e-c/"
},
"carrier_names": [

View File

@ -53,6 +53,7 @@
"Ticonderoga_class"
],
"requirements": {
"MB-339A/PAN by Frecce Tricolori Virtuali": "http://www.freccetricolorivirtuali.net/"
},
"carrier_names": [
],

View File

@ -30,7 +30,7 @@
"AvengerGenerator"
],
"requirements": {
"MB-339A": "http://www.freccetricolorivirtuali.net/"
"MB-339A/PAN by Frecce Tricolori Virtuali": "http://www.freccetricolorivirtuali.net/"
},
"has_jtac": true,
"jtac_unit": "MQ_9_Reaper"

View File

@ -71,7 +71,9 @@
"cruisers": [
"FSG_1241_1MP_Molniya"
],
"requirements": {},
"requirements": {
"SU-57 Felon By CubanAce Simulations": "https://www.digitalcombatsimulator.com/fr/files/2539621/"
},
"carrier_names": [
"Admiral Kuznetov"
],

View File

@ -0,0 +1,7 @@
<strong>Author(s): {{ campaign.authors }}</strong>
<br/>
<br/>
<strong>Number of control points:</strong> {{ campaign.theater.controlpoints|length }}
<br/>
{{ campaign.description|safe }}

View File

@ -5,7 +5,7 @@
<br/><br/>
<strong>Available airplanes:</strong>
<strong>Available aircrafts:</strong>
<ul>
{% for aircraft in faction.aircrafts %}
<li>{{aircraft.id}}</li>