mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Rename UnitType.name what it is: the variant ID.
This property affects safe compat because the ID is what gets preserved in the save, but it's unfortunately also used as the display name, which means changing the display name breaks save compat. It also prevents us from changing display names without breaking faction definitions. This is the first step in fixing that. The next is adding a separate display_name property that can be updated without breaking either of those.
This commit is contained in:
parent
97ee6ba19f
commit
1760532168
@ -289,7 +289,7 @@ class ForceGroup:
|
|||||||
unit.id = game.next_unit_id()
|
unit.id = game.next_unit_id()
|
||||||
# Add unit name escaped so that we do not have scripting issues later
|
# Add unit name escaped so that we do not have scripting issues later
|
||||||
unit.name = escape_string_for_lua(
|
unit.name = escape_string_for_lua(
|
||||||
unit.unit_type.name if unit.unit_type else unit.type.name
|
unit.unit_type.variant_id if unit.unit_type else unit.type.name
|
||||||
)
|
)
|
||||||
unit.position = PointWithHeading.from_point(
|
unit.position = PointWithHeading.from_point(
|
||||||
ground_object.position + unit.position,
|
ground_object.position + unit.position,
|
||||||
|
|||||||
@ -39,6 +39,7 @@ from game.radio.channels import (
|
|||||||
ViperChannelNamer,
|
ViperChannelNamer,
|
||||||
WarthogChannelNamer,
|
WarthogChannelNamer,
|
||||||
)
|
)
|
||||||
|
from game.savecompat import has_save_compat_for
|
||||||
from game.utils import (
|
from game.utils import (
|
||||||
Distance,
|
Distance,
|
||||||
ImperialUnits,
|
ImperialUnits,
|
||||||
@ -219,7 +220,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls, unit_type: AircraftType) -> None:
|
def register(cls, unit_type: AircraftType) -> None:
|
||||||
cls._by_name[unit_type.name] = unit_type
|
cls._by_name[unit_type.variant_id] = unit_type
|
||||||
cls._by_unit_type[unit_type.dcs_unit_type].append(unit_type)
|
cls._by_unit_type[unit_type.dcs_unit_type].append(unit_type)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -297,7 +298,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
else:
|
else:
|
||||||
# Slow like warbirds or helicopters
|
# Slow like warbirds or helicopters
|
||||||
# Use whichever is slowest - mach 0.35 or 50% of max speed
|
# Use whichever is slowest - mach 0.35 or 50% of max speed
|
||||||
logging.debug(f"{self.name} max_speed * 0.5 is {max_speed * 0.5}")
|
logging.debug(f"{self.variant_id} max_speed * 0.5 is {max_speed * 0.5}")
|
||||||
return min(Speed.from_mach(0.35, altitude), 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:
|
def alloc_flight_radio(self, radio_registry: RadioRegistry) -> RadioFrequency:
|
||||||
@ -352,9 +353,14 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
def task_priority(self, task: FlightType) -> int:
|
def task_priority(self, task: FlightType) -> int:
|
||||||
return self.task_priorities[task]
|
return self.task_priorities[task]
|
||||||
|
|
||||||
|
@has_save_compat_for(9)
|
||||||
def __setstate__(self, state: dict[str, Any]) -> None:
|
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||||
|
# Save compat: the `name` field has been renamed `variant_id`.
|
||||||
|
if "name" in state:
|
||||||
|
state["variant_id"] = state.pop("name")
|
||||||
|
|
||||||
# Update any existing models with new data on load.
|
# Update any existing models with new data on load.
|
||||||
updated = AircraftType.named(state["name"])
|
updated = AircraftType.named(state["variant_id"])
|
||||||
state.update(updated.__dict__)
|
state.update(updated.__dict__)
|
||||||
self.__dict__.update(state)
|
self.__dict__.update(state)
|
||||||
|
|
||||||
@ -485,7 +491,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
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,
|
||||||
name=variant,
|
variant_id=variant,
|
||||||
description=data.get(
|
description=data.get(
|
||||||
"description",
|
"description",
|
||||||
f"No data. <a href=\"https://google.com/search?q=DCS+{variant.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant}</span></a>",
|
f"No data. <a href=\"https://google.com/search?q=DCS+{variant.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant}</span></a>",
|
||||||
@ -552,4 +558,4 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
AircraftType._custom_weapon_injections(aircraft, data)
|
AircraftType._custom_weapon_injections(aircraft, data)
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return hash(self.name)
|
return hash(self.variant_id)
|
||||||
|
|||||||
@ -12,6 +12,7 @@ from dcs.vehicles import vehicle_map
|
|||||||
|
|
||||||
from game.data.units import UnitClass
|
from game.data.units import UnitClass
|
||||||
from game.dcs.unittype import UnitType
|
from game.dcs.unittype import UnitType
|
||||||
|
from game.savecompat import has_save_compat_for
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -65,9 +66,20 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
|
|||||||
dict[type[VehicleType], list[GroundUnitType]]
|
dict[type[VehicleType], list[GroundUnitType]]
|
||||||
] = defaultdict(list)
|
] = defaultdict(list)
|
||||||
|
|
||||||
|
@has_save_compat_for(9)
|
||||||
|
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||||
|
# Save compat: the `name` field has been renamed `variant_id`.
|
||||||
|
if "name" in state:
|
||||||
|
state["variant_id"] = state.pop("name")
|
||||||
|
|
||||||
|
# Update any existing models with new data on load.
|
||||||
|
updated = GroundUnitType.named(state["variant_id"])
|
||||||
|
state.update(updated.__dict__)
|
||||||
|
self.__dict__.update(state)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls, unit_type: GroundUnitType) -> None:
|
def register(cls, unit_type: GroundUnitType) -> None:
|
||||||
cls._by_name[unit_type.name] = unit_type
|
cls._by_name[unit_type.variant_id] = unit_type
|
||||||
cls._by_unit_type[unit_type.dcs_unit_type].append(unit_type)
|
cls._by_unit_type[unit_type.dcs_unit_type].append(unit_type)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -115,7 +127,7 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
|
|||||||
dcs_unit_type=vehicle,
|
dcs_unit_type=vehicle,
|
||||||
unit_class=unit_class,
|
unit_class=unit_class,
|
||||||
spawn_weight=data.get("spawn_weight", 0),
|
spawn_weight=data.get("spawn_weight", 0),
|
||||||
name=variant,
|
variant_id=variant,
|
||||||
description=data.get(
|
description=data.get(
|
||||||
"description",
|
"description",
|
||||||
f"No data. <a href=\"https://google.com/search?q=DCS+{variant.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant}</span></a>",
|
f"No data. <a href=\"https://google.com/search?q=DCS+{variant.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant}</span></a>",
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import logging
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import ClassVar, Iterator, Type
|
from typing import ClassVar, Iterator, Type, Any
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from dcs.ships import ship_map
|
from dcs.ships import ship_map
|
||||||
@ -12,6 +12,7 @@ from dcs.unittype import ShipType
|
|||||||
|
|
||||||
from game.data.units import UnitClass
|
from game.data.units import UnitClass
|
||||||
from game.dcs.unittype import UnitType
|
from game.dcs.unittype import UnitType
|
||||||
|
from game.savecompat import has_save_compat_for
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@ -21,9 +22,20 @@ class ShipUnitType(UnitType[Type[ShipType]]):
|
|||||||
list
|
list
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@has_save_compat_for(9)
|
||||||
|
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||||
|
# Save compat: the `name` field has been renamed `variant_id`.
|
||||||
|
if "name" in state:
|
||||||
|
state["variant_id"] = state.pop("name")
|
||||||
|
|
||||||
|
# Update any existing models with new data on load.
|
||||||
|
updated = ShipUnitType.named(state["variant_id"])
|
||||||
|
state.update(updated.__dict__)
|
||||||
|
self.__dict__.update(state)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls, unit_type: ShipUnitType) -> None:
|
def register(cls, unit_type: ShipUnitType) -> None:
|
||||||
cls._by_name[unit_type.name] = unit_type
|
cls._by_name[unit_type.variant_id] = unit_type
|
||||||
cls._by_unit_type[unit_type.dcs_unit_type].append(unit_type)
|
cls._by_unit_type[unit_type.dcs_unit_type].append(unit_type)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -66,7 +78,7 @@ class ShipUnitType(UnitType[Type[ShipType]]):
|
|||||||
yield ShipUnitType(
|
yield ShipUnitType(
|
||||||
dcs_unit_type=ship,
|
dcs_unit_type=ship,
|
||||||
unit_class=unit_class,
|
unit_class=unit_class,
|
||||||
name=variant,
|
variant_id=variant,
|
||||||
description=data.get(
|
description=data.get(
|
||||||
"description",
|
"description",
|
||||||
f"No data. <a href=\"https://google.com/search?q=DCS+{variant.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant}</span></a>",
|
f"No data. <a href=\"https://google.com/search?q=DCS+{variant.replace(' ', '+')}\"><span style=\"color:#FFFFFF\">Google {variant}</span></a>",
|
||||||
|
|||||||
@ -16,7 +16,7 @@ DcsUnitTypeT = TypeVar("DcsUnitTypeT", bound=Type[DcsUnitType])
|
|||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class UnitType(ABC, Generic[DcsUnitTypeT]):
|
class UnitType(ABC, Generic[DcsUnitTypeT]):
|
||||||
dcs_unit_type: DcsUnitTypeT
|
dcs_unit_type: DcsUnitTypeT
|
||||||
name: str
|
variant_id: str
|
||||||
description: str
|
description: str
|
||||||
year_introduced: str
|
year_introduced: str
|
||||||
country_of_origin: str
|
country_of_origin: str
|
||||||
@ -28,7 +28,7 @@ class UnitType(ABC, Generic[DcsUnitTypeT]):
|
|||||||
_loaded: ClassVar[bool] = False
|
_loaded: ClassVar[bool] = False
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.variant_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dcs_id(self) -> str:
|
def dcs_id(self) -> str:
|
||||||
|
|||||||
@ -169,7 +169,7 @@ class Faction:
|
|||||||
def air_defenses(self) -> list[str]:
|
def air_defenses(self) -> list[str]:
|
||||||
"""Returns the Air Defense types"""
|
"""Returns the Air Defense types"""
|
||||||
# This is used for the faction overview in NewGameWizard
|
# This is used for the faction overview in NewGameWizard
|
||||||
air_defenses = [a.name for a in self.air_defense_units]
|
air_defenses = [a.variant_id for a in self.air_defense_units]
|
||||||
air_defenses.extend(
|
air_defenses.extend(
|
||||||
[
|
[
|
||||||
pg.name
|
pg.name
|
||||||
|
|||||||
@ -209,7 +209,7 @@ class FlightGroupConfigurator:
|
|||||||
TankerInfo(
|
TankerInfo(
|
||||||
group_name=str(self.group.name),
|
group_name=str(self.group.name),
|
||||||
callsign=callsign,
|
callsign=callsign,
|
||||||
variant=self.flight.unit_type.name,
|
variant=self.flight.unit_type.variant_id,
|
||||||
freq=channel,
|
freq=channel,
|
||||||
tacan=tacan,
|
tacan=tacan,
|
||||||
start_time=self.flight.flight_plan.patrol_start_time,
|
start_time=self.flight.flight_plan.patrol_start_time,
|
||||||
|
|||||||
@ -484,13 +484,13 @@ class NameGenerator:
|
|||||||
else:
|
else:
|
||||||
name_str = "{} {}".format(flight.package.target.name, flight.flight_type)
|
name_str = "{} {}".format(flight.package.target.name, flight.flight_type)
|
||||||
return "{}|{}|{}|{}|".format(
|
return "{}|{}|{}|{}|".format(
|
||||||
name_str, country.id, cls.aircraft_number, flight.unit_type.name
|
name_str, country.id, cls.aircraft_number, flight.unit_type.variant_id
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def next_unit_name(cls, country: Country, unit_type: UnitType[Any]) -> str:
|
def next_unit_name(cls, country: Country, unit_type: UnitType[Any]) -> str:
|
||||||
cls.number += 1
|
cls.number += 1
|
||||||
return "unit|{}|{}|{}|".format(country.id, cls.number, unit_type.name)
|
return "unit|{}|{}|{}|".format(country.id, cls.number, unit_type.variant_id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def next_infantry_name(cls, country: Country, unit_type: UnitType[Any]) -> str:
|
def next_infantry_name(cls, country: Country, unit_type: UnitType[Any]) -> str:
|
||||||
@ -498,7 +498,7 @@ class NameGenerator:
|
|||||||
return "infantry|{}|{}|{}|".format(
|
return "infantry|{}|{}|{}|".format(
|
||||||
country.id,
|
country.id,
|
||||||
cls.infantry_number,
|
cls.infantry_number,
|
||||||
unit_type.name,
|
unit_type.variant_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -509,7 +509,7 @@ class NameGenerator:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def next_tanker_name(cls, country: Country, unit_type: AircraftType) -> str:
|
def next_tanker_name(cls, country: Country, unit_type: AircraftType) -> str:
|
||||||
cls.number += 1
|
cls.number += 1
|
||||||
return "tanker|{}|{}|0|{}".format(country.id, cls.number, unit_type.name)
|
return "tanker|{}|{}|0|{}".format(country.id, cls.number, unit_type.variant_id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def next_carrier_name(cls, country: Country) -> str:
|
def next_carrier_name(cls, country: Country) -> str:
|
||||||
|
|||||||
@ -142,7 +142,7 @@ class AircraftPurchaseAdapter(PurchaseAdapter[Squadron]):
|
|||||||
separator = "<br />"
|
separator = "<br />"
|
||||||
else:
|
else:
|
||||||
separator = " "
|
separator = " "
|
||||||
return separator.join([item.aircraft.name, str(item)])
|
return separator.join([item.aircraft.variant_id, str(item)])
|
||||||
|
|
||||||
def unit_type_of(self, item: Squadron) -> AircraftType:
|
def unit_type_of(self, item: Squadron) -> AircraftType:
|
||||||
return item.aircraft
|
return item.aircraft
|
||||||
|
|||||||
@ -611,12 +611,12 @@ class AircraftTypeList(QListView):
|
|||||||
self.add_aircraft_type(aircraft)
|
self.add_aircraft_type(aircraft)
|
||||||
|
|
||||||
def remove_aircraft_type(self, aircraft: AircraftType):
|
def remove_aircraft_type(self, aircraft: AircraftType):
|
||||||
for item in self.item_model.findItems(aircraft.name):
|
for item in self.item_model.findItems(aircraft.variant_id):
|
||||||
self.item_model.removeRow(item.row())
|
self.item_model.removeRow(item.row())
|
||||||
self.page_index_changed.emit(self.selectionModel().currentIndex().row())
|
self.page_index_changed.emit(self.selectionModel().currentIndex().row())
|
||||||
|
|
||||||
def add_aircraft_type(self, aircraft: AircraftType):
|
def add_aircraft_type(self, aircraft: AircraftType):
|
||||||
aircraft_item = QStandardItem(aircraft.name)
|
aircraft_item = QStandardItem(aircraft.variant_id)
|
||||||
icon = self.icon_for(aircraft)
|
icon = self.icon_for(aircraft)
|
||||||
if icon is not None:
|
if icon is not None:
|
||||||
aircraft_item.setIcon(icon)
|
aircraft_item.setIcon(icon)
|
||||||
@ -728,7 +728,7 @@ class AirWingConfigurationTab(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Add Squadron
|
# Add Squadron
|
||||||
if not self.type_list.item_model.findItems(selected_type.name):
|
if not self.type_list.item_model.findItems(selected_type.variant_id):
|
||||||
self.type_list.add_aircraft_type(selected_type)
|
self.type_list.add_aircraft_type(selected_type)
|
||||||
# TODO Select the newly added type
|
# TODO Select the newly added type
|
||||||
self.squadrons_panel.add_squadron_to_panel(squadron)
|
self.squadrons_panel.add_squadron_to_panel(squadron)
|
||||||
@ -814,8 +814,8 @@ class SquadronAircraftTypeSelector(QComboBox):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.setSizeAdjustPolicy(self.AdjustToContents)
|
self.setSizeAdjustPolicy(self.AdjustToContents)
|
||||||
|
|
||||||
for type in sorted(types, key=lambda type: type.name):
|
for type in sorted(types, key=lambda type: type.variant_id):
|
||||||
self.addItem(type.name, type)
|
self.addItem(type.variant_id, type)
|
||||||
|
|
||||||
if selected_aircraft:
|
if selected_aircraft:
|
||||||
self.setCurrentText(selected_aircraft)
|
self.setCurrentText(selected_aircraft)
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class SquadronDelegate(TwoColumnRowDelegate):
|
|||||||
nickname = ""
|
nickname = ""
|
||||||
return f"{squadron.name}{nickname}"
|
return f"{squadron.name}{nickname}"
|
||||||
elif (row, column) == (0, 1):
|
elif (row, column) == (0, 1):
|
||||||
return squadron.aircraft.name
|
return squadron.aircraft.variant_id
|
||||||
elif (row, column) == (1, 0):
|
elif (row, column) == (1, 0):
|
||||||
return squadron.location.name
|
return squadron.location.name
|
||||||
elif (row, column) == (1, 1):
|
elif (row, column) == (1, 1):
|
||||||
@ -130,7 +130,7 @@ class AircraftInventoryData:
|
|||||||
player = "Player" if pilot.player else "AI"
|
player = "Player" if pilot.player else "AI"
|
||||||
yield AircraftInventoryData(
|
yield AircraftInventoryData(
|
||||||
flight.departure.name,
|
flight.departure.name,
|
||||||
flight.unit_type.name,
|
flight.unit_type.variant_id,
|
||||||
flight_type,
|
flight_type,
|
||||||
target,
|
target,
|
||||||
pilot_name,
|
pilot_name,
|
||||||
@ -143,7 +143,7 @@ class AircraftInventoryData:
|
|||||||
) -> Iterator[AircraftInventoryData]:
|
) -> Iterator[AircraftInventoryData]:
|
||||||
for _ in range(0, squadron.untasked_aircraft):
|
for _ in range(0, squadron.untasked_aircraft):
|
||||||
yield AircraftInventoryData(
|
yield AircraftInventoryData(
|
||||||
squadron.name, squadron.aircraft.name, "Idle", "N/A", "N/A", "N/A"
|
squadron.name, squadron.aircraft.variant_id, "Idle", "N/A", "N/A", "N/A"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,9 @@ class LossGrid(QGridLayout):
|
|||||||
def __init__(self, debriefing: Debriefing, player: bool) -> None:
|
def __init__(self, debriefing: Debriefing, player: bool) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.add_loss_rows(debriefing.air_losses.by_type(player), lambda u: u.name)
|
self.add_loss_rows(
|
||||||
|
debriefing.air_losses.by_type(player), lambda u: u.variant_id
|
||||||
|
)
|
||||||
self.add_loss_rows(
|
self.add_loss_rows(
|
||||||
debriefing.front_line_losses_by_type(player), lambda u: str(u)
|
debriefing.front_line_losses_by_type(player), lambda u: str(u)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -66,7 +66,7 @@ class QUnitInfoWindow(QDialog):
|
|||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
self.game = game
|
self.game = game
|
||||||
self.unit_type = unit_type
|
self.unit_type = unit_type
|
||||||
self.name = unit_type.name
|
self.name = unit_type.variant_id
|
||||||
self.setWindowTitle(f"Unit Info: {self.name}")
|
self.setWindowTitle(f"Unit Info: {self.name}")
|
||||||
self.setWindowIcon(QIcon("./resources/icon.png"))
|
self.setWindowIcon(QIcon("./resources/icon.png"))
|
||||||
self.setMinimumHeight(570)
|
self.setMinimumHeight(570)
|
||||||
@ -93,7 +93,7 @@ class QUnitInfoWindow(QDialog):
|
|||||||
self.details_grid_layout.setMargin(0)
|
self.details_grid_layout.setMargin(0)
|
||||||
|
|
||||||
self.name_box = QLabel(
|
self.name_box = QLabel(
|
||||||
f"<b>Name:</b> {unit_type.manufacturer} {unit_type.name}"
|
f"<b>Name:</b> {unit_type.manufacturer} {unit_type.variant_id}"
|
||||||
)
|
)
|
||||||
self.name_box.setProperty("style", "info-element")
|
self.name_box.setProperty("style", "info-element")
|
||||||
|
|
||||||
|
|||||||
@ -33,11 +33,11 @@ class DepartingConvoyInfo(QGroupBox):
|
|||||||
if unit_type.dcs_id in VEHICLES_ICONS.keys():
|
if unit_type.dcs_id in VEHICLES_ICONS.keys():
|
||||||
icon.setPixmap(VEHICLES_ICONS[unit_type.dcs_id])
|
icon.setPixmap(VEHICLES_ICONS[unit_type.dcs_id])
|
||||||
else:
|
else:
|
||||||
icon.setText("<b>" + unit_type.name + "</b>")
|
icon.setText("<b>" + unit_type.variant_id + "</b>")
|
||||||
icon.setProperty("style", "icon-armor")
|
icon.setProperty("style", "icon-armor")
|
||||||
unit_layout.addWidget(icon, idx, 0)
|
unit_layout.addWidget(icon, idx, 0)
|
||||||
unit_layout.addWidget(
|
unit_layout.addWidget(
|
||||||
QLabel(f"{count} x <strong>{unit_type.name}</strong>"),
|
QLabel(f"{count} x <strong>{unit_type.variant_id}</strong>"),
|
||||||
idx,
|
idx,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class UnitTransferList(QFrame):
|
|||||||
task_box_layout = QGridLayout()
|
task_box_layout = QGridLayout()
|
||||||
scroll_content.setLayout(task_box_layout)
|
scroll_content.setLayout(task_box_layout)
|
||||||
|
|
||||||
units_column = sorted(cp.base.armor, key=lambda u: u.name)
|
units_column = sorted(cp.base.armor, key=lambda u: u.variant_id)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for count, unit_type in enumerate(units_column):
|
for count, unit_type in enumerate(units_column):
|
||||||
@ -173,7 +173,7 @@ class ScrollingUnitTransferGrid(QFrame):
|
|||||||
unit_types = set(self.game_model.game.faction_for(player=True).ground_units)
|
unit_types = set(self.game_model.game.faction_for(player=True).ground_units)
|
||||||
sorted_units = sorted(
|
sorted_units = sorted(
|
||||||
{u for u in unit_types if self.cp.base.total_units_of_type(u)},
|
{u for u in unit_types if self.cp.base.total_units_of_type(u)},
|
||||||
key=lambda u: u.name,
|
key=lambda u: u.variant_id,
|
||||||
)
|
)
|
||||||
for row, unit_type in enumerate(sorted_units):
|
for row, unit_type in enumerate(sorted_units):
|
||||||
self.add_unit_row(unit_type, task_box_layout, row)
|
self.add_unit_row(unit_type, task_box_layout, row)
|
||||||
@ -205,7 +205,7 @@ class ScrollingUnitTransferGrid(QFrame):
|
|||||||
|
|
||||||
origin_inventory = self.cp.base.total_units_of_type(unit_type)
|
origin_inventory = self.cp.base.total_units_of_type(unit_type)
|
||||||
|
|
||||||
unit_name = QLabel(f"<b>{unit_type.name}</b>")
|
unit_name = QLabel(f"<b>{unit_type.variant_id}</b>")
|
||||||
unit_name.setSizePolicy(
|
unit_name.setSizePolicy(
|
||||||
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -44,7 +44,9 @@ class QAircraftRecruitmentMenu(UnitTransactionFrame[Squadron]):
|
|||||||
for squadron in cp.squadrons:
|
for squadron in cp.squadrons:
|
||||||
unit_types.add(squadron.aircraft)
|
unit_types.add(squadron.aircraft)
|
||||||
|
|
||||||
sorted_squadrons = sorted(cp.squadrons, key=lambda s: (s.aircraft.name, s.name))
|
sorted_squadrons = sorted(
|
||||||
|
cp.squadrons, key=lambda s: (s.aircraft.variant_id, s.name)
|
||||||
|
)
|
||||||
for row, squadron in enumerate(sorted_squadrons):
|
for row, squadron in enumerate(sorted_squadrons):
|
||||||
self.add_purchase_row(squadron, task_box_layout, row)
|
self.add_purchase_row(squadron, task_box_layout, row)
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class QArmorRecruitmentMenu(UnitTransactionFrame[GroundUnitType]):
|
|||||||
unit_types = list(
|
unit_types = list(
|
||||||
set(self.game_model.game.faction_for(player=True).ground_units)
|
set(self.game_model.game.faction_for(player=True).ground_units)
|
||||||
)
|
)
|
||||||
unit_types.sort(key=lambda u: u.name)
|
unit_types.sort(key=lambda u: u.variant_id)
|
||||||
for row, unit_type in enumerate(unit_types):
|
for row, unit_type in enumerate(unit_types):
|
||||||
self.add_purchase_row(unit_type, task_box_layout, row)
|
self.add_purchase_row(unit_type, task_box_layout, row)
|
||||||
stretch = QVBoxLayout()
|
stretch = QVBoxLayout()
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class QIntelInfo(QFrame):
|
|||||||
).present.items():
|
).present.items():
|
||||||
if count:
|
if count:
|
||||||
task_type = unit_type.dcs_unit_type.task_default.name
|
task_type = unit_type.dcs_unit_type.task_default.name
|
||||||
units_by_task[task_type][unit_type.name] += count
|
units_by_task[task_type][unit_type.variant_id] += count
|
||||||
|
|
||||||
units_by_task = {
|
units_by_task = {
|
||||||
task: units_by_task[task] for task in sorted(units_by_task.keys())
|
task: units_by_task[task] for task in sorted(units_by_task.keys())
|
||||||
@ -41,7 +41,7 @@ class QIntelInfo(QFrame):
|
|||||||
front_line_units = defaultdict(int)
|
front_line_units = defaultdict(int)
|
||||||
for unit_type, count in self.cp.base.armor.items():
|
for unit_type, count in self.cp.base.armor.items():
|
||||||
if count:
|
if count:
|
||||||
front_line_units[unit_type.name] += count
|
front_line_units[unit_type.variant_id] += count
|
||||||
|
|
||||||
units_by_task["Front line units"] = front_line_units
|
units_by_task["Front line units"] = front_line_units
|
||||||
for task, unit_types in units_by_task.items():
|
for task, unit_types in units_by_task.items():
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class QTgoLayoutGroupRow(QWidget):
|
|||||||
# Add all possible units with the price
|
# Add all possible units with the price
|
||||||
for unit_type in force_group.unit_types_for_group(group):
|
for unit_type in force_group.unit_types_for_group(group):
|
||||||
self.unit_selector.addItem(
|
self.unit_selector.addItem(
|
||||||
f"{unit_type.name} [${unit_type.price}M]",
|
f"{unit_type.variant_id} [${unit_type.price}M]",
|
||||||
userData=(unit_type.dcs_unit_type, unit_type.price),
|
userData=(unit_type.dcs_unit_type, unit_type.price),
|
||||||
)
|
)
|
||||||
# Add all possible statics with price = 0
|
# Add all possible statics with price = 0
|
||||||
|
|||||||
@ -88,11 +88,11 @@ class AircraftIntelLayout(IntelTableLayout):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
self.add_header(f"{control_point.name} ({base_total})")
|
self.add_header(f"{control_point.name} ({base_total})")
|
||||||
for airframe in sorted(allocation.present, key=lambda k: k.name):
|
for airframe in sorted(allocation.present, key=lambda k: k.variant_id):
|
||||||
count = allocation.present[airframe]
|
count = allocation.present[airframe]
|
||||||
if not count:
|
if not count:
|
||||||
continue
|
continue
|
||||||
self.add_row(f" {airframe.name}", count)
|
self.add_row(f" {airframe.variant_id}", count)
|
||||||
self.add_row("")
|
self.add_row("")
|
||||||
|
|
||||||
self.add_row("<b>Total</b>", total)
|
self.add_row("<b>Total</b>", total)
|
||||||
@ -117,11 +117,11 @@ class ArmyIntelLayout(IntelTableLayout):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
self.add_header(f"{control_point.name} ({base.total_armor})")
|
self.add_header(f"{control_point.name} ({base.total_armor})")
|
||||||
for vehicle in sorted(base.armor, key=lambda k: k.name):
|
for vehicle in sorted(base.armor, key=lambda k: k.variant_id):
|
||||||
count = base.armor[vehicle]
|
count = base.armor[vehicle]
|
||||||
if not count:
|
if not count:
|
||||||
continue
|
continue
|
||||||
self.add_row(f" {vehicle.name}", count)
|
self.add_row(f" {vehicle.variant_id}", count)
|
||||||
self.add_row("")
|
self.add_row("")
|
||||||
|
|
||||||
self.add_row("<b>Total</b>", total)
|
self.add_row("<b>Total</b>", total)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user