mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix loadouts to work with clean pylons.
This commit is contained in:
parent
f2e3ccd18c
commit
f63d218aae
@ -59,6 +59,9 @@ class Weapon:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_clsid(cls, clsid: str) -> Optional[Weapon]:
|
def from_clsid(cls, clsid: str) -> Optional[Weapon]:
|
||||||
data = weapon_ids.get(clsid)
|
data = weapon_ids.get(clsid)
|
||||||
|
if clsid == "<CLEAN>":
|
||||||
|
# Special case for a "weapon" that isn't exposed by pydcs.
|
||||||
|
return Weapon(clsid, "Clean", 0)
|
||||||
if data is None:
|
if data is None:
|
||||||
return None
|
return None
|
||||||
return cls.from_pydcs(data)
|
return cls.from_pydcs(data)
|
||||||
@ -70,7 +73,15 @@ class Pylon:
|
|||||||
allowed: Set[Weapon]
|
allowed: Set[Weapon]
|
||||||
|
|
||||||
def can_equip(self, weapon: Weapon) -> bool:
|
def can_equip(self, weapon: Weapon) -> bool:
|
||||||
return weapon in self.allowed
|
# TODO: Fix pydcs to support the <CLEAN> "weapon".
|
||||||
|
# <CLEAN> is a special case because pydcs doesn't know about that "weapon", so
|
||||||
|
# it's not compatible with *any* pylon. Just trust the loadout and try to equip
|
||||||
|
# it.
|
||||||
|
#
|
||||||
|
# A similar hack exists in QPylonEditor to forcibly add "Clean" to the list of
|
||||||
|
# valid configurations for that pylon if a loadout has been seen with that
|
||||||
|
# configuration.
|
||||||
|
return weapon in self.allowed or weapon.cls_id == "<CLEAN>"
|
||||||
|
|
||||||
def equip(self, group: FlyingGroup, weapon: Weapon) -> None:
|
def equip(self, group: FlyingGroup, weapon: Weapon) -> None:
|
||||||
if not self.can_equip(weapon):
|
if not self.can_equip(weapon):
|
||||||
|
|||||||
@ -1243,7 +1243,6 @@ class AircraftConflictGenerator:
|
|||||||
# Note that the only effect that the DCS task type has is in determining which
|
# Note that the only effect that the DCS task type has is in determining which
|
||||||
# waypoint actions the group may perform.
|
# waypoint actions the group may perform.
|
||||||
group.task = CAS.name
|
group.task = CAS.name
|
||||||
# But we still use the SEAD *loadout*.
|
|
||||||
self._setup_group(group, package, flight, dynamic_runways)
|
self._setup_group(group, package, flight, dynamic_runways)
|
||||||
self.configure_behavior(
|
self.configure_behavior(
|
||||||
group,
|
group,
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class QPylonEditor(QComboBox):
|
|||||||
self.flight = flight
|
self.flight = flight
|
||||||
self.pylon = pylon
|
self.pylon = pylon
|
||||||
self.game = game
|
self.game = game
|
||||||
|
self.has_added_clean_item = False
|
||||||
|
|
||||||
current = self.flight.loadout.pylons.get(self.pylon.number)
|
current = self.flight.loadout.pylons.get(self.pylon.number)
|
||||||
|
|
||||||
@ -45,9 +46,20 @@ class QPylonEditor(QComboBox):
|
|||||||
weapon = loadout.pylons.get(self.pylon.number)
|
weapon = loadout.pylons.get(self.pylon.number)
|
||||||
if weapon is None:
|
if weapon is None:
|
||||||
return None
|
return None
|
||||||
# TODO: Handle removed pylons better.
|
# TODO: Fix pydcs to support the <CLEAN> "weapon".
|
||||||
|
# These are not exported in the pydcs weapon map, which causes the pydcs pylon
|
||||||
|
# exporter to fail to include them in the supported list. Since they aren't
|
||||||
|
# known to be compatible (and we can't show them as compatible for *every*
|
||||||
|
# pylon, because they aren't), we won't have populated a "Clean" weapon when
|
||||||
|
# creating the selection list, so it's not selectable. To work around this, add
|
||||||
|
# the item to the list the first time it's encountered for the pylon.
|
||||||
|
#
|
||||||
|
# A similar hack exists in Pylon to support forcibly equipping this even when
|
||||||
|
# it's not known to be compatible.
|
||||||
if weapon.cls_id == "<CLEAN>":
|
if weapon.cls_id == "<CLEAN>":
|
||||||
return None
|
if not self.has_added_clean_item:
|
||||||
|
self.addItem("Clean", weapon)
|
||||||
|
self.has_added_clean_item = True
|
||||||
return weapon
|
return weapon
|
||||||
|
|
||||||
def matching_weapon_name(self, loadout: Loadout) -> str:
|
def matching_weapon_name(self, loadout: Loadout) -> str:
|
||||||
@ -55,7 +67,7 @@ class QPylonEditor(QComboBox):
|
|||||||
loadout = loadout.degrade_for_date(self.flight.unit_type, self.game.date)
|
loadout = loadout.degrade_for_date(self.flight.unit_type, self.game.date)
|
||||||
weapon = self.weapon_from_loadout(loadout)
|
weapon = self.weapon_from_loadout(loadout)
|
||||||
if weapon is None:
|
if weapon is None:
|
||||||
return ""
|
return "None"
|
||||||
return weapon.name
|
return weapon.name
|
||||||
|
|
||||||
def set_from(self, loadout: Loadout) -> None:
|
def set_from(self, loadout: Loadout) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user