mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Dan's massive refactor
Squashing 8 commits by DanAlbert: - Track theater in ControlPoint. Simplifies finding the owning theater of a control point. Not used yet. - Clean some cruft out of FlightPlanBuilder. - Clean up silly some exception handling. - Move FlightPlan instantiation into the builder. I'm working on moving the builder to be owned by the Flight, which will simplify callers that need to create (or recreate) flight plans for a flight. - Simplify IBuilder constructor. We have access to the theater via the flight's departure airbase now. - Move FlightPlan creation into Flight. For now this is just a callsite cleanup. Later, this will make it easier to separate unscheduled and scheduled flights into different classes without complicating the layout/scheduling. - Remove superfluous constructors. - Remove unused Package field.
This commit is contained in:
@@ -1,30 +1,25 @@
|
||||
import logging
|
||||
from typing import Callable, Iterator, Optional
|
||||
|
||||
from PySide2.QtCore import (
|
||||
QItemSelectionModel,
|
||||
QModelIndex,
|
||||
Qt,
|
||||
QItemSelection,
|
||||
)
|
||||
from PySide2.QtCore import QItemSelection, QItemSelectionModel, QModelIndex, Qt
|
||||
from PySide2.QtWidgets import (
|
||||
QAbstractItemView,
|
||||
QDialog,
|
||||
QListView,
|
||||
QVBoxLayout,
|
||||
QPushButton,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QCheckBox,
|
||||
QComboBox,
|
||||
QDialog,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QListView,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
)
|
||||
|
||||
from game.squadrons import Pilot, Squadron
|
||||
from game.theater import ControlPoint, ConflictTheater
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.squadrons import Pilot, Squadron
|
||||
from game.theater import ConflictTheater, ControlPoint
|
||||
from qt_ui.delegates import TwoColumnRowDelegate
|
||||
from qt_ui.errorreporter import report_errors
|
||||
from qt_ui.models import SquadronModel, AtoModel
|
||||
from qt_ui.models import AtoModel, SquadronModel
|
||||
|
||||
|
||||
class PilotDelegate(TwoColumnRowDelegate):
|
||||
@@ -144,7 +139,6 @@ class SquadronDialog(QDialog):
|
||||
super().__init__(parent)
|
||||
self.ato_model = ato_model
|
||||
self.squadron_model = squadron_model
|
||||
self.theater = theater
|
||||
|
||||
self.setMinimumSize(1000, 440)
|
||||
self.setWindowTitle(str(squadron_model.squadron))
|
||||
@@ -200,7 +194,7 @@ class SquadronDialog(QDialog):
|
||||
if destination is None:
|
||||
self.squadron.cancel_relocation()
|
||||
else:
|
||||
self.squadron.plan_relocation(destination, self.theater)
|
||||
self.squadron.plan_relocation(destination)
|
||||
self.ato_model.replace_from_game(player=True)
|
||||
|
||||
def check_disabled_button_states(
|
||||
|
||||
@@ -16,7 +16,6 @@ from PySide2.QtWidgets import (
|
||||
)
|
||||
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
|
||||
from game.ato.flightplans.planningerror import PlanningError
|
||||
from game.ato.package import Package
|
||||
from game.game import Game
|
||||
@@ -181,11 +180,8 @@ class QPackageDialog(QDialog):
|
||||
def add_flight(self, flight: Flight) -> None:
|
||||
"""Adds the new flight to the package."""
|
||||
self.package_model.add_flight(flight)
|
||||
planner = FlightPlanBuilder(
|
||||
self.package_model.package, self.game.blue, self.game.theater
|
||||
)
|
||||
try:
|
||||
planner.populate_flight_plan(flight)
|
||||
flight.recreate_flight_plan()
|
||||
self.package_model.update_tot()
|
||||
EventStream.put_nowait(GameUpdateEvents().new_flight(flight))
|
||||
except PlanningError as ex:
|
||||
|
||||
@@ -4,7 +4,6 @@ from PySide2.QtWidgets import QGroupBox, QLabel, QMessageBox, QVBoxLayout
|
||||
|
||||
from game import Game
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
|
||||
from game.ato.flightplans.planningerror import PlanningError
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from qt_ui.models import PackageModel
|
||||
@@ -71,16 +70,10 @@ class FlightAirfieldDisplay(QGroupBox):
|
||||
|
||||
self.flight.divert = divert
|
||||
try:
|
||||
self.update_flight_plan()
|
||||
self.flight.recreate_flight_plan()
|
||||
except PlanningError as ex:
|
||||
self.flight.divert = old_divert
|
||||
logging.exception("Could not change divert airfield")
|
||||
QMessageBox.critical(
|
||||
self, "Could not update flight plan", str(ex), QMessageBox.Ok
|
||||
)
|
||||
|
||||
def update_flight_plan(self) -> None:
|
||||
planner = FlightPlanBuilder(
|
||||
self.package_model.package, self.game.blue, self.game.theater
|
||||
)
|
||||
planner.populate_flight_plan(self.flight)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import Iterable, List, Optional, Any
|
||||
from typing import Iterable, List, Optional
|
||||
|
||||
from PySide2.QtCore import Signal
|
||||
from PySide2.QtWidgets import (
|
||||
@@ -14,10 +14,9 @@ from PySide2.QtWidgets import (
|
||||
from game import Game
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flightplans.custom import CustomFlightPlan, CustomLayout
|
||||
from game.ato.flightplans.flightplan import FlightPlan
|
||||
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
|
||||
from game.ato.flightplans.formationattack import FormationAttackFlightPlan
|
||||
from game.ato.flightplans.planningerror import PlanningError
|
||||
from game.ato.flightplans.waypointbuilder import WaypointBuilder
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.flightwaypoint import FlightWaypoint
|
||||
from game.ato.loadouts import Loadout
|
||||
@@ -38,7 +37,6 @@ class QFlightWaypointTab(QFrame):
|
||||
self.game = game
|
||||
self.package = package
|
||||
self.flight = flight
|
||||
self.planner = FlightPlanBuilder(package, game.blue, game.theater)
|
||||
|
||||
self.flight_waypoint_list: Optional[QFlightWaypointList] = None
|
||||
self.rtb_waypoint: Optional[QPushButton] = None
|
||||
@@ -139,7 +137,7 @@ class QFlightWaypointTab(QFrame):
|
||||
self.on_change()
|
||||
|
||||
def on_rtb_waypoint(self):
|
||||
rtb = self.planner.generate_rtb_waypoint(self.flight, self.flight.from_cp)
|
||||
rtb = WaypointBuilder(self.flight, self.coalition).land(self.flight.arrival)
|
||||
self.degrade_to_custom_flight_plan()
|
||||
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
|
||||
self.flight.flight_plan.layout.custom_waypoints.append(rtb)
|
||||
@@ -168,7 +166,7 @@ class QFlightWaypointTab(QFrame):
|
||||
if result == QMessageBox.Yes:
|
||||
self.flight.flight_type = task
|
||||
try:
|
||||
self.planner.populate_flight_plan(self.flight)
|
||||
self.flight.recreate_flight_plan()
|
||||
except PlanningError as ex:
|
||||
self.flight.flight_type = original_task
|
||||
logging.exception("Could not recreate flight")
|
||||
|
||||
Reference in New Issue
Block a user