fix numerous UI elements using is_ownfor

This commit is contained in:
Eclipse/Druss99 2025-10-14 21:42:40 -04:00 committed by Raffson
parent 624f2a00fd
commit 3d788e3ae8
12 changed files with 33 additions and 21 deletions

View File

@ -38,7 +38,7 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
self._generate_package_waypoints_if_needed(dump_debug_info) self._generate_package_waypoints_if_needed(dump_debug_info)
self._flight_plan = self.build(dump_debug_info) self._flight_plan = self.build(dump_debug_info)
except NavMeshError as ex: 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( raise PlanningError(
f"Could not plan {color} {self.flight.flight_type.value} from " f"Could not plan {color} {self.flight.flight_type.value} from "
f"{self.flight.departure} to {self.package.target}" f"{self.flight.departure} to {self.package.target}"

View File

@ -27,7 +27,7 @@ class FrontLineStanceTask(TheaterCommanderTask, ABC):
@staticmethod @staticmethod
def management_allowed(state: TheaterState) -> bool: def management_allowed(state: TheaterState) -> bool:
return ( return (
not state.context.coalition.player not state.context.coalition.player.is_blue
or state.context.settings.automate_front_line_stance or state.context.settings.automate_front_line_stance
) )

View File

@ -45,7 +45,7 @@ class PackagePlanningTask(TheaterCommanderTask, Generic[MissionTargetT]):
def preconditions_met(self, state: TheaterState) -> bool: def preconditions_met(self, state: TheaterState) -> bool:
if ( if (
state.context.coalition.player state.context.coalition.player.is_blue
and state.context.settings.auto_ato_behavior is AutoAtoBehavior.Disabled and state.context.settings.auto_ato_behavior is AutoAtoBehavior.Disabled
): ):
return False return False
@ -102,7 +102,7 @@ class PackagePlanningTask(TheaterCommanderTask, Generic[MissionTargetT]):
return 1 return 1
def fulfill_mission(self, state: TheaterState) -> bool: 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() self.propose_flights()
fulfiller = PackageFulfiller( fulfiller = PackageFulfiller(
state.context.coalition, state.context.coalition,
@ -214,7 +214,7 @@ class PackagePlanningTask(TheaterCommanderTask, Generic[MissionTargetT]):
settings = state.context.coalition.game.settings settings = state.context.coalition.game.settings
margin = 100 - ( margin = 100 - (
settings.ownfor_autoplanner_aggressiveness settings.ownfor_autoplanner_aggressiveness
if state.context.coalition.player if state.context.coalition.player.is_blue
else settings.opfor_autoplanner_aggressiveness else settings.opfor_autoplanner_aggressiveness
) )
threat_range = iads_threat.max_threat_range() * (margin / 100) threat_range = iads_threat.max_threat_range() * (margin / 100)

View File

@ -12,7 +12,7 @@ from game.theater import MissionTarget
class PlanAewc(PackagePlanningTask[MissionTarget]): class PlanAewc(PackagePlanningTask[MissionTarget]):
def preconditions_met(self, state: TheaterState) -> bool: def preconditions_met(self, state: TheaterState) -> bool:
if ( if (
state.context.coalition.player state.context.coalition.player.is_blue
and not state.context.settings.auto_ato_behavior_awacs and not state.context.settings.auto_ato_behavior_awacs
): ):
return False return False

View File

@ -14,7 +14,7 @@ MARGIN = 4 # assume 4 aircraft can land without refueling
class PlanRecovery(PackagePlanningTask[ControlPoint]): class PlanRecovery(PackagePlanningTask[ControlPoint]):
def preconditions_met(self, state: TheaterState) -> bool: def preconditions_met(self, state: TheaterState) -> bool:
if ( if (
state.context.coalition.player state.context.coalition.player.is_blue
and not state.context.settings.auto_ato_behavior_tankers and not state.context.settings.auto_ato_behavior_tankers
): ):
return False return False

View File

@ -12,7 +12,7 @@ from game.theater import MissionTarget
class PlanRefueling(PackagePlanningTask[MissionTarget]): class PlanRefueling(PackagePlanningTask[MissionTarget]):
def preconditions_met(self, state: TheaterState) -> bool: def preconditions_met(self, state: TheaterState) -> bool:
if ( if (
state.context.coalition.player state.context.coalition.player.is_blue
and not state.context.settings.auto_ato_behavior_tankers and not state.context.settings.auto_ato_behavior_tankers
): ):
return False return False

View File

@ -866,7 +866,7 @@ class HelipadGenerator:
if self.game.position_culled(helipad): if self.game.position_culled(helipad):
cull_farp_statics = True 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 package in self.cp.coalition.ato.packages:
for flight in package.flights: for flight in package.flights:
if flight.squadron.location == self.cp: if flight.squadron.location == self.cp:
@ -998,7 +998,7 @@ class GroundSpawnRoadbaseGenerator:
cull_farp_statics = True cull_farp_statics = True
elif self.game.position_culled(ground_spawn[0]): elif self.game.position_culled(ground_spawn[0]):
cull_farp_statics = True 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 package in self.cp.coalition.ato.packages:
for flight in package.flights: for flight in package.flights:
if flight.squadron.location == self.cp: if flight.squadron.location == self.cp:
@ -1277,7 +1277,7 @@ class GroundSpawnGenerator:
cull_farp_statics = True cull_farp_statics = True
elif self.game.position_culled(vtol_pad[0]): elif self.game.position_culled(vtol_pad[0]):
cull_farp_statics = True 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 package in self.cp.coalition.ato.packages:
for flight in package.flights: for flight in package.flights:
if flight.squadron.location == self.cp: if flight.squadron.location == self.cp:

View File

@ -5,6 +5,7 @@ from PySide6.QtWidgets import QComboBox
from game.ato.flighttype import FlightType from game.ato.flighttype import FlightType
from game.settings.settings import Settings from game.settings.settings import Settings
from game.theater import ConflictTheater, MissionTarget from game.theater import ConflictTheater, MissionTarget
from game.theater.player import Player
class QFlightTypeComboBox(QComboBox): class QFlightTypeComboBox(QComboBox):
@ -20,7 +21,9 @@ class QFlightTypeComboBox(QComboBox):
super().__init__() super().__init__()
self.theater = theater self.theater = theater
self.target = target 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( if mission_type == FlightType.AIR_ASSAULT and not settings.plugin_option(
"ctld" "ctld"
): ):

View File

@ -276,14 +276,14 @@ class SquadronConfigurationBox(QGroupBox):
self.parking_tracker.allocation_changed.connect(self.update_parking_label) self.parking_tracker.allocation_changed.connect(self.update_parking_label)
left_column.addWidget(self.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") player_label = QLabel("Player slots not available for opfor")
elif not squadron.aircraft.flyable: elif not squadron.aircraft.flyable:
player_label = QLabel("Player slots not available for non-flyable aircraft") player_label = QLabel("Player slots not available for non-flyable aircraft")
else: else:
msg1 = "Player slots not available for opfor" msg1 = "Player slots not available for opfor"
msg2 = "Player slots not available for non-flyable aircraft" 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) player_label = QLabel(text)
left_column.addWidget(player_label) left_column.addWidget(player_label)
@ -291,7 +291,9 @@ class SquadronConfigurationBox(QGroupBox):
"<br />".join(p.name for p in self.claim_players_from_squadron()) "<br />".join(p.name for p in self.claim_players_from_squadron())
) )
self.player_list.setAcceptRichText(False) 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) left_column.addWidget(self.player_list)
button_row = QHBoxLayout() button_row = QHBoxLayout()
@ -388,7 +390,7 @@ class SquadronConfigurationBox(QGroupBox):
return squadron return squadron
def claim_players_from_squadron(self) -> list[Pilot]: def claim_players_from_squadron(self) -> list[Pilot]:
if not self.squadron.player: if not self.squadron.player.is_blue:
return [] return []
players = [p for p in self.squadron.pilot_pool if p.player] players = [p for p in self.squadron.pilot_pool if p.player]
@ -397,7 +399,7 @@ class SquadronConfigurationBox(QGroupBox):
return players return players
def return_players_to_squadron(self) -> None: def return_players_to_squadron(self) -> None:
if not self.squadron.player: if not self.squadron.player.is_blue:
return return
player_names = self.player_list.toPlainText().splitlines() player_names = self.player_list.toPlainText().splitlines()

View File

@ -58,7 +58,7 @@ class PendingTransfersList(QListView):
index = self.indexAt(event.pos()) index = self.indexAt(event.pos())
if not index.isValid(): if not index.isValid():
return return
if not self.transfer_model.transfer_at_index(index).player: if not self.transfer_model.transfer_at_index(index).player.is_blue:
return return
menu = QMenu("Menu") menu = QMenu("Menu")

View File

@ -195,7 +195,9 @@ class QGroundObjectMenu(QDialog):
lambda degrees: self.rotate_tgo(Heading(degrees)) lambda degrees: self.rotate_tgo(Heading(degrees))
) )
self.orientationBoxLayout.addWidget(self.headingSelector) 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: if can_adjust_heading:
self.head_to_conflict_button = QPushButton("Head to conflict") self.head_to_conflict_button = QPushButton("Head to conflict")
heading = ( heading = (

View File

@ -17,6 +17,7 @@ from game.ato import FlightType
from game.commander.missionproposals import ProposedFlight, ProposedMission from game.commander.missionproposals import ProposedFlight, ProposedMission
from game.commander.packagefulfiller import PackageFulfiller from game.commander.packagefulfiller import PackageFulfiller
from game.profiling import MultiEventTracer from game.profiling import MultiEventTracer
from game.theater.player import Player
from qt_ui.models import PackageModel from qt_ui.models import PackageModel
from qt_ui.uiconstants import EVENT_ICONS from qt_ui.uiconstants import EVENT_ICONS
@ -193,7 +194,9 @@ class QAutoCreateDialog(QDialog):
FlightType.ARMED_RECON, FlightType.ARMED_RECON,
FlightType.AIR_ASSAULT, 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: if mt in primary_tasks:
self.primary_combobox.addItem(mt.value, mt) self.primary_combobox.addItem(mt.value, mt)
self.primary_combobox.setCurrentIndex(0) self.primary_combobox.setCurrentIndex(0)
@ -252,7 +255,9 @@ class QAutoCreateDialog(QDialog):
with tracer.trace(f"Auto-plan package"): with tracer.trace(f"Auto-plan package"):
pm = ProposedMission(self.package.target, pf, asap=True) pm = ProposedMission(self.package.target, pf, asap=True)
pff = PackageFulfiller( 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.theater,
self.game.db.flights, self.game.db.flights,
self.game.settings, self.game.settings,