mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Replace client count with player pilots.
https://github.com/dcs-liberation/dcs_liberation/issues/276
This commit is contained in:
parent
a52043ef29
commit
1b7a225f9d
@ -751,6 +751,16 @@ class AircraftConflictGenerator:
|
|||||||
new_level = min(current_level + increase, len(levels) - 1)
|
new_level = min(current_level + increase, len(levels) - 1)
|
||||||
return levels[new_level]
|
return levels[new_level]
|
||||||
|
|
||||||
|
def set_skill(self, unit: FlyingUnit, pilot: Optional[Pilot], blue: bool) -> None:
|
||||||
|
if pilot is None or not pilot.player:
|
||||||
|
unit.skill = self.skill_level_for(unit, pilot, blue)
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.use_client:
|
||||||
|
unit.set_client()
|
||||||
|
else:
|
||||||
|
unit.set_player()
|
||||||
|
|
||||||
def _setup_group(
|
def _setup_group(
|
||||||
self,
|
self,
|
||||||
group: FlyingGroup,
|
group: FlyingGroup,
|
||||||
@ -777,29 +787,17 @@ class AircraftConflictGenerator:
|
|||||||
for unit_instance in group.units:
|
for unit_instance in group.units:
|
||||||
unit_instance.livery_id = livery
|
unit_instance.livery_id = livery
|
||||||
|
|
||||||
num_clients = min(len(group.units), flight.client_count)
|
for unit, pilot in zip(group.units, flight.pilots):
|
||||||
for idx in range(0, num_clients):
|
player = pilot is not None and pilot.player
|
||||||
unit = group.units[idx]
|
self.set_skill(unit, pilot, blue=flight.departure.captured)
|
||||||
if self.use_client:
|
|
||||||
unit.set_client()
|
|
||||||
else:
|
|
||||||
unit.set_player()
|
|
||||||
|
|
||||||
# Do not generate player group with late activation.
|
# Do not generate player group with late activation.
|
||||||
if group.late_activation:
|
if player and group.late_activation:
|
||||||
group.late_activation = False
|
group.late_activation = False
|
||||||
|
|
||||||
# Set up F-14 Client to have pre-stored alignment
|
# Set up F-14 Client to have pre-stored alignment
|
||||||
if unit_type is F_14B:
|
if unit_type is F_14B:
|
||||||
unit.set_property(F_14B.Properties.INSAlignmentStored.id, True)
|
unit.set_property(F_14B.Properties.INSAlignmentStored.id, True)
|
||||||
|
|
||||||
for idx in range(num_clients, len(group.units)):
|
|
||||||
unit = group.units[idx]
|
|
||||||
pilot = flight.pilots[idx]
|
|
||||||
unit.skill = self.skill_level_for(
|
|
||||||
unit, pilot, blue=flight.departure.captured
|
|
||||||
)
|
|
||||||
|
|
||||||
group.points[0].tasks.append(
|
group.points[0].tasks.append(
|
||||||
OptReactOnThreat(OptReactOnThreat.Values.EvadeFire)
|
OptReactOnThreat(OptReactOnThreat.Values.EvadeFire)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -228,7 +228,6 @@ class Flight:
|
|||||||
self.loadout = Loadout.default_for(self)
|
self.loadout = Loadout.default_for(self)
|
||||||
self.start_type = start_type
|
self.start_type = start_type
|
||||||
self.use_custom_loadout = False
|
self.use_custom_loadout = False
|
||||||
self.client_count = 0
|
|
||||||
self.custom_name = custom_name
|
self.custom_name = custom_name
|
||||||
|
|
||||||
# Only used by transport missions.
|
# Only used by transport missions.
|
||||||
@ -247,6 +246,10 @@ class Flight:
|
|||||||
def count(self) -> int:
|
def count(self) -> int:
|
||||||
return len(self.pilots)
|
return len(self.pilots)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def client_count(self) -> int:
|
||||||
|
return len([p for p in self.pilots if p is not None and p.player])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_type(self) -> Type[FlyingType]:
|
def unit_type(self) -> Type[FlyingType]:
|
||||||
return self.squadron.aircraft
|
return self.squadron.aircraft
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from PySide2.QtCore import Signal, QModelIndex
|
|||||||
from PySide2.QtWidgets import QLabel, QGroupBox, QSpinBox, QGridLayout, QComboBox
|
from PySide2.QtWidgets import QLabel, QGroupBox, QSpinBox, QGridLayout, QComboBox
|
||||||
|
|
||||||
from game import Game
|
from game import Game
|
||||||
|
from game.squadrons import Pilot
|
||||||
from gen.flights.flight import Flight
|
from gen.flights.flight import Flight
|
||||||
from qt_ui.models import PackageModel
|
from qt_ui.models import PackageModel
|
||||||
|
|
||||||
@ -18,6 +19,12 @@ class PilotSelector(QComboBox):
|
|||||||
|
|
||||||
self.rebuild(initial_build=True)
|
self.rebuild(initial_build=True)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def text_for(pilot: Pilot) -> str:
|
||||||
|
if pilot.player:
|
||||||
|
return f"{pilot.name} (player)"
|
||||||
|
return pilot.name
|
||||||
|
|
||||||
def _do_rebuild(self) -> None:
|
def _do_rebuild(self) -> None:
|
||||||
self.clear()
|
self.clear()
|
||||||
if self.pilot_index >= self.flight.count:
|
if self.pilot_index >= self.flight.count:
|
||||||
@ -31,12 +38,13 @@ class PilotSelector(QComboBox):
|
|||||||
current_pilot = self.flight.pilots[self.pilot_index]
|
current_pilot = self.flight.pilots[self.pilot_index]
|
||||||
if current_pilot is not None:
|
if current_pilot is not None:
|
||||||
choices.append(current_pilot)
|
choices.append(current_pilot)
|
||||||
for pilot in sorted(choices, key=lambda p: p.name):
|
# Put players first, otherwise alphabetically.
|
||||||
self.addItem(pilot.name, pilot)
|
for pilot in sorted(choices, key=lambda p: (not p.player, p.name)):
|
||||||
|
self.addItem(self.text_for(pilot), pilot)
|
||||||
if current_pilot is None:
|
if current_pilot is None:
|
||||||
self.setCurrentText("Unassigned")
|
self.setCurrentText("Unassigned")
|
||||||
return
|
return
|
||||||
self.setCurrentText(current_pilot.name)
|
self.setCurrentText(self.text_for(current_pilot))
|
||||||
self.currentIndexChanged.connect(self.replace_pilot)
|
self.currentIndexChanged.connect(self.replace_pilot)
|
||||||
|
|
||||||
def rebuild(self, initial_build: bool = False) -> None:
|
def rebuild(self, initial_build: bool = False) -> None:
|
||||||
@ -90,29 +98,15 @@ class QFlightSlotEditor(QGroupBox):
|
|||||||
self.aircraft_count_spinner.setValue(flight.count)
|
self.aircraft_count_spinner.setValue(flight.count)
|
||||||
self.aircraft_count_spinner.valueChanged.connect(self._changed_aircraft_count)
|
self.aircraft_count_spinner.valueChanged.connect(self._changed_aircraft_count)
|
||||||
|
|
||||||
self.client_count = QLabel("Client slots count:")
|
|
||||||
self.client_count_spinner = QSpinBox()
|
|
||||||
self.client_count_spinner.setMinimum(0)
|
|
||||||
self.client_count_spinner.setMaximum(max_count)
|
|
||||||
self.client_count_spinner.setValue(flight.client_count)
|
|
||||||
self.client_count_spinner.valueChanged.connect(self._changed_client_count)
|
|
||||||
|
|
||||||
if not self.flight.unit_type.flyable:
|
|
||||||
self.client_count_spinner.setValue(0)
|
|
||||||
self.client_count_spinner.setEnabled(False)
|
|
||||||
|
|
||||||
layout.addWidget(self.aircraft_count, 0, 0)
|
layout.addWidget(self.aircraft_count, 0, 0)
|
||||||
layout.addWidget(self.aircraft_count_spinner, 0, 1)
|
layout.addWidget(self.aircraft_count_spinner, 0, 1)
|
||||||
|
|
||||||
layout.addWidget(self.client_count, 1, 0)
|
layout.addWidget(QLabel("Squadron:"), 1, 0)
|
||||||
layout.addWidget(self.client_count_spinner, 1, 1)
|
layout.addWidget(QLabel(self.flight.squadron.name), 1, 1)
|
||||||
|
|
||||||
layout.addWidget(QLabel("Squadron:"), 2, 0)
|
layout.addWidget(QLabel("Assigned pilots:"), 2, 0)
|
||||||
layout.addWidget(QLabel(self.flight.squadron.name), 2, 1)
|
|
||||||
|
|
||||||
layout.addWidget(QLabel("Assigned pilots:"), 3, 0)
|
|
||||||
self.pilot_selectors = []
|
self.pilot_selectors = []
|
||||||
for pilot_idx, row in enumerate(range(3, 7)):
|
for pilot_idx, row in enumerate(range(2, 6)):
|
||||||
selector = PilotSelector(self.flight, pilot_idx)
|
selector = PilotSelector(self.flight, pilot_idx)
|
||||||
selector.available_pilots_changed.connect(self.reset_pilot_selectors)
|
selector.available_pilots_changed.connect(self.reset_pilot_selectors)
|
||||||
self.pilot_selectors.append(selector)
|
self.pilot_selectors.append(selector)
|
||||||
@ -143,15 +137,4 @@ class QFlightSlotEditor(QGroupBox):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.flight.resize(new_count)
|
self.flight.resize(new_count)
|
||||||
self._cap_client_count()
|
|
||||||
self.reset_pilot_selectors()
|
self.reset_pilot_selectors()
|
||||||
|
|
||||||
def _changed_client_count(self):
|
|
||||||
self.flight.client_count = int(self.client_count_spinner.value())
|
|
||||||
self._cap_client_count()
|
|
||||||
self.package_model.update_tot()
|
|
||||||
|
|
||||||
def _cap_client_count(self):
|
|
||||||
if self.flight.client_count > self.flight.count:
|
|
||||||
self.flight.client_count = self.flight.count
|
|
||||||
self.client_count_spinner.setValue(self.flight.client_count)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user