Made the payload editor more user-friendly.

A user can now modify the existing default loadout, rather than starting from scratch.

Also adds WIP handling for removed pylons, which looks like it may need some PyDCS work.

Also fixes the F-14B default loadouts for everything OTHER than fighter sweep again.
This commit is contained in:
Simon Clark 2021-01-08 09:42:09 +00:00
parent 0bfd766a0b
commit 558dc591a3
3 changed files with 15 additions and 21 deletions

View File

@ -1018,7 +1018,8 @@ COMMON_OVERRIDE = {
AntishipStrike: "ANTISHIP",
GroundAttack: "STRIKE",
Escort: "CAP",
RunwayAttack: "RUNWAY_ATTACK"
RunwayAttack: "RUNWAY_ATTACK",
FighterSweep: "CAP"
}
"""
@ -1061,6 +1062,7 @@ PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = {
AntishipStrike: "ANTISHIP",
GroundAttack: "STRIKE",
Escort: "CAP HEAVY",
FighterSweep: "CAP HEAVY",
},
F_A_18C: {
CAP: "CAP HEAVY",
@ -1071,6 +1073,7 @@ PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = {
AntishipStrike: "ANTISHIP",
GroundAttack: "STRIKE",
Escort: "CAP HEAVY",
FighterSweep: "CAP HEAVY",
},
Tu_160: {
PinpointStrike: "Kh-65*12",
@ -1084,9 +1087,7 @@ PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = {
C_101CC: COMMON_OVERRIDE,
F_5E_3: COMMON_OVERRIDE,
F_14A_135_GR: COMMON_OVERRIDE,
F_14B: {
FighterSweep: "CAP",
},
F_14B: COMMON_OVERRIDE,
F_15C: COMMON_OVERRIDE,
F_111F: COMMON_OVERRIDE,
F_22A: COMMON_OVERRIDE,

View File

@ -39,14 +39,7 @@ class QLoadoutEditor(QGroupBox):
def on_toggle(self):
self.flight.use_custom_loadout = self.isChecked()
if not self.isChecked():
for i in self.findChildren(QPylonEditor):
for j in enumerate(Pylon.iter_pylons(self.flight.unit_type)):
# Only change the text in the pylon selector, not any actual data.
i.default_loadout(j[0])
else:
for i in self.findChildren(QPylonEditor):
# Clear the loadout so that the user has select it themself.
# If we don't do this, the user may end up leaving an entry as the default,
# which is just text, not actual data, meaning they'd have an empty pylon.
i.clear_loadout()
# When the toggle button is hit, reset the loadout to default.
# We need to do this regardless of whether we're toggling on or off.
for i in self.findChildren(QPylonEditor):
i.default_loadout(i.pylon.number)

View File

@ -45,6 +45,7 @@ class QPylonEditor(QComboBox):
def default_loadout(self, pylon: Pylon) -> None:
self.flight.unit_type.load_payloads()
self.setCurrentText("None")
pylon_default_weapon = None
loadout = None
# Iterate through each possible payload type for a given aircraft.
@ -56,10 +57,9 @@ class QPylonEditor(QComboBox):
for i in loadout:
if i[0] == self.pylon.number:
pylon_default_weapon = i[1]["clsid"]
# TODO: Handle removed pylons better.
if pylon_default_weapon == "<CLEAN>":
pylon_default_weapon = None
if pylon_default_weapon is not None:
self.setCurrentText(weapons_data.weapon_ids.get(pylon_default_weapon).get("name"))
else:
self.setCurrentText("None")
def clear_loadout(self) -> None:
self.setCurrentIndex(0)
#self.setCurrentIndex(self.findText(weapons_data.weapon_ids.get(pylon_default_weapon).get("name")))
self.setCurrentText(weapons_data.weapon_ids.get(pylon_default_weapon).get("name"))