diff --git a/changelog.md b/changelog.md index ad329a31..5fa38ca2 100644 --- a/changelog.md +++ b/changelog.md @@ -210,8 +210,8 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions * **[Flight Planning]** Improved IP selection for targets that are near the center of a threat zone. * **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate. - -* **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate. +* **[UI]** An error will be displayed when invalid fast-forward options are selected rather than beginning a never ending simulation. +* **[UI]** Added cheats for instantly repairing and destroying runways. ## Fixes diff --git a/game/settings/settings.py b/game/settings/settings.py index 9d81ae07..52cf9dd8 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -878,6 +878,7 @@ class Settings: enable_frontline_cheats: bool = False enable_base_capture_cheat: bool = False enable_transfer_cheat: bool = False + enable_runway_state_cheat: bool = False # LUA Plugins system plugins: Dict[str, bool] = field(default_factory=dict) diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index 30d2829e..567a7be9 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -256,6 +256,10 @@ class RunwayStatus: # is reset. self.repair_turns_remaining = None + def repair(self) -> None: + self.repair_turns_remaining = None + self.damaged = False + def begin_repair(self) -> None: if self.repair_turns_remaining is not None: logging.error("Runway already under repair. Restarting.") @@ -264,8 +268,7 @@ class RunwayStatus: def process_turn(self) -> None: if self.repair_turns_remaining is not None: if self.repair_turns_remaining == 1: - self.repair_turns_remaining = None - self.damaged = False + self.repair() else: self.repair_turns_remaining -= 1 @@ -977,6 +980,11 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC): def parking_slots(self) -> Iterator[ParkingSlot]: yield from [] + @property + @abstractmethod + def runway_is_destroyable(self) -> bool: + ... + @property @abstractmethod def runway_status(self) -> RunwayStatus: @@ -1250,6 +1258,10 @@ class Airfield(ControlPoint, CTLD): def heading(self) -> Heading: return Heading.from_degrees(self.airport.runways[0].heading) + @property + def runway_is_destroyable(self) -> bool: + return True + def runway_is_operational(self) -> bool: return not self.runway_status.damaged @@ -1341,6 +1353,10 @@ class NavalControlPoint( return g raise RuntimeError(f"Found no carrier/LHA group for {self.name}") + @property + def runway_is_destroyable(self) -> bool: + return False + def runway_is_operational(self) -> bool: # Necessary because it's possible for the carrier itself to have sunk # while its escorts are still alive. @@ -1521,6 +1537,10 @@ class OffMapSpawn(ControlPoint): logging.warning("TODO: Off map spawns have no runways.") return self.stub_runway_data() + @property + def runway_is_destroyable(self) -> bool: + return False + @property def runway_status(self) -> RunwayStatus: return RunwayStatus() @@ -1557,6 +1577,10 @@ class Fob(ControlPoint, RadioFrequencyContainer, CTLD): def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: return SymbolSet.LAND_INSTALLATIONS, LandInstallationEntity.MILITARY_BASE + @property + def runway_is_destroyable(self) -> bool: + return False + def runway_is_operational(self) -> bool: return self.has_helipads or self.has_ground_spawns diff --git a/qt_ui/windows/basemenu/QBaseMenu2.py b/qt_ui/windows/basemenu/QBaseMenu2.py index 5938c7c1..1236a09a 100644 --- a/qt_ui/windows/basemenu/QBaseMenu2.py +++ b/qt_ui/windows/basemenu/QBaseMenu2.py @@ -116,10 +116,23 @@ class QBaseMenu2(QDialog): top_layout.addWidget(self.intel_summary) top_layout.setAlignment(Qt.AlignTop) + runway_buttons_layout = QVBoxLayout() + top_layout.addLayout(runway_buttons_layout) + + if ( + self.cp.runway_is_destroyable + and self.game_model.game.settings.enable_runway_state_cheat + ): + self.cheat_runway_state = QPushButton() + self.update_cheat_runway_state_text() + self.cheat_runway_state.clicked.connect(self.on_cheat_runway_state) + runway_buttons_layout.addWidget(self.cheat_runway_state) + self.repair_button = QPushButton() self.repair_button.clicked.connect(self.begin_runway_repair) self.update_repair_button() - top_layout.addWidget(self.repair_button) + runway_buttons_layout.addWidget(self.repair_button) + runway_buttons_layout.addStretch() base_menu_header.setProperty("style", "baseMenuHeader") base_menu_header.setLayout(top_layout) @@ -181,6 +194,23 @@ class QBaseMenu2(QDialog): self.cp.captured ).has_destinations(self.cp) + def update_cheat_runway_state_text(self) -> None: + if self.cp.runway_can_be_repaired: + self.cheat_runway_state.setText("CHEAT: Repair runway") + else: + self.cheat_runway_state.setText("CHEAT: Destroy runway") + + def on_cheat_runway_state(self) -> None: + if self.cp.runway_can_be_repaired: + self.cp.runway_status.repair() + else: + self.cp.runway_status.damage() + self.update_cheat_runway_state_text() + self.update_repair_button() + self.update_intel_summary() + with EventStream.event_context() as events: + events.update_control_point(self.cp) + @property def can_repair_runway(self) -> bool: return self.cp.captured and self.cp.runway_can_be_repaired diff --git a/qt_ui/windows/settings/QSettingsWindow.py b/qt_ui/windows/settings/QSettingsWindow.py index 0aea762f..a7ba3c02 100644 --- a/qt_ui/windows/settings/QSettingsWindow.py +++ b/qt_ui/windows/settings/QSettingsWindow.py @@ -81,6 +81,18 @@ class CheatSettingsBox(QGroupBox): self.base_capture_cheat = QLabeledWidget( "Enable Base Capture Cheat:", self.base_capture_cheat_checkbox ) + + self.base_runway_state_cheat_checkbox = QCheckBox() + self.base_runway_state_cheat_checkbox.setChecked( + game.settings.enable_runway_state_cheat + ) + self.base_runway_state_cheat_checkbox.toggled.connect(apply_settings) + self.main_layout.addLayout( + QLabeledWidget( + "Enable runway state cheat:", self.base_runway_state_cheat_checkbox + ) + ) + self.main_layout.addLayout(self.base_capture_cheat) self.transfer_cheat = QLabeledWidget( "Enable Instant Squadron Transfer Cheat:", self.transfer_cheat_checkbox @@ -103,6 +115,9 @@ class CheatSettingsBox(QGroupBox): def show_transfer_cheat(self) -> bool: return self.transfer_cheat_checkbox.isChecked() + def enable_runway_state_cheat(self) -> bool: + return self.base_runway_state_cheat_checkbox.isChecked() + class AutoSettingsLayout(QGridLayout): def __init__( @@ -451,6 +466,9 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer): self.cheat_options.show_base_capture_cheat ) self.settings.enable_transfer_cheat = self.cheat_options.show_transfer_cheat + self.game.settings.enable_runway_state_cheat = ( + self.cheat_options.enable_runway_state_cheat + ) if self.game: events = GameUpdateEvents()