From fcf45554efa92b2b9baa2b981b995dd0be2e4743 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 21 Nov 2020 17:01:50 +0100 Subject: [PATCH] Fixed culling display and added setting to include/exclude carriers from culling area. --- game/game.py | 15 ++++++++++++--- game/settings.py | 1 + qt_ui/widgets/map/QLiberationMap.py | 2 +- qt_ui/windows/settings/QSettingsWindow.py | 8 ++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/game/game.py b/game/game.py index dd03be4f..e62ff1e1 100644 --- a/game/game.py +++ b/game/game.py @@ -84,7 +84,8 @@ class Game: self.ground_planners: Dict[int, GroundPlanner] = {} self.informations = [] self.informations.append(Information("Game Start", "-" * 40, 0)) - self.__culling_points = self.compute_conflicts_position() + self.__culling_points: List[Point] = [] + self.compute_conflicts_position() self.__destroyed_units: List[str] = [] self.savepath = "" self.budget = PLAYER_BUDGET_INITIAL @@ -239,7 +240,7 @@ class Game: self.aircraft_inventory.set_from_control_point(cp) # Plan flights & combat for next turn - self.__culling_points = self.compute_conflicts_position() + self.compute_conflicts_position() self.ground_planners = {} self.blue_ato.clear() self.red_ato.clear() @@ -364,6 +365,14 @@ class Game: points.append(front_line.control_point_a.position) points.append(front_line.control_point_b.position) + # If do_not_cull_carrier is enabled, add carriers as culling point + print("------") + print(self.settings.perf_do_not_cull_carrier) + if self.settings.perf_do_not_cull_carrier: + for cp in self.theater.controlpoints: + if cp.is_carrier or cp.is_lha: + points.append(cp.position) + # If there is no conflict take the center point between the two nearest opposing bases if len(points) == 0: cpoint = None @@ -387,7 +396,7 @@ class Game: if len(points) == 0: points.append(Point(0, 0)) - return points + self.__culling_points = points def add_destroyed_units(self, data): pos = Point(data["x"], data["z"]) diff --git a/game/settings.py b/game/settings.py index ff73b63c..1e54c1b4 100644 --- a/game/settings.py +++ b/game/settings.py @@ -39,6 +39,7 @@ class Settings: # Performance culling perf_culling: bool = False perf_culling_distance: int = 100 + perf_do_not_cull_carrier = True # LUA Plugins system plugins: Dict[str, bool] = field(default_factory=dict) diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index 50fc5fba..0937f8c9 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -296,7 +296,7 @@ class QLiberationMap(QGraphicsView): # Display Culling if DisplayOptions.culling and self.game.settings.perf_culling: - self.display_culling() + self.display_culling(scene) for cp in self.game.theater.controlpoints: diff --git a/qt_ui/windows/settings/QSettingsWindow.py b/qt_ui/windows/settings/QSettingsWindow.py index 486068f5..1506187d 100644 --- a/qt_ui/windows/settings/QSettingsWindow.py +++ b/qt_ui/windows/settings/QSettingsWindow.py @@ -279,6 +279,10 @@ class QSettingsWindow(QDialog): self.culling_distance.setValue(self.game.settings.perf_culling_distance) self.culling_distance.valueChanged.connect(self.applySettings) + self.culling_do_not_cull_carrier = QCheckBox() + self.culling_do_not_cull_carrier.setChecked(self.game.settings.perf_do_not_cull_carrier) + self.culling_do_not_cull_carrier.toggled.connect(self.applySettings) + self.performanceLayout.addWidget(QLabel("Smoke visual effect on frontline"), 0, 0) self.performanceLayout.addWidget(self.smoke, 0, 1, alignment=Qt.AlignRight) self.performanceLayout.addWidget(QLabel("SAM starts in RED alert mode"), 1, 0) @@ -299,6 +303,8 @@ class QSettingsWindow(QDialog): self.performanceLayout.addWidget(self.culling, 8, 1, alignment=Qt.AlignRight) self.performanceLayout.addWidget(QLabel("Culling distance (km)"), 9, 0) self.performanceLayout.addWidget(self.culling_distance, 9, 1, alignment=Qt.AlignRight) + self.performanceLayout.addWidget(QLabel("Do not cull carrier's surroundings"), 10, 0) + self.performanceLayout.addWidget(self.culling_do_not_cull_carrier, 10, 1, alignment=Qt.AlignRight) self.generatorLayout.addWidget(self.gameplay) self.generatorLayout.addWidget(QLabel("Disabling settings below may improve performance, but will impact the overall quality of the experience.")) @@ -366,9 +372,11 @@ class QSettingsWindow(QDialog): self.game.settings.perf_culling = self.culling.isChecked() self.game.settings.perf_culling_distance = int(self.culling_distance.value()) + self.game.settings.perf_do_not_cull_carrier = self.culling_do_not_cull_carrier.isChecked() self.game.settings.show_red_ato = self.cheat_options.show_red_ato + self.game.compute_conflicts_position() GameUpdateSignal.get_instance().updateGame(self.game) def onSelectionChanged(self):