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:
Dan Albert
2023-08-09 20:50:01 -07:00
committed by Raffson
parent 97ee6ba19f
commit 1760532168
20 changed files with 79 additions and 45 deletions

View File

@@ -611,12 +611,12 @@ class AircraftTypeList(QListView):
self.add_aircraft_type(aircraft)
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.page_index_changed.emit(self.selectionModel().currentIndex().row())
def add_aircraft_type(self, aircraft: AircraftType):
aircraft_item = QStandardItem(aircraft.name)
aircraft_item = QStandardItem(aircraft.variant_id)
icon = self.icon_for(aircraft)
if icon is not None:
aircraft_item.setIcon(icon)
@@ -728,7 +728,7 @@ class AirWingConfigurationTab(QWidget):
)
# 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)
# TODO Select the newly added type
self.squadrons_panel.add_squadron_to_panel(squadron)
@@ -814,8 +814,8 @@ class SquadronAircraftTypeSelector(QComboBox):
super().__init__()
self.setSizeAdjustPolicy(self.AdjustToContents)
for type in sorted(types, key=lambda type: type.name):
self.addItem(type.name, type)
for type in sorted(types, key=lambda type: type.variant_id):
self.addItem(type.variant_id, type)
if selected_aircraft:
self.setCurrentText(selected_aircraft)