mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fixup None loadouts for aircraft with no loadouts.
Aircraft that have no loadouts at all (such as the IL-78M) will have no loadouts and thus no values in the dropdown menu. If the player toggles the custom layout box we reset the flight's loadout to the selected loadout, and with no loadouts in the combo box that is None, and `Flight.loadout` isn't supposed to be optional. Check for that case in the loadout selector and replace with an empty loadout if that happens. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1402
This commit is contained in:
parent
4add853473
commit
727facfb90
@ -29,6 +29,7 @@ Saves from 4.0.0 are compatible with 4.1.0.
|
|||||||
* **[Mission Generation]** The lua data for other plugins is now generated correctly
|
* **[Mission Generation]** The lua data for other plugins is now generated correctly
|
||||||
* **[Mission Generation]** The legacy always-available tanker option no longer prevents mission creation.
|
* **[Mission Generation]** The legacy always-available tanker option no longer prevents mission creation.
|
||||||
* **[UI]** Statistics window tick marks are now always integers.
|
* **[UI]** Statistics window tick marks are now always integers.
|
||||||
|
* **[UI]** Toggling custom loadout for an aircraft with no preset loadouts no longer breaks the flight.
|
||||||
|
|
||||||
# 4.0.0
|
# 4.0.0
|
||||||
|
|
||||||
|
|||||||
@ -133,4 +133,8 @@ class Loadout:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Try group.load_task_default_loadout(loadout_for_task)
|
# TODO: Try group.load_task_default_loadout(loadout_for_task)
|
||||||
|
return cls.empty_loadout()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def empty_loadout(cls) -> Loadout:
|
||||||
return Loadout("Empty", {}, date=None)
|
return Loadout("Empty", {}, date=None)
|
||||||
|
|||||||
@ -47,8 +47,20 @@ class QFlightPayloadTab(QFrame):
|
|||||||
def reload_from_flight(self) -> None:
|
def reload_from_flight(self) -> None:
|
||||||
self.loadout_selector.setCurrentText(self.flight.loadout.name)
|
self.loadout_selector.setCurrentText(self.flight.loadout.name)
|
||||||
|
|
||||||
|
def loadout_at(self, index: int) -> Loadout:
|
||||||
|
loadout = self.loadout_selector.itemData(index)
|
||||||
|
if loadout is None:
|
||||||
|
return Loadout.empty_loadout()
|
||||||
|
return loadout
|
||||||
|
|
||||||
|
def current_loadout(self) -> Loadout:
|
||||||
|
loadout = self.loadout_selector.currentData()
|
||||||
|
if loadout is None:
|
||||||
|
return Loadout.empty_loadout()
|
||||||
|
return loadout
|
||||||
|
|
||||||
def on_new_loadout(self, index: int) -> None:
|
def on_new_loadout(self, index: int) -> None:
|
||||||
self.flight.loadout = self.loadout_selector.itemData(index)
|
self.flight.loadout = self.loadout_at(index)
|
||||||
self.payload_editor.reset_pylons()
|
self.payload_editor.reset_pylons()
|
||||||
|
|
||||||
def on_custom_toggled(self, use_custom: bool) -> None:
|
def on_custom_toggled(self, use_custom: bool) -> None:
|
||||||
@ -56,5 +68,5 @@ class QFlightPayloadTab(QFrame):
|
|||||||
if use_custom:
|
if use_custom:
|
||||||
self.flight.loadout = self.flight.loadout.derive_custom("Custom")
|
self.flight.loadout = self.flight.loadout.derive_custom("Custom")
|
||||||
else:
|
else:
|
||||||
self.flight.loadout = self.loadout_selector.currentData()
|
self.flight.loadout = self.current_loadout()
|
||||||
self.payload_editor.reset_pylons()
|
self.payload_editor.reset_pylons()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user