Change squadrons to operate out of a single base.

https://github.com/dcs-liberation/dcs_liberation/issues/1145

Currently this is fixed at the start of the campaign. The squadron
locations are defined by the campaign file.

Follow up work:

* Track aircraft ownership per-squadron rather than per-airbase.
* UI for relocating squadrons.
* Ferry missions for squadrons that are relocating.
* Auto-relocation (probably only for retreat handling).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1138
This commit is contained in:
Dan Albert
2021-08-07 21:51:18 -07:00
parent 51e056a765
commit 90ad1f4a61
51 changed files with 1043 additions and 652 deletions

View File

@@ -233,10 +233,12 @@ def create_game(
# way.
inject_custom_payloads(Path(persistency.base_path()))
campaign = Campaign.from_file(campaign_path)
theater = campaign.load_theater()
generator = GameGenerator(
FACTIONS[blue],
FACTIONS[red],
campaign.load_theater(),
theater,
campaign.load_air_wing_config(theater),
Settings(
supercarrier=supercarrier,
automate_runway_repair=auto_procurement,

View File

@@ -13,7 +13,7 @@ from PySide2.QtCore import (
from PySide2.QtGui import QIcon
from game.game import Game
from game.squadrons import Squadron, Pilot
from game.squadrons.squadron import Pilot, Squadron
from game.theater.missiontarget import MissionTarget
from game.transfers import TransferOrder, PendingTransfers
from gen.ato import AirTaskingOrder, Package

View File

@@ -1,10 +1,10 @@
from PySide2.QtGui import QStandardItem, QStandardItemModel
from game import Game
from game.theater import ControlPointType
from game.theater import ControlPointType, BuildingGroundObject
from game.utils import Distance
from gen import BuildingGroundObject, Conflict, FlightWaypointType
from gen.flights.flight import FlightWaypoint
from gen.conflictgen import Conflict
from gen.flights.flight import FlightWaypoint, FlightWaypointType
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox

View File

@@ -28,7 +28,7 @@ from PySide2.QtWidgets import (
from game import Game
from game.dcs.aircrafttype import AircraftType
from game.squadrons import Squadron, AirWing, Pilot
from game.squadrons import AirWing, Pilot, Squadron
from gen.flights.flight import FlightType
from qt_ui.models import AirWingModel, SquadronModel
from qt_ui.uiconstants import AIRCRAFT_ICONS

View File

@@ -34,13 +34,17 @@ class SquadronDelegate(TwoColumnRowDelegate):
return index.data(AirWingModel.SquadronRole)
def text_for(self, index: QModelIndex, row: int, column: int) -> str:
squadron = self.squadron(index)
if (row, column) == (0, 0):
return self.squadron(index).name
if squadron.nickname:
nickname = f' "{squadron.nickname}"'
else:
nickname = ""
return f"{squadron.name}{nickname}"
elif (row, column) == (0, 1):
squadron = self.air_wing_model.data(index, AirWingModel.SquadronRole)
return squadron.aircraft.name
elif (row, column) == (1, 0):
return self.squadron(index).nickname or ""
return squadron.location.name
elif (row, column) == (1, 1):
squadron = self.squadron(index)
active = len(squadron.active_pilots)

View File

@@ -14,7 +14,6 @@ from PySide2.QtWidgets import (
QVBoxLayout,
QPushButton,
QHBoxLayout,
QGridLayout,
QLabel,
QCheckBox,
)

View File

@@ -45,22 +45,10 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
row = 0
unit_types: Set[AircraftType] = set()
for unit_type in self.game_model.game.blue.faction.aircrafts:
if self.cp.is_carrier and not unit_type.carrier_capable:
continue
if self.cp.is_lha and not unit_type.lha_capable:
continue
if (
self.cp.cptype in [ControlPointType.FOB, ControlPointType.FARP]
and unit_type not in helicopter_map.values()
):
continue
unit_types.add(unit_type)
for squadron in cp.squadrons:
unit_types.add(squadron.aircraft)
sorted_units = sorted(
unit_types,
key=lambda u: u.name,
)
sorted_units = sorted(unit_types, key=lambda u: u.name)
for row, unit_type in enumerate(sorted_units):
self.add_purchase_row(unit_type, task_box_layout, row)
stretch = QVBoxLayout()

View File

@@ -14,7 +14,7 @@ from PySide2.QtWidgets import (
from dcs.unittype import FlyingType
from game import Game
from game.squadrons import Squadron
from game.squadrons.squadron import Squadron
from game.theater import ControlPoint, OffMapSpawn
from gen.ato import Package
from gen.flights.flight import Flight, FlightRoster

View File

@@ -4,7 +4,7 @@ from typing import Type, Optional
from PySide2.QtWidgets import QComboBox
from dcs.unittype import FlyingType
from game.squadrons import AirWing
from game.squadrons.airwing import AirWing
from gen.flights.flight import FlightType

View File

@@ -14,7 +14,7 @@ from PySide2.QtWidgets import (
)
from game import Game
from game.squadrons import Pilot
from game.squadrons.pilot import Pilot
from gen.flights.flight import Flight, FlightRoster
from qt_ui.models import PackageModel

View File

@@ -113,10 +113,12 @@ class NewGameWizard(QtWidgets.QWizard):
blue_faction = self.faction_selection_page.selected_blue_faction
red_faction = self.faction_selection_page.selected_red_faction
theater = campaign.load_theater()
generator = GameGenerator(
blue_faction,
red_faction,
campaign.load_theater(),
theater,
campaign.load_air_wing_config(theater),
settings,
generator_settings,
mod_settings,