From 558dc591a37e851ae4f080a2ab42da9cbd1b22f1 Mon Sep 17 00:00:00 2001 From: Simon Clark Date: Fri, 8 Jan 2021 09:42:09 +0000 Subject: [PATCH] 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. --- game/db.py | 9 +++++---- .../mission/flight/payload/QLoadoutEditor.py | 15 ++++----------- .../mission/flight/payload/QPylonEditor.py | 12 ++++++------ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/game/db.py b/game/db.py index 938ce1df..6c71a4e2 100644 --- a/game/db.py +++ b/game/db.py @@ -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, diff --git a/qt_ui/windows/mission/flight/payload/QLoadoutEditor.py b/qt_ui/windows/mission/flight/payload/QLoadoutEditor.py index da70a9fd..b84200e4 100644 --- a/qt_ui/windows/mission/flight/payload/QLoadoutEditor.py +++ b/qt_ui/windows/mission/flight/payload/QLoadoutEditor.py @@ -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) diff --git a/qt_ui/windows/mission/flight/payload/QPylonEditor.py b/qt_ui/windows/mission/flight/payload/QPylonEditor.py index 8333bf21..c869c380 100644 --- a/qt_ui/windows/mission/flight/payload/QPylonEditor.py +++ b/qt_ui/windows/mission/flight/payload/QPylonEditor.py @@ -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 == "": + 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")) \ No newline at end of file