mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Follow up work: * Data entry. I plan to do the air-to-air missiles in the near term. I covered some variants of the AIM-120, AIM-7, and AIM-9 here, but there are variants of those weapons for each mounting rack that need to be done still, as well as all the non-US weapons. * Arbitrary start dates. https://github.com/Khopa/dcs_liberation/issues/490
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import logging
|
|
import operator
|
|
from typing import Optional
|
|
|
|
from PySide2.QtWidgets import QComboBox
|
|
|
|
from game import Game
|
|
from game.data.weapons import Pylon, Weapon
|
|
from gen.flights.flight import Flight
|
|
|
|
|
|
class QPylonEditor(QComboBox):
|
|
|
|
def __init__(self, game: Game, flight: Flight, pylon: Pylon) -> None:
|
|
super().__init__()
|
|
self.flight = flight
|
|
self.pylon = pylon
|
|
|
|
current = self.flight.loadout.get(self.pylon.number)
|
|
|
|
self.addItem("None", None)
|
|
if game.settings.restrict_weapons_by_date:
|
|
weapons = pylon.available_on(game.date)
|
|
else:
|
|
weapons = pylon.allowed
|
|
allowed = sorted(weapons, key=operator.attrgetter("name"))
|
|
for i, weapon in enumerate(allowed):
|
|
self.addItem(weapon.name, weapon)
|
|
if current == weapon:
|
|
self.setCurrentIndex(i + 1)
|
|
|
|
self.currentIndexChanged.connect(self.on_pylon_change)
|
|
|
|
def on_pylon_change(self):
|
|
selected: Optional[Weapon] = self.currentData()
|
|
self.flight.loadout[self.pylon.number] = selected
|
|
|
|
if selected is None:
|
|
logging.debug(f"Pylon {self.pylon.number} emptied")
|
|
else:
|
|
logging.debug(
|
|
f"Pylon {self.pylon.number} changed to {selected.name}")
|