mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add display name property for unit types.
Unlike the variant ID, this can be changed without breaking save compat.
This commit is contained in:
@@ -297,7 +297,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
else:
|
||||
# Slow like warbirds or helicopters
|
||||
# Use whichever is slowest - mach 0.35 or 50% of max speed
|
||||
logging.debug(f"{self.variant_id} max_speed * 0.5 is {max_speed * 0.5}")
|
||||
logging.debug(f"{self.display_name} max_speed * 0.5 is {max_speed * 0.5}")
|
||||
return min(Speed.from_mach(0.35, altitude), max_speed * 0.5)
|
||||
|
||||
def alloc_flight_radio(self, radio_registry: RadioRegistry) -> RadioFrequency:
|
||||
@@ -477,12 +477,14 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
for task_name, priority in data.get("tasks", {}).items():
|
||||
task_priorities[FlightType(task_name)] = priority
|
||||
|
||||
display_name = data.get("display_name", variant_id)
|
||||
return AircraftType(
|
||||
dcs_unit_type=aircraft,
|
||||
variant_id=variant_id,
|
||||
display_name=display_name,
|
||||
description=data.get(
|
||||
"description",
|
||||
f"No data. <a href=\"https://google.com/search?q=DCS+{variant_id.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant_id}</span></a>",
|
||||
f"No data. <a href=\"https://google.com/search?q=DCS+{display_name.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {display_name}</span></a>",
|
||||
),
|
||||
year_introduced=introduction,
|
||||
country_of_origin=data.get("origin", "No data."),
|
||||
|
||||
@@ -117,14 +117,16 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
|
||||
else:
|
||||
unit_class = UnitClass(class_name)
|
||||
|
||||
display_name = data.get("display_name", variant_id)
|
||||
return GroundUnitType(
|
||||
dcs_unit_type=vehicle,
|
||||
unit_class=unit_class,
|
||||
spawn_weight=data.get("spawn_weight", 0),
|
||||
variant_id=variant_id,
|
||||
display_name=display_name,
|
||||
description=data.get(
|
||||
"description",
|
||||
f"No data. <a href=\"https://google.com/search?q=DCS+{variant_id.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant_id}</span></a>",
|
||||
f"No data. <a href=\"https://google.com/search?q=DCS+{display_name.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {display_name}</span></a>",
|
||||
),
|
||||
year_introduced=introduction,
|
||||
country_of_origin=data.get("origin", "No data."),
|
||||
|
||||
@@ -68,13 +68,15 @@ class ShipUnitType(UnitType[Type[ShipType]]):
|
||||
class_name = data.get("class")
|
||||
unit_class = UnitClass(class_name)
|
||||
|
||||
display_name = data.get("display_name", variant_id)
|
||||
return ShipUnitType(
|
||||
dcs_unit_type=ship,
|
||||
unit_class=unit_class,
|
||||
variant_id=variant_id,
|
||||
display_name=data.get("display_name", variant_id),
|
||||
description=data.get(
|
||||
"description",
|
||||
f"No data. <a href=\"https://google.com/search?q=DCS+{variant_id.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant_id}</span></a>",
|
||||
f"No data. <a href=\"https://google.com/search?q=DCS+{display_name.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {display_name}</span></a>",
|
||||
),
|
||||
year_introduced=introduction,
|
||||
country_of_origin=data.get("origin", "No data."),
|
||||
|
||||
@@ -20,6 +20,7 @@ DcsUnitTypeT = TypeVar("DcsUnitTypeT", bound=Type[DcsUnitType])
|
||||
class UnitType(ABC, Generic[DcsUnitTypeT]):
|
||||
dcs_unit_type: DcsUnitTypeT
|
||||
variant_id: str
|
||||
display_name: str
|
||||
description: str
|
||||
year_introduced: str
|
||||
country_of_origin: str
|
||||
@@ -31,7 +32,7 @@ class UnitType(ABC, Generic[DcsUnitTypeT]):
|
||||
_loaded: ClassVar[bool] = False
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.variant_id
|
||||
return self.display_name
|
||||
|
||||
@property
|
||||
def dcs_id(self) -> str:
|
||||
|
||||
@@ -209,7 +209,7 @@ class FlightGroupConfigurator:
|
||||
TankerInfo(
|
||||
group_name=str(self.group.name),
|
||||
callsign=callsign,
|
||||
variant=self.flight.unit_type.variant_id,
|
||||
variant=self.flight.unit_type.display_name,
|
||||
freq=channel,
|
||||
tacan=tacan,
|
||||
start_time=self.flight.flight_plan.patrol_start_time,
|
||||
|
||||
@@ -142,7 +142,7 @@ class AircraftPurchaseAdapter(PurchaseAdapter[Squadron]):
|
||||
separator = "<br />"
|
||||
else:
|
||||
separator = " "
|
||||
return separator.join([item.aircraft.variant_id, str(item)])
|
||||
return separator.join([item.aircraft.display_name, str(item)])
|
||||
|
||||
def unit_type_of(self, item: Squadron) -> AircraftType:
|
||||
return item.aircraft
|
||||
|
||||
Reference in New Issue
Block a user