Finish implementation of add/remove squadrons from AirWingConfigurationDialog

Users can now add and remove squadrons with specific buttons. this also allows new aircraft types to be added as well.

- rebased existing PR to develop
- reverted observable and changed to signals
- changed the general concept so that changes only affect the ui data model and not the game directly. Game will only be updated on apply
- removed unused code
- adopt to review comments
- allow user to choose a predefined squadron preset (also alow none value to use the random generator)
- Reuse the squadron defs from the default assigner in the AirWing class
- allow user to re-roll the squadron nickname (also added new ui icons for the button)
This commit is contained in:
RndName
2021-11-16 23:16:19 +01:00
parent e4ba9a8b72
commit d2f7785f9f
14 changed files with 342 additions and 382 deletions

View File

@@ -12,12 +12,12 @@ from gen.flights.ai_flight_planner_db import aircraft_for_task, tasks_for_aircra
from game.ato.flighttype import FlightType
if TYPE_CHECKING:
from game.coalition import Coalition
from game.factions.faction import Faction
class SquadronDefGenerator:
def __init__(self, coalition: Coalition) -> None:
self.coalition = coalition
def __init__(self, faction: Faction) -> None:
self.faction = faction
self.count = itertools.count(1)
self.used_nicknames: set[str] = set()
@@ -26,7 +26,7 @@ class SquadronDefGenerator:
) -> Optional[SquadronDef]:
aircraft_choice: Optional[AircraftType] = None
for aircraft in aircraft_for_task(task):
if aircraft not in self.coalition.faction.aircrafts:
if aircraft not in self.faction.aircrafts:
continue
if not control_point.can_operate(aircraft):
continue
@@ -44,7 +44,7 @@ class SquadronDefGenerator:
return SquadronDef(
name=f"Squadron {next(self.count):03}",
nickname=self.random_nickname(),
country=self.coalition.country_name,
country=self.faction.country,
role="Flying Squadron",
aircraft=aircraft,
livery=None,