mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Store the owning coalition in ControlPoint.
This is needed fairly often, and we have a lot of Game being passed around to ControlPoint methods specifically to support this. Just store the owning Coalition directly in the ControlPoint to clean up. I haven't cleaned up *every* API here, but did that aircraft allocations as an example.
This commit is contained in:
@@ -252,7 +252,6 @@ def create_game(
|
||||
start_date=start_date,
|
||||
player_budget=DEFAULT_BUDGET,
|
||||
enemy_budget=DEFAULT_BUDGET,
|
||||
midgame=False,
|
||||
inverted=inverted,
|
||||
no_carrier=False,
|
||||
no_lha=False,
|
||||
|
||||
@@ -190,7 +190,7 @@ class QBaseMenu2(QDialog):
|
||||
self.repair_button.setDisabled(True)
|
||||
|
||||
def update_intel_summary(self) -> None:
|
||||
aircraft = self.cp.allocated_aircraft(self.game_model.game).total_present
|
||||
aircraft = self.cp.allocated_aircraft().total_present
|
||||
parking = self.cp.total_aircraft_parking
|
||||
ground_unit_limit = self.cp.frontline_unit_count_limit
|
||||
deployable_unit_info = ""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from PySide2.QtWidgets import QTabWidget
|
||||
|
||||
from game.theater import ControlPoint, OffMapSpawn, Fob
|
||||
from game.theater import ControlPoint, Fob
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.windows.basemenu.DepartingConvoysMenu import DepartingConvoysMenu
|
||||
from qt_ui.windows.basemenu.airfield.QAirfieldCommand import QAirfieldCommand
|
||||
@@ -13,7 +13,7 @@ class QBaseMenuTabs(QTabWidget):
|
||||
super(QBaseMenuTabs, self).__init__()
|
||||
|
||||
if not cp.captured:
|
||||
self.intel = QIntelInfo(cp, game_model.game)
|
||||
self.intel = QIntelInfo(cp)
|
||||
self.addTab(self.intel, "Intel")
|
||||
|
||||
self.departing_convoys = DepartingConvoysMenu(cp, game_model)
|
||||
|
||||
@@ -21,12 +21,7 @@ from game.purchaseadapter import AircraftPurchaseAdapter
|
||||
|
||||
class QAircraftRecruitmentMenu(UnitTransactionFrame[Squadron]):
|
||||
def __init__(self, cp: ControlPoint, game_model: GameModel) -> None:
|
||||
super().__init__(
|
||||
game_model,
|
||||
AircraftPurchaseAdapter(
|
||||
cp, game_model.game.coalition_for(cp.captured), game_model.game
|
||||
),
|
||||
)
|
||||
super().__init__(game_model, AircraftPurchaseAdapter(cp))
|
||||
self.cp = cp
|
||||
self.game_model = game_model
|
||||
self.purchase_groups = {}
|
||||
@@ -96,7 +91,7 @@ class QHangarStatus(QHBoxLayout):
|
||||
self.setAlignment(Qt.AlignLeft)
|
||||
|
||||
def update_label(self) -> None:
|
||||
next_turn = self.control_point.allocated_aircraft(self.game_model.game)
|
||||
next_turn = self.control_point.allocated_aircraft()
|
||||
max_amount = self.control_point.total_aircraft_parking
|
||||
|
||||
components = [f"{next_turn.total_present} present"]
|
||||
|
||||
@@ -11,22 +11,20 @@ from PySide2.QtWidgets import (
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from game import Game
|
||||
from game.theater import ControlPoint
|
||||
|
||||
|
||||
class QIntelInfo(QFrame):
|
||||
def __init__(self, cp: ControlPoint, game: Game):
|
||||
def __init__(self, cp: ControlPoint):
|
||||
super(QIntelInfo, self).__init__()
|
||||
self.cp = cp
|
||||
self.game = game
|
||||
|
||||
layout = QVBoxLayout()
|
||||
scroll_content = QWidget()
|
||||
intel_layout = QVBoxLayout()
|
||||
|
||||
units_by_task: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))
|
||||
for unit_type, count in self.cp.allocated_aircraft(game).present.items():
|
||||
for unit_type, count in self.cp.allocated_aircraft().present.items():
|
||||
if count:
|
||||
task_type = unit_type.dcs_unit_type.task_default.name
|
||||
units_by_task[task_type][unit_type.name] += count
|
||||
|
||||
@@ -77,7 +77,7 @@ class AircraftIntelLayout(IntelTableLayout):
|
||||
|
||||
total = 0
|
||||
for control_point in game.theater.control_points_for(player):
|
||||
allocation = control_point.allocated_aircraft(game)
|
||||
allocation = control_point.allocated_aircraft()
|
||||
base_total = allocation.total_present
|
||||
total += base_total
|
||||
if not base_total:
|
||||
|
||||
@@ -94,7 +94,6 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
enemy_budget=int(self.field("enemy_starting_money")),
|
||||
# QSlider forces integers, so we use 1 to 50 and divide by 10 to
|
||||
# give 0.1 to 5.0.
|
||||
midgame=False,
|
||||
inverted=self.field("invertMap"),
|
||||
no_carrier=self.field("no_carrier"),
|
||||
no_lha=self.field("no_lha"),
|
||||
|
||||
Reference in New Issue
Block a user