Dan Albert 0e3bc1ce43 Loadout implementation cleanup.
Loadout selection no longer has two (disagreeing) implementations. What
the UI shows is now what the miz will have.

We now store the chosen layout in the Flight *always*, not just for
custom loadouts. This means that we do loadout lookups at the start of
each turn, but the data is cached in pydcs.

Era-specific loadout degradation is still done at generation (and
presentation) time. This is so that players can toggle that option and
have it affect the *current* turn, rather than the next one.
2021-05-17 01:23:00 -07:00

37 lines
1.3 KiB
Python

from PySide2.QtCore import Qt
from PySide2.QtWidgets import QFrame, QLabel, QVBoxLayout
from game import Game
from gen.flights.flight import Flight
from gen.flights.loadouts import Loadout
from qt_ui.windows.mission.flight.payload.QLoadoutEditor import QLoadoutEditor
class QFlightPayloadTab(QFrame):
def __init__(self, flight: Flight, game: Game):
super(QFlightPayloadTab, self).__init__()
self.flight = flight
self.payload_editor = QLoadoutEditor(flight, game)
layout = QVBoxLayout()
# Docs Link
docsText = QLabel(
'<a href="https://github.com/dcs-liberation/dcs_liberation/wiki/Custom-Loadouts"><span style="color:#FFFFFF;">How to create your own default loadout</span></a>'
)
docsText.setAlignment(Qt.AlignCenter)
docsText.setOpenExternalLinks(True)
self.payload_editor.toggled.connect(self.on_custom_toggled)
layout.addWidget(self.payload_editor)
layout.addWidget(docsText)
self.setLayout(layout)
def on_custom_toggled(self, use_custom: bool) -> None:
if use_custom:
self.flight.loadout = self.flight.loadout.derive_custom("Custom")
else:
self.flight.loadout = Loadout.default_for(self.flight)
self.payload_editor.reset_pylons()