mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
* Fix #1988 * Allow overwriting default aircraft properties * Add logging to setting invalid props
This commit is contained in:
parent
9e2e4ffa74
commit
bb72acd3ac
@ -4,7 +4,7 @@ import logging
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Iterator, Optional, TYPE_CHECKING, Type
|
from typing import Any, Iterator, Optional, TYPE_CHECKING, Type, Dict
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from dcs.helicopters import helicopter_map
|
from dcs.helicopters import helicopter_map
|
||||||
@ -317,6 +317,23 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
yield from helicopter_map.values()
|
yield from helicopter_map.values()
|
||||||
yield from plane_map.values()
|
yield from plane_map.values()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_props_overrides(
|
||||||
|
config: Dict[str, Any], aircraft: Type[FlyingType], data_path: Path
|
||||||
|
) -> None:
|
||||||
|
if aircraft.property_defaults is None:
|
||||||
|
logging.warning(
|
||||||
|
f"'{data_path.name}' attempted to set default prop that does not exist."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
for k in config:
|
||||||
|
if k in aircraft.property_defaults:
|
||||||
|
aircraft.property_defaults[k] = config[k]
|
||||||
|
else:
|
||||||
|
logging.warning(
|
||||||
|
f"'{data_path.name}' attempted to set default prop '{k}' that does not exist"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _each_variant_of(cls, aircraft: Type[FlyingType]) -> Iterator[AircraftType]:
|
def _each_variant_of(cls, aircraft: Type[FlyingType]) -> Iterator[AircraftType]:
|
||||||
data_path = Path("resources/units/aircraft") / f"{aircraft.id}.yaml"
|
data_path = Path("resources/units/aircraft") / f"{aircraft.id}.yaml"
|
||||||
@ -368,6 +385,10 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
if units_data == "metric":
|
if units_data == "metric":
|
||||||
units = MetricUnits()
|
units = MetricUnits()
|
||||||
|
|
||||||
|
prop_overrides = data.get("default_overrides")
|
||||||
|
if prop_overrides is not None:
|
||||||
|
cls._set_props_overrides(prop_overrides, aircraft, data_path)
|
||||||
|
|
||||||
for variant in data.get("variants", [aircraft.id]):
|
for variant in data.get("variants", [aircraft.id]):
|
||||||
yield AircraftType(
|
yield AircraftType(
|
||||||
dcs_unit_type=aircraft,
|
dcs_unit_type=aircraft,
|
||||||
|
|||||||
@ -6,7 +6,6 @@ from typing import Any, Optional, TYPE_CHECKING
|
|||||||
|
|
||||||
from dcs import Mission
|
from dcs import Mission
|
||||||
from dcs.flyingunit import FlyingUnit
|
from dcs.flyingunit import FlyingUnit
|
||||||
from dcs.planes import F_14A_135_GR, F_14B
|
|
||||||
from dcs.unit import Skill
|
from dcs.unit import Skill
|
||||||
from dcs.unitgroup import FlyingGroup
|
from dcs.unitgroup import FlyingGroup
|
||||||
|
|
||||||
@ -116,10 +115,6 @@ class FlightGroupConfigurator:
|
|||||||
laser_codes.append(self.laser_code_registry.get_next_laser_code())
|
laser_codes.append(self.laser_code_registry.get_next_laser_code())
|
||||||
else:
|
else:
|
||||||
laser_codes.append(None)
|
laser_codes.append(None)
|
||||||
if unit.unit_type is F_14B:
|
|
||||||
unit.set_property(F_14B.Properties.INSAlignmentStored.id, True)
|
|
||||||
elif unit.unit_type is F_14A_135_GR:
|
|
||||||
unit.set_property(F_14A_135_GR.Properties.INSAlignmentStored.id, True)
|
|
||||||
|
|
||||||
def setup_radios(self) -> RadioFrequency:
|
def setup_radios(self) -> RadioFrequency:
|
||||||
if self.flight.flight_type in {FlightType.AEWC, FlightType.REFUELING}:
|
if self.flight.flight_type in {FlightType.AEWC, FlightType.REFUELING}:
|
||||||
|
|||||||
@ -32,3 +32,5 @@ radios:
|
|||||||
namer: tomcat
|
namer: tomcat
|
||||||
intra_flight_radio_index: 2
|
intra_flight_radio_index: 2
|
||||||
inter_flight_radio_index: 1
|
inter_flight_radio_index: 1
|
||||||
|
default_overrides:
|
||||||
|
INSAlignmentStored: true
|
||||||
|
|||||||
@ -32,3 +32,6 @@ radios:
|
|||||||
namer: tomcat
|
namer: tomcat
|
||||||
intra_flight_radio_index: 2
|
intra_flight_radio_index: 2
|
||||||
inter_flight_radio_index: 1
|
inter_flight_radio_index: 1
|
||||||
|
default_overrides:
|
||||||
|
INSAlignmentStored: true
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user