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

@@ -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"
):

View File

@@ -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()

View File

@@ -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")

View File

@@ -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 = (

View File

@@ -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,