mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Make squadron nicknames optional.
This commit is contained in:
parent
3c802e7d55
commit
25c289deaa
@ -74,7 +74,7 @@ class Pilot:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Squadron:
|
class Squadron:
|
||||||
name: str
|
name: str
|
||||||
nickname: str
|
nickname: Optional[str]
|
||||||
country: str
|
country: str
|
||||||
role: str
|
role: str
|
||||||
aircraft: AircraftType
|
aircraft: AircraftType
|
||||||
@ -97,6 +97,8 @@ class Squadron:
|
|||||||
self.auto_assignable_mission_types = set(self.mission_types)
|
self.auto_assignable_mission_types = set(self.mission_types)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
if self.nickname is None:
|
||||||
|
return self.name
|
||||||
return f'{self.name} "{self.nickname}"'
|
return f'{self.name} "{self.nickname}"'
|
||||||
|
|
||||||
def claim_available_pilot(self) -> Optional[Pilot]:
|
def claim_available_pilot(self) -> Optional[Pilot]:
|
||||||
@ -215,7 +217,7 @@ class Squadron:
|
|||||||
|
|
||||||
return Squadron(
|
return Squadron(
|
||||||
name=data["name"],
|
name=data["name"],
|
||||||
nickname=data["nickname"],
|
nickname=data.get("nickname"),
|
||||||
country=data["country"],
|
country=data["country"],
|
||||||
role=data["role"],
|
role=data["role"],
|
||||||
aircraft=unit_type,
|
aircraft=unit_type,
|
||||||
|
|||||||
@ -40,12 +40,12 @@ class SquadronDelegate(TwoColumnRowDelegate):
|
|||||||
|
|
||||||
def text_for(self, index: QModelIndex, row: int, column: int) -> str:
|
def text_for(self, index: QModelIndex, row: int, column: int) -> str:
|
||||||
if (row, column) == (0, 0):
|
if (row, column) == (0, 0):
|
||||||
return self.air_wing_model.data(index, Qt.DisplayRole)
|
return self.squadron(index).name
|
||||||
elif (row, column) == (0, 1):
|
elif (row, column) == (0, 1):
|
||||||
squadron = self.air_wing_model.data(index, AirWingModel.SquadronRole)
|
squadron = self.air_wing_model.data(index, AirWingModel.SquadronRole)
|
||||||
return squadron.aircraft.name
|
return squadron.aircraft.name
|
||||||
elif (row, column) == (1, 0):
|
elif (row, column) == (1, 0):
|
||||||
return self.squadron(index).nickname
|
return self.squadron(index).nickname or ""
|
||||||
elif (row, column) == (1, 1):
|
elif (row, column) == (1, 1):
|
||||||
squadron = self.squadron(index)
|
squadron = self.squadron(index)
|
||||||
alive = squadron.number_of_living_pilots
|
alive = squadron.number_of_living_pilots
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user