mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
* Roadbase and ground spawn support Implemented support for roadbases and ground spawn slots at airfields and FOBs. The ground spawn slots can be inserted in campaigns by placing either an A-10A or an AJS37 at a runway or ramp. This will cause an invisible FARP, an ammo dump and a fuel dump to be placed (behind the slot in case of A-10A, to the side in case of AJS37) in the generated campaigns. The ground spawn slot can be used by human controlled aircraft in generated missions. Also allowed the use of the four-slot FARP and the single helipad in campaigns, in addition to the invisible FARP. The first waypoint of the placed aircraft will be the center of a Remove Statics trigger zone (which might or might not work in multiplayer due to a DCS limitation). Also implemented three new options in settings: - AI fixed-wing aircraft can use roadbases / bases with only ground spawns - This setting will allow the AI to use the roadbases for flights and transfers. AI flights will air-start from these bases, since the AI in DCS is not currently able to take off from ground spawns. - Spawn trucks at ground spawns in airbases instead of FARP statics - Spawn trucks at ground spawns in roadbases instead of FARP statics - These settings will replace the FARP statics with refueler and ammo trucks at roadbases. Enabling them might have a negative performance impact. * Modified calculate_parking_slots() so it now takes into account also helicopter slots on FARPs and also ground start slots (but only if the aircraft is flyable or the "AI fixed-wing aircraft can use roadbases / bases with only ground spawns" option is enabled in settings). * Improved the way parking slots are communicated on the basemenu window. * Refactored helipad and ground spawn appends to static methods _add_helipad and _add_ground_spawn in mizcampaignloader.py Added missing changelog entries. Fixed tgogenerator.py imports. Cleaned up ParkingType() construction. * Added test_control_point_parking for testing that the correct number of parking slots are returned for control point in test_controlpoint.py * Added test_parking_type_from_squadron to test the correct ParkingType object is returned for a squadron of Viggens in test_controlpoint.py * Added test_parking_type_from_aircraft to test the correct ParkingType object is returned for Viggen aircraft type in test_controlpoint.py --------- Co-authored-by: Raffson <Raffson@users.noreply.github.com>
117 lines
3.8 KiB
Python
117 lines
3.8 KiB
Python
from typing import Set
|
|
|
|
from PySide2.QtCore import Qt
|
|
from PySide2.QtWidgets import (
|
|
QGridLayout,
|
|
QHBoxLayout,
|
|
QLabel,
|
|
QScrollArea,
|
|
QVBoxLayout,
|
|
QWidget,
|
|
)
|
|
|
|
from game.dcs.aircrafttype import AircraftType
|
|
from game.purchaseadapter import AircraftPurchaseAdapter
|
|
from game.squadrons import Squadron
|
|
from game.theater import ControlPoint, ParkingType
|
|
from qt_ui.models import GameModel
|
|
from qt_ui.uiconstants import ICONS
|
|
from qt_ui.windows.basemenu.UnitTransactionFrame import UnitTransactionFrame
|
|
|
|
|
|
class QAircraftRecruitmentMenu(UnitTransactionFrame[Squadron]):
|
|
def __init__(self, cp: ControlPoint, game_model: GameModel) -> None:
|
|
super().__init__(game_model, AircraftPurchaseAdapter(cp))
|
|
self.cp = cp
|
|
self.game_model = game_model
|
|
self.purchase_groups = {}
|
|
self.bought_amount_labels = {}
|
|
self.existing_units_labels = {}
|
|
|
|
self.bought_amount_labels = {}
|
|
self.existing_units_labels = {}
|
|
|
|
self.hangar_status = QHangarStatus(game_model, self.cp)
|
|
|
|
main_layout = QVBoxLayout()
|
|
|
|
scroll_content = QWidget()
|
|
task_box_layout = QGridLayout()
|
|
row = 0
|
|
|
|
unit_types: Set[AircraftType] = set()
|
|
|
|
for squadron in cp.squadrons:
|
|
unit_types.add(squadron.aircraft)
|
|
|
|
sorted_squadrons = sorted(cp.squadrons, key=lambda s: (s.aircraft.name, s.name))
|
|
for row, squadron in enumerate(sorted_squadrons):
|
|
self.add_purchase_row(squadron, task_box_layout, row)
|
|
|
|
stretch = QVBoxLayout()
|
|
stretch.addStretch()
|
|
task_box_layout.addLayout(stretch, row, 0)
|
|
|
|
scroll_content.setLayout(task_box_layout)
|
|
scroll = QScrollArea()
|
|
scroll.setWidgetResizable(True)
|
|
scroll.setWidget(scroll_content)
|
|
main_layout.addLayout(self.hangar_status)
|
|
main_layout.addWidget(scroll)
|
|
self.setLayout(main_layout)
|
|
|
|
def sell_tooltip(self, is_enabled: bool) -> str:
|
|
if is_enabled:
|
|
return "Sell unit. Use Shift or Ctrl key to sell multiple units at once."
|
|
else:
|
|
return (
|
|
"Can not be sold because either no aircraft are available or are "
|
|
"already assigned to a mission."
|
|
)
|
|
|
|
def post_transaction_update(self) -> None:
|
|
super().post_transaction_update()
|
|
self.hangar_status.update_label()
|
|
|
|
|
|
class QHangarStatus(QHBoxLayout):
|
|
def __init__(self, game_model: GameModel, control_point: ControlPoint) -> None:
|
|
super().__init__()
|
|
self.game_model = game_model
|
|
self.control_point = control_point
|
|
|
|
self.icon = QLabel()
|
|
self.icon.setPixmap(ICONS["Hangar"])
|
|
self.text = QLabel("")
|
|
|
|
self.update_label()
|
|
self.addWidget(self.icon, Qt.AlignLeft)
|
|
self.addWidget(self.text, Qt.AlignLeft)
|
|
self.addStretch(50)
|
|
self.setAlignment(Qt.AlignLeft)
|
|
|
|
def update_label(self) -> None:
|
|
parking_type = ParkingType(
|
|
fixed_wing=True, fixed_wing_stol=True, rotary_wing=True
|
|
)
|
|
|
|
next_turn = self.control_point.allocated_aircraft(parking_type)
|
|
max_amount = self.control_point.total_aircraft_parking(parking_type)
|
|
|
|
components = [f"{next_turn.total_present} present"]
|
|
if next_turn.total_ordered > 0:
|
|
components.append(f"{next_turn.total_ordered} purchased")
|
|
elif next_turn.total_ordered < 0:
|
|
components.append(f"{-next_turn.total_ordered} sold")
|
|
|
|
transferring = next_turn.total_transferring
|
|
if transferring > 0:
|
|
components.append(f"{transferring} transferring in")
|
|
if transferring < 0:
|
|
components.append(f"{-transferring} transferring out")
|
|
|
|
details = ", ".join(components)
|
|
self.text.setText(
|
|
f"<strong>{next_turn.total}/{max_amount}</strong> ({details})"
|
|
)
|