Add "Instant Squadron Transfer" cheat option

Resolves #14
This commit is contained in:
Raffson 2022-12-26 01:27:52 +01:00
parent 5c06e74659
commit 00ab0c4be2
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
7 changed files with 42 additions and 4 deletions

View File

@ -3,6 +3,7 @@
## Features/Improvements
* **[Mission Generation]** Given a CAS flight was planned, delay ground force attack until first CAS flight is on station
* **[Mission Generation]** Add option to switch ATFLIR to LITENING automatically for ground based F-18C flights
* **[Cheat Menu]** Option to instantly transfer squadrons across bases.
## Fixes
* **[UI]** Removed deprecated options

View File

@ -264,4 +264,8 @@ class Flight(SidcDescribable):
results.kill_pilot(self, pilot)
def recreate_flight_plan(self) -> None:
from game.sim.gameupdateevents import GameUpdateEvents
from game.server import EventStream
self._flight_plan_builder.regenerate()
EventStream.put_nowait(GameUpdateEvents().update_flight(self))

View File

@ -4,7 +4,6 @@ from typing import TYPE_CHECKING
from game.ato.packagewaypoints import PackageWaypoints
from game.data.doctrine import MODERN_DOCTRINE, COLDWAR_DOCTRINE, WWII_DOCTRINE
from game.utils import knots, feet, nautical_miles
if TYPE_CHECKING:
from game import Game

View File

@ -509,6 +509,7 @@ class Settings:
show_red_ato: bool = False
enable_frontline_cheats: bool = False
enable_base_capture_cheat: bool = False
enable_transfer_cheat: bool = False
# LUA Plugins system
plugins: Dict[str, bool] = field(default_factory=dict)

View File

@ -304,6 +304,7 @@ def create_game(
automate_aircraft_reinforcements=auto_procurement,
enable_frontline_cheats=cheats,
enable_base_capture_cheat=cheats,
enable_transfer_cheat=cheats,
restrict_weapons_by_date=restrict_weapons_by_date,
),
GeneratorSettings(

View File

@ -14,7 +14,9 @@ from PySide2.QtWidgets import (
QVBoxLayout,
)
from game.ato.flightplans.custom import CustomFlightPlan
from game.ato.flighttype import FlightType
from game.ato.flightwaypointtype import FlightWaypointType
from game.squadrons import Pilot, Squadron
from game.theater import ConflictTheater, ControlPoint
from qt_ui.delegates import TwoColumnRowDelegate
@ -96,7 +98,8 @@ class SquadronDestinationComboBox(QComboBox):
room = squadron.location.unclaimed_parking()
self.addItem(
f"Remain at {squadron.location} (room for {room} more aircraft)", None
f"Remain at {squadron.location} (room for {room} more aircraft)",
squadron.location,
)
selected_index: Optional[int] = None
for idx, destination in enumerate(sorted(self.iter_destinations(), key=str), 1):
@ -117,7 +120,7 @@ class SquadronDestinationComboBox(QComboBox):
def iter_destinations(self) -> Iterator[ControlPoint]:
size = self.squadron.expected_size_next_turn
for control_point in self.theater.control_points_for(self.squadron.player):
if control_point == self:
if control_point == self.squadron.location:
continue
if not control_point.can_operate(self.squadron.aircraft):
continue
@ -188,11 +191,25 @@ class SquadronDialog(QDialog):
def squadron(self) -> Squadron:
return self.squadron_model.squadron
def _instant_relocate(self, destination: ControlPoint) -> None:
self.squadron.relocate_to(destination)
for _, f in self.squadron.flight_db.objects.items():
if f.squadron == self.squadron:
if isinstance(f.flight_plan, CustomFlightPlan):
for wpt in f.flight_plan.waypoints:
if wpt.waypoint_type == FlightWaypointType.LANDING_POINT:
wpt.control_point = destination
wpt.position = wpt.control_point.position
break
f.recreate_flight_plan()
def on_destination_changed(self, index: int) -> None:
with report_errors("Could not change squadron destination", self):
destination = self.transfer_destination.itemData(index)
if destination is None:
if destination is self.squadron.location:
self.squadron.cancel_relocation()
elif self.ato_model.game.settings.enable_transfer_cheat:
self._instant_relocate(destination)
else:
self.squadron.plan_relocation(destination)
self.ato_model.replace_from_game(player=True)

View File

@ -60,6 +60,10 @@ class CheatSettingsBox(QGroupBox):
)
self.base_capture_cheat_checkbox.toggled.connect(apply_settings)
self.transfer_cheat_checkbox = QCheckBox()
self.transfer_cheat_checkbox.setChecked(game.settings.enable_transfer_cheat)
self.transfer_cheat_checkbox.toggled.connect(apply_settings)
self.red_ato = QLabeledWidget("Show Red ATO:", self.red_ato_checkbox)
self.main_layout.addLayout(self.red_ato)
self.frontline_cheat = QLabeledWidget(
@ -70,6 +74,10 @@ class CheatSettingsBox(QGroupBox):
"Enable Base Capture Cheat:", self.base_capture_cheat_checkbox
)
self.main_layout.addLayout(self.base_capture_cheat)
self.transfer_cheat = QLabeledWidget(
"Enable Instant Squadron Transfer Cheat:", self.transfer_cheat_checkbox
)
self.main_layout.addLayout(self.transfer_cheat)
@property
def show_red_ato(self) -> bool:
@ -83,6 +91,10 @@ class CheatSettingsBox(QGroupBox):
def show_base_capture_cheat(self) -> bool:
return self.base_capture_cheat_checkbox.isChecked()
@property
def show_transfer_cheat(self) -> bool:
return self.transfer_cheat_checkbox.isChecked()
class AutoSettingsLayout(QGridLayout):
def __init__(
@ -360,6 +372,9 @@ class QSettingsWindow(QDialog):
self.game.settings.enable_base_capture_cheat = (
self.cheat_options.show_base_capture_cheat
)
self.game.settings.enable_transfer_cheat = (
self.cheat_options.show_transfer_cheat
)
events = GameUpdateEvents()
self.game.compute_unculled_zones(events)