mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Improve unit system support in kneeboards.
* Factor out unit systems. * Add support for more unit systems (nautical and imperial). * Fuel units support. * Data for many more aircraft.
This commit is contained in:
@@ -33,7 +33,11 @@ from game.radio.channels import (
|
||||
from game.utils import (
|
||||
Distance,
|
||||
SPEED_OF_SOUND_AT_SEA_LEVEL,
|
||||
ImperialUnits,
|
||||
MetricUnits,
|
||||
NauticalUnits,
|
||||
Speed,
|
||||
UnitSystem,
|
||||
feet,
|
||||
knots,
|
||||
kph,
|
||||
@@ -154,8 +158,8 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
# main weapon. It'll RTB when it doesn't have gun ammo left.
|
||||
gunfighter: bool
|
||||
|
||||
# If true, kneeboards will be generated in metric units
|
||||
metric_kneeboard: bool
|
||||
# UnitSystem to use for the kneeboard, defaults to Nautical (kt/nm/ft)
|
||||
kneeboard_units: UnitSystem
|
||||
|
||||
# If true, kneeboards will display zulu times
|
||||
utc_kneeboard: bool
|
||||
@@ -376,6 +380,13 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
except KeyError:
|
||||
introduction = "No data."
|
||||
|
||||
units_data = data.get("kneeboard_units", "nautical").lower()
|
||||
units: UnitSystem = NauticalUnits()
|
||||
if units_data == "imperial":
|
||||
units = ImperialUnits()
|
||||
if units_data == "metric":
|
||||
units = MetricUnits()
|
||||
|
||||
for variant in data.get("variants", [aircraft.id]):
|
||||
yield AircraftType(
|
||||
dcs_unit_type=aircraft,
|
||||
@@ -401,6 +412,6 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
intra_flight_radio=radio_config.intra_flight,
|
||||
channel_allocator=radio_config.channel_allocator,
|
||||
channel_namer=radio_config.channel_namer,
|
||||
metric_kneeboard=data.get("metric_kneeboard", False),
|
||||
kneeboard_units=units,
|
||||
utc_kneeboard=data.get("utc_kneeboard", False),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user