mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
fix numerous UI elements using is_ownfor
This commit is contained in:
parent
624f2a00fd
commit
3d788e3ae8
@ -38,7 +38,7 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
|
||||
self._generate_package_waypoints_if_needed(dump_debug_info)
|
||||
self._flight_plan = self.build(dump_debug_info)
|
||||
except NavMeshError as ex:
|
||||
color = "blue" if self.flight.squadron.player else "red"
|
||||
color = "blue" if self.flight.squadron.player.is_blue else "red"
|
||||
raise PlanningError(
|
||||
f"Could not plan {color} {self.flight.flight_type.value} from "
|
||||
f"{self.flight.departure} to {self.package.target}"
|
||||
|
||||
@ -27,7 +27,7 @@ class FrontLineStanceTask(TheaterCommanderTask, ABC):
|
||||
@staticmethod
|
||||
def management_allowed(state: TheaterState) -> bool:
|
||||
return (
|
||||
not state.context.coalition.player
|
||||
not state.context.coalition.player.is_blue
|
||||
or state.context.settings.automate_front_line_stance
|
||||
)
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class PackagePlanningTask(TheaterCommanderTask, Generic[MissionTargetT]):
|
||||
|
||||
def preconditions_met(self, state: TheaterState) -> bool:
|
||||
if (
|
||||
state.context.coalition.player
|
||||
state.context.coalition.player.is_blue
|
||||
and state.context.settings.auto_ato_behavior is AutoAtoBehavior.Disabled
|
||||
):
|
||||
return False
|
||||
@ -102,7 +102,7 @@ class PackagePlanningTask(TheaterCommanderTask, Generic[MissionTargetT]):
|
||||
return 1
|
||||
|
||||
def fulfill_mission(self, state: TheaterState) -> bool:
|
||||
color = "blue" if state.context.coalition.player else "red"
|
||||
color = "blue" if state.context.coalition.player.is_blue else "red"
|
||||
self.propose_flights()
|
||||
fulfiller = PackageFulfiller(
|
||||
state.context.coalition,
|
||||
@ -214,7 +214,7 @@ class PackagePlanningTask(TheaterCommanderTask, Generic[MissionTargetT]):
|
||||
settings = state.context.coalition.game.settings
|
||||
margin = 100 - (
|
||||
settings.ownfor_autoplanner_aggressiveness
|
||||
if state.context.coalition.player
|
||||
if state.context.coalition.player.is_blue
|
||||
else settings.opfor_autoplanner_aggressiveness
|
||||
)
|
||||
threat_range = iads_threat.max_threat_range() * (margin / 100)
|
||||
|
||||
@ -12,7 +12,7 @@ from game.theater import MissionTarget
|
||||
class PlanAewc(PackagePlanningTask[MissionTarget]):
|
||||
def preconditions_met(self, state: TheaterState) -> bool:
|
||||
if (
|
||||
state.context.coalition.player
|
||||
state.context.coalition.player.is_blue
|
||||
and not state.context.settings.auto_ato_behavior_awacs
|
||||
):
|
||||
return False
|
||||
|
||||
@ -14,7 +14,7 @@ MARGIN = 4 # assume 4 aircraft can land without refueling
|
||||
class PlanRecovery(PackagePlanningTask[ControlPoint]):
|
||||
def preconditions_met(self, state: TheaterState) -> bool:
|
||||
if (
|
||||
state.context.coalition.player
|
||||
state.context.coalition.player.is_blue
|
||||
and not state.context.settings.auto_ato_behavior_tankers
|
||||
):
|
||||
return False
|
||||
|
||||
@ -12,7 +12,7 @@ from game.theater import MissionTarget
|
||||
class PlanRefueling(PackagePlanningTask[MissionTarget]):
|
||||
def preconditions_met(self, state: TheaterState) -> bool:
|
||||
if (
|
||||
state.context.coalition.player
|
||||
state.context.coalition.player.is_blue
|
||||
and not state.context.settings.auto_ato_behavior_tankers
|
||||
):
|
||||
return False
|
||||
|
||||
@ -866,7 +866,7 @@ class HelipadGenerator:
|
||||
|
||||
if self.game.position_culled(helipad):
|
||||
cull_farp_statics = True
|
||||
if self.cp.coalition.player:
|
||||
if self.cp.coalition.player.is_blue:
|
||||
for package in self.cp.coalition.ato.packages:
|
||||
for flight in package.flights:
|
||||
if flight.squadron.location == self.cp:
|
||||
@ -998,7 +998,7 @@ class GroundSpawnRoadbaseGenerator:
|
||||
cull_farp_statics = True
|
||||
elif self.game.position_culled(ground_spawn[0]):
|
||||
cull_farp_statics = True
|
||||
if self.cp.coalition.player:
|
||||
if self.cp.coalition.player.is_blue:
|
||||
for package in self.cp.coalition.ato.packages:
|
||||
for flight in package.flights:
|
||||
if flight.squadron.location == self.cp:
|
||||
@ -1277,7 +1277,7 @@ class GroundSpawnGenerator:
|
||||
cull_farp_statics = True
|
||||
elif self.game.position_culled(vtol_pad[0]):
|
||||
cull_farp_statics = True
|
||||
if self.cp.coalition.player:
|
||||
if self.cp.coalition.player.is_blue:
|
||||
for package in self.cp.coalition.ato.packages:
|
||||
for flight in package.flights:
|
||||
if flight.squadron.location == self.cp:
|
||||
|
||||
@ -5,6 +5,7 @@ from PySide6.QtWidgets import QComboBox
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.settings.settings import Settings
|
||||
from game.theater import ConflictTheater, MissionTarget
|
||||
from game.theater.player import Player
|
||||
|
||||
|
||||
class QFlightTypeComboBox(QComboBox):
|
||||
@ -20,7 +21,9 @@ class QFlightTypeComboBox(QComboBox):
|
||||
super().__init__()
|
||||
self.theater = theater
|
||||
self.target = target
|
||||
for mission_type in self.target.mission_types(for_player=is_ownfor):
|
||||
for mission_type in self.target.mission_types(
|
||||
for_player=Player.BLUE if is_ownfor else Player.RED
|
||||
):
|
||||
if mission_type == FlightType.AIR_ASSAULT and not settings.plugin_option(
|
||||
"ctld"
|
||||
):
|
||||
|
||||
@ -276,14 +276,14 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
self.parking_tracker.allocation_changed.connect(self.update_parking_label)
|
||||
left_column.addWidget(self.parking_label)
|
||||
|
||||
if not squadron.player and squadron.aircraft.flyable:
|
||||
if not squadron.player.is_blue and squadron.aircraft.flyable:
|
||||
player_label = QLabel("Player slots not available for opfor")
|
||||
elif not squadron.aircraft.flyable:
|
||||
player_label = QLabel("Player slots not available for non-flyable aircraft")
|
||||
else:
|
||||
msg1 = "Player slots not available for opfor"
|
||||
msg2 = "Player slots not available for non-flyable aircraft"
|
||||
text = msg2 if squadron.player else msg1
|
||||
text = msg2 if squadron.player.is_blue else msg1
|
||||
player_label = QLabel(text)
|
||||
left_column.addWidget(player_label)
|
||||
|
||||
@ -291,7 +291,9 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
"<br />".join(p.name for p in self.claim_players_from_squadron())
|
||||
)
|
||||
self.player_list.setAcceptRichText(False)
|
||||
self.player_list.setEnabled(squadron.player and squadron.aircraft.flyable)
|
||||
self.player_list.setEnabled(
|
||||
squadron.player.is_blue and squadron.aircraft.flyable
|
||||
)
|
||||
left_column.addWidget(self.player_list)
|
||||
|
||||
button_row = QHBoxLayout()
|
||||
@ -388,7 +390,7 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
return squadron
|
||||
|
||||
def claim_players_from_squadron(self) -> list[Pilot]:
|
||||
if not self.squadron.player:
|
||||
if not self.squadron.player.is_blue:
|
||||
return []
|
||||
|
||||
players = [p for p in self.squadron.pilot_pool if p.player]
|
||||
@ -397,7 +399,7 @@ class SquadronConfigurationBox(QGroupBox):
|
||||
return players
|
||||
|
||||
def return_players_to_squadron(self) -> None:
|
||||
if not self.squadron.player:
|
||||
if not self.squadron.player.is_blue:
|
||||
return
|
||||
|
||||
player_names = self.player_list.toPlainText().splitlines()
|
||||
|
||||
@ -58,7 +58,7 @@ class PendingTransfersList(QListView):
|
||||
index = self.indexAt(event.pos())
|
||||
if not index.isValid():
|
||||
return
|
||||
if not self.transfer_model.transfer_at_index(index).player:
|
||||
if not self.transfer_model.transfer_at_index(index).player.is_blue:
|
||||
return
|
||||
|
||||
menu = QMenu("Menu")
|
||||
|
||||
@ -195,7 +195,9 @@ class QGroundObjectMenu(QDialog):
|
||||
lambda degrees: self.rotate_tgo(Heading(degrees))
|
||||
)
|
||||
self.orientationBoxLayout.addWidget(self.headingSelector)
|
||||
can_adjust_heading = self.cp.is_friendly(to_player=self.game_model.is_ownfor)
|
||||
can_adjust_heading = self.cp.is_friendly(
|
||||
to_player=Player.BLUE if self.game_model.is_ownfor else Player.RED
|
||||
)
|
||||
if can_adjust_heading:
|
||||
self.head_to_conflict_button = QPushButton("Head to conflict")
|
||||
heading = (
|
||||
|
||||
@ -17,6 +17,7 @@ from game.ato import FlightType
|
||||
from game.commander.missionproposals import ProposedFlight, ProposedMission
|
||||
from game.commander.packagefulfiller import PackageFulfiller
|
||||
from game.profiling import MultiEventTracer
|
||||
from game.theater.player import Player
|
||||
from qt_ui.models import PackageModel
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
|
||||
@ -193,7 +194,9 @@ class QAutoCreateDialog(QDialog):
|
||||
FlightType.ARMED_RECON,
|
||||
FlightType.AIR_ASSAULT,
|
||||
}
|
||||
for mt in self.package.target.mission_types(self.is_ownfor):
|
||||
for mt in self.package.target.mission_types(
|
||||
Player.BLUE if self.is_ownfor else Player.RED
|
||||
):
|
||||
if mt in primary_tasks:
|
||||
self.primary_combobox.addItem(mt.value, mt)
|
||||
self.primary_combobox.setCurrentIndex(0)
|
||||
@ -252,7 +255,9 @@ class QAutoCreateDialog(QDialog):
|
||||
with tracer.trace(f"Auto-plan package"):
|
||||
pm = ProposedMission(self.package.target, pf, asap=True)
|
||||
pff = PackageFulfiller(
|
||||
self.game.coalition_for(self.is_ownfor),
|
||||
self.game.coalition_for(
|
||||
Player.BLUE if self.is_ownfor else Player.RED
|
||||
),
|
||||
self.game.theater,
|
||||
self.game.db.flights,
|
||||
self.game.settings,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user